Update stats

This commit is contained in:
libraryaddict 2017-06-23 04:14:19 +12:00
parent 27230d5148
commit 06ce2d0e02
12 changed files with 1365 additions and 1024 deletions

View File

@ -180,4 +180,4 @@ PacketsEnabled:
# Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity # Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity
Riding: true 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. # 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 WitherSkull: true

140
pom.xml
View File

@ -1,80 +1,80 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>LibsDisguises</groupId> <groupId>LibsDisguises</groupId>
<artifactId>LibsDisguises</artifactId> <artifactId>LibsDisguises</artifactId>
<version>9.4.0-SNAPSHOT</version> <version>9.4.0-SNAPSHOT</version>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<directory>target</directory> <directory>target</directory>
<finalName>LibsDisguises</finalName> <finalName>LibsDisguises</finalName>
<resources> <resources>
<resource> <resource>
<targetPath>.</targetPath> <targetPath>.</targetPath>
<filtering>true</filtering> <filtering>true</filtering>
<directory>${project.basedir}</directory> <directory>${project.basedir}</directory>
<includes> <includes>
<include>plugin.yml</include> <include>plugin.yml</include>
<include>config.yml</include> <include>config.yml</include>
<include>disguises.yml</include> <include>disguises.yml</include>
<include>README.md</include> <include>README.md</include>
</includes> </includes>
</resource> </resource>
</resources> </resources>
</build> </build>
<properties> <properties>
<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>4.2.0-SNAPSHOT</version> <version>4.2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.12-pre6-SNAPSHOT</version> <version>1.12-pre6-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.12-pre6-SNAPSHOT</version> <version>1.12-pre6-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
<repositories> <repositories>
<repository> <repository>
<id>dmulloy2-repo</id> <id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/content/groups/public/</url> <url>http://repo.dmulloy2.net/content/groups/public/</url>
</repository> </repository>
<repository> <repository>
<id>md_5-releases</id> <id>md_5-releases</id>
<url>https://repo.md-5.net/content/repositories/releases/</url> <url>https://repo.md-5.net/content/repositories/releases/</url>
</repository> </repository>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
</repositories> </repositories>
<distributionManagement> <distributionManagement>
<repository> <repository>
<id>md_5-releases</id> <id>md_5-releases</id>
<url>https://repo.md-5.net/content/repositories/releases/</url> <url>https://repo.md-5.net/content/repositories/releases/</url>
</repository> </repository>
<snapshotRepository> <snapshotRepository>
<id>md_5-snapshots</id> <id>md_5-snapshots</id>
<url>https://repo.md-5.net/content/repositories/snapshots/</url> <url>https://repo.md-5.net/content/repositories/snapshots/</url>
</snapshotRepository> </snapshotRepository>
</distributionManagement> </distributionManagement>
</project> </project>

View File

@ -256,6 +256,7 @@ public class DisguiseAPI {
for (String observer : ((TargetedDisguise) disguise).getObservers()) { for (String observer : ((TargetedDisguise) disguise).getObservers()) {
((TargetedDisguise) disguise).removePlayer(observer); ((TargetedDisguise) disguise).removePlayer(observer);
} }
disguiseEntity(entity, disguise); disguiseEntity(entity, disguise);
} }

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.TranslateType; import me.libraryaddict.disguise.utilities.TranslateType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -156,7 +157,8 @@ public class DisguiseConfig {
setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible")); setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible"));
setModifyBoundingBox(config.getBoolean("ModifyBoundingBox")); setModifyBoundingBox(config.getBoolean("ModifyBoundingBox"));
setMonstersIgnoreDisguises(config.getBoolean("MonstersIgnoreDisguises")); setMonstersIgnoreDisguises(config.getBoolean("MonstersIgnoreDisguises"));
setDisguiseBlownWhenAttacking(config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacking"))); setDisguiseBlownWhenAttacking(
config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacking")));
setDisguiseBlownWhenAttacked(config.getBoolean("BlowDisguisesWhenAttacked")); setDisguiseBlownWhenAttacked(config.getBoolean("BlowDisguisesWhenAttacked"));
setKeepDisguiseOnPlayerDeath(config.getBoolean("KeepDisguises.PlayerDeath")); setKeepDisguiseOnPlayerDeath(config.getBoolean("KeepDisguises.PlayerDeath"));
setMiscDisguisesForLivingEnabled(config.getBoolean("MiscDisguisesForLiving")); setMiscDisguisesForLivingEnabled(config.getBoolean("MiscDisguisesForLiving"));
@ -186,6 +188,10 @@ public class DisguiseConfig {
setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities")); setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities"));
setUseTranslations(config.getBoolean("Translations")); setUseTranslations(config.getBoolean("Translations"));
if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) {
System.out.println("[LibsDisguises] You must purchase the plugin to use saved disguises!");
}
try { try {
String option = config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name()) String option = config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name())
.toUpperCase(); .toUpperCase();

View File

@ -8,10 +8,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
import com.comphenix.protocol.wrappers.PlayerInfoData; import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedGameProfile;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.*;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.DisguiseParser; import me.libraryaddict.disguise.utilities.DisguiseParser;
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException;
@ -111,6 +108,8 @@ public class DisguiseListener implements Listener {
if (disguises.length <= 0) if (disguises.length <= 0)
continue; continue;
DisguiseUtilities.resetPluginTimer();
for (Disguise disguise : disguises) { for (Disguise disguise : disguises) {
disguise.setEntity(entity); disguise.setEntity(entity);
disguise.startDisguise(); disguise.startDisguise();
@ -248,6 +247,8 @@ public class DisguiseListener implements Listener {
if (disguises.length <= 0) if (disguises.length <= 0)
continue; continue;
DisguiseUtilities.resetPluginTimer();
for (Disguise disguise : disguises) { for (Disguise disguise : disguises) {
disguise.setEntity(entity); disguise.setEntity(entity);
disguise.startDisguise(); disguise.startDisguise();
@ -266,6 +267,8 @@ public class DisguiseListener implements Listener {
if (disguises.length <= 0) if (disguises.length <= 0)
continue; continue;
DisguiseUtilities.resetPluginTimer();
for (Disguise disguise : disguises) { for (Disguise disguise : disguises) {
disguise.setEntity(entity); disguise.setEntity(entity);
disguise.startDisguise(); disguise.startDisguise();
@ -297,6 +300,10 @@ public class DisguiseListener implements Listener {
if (DisguiseConfig.isSavePlayerDisguises()) { if (DisguiseConfig.isSavePlayerDisguises()) {
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(p.getUniqueId(), true); Disguise[] disguises = DisguiseUtilities.getSavedDisguises(p.getUniqueId(), true);
if (disguises.length > 0) {
DisguiseUtilities.resetPluginTimer();
}
for (Disguise disguise : disguises) { for (Disguise disguise : disguises) {
disguise.setEntity(p); disguise.setEntity(p);
disguise.startDisguise(); disguise.startDisguise();
@ -311,26 +318,6 @@ public class DisguiseListener implements Listener {
if (!targetedDisguise.canSee(p)) if (!targetedDisguise.canSee(p))
continue; continue;
// Don't need this as we have a packet listener doing that for us
/*if (targetedDisguise.isPlayerHiddenInTab() && targetedDisguise.getEntity() instanceof Player) {
try {
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
Player player = (Player) targetedDisguise.getEntity();
addTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
addTab.getPlayerInfoDataLists()
.write(0,
Arrays.asList(new PlayerInfoData(ReflectionManager.getGameProfile(player), 0,
NativeGameMode.SURVIVAL,
WrappedChatComponent.fromText(player.getDisplayName()))));
ProtocolLibrary.getProtocolManager().sendServerPacket(p, addTab);
}
catch (InvocationTargetException e) {
e.printStackTrace();
}
}*/
if (!(targetedDisguise instanceof PlayerDisguise)) if (!(targetedDisguise instanceof PlayerDisguise))
continue; continue;

View File

@ -1,48 +1,24 @@
package me.libraryaddict.disguise; package me.libraryaddict.disguise;
import java.io.File; import com.comphenix.protocol.reflect.FieldAccessException;
import java.io.IOException; import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import java.lang.reflect.Field; import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import java.util.ArrayList; import me.libraryaddict.disguise.commands.*;
import me.libraryaddict.disguise.disguisetypes.*;
import me.libraryaddict.disguise.disguisetypes.watchers.*; import me.libraryaddict.disguise.disguisetypes.watchers.*;
import me.libraryaddict.disguise.utilities.*; import me.libraryaddict.disguise.utilities.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Ageable; import org.bukkit.entity.*;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Damageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Zombie;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.reflect.FieldAccessException; import java.io.File;
import com.comphenix.protocol.wrappers.WrappedDataWatcher; import java.lang.reflect.Field;
import com.comphenix.protocol.wrappers.WrappedWatchableObject; import java.util.ArrayList;
import java.util.HashMap;
import me.libraryaddict.disguise.commands.DisguiseCloneCommand; import java.util.HashSet;
import me.libraryaddict.disguise.commands.DisguiseCommand;
import me.libraryaddict.disguise.commands.DisguiseEntityCommand;
import me.libraryaddict.disguise.commands.DisguiseHelpCommand;
import me.libraryaddict.disguise.commands.DisguiseModifyCommand;
import me.libraryaddict.disguise.commands.DisguiseModifyEntityCommand;
import me.libraryaddict.disguise.commands.DisguiseModifyPlayerCommand;
import me.libraryaddict.disguise.commands.DisguiseModifyRadiusCommand;
import me.libraryaddict.disguise.commands.DisguisePlayerCommand;
import me.libraryaddict.disguise.commands.DisguiseRadiusCommand;
import me.libraryaddict.disguise.commands.DisguiseViewSelfCommand;
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
import me.libraryaddict.disguise.commands.UndisguiseCommand;
import me.libraryaddict.disguise.commands.UndisguiseEntityCommand;
import me.libraryaddict.disguise.commands.UndisguisePlayerCommand;
import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
public class LibsDisguises extends JavaPlugin { public class LibsDisguises extends JavaPlugin {
private static LibsDisguises instance; private static LibsDisguises instance;
@ -50,16 +26,6 @@ public class LibsDisguises extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
try {
Class.forName("com.comphenix.protocol.wrappers.Vector3F").getName();
}
catch (Exception ex) {
System.err.println("[LibsDisguises] Lib's Disguises failed to startup, outdated ProtocolLib!");
System.err.println(
"[LibsDisguises] You need to update ProtocolLib, please try this build http://ci.dmulloy2.net/job/ProtocolLib/lastStableBuild/artifact/modules/ProtocolLib/target/ProtocolLib.jar");
return;
}
instance = this; instance = this;
saveDefaultConfig(); saveDefaultConfig();
@ -100,13 +66,114 @@ public class LibsDisguises extends JavaPlugin {
registerCommand("disguisemodifyradius", registerCommand("disguisemodifyradius",
new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
try { infectWithMetrics();
Metrics metrics = new Metrics(this); }
metrics.start();
} private void infectWithMetrics() {
catch (IOException e) { Metrics metrics = new Metrics(this);
// Don't print error
} final String premium = LibsPremium.isPremium() ?
getDescription().getVersion().contains("SNAPSHOT") ? "Paid Builds" : "Paid Plugin" : "Free Builds";
metrics.addCustomChart(new Metrics.SimplePie("premium") {
@Override
public String getValue() {
return premium;
}
});
metrics.addCustomChart(new Metrics.SimplePie("translations") {
@Override
public String getValue() {
return LibsPremium.isPremium() && DisguiseConfig.isUseTranslations() ? "Yes" : "No";
}
});
metrics.addCustomChart(new Metrics.SimplePie("custom_disguises") {
@Override
public String getValue() {
HashMap map = DisguiseConfig.getCustomDisguises();
return map.size() + (map.containsKey("libraryaddict") ? -1 : 0) > 0 ? "Yes" : "No";
}
});
metrics.addCustomChart(new Metrics.MultiLineChart("disguised_entities") {
@Override
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
for (HashSet<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
for (Disguise disg : list) {
if (disg.getEntity() == null || !disg.isDisguiseInUse())
continue;
String name = disg.getEntity().getType().name();
hashMap.put(name, hashMap.containsKey(name) ? hashMap.get(name) + 1 : 1);
}
}
return hashMap;
}
});
metrics.addCustomChart(new Metrics.MultiLineChart("disguises_used") {
@Override
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
for (HashSet<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
for (Disguise disg : list) {
if (disg.getEntity() == null || !disg.isDisguiseInUse())
continue;
String name = disg.getType().name();
hashMap.put(name, hashMap.containsKey(name) ? hashMap.get(name) + 1 : 1);
}
}
return hashMap;
}
});
metrics.addCustomChart(new Metrics.SimplePie("disguised_with_commands") {
@Override
public String getValue() {
return DisguiseUtilities.isCommandsUsed() ? "Yes" : "No";
}
});
metrics.addCustomChart(new Metrics.SimplePie("disguised_with_plugins") {
@Override
public String getValue() {
return DisguiseUtilities.isPluginsUsed() ? "Yes" : "No";
}
});
metrics.addCustomChart(new Metrics.SimplePie("using_disguises") {
@Override
public String getValue() {
return !DisguiseUtilities.getDisguises().isEmpty() ? "Yes" : "No";
}
});
metrics.addCustomChart(new Metrics.SimplePie("self_disguises") {
@Override
public String getValue() {
return DisguiseConfig.isViewDisguises() ? "Yes" : "No";
}
});
metrics.addCustomChart(new Metrics.SimplePie("spigot") {
@Override
public String getValue() {
try {
Class.forName("org.spigotmc.SpigotConfig");
return "Yes";
}
catch (Exception ex) {
return "No";
}
}
});
} }
@Override @Override

View File

@ -71,8 +71,6 @@ public abstract class Disguise {
/** /**
* 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 The disguise
*/ */
protected void createDisguise() { protected void createDisguise() {
if (getType().getEntityType() == null) { if (getType().getEntityType() == null) {
@ -234,7 +232,8 @@ public abstract class Disguise {
int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4; int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4;
if (loc.getBlockX() != blockX || loc.getBlockY() != blockY || loc.getBlockZ() != blockZ || newFacing != facing) { if (loc.getBlockX() != blockX || loc.getBlockY() != blockY || loc
.getBlockZ() != blockZ || newFacing != facing) {
blockX = loc.getBlockX(); blockX = loc.getBlockX();
blockY = loc.getBlockY(); blockY = loc.getBlockY();
blockZ = loc.getBlockZ(); blockZ = loc.getBlockZ();
@ -260,7 +259,8 @@ public abstract class Disguise {
// If the entity doesn't have velocity changes already - You know. I really can't wrap my head about the // If the entity doesn't have velocity changes already - You know. I really can't wrap my head about the
// if statement. // if statement.
// But it doesn't seem to do anything wrong.. // But it doesn't seem to do anything wrong..
if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && getEntity().isOnGround())) { if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && getEntity()
.isOnGround())) {
return; return;
} }
@ -268,7 +268,8 @@ public abstract class Disguise {
if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) { if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) {
PacketContainer lookPacket = null; PacketContainer lookPacket = null;
if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) { if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig
.isWitherSkullPacketsEnabled()) {
lookPacket = new PacketContainer(Server.ENTITY_LOOK); lookPacket = new PacketContainer(Server.ENTITY_LOOK);
StructureModifier<Object> mods = lookPacket.getModifier(); StructureModifier<Object> mods = lookPacket.getModifier();
@ -277,8 +278,8 @@ public abstract class Disguise {
mods.write(4, PacketsManager.getYaw(getType(), getEntity().getType(), mods.write(4, PacketsManager.getYaw(getType(), getEntity().getType(),
(byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
mods.write(5, mods.write(5, PacketsManager
PacketsManager.getPitch(getType(), DisguiseType.getType(getEntity().getType()), .getPitch(getType(), DisguiseType.getType(getEntity().getType()),
(byte) Math.floor(loc.getPitch() * 256.0F / 360.0F))); (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
if (isSelfDisguiseVisible() && getEntity() instanceof Player) { if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
@ -287,8 +288,8 @@ public abstract class Disguise {
selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId()); selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
try { try {
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), ProtocolLibrary.getProtocolManager()
selfLookPacket, false); .sendServerPacket((Player) getEntity(), selfLookPacket, false);
} }
catch (InvocationTargetException e) { catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
@ -319,12 +320,12 @@ public abstract class Disguise {
(int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D)); (int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D));
if (lookPacket != null && player != getEntity()) { if (lookPacket != null && player != getEntity()) {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket, ProtocolLibrary.getProtocolManager()
false); .sendServerPacket(player, lookPacket, false);
} }
ProtocolLibrary.getProtocolManager().sendServerPacket(player, ProtocolLibrary.getProtocolManager()
velocityPacket.shallowClone(), false); .sendServerPacket(player, velocityPacket.shallowClone(), false);
} }
} }
catch (Exception e) { catch (Exception e) {
@ -348,8 +349,8 @@ public abstract class Disguise {
selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId()); selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId());
try { try {
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), ProtocolLibrary.getProtocolManager()
selfPacket, false); .sendServerPacket((Player) getEntity(), selfPacket, false);
} }
catch (InvocationTargetException e) { catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
@ -683,8 +684,8 @@ public abstract class Disguise {
*/ */
private void setupWatcher() { private void setupWatcher() {
ArrayList<MetaIndex> disguiseFlags = MetaIndex.getFlags(getType().getWatcherClass()); ArrayList<MetaIndex> disguiseFlags = MetaIndex.getFlags(getType().getWatcherClass());
ArrayList<MetaIndex> entityFlags = MetaIndex.getFlags( ArrayList<MetaIndex> entityFlags = MetaIndex
DisguiseType.getType(getEntity().getType()).getWatcherClass()); .getFlags(DisguiseType.getType(getEntity().getType()).getWatcherClass());
for (MetaIndex flag : entityFlags) { for (MetaIndex flag : entityFlags) {
if (disguiseFlags.contains(flag)) if (disguiseFlags.contains(flag))
@ -736,7 +737,8 @@ public abstract class Disguise {
public Disguise setWatcher(FlagWatcher newWatcher) { public Disguise setWatcher(FlagWatcher newWatcher) {
if (!getType().getWatcherClass().isInstance(newWatcher)) { if (!getType().getWatcherClass().isInstance(newWatcher)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
newWatcher.getClass().getSimpleName() + " is not a instance of " + getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name()); newWatcher.getClass().getSimpleName() + " is not a instance of " + getType().getWatcherClass()
.getSimpleName() + " for DisguiseType " + getType().name());
} }
watcher = newWatcher; watcher = newWatcher;
@ -749,78 +751,47 @@ public abstract class Disguise {
} }
public boolean startDisguise() { public boolean startDisguise() {
if (!isDisguiseInUse()) { if (isDisguiseInUse()) {
if (getEntity() == null) { return false;
throw new RuntimeException("No entity is assigned to this disguise!"); }
}
// Fire a disguise event if (getEntity() == null) {
DisguiseEvent event = new DisguiseEvent(entity, this); throw new RuntimeException("No entity is assigned to this disguise!");
}
Bukkit.getPluginManager().callEvent(event); DisguiseUtilities.setPluginsUsed();
// If they cancelled this disguise event. No idea why. // Fire a disguise event
// Just return. DisguiseEvent event = new DisguiseEvent(entity, this);
if (event.isCancelled()) {
return false;
}
disguiseInUse = true; Bukkit.getPluginManager().
callEvent(event);
if (velocityRunnable == null) { // If they cancelled this disguise event. No idea why.
createRunnable(); // Just return.
} if (event.isCancelled()) {
return false;
}
task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1); disguiseInUse = true;
if (this instanceof PlayerDisguise) { if (velocityRunnable == null) {
PlayerDisguise disguise = (PlayerDisguise) this; createRunnable();
}
if (disguise.isDisplayedInTab()) { task = Bukkit.getScheduler().
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER);
addTab.getPlayerInfoDataLists().write(0, Arrays.asList(
new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL,
WrappedChatComponent.fromText(disguise.getName()))));
try { runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1);
for (Player player : Bukkit.getOnlinePlayers()) {
if (!((TargetedDisguise) this).canSee(player))
continue;
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab); if (this instanceof PlayerDisguise) {
} PlayerDisguise disguise = (PlayerDisguise) this;
}
catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
// Stick the disguise in the disguises bin if (disguise.isDisplayedInTab()) {
DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this);
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
DisguiseUtilities.removeSelfDisguise((Player) getEntity());
}
// Resend the disguised entity's packet
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
// If he is a player, then self disguise himself
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() {
@Override
public void run() {
DisguiseUtilities.setupFakeDisguise(Disguise.this);
}
}, 2);
if (isHidePlayer() && getEntity() instanceof Player) {
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
addTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER);
addTab.getPlayerInfoDataLists().write(0, Arrays.asList( addTab.getPlayerInfoDataLists().write(0, Arrays.asList(
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL,
NativeGameMode.SURVIVAL, WrappedChatComponent.fromText("")))); WrappedChatComponent.fromText(disguise.getName()))));
try { try {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
@ -834,14 +805,51 @@ public abstract class Disguise {
e.printStackTrace(); e.printStackTrace();
} }
} }
return true;
} }
return false; // Stick the disguise in the disguises bin
DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this);
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
DisguiseUtilities.removeSelfDisguise((Player) getEntity());
}
// Resend the disguised entity's packet
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
// If he is a player, then self disguise himself
Bukkit.getScheduler().
scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() {
@Override
public void run() {
DisguiseUtilities.setupFakeDisguise(Disguise.this);
}
}, 2);
if (isHidePlayer() && getEntity() instanceof Player) {
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
addTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
addTab.getPlayerInfoDataLists().write(0, Arrays.asList(
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(""))));
try {
for (Player player : Bukkit.getOnlinePlayers()) {
if (!((TargetedDisguise) this).canSee(player))
continue;
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
}
}
catch (InvocationTargetException e) {
e.printStackTrace();
}
}
return true;
} }
public boolean stopDisguise() { public boolean stopDisguise() {
return removeDisguise(); return removeDisguise();
} }
} }

View File

@ -453,6 +453,10 @@ public class DisguiseParser {
*/ */
public static Disguise parseDisguise(CommandSender sender, String permNode, String[] args, public static Disguise parseDisguise(CommandSender sender, String permNode, String[] args,
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permissionMap) throws DisguiseParseException, IllegalAccessException, InvocationTargetException { HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permissionMap) throws DisguiseParseException, IllegalAccessException, InvocationTargetException {
if (sender instanceof Player) {
DisguiseUtilities.setCommandsUsed();
}
if (permissionMap.isEmpty()) { if (permissionMap.isEmpty()) {
throw new DisguiseParseException(LibsMsg.NO_PERM); throw new DisguiseParseException(LibsMsg.NO_PERM);
} }

View File

@ -74,6 +74,33 @@ public class DisguiseUtilities {
"plugins/LibsDisguises/SavedDisguises"); "plugins/LibsDisguises/SavedDisguises");
private static Gson gson; private static Gson gson;
private static BackwardMethods methods; private static BackwardMethods methods;
private static boolean pluginsUsed, commandsUsed;
private static long libsDisguisesCalled;
public static void setPluginsUsed() {
if (libsDisguisesCalled > System.currentTimeMillis()) {
return;
}
pluginsUsed = true;
}
public static void resetPluginTimer() {
libsDisguisesCalled = System.currentTimeMillis() + 100;
}
public static void setCommandsUsed() {
resetPluginTimer();
commandsUsed = true;
}
public static boolean isPluginsUsed() {
return pluginsUsed;
}
public static boolean isCommandsUsed() {
return commandsUsed;
}
public static void saveDisguises() { public static void saveDisguises() {
for (HashSet<TargetedDisguise> list : disguisesInUse.values()) { for (HashSet<TargetedDisguise> list : disguisesInUse.values()) {

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,10 @@ public enum TranslateType {
type.reload(); type.reload();
} }
if (!LibsPremium.isPremium() && DisguiseConfig.isUseTranslations()) {
System.out.println("[LibsDisguises] You must purchase the plugin to use translations!");
}
TranslateFiller.fillConfigs(); TranslateFiller.fillConfigs();
} }

View File

@ -15,14 +15,18 @@ public class BackwardsSupport {
public static BackwardMethods getMethods() { public static BackwardMethods getMethods() {
try { try {
String version = ReflectionManager.getBukkitVersion(); String version = ReflectionManager.getBukkitVersion();
Class<? extends BackwardMethods> methods = BackwardMethods.class;
if (LibsPremium.isPremium()) { if (version.equals("v1_11_R1")) {
if (version.equals("v1_11_R1")) { methods = Version_1_11.class;
return setupMetadata(Version_1_11.class);
}
} }
return setupMetadata(BackwardMethods.class); if (!LibsPremium.isPremium() && methods != BackwardMethods.class) {
System.out.println("[LibsDisguises] You must purchase the plugin to use backwards compatibility!");
methods = BackwardMethods.class;
}
return setupMetadata(methods);
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();