Completely remove PlayerData#LastLogin
Not tested, but other than maintaining SQL storage "compatibility" I've
removed all usages of it. It doesn't seem to be used at all anyways
other than to be stored since commit
f935806b45 removed its purpose.
Addresses a request in #22
This commit is contained in:
parent
f7319e2431
commit
5d4ccdca20
4
pom.xml
4
pom.xml
|
|
@ -56,8 +56,8 @@
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!--Bukkit API-->
|
<!--Bukkit API-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.destroystokyo.paper</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
||||||
|
|
@ -501,7 +501,6 @@ public class DatabaseDataStore extends DataStore
|
||||||
//if data for this player exists, use it
|
//if data for this player exists, use it
|
||||||
if(results.next())
|
if(results.next())
|
||||||
{
|
{
|
||||||
playerData.setLastLogin(results.getTimestamp("lastlogin"));
|
|
||||||
playerData.setAccruedClaimBlocks(results.getInt("accruedblocks"));
|
playerData.setAccruedClaimBlocks(results.getInt("accruedblocks"));
|
||||||
playerData.setBonusClaimBlocks(results.getInt("bonusblocks"));
|
playerData.setBonusClaimBlocks(results.getInt("bonusblocks"));
|
||||||
}
|
}
|
||||||
|
|
@ -531,9 +530,10 @@ public class DatabaseDataStore extends DataStore
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.refreshDataConnection();
|
this.refreshDataConnection();
|
||||||
|
OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(playerID));
|
||||||
|
|
||||||
SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String dateString = sqlFormat.format(playerData.getLastLogin());
|
String dateString = sqlFormat.format(new Date(player.getLastPlayed()));
|
||||||
|
|
||||||
Statement statement = databaseConnection.createStatement();
|
Statement statement = databaseConnection.createStatement();
|
||||||
statement.execute("DELETE FROM griefprevention_playerdata WHERE name='" + playerID.toString() + "';");
|
statement.execute("DELETE FROM griefprevention_playerdata WHERE name='" + playerID.toString() + "';");
|
||||||
|
|
|
||||||
|
|
@ -613,20 +613,20 @@ public class FlatFileDataStore extends DataStore
|
||||||
List<String> lines = Files.readLines(playerFile, Charset.forName("UTF-8"));
|
List<String> lines = Files.readLines(playerFile, Charset.forName("UTF-8"));
|
||||||
Iterator<String> iterator = lines.iterator();
|
Iterator<String> iterator = lines.iterator();
|
||||||
|
|
||||||
//first line is last login timestamp
|
//first line is last login timestamp //RoboMWM - not using this anymore
|
||||||
String lastLoginTimestampString = iterator.next();
|
// String lastLoginTimestampString = iterator.next();
|
||||||
|
//
|
||||||
//convert that to a date and store it
|
// //convert that to a date and store it
|
||||||
DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
// DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
playerData.setLastLogin(dateFormat.parse(lastLoginTimestampString));
|
// playerData.setLastLogin(dateFormat.parse(lastLoginTimestampString));
|
||||||
}
|
// }
|
||||||
catch(ParseException parseException)
|
// catch(ParseException parseException)
|
||||||
{
|
// {
|
||||||
GriefPrevention.AddLogEntry("Unable to load last login for \"" + playerFile.getName() + "\".");
|
// GriefPrevention.AddLogEntry("Unable to load last login for \"" + playerFile.getName() + "\".");
|
||||||
playerData.setLastLogin(null);
|
// playerData.setLastLogin(null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//second line is accrued claim blocks
|
//second line is accrued claim blocks
|
||||||
String accruedBlocksString = iterator.next();
|
String accruedBlocksString = iterator.next();
|
||||||
|
|
@ -683,10 +683,10 @@ public class FlatFileDataStore extends DataStore
|
||||||
StringBuilder fileContent = new StringBuilder();
|
StringBuilder fileContent = new StringBuilder();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//first line is last login timestamp
|
//first line is last login timestamp //RoboMWM - no longer storing/using
|
||||||
if(playerData.getLastLogin() == null) playerData.setLastLogin(new Date());
|
//if(playerData.getLastLogin() == null) playerData.setLastLogin(new Date());
|
||||||
DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
//DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
||||||
fileContent.append(dateFormat.format(playerData.getLastLogin()));
|
//fileContent.append(dateFormat.format(playerData.getLastLogin()));
|
||||||
fileContent.append("\n");
|
fileContent.append("\n");
|
||||||
|
|
||||||
//second line is accrued claim blocks
|
//second line is accrued claim blocks
|
||||||
|
|
|
||||||
|
|
@ -776,7 +776,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
catch(NoSuchMethodError e)
|
catch(NoSuchMethodError e)
|
||||||
{
|
{
|
||||||
this.getLogger().severe("You are running an old version of Java which is susceptible to security exploits. Please update to Java 8.");
|
this.getLogger().severe("You are running an old version of Java which is susceptible to security exploits. Please update to Java 8.");
|
||||||
this.getLogger().severe("If you are on a shared host, tell your hosting provider to update, as Java 7 is End of Life.");
|
this.getLogger().severe("If you are on a shared host, tell your hosting provider to update, as Java 7 is End of Life, and you're missing out on security and performance improvements");
|
||||||
this.getLogger().severe("If they refuse, I'd suggesting switching to a more secure and responsive host.");
|
this.getLogger().severe("If they refuse, I'd suggesting switching to a more secure and responsive host.");
|
||||||
this.getLogger().severe("But if you truly have absolutely no choice, then please download the Java 7 version of GriefPrevention.");
|
this.getLogger().severe("But if you truly have absolutely no choice, then please download the Java 7 version of GriefPrevention.");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,6 @@ public class PlayerData
|
||||||
//whether the player was kicked (set and used during logout)
|
//whether the player was kicked (set and used during logout)
|
||||||
boolean wasKicked = false;
|
boolean wasKicked = false;
|
||||||
|
|
||||||
//spam
|
|
||||||
private Date lastLogin = null; //when the player last logged into the server
|
|
||||||
|
|
||||||
//visualization
|
//visualization
|
||||||
public Visualization currentVisualization = null;
|
public Visualization currentVisualization = null;
|
||||||
|
|
||||||
|
|
@ -217,40 +214,11 @@ public class PlayerData
|
||||||
this.bonusClaimBlocks = bonusClaimBlocks;
|
this.bonusClaimBlocks = bonusClaimBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getLastLogin()
|
|
||||||
{
|
|
||||||
if(this.lastLogin == null) this.loadDataFromSecondaryStorage();
|
|
||||||
return this.lastLogin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastLogin(Date lastLogin)
|
|
||||||
{
|
|
||||||
this.lastLogin = lastLogin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadDataFromSecondaryStorage()
|
private void loadDataFromSecondaryStorage()
|
||||||
{
|
{
|
||||||
//reach out to secondary storage to get any data there
|
//reach out to secondary storage to get any data there
|
||||||
PlayerData storageData = GriefPrevention.instance.dataStore.getPlayerDataFromStorage(this.playerID);
|
PlayerData storageData = GriefPrevention.instance.dataStore.getPlayerDataFromStorage(this.playerID);
|
||||||
|
|
||||||
//fill in any missing pieces
|
|
||||||
if(this.lastLogin == null)
|
|
||||||
{
|
|
||||||
if(storageData.lastLogin != null)
|
|
||||||
{
|
|
||||||
this.lastLogin = storageData.lastLogin;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//default last login date value to 5 minutes ago to ensure a brand new player can log in
|
|
||||||
//see login cooldown feature, PlayerEventHandler.onPlayerLogin()
|
|
||||||
//if the player successfully logs in, this value will be overwritten with the current date and time
|
|
||||||
Calendar fiveMinutesBack = Calendar.getInstance();
|
|
||||||
fiveMinutesBack.add(Calendar.MINUTE, -5);
|
|
||||||
this.lastLogin = fiveMinutesBack.getTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.accruedClaimBlocks == null)
|
if(this.accruedClaimBlocks == null)
|
||||||
{
|
{
|
||||||
if(storageData.accruedClaimBlocks != null)
|
if(storageData.accruedClaimBlocks != null)
|
||||||
|
|
|
||||||
|
|
@ -627,7 +627,6 @@ class PlayerEventHandler implements Listener
|
||||||
long now = nowDate.getTime();
|
long now = nowDate.getTime();
|
||||||
PlayerData playerData = this.dataStore.getPlayerData(playerID);
|
PlayerData playerData = this.dataStore.getPlayerData(playerID);
|
||||||
playerData.lastSpawn = now;
|
playerData.lastSpawn = now;
|
||||||
playerData.setLastLogin(nowDate);
|
|
||||||
this.lastLoginThisServerSessionMap.put(playerID, nowDate);
|
this.lastLoginThisServerSessionMap.put(playerID, nowDate);
|
||||||
|
|
||||||
//if newish, prevent chat until he's moved a bit to prove he's not a bot
|
//if newish, prevent chat until he's moved a bit to prove he's not a bot
|
||||||
|
|
@ -1870,8 +1869,7 @@ class PlayerEventHandler implements Listener
|
||||||
{
|
{
|
||||||
claim = claim.parent;
|
claim = claim.parent;
|
||||||
}
|
}
|
||||||
PlayerData otherPlayerData = this.dataStore.getPlayerData(claim.ownerID);
|
Date lastLogin = new Date(Bukkit.getOfflinePlayer(claim.ownerID).getLastPlayed());
|
||||||
Date lastLogin = otherPlayerData.getLastLogin();
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
long daysElapsed = (now.getTime() - lastLogin.getTime()) / (1000 * 60 * 60 * 24);
|
long daysElapsed = (now.getTime() - lastLogin.getTime()) / (1000 * 60 * 60 * 24);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user