fix doublegui plugin close dupe, add more compatibility sounds, convert update gui to new system, add highlighter

This commit is contained in:
jascotty2 2019-08-27 20:48:42 -05:00
parent 49d8503592
commit c5745477f7
14 changed files with 1221 additions and 962 deletions

View File

@ -1,5 +1,6 @@
package com.songoda.core; package com.songoda.core;
import com.songoda.core.compatibility.LegacyMaterials;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
@ -7,20 +8,25 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class PluginInfo { public final class PluginInfo {
private final JavaPlugin javaPlugin; protected final JavaPlugin javaPlugin;
private final int songodaId; protected final int songodaId;
protected final String coreIcon;
protected final LegacyMaterials icon;
private final List<PluginInfoModule> modules = new ArrayList<>(); private final List<PluginInfoModule> modules = new ArrayList<>();
private boolean hasUpdate = false;
private String latestVersion; private String latestVersion;
private String notification; private String notification;
private String changeLog; private String changeLog;
private String marketplaceLink; private String marketplaceLink;
private JSONObject json; private JSONObject json;
protected PluginInfo(JavaPlugin javaPlugin, int songodaId) { protected PluginInfo(JavaPlugin javaPlugin, int songodaId, String icon) {
this.javaPlugin = javaPlugin; this.javaPlugin = javaPlugin;
this.songodaId = songodaId; this.songodaId = songodaId;
this.coreIcon = icon;
this.icon = LegacyMaterials.getMaterial(icon);
} }
public String getLatestVersion() { public String getLatestVersion() {
@ -29,6 +35,7 @@ public class PluginInfo {
public void setLatestVersion(String latestVersion) { public void setLatestVersion(String latestVersion) {
this.latestVersion = latestVersion; this.latestVersion = latestVersion;
hasUpdate = !javaPlugin.getDescription().getVersion().equalsIgnoreCase(latestVersion);
} }
public String getNotification() { public String getNotification() {
@ -39,6 +46,14 @@ public class PluginInfo {
this.notification = notification; this.notification = notification;
} }
public boolean hasUpdate() {
return hasUpdate;
}
public void setHasUpdate(boolean hasUpdate) {
this.hasUpdate = hasUpdate;
}
public String getChangeLog() { public String getChangeLog() {
return changeLog; return changeLog;
} }

View File

@ -1,6 +1,8 @@
package com.songoda.core; package com.songoda.core;
import com.songoda.core.commands.CommandManager; import com.songoda.core.commands.CommandManager;
import com.songoda.core.compatibility.LegacyMaterials;
import com.songoda.core.gui.GUIManager;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -35,18 +37,23 @@ public class SongodaCore {
private static SongodaCore INSTANCE = null; private static SongodaCore INSTANCE = null;
private JavaPlugin piggybackedPlugin; private JavaPlugin piggybackedPlugin;
protected GUIManager guiManager;
private final CommandManager commandManager; private final CommandManager commandManager;
private final EventListener loginListener = new EventListener(); private final EventListener loginListener = new EventListener();
private final HashMap<UUID, Long> lastCheck = new HashMap(); private final HashMap<UUID, Long> lastCheck = new HashMap();
public static void registerPlugin(JavaPlugin plugin, int pluginID) { public static void registerPlugin(JavaPlugin plugin, int pluginID, LegacyMaterials icon) {
registerPlugin(plugin, pluginID, icon == null ? "STONE" : icon.name());
}
public static void registerPlugin(JavaPlugin plugin, int pluginID, String icon) {
if(INSTANCE == null) { if(INSTANCE == null) {
// First: are there any other instances of SongodaCore active? // First: are there any other instances of SongodaCore active?
for (Class<?> clazz : Bukkit.getServicesManager().getKnownServices()) { for (Class<?> clazz : Bukkit.getServicesManager().getKnownServices()) {
if(clazz.getSimpleName().equals("SongodaCore")) { if(clazz.getSimpleName().equals("SongodaCore")) {
try { try {
// use the active service // use the active service
clazz.getMethod("registerPlugin", JavaPlugin.class, int.class).invoke(null, plugin, pluginID); clazz.getMethod("registerPlugin", JavaPlugin.class, int.class, String.class).invoke(null, plugin, pluginID, icon);
return; return;
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {
@ -57,7 +64,7 @@ public class SongodaCore {
INSTANCE = new SongodaCore(plugin); INSTANCE = new SongodaCore(plugin);
Bukkit.getServicesManager().register(SongodaCore.class, INSTANCE, plugin, ServicePriority.Normal); Bukkit.getServicesManager().register(SongodaCore.class, INSTANCE, plugin, ServicePriority.Normal);
} }
INSTANCE.register(plugin, pluginID); INSTANCE.register(plugin, pluginID, icon);
} }
public SongodaCore(JavaPlugin javaPlugin) { public SongodaCore(JavaPlugin javaPlugin) {
@ -66,11 +73,15 @@ public class SongodaCore {
commandManager.registerCommandDynamically(new SongodaCoreCommand(this)) commandManager.registerCommandDynamically(new SongodaCoreCommand(this))
.addSubCommand(new SongodaCoreDiagCommand(this)); .addSubCommand(new SongodaCoreDiagCommand(this));
Bukkit.getPluginManager().registerEvents(loginListener, javaPlugin); Bukkit.getPluginManager().registerEvents(loginListener, javaPlugin);
// we aggressevely want to own this command
Bukkit.getScheduler().runTaskLaterAsynchronously(javaPlugin, ()->{CommandManager.registerCommandDynamically(piggybackedPlugin, "songoda", commandManager, commandManager);}, 20 * 60 * 1);
Bukkit.getScheduler().runTaskLaterAsynchronously(javaPlugin, ()->{CommandManager.registerCommandDynamically(piggybackedPlugin, "songoda", commandManager, commandManager);}, 20 * 60 * 2);
Bukkit.getScheduler().runTaskLaterAsynchronously(javaPlugin, ()->{CommandManager.registerCommandDynamically(piggybackedPlugin, "songoda", commandManager, commandManager);}, 20 * 60 * 2);
} }
private void register(JavaPlugin plugin, int pluginID) { private void register(JavaPlugin plugin, int pluginID, String icon) {
System.out.println(getPrefix() + "Hooked " + plugin.getName() + "."); System.out.println(getPrefix() + "Hooked " + plugin.getName() + ".");
PluginInfo info = new PluginInfo(plugin, pluginID); PluginInfo info = new PluginInfo(plugin, pluginID, icon);
// don't forget to check for language pack updates ;) // don't forget to check for language pack updates ;)
info.addModule(new LocaleModule()); info.addModule(new LocaleModule());
registeredPlugins.add(info); registeredPlugins.add(info);
@ -166,6 +177,9 @@ public class SongodaCore {
} }
if(event.getPlugin() == piggybackedPlugin) { if(event.getPlugin() == piggybackedPlugin) {
// uh-oh! Abandon ship!! // uh-oh! Abandon ship!!
if(guiManager != null) {
guiManager.closeAll();
}
Bukkit.getServicesManager().unregisterAll(piggybackedPlugin); Bukkit.getServicesManager().unregisterAll(piggybackedPlugin);
// can we move somewhere else? // can we move somewhere else?
if((pi = registeredPlugins.stream().findFirst().orElse(null)) != null) { if((pi = registeredPlugins.stream().findFirst().orElse(null)) != null) {
@ -174,6 +188,7 @@ public class SongodaCore {
Bukkit.getServicesManager().register(SongodaCore.class, INSTANCE, piggybackedPlugin, ServicePriority.Normal); Bukkit.getServicesManager().register(SongodaCore.class, INSTANCE, piggybackedPlugin, ServicePriority.Normal);
Bukkit.getPluginManager().registerEvents(loginListener, piggybackedPlugin); Bukkit.getPluginManager().registerEvents(loginListener, piggybackedPlugin);
CommandManager.registerCommandDynamically(piggybackedPlugin, "songoda", commandManager, commandManager); CommandManager.registerCommandDynamically(piggybackedPlugin, "songoda", commandManager, commandManager);
guiManager = null;
} }
} }
} }

View File

@ -1,6 +1,7 @@
package com.songoda.core; package com.songoda.core;
import com.songoda.core.commands.AbstractCommand; import com.songoda.core.commands.AbstractCommand;
import com.songoda.core.gui.GUIManager;
import java.util.List; import java.util.List;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -16,7 +17,10 @@ class SongodaCoreCommand extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if(sender instanceof Player) { if(sender instanceof Player) {
new SongodaCoreOverviewGUI(instance, (Player) sender); if(instance.guiManager == null) {
instance.guiManager = new GUIManager(SongodaCore.getHijackedPlugin());
}
instance.guiManager.showGUI((Player) sender, new SongodaCoreOverviewGUI(instance));
} else { } else {
sender.sendMessage("/songoda diag"); sender.sendMessage("/songoda diag");
} }

View File

@ -1,50 +1,50 @@
package com.songoda.core; package com.songoda.core;
import com.songoda.core.utils.gui.AbstractGUI; import com.songoda.core.compatibility.LegacyMaterials;
import org.bukkit.Material; import com.songoda.core.gui.GUI;
import org.bukkit.entity.Player; import com.songoda.core.gui.GuiUtils;
import java.util.List; import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.ClickType;
class SongodaCoreOverviewGUI extends AbstractGUI { final class SongodaCoreOverviewGUI extends GUI {
private final SongodaCore update; private final SongodaCore update;
protected SongodaCoreOverviewGUI(SongodaCore update, Player player) { protected SongodaCoreOverviewGUI(SongodaCore update) {
super(player);
this.update = update; this.update = update;
init("Songoda Update", 36);
}
@Override
protected void constructGUI() {
List<PluginInfo> plugins = update.getPlugins(); List<PluginInfo> plugins = update.getPlugins();
// could do pages, too, but don't think we'll have that many at a time for a while
int max = (int) Math.ceil(plugins.size() / 9.);
setRows(max);
setTitle("Songoda Plugins");
// TODO: this could use some decorating
for (int i = 0; i < plugins.size(); i++) { for (int i = 0; i < plugins.size(); i++) {
PluginInfo plugin = plugins.get(i); PluginInfo plugin = plugins.get(i);
if (plugin.hasUpdate()) {
createButton(i + 9, Material.STONE, "&6" + plugin.getJavaPlugin().getName(), setButton(i, GuiUtils.createButtonItem(plugin.icon != null ? plugin.icon : LegacyMaterials.STONE,
"&7Latest Version: " + plugin.getLatestVersion(), ChatColor.GOLD + plugin.getJavaPlugin().getName(),
"&7Installed Version: " + plugin.getJavaPlugin().getDescription().getVersion(), ChatColor.GRAY + "Latest Version: " + plugin.getLatestVersion(),
ChatColor.GRAY + "Installed Version: " + plugin.getJavaPlugin().getDescription().getVersion(),
"", "",
"Change log:", "Change log:",
plugin.getChangeLog(), plugin.getChangeLog(),
"", "",
"&6Click for the marketplace page link."); ChatColor.GOLD + "Click for the marketplace page link."
),
registerClickable(i + 9, ((player1, inventory1, cursor, slot, type) -> ClickType.LEFT, (player, inv, gui, cursor, slot, type) -> player.sendMessage(plugin.getMarketplaceLink()));
player.sendMessage(plugin.getMarketplaceLink()))); highlightItem(i);
} else {
setButton(i, GuiUtils.createButtonItem(plugin.icon != null ? plugin.icon : LegacyMaterials.STONE,
ChatColor.GOLD + plugin.getJavaPlugin().getName(),
ChatColor.GRAY + "Installed Version: " + plugin.getJavaPlugin().getDescription().getVersion(),
"",
ChatColor.GOLD + "Click for the marketplace page link."
),
ClickType.LEFT, (player, inv, gui, cursor, slot, type) -> player.sendMessage(plugin.getMarketplaceLink()));
} }
} }
@Override
protected void registerClickables() {
}
@Override
protected void registerOnCloses() {
} }
} }

View File

@ -4,7 +4,8 @@ import org.bukkit.Sound;
/** /**
* Sounds that are compatible with server versions 1.7+ <br> * Sounds that are compatible with server versions 1.7+ <br>
* TODO: This needs work. Finished 1.8, finished 1.9 blocks, resume with 1.9 entities<br> * TODO: This needs work.
* Finished 1.8, finished 1.9 blocks, resume with 1.9 entities<br>
* Between 1.8 and 1.9, all sounds were renamed, and between 1.12 and 1.13, some * Between 1.8 and 1.9, all sounds were renamed, and between 1.12 and 1.13, some
* sounds were renamed. New sounds have been added by different versions, as * sounds were renamed. New sounds have been added by different versions, as
* well. The intent of this class is to provide either the correct sound or a * well. The intent of this class is to provide either the correct sound or a
@ -34,7 +35,7 @@ public enum CompatibleSounds {
BLOCK_ANVIL_PLACE(ServerVersion.V1_9, v("ANVIL_LAND", true)), BLOCK_ANVIL_PLACE(ServerVersion.V1_9, v("ANVIL_LAND", true)),
BLOCK_ANVIL_STEP(ServerVersion.V1_9, v("ANVIL_LAND", true)), BLOCK_ANVIL_STEP(ServerVersion.V1_9, v("ANVIL_LAND", true)),
BLOCK_ANVIL_USE("ANVIL_USE"), BLOCK_ANVIL_USE("ANVIL_USE"),
BLOCK_BAMBOO_BREAK(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_WOOD_BREAK"), v(ServerVersion.V1_8, "DIG_WOOD")), BLOCK_BAMBOO_BREAK(ServerVersion.V1_14, v(ServerVersion.V1_9, "BLOCK_WOOD_BREAK"), v(ServerVersion.V1_8, "DIG_WOOD")),
BLOCK_BAMBOO_FALL, BLOCK_BAMBOO_FALL,
BLOCK_BAMBOO_HIT, BLOCK_BAMBOO_HIT,
BLOCK_BAMBOO_PLACE, BLOCK_BAMBOO_PLACE,
@ -83,8 +84,8 @@ public enum CompatibleSounds {
BLOCK_DISPENSER_FAIL(ServerVersion.V1_9, v("WOOD_CLICK", true)), BLOCK_DISPENSER_FAIL(ServerVersion.V1_9, v("WOOD_CLICK", true)),
BLOCK_DISPENSER_LAUNCH(ServerVersion.V1_9, v("GHAST_FIREBALL", true)), BLOCK_DISPENSER_LAUNCH(ServerVersion.V1_9, v("GHAST_FIREBALL", true)),
BLOCK_ENCHANTMENT_TABLE_USE, BLOCK_ENCHANTMENT_TABLE_USE,
BLOCK_ENDER_CHEST_CLOSE(ServerVersion.V1_9, v("CHEST_CLOSE", true)), BLOCK_ENDER_CHEST_CLOSE(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_ENDERCHEST_CLOSE"), v("CHEST_CLOSE", true)),
BLOCK_ENDER_CHEST_OPEN(ServerVersion.V1_9, v("CHEST_OPEN", true)), BLOCK_ENDER_CHEST_OPEN(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_ENDERCHEST_OPEN"), v("CHEST_OPEN", true)),
BLOCK_END_GATEWAY_SPAWN(ServerVersion.V1_9, v("PORTAL_TRIGGER", true)), BLOCK_END_GATEWAY_SPAWN(ServerVersion.V1_9, v("PORTAL_TRIGGER", true)),
BLOCK_END_PORTAL_FRAME_FILL, BLOCK_END_PORTAL_FRAME_FILL,
BLOCK_END_PORTAL_SPAWN, BLOCK_END_PORTAL_SPAWN,
@ -132,26 +133,26 @@ public enum CompatibleSounds {
BLOCK_METAL_FALL(ServerVersion.V1_9, v(null, true)), BLOCK_METAL_FALL(ServerVersion.V1_9, v(null, true)),
BLOCK_METAL_HIT(ServerVersion.V1_9, v(null, true)), BLOCK_METAL_HIT(ServerVersion.V1_9, v(null, true)),
BLOCK_METAL_PLACE(ServerVersion.V1_9, v(null, true)), BLOCK_METAL_PLACE(ServerVersion.V1_9, v(null, true)),
BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF(ServerVersion.V1_9, v("WOOD_CLICK", true)), BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_METAL_PRESSUREPLATE_CLICK_OFF"), v("WOOD_CLICK", true)),
BLOCK_METAL_PRESSURE_PLATE_CLICK_ON(ServerVersion.V1_9, v("WOOD_CLICK", true)), BLOCK_METAL_PRESSURE_PLATE_CLICK_ON(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_METAL_PRESSUREPLATE_CLICK_ON"), v("WOOD_CLICK", true)),
BLOCK_METAL_STEP(ServerVersion.V1_9, v("STEP_STONE", true)), BLOCK_METAL_STEP(ServerVersion.V1_9, v("STEP_STONE", true)),
BLOCK_NETHER_WART_BREAK, BLOCK_NETHER_WART_BREAK,
BLOCK_NOTE_BLOCK_BANJO(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_GUITAR", true), v(ServerVersion.V1_9, "BLOCK_NOTE_GUITAR", true), v("NOTE_BASS_GUITAR", true)), BLOCK_NOTE_BLOCK_BANJO(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_GUITAR", true), v(ServerVersion.V1_9, "BLOCK_NOTE_GUITAR", true), v("NOTE_BASS_GUITAR", true)),
BLOCK_NOTE_BLOCK_BASEDRUM(v(ServerVersion.V1_9, "BLOCK_NOTE_BASEDRUM"), v("NOTE_BASS_DRUM")), BLOCK_NOTE_BLOCK_BASEDRUM(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_NOTE_BASEDRUM"), v("NOTE_BASS_DRUM")),
BLOCK_NOTE_BLOCK_BASS(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_BASS"), v("NOTE_BASS")), BLOCK_NOTE_BLOCK_BASS(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_NOTE_BASS"), v("NOTE_BASS")),
BLOCK_NOTE_BLOCK_BELL(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_BELL"), v(ServerVersion.V1_11, "BLOCK_NOTE_HARP", true), v("NOTE_PLING", true)), BLOCK_NOTE_BLOCK_BELL(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_BELL"), v(ServerVersion.V1_9, "BLOCK_NOTE_HARP", true), v("NOTE_PLING", true)),
BLOCK_NOTE_BLOCK_BIT(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_BELL", true), v(ServerVersion.V1_12, "BLOCK_NOTE_BELL", true), v(ServerVersion.V1_11, "BLOCK_NOTE_HARP", true), v("NOTE_PLING", true)), BLOCK_NOTE_BLOCK_BIT(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_BELL", true), v(ServerVersion.V1_12, "BLOCK_NOTE_BELL", true), v(ServerVersion.V1_9, "BLOCK_NOTE_HARP", true), v("NOTE_PLING", true)),
BLOCK_NOTE_BLOCK_CHIME(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_CHIME"), v(ServerVersion.V1_11, "BLOCK_NOTE_PLING", true), v("NOTE_PLING", true)), BLOCK_NOTE_BLOCK_CHIME(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_CHIME"), v(ServerVersion.V1_9, "BLOCK_NOTE_PLING", true), v("NOTE_PLING", true)),
BLOCK_NOTE_BLOCK_COW_BELL(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_BELL", true), v(ServerVersion.V1_12, "BLOCK_NOTE_BELL"), v(ServerVersion.V1_11, "BLOCK_NOTE_HARP", true), v("NOTE_PLING", true)), BLOCK_NOTE_BLOCK_COW_BELL(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_BELL", true), v(ServerVersion.V1_12, "BLOCK_NOTE_BELL"), v(ServerVersion.V1_9, "BLOCK_NOTE_HARP", true), v("NOTE_PLING", true)),
BLOCK_NOTE_BLOCK_DIDGERIDOO(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_FLUTE", true), v(ServerVersion.V1_12, "BLOCK_NOTE_FLUTE", true), v(ServerVersion.V1_11, "BLOCK_NOTE_HARP", true), v("NOTE_BASS_GUITAR", true)), BLOCK_NOTE_BLOCK_DIDGERIDOO(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_FLUTE", true), v(ServerVersion.V1_12, "BLOCK_NOTE_FLUTE", true), v(ServerVersion.V1_9, "BLOCK_NOTE_HARP", true), v("NOTE_BASS_GUITAR", true)),
BLOCK_NOTE_BLOCK_FLUTE(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_FLUTE"), v(ServerVersion.V1_11, "BLOCK_NOTE_HARP", true), v("NOTE_BASS_GUITAR", true)), BLOCK_NOTE_BLOCK_FLUTE(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_FLUTE"), v(ServerVersion.V1_9, "BLOCK_NOTE_HARP", true), v("NOTE_BASS_GUITAR", true)),
BLOCK_NOTE_BLOCK_GUITAR(v(ServerVersion.V1_12, "BLOCK_NOTE_GUITAR"), v(ServerVersion.V1_11, "BLOCK_NOTE_HARP", true), v("NOTE_BASS_GUITAR")), // This value disappeared from the API from 1.9-1.11 (returned in 12) BLOCK_NOTE_BLOCK_GUITAR(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_GUITAR"), v(ServerVersion.V1_9, "BLOCK_NOTE_HARP", true), v("NOTE_BASS_GUITAR")), // This value disappeared from the API from 1.9-1.11 (returned in 12)
BLOCK_NOTE_BLOCK_HARP(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_HARP"), v("NOTE_PIANO")), BLOCK_NOTE_BLOCK_HARP(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_NOTE_HARP"), v("NOTE_PIANO")),
BLOCK_NOTE_BLOCK_HAT(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_HAT"), v("NOTE_STICKS")), BLOCK_NOTE_BLOCK_HAT(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_NOTE_HAT"), v("NOTE_STICKS")),
BLOCK_NOTE_BLOCK_IRON_XYLOPHONE(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_XYLOPHONE", true), v(ServerVersion.V1_12, "BLOCK_NOTE_XYLOPHONE", true)), BLOCK_NOTE_BLOCK_IRON_XYLOPHONE(ServerVersion.V1_14, v(ServerVersion.V1_13, "BLOCK_NOTE_BLOCK_XYLOPHONE", true), v(ServerVersion.V1_9, "BLOCK_NOTE_XYLOPHONE", true), v("NOTE_PLING", true)),
BLOCK_NOTE_BLOCK_PLING(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_PLING"), v("NOTE_PLING")), BLOCK_NOTE_BLOCK_PLING(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_NOTE_PLING"), v("NOTE_PLING")),
BLOCK_NOTE_BLOCK_SNARE(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_SNARE"), v("NOTE_SNARE_DRUM")), BLOCK_NOTE_BLOCK_SNARE(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_NOTE_SNARE"), v("NOTE_SNARE_DRUM")),
BLOCK_NOTE_BLOCK_XYLOPHONE(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_XYLOPHONE"), v("NOTE_PLING", true)), BLOCK_NOTE_BLOCK_XYLOPHONE(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_NOTE_XYLOPHONE"), v(ServerVersion.V1_9, "BLOCK_NOTE_PLING", true), v("NOTE_PLING", true)),
BLOCK_PISTON_CONTRACT("PISTON_RETRACT"), BLOCK_PISTON_CONTRACT("PISTON_RETRACT"),
BLOCK_PISTON_EXTEND("PISTON_EXTEND"), BLOCK_PISTON_EXTEND("PISTON_EXTEND"),
BLOCK_PORTAL_AMBIENT("PORTAL"), BLOCK_PORTAL_AMBIENT("PORTAL"),
@ -160,9 +161,9 @@ public enum CompatibleSounds {
BLOCK_PUMPKIN_CARVE, BLOCK_PUMPKIN_CARVE,
BLOCK_REDSTONE_TORCH_BURNOUT("FIZZ"), BLOCK_REDSTONE_TORCH_BURNOUT("FIZZ"),
BLOCK_SAND_BREAK("DIG_SAND"), BLOCK_SAND_BREAK("DIG_SAND"),
BLOCK_SAND_FALL(ServerVersion.V1_9, v( "STEP_SAND", true)), BLOCK_SAND_FALL(ServerVersion.V1_9, v("STEP_SAND", true)),
BLOCK_SAND_HIT(ServerVersion.V1_9, v( "STEP_SAND", true)), BLOCK_SAND_HIT(ServerVersion.V1_9, v("STEP_SAND", true)),
BLOCK_SAND_PLACE(ServerVersion.V1_9, v( "STEP_SAND", true)), BLOCK_SAND_PLACE(ServerVersion.V1_9, v("STEP_SAND", true)),
BLOCK_SAND_STEP("STEP_SAND"), BLOCK_SAND_STEP("STEP_SAND"),
BLOCK_SCAFFOLDING_BREAK, BLOCK_SCAFFOLDING_BREAK,
BLOCK_SCAFFOLDING_FALL, BLOCK_SCAFFOLDING_FALL,
@ -171,11 +172,11 @@ public enum CompatibleSounds {
BLOCK_SCAFFOLDING_STEP, BLOCK_SCAFFOLDING_STEP,
BLOCK_SHULKER_BOX_CLOSE("CHEST_CLOSE"), BLOCK_SHULKER_BOX_CLOSE("CHEST_CLOSE"),
BLOCK_SHULKER_BOX_OPEN("CHEST_OPEN"), BLOCK_SHULKER_BOX_OPEN("CHEST_OPEN"),
BLOCK_SLIME_BLOCK_BREAK(ServerVersion.V1_9, v(null, true)), BLOCK_SLIME_BLOCK_BREAK(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_SLIME_BREAK"), v(null, true)),
BLOCK_SLIME_BLOCK_FALL(ServerVersion.V1_9, v(null, true)), BLOCK_SLIME_BLOCK_FALL(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_SLIME_FALL"), v(null, true)),
BLOCK_SLIME_BLOCK_HIT(ServerVersion.V1_9, v(null, true)), BLOCK_SLIME_BLOCK_HIT(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_SLIME_HIT"), v(null, true)),
BLOCK_SLIME_BLOCK_PLACE(ServerVersion.V1_9, v(null, true)), BLOCK_SLIME_BLOCK_PLACE(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_SLIME_PLACE"), v(null, true)),
BLOCK_SLIME_BLOCK_STEP(ServerVersion.V1_9, v(null, true)), BLOCK_SLIME_BLOCK_STEP(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_SLIME_STEP"), v(null, true)),
BLOCK_SMOKER_SMOKE, BLOCK_SMOKER_SMOKE,
BLOCK_SNOW_BREAK("DIG_SNOW"), BLOCK_SNOW_BREAK("DIG_SNOW"),
BLOCK_SNOW_FALL(ServerVersion.V1_9, v("STEP_SNOW", true)), BLOCK_SNOW_FALL(ServerVersion.V1_9, v("STEP_SNOW", true)),
@ -203,12 +204,12 @@ public enum CompatibleSounds {
BLOCK_WET_GRASS_HIT, BLOCK_WET_GRASS_HIT,
BLOCK_WET_GRASS_PLACE, BLOCK_WET_GRASS_PLACE,
BLOCK_WET_GRASS_STEP, BLOCK_WET_GRASS_STEP,
BLOCK_WOODEN_BUTTON_CLICK_OFF("WOOD_CLICK"), BLOCK_WOODEN_BUTTON_CLICK_OFF(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_WOOD_BUTTON_CLICK_ON"), v("WOOD_CLICK")),
BLOCK_WOODEN_BUTTON_CLICK_ON("WOOD_CLICK"), BLOCK_WOODEN_BUTTON_CLICK_ON(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_WOOD_BUTTON_CLICK_ON"), v("WOOD_CLICK")),
BLOCK_WOODEN_DOOR_CLOSE("DOOR_CLOSE"), BLOCK_WOODEN_DOOR_CLOSE("DOOR_CLOSE"),
BLOCK_WOODEN_DOOR_OPEN("DOOR_OPEN"), BLOCK_WOODEN_DOOR_OPEN("DOOR_OPEN"),
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF(ServerVersion.V1_9, v("WOOD_CLICK", true)), BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_WOOD_PRESSUREPLATE_CLICK_OFF"), v("WOOD_CLICK", true)),
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON(ServerVersion.V1_9, v("WOOD_CLICK", true)), BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_WOOD_PRESSUREPLATE_CLICK_ON"), v("WOOD_CLICK", true)),
BLOCK_WOODEN_TRAPDOOR_CLOSE("DOOR_OPEN"), BLOCK_WOODEN_TRAPDOOR_CLOSE("DOOR_OPEN"),
BLOCK_WOODEN_TRAPDOOR_OPEN("DOOR_OPEN"), BLOCK_WOODEN_TRAPDOOR_OPEN("DOOR_OPEN"),
BLOCK_WOOD_BREAK("DIG_WOOD"), BLOCK_WOOD_BREAK("DIG_WOOD"),
@ -216,11 +217,11 @@ public enum CompatibleSounds {
BLOCK_WOOD_HIT(ServerVersion.V1_9, v("STEP_WOOD", true)), BLOCK_WOOD_HIT(ServerVersion.V1_9, v("STEP_WOOD", true)),
BLOCK_WOOD_PLACE(ServerVersion.V1_9, v("STEP_WOOD", true)), BLOCK_WOOD_PLACE(ServerVersion.V1_9, v("STEP_WOOD", true)),
BLOCK_WOOD_STEP("STEP_WOOD"), BLOCK_WOOD_STEP("STEP_WOOD"),
BLOCK_WOOL_BREAK(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_CLOTH_BREAK"), v("DIG_WOOL")), BLOCK_WOOL_BREAK(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_CLOTH_BREAK"), v("DIG_WOOL")),
BLOCK_WOOL_FALL(ServerVersion.V1_13, v(ServerVersion.V1_9,"BLOCK_CLOTH_STEP", true), v("STEP_WOOL", true)), BLOCK_WOOL_FALL(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_CLOTH_STEP", true), v("STEP_WOOL", true)),
BLOCK_WOOL_HIT(ServerVersion.V1_13, v(ServerVersion.V1_9,"BLOCK_CLOTH_STEP", true), v("STEP_WOOL", true)), BLOCK_WOOL_HIT(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_CLOTH_STEP", true), v("STEP_WOOL", true)),
BLOCK_WOOL_PLACE(ServerVersion.V1_13, v(ServerVersion.V1_9,"BLOCK_CLOTH_STEP", true), v("STEP_WOOL", true)), BLOCK_WOOL_PLACE(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_CLOTH_STEP", true), v("STEP_WOOL", true)),
BLOCK_WOOL_STEP(ServerVersion.V1_13, v(ServerVersion.V1_12, "BLOCK_CLOTH_STEP"), v("STEP_WOOL")), BLOCK_WOOL_STEP(ServerVersion.V1_13, v(ServerVersion.V1_9, "BLOCK_CLOTH_STEP"), v("STEP_WOOL")),
ENCHANT_THORNS_HIT, ENCHANT_THORNS_HIT,
ENTITY_ARMOR_STAND_BREAK, ENTITY_ARMOR_STAND_BREAK,
ENTITY_ARMOR_STAND_FALL, ENTITY_ARMOR_STAND_FALL,
@ -241,10 +242,10 @@ public enum CompatibleSounds {
ENTITY_BLAZE_SHOOT, ENTITY_BLAZE_SHOOT,
ENTITY_BOAT_PADDLE_LAND, ENTITY_BOAT_PADDLE_LAND,
ENTITY_BOAT_PADDLE_WATER, ENTITY_BOAT_PADDLE_WATER,
ENTITY_CAT_AMBIENT, ENTITY_CAT_AMBIENT(ServerVersion.V1_9, v("CAT_MEOW")),
ENTITY_CAT_BEG_FOR_FOOD("CAT_MEOW"), ENTITY_CAT_BEG_FOR_FOOD(ServerVersion.V1_14, v(ServerVersion.V1_9, "ENTITY_CAT_AMBIENT", true), v("CAT_MEOW", true)),
ENTITY_CAT_DEATH, ENTITY_CAT_DEATH,
ENTITY_CAT_EAT("EAT"), ENTITY_CAT_EAT(ServerVersion.V1_14, v(ServerVersion.V1_9, "ENTITY_GENERIC_EAT"), v("EAT")),
ENTITY_CAT_HISS("CAT_HISS"), ENTITY_CAT_HISS("CAT_HISS"),
ENTITY_CAT_HURT("CAT_HIT"), ENTITY_CAT_HURT("CAT_HIT"),
ENTITY_CAT_PURR("CAT_PURR"), ENTITY_CAT_PURR("CAT_PURR"),
@ -255,12 +256,12 @@ public enum CompatibleSounds {
ENTITY_CHICKEN_EGG("CHICKEN_EGG_POP"), ENTITY_CHICKEN_EGG("CHICKEN_EGG_POP"),
ENTITY_CHICKEN_HURT("CHICKEN_HURT"), ENTITY_CHICKEN_HURT("CHICKEN_HURT"),
ENTITY_CHICKEN_STEP("CHICKEN_WALK"), ENTITY_CHICKEN_STEP("CHICKEN_WALK"),
ENTITY_COD_AMBIENT("COW_IDLE"), ENTITY_COD_AMBIENT,
ENTITY_COD_DEATH, ENTITY_COD_DEATH,
ENTITY_COD_FLOP, ENTITY_COD_FLOP,
ENTITY_COD_HURT("COW_HURT"), ENTITY_COD_HURT,
ENTITY_COW_AMBIENT, ENTITY_COW_AMBIENT("COW_IDLE"),
ENTITY_COW_DEATH, ENTITY_COW_DEATH("COW_HURT"),
ENTITY_COW_HURT("COW_HURT"), ENTITY_COW_HURT("COW_HURT"),
ENTITY_COW_MILK, ENTITY_COW_MILK,
ENTITY_COW_STEP("COW_WALK"), ENTITY_COW_STEP("COW_WALK"),
@ -271,11 +272,11 @@ public enum CompatibleSounds {
ENTITY_DOLPHIN_AMBIENT_WATER, ENTITY_DOLPHIN_AMBIENT_WATER,
ENTITY_DOLPHIN_ATTACK, ENTITY_DOLPHIN_ATTACK,
ENTITY_DOLPHIN_DEATH, ENTITY_DOLPHIN_DEATH,
ENTITY_DOLPHIN_EAT(ServerVersion.V1_13, v(ServerVersion.V1_12, "ENTITY_GENERIC_EAT", true), v("EAT", true)), ENTITY_DOLPHIN_EAT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_GENERIC_EAT", true), v("EAT", true)),
ENTITY_DOLPHIN_HURT, ENTITY_DOLPHIN_HURT,
ENTITY_DOLPHIN_JUMP, ENTITY_DOLPHIN_JUMP,
ENTITY_DOLPHIN_PLAY, ENTITY_DOLPHIN_PLAY,
ENTITY_DOLPHIN_SPLASH(ServerVersion.V1_13, v(ServerVersion.V1_12, "ENTITY_GENERIC_SPLASH", true), v("SPLASH", true)), ENTITY_DOLPHIN_SPLASH(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_GENERIC_SPLASH", true), v("SPLASH", true)),
ENTITY_DOLPHIN_SWIM, ENTITY_DOLPHIN_SWIM,
ENTITY_DONKEY_AMBIENT("DONKEY_IDLE"), ENTITY_DONKEY_AMBIENT("DONKEY_IDLE"),
ENTITY_DONKEY_ANGRY("DONKEY_ANGRY"), ENTITY_DONKEY_ANGRY("DONKEY_ANGRY"),
@ -301,24 +302,24 @@ public enum CompatibleSounds {
ENTITY_ELDER_GUARDIAN_FLOP, ENTITY_ELDER_GUARDIAN_FLOP,
ENTITY_ELDER_GUARDIAN_HURT, ENTITY_ELDER_GUARDIAN_HURT,
ENTITY_ELDER_GUARDIAN_HURT_LAND, ENTITY_ELDER_GUARDIAN_HURT_LAND,
ENTITY_ENDERMAN_AMBIENT("ENDERMAN_IDLE"), ENTITY_ENDERMAN_AMBIENT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERMEN_AMBIENT"), v("ENDERMAN_IDLE")),
ENTITY_ENDERMAN_DEATH("ENDERMAN_DEATH"), ENTITY_ENDERMAN_DEATH(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERMEN_DEATH"), v("ENDERMAN_DEATH")),
ENTITY_ENDERMAN_HURT("ENDERMAN_HIT"), ENTITY_ENDERMAN_HURT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERMEN_HURT"), v("ENDERMAN_HIT")),
ENTITY_ENDERMAN_SCREAM("ENDERMAN_SCREAM"), ENTITY_ENDERMAN_SCREAM(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERMEN_SCREAM"), v("ENDERMAN_SCREAM")),
ENTITY_ENDERMAN_STARE("ENDERMAN_STARE"), ENTITY_ENDERMAN_STARE(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERMEN_STARE"), v("ENDERMAN_STARE")),
ENTITY_ENDERMAN_TELEPORT("ENDERMAN_TELEPORT"), ENTITY_ENDERMAN_TELEPORT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERMEN_TELEPORT"), v("ENDERMAN_TELEPORT")),
ENTITY_ENDERMITE_AMBIENT, ENTITY_ENDERMITE_AMBIENT,
ENTITY_ENDERMITE_DEATH, ENTITY_ENDERMITE_DEATH,
ENTITY_ENDERMITE_HURT, ENTITY_ENDERMITE_HURT,
ENTITY_ENDERMITE_STEP, ENTITY_ENDERMITE_STEP,
ENTITY_ENDER_DRAGON_AMBIENT, ENTITY_ENDER_DRAGON_AMBIENT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERDRAGON_AMBIENT"), v("ENDERDRAGON_GROWL", true)),
ENTITY_ENDER_DRAGON_DEATH("ENDERDRAGON_DEATH"), ENTITY_ENDER_DRAGON_DEATH(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERDRAGON_DEATH"), v("ENDERDRAGON_DEATH")),
ENTITY_ENDER_DRAGON_FLAP("ENDERDRAGON_WINGS"), ENTITY_ENDER_DRAGON_FLAP(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERDRAGON_FLAP"), v("ENDERDRAGON_WINGS")),
ENTITY_ENDER_DRAGON_GROWL("ENDERDRAGON_GROWL"), ENTITY_ENDER_DRAGON_GROWL(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERDRAGON_GROWL"), v("ENDERDRAGON_GROWL")),
ENTITY_ENDER_DRAGON_HURT("ENDERDRAGON_HIT"), ENTITY_ENDER_DRAGON_HURT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERDRAGON_HURT"), v("ENDERDRAGON_HIT")),
ENTITY_ENDER_DRAGON_SHOOT, ENTITY_ENDER_DRAGON_SHOOT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDERDRAGON_SHOOT"), v("GHAST_FIREBALL", true)),
ENTITY_ENDER_EYE_DEATH, ENTITY_ENDER_EYE_DEATH(ServerVersion.V1_13, v(ServerVersion.V1_12, "ENTITY_ENDEREYE_DEATH"), v(ServerVersion.V1_9, "BLOCK_GLASS_BREAK", true), v("GLASS", true)),
ENTITY_ENDER_EYE_LAUNCH, ENTITY_ENDER_EYE_LAUNCH(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ENDEREYE_LAUNCH"), v("BLOCK_PORTAL_TRIGGER", true)),
ENTITY_ENDER_PEARL_THROW, ENTITY_ENDER_PEARL_THROW,
ENTITY_EVOKER_AMBIENT, ENTITY_EVOKER_AMBIENT,
ENTITY_EVOKER_CAST_SPELL, ENTITY_EVOKER_CAST_SPELL,
@ -331,14 +332,14 @@ public enum CompatibleSounds {
ENTITY_EVOKER_PREPARE_WOLOLO, ENTITY_EVOKER_PREPARE_WOLOLO,
ENTITY_EXPERIENCE_BOTTLE_THROW, ENTITY_EXPERIENCE_BOTTLE_THROW,
ENTITY_EXPERIENCE_ORB_PICKUP("ORB_PICKUP"), ENTITY_EXPERIENCE_ORB_PICKUP("ORB_PICKUP"),
ENTITY_FIREWORK_ROCKET_BLAST("FIREWORK_BLAST"), ENTITY_FIREWORK_ROCKET_BLAST(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_FIREWORK_BLAST"), v("FIREWORK_BLAST")),
ENTITY_FIREWORK_ROCKET_BLAST_FAR("FIREWORK_BLAST2"), ENTITY_FIREWORK_ROCKET_BLAST_FAR(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_FIREWORK_BLAST_FAR"), v("FIREWORK_BLAST2")),
ENTITY_FIREWORK_ROCKET_LARGE_BLAST("FIREWORK_LARGE_BLAST"), ENTITY_FIREWORK_ROCKET_LARGE_BLAST(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_FIREWORK_LARGE_BLAST"), v("FIREWORK_LARGE_BLAST")),
ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR("FIREWORK_LARGE_BLAST2"), ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_FIREWORK_LARGE_BLAST_FAR"), v("FIREWORK_LARGE_BLAST2")),
ENTITY_FIREWORK_ROCKET_LAUNCH("FIREWORK_LAUNCH"), ENTITY_FIREWORK_ROCKET_LAUNCH(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_FIREWORK_LAUNCH"), v("FIREWORK_LAUNCH")),
ENTITY_FIREWORK_ROCKET_SHOOT, ENTITY_FIREWORK_ROCKET_SHOOT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_FIREWORK_SHOOT"), v("FIREWORK_LAUNCH", true)),
ENTITY_FIREWORK_ROCKET_TWINKLE("FIREWORK_TWINKLE"), ENTITY_FIREWORK_ROCKET_TWINKLE(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_FIREWORK_TWINKLE"), v("FIREWORK_TWINKLE")),
ENTITY_FIREWORK_ROCKET_TWINKLE_FAR("FIREWORK_TWINKLE2"), ENTITY_FIREWORK_ROCKET_TWINKLE_FAR(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_FIREWORK_TWINKLE_FAR"), v("FIREWORK_TWINKLE2")),
ENTITY_FISHING_BOBBER_RETRIEVE, ENTITY_FISHING_BOBBER_RETRIEVE,
ENTITY_FISHING_BOBBER_SPLASH, ENTITY_FISHING_BOBBER_SPLASH,
ENTITY_FISHING_BOBBER_THROW, ENTITY_FISHING_BOBBER_THROW,
@ -347,7 +348,7 @@ public enum CompatibleSounds {
ENTITY_FOX_AMBIENT, ENTITY_FOX_AMBIENT,
ENTITY_FOX_BITE, ENTITY_FOX_BITE,
ENTITY_FOX_DEATH, ENTITY_FOX_DEATH,
ENTITY_FOX_EAT("EAT"), ENTITY_FOX_EAT(ServerVersion.V1_14, v(ServerVersion.V1_9, "ENTITY_GENERIC_EAT", true), v("EAT", true)),
ENTITY_FOX_HURT, ENTITY_FOX_HURT,
ENTITY_FOX_SCREECH, ENTITY_FOX_SCREECH,
ENTITY_FOX_SLEEP, ENTITY_FOX_SLEEP,
@ -409,10 +410,10 @@ public enum CompatibleSounds {
ENTITY_ILLUSIONER_MIRROR_MOVE, ENTITY_ILLUSIONER_MIRROR_MOVE,
ENTITY_ILLUSIONER_PREPARE_BLINDNESS, ENTITY_ILLUSIONER_PREPARE_BLINDNESS,
ENTITY_ILLUSIONER_PREPARE_MIRROR, ENTITY_ILLUSIONER_PREPARE_MIRROR,
ENTITY_IRON_GOLEM_ATTACK("IRONGOLEM_THROW"), ENTITY_IRON_GOLEM_ATTACK(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_IRONGOLEM_ATTACK"), v("IRONGOLEM_THROW")),
ENTITY_IRON_GOLEM_DEATH("IRONGOLEM_DEATH"), ENTITY_IRON_GOLEM_DEATH(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_IRONGOLEM_DEATH"), v("IRONGOLEM_DEATH")),
ENTITY_IRON_GOLEM_HURT("IRONGOLEM_HIT"), ENTITY_IRON_GOLEM_HURT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_IRONGOLEM_HURT"), v("IRONGOLEM_HIT")),
ENTITY_IRON_GOLEM_STEP("IRONGOLEM_WALK"), ENTITY_IRON_GOLEM_STEP(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_IRONGOLEM_STEP"), v("IRONGOLEM_WALK")),
ENTITY_ITEM_BREAK("ITEM_BREAK"), ENTITY_ITEM_BREAK("ITEM_BREAK"),
ENTITY_ITEM_FRAME_ADD_ITEM, ENTITY_ITEM_FRAME_ADD_ITEM,
ENTITY_ITEM_FRAME_BREAK, ENTITY_ITEM_FRAME_BREAK,
@ -422,8 +423,8 @@ public enum CompatibleSounds {
ENTITY_ITEM_PICKUP("ITEM_PICKUP"), ENTITY_ITEM_PICKUP("ITEM_PICKUP"),
ENTITY_LEASH_KNOT_BREAK, ENTITY_LEASH_KNOT_BREAK,
ENTITY_LEASH_KNOT_PLACE, ENTITY_LEASH_KNOT_PLACE,
ENTITY_LIGHTNING_BOLT_IMPACT, ENTITY_LIGHTNING_BOLT_IMPACT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_LIGHTNING_IMPACT"), v("AMBIENCE_THUNDER", true)),
ENTITY_LIGHTNING_BOLT_THUNDER("AMBIENCE_THUNDER"), ENTITY_LIGHTNING_BOLT_THUNDER(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_LIGHTNING_THUNDER"), v("AMBIENCE_THUNDER")),
ENTITY_LINGERING_POTION_THROW, ENTITY_LINGERING_POTION_THROW,
ENTITY_LLAMA_AMBIENT, ENTITY_LLAMA_AMBIENT,
ENTITY_LLAMA_ANGRY, ENTITY_LLAMA_ANGRY,
@ -434,17 +435,17 @@ public enum CompatibleSounds {
ENTITY_LLAMA_SPIT, ENTITY_LLAMA_SPIT,
ENTITY_LLAMA_STEP, ENTITY_LLAMA_STEP,
ENTITY_LLAMA_SWAG, ENTITY_LLAMA_SWAG,
ENTITY_MAGMA_CUBE_DEATH, ENTITY_MAGMA_CUBE_DEATH, // ENTITY_MAGMACUBE_DEATH
ENTITY_MAGMA_CUBE_DEATH_SMALL, ENTITY_MAGMA_CUBE_DEATH_SMALL,
ENTITY_MAGMA_CUBE_HURT, ENTITY_MAGMA_CUBE_HURT, // ENTITY_MAGMACUBE_HURT
ENTITY_MAGMA_CUBE_HURT_SMALL, ENTITY_MAGMA_CUBE_HURT_SMALL,
ENTITY_MAGMA_CUBE_JUMP("MAGMACUBE_JUMP"), ENTITY_MAGMA_CUBE_JUMP(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_MAGMACUBE_JUMP"), v("MAGMACUBE_JUMP")),
ENTITY_MAGMA_CUBE_SQUISH("MAGMACUBE_WALK"), ENTITY_MAGMA_CUBE_SQUISH(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_MAGMACUBE_SQUISH"), v("MAGMACUBE_WALK")),
ENTITY_MAGMA_CUBE_SQUISH_SMALL("MAGMACUBE_WALK2"), ENTITY_MAGMA_CUBE_SQUISH_SMALL(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_MAGMACUBE_SQUISH", true), v("MAGMACUBE_WALK2")),
ENTITY_MINECART_INSIDE("MINECART_INSIDE"), ENTITY_MINECART_INSIDE("MINECART_INSIDE"),
ENTITY_MINECART_RIDING("MINECART_BASE"), ENTITY_MINECART_RIDING("MINECART_BASE"),
ENTITY_MOOSHROOM_CONVERT, ENTITY_MOOSHROOM_CONVERT,
ENTITY_MOOSHROOM_EAT("EAT"), ENTITY_MOOSHROOM_EAT(ServerVersion.V1_14, v(ServerVersion.V1_9, "ENTITY_GENERIC_EAT", true), v("EAT", true)),
ENTITY_MOOSHROOM_MILK, ENTITY_MOOSHROOM_MILK,
ENTITY_MOOSHROOM_SHEAR, ENTITY_MOOSHROOM_SHEAR,
ENTITY_MOOSHROOM_SUSPICIOUS_MILK, ENTITY_MOOSHROOM_SUSPICIOUS_MILK,
@ -462,7 +463,7 @@ public enum CompatibleSounds {
ENTITY_PANDA_BITE, ENTITY_PANDA_BITE,
ENTITY_PANDA_CANT_BREED, ENTITY_PANDA_CANT_BREED,
ENTITY_PANDA_DEATH, ENTITY_PANDA_DEATH,
ENTITY_PANDA_EAT("EAT"), ENTITY_PANDA_EAT(ServerVersion.V1_14, v(ServerVersion.V1_9, "ENTITY_GENERIC_EAT", true), v("EAT", true)),
ENTITY_PANDA_HURT, ENTITY_PANDA_HURT,
ENTITY_PANDA_PRE_SNEEZE, ENTITY_PANDA_PRE_SNEEZE,
ENTITY_PANDA_SNEEZE, ENTITY_PANDA_SNEEZE,
@ -470,7 +471,7 @@ public enum CompatibleSounds {
ENTITY_PANDA_WORRIED_AMBIENT, ENTITY_PANDA_WORRIED_AMBIENT,
ENTITY_PARROT_AMBIENT, ENTITY_PARROT_AMBIENT,
ENTITY_PARROT_DEATH, ENTITY_PARROT_DEATH,
ENTITY_PARROT_EAT("EAT"), ENTITY_PARROT_EAT(ServerVersion.V1_12, v(ServerVersion.V1_9, "ENTITY_GENERIC_EAT", true), v("EAT", true)),
ENTITY_PARROT_FLY, ENTITY_PARROT_FLY,
ENTITY_PARROT_HURT, ENTITY_PARROT_HURT,
ENTITY_PARROT_IMITATE_BLAZE, ENTITY_PARROT_IMITATE_BLAZE,
@ -539,7 +540,7 @@ public enum CompatibleSounds {
ENTITY_PLAYER_LEVELUP("LEVEL_UP"), ENTITY_PLAYER_LEVELUP("LEVEL_UP"),
ENTITY_PLAYER_SMALL_FALL, ENTITY_PLAYER_SMALL_FALL,
ENTITY_PLAYER_SPLASH("SPLASH"), ENTITY_PLAYER_SPLASH("SPLASH"),
ENTITY_PLAYER_SPLASH_HIGH_SPEED("SPLASH2"), ENTITY_PLAYER_SPLASH_HIGH_SPEED(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_GENERIC_SPLASH"), v("SPLASH2", true)),
ENTITY_PLAYER_SWIM("SWIM"), ENTITY_PLAYER_SWIM("SWIM"),
ENTITY_POLAR_BEAR_AMBIENT, ENTITY_POLAR_BEAR_AMBIENT,
ENTITY_POLAR_BEAR_AMBIENT_BABY, ENTITY_POLAR_BEAR_AMBIENT_BABY,
@ -608,15 +609,15 @@ public enum CompatibleSounds {
ENTITY_SLIME_DEATH_SMALL, ENTITY_SLIME_DEATH_SMALL,
ENTITY_SLIME_HURT, ENTITY_SLIME_HURT,
ENTITY_SLIME_HURT_SMALL, ENTITY_SLIME_HURT_SMALL,
ENTITY_SLIME_JUMP("SLIME_WALK2"), // Not sure which is 1 or 2 ENTITY_SLIME_JUMP("SLIME_WALK"), // Not sure which is 1 or 2
ENTITY_SLIME_JUMP_SMALL("SLIME_WALK"), ENTITY_SLIME_JUMP_SMALL(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_SLIME_JUMP", true), v("SLIME_WALK", true)),
ENTITY_SLIME_SQUISH("SLIME_WALK2"), ENTITY_SLIME_SQUISH("SLIME_WALK2"),
ENTITY_SLIME_SQUISH_SMALL("SLIME_WALK"), ENTITY_SLIME_SQUISH_SMALL(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_SLIME_JUMP", true), v("SLIME_WALK2", true)),
ENTITY_SNOWBALL_THROW, ENTITY_SNOWBALL_THROW,
ENTITY_SNOW_GOLEM_AMBIENT, ENTITY_SNOW_GOLEM_AMBIENT,
ENTITY_SNOW_GOLEM_DEATH, ENTITY_SNOW_GOLEM_DEATH,
ENTITY_SNOW_GOLEM_HURT, ENTITY_SNOW_GOLEM_HURT,
ENTITY_SNOW_GOLEM_SHOOT(ServerVersion.V1_13, v(ServerVersion.V1_12, "ENTITY_SNOWMAN_SHOOT"), v("SHOOT_ARROW", true)), // this is missing from 1.8 API for some reason ENTITY_SNOW_GOLEM_SHOOT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_SNOWMAN_SHOOT"), v("SHOOT_ARROW", true)), // this is missing from 1.8 API for some reason
ENTITY_SPIDER_AMBIENT("SPIDER_IDLE"), ENTITY_SPIDER_AMBIENT("SPIDER_IDLE"),
ENTITY_SPIDER_DEATH("SPIDER_DEATH"), ENTITY_SPIDER_DEATH("SPIDER_DEATH"),
ENTITY_SPIDER_HURT, ENTITY_SPIDER_HURT,
@ -657,7 +658,7 @@ public enum CompatibleSounds {
ENTITY_VILLAGER_DEATH("VILLAGER_DEATH"), ENTITY_VILLAGER_DEATH("VILLAGER_DEATH"),
ENTITY_VILLAGER_HURT("VILLAGER_HIT"), ENTITY_VILLAGER_HURT("VILLAGER_HIT"),
ENTITY_VILLAGER_NO("VILLAGER_NO"), ENTITY_VILLAGER_NO("VILLAGER_NO"),
ENTITY_VILLAGER_TRADE("VILLAGER_HAGGLE"), ENTITY_VILLAGER_TRADE(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_VILLAGER_TRADING"), v("VILLAGER_HAGGLE")),
ENTITY_VILLAGER_WORK_ARMORER, ENTITY_VILLAGER_WORK_ARMORER,
ENTITY_VILLAGER_WORK_BUTCHER, ENTITY_VILLAGER_WORK_BUTCHER,
ENTITY_VILLAGER_WORK_CARTOGRAPHER, ENTITY_VILLAGER_WORK_CARTOGRAPHER,
@ -679,8 +680,8 @@ public enum CompatibleSounds {
ENTITY_WANDERING_TRADER_AMBIENT, ENTITY_WANDERING_TRADER_AMBIENT,
ENTITY_WANDERING_TRADER_DEATH, ENTITY_WANDERING_TRADER_DEATH,
ENTITY_WANDERING_TRADER_DISAPPEARED, ENTITY_WANDERING_TRADER_DISAPPEARED,
ENTITY_WANDERING_TRADER_DRINK_MILK("DRINK"), ENTITY_WANDERING_TRADER_DRINK_MILK(ServerVersion.V1_14, v(ServerVersion.V1_9, "ENTITY_GENERIC_DRINK", true), v("DRINK", true)),
ENTITY_WANDERING_TRADER_DRINK_POTION("DRINK"), ENTITY_WANDERING_TRADER_DRINK_POTION(ServerVersion.V1_14, v(ServerVersion.V1_9, "ENTITY_GENERIC_DRINK", true), v("DRINK", true)),
ENTITY_WANDERING_TRADER_HURT, ENTITY_WANDERING_TRADER_HURT,
ENTITY_WANDERING_TRADER_NO, ENTITY_WANDERING_TRADER_NO,
ENTITY_WANDERING_TRADER_REAPPEARED, ENTITY_WANDERING_TRADER_REAPPEARED,
@ -712,9 +713,9 @@ public enum CompatibleSounds {
ENTITY_WOLF_STEP("WOLF_WALK"), ENTITY_WOLF_STEP("WOLF_WALK"),
ENTITY_WOLF_WHINE("WOLF_WHINE"), ENTITY_WOLF_WHINE("WOLF_WHINE"),
ENTITY_ZOMBIE_AMBIENT("ZOMBIE_IDLE"), ENTITY_ZOMBIE_AMBIENT("ZOMBIE_IDLE"),
ENTITY_ZOMBIE_ATTACK_IRON_DOOR("ZOMBIE_METAL"), ENTITY_ZOMBIE_ATTACK_IRON_DOOR(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ZOMBIE_ATTACK_IRON_DOOR", true), v("ZOMBIE_METAL")),
ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR("ZOMBIE_WOOD"), ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ZOMBIE_ATTACK_DOOR_WOOD", true), v("ZOMBIE_WOOD")),
ENTITY_ZOMBIE_BREAK_WOODEN_DOOR("ZOMBIE_WOODBREAK"), ENTITY_ZOMBIE_BREAK_WOODEN_DOOR(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ZOMBIE_BREAK_DOOR_WOOD", true), v("ZOMBIE_WOODBREAK")),
ENTITY_ZOMBIE_CONVERTED_TO_DROWNED, ENTITY_ZOMBIE_CONVERTED_TO_DROWNED,
ENTITY_ZOMBIE_DEATH("ZOMBIE_DEATH"), ENTITY_ZOMBIE_DEATH("ZOMBIE_DEATH"),
ENTITY_ZOMBIE_DESTROY_EGG, ENTITY_ZOMBIE_DESTROY_EGG,
@ -723,10 +724,10 @@ public enum CompatibleSounds {
ENTITY_ZOMBIE_HORSE_HURT("HORSE_ZOMBIE_HIT"), ENTITY_ZOMBIE_HORSE_HURT("HORSE_ZOMBIE_HIT"),
ENTITY_ZOMBIE_HURT("ZOMBIE_HURT"), ENTITY_ZOMBIE_HURT("ZOMBIE_HURT"),
ENTITY_ZOMBIE_INFECT("ZOMBIE_INFECT"), ENTITY_ZOMBIE_INFECT("ZOMBIE_INFECT"),
ENTITY_ZOMBIE_PIGMAN_AMBIENT("ZOMBIE_PIG_IDLE"), ENTITY_ZOMBIE_PIGMAN_AMBIENT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ZOMBIE_PIG_AMBIENT", true), v("ZOMBIE_PIG_IDLE")),
ENTITY_ZOMBIE_PIGMAN_ANGRY("ZOMBIE_PIG_ANGRY"), ENTITY_ZOMBIE_PIGMAN_ANGRY(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ZOMBIE_PIG_ANGRY", true), v("ZOMBIE_PIG_ANGRY")),
ENTITY_ZOMBIE_PIGMAN_DEATH("ZOMBIE_PIG_DEATH"), ENTITY_ZOMBIE_PIGMAN_DEATH(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ZOMBIE_PIG_DEATH", true), v("ZOMBIE_PIG_DEATH")),
ENTITY_ZOMBIE_PIGMAN_HURT("ZOMBIE_PIG_HURT"), ENTITY_ZOMBIE_PIGMAN_HURT(ServerVersion.V1_13, v(ServerVersion.V1_9, "ENTITY_ZOMBIE_PIG_HURT", true), v("ZOMBIE_PIG_HURT")),
ENTITY_ZOMBIE_STEP("ZOMBIE_WALK"), ENTITY_ZOMBIE_STEP("ZOMBIE_WALK"),
ENTITY_ZOMBIE_VILLAGER_AMBIENT, ENTITY_ZOMBIE_VILLAGER_AMBIENT,
ENTITY_ZOMBIE_VILLAGER_CONVERTED("ZOMBIE_REMEDY"), ENTITY_ZOMBIE_VILLAGER_CONVERTED("ZOMBIE_REMEDY"),
@ -815,8 +816,9 @@ public enum CompatibleSounds {
WEATHER_RAIN("AMBIENCE_RAIN"), WEATHER_RAIN("AMBIENCE_RAIN"),
WEATHER_RAIN_ABOVE; WEATHER_RAIN_ABOVE;
protected final Sound sound; protected /*final*/ Sound sound;
protected final boolean compatibilityMode; protected /*final*/ boolean compatibilityMode;
protected static final boolean DEBUG = true;
private CompatibleSounds() { private CompatibleSounds() {
// This could get risky, since we haven't finished this // This could get risky, since we haven't finished this
@ -828,21 +830,30 @@ public enum CompatibleSounds {
break; break;
} }
} }
if(DEBUG && find == null) {
System.out.println("Sound for " + name() + " Not found!");
}
sound = find; sound = find;
compatibilityMode = find == null; compatibilityMode = find == null;
} }
// if the sound ony ever changed from 1.8 -> 1.9 // if the sound ony ever changed from 1.8 -> 1.9
private CompatibleSounds(String compatibility_18) { private CompatibleSounds(String compatibility_18) {
try {
compatibilityMode = false; compatibilityMode = false;
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_9)) { if (ServerVersion.isServerVersionBelow(ServerVersion.V1_9)) {
sound = Sound.valueOf(compatibility_18); sound = Sound.valueOf(compatibility_18);
} else { } else {
sound = Sound.valueOf(name()); sound = Sound.valueOf(name());
} }
} catch (Exception e) {
System.out.println("ERROR loading " + name());
e.printStackTrace();
}
} }
private CompatibleSounds(Version... versions) { private CompatibleSounds(Version... versions) {
try {
for (Version v : versions) { for (Version v : versions) {
if (v.sound != null && ServerVersion.isServerVersionAtLeast(v.version)) { if (v.sound != null && ServerVersion.isServerVersionAtLeast(v.version)) {
sound = Sound.valueOf(v.sound); sound = Sound.valueOf(v.sound);
@ -851,6 +862,13 @@ public enum CompatibleSounds {
} }
} }
} catch (Exception e) {
System.out.println("ERROR loading " + name());
for (Version v : versions) {
System.out.println(v.version + " - " + v.sound);
}
e.printStackTrace();
}
Sound find = null; Sound find = null;
for (Sound s : Sound.values()) { for (Sound s : Sound.values()) {
if (s.name().equals(name())) { if (s.name().equals(name())) {
@ -863,6 +881,7 @@ public enum CompatibleSounds {
} }
private CompatibleSounds(ServerVersion minVersion, Version... versions) { private CompatibleSounds(ServerVersion minVersion, Version... versions) {
try {
if (ServerVersion.isServerVersionAtLeast(minVersion)) { if (ServerVersion.isServerVersionAtLeast(minVersion)) {
// should be good to use this sound // should be good to use this sound
sound = Sound.valueOf(name()); sound = Sound.valueOf(name());
@ -878,6 +897,13 @@ public enum CompatibleSounds {
sound = null; sound = null;
compatibilityMode = false; compatibilityMode = false;
} }
} catch (Exception e) {
System.out.println("ERROR loading " + name() + " (" + minVersion);
for (Version v : versions) {
System.out.println(v.version + " - " + v.sound);
}
e.printStackTrace();
}
} }
/** /**

View File

@ -8,13 +8,13 @@ public enum ServerVersion {
UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20; UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20;
private final static String serverPackagePath = Bukkit.getServer().getClass().getPackage().getName(); private final static String serverPackagePath = Bukkit.getServer().getClass().getPackage().getName();
private final static String serverPackageVersion = serverPackagePath.substring(serverPackagePath.lastIndexOf('.') + 1).toUpperCase(); private final static String serverPackageVersion = serverPackagePath.substring(serverPackagePath.lastIndexOf('.') + 1);
private static ServerVersion serverVersion = UNKNOWN; private static ServerVersion serverVersion = UNKNOWN;
private static String serverReleaseVersion; private static String serverReleaseVersion;
static { static {
for (ServerVersion version : values()) { for (ServerVersion version : values()) {
if (serverPackageVersion.startsWith(version.name())) { if (serverPackageVersion.toUpperCase().startsWith(version.name())) {
serverVersion = version; serverVersion = version;
serverReleaseVersion = serverPackageVersion.substring(version.name().length() + 2); serverReleaseVersion = serverPackageVersion.substring(version.name().length() + 2);
} }

View File

@ -7,6 +7,7 @@ import com.songoda.core.gui.methods.Droppable;
import com.songoda.core.gui.methods.Openable; import com.songoda.core.gui.methods.Openable;
import com.songoda.core.gui.methods.Pagable; import com.songoda.core.gui.methods.Pagable;
import com.songoda.core.gui.methods.SimpleClickable; import com.songoda.core.gui.methods.SimpleClickable;
import com.songoda.core.utils.ItemUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -18,9 +19,9 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
/** /**
* DO NOT USE YET! * TODO: does not restore inventory if server crashes while player inventory is open
* TODO: does not restore inventory if server is shut down while player inventory is open (1.8)
* Method to fix: save inv + ender slot to file, store paper in ender inv with name of cache file, check for paper item in slot when loading * Method to fix: save inv + ender slot to file, store paper in ender inv with name of cache file, check for paper item in slot when loading
* Or just manually manage all inventories in a file and remove when restored
* *
* @since 2019-08-25 * @since 2019-08-25
* @author jascotty2 * @author jascotty2
@ -106,6 +107,25 @@ public class DoubleGUI extends GUI {
return this; return this;
} }
public DoubleGUI highlightPlayerItem(int cell) {
final int invCell = invOffset(cell);
ItemStack item = cellItems.get(invCell);
if (item != null) {
setPlayerItem(cell, ItemUtils.addGlow(item));
}
return this;
}
public DoubleGUI highlightPlayerItem(int row, int col) {
final int cell = col + row * 9;
final int invCell = invOffset(cell);
ItemStack item = cellItems.get(invCell);
if (item != null) {
setPlayerItem(cell, ItemUtils.addGlow(item));
}
return this;
}
public DoubleGUI setPlayerAction(int cell, Clickable action) { public DoubleGUI setPlayerAction(int cell, Clickable action) {
setConditional(invOffset(cell), null, action, null); setConditional(invOffset(cell), null, action, null);
return this; return this;
@ -307,7 +327,7 @@ public class DoubleGUI extends GUI {
ItemStack[] oldInv = player.getInventory().getContents(); ItemStack[] oldInv = player.getInventory().getContents();
ItemStack[] newInv = new ItemStack[oldInv.length]; ItemStack[] newInv = new ItemStack[oldInv.length];
for (int i = 0; i < newInv.length; ++i) { for (int i = 0; i < 36; ++i) {
final ItemStack item = cellItems.get(invOffset(i < 9 ? i + 27 : i - 9)); final ItemStack item = cellItems.get(invOffset(i < 9 ? i + 27 : i - 9));
newInv[i] = item != null ? item : blankItem; newInv[i] = item != null ? item : blankItem;
} }
@ -402,6 +422,16 @@ public class DoubleGUI extends GUI {
return (DoubleGUI) super.setItem(row, col, item); return (DoubleGUI) super.setItem(row, col, item);
} }
@Override
public DoubleGUI highlightItem(int cell) {
return (DoubleGUI) super.highlightItem(cell);
}
@Override
public DoubleGUI highlightItem(int row, int col) {
return (DoubleGUI) super.highlightItem(row, col);
}
@Override @Override
public DoubleGUI updateItem(int cell, String name, String... lore) { public DoubleGUI updateItem(int cell, String name, String... lore) {
return (DoubleGUI) super.updateItem(cell, name, lore); return (DoubleGUI) super.updateItem(cell, name, lore);

View File

@ -7,6 +7,7 @@ import com.songoda.core.gui.methods.Droppable;
import com.songoda.core.gui.methods.Closable; import com.songoda.core.gui.methods.Closable;
import com.songoda.core.gui.methods.Openable; import com.songoda.core.gui.methods.Openable;
import com.songoda.core.gui.methods.SimpleClickable; import com.songoda.core.gui.methods.SimpleClickable;
import com.songoda.core.utils.ItemUtils;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -15,6 +16,7 @@ import java.util.stream.Collectors;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@ -32,7 +34,7 @@ public class GUI {
protected Inventory inventory; protected Inventory inventory;
protected String title; protected String title;
protected GUIType type = GUIType.STANDARD; protected GUIType inventoryType = GUIType.STANDARD;
protected int rows, page, pages; protected int rows, page, pages;
protected boolean acceptsItems = false; protected boolean acceptsItems = false;
protected boolean allowDropItems = true; protected boolean allowDropItems = true;
@ -58,7 +60,7 @@ public class GUI {
} }
public GUI(GUIType type) { public GUI(GUIType type) {
this.type = type; this.inventoryType = type;
switch (type) { switch (type) {
case HOPPER: case HOPPER:
case DISPENSER: case DISPENSER:
@ -140,7 +142,7 @@ public class GUI {
} }
public GUIType getType() { public GUIType getType() {
return type; return inventoryType;
} }
public GUI setUnlocked(int cell) { public GUI setUnlocked(int cell) {
@ -190,7 +192,7 @@ public class GUI {
} }
public GUI setRows(int rows) { public GUI setRows(int rows) {
switch (type) { switch (inventoryType) {
case HOPPER: case HOPPER:
case DISPENSER: case DISPENSER:
break; break;
@ -222,6 +224,40 @@ public class GUI {
return this; return this;
} }
public GUI highlightItem(int cell) {
ItemStack item = cellItems.get(cell);
if (item != null && item.getType() != Material.AIR) {
setItem(cell, ItemUtils.addGlow(item));
}
return this;
}
public GUI highlightItem(int row, int col) {
final int cell = col + row * 9;
ItemStack item = cellItems.get(cell);
if (item != null && item.getType() != Material.AIR) {
setItem(cell, ItemUtils.addGlow(item));
}
return this;
}
public GUI removeHighlight(int cell) {
ItemStack item = cellItems.get(cell);
if (item != null && item.getType() != Material.AIR) {
setItem(cell, ItemUtils.removeGlow(item));
}
return this;
}
public GUI removeHighlight(int row, int col) {
final int cell = col + row * 9;
ItemStack item = cellItems.get(cell);
if (item != null && item.getType() != Material.AIR) {
setItem(cell, ItemUtils.removeGlow(item));
}
return this;
}
public GUI updateItem(int row, int col, String name, String... lore) { public GUI updateItem(int row, int col, String name, String... lore) {
return updateItem(col + row * 9, name, lore); return updateItem(col + row * 9, name, lore);
} }
@ -571,7 +607,7 @@ public class GUI {
protected Inventory generateInventory() { protected Inventory generateInventory() {
final int cells = rows * 9; final int cells = rows * 9;
InventoryType t = type == null ? InventoryType.CHEST : type.type; InventoryType t = inventoryType == null ? InventoryType.CHEST : inventoryType.type;
switch (t) { switch (t) {
case DISPENSER: case DISPENSER:
case HOPPER: case HOPPER:

View File

@ -27,6 +27,7 @@ public class GUIManager {
final GuiListener listener = new GuiListener(this); final GuiListener listener = new GuiListener(this);
final Map<Player, Inventory> openInventories = new HashMap(); final Map<Player, Inventory> openInventories = new HashMap();
private boolean initialized = false; private boolean initialized = false;
private boolean shutdown = false;
public GUIManager(Plugin plugin) { public GUIManager(Plugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -38,6 +39,7 @@ public class GUIManager {
public void init() { public void init() {
Bukkit.getPluginManager().registerEvents(listener, plugin); Bukkit.getPluginManager().registerEvents(listener, plugin);
initialized = true; initialized = true;
shutdown = false;
} }
/** /**
@ -118,7 +120,11 @@ public class GUIManager {
if (!gui.allowDropItems) { if (!gui.allowDropItems) {
player.setItemOnCursor(null); player.setItemOnCursor(null);
} }
if(manager.shutdown) {
gui.onClose(manager, player);
} else {
Bukkit.getScheduler().runTaskLater(manager.plugin, () -> gui.onClose(manager, player), 1); Bukkit.getScheduler().runTaskLater(manager.plugin, () -> gui.onClose(manager, player), 1);
}
manager.openInventories.remove(player); manager.openInventories.remove(player);
} }
} }
@ -127,6 +133,7 @@ public class GUIManager {
void onDisable(PluginDisableEvent event) { void onDisable(PluginDisableEvent event) {
if (event.getPlugin() == manager.plugin) { if (event.getPlugin() == manager.plugin) {
// uh-oh! Abandon ship!! // uh-oh! Abandon ship!!
manager.shutdown = true;
manager.closeAll(); manager.closeAll();
manager.initialized = false; manager.initialized = false;
} }

View File

@ -5,7 +5,7 @@ import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.Plugin;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -14,9 +14,9 @@ import java.util.Map;
public class Config { public class Config {
private final JavaPlugin plugin; private final Plugin plugin;
private final String folderName, fileName; private final String folderName, fileName;
private FileConfiguration fileConfiguration; private FileConfiguration fileConfiguration;
private File configFile; private File configFile;
@ -319,7 +319,7 @@ public class Config {
return fileName; return fileName;
} }
public JavaPlugin getPlugin() { public Plugin getPlugin() {
return plugin; return plugin;
} }
} }

View File

@ -15,16 +15,16 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.*; import java.util.*;
import org.bukkit.plugin.Plugin;
/** /**
* Created by songoda on 6/4/2017. * Created by songoda on 6/4/2017.
*/ */
public class SettingsManagerOld implements Listener { public class SettingsManagerOld implements Listener {
private final JavaPlugin plugin; private final Plugin plugin;
private final Config config; private final Config config;
private Map<Player, String> cat = new HashMap<>(); private Map<Player, String> cat = new HashMap<>();

View File

@ -3,7 +3,6 @@ package com.songoda.core.settings.editor;
import com.songoda.core.compatibility.LegacyMaterials; import com.songoda.core.compatibility.LegacyMaterials;
import com.songoda.core.settings.Config; import com.songoda.core.settings.Config;
import com.songoda.core.utils.gui.AbstractGUI; import com.songoda.core.utils.gui.AbstractGUI;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;

View File

@ -8,14 +8,21 @@ import com.mojang.authlib.properties.Property;
import com.songoda.core.compatibility.LegacyMaterials; import com.songoda.core.compatibility.LegacyMaterials;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Base64; import java.util.Base64;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
@ -41,6 +48,119 @@ public class ItemUtils {
return clone; return clone;
} }
static Class cb_ItemStack = NMSUtils.getCraftClass("inventory.CraftItemStack");
static Class mc_ItemStack = NMSUtils.getNMSClass("ItemStack");
static Class mc_NBTTagCompound = NMSUtils.getNMSClass("NBTTagCompound");
static Class mc_NBTTagList = NMSUtils.getNMSClass("NBTTagList");
static Class mc_NBTBase = NMSUtils.getNMSClass("NBTBase");
static Method mc_ItemStack_getTag;
static Method mc_ItemStack_setTag;
static Method mc_NBTTagCompound_set;
static Method mc_NBTTagCompound_remove;
static Method mc_NBTTagCompound_setShort;
static Method mc_NBTTagCompound_setString;
static Method mc_NBTTagList_add;
static Method cb_CraftItemStack_asNMSCopy;
static Method cb_CraftItemStack_asCraftMirror;
static {
if(cb_ItemStack != null) {
try {
mc_ItemStack_getTag = mc_ItemStack.getDeclaredMethod("getTag");
mc_ItemStack_setTag = mc_ItemStack.getDeclaredMethod("setTag", mc_NBTTagCompound);
mc_NBTTagCompound_set = mc_NBTTagCompound.getDeclaredMethod("set", String.class, mc_NBTBase);
mc_NBTTagCompound_remove = mc_NBTTagCompound.getDeclaredMethod("remove", String.class);
mc_NBTTagCompound_setShort = mc_NBTTagCompound.getDeclaredMethod("setShort", String.class, short.class);
mc_NBTTagCompound_setString = mc_NBTTagCompound.getDeclaredMethod("setString", String.class, String.class);
cb_CraftItemStack_asNMSCopy = cb_ItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class);
cb_CraftItemStack_asCraftMirror = cb_ItemStack.getDeclaredMethod("asCraftMirror", mc_ItemStack);
mc_NBTTagList_add = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)
? NMSUtils.getPrivateMethod(mc_NBTTagList, "a", mc_NBTBase)
: mc_NBTTagList.getDeclaredMethod("add", mc_NBTBase);
} catch (Exception ex) {
Logger.getLogger(ItemUtils.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
/**
* Make an item glow as if it contained an enchantment. <br>
* Tested working 1.8-1.14
*
* @param item itemstack to create a glowing copy of
* @return copy of item with a blank enchantment nbt tag
*/
public static ItemStack addGlow(ItemStack item) {
// from 1.11 up, fake enchantments don't work without more steps
// creating a new Enchantment involves some very involved reflection,
// as the namespace is the same but until 1.12 requires an int, but versions after require a String
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
item.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
// you can at least hide the enchantment, though
ItemMeta m = item.getItemMeta();
m.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(m);
return item;
} else {
// hack a fake enchant onto the item
// Confirmed works on 1.8, 1.9, 1.10
// Does not work 1.11+ (minecraft ignores the glitched enchantment)
if (item != null && item.getType() != Material.AIR && cb_CraftItemStack_asCraftMirror != null) {
try {
Object nmsStack = cb_CraftItemStack_asNMSCopy.invoke(null, item);
Object tag = mc_ItemStack_getTag.invoke(nmsStack);
if (tag == null) {
tag = mc_NBTTagCompound.newInstance();
}
// set to have a fake enchantment
Object enchantmentList = mc_NBTTagList.newInstance();
/*
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
// Servers from 1.13 and up change the id to a string
Object fakeEnchantment = mc_NBTTagCompound.newInstance();
mc_NBTTagCompound_setString.invoke(fakeEnchantment, "id", "glow:glow");
mc_NBTTagCompound_setShort.invoke(fakeEnchantment, "lvl", (short) 0);
mc_NBTTagList_add.invoke(enchantmentList, fakeEnchantment);
} else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
// Servers from 1.11 and up require *something* in the enchantment field
Object fakeEnchantment = mc_NBTTagCompound.newInstance();
mc_NBTTagCompound_setShort.invoke(fakeEnchantment, "id", (short) 245);
mc_NBTTagCompound_setShort.invoke(fakeEnchantment, "lvl", (short) 1);
mc_NBTTagList_add.invoke(enchantmentList, fakeEnchantment);
}//*/
mc_NBTTagCompound_set.invoke(tag, "ench", enchantmentList);
mc_ItemStack_setTag.invoke(nmsStack, tag);
item = (ItemStack) cb_CraftItemStack_asCraftMirror.invoke(null, nmsStack);
} catch (Exception ex) {
Bukkit.getLogger().log(Level.SEVERE, "Failed to set glow enchantment on item: " + item, ex);
}
}
}
return item;
}
/**
* Remove all enchantments, including hidden enchantments
* @param item item to clear enchants from
* @return copy of the item without any enchantment tag
*/
public static ItemStack removeGlow(ItemStack item) {
if (item != null && item.getType() != Material.AIR && cb_CraftItemStack_asCraftMirror != null) {
try {
Object nmsStack = cb_CraftItemStack_asNMSCopy.invoke(null, item);
Object tag = mc_ItemStack_getTag.invoke(nmsStack);
if (tag != null) {
// remove enchantment list
mc_NBTTagCompound_remove.invoke(tag, "ench");
mc_ItemStack_setTag.invoke(nmsStack, tag);
item = (ItemStack) cb_CraftItemStack_asCraftMirror.invoke(null, nmsStack);
}
} catch (Exception ex) {
Bukkit.getLogger().log(Level.SEVERE, "Failed to set glow enchantment on item: " + item, ex);
}
}
return item;
}
public static String getItemName(ItemStack it) { public static String getItemName(ItemStack it) {
if (!check_compatibility) { if (!check_compatibility) {
init(); init();

View File

@ -4,8 +4,9 @@ import com.songoda.core.compatibility.ServerVersion;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class NMSUtil { public class NMSUtils {
public static Class<?> getNMSClass(String className) { public static Class<?> getNMSClass(String className) {
try { try {
@ -29,6 +30,12 @@ public class NMSUtil {
} }
} }
public static Method getPrivateMethod(Class<?> c, String methodName, Class<?> ... parameters) throws Exception {
Method m = c.getDeclaredMethod(methodName, parameters);
m.setAccessible(true);
return m;
}
public static Field getField(Class<?> clazz, String name, boolean declared) { public static Field getField(Class<?> clazz, String name, boolean declared) {
try { try {
Field field; Field field;