Multiple Messages From Disband Fixed

This commit is contained in:
Driftay 2020-03-25 15:50:19 -04:00
parent efae187e1a
commit 66ad927b2f
6 changed files with 19 additions and 8 deletions

View File

@ -12,6 +12,7 @@ import com.massivecraft.factions.cmd.check.CheckTask;
import com.massivecraft.factions.cmd.check.WeeWooTask;
import com.massivecraft.factions.cmd.chest.AntiChestListener;
import com.massivecraft.factions.cmd.reserve.ListParameterizedType;
import com.massivecraft.factions.cmd.reserve.ReserveAdapter;
import com.massivecraft.factions.cmd.reserve.ReserveObject;
import com.massivecraft.factions.discord.Discord;
import com.massivecraft.factions.discord.DiscordListener;
@ -418,6 +419,7 @@ public class FactionsPlugin extends MPlugin {
.registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter())
.registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter())
.registerTypeAdapter(Inventory.class, new InventoryTypeAdapter())
.registerTypeAdapter(ReserveObject.class, new ReserveAdapter())
.registerTypeAdapter(Location.class, new LocationTypeAdapter())
.registerTypeAdapterFactory(EnumTypeAdapter.ENUM_FACTORY);
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.reserve.ReserveObject;
import com.massivecraft.factions.discord.Discord;
import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.factions.event.FactionCreateEvent;
@ -52,6 +53,12 @@ public class CmdCreate extends FCommand {
return;
}
ReserveObject factionReserve = FactionsPlugin.getInstance().getFactionReserves().stream().filter(factionReserve1 -> factionReserve1.getFactionName().equalsIgnoreCase(tag)).findFirst().orElse(null);
if (factionReserve != null && !factionReserve.getName().equalsIgnoreCase(context.player.getName())) {
context.msg(TL.COMMAND_CREATE_ALREADY_RESERVED);
return;
}
ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag);
if (tagValidationErrors.size() > 0) {
context.sendMessage(tagValidationErrors);
@ -85,7 +92,9 @@ public class CmdCreate extends FCommand {
// finish setting up the Faction
faction.setTag(tag);
if (factionReserve != null) {
FactionsPlugin.getInstance().getFactionReserves().remove(factionReserve);
}
// trigger the faction join event for the creator
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE);
Bukkit.getServer().getPluginManager().callEvent(joinEvent);

View File

@ -21,8 +21,6 @@ public class CmdDisband extends FCommand {
* @author FactionsUUID Team
*/
//TODO: Add Disband Confirmation GUI
private static HashMap<String, String> disbandMap = new HashMap<>();
@ -105,8 +103,11 @@ public class CmdDisband extends FCommand {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
}
}
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")){
faction.disband(context.player, PlayerDisbandReason.COMMAND);
context.fPlayer.setFFlying(false, false);
return;
}
} else {
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
}

View File

@ -11,8 +11,7 @@ public class ReserveAdapter implements JsonSerializer<ReserveObject>, JsonDeseri
public ReserveObject deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
JsonObject object = jsonElement.getAsJsonObject();
ReserveObject faction = new ReserveObject(object.get("username").getAsString(), object.get("name").getAsString());
return faction;
return new ReserveObject(object.get("username").getAsString(), object.get("name").getAsString());
}
public JsonElement serialize(ReserveObject data, final Type type, final JsonSerializationContext jsonSerializationContext) {

View File

@ -966,8 +966,7 @@ public abstract class MemoryFPlayer implements FPlayer {
if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly)
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
if (!fly) sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
} else {
msg(TL.COMMAND_FLY_DAMAGE);
}

View File

@ -296,6 +296,7 @@ public enum TL {
COMMAND_CHECKPOINT_CLAIMED("&c&l[!]&7 Your current &cfaction checkpoint&7 is claimed, set a &cnew &7one!"),
COMMAND_CHECKPOINT_DESCRIPTION("Set or go to your faction checkpoint!"),
COMMAND_CREATE_ALREADY_RESERVED("&c&l[!] &7This faction tag has already been reserved!"),
COMMAND_CREATE_MUSTLEAVE("&c&l[!]&7 You must &cleave &7your &ccurrent faction &7first."),
COMMAND_CREATE_INUSE("&c&l[!]&7 That tag is &calready &7in use."),
COMMAND_CREATE_TOCREATE("to create a new faction"),