Fix movement, update stuff, fix bugs, something, made sweet love to

herobrine
This commit is contained in:
libraryaddict 2016-06-13 06:24:14 +12:00
parent 26c560e8e8
commit 25e0a59099
5 changed files with 119 additions and 87 deletions

View File

@ -160,6 +160,7 @@ public class LibsDisguises extends JavaPlugin
break;
case ZOMBIE_VILLAGER:
case PIG_ZOMBIE:
case HUSK:
watcherClass = ZombieWatcher.class;
break;
case MAGMA_CUBE:
@ -169,6 +170,7 @@ public class LibsDisguises extends JavaPlugin
watcherClass = GuardianWatcher.class;
break;
case WITHER_SKELETON:
case STRAY:
watcherClass = SkeletonWatcher.class;
break;
default:
@ -234,6 +236,8 @@ public class LibsDisguises extends JavaPlugin
case MULE:
case UNDEAD_HORSE:
case SKELETON_HORSE:
case STRAY:
case HUSK:
continue;
case PRIMED_TNT:
nmsEntityName = "TNTPrimed";

View File

@ -195,9 +195,11 @@ public enum DisguiseType
toUse = DisguiseType.HORSE;
break;
case ZOMBIE_VILLAGER:
case HUSK:
toUse = DisguiseType.ZOMBIE;
break;
case WITHER_SKELETON:
case STRAY:
toUse = DisguiseType.SKELETON;
break;
case ELDER_GUARDIAN:

View File

@ -12,20 +12,25 @@ import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher;
public class MiscDisguise extends TargetedDisguise {
public class MiscDisguise extends TargetedDisguise
{
private int id = -1, data = 0;
public MiscDisguise(DisguiseType disguiseType) {
public MiscDisguise(DisguiseType disguiseType)
{
this(disguiseType, -1, disguiseType.getDefaultData());
}
public MiscDisguise(DisguiseType disguiseType, int id) {
public MiscDisguise(DisguiseType disguiseType, int id)
{
this(disguiseType, id, disguiseType.getDefaultData());
}
public MiscDisguise(DisguiseType disguiseType, int id, int data) {
if (!disguiseType.isMisc()) {
public MiscDisguise(DisguiseType disguiseType, int id, int data)
{
if (!disguiseType.isMisc())
{
throw new InvalidParameterException("Expected a non-living DisguiseType while constructing MiscDisguise. Received "
+ disguiseType + " instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise")
+ " instead");
@ -33,49 +38,53 @@ public class MiscDisguise extends TargetedDisguise {
createDisguise(disguiseType);
this.id = getType().getTypeId();
this.data = getType().getDefaultData();
switch (disguiseType) {
// The only disguises which should use a custom data.
case PAINTING:
((PaintingWatcher) getWatcher()).setArt(Art.values()[Math.max(0, id) % Art.values().length]);
break;
case FALLING_BLOCK:
((FallingBlockWatcher) getWatcher()).setBlock(new ItemStack(Math.max(1, id), 1, (short) Math.max(0,
data)));
break;
case SPLASH_POTION:
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, id));
break;
case DROPPED_ITEM:
if (id > 0) {
((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(id, Math.max(0, data)));
}
break;
case FISHING_HOOK: // Entity ID of whoever is holding fishing rod
case ARROW:
case TIPPED_ARROW: // Entity ID of shooter. Used for "Is he on this scoreboard team and do I render it moving through his body?"
case SPECTRAL_ARROW:
case SMALL_FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
case FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
case WITHER_SKULL: // Unknown. Uses entity id of shooter. 0 if no shooter
this.data = id;
break;
default:
break;
switch (disguiseType)
{
// The only disguises which should use a custom data.
case PAINTING:
((PaintingWatcher) getWatcher()).setArt(Art.values()[Math.max(0, id) % Art.values().length]);
break;
case FALLING_BLOCK:
((FallingBlockWatcher) getWatcher()).setBlock(new ItemStack(Math.max(1, id), 1, (short) Math.max(0, data)));
break;
case SPLASH_POTION:
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, id));
break;
case DROPPED_ITEM:
if (id > 0)
{
((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(id, Math.max(0, data)));
}
break;
case FISHING_HOOK: // Entity ID of whoever is holding fishing rod
case ARROW: // Entity ID of shooter. Used for "Is he on this scoreboard team and do I render it moving through his body?"
case TIPPED_ARROW:
case SPECTRAL_ARROW:
case SMALL_FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
case FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
case WITHER_SKULL: // Unknown. Uses entity id of shooter. 0 if no shooter
this.data = id;
break;
default:
break;
}
}
@Override
public MiscDisguise addPlayer(Player player) {
public MiscDisguise addPlayer(Player player)
{
return (MiscDisguise) super.addPlayer(player);
}
@Override
public MiscDisguise addPlayer(String playername) {
public MiscDisguise addPlayer(String playername)
{
return (MiscDisguise) super.addPlayer(playername);
}
@Override
public MiscDisguise clone() {
public MiscDisguise clone()
{
MiscDisguise disguise = new MiscDisguise(getType(), getData());
disguise.setReplaceSounds(isSoundsReplaced());
disguise.setViewSelfDisguise(isSelfDisguiseVisible());
@ -91,116 +100,138 @@ public class MiscDisguise extends TargetedDisguise {
/**
* This is the getId of everything but falling block.
*/
public int getData() {
switch (getType()) {
case FALLING_BLOCK:
return (int) ((FallingBlockWatcher) getWatcher()).getBlock().getDurability();
case PAINTING:
return ((PaintingWatcher) getWatcher()).getArt().getId();
case SPLASH_POTION:
return ((SplashPotionWatcher) getWatcher()).getPotionId();
default:
return data;
public int getData()
{
switch (getType())
{
case FALLING_BLOCK:
return (int) ((FallingBlockWatcher) getWatcher()).getBlock().getDurability();
case PAINTING:
return ((PaintingWatcher) getWatcher()).getArt().getId();
case SPLASH_POTION:
return ((SplashPotionWatcher) getWatcher()).getPotionId();
default:
return data;
}
}
/**
* Only falling block should use this
*/
public int getId() {
if (getType() == DisguiseType.FALLING_BLOCK) {
public int getId()
{
if (getType() == DisguiseType.FALLING_BLOCK)
{
return ((FallingBlockWatcher) getWatcher()).getBlock().getTypeId();
}
return id;
}
@Override
public boolean isMiscDisguise() {
public boolean isMiscDisguise()
{
return true;
}
@Override
public MiscDisguise removePlayer(Player player) {
public MiscDisguise removePlayer(Player player)
{
return (MiscDisguise) super.removePlayer(player);
}
@Override
public MiscDisguise removePlayer(String playername) {
public MiscDisguise removePlayer(String playername)
{
return (MiscDisguise) super.removePlayer(playername);
}
@Override
public MiscDisguise setDisguiseTarget(TargetType newTargetType) {
public MiscDisguise setDisguiseTarget(TargetType newTargetType)
{
return (MiscDisguise) super.setDisguiseTarget(newTargetType);
}
@Override
public MiscDisguise setEntity(Entity entity) {
public MiscDisguise setEntity(Entity entity)
{
return (MiscDisguise) super.setEntity(entity);
}
@Override
public MiscDisguise setHearSelfDisguise(boolean hearSelfDisguise) {
public MiscDisguise setHearSelfDisguise(boolean hearSelfDisguise)
{
return (MiscDisguise) super.setHearSelfDisguise(hearSelfDisguise);
}
@Override
public MiscDisguise setHideArmorFromSelf(boolean hideArmor) {
public MiscDisguise setHideArmorFromSelf(boolean hideArmor)
{
return (MiscDisguise) super.setHideArmorFromSelf(hideArmor);
}
@Override
public MiscDisguise setHideHeldItemFromSelf(boolean hideHeldItem) {
public MiscDisguise setHideHeldItemFromSelf(boolean hideHeldItem)
{
return (MiscDisguise) super.setHideHeldItemFromSelf(hideHeldItem);
}
@Override
public MiscDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) {
public MiscDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise)
{
return (MiscDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise);
}
@Override
public MiscDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) {
public MiscDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise)
{
return (MiscDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise);
}
@Override
public MiscDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) {
public MiscDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise)
{
return (MiscDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise);
}
@Override
public MiscDisguise setModifyBoundingBox(boolean modifyBox) {
public MiscDisguise setModifyBoundingBox(boolean modifyBox)
{
return (MiscDisguise) super.setModifyBoundingBox(modifyBox);
}
@Override
public MiscDisguise setReplaceSounds(boolean areSoundsReplaced) {
public MiscDisguise setReplaceSounds(boolean areSoundsReplaced)
{
return (MiscDisguise) super.setReplaceSounds(areSoundsReplaced);
}
@Override
public MiscDisguise setVelocitySent(boolean sendVelocity) {
public MiscDisguise setVelocitySent(boolean sendVelocity)
{
return (MiscDisguise) super.setVelocitySent(sendVelocity);
}
@Override
public MiscDisguise setViewSelfDisguise(boolean viewSelfDisguise) {
public MiscDisguise setViewSelfDisguise(boolean viewSelfDisguise)
{
return (MiscDisguise) super.setViewSelfDisguise(viewSelfDisguise);
}
@Override
public MiscDisguise setWatcher(FlagWatcher newWatcher) {
public MiscDisguise setWatcher(FlagWatcher newWatcher)
{
return (MiscDisguise) super.setWatcher(newWatcher);
}
@Override
public MiscDisguise silentlyAddPlayer(String playername) {
public MiscDisguise silentlyAddPlayer(String playername)
{
return (MiscDisguise) super.silentlyAddPlayer(playername);
}
@Override
public MiscDisguise silentlyRemovePlayer(String playername) {
public MiscDisguise silentlyRemovePlayer(String playername)
{
return (MiscDisguise) super.silentlyRemovePlayer(playername);
}

View File

@ -1186,8 +1186,6 @@ public class DisguiseUtilities
if ((t = scoreboard.getTeam("LDPushing")) != null)
{
t.setOption(Option.COLLISION_RULE, OptionStatus.ALWAYS);
t.removeEntry(player.getName());
t.unregister();
}
@ -1280,6 +1278,19 @@ public class DisguiseUtilities
return;
}
// Code to stop player pushing in 1.9
Scoreboard scoreboard = player.getScoreboard();
Team t;
if ((t = scoreboard.getTeam("LDPushing")) == null)
{
t = scoreboard.registerNewTeam("LDPushing");
t.setOption(Option.COLLISION_RULE, OptionStatus.NEVER);
}
t.addEntry(player.getName());
// Add himself to his own entity tracker
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
.get(entityTrackerEntry);
@ -1498,22 +1509,6 @@ public class DisguiseUtilities
return;
}
// Code to stop player pushing in 1.9
Scoreboard scoreboard = player.getScoreboard();
Team t;
if ((t = scoreboard.getTeam("LDPushing")) != null)
{
t.setOption(Option.COLLISION_RULE, OptionStatus.NEVER);
}
else
{
t = scoreboard.registerNewTeam("LDPushing");
t.setOption(Option.COLLISION_RULE, OptionStatus.NEVER);
t.addEntry(player.getName());
}
// player.spigot().setCollidesWithEntities(false);
// Finish up
selfDisguised.add(player.getUniqueId());

View File

@ -408,9 +408,9 @@ public class ReflectionManager
return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData")
.getDeclaredConstructor(getNmsClass("PacketPlayOutPlayerInfo"), gameProfile.getHandleType(), int.class,
getNmsClass("WorldSettings$EnumGamemode"), getNmsClass("IChatBaseComponent"))
.newInstance(playerInfoPacket, gameProfile.getHandle(), 0,
getNmsClass("WorldSettings$EnumGamemode").getEnumConstants()[1], playerListName);
getNmsClass("EnumGamemode"), getNmsClass("IChatBaseComponent"))
.newInstance(playerInfoPacket, gameProfile.getHandle(), 0, getNmsClass("EnumGamemode").getEnumConstants()[1],
playerListName);
}
catch (Exception ex)
{