diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java index b0d4bd9bc..696cf72d3 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java @@ -11,7 +11,6 @@ import org.bukkit.World.Environment; import org.bukkit.WorldBorder; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; import org.bukkit.util.Vector; import com.google.common.collect.Lists; @@ -22,6 +21,11 @@ public class UtilWorld { return Bukkit.getServer().getWorld(world); } + + public static boolean isInChunk(Location location, Chunk chunk) + { + return location.getChunk().getX() == chunk.getX() && location.getChunk().getZ() == chunk.getZ() && chunk.getWorld().equals(location.getChunk().getWorld()); + } public static boolean areChunksEqual(Location first, Location second) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 941756e20..2fed14075 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -792,10 +792,12 @@ public class ClansManager extends MiniClientPluginimplements IRelati { player.setOp(true); } - if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug + if (player.getInventory().getHelmet() != null) //Reset helmet to fix 1 damage bug + { ItemStack helmet = player.getInventory().getHelmet().clone(); player.getInventory().setHelmet(null); - runSyncLater(() -> { + runSyncLater(() -> + { player.getInventory().setHelmet(helmet); }, 20L); } @@ -806,7 +808,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati { // happens 20 ticks later because player channels don't // seem to work immediately after joining. - runSyncLater(() -> { + runSyncLater(() -> + { ByteArrayDataOutput bado = ByteStreams.newDataOutput(); bado.writeUTF("no_xray"); @@ -844,7 +847,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (String message : messages) { - if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().startsWith("/" + message + " ")) + if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().toLowerCase().startsWith("/" + message + " ")) { continue; } @@ -903,7 +906,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Player other : event.getRecipients()) { if (_tutorial.inTutorial(other)) + { continue; + } UtilPlayer.message(other, String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage())); } @@ -917,7 +922,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Player other : event.getRecipients()) { if (_tutorial.inTutorial(other)) + { continue; + } ClanInfo otherClan = _clanUtility.getClanByPlayer(other); @@ -940,7 +947,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void disableObsidian(BlockBreakEvent event) { - if(event.getBlock().getType().equals(Material.OBSIDIAN)) + if (event.getBlock().getType().equals(Material.OBSIDIAN)) { event.setCancelled(true); event.getBlock().setType(Material.AIR); @@ -976,7 +983,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH)) + { rank = ""; + } if (client.isClanChat() && clan != null) { @@ -1028,7 +1037,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + { rank = ""; + } handleClanChat(caller, message, clan, rank); } @@ -1038,7 +1049,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + { rank = ""; + } handleAllyChat(caller, message, clan, rank); } @@ -1316,7 +1329,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void updateBedStatus(UpdateEvent event) { if (event.getType() != UpdateType.TWOSEC) + { return; + } for (String name : getClanNameSet()) { @@ -1391,7 +1406,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati { _clanMemberLeftMap.remove(uuid); _warPointEvasion.resetCooldown(uuid); - } @EventHandler(priority = EventPriority.LOWEST) @@ -1405,7 +1419,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati { if (event.getEntered() instanceof Player && event.getVehicle() instanceof Horse) { - if(!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false)) + if (!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false)) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index d262f4270..c0d55196d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -20,6 +20,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.HorseInventory; import org.bukkit.plugin.java.JavaPlugin; @@ -34,6 +35,7 @@ import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -481,6 +483,18 @@ public class MountManager extends MiniDbClientPlugin UtilPlayer.message(event.getPlayer(), F.main(getName(), "This is not your Mount!")); event.setCancelled(true); } + + @EventHandler + public void onChunkUnload(ChunkUnloadEvent event) + { + _spawnedMounts.entrySet().forEach(entry -> + { + if (UtilWorld.isInChunk(entry.getKey().getLocation(), event.getChunk())) + { + entry.getValue().despawn(false); + } + }); + } @Override public String getQuery(int accountId, String uuid, String name)