transfer ranks on rename

This commit is contained in:
Super_ 2020-07-15 20:00:50 -04:00
parent 99618d7241
commit a4d359f3d2
3 changed files with 14 additions and 1 deletions

View file

@ -74,6 +74,7 @@ public class RenameSubcommand extends Common implements CommandExecutor
guild.disband();
guild.setIdentifier(GUtil.flatten(newName));
guild.setName(newName);
guild.updateRankIdentifiers();
sender.sendMessage(tl(PREFIX + "Set %s%" + GUtil.colorize(newName) + "%p% as the new name of your guild%p%."));
guild.broadcast(tl("%p%Your guild has been renamed to " + GUtil.colorize(newName) + "%p%."));
guild.save();

View file

@ -282,6 +282,17 @@ public class Guild
plugin.guilds.save();
}
public void updateRankIdentifiers()
{
for (GuildRank rank : ranks)
{
rank.delete();
rank.setIguild(identifier);
rank.set();
plugin.guilds.save();
}
}
public static Guild createGuild(String identifier, String name, Player owner)
{
if (plugin.guilds.contains(identifier))

View file

@ -1,8 +1,8 @@
package me.totalfreedom.tfguilds.guild;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.tfguilds.TFGuilds;
import me.totalfreedom.tfguilds.util.GLog;
import java.util.List;
@ -11,6 +11,7 @@ public class GuildRank
private static TFGuilds plugin = TFGuilds.getPlugin();
// owning guild's identifier
@Setter
private String iguild;
// identifier