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

View File

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

View File

@ -1186,8 +1186,6 @@ public class DisguiseUtilities
if ((t = scoreboard.getTeam("LDPushing")) != null) if ((t = scoreboard.getTeam("LDPushing")) != null)
{ {
t.setOption(Option.COLLISION_RULE, OptionStatus.ALWAYS);
t.removeEntry(player.getName());
t.unregister(); t.unregister();
} }
@ -1280,6 +1278,19 @@ public class DisguiseUtilities
return; 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 // Add himself to his own entity tracker
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
.get(entityTrackerEntry); .get(entityTrackerEntry);
@ -1498,22 +1509,6 @@ public class DisguiseUtilities
return; 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); // player.spigot().setCollidesWithEntities(false);
// Finish up // Finish up
selfDisguised.add(player.getUniqueId()); selfDisguised.add(player.getUniqueId());

View File

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