From 8b577d360b51319cd49fffca6b652cd2529a70d0 Mon Sep 17 00:00:00 2001 From: Driftay Date: Sun, 26 Jan 2020 12:51:41 -0500 Subject: [PATCH 01/13] Added Barrels to Container Permissible Action & Fixed NPE When running f seechunk on 1.15.1 --- src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java | 3 +-- .../factions/listeners/FactionsPlayerListener.java | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java index f56ea15a..8a72aefb 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java @@ -117,12 +117,11 @@ public class CmdSeeChunk extends FCommand { if (FactionsPlugin.getInstance().useNonPacketParticles) { // Dust options only exists in the 1.13 API, so we use an // alternative method to achieve this in lower versions. - if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114) { + if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114 || FactionsPlugin.getInstance().mc115) { player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1)); } else { player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1); } - } else { this.effect.display(0, 0, 0, 0, 1, loc, player); } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 8ac4053c..a4833956 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -381,6 +381,8 @@ public class FactionsPlayerListener implements Listener { case TRAPPED_CHEST: case CHEST_MINECART: + case BARREL: + case SHULKER_BOX: case BLACK_SHULKER_BOX: case BLUE_SHULKER_BOX: From ad56264c5d8c01176d4924e23665e4b97e18dd7d Mon Sep 17 00:00:00 2001 From: Driftay Date: Sun, 26 Jan 2020 15:54:54 -0500 Subject: [PATCH 02/13] 1.15 Support for Permissable Items & Fixed F Upgrades GUI Rows --- .../massivecraft/factions/listeners/FactionsPlayerListener.java | 2 +- .../massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index a4833956..660326e3 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -338,7 +338,7 @@ public class FactionsPlayerListener implements Listener { return PermissableAction.DOOR; if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR")) return PermissableAction.BUTTON; - if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114) { + if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114 || FactionsPlugin.getInstance().mc115) { switch (material) { case LEVER: return PermissableAction.LEVER; diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java index e3d17197..3685c2ef 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java @@ -25,7 +25,7 @@ public class FUpgradeFrame { public FUpgradeFrame(Faction f) { this.gui = new Gui(FactionsPlugin.getInstance(), - FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.rows", 5), + FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5), FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", f.getTag())); } From 1a4c860c463118494cd4d6843f9b6b968eaa97d1 Mon Sep 17 00:00:00 2001 From: Driftay Date: Sun, 26 Jan 2020 16:08:03 -0500 Subject: [PATCH 03/13] Fixed F Power Upgrade --- .../massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java index 3685c2ef..73c96ee6 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java @@ -95,7 +95,7 @@ public class FUpgradeFrame { private void updateFactionPowerBoost(Faction f) { double boost = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Power.Power-Boost.level-" + (f.getUpgrade(UpgradeType.POWER) + 1)); if (boost < 0.0) return; - f.setPowerBoost(f.getPower() + boost); + f.setPowerBoost(boost); } From 591dc2172f6db0307a89fd806e4abbb2d9c7b2a5 Mon Sep 17 00:00:00 2001 From: Driftay Date: Sun, 26 Jan 2020 16:17:08 -0500 Subject: [PATCH 04/13] Fixed F Disband w/Admins Disbanding Other Factions --- src/main/java/com/massivecraft/factions/cmd/CmdDisband.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index 81418df8..66109f07 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -72,13 +72,14 @@ public class CmdDisband extends FCommand { return; } + boolean access = false; if (context.fPlayer.getPlayer().hasMetadata("disband_confirm") && (time = context.fPlayer.getPlayer().getMetadata("disband_confirm").get(0).asLong()) != 0L && System.currentTimeMillis() - time <= TimeUnit.SECONDS.toMillis(3L)) { access = true; } if (!access) { - if(Conf.useDisbandGUI) { + if(Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) { if (!disbandMap.containsKey(context.player.getUniqueId().toString())) { new FDisbandFrame(context.faction).buildGUI(context.fPlayer); return; From 8ff8c78a44ce27acf91e8af7c70e8139bfb88f5c Mon Sep 17 00:00:00 2001 From: Driftay Date: Mon, 27 Jan 2020 00:47:48 -0500 Subject: [PATCH 05/13] Fixed Mouse Movement for Wild Teleportation & Properly initialized tntfill aliases --- .../massivecraft/factions/cmd/tnt/CmdTntFill.java | 2 +- .../factions/listeners/FactionsPlayerListener.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTntFill.java b/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTntFill.java index b49e00b0..de3bb5f3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTntFill.java +++ b/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTntFill.java @@ -26,7 +26,7 @@ public class CmdTntFill extends FCommand { public CmdTntFill() { super(); - this.aliases.add("tntfill"); + this.aliases.addAll(Aliases.tnt_tntfill); this.requiredArgs.add("radius"); this.requiredArgs.add("amount"); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 660326e3..e96a3f21 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -920,6 +920,8 @@ public class FactionsPlayerListener implements Listener { } } + + @EventHandler public void onLogoutMove(PlayerMoveEvent e) { LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName()); @@ -927,6 +929,12 @@ public class FactionsPlayerListener implements Listener { handler.cancelLogout(e.getPlayer()); e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED)); } + + if (e.getTo().getBlockX() == e.getFrom().getBlockX() && + e.getTo().getBlockY() == e.getFrom().getBlockY() && + e.getTo().getBlockZ() == e.getFrom().getBlockZ()) + return; + if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) { CmdWild.waitingTeleport.remove(e.getPlayer()); FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED); @@ -1062,13 +1070,13 @@ public class FactionsPlayerListener implements Listener { } FPlayer fp = FPlayers.getInstance().getByPlayer(e.getPlayer()); - if(fp == null) return; + if (fp == null) return; if (fp.getChatMode() != ChatMode.FACTION) { return; } Faction f = fp.getFaction(); - if(f == null) return; + if (f == null) return; if (f.isSystemFaction()) { return; } @@ -1087,7 +1095,7 @@ public class FactionsPlayerListener implements Listener { } } else { for (Member m : t.getMembers()) { - if (m.getEffectiveName().contains(target) | m.getUser().getName().contains(target)){ + if (m.getEffectiveName().contains(target) | m.getUser().getName().contains(target)) { targets.add("@" + m.getUser().getName() + "#" + m.getUser().getDiscriminator()); } } From 94d2035c78ac89016e72de984427b40c4de58ffe Mon Sep 17 00:00:00 2001 From: Driftay Date: Mon, 27 Jan 2020 00:52:52 -0500 Subject: [PATCH 06/13] Version Change --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3bb7c25f..b22fb643 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.massivecraft Factions - 1.6.9.5-2.2.7-RC + 1.6.9.5-2.2.8-RC jar SaberFactions From ed73baf5f1d32472fdfa854d93794da70143cb27 Mon Sep 17 00:00:00 2001 From: Driftay Date: Wed, 29 Jan 2020 14:32:32 -0500 Subject: [PATCH 07/13] SeeChunk 1.15 Fix --- .../com/massivecraft/factions/cmd/CmdSeeChunk.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java index 8a72aefb..fc1ce6a3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java @@ -74,7 +74,9 @@ public class CmdSeeChunk extends FCommand { for (Object nameObject : seeChunkMap.keySet()) { String name = nameObject + ""; Player player = Bukkit.getPlayer(name); - showBorders(player); + if (player != null) { + showBorders(player); + } } manageTask(); }, 0, interval); @@ -110,9 +112,7 @@ public class CmdSeeChunk extends FCommand { private void showPillar(Player player, World world, int blockX, int blockZ) { for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) { Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5); - if (loc.getBlock().getType() != Material.AIR) { - continue; - } + if (loc.getBlock().getType() != Material.AIR) continue; if (useParticles) { if (FactionsPlugin.getInstance().useNonPacketParticles) { // Dust options only exists in the 1.13 API, so we use an @@ -125,8 +125,6 @@ public class CmdSeeChunk extends FCommand { } else { this.effect.display(0, 0, 0, 0, 1, loc, player); } - - } else { Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial(); VisualizeUtil.addLocation(player, loc, type); From d30780e06e9582148bff2ad52aedda158cf829c6 Mon Sep 17 00:00:00 2001 From: Driftay Date: Thu, 30 Jan 2020 04:18:18 -0500 Subject: [PATCH 08/13] Created Time Utility for Shields --- .../massivecraft/factions/util/TimeUtil.java | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/main/java/com/massivecraft/factions/util/TimeUtil.java diff --git a/src/main/java/com/massivecraft/factions/util/TimeUtil.java b/src/main/java/com/massivecraft/factions/util/TimeUtil.java new file mode 100644 index 00000000..0685fc4e --- /dev/null +++ b/src/main/java/com/massivecraft/factions/util/TimeUtil.java @@ -0,0 +1,108 @@ +package com.massivecraft.factions.util; + +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Factions - Developed by Driftay. + * All rights reserved 2020. + * Creation Date: 1/30/2020 + */ +public class TimeUtil { + + public static long parseDateDiff(String time, boolean future) throws Exception { + Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?", 2); + Matcher m = timePattern.matcher(time); + int years = 0; + int months = 0; + int weeks = 0; + int days = 0; + int hours = 0; + int minutes = 0; + int seconds = 0; + boolean found = false; + while (m.find()) { + if (m.group() != null) { + if (m.group().isEmpty()) continue; + for (int i = 0; i < m.groupCount(); ++i) { + if (m.group(i) != null && !m.group(i).isEmpty()) { + found = true; + break; + } + } + if (!found) continue; + + if (m.group(1) != null && !m.group(1).isEmpty()) years = Integer.parseInt(m.group(1)); + + if (m.group(2) != null && !m.group(2).isEmpty()) months = Integer.parseInt(m.group(2)); + + if (m.group(3) != null && !m.group(3).isEmpty()) weeks = Integer.parseInt(m.group(3)); + + if (m.group(4) != null && !m.group(4).isEmpty()) days = Integer.parseInt(m.group(4)); + + if (m.group(5) != null && !m.group(5).isEmpty()) hours = Integer.parseInt(m.group(5)); + + if (m.group(6) != null && !m.group(6).isEmpty()) minutes = Integer.parseInt(m.group(6)); + + if (m.group(7) != null && !m.group(7).isEmpty()) { + seconds = Integer.parseInt(m.group(7)); + break; + } + break; + } + } + if (!found) throw new Exception("Illegal Date"); + + if (years > 20) throw new Exception("Illegal Date"); + + Calendar c = new GregorianCalendar(); + if (years > 0) c.add(Calendar.YEAR, years * (future ? 1 : -1)); + + if (months > 0) c.add(Calendar.MONTH, months * (future ? 1 : -1)); + + if (weeks > 0) c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1)); + + if (days > 0) c.add(Calendar.DATE, days * (future ? 1 : -1)); + + if (hours > 0) c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1)); + + if (minutes > 0) c.add(Calendar.MINUTE, minutes * (future ? 1 : -1)); + + if (seconds > 0) c.add(Calendar.SECOND, seconds * (future ? 1 : -1)); + + System.out.println("current: " + c.getTimeInMillis() + " Time: " + System.currentTimeMillis() + " Form: " + formatTime(c.getTimeInMillis() / 1000L)); + return c.getTimeInMillis() / 1000L; + } + + public static String formatDifference(long time) { + if (time == 0L) return "Never"; + + long day = TimeUnit.SECONDS.toDays(time); + long hours = TimeUnit.SECONDS.toHours(time) - day * 24L; + long minutes = TimeUnit.SECONDS.toMinutes(time) - TimeUnit.SECONDS.toHours(time) * 60L; + long seconds = TimeUnit.SECONDS.toSeconds(time) - TimeUnit.SECONDS.toMinutes(time) * 60L; + StringBuilder sb = new StringBuilder(); + if (day > 0L) sb.append(day).append((day == 1L) ? "day" : "days").append(" "); + + if (hours > 0L) sb.append(hours).append((hours == 1L) ? "h" : "h").append(" "); + + if (minutes > 0L) sb.append(minutes).append((minutes == 1L) ? "m" : "m").append(" "); + + if (seconds > 0L) sb.append(seconds).append((seconds == 1L) ? "s" : "s"); + + String diff = sb.toString().trim(); + return diff.isEmpty() ? "Now" : diff; + } + + public static String formatTime(long time) { + if (time == System.currentTimeMillis()) return "Now"; + + if (time == -1L) return "Never"; + + return formatDifference(time - System.currentTimeMillis() / 1000L); + } +} + From bcc04e6174bcc56cce68735c8c8bda819e76e1fb Mon Sep 17 00:00:00 2001 From: Driftay Date: Sat, 1 Feb 2020 03:01:36 -0500 Subject: [PATCH 09/13] Updated TimeUtil --- src/main/java/com/massivecraft/factions/util/TimeUtil.java | 2 +- src/main/resources/plugin.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/util/TimeUtil.java b/src/main/java/com/massivecraft/factions/util/TimeUtil.java index 0685fc4e..8c5bcd43 100644 --- a/src/main/java/com/massivecraft/factions/util/TimeUtil.java +++ b/src/main/java/com/massivecraft/factions/util/TimeUtil.java @@ -12,7 +12,7 @@ import java.util.regex.Pattern; * Creation Date: 1/30/2020 */ public class TimeUtil { - + public static long parseDateDiff(String time, boolean future) throws Exception { Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?", 2); Matcher m = timePattern.matcher(time); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4479d7c0..ec1d7b1f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: Factions version: ${project.version} api-version: 1.13 main: com.massivecraft.factions.FactionsPlugin -authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage, SvenjaReißaus, FroggyKnight, Driftay] +authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage, SvenjaReißaus, Driftay] softdepend: [Skript, CoreProtect, PlayerVaults, PlaceholderAPI, MVdWPlaceholderAPI, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap, FactionsTop] commands: From 61570be01212e7b54d299bbb70de501f2cb5fcc3 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Tue, 4 Feb 2020 02:37:00 +0100 Subject: [PATCH 10/13] Fixed upercase version Kinda triggering my ocd --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 593fb486..8b114c6c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -23,7 +23,7 @@ A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. -**Server VErsion (please complete the following information):** +**Server Version (please complete the following information):** - Spigot Version: [e.g. Paperspigot 1.8.8] - Factions Version [use /f version] - Minecraft Version: [If a bug is dependent on client version] From 0fc3e472890702a10428b29a681e5c66aff04758 Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 11 Feb 2020 22:17:01 -0500 Subject: [PATCH 11/13] Fixed Spawner Mining Error --- .../listeners/FactionsBlockListener.java | 30 ++++++++++++++----- .../listeners/FactionsPlayerListener.java | 11 +++---- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index 15b6d8bc..ccf0d509 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -162,18 +162,20 @@ public class FactionsBlockListener implements Listener { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { - Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced())); if (!event.canBuild()) return; if (event.getBlockPlaced().getType() == Material.FIRE) return; - + boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()); if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) { event.setCancelled(true); return; } - if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()) && Conf.spawnerLock) { - event.setCancelled(true); - event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString())); + + if (isSpawner) { + if (Conf.spawnerLock) { + event.setCancelled(true); + event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString())); + } } } @@ -494,12 +496,24 @@ public class FactionsBlockListener implements Listener { Block block = event.getBlock(); Faction at = Board.getInstance().getFactionAt(new FLocation(block)); - boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial(); - if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) { + boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()); + + if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { event.setCancelled(true); return; } - if (block != null && isSpawner) { + + FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer()); + if (fme == null || !fme.hasFaction()) return; + + if (isSpawner) { + Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners"); + } + } + + if (isSpawner && !fme.isAdminBypassing()) { ItemStack item = new ItemStack(block.getType(), 1, block.getData()); if (at != null && at.isNormal()) { FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index e96a3f21..ae77aaa6 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -925,16 +925,17 @@ public class FactionsPlayerListener implements Listener { @EventHandler public void onLogoutMove(PlayerMoveEvent e) { LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName()); + + if (Objects.requireNonNull(e.getTo()).getBlockX() == e.getFrom().getBlockX() && + e.getTo().getBlockY() == e.getFrom().getBlockY() && + e.getTo().getBlockZ() == e.getFrom().getBlockZ()) + return; + if (handler.isLogoutActive(e.getPlayer())) { handler.cancelLogout(e.getPlayer()); e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED)); } - if (e.getTo().getBlockX() == e.getFrom().getBlockX() && - e.getTo().getBlockY() == e.getFrom().getBlockY() && - e.getTo().getBlockZ() == e.getFrom().getBlockZ()) - return; - if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) { CmdWild.waitingTeleport.remove(e.getPlayer()); FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED); From 4f675dfd667d106d7c306b0ed7131e94681568bb Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 11 Feb 2020 22:23:14 -0500 Subject: [PATCH 12/13] Version Change --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b22fb643..875c61b1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.massivecraft Factions - 1.6.9.5-2.2.8-RC + 1.6.9.5-2.2.9-RC jar SaberFactions From 55d6af7195c36d8d9aee2e0104b30dbc08970198 Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 11 Feb 2020 22:42:14 -0500 Subject: [PATCH 13/13] Proper Distribution for Reserve Saving --- .../com/massivecraft/factions/FactionsPlugin.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/massivecraft/factions/FactionsPlugin.java b/src/main/java/com/massivecraft/factions/FactionsPlugin.java index c7b33995..fd5b0d00 100755 --- a/src/main/java/com/massivecraft/factions/FactionsPlugin.java +++ b/src/main/java/com/massivecraft/factions/FactionsPlugin.java @@ -52,6 +52,7 @@ import java.io.*; import java.lang.reflect.Modifier; import java.lang.reflect.Type; import java.nio.file.Files; +import java.nio.file.OpenOption; import java.nio.file.Paths; import java.util.*; import java.util.concurrent.atomic.AtomicReference; @@ -430,6 +431,18 @@ public class FactionsPlugin extends MPlugin { @Override public void onDisable() { + try { + String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json"; + File file = new File(path); + if (!file.exists()) { + file.getParentFile().mkdirs(); + file.createNewFile(); + } + Files.write(Paths.get(file.getPath()),getGsonBuilder().create().toJson(reserveObjects).getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + // only save data if plugin actually completely loaded successfully if (this.loadSuccessful) Conf.saveSync();