2014-11-08 20:27:09 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
|
|
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
|
|
|
// /
|
|
|
|
// This program is free software; you can redistribute it and/or modify /
|
|
|
|
// it under the terms of the GNU General Public License as published by /
|
|
|
|
// the Free Software Foundation; either version 3 of the License, or /
|
|
|
|
// (at your option) any later version. /
|
|
|
|
// /
|
|
|
|
// This program is distributed in the hope that it will be useful, /
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
|
|
|
// GNU General Public License for more details. /
|
|
|
|
// /
|
|
|
|
// You should have received a copy of the GNU General Public License /
|
|
|
|
// along with this program; if not, write to the Free Software Foundation, /
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
|
|
|
// /
|
|
|
|
// You can contact us via: support@intellectualsites.com /
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2014-09-22 13:02:14 +02:00
|
|
|
package com.intellectualcrafters.plot.commands;
|
|
|
|
|
2015-07-03 14:15:20 +02:00
|
|
|
import com.intellectualcrafters.plot.PS;
|
2014-11-16 10:48:18 +01:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
2015-02-21 12:38:44 +01:00
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
2014-11-16 10:48:18 +01:00
|
|
|
import com.intellectualcrafters.plot.util.Lag;
|
2015-02-20 12:23:48 +01:00
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2015-07-27 19:50:04 +02:00
|
|
|
import com.plotsquared.general.commands.CommandDeclaration;
|
2014-09-22 13:02:14 +02:00
|
|
|
|
2015-07-27 00:26:19 +02:00
|
|
|
@CommandDeclaration(
|
2015-09-11 12:09:22 +02:00
|
|
|
command = "debug",
|
|
|
|
category = CommandCategory.DEBUG,
|
|
|
|
description = "Show debug information",
|
|
|
|
usage = "/plot debug [msg]",
|
|
|
|
permission = "plots.admin")
|
|
|
|
public class Debug extends SubCommand
|
|
|
|
{
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
@Override
|
2015-09-11 12:09:22 +02:00
|
|
|
public boolean onCommand(final PlotPlayer plr, final String[] args)
|
|
|
|
{
|
|
|
|
if ((args.length > 0) && args[0].equalsIgnoreCase("msg"))
|
|
|
|
{
|
2014-11-05 04:42:08 +01:00
|
|
|
final StringBuilder msg = new StringBuilder();
|
2015-09-11 12:09:22 +02:00
|
|
|
for (final C c : C.values())
|
|
|
|
{
|
2014-11-08 20:27:09 +01:00
|
|
|
msg.append(c.s()).append("\n");
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
2015-02-21 12:24:46 +01:00
|
|
|
MainUtil.sendMessage(plr, msg.toString());
|
2014-11-05 04:42:08 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
StringBuilder information;
|
|
|
|
String header, line, section;
|
|
|
|
{
|
|
|
|
information = new StringBuilder();
|
2015-07-14 09:18:31 +02:00
|
|
|
header = C.DEBUG_HEADER.s();
|
2014-11-05 04:42:08 +01:00
|
|
|
line = C.DEBUG_LINE.s();
|
|
|
|
section = C.DEBUG_SECTION.s();
|
|
|
|
}
|
|
|
|
{
|
|
|
|
final StringBuilder worlds = new StringBuilder("");
|
2015-09-11 12:09:22 +02:00
|
|
|
for (final String world : PS.get().getPlotWorlds())
|
|
|
|
{
|
2014-11-08 20:27:09 +01:00
|
|
|
worlds.append(world).append(" ");
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
|
|
|
information.append(header);
|
|
|
|
information.append(getSection(section, "Lag / TPS"));
|
|
|
|
information.append(getLine(line, "Ticks Per Second", Lag.getTPS()));
|
|
|
|
information.append(getLine(line, "Lag Percentage", (int) Lag.getPercentage() + "%"));
|
|
|
|
information.append(getLine(line, "TPS Percentage", (int) Lag.getFullPercentage() + "%"));
|
|
|
|
information.append(getSection(section, "PlotWorld"));
|
|
|
|
information.append(getLine(line, "Plot Worlds", worlds));
|
2015-07-03 14:15:20 +02:00
|
|
|
information.append(getLine(line, "Owned Plots", PS.get().getPlots().size()));
|
2014-11-05 04:42:08 +01:00
|
|
|
information.append(getSection(section, "Messages"));
|
|
|
|
information.append(getLine(line, "Total Messages", C.values().length));
|
|
|
|
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
|
|
|
}
|
|
|
|
{
|
2015-02-21 12:24:46 +01:00
|
|
|
MainUtil.sendMessage(plr, information.toString());
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-09-11 12:09:22 +02:00
|
|
|
private String getSection(final String line, final String val)
|
|
|
|
{
|
2014-11-05 04:42:08 +01:00
|
|
|
return line.replaceAll("%val%", val) + "\n";
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-09-11 12:09:22 +02:00
|
|
|
private String getLine(final String line, final String var, final Object val)
|
|
|
|
{
|
2014-11-05 04:42:08 +01:00
|
|
|
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n";
|
|
|
|
}
|
2014-09-22 13:02:14 +02:00
|
|
|
}
|