Remove old unused debugger from 2017.

This commit is contained in:
Brianna 2020-01-31 11:18:09 -05:00
parent 3b3f2f7ae2
commit 709f8f29af
7 changed files with 197 additions and 276 deletions

View File

@ -10,7 +10,10 @@ import com.songoda.core.hooks.EconomyManager;
import com.songoda.core.hooks.HologramManager; import com.songoda.core.hooks.HologramManager;
import com.songoda.ultimaterepairing.anvil.AnvilManager; import com.songoda.ultimaterepairing.anvil.AnvilManager;
import com.songoda.ultimaterepairing.anvil.UAnvil; import com.songoda.ultimaterepairing.anvil.UAnvil;
import com.songoda.ultimaterepairing.commands.*; import com.songoda.ultimaterepairing.commands.CommandReload;
import com.songoda.ultimaterepairing.commands.CommandSettings;
import com.songoda.ultimaterepairing.commands.CommandURAnvil;
import com.songoda.ultimaterepairing.commands.CommandUltimateRepairing;
import com.songoda.ultimaterepairing.handlers.ParticleTask; import com.songoda.ultimaterepairing.handlers.ParticleTask;
import com.songoda.ultimaterepairing.handlers.RepairHandler; import com.songoda.ultimaterepairing.handlers.RepairHandler;
import com.songoda.ultimaterepairing.listeners.BlockListeners; import com.songoda.ultimaterepairing.listeners.BlockListeners;
@ -18,14 +21,14 @@ import com.songoda.ultimaterepairing.listeners.InteractListeners;
import com.songoda.ultimaterepairing.listeners.InventoryListeners; import com.songoda.ultimaterepairing.listeners.InventoryListeners;
import com.songoda.ultimaterepairing.listeners.PlayerListeners; import com.songoda.ultimaterepairing.listeners.PlayerListeners;
import com.songoda.ultimaterepairing.settings.Settings; import com.songoda.ultimaterepairing.settings.Settings;
import com.songoda.ultimaterepairing.utils.Debugger;
import com.songoda.ultimaterepairing.utils.Methods; import com.songoda.ultimaterepairing.utils.Methods;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import java.util.Arrays;
import java.util.List;
public class UltimateRepairing extends SongodaPlugin { public class UltimateRepairing extends SongodaPlugin {
private static UltimateRepairing INSTANCE; private static UltimateRepairing INSTANCE;
@ -142,12 +145,8 @@ public class UltimateRepairing extends SongodaPlugin {
@Override @Override
public void onConfigReload() { public void onConfigReload() {
try {
this.setLocale(Settings.LANGUGE_MODE.getString(), true); this.setLocale(Settings.LANGUGE_MODE.getString(), true);
particleTask.reload(); particleTask.reload();
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
public RepairHandler getRepairHandler() { public RepairHandler getRepairHandler() {

View File

@ -3,7 +3,6 @@ package com.songoda.ultimaterepairing.handlers;
import com.songoda.core.compatibility.CompatibleParticleHandler; import com.songoda.core.compatibility.CompatibleParticleHandler;
import com.songoda.core.compatibility.CompatibleParticleHandler.ParticleType; import com.songoda.core.compatibility.CompatibleParticleHandler.ParticleType;
import com.songoda.ultimaterepairing.UltimateRepairing; import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
@ -48,12 +47,8 @@ public class ParticleTask implements Listener {
public void applyParticles() { public void applyParticles() {
if (instance.getAnvilManager().getAnvils().isEmpty()) return; if (instance.getAnvilManager().getAnvils().isEmpty()) return;
try {
instance.getAnvilManager().getAnvils().parallelStream() instance.getAnvilManager().getAnvils().parallelStream()
.filter(anvil -> anvil.isParticles() && anvil.isInLoadedChunk()) .filter(anvil -> anvil.isParticles() && anvil.isInLoadedChunk())
.forEach(anvil -> CompatibleParticleHandler.spawnParticles(type, anvil.getLocation().add(.5, 0, .5), amt, 0.25, 0.25, 0.25)); .forEach(anvil -> CompatibleParticleHandler.spawnParticles(type, anvil.getLocation().add(.5, 0, .5), amt, 0.25, 0.25, 0.25));
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
} }

View File

@ -9,22 +9,18 @@ import com.songoda.ultimaterepairing.anvil.PlayerAnvilData;
import com.songoda.ultimaterepairing.anvil.PlayerAnvilData.RepairType; import com.songoda.ultimaterepairing.anvil.PlayerAnvilData.RepairType;
import com.songoda.ultimaterepairing.gui.RepairTypeGui; import com.songoda.ultimaterepairing.gui.RepairTypeGui;
import com.songoda.ultimaterepairing.gui.StartConfirmGui; import com.songoda.ultimaterepairing.gui.StartConfirmGui;
import com.songoda.ultimaterepairing.utils.Debugger;
import com.songoda.ultimaterepairing.utils.Methods; import com.songoda.ultimaterepairing.utils.Methods;
import java.util.HashMap; import org.bukkit.*;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/** /**
* Created by songoda on 2/25/2017. * Created by songoda on 2/25/2017.
*/ */
@ -41,20 +37,15 @@ public class RepairHandler {
} }
private void repairType(Player p, Location l) { private void repairType(Player p, Location l) {
try {
if (getDataFor(p).getInRepair()) { if (getDataFor(p).getInRepair()) {
yesNo(p, getDataFor(p).getType(), getDataFor(p).getToBeRepaired()); yesNo(p, getDataFor(p).getType(), getDataFor(p).getToBeRepaired());
} else { } else {
guiManager.showGUI(p, new RepairTypeGui(p, l)); guiManager.showGUI(p, new RepairTypeGui(p, l));
} }
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
public void preRepair(Player player, RepairType type, Location anvil) { public void preRepair(Player player, RepairType type, Location anvil) {
try {
ItemStack itemStack = player.getItemInHand(); ItemStack itemStack = player.getItemInHand();
player.setItemInHand(null); player.setItemInHand(null);
Item item = player.getWorld().dropItem(anvil.add(0.5, 2, 0.5), itemStack); Item item = player.getWorld().dropItem(anvil.add(0.5, 2, 0.5), itemStack);
@ -88,9 +79,6 @@ public class RepairHandler {
} }
}, instance.getConfig().getLong("Main.Time Before Repair Auto Canceled")); }, instance.getConfig().getLong("Main.Time Before Repair Auto Canceled"));
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
public void initRepair(Player player, Location anvil) { public void initRepair(Player player, Location anvil) {
@ -128,7 +116,6 @@ public class RepairHandler {
} }
private void yesNo(Player p, RepairType type, ItemStack item) { private void yesNo(Player p, RepairType type, ItemStack item) {
try {
PlayerAnvilData playerData = getDataFor(p); PlayerAnvilData playerData = getDataFor(p);
if (playerData.isBeingRepaired()) { if (playerData.isBeingRepaired()) {
@ -141,15 +128,10 @@ public class RepairHandler {
playerData.setPrice(price); playerData.setPrice(price);
guiManager.showGUI(p, new StartConfirmGui(playerData.getLocation(), type, p, item)); guiManager.showGUI(p, new StartConfirmGui(playerData.getLocation(), type, p, item));
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
public void finish(boolean answer, Player player) { public void finish(boolean answer, Player player) {
try {
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData()); PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData());
if (!answer) { if (!answer) {
removeItem(playerData, player); removeItem(playerData, player);
@ -248,21 +230,13 @@ public class RepairHandler {
// we've failed to repair, so return the item // we've failed to repair, so return the item
removeItem(playerData, player); removeItem(playerData, player);
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
public void removeItem(PlayerAnvilData playerData, Player player) { public void removeItem(PlayerAnvilData playerData, Player player) {
try {
player.getInventory().addItem(playerData.getToBeRepaired()); player.getInventory().addItem(playerData.getToBeRepaired());
playerData.getItem().remove(); playerData.getItem().remove();
this.playerAnvilData.remove(player.getUniqueId()); this.playerAnvilData.remove(player.getUniqueId());
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
public boolean hasInstance(Player player) { public boolean hasInstance(Player player) {

View File

@ -2,7 +2,6 @@ package com.songoda.ultimaterepairing.listeners;
import com.songoda.ultimaterepairing.UltimateRepairing; import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.anvil.UAnvil; import com.songoda.ultimaterepairing.anvil.UAnvil;
import com.songoda.ultimaterepairing.utils.Debugger;
import com.songoda.ultimaterepairing.utils.Methods; import com.songoda.ultimaterepairing.utils.Methods;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -23,22 +22,16 @@ public class BlockListeners implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
try {
if (!event.getBlockPlaced().getType().name().contains("ANVIL") if (!event.getBlockPlaced().getType().name().contains("ANVIL")
|| !event.getPlayer().hasPermission("ultimaterepairing.permPlace")) { || !event.getPlayer().hasPermission("ultimaterepairing.permPlace")) {
return; return;
} }
instance.getAnvilManager().getAnvil(event.getBlock()).setPermPlaced(true); instance.getAnvilManager().getAnvil(event.getBlock()).setPermPlaced(true);
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
try {
String loc = Methods.serializeLocation(event.getBlock()); String loc = Methods.serializeLocation(event.getBlock());
if (!event.getBlock().getType().name().contains("ANVIL") && !instance.getConfig().contains("data.anvil." + loc)) { if (!event.getBlock().getType().name().contains("ANVIL") && !instance.getConfig().contains("data.anvil." + loc)) {
@ -48,8 +41,5 @@ public class BlockListeners implements Listener {
UAnvil anvil = instance.getAnvilManager().getAnvil(event.getBlock()); UAnvil anvil = instance.getAnvilManager().getAnvil(event.getBlock());
anvil.setHologram(false); anvil.setHologram(false);
instance.getAnvilManager().removeAnvil(event.getBlock().getLocation()); instance.getAnvilManager().removeAnvil(event.getBlock().getLocation());
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
} }

View File

@ -5,15 +5,14 @@ import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.anvil.UAnvil; import com.songoda.ultimaterepairing.anvil.UAnvil;
import com.songoda.ultimaterepairing.gui.AnvilSettingsGui; import com.songoda.ultimaterepairing.gui.AnvilSettingsGui;
import com.songoda.ultimaterepairing.settings.Settings; import com.songoda.ultimaterepairing.settings.Settings;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
/** /**
* Created by songoda on 2/25/2017. * Created by songoda on 2/25/2017.
@ -31,7 +30,6 @@ public class InteractListeners implements Listener {
@EventHandler @EventHandler
public void onAnvilClick(PlayerInteractEvent event) { public void onAnvilClick(PlayerInteractEvent event) {
try {
boolean ourRepair = false; boolean ourRepair = false;
boolean vanillaRepair = false; boolean vanillaRepair = false;
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -78,12 +76,8 @@ public class InteractListeners implements Listener {
instance.getRepairHandler().initRepair(player, event.getClickedBlock().getLocation()); instance.getRepairHandler().initRepair(player, event.getClickedBlock().getLocation());
event.setCancelled(true); event.setCancelled(true);
} else if (vanillaRepair && anvil1.isInfinity()) { } else if (vanillaRepair && anvil1.isInfinity()) {
Inventory inv = Bukkit.createInventory(null, InventoryType.ANVIL, "Repair & Name"); player.openInventory(Bukkit.createInventory(null, InventoryType.ANVIL, ChatColor.DARK_GRAY + "Repair & Name"));
player.openInventory(inv);
event.setCancelled(true); event.setCancelled(true);
} }
} catch (Exception ex) {
Debugger.runReport(ex);
}
} }
} }

View File

@ -21,5 +21,4 @@ public class InventoryListeners implements Listener {
if (event.getItem().hasMetadata("UltimateRepairing")) if (event.getItem().hasMetadata("UltimateRepairing"))
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -1,30 +0,0 @@
package com.songoda.ultimaterepairing.utils;
import com.songoda.ultimaterepairing.UltimateRepairing;
/**
* Created by songoda on 3/21/2017.
*/
public class Debugger {
public static void runReport(Exception e) {
if (isDebug()) {
System.out.println("==============================================================");
System.out.println("The following is an error encountered in UltimateRepairing.");
System.out.println("--------------------------------------------------------------");
e.printStackTrace();
System.out.println("==============================================================");
}
sendReport(e);
}
public static void sendReport(Exception e) {
}
public static boolean isDebug() {
return UltimateRepairing.getInstance().getConfig().getBoolean("System.Debugger Enabled");
}
}