From d6ca2934dee5fd66248abf578e2e097a94771bd1 Mon Sep 17 00:00:00 2001 From: Driftay Date: Fri, 20 Sep 2019 16:59:31 -0400 Subject: [PATCH 1/5] Fixed a Few Things --- .../com/massivecraft/factions/shop/ShopGUIFrame.java | 2 -- .../factions/util/InventoryTypeAdapter.java | 6 +++--- .../com/massivecraft/factions/util/InventoryUtil.java | 5 +++-- .../factions/zcore/fupgrades/FUpgradesGUI.java | 3 ++- .../factions/zcore/persist/MemoryFaction.java | 11 ++++++++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/shop/ShopGUIFrame.java b/src/main/java/com/massivecraft/factions/shop/ShopGUIFrame.java index fe0fa335..4f83ccb4 100644 --- a/src/main/java/com/massivecraft/factions/shop/ShopGUIFrame.java +++ b/src/main/java/com/massivecraft/factions/shop/ShopGUIFrame.java @@ -3,7 +3,6 @@ package com.massivecraft.factions.shop; import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.GuiItem; import com.github.stefvanschie.inventoryframework.pane.PaginatedPane; -import com.google.common.collect.ImmutableList; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; @@ -21,7 +20,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java index 0b941b1d..db7c7f61 100644 --- a/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java @@ -1,6 +1,8 @@ package com.massivecraft.factions.util; import com.google.gson.*; +import com.massivecraft.factions.Conf; +import com.massivecraft.factions.FactionsPlugin; import org.bukkit.inventory.Inventory; import java.lang.reflect.Type; @@ -20,8 +22,6 @@ public class InventoryTypeAdapter implements JsonSerializer, JsonDese @Override public Inventory deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) { JsonObject object = jsonElement.getAsJsonObject(); - return InventoryUtil.fromBase64(object.get("contents").getAsString()); + return InventoryUtil.fromBase64(object.get("contents").getAsString(), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))); } - - } diff --git a/src/main/java/com/massivecraft/factions/util/InventoryUtil.java b/src/main/java/com/massivecraft/factions/util/InventoryUtil.java index 98f31df6..a6b0908e 100644 --- a/src/main/java/com/massivecraft/factions/util/InventoryUtil.java +++ b/src/main/java/com/massivecraft/factions/util/InventoryUtil.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.util; +import com.massivecraft.factions.FactionsPlugin; import org.bukkit.Bukkit; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -71,11 +72,11 @@ public class InventoryUtil { return toBase64(inventory); } - public static Inventory fromBase64(String data) { + public static Inventory fromBase64(String data, String invName) { try { ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); - Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt()); + Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt(), FactionsPlugin.getInstance().color(invName)); // Read the serialized inventory for (int i = 0; i < inventory.getSize(); i++) { diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java index ec68a21a..20731626 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.util.XMaterial; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -272,7 +273,7 @@ public class FUpgradesGUI implements Listener { private void updateChests(Faction faction) { String invName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")); - for (Player player : faction.getOnlinePlayers()) { + for (HumanEntity player : faction.getChestInventory().getViewers()) { if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName)) player.closeInventory(); } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index cf9cfbe7..3b6f5e11 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -423,8 +423,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { @Override public Inventory getChestInventory() { - if (chest != null) return chest; + if (chest == null) { + this.chest = Bukkit.createInventory(null, getChestSize(), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))); + return chest; + } + return chest; + } + private int getChestSize() { int size = 9; switch (getUpgrade(UpgradeType.CHEST)) { case 1: @@ -437,8 +443,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3") * 9; break; } - chest = Bukkit.createInventory(null, size, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))); - return chest; + return size; } From 5b8d2ac4d55bb7f38fce981bc5d900c7c3533655 Mon Sep 17 00:00:00 2001 From: Driftay Date: Fri, 20 Sep 2019 16:59:57 -0400 Subject: [PATCH 2/5] Version Change --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 65d1c52f..754ba990 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.massivecraft Factions - 1.6.9.5-U0.2.1-1.9.4-BETA + 1.6.9.5-U0.2.1-1.9.5-BETA jar SaberFactions From 99edc5b3b52bb7d29298bf3d9cffd1567018c9da Mon Sep 17 00:00:00 2001 From: Driftay Date: Sat, 21 Sep 2019 10:35:08 -0400 Subject: [PATCH 3/5] Missions Not Be Able to Be Done Multiple Times --- src/main/java/com/massivecraft/factions/Faction.java | 2 ++ .../com/massivecraft/factions/cmd/econ/CmdMoney.java | 2 +- .../massivecraft/factions/missions/MissionGUI.java | 7 +++++++ .../factions/missions/MissionHandler.java | 1 + .../factions/zcore/persist/MemoryFaction.java | 12 +++++++++--- .../com/massivecraft/factions/zcore/util/TL.java | 1 + src/main/resources/config.yml | 1 + 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index 1ee3d30f..d5bdd980 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -59,6 +59,8 @@ public interface Faction extends EconomyParticipator { Map getMissions(); + List getCompletedMissions(); + void deinviteAlt(FPlayer alt); void deinviteAllAlts(); diff --git a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoney.java b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoney.java index 3b3380b7..9c0a5276 100644 --- a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoney.java +++ b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoney.java @@ -35,7 +35,7 @@ public class CmdMoney extends FCommand { @Override public void perform(CommandContext context) { - if (!Conf.econEnabled) { + if (!Conf.econEnabled || !Conf.bankEnabled) { context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json"); return; } diff --git a/src/main/java/com/massivecraft/factions/missions/MissionGUI.java b/src/main/java/com/massivecraft/factions/missions/MissionGUI.java index 3e5163a6..03d90099 100644 --- a/src/main/java/com/massivecraft/factions/missions/MissionGUI.java +++ b/src/main/java/com/massivecraft/factions/missions/MissionGUI.java @@ -55,6 +55,13 @@ public class MissionGUI implements FactionGUI { if (section == null) { return; } + if(FactionsPlugin.getInstance().getConfig().getBoolean("DenyMissionsMoreThenOnce")) { + if (fPlayer.getFaction().getCompletedMissions().contains(missionName)) { + fPlayer.msg(TL.MISSION_ALREAD_COMPLETED); + return; + } + } + ConfigurationSection missionSection = section.getConfigurationSection("Mission"); if (missionSection == null) { return; diff --git a/src/main/java/com/massivecraft/factions/missions/MissionHandler.java b/src/main/java/com/massivecraft/factions/missions/MissionHandler.java index f301dfab..7fc7d8f9 100644 --- a/src/main/java/com/massivecraft/factions/missions/MissionHandler.java +++ b/src/main/java/com/massivecraft/factions/missions/MissionHandler.java @@ -159,5 +159,6 @@ public class MissionHandler implements Listener { } fPlayer.getFaction().getMissions().remove(mission.getName()); fPlayer.getFaction().msg(TL.MISSION_MISSION_FINISHED, plugin.color(section.getString("Name"))); + fPlayer.getFaction().getCompletedMissions().add(mission.getName()); } } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index 3b6f5e11..2e7d8ed9 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -83,6 +83,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { private int tntBankSize; private int warpLimit; private double reinforcedArmor; + private List completedMissions; // -------------------------------------------- // @@ -112,6 +113,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { this.checks = new ConcurrentHashMap<>(); this.playerWallCheckCount = new ConcurrentHashMap<>(); this.playerBufferCheckCount = new ConcurrentHashMap<>(); + this.completedMissions = new ArrayList<>(); resetPerms(); // Reset on new Faction so it has default values. } @@ -130,6 +132,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { money = old.money; powerBoost = old.powerBoost; missions = new ConcurrentHashMap<>(); + this.completedMissions = new ArrayList<>(); relationWish = old.relationWish; claimOwnership = old.claimOwnership; fplayers = new HashSet<>(); @@ -509,7 +512,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return this.wallCheckMinutes; } - public void setWallCheckMinutes(final int wallCheckMinutes) { + public void setWallCheckMinutes(int wallCheckMinutes) { this.wallCheckMinutes = wallCheckMinutes; } @@ -517,7 +520,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return this.bufferCheckMinutes; } - public void setBufferCheckMinutes(final int bufferCheckMinutes) { + public void setBufferCheckMinutes(int bufferCheckMinutes) { this.bufferCheckMinutes = bufferCheckMinutes; } @@ -537,7 +540,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return this.weeWoo; } - public void setWeeWoo(final boolean weeWoo) { + public void setWeeWoo(boolean weeWoo) { this.weeWoo = weeWoo; } @@ -1266,6 +1269,9 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return this.missions; } + @Override + public List getCompletedMissions() {return this.completedMissions;} + public void clearAllClaimOwnership() { claimOwnership.clear(); } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index f7a33bbb..38443559 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -999,6 +999,7 @@ public enum TL { MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"), + MISSION_ALREAD_COMPLETED("&c&l[!] &7You may not restart a mission you have already completed"), MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"), MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more then &b%1$s &7missions active at once."), MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a452fd1d..79785fd6 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -737,6 +737,7 @@ Missions-Enabled: true Missions-GUI-Title: '&bFaction Missions' MaximumMissionsAllowedAtOnce: 1 Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}' +DenyMissionsMoreThenOnce: true #this setting to true, means that if they complete a mission they cannot redo the same mission #Mission Types: KILL, MINE, PLACE, FISH, TAME, ENCHANT, CONSUME Missions: From 8338e21dd2e2fcdd1817f7b197f874cf8cf386e1 Mon Sep 17 00:00:00 2001 From: Driftay Date: Sat, 21 Sep 2019 13:02:51 -0400 Subject: [PATCH 4/5] Added F Discord --- .../com/massivecraft/factions/Faction.java | 4 ++ .../factions/cmd/CmdSeeDiscord.java | 59 +++++++++++++++++ .../factions/cmd/CmdSetDiscord.java | 65 +++++++++++++++++++ .../massivecraft/factions/cmd/FCmdRoot.java | 8 +++ .../factions/struct/Permission.java | 2 + .../factions/zcore/persist/MemoryFaction.java | 9 +++ .../massivecraft/factions/zcore/util/TL.java | 12 ++++ src/main/resources/config.yml | 8 +++ src/main/resources/plugin.yml | 4 ++ 9 files changed, 171 insertions(+) create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdSeeDiscord.java create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdSetDiscord.java diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index d5bdd980..35e03aa7 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -23,6 +23,10 @@ import java.util.concurrent.ConcurrentHashMap; public interface Faction extends EconomyParticipator { + String getDiscord(); + + void setDiscord(String link); + void checkPerms(); double getReinforcedArmor(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeDiscord.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeDiscord.java new file mode 100644 index 00000000..b37bc4a7 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeDiscord.java @@ -0,0 +1,59 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.FactionsPlugin; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TL; + +public class CmdSeeDiscord extends FCommand{ + + public CmdSeeDiscord() { + this.aliases.add("seediscord"); + this.aliases.add("discord"); + + this.optionalArgs.put("faction", "yours"); + + this.requirements = new CommandRequirements.Builder(Permission.DISCORD) + .memberOnly() + .build(); + } + + @Override + public void perform(CommandContext context) { + if (!FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) { + context.msg(TL.GENERIC_DISABLED); + return; + } + + + + if (context.args.size() == 0) { + if (context.fPlayer.getFaction().getDiscord() == null) { + context.msg(TL.COMMAND_DISCORD_NOTSET); + } else { + context.msg(TL.DISCORD_PLAYER_DISCORD, context.fPlayer.getFaction().getDiscord()); + } + } else if (context.args.size() == 1) { + if (context.fPlayer.isAdminBypassing()) { + Faction faction = context.argAsFaction(0); + if (faction != null) { + if (faction.getDiscord() == null) { + context.msg(TL.COMMAND_DISCORDSEE_FACTION_NOTSET, faction.getTag()); + } else { + context.msg(TL.COMMAND_DISCORDSEE_FACTION_DISCORD.toString(), faction.getTag(), faction.getDiscord()); + } + } + } else { + context.msg(TL.GENERIC_NOPERMISSION, "see another factions discord."); + } + } else { + context.msg(FactionsPlugin.getInstance().cmdBase.cmdSeeDiscord.getUsageTemplate(context)); + } + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_DISCORDSEE_DESCRIPTION; + } +} + diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetDiscord.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetDiscord.java new file mode 100644 index 00000000..35e6f3a4 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetDiscord.java @@ -0,0 +1,65 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.FactionsPlugin; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TL; + +public class CmdSetDiscord extends FCommand { + + public CmdSetDiscord(){ + super(); + this.aliases.add("setdiscord"); + + this.optionalArgs.put("faction", "yours"); + + this.requiredArgs.add("link"); + this.requirements = new CommandRequirements.Builder(Permission.SETDISCORD) + .playerOnly() + .memberOnly() + .build(); + } + + @Override + public void perform(CommandContext context) { + if (!FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) { + context.fPlayer.msg(TL.GENERIC_DISABLED, "discord"); + return; + } + + if (context.args.size() == 1) { + if (isDiscordInvite(context.argAsString(0))) { + context.fPlayer.getFaction().setDiscord(context.argAsString(0)); + context.msg(TL.COMMAND_DISCORDSET_SUCCESSFUL, context.argAsString(0)); + } else { + context.msg(TL.COMMAND_DISCORDSET_NOTEMAIL, context.argAsString(0)); + } + } else if (context.args.size() == 2) { + if (context.fPlayer.isAdminBypassing()) { + Faction faction = context.argAsFaction(1); + if (faction != null) { + if (isDiscordInvite(context.argAsString(0))) { + context.fPlayer.getFaction().setDiscord(context.argAsString(0)); + context.msg(TL.COMMAND_DISCORDSET_ADMIN_SUCCESSFUL, faction.getTag(), context.argAsString(0)); + } else { + context.msg(TL.COMMAND_DISCORDSET_ADMIN_FAILED, context.argAsString(0)); + } + } + } else { + context.msg(TL.GENERIC_NOPERMISSION, "set another factions discord link!"); + } + } else { + context.msg(FactionsPlugin.getInstance().cmdBase.cmdSetDiscord.getUsageTemplate(context)); + + } + } + + private boolean isDiscordInvite(String invite){ + return invite.contains("discord.gg") || invite.contains("discord.me"); + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_DISCORDSET_DESCRIPTION; + } +} diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index b854ea20..540c1e02 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -147,6 +147,8 @@ public class FCmdRoot extends FCommand implements CommandExecutor { public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo(); public CmdConvertConfig cmdConvertConfig = new CmdConvertConfig(); public CmdSpawnerLock cmdSpawnerLock = new CmdSpawnerLock(); + public CmdSetDiscord cmdSetDiscord = new CmdSetDiscord(); + public CmdSeeDiscord cmdSeeDiscord = new CmdSeeDiscord(); public FCmdRoot() { super(); @@ -307,6 +309,12 @@ public class FCmdRoot extends FCommand implements CommandExecutor { FactionsPlugin.getInstance().log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc."); this.addSubCommand(this.cmdTop); } + + if (FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) { + this.addSubCommand(this.cmdSetDiscord); + this.addSubCommand(this.cmdSeeDiscord); + } + if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) { this.addSubCommand(this.cmdPaypalSet); this.addSubCommand(this.cmdPaypalSee); diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index 952fb4b5..cbd8dbd9 100755 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -34,6 +34,7 @@ public enum Permission { DESCRIPTION("description"), DISBAND("disband"), DISBAND_ANY("disband.any"), + DISCORD("discord"), FLY("fly"), FOCUS("focus"), GLOBALCHAT("globalchat"), @@ -90,6 +91,7 @@ public enum Permission { RELOAD("reload"), SAVE("save"), SPAM("spam"), + SETDISCORD("setdiscord"), SETHOME("sethome"), SETHOME_ANY("sethome.any"), SETSTRIKES("setstrikes"), diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index 2e7d8ed9..7ec03c95 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -84,6 +84,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { private int warpLimit; private double reinforcedArmor; private List completedMissions; + protected String discord; // -------------------------------------------- // @@ -217,6 +218,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password); } + public String getDiscord() { + return this.discord; + } + + public void setDiscord(String link) { + this.discord = link; + } + public String getPaypal() { return this.paypal; } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index 38443559..bf3a56b9 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -566,6 +566,18 @@ public enum TL { COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"), COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"), + COMMAND_DISCORDSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7discord to &b%2$s&7."), + COMMAND_DISCORDSET_ADMIN_FAILED("&c&l[!] &b%1$s &7is not an discord link!"), + COMMAND_DISCORDSET_NOTEMAIL("&c&l[!] &b%1$s &7is not an discord link!"), + COMMAND_DISCORDSET_DESCRIPTION("&c&l[!] &7Set the link of your factions discord."), + COMMAND_DISCORDSET_SUCCESSFUL("&c&l[!] &7Successfully set your factions discord link - &b%1$s&7."), + DISCORD_PLAYER_DISCORD("&c&l[!] &7You're factions discord link is: &b%1$s&7."), + COMMAND_DISCORD_NOTSET("&c&l[!] &7Your faction does not have their discord set!"), + COMMAND_DISCORDSEE_FACTION_NOTSET("&c&l[!] &b%1$s's &7discord has not yet been set!"), + COMMAND_DISCORDSEE_FACTION_DISCORD("&c&l[!] &b%1$s's &7faction has their discord link set to &b%2$s&7."), + COMMAND_DISCORDSEE_DESCRIPTION("&c&l[!] &7View a specific factions discord link with &b/f discord &b."), + + PAYPALSEE_PLAYER_PAYPAL("&c&l[!] &7You're factions paypal is: &b%1$s&7."), COMMAND_PAYPAL_NOTSET("&c&l[!] &7Your faction does not have their paypal set!"), COMMAND_PAYPALSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7paypal to &b%2$s&7."), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 79785fd6..ae63e0a1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -649,6 +649,14 @@ ftnt: Enabled: true Bank-Limit: 250000 +############################################################ +# +------------------------------------------------------+ # +# | Faction Discord | # +# +------------------------------------------------------+ # +############################################################ +fdiscord: + Enabled: true + ############################################################ # +------------------------------------------------------+ # # | Faction PayPal | # diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index e83388f5..77a8602b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -158,6 +158,10 @@ permissions: description: create a new faction factions.deinvite: description: remove a pending invitation + factions.setdiscord: + description: set discord link + factions.discord: + description: view factions discord factions.description: description: change the faction description factions.disband: From f358e6d75b72e40e95a67d56dfb5344cab92fbf3 Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 24 Sep 2019 06:39:43 -0400 Subject: [PATCH 5/5] Added Anti-FChest-Items (Ability to deny storing items in factions chest) --- .../massivecraft/factions/FactionsPlugin.java | 3 + .../factions/cmd/chest/AntiChestListener.java | 67 +++++++++++++++++++ .../massivecraft/factions/zcore/util/TL.java | 2 + src/main/resources/config.yml | 3 + 4 files changed, 75 insertions(+) create mode 100644 src/main/java/com/massivecraft/factions/cmd/chest/AntiChestListener.java diff --git a/src/main/java/com/massivecraft/factions/FactionsPlugin.java b/src/main/java/com/massivecraft/factions/FactionsPlugin.java index bce174a6..a4551b47 100755 --- a/src/main/java/com/massivecraft/factions/FactionsPlugin.java +++ b/src/main/java/com/massivecraft/factions/FactionsPlugin.java @@ -10,6 +10,7 @@ import com.massivecraft.factions.cmd.FCmdRoot; import com.massivecraft.factions.cmd.FCommand; 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.chest.ChestLogsHandler; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Worldguard; @@ -86,6 +87,7 @@ public class FactionsPlugin extends MPlugin { private ClipPlaceholderAPIManager clipPlaceholderAPIManager; private boolean mvdwPlaceholderAPIManager = false; private Listener[] eventsListener; + public List itemList = getConfig().getStringList("fchest.Items-Not-Allowed"); public FactionsPlugin() { @@ -268,6 +270,7 @@ public class FactionsPlugin extends MPlugin { new FUpgradesGUI(), new UpgradesListener(), new MissionHandler(this), + new AntiChestListener(), new ChestLogsHandler() }; diff --git a/src/main/java/com/massivecraft/factions/cmd/chest/AntiChestListener.java b/src/main/java/com/massivecraft/factions/cmd/chest/AntiChestListener.java new file mode 100644 index 00000000..0abdccdc --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/chest/AntiChestListener.java @@ -0,0 +1,67 @@ +package com.massivecraft.factions.cmd.chest; + +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.FactionsPlugin; +import com.massivecraft.factions.zcore.util.TL; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +public class AntiChestListener implements Listener { + + + @EventHandler + public void onInventoryClick(InventoryClickEvent e) { + Player player = (Player) e.getWhoClicked(); + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return; + + if (e.isCancelled()) return; + + Inventory clicked = e.getClickedInventory(); + + if (e.getClick().isShiftClick()) { + if (clicked == e.getWhoClicked().getInventory()) { + ItemStack clickedOn = e.getCurrentItem(); + if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) { + fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString()); + e.setCancelled(true); + } + } + } + + if (clicked != e.getWhoClicked().getInventory()) { + ItemStack onCursor = e.getCursor(); + if (onCursor != null && FactionsPlugin.getInstance().itemList.contains(onCursor.getType().toString())) { + fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, onCursor.getType().toString()); + e.setCancelled(true); + } + } + } + + @EventHandler + public void onInventoryDrag(InventoryDragEvent e) { + Player p = (Player) e.getWhoClicked(); + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(p); + + if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return; + if (e.isCancelled()) return; + + ItemStack dragged = e.getOldCursor(); + if (FactionsPlugin.getInstance().itemList.contains(dragged.getType().toString())) { + int inventorySize = e.getInventory().getSize(); + for (int i : e.getRawSlots()) { + if (i < inventorySize) { + fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, dragged.getType().toString()); + e.setCancelled(true); + break; + } + } + } + } +} diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index bf3a56b9..b0df2168 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -239,6 +239,8 @@ public enum TL { COMMAND_CLAIMLINE_ABOVEMAX("&c&l[!]&7 The &cmaximum&7 limit for claim line is &c%s&7."), COMMAND_CLAIMLINE_NOTVALID("&c&l[!]&7 &c%s&7 is not a &ccardinal &7direction. You may use &cnorth&7, &ceast&7, &csouth &7or &cwest&7."), + CHEST_ITEM_DENIED_TRANSFER("&c&l[!] &7You may not transfer &b%1$s &7into your factions chest!"), + COMMAND_CONFIG_NOEXIST("&c&l[!]&7 No configuration setting \"&c%1$s&7\" exists."), COMMAND_CONFIG_SET_TRUE("\" option set to true (enabled)."), COMMAND_CONFIG_SET_FALSE("\" option set to false (disabled)."), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ae63e0a1..e9a30032 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -857,6 +857,9 @@ fvault: fchest: Enabled: true Inventory-Title: '&2&lFaction Chest' + Items-Not-Allowed: + - 'MOB_SPAWNER' + - 'COOKIE' # Chest size upgrades can be configured in the upgrades section of config ############################################################