Fix libsdisguises.seethrough
This commit is contained in:
parent
11785d1842
commit
ead8daca4e
@ -1081,6 +1081,15 @@ public abstract class Disguise {
|
|||||||
multiName = new String[0];
|
multiName = new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (player.hasPermission("libsdisguises.seethrough") ||
|
||||||
|
((TargetedDisguise) this).getDisguiseTarget() != TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
((TargetedDisguise) this).addPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
if (LibsPremium.getUserID().equals("123" + "45") || !LibsMsg.OWNED_BY.getRaw().contains("'")) {
|
if (LibsPremium.getUserID().equals("123" + "45") || !LibsMsg.OWNED_BY.getRaw().contains("'")) {
|
||||||
((TargetedDisguise) this).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
((TargetedDisguise) this).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import me.libraryaddict.disguise.utilities.LibsEntityInteract;
|
|||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.modded.ModdedEntity;
|
import me.libraryaddict.disguise.utilities.modded.ModdedEntity;
|
||||||
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
|
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.apache.commons.lang.math.RandomUtils;
|
import org.apache.commons.lang.math.RandomUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -59,8 +58,7 @@ public class DisguiseListener implements Listener {
|
|||||||
|
|
||||||
runUpdateScheduler();
|
runUpdateScheduler();
|
||||||
|
|
||||||
if (!LibsPremium.getPluginInformation().isPremium() ||
|
if (!LibsPremium.getPluginInformation().isPremium() || LibsPremium.getPluginInformation().getUserID().matches("[0-9]+")) {
|
||||||
LibsPremium.getPluginInformation().getUserID().matches("[0-9]+")) {
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,8 +107,7 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (autoUpdate && !isCheckReleases()) {
|
if (autoUpdate && !isCheckReleases()) {
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().info("Plugin will attempt to auto update when new builds are ready! Check config to disable.");
|
||||||
.info("Plugin will attempt to auto update when new builds are ready! Check config to disable.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,8 +129,7 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR,
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
ignoreCancelled = true)
|
|
||||||
public void onVelocity(PlayerVelocityEvent event) {
|
public void onVelocity(PlayerVelocityEvent event) {
|
||||||
DisguiseUtilities.setPlayerVelocity(event.getPlayer());
|
DisguiseUtilities.setPlayerVelocity(event.getPlayer());
|
||||||
|
|
||||||
@ -142,8 +138,7 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH,
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
ignoreCancelled = true)
|
|
||||||
public void onAttack(EntityDamageByEntityEvent event) {
|
public void onAttack(EntityDamageByEntityEvent event) {
|
||||||
Entity attacker = event.getDamager();
|
Entity attacker = event.getDamager();
|
||||||
|
|
||||||
@ -177,14 +172,12 @@ public class DisguiseListener implements Listener {
|
|||||||
|
|
||||||
private boolean canRetaliate(Entity entity) {
|
private boolean canRetaliate(Entity entity) {
|
||||||
return entity.hasMetadata("LD-LastAttacked") &&
|
return entity.hasMetadata("LD-LastAttacked") &&
|
||||||
entity.getMetadata("LD-LastAttacked").get(0).asLong() + (DisguiseConfig.getPvPTimer() * 1000) >
|
entity.getMetadata("LD-LastAttacked").get(0).asLong() + (DisguiseConfig.getPvPTimer() * 1000) > System.currentTimeMillis();
|
||||||
System.currentTimeMillis();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRetaliation(Entity entity) {
|
private void setRetaliation(Entity entity) {
|
||||||
entity.removeMetadata("LD-LastAttacked", LibsDisguises.getInstance());
|
entity.removeMetadata("LD-LastAttacked", LibsDisguises.getInstance());
|
||||||
entity.setMetadata("LD-LastAttacked",
|
entity.setMetadata("LD-LastAttacked", new FixedMetadataValue(LibsDisguises.getInstance(), System.currentTimeMillis()));
|
||||||
new FixedMetadataValue(LibsDisguises.getInstance(), System.currentTimeMillis()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPlayerCanFight(EntityDamageByEntityEvent event, Entity attacker) {
|
private void checkPlayerCanFight(EntityDamageByEntityEvent event, Entity attacker) {
|
||||||
@ -195,8 +188,7 @@ public class DisguiseListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attacker.hasPermission("libsdisguises." + (pvp ? "pvp" : "pve")) &&
|
if (!attacker.hasPermission("libsdisguises." + (pvp ? "pvp" : "pve")) && !attacker.hasPermission("libsdisguises." + (pvp ? "pvp" : "pve"))) {
|
||||||
!attacker.hasPermission("libsdisguises." + (pvp ? "pvp" : "pve"))) {
|
|
||||||
if (!DisguiseConfig.isRetaliationCombat() || !canRetaliate(attacker)) {
|
if (!DisguiseConfig.isRetaliationCombat() || !canRetaliate(attacker)) {
|
||||||
Disguise[] disguises = DisguiseAPI.getDisguises(attacker);
|
Disguise[] disguises = DisguiseAPI.getDisguises(attacker);
|
||||||
|
|
||||||
@ -371,6 +363,11 @@ public class DisguiseListener implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p.hasPermission("libsdisguises.seethrough") &&
|
||||||
|
targetedDisguise.getDisguiseTarget() == TargetedDisguise.TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
||||||
|
targetedDisguise.addPlayer(p);
|
||||||
|
}
|
||||||
|
|
||||||
if (!targetedDisguise.canSee(p)) {
|
if (!targetedDisguise.canSee(p)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -383,8 +380,7 @@ public class DisguiseListener implements Listener {
|
|||||||
|
|
||||||
if (disguise.isDisplayedInTab()) {
|
if (disguise.isDisplayedInTab()) {
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(p,
|
ProtocolLibrary.getProtocolManager().sendServerPacket(p, DisguiseUtilities.getTabPacket(disguise, PlayerInfoAction.ADD_PLAYER));
|
||||||
DisguiseUtilities.getTabPacket(disguise, PlayerInfoAction.ADD_PLAYER));
|
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -406,14 +402,13 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!p.hasMetadata("forge_mods")) {
|
if (!p.hasMetadata("forge_mods")) {
|
||||||
Optional<ModdedEntity> required = ModdedManager.getEntities().values().stream()
|
Optional<ModdedEntity> required =
|
||||||
.filter(c -> c.getMod() != null && c.getRequired() != null).findAny();
|
ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny();
|
||||||
|
|
||||||
required.ifPresent(customEntity -> p.kickPlayer(customEntity.getRequired()));
|
required.ifPresent(customEntity -> p.kickPlayer(customEntity.getRequired()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DisguiseConfig.isSaveGameProfiles() && DisguiseConfig.isUpdateGameProfiles() &&
|
if (DisguiseConfig.isSaveGameProfiles() && DisguiseConfig.isUpdateGameProfiles() && DisguiseUtilities.hasGameProfile(p.getName())) {
|
||||||
DisguiseUtilities.hasGameProfile(p.getName())) {
|
|
||||||
WrappedGameProfile profile = WrappedGameProfile.fromPlayer(p);
|
WrappedGameProfile profile = WrappedGameProfile.fromPlayer(p);
|
||||||
|
|
||||||
if (!profile.getProperties().isEmpty()) {
|
if (!profile.getProperties().isEmpty()) {
|
||||||
@ -431,8 +426,8 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!p.hasMetadata("forge_mods")) {
|
if (!p.hasMetadata("forge_mods")) {
|
||||||
Optional<ModdedEntity> required = ModdedManager.getEntities().values().stream()
|
Optional<ModdedEntity> required =
|
||||||
.filter(c -> c.getMod() != null && c.getRequired() != null).findAny();
|
ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny();
|
||||||
|
|
||||||
required.ifPresent(customEntity -> p.kickPlayer(customEntity.getRequired()));
|
required.ifPresent(customEntity -> p.kickPlayer(customEntity.getRequired()));
|
||||||
}
|
}
|
||||||
@ -443,12 +438,10 @@ public class DisguiseListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Most likely faster if we don't bother doing checks if he sees a player disguise
|
* Most likely faster if we don't bother doing checks if he sees a player disguise
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR,
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
ignoreCancelled = true)
|
|
||||||
public void onMove(PlayerMoveEvent event) {
|
public void onMove(PlayerMoveEvent event) {
|
||||||
// If yer a pirate with a pirated jar, sometimes you can't move
|
// If yer a pirate with a pirated jar, sometimes you can't move
|
||||||
if (("%%__USER__%%".isEmpty() || DisguiseUtilities.isInvalidFile()) && !event.getPlayer().isOp() &&
|
if (("%%__USER__%%".isEmpty() || DisguiseUtilities.isInvalidFile()) && !event.getPlayer().isOp() && RandomUtils.nextDouble() < 0.01) {
|
||||||
RandomUtils.nextDouble() < 0.01) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,8 +464,7 @@ public class DisguiseListener implements Listener {
|
|||||||
Disguise disguise;
|
Disguise disguise;
|
||||||
|
|
||||||
if ((disguise = DisguiseAPI.getDisguise(event.getPlayer())) != null) {
|
if ((disguise = DisguiseAPI.getDisguise(event.getPlayer())) != null) {
|
||||||
if (disguise.getType() ==
|
if (disguise.getType() == DisguiseType.SHULKER) { // Stop Shulker disguises from moving their coordinates
|
||||||
DisguiseType.SHULKER) { // Stop Shulker disguises from moving their coordinates
|
|
||||||
Location from = event.getFrom();
|
Location from = event.getFrom();
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
|
|
||||||
@ -491,6 +483,18 @@ public class DisguiseListener implements Listener {
|
|||||||
|
|
||||||
DisguiseUtilities.removeSelfDisguiseScoreboard(player);
|
DisguiseUtilities.removeSelfDisguiseScoreboard(player);
|
||||||
|
|
||||||
|
if (player.hasPermission("libsdisguises.seethrough")) {
|
||||||
|
for (Set<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
||||||
|
for (TargetedDisguise disguise : disguises) {
|
||||||
|
if (disguise.getDisguiseTarget() != TargetedDisguise.TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
disguise.silentlyRemovePlayer(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!DisguiseConfig.isSavePlayerDisguises()) {
|
if (!DisguiseConfig.isSavePlayerDisguises()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -563,15 +567,13 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR,
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
ignoreCancelled = true)
|
|
||||||
public void onTeleport(PlayerTeleportEvent event) {
|
public void onTeleport(PlayerTeleportEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
Location from = event.getFrom();
|
Location from = event.getFrom();
|
||||||
|
|
||||||
if (!player.isOp() && !player.hasPermission("minecraft.command.teleport") &&
|
if (!player.isOp() && !player.hasPermission("minecraft.command.teleport") && LibsPremium.getPaidInformation() != null &&
|
||||||
LibsPremium.getPaidInformation() != null &&
|
|
||||||
LibsPremium.getPaidInformation().getUserID().equals("1592")) {
|
LibsPremium.getPaidInformation().getUserID().equals("1592")) {
|
||||||
player.sendMessage(ChatColor.GOLD + "Your teleport was a success!");
|
player.sendMessage(ChatColor.GOLD + "Your teleport was a success!");
|
||||||
}
|
}
|
||||||
@ -580,8 +582,7 @@ public class DisguiseListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DisguiseConfig.isUndisguiseOnWorldChange() && to.getWorld() != null && from.getWorld() != null &&
|
if (DisguiseConfig.isUndisguiseOnWorldChange() && to.getWorld() != null && from.getWorld() != null && to.getWorld() != from.getWorld()) {
|
||||||
to.getWorld() != from.getWorld()) {
|
|
||||||
Disguise[] disguises = DisguiseAPI.getDisguises(event.getPlayer());
|
Disguise[] disguises = DisguiseAPI.getDisguises(event.getPlayer());
|
||||||
|
|
||||||
if (disguises.length > 0) {
|
if (disguises.length > 0) {
|
||||||
@ -634,8 +635,7 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR,
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
ignoreCancelled = true)
|
|
||||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||||
if (!(event.getEntered() instanceof Player)) {
|
if (!(event.getEntered() instanceof Player)) {
|
||||||
return;
|
return;
|
||||||
@ -652,8 +652,7 @@ public class DisguiseListener implements Listener {
|
|||||||
((Player) event.getEntered()).updateInventory();
|
((Player) event.getEntered()).updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR,
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
ignoreCancelled = true)
|
|
||||||
public void onVehicleLeave(VehicleExitEvent event) {
|
public void onVehicleLeave(VehicleExitEvent event) {
|
||||||
if (event.getExited() instanceof Player) {
|
if (event.getExited() instanceof Player) {
|
||||||
final Disguise disguise = DisguiseAPI.getDisguise((Player) event.getExited(), event.getExited());
|
final Disguise disguise = DisguiseAPI.getDisguise((Player) event.getExited(), event.getExited());
|
||||||
@ -671,8 +670,7 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR,
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
ignoreCancelled = true)
|
|
||||||
public void onWorldSwitch(final PlayerChangedWorldEvent event) {
|
public void onWorldSwitch(final PlayerChangedWorldEvent event) {
|
||||||
if (!DisguiseAPI.isDisguised(event.getPlayer())) {
|
if (!DisguiseAPI.isDisguised(event.getPlayer())) {
|
||||||
return;
|
return;
|
||||||
|
@ -57,7 +57,6 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) {
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) {
|
||||||
|
|
||||||
packets.clear();
|
packets.clear();
|
||||||
|
|
||||||
if (disguise.getType() == DisguiseType.UNKNOWN) {
|
if (disguise.getType() == DisguiseType.UNKNOWN) {
|
||||||
|
Loading…
Reference in New Issue
Block a user