Add new disguise option to remove disguises on world change
This commit is contained in:
parent
f777b33917
commit
c145ae5106
@ -86,6 +86,9 @@ MaxHealthDeterminedByEntity: true
|
||||
# This disables the Attributes packet, Non-living entities can still disguise as other non-living
|
||||
MiscDisguisesForLiving: true
|
||||
|
||||
# Turn this to true to have players undisguised when switching worlds
|
||||
UndisguiseOnWorldChange: false
|
||||
|
||||
# This will help performance, especially with CPU
|
||||
# Due to safety reasons, self disguises can never have their packets disabled.
|
||||
PacketsEnabled:
|
||||
|
@ -34,6 +34,7 @@ public class DisguiseConfig {
|
||||
private static boolean showNameAboveHead;
|
||||
private static boolean showNameAboveHeadAlwaysVisible;
|
||||
private static boolean targetDisguises;
|
||||
private static boolean undisguiseSwitchWorlds;
|
||||
private static boolean witherSkullEnabled;
|
||||
|
||||
public static String getDisguiseBlownMessage() {
|
||||
@ -85,6 +86,7 @@ public class DisguiseConfig {
|
||||
setMaxClonedDisguises(config.getInt("DisguiseCloneSize"));
|
||||
setSheepDyeable(config.getBoolean("DyeableSheep"));
|
||||
setWolfDyeable(config.getBoolean("DyeableWolf"));
|
||||
setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange"));
|
||||
}
|
||||
|
||||
public static boolean isAnimationPacketsEnabled() {
|
||||
@ -192,6 +194,10 @@ public class DisguiseConfig {
|
||||
return PacketsManager.isHearDisguisesEnabled();
|
||||
}
|
||||
|
||||
public static boolean isUndisguiseOnWorldChange() {
|
||||
return undisguiseSwitchWorlds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the velocity packets sent
|
||||
*/
|
||||
@ -370,6 +376,10 @@ public class DisguiseConfig {
|
||||
PacketsManager.setHearDisguisesListener(isSoundsEnabled);
|
||||
}
|
||||
|
||||
public static void setUndisguiseOnWorldChange(boolean isUndisguise) {
|
||||
undisguiseSwitchWorlds = isUndisguise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get?
|
||||
*/
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
@ -189,8 +190,8 @@ public class DisguiseListener implements Listener {
|
||||
p.sendMessage(ChatColor.RED + "Disguised " + (entity instanceof Player ? "" : "the ") + entityName
|
||||
+ " as " + disguiseName + "!");
|
||||
} else {
|
||||
p.sendMessage(ChatColor.RED + "Failed to disguise " + (entity instanceof Player ? "" : "the ") + entityName
|
||||
+ " as " + disguiseName + "!");
|
||||
p.sendMessage(ChatColor.RED + "Failed to disguise " + (entity instanceof Player ? "" : "the ")
|
||||
+ entityName + " as " + disguiseName + "!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -248,6 +249,15 @@ public class DisguiseListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldSwitch(PlayerPortalEvent event) {
|
||||
if (DisguiseConfig.isUndisguiseOnWorldChange() && event.getFrom().getWorld() != event.getTo().getWorld()) {
|
||||
for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) {
|
||||
disguise.removeDisguise();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDisguiseClone(final String player, Boolean[] options) {
|
||||
if (disguiseRunnable.containsKey(player)) {
|
||||
BukkitRunnable run = disguiseRunnable.remove(player);
|
||||
|
Loading…
Reference in New Issue
Block a user