Update stats
This commit is contained in:
parent
27230d5148
commit
06ce2d0e02
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void infectWithMetrics() {
|
||||||
Metrics metrics = new Metrics(this);
|
Metrics metrics = new Metrics(this);
|
||||||
metrics.start();
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
});
|
||||||
// Don't print error
|
|
||||||
|
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
|
||||||
|
@ -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,15 +751,21 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean startDisguise() {
|
public boolean startDisguise() {
|
||||||
if (!isDisguiseInUse()) {
|
if (isDisguiseInUse()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (getEntity() == null) {
|
if (getEntity() == null) {
|
||||||
throw new RuntimeException("No entity is assigned to this disguise!");
|
throw new RuntimeException("No entity is assigned to this disguise!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisguiseUtilities.setPluginsUsed();
|
||||||
|
|
||||||
// Fire a disguise event
|
// Fire a disguise event
|
||||||
DisguiseEvent event = new DisguiseEvent(entity, this);
|
DisguiseEvent event = new DisguiseEvent(entity, this);
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().
|
||||||
|
callEvent(event);
|
||||||
|
|
||||||
// If they cancelled this disguise event. No idea why.
|
// If they cancelled this disguise event. No idea why.
|
||||||
// Just return.
|
// Just return.
|
||||||
@ -771,7 +779,9 @@ public abstract class Disguise {
|
|||||||
createRunnable();
|
createRunnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1);
|
task = Bukkit.getScheduler().
|
||||||
|
|
||||||
|
runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1);
|
||||||
|
|
||||||
if (this instanceof PlayerDisguise) {
|
if (this instanceof PlayerDisguise) {
|
||||||
PlayerDisguise disguise = (PlayerDisguise) this;
|
PlayerDisguise disguise = (PlayerDisguise) this;
|
||||||
@ -808,7 +818,8 @@ public abstract class Disguise {
|
|||||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
|
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
|
||||||
|
|
||||||
// If he is a player, then self disguise himself
|
// If he is a player, then self disguise himself
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() {
|
Bukkit.getScheduler().
|
||||||
|
scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DisguiseUtilities.setupFakeDisguise(Disguise.this);
|
DisguiseUtilities.setupFakeDisguise(Disguise.this);
|
||||||
@ -838,9 +849,6 @@ public abstract class Disguise {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean stopDisguise() {
|
public boolean stopDisguise() {
|
||||||
return removeDisguise();
|
return removeDisguise();
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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")) {
|
||||||
return setupMetadata(Version_1_11.class);
|
methods = 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();
|
||||||
|
Loading…
Reference in New Issue
Block a user