mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Name change fix for guilds and reset timer delay > credits to: Jonas
This commit is contained in:
parent
d92d5560d3
commit
0a6355996a
@ -136,6 +136,10 @@ public class Guild implements Runnable {
|
||||
return this.ownerName;
|
||||
}
|
||||
|
||||
public void setOwnerName(String ownerName) {
|
||||
this.ownerName = ownerName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
@ -504,6 +504,27 @@ public class GuildManager {
|
||||
return guilds;
|
||||
}
|
||||
|
||||
public List<Guild> getOwnedGuilds(int userId) {
|
||||
List<Guild> guilds = new ArrayList<Guild>();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT id FROM guilds WHERE user_id = ?")) {
|
||||
statement.setInt(1, userId);
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
Guild guild = getGuild(set.getInt("id"));
|
||||
|
||||
if (guild != null) {
|
||||
guilds.add(guild);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception", e);
|
||||
}
|
||||
|
||||
return guilds;
|
||||
}
|
||||
|
||||
public List<Guild> getAllGuilds() {
|
||||
List<Guild> guilds = new ArrayList<Guild>();
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.delay
|
||||
this.getDelay()
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -21,44 +21,54 @@ public class GuildRemoveMemberEvent extends MessageHandler {
|
||||
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
||||
|
||||
if(guild == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (guild != null) {
|
||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
||||
if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo);
|
||||
Emulator.getPluginManager().fireEvent(removedMemberEvent);
|
||||
if (removedMemberEvent.isCancelled())
|
||||
return;
|
||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
||||
|
||||
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId);
|
||||
guild.decreaseMemberCount();
|
||||
if(member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (userId != this.client.getHabbo().getHabboInfo().getId()) {
|
||||
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
||||
}
|
||||
if(userId == guild.getOwnerId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId());
|
||||
if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo);
|
||||
Emulator.getPluginManager().fireEvent(removedMemberEvent);
|
||||
if (removedMemberEvent.isCancelled())
|
||||
return;
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getHabboStats().removeGuild(guild.getId());
|
||||
if (habbo.getHabboStats().guild == guildId)
|
||||
habbo.getHabboStats().guild = 0;
|
||||
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId);
|
||||
guild.decreaseMemberCount();
|
||||
|
||||
if (room != null) {
|
||||
if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null)
|
||||
habbo.getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(habbo.getRoomUnit(), null).compose());
|
||||
if (habbo.getHabboInfo().getCurrentRoom() == room)
|
||||
room.refreshRightsForHabbo(habbo);
|
||||
}
|
||||
if (userId != this.client.getHabbo().getHabboInfo().getId()) {
|
||||
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null));
|
||||
}
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId());
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getHabboStats().removeGuild(guild.getId());
|
||||
if (habbo.getHabboStats().guild == guildId)
|
||||
habbo.getHabboStats().guild = 0;
|
||||
|
||||
if (room != null) {
|
||||
if (room.getGuildId() == guildId) {
|
||||
room.ejectUserFurni(userId);
|
||||
}
|
||||
if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null)
|
||||
habbo.getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(habbo.getRoomUnit(), null).compose());
|
||||
if (habbo.getHabboInfo().getCurrentRoom() == room)
|
||||
room.refreshRightsForHabbo(habbo);
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null));
|
||||
}
|
||||
|
||||
if (room != null) {
|
||||
if (room.getGuildId() == guildId) {
|
||||
room.ejectUserFurni(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.messages.incoming.users;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.HabboInfo;
|
||||
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||
@ -62,6 +63,10 @@ public class ConfirmChangeNameEvent extends MessageHandler {
|
||||
room.save();
|
||||
}
|
||||
|
||||
for (Guild guild : Emulator.getGameEnvironment().getGuildManager().getOwnedGuilds(this.client.getHabbo().getHabboInfo().getId())) {
|
||||
guild.setOwnerName(name);
|
||||
}
|
||||
|
||||
synchronized (changingUsernames) {
|
||||
changingUsernames.remove(name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user