mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-13 15:16:50 +01:00
Update stats
This commit is contained in:
parent
27230d5148
commit
06ce2d0e02
@ -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
|
||||
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.
|
||||
WitherSkull: true
|
||||
WitherSkull: true
|
140
pom.xml
140
pom.xml
@ -1,80 +1,80 @@
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>LibsDisguises</artifactId>
|
||||
<version>9.4.0-SNAPSHOT</version>
|
||||
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>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>LibsDisguises</artifactId>
|
||||
<version>9.4.0-SNAPSHOT</version>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<directory>target</directory>
|
||||
<finalName>LibsDisguises</finalName>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<directory>target</directory>
|
||||
<finalName>LibsDisguises</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${project.basedir}</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>config.yml</include>
|
||||
<include>disguises.yml</include>
|
||||
<include>README.md</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${project.basedir}</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>config.yml</include>
|
||||
<include>disguises.yml</include>
|
||||
<include>README.md</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<properties>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-pre6-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12-pre6-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-pre6-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12-pre6-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>http://repo.dmulloy2.net/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>md_5-releases</id>
|
||||
<url>https://repo.md-5.net/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>http://repo.dmulloy2.net/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>md_5-releases</id>
|
||||
<url>https://repo.md-5.net/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>md_5-releases</id>
|
||||
<url>https://repo.md-5.net/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>md_5-snapshots</id>
|
||||
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>md_5-releases</id>
|
||||
<url>https://repo.md-5.net/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>md_5-snapshots</id>
|
||||
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
@ -256,6 +256,7 @@ public class DisguiseAPI {
|
||||
for (String observer : ((TargetedDisguise) disguise).getObservers()) {
|
||||
((TargetedDisguise) disguise).removePlayer(observer);
|
||||
}
|
||||
|
||||
disguiseEntity(entity, disguise);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -156,7 +157,8 @@ public class DisguiseConfig {
|
||||
setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible"));
|
||||
setModifyBoundingBox(config.getBoolean("ModifyBoundingBox"));
|
||||
setMonstersIgnoreDisguises(config.getBoolean("MonstersIgnoreDisguises"));
|
||||
setDisguiseBlownWhenAttacking(config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacking")));
|
||||
setDisguiseBlownWhenAttacking(
|
||||
config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacking")));
|
||||
setDisguiseBlownWhenAttacked(config.getBoolean("BlowDisguisesWhenAttacked"));
|
||||
setKeepDisguiseOnPlayerDeath(config.getBoolean("KeepDisguises.PlayerDeath"));
|
||||
setMiscDisguisesForLivingEnabled(config.getBoolean("MiscDisguisesForLiving"));
|
||||
@ -186,6 +188,10 @@ public class DisguiseConfig {
|
||||
setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities"));
|
||||
setUseTranslations(config.getBoolean("Translations"));
|
||||
|
||||
if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) {
|
||||
System.out.println("[LibsDisguises] You must purchase the plugin to use saved disguises!");
|
||||
}
|
||||
|
||||
try {
|
||||
String option = config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name())
|
||||
.toUpperCase();
|
||||
|
@ -8,10 +8,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException;
|
||||
@ -111,6 +108,8 @@ public class DisguiseListener implements Listener {
|
||||
if (disguises.length <= 0)
|
||||
continue;
|
||||
|
||||
DisguiseUtilities.resetPluginTimer();
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.setEntity(entity);
|
||||
disguise.startDisguise();
|
||||
@ -248,6 +247,8 @@ public class DisguiseListener implements Listener {
|
||||
if (disguises.length <= 0)
|
||||
continue;
|
||||
|
||||
DisguiseUtilities.resetPluginTimer();
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.setEntity(entity);
|
||||
disguise.startDisguise();
|
||||
@ -266,6 +267,8 @@ public class DisguiseListener implements Listener {
|
||||
if (disguises.length <= 0)
|
||||
continue;
|
||||
|
||||
DisguiseUtilities.resetPluginTimer();
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.setEntity(entity);
|
||||
disguise.startDisguise();
|
||||
@ -297,6 +300,10 @@ public class DisguiseListener implements Listener {
|
||||
if (DisguiseConfig.isSavePlayerDisguises()) {
|
||||
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(p.getUniqueId(), true);
|
||||
|
||||
if (disguises.length > 0) {
|
||||
DisguiseUtilities.resetPluginTimer();
|
||||
}
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.setEntity(p);
|
||||
disguise.startDisguise();
|
||||
@ -311,26 +318,6 @@ public class DisguiseListener implements Listener {
|
||||
if (!targetedDisguise.canSee(p))
|
||||
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))
|
||||
continue;
|
||||
|
||||
|
@ -1,48 +1,24 @@
|
||||
package me.libraryaddict.disguise;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import me.libraryaddict.disguise.commands.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||
import me.libraryaddict.disguise.utilities.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Ageable;
|
||||
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.entity.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
|
||||
import me.libraryaddict.disguise.commands.DisguiseCloneCommand;
|
||||
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;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class LibsDisguises extends JavaPlugin {
|
||||
private static LibsDisguises instance;
|
||||
@ -50,16 +26,6 @@ public class LibsDisguises extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
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;
|
||||
saveDefaultConfig();
|
||||
|
||||
@ -100,13 +66,114 @@ public class LibsDisguises extends JavaPlugin {
|
||||
registerCommand("disguisemodifyradius",
|
||||
new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
|
||||
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// Don't print error
|
||||
}
|
||||
infectWithMetrics();
|
||||
}
|
||||
|
||||
private void infectWithMetrics() {
|
||||
Metrics metrics = new Metrics(this);
|
||||
|
||||
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
|
||||
|
@ -71,8 +71,6 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Seems I do this method so I can make cleaner constructors on disguises..
|
||||
*
|
||||
* @param newType The disguise
|
||||
*/
|
||||
protected void createDisguise() {
|
||||
if (getType().getEntityType() == null) {
|
||||
@ -234,7 +232,8 @@ public abstract class Disguise {
|
||||
|
||||
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();
|
||||
blockY = loc.getBlockY();
|
||||
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 statement.
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -268,7 +268,8 @@ public abstract class Disguise {
|
||||
if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) {
|
||||
PacketContainer lookPacket = null;
|
||||
|
||||
if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) {
|
||||
if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig
|
||||
.isWitherSkullPacketsEnabled()) {
|
||||
lookPacket = new PacketContainer(Server.ENTITY_LOOK);
|
||||
|
||||
StructureModifier<Object> mods = lookPacket.getModifier();
|
||||
@ -277,8 +278,8 @@ public abstract class Disguise {
|
||||
|
||||
mods.write(4, PacketsManager.getYaw(getType(), getEntity().getType(),
|
||||
(byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
|
||||
mods.write(5,
|
||||
PacketsManager.getPitch(getType(), DisguiseType.getType(getEntity().getType()),
|
||||
mods.write(5, PacketsManager
|
||||
.getPitch(getType(), DisguiseType.getType(getEntity().getType()),
|
||||
(byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
|
||||
|
||||
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
|
||||
@ -287,8 +288,8 @@ public abstract class Disguise {
|
||||
selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
|
||||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(),
|
||||
selfLookPacket, false);
|
||||
ProtocolLibrary.getProtocolManager()
|
||||
.sendServerPacket((Player) getEntity(), selfLookPacket, false);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
@ -319,12 +320,12 @@ public abstract class Disguise {
|
||||
(int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D));
|
||||
|
||||
if (lookPacket != null && player != getEntity()) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket,
|
||||
false);
|
||||
ProtocolLibrary.getProtocolManager()
|
||||
.sendServerPacket(player, lookPacket, false);
|
||||
}
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player,
|
||||
velocityPacket.shallowClone(), false);
|
||||
ProtocolLibrary.getProtocolManager()
|
||||
.sendServerPacket(player, velocityPacket.shallowClone(), false);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -348,8 +349,8 @@ public abstract class Disguise {
|
||||
selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId());
|
||||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(),
|
||||
selfPacket, false);
|
||||
ProtocolLibrary.getProtocolManager()
|
||||
.sendServerPacket((Player) getEntity(), selfPacket, false);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
@ -683,8 +684,8 @@ public abstract class Disguise {
|
||||
*/
|
||||
private void setupWatcher() {
|
||||
ArrayList<MetaIndex> disguiseFlags = MetaIndex.getFlags(getType().getWatcherClass());
|
||||
ArrayList<MetaIndex> entityFlags = MetaIndex.getFlags(
|
||||
DisguiseType.getType(getEntity().getType()).getWatcherClass());
|
||||
ArrayList<MetaIndex> entityFlags = MetaIndex
|
||||
.getFlags(DisguiseType.getType(getEntity().getType()).getWatcherClass());
|
||||
|
||||
for (MetaIndex flag : entityFlags) {
|
||||
if (disguiseFlags.contains(flag))
|
||||
@ -736,7 +737,8 @@ public abstract class Disguise {
|
||||
public Disguise setWatcher(FlagWatcher newWatcher) {
|
||||
if (!getType().getWatcherClass().isInstance(newWatcher)) {
|
||||
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;
|
||||
@ -749,78 +751,47 @@ public abstract class Disguise {
|
||||
}
|
||||
|
||||
public boolean startDisguise() {
|
||||
if (!isDisguiseInUse()) {
|
||||
if (getEntity() == null) {
|
||||
throw new RuntimeException("No entity is assigned to this disguise!");
|
||||
}
|
||||
if (isDisguiseInUse()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fire a disguise event
|
||||
DisguiseEvent event = new DisguiseEvent(entity, this);
|
||||
if (getEntity() == null) {
|
||||
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.
|
||||
// Just return.
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
// Fire a disguise event
|
||||
DisguiseEvent event = new DisguiseEvent(entity, this);
|
||||
|
||||
disguiseInUse = true;
|
||||
Bukkit.getPluginManager().
|
||||
callEvent(event);
|
||||
|
||||
if (velocityRunnable == null) {
|
||||
createRunnable();
|
||||
}
|
||||
// If they cancelled this disguise event. No idea why.
|
||||
// Just return.
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1);
|
||||
disguiseInUse = true;
|
||||
|
||||
if (this instanceof PlayerDisguise) {
|
||||
PlayerDisguise disguise = (PlayerDisguise) this;
|
||||
if (velocityRunnable == null) {
|
||||
createRunnable();
|
||||
}
|
||||
|
||||
if (disguise.isDisplayedInTab()) {
|
||||
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()))));
|
||||
task = Bukkit.getScheduler().
|
||||
|
||||
try {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!((TargetedDisguise) this).canSee(player))
|
||||
continue;
|
||||
runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1);
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this instanceof PlayerDisguise) {
|
||||
PlayerDisguise disguise = (PlayerDisguise) this;
|
||||
|
||||
// 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) {
|
||||
if (disguise.isDisplayedInTab()) {
|
||||
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(
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||
NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(""))));
|
||||
new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL,
|
||||
WrappedChatComponent.fromText(disguise.getName()))));
|
||||
|
||||
try {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
@ -834,14 +805,51 @@ public abstract class Disguise {
|
||||
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() {
|
||||
return removeDisguise();
|
||||
}
|
||||
}
|
||||
}
|
@ -453,6 +453,10 @@ public class DisguiseParser {
|
||||
*/
|
||||
public static Disguise parseDisguise(CommandSender sender, String permNode, String[] args,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permissionMap) throws DisguiseParseException, IllegalAccessException, InvocationTargetException {
|
||||
if (sender instanceof Player) {
|
||||
DisguiseUtilities.setCommandsUsed();
|
||||
}
|
||||
|
||||
if (permissionMap.isEmpty()) {
|
||||
throw new DisguiseParseException(LibsMsg.NO_PERM);
|
||||
}
|
||||
|
@ -74,6 +74,33 @@ public class DisguiseUtilities {
|
||||
"plugins/LibsDisguises/SavedDisguises");
|
||||
private static Gson gson;
|
||||
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() {
|
||||
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();
|
||||
}
|
||||
|
||||
if (!LibsPremium.isPremium() && DisguiseConfig.isUseTranslations()) {
|
||||
System.out.println("[LibsDisguises] You must purchase the plugin to use translations!");
|
||||
}
|
||||
|
||||
TranslateFiller.fillConfigs();
|
||||
}
|
||||
|
||||
|
@ -15,14 +15,18 @@ public class BackwardsSupport {
|
||||
public static BackwardMethods getMethods() {
|
||||
try {
|
||||
String version = ReflectionManager.getBukkitVersion();
|
||||
Class<? extends BackwardMethods> methods = BackwardMethods.class;
|
||||
|
||||
if (LibsPremium.isPremium()) {
|
||||
if (version.equals("v1_11_R1")) {
|
||||
return setupMetadata(Version_1_11.class);
|
||||
}
|
||||
if (version.equals("v1_11_R1")) {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user