Despawn mounts on chunk unload and clean up some formatting
This commit is contained in:
parent
5e70ff8471
commit
d5355ab757
@ -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;
|
||||
@ -23,6 +22,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)
|
||||
{
|
||||
return first.getBlockX() >> 4 == second.getBlockX() >> 4 && first.getBlockZ() >> 4 == second.getBlockZ() >> 4;
|
||||
|
@ -792,10 +792,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements 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 MiniClientPlugin<ClientClan>implements 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 MiniClientPlugin<ClientClan>implements 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 MiniClientPlugin<ClientClan>implements 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 MiniClientPlugin<ClientClan>implements IRelati
|
||||
for (Player other : event.getRecipients())
|
||||
{
|
||||
if (_tutorial.inTutorial(other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ClanInfo otherClan = _clanUtility.getClanByPlayer(other);
|
||||
|
||||
@ -976,7 +983,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements 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 MiniClientPlugin<ClientClan>implements 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 MiniClientPlugin<ClientClan>implements 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 MiniClientPlugin<ClientClan>implements IRelati
|
||||
public void updateBedStatus(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TWOSEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (String name : getClanNameSet())
|
||||
{
|
||||
@ -1391,7 +1406,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
_clanMemberLeftMap.remove(uuid);
|
||||
_warPointEvasion.resetCooldown(uuid);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
|
@ -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;
|
||||
@ -482,6 +484,18 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user