mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40: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,9 +21,20 @@ 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(member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(userId == guild.getOwnerId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -62,5 +73,4 @@ public class GuildRemoveMemberEvent extends MessageHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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