mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-01 00:10:12 +01:00
Bugfixes & Two more listeners [2.0.0-DEV]
- Async tasks for database. - Proper save on disable. - Debugging with inspect command. - Database now manages to save and load data, data needs to be debugged. Known bugs: - CommandListener things every command is / - LastGameMode is set to null when player joins - NullPointerException: LoginTimes when player not online on inspect - Some values are negative (Probably times) - ServerData not updating properly - (DataBase saves non-existent ids) - LoginTimes is not updated - LoginTimes not found from database with sqlite3
This commit is contained in:
parent
e903a5ac25
commit
fa776d30fd
@ -8,8 +8,10 @@ import com.djrapitops.plan.database.databases.MySQLDB;
|
|||||||
import com.djrapitops.plan.database.databases.SQLiteDB;
|
import com.djrapitops.plan.database.databases.SQLiteDB;
|
||||||
import com.djrapitops.plan.datahandlers.DataHandler;
|
import com.djrapitops.plan.datahandlers.DataHandler;
|
||||||
import com.djrapitops.plan.datahandlers.listeners.PlanChatListener;
|
import com.djrapitops.plan.datahandlers.listeners.PlanChatListener;
|
||||||
|
import com.djrapitops.plan.datahandlers.listeners.PlanCommandPreprocessListener;
|
||||||
import com.djrapitops.plan.datahandlers.listeners.PlanGamemodeChangeListener;
|
import com.djrapitops.plan.datahandlers.listeners.PlanGamemodeChangeListener;
|
||||||
import com.djrapitops.plan.datahandlers.listeners.PlanPlayerListener;
|
import com.djrapitops.plan.datahandlers.listeners.PlanPlayerListener;
|
||||||
|
import com.djrapitops.plan.datahandlers.listeners.PlanPlayerMoveListener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -72,7 +74,9 @@ public class Plan extends JavaPlugin {
|
|||||||
log(MiscUtils.checkVersion());
|
log(MiscUtils.checkVersion());
|
||||||
|
|
||||||
getCommand("plan").setExecutor(new PlanCommand(this));
|
getCommand("plan").setExecutor(new PlanCommand(this));
|
||||||
|
handler.handleReload();
|
||||||
|
|
||||||
|
logToFile("-- Server Start/Reload --");
|
||||||
log("Player Analytics Enabled.");
|
log("Player Analytics Enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +98,8 @@ public class Plan extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
log("Saving cached data..");
|
log("Saving cached data..");
|
||||||
handler.saveCachedData();
|
handler.saveCacheOnDisable();
|
||||||
|
db.close();
|
||||||
log("Player Analytics Disabled.");
|
log("Player Analytics Disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +149,8 @@ public class Plan extends JavaPlugin {
|
|||||||
getServer().getPluginManager().registerEvents(new PlanChatListener(this), this);
|
getServer().getPluginManager().registerEvents(new PlanChatListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlanPlayerListener(this), this);
|
getServer().getPluginManager().registerEvents(new PlanPlayerListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlanGamemodeChangeListener(this), this);
|
getServer().getPluginManager().registerEvents(new PlanGamemodeChangeListener(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new PlanCommandPreprocessListener(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new PlanPlayerMoveListener(this), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataHandler getHandler() {
|
public DataHandler getHandler() {
|
||||||
|
@ -7,16 +7,19 @@ import com.djrapitops.plan.command.CommandType;
|
|||||||
import com.djrapitops.plan.command.SubCommand;
|
import com.djrapitops.plan.command.SubCommand;
|
||||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||||
import com.djrapitops.plan.command.utils.DataUtils;
|
import com.djrapitops.plan.command.utils.DataUtils;
|
||||||
|
import com.djrapitops.plan.database.ServerData;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import com.djrapitops.plan.database.UserData;
|
import com.djrapitops.plan.database.UserData;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
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 static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
|
|
||||||
public class InspectCommand extends SubCommand {
|
public class InspectCommand extends SubCommand {
|
||||||
|
|
||||||
@ -57,12 +60,31 @@ public class InspectCommand extends SubCommand {
|
|||||||
ChatColor operatorColor = Phrase.COLOR_MAIN.color();
|
ChatColor operatorColor = Phrase.COLOR_MAIN.color();
|
||||||
ChatColor textColor = Phrase.COLOR_SEC.color();
|
ChatColor textColor = Phrase.COLOR_SEC.color();
|
||||||
|
|
||||||
|
List<String> msgs = new ArrayList<>();
|
||||||
|
msgs.add(""+data.getLoginTimes());
|
||||||
|
msgs.add(""+data.getBedLocation().getBlockX());
|
||||||
|
msgs.add(""+data.getDemData().getGeoLocation());
|
||||||
|
msgs.add(""+data.getGmTimes().keySet().toString());
|
||||||
|
msgs.add(""+data.getIps().toString());
|
||||||
|
msgs.add(""+data.getLastGamemode());
|
||||||
|
msgs.add(""+data.getLastGmSwapTime());
|
||||||
|
msgs.add(""+data.getLastPlayed());
|
||||||
|
msgs.add(""+data.getLocation().getBlockX());
|
||||||
|
msgs.add(""+data.getNicknames().toString());
|
||||||
|
msgs.add(""+data.getRegistered());
|
||||||
|
msgs.add(""+data.getTimesKicked());
|
||||||
|
msgs.add(""+data.getUuid());
|
||||||
|
msgs.add(operatorColor+"SERVER");
|
||||||
|
ServerData sdata = plugin.getHandler().getServerData();
|
||||||
|
msgs.add(""+sdata.getCommandUsage().keySet().toString());
|
||||||
|
msgs.add(""+sdata.getNewPlayers());
|
||||||
|
msgs.add(""+sdata.getPlayersOnline());
|
||||||
//header
|
//header
|
||||||
sender.sendMessage(textColor + "-- [" + operatorColor + "PLAN - Inspect results: " + playerName +" - took "+DataFormatUtils.formatTimeAmountSinceDate(refreshDate, new Date())+ textColor + "] --");
|
sender.sendMessage(textColor + "-- [" + operatorColor + "PLAN - Inspect results: " + playerName +" - took "+DataFormatUtils.formatTimeAmountSinceDate(refreshDate, new Date())+ textColor + "] --");
|
||||||
|
|
||||||
sender.sendMessage(data.getUuid().toString());
|
for (String message : msgs) {
|
||||||
sender.sendMessage(data.getIps().toString());
|
sender.sendMessage(textColor+message);
|
||||||
sender.sendMessage(""+data.isBanned());
|
}
|
||||||
|
|
||||||
sender.sendMessage(textColor + "-- o --");
|
sender.sendMessage(textColor + "-- o --");
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||||
|
|
||||||
public class MiscUtils {
|
public class MiscUtils {
|
||||||
@ -58,4 +59,22 @@ public class MiscUtils {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GameMode parseGM(String string) {
|
||||||
|
String survival = GameMode.SURVIVAL.name();
|
||||||
|
String creative = GameMode.CREATIVE.name();
|
||||||
|
String adventure = GameMode.ADVENTURE.name();
|
||||||
|
String spectator = GameMode.SPECTATOR.name();
|
||||||
|
if (string.equalsIgnoreCase(survival)) {
|
||||||
|
return GameMode.SURVIVAL;
|
||||||
|
} else if (string.equalsIgnoreCase(creative)) {
|
||||||
|
return GameMode.CREATIVE;
|
||||||
|
} else if (string.equalsIgnoreCase(adventure)) {
|
||||||
|
return GameMode.ADVENTURE;
|
||||||
|
} else if (string.equalsIgnoreCase(spectator)) {
|
||||||
|
return GameMode.SPECTATOR;
|
||||||
|
} else {
|
||||||
|
return GameMode.SURVIVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,6 @@ import com.djrapitops.plan.Plan;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public abstract class Database {
|
public abstract class Database {
|
||||||
|
|
||||||
@ -48,5 +44,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
public abstract void saveServerData(ServerData serverData);
|
public abstract void saveServerData(ServerData serverData);
|
||||||
|
|
||||||
public abstract ServerData getServerData();
|
public abstract ServerData getNewestServerData();
|
||||||
|
|
||||||
|
public abstract void close();
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class DemographicsData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DemographicsData() {
|
public DemographicsData() {
|
||||||
this(-1, Gender.UNKNOWN, "UNKNOWN");
|
this(-1, Gender.UNKNOWN, "Not_known");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package com.djrapitops.plan.database;
|
package com.djrapitops.plan.database;
|
||||||
|
|
||||||
import com.djrapitops.plan.database.DemographicsData;
|
|
||||||
import com.djrapitops.plan.database.Database;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -38,6 +37,9 @@ public class UserData {
|
|||||||
public UserData(Player player, DemographicsData demData, Database db) {
|
public UserData(Player player, DemographicsData demData, Database db) {
|
||||||
uuid = player.getUniqueId();
|
uuid = player.getUniqueId();
|
||||||
bedLocation = player.getBedSpawnLocation();
|
bedLocation = player.getBedSpawnLocation();
|
||||||
|
if (bedLocation == null) {
|
||||||
|
bedLocation = new Location(Bukkit.getServer().getWorlds().get(0), 0, 0 ,0);
|
||||||
|
}
|
||||||
registered = player.getFirstPlayed();
|
registered = player.getFirstPlayed();
|
||||||
location = player.getLocation();
|
location = player.getLocation();
|
||||||
isOp = player.isOp();
|
isOp = player.isOp();
|
||||||
@ -45,6 +47,12 @@ public class UserData {
|
|||||||
nicknames = new ArrayList<>();
|
nicknames = new ArrayList<>();
|
||||||
ips = new ArrayList<>();
|
ips = new ArrayList<>();
|
||||||
gmTimes = new HashMap<>();
|
gmTimes = new HashMap<>();
|
||||||
|
long zero = Long.parseLong("0");
|
||||||
|
gmTimes.put(GameMode.SURVIVAL, zero);
|
||||||
|
gmTimes.put(GameMode.CREATIVE, zero);
|
||||||
|
gmTimes.put(GameMode.ADVENTURE, zero);
|
||||||
|
gmTimes.put(GameMode.SPECTATOR, zero);
|
||||||
|
lastGamemode = player.getGameMode();
|
||||||
this.demData = demData;
|
this.demData = demData;
|
||||||
isBanned = player.isBanned();
|
isBanned = player.isBanned();
|
||||||
}
|
}
|
||||||
@ -52,24 +60,20 @@ public class UserData {
|
|||||||
public UserData(OfflinePlayer player, DemographicsData demData, Database db) {
|
public UserData(OfflinePlayer player, DemographicsData demData, Database db) {
|
||||||
uuid = player.getUniqueId();
|
uuid = player.getUniqueId();
|
||||||
bedLocation = player.getBedSpawnLocation();
|
bedLocation = player.getBedSpawnLocation();
|
||||||
registered = player.getFirstPlayed();
|
if (bedLocation == null) {
|
||||||
isOp = player.isOp();
|
bedLocation = new Location(Bukkit.getServer().getWorlds().get(0), 0, 0 ,0);
|
||||||
locations = new ArrayList<>();
|
|
||||||
nicknames = new ArrayList<>();
|
|
||||||
ips = new ArrayList<>();
|
|
||||||
gmTimes = new HashMap<>();
|
|
||||||
this.demData = demData;
|
|
||||||
isBanned = player.isBanned();
|
|
||||||
}
|
}
|
||||||
public UserData(OfflinePlayer player, DemographicsData demData) {
|
|
||||||
uuid = player.getUniqueId();
|
|
||||||
bedLocation = player.getBedSpawnLocation();
|
|
||||||
registered = player.getFirstPlayed();
|
registered = player.getFirstPlayed();
|
||||||
isOp = player.isOp();
|
isOp = player.isOp();
|
||||||
locations = new ArrayList<>();
|
locations = new ArrayList<>();
|
||||||
nicknames = new ArrayList<>();
|
nicknames = new ArrayList<>();
|
||||||
ips = new ArrayList<>();
|
ips = new ArrayList<>();
|
||||||
gmTimes = new HashMap<>();
|
gmTimes = new HashMap<>();
|
||||||
|
long zero = Long.parseLong("0");
|
||||||
|
gmTimes.put(GameMode.SURVIVAL, zero);
|
||||||
|
gmTimes.put(GameMode.CREATIVE, zero);
|
||||||
|
gmTimes.put(GameMode.ADVENTURE, zero);
|
||||||
|
gmTimes.put(GameMode.SPECTATOR, zero);
|
||||||
this.demData = demData;
|
this.demData = demData;
|
||||||
isBanned = player.isBanned();
|
isBanned = player.isBanned();
|
||||||
}
|
}
|
||||||
@ -86,12 +90,12 @@ public class UserData {
|
|||||||
|
|
||||||
public void addLocation(Location loc) {
|
public void addLocation(Location loc) {
|
||||||
locations.add(loc);
|
locations.add(loc);
|
||||||
location = locations.get(locations.size()-1);
|
location = locations.get(locations.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLocations(Collection<Location> addLocs) {
|
public void addLocations(Collection<Location> addLocs) {
|
||||||
locations.addAll(addLocs);
|
locations.addAll(addLocs);
|
||||||
location = locations.get(locations.size()-1);
|
location = locations.get(locations.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNickname(String nick) {
|
public void addNickname(String nick) {
|
||||||
|
@ -2,6 +2,7 @@ package com.djrapitops.plan.database.databases;
|
|||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.api.Gender;
|
import com.djrapitops.plan.api.Gender;
|
||||||
|
import com.djrapitops.plan.command.utils.MiscUtils;
|
||||||
import com.djrapitops.plan.database.Database;
|
import com.djrapitops.plan.database.Database;
|
||||||
import com.djrapitops.plan.database.DemographicsData;
|
import com.djrapitops.plan.database.DemographicsData;
|
||||||
import com.djrapitops.plan.database.ServerData;
|
import com.djrapitops.plan.database.ServerData;
|
||||||
@ -13,13 +14,18 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
|
|
||||||
public abstract class SQLDB extends Database {
|
public abstract class SQLDB extends Database {
|
||||||
|
|
||||||
@ -149,7 +155,7 @@ public abstract class SQLDB extends Database {
|
|||||||
set.close();
|
set.close();
|
||||||
|
|
||||||
query("CREATE TABLE IF NOT EXISTS " + userName + " ("
|
query("CREATE TABLE IF NOT EXISTS " + userName + " ("
|
||||||
+ userColumnID + " int NOT NULL PRIMARY KEY, "
|
+ userColumnID + " int PRIMARY KEY, "
|
||||||
+ userColumnUUID + " varchar(36) NOT NULL, "
|
+ userColumnUUID + " varchar(36) NOT NULL, "
|
||||||
+ userColumnDemAge + " int NOT NULL, "
|
+ userColumnDemAge + " int NOT NULL, "
|
||||||
+ userColumnDemGender + " varchar(8) NOT NULL, "
|
+ userColumnDemGender + " varchar(8) NOT NULL, "
|
||||||
@ -226,6 +232,7 @@ public abstract class SQLDB extends Database {
|
|||||||
return connection.createStatement().execute(sql);
|
return connection.createStatement().execute(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
try {
|
try {
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
@ -281,14 +288,14 @@ public abstract class SQLDB extends Database {
|
|||||||
int userId = -1;
|
int userId = -1;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT "+userColumnID+" FROM " + userName + " WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)");
|
PreparedStatement statement = connection.prepareStatement("SELECT " + userColumnID + " FROM " + userName + " WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, uuid);
|
statement.setString(1, uuid);
|
||||||
ResultSet set = statement.executeQuery();
|
ResultSet set = statement.executeQuery();
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
userId = set.getInt(userColumnID);
|
userId = set.getInt(userColumnID);
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
} catch (SQLException | NullPointerException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return userId;
|
return userId;
|
||||||
@ -299,12 +306,14 @@ public abstract class SQLDB extends Database {
|
|||||||
checkConnection();
|
checkConnection();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
UserData data = new UserData(getOfflinePlayer(uuid), new DemographicsData(), this);
|
||||||
|
if (wasSeenBefore(uuid)) {
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + userName + " WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)");
|
PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + userName + " WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, uuid.toString());
|
statement.setString(1, uuid.toString());
|
||||||
ResultSet set = statement.executeQuery();
|
ResultSet set = statement.executeQuery();
|
||||||
|
|
||||||
UserData data = new UserData(getOfflinePlayer(uuid), new DemographicsData());
|
|
||||||
String id = null;
|
String id = null;
|
||||||
|
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
id = set.getString(userColumnID);
|
id = set.getString(userColumnID);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
@ -313,11 +322,12 @@ public abstract class SQLDB extends Database {
|
|||||||
data.getDemData().setAge(set.getInt(userColumnDemAge));
|
data.getDemData().setAge(set.getInt(userColumnDemAge));
|
||||||
data.getDemData().setGender(Gender.parse(set.getString(userColumnDemGender)));
|
data.getDemData().setGender(Gender.parse(set.getString(userColumnDemGender)));
|
||||||
data.getDemData().setGeoLocation(set.getString(userColumnDemGeoLocation));
|
data.getDemData().setGeoLocation(set.getString(userColumnDemGeoLocation));
|
||||||
data.setLastGamemode(GameMode.valueOf(userColumnLastGM));
|
data.setLastGamemode(MiscUtils.parseGM(set.getString(userColumnLastGM)));
|
||||||
data.setLastGmSwapTime(set.getLong(userColumnLastGMSwapTime));
|
data.setLastGmSwapTime(set.getLong(userColumnLastGMSwapTime));
|
||||||
data.setPlayTime(set.getLong(userColumnPlayTime));
|
data.setPlayTime(set.getLong(userColumnPlayTime));
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
|
statement.close();
|
||||||
|
|
||||||
statement = connection.prepareStatement("SELECT * FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
|
statement = connection.prepareStatement("SELECT * FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, id);
|
statement.setString(1, id);
|
||||||
@ -328,6 +338,7 @@ public abstract class SQLDB extends Database {
|
|||||||
locations.add(new Location(Bukkit.getWorld(set.getString(locationColumnWorld)), set.getInt(locationColumnCoordinatesX), 0, set.getInt(locationColumnCoordinatesZ)));
|
locations.add(new Location(Bukkit.getWorld(set.getString(locationColumnWorld)), set.getInt(locationColumnCoordinatesX), 0, set.getInt(locationColumnCoordinatesZ)));
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
|
statement.close();
|
||||||
data.addLocations(locations);
|
data.addLocations(locations);
|
||||||
if (locations.isEmpty()) {
|
if (locations.isEmpty()) {
|
||||||
plugin.logToFile("DATABASE-SQLDB\nLocations list is empty");
|
plugin.logToFile("DATABASE-SQLDB\nLocations list is empty");
|
||||||
@ -344,6 +355,7 @@ public abstract class SQLDB extends Database {
|
|||||||
nicknames.add(set.getString(nicknamesColumnNick));
|
nicknames.add(set.getString(nicknamesColumnNick));
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
|
statement.close();
|
||||||
data.addNicknames(nicknames);
|
data.addNicknames(nicknames);
|
||||||
|
|
||||||
statement = connection.prepareStatement("SELECT * FROM " + ipsName + " WHERE UPPER(" + ipsColumnUserID + ") LIKE UPPER(?)");
|
statement = connection.prepareStatement("SELECT * FROM " + ipsName + " WHERE UPPER(" + ipsColumnUserID + ") LIKE UPPER(?)");
|
||||||
@ -358,6 +370,7 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
|
statement.close();
|
||||||
data.addIpAddresses(ips);
|
data.addIpAddresses(ips);
|
||||||
|
|
||||||
statement = connection.prepareStatement("SELECT * FROM " + gamemodetimesName + " WHERE UPPER(" + gamemodetimesColumnUserID + ") LIKE UPPER(?)");
|
statement = connection.prepareStatement("SELECT * FROM " + gamemodetimesName + " WHERE UPPER(" + gamemodetimesColumnUserID + ") LIKE UPPER(?)");
|
||||||
@ -369,8 +382,20 @@ public abstract class SQLDB extends Database {
|
|||||||
times.put(GameMode.valueOf(set.getString(gamemodetimesColumnGamemode)), set.getLong(gamemodetimesColumnTime));
|
times.put(GameMode.valueOf(set.getString(gamemodetimesColumnGamemode)), set.getLong(gamemodetimesColumnTime));
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
|
statement.close();
|
||||||
data.setGmTimes(times);
|
data.setGmTimes(times);
|
||||||
|
} else {
|
||||||
|
GameMode defaultGM = Bukkit.getServer().getDefaultGameMode();
|
||||||
|
if (defaultGM != null) {
|
||||||
|
data.setLastGamemode(defaultGM);
|
||||||
|
} else {
|
||||||
|
data.setLastGamemode(GameMode.SURVIVAL);
|
||||||
|
}
|
||||||
|
data.setPlayTime(Long.parseLong("0"));
|
||||||
|
data.setTimesKicked(0);
|
||||||
|
data.setLoginTimes(1);
|
||||||
|
data.setLastGmSwapTime(Long.parseLong("0"));
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logToFile("DATABASE-SQLDB\n" + e + "\n" + e.getCause());
|
plugin.logToFile("DATABASE-SQLDB\n" + e + "\n" + e.getCause());
|
||||||
@ -379,29 +404,50 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerData getServerData() {
|
public ServerData getNewestServerData() {
|
||||||
HashMap<String, Integer> commandUse = getCommandUse();
|
HashMap<String, Integer> commandUse = getCommandUse();
|
||||||
int newPlayers = 0;
|
int newPlayers = 0;
|
||||||
try{
|
Date now = new Date();
|
||||||
|
Date startOfToday = new Date(now.getTime() - now.getTime() % 86400000);
|
||||||
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + serverdataName
|
PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + serverdataName
|
||||||
+"ORDER BY "+serverdataColumnDate+" ASC LIMIT 1");
|
+ "ORDER BY " + serverdataColumnDate + " ASC");
|
||||||
|
|
||||||
ResultSet set = statement.executeQuery();
|
ResultSet set = statement.executeQuery();
|
||||||
|
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
|
Date lastSave = new Date(set.getLong(serverdataColumnDate));
|
||||||
|
Date startOfSaveDay = new Date(lastSave.getTime() - lastSave.getTime() % 86400000);
|
||||||
|
if (startOfSaveDay == startOfToday) {
|
||||||
newPlayers = set.getInt(serverdataColumnNewPlayers);
|
newPlayers = set.getInt(serverdataColumnNewPlayers);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
set.close();
|
set.close();
|
||||||
|
statement.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logToFile("DATABASE-SQLDB-GetServerData\n" + e + "\n" + e.getCause());
|
plugin.logToFile("DATABASE-SQLDB-GetServerData\n" + e + "\n" + e.getCause());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return new ServerData(commandUse, newPlayers);
|
return new ServerData(commandUse, newPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveServerData(ServerData data) {
|
public void saveServerData(ServerData data) {
|
||||||
|
try {
|
||||||
saveCommandUse(data.getCommandUsage());
|
saveCommandUse(data.getCommandUsage());
|
||||||
|
long now = new Date().getTime();
|
||||||
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO " + serverdataName + " ("
|
||||||
|
+ serverdataColumnDate + ", "
|
||||||
|
+ serverdataColumnNewPlayers + ", "
|
||||||
|
+ serverdataColumnPlayersOnline
|
||||||
|
+ ") VALUES (?, ?, ?)");
|
||||||
|
|
||||||
|
statement.setLong(1, now);
|
||||||
|
statement.setInt(2, data.getNewPlayers());
|
||||||
|
statement.setInt(3, data.getPlayersOnline());
|
||||||
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
Logger.getLogger(SQLDB.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCommandUse(HashMap<String, Integer> data) {
|
private void saveCommandUse(HashMap<String, Integer> data) {
|
||||||
@ -409,7 +455,7 @@ public abstract class SQLDB extends Database {
|
|||||||
PreparedStatement statement = connection.prepareStatement(
|
PreparedStatement statement = connection.prepareStatement(
|
||||||
"DELETE FROM " + commanduseName);
|
"DELETE FROM " + commanduseName);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
for (String key : data.keySet()) {
|
for (String key : data.keySet()) {
|
||||||
statement = connection.prepareStatement("INSERT INTO " + commanduseName + " ("
|
statement = connection.prepareStatement("INSERT INTO " + commanduseName + " ("
|
||||||
+ commanduseColumnCommand + ", "
|
+ commanduseColumnCommand + ", "
|
||||||
@ -419,6 +465,7 @@ public abstract class SQLDB extends Database {
|
|||||||
statement.setString(1, key);
|
statement.setString(1, key);
|
||||||
statement.setInt(2, data.get(key));
|
statement.setInt(2, data.get(key));
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -428,7 +475,7 @@ public abstract class SQLDB extends Database {
|
|||||||
|
|
||||||
private HashMap<String, Integer> getCommandUse() {
|
private HashMap<String, Integer> getCommandUse() {
|
||||||
HashMap<String, Integer> commandUse = new HashMap<>();
|
HashMap<String, Integer> commandUse = new HashMap<>();
|
||||||
try{
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + commanduseName);
|
PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + commanduseName);
|
||||||
|
|
||||||
ResultSet set = statement.executeQuery();
|
ResultSet set = statement.executeQuery();
|
||||||
@ -437,6 +484,7 @@ public abstract class SQLDB extends Database {
|
|||||||
commandUse.put(set.getString(commanduseColumnCommand), set.getInt(commanduseColumnTimesUsed));
|
commandUse.put(set.getString(commanduseColumnCommand), set.getInt(commanduseColumnTimesUsed));
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
|
statement.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logToFile("DATABASE-SQLDB\n" + e + "\n" + e.getCause());
|
plugin.logToFile("DATABASE-SQLDB\n" + e + "\n" + e.getCause());
|
||||||
}
|
}
|
||||||
@ -456,18 +504,23 @@ public abstract class SQLDB extends Database {
|
|||||||
statement = connection.prepareStatement("DELETE FROM " + userName + " WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)");
|
statement = connection.prepareStatement("DELETE FROM " + userName + " WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, uuid);
|
statement.setString(1, uuid);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
statement = connection.prepareStatement("DELETE FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
|
statement = connection.prepareStatement("DELETE FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, "" + userId);
|
statement.setString(1, "" + userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
statement = connection.prepareStatement("DELETE FROM " + nicknamesName + " WHERE UPPER(" + nicknamesColumnUserID + ") LIKE UPPER(?)");
|
statement = connection.prepareStatement("DELETE FROM " + nicknamesName + " WHERE UPPER(" + nicknamesColumnUserID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, "" + userId);
|
statement.setString(1, "" + userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
statement = connection.prepareStatement("DELETE FROM " + gamemodetimesName + " WHERE UPPER(" + gamemodetimesColumnUserID + ") LIKE UPPER(?)");
|
statement = connection.prepareStatement("DELETE FROM " + gamemodetimesName + " WHERE UPPER(" + gamemodetimesColumnUserID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, "" + userId);
|
statement.setString(1, "" + userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
statement = connection.prepareStatement("DELETE FROM " + ipsName + " WHERE UPPER(" + ipsColumnIP + ") LIKE UPPER(?)");
|
statement = connection.prepareStatement("DELETE FROM " + ipsName + " WHERE UPPER(" + ipsColumnIP + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, "" + userId);
|
statement.setString(1, "" + userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logToFile("DATABASE_SQLDB\n" + e + "\n" + e.getCause());
|
plugin.logToFile("DATABASE_SQLDB\n" + e + "\n" + e.getCause());
|
||||||
}
|
}
|
||||||
@ -479,26 +532,31 @@ public abstract class SQLDB extends Database {
|
|||||||
|
|
||||||
int userId = getUserId(uuid.toString());
|
int userId = getUserId(uuid.toString());
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String sql = "UPDATE " + userName + " SET "
|
String sql = "UPDATE " + userName + " SET "
|
||||||
+ userColumnDemAge + "=?, "
|
+ userColumnDemAge + "=?, "
|
||||||
+ userColumnDemGender + "=? "
|
+ userColumnDemGender + "=?, "
|
||||||
+ userColumnDemGeoLocation + "=? "
|
+ userColumnDemGeoLocation + "=?, "
|
||||||
+ userColumnLastGM + "=? "
|
+ userColumnLastGM + "=?, "
|
||||||
+ userColumnLastGMSwapTime + "=? "
|
+ userColumnLastGMSwapTime + "=?, "
|
||||||
+ userColumnPlayTime + "=? "
|
+ userColumnPlayTime + "=? "
|
||||||
+ "WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)";
|
+ "WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)";
|
||||||
|
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
PreparedStatement statement = connection.prepareStatement(sql);
|
||||||
statement.setInt(1, data.getDemData().getAge());
|
statement.setInt(1, data.getDemData().getAge());
|
||||||
statement.setString(2, data.getDemData().getGender().toString());
|
statement.setString(2, data.getDemData().getGender().toString().toLowerCase());
|
||||||
statement.setString(3, data.getDemData().getGeoLocation());
|
statement.setString(3, data.getDemData().getGeoLocation());
|
||||||
|
GameMode gm = data.getLastGamemode();
|
||||||
|
if (gm != null) {
|
||||||
statement.setString(4, data.getLastGamemode().name());
|
statement.setString(4, data.getLastGamemode().name());
|
||||||
|
} else {
|
||||||
|
statement.setString(4, GameMode.SURVIVAL.name());
|
||||||
|
}
|
||||||
statement.setLong(5, data.getLastGmSwapTime());
|
statement.setLong(5, data.getLastGmSwapTime());
|
||||||
statement.setLong(6, data.getPlayTime());
|
statement.setLong(6, data.getPlayTime());
|
||||||
|
|
||||||
if (statement.executeUpdate() == 0) {
|
if (statement.executeUpdate() == 0) {
|
||||||
statement = connection.prepareStatement("INSERT INTO " + userName + " ("
|
statement = connection.prepareStatement("INSERT INTO " + userName + " ("
|
||||||
+ userColumnID + ", "
|
|
||||||
+ userColumnUUID + ", "
|
+ userColumnUUID + ", "
|
||||||
+ userColumnDemAge + ", "
|
+ userColumnDemAge + ", "
|
||||||
+ userColumnDemGender + ", "
|
+ userColumnDemGender + ", "
|
||||||
@ -506,26 +564,35 @@ public abstract class SQLDB extends Database {
|
|||||||
+ userColumnLastGM + ", "
|
+ userColumnLastGM + ", "
|
||||||
+ userColumnLastGMSwapTime + ", "
|
+ userColumnLastGMSwapTime + ", "
|
||||||
+ userColumnPlayTime
|
+ userColumnPlayTime
|
||||||
+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
+ ") VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
statement.setInt(1, userId);
|
statement.setString(1, uuid.toString());
|
||||||
statement.setString(2, uuid.toString());
|
statement.setInt(2, data.getDemData().getAge());
|
||||||
statement.setInt(3, data.getDemData().getAge());
|
statement.setString(3, data.getDemData().getGender().toString().toLowerCase());
|
||||||
statement.setString(4, data.getDemData().getGender().toString());
|
statement.setString(4, data.getDemData().getGeoLocation());
|
||||||
statement.setString(5, data.getDemData().getGeoLocation());
|
if (gm != null) {
|
||||||
statement.setString(6, data.getLastGamemode().name());
|
statement.setString(5, data.getLastGamemode().name());
|
||||||
statement.setLong(7, data.getLastGmSwapTime());
|
} else {
|
||||||
statement.setLong(8, data.getPlayTime());
|
statement.setString(5, GameMode.SURVIVAL.name());
|
||||||
|
}
|
||||||
|
statement.setLong(6, data.getLastGmSwapTime());
|
||||||
|
statement.setLong(7, data.getPlayTime());
|
||||||
|
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
}
|
}
|
||||||
saveLocationList(userId, data.getLocations());
|
saveLocationList(userId, data.getLocations());
|
||||||
saveNickList(userId, data.getNicknames());
|
saveNickList(userId, data.getNicknames());
|
||||||
saveIPList(userId, data.getIps());
|
saveIPList(userId, data.getIps());
|
||||||
saveGMTimes(userId, data.getGmTimes());
|
saveGMTimes(userId, data.getGmTimes());
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException | NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
plugin.logToFile("SQLDB-Save\n" + e
|
||||||
|
+ "\n" + data.getLastGamemode()
|
||||||
|
+ "\n" + Bukkit.getDefaultGameMode()
|
||||||
|
+ "\n" + wasSeenBefore(uuid)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,6 +602,7 @@ public abstract class SQLDB extends Database {
|
|||||||
"DELETE FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
|
"DELETE FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, "" + userId);
|
statement.setString(1, "" + userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
|
|
||||||
for (int i = 0; i < locations.size(); i++) {
|
for (int i = 0; i < locations.size(); i++) {
|
||||||
Location location = locations.get(i);
|
Location location = locations.get(i);
|
||||||
@ -553,6 +621,7 @@ public abstract class SQLDB extends Database {
|
|||||||
statement.setString(5, location.getWorld().getName());
|
statement.setString(5, location.getWorld().getName());
|
||||||
|
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -576,6 +645,7 @@ public abstract class SQLDB extends Database {
|
|||||||
statement.setInt(1, userId);
|
statement.setInt(1, userId);
|
||||||
statement.setString(2, name);
|
statement.setString(2, name);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -589,6 +659,7 @@ public abstract class SQLDB extends Database {
|
|||||||
"DELETE FROM " + ipsName + " WHERE UPPER(" + ipsColumnUserID + ") LIKE UPPER(?)");
|
"DELETE FROM " + ipsName + " WHERE UPPER(" + ipsColumnUserID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, "" + userId);
|
statement.setString(1, "" + userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
|
|
||||||
for (InetAddress ip : ips) {
|
for (InetAddress ip : ips) {
|
||||||
statement = connection.prepareStatement("INSERT INTO " + ipsName + " ("
|
statement = connection.prepareStatement("INSERT INTO " + ipsName + " ("
|
||||||
@ -599,6 +670,7 @@ public abstract class SQLDB extends Database {
|
|||||||
statement.setInt(1, userId);
|
statement.setInt(1, userId);
|
||||||
statement.setString(2, ip.getHostAddress());
|
statement.setString(2, ip.getHostAddress());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -612,6 +684,7 @@ public abstract class SQLDB extends Database {
|
|||||||
"DELETE FROM " + gamemodetimesName + " WHERE UPPER(" + gamemodetimesColumnUserID + ") LIKE UPPER(?)");
|
"DELETE FROM " + gamemodetimesName + " WHERE UPPER(" + gamemodetimesColumnUserID + ") LIKE UPPER(?)");
|
||||||
statement.setString(1, "" + userId);
|
statement.setString(1, "" + userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
|
|
||||||
for (GameMode gm : gamemodeTimes.keySet()) {
|
for (GameMode gm : gamemodeTimes.keySet()) {
|
||||||
statement = connection.prepareStatement("INSERT INTO " + gamemodetimesName + " ("
|
statement = connection.prepareStatement("INSERT INTO " + gamemodetimesName + " ("
|
||||||
@ -624,6 +697,7 @@ public abstract class SQLDB extends Database {
|
|||||||
statement.setString(2, gm.name());
|
statement.setString(2, gm.name());
|
||||||
statement.setLong(3, gamemodeTimes.get(gm));
|
statement.setLong(3, gamemodeTimes.get(gm));
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -24,7 +24,7 @@ public class ActivityHandler {
|
|||||||
|
|
||||||
public void saveToCache(Player player, UserData data) {
|
public void saveToCache(Player player, UserData data) {
|
||||||
long timeNow = new Date().getTime();
|
long timeNow = new Date().getTime();
|
||||||
data.setPlayTime(data.getPlayTime()+(data.getLastPlayed()-timeNow));
|
data.setPlayTime(data.getPlayTime() + (data.getLastPlayed() - timeNow));
|
||||||
data.setLastPlayed(timeNow);
|
data.setLastPlayed(timeNow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,12 @@ public class ActivityHandler {
|
|||||||
|
|
||||||
public void handleLogOut(PlayerQuitEvent event, UserData data) {
|
public void handleLogOut(PlayerQuitEvent event, UserData data) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
data.setPlayTime(data.getPlayTime()+(data.getLastPlayed()-new Date().getTime()));
|
data.setPlayTime(data.getPlayTime() + (data.getLastPlayed() - new Date().getTime()));
|
||||||
|
data.setLastPlayed(player.getLastPlayed());
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleReload(Player player, UserData data) {
|
||||||
|
data.setPlayTime(data.getPlayTime() + (data.getLastPlayed() - new Date().getTime()));
|
||||||
data.setLastPlayed(player.getLastPlayed());
|
data.setLastPlayed(player.getLastPlayed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,14 @@ public class BasicInfoHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleLogIn(PlayerLoginEvent event) {
|
public void handleLogIn(PlayerLoginEvent event, UserData data) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UserData data = handler.getCurrentData(player.getUniqueId());
|
|
||||||
data.addNickname(player.getDisplayName());
|
data.addNickname(player.getDisplayName());
|
||||||
data.addIpAddress(event.getAddress());
|
data.addIpAddress(event.getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleLogOut(PlayerQuitEvent event) {
|
void handleReload(Player player, UserData data) {
|
||||||
Player player = event.getPlayer();
|
data.addNickname(player.getDisplayName());
|
||||||
UserData data = handler.getCurrentData(player.getUniqueId());
|
data.addIpAddress(player.getAddress().getAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,11 @@ import com.djrapitops.plan.database.ServerData;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
|
||||||
public class DataHandler {
|
public class DataHandler {
|
||||||
|
|
||||||
@ -25,6 +29,8 @@ public class DataHandler {
|
|||||||
private final PlanLiteHandler planLiteHandler;
|
private final PlanLiteHandler planLiteHandler;
|
||||||
private final Database db;
|
private final Database db;
|
||||||
|
|
||||||
|
private int timesSaved;
|
||||||
|
|
||||||
public DataHandler(Plan plugin) {
|
public DataHandler(Plan plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
db = plugin.getDB();
|
db = plugin.getDB();
|
||||||
@ -35,16 +41,21 @@ public class DataHandler {
|
|||||||
demographicsHandler = new DemographicsHandler(plugin, this);
|
demographicsHandler = new DemographicsHandler(plugin, this);
|
||||||
basicInfoHandler = new BasicInfoHandler(plugin, this);
|
basicInfoHandler = new BasicInfoHandler(plugin, this);
|
||||||
ruleBreakingHandler = new RuleBreakingHandler(plugin, this);
|
ruleBreakingHandler = new RuleBreakingHandler(plugin, this);
|
||||||
serverData = db.getServerData();
|
serverData = db.getNewestServerData();
|
||||||
serverDataHandler = new ServerDataHandler(serverData);
|
serverDataHandler = new ServerDataHandler(serverData);
|
||||||
planLiteHandler = new PlanLiteHandler(plugin);
|
planLiteHandler = new PlanLiteHandler(plugin);
|
||||||
|
|
||||||
|
timesSaved = 0;
|
||||||
|
|
||||||
int minutes = plugin.getConfig().getInt("saveEveryXMinutes");
|
int minutes = plugin.getConfig().getInt("saveEveryXMinutes");
|
||||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
saveHandlerDataToCache();
|
saveHandlerDataToCache();
|
||||||
saveCachedData();
|
saveCachedData();
|
||||||
|
if (timesSaved % 5 == 0) {
|
||||||
|
clearCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 60 * 20 * minutes, 60 * 20 * minutes);
|
}, 60 * 20 * minutes, 60 * 20 * minutes);
|
||||||
}
|
}
|
||||||
@ -55,9 +66,6 @@ public class DataHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UserData getCurrentData(UUID uuid, boolean cache) {
|
public UserData getCurrentData(UUID uuid, boolean cache) {
|
||||||
if (!db.wasSeenBefore(uuid)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (cache) {
|
if (cache) {
|
||||||
if (dataCache.get(uuid) == null) {
|
if (dataCache.get(uuid) == null) {
|
||||||
dataCache.put(uuid, db.getUserData(uuid));
|
dataCache.put(uuid, db.getUserData(uuid));
|
||||||
@ -77,17 +85,37 @@ public class DataHandler {
|
|||||||
saveCachedData(uuid);
|
saveCachedData(uuid);
|
||||||
});
|
});
|
||||||
saveServerData();
|
saveServerData();
|
||||||
|
timesSaved++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveCacheOnDisable() {
|
||||||
|
dataCache.keySet().stream().forEach((uuid) -> {
|
||||||
|
if (dataCache.get(uuid) != null) {
|
||||||
|
db.saveUserData(uuid, dataCache.get(uuid));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
db.saveServerData(serverData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveCachedData(UUID uuid) {
|
public void saveCachedData(UUID uuid) {
|
||||||
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
if (dataCache.get(uuid) != null) {
|
if (dataCache.get(uuid) != null) {
|
||||||
db.saveUserData(uuid, dataCache.get(uuid));
|
db.saveUserData(uuid, dataCache.get(uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void saveServerData() {
|
public void saveServerData() {
|
||||||
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
db.saveServerData(serverData);
|
db.saveServerData(serverData);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void saveHandlerDataToCache() {
|
private void saveHandlerDataToCache() {
|
||||||
Bukkit.getServer().getOnlinePlayers().parallelStream().forEach((p) -> {
|
Bukkit.getServer().getOnlinePlayers().parallelStream().forEach((p) -> {
|
||||||
@ -108,7 +136,19 @@ public class DataHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void newPlayer(Player player) {
|
public void newPlayer(Player player) {
|
||||||
dataCache.put(player.getUniqueId(), new UserData(player, new DemographicsData(), db));
|
UserData data = new UserData(player, new DemographicsData(), db);
|
||||||
|
saveCachedData(player.getUniqueId());
|
||||||
|
GameMode defaultGM = Bukkit.getServer().getDefaultGameMode();
|
||||||
|
if (defaultGM != null) {
|
||||||
|
data.setLastGamemode(defaultGM);
|
||||||
|
} else {
|
||||||
|
data.setLastGamemode(GameMode.SURVIVAL);
|
||||||
|
}
|
||||||
|
data.setPlayTime(Long.parseLong("0"));
|
||||||
|
data.setTimesKicked(0);
|
||||||
|
data.setLoginTimes(1);
|
||||||
|
data.setLastGmSwapTime(Long.parseLong("0"));
|
||||||
|
dataCache.put(player.getUniqueId(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActivityHandler getActivityHandler() {
|
public ActivityHandler getActivityHandler() {
|
||||||
@ -135,7 +175,6 @@ public class DataHandler {
|
|||||||
return gamemodeTimesHandler;
|
return gamemodeTimesHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Database getDB() {
|
public Database getDB() {
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
@ -147,4 +186,19 @@ public class DataHandler {
|
|||||||
public ServerDataHandler getServerDataHandler() {
|
public ServerDataHandler getServerDataHandler() {
|
||||||
return serverDataHandler;
|
return serverDataHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleReload() {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
boolean newPlayer = activityHandler.isFirstTimeJoin(uuid);
|
||||||
|
newPlayer(player);
|
||||||
|
serverDataHandler.handleLogin(newPlayer);
|
||||||
|
UserData data = getCurrentData(uuid);
|
||||||
|
activityHandler.handleReload(player, data);
|
||||||
|
basicInfoHandler.handleReload(player, data);
|
||||||
|
gamemodeTimesHandler.handleReload(player, data);
|
||||||
|
demographicsHandler.handleReload(player, data);
|
||||||
|
saveCachedData(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package com.djrapitops.plan.datahandlers;
|
package com.djrapitops.plan.datahandlers;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
@ -17,6 +16,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
|||||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||||
|
|
||||||
public class DemographicsHandler {
|
public class DemographicsHandler {
|
||||||
|
|
||||||
private final DataHandler handler;
|
private final DataHandler handler;
|
||||||
|
|
||||||
public DemographicsHandler(Plan plugin, DataHandler h) {
|
public DemographicsHandler(Plan plugin, DataHandler h) {
|
||||||
@ -111,7 +111,7 @@ public class DemographicsHandler {
|
|||||||
if (results.size() >= 2) {
|
if (results.size() >= 2) {
|
||||||
data.getDemData().setGeoLocation(results.get(1));
|
data.getDemData().setGeoLocation(results.get(1));
|
||||||
} else {
|
} else {
|
||||||
data.getDemData().setGeoLocation("UNKOWN");
|
data.getDemData().setGeoLocation("Not Known");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Plan plugin = getPlugin(Plan.class);
|
Plan plugin = getPlugin(Plan.class);
|
||||||
@ -121,5 +121,25 @@ public class DemographicsHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleReload(Player player, UserData data) {
|
||||||
|
InetAddress address = player.getAddress().getAddress();
|
||||||
|
try {
|
||||||
|
Scanner locationScanner = new Scanner("http://ip-api.com/line/" + address.getHostAddress());
|
||||||
|
List<String> results = new ArrayList<>();
|
||||||
|
while (locationScanner.hasNextLine()) {
|
||||||
|
results.add(locationScanner.nextLine());
|
||||||
|
}
|
||||||
|
if (results.size() >= 2) {
|
||||||
|
data.getDemData().setGeoLocation(results.get(1));
|
||||||
|
} else {
|
||||||
|
data.getDemData().setGeoLocation("Not Known");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Plan plugin = getPlugin(Plan.class);
|
||||||
|
plugin.logToFile("http://ip-api.com/line/" + address.getHostAddress());
|
||||||
|
plugin.logToFile("" + e);
|
||||||
|
plugin.logToFile(address.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package com.djrapitops.plan.datahandlers;
|
package com.djrapitops.plan.datahandlers;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
@ -7,8 +6,10 @@ import java.util.HashMap;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
|
||||||
public class GamemodeTimesHandler {
|
public class GamemodeTimesHandler {
|
||||||
|
|
||||||
private final Plan plugin;
|
private final Plan plugin;
|
||||||
private final DataHandler handler;
|
private final DataHandler handler;
|
||||||
|
|
||||||
@ -17,13 +18,17 @@ public class GamemodeTimesHandler {
|
|||||||
handler = h;
|
handler = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleLogin(PlayerLoginEvent event, UserData data) {
|
||||||
|
data.setLastGamemode(event.getPlayer().getGameMode());
|
||||||
|
}
|
||||||
|
|
||||||
public void handleChangeEvent(PlayerGameModeChangeEvent event, UserData data) {
|
public void handleChangeEvent(PlayerGameModeChangeEvent event, UserData data) {
|
||||||
HashMap<GameMode, Long> times = data.getGmTimes();
|
HashMap<GameMode, Long> times = data.getGmTimes();
|
||||||
long lastSwap = data.getLastGmSwapTime();
|
long lastSwap = data.getLastGmSwapTime();
|
||||||
handler.getActivityHandler().saveToCache(event.getPlayer(), data);
|
handler.getActivityHandler().saveToCache(event.getPlayer(), data);
|
||||||
long now = data.getPlayTime();
|
long now = data.getPlayTime();
|
||||||
GameMode oldGM = data.getLastGamemode();
|
GameMode oldGM = data.getLastGamemode();
|
||||||
data.setGMTime(oldGM, times.get(oldGM)+(lastSwap-now));
|
data.setGMTime(oldGM, times.get(oldGM) + (lastSwap - now));
|
||||||
GameMode newGM = event.getNewGameMode();
|
GameMode newGM = event.getNewGameMode();
|
||||||
data.setLastGamemode(newGM);
|
data.setLastGamemode(newGM);
|
||||||
data.setLastGmSwapTime(now);
|
data.setLastGmSwapTime(now);
|
||||||
@ -35,9 +40,18 @@ public class GamemodeTimesHandler {
|
|||||||
handler.getActivityHandler().saveToCache(p, data);
|
handler.getActivityHandler().saveToCache(p, data);
|
||||||
long now = data.getPlayTime();
|
long now = data.getPlayTime();
|
||||||
GameMode currentGM = p.getGameMode();
|
GameMode currentGM = p.getGameMode();
|
||||||
data.setGMTime(currentGM, times.get(currentGM)+(lastSwap-now));
|
data.setGMTime(currentGM, times.get(currentGM) + (lastSwap - now));
|
||||||
data.setLastGmSwapTime(now);
|
data.setLastGmSwapTime(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleReload(Player p, UserData data) {
|
||||||
|
HashMap<GameMode, Long> times = data.getGmTimes();
|
||||||
|
long lastSwap = data.getLastGmSwapTime();
|
||||||
|
handler.getActivityHandler().saveToCache(p, data);
|
||||||
|
long now = data.getPlayTime();
|
||||||
|
GameMode currentGM = p.getGameMode();
|
||||||
|
data.setGMTime(currentGM, times.get(currentGM) + (lastSwap - now));
|
||||||
|
data.setLastGmSwapTime(now);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.djrapitops.plan.datahandlers.listeners;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.Plan;
|
||||||
|
import com.djrapitops.plan.datahandlers.DataHandler;
|
||||||
|
import com.djrapitops.plan.datahandlers.ServerDataHandler;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class PlanCommandPreprocessListener implements Listener {
|
||||||
|
|
||||||
|
private final Plan plugin;
|
||||||
|
private final DataHandler handler;
|
||||||
|
private final ServerDataHandler serverH;
|
||||||
|
|
||||||
|
public PlanCommandPreprocessListener(Plan plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
handler = plugin.getHandler();
|
||||||
|
serverH = handler.getServerDataHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serverH.handleCommand(event.getMessage().split("\\s*")[0]);
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,8 @@ import com.djrapitops.plan.datahandlers.LocationHandler;
|
|||||||
import com.djrapitops.plan.datahandlers.RuleBreakingHandler;
|
import com.djrapitops.plan.datahandlers.RuleBreakingHandler;
|
||||||
import com.djrapitops.plan.datahandlers.ServerDataHandler;
|
import com.djrapitops.plan.datahandlers.ServerDataHandler;
|
||||||
import com.djrapitops.plan.database.UserData;
|
import com.djrapitops.plan.database.UserData;
|
||||||
|
import com.djrapitops.plan.datahandlers.BasicInfoHandler;
|
||||||
|
import com.djrapitops.plan.datahandlers.GamemodeTimesHandler;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -22,6 +24,8 @@ public class PlanPlayerListener implements Listener {
|
|||||||
|
|
||||||
private final DataHandler handler;
|
private final DataHandler handler;
|
||||||
private final ActivityHandler activityH;
|
private final ActivityHandler activityH;
|
||||||
|
private final BasicInfoHandler basicInfoH;
|
||||||
|
private final GamemodeTimesHandler gmTimesH;
|
||||||
private final LocationHandler locationH;
|
private final LocationHandler locationH;
|
||||||
private final DemographicsHandler demographicH;
|
private final DemographicsHandler demographicH;
|
||||||
private final RuleBreakingHandler rulebreakH;
|
private final RuleBreakingHandler rulebreakH;
|
||||||
@ -30,6 +34,8 @@ public class PlanPlayerListener implements Listener {
|
|||||||
public PlanPlayerListener(Plan plugin) {
|
public PlanPlayerListener(Plan plugin) {
|
||||||
handler = plugin.getHandler();
|
handler = plugin.getHandler();
|
||||||
activityH = handler.getActivityHandler();
|
activityH = handler.getActivityHandler();
|
||||||
|
basicInfoH = handler.getBasicInfoHandler();
|
||||||
|
gmTimesH = handler.getGamemodeTimesHandler();
|
||||||
demographicH = handler.getDemographicsHandler();
|
demographicH = handler.getDemographicsHandler();
|
||||||
locationH = handler.getLocationHandler();
|
locationH = handler.getLocationHandler();
|
||||||
rulebreakH = handler.getRuleBreakingHandler();
|
rulebreakH = handler.getRuleBreakingHandler();
|
||||||
@ -44,12 +50,12 @@ public class PlanPlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
boolean newPlayer = activityH.isFirstTimeJoin(uuid);
|
boolean newPlayer = activityH.isFirstTimeJoin(uuid);
|
||||||
if (newPlayer) {
|
|
||||||
handler.newPlayer(player);
|
handler.newPlayer(player);
|
||||||
}
|
|
||||||
serverHandler.handleLogin(newPlayer);
|
serverHandler.handleLogin(newPlayer);
|
||||||
UserData data = handler.getCurrentData(uuid);
|
UserData data = handler.getCurrentData(uuid);
|
||||||
activityH.handleLogIn(event, data);
|
activityH.handleLogIn(event, data);
|
||||||
|
basicInfoH.handleLogIn(event, data);
|
||||||
|
gmTimesH.handleLogin(event, data);
|
||||||
demographicH.handleLogIn(event, data);
|
demographicH.handleLogIn(event, data);
|
||||||
handler.saveCachedData(uuid);
|
handler.saveCachedData(uuid);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.djrapitops.plan.datahandlers.listeners;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.Plan;
|
||||||
|
import com.djrapitops.plan.datahandlers.DataHandler;
|
||||||
|
import com.djrapitops.plan.datahandlers.LocationHandler;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
public class PlanPlayerMoveListener implements Listener {
|
||||||
|
|
||||||
|
private final Plan plugin;
|
||||||
|
private final DataHandler handler;
|
||||||
|
private final LocationHandler locationH;
|
||||||
|
|
||||||
|
public PlanPlayerMoveListener(Plan plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
handler = plugin.getHandler();
|
||||||
|
locationH = handler.getLocationHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
Location from = event.getFrom();
|
||||||
|
Location to = event.getTo();
|
||||||
|
if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ() && from.getWorld() == to.getWorld()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
locationH.addLocation(p.getUniqueId(), to);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user