Added the new /disguiseviewself command, allows for toggling the disguise model when you see yourself.
Permission is libsdisguises.viewself Aliases are: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd]
This commit is contained in:
parent
1d54ba9997
commit
b57e9931b0
@ -156,6 +156,9 @@ public class DisguiseAPI {
|
|||||||
// Set the disguise's entity
|
// Set the disguise's entity
|
||||||
disguise.setEntity(entity);
|
disguise.setEntity(entity);
|
||||||
}
|
}
|
||||||
|
if (Disguise.getViewSelf().contains(disguise.getEntity().getUniqueId())) {
|
||||||
|
disguise.setViewSelfDisguise(true);
|
||||||
|
}
|
||||||
disguise.startDisguise();
|
disguise.startDisguise();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,6 +268,8 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the disguise of a entity
|
* Get the disguise of a entity
|
||||||
|
* @param disguised
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Disguise getDisguise(Entity disguised) {
|
public static Disguise getDisguise(Entity disguised) {
|
||||||
if (disguised == null)
|
if (disguised == null)
|
||||||
@ -274,6 +279,9 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the disguise of a entity
|
* Get the disguise of a entity
|
||||||
|
* @param observer
|
||||||
|
* @param disguised
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Disguise getDisguise(Player observer, Entity disguised) {
|
public static Disguise getDisguise(Player observer, Entity disguised) {
|
||||||
if (disguised == null || observer == null)
|
if (disguised == null || observer == null)
|
||||||
@ -283,6 +291,8 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the disguises of a entity
|
* Get the disguises of a entity
|
||||||
|
* @param disguised
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Disguise[] getDisguises(Entity disguised) {
|
public static Disguise[] getDisguises(Entity disguised) {
|
||||||
if (disguised == null)
|
if (disguised == null)
|
||||||
@ -292,6 +302,8 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ID of a fake disguise for a entityplayer
|
* Get the ID of a fake disguise for a entityplayer
|
||||||
|
* @param entityId
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static int getFakeDisguise(UUID entityId) {
|
public static int getFakeDisguise(UUID entityId) {
|
||||||
@ -304,6 +316,8 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this entity disguised
|
* Is this entity disguised
|
||||||
|
* @param disguised
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isDisguised(Entity disguised) {
|
public static boolean isDisguised(Entity disguised) {
|
||||||
return getDisguise(disguised) != null;
|
return getDisguise(disguised) != null;
|
||||||
@ -311,6 +325,9 @@ public class DisguiseAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this entity disguised
|
* Is this entity disguised
|
||||||
|
* @param observer
|
||||||
|
* @param disguised
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isDisguised(Player observer, Entity disguised) {
|
public static boolean isDisguised(Player observer, Entity disguised) {
|
||||||
return getDisguise(observer, disguised) != null;
|
return getDisguise(observer, disguised) != null;
|
||||||
@ -323,10 +340,21 @@ public class DisguiseAPI {
|
|||||||
public static boolean isSelfDisguised(Player player) {
|
public static boolean isSelfDisguised(Player player) {
|
||||||
return DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId());
|
return DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the entitiy has /disguiseviewself toggled
|
||||||
|
* on.
|
||||||
|
* @param entity
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isViewSelfToggled(Entity entity) {
|
||||||
|
return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible() : Disguise.getViewSelf().contains(entity.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from
|
* Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from
|
||||||
* the world.
|
* the world.
|
||||||
|
* @param entity
|
||||||
*/
|
*/
|
||||||
public static void undisguiseToAll(Entity entity) {
|
public static void undisguiseToAll(Entity entity) {
|
||||||
Disguise[] disguises = getDisguises(entity);
|
Disguise[] disguises = getDisguises(entity);
|
||||||
@ -334,6 +362,25 @@ public class DisguiseAPI {
|
|||||||
disguise.removeDisguise();
|
disguise.removeDisguise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether this player can see his
|
||||||
|
* own disguise or not.
|
||||||
|
* @param entity
|
||||||
|
* @param toggled
|
||||||
|
*/
|
||||||
|
public static void setViewDisguiseToggled(Entity entity, boolean toggled) {
|
||||||
|
if (isDisguised(entity)) {
|
||||||
|
Disguise disguise = getDisguise(entity);
|
||||||
|
disguise.setViewSelfDisguise(toggled);
|
||||||
|
}
|
||||||
|
if (toggled) {
|
||||||
|
if (!Disguise.getViewSelf().contains(entity.getUniqueId()))
|
||||||
|
Disguise.getViewSelf().add(entity.getUniqueId());
|
||||||
|
} else {
|
||||||
|
Disguise.getViewSelf().remove(entity.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private DisguiseAPI() {
|
private DisguiseAPI() {
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ public class DisguiseConfig {
|
|||||||
private static boolean entityStatusEnabled;
|
private static boolean entityStatusEnabled;
|
||||||
private static boolean equipmentEnabled;
|
private static boolean equipmentEnabled;
|
||||||
private static boolean hearSelfDisguise;
|
private static boolean hearSelfDisguise;
|
||||||
|
private static boolean viewSelfDisguise;
|
||||||
private static boolean hidingArmor;
|
private static boolean hidingArmor;
|
||||||
private static boolean hidingHeldItem;
|
private static boolean hidingHeldItem;
|
||||||
private static boolean keepDisguiseEntityDespawn;
|
private static boolean keepDisguiseEntityDespawn;
|
||||||
@ -68,7 +69,8 @@ public class DisguiseConfig {
|
|||||||
public static void initConfig(ConfigurationSection config) {
|
public static void initConfig(ConfigurationSection config) {
|
||||||
setSoundsEnabled(config.getBoolean("DisguiseSounds"));
|
setSoundsEnabled(config.getBoolean("DisguiseSounds"));
|
||||||
setVelocitySent(config.getBoolean("SendVelocity"));
|
setVelocitySent(config.getBoolean("SendVelocity"));
|
||||||
setViewDisguises(config.getBoolean("ViewSelfDisguises"));
|
setViewDisguises(config.getBoolean("ViewSelfDisguises")); //Since we can now toggle, the view disguises listener must always be on
|
||||||
|
PacketsManager.setViewDisguisesListener(true);
|
||||||
setHearSelfDisguise(config.getBoolean("HearSelfDisguise"));
|
setHearSelfDisguise(config.getBoolean("HearSelfDisguise"));
|
||||||
setHideArmorFromSelf(config.getBoolean("RemoveArmor"));
|
setHideArmorFromSelf(config.getBoolean("RemoveArmor"));
|
||||||
setHideHeldItemFromSelf(config.getBoolean("RemoveHeldItem"));
|
setHideHeldItemFromSelf(config.getBoolean("RemoveHeldItem"));
|
||||||
@ -216,6 +218,7 @@ public class DisguiseConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the velocity packets sent
|
* Is the velocity packets sent
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isVelocitySent() {
|
public static boolean isVelocitySent() {
|
||||||
return sendVelocity;
|
return sendVelocity;
|
||||||
@ -223,9 +226,10 @@ public class DisguiseConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The default value if a player views his own disguise
|
* The default value if a player views his own disguise
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isViewDisguises() {
|
public static boolean isViewDisguises() {
|
||||||
return PacketsManager.isViewDisguisesListenerEnabled();
|
return viewSelfDisguise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWitherSkullPacketsEnabled() {
|
public static boolean isWitherSkullPacketsEnabled() {
|
||||||
@ -404,13 +408,14 @@ public class DisguiseConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get?
|
* Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get?
|
||||||
|
* @param sendVelocityPackets
|
||||||
*/
|
*/
|
||||||
public static void setVelocitySent(boolean sendVelocityPackets) {
|
public static void setVelocitySent(boolean sendVelocityPackets) {
|
||||||
sendVelocity = sendVelocityPackets;
|
sendVelocity = sendVelocityPackets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setViewDisguises(boolean seeOwnDisguise) {
|
public static void setViewDisguises(boolean seeOwnDisguise) {
|
||||||
PacketsManager.setViewDisguisesListener(seeOwnDisguise);
|
viewSelfDisguise = seeOwnDisguise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setWitherSkullPacketsEnabled(boolean enabled) {
|
public static void setWitherSkullPacketsEnabled(boolean enabled) {
|
||||||
|
@ -63,6 +63,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
getCommand("disguisehelp").setExecutor(new DisguiseHelpCommand());
|
getCommand("disguisehelp").setExecutor(new DisguiseHelpCommand());
|
||||||
getCommand("disguiseclone").setExecutor(new DisguiseCloneCommand());
|
getCommand("disguiseclone").setExecutor(new DisguiseCloneCommand());
|
||||||
getCommand("libsdisguises").setExecutor(new LibsDisguisesCommand());
|
getCommand("libsdisguises").setExecutor(new LibsDisguisesCommand());
|
||||||
|
getCommand("disguiseviewself").setExecutor(new DisguiseViewSelf());
|
||||||
registerValues();
|
registerValues();
|
||||||
instance = this;
|
instance = this;
|
||||||
try {
|
try {
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Navid
|
||||||
|
*/
|
||||||
|
public class DisguiseViewSelf implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender.getName().equals("CONSOLE")) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (sender.hasPermission("libsdisguises.viewself")) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (DisguiseAPI.isViewSelfToggled(player)) {
|
||||||
|
DisguiseAPI.setViewDisguiseToggled(player, false);
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Toggled viewing own disguise off!");
|
||||||
|
} else {
|
||||||
|
DisguiseAPI.setViewDisguiseToggled(player, true);
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Toggled viewing own disguise on!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,6 +33,9 @@ import com.comphenix.protocol.PacketType;
|
|||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
|
||||||
public abstract class Disguise {
|
public abstract class Disguise {
|
||||||
@ -54,11 +57,14 @@ public abstract class Disguise {
|
|||||||
private FlagWatcher watcher;
|
private FlagWatcher watcher;
|
||||||
private boolean showName = false;
|
private boolean showName = false;
|
||||||
|
|
||||||
|
private static List<UUID> viewSelf = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract Disguise clone();
|
public abstract Disguise clone();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seems I do this method so I can make cleaner constructors on disguises..
|
* Seems I do this method so I can make cleaner constructors on disguises..
|
||||||
|
* @param newType
|
||||||
*/
|
*/
|
||||||
protected void createDisguise(DisguiseType newType) {
|
protected void createDisguise(DisguiseType newType) {
|
||||||
if (getWatcher() != null)
|
if (getWatcher() != null)
|
||||||
@ -408,6 +414,7 @@ public abstract class Disguise {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Can the disguised view himself as the disguise
|
* Can the disguised view himself as the disguise
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isSelfDisguiseVisible() {
|
public boolean isSelfDisguiseVisible() {
|
||||||
return viewSelfDisguise;
|
return viewSelfDisguise;
|
||||||
@ -685,6 +692,7 @@ public abstract class Disguise {
|
|||||||
/**
|
/**
|
||||||
* Can the disguised view himself as the disguise
|
* Can the disguised view himself as the disguise
|
||||||
*
|
*
|
||||||
|
* @param viewSelfDisguise
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Disguise setViewSelfDisguise(boolean viewSelfDisguise) {
|
public Disguise setViewSelfDisguise(boolean viewSelfDisguise) {
|
||||||
@ -750,4 +758,13 @@ public abstract class Disguise {
|
|||||||
public boolean stopDisguise() {
|
public boolean stopDisguise() {
|
||||||
return removeDisguise();
|
return removeDisguise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of people who have /disguiseViewSelf
|
||||||
|
* toggled on
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<UUID> getViewSelf() {
|
||||||
|
return viewSelf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
@ -41,9 +44,8 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
public DisguiseParseException(String string) {
|
public DisguiseParseException(String string) {
|
||||||
super(string);
|
super(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) {
|
protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) {
|
||||||
ArrayList<String> allowedDisguises = new ArrayList<>();
|
ArrayList<String> allowedDisguises = new ArrayList<>();
|
||||||
for (DisguiseType type : hashMap.keySet()) {
|
for (DisguiseType type : hashMap.keySet()) {
|
||||||
|
@ -433,6 +433,8 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise.
|
* Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise.
|
||||||
|
* @param disguise
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ArrayList<Player> getPerverts(Disguise disguise) {
|
public static ArrayList<Player> getPerverts(Disguise disguise) {
|
||||||
ArrayList<Player> players = new ArrayList<>();
|
ArrayList<Player> players = new ArrayList<>();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: LibsDisguises
|
name: LibsDisguises
|
||||||
main: me.libraryaddict.disguise.LibsDisguises
|
main: me.libraryaddict.disguise.LibsDisguises
|
||||||
version: 8.5.2
|
version: 8.6
|
||||||
author: libraryaddict
|
author: libraryaddict
|
||||||
authors: [Byteflux, Navid K.]
|
authors: [Byteflux, Navid K.]
|
||||||
depend: [ProtocolLib]
|
depend: [ProtocolLib]
|
||||||
@ -48,6 +48,10 @@ commands:
|
|||||||
aliases: [disguisec, disc, disclone, dclone, clonedisguise, clonedis, cdisguise, cdis]
|
aliases: [disguisec, disc, disclone, dclone, clonedisguise, clonedis, cdisguise, cdis]
|
||||||
permission: libsdisguises.seecmd.disguiseclone
|
permission: libsdisguises.seecmd.disguiseclone
|
||||||
description: Copy a disguise (or entity) and use it later.
|
description: Copy a disguise (or entity) and use it later.
|
||||||
|
disguiseviewself:
|
||||||
|
aliases: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd]
|
||||||
|
permission: libsdisguises.seecmd.viewself
|
||||||
|
description: Toggle seeing your own disguise on or off.
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
libsdisguises.seethrough:
|
libsdisguises.seethrough:
|
||||||
@ -68,8 +72,11 @@ permissions:
|
|||||||
libsdisguises.seecmd.undisguiseplayer: true
|
libsdisguises.seecmd.undisguiseplayer: true
|
||||||
libsdisguises.seecmd.undisguiseradius: true
|
libsdisguises.seecmd.undisguiseradius: true
|
||||||
libsdisguises.seecmd.disguiseclone: true
|
libsdisguises.seecmd.disguiseclone: true
|
||||||
|
libsdisguises.seecmd.disguiseviewself: true
|
||||||
libsdisguises.seecmd.libsdisguises:
|
libsdisguises.seecmd.libsdisguises:
|
||||||
description: See the /libsdisguises command in tab-completion
|
description: See the /libsdisguises command in tab-completion
|
||||||
|
libsdisguises.seecmd.disguiseviewself:
|
||||||
|
description: See the /disguiseviewself command in tab-completion
|
||||||
libsdisguises.seecmd.disguise:
|
libsdisguises.seecmd.disguise:
|
||||||
description: See the /disguise command in tab-completion
|
description: See the /disguise command in tab-completion
|
||||||
libsdisguises.seecmd.disguiseentity:
|
libsdisguises.seecmd.disguiseentity:
|
||||||
|
Loading…
Reference in New Issue
Block a user