Fix imports, run code formatter

This commit is contained in:
libraryaddict 2022-02-02 20:16:24 +13:00
parent 7c0eb550e7
commit e0bbcbd43e
164 changed files with 1494 additions and 1527 deletions

View File

@ -3,13 +3,6 @@ package me.libraryaddict.disguise;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
@ -36,6 +29,14 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public class DisguiseAPI {
private static int selfDisguiseId;
private static int entityAttachmentId;

View File

@ -1,17 +1,5 @@
package me.libraryaddict.disguise;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
@ -41,6 +29,19 @@ import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.scheduler.BukkitTask;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class DisguiseConfig {
@Getter
@Setter
@ -738,8 +739,9 @@ public class DisguiseConfig {
ArrayList<String> returns = doOutput(config, changed, verbose);
if (!returns.isEmpty()) {
DisguiseUtilities.getLogger().info("This is not an error! Now outputting " + (verbose ? "missing " : "") +
(changed ? (verbose ? "and " : "") + "changed/invalid " : "") + "config values");
DisguiseUtilities.getLogger().info(
"This is not an error! Now outputting " + (verbose ? "missing " : "") + (changed ? (verbose ? "and " : "") + "changed/invalid " : "") +
"config values");
for (String v : returns) {
DisguiseUtilities.getLogger().info(v);
@ -829,8 +831,8 @@ public class DisguiseConfig {
continue;
}
ModdedManager
.registerModdedEntity(new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)), entity, register);
ModdedManager.registerModdedEntity(new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)), entity,
register);
DisguiseUtilities.getLogger().info("Modded entity " + name + " has been " + (register ? "registered" : "added"));
} catch (Exception ex) {

View File

@ -1,10 +1,5 @@
package me.libraryaddict.disguise;
import java.io.File;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.Getter;
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
@ -53,6 +48,12 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.stream.Collectors;
public class LibsDisguises extends JavaPlugin {
private static LibsDisguises instance;
private DisguiseListener listener;
@ -94,8 +95,8 @@ public class LibsDisguises extends JavaPlugin {
}
} catch (Exception e) {
getLogger().severe(
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" +
" can " + "join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" + " can " +
"join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
e.printStackTrace();
}

View File

@ -3,16 +3,6 @@ package me.libraryaddict.disguise.commands;
import com.comphenix.protocol.ProtocolLibrary;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
import me.libraryaddict.disguise.commands.disguise.DisguiseEntityCommand;
@ -40,6 +30,17 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
* @author libraryaddict
*/

View File

@ -1,9 +1,5 @@
package me.libraryaddict.disguise.commands;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import lombok.Getter;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.commands.libsdisguises.LDChangelog;
@ -30,6 +26,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
@Getter
private final ArrayList<LDCommand> commands = new ArrayList<>();
@ -53,8 +54,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
}
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
if (origArgs.length == 0)
if (origArgs.length == 0) {
return list;
}
Iterator<String> itel = list.iterator();
String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
@ -62,8 +64,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
while (itel.hasNext()) {
String name = itel.next();
if (name.toLowerCase(Locale.ENGLISH).startsWith(label))
if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) {
continue;
}
itel.remove();
}
@ -77,8 +80,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
for (int i = 0; i < args.length - 1; i++) {
String s = args[i];
if (s.trim().isEmpty())
if (s.trim().isEmpty()) {
continue;
}
newArgs.add(s);
}
@ -107,9 +111,8 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
" by libraryaddict, formerly maintained by Byteflux and NavidK0.");
if (sender.hasPermission("libsdisguises.reload")) {
sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" +
ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" +
".");
sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" + ChatColor.DARK_GREEN +
" to reload the config. All disguises will be blown by doing this" + ".");
sender.sendMessage(ChatColor.DARK_GREEN + "Use /libsdisguises help to see more help");
}

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.disguise;
import java.util.ArrayList;
import java.util.List;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
@ -19,6 +17,9 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
@ -43,8 +44,8 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
Disguise disguise;
try {
disguise = DisguiseParser
.parseDisguise(sender, (Entity) sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")), getPermissions(sender));
disguise = DisguiseParser.parseDisguise(sender, (Entity) sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")),
getPermissions(sender));
} catch (DisguiseParseException ex) {
ex.send(sender);
@ -68,7 +69,8 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
if (!setViewDisguise(args)) {
// They prefer to have the opposite of whatever the view disguises option is
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
}
}

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.disguise;
import java.util.ArrayList;
import java.util.List;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
@ -18,6 +16,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

View File

@ -1,8 +1,5 @@
package me.libraryaddict.disguise.commands.disguise;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
@ -22,6 +19,10 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
@ -106,7 +107,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
if (!setViewDisguise(args)) {
// They prefer to have the opposite of whatever the view disguises option is
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
}
}
@ -121,9 +123,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
LibsMsg.DISG_PLAYER_AS_DISG.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(),
disguise.getDisguiseName());
} else {
LibsMsg.DISG_PLAYER_AS_DISG_FAIL
.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(),
disguise.getDisguiseName());
LibsMsg.DISG_PLAYER_AS_DISG_FAIL.send(sender,
entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName());
}
return true;

View File

@ -1,9 +1,5 @@
package me.libraryaddict.disguise.commands.disguise;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
@ -27,6 +23,11 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
private ArrayList<Class<? extends Entity>> validClasses = new ArrayList<>();
@ -188,7 +189,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
if (!setViewDisguise(args)) {
// They prefer to have the opposite of whatever the view disguises option is
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
}
}

View File

@ -26,12 +26,10 @@ public class CopyDisguiseInteraction implements LibsEntityInteract {
Disguise disguise = DisguiseAPI.getDisguise(player, entity);
String disguiseString = DisguiseParser.parseToString(disguise, false);
getCopyDisguiseCommand()
.sendMessage(player, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false);
getCopyDisguiseCommand().sendMessage(player, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false);
if (disguise instanceof PlayerDisguise) {
getCopyDisguiseCommand()
.sendMessage(player, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY,
getCopyDisguiseCommand().sendMessage(player, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY,
DisguiseParser.parseToString(disguise), true);
}
} else {

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.interactions;
import java.util.ArrayList;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise;
@ -15,6 +13,9 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Created by libraryaddict on 4/04/2020.
*/

View File

@ -24,15 +24,17 @@ public class UndisguiseEntityInteraction implements LibsEntityInteract {
if (DisguiseAPI.isDisguised(entity)) {
DisguiseAPI.undisguiseToAll(p, entity);
if (entity instanceof Player)
if (entity instanceof Player) {
LibsMsg.LISTEN_UNDISG_PLAYER.send(p, entityName);
else
LibsMsg.LISTEN_UNDISG_ENT.send(p, entityName);
} else {
if (entity instanceof Player)
LibsMsg.LISTEN_UNDISG_ENT.send(p, entityName);
}
} else {
if (entity instanceof Player) {
LibsMsg.LISTEN_UNDISG_PLAYER_FAIL.send(p, entityName);
else
} else {
LibsMsg.LISTEN_UNDISG_ENT_FAIL.send(p, entityName);
}
}
}
}

View File

@ -1,13 +1,14 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.Collections;
import java.util.List;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.updates.UpdateChecker;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.Collections;
import java.util.List;
/**
* Created by libraryaddict on 27/04/2020.
*/
@ -43,8 +44,7 @@ public class LDChangelog implements LDCommand {
if (!checker.getUpdate().isReleaseBuild()) {
sender.sendMessage(
ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") +
LibsDisguises.getInstance().getBuildNo());
ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") + LibsDisguises.getInstance().getBuildNo());
}
for (String msg : checker.getUpdate().getChangelog()) {

View File

@ -1,9 +1,10 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.List;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.command.CommandSender;
import java.util.List;
/**
* Created by libraryaddict on 20/04/2020.
*/

View File

@ -1,13 +1,14 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by libraryaddict on 20/04/2020.
*/

View File

@ -1,10 +1,5 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
@ -13,6 +8,12 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.translations.TranslateType;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
/**
* Created by libraryaddict on 20/04/2020.
*/
@ -40,18 +41,16 @@ public class LDCount implements LDCommand {
if (counts.isEmpty()) {
LibsMsg.NO_DISGUISES_IN_USE.send(sender);
} else {
LibsMsg.ACTIVE_DISGUISES_COUNT.send(sender,
counts.values().stream().reduce(Integer::sum).get());
LibsMsg.ACTIVE_DISGUISES_COUNT.send(sender, counts.values().stream().reduce(Integer::sum).get());
ArrayList<DisguiseType> types = new ArrayList<>(counts.keySet());
types.sort((d1, d2) -> String.CASE_INSENSITIVE_ORDER.compare(TranslateType.DISGUISES.get(d1.toReadable()),
TranslateType.DISGUISES.get(d2.toReadable())));
types.sort(
(d1, d2) -> String.CASE_INSENSITIVE_ORDER.compare(TranslateType.DISGUISES.get(d1.toReadable()), TranslateType.DISGUISES.get(d2.toReadable())));
StringBuilder builder = new StringBuilder();
for (int i = 0; i < types.size(); i++) {
builder.append(LibsMsg.ACTIVE_DISGUISES_DISGUISE
.get(TranslateType.DISGUISES.get(types.get(i).toReadable()), counts.get(types.get(i))));
builder.append(LibsMsg.ACTIVE_DISGUISES_DISGUISE.get(TranslateType.DISGUISES.get(types.get(i).toReadable()), counts.get(types.get(i))));
if (i + 1 < types.size()) {
builder.append(LibsMsg.ACTIVE_DISGUISES_SEPERATOR.get());

View File

@ -1,12 +1,13 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.Collections;
import java.util.List;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.mineskin.MineSkinAPI;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.command.CommandSender;
import java.util.Collections;
import java.util.List;
/**
* Created by libraryaddict on 22/05/2021.
*/

View File

@ -1,8 +1,6 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import com.google.gson.Gson;
import java.util.Collections;
import java.util.List;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
@ -18,6 +16,9 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;
import java.util.Collections;
import java.util.List;
/**
* Created by libraryaddict on 24/04/2020.
*/
@ -49,18 +50,14 @@ public class LDDebugPlayer implements LDCommand {
DisguiseUtilities.DScoreTeam name = disg.getScoreboardName();
player.sendMessage(ChatColor.RED +
String.format("Prefix: '%s', Suffix: '%s', Disguise Name: '%s', Team '%s'",
name.getPrefix().replace(ChatColor.COLOR_CHAR, '&'),
name.getSuffix().replace(ChatColor.COLOR_CHAR, '&'),
name.getPlayer().replace(ChatColor.COLOR_CHAR, '&'), name.getTeamName()));
String.format("Prefix: '%s', Suffix: '%s', Disguise Name: '%s', Team '%s'", name.getPrefix().replace(ChatColor.COLOR_CHAR, '&'),
name.getSuffix().replace(ChatColor.COLOR_CHAR, '&'), name.getPlayer().replace(ChatColor.COLOR_CHAR, '&'), name.getTeamName()));
if (DisguiseConfig.isArmorstandsName()) {
player.sendMessage(
ChatColor.AQUA + "Oh! You're using armorstands! Lets give some debug for that too..");
player.sendMessage(ChatColor.RED + String.format("Names: %s, Length: %s, Custom Name: '%s'",
new Gson().toJson(disg.getMultiName()).replace(ChatColor.COLOR_CHAR, '&'),
disg.getMultiNameLength(),
disg.getWatcher().getCustomName().replace(ChatColor.COLOR_CHAR, '&')));
player.sendMessage(ChatColor.AQUA + "Oh! You're using armorstands! Lets give some debug for that too..");
player.sendMessage(ChatColor.RED +
String.format("Names: %s, Length: %s, Custom Name: '%s'", new Gson().toJson(disg.getMultiName()).replace(ChatColor.COLOR_CHAR, '&'),
disg.getMultiNameLength(), disg.getWatcher().getCustomName().replace(ChatColor.COLOR_CHAR, '&')));
}
Team team = player.getScoreboard().getTeam(name.getTeamName());
@ -75,9 +72,8 @@ public class LDDebugPlayer implements LDCommand {
}
player.sendMessage(ChatColor.RED +
String.format("Prefix Matches: %s, Suffix Matches: %s, In Team: %s, Name Visibility: %s",
team.getPrefix().equals(name.getPrefix()), team.getSuffix().equals(name.getSuffix()),
team.hasEntry(name.getPlayer()), team.getOption(Team.Option.NAME_TAG_VISIBILITY)));
String.format("Prefix Matches: %s, Suffix Matches: %s, In Team: %s, Name Visibility: %s", team.getPrefix().equals(name.getPrefix()),
team.getSuffix().equals(name.getSuffix()), team.hasEntry(name.getPlayer()), team.getOption(Team.Option.NAME_TAG_VISIBILITY)));
}
}

View File

@ -1,13 +1,14 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.Collections;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.command.CommandSender;
import java.util.Collections;
import java.util.List;
/**
* Created by libraryaddict on 22/04/2020.
*/

View File

@ -1,9 +1,6 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
@ -17,6 +14,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by libraryaddict on 20/04/2020.
*/
@ -114,8 +115,7 @@ public class LDJson implements LDCommand {
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub));
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append((string.length() <= 256 ? "" : " " + msg))
.create()));
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append((string.length() <= 256 ? "" : " " + msg)).create()));
msg += 1;
}

View File

@ -1,9 +1,5 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import net.md_5.bungee.api.chat.ClickEvent;
@ -12,6 +8,11 @@ import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* Created by libraryaddict on 20/04/2020.
*/

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.Collections;
import java.util.List;
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils;
@ -9,6 +7,9 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.List;
/**
* Created by libraryaddict on 20/04/2020.
*/
@ -51,8 +52,7 @@ public class LDMods implements LDCommand {
return;
}
LibsMsg.MODS_LIST.send(sender, player.getName(),
StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", "));
LibsMsg.MODS_LIST.send(sender, player.getName(), StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", "));
}
@Override

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.Arrays;
import java.util.List;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.LibsPremium;
@ -13,6 +11,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.permissions.Permissible;
import java.util.Arrays;
import java.util.List;
/**
* Created by libraryaddict on 20/04/2020.
*/
@ -65,8 +66,7 @@ public class LDPermTest implements LDCommand {
LibsMsg.NORMAL_PERM_CHECK_FAIL.send(sender);
}
if (player.hasPermission("libsdisguises.disguise.zombie") ||
permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.ZOMBIE))) {
if (player.hasPermission("libsdisguises.disguise.zombie") || permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.ZOMBIE))) {
LibsMsg.LIBS_PERM_CHECK_ZOMBIE_PERMISSIONS.send(sender);
}

View File

@ -1,12 +1,13 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.Collections;
import java.util.List;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.utilities.sounds.SoundManager;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.command.CommandSender;
import java.util.Collections;
import java.util.List;
/**
* Created by libraryaddict on 20/04/2020.
*/

View File

@ -3,11 +3,6 @@ package me.libraryaddict.disguise.commands.libsdisguises;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
@ -27,6 +22,12 @@ import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Created by libraryaddict on 20/04/2020.
*/
@ -78,7 +79,6 @@ public class LDScoreboard implements LDCommand {
checked.add(board);
Team team = board.getTeam(scoreboardName.getTeamName());
if (team == null) {
@ -125,8 +125,8 @@ public class LDScoreboard implements LDCommand {
LibsMsg.LIBS_SCOREBOARD_NAMES_DISABLED.send(sender);
}
List<PacketListener> listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream()
.filter(listener -> listener.getPlugin() != LibsDisguises.getInstance() &&
List<PacketListener> listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream().filter(
listener -> listener.getPlugin() != LibsDisguises.getInstance() &&
listener.getSendingWhitelist().getTypes().contains(PacketType.Play.Server.SCOREBOARD_TEAM)).collect(Collectors.toList());
if (!listeners.isEmpty()) {
@ -149,8 +149,8 @@ public class LDScoreboard implements LDCommand {
builder.append(listener.getPlugin().getName());
builder.color(net.md_5.bungee.api.ChatColor.AQUA);
String plugin = ChatColor.GOLD + "Plugin: " + ChatColor.YELLOW + listener.getPlugin().getName() + " v" +
listener.getPlugin().getDescription().getVersion();
String plugin =
ChatColor.GOLD + "Plugin: " + ChatColor.YELLOW + listener.getPlugin().getName() + " v" + listener.getPlugin().getDescription().getVersion();
String listenerClass = ChatColor.GOLD + "Listener: " + ChatColor.YELLOW + listener.getClass().toString();
String packets = ChatColor.GOLD + "Packets: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getTypes(), ", ");
String priority = ChatColor.GOLD + "Priority: " + ChatColor.YELLOW + listener.getSendingWhitelist().getPriority();
@ -165,8 +165,8 @@ public class LDScoreboard implements LDCommand {
LibsMsg.LIBS_SCOREBOARD_IGNORE_TEST.send(sender);
sender.sendMessage(ChatColor.RED +
"This command is somewhat outdated and needs to be changed, pushing is now disabled on the entities themselves and not players");
sender.sendMessage(
ChatColor.RED + "This command is somewhat outdated and needs to be changed, pushing is now disabled on the entities themselves and not players");
Player player;

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.util.Arrays;
import java.util.List;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
@ -12,6 +10,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.Arrays;
import java.util.List;
/**
* Created by libraryaddict on 20/04/2020.
*/

View File

@ -1,9 +1,5 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
@ -11,6 +7,11 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Created by libraryaddict on 30/06/2020.
*/

View File

@ -1,5 +1,18 @@
package me.libraryaddict.disguise.commands.libsdisguises;
import javax.net.ssl.HttpsURLConnection;
import lombok.Data;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.config.ConfigLoader;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
@ -15,18 +28,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.net.ssl.HttpsURLConnection;
import lombok.Data;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.config.ConfigLoader;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
/**
* Created by libraryaddict on 18/06/2020.
@ -230,8 +231,8 @@ public class LDUploadLogs implements LDCommand {
sender.sendMessage(ChatColor.GOLD + "Click on the below message to have it appear in your chat input");
}
String text = "My log file: " + latestPaste + ", my combined config files: " + configPaste + " and my disguises file: " +
disguisesPaste;
String text =
"My log file: " + latestPaste + ", my combined config files: " + configPaste + " and my disguises file: " + disguisesPaste;
ComponentBuilder builder = new ComponentBuilder("");
builder.append(text);

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.modify;
import java.util.ArrayList;
import java.util.List;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
import me.libraryaddict.disguise.disguisetypes.Disguise;
@ -18,6 +16,9 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
@ -57,15 +58,12 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
options = DisguiseParser.parsePlaceholders(options, sender, sender);
try {
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
"DisguiseModify");
}
catch (DisguiseParseException ex) {
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, "DisguiseModify");
} catch (DisguiseParseException ex) {
ex.send(sender);
return true;
}
catch (Throwable ex) {
} catch (Throwable ex) {
ex.printStackTrace();
return true;
}
@ -77,13 +75,15 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
if (!(sender instanceof Player))
if (!(sender instanceof Player)) {
return new ArrayList<>();
}
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
if (disguise == null)
if (disguise == null) {
return new ArrayList<>();
}
String[] args = getPreviousArgs(origArgs);
@ -105,7 +105,6 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
LibsMsg.DMODIFY_HELP1.send(sender);
LibsMsg.DMODIFY_HELP2.send(sender);
LibsMsg.DMODIFY_HELP3.send(sender,
StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
}
}

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.modify;
import java.util.ArrayList;
import java.util.List;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
@ -16,6 +14,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
@ -39,8 +40,8 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
// TODO Validate if any disguises have this arg
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(),
new DisguiseModifyInteraction(DisguiseUtilities.split(StringUtils.join(args, " "))),
LibsDisguises.getInstance().getListener()
.addInteraction(sender.getName(), new DisguiseModifyInteraction(DisguiseUtilities.split(StringUtils.join(args, " "))),
DisguiseConfig.getDisguiseEntityExpire());
LibsMsg.DMODIFYENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire());
@ -78,7 +79,6 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
LibsMsg.DMODENT_HELP1.send(sender);
LibsMsg.DMODIFY_HELP3.send(sender,
StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
}
}

View File

@ -1,8 +1,5 @@
package me.libraryaddict.disguise.commands.modify;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
import me.libraryaddict.disguise.disguisetypes.Disguise;
@ -20,6 +17,10 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
@ -42,8 +43,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
if (args[0].contains("-")) {
try {
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
}
catch (Exception ignored) {
} catch (Exception ignored) {
}
}
}
@ -63,11 +63,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
Disguise disguise = null;
if (sender instanceof Player)
if (sender instanceof Player) {
disguise = DisguiseAPI.getDisguise((Player) sender, entityTarget);
}
if (disguise == null)
if (disguise == null) {
disguise = DisguiseAPI.getDisguise(entityTarget);
}
if (disguise == null) {
LibsMsg.DMODPLAYER_NODISGUISE.send(sender, entityTarget.getName());
@ -86,15 +88,11 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
options = DisguiseParser.parsePlaceholders(options, sender, entityTarget);
try {
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
"DisguiseModifyPlayer");
}
catch (DisguiseParseException ex) {
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, "DisguiseModifyPlayer");
} catch (DisguiseParseException ex) {
ex.send(sender);
return true;
}
catch (Throwable ex) {
} catch (Throwable ex) {
ex.printStackTrace();
return true;
}
@ -133,11 +131,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
Disguise disguise = null;
if (sender instanceof Player)
if (sender instanceof Player) {
disguise = DisguiseAPI.getDisguise((Player) sender, player);
}
if (disguise == null)
if (disguise == null) {
disguise = DisguiseAPI.getDisguise(player);
}
if (disguise == null) {
return tabs;
@ -159,7 +159,6 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
LibsMsg.DMODPLAYER_HELP1.send(sender);
LibsMsg.DMODIFY_HELP3.send(sender,
StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
}
}

View File

@ -1,10 +1,5 @@
package me.libraryaddict.disguise.commands.modify;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
@ -29,6 +24,12 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
private Collection<Entity> getNearbyEntities(CommandSender sender, int radius) {
Location center;

View File

@ -16,7 +16,9 @@ public class UndisguiseCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player && !sender.isOp() &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
sender.sendMessage(ChatColor.RED +
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
"usage!");
return true;
}

View File

@ -16,7 +16,9 @@ public class UndisguiseEntityCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player && !sender.isOp() &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
sender.sendMessage(ChatColor.RED +
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
"usage!");
return true;
}
@ -30,8 +32,7 @@ public class UndisguiseEntityCommand implements CommandExecutor {
return true;
}
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new UndisguiseEntityInteraction(),
DisguiseConfig.getDisguiseEntityExpire());
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new UndisguiseEntityInteraction(), DisguiseConfig.getDisguiseEntityExpire());
LibsMsg.UND_ENTITY.send(sender);
return true;

View File

@ -1,10 +1,5 @@
package me.libraryaddict.disguise.commands.undisguise;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.LibsPremium;
@ -18,10 +13,17 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
if (origArgs.length == 0)
if (origArgs.length == 0) {
return list;
}
Iterator<String> itel = list.iterator();
String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
@ -29,8 +31,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
while (itel.hasNext()) {
String name = itel.next();
if (name.toLowerCase(Locale.ENGLISH).startsWith(label))
if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) {
continue;
}
itel.remove();
}
@ -44,8 +47,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
for (int i = 0; i < args.length - 1; i++) {
String s = args[i];
if (s.trim().isEmpty())
if (s.trim().isEmpty()) {
continue;
}
newArgs.add(s);
}
@ -57,7 +61,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player && !sender.isOp() &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
sender.sendMessage(ChatColor.RED +
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
"usage!");
return true;
}
@ -77,8 +83,7 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
if (args[0].contains("-")) {
try {
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
}
catch (Exception ignored) {
} catch (Exception ignored) {
}
}
}
@ -90,13 +95,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
if (DisguiseAPI.isDisguised(entityTarget)) {
DisguiseAPI.undisguiseToAll(sender, entityTarget);
LibsMsg.UNDISG_PLAYER.send(sender,
entityTarget instanceof Player ? entityTarget.getName() :
DisguiseType.getType(entityTarget).toReadable());
LibsMsg.UNDISG_PLAYER.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable());
} else {
LibsMsg.UNDISG_PLAYER_FAIL.send(sender,
entityTarget instanceof Player ? entityTarget.getName() :
DisguiseType.getType(entityTarget).toReadable());
LibsMsg.UNDISG_PLAYER_FAIL.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable());
}
return true;
@ -107,8 +108,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
ArrayList<String> tabs = new ArrayList<>();
String[] args = getArgs(origArgs);
if (args.length != 0)
if (args.length != 0) {
return filterTabs(tabs, origArgs);
}
for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name

View File

@ -18,8 +18,7 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
try {
Integer.parseInt(string);
return true;
}
catch (Exception ex) {
} catch (Exception ex) {
return false;
}
}
@ -28,7 +27,9 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player && !sender.isOp() &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
sender.sendMessage(ChatColor.RED +
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
"usage!");
return true;
}

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.utils;
import java.util.Arrays;
import java.util.UUID;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
@ -23,6 +21,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.UUID;
/**
* Created by libraryaddict on 1/01/2020.
*/

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.commands.utils;
import java.util.ArrayList;
import java.util.List;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
@ -16,6 +14,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
@ -57,8 +58,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
DisguiseUtilities.createClonedDisguise((Player) sender, player, options);
} else {
LibsDisguises.getInstance().getListener()
.addInteraction(sender.getName(), new DisguiseCloneInteraction(options),
DisguiseConfig.getDisguiseCloneExpire());
.addInteraction(sender.getName(), new DisguiseCloneInteraction(options), DisguiseConfig.getDisguiseCloneExpire());
LibsMsg.CLICK_TIMER.send(sender, DisguiseConfig.getDisguiseCloneExpire());
}

View File

@ -1,9 +1,5 @@
package me.libraryaddict.disguise.commands.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
import me.libraryaddict.disguise.utilities.params.ParamInfo;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
@ -19,6 +15,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
@ -47,12 +48,10 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
if (help != null) {
if (help.hasValues() && help.canTranslateValues()) {
LibsMsg.DHELP_HELP4.send(sender, help.getName(),
StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get()));
LibsMsg.DHELP_HELP4.send(sender, help.getName(), StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get()));
} else {
if (!help.getName().equals(help.getDescriptiveName())) {
LibsMsg.DHELP_HELP6
.send(sender, help.getName(), help.getDescriptiveName(), help.getDescription());
LibsMsg.DHELP_HELP6.send(sender, help.getName(), help.getDescriptiveName(), help.getDescription());
} else {
LibsMsg.DHELP_HELP5.send(sender, help.getName(), help.getDescription());
}
@ -80,8 +79,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
try {
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase(
Locale.ENGLISH)))) {
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase(Locale.ENGLISH)))) {
ignored++;
continue;
}
@ -98,13 +96,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
methodColor = ChatColor.GRAY;
}
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" +
ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")";
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info.getName() +
ChatColor.DARK_RED + ")";
methods.add(methodColor + str);
}
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
@ -112,8 +109,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
}
LibsMsg.DHELP_OPTIONS.send(sender, ChatColor.DARK_RED + type.toReadable(),
StringUtils.join(methods, ChatColor.DARK_RED + ", "));
LibsMsg.DHELP_OPTIONS.send(sender, ChatColor.DARK_RED + type.toReadable(), StringUtils.join(methods, ChatColor.DARK_RED + ", "));
if (ignored > 0) {
LibsMsg.NO_PERMS_USE_OPTIONS.send(sender, ignored);
@ -137,8 +133,9 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
if (args.length == 0) {
for (DisguisePerm type : perms.getAllowed()) {
if (type.isUnknown())
if (type.isUnknown()) {
continue;
}
tabs.add(type.toReadable().replaceAll(" ", "_"));
}
@ -163,9 +160,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
LibsMsg.DHELP_HELP2.send(sender);
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
LibsMsg.DHELP_HELP3.send(sender, s.getName().replaceAll(" ", "") +
(!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""),
s.getDescription());
LibsMsg.DHELP_HELP3.send(sender,
s.getName().replaceAll(" ", "") + (!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""), s.getDescription());
}
}
}

View File

@ -1,7 +1,6 @@
package me.libraryaddict.disguise.commands.utils;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import java.lang.reflect.Field;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsPremium;
@ -19,6 +18,8 @@ import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.lang.reflect.Field;
/**
* Created by libraryaddict on 20/06/2020.
*/
@ -27,7 +28,9 @@ public class GrabHeadCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
if (sender instanceof Player && !sender.isOp() &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
sender.sendMessage(ChatColor.RED +
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
"usage!");
return true;
}
@ -93,8 +96,7 @@ public class GrabHeadCommand implements CommandExecutor {
Field field = meta.getClass().getDeclaredField("profile");
field.setAccessible(true);
field.set(meta, profile.getHandle());
}
catch (NoSuchFieldException | IllegalAccessException e) {
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}

View File

@ -1,7 +1,6 @@
package me.libraryaddict.disguise.commands.utils;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import java.util.Arrays;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.Disguise;
@ -20,6 +19,8 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.Arrays;
/**
* Created by libraryaddict on 28/12/2019.
*/

View File

@ -6,27 +6,23 @@ import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public enum AnimalColor {
BLACK(DyeColor.BLACK,
NmsVersion.v1_13.isSupported() ? Material.getMaterial("INK_SAC") : Material.getMaterial("INK_SACK")),
BLACK(DyeColor.BLACK, NmsVersion.v1_13.isSupported() ? Material.getMaterial("INK_SAC") : Material.getMaterial("INK_SACK")),
BLUE(DyeColor.BLUE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LAPIS_LAZULI") : null),
BROWN(DyeColor.BROWN, NmsVersion.v1_13.isSupported() ? Material.getMaterial("COCOA_BEANS") : null),
CYAN(DyeColor.CYAN, NmsVersion.v1_13.isSupported() ? Material.getMaterial("CYAN_DYE") : null),
GRAY(DyeColor.GRAY, NmsVersion.v1_13.isSupported() ? Material.getMaterial("GRAY_DYE") : null),
GREEN(DyeColor.GREEN,
NmsVersion.v1_14.isSupported() ? Material.getMaterial("GREEN_DYE") : Material.getMaterial("CACTUS_GREEN")),
GREEN(DyeColor.GREEN, NmsVersion.v1_14.isSupported() ? Material.getMaterial("GREEN_DYE") : Material.getMaterial("CACTUS_GREEN")),
LIGHT_BLUE(DyeColor.LIGHT_BLUE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_BLUE_DYE") : null),
LIME(DyeColor.LIME, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIME_DYE") : null),
MAGENTA(DyeColor.MAGENTA, NmsVersion.v1_13.isSupported() ? Material.getMaterial("MAGENTA_DYE") : null),
ORANGE(DyeColor.ORANGE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("ORANGE_DYE") : null),
PINK(DyeColor.PINK, NmsVersion.v1_13.isSupported() ? Material.getMaterial("PINK_DYE") : null),
PURPLE(DyeColor.PURPLE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("PURPLE_DYE") : null),
RED(DyeColor.RED,
NmsVersion.v1_14.isSupported() ? Material.getMaterial("RED_DYE") : Material.getMaterial("ROSE_RED")),
RED(DyeColor.RED, NmsVersion.v1_14.isSupported() ? Material.getMaterial("RED_DYE") : Material.getMaterial("ROSE_RED")),
LIGHT_GRAY(DyeColor.valueOf(NmsVersion.v1_13.isSupported() ? "LIGHT_GRAY" : "SILVER"),
NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_GRAY_DYE") : null),
WHITE(DyeColor.WHITE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("BONE_MEAL") : null),
YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") :
Material.getMaterial("DANDELION_YELLOW"));
YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") : Material.getMaterial("DANDELION_YELLOW"));
public static AnimalColor getColorByWool(int woolId) {
for (AnimalColor color : values()) {

View File

@ -7,16 +7,6 @@ import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
@ -54,6 +44,17 @@ import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
public abstract class Disguise {
private transient boolean disguiseInUse;
private DisguiseType disguiseType;
@ -511,8 +512,9 @@ public abstract class Disguise {
@Deprecated
public Disguise setWatcher(FlagWatcher newWatcher) {
if (!getType().getWatcherClass().isInstance(newWatcher)) {
throw new IllegalArgumentException((newWatcher == null ? "null" : newWatcher.getClass().getSimpleName()) + " is not a instance of " +
getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name());
throw new IllegalArgumentException(
(newWatcher == null ? "null" : newWatcher.getClass().getSimpleName()) + " is not a instance of " + getType().getWatcherClass().getSimpleName() +
" for DisguiseType " + getType().name());
}
watcher = newWatcher;
@ -784,8 +786,8 @@ public abstract class Disguise {
}
if (isHidePlayer() && getEntity() instanceof Player && ((Player) getEntity()).isOnline()) {
PlayerInfoData playerInfo = new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
NativeGameMode.fromBukkit(((Player) getEntity()).getGameMode()),
PlayerInfoData playerInfo =
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.fromBukkit(((Player) getEntity()).getGameMode()),
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())));
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);

View File

@ -4,7 +4,6 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import java.lang.reflect.InvocationTargetException;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
@ -17,6 +16,8 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.lang.reflect.InvocationTargetException;
/**
* Created by libraryaddict on 20/05/2021.
*/
@ -183,8 +184,8 @@ class DisguiseRunnable extends BukkitRunnable {
mods.write(4,
DisguiseUtilities.getYaw(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
mods.write(5, DisguiseUtilities
.getPitch(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
mods.write(5,
DisguiseUtilities.getPitch(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
if (disguise.isSelfDisguiseVisible() && disguise.getEntity() instanceof Player) {
PacketContainer selfLookPacket = lookPacket.shallowClone();

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes;
import java.util.Locale;
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
@ -9,6 +8,8 @@ import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import java.util.Locale;
public enum DisguiseType {
AREA_EFFECT_CLOUD(3, 0),

View File

@ -10,14 +10,6 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import com.google.common.base.Strings;
import com.mojang.datafixers.util.Pair;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import lombok.AccessLevel;
import lombok.Getter;
import me.libraryaddict.disguise.DisguiseAPI;
@ -41,6 +33,15 @@ import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
public class FlagWatcher {
private boolean addEntityAnimations = DisguiseConfig.isAddEntityAnimations();
/**

View File

@ -10,16 +10,6 @@ import com.comphenix.protocol.wrappers.WrappedParticle;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import com.comphenix.protocol.wrappers.nbt.NbtType;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.UUID;
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractSkeletonWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractVillagerWatcher;
@ -113,6 +103,17 @@ import org.bukkit.Particle;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.UUID;
public class MetaIndex<Y> {
private static MetaIndex[] _values = new MetaIndex[0];
@ -697,8 +698,8 @@ public class MetaIndex<Y> {
public static MetaIndex<Integer> ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0);
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex<VillagerData> VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0,
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
public static MetaIndex<VillagerData> VILLAGER_DATA =
new MetaIndex<>(VillagerWatcher.class, 0, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
public static MetaIndex<Boolean> WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false);
@ -1002,8 +1003,9 @@ public class MetaIndex<Y> {
continue;
}
DisguiseUtilities.getLogger().severe("MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() +
" has already registered this! (" + metaIndex.getDefault() + "," + index.getDefault() + ")");
DisguiseUtilities.getLogger().severe(
"MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() + " has already registered this! (" +
metaIndex.getDefault() + "," + index.getDefault() + ")");
}
values()[i] = metaIndexes[a];

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes;
import java.security.InvalidParameterException;
import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher;
@ -12,6 +11,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.security.InvalidParameterException;
public class MiscDisguise extends TargetedDisguise {
private int id = -1, data = 0;
@ -27,8 +28,7 @@ public class MiscDisguise extends TargetedDisguise {
super(disguiseType);
if (disguiseType != DisguiseType.FALLING_BLOCK && disguiseType != DisguiseType.DROPPED_ITEM) {
throw new IllegalArgumentException(
"This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
throw new IllegalArgumentException("This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
}
apply(0, itemStack);
@ -38,8 +38,7 @@ public class MiscDisguise extends TargetedDisguise {
super(disguiseType);
if (disguiseType != DisguiseType.FALLING_BLOCK && disguiseType != DisguiseType.DROPPED_ITEM) {
throw new IllegalArgumentException(
"This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
throw new IllegalArgumentException("This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
}
apply(0, new ItemStack(material));
@ -55,9 +54,8 @@ public class MiscDisguise extends TargetedDisguise {
if (!disguiseType.isMisc()) {
throw new InvalidParameterException(
"Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType +
" instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") +
" instead");
"Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType + " instead. Please use " +
(disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") + " instead");
}
apply(id, new ItemStack(Material.STONE));

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes;
import java.security.InvalidParameterException;
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.ArmorStandWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
@ -10,6 +9,8 @@ import me.libraryaddict.disguise.utilities.DisguiseValues;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.security.InvalidParameterException;
public class MobDisguise extends TargetedDisguise {
private boolean isAdult;
@ -22,9 +23,8 @@ public class MobDisguise extends TargetedDisguise {
if (!disguiseType.isMob()) {
throw new InvalidParameterException(
"Expected a living DisguiseType while constructing MobDisguise. Received " + disguiseType +
" instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") +
" instead");
"Expected a living DisguiseType while constructing MobDisguise. Received " + disguiseType + " instead. Please use " +
(disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") + " instead");
}
this.isAdult = isAdult;
@ -46,8 +46,7 @@ public class MobDisguise extends TargetedDisguise {
if (getWatcher() != null) {
if (getType() == DisguiseType.ARMOR_STAND) {
return (((ArmorStandWatcher) getWatcher()).isSmall() ? values.getBabyBox() : values.getAdultBox())
.getY();
return (((ArmorStandWatcher) getWatcher()).isSmall() ? values.getBabyBox() : values.getAdultBox()).getY();
} else if (getType() == DisguiseType.SLIME || getType() == DisguiseType.MAGMA_CUBE) {
return 0.51 * (0.255 * ((SlimeWatcher) getWatcher()).getSize());
}
@ -76,8 +75,7 @@ public class MobDisguise extends TargetedDisguise {
}
public boolean doesDisguiseAge() {
return getWatcher() != null &&
(getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
return getWatcher() != null && (getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
}
@Override

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes;
import java.security.InvalidParameterException;
import lombok.Getter;
import me.libraryaddict.disguise.disguisetypes.watchers.ModdedWatcher;
import me.libraryaddict.disguise.utilities.modded.ModdedEntity;
@ -8,6 +7,8 @@ import me.libraryaddict.disguise.utilities.modded.ModdedManager;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.security.InvalidParameterException;
/**
* Created by libraryaddict on 15/04/2020.
*/
@ -30,8 +31,7 @@ public class ModdedDisguise extends TargetedDisguise {
super(disguiseType);
if (disguiseType != DisguiseType.UNKNOWN) {
throw new InvalidParameterException(
"CustomDisguise is only for DisguiseType.MODDED_LIVING/MISC and DisguiseType.UNKNOWN");
throw new InvalidParameterException("CustomDisguise is only for DisguiseType.MODDED_LIVING/MISC and DisguiseType.UNKNOWN");
}
createDisguise();

View File

@ -4,7 +4,6 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import java.lang.reflect.InvocationTargetException;
import lombok.Getter;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
@ -19,6 +18,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.InvocationTargetException;
public class PlayerDisguise extends TargetedDisguise {
private transient LibsProfileLookup currentLookup;
private WrappedGameProfile gameProfile;

View File

@ -7,17 +7,18 @@ import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public abstract class TargetedDisguise extends Disguise {
public TargetedDisguise(DisguiseType disguiseType) {
@ -61,17 +62,14 @@ public abstract class TargetedDisguise extends Disguise {
if (player != null) {
PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
deleteTab.getPlayerInfoAction().write(0,
canSee(player) ? PlayerInfoAction.REMOVE_PLAYER : PlayerInfoAction.ADD_PLAYER);
deleteTab.getPlayerInfoAction().write(0, canSee(player) ? PlayerInfoAction.REMOVE_PLAYER : PlayerInfoAction.ADD_PLAYER);
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
NativeGameMode.SURVIVAL, WrappedChatComponent
.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL,
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
}
}
catch (InvocationTargetException e) {
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
@ -134,17 +132,14 @@ public abstract class TargetedDisguise extends Disguise {
if (player != null) {
PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
deleteTab.getPlayerInfoAction().write(0,
canSee(player) ? PlayerInfoAction.ADD_PLAYER : PlayerInfoAction.REMOVE_PLAYER);
deleteTab.getPlayerInfoAction().write(0, canSee(player) ? PlayerInfoAction.ADD_PLAYER : PlayerInfoAction.REMOVE_PLAYER);
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
NativeGameMode.SURVIVAL, WrappedChatComponent
.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL,
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
}
}
catch (InvocationTargetException e) {
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}

View File

@ -1,9 +1,10 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import java.util.Optional;
import java.util.UUID;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
public abstract class AbstractHorseWatcher extends AgeableWatcher {
private static final int TAMED = 2, SADDLED = 4, REPRODUCED = 8, GRAZING = 16, REARING = 32, EATING = 64;

View File

@ -31,8 +31,9 @@ public class ArmorStandWatcher extends LivingWatcher {
}
private EulerAngle getPose(MetaIndex<Vector3F> type) {
if (!hasValue(type))
if (!hasValue(type)) {
return new EulerAngle(0, 0, 0);
}
Vector3F vec = getData(type);

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.util.Random;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.Disguise;
@ -11,6 +10,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.DyeColor;
import org.bukkit.entity.Cat;
import java.util.Random;
/**
* Created by libraryaddict on 6/05/2019.
*/

View File

@ -17,10 +17,8 @@ public class CreeperWatcher extends InsentientWatcher {
public void setIgnited(boolean ignited) {
// If creeper is already ignited and they want to set it to unignited, then resend disguise
boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() &&
((hasValue(MetaIndex.CREEPER_IGNITED) && isIgnited()) ||
(getDisguise().getEntity() instanceof Creeper &&
((Creeper) getDisguise().getEntity()).isPowered()));
boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() && ((hasValue(MetaIndex.CREEPER_IGNITED) && isIgnited()) ||
(getDisguise().getEntity() instanceof Creeper && ((Creeper) getDisguise().getEntity()).isPowered()));
setData(MetaIndex.CREEPER_IGNITED, ignited);
sendData(MetaIndex.CREEPER_IGNITED);

View File

@ -24,8 +24,7 @@ public class DroppedItemWatcher extends FlagWatcher {
if (!getDisguise().isCustomDisguiseName()) {
getDisguise().setDisguiseName(TranslateType.DISGUISES.get(DisguiseType.DROPPED_ITEM.toReadable()) + " " +
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager
.toReadable((item == null ? Material.AIR : item.getType()).name(), " ")));
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable((item == null ? Material.AIR : item.getType()).name(), " ")));
}
}
}

View File

@ -1,11 +1,12 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import com.comphenix.protocol.wrappers.BlockPosition;
import java.util.Optional;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import java.util.Optional;
/**
* @author Navid
*/

View File

@ -1,12 +1,13 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import com.comphenix.protocol.wrappers.WrappedBlockData;
import java.util.Optional;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.Optional;
public class EndermanWatcher extends InsentientWatcher {
public EndermanWatcher(Disguise disguise) {

View File

@ -4,7 +4,6 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import java.lang.reflect.InvocationTargetException;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
@ -19,6 +18,8 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
public class FallingBlockWatcher extends FlagWatcher {
private int blockCombinedId = 1;
private boolean gridLocked;

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.util.OptionalInt;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
@ -9,6 +8,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.OptionalInt;
public class FireworkWatcher extends FlagWatcher {
public FireworkWatcher(Disguise disguise) {
super(disguise);

View File

@ -12,8 +12,9 @@ public class FishingHookWatcher extends FlagWatcher {
public int getHookedId() {
int hooked = getData(MetaIndex.FISHING_HOOK_HOOKED_ID);
if (hooked > 0)
if (hooked > 0) {
hooked--;
}
return hooked;
}

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.util.Random;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
@ -9,6 +8,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.entity.Fox;
import java.util.Random;
/**
* Created by libraryaddict on 6/05/2019.
*/

View File

@ -49,8 +49,9 @@ public class GuardianWatcher extends InsentientWatcher {
public void setTarget(String playername) {
Player player = Bukkit.getPlayer(playername);
if (player == null)
if (player == null) {
return;
}
setData(MetaIndex.GUARDIAN_TARGET, player.getEntityId());
sendData(MetaIndex.GUARDIAN_TARGET);

View File

@ -6,13 +6,6 @@ import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.WrappedAttribute;
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import lombok.Getter;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise;
@ -26,6 +19,14 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
public class LivingWatcher extends FlagWatcher {
private double maxHealth;
private boolean maxHealthSet;

View File

@ -1,12 +1,13 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.util.Locale;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.entity.MushroomCow;
import java.util.Locale;
/**
* Created by libraryaddict on 6/05/2019.
*/

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.util.Optional;
import java.util.UUID;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
@ -9,6 +7,9 @@ import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.entity.Ocelot;
import java.util.Optional;
import java.util.UUID;
public class OcelotWatcher extends AgeableWatcher {
public OcelotWatcher(Disguise disguise) {

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.util.Random;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
@ -9,6 +8,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.entity.Panda;
import java.util.Random;
/**
* Created by libraryaddict on 6/05/2019.
*/

View File

@ -26,8 +26,9 @@ public class PlayerWatcher extends LivingWatcher {
}
public void setDisplayedInTab(boolean showPlayerInTab) {
if (getDisguise().isDisguiseInUse())
if (getDisguise().isDisguiseInUse()) {
throw new IllegalStateException("Cannot set this while disguise is in use!");
}
alwaysShowInTab = showPlayerInTab;
}

View File

@ -2,13 +2,14 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
import java.util.Optional;
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import org.bukkit.DyeColor;
import org.bukkit.block.BlockFace;
import java.util.Optional;
/**
* @author Navid
*/
@ -41,11 +42,13 @@ public class ShulkerWatcher extends InsentientWatcher {
}
public void setShieldHeight(int newHeight) {
if (newHeight < 0)
if (newHeight < 0) {
newHeight = 0;
}
if (newHeight > 127)
if (newHeight > 127) {
newHeight = 127;
}
setData(MetaIndex.SHULKER_PEEKING, (byte) newHeight);
sendData(MetaIndex.SHULKER_PEEKING);

View File

@ -1,9 +1,10 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import java.util.Optional;
import java.util.UUID;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
public class TameableWatcher extends AgeableWatcher {
public TameableWatcher(Disguise disguise) {

View File

@ -1,7 +1,5 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.util.HashMap;
import java.util.Map;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
@ -10,6 +8,9 @@ import org.apache.commons.lang.math.RandomUtils;
import org.bukkit.DyeColor;
import org.bukkit.entity.TropicalFish;
import java.util.HashMap;
import java.util.Map;
/**
* Created by libraryaddict on 6/08/2018.
*/
@ -75,8 +76,7 @@ public class TropicalFishWatcher extends FishWatcher {
}
private int getData(final DyeColor patternColor, final DyeColor bodyColor, final TropicalFish.Pattern type) {
return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 |
CraftPattern.values()[type.ordinal()].getDataValue();
return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 | CraftPattern.values()[type.ordinal()].getDataValue();
}
public DyeColor getBodyColor() {

View File

@ -1,10 +1,11 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.security.InvalidParameterException;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import org.bukkit.ChatColor;
import java.security.InvalidParameterException;
public class WitherWatcher extends InsentientWatcher {
public WitherWatcher(Disguise disguise) {
@ -21,8 +22,7 @@ public class WitherWatcher extends InsentientWatcher {
}
public int[] getTargets() {
return new int[]{getData(MetaIndex.WITHER_TARGET_1), getData(MetaIndex.WITHER_TARGET_2),
getData(MetaIndex.WITHER_TARGET_3)};
return new int[]{getData(MetaIndex.WITHER_TARGET_1), getData(MetaIndex.WITHER_TARGET_2), getData(MetaIndex.WITHER_TARGET_3)};
}
/**
@ -35,8 +35,7 @@ public class WitherWatcher extends InsentientWatcher {
public void setTargets(int... targets) {
if (targets.length != 3) {
throw new InvalidParameterException(
ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length);
throw new InvalidParameterException(ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length);
}
setData(MetaIndex.WITHER_TARGET_1, targets[0]);
setData(MetaIndex.WITHER_TARGET_2, targets[1]);

View File

@ -1,6 +1,5 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import java.util.Random;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
@ -11,6 +10,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession;
import java.util.Random;
public class ZombieVillagerWatcher extends ZombieWatcher {
public ZombieVillagerWatcher(Disguise disguise) {

View File

@ -22,47 +22,6 @@ import com.google.gson.JsonSerializer;
import com.google.gson.JsonSyntaxException;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.datafixers.util.Pair;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.Setter;
import me.libraryaddict.disguise.DisguiseAPI;
@ -135,6 +94,48 @@ import org.bukkit.scoreboard.Team.Option;
import org.bukkit.scoreboard.Team.OptionStatus;
import org.bukkit.util.Vector;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class DisguiseUtilities {
@Setter
public static class DScoreTeam {

View File

@ -1,9 +1,10 @@
package me.libraryaddict.disguise.utilities;
import java.util.HashMap;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
import java.util.HashMap;
/**
* Created by libraryaddict on 19/02/2020.
*/

View File

@ -1,5 +1,13 @@
package me.libraryaddict.disguise.utilities;
import lombok.Getter;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.plugin.BisectHosting;
import me.libraryaddict.disguise.utilities.plugin.PluginInformation;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.FileUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
@ -8,13 +16,6 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
import lombok.Getter;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.plugin.BisectHosting;
import me.libraryaddict.disguise.utilities.plugin.PluginInformation;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.FileUtil;
/**
* Created by libraryaddict on 2/06/2017.
@ -171,8 +172,8 @@ public class LibsPremium {
try {
plugin = getInformation(file);
} catch (ClassNotFoundException | NoClassDefFoundError ex) {
DisguiseUtilities.getLogger().warning("Found an unrecognized jar in the LibsDisguises folder (" + file.getName() +
") - It may need replacing with a newer jar from SpigotMC");
DisguiseUtilities.getLogger().warning(
"Found an unrecognized jar in the LibsDisguises folder (" + file.getName() + ") - It may need replacing with a newer jar from SpigotMC");
continue;
} catch (Exception ex) {
DisguiseUtilities.getLogger().warning("Error while trying to handle the file " + file.getName());

View File

@ -2,10 +2,6 @@ package me.libraryaddict.disguise.utilities;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.mojang.authlib.GameProfile;
import java.io.File;
import java.util.Locale;
import java.util.UUID;
import java.util.regex.Pattern;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.mineskin.MineSkinResponse;
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
@ -13,6 +9,11 @@ import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.Locale;
import java.util.UUID;
import java.util.regex.Pattern;
/**
* Created by libraryaddict on 1/01/2020.
*/
@ -35,8 +36,7 @@ public class SkinUtils {
@Override
public void run() {
try {
MineSkinResponse response = DisguiseUtilities.getMineSkinAPI()
.generateFromFile(callback, file, modelType);
MineSkinResponse response = DisguiseUtilities.getMineSkinAPI().generateFromFile(callback, file, modelType);
new BukkitRunnable() {
@Override
@ -51,8 +51,7 @@ public class SkinUtils {
handleProfile(response.getGameProfile(), modelType, callback);
}
}.runTask(LibsDisguises.getInstance());
}
catch (IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
new BukkitRunnable() {
@Override
public void run() {
@ -68,8 +67,7 @@ public class SkinUtils {
new BukkitRunnable() {
@Override
public void run() {
MineSkinResponse response = DisguiseUtilities.getMineSkinAPI()
.generateFromUrl(callback, url, modelType);
MineSkinResponse response = DisguiseUtilities.getMineSkinAPI().generateFromUrl(callback, url, modelType);
new BukkitRunnable() {
@Override
@ -130,8 +128,7 @@ public class SkinUtils {
new BukkitRunnable() {
@Override
public void run() {
WrappedGameProfile profile = ReflectionManager
.getSkullBlob(new WrappedGameProfile(uuid, "AutoGenerated"));
WrappedGameProfile profile = ReflectionManager.getSkullBlob(new WrappedGameProfile(uuid, "AutoGenerated"));
new BukkitRunnable() {
@Override
@ -183,8 +180,8 @@ public class SkinUtils {
return;
}
File file = new File(LibsDisguises.getInstance().getDataFolder(),
"/Skins/" + param + (param.toLowerCase(Locale.ENGLISH).endsWith(".png") ? "" : ".png"));
File file =
new File(LibsDisguises.getInstance().getDataFolder(), "/Skins/" + param + (param.toLowerCase(Locale.ENGLISH).endsWith(".png") ? "" : ".png"));
if (!file.exists()) {
file = null;
@ -208,8 +205,7 @@ public class SkinUtils {
callback.onInfo(LibsMsg.SKIN_API_USING_UUID);
handleUUID(uuid, modelType, callback);
return;
}
catch (Exception ignored) {
} catch (Exception ignored) {
}
}

View File

@ -1,10 +1,5 @@
package me.libraryaddict.disguise.utilities.config;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
@ -15,6 +10,12 @@ import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
/**
* Created by libraryaddict on 31/01/2021.
*/

View File

@ -1,6 +1,14 @@
package me.libraryaddict.disguise.utilities.config;
import com.google.common.base.Strings;
import lombok.Getter;
import lombok.Setter;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.PluginDescriptionFile;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -12,13 +20,6 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.PluginDescriptionFile;
/**
* Created by libraryaddict on 28/01/2021.

View File

@ -6,18 +6,17 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import org.bukkit.Bukkit;
import org.bukkit.block.data.BlockData;
import java.lang.reflect.Type;
/**
* Created by libraryaddict on 27/11/2018.
*/
public class SerializerBlockData implements JsonDeserializer<BlockData>,
JsonSerializer<BlockData> {
public class SerializerBlockData implements JsonDeserializer<BlockData>, JsonSerializer<BlockData> {
@Override
public BlockData deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
public BlockData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return Bukkit.createBlockData(json.getAsString());
}

View File

@ -7,17 +7,16 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
/**
* Created by libraryaddict on 27/11/2018.
*/
public class SerializerChatComponent implements JsonDeserializer<WrappedChatComponent>,
JsonSerializer<WrappedChatComponent> {
public class SerializerChatComponent implements JsonDeserializer<WrappedChatComponent>, JsonSerializer<WrappedChatComponent> {
@Override
public WrappedChatComponent deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
public WrappedChatComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (json.isJsonPrimitive()) {
return WrappedChatComponent.fromJson(json.getAsString());
}

View File

@ -6,7 +6,6 @@ import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
@ -14,6 +13,8 @@ import me.libraryaddict.disguise.disguisetypes.MobDisguise;
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
import java.lang.reflect.Type;
/**
* Created by libraryaddict on 1/06/2017.
*/

View File

@ -9,12 +9,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.internal.LinkedTreeMap;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.EntityPose;
@ -28,6 +22,13 @@ import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoParticle
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
/**
* Created by libraryaddict on 1/06/2017.
*/

View File

@ -9,6 +9,7 @@ import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.mojang.authlib.GameProfile;
import java.lang.reflect.Type;
import java.util.regex.Pattern;
@ -23,14 +24,13 @@ public class SerializerGameProfile implements JsonSerializer<WrappedGameProfile>
}
@Override
public WrappedGameProfile deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
public WrappedGameProfile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject obj = json.getAsJsonObject();
if (obj.has("id") && !obj.get("id").getAsString().contains("-")) {
obj.addProperty("id",
Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)")
.matcher(obj.get("id").getAsString()).replaceFirst("$1-$2-$3-$4-$5"));
Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)").matcher(obj.get("id").getAsString())
.replaceFirst("$1-$2-$3-$4-$5"));
}
return WrappedGameProfile.fromHandle(context.deserialize(json, GameProfile.class));

View File

@ -6,13 +6,14 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
/**
* Created by libraryaddict on 1/06/2017.
*/
@ -30,8 +31,7 @@ public class SerializerItemStack implements JsonSerializer<ItemStack>, JsonDeser
}
@Override
public ItemStack deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
HashMap map = context.deserialize(json, HashMap.class);
if (map.containsKey("meta")) {

View File

@ -7,9 +7,10 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import java.lang.reflect.Type;
/**
* Created by libraryaddict on 1/06/2017.
*/
@ -24,18 +25,19 @@ public class SerializerMetaIndex implements JsonSerializer<MetaIndex>, JsonDeser
}
@Override
public MetaIndex deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
public MetaIndex deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject obj = json.getAsJsonObject();
String name = obj.get("flagwatcher").getAsString();
int index = obj.get("index").getAsInt();
for (MetaIndex i : MetaIndex.values()) {
if (i.getIndex() != index)
if (i.getIndex() != index) {
continue;
}
if (!i.getFlagWatcher().getSimpleName().equals(name))
if (!i.getFlagWatcher().getSimpleName().equals(name)) {
continue;
}
return i;
}

View File

@ -4,9 +4,10 @@ import com.comphenix.protocol.wrappers.WrappedParticle;
import com.google.gson.JsonElement;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
import java.lang.reflect.Type;
/**
* Created by libraryaddict on 5/12/2020.
*/

View File

@ -8,14 +8,14 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import org.bukkit.Material;
import java.lang.reflect.Type;
/**
* Created by libraryaddict on 1/06/2017.
*/
public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockData>,
JsonDeserializer<WrappedBlockData> {
public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockData>, JsonDeserializer<WrappedBlockData> {
@Override
public JsonElement serialize(WrappedBlockData src, Type typeOfSrc, JsonSerializationContext context) {
@ -26,8 +26,7 @@ public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockDa
}
@Override
public WrappedBlockData deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
public WrappedBlockData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject obj = json.getAsJsonObject();
return WrappedBlockData.createData(Material.valueOf(obj.get("type").getAsString()), obj.get("data").getAsInt());

View File

@ -6,11 +6,6 @@ import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import lombok.Getter;
import lombok.Setter;
import me.libraryaddict.disguise.DisguiseAPI;
@ -64,6 +59,12 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
public class DisguiseListener implements Listener {
private HashMap<String, LibsEntityInteract> interactions = new HashMap<>();
private HashMap<String, BukkitRunnable> disguiseRunnable = new HashMap<>();

View File

@ -14,15 +14,17 @@ import org.bukkit.event.Listener;
public class PaperDisguiseListener implements Listener {
@EventHandler
public void onEntityLoad(EntityAddToWorldEvent event) {
if (!DisguiseConfig.isSaveEntityDisguises())
if (!DisguiseConfig.isSaveEntityDisguises()) {
return;
}
Entity entity = event.getEntity();
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity.getUniqueId(), true);
if (disguises.length <= 0)
if (disguises.length <= 0) {
return;
}
DisguiseUtilities.resetPluginTimer();

View File

@ -10,13 +10,6 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalCause;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@ -37,6 +30,14 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* Created by libraryaddict on 15/09/2020.
*/

View File

@ -3,6 +3,13 @@ package me.libraryaddict.disguise.utilities.metrics;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import javax.net.ssl.HttpsURLConnection;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
@ -20,12 +27,6 @@ import java.util.TimerTask;
import java.util.UUID;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
/**
* bStats collects some data for plugin authors.
@ -37,11 +38,9 @@ public class Metrics {
static {
// Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
final String defaultPackage = new String(new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'});
final String examplePackage = new String(
new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
// We want to make sure nobody just copy & pastes the example and use the wrong package names
if (Metrics.class.getPackage().getName().equals(defaultPackage) ||
Metrics.class.getPackage().getName().equals(examplePackage)) {
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
}
}
@ -95,16 +94,13 @@ public class Metrics {
config.addDefault("logFailedRequests", false);
// Inform the server owners about bStats
config.options()
.header("bStats collects some data for plugin authors like how many servers are using their " +
"plugins.\n" + "To honor their work, you should not disable it.\n" +
"This has nearly no effect on the server performance!\n" +
config.options().header("bStats collects some data for plugin authors like how many servers are using their " + "plugins.\n" +
"To honor their work, you should not disable it.\n" + "This has nearly no effect on the server performance!\n" +
"Check out https://bStats.org/ to learn more :)").copyDefaults(true);
try {
config.save(configFile);
DisguiseUtilities.getLogger().info("Saved bStats config");
}
catch (IOException ignored) {
} catch (IOException ignored) {
}
}
@ -119,8 +115,7 @@ public class Metrics {
service.getField("B_STATS_VERSION"); // Our identifier :)
found = true; // We aren't the first
break;
}
catch (NoSuchFieldException ignored) {
} catch (NoSuchFieldException ignored) {
}
}
// Register our service
@ -249,15 +244,13 @@ public class Metrics {
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
}
catch (NoSuchFieldException ignored) {
} catch (NoSuchFieldException ignored) {
continue; // Continue "searching"
}
// Found one!
try {
pluginData.add(new Gson().toJson(service.getMethod("getPluginData").invoke(Bukkit.getServicesManager().load(service))));
}
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
}
}
@ -270,12 +263,10 @@ public class Metrics {
try {
// Send the data
sendData(data);
}
catch (Exception e) {
} catch (Exception e) {
// Something went wrong! :(
if (logFailedRequests) {
plugin.getLogger()
.log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
}
}
}
@ -367,8 +358,7 @@ public class Metrics {
return null;
}
chart.add("data", data);
}
catch (Throwable t) {
} catch (Throwable t) {
if (logFailedRequests) {
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
}

View File

@ -1,8 +1,5 @@
package me.libraryaddict.disguise.utilities.metrics;
import java.util.Collection;
import java.util.HashMap;
import java.util.Set;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
@ -12,6 +9,10 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.plugin.PluginInformation;
import java.util.Collection;
import java.util.HashMap;
import java.util.Set;
/**
* Created by libraryaddict on 3/01/2019.
*/
@ -49,8 +50,8 @@ public class MetricsInitalizer {
info = LibsPremium.getPluginInformation();
}
boolean customPremium = !info.getUserID().matches("[0-9]+") || info.getUserID().equals("1") ||
!info.getResourceID().equals("32453") || !info.getDownloadID().matches("-?[0-9]+");
boolean customPremium = !info.getUserID().matches("[0-9]+") || info.getUserID().equals("1") || !info.getResourceID().equals("32453") ||
!info.getDownloadID().matches("-?[0-9]+");
if (customPremium) {
if (plugin.isReleaseBuild() && LibsPremium.getPaidInformation() == null) {
@ -137,8 +138,9 @@ public class MetricsInitalizer {
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
for (Set<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
for (Disguise disg : list) {
if (disg.getEntity() == null || !disg.isDisguiseInUse())
if (disg.getEntity() == null || !disg.isDisguiseInUse()) {
continue;
}
String name = disg.getEntity().getType().name();
@ -155,8 +157,9 @@ public class MetricsInitalizer {
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
for (Set<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
for (Disguise disg : list) {
if (disg.getEntity() == null || !disg.isDisguiseInUse())
if (disg.getEntity() == null || !disg.isDisguiseInUse()) {
continue;
}
String name = disg.getType().name();
@ -194,20 +197,22 @@ public class MetricsInitalizer {
disgs += set.size();
}
if (disgs == 0)
if (disgs == 0) {
return "0";
if (disgs <= 5)
}
if (disgs <= 5) {
return "1 to 5";
else if (disgs <= 15)
} else if (disgs <= 15) {
return "6 to 15";
else if (disgs <= 30)
} else if (disgs <= 30) {
return "16 to 30";
else if (disgs <= 60)
} else if (disgs <= 60) {
return "30 to 60";
else if (disgs <= 100)
} else if (disgs <= 100) {
return "60 to 100";
else if (disgs <= 200)
} else if (disgs <= 200) {
return "100 to 200";
}
return "More than 200";
}
@ -233,8 +238,7 @@ public class MetricsInitalizer {
try {
Class.forName("org.spigotmc.SpigotConfig");
return "Yes";
}
catch (Exception ex) {
} catch (Exception ex) {
return "No";
}
}
@ -275,13 +279,15 @@ public class MetricsInitalizer {
Collection<Set<TargetedDisguise>> list = DisguiseUtilities.getDisguises().values();
if (list.isEmpty())
if (list.isEmpty()) {
return "Unknown";
}
for (Set<TargetedDisguise> dList : list) {
for (TargetedDisguise disg : dList) {
if (disg.getObservers().isEmpty())
if (disg.getObservers().isEmpty()) {
continue;
}
targetedDisguises = true;
return "Yes";

View File

@ -1,6 +1,13 @@
package me.libraryaddict.disguise.utilities.mineskin;
import com.google.gson.Gson;
import lombok.Getter;
import lombok.Setter;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.SkinUtils;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@ -18,12 +25,6 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.Setter;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.SkinUtils;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
/**
* Created by libraryaddict on 28/12/2019.
@ -164,8 +165,8 @@ public class MineSkinAPI {
printDebug("Received status code: " + connection.getResponseCode());
if (connection.getResponseCode() == 500) {
String errorMessage = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining("\n"));
String errorMessage =
new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
APIError error = new Gson().fromJson(errorMessage, APIError.class);

View File

@ -3,10 +3,11 @@ package me.libraryaddict.disguise.utilities.mineskin;
import com.google.gson.annotations.SerializedName;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import java.util.UUID;
import lombok.Getter;
import org.apache.commons.lang.StringUtils;
import java.util.UUID;
/**
* Created by libraryaddict on 29/12/2019.
*/

View File

@ -4,14 +4,6 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.utility.StreamSerializer;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
@ -25,6 +17,15 @@ import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* Created by libraryaddict on 14/04/2020.
*/
@ -36,8 +37,7 @@ public class ModdedManager {
@Getter
private static byte[] fmlRegistries;
@Getter
private static final Cache<String, ArrayList<String>> forgeMods = CacheBuilder.newBuilder()
.expireAfterWrite(1, TimeUnit.MINUTES).build();
private static final Cache<String, ArrayList<String>> forgeMods = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build();
public ModdedManager(ArrayList<String> channels) {
if (getEntities().isEmpty()) {
@ -80,8 +80,7 @@ public class ModdedManager {
// Only this one thx
// s.serializeString(output, "minecraft:entity_type");
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
@ -123,8 +122,7 @@ public class ModdedManager {
// Or dummied. What is dummied anyways. What are these others?
s.serializeVarInt(output, 0);
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
@ -202,9 +200,7 @@ public class ModdedManager {
ArrayList<DisguisePerm> perms = new ArrayList<>();
for (Map.Entry<NamespacedKey, ModdedEntity> entry : entities.entrySet()) {
perms.add(new DisguisePerm(
entry.getValue().isLiving() ? DisguiseType.MODDED_LIVING : DisguiseType.MODDED_MISC,
entry.getValue().getName()));
perms.add(new DisguisePerm(entry.getValue().isLiving() ? DisguiseType.MODDED_LIVING : DisguiseType.MODDED_MISC, entry.getValue().getName()));
}
return perms;

View File

@ -5,11 +5,6 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.mojang.datafixers.util.Pair;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@ -23,6 +18,12 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by libraryaddict on 3/01/2019.
*/

View File

@ -2,8 +2,6 @@ package me.libraryaddict.disguise.utilities.packets;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import java.util.ArrayList;
import java.util.Collection;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
@ -22,6 +20,9 @@ import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerV
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collection;
/**
* Created by libraryaddict on 3/01/2019.
*/
@ -45,8 +46,7 @@ public class PacketsHandler {
packetHandlers.add(new PacketHandlerHeadRotation());
// If not prem, if build is from jenkins, else its a custom and needs paid info
if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") ||
LibsPremium.getPaidInformation() != null) {
if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") || LibsPremium.getPaidInformation() != null) {
packetHandlers.add(new PacketHandlerMetadata(this));
}

View File

@ -4,7 +4,6 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.PacketType.Play.Server;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketListener;
import java.util.ArrayList;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
@ -23,6 +22,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.ArrayList;
public class PacketsManager {
private static PacketListener clientInteractEntityListener;
private static PacketListener inventoryListener;
@ -177,8 +178,7 @@ public class PacketsManager {
ProtocolLibrary.getProtocolManager().addPacketListener(mainListener);
ProtocolLibrary.getProtocolManager().addPacketListener(destroyListener);
if (NmsVersion.v1_13.isSupported() &&
DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) {
if (NmsVersion.v1_13.isSupported() && DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) {
scoreboardTeamListener = new PacketListenerScoreboardTeam();
ProtocolLibrary.getProtocolManager().addPacketListener(scoreboardTeamListener);
@ -207,8 +207,7 @@ public class PacketsManager {
DisguiseUtilities.removeSelfDisguise(disguise);
}
if (inventoryModifierEnabled &&
(disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
if (inventoryModifierEnabled && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
player.updateInventory();
}
}

Some files were not shown because too many files have changed in this diff Show More