diff --git a/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_0.xml b/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_1.xml similarity index 67% rename from .idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_0.xml rename to .idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_1.xml index e90b3b519..826d210d1 100644 --- a/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_0.xml +++ b/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_1.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/Plan/dependency-reduced-pom.xml b/Plan/dependency-reduced-pom.xml index 3e8915339..8da93e303 100644 --- a/Plan/dependency-reduced-pom.xml +++ b/Plan/dependency-reduced-pom.xml @@ -1,183 +1,186 @@ - - 4.0.0 - com.djrapitops - Plan - 3.5.4 - - ${basedir}/src - clean package install - - - . - ${basedir}/src/main/resources - - *.yml - *.html - - - - ${project.name} - - - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - - - - maven-shade-plugin - 2.4.3 - - - package - - shade - - - - - - - org.powermock:* - org.javassist:* - com.thoughtworks.xstream:* - xmlpull:* - xpp3:* - org.objenesis:* - cglib:* - org.*:* - org.easymock:* - junit:* - - - - - - maven-jar-plugin - 2.6 - - - **/test/* - **/*/test/* - **/*/test.* - **/test/**/* - - - - - org.pitest - pitest-maven - 1.1.8 - - - main.java.com.djrapitops.plan.* - - - test.java.main.java.com.djrapitops.plan.* - - 1000 - - - - maven-checkstyle-plugin - 2.17 - - **/test/**/* - checkstyle.xml - - - - maven-javadoc-plugin - 2.10.4 - - test.* - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - - - org.spigotmc - spigot - 1.12-R0.1-SNAPSHOT - provided - - - org.powermock - powermock - 1.6.6 - pom - compile - - - org.powermock - powermock-api-mockito - 1.6.6 - compile - - - org.powermock - powermock-module-junit4 - 1.6.6 - compile - - - org.powermock - powermock-module-junit4-rule - 1.6.6 - compile - - - org.powermock - powermock-classloading-xstream - 1.6.6 - compile - - - org.mockito - mockito-core - 1.10.19 - compile - - - org.powermock - powermock-api-easymock - 1.6.6 - compile - - - org.easymock - easymock - 3.4 - compile - - - junit - junit - 4.12 - compile - - - org.hamcrest - hamcrest-core - 1.3 - test - - - - 1.8 - UTF-8 - 1.8 - + + 4.0.0 + com.djrapitops + Plan + 3.5.5 + + ${basedir}/src + clean package install + + + . + ${basedir}/src/main/resources + + *.yml + *.html + + + + ${project.name} + + + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + + + + maven-shade-plugin + 2.4.3 + + + package + + shade + + + + + + + org.powermock:* + org.javassist:* + com.thoughtworks.xstream:* + xmlpull:* + xpp3:* + org.objenesis:* + cglib:* + org.*:* + org.easymock:* + junit:* + + + + + + maven-jar-plugin + 2.6 + + + **/test/* + **/*/test/* + **/*/test.* + **/test/**/* + + + + + org.pitest + pitest-maven + 1.1.8 + + + main.java.com.djrapitops.plan.* + + + test.java.main.java.com.djrapitops.plan.* + + 1000 + + + + maven-checkstyle-plugin + 2.17 + + **/test/**/* + checkstyle.xml + + + + maven-javadoc-plugin + 2.10.4 + + test.* + + + + + + + plan-repo + http://repo.fuzzlemann.de/artifactory/libs-release/ + + + plan-snapshot-repo + http://repo.fuzzlemann.de/artifactory/libs-snapshot/ + + + + + com.destroystokyo.paper + paper + 1.12-R0.1-20170725.202533-1 + provided + + + org.powermock + powermock + 1.6.6 + pom + compile + + + org.powermock + powermock-api-mockito + 1.6.6 + compile + + + org.powermock + powermock-module-junit4 + 1.6.6 + compile + + + org.powermock + powermock-module-junit4-rule + 1.6.6 + compile + + + org.powermock + powermock-classloading-xstream + 1.6.6 + compile + + + org.mockito + mockito-core + 1.10.19 + compile + + + org.powermock + powermock-api-easymock + 1.6.6 + compile + + + org.easymock + easymock + 3.4 + compile + + + junit + junit + 4.12 + compile + + + org.hamcrest + hamcrest-core + 1.3 + test + + + + 1.8 + UTF-8 + 1.8 + diff --git a/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java b/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java index f7bbbb6e1..46feb38ed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java +++ b/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java @@ -25,7 +25,8 @@ public class ServerVariableHolder { ip = server.getIp(); String serverName = server.getName(); - usingPaper = serverName.equals("Paper") || serverName.equals("TacoSpigot"); + usingPaper = serverName.equals("Paper") + || serverName.equals("TacoSpigot"); //Fork of Paper } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index da35baaba..80a0d742b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -15,9 +15,7 @@ import main.java.com.djrapitops.plan.ui.text.TextUI; import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.HtmlUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.command.CommandException; /** * This subcommand is used to run the analysis and access the /server link. @@ -150,12 +148,4 @@ public class AnalyzeCommand extends SubCommand { } sender.sendMessage(Phrase.CMD_FOOTER.toString()); } - - @Deprecated // TODO Will be rewritten to the RslPlugin abstractions in the future. - private void sendLink(ISender sender, String url) throws CommandException { - plugin.getServer().dispatchCommand( - Bukkit.getConsoleSender(), - "tellraw " + sender.getName() + " [\"\",{\"text\":\"" + Phrase.CMD_CLICK_ME + "\",\"underlined\":true," - + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]"); - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 6a45ada52..5ee812514 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -153,4 +153,4 @@ public class InspectCommand extends SubCommand { sender.sendMessage(Phrase.CMD_FOOTER + ""); } -} \ No newline at end of file +} diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageCleanCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageCleanCommand.java index 4da62da1a..d529912f8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageCleanCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageCleanCommand.java @@ -39,6 +39,7 @@ public class ManageCleanCommand extends SubCommand { if (!Check.isTrue(args.length != 0, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) { return true; } + String dbName = args[0].toLowerCase(); boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java index 97dab4ac3..08367a022 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java @@ -78,6 +78,7 @@ public class ManageImportCommand extends SubCommand { if (!Check.isTrue(importPlugins.keySet().contains(importFromPlugin), Phrase.MANAGE_ERROR_INCORRECT_PLUGIN + importFromPlugin, sender)) { return true; } + if (!Check.isTrue(ImportUtils.isPluginEnabled(importFromPlugin), Phrase.MANAGE_ERROR_PLUGIN_NOT_ENABLED + importFromPlugin, sender)) { return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java index 45e4c7d9a..ffec8a003 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java @@ -58,9 +58,11 @@ public class ManageMoveCommand extends SubCommand { if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + toDB, sender)) { return true; } + if (!Check.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Phrase.MANAGE_ERROR_SAME_DB.toString(), sender)) { return true; } + if (!Check.isTrue(Verify.contains("-a", args), Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(args[1])), sender)) { return true; } @@ -92,7 +94,9 @@ public class ManageMoveCommand extends SubCommand { if (Check.isTrue(Verify.isEmpty(uuids), Phrase.MANAGE_ERROR_NO_PLAYERS + " (" + fromDatabase.getName() + ")", sender)) { return; } + sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse()); + if (ManageUtils.clearAndCopy(toDatabase, fromDatabase, uuids)) { sender.sendMessage(Phrase.MANAGE_MOVE_SUCCESS + ""); boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), plugin.getDB().getConfigName()); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index f7b3c4093..c8ec111f4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -74,13 +74,16 @@ public class ManageRemoveCommand extends SubCommand { try { UUID uuid = UUIDUtility.getUUIDOf(playerName); String message = Phrase.USERNAME_NOT_VALID.toString(); + if (!Check.isTrue(Verify.notNull(uuid), message, sender)) { return; } + message = Phrase.USERNAME_NOT_KNOWN.toString(); if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), message, sender)) { return; } + message = Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(plugin.getDB().getConfigName())); if (!Check.isTrue(Verify.contains("-a", args), message, sender)) { return; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java index 3ef71609f..671809b8f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java @@ -44,12 +44,14 @@ public class ManageRestoreCommand extends SubCommand { if (!Check.isTrue(args.length >= 2, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_RESTORE.toString()), sender)) { return true; } + String db = args[1].toLowerCase(); boolean isCorrectDB = "sqlite".equals(db) || "mysql".equals(db); if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + db, sender)) { return true; } + if (!Check.isTrue(Verify.contains("-a", args), Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REWRITE.parse(args[1])), sender)) { return true; } @@ -81,20 +83,25 @@ public class ManageRestoreCommand extends SubCommand { if (containsDBFileExtension) { backupDBName = backupDBName.replace(".db", ""); } + SQLiteDB backupDB = new SQLiteDB(plugin, backupDBName); if (!backupDB.init()) { sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE.toString()); return; } + sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse()); + final Collection uuids = ManageUtils.getUUIDS(backupDB); if (!Check.isTrue(!Verify.isEmpty(uuids), Phrase.MANAGE_ERROR_NO_PLAYERS + " (" + backupDBName + ")", sender)) { return; } + if (ManageUtils.clearAndCopy(database, backupDB, uuids)) { if (database.getConfigName().equals(plugin.getDB().getConfigName())) { plugin.getHandler().getCommandUseFromDb(); } + sender.sendMessage(Phrase.MANAGE_COPY_SUCCESS.toString()); } else { sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString()); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java index 1a2a98d60..c34f18b19 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java @@ -37,7 +37,6 @@ public class WebListUsersCommand extends SubCommand { try { ColorScheme cs = plugin.getColorScheme(); String mCol = cs.getMainColor(); - String sCol = cs.getSecondaryColor(); List users = plugin.getDB().getSecurityTable().getUsers(); users.sort(new WebUserComparator()); sender.sendMessage(Phrase.CMD_FOOTER.parse() + mCol + " WebUsers (" + users.size() + ")"); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/analysis/GamemodePart.java b/Plan/src/main/java/com/djrapitops/plan/data/analysis/GamemodePart.java index 29a90c5ec..150d9df1f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/analysis/GamemodePart.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/analysis/GamemodePart.java @@ -53,10 +53,10 @@ public class GamemodePart extends RawData { long[] times = new long[]{ survivalTime, creativeTime, adventureTime, spectatorTime }; - String col0 = Settings.HCOLOR_GMP_0 + ""; - String col1 = Settings.HCOLOR_GMP_1 + ""; - String col2 = Settings.HCOLOR_GMP_2 + ""; - String col3 = Settings.HCOLOR_GMP_3 + ""; + String col0 = Settings.HCOLOR_GMP_0.toString(); + String col1 = Settings.HCOLOR_GMP_1.toString(); + String col2 = Settings.HCOLOR_GMP_2.toString(); + String col3 = Settings.HCOLOR_GMP_3.toString(); addValue("%gm0col%", col0); addValue("%gm1col%", col1); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/cache/GeolocationCacheHandler.java b/Plan/src/main/java/com/djrapitops/plan/data/cache/GeolocationCacheHandler.java index 1f9b5a453..f4a7fe0ce 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/cache/GeolocationCacheHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/cache/GeolocationCacheHandler.java @@ -87,7 +87,5 @@ public class GeolocationCacheHandler { } finally { Benchmark.stop("getUncachedCountry"); } - } - } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanDeathEventListener.java b/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanDeathEventListener.java index 06cd75d31..9ee87bf58 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanDeathEventListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanDeathEventListener.java @@ -6,11 +6,12 @@ import main.java.com.djrapitops.plan.data.handling.info.DeathInfo; import main.java.com.djrapitops.plan.data.handling.info.KillInfo; import main.java.com.djrapitops.plan.utilities.MiscUtils; import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; /** @@ -41,9 +42,21 @@ public class PlanDeathEventListener implements Listener { public void onDeath(EntityDeathEvent event) { long time = MiscUtils.getTime(); LivingEntity dead = event.getEntity(); - Player killer = dead.getKiller(); - boolean killerIsPlayer = killer != null; - if (killerIsPlayer) { + + if (dead instanceof Player) { + handler.addToPool(new DeathInfo(dead.getUniqueId())); + } + + EntityDamageEvent entityDamageEvent = dead.getLastDamageCause(); + if (!(entityDamageEvent instanceof EntityDamageByEntityEvent)) { + return; + } + + EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) entityDamageEvent; + Entity killerEntity = entityDamageByEntityEvent.getDamager(); + + if (killerEntity instanceof Player) { + Player killer = (Player) killerEntity; Material itemInHand; try { itemInHand = killer.getInventory().getItemInMainHand().getType(); @@ -54,10 +67,26 @@ public class PlanDeathEventListener implements Listener { itemInHand = Material.AIR; } } + handler.addToPool(new KillInfo(killer.getUniqueId(), time, dead, itemInHand.name())); + return; } - if (dead instanceof Player) { - handler.addToPool(new DeathInfo(dead.getUniqueId())); + + if (killerEntity instanceof Wolf) { + Wolf wolf = (Wolf) killerEntity; + + if (!wolf.isTamed()) { + return; + } + + AnimalTamer owner = wolf.getOwner(); + + if (!(owner instanceof Player)) { + return; + } + + handler.addToPool(new KillInfo(owner.getUniqueId(), time, dead, "Wolf")); } } } + diff --git a/Plan/src/main/java/com/djrapitops/plan/data/listeners/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/data/listeners/TPSCountTimer.java index 3802b6520..edc65d4e7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/listeners/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/listeners/TPSCountTimer.java @@ -75,8 +75,8 @@ public class TPSCountTimer extends AbsRunnable { Runtime runtime = Runtime.getRuntime(); - long totalMemory = runtime.totalMemory() / 1024L; - long usedMemory = totalMemory - runtime.freeMemory() / 1024L; + long totalMemory = runtime.totalMemory(); + long usedMemory = (totalMemory - runtime.freeMemory()) / (1024L * 1024L); int playersOnline = plugin.getServer().getOnlinePlayers().size(); int loadedChunks = getLoadedChunks();