mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 09:50:51 +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;
|
return this.ownerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOwnerName(String ownerName) {
|
||||||
|
this.ownerName = ownerName;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
@ -504,6 +504,27 @@ public class GuildManager {
|
|||||||
return guilds;
|
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() {
|
public List<Guild> getAllGuilds() {
|
||||||
List<Guild> guilds = new ArrayList<Guild>();
|
List<Guild> guilds = new ArrayList<Guild>();
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
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);
|
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
||||||
|
|
||||||
|
if(guild == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (guild != null) {
|
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
||||||
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;
|
|
||||||
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId);
|
if(member == null) {
|
||||||
guild.decreaseMemberCount();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (userId != this.client.getHabbo().getHabboInfo().getId()) {
|
if(userId == guild.getOwnerId()) {
|
||||||
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
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) {
|
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId);
|
||||||
habbo.getHabboStats().removeGuild(guild.getId());
|
guild.decreaseMemberCount();
|
||||||
if (habbo.getHabboStats().guild == guildId)
|
|
||||||
habbo.getHabboStats().guild = 0;
|
|
||||||
|
|
||||||
if (room != null) {
|
if (userId != this.client.getHabbo().getHabboInfo().getId()) {
|
||||||
if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null)
|
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
||||||
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));
|
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 != null) {
|
||||||
if (room.getGuildId() == guildId) {
|
if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null)
|
||||||
room.ejectUserFurni(userId);
|
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;
|
package com.eu.habbo.messages.incoming.users;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.users.HabboInfo;
|
import com.eu.habbo.habbohotel.users.HabboInfo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboManager;
|
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||||
@ -62,6 +63,10 @@ public class ConfirmChangeNameEvent extends MessageHandler {
|
|||||||
room.save();
|
room.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Guild guild : Emulator.getGameEnvironment().getGuildManager().getOwnedGuilds(this.client.getHabbo().getHabboInfo().getId())) {
|
||||||
|
guild.setOwnerName(name);
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (changingUsernames) {
|
synchronized (changingUsernames) {
|
||||||
changingUsernames.remove(name);
|
changingUsernames.remove(name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user