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;
@ -57,8 +60,8 @@ public class UltimateRepairing extends SongodaPlugin {
// Load Economy & Hologram hooks
EconomyManager.load();
HologramManager.load(this);
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
PluginManager pluginManager = getServer().getPluginManager();
@ -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);
}
this.setLocale(Settings.LANGUGE_MODE.getString(), true);
particleTask.reload();
}
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);
}
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));
}
}

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,56 +37,48 @@ 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);
if (getDataFor(p).getInRepair()) {
yesNo(p, getDataFor(p).getType(), getDataFor(p).getToBeRepaired());
} else {
guiManager.showGUI(p, new RepairTypeGui(p, l));
}
}
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);
ItemStack itemStack = player.getItemInHand();
player.setItemInHand(null);
Item item = player.getWorld().dropItem(anvil.add(0.5, 2, 0.5), itemStack);
// Support for EpicHoppers suction.
item.setMetadata("grabbed", new FixedMetadataValue(instance, "true"));
// Support for EpicHoppers suction.
item.setMetadata("grabbed", new FixedMetadataValue(instance, "true"));
item.setMetadata("betterdrops_ignore", new FixedMetadataValue(instance, true));
Vector vec = player.getEyeLocation().getDirection();
vec.setX(0);
vec.setY(0);
vec.setZ(0);
item.setVelocity(vec);
item.setPickupDelay(3600);
item.setMetadata("UltimateRepairing", new FixedMetadataValue(instance, ""));
item.setMetadata("betterdrops_ignore", new FixedMetadataValue(instance, true));
Vector vec = player.getEyeLocation().getDirection();
vec.setX(0);
vec.setY(0);
vec.setZ(0);
item.setVelocity(vec);
item.setPickupDelay(3600);
item.setMetadata("UltimateRepairing", new FixedMetadataValue(instance, ""));
// Get from Map, put new instance in Map if it doesn't exist
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData());
playerData.setItem(item);
playerData.setToBeRepaired(itemStack);
playerData.setLocations(anvil.add(0, -2, 0));
// Get from Map, put new instance in Map if it doesn't exist
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData());
playerData.setItem(item);
playerData.setToBeRepaired(itemStack);
playerData.setLocations(anvil.add(0, -2, 0));
yesNo(player, type, itemStack);
yesNo(player, type, itemStack);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
if (item.isValid() && !playerData.isBeingRepaired()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
if (item.isValid() && !playerData.isBeingRepaired()) {
instance.getLocale().getMessage("event.repair.timeout").sendPrefixedMessage(player);
removeItem(playerData, player);
player.closeInventory();
instance.getLocale().getMessage("event.repair.timeout").sendPrefixedMessage(player);
removeItem(playerData, player);
player.closeInventory();
}
}, instance.getConfig().getLong("Main.Time Before Repair Auto Canceled"));
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
}, instance.getConfig().getLong("Main.Time Before Repair Auto Canceled"));
}
public void initRepair(Player player, Location anvil) {
@ -128,141 +116,127 @@ public class RepairHandler {
}
private void yesNo(Player p, RepairType type, ItemStack item) {
try {
PlayerAnvilData playerData = getDataFor(p);
PlayerAnvilData playerData = getDataFor(p);
if (playerData.isBeingRepaired()) {
return;
}
int price = Methods.getCost(type, item);
playerData.setInRepair(true);
playerData.setType(type);
playerData.setPrice(price);
guiManager.showGUI(p, new StartConfirmGui(playerData.getLocation(), type, p, item));
} catch (Exception ex) {
Debugger.runReport(ex);
if (playerData.isBeingRepaired()) {
return;
}
int price = Methods.getCost(type, item);
playerData.setInRepair(true);
playerData.setType(type);
playerData.setPrice(price);
guiManager.showGUI(p, new StartConfirmGui(playerData.getLocation(), type, p, item));
}
public void finish(boolean answer, Player player) {
try {
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData());
if (!answer) {
removeItem(playerData, player);
instance.getLocale().getMessage("event.repair.cancelled").sendPrefixedMessage(player);
return;
}
RepairType type = playerData.getType();
ItemStack players = playerData.getToBeRepaired();
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData());
if (!answer) {
removeItem(playerData, player);
instance.getLocale().getMessage("event.repair.cancelled").sendPrefixedMessage(player);
return;
}
RepairType type = playerData.getType();
ItemStack players = playerData.getToBeRepaired();
boolean sold = false;
if (type == RepairType.ECONOMY && EconomyManager.isEnabled()) {
int price = playerData.getPrice();
boolean sold = false;
if (type == RepairType.ECONOMY && EconomyManager.isEnabled()) {
int price = playerData.getPrice();
if(EconomyManager.hasBalance(player, price)) {
EconomyManager.withdrawBalance(player, price);
sold = true;
}
}
int cost = Methods.getCost(type, players);
ItemStack item2 = new ItemStack(Methods.getType(players), cost);
String name = (item2.getType().name().substring(0, 1).toUpperCase() + item2.getType().name().toLowerCase().substring(1)).replace("_", " ");
if (type == RepairType.ITEM && Methods.inventoryContains(player.getInventory(), item2)) {
Methods.removeFromInventory(player.getInventory(), item2);
if (EconomyManager.hasBalance(player, price)) {
EconomyManager.withdrawBalance(player, price);
sold = true;
}
}
if (type == RepairType.XP && player.getLevel() >= playerData.getPrice() || sold || player.getGameMode() == GameMode.CREATIVE) {
playerData.setBeingRepaired(true);
int cost = Methods.getCost(type, players);
ItemStack item2 = new ItemStack(Methods.getType(players), cost);
String name = (item2.getType().name().substring(0, 1).toUpperCase() + item2.getType().name().toLowerCase().substring(1)).replace("_", " ");
if (type == RepairType.ITEM && Methods.inventoryContains(player.getInventory(), item2)) {
Methods.removeFromInventory(player.getInventory(), item2);
sold = true;
}
Effect effect = Effect.STEP_SOUND;
if (type == RepairType.XP && player.getLevel() >= playerData.getPrice() || sold || player.getGameMode() == GameMode.CREATIVE) {
playerData.setBeingRepaired(true);
Material blockType = Material.REDSTONE_BLOCK;
Effect effect = Effect.STEP_SOUND;
String typeStr = playerData.getToBeRepaired().getType().name().toUpperCase();
Material blockType = Material.REDSTONE_BLOCK;
if (typeStr.contains("DIAMOND")) {
blockType = Material.DIAMOND_BLOCK;
} else if (typeStr.contains("IRON")) {
blockType = Material.IRON_BLOCK;
} else if (typeStr.contains("GOLD")) {
blockType = Material.GOLD_BLOCK;
} else if (typeStr.contains("STONE")) {
blockType = Material.STONE;
} else if (typeStr.contains("WOOD")) {
blockType = CompatibleMaterial.OAK_WOOD.getMaterial();
}
String typeStr = playerData.getToBeRepaired().getType().name().toUpperCase();
final Material blockTypeFinal = blockType;
Location location = playerData.getLocations();
player.getWorld().playEffect(location, effect, blockType);
Runnable runnable = () -> player.getWorld().playEffect(location, effect, blockTypeFinal);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, runnable, 5L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
player.getWorld().playEffect(location, effect, blockTypeFinal);
player.getWorld().playEffect(location, effect, Material.STONE);
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
}, 10L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, runnable, 15L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, runnable, 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
player.getWorld().playEffect(location, effect, blockTypeFinal);
player.getWorld().playEffect(location, effect, Material.ANVIL);
instance.getLocale().getMessage("event.repair.success").sendPrefixedMessage(player);
playerData.getToBeRepaired().setDurability((short) 0);
HashMap<Integer, ItemStack> items = player.getInventory().addItem(playerData.getToBeRepaired());
for (ItemStack item : items.values()) {
player.getWorld().dropItemNaturally(player.getLocation(), item);
}
playerData.getItem().remove();
if (player.getGameMode() != GameMode.CREATIVE &&
type == RepairType.XP) {
player.setLevel(player.getLevel() - playerData.getPrice());
}
this.playerAnvilData.remove(player.getUniqueId());
player.closeInventory();
}, 25L);
return;
if (typeStr.contains("DIAMOND")) {
blockType = Material.DIAMOND_BLOCK;
} else if (typeStr.contains("IRON")) {
blockType = Material.IRON_BLOCK;
} else if (typeStr.contains("GOLD")) {
blockType = Material.GOLD_BLOCK;
} else if (typeStr.contains("STONE")) {
blockType = Material.STONE;
} else if (typeStr.contains("WOOD")) {
blockType = CompatibleMaterial.OAK_WOOD.getMaterial();
}
if (type == RepairType.ECONOMY) {
instance.getLocale().getMessage("event.repair.notenough")
.processPlaceholder("type", instance.getLocale().getMessage("interface.repair.eco").getMessage())
.sendPrefixedMessage(player);
} else if (type == RepairType.XP)
instance.getLocale().getMessage("event.repair.notenough")
.processPlaceholder("type", instance.getLocale().getMessage("interface.repair.xp").getMessage())
.sendPrefixedMessage(player);
else
instance.getLocale().getMessage("event.repair.notenough")
.processPlaceholder("type", name).sendPrefixedMessage(player);
final Material blockTypeFinal = blockType;
// we've failed to repair, so return the item
removeItem(playerData, player);
Location location = playerData.getLocations();
player.getWorld().playEffect(location, effect, blockType);
Runnable runnable = () -> player.getWorld().playEffect(location, effect, blockTypeFinal);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, runnable, 5L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
player.getWorld().playEffect(location, effect, blockTypeFinal);
player.getWorld().playEffect(location, effect, Material.STONE);
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
}, 10L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, runnable, 15L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, runnable, 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
player.getWorld().playEffect(location, effect, blockTypeFinal);
player.getWorld().playEffect(location, effect, Material.ANVIL);
instance.getLocale().getMessage("event.repair.success").sendPrefixedMessage(player);
} catch (Exception ex) {
Debugger.runReport(ex);
playerData.getToBeRepaired().setDurability((short) 0);
HashMap<Integer, ItemStack> items = player.getInventory().addItem(playerData.getToBeRepaired());
for (ItemStack item : items.values()) {
player.getWorld().dropItemNaturally(player.getLocation(), item);
}
playerData.getItem().remove();
if (player.getGameMode() != GameMode.CREATIVE &&
type == RepairType.XP) {
player.setLevel(player.getLevel() - playerData.getPrice());
}
this.playerAnvilData.remove(player.getUniqueId());
player.closeInventory();
}, 25L);
return;
}
if (type == RepairType.ECONOMY) {
instance.getLocale().getMessage("event.repair.notenough")
.processPlaceholder("type", instance.getLocale().getMessage("interface.repair.eco").getMessage())
.sendPrefixedMessage(player);
} else if (type == RepairType.XP)
instance.getLocale().getMessage("event.repair.notenough")
.processPlaceholder("type", instance.getLocale().getMessage("interface.repair.xp").getMessage())
.sendPrefixedMessage(player);
else
instance.getLocale().getMessage("event.repair.notenough")
.processPlaceholder("type", name).sendPrefixedMessage(player);
// we've failed to repair, so return the item
removeItem(playerData, player);
}
public void removeItem(PlayerAnvilData playerData, Player player) {
try {
player.getInventory().addItem(playerData.getToBeRepaired());
playerData.getItem().remove();
player.getInventory().addItem(playerData.getToBeRepaired());
playerData.getItem().remove();
this.playerAnvilData.remove(player.getUniqueId());
} catch (Exception ex) {
Debugger.runReport(ex);
}
this.playerAnvilData.remove(player.getUniqueId());
}
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,33 +22,24 @@ 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);
if (!event.getBlockPlaced().getType().name().contains("ANVIL")
|| !event.getPlayer().hasPermission("ultimaterepairing.permPlace")) {
return;
}
instance.getAnvilManager().getAnvil(event.getBlock()).setPermPlaced(true);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
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)) {
return;
}
UAnvil anvil = instance.getAnvilManager().getAnvil(event.getBlock());
anvil.setHologram(false);
instance.getAnvilManager().removeAnvil(event.getBlock().getLocation());
} catch (Exception ex) {
Debugger.runReport(ex);
if (!event.getBlock().getType().name().contains("ANVIL") && !instance.getConfig().contains("data.anvil." + loc)) {
return;
}
UAnvil anvil = instance.getAnvilManager().getAnvil(event.getBlock());
anvil.setHologram(false);
instance.getAnvilManager().removeAnvil(event.getBlock().getLocation());
}
}

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,59 +30,54 @@ public class InteractListeners implements Listener {
@EventHandler
public void onAnvilClick(PlayerInteractEvent event) {
try {
boolean ourRepair = false;
boolean vanillaRepair = false;
Player player = event.getPlayer();
if (event.getClickedBlock() == null) return;
boolean ourRepair = false;
boolean vanillaRepair = false;
Player player = event.getPlayer();
if (event.getClickedBlock() == null) return;
UAnvil anvil1 = null;
UAnvil anvil1 = null;
if (!event.getClickedBlock().getType().name().contains("ANVIL") // don't pay attention if it's not an anvil
// also don't handle if we don't have perms to use this repair anvil
|| (Settings.PERMISSION_ANVIL_PLACE.getBoolean()
&& !(anvil1 = instance.getAnvilManager().getAnvil(event.getClickedBlock())).isPermPlaced())) {
return;
}
anvil1 = anvil1 != null ? anvil1 : instance.getAnvilManager().getAnvil(event.getClickedBlock());
if (!event.getClickedBlock().getType().name().contains("ANVIL") // don't pay attention if it's not an anvil
// also don't handle if we don't have perms to use this repair anvil
|| (Settings.PERMISSION_ANVIL_PLACE.getBoolean()
&& !(anvil1 = instance.getAnvilManager().getAnvil(event.getClickedBlock())).isPermPlaced())) {
return;
}
anvil1 = anvil1 != null ? anvil1 : instance.getAnvilManager().getAnvil(event.getClickedBlock());
// if (anvil1.isInfinity()) {
// event.getClickedBlock().setType(Material.AIR);
// event.getClickedBlock().setType(Material.ANVIL); //ToDO: This may not work.
// }
// 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")) {
guiManager.showGUI(player, new AnvilSettingsGui(anvil1));
// 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")) {
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) {
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) {
event.setCancelled(true);
}
// replace our functions for vanilla mechanics only
if(!rightClick) {
return;
}
ourRepair = true;
} else if(rightClick) {
// allowing normal repair
vanillaRepair = true;
} else if(!player.isSneaking()) {
// that's us!
ourRepair = true;
}
// replace our functions for vanilla mechanics only
if (!rightClick) {
return;
}
ourRepair = true;
} else if (rightClick) {
// allowing normal repair
vanillaRepair = true;
} else if (!player.isSneaking()) {
// that's us!
ourRepair = true;
}
if (ourRepair) {
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);
event.setCancelled(true);
}
} catch (Exception ex) {
Debugger.runReport(ex);
if (ourRepair) {
instance.getRepairHandler().initRepair(player, event.getClickedBlock().getLocation());
event.setCancelled(true);
} else if (vanillaRepair && anvil1.isInfinity()) {
player.openInventory(Bukkit.createInventory(null, InventoryType.ANVIL, ChatColor.DARK_GRAY + "Repair & Name"));
event.setCancelled(true);
}
}
}

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");
}
}