Add disguises pushing options
This commit is contained in:
parent
451b4a9465
commit
448dd06104
@ -1,9 +1,11 @@
|
||||
# Shall I notify people of a LibsDisguises update?
|
||||
NotifyUpdate: true
|
||||
|
||||
# Should the plugin use scoreboards to disable pushing? Please note that disabling this effectively means that self disguises will push the disguiser around
|
||||
# Alternatively when this is enabled this will remove the player from any scoreboard team he is in
|
||||
DisablePushing: true
|
||||
# How should the plugin handle self disguises scoreboards?
|
||||
# MODIFY - Modifies the player's existing scoreboard if possible, otherwise assigns them to a new scoreboard team
|
||||
# IGNORE - Doesn't touch scoreboards at all, effectively means that if you didn't disable pushing in their scoreboard team they will be pushed around
|
||||
# CREATE - Assigns them to a new team which copies the attributes of their previous scoreboard team. This means they keep nametag color and other options.
|
||||
SelfDisguisesScoreboard: MODIFY
|
||||
|
||||
# Whats the permission to get the notification?
|
||||
Permission: 'libsdisguises.update'
|
||||
|
@ -15,6 +15,9 @@ import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException
|
||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
||||
|
||||
public class DisguiseConfig {
|
||||
public static enum DisguisePushing {
|
||||
MODIFY, IGNORE, CREATE;
|
||||
}
|
||||
|
||||
private static boolean animationEnabled;
|
||||
private static boolean bedEnabled;
|
||||
@ -56,7 +59,7 @@ public class DisguiseConfig {
|
||||
private static String updateNotificationPermission;
|
||||
private static boolean viewSelfDisguise;
|
||||
private static boolean witherSkullEnabled;
|
||||
private static boolean disablePushing;
|
||||
private static DisguisePushing disablePushing;
|
||||
|
||||
public static Entry<String, Disguise> getCustomDisguise(String disguise) {
|
||||
for (Entry<String, Disguise> entry : customDisguises.entrySet()) {
|
||||
@ -69,7 +72,7 @@ public class DisguiseConfig {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isPushingDisabled() {
|
||||
public static DisguisePushing getPushingOption() {
|
||||
return disablePushing;
|
||||
}
|
||||
|
||||
@ -141,7 +144,14 @@ public class DisguiseConfig {
|
||||
setHideDisguisedPlayers(config.getBoolean("HideDisguisedPlayersFromTab"));
|
||||
setShowDisguisedPlayersInTab(config.getBoolean("ShowPlayerDisguisesInTab"));
|
||||
setDisabledInvisibility(config.getBoolean("DisableInvisibility"));
|
||||
disablePushing = config.getBoolean("DisablePushing");
|
||||
|
||||
try {
|
||||
disablePushing = DisguisePushing.valueOf(config.getString("DisablePushing").toUpperCase());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("[LibsDisguises] Cannot parse '" + config.getString("SelfDisguisesTeams")
|
||||
+ "' to a valid option for SelfDisguisesTeam");
|
||||
}
|
||||
|
||||
customDisguises.clear();
|
||||
|
||||
|
@ -47,6 +47,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.DisguiseConfig.DisguisePushing;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
@ -84,6 +85,7 @@ public class DisguiseUtilities {
|
||||
private static HashSet<UUID> selfDisguised = new HashSet<>();
|
||||
private static Thread mainThread;
|
||||
private static PacketContainer spawnChunk;
|
||||
private static HashMap<UUID, String> previousTeam = new HashMap<UUID, String>();
|
||||
|
||||
static {
|
||||
try {
|
||||
@ -988,13 +990,28 @@ public class DisguiseUtilities {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isPushingDisabled()) {
|
||||
String prevTeam = previousTeam.remove(player.getUniqueId());
|
||||
|
||||
if (DisguiseConfig.getPushingOption() != DisguisePushing.IGNORE) {
|
||||
// Code to stop player pushing in 1.9
|
||||
Scoreboard scoreboard = player.getScoreboard();
|
||||
Team t;
|
||||
Team team = scoreboard.getTeam(prevTeam);
|
||||
Team ldTeam = scoreboard.getEntryTeam(player.getName());
|
||||
|
||||
if ((t = scoreboard.getTeam("LDPushing")) != null) {
|
||||
t.removeEntry(player.getName());
|
||||
if (ldTeam != null) {
|
||||
if (!ldTeam.getName().equals("LDPushing") && !ldTeam.getName().endsWith("_LDP"))
|
||||
ldTeam = null;
|
||||
}
|
||||
|
||||
if (team != null) {
|
||||
team.addEntry(player.getName());
|
||||
}
|
||||
else if (ldTeam != null) {
|
||||
ldTeam.removeEntry(player.getName());
|
||||
}
|
||||
|
||||
if (ldTeam != null && ldTeam.getEntries().isEmpty()) {
|
||||
ldTeam.unregister();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1073,22 +1090,55 @@ public class DisguiseUtilities {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isPushingDisabled()) {
|
||||
DisguisePushing pOption = DisguiseConfig.getPushingOption();
|
||||
|
||||
if (pOption != DisguisePushing.IGNORE) {
|
||||
// Code to stop player pushing
|
||||
Scoreboard scoreboard = player.getScoreboard();
|
||||
Team t;
|
||||
Team prevTeam = scoreboard.getEntryTeam(player.getName());
|
||||
|
||||
if ((t = scoreboard.getTeam("LDPushing")) == null) {
|
||||
t = scoreboard.registerNewTeam("LDPushing");
|
||||
if (prevTeam != null && pOption == DisguisePushing.CREATE) {
|
||||
previousTeam.put(player.getUniqueId(), prevTeam.getName());
|
||||
}
|
||||
|
||||
Team t;
|
||||
String createName = null;
|
||||
|
||||
if (pOption == DisguisePushing.CREATE) {
|
||||
createName = (prevTeam == null ? "No Team" : prevTeam.getName());
|
||||
|
||||
createName = createName.substring(0, Math.min(12, createName.length()));
|
||||
}
|
||||
else {
|
||||
createName = "LDPushing";
|
||||
}
|
||||
|
||||
if ((t = scoreboard.getTeam(createName)) == null) {
|
||||
t = scoreboard.registerNewTeam(createName);
|
||||
}
|
||||
|
||||
if (t.getOption(Option.COLLISION_RULE) != OptionStatus.NEVER) {
|
||||
t.setOption(Option.COLLISION_RULE, OptionStatus.NEVER);
|
||||
}
|
||||
|
||||
if (t.canSeeFriendlyInvisibles()) {
|
||||
t.setCanSeeFriendlyInvisibles(false);
|
||||
}
|
||||
|
||||
if (!t.hasEntry(player.getName()))
|
||||
t.addEntry(player.getName());
|
||||
|
||||
if (pOption == DisguisePushing.CREATE && prevTeam != null) {
|
||||
t.setAllowFriendlyFire(prevTeam.allowFriendlyFire());
|
||||
t.setCanSeeFriendlyInvisibles(prevTeam.canSeeFriendlyInvisibles());
|
||||
t.setDisplayName(prevTeam.getDisplayName());
|
||||
t.setPrefix(prevTeam.getPrefix());
|
||||
t.setSuffix(prevTeam.getSuffix());
|
||||
|
||||
for (Option option : Team.Option.values()) {
|
||||
t.setOption(option, prevTeam.getOption(option));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add himself to his own entity tracker
|
||||
|
Loading…
Reference in New Issue
Block a user