Files
src
pom.xml
Code
35 3,503
src/main/java/me/voxen/plugin/Main.java
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.bukkit.Material
* org.bukkit.NamespacedKey
* org.bukkit.command.CommandExecutor
* org.bukkit.event.Listener
* org.bukkit.inventory.ItemStack
* org.bukkit.inventory.Recipe
* org.bukkit.inventory.ShapedRecipe
* org.bukkit.plugin.Plugin
* org.bukkit.plugin.java.JavaPlugin
*/
package me.voxen.plugin;
import me.voxen.plugin.commands.GemSmpCommand;
import me.voxen.plugin.commands.BanHammerCommand;
import me.voxen.plugin.commands.FreezeCommand;
import me.voxen.plugin.commands.JailCommand;
import me.voxen.plugin.commands.RerollCommand;
import me.voxen.plugin.commands.PluginTabCompleter;
import me.voxen.plugin.commands.SpectateCommand;
import me.voxen.plugin.commands.Ultimate1Command;
import me.voxen.plugin.commands.Ultimate2Command;
import me.voxen.plugin.commands.UnbanCommand;
import me.voxen.plugin.listeners.BanHammerListener;
import me.voxen.plugin.listeners.CombatTagListener;
import me.voxen.plugin.listeners.CombatListener;
import me.voxen.plugin.listeners.GemDropListener;
import me.voxen.plugin.listeners.CommandVisibilityListener;
import me.voxen.plugin.listeners.ModerationListener;
import me.voxen.plugin.listeners.SpectateListener;
import me.voxen.plugin.listeners.DragonVoidListener;
import me.voxen.plugin.listeners.JoinListener;
import me.voxen.plugin.listeners.KillListener;
import me.voxen.plugin.listeners.MaceCraftingListener;
import me.voxen.plugin.listeners.RerollListener;
import me.voxen.plugin.menus.GemInfoMenu;
import me.voxen.plugin.managers.CooldownManager;
import me.voxen.plugin.managers.GemManager;
import me.voxen.plugin.managers.GemType;
import me.voxen.plugin.managers.InventoryHistoryManager;
import me.voxen.plugin.managers.JailManager;
import me.voxen.plugin.managers.ModerationManager;
import me.voxen.plugin.managers.SpectateManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class Main
extends JavaPlugin {
private GemManager gemManager;
private CooldownManager cooldownManager;
private InventoryHistoryManager inventoryHistoryManager;
private CombatTagListener combatTagListener;
private JailManager jailManager;
private boolean smpStarted;
public void onEnable() {
this.gemManager = new GemManager(this);
this.gemManager.loadSavedGems();
this.cooldownManager = new CooldownManager();
this.inventoryHistoryManager = new InventoryHistoryManager(this);
this.smpStarted = this.getConfig().getBoolean("smp-started", false);
ModerationManager moderationManager = new ModerationManager();
SpectateManager spectateManager = new SpectateManager();
this.jailManager = new JailManager();
PluginTabCompleter tabCompleter = new PluginTabCompleter();
this.getCommand("ultimate1").setExecutor((CommandExecutor)new Ultimate1Command(this));
this.getCommand("ultimate1").setTabCompleter(tabCompleter);
this.getCommand("ultimate2").setExecutor((CommandExecutor)new Ultimate2Command(this));
this.getCommand("ultimate2").setTabCompleter(tabCompleter);
this.getCommand("gemsmp").setExecutor((CommandExecutor)new GemSmpCommand(this));
this.getCommand("gemsmp").setTabCompleter(tabCompleter);
this.getCommand("trust").setExecutor((CommandExecutor)new GemSmpCommand(this));
this.getCommand("trust").setTabCompleter(tabCompleter);
this.getCommand("untrust").setExecutor((CommandExecutor)new GemSmpCommand(this));
this.getCommand("untrust").setTabCompleter(tabCompleter);
this.getCommand("banhammer").setExecutor((CommandExecutor)new BanHammerCommand());
this.getCommand("banhammer").setTabCompleter(tabCompleter);
this.getCommand("unban").setExecutor((CommandExecutor)new UnbanCommand());
this.getCommand("unban").setTabCompleter(tabCompleter);
this.getCommand("reroll").setExecutor((CommandExecutor)new RerollCommand(this.inventoryHistoryManager));
this.getCommand("reroll").setTabCompleter(tabCompleter);
this.getCommand("freeze").setExecutor(new FreezeCommand(moderationManager));
this.getCommand("freeze").setTabCompleter(tabCompleter);
this.getCommand("spectate").setExecutor(new SpectateCommand(spectateManager));
this.getCommand("spectate").setTabCompleter(tabCompleter);
this.getCommand("jail").setExecutor(new JailCommand(this.jailManager));
this.getCommand("jail").setTabCompleter(tabCompleter);
this.getServer().getPluginManager().registerEvents((Listener)new CommandVisibilityListener(), (Plugin)this);
this.getServer().getPluginManager().registerEvents(this.jailManager, this);
this.getServer().getPluginManager().registerEvents(new ModerationListener(moderationManager), this);
this.getServer().getPluginManager().registerEvents(new SpectateListener(spectateManager), this);
this.getServer().getPluginManager().registerEvents((Listener)new JoinListener(this), (Plugin)this);
this.getServer().getPluginManager().registerEvents((Listener)new CombatListener(this), (Plugin)this);
this.combatTagListener = new CombatTagListener(this);
this.getServer().getPluginManager().registerEvents(this.combatTagListener, this);
this.getServer().getPluginManager().registerEvents((Listener)new BanHammerListener(), (Plugin)this);
this.getServer().getPluginManager().registerEvents((Listener)new KillListener(this), (Plugin)this);
this.getServer().getPluginManager().registerEvents((Listener)new RerollListener(this), (Plugin)this);
this.getServer().getPluginManager().registerEvents((Listener)new GemDropListener(this), (Plugin)this);
this.getServer().getPluginManager().registerEvents((Listener)new DragonVoidListener(this), (Plugin)this);
this.getServer().getPluginManager().registerEvents((Listener)new GemInfoMenu(), (Plugin)this);
this.getServer().getPluginManager().registerEvents((Listener)new MaceCraftingListener(), (Plugin)this);
this.inventoryHistoryManager.start();
this.registerRerollRecipe();
this.gemManager.startVoidTask();
this.startUltimateHud();
this.getLogger().info("gemplugin enabled!");
}
private void startUltimateHud() {
Bukkit.getScheduler().runTaskTimer(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
long combatSeconds = this.combatTagListener.getRemainingCombatSeconds(player);
GemType gem = this.gemManager.getGem(player);
String ultimate1 = gem == null ? "No gem" : this.getUltimateStatus(player, gem.name() + "_U1");
String ultimate2 = gem == null ? "No gem" : this.getUltimateStatus(player, gem.name() + "_U2");
String combatStatus = combatSeconds > 0L ? "Combat: " + combatSeconds + "s " : "";
String display = combatStatus + "ULTIMATE 1 : " + ultimate1 + " ULTIMATE 2 : " + ultimate2;
player.sendActionBar(Component.text(display, NamedTextColor.DARK_RED));
}
}, 0L, 10L);
}
private String getUltimateStatus(Player player, String id) {
if (this.cooldownManager.isInUse(player.getUniqueId(), id)) {
return "In use";
}
if (!this.cooldownManager.isOnCooldown(player.getUniqueId(), id)) {
return "Ready";
}
return Math.max(1L, this.cooldownManager.getRemaining(player.getUniqueId(), id)) + "s";
}
public void onDisable() {
this.getLogger().info("gemplugin disabled!");
this.getConfig().set("smp-started", this.smpStarted);
this.saveConfig();
if (this.jailManager != null) {
this.jailManager.restoreAll();
}
}
private void registerRerollRecipe() {
ItemStack result = GemManager.createReroller();
NamespacedKey key = new NamespacedKey((Plugin)this, "gem_reroller");
ShapedRecipe recipe = new ShapedRecipe(key, result);
recipe.shape(new String[]{"DGD", "GEG", "DGD"});
recipe.setIngredient('D', Material.DIAMOND_BLOCK);
recipe.setIngredient('G', Material.GOLD_BLOCK);
recipe.setIngredient('E', Material.ENCHANTED_GOLDEN_APPLE);
this.getServer().addRecipe((Recipe)recipe);
}
public GemManager getGemManager() {
return this.gemManager;
}
public CooldownManager getCooldownManager() {
return this.cooldownManager;
}
public boolean isSmpStarted() {
return this.smpStarted;
}
public void setSmpStarted(boolean smpStarted) {
this.smpStarted = smpStarted;
this.getConfig().set("smp-started", smpStarted);
this.saveConfig();
}
}