diff --git a/config.yml b/config.yml
index 863bd1ca..3219c0cc 100644
--- a/config.yml
+++ b/config.yml
@@ -61,6 +61,34 @@ BlownDisguiseMessage: '&cYour disguise was blown!'
# These disguises, as normal will not persist after a server restart.
# There is also no EntityDeath option as entities do not revive after death.
KeepDisguises:
+ EntityDespawn: false
PlayerDeath: false
PlayerLogout: false
- EntityDespawn: false
\ No newline at end of file
+
+# This here is a option to turn off misc disguises.
+# This means you can not have a living entity disguise as a non-living entity.
+# This disables the Attributes packet, Non-living entities can still disguise as other non-living
+MiscDisguisesForLiving: true
+
+# This will help performance, especially with CPU
+# Due to safety reasons, self disguises can never have their packets disabled.
+PacketsEnabled:
+ # This disables the animation packet. If a disguised entity sends a animation packet and they are using a non-living disguise. People will crash.
+ # Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash
+ Animation: true
+ # Disabling this means that you can't use the setSleeping option on a player disguise. Also you will crash anyone watching when you try to sleep in a bed
+ Bed: true
+ # This disguises the collect packet. If a living entity disguised as a non-living entity picks up a item. People will crash. This fixes it
+ # This also fixes people crashing if a item disguised as a sleeping player is picked up - Only true if Bed is enabled as well
+ Collect: true
+ # This disables a fix for when a disguised entity wearing armor dies, if the disguise can wear armor. It drops unpickupable items to anyone watching.
+ EntityStatus: true
+ # Entity enquipment is the packets that are sent to ensure that a disguise has or doesn't have armor, and their held item.
+ # Disabling this means that any disguises which can wear armor or hold items will show the armor/held item that the disguised is wearing.
+ Enquipment: true
+ # Movement packets are the biggest cpu hit. These are majorly used to ensure that the disguises facing direction isn't bugged up
+ Movement: true
+ # Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity
+ Riding: true
+ # When disguised as a wither skull, it sends a look packet every tick so that the wither skull is facing the right way.
+ WitherSkull: true
diff --git a/pom.xml b/pom.xml
index 7a84d561..9428bd21 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,6 +3,8 @@
4.0.0LibsDisguisesLibsDisguises
+ 8.2.0-SNAPSHOT
+
srcclean package
@@ -84,7 +86,6 @@
3.1.0
- 8.2.0-SNAPSHOT
diff --git a/src/me/libraryaddict/disguise/DisguiseConfig.java b/src/me/libraryaddict/disguise/DisguiseConfig.java
index 7f07306b..aa84deea 100644
--- a/src/me/libraryaddict/disguise/DisguiseConfig.java
+++ b/src/me/libraryaddict/disguise/DisguiseConfig.java
@@ -3,34 +3,63 @@ package me.libraryaddict.disguise;
import me.libraryaddict.disguise.utilities.PacketsManager;
public class DisguiseConfig {
+ private static boolean animationEnabled;
+ private static boolean bedEnabled;
private static boolean blowDisguisesOnAttack;
+ private static boolean collectEnabled;
private static String disguiseBlownMessage;
+ private static boolean enquipmentEnabled;
private static boolean entityAnimationsAdded;
+ private static boolean entityStatusEnabled;
private static boolean hearSelfDisguise;
private static boolean hidingArmor;
private static boolean hidingHeldItem;
private static boolean keepDisguiseEntityDespawn;
private static boolean keepDisguisePlayerDeath;
private static boolean keepDisguisePlayerLogout;
+ private static boolean miscDisguisesForLivingEnabled;
private static boolean modifyBoundingBox;
+ private static boolean movementEnabled;
private static boolean removeUnseenDisguises;
+ private static boolean ridingEnabled;
private static boolean sendVelocity;
private static boolean showNameAboveHead;
private static boolean showNameAboveHeadAlwaysVisible;
private static boolean targetDisguises;
+ private static boolean witherSkullEnabled;
public static String getDisguiseBlownMessage() {
return disguiseBlownMessage;
}
+ public static boolean isAnimationPacketsEnabled() {
+ return animationEnabled;
+ }
+
+ public static boolean isBedPacketsEnabled() {
+ return bedEnabled;
+ }
+
+ public static boolean isCollectPacketsEnabled() {
+ return collectEnabled;
+ }
+
public static boolean isDisguiseBlownOnAttack() {
return blowDisguisesOnAttack;
}
+ public static boolean isEnquipmentPacketsEnabled() {
+ return enquipmentEnabled;
+ }
+
public static boolean isEntityAnimationsAdded() {
return entityAnimationsAdded;
}
+ public static boolean isEntityStatusPacketsEnabled() {
+ return entityStatusEnabled;
+ }
+
/**
* Is the plugin modifying the inventory packets so that players when self disguised, do not see their armor floating around
*/
@@ -57,6 +86,10 @@ public class DisguiseConfig {
return keepDisguisePlayerLogout;
}
+ public static boolean isMiscDisguisesForLivingEnabled() {
+ return miscDisguisesForLivingEnabled;
+ }
+
public static boolean isModifyBoundingBox() {
return modifyBoundingBox;
}
@@ -65,6 +98,10 @@ public class DisguiseConfig {
return targetDisguises;
}
+ public static boolean isMovementPacketsEnabled() {
+ return movementEnabled;
+ }
+
public static boolean isNameAboveHeadAlwaysVisible() {
return showNameAboveHeadAlwaysVisible;
}
@@ -73,6 +110,10 @@ public class DisguiseConfig {
return showNameAboveHead;
}
+ public static boolean isRidingPacketsEnabled() {
+ return ridingEnabled;
+ }
+
public static boolean isSelfDisguisesSoundsReplaced() {
return hearSelfDisguise;
}
@@ -102,10 +143,35 @@ public class DisguiseConfig {
return PacketsManager.isViewDisguisesListenerEnabled();
}
+ public static boolean isWitherSkullPacketsEnabled() {
+ return witherSkullEnabled;
+ }
+
public static void setAddEntityAnimations(boolean isEntityAnimationsAdded) {
entityAnimationsAdded = isEntityAnimationsAdded;
}
+ public static void setAnimationPacketsEnabled(boolean enabled) {
+ if (enabled != isAnimationPacketsEnabled()) {
+ animationEnabled = enabled;
+ PacketsManager.setupMainPacketsListener();
+ }
+ }
+
+ public static void setBedPacketsEnabled(boolean enabled) {
+ if (enabled != isBedPacketsEnabled()) {
+ bedEnabled = enabled;
+ PacketsManager.setupMainPacketsListener();
+ }
+ }
+
+ public static void setCollectPacketsEnabled(boolean enabled) {
+ if (enabled != isCollectPacketsEnabled()) {
+ collectEnabled = enabled;
+ PacketsManager.setupMainPacketsListener();
+ }
+ }
+
public static void setDisguiseBlownMessage(String newMessage) {
disguiseBlownMessage = newMessage;
}
@@ -114,6 +180,20 @@ public class DisguiseConfig {
blowDisguisesOnAttack = blowDisguise;
}
+ public static void setEnquipmentPacketsEnabled(boolean enabled) {
+ if (enabled != isEnquipmentPacketsEnabled()) {
+ enquipmentEnabled = enabled;
+ PacketsManager.setupMainPacketsListener();
+ }
+ }
+
+ public static void setEntityStatusPacketsEnabled(boolean enabled) {
+ if (enabled != isEntityStatusPacketsEnabled()) {
+ entityStatusEnabled = enabled;
+ PacketsManager.setupMainPacketsListener();
+ }
+ }
+
/**
* Can players hear their own disguises
*/
@@ -155,6 +235,13 @@ public class DisguiseConfig {
keepDisguisePlayerLogout = keepDisguise;
}
+ public static void setMiscDisguisesForLivingEnabled(boolean enabled) {
+ if (enabled != isMiscDisguisesForLivingEnabled()) {
+ miscDisguisesForLivingEnabled = enabled;
+ PacketsManager.setupMainPacketsListener();
+ }
+ }
+
public static void setModifyBoundingBox(boolean modifyBounding) {
modifyBoundingBox = modifyBounding;
}
@@ -163,6 +250,13 @@ public class DisguiseConfig {
targetDisguises = ignore;
}
+ public static void setMovementPacketsEnabled(boolean enabled) {
+ if (enabled != isMovementPacketsEnabled()) {
+ movementEnabled = enabled;
+ PacketsManager.setupMainPacketsListener();
+ }
+ }
+
public static void setNameAboveHeadAlwaysVisible(boolean alwaysVisible) {
showNameAboveHeadAlwaysVisible = alwaysVisible;
}
@@ -171,6 +265,13 @@ public class DisguiseConfig {
showNameAboveHead = showNames;
}
+ public static void setRidingPacketsEnabled(boolean enabled) {
+ if (enabled != isRidingPacketsEnabled()) {
+ ridingEnabled = enabled;
+ PacketsManager.setupMainPacketsListener();
+ }
+ }
+
/**
* Set if the disguises play sounds when hurt
*/
@@ -193,6 +294,10 @@ public class DisguiseConfig {
PacketsManager.setViewDisguisesListener(seeOwnDisguise);
}
+ public static void setWitherSkullPacketsEnabled(boolean enabled) {
+ witherSkullEnabled = enabled;
+ }
+
private DisguiseConfig() {
}
diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java
index 359a837a..1a34e41c 100644
--- a/src/me/libraryaddict/disguise/LibsDisguises.java
+++ b/src/me/libraryaddict/disguise/LibsDisguises.java
@@ -23,6 +23,7 @@ import me.libraryaddict.disguise.utilities.DisguiseValues;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Ageable;
@@ -46,14 +47,16 @@ public class LibsDisguises extends JavaPlugin {
stream = getClassLoader().getResource("config.yml").openStream();
YamlConfiguration internalConfig = YamlConfiguration.loadConfiguration(stream);
for (String option : internalConfig.getKeys(false)) {
- if (!config.contains(option)) {
- if (internalConfig.isConfigurationSection(option)) {
- for (String secondOption : internalConfig.getConfigurationSection(option).getKeys(false)) {
- config.set(option, getConfig().get(option + "." + secondOption));
+ if (internalConfig.isConfigurationSection(option)) {
+ ConfigurationSection section = internalConfig.getConfigurationSection(option);
+ for (String secondOption : section.getKeys(false)) {
+ if (!config.contains(secondOption)) {
+ config.set(option + "." + secondOption, section.get(secondOption));
+ needToSaveConfig = true;
}
- } else {
- config.set(option, getConfig().get(option));
}
+ } else if (!config.contains(option)) {
+ config.set(option, getConfig().get(option));
needToSaveConfig = true;
}
}
@@ -94,6 +97,15 @@ public class LibsDisguises extends JavaPlugin {
DisguiseConfig.setKeepDisguiseOnPlayerDeath(getConfig().getBoolean("KeepDisguises.PlayerDeath"));
DisguiseConfig.setKeepDisguiseOnPlayerLogout(getConfig().getBoolean("KeepDisguises.PlayerLogout"));
DisguiseConfig.setKeepDisguiseOnEntityDespawn(getConfig().getBoolean("KeepDisguises.EntityDespawn"));
+ DisguiseConfig.setMiscDisguisesForLivingEnabled(getConfig().getBoolean("MiscDisguisesForLiving"));
+ DisguiseConfig.setMovementPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Movement"));
+ DisguiseConfig.setWitherSkullPacketsEnabled(getConfig().getBoolean("PacketsEnabled.WitherSkull"));
+ DisguiseConfig.setEnquipmentPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Enquipment"));
+ DisguiseConfig.setAnimationPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Animation"));
+ DisguiseConfig.setBedPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Bed"));
+ DisguiseConfig.setRidingPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Riding"));
+ DisguiseConfig.setEntityStatusPacketsEnabled(getConfig().getBoolean("PacketsEnabled.EntityStatus"));
+ DisguiseConfig.setCollectPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Collect"));
try {
// Here I use reflection to set the plugin for Disguise..
// Kind of stupid but I don't want open API calls for a commonly used object.
@@ -103,7 +115,7 @@ public class LibsDisguises extends JavaPlugin {
} catch (Exception ex) {
ex.printStackTrace();
}
- PacketsManager.addPacketListeners(this);
+ PacketsManager.addPacketListeners();
DisguiseListener listener = new DisguiseListener(this);
Bukkit.getPluginManager().registerEvents(listener, this);
getCommand("disguise").setExecutor(new DisguiseCommand());
diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java
index 0d7d8d53..b06907e6 100644
--- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java
+++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java
@@ -21,6 +21,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse.Variant;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
@@ -227,7 +228,7 @@ public abstract class Disguise {
// If disguise isn't a experience orb, or the entity isn't standing on the ground
if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) {
PacketContainer lookPacket = null;
- if (getType() == DisguiseType.WITHER_SKULL) {
+ if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) {
lookPacket = new PacketContainer(PacketType.Play.Server.ENTITY_LOOK);
StructureModifier