From 51f718dcac81e6c5e98cd1710fbbba27f9b38ba3 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 31 Oct 2014 10:19:36 +1100 Subject: [PATCH] Added debug category --- .../plot/commands/Debug.java | 2 +- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugLoadTest.java | 71 +++++++++++++++++++ .../plot/commands/DebugSaveTest.java | 63 ++++++++++++++++ .../plot/commands/SubCommand.java | 3 +- 5 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java index c700ca974..c9200c881 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -34,7 +34,7 @@ public class Debug extends SubCommand { // private extends SubCommand^Implements {Command, Information} from // >>\\S.txt6\\ public Debug() { - super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.INFO, false); + super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false); { /** * This. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index f0413d8d3..62b0d75b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; public class DebugClaimTest extends SubCommand { public DebugClaimTest() { - super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "claim", CommandCategory.INFO, false); + super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "claim", CommandCategory.DEBUG, false); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java new file mode 100644 index 000000000..3dd2a0207 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Claim.java >> Generated by: Citymonstret at 2014-08-09 01:41 + */ + +package com.intellectualcrafters.plot.commands; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Set; +import java.util.UUID; + +import net.milkbowl.vault.economy.Economy; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; + +import com.google.common.collect.BiMap; +import com.intellectualcrafters.plot.C; +import com.intellectualcrafters.plot.FlagManager; +import com.intellectualcrafters.plot.PlayerFunctions; +import com.intellectualcrafters.plot.Plot; +import com.intellectualcrafters.plot.PlotHelper; +import com.intellectualcrafters.plot.PlotId; +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotManager; +import com.intellectualcrafters.plot.PlotWorld; +import com.intellectualcrafters.plot.SchematicHandler; +import com.intellectualcrafters.plot.StringWrapper; +import com.intellectualcrafters.plot.UUIDHandler; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; +import com.worldcretornica.plotme.PlayerList; + +/** + * @author Citymonstret + */ +public class DebugLoadTest extends SubCommand { + + public DebugLoadTest() { + super(Command.DEBUGCLAIMTEST, "This debug command will force the reload of all plots in the DB", "claim", CommandCategory.DEBUG, false); + } + + @Override + public boolean execute(Player plr, String... args) { + if (plr==null) { + try { + Field fPlots = PlotMain.class.getDeclaredField("plots"); + fPlots.setAccessible(true); + fPlots.set(null, DBFunc.getPlots()); + } + catch (Exception e) { + PlotMain.sendConsoleSenderMessage("&3===FAILED&3==="); + e.printStackTrace(); + PlotMain.sendConsoleSenderMessage("&3===END OF STACKTRACE==="); + } + } + else { + PlayerFunctions.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused."); + } + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java new file mode 100644 index 000000000..d72364bd4 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Claim.java >> Generated by: Citymonstret at 2014-08-09 01:41 + */ + +package com.intellectualcrafters.plot.commands; + +import java.util.ArrayList; +import java.util.Set; +import java.util.UUID; + +import net.milkbowl.vault.economy.Economy; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; + +import com.google.common.collect.BiMap; +import com.intellectualcrafters.plot.C; +import com.intellectualcrafters.plot.FlagManager; +import com.intellectualcrafters.plot.PlayerFunctions; +import com.intellectualcrafters.plot.Plot; +import com.intellectualcrafters.plot.PlotHelper; +import com.intellectualcrafters.plot.PlotId; +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotManager; +import com.intellectualcrafters.plot.PlotWorld; +import com.intellectualcrafters.plot.SchematicHandler; +import com.intellectualcrafters.plot.StringWrapper; +import com.intellectualcrafters.plot.UUIDHandler; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; + +/** + * @author Citymonstret + */ +public class DebugSaveTest extends SubCommand { + + public DebugSaveTest() { + super(Command.DEBUGCLAIMTEST, "This debug command will force the recreation of all plots in the DB", "claim", CommandCategory.DEBUG, false); + } + + @Override + public boolean execute(Player plr, String... args) { + if (plr==null) { + ArrayList plots = new ArrayList(); + plots.addAll(PlotMain.getPlots()); + DBFunc.createPlots(plots); + DBFunc.createAllSettingsAndHelpers(plots); + } + else { + PlayerFunctions.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused."); + } + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index d4173d52c..4d953f694 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -120,7 +120,8 @@ public abstract class SubCommand { CLAIMING("Claiming"), TELEPORT("Teleportation"), ACTIONS("Actions"), - INFO("Information"); + INFO("Information"), + DEBUG("Debug"); private String name; CommandCategory(String name) {