mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-01 00:10:12 +01:00
Bugfixes [2.6.1]
- Fix for #17: Schema now updated properly - Fix for #18 Hooks to other plugins no longer cause NPE if plugin is not found. (Added another constructor that sets isEnabled to false) - Fix for #19 Removed debug message and replaced with continue; - Fix for #20 Made new player creation async Made inspect & search commands async
This commit is contained in:
parent
44d1f6f021
commit
964954c674
@ -33,7 +33,7 @@ public class InspectCommand extends SubCommand {
|
|||||||
* @param plugin Current instance of Plan
|
* @param plugin Current instance of Plan
|
||||||
*/
|
*/
|
||||||
public InspectCommand(Plan plugin) {
|
public InspectCommand(Plan plugin) {
|
||||||
super("inspect", "plan.inspect", Phrase.CMD_USG_INSPECT+"", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_PLAYER+"");
|
super("inspect", "plan.inspect", Phrase.CMD_USG_INSPECT + "", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_PLAYER + "");
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
inspectCache = plugin.getInspectCache();
|
inspectCache = plugin.getInspectCache();
|
||||||
@ -67,7 +67,9 @@ public class InspectCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String playerName = MiscUtils.getPlayerDisplayname(args, sender);
|
String playerName = MiscUtils.getPlayerDisplayname(args, sender);
|
||||||
|
BukkitTask inspectTask = (new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
try {
|
try {
|
||||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||||
@ -76,16 +78,19 @@ public class InspectCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(Phrase.USERNAME_NOT_VALID.toString());
|
sender.sendMessage(Phrase.USERNAME_NOT_VALID.toString());
|
||||||
return true;
|
this.cancel();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
OfflinePlayer p = Bukkit.getOfflinePlayer(uuid);
|
OfflinePlayer p = Bukkit.getOfflinePlayer(uuid);
|
||||||
if (!p.hasPlayedBefore()) {
|
if (!p.hasPlayedBefore()) {
|
||||||
sender.sendMessage(Phrase.USERNAME_NOT_SEEN.toString());
|
sender.sendMessage(Phrase.USERNAME_NOT_SEEN.toString());
|
||||||
return true;
|
this.cancel();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!plugin.getDB().wasSeenBefore(uuid)) {
|
if (!plugin.getDB().wasSeenBefore(uuid)) {
|
||||||
sender.sendMessage(Phrase.USERNAME_NOT_KNOWN.toString());
|
sender.sendMessage(Phrase.USERNAME_NOT_KNOWN.toString());
|
||||||
return true;
|
this.cancel();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||||
inspectCache.cache(uuid);
|
inspectCache.cache(uuid);
|
||||||
@ -104,7 +109,7 @@ public class InspectCommand extends SubCommand {
|
|||||||
sender.sendMessage(Phrase.CMD_INSPECT_HEADER + playerName);
|
sender.sendMessage(Phrase.CMD_INSPECT_HEADER + playerName);
|
||||||
// Link
|
// Link
|
||||||
String url = HtmlUtils.getInspectUrl(playerName);
|
String url = HtmlUtils.getInspectUrl(playerName);
|
||||||
String message = Phrase.CMD_LINK+"";
|
String message = Phrase.CMD_LINK + "";
|
||||||
boolean console = !(sender instanceof Player);
|
boolean console = !(sender instanceof Player);
|
||||||
if (console) {
|
if (console) {
|
||||||
sender.sendMessage(message + url);
|
sender.sendMessage(message + url);
|
||||||
@ -113,12 +118,12 @@ public class InspectCommand extends SubCommand {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Bukkit.getServer().dispatchCommand(
|
Bukkit.getServer().dispatchCommand(
|
||||||
Bukkit.getConsoleSender(),
|
Bukkit.getConsoleSender(),
|
||||||
"tellraw " + player.getName() + " [\"\",{\"text\":\""+Phrase.CMD_CLICK_ME+"\",\"underlined\":true,"
|
"tellraw " + player.getName() + " [\"\",{\"text\":\"" + Phrase.CMD_CLICK_ME + "\",\"underlined\":true,"
|
||||||
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
|
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available+""));
|
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available + ""));
|
||||||
sender.sendMessage(Phrase.CMD_FOOTER+"");
|
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
if (timesrun > 10) {
|
if (timesrun > 10) {
|
||||||
@ -127,6 +132,8 @@ public class InspectCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
|
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
|
||||||
|
}
|
||||||
|
}).runTaskAsynchronously(plugin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -33,7 +35,7 @@ public class SearchCommand extends SubCommand {
|
|||||||
* @param plugin Current instance of Plan
|
* @param plugin Current instance of Plan
|
||||||
*/
|
*/
|
||||||
public SearchCommand(Plan plugin) {
|
public SearchCommand(Plan plugin) {
|
||||||
super("search", "plan.search", Phrase.CMD_USG_SEARCH+"", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_SEARCH+"");
|
super("search", "plan.search", Phrase.CMD_USG_SEARCH + "", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_SEARCH + "");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
inspectCache = plugin.getInspectCache();
|
inspectCache = plugin.getInspectCache();
|
||||||
}
|
}
|
||||||
@ -63,6 +65,9 @@ public class SearchCommand extends SubCommand {
|
|||||||
|
|
||||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||||
Set<OfflinePlayer> matches = MiscUtils.getMatchingDisplaynames(args[0]);
|
Set<OfflinePlayer> matches = MiscUtils.getMatchingDisplaynames(args[0]);
|
||||||
|
BukkitTask searchTask = (new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
Set<UUID> uuids = new HashSet<>();
|
Set<UUID> uuids = new HashSet<>();
|
||||||
for (OfflinePlayer match : matches) {
|
for (OfflinePlayer match : matches) {
|
||||||
UUID uuid = match.getUniqueId();
|
UUID uuid = match.getUniqueId();
|
||||||
@ -91,7 +96,7 @@ public class SearchCommand extends SubCommand {
|
|||||||
sender.sendMessage(Phrase.CMD_MATCH + name);
|
sender.sendMessage(Phrase.CMD_MATCH + name);
|
||||||
// Link
|
// Link
|
||||||
String url = HtmlUtils.getInspectUrl(name);
|
String url = HtmlUtils.getInspectUrl(name);
|
||||||
String message = Phrase.CMD_LINK+"";
|
String message = Phrase.CMD_LINK + "";
|
||||||
boolean console = !(sender instanceof Player);
|
boolean console = !(sender instanceof Player);
|
||||||
if (console) {
|
if (console) {
|
||||||
sender.sendMessage(message + url);
|
sender.sendMessage(message + url);
|
||||||
@ -105,8 +110,10 @@ public class SearchCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available+""));
|
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available + ""));
|
||||||
sender.sendMessage(Phrase.CMD_FOOTER+"");
|
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||||
|
}
|
||||||
|
}).runTaskAsynchronously(plugin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,11 @@ public class AdvancedAchievementsHook extends Hook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AdvancedAchievementsHook() {
|
||||||
|
super();
|
||||||
|
plugin = null;
|
||||||
|
}
|
||||||
|
|
||||||
private int calcTotalAchievements() throws Exception, NoClassDefFoundError {
|
private int calcTotalAchievements() throws Exception, NoClassDefFoundError {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (NormalAchievements category : NormalAchievements.values()) {
|
for (NormalAchievements category : NormalAchievements.values()) {
|
||||||
|
@ -33,6 +33,11 @@ public class EssentialsHook extends Hook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EssentialsHook() {
|
||||||
|
super();
|
||||||
|
plugin = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs information not provided by Player class or Plan from Essentials.
|
* Grabs information not provided by Player class or Plan from Essentials.
|
||||||
* isEnabled() should be called before this method.
|
* isEnabled() should be called before this method.
|
||||||
|
@ -32,6 +32,11 @@ public class FactionsHook extends Hook {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FactionsHook() {
|
||||||
|
super();
|
||||||
|
plugin = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return List of Faction names sorted by power
|
* @return List of Faction names sorted by power
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +25,10 @@ public abstract class Hook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Hook() {
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Whether or not the plugin was successfully hooked.
|
* @return Whether or not the plugin was successfully hooked.
|
||||||
*/
|
*/
|
||||||
|
@ -32,12 +32,36 @@ public class HookHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void hook() {
|
private void hook() {
|
||||||
try {advancedAchievementsHook = new AdvancedAchievementsHook(plan);} catch (NoClassDefFoundError e) {}
|
try {
|
||||||
try {essentialsHook = new EssentialsHook(plan);} catch (NoClassDefFoundError e) {}
|
advancedAchievementsHook = new AdvancedAchievementsHook(plan);
|
||||||
try {superbVoteHook = new SuperbVoteHook(plan);} catch (NoClassDefFoundError e) {}
|
} catch (NoClassDefFoundError e) {
|
||||||
try {factionsHook = new FactionsHook(plan);} catch (NoClassDefFoundError e) {}
|
advancedAchievementsHook = new AdvancedAchievementsHook();
|
||||||
try {townyHook = new TownyHook(plan);} catch (NoClassDefFoundError e) {}
|
}
|
||||||
try {onTimeHook = new OnTimeHook(plan);} catch (NoClassDefFoundError e) {}
|
try {
|
||||||
|
essentialsHook = new EssentialsHook(plan);
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
essentialsHook = new EssentialsHook();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
superbVoteHook = new SuperbVoteHook(plan);
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
superbVoteHook = new SuperbVoteHook();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
factionsHook = new FactionsHook(plan);
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
factionsHook = new FactionsHook();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
townyHook = new TownyHook(plan);
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
townyHook = new TownyHook();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
onTimeHook = new OnTimeHook(plan);
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
onTimeHook = new OnTimeHook();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdvancedAchievementsHook getAdvancedAchievementsHook() {
|
public AdvancedAchievementsHook getAdvancedAchievementsHook() {
|
||||||
@ -73,7 +97,7 @@ public class HookHandler {
|
|||||||
TownyHook tH = townyHook;
|
TownyHook tH = townyHook;
|
||||||
addReplace.put("%towntable%", tH.isEnabled() ? SortableTownTableCreator.createSortableTownsTable(tH.getTopTowns(), tH) : "");
|
addReplace.put("%towntable%", tH.isEnabled() ? SortableTownTableCreator.createSortableTownsTable(tH.getTopTowns(), tH) : "");
|
||||||
addReplace.put("%factionstable%", fH.isEnabled() ? SortableFactionsTableCreator.createSortableFactionsTable(fH.getTopFactions(), fH) : "");
|
addReplace.put("%factionstable%", fH.isEnabled() ? SortableFactionsTableCreator.createSortableFactionsTable(fH.getTopFactions(), fH) : "");
|
||||||
addReplace.put("%essentialswarps%", eH.isEnabled() ? "<br/>Warps: "+eH.getWarps().toString() : "");
|
addReplace.put("%essentialswarps%", eH.isEnabled() ? "<br/>Warps: " + eH.getWarps().toString() : "");
|
||||||
return addReplace;
|
return addReplace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,11 @@ public class OnTimeHook extends Hook {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OnTimeHook() {
|
||||||
|
super();
|
||||||
|
plugin = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs information not provided by Player class or Plan from OnTime.
|
* Grabs information not provided by Player class or Plan from OnTime.
|
||||||
* isEnabled() should be called before this method.
|
* isEnabled() should be called before this method.
|
||||||
|
@ -24,6 +24,11 @@ public class SuperbVoteHook extends Hook {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SuperbVoteHook() {
|
||||||
|
super();
|
||||||
|
plugin = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs votes from SuperbVote.
|
* Grabs votes from SuperbVote.
|
||||||
* isEnabled() should be called before this
|
* isEnabled() should be called before this
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package main.java.com.djrapitops.plan.data.additional;
|
package main.java.com.djrapitops.plan.data.additional;
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||||
@ -23,7 +22,7 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
|||||||
public class TownyHook extends Hook {
|
public class TownyHook extends Hook {
|
||||||
|
|
||||||
private final Plan plugin;
|
private final Plan plugin;
|
||||||
private final Towny towny;
|
private Towny towny;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hooks to Factions plugin
|
* Hooks to Factions plugin
|
||||||
@ -36,6 +35,11 @@ public class TownyHook extends Hook {
|
|||||||
this.towny = getPlugin(Towny.class);
|
this.towny = getPlugin(Towny.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TownyHook() {
|
||||||
|
super();
|
||||||
|
plugin = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return List of Faction names sorted by power
|
* @return List of Faction names sorted by power
|
||||||
*/
|
*/
|
||||||
@ -62,7 +66,7 @@ public class TownyHook extends Hook {
|
|||||||
info.put("RESIDENTS", town.getNumResidents());
|
info.put("RESIDENTS", town.getNumResidents());
|
||||||
info.put("MAYOR", town.getMayor().getName());
|
info.put("MAYOR", town.getMayor().getName());
|
||||||
info.put("LAND", town.getPurchasedBlocks());
|
info.put("LAND", town.getPurchasedBlocks());
|
||||||
} catch (NotRegisteredException ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -85,7 +89,7 @@ public class TownyHook extends Hook {
|
|||||||
info.put("TOWN", "Not in town");
|
info.put("TOWN", "Not in town");
|
||||||
}
|
}
|
||||||
info.put("FRIENDS", res.getFriends().toString());
|
info.put("FRIENDS", res.getFriends().toString());
|
||||||
} catch (NotRegisteredException ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -61,6 +63,9 @@ public class PlanPlayerListener implements Listener {
|
|||||||
public void onPlayerLogin(PlayerJoinEvent event) {
|
public void onPlayerLogin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
BukkitTask asyncLoginSaveTask = (new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
boolean isNewPlayer = activityH.isFirstTimeJoin(uuid);
|
boolean isNewPlayer = activityH.isFirstTimeJoin(uuid);
|
||||||
if (isNewPlayer) {
|
if (isNewPlayer) {
|
||||||
handler.newPlayer(player);
|
handler.newPlayer(player);
|
||||||
@ -77,6 +82,9 @@ public class PlanPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
handler.getUserDataForProcessing(loginProcessor, uuid);
|
handler.getUserDataForProcessing(loginProcessor, uuid);
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
}).runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,6 +8,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -188,9 +189,12 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
boolean usingMySQL = supportsModification;
|
boolean usingMySQL = supportsModification;
|
||||||
|
|
||||||
ResultSet set = connection.prepareStatement(supportsModification ? ("SHOW TABLES LIKE '" + userName + "'") : "SELECT name FROM sqlite_master WHERE type='table' AND name='" + userName + "'").executeQuery();
|
boolean newDatabase = true;
|
||||||
boolean newDatabase = set.next();
|
try {
|
||||||
set.close();
|
getVersion();
|
||||||
|
newDatabase = false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
query("CREATE TABLE IF NOT EXISTS " + userName + " ("
|
query("CREATE TABLE IF NOT EXISTS " + userName + " ("
|
||||||
+ userColumnID + " integer " + ((usingMySQL) ? "NOT NULL AUTO_INCREMENT" : "PRIMARY KEY") + ", "
|
+ userColumnID + " integer " + ((usingMySQL) ? "NOT NULL AUTO_INCREMENT" : "PRIMARY KEY") + ", "
|
||||||
+ userColumnUUID + " varchar(36) NOT NULL UNIQUE, "
|
+ userColumnUUID + " varchar(36) NOT NULL UNIQUE, "
|
||||||
@ -272,38 +276,29 @@ public abstract class SQLDB extends Database {
|
|||||||
+ ")"
|
+ ")"
|
||||||
);
|
);
|
||||||
if (newDatabase) {
|
if (newDatabase) {
|
||||||
setVersion(2);
|
plugin.log("New Database created.");
|
||||||
|
setVersion(3);
|
||||||
}
|
}
|
||||||
int version = getVersion();
|
int version = getVersion();
|
||||||
if (version < 1) {
|
if (version < 3) {
|
||||||
|
String sqlite = usingMySQL ? "" : "COLUMN ";
|
||||||
String[] queries = new String[]{
|
String[] queries = new String[]{
|
||||||
"ALTER TABLE " + userName + " ADD " + userColumnDeaths + " integer NOT NULL DEFAULT 0",
|
"ALTER TABLE " + userName + " ADD " + sqlite + userColumnDeaths + " integer NOT NULL DEFAULT 0",
|
||||||
"ALTER TABLE " + userName + " ADD " + userColumnMobKills + " integer NOT NULL DEFAULT 0",
|
"ALTER TABLE " + userName + " ADD " + sqlite + userColumnMobKills + " integer NOT NULL DEFAULT 0",
|
||||||
"ALTER TABLE " + nicknamesName + " ADD " + nicknamesColumnCurrent + " boolean NOT NULL DEFAULT (false)",
|
"ALTER TABLE " + nicknamesName + " ADD " + sqlite + nicknamesColumnCurrent + " boolean NOT NULL DEFAULT 0",
|
||||||
"DROP TABLE IF EXISTS " + serverdataName
|
|
||||||
};
|
|
||||||
for (String query : queries) {
|
|
||||||
try {
|
|
||||||
query(query);
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setVersion(1);
|
|
||||||
} else if (version < 2) {
|
|
||||||
String[] queries = new String[]{
|
|
||||||
"ALTER TABLE " + nicknamesName + " ADD " + nicknamesColumnCurrent + " boolean NOT NULL DEFAULT 0",
|
|
||||||
"DROP TABLE IF EXISTS " + serverdataName
|
"DROP TABLE IF EXISTS " + serverdataName
|
||||||
};
|
};
|
||||||
for (String query : queries) {
|
for (String query : queries) {
|
||||||
try {
|
try {
|
||||||
query(query);
|
query(query);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (usingMySQL) {
|
if (usingMySQL) {
|
||||||
query("ALTER TABLE " + userName + " DROP INDEX " + userColumnPlayerKills);
|
query("ALTER TABLE " + userName + " DROP INDEX " + userColumnPlayerKills);
|
||||||
}
|
}
|
||||||
setVersion(2);
|
setVersion(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -514,7 +509,6 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
// Check if user is in the database
|
// Check if user is in the database
|
||||||
if (!wasSeenBefore(uuid)) {
|
if (!wasSeenBefore(uuid)) {
|
||||||
plugin.logError(uuid + " was not found from the database!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<World> worldList = Bukkit.getServer().getWorlds();
|
List<World> worldList = Bukkit.getServer().getWorlds();
|
||||||
@ -705,7 +699,7 @@ public abstract class SQLDB extends Database {
|
|||||||
for (UserData uData : data) {
|
for (UserData uData : data) {
|
||||||
try {
|
try {
|
||||||
if (uData == null) {
|
if (uData == null) {
|
||||||
throw new IllegalStateException("UserData is null somehow!");
|
continue;
|
||||||
}
|
}
|
||||||
uData.access();
|
uData.access();
|
||||||
int userId = getUserId(uData.getUuid().toString());
|
int userId = getUserId(uData.getUuid().toString());
|
||||||
@ -751,7 +745,7 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
for (UserData uData : data) {
|
for (UserData uData : data) {
|
||||||
if (uData == null) {
|
if (uData == null) {
|
||||||
throw new IllegalStateException("UserData is null somehow!");
|
continue;
|
||||||
}
|
}
|
||||||
uData.access();
|
uData.access();
|
||||||
try {
|
try {
|
||||||
@ -867,7 +861,9 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveAdditionalLocationsList(int userId, List<Location> locations) throws SQLException {
|
public void saveAdditionalLocationsList(int userId, List<Location> locations) throws SQLException {
|
||||||
if (locations.isEmpty()) {
|
List<Location> newLocations = new ArrayList<>();
|
||||||
|
newLocations.addAll(locations);
|
||||||
|
if (newLocations.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PreparedStatement saveStatement = connection.prepareStatement("INSERT INTO " + locationName + " ("
|
PreparedStatement saveStatement = connection.prepareStatement("INSERT INTO " + locationName + " ("
|
||||||
@ -877,8 +873,8 @@ public abstract class SQLDB extends Database {
|
|||||||
+ locationColumnWorld
|
+ locationColumnWorld
|
||||||
+ ") VALUES (?, ?, ?, ?)");
|
+ ") VALUES (?, ?, ?, ?)");
|
||||||
boolean commitRequired = false;
|
boolean commitRequired = false;
|
||||||
if (!locations.isEmpty()) {
|
if (!newLocations.isEmpty()) {
|
||||||
for (Location location : locations) {
|
for (Location location : newLocations) {
|
||||||
saveStatement.setInt(1, userId);
|
saveStatement.setInt(1, userId);
|
||||||
saveStatement.setInt(2, (int) location.getBlockX());
|
saveStatement.setInt(2, (int) location.getBlockX());
|
||||||
saveStatement.setInt(3, (int) location.getBlockZ());
|
saveStatement.setInt(3, (int) location.getBlockZ());
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: Plan
|
name: Plan
|
||||||
author: Rsl1122
|
author: Rsl1122
|
||||||
main: main.java.com.djrapitops.plan.Plan
|
main: main.java.com.djrapitops.plan.Plan
|
||||||
version: 2.6.0
|
version: 2.6.1
|
||||||
|
|
||||||
softdepend:
|
softdepend:
|
||||||
- OnTime
|
- OnTime
|
||||||
|
Loading…
Reference in New Issue
Block a user