diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..b6c324795 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,27 @@ +version: 2 +jobs: + build: + + working_directory: ~/Factions + + docker: + - image: circleci/openjdk:8-jdk-browsers + + steps: + + - checkout + + - restore_cache: + key: Factions-{{ checksum "pom.xml" }} + + - run: mvn dependency:go-offline + + - save_cache: + paths: + - ~/.m2 + key: Factions-{{ checksum "pom.xml" }} + + - run: mvn clean package + + - store_artifacts: + path: target/Factions.jar \ No newline at end of file diff --git a/.gitignore b/.gitignore index 56db3b082..b9b45a223 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,15 @@ -# Eclipse stuff -/.classpath -/.project -/.settings - -# NetBeans +.classpath +.project +.settings /nbproject /build.xml - -# vim .*.sw[a-p] - -# various other potential build files /build /bin /dist /*.jardesc /*.jar - -# Mac filesystem dust .DS_Store -/target/ +/target +.idea +*.iml diff --git a/Factions1.6.iml b/Factions1.6.iml deleted file mode 100644 index bb4f1a4c4..000000000 --- a/Factions1.6.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index b970b9488..b792fa0b2 100644 --- a/README.md +++ b/README.md @@ -29,18 +29,6 @@ You may also read the documentation ingame as the plugin ships with an ingame he * `/f help 2` * `/f help 3` -Note that you may optionally skip the slash and just write - -* `f` - -Installing ----------- -1. Compile using github and Maven. Once this is stable I will release it. -1. Put Factions.jar in the plugins folder. -You can also download it here: https://mega.nz/#!3FlR2ZpJ!RkUljAttEVtZBF8RdearGkKjaWvH6rumHbMsIHEBWh0 - -A default config file will be created on the first run. - License ---------- This project has a LGPL license.
diff --git a/pom.xml b/pom.xml index f28a06749..0dbe7d9f2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,15 @@ 4.0.0 com.massivecraft - factions - 1.0-SNAPSHOT + Factions + 1.8.0-Nukkit src Factions + . + true ${basedir}/src/resources plugin.yml @@ -31,11 +33,10 @@ - mengcraft - http://ci.mengcraft.com:8080/plugin/repository/everything/ + nukkitx + https://repo.nukkitx.com/main/ - cn.nukkit @@ -46,8 +47,11 @@ com.google.code.gson gson - 2.5 + 2.8.6 + provided - - \ No newline at end of file + + UTF-8 + + diff --git a/src/com/massivecraft/factions/Board.java b/src/com/massivecraft/factions/Board.java index 73ffe5269..c646503cd 100644 --- a/src/com/massivecraft/factions/Board.java +++ b/src/com/massivecraft/factions/Board.java @@ -170,20 +170,20 @@ public static ArrayList getMap(Faction faction, FLocation flocation, dou // For each row for (int dz = 0; dz < height; dz++) { // Draw and add that row - String row = ""; + StringBuilder row = new StringBuilder(); for (int dx = 0; dx < width; dx++) { if (dx == halfWidth && dz == halfHeight) { - row += TextFormat.AQUA + "+"; + row.append(TextFormat.AQUA + "+"); } else { FLocation flocationHere = topLeft.getRelative(dx, dz); Faction factionHere = getFactionAt(flocationHere); Relation relation = faction.getRelationTo(factionHere); if (factionHere.isNone()) { - row += TextFormat.GRAY + "-"; + row.append(TextFormat.GRAY + "-"); } else if (factionHere.isSafeZone()) { - row += Conf.colorPeaceful + "+"; + row.append(Conf.colorPeaceful).append("+"); } else if (factionHere.isWarZone()) { - row += TextFormat.DARK_RED + "+"; + row.append(TextFormat.DARK_RED + "+"); } else if ( factionHere == faction @@ -199,13 +199,13 @@ public static ArrayList getMap(Faction faction, FLocation flocation, dou if (!fList.containsKey(factionHere.getTag())) fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]); char tag = fList.get(factionHere.getTag()); - row += factionHere.getColorTo(faction) + "" + tag; + row.append(factionHere.getColorTo(faction)).append(tag); } else { - row += TextFormat.GRAY + "-"; + row.append(TextFormat.GRAY + "-"); } } } - ret.add(row); + ret.add(row.toString()); } // Get the compass @@ -218,11 +218,11 @@ public static ArrayList getMap(Faction faction, FLocation flocation, dou // Add the faction key if (Conf.showMapFactionKey) { - String fRow = ""; + StringBuilder fRow = new StringBuilder(); for (String key : fList.keySet()) { - fRow += String.format("%s%s: %s ", TextFormat.GRAY, fList.get(key), key); + fRow.append(String.format("%s%s: %s ", TextFormat.GRAY, fList.get(key), key)); } - ret.add(fRow); + ret.add(fRow.toString()); } return ret; diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index d234b6dcb..1fd828b51 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -54,9 +54,9 @@ public class Conf { public static boolean canLeaveWithNegativePower = true; // Configuration for faction-only chat - public static boolean factionOnlyChat = true; + public static boolean factionOnlyChat = false; // Configuration on the Faction tag in chat messages. - public static boolean chatTagEnabled = true; + public static boolean chatTagEnabled = false; public static transient boolean chatTagHandledByAnotherPlugin = false; public static boolean chatTagRelationColored = true; public static String chatTagReplaceString = "[FACTION]"; @@ -95,7 +95,7 @@ public class Conf { public static boolean logLandClaims = true; public static boolean logLandUnclaims = true; public static boolean logMoneyTransactions = true; - public static boolean logPlayerCommands = true; + public static boolean logPlayerCommands = false; // prevent some potential exploits public static boolean handleExploitObsidianGenerators = true; @@ -212,6 +212,8 @@ public class Conf { public static boolean ownedMessageOnBorder = true; public static boolean ownedMessageInsideTerritory = true; public static boolean ownedMessageByChunk = false; + public static boolean factionHereMessage = true; + public static String factionHereMessageType = "tip"; // "tip", "popup", "actionbar" or "chat" public static boolean pistonProtectionThroughDenyBuild = true; //TODO Blocks are not enums they are static ints needs a large rewrite @@ -315,25 +317,33 @@ public class Conf { territoryProtectedMaterials.add(Block.CHEST); territoryProtectedMaterials.add(Block.FURNACE); territoryProtectedMaterials.add(Block.BURNING_FURNACE); -// territoryProtectedMaterials.add(Block.DISPENSER); -// territoryProtectedMaterials.add(Block.DIODE_BLOCK_OFF); -// territoryProtectedMaterials.add(Block.DIODE_BLOCK_ON); -// territoryProtectedMaterials.add(Block.JUKEBOX); + territoryProtectedMaterials.add(Block.DISPENSER); + territoryProtectedMaterials.add(Block.JUKEBOX); territoryProtectedMaterials.add(Block.BREWING_STAND_BLOCK); territoryProtectedMaterials.add(Block.ENCHANTMENT_TABLE); -// territoryProtectedMaterials.add(Block.CAULDRON); + territoryProtectedMaterials.add(Block.CAULDRON_BLOCK); territoryProtectedMaterials.add(Block.FARMLAND); -// territoryProtectedMaterials.add(Block.BEACON); + territoryProtectedMaterials.add(Block.BEACON); territoryProtectedMaterials.add(Block.ANVIL); -// territoryProtectedMaterials.add(Block.TRAPPED_CHEST); -// territoryProtectedMaterials.add(Block.DROPPER); -// territoryProtectedMaterials.add(Block.HOPPER); + territoryProtectedMaterials.add(Block.TRAPPED_CHEST); + territoryProtectedMaterials.add(Block.DROPPER); + territoryProtectedMaterials.add(Block.HOPPER_BLOCK); -// territoryDenyUseageMaterials.add(Item.FIREBALL); territoryDenyUseageMaterials.add(Item.FLINT_AND_STEEL); territoryDenyUseageMaterials.add(Item.BUCKET); -// territoryDenyUseageMaterials.add(Item.WATER_BUCKET); -// territoryDenyUseageMaterials.add(Item.LAVA_BUCKET); + territoryDenyUseageMaterials.add(Item.FIRE_CHARGE); + territoryDenyUseageMaterials.add(Item.NETHERITE_HOE); + territoryDenyUseageMaterials.add(Item.DIAMOND_HOE); + territoryDenyUseageMaterials.add(Item.IRON_HOE); + territoryDenyUseageMaterials.add(Item.GOLD_HOE); + territoryDenyUseageMaterials.add(Item.STONE_HOE); + territoryDenyUseageMaterials.add(Item.WOODEN_HOE); + territoryDenyUseageMaterials.add(Item.NETHERITE_SHOVEL); + territoryDenyUseageMaterials.add(Item.DIAMOND_SHOVEL); + territoryDenyUseageMaterials.add(Item.IRON_SHOVEL); + territoryDenyUseageMaterials.add(Item.GOLD_SHOVEL); + territoryDenyUseageMaterials.add(Item.STONE_SHOVEL); + territoryDenyUseageMaterials.add(Item.WOODEN_SHOVEL); territoryProtectedMaterialsWhenOffline.add(Block.WOOD_DOOR_BLOCK); territoryProtectedMaterialsWhenOffline.add(Block.IRON_DOOR_BLOCK); @@ -347,25 +357,33 @@ public class Conf { territoryProtectedMaterialsWhenOffline.add(Block.CHEST); territoryProtectedMaterialsWhenOffline.add(Block.FURNACE); territoryProtectedMaterialsWhenOffline.add(Block.BURNING_FURNACE); -// territoryProtectedMaterialsWhenOffline.add(Block.DISPENSER); -// territoryProtectedMaterialsWhenOffline.add(Block.DIODE_BLOCK_OFF); -// territoryProtectedMaterialsWhenOffline.add(Block.DIODE_BLOCK_ON); -// territoryProtectedMaterialsWhenOffline.add(Block.JUKEBOX); + territoryProtectedMaterialsWhenOffline.add(Block.DISPENSER); + territoryProtectedMaterialsWhenOffline.add(Block.JUKEBOX); territoryProtectedMaterialsWhenOffline.add(Block.BREWING_STAND_BLOCK); territoryProtectedMaterialsWhenOffline.add(Block.ENCHANTMENT_TABLE); -// territoryProtectedMaterialsWhenOffline.add(Block.CAULDRON); + territoryProtectedMaterialsWhenOffline.add(Block.CAULDRON_BLOCK); territoryProtectedMaterialsWhenOffline.add(Block.FARMLAND); -// territoryProtectedMaterialsWhenOffline.add(Block.BEACON); + territoryProtectedMaterialsWhenOffline.add(Block.BEACON); territoryProtectedMaterialsWhenOffline.add(Block.ANVIL); -// territoryProtectedMaterialsWhenOffline.add(Block.TRAPPED_CHEST); -// territoryProtectedMaterialsWhenOffline.add(Block.DROPPER); -// territoryProtectedMaterialsWhenOffline.add(Block.HOPPER); + territoryProtectedMaterialsWhenOffline.add(Block.TRAPPED_CHEST); + territoryProtectedMaterialsWhenOffline.add(Block.DROPPER); + territoryProtectedMaterialsWhenOffline.add(Block.HOPPER_BLOCK); -// territoryDenyUseageMaterialsWhenOffline.add(Item.FIREBALL); + territoryDenyUseageMaterialsWhenOffline.add(Item.FIRE_CHARGE); territoryDenyUseageMaterialsWhenOffline.add(Item.FLINT_AND_STEEL); territoryDenyUseageMaterialsWhenOffline.add(Item.BUCKET); -// territoryDenyUseageMaterialsWhenOffline.add(Item.WATER_BUCKET); -// territoryDenyUseageMaterialsWhenOffline.add(Item.LAVA_BUCKET); + territoryDenyUseageMaterialsWhenOffline.add(Item.NETHERITE_HOE); + territoryDenyUseageMaterialsWhenOffline.add(Item.DIAMOND_HOE); + territoryDenyUseageMaterialsWhenOffline.add(Item.IRON_HOE); + territoryDenyUseageMaterialsWhenOffline.add(Item.GOLD_HOE); + territoryDenyUseageMaterialsWhenOffline.add(Item.STONE_HOE); + territoryDenyUseageMaterialsWhenOffline.add(Item.WOODEN_HOE); + territoryDenyUseageMaterialsWhenOffline.add(Item.NETHERITE_SHOVEL); + territoryDenyUseageMaterialsWhenOffline.add(Item.DIAMOND_SHOVEL); + territoryDenyUseageMaterialsWhenOffline.add(Item.IRON_SHOVEL); + territoryDenyUseageMaterialsWhenOffline.add(Item.GOLD_SHOVEL); + territoryDenyUseageMaterialsWhenOffline.add(Item.STONE_SHOVEL); + territoryDenyUseageMaterialsWhenOffline.add(Item.WOODEN_SHOVEL); // safeZoneNerfedCreatureTypes.add(Entity.BLAZE); // safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER); diff --git a/src/com/massivecraft/factions/FLocation.java b/src/com/massivecraft/factions/FLocation.java index 048153c75..17eaa4d09 100644 --- a/src/com/massivecraft/factions/FLocation.java +++ b/src/com/massivecraft/factions/FLocation.java @@ -49,7 +49,7 @@ public FLocation(FPlayer fplayer) { } public FLocation(Block block) { - this(block.getLevel().getName(), block.getFloorX(), block.getFloorZ()); + this(block.getLevel().getName(), blockToChunk(block.getFloorX()), blockToChunk(block.getFloorZ())); } //----------------------------------------------// @@ -191,4 +191,4 @@ public boolean equals(Object obj) { FLocation that = (FLocation) obj; return this.x == that.x && this.z == that.z && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName)); } -} \ No newline at end of file +} diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index d2bb3c58a..d61a456f6 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -297,7 +297,7 @@ public String getTag() { public String getNameAndSomething(String something) { String ret = this.role.getPrefix(); - if (something.length() > 0) { + if (!something.isEmpty()) { ret += something + " "; } ret += this.getName(); @@ -525,12 +525,33 @@ public boolean isInEnemyTerritory() { } public void sendFactionHereMessage() { + if (!Conf.factionHereMessage) { + return; + } Faction factionHere = Board.getFactionAt(this.getLastStoodAt()); String msg = P.p.txt.parse("") + " ~ " + factionHere.getTag(this); - if (factionHere.getDescription().length() > 0) { + if (!factionHere.getDescription().isEmpty()) { msg += " - " + factionHere.getDescription(); } - this.sendMessage(msg); + Player player = this.getPlayer(); + if (player != null) { + switch (Conf.factionHereMessageType) { + case "tip": + player.sendTip(msg); + break; + case "popup": + player.sendPopup(msg); + break; + case "actionbar": + player.sendActionBar(msg); + break; + case "chat": + player.sendMessage(msg); + break; + default: + player.sendMessage("§cERROR! Invalid factionHereMessageType. Must be 'tip', 'popup', 'actionbar' or 'chat'. Please report this to admin."); + } + } } // ------------------------------- diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 64e3f490f..e076b8c0c 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -610,16 +610,16 @@ public String getOwnerListString(FLocation loc) { return ""; } - String ownerList = ""; + StringBuilder ownerList = new StringBuilder(); Iterator iter = ownerData.iterator(); while (iter.hasNext()) { - if (!ownerList.isEmpty()) { - ownerList += ", "; + if (ownerList.length() > 0) { + ownerList.append(", "); } - ownerList += iter.next(); + ownerList.append(iter.next()); } - return ownerList; + return ownerList.toString(); } public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) { diff --git a/src/com/massivecraft/factions/P.java b/src/com/massivecraft/factions/P.java index 0a93014f6..5f1fb9232 100644 --- a/src/com/massivecraft/factions/P.java +++ b/src/com/massivecraft/factions/P.java @@ -79,7 +79,6 @@ public void onEnable() { this.cmdAutoHelp = new CmdAutoHelp(); this.getBaseCommands().add(cmdBase); - // start up task which runs the autoLeaveAfterDaysOfInactivity routine startAutoLeaveTask(false); @@ -87,13 +86,9 @@ public void onEnable() { getServer().getPluginManager().registerEvents(playerListener, this); getServer().getPluginManager().registerEvents(chatListener, this); getServer().getPluginManager().registerEvents(entityListener, this); - getServer().getPluginManager().registerEvents(exploitListener, this); + //getServer().getPluginManager().registerEvents(exploitListener, this); //currently unused getServer().getPluginManager().registerEvents(blockListener, this); - //// TODO: 03/01/2016 unsure what this will do and nukkit doesn't have anything like it - // since some other plugins execute commands directly through this command interface, provide it -// this.getCommand(this.refCommand).setExecutor(this); - postEnable(); this.loadSuccessful = true; } @@ -133,7 +128,7 @@ public void startAutoLeaveTask(boolean restartIfRunning) { if (Conf.autoLeaveRoutineRunsEveryXMinutes > 0.0) { int ticks = (int) (20 * 60 * Conf.autoLeaveRoutineRunsEveryXMinutes); - AutoLeaveTask = getServer().getScheduler().scheduleRepeatingTask(new AutoLeaveTask(), ticks).getTaskId(); + AutoLeaveTask = getServer().getScheduler().scheduleRepeatingTask(this, new AutoLeaveTask(), ticks).getTaskId(); } } diff --git a/src/com/massivecraft/factions/cmd/CmdAutoHelp.java b/src/com/massivecraft/factions/cmd/CmdAutoHelp.java index 16be3fc2f..ac2a5c8d4 100644 --- a/src/com/massivecraft/factions/cmd/CmdAutoHelp.java +++ b/src/com/massivecraft/factions/cmd/CmdAutoHelp.java @@ -20,7 +20,7 @@ public CmdAutoHelp() { @Override public void perform() { - if (this.commandChain.size() == 0) return; + if (this.commandChain.isEmpty()) return; MCommand pcmd = this.commandChain.get(this.commandChain.size() - 1); ArrayList lines = new ArrayList(); diff --git a/src/com/massivecraft/factions/cmd/CmdCreate.java b/src/com/massivecraft/factions/cmd/CmdCreate.java index dd8577202..68f949b1a 100644 --- a/src/com/massivecraft/factions/cmd/CmdCreate.java +++ b/src/com/massivecraft/factions/cmd/CmdCreate.java @@ -42,7 +42,7 @@ public void perform() { } ArrayList tagValidationErrors = Factions.validateTag(tag); - if (tagValidationErrors.size() > 0) { + if (!tagValidationErrors.isEmpty()) { sendMessage(tagValidationErrors); return; } diff --git a/src/com/massivecraft/factions/cmd/CmdShow.java b/src/com/massivecraft/factions/cmd/CmdShow.java index cf46366fc..4ca559dd3 100644 --- a/src/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/com/massivecraft/factions/cmd/CmdShow.java @@ -91,43 +91,43 @@ else if (rel.isEnemy()) sendMessage(enemyList); // List the members... - String onlineList = p.txt.parse("") + "Members online: "; - String offlineList = p.txt.parse("") + "Members offline: "; + StringBuilder onlineList = new StringBuilder(p.txt.parse("") + "Members online: "); + StringBuilder offlineList = new StringBuilder(p.txt.parse("") + "Members offline: "); for (FPlayer follower : admins) { listpart = follower.getNameAndTitle(fme) + p.txt.parse("") + ", "; if (follower.isOnlineAndVisibleTo(me)) { - onlineList += listpart; + onlineList.append(listpart); } else { - offlineList += listpart; + offlineList.append(listpart); } } for (FPlayer follower : mods) { listpart = follower.getNameAndTitle(fme) + p.txt.parse("") + ", "; if (follower.isOnlineAndVisibleTo(me)) { - onlineList += listpart; + onlineList.append(listpart); } else { - offlineList += listpart; + offlineList.append(listpart); } } for (FPlayer follower : normals) { listpart = follower.getNameAndTitle(fme) + p.txt.parse("") + ", "; if (follower.isOnlineAndVisibleTo(me)) { - onlineList += listpart; + onlineList.append(listpart); } else { - offlineList += listpart; + offlineList.append(listpart); } } - if (onlineList.endsWith(", ")) { - onlineList = onlineList.substring(0, onlineList.length() - 2); + if (onlineList.toString().endsWith(", ")) { + onlineList = new StringBuilder(onlineList.substring(0, onlineList.length() - 2)); } - if (offlineList.endsWith(", ")) { - offlineList = offlineList.substring(0, offlineList.length() - 2); + if (offlineList.toString().endsWith(", ")) { + offlineList = new StringBuilder(offlineList.substring(0, offlineList.length() - 2)); } - sendMessage(onlineList); - sendMessage(offlineList); + sendMessage(onlineList.toString()); + sendMessage(offlineList.toString()); } } diff --git a/src/com/massivecraft/factions/cmd/CmdTag.java b/src/com/massivecraft/factions/cmd/CmdTag.java index 6014de252..a59dd4d1d 100644 --- a/src/com/massivecraft/factions/cmd/CmdTag.java +++ b/src/com/massivecraft/factions/cmd/CmdTag.java @@ -39,7 +39,7 @@ public void perform() { ArrayList errors = new ArrayList(); errors.addAll(Factions.validateTag(tag)); - if (errors.size() > 0) { + if (!errors.isEmpty()) { sendMessage(errors); return; } diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 4eaaaef9b..75342614a 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -290,9 +290,6 @@ public void onPlayerMove(PlayerMoveEvent event) { Faction factionTo = Board.getFactionAt(to); boolean changedFaction = (factionFrom != factionTo); - if (changedFaction) - changedFaction = false; - if (me.isMapAutoUpdating()) { me.sendMessage(Board.getMap(me.getFaction(), to, player.getLocation().getYaw())); } else { @@ -353,7 +350,7 @@ else if (!Conf.publicLandMessage.isEmpty()) public void onPlayerInteract(PlayerInteractEvent event) { if (event.isCancelled()) return; // only need to check right-clicks and physical as of MC 1.4+; good performance boost - if (event.getAction() != PlayerInteractEvent.RIGHT_CLICK_BLOCK && event.getAction() != PlayerInteractEvent.PHYSICAL) + if (event.getAction() != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && event.getAction() != PlayerInteractEvent.Action.PHYSICAL) return; Block block = event.getBlock(); @@ -361,7 +358,12 @@ public void onPlayerInteract(PlayerInteractEvent event) { if (block == null) return; // clicked in air, apparently - if (!canPlayerUseBlock(player, block, false)) { + if (event.getAction() == PlayerInteractEvent.Action.PHYSICAL && block.getId() == Block.FARMLAND) { + if (!FactionsBlockListener.playerCanBuildDestroyBlock(player, new Location(block.getFloorX(), block.getFloorY(), block.getFloorZ(), 0, 0, block.getLevel()), "destroy", true)) { + // Hack: Farmland protection + event.setCancelled(true); + } + } else if (!canPlayerUseBlock(player, block, false)) { event.setCancelled(true); if (Conf.handleExploitInteractionSpam) { String name = player.getName(); @@ -380,7 +382,7 @@ public void onPlayerInteract(PlayerInteractEvent event) { return; } - if (event.getAction() != PlayerInteractEvent.RIGHT_CLICK_BLOCK) + if (event.getAction() != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return; // only interested on right-clicks for below if (!playerCanUseItemHere(player, new Location(block.getFloorX(), block.getFloorY(), block.getFloorZ(), 0, 0, block.getLevel()), event.getItem(), false)) { @@ -452,7 +454,7 @@ public void onPlayerKick(PlayerKickEvent event) { } // if player was banned (not just kicked), get rid of their stored info - if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) { + if (Conf.removePlayerDataWhenBanned && (event.getReasonEnum() == PlayerKickEvent.Reason.NAME_BANNED || event.getReasonEnum() == PlayerKickEvent.Reason.IP_BANNED)) { if (badGuy.getRole() == Role.ADMIN) badGuy.getFaction().promoteNewLeader(); diff --git a/src/com/massivecraft/factions/util/MiscUtil.java b/src/com/massivecraft/factions/util/MiscUtil.java index 2cf8b3daa..494b0da13 100644 --- a/src/com/massivecraft/factions/util/MiscUtil.java +++ b/src/com/massivecraft/factions/util/MiscUtil.java @@ -58,17 +58,17 @@ public static long[] range(long start, long end) { } public static String getComparisonString(String str) { - String ret = ""; + StringBuilder ret = new StringBuilder(); str = TextFormat.clean(str); str = str.toLowerCase(); for (char c : str.toCharArray()) { if (substanceChars.contains(String.valueOf(c))) { - ret += c; + ret.append(c); } } - return ret.toLowerCase(); + return ret.toString().toLowerCase(); } } diff --git a/src/com/massivecraft/factions/zcore/MCommand.java b/src/com/massivecraft/factions/zcore/MCommand.java index f2504f209..79131a853 100644 --- a/src/com/massivecraft/factions/zcore/MCommand.java +++ b/src/com/massivecraft/factions/zcore/MCommand.java @@ -93,7 +93,7 @@ public void execute(CommandSender sender, List args, List> c this.commandChain = commandChain; // Is there a matching sub command? - if (args.size() > 0) { + if (!args.isEmpty()) { for (MCommand subCommand : this.subCommands) { if (subCommand.aliases.contains(args.get(0))) { args.remove(0); @@ -219,7 +219,7 @@ public String getUseageTemplate(List> commandChain, boolean addShort args.add("[" + optionalArg.getKey() + val + "]"); } - if (args.size() > 0) { + if (!args.isEmpty()) { ret.append(p.txt.parseTags("

")); ret.append(TextUtil.implode(args, " ")); } @@ -377,7 +377,7 @@ public Player strAsBestPlayerMatch(String name, Player def, boolean msg) { if (name != null) { List players = Arrays.asList(Server.getInstance().matchPlayer(name)); - if (players.size() > 0) { + if (!players.isEmpty()) { ret = players.get(0); } } diff --git a/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java b/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java index a7e22387d..f8024e46b 100644 --- a/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java +++ b/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java @@ -15,7 +15,7 @@ public MPluginSecretServerListener(MPlugin p) { @EventHandler(priority = EventPriority.LOWEST) public void onServerCommand(ServerCommandEvent event) { - if (event.getCommand().length() == 0) return; + if (event.getCommand().isEmpty()) return; if (p.handleCommand(event.getSender(), event.getCommand())) { event.setCommand(p.refCommand); diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml index 1a5c7837c..a341bf4c9 100644 --- a/src/resources/plugin.yml +++ b/src/resources/plugin.yml @@ -1,15 +1,15 @@ name: Factions -version: "1.6.9.5" +version: "${pom.version}" api: ["1.0.0"] main: com.massivecraft.factions.P authors: [Olof Larsson, Brett Flannigan] commands: factions: - description: Reference command for Factions. + description: Reference command for Factions aliases: [f] permissions: factions.kit.admin: - description: All faction permissions. + description: All faction permissions children: factions.kit.mod: true factions.config: true @@ -21,7 +21,7 @@ permissions: children: factions.kit.admin: true factions.kit.mod: - description: All faction permissions but configuration and persistance. + description: All faction permissions but configuration and persistance children: factions.kit.halfmod: true factions.disband.any: true @@ -47,12 +47,12 @@ permissions: factions.chatspy: true factions.kit.fullplayer: default: true - description: Can also create new factions. + description: Can also create new factions children: factions.kit.halfplayer: true factions.create: true factions.kit.halfplayer: - description: Can do all but create factions. + description: Can do all but create factions children: factions.admin: true factions.autoclaim: true