mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-13 17:38:03 +08:00
removed NumberFormatException, IllegalArgumentException,UnsupportedOperationException, NullPointerException throws from method signatures
Rename tps in TPS Rename & deprecated old API method with typo Removed unnecessary plan constructor
This commit is contained in:
parent
0c210f4877
commit
d3a7f5adae
@ -114,15 +114,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
// Sets the Required variables for BukkitPlugin instance to function correctly
|
||||
setInstance(this);
|
||||
super.setDebugMode(Settings.DEBUG.toString());
|
||||
try {
|
||||
ChatColor mainColor = ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1));
|
||||
ChatColor secColor = ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1));
|
||||
ChatColor terColor = ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1));
|
||||
super.setColorScheme(new ColorScheme(mainColor, secColor, terColor));
|
||||
} catch (Exception e) {
|
||||
Log.infoColor(ChatColor.RED + "Customization, Chat colors set-up wrong, using defaults.");
|
||||
super.setColorScheme(new ColorScheme(ChatColor.DARK_GREEN, ChatColor.GRAY, ChatColor.WHITE));
|
||||
}
|
||||
initColorScheme();
|
||||
super.setLogPrefix("[Plan]");
|
||||
super.setUpdateCheckUrl("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml");
|
||||
super.setUpdateUrl("https://www.spigotmc.org/resources/plan-player-analytics.32536/");
|
||||
@ -227,6 +219,18 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
}
|
||||
}
|
||||
|
||||
private final void initColorScheme() {
|
||||
try {
|
||||
ChatColor mainColor = ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1));
|
||||
ChatColor secColor = ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1));
|
||||
ChatColor terColor = ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1));
|
||||
super.setColorScheme(new ColorScheme(mainColor, secColor, terColor));
|
||||
} catch (Exception e) {
|
||||
Log.infoColor(ChatColor.RED + "Customization, Chat colors set-up wrong, using defaults.");
|
||||
super.setColorScheme(new ColorScheme(ChatColor.DARK_GREEN, ChatColor.GRAY, ChatColor.WHITE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the plugin.
|
||||
* <p>
|
||||
@ -449,15 +453,4 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
public ServerVariableHolder getVariable() {
|
||||
return serverVariableHolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Old method for getting the API.
|
||||
*
|
||||
* @return the Plan API.
|
||||
* @deprecated Use Plan.getPlanAPI() (static method) instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public API getAPI() {
|
||||
return api;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.api;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import com.djrapitops.plugin.utilities.player.Fetch;
|
||||
import com.djrapitops.plugin.utilities.player.IOfflinePlayer;
|
||||
import com.djrapitops.plugin.utilities.player.UUIDFetcher;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
@ -14,6 +13,7 @@ import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
||||
import main.java.com.djrapitops.plan.ui.html.DataRequestHandler;
|
||||
import main.java.com.djrapitops.plan.ui.webserver.WebServer;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
@ -247,14 +247,31 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses UUIDFetcher to turn PlayerName to UUID.
|
||||
* Uses UUIDUtility to turn PlayerName to UUID.
|
||||
*
|
||||
* @param playerName Player's name
|
||||
* @return UUID of the Player
|
||||
* @throws Exception if player's name is not registered at Mojang
|
||||
* @deprecated Typo in method name, use playerNameToUUID instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UUID PlayerNameToUUID(String playerName) throws Exception {
|
||||
return playerNameToUUID(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses UUIDUtility to turn PlayerName to UUID.
|
||||
*
|
||||
* @param playerName Player's name
|
||||
* @return UUID of the Player
|
||||
* @throws Exception if player's name is not registered at Mojang
|
||||
*/
|
||||
public UUID PlayerNameToUUID(String playerName) throws Exception {
|
||||
return UUIDFetcher.getUUIDOf(playerName);
|
||||
public UUID playerNameToUUID(String playerName) throws Exception {
|
||||
UUID uuid = UUIDUtility.getUUIDOf(playerName);
|
||||
if (uuid == null) {
|
||||
throw new Exception("UUID did not get a match");
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ public class PlanCommand extends TreeCommand<Plan> {
|
||||
commands.add(new ManageCommand(plugin));
|
||||
commands.add(new StatusCommand<>(plugin, Permissions.MANAGE.getPermission()));
|
||||
if (plugin.getUiServer().isEnabled()) {
|
||||
commands.add(new ListCommand(plugin));
|
||||
commands.add(new ListCommand());
|
||||
RegisterCommand registerCommand = new RegisterCommand(plugin);
|
||||
commands.add(registerCommand);
|
||||
commands.add(new WebUserCommand(plugin, registerCommand));
|
||||
|
@ -5,7 +5,6 @@ import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.command.ConditionUtils;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
@ -24,10 +23,8 @@ public class ListCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ListCommand(Plan plugin) {
|
||||
public ListCommand() {
|
||||
super("list, pl", CommandType.CONSOLE, Permissions.INSPECT_OTHER.getPermission(), Locale.get(Msg.CMD_USG_LIST).toString(), "");
|
||||
|
||||
}
|
||||
|
@ -63,8 +63,7 @@ public class RegisterCommandFilter extends AbstractFilter {
|
||||
}
|
||||
|
||||
private boolean isSensibleCommand(String message) {
|
||||
message = message.toLowerCase();
|
||||
return message.contains("issued server command:") && isSensible(message);
|
||||
return message.toLowerCase().contains("issued server command:") && isSensible(message);
|
||||
}
|
||||
|
||||
private boolean isSensible(String message) {
|
||||
|
@ -14,7 +14,7 @@ package main.java.com.djrapitops.plan.data;
|
||||
public class TPS {
|
||||
|
||||
private final long date;
|
||||
private final double tps;
|
||||
private final double ticksPerSecond;
|
||||
private final int players;
|
||||
private final double cpuUsage;
|
||||
private final long usedMemory;
|
||||
@ -25,16 +25,16 @@ public class TPS {
|
||||
* Constructor.
|
||||
*
|
||||
* @param date time of the TPS calculation.
|
||||
* @param tps average tps for the last minute.
|
||||
* @param ticksPerSecond average ticksPerSecond for the last minute.
|
||||
* @param players players for the minute.
|
||||
* @param cpuUsage CPU usage for the minute
|
||||
* @param usedMemory used memory at the time of fetching
|
||||
* @param entityCount amount of entities at the time of fetching
|
||||
* @param chunksLoaded amount of chunks loaded at the time of fetching
|
||||
*/
|
||||
public TPS(long date, double tps, int players, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded) {
|
||||
public TPS(long date, double ticksPerSecond, int players, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded) {
|
||||
this.date = date;
|
||||
this.tps = tps;
|
||||
this.ticksPerSecond = ticksPerSecond;
|
||||
this.players = players;
|
||||
this.cpuUsage = cpuUsage;
|
||||
this.usedMemory = usedMemory;
|
||||
@ -52,12 +52,12 @@ public class TPS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the average tps for the minute.
|
||||
* Get the average ticksPerSecond for the minute.
|
||||
*
|
||||
* @return 0-20 double
|
||||
*/
|
||||
public double getTps() {
|
||||
return tps;
|
||||
public double getTicksPerSecond() {
|
||||
return ticksPerSecond;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,7 +109,7 @@ public class TPS {
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 97 * hash + (int) (this.date ^ (this.date >>> 32));
|
||||
hash = 97 * hash + (int) (Double.doubleToLongBits(this.tps) ^ (Double.doubleToLongBits(this.tps) >>> 32));
|
||||
hash = 97 * hash + (int) (Double.doubleToLongBits(this.ticksPerSecond) ^ (Double.doubleToLongBits(this.ticksPerSecond) >>> 32));
|
||||
hash = 97 * hash + this.players;
|
||||
return hash;
|
||||
}
|
||||
@ -130,13 +130,13 @@ public class TPS {
|
||||
|
||||
final TPS other = (TPS) obj;
|
||||
return date == other.date
|
||||
&& Double.compare(this.tps, other.tps) == 0
|
||||
&& Double.compare(this.ticksPerSecond, other.ticksPerSecond) == 0
|
||||
&& this.players == other.players
|
||||
&& Double.compare(cpuUsage, other.cpuUsage) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TPS{" + date + "|" + tps + "|" + players + "|" + cpuUsage + "}";
|
||||
return "TPS{" + date + "|" + ticksPerSecond + "|" + players + "|" + cpuUsage + "}";
|
||||
}
|
||||
}
|
||||
|
@ -182,16 +182,6 @@ public class UserData {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getLastGamemode() {
|
||||
return gmTimes.getState();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public long getLastGmSwapTime() {
|
||||
return gmTimes.getLastStateChange();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an to the ips Set if it is not null or the set doesn't contain it.
|
||||
*
|
||||
|
@ -47,8 +47,8 @@ public class TPSPart extends RawData {
|
||||
addValue("entityseries", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsData));
|
||||
addValue("chunkseries", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsData));
|
||||
|
||||
double averageTPSWeek = MathUtils.averageDouble(week.stream().map(TPS::getTps));
|
||||
double averageTPSDay = MathUtils.averageDouble(day.stream().map(TPS::getTps));
|
||||
double averageTPSWeek = MathUtils.averageDouble(week.stream().map(TPS::getTicksPerSecond));
|
||||
double averageTPSDay = MathUtils.averageDouble(day.stream().map(TPS::getTicksPerSecond));
|
||||
|
||||
double averageCPUWeek = MathUtils.averageDouble(week.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||
double averageCPUDay = MathUtils.averageDouble(day.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||
|
@ -355,7 +355,7 @@ public class DataCacheHandler extends SessionCache {
|
||||
|
||||
for (List<TPS> history : copy) {
|
||||
final long lastDate = history.get(history.size() - 1).getDate();
|
||||
final double averageTPS = MathUtils.round(MathUtils.averageDouble(history.stream().map(TPS::getTps)));
|
||||
final double averageTPS = MathUtils.round(MathUtils.averageDouble(history.stream().map(TPS::getTicksPerSecond)));
|
||||
final int averagePlayersOnline = (int) MathUtils.averageInt(history.stream().map(TPS::getPlayers));
|
||||
final double averageCPUUsage = MathUtils.round(MathUtils.averageDouble(history.stream().map(TPS::getCPUUsage)));
|
||||
final long averageUsedMemory = MathUtils.averageLong(history.stream().map(TPS::getUsedMemory));
|
||||
|
@ -149,7 +149,7 @@ public class TPSTable extends Table {
|
||||
|
||||
for (TPS tps : batch) {
|
||||
statement.setLong(1, tps.getDate());
|
||||
statement.setDouble(2, tps.getTps());
|
||||
statement.setDouble(2, tps.getTicksPerSecond());
|
||||
statement.setInt(3, tps.getPlayers());
|
||||
statement.setDouble(4, tps.getCPUUsage());
|
||||
statement.setLong(5, tps.getUsedMemory());
|
||||
|
@ -22,7 +22,7 @@ public class TPSGraphCreator {
|
||||
|
||||
public static String buildSeriesDataString(List<TPS> tpsData) {
|
||||
List<Point> points = tpsData.stream()
|
||||
.map(tps -> new Point(tps.getDate(), tps.getTps()))
|
||||
.map(tps -> new Point(tps.getDate(), tps.getTicksPerSecond()))
|
||||
.collect(Collectors.toList());
|
||||
return SeriesCreator.seriesGraph(points, true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user