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.ultimaterepairing.anvil.AnvilManager;
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.RepairHandler;
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.PlayerListeners;
import com.songoda.ultimaterepairing.settings.Settings;
import com.songoda.ultimaterepairing.utils.Debugger;
import com.songoda.ultimaterepairing.utils.Methods;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.plugin.PluginManager;
import java.util.Arrays;
import java.util.List;
public class UltimateRepairing extends SongodaPlugin {
private static UltimateRepairing INSTANCE;
@ -142,12 +145,8 @@ public class UltimateRepairing extends SongodaPlugin {
@Override
public void onConfigReload() {
try {
this.setLocale(Settings.LANGUGE_MODE.getString(), true);
particleTask.reload();
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
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.ParticleType;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitTask;
@ -48,12 +47,8 @@ public class ParticleTask implements Listener {
public void applyParticles() {
if (instance.getAnvilManager().getAnvils().isEmpty()) return;
try {
instance.getAnvilManager().getAnvils().parallelStream()
.filter(anvil -> anvil.isParticles() && anvil.isInLoadedChunk())
.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.gui.RepairTypeGui;
import com.songoda.ultimaterepairing.gui.StartConfirmGui;
import com.songoda.ultimaterepairing.utils.Debugger;
import com.songoda.ultimaterepairing.utils.Methods;
import java.util.HashMap;
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.*;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* Created by songoda on 2/25/2017.
*/
@ -41,20 +37,15 @@ public class RepairHandler {
}
private void repairType(Player p, Location l) {
try {
if (getDataFor(p).getInRepair()) {
yesNo(p, getDataFor(p).getType(), getDataFor(p).getToBeRepaired());
} else {
guiManager.showGUI(p, new RepairTypeGui(p, l));
}
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void preRepair(Player player, RepairType type, Location anvil) {
try {
ItemStack itemStack = player.getItemInHand();
player.setItemInHand(null);
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"));
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void initRepair(Player player, Location anvil) {
@ -128,7 +116,6 @@ public class RepairHandler {
}
private void yesNo(Player p, RepairType type, ItemStack item) {
try {
PlayerAnvilData playerData = getDataFor(p);
if (playerData.isBeingRepaired()) {
@ -141,15 +128,10 @@ public class RepairHandler {
playerData.setPrice(price);
guiManager.showGUI(p, new StartConfirmGui(playerData.getLocation(), type, p, item));
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void finish(boolean answer, Player player) {
try {
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData());
if (!answer) {
removeItem(playerData, player);
@ -163,7 +145,7 @@ public class RepairHandler {
if (type == RepairType.ECONOMY && EconomyManager.isEnabled()) {
int price = playerData.getPrice();
if(EconomyManager.hasBalance(player, price)) {
if (EconomyManager.hasBalance(player, price)) {
EconomyManager.withdrawBalance(player, price);
sold = true;
}
@ -248,21 +230,13 @@ public class RepairHandler {
// we've failed to repair, so return the item
removeItem(playerData, player);
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void removeItem(PlayerAnvilData playerData, Player player) {
try {
player.getInventory().addItem(playerData.getToBeRepaired());
playerData.getItem().remove();
this.playerAnvilData.remove(player.getUniqueId());
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
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.anvil.UAnvil;
import com.songoda.ultimaterepairing.utils.Debugger;
import com.songoda.ultimaterepairing.utils.Methods;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -23,22 +22,16 @@ public class BlockListeners implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
try {
if (!event.getBlockPlaced().getType().name().contains("ANVIL")
|| !event.getPlayer().hasPermission("ultimaterepairing.permPlace")) {
return;
}
instance.getAnvilManager().getAnvil(event.getBlock()).setPermPlaced(true);
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
try {
String loc = Methods.serializeLocation(event.getBlock());
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());
anvil.setHologram(false);
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.gui.AnvilSettingsGui;
import com.songoda.ultimaterepairing.settings.Settings;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
/**
* Created by songoda on 2/25/2017.
@ -31,7 +30,6 @@ public class InteractListeners implements Listener {
@EventHandler
public void onAnvilClick(PlayerInteractEvent event) {
try {
boolean ourRepair = false;
boolean vanillaRepair = false;
Player player = event.getPlayer();
@ -53,23 +51,23 @@ public class InteractListeners implements Listener {
// check if we should process this as a right click
boolean rightClick = (event.getAction() == Action.RIGHT_CLICK_BLOCK) ^ (Settings.SWAP_LEFT_RIGHT.getBoolean());
// admin interface?
if(rightClick && player.isSneaking() && player.hasPermission("ultimaterepairing.admin")) {
if (rightClick && player.isSneaking() && player.hasPermission("ultimaterepairing.admin")) {
guiManager.showGUI(player, new AnvilSettingsGui(anvil1));
event.setCancelled(true);
} else if (!Settings.ENABLE_ANVIL_DEFAULT_FUNCTION.getBoolean()) {
// if not allowing default anvil, then always use ourRepair
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
event.setCancelled(true);
}
// replace our functions for vanilla mechanics only
if(!rightClick) {
if (!rightClick) {
return;
}
ourRepair = true;
} else if(rightClick) {
} else if (rightClick) {
// allowing normal repair
vanillaRepair = true;
} else if(!player.isSneaking()) {
} else if (!player.isSneaking()) {
// that's us!
ourRepair = true;
}
@ -78,12 +76,8 @@ public class InteractListeners implements Listener {
instance.getRepairHandler().initRepair(player, event.getClickedBlock().getLocation());
event.setCancelled(true);
} else if (vanillaRepair && anvil1.isInfinity()) {
Inventory inv = Bukkit.createInventory(null, InventoryType.ANVIL, "Repair & Name");
player.openInventory(inv);
player.openInventory(Bukkit.createInventory(null, InventoryType.ANVIL, ChatColor.DARK_GRAY + "Repair & Name"));
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"))
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");
}
}