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
8
pom.xml
8
pom.xml
|
|
@ -56,10 +56,10 @@
|
|||
<dependencies>
|
||||
<!--Bukkit API-->
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Worldguard dependency-->
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -500,8 +500,7 @@ public class DatabaseDataStore extends DataStore
|
|||
|
||||
//if data for this player exists, use it
|
||||
if(results.next())
|
||||
{
|
||||
playerData.setLastLogin(results.getTimestamp("lastlogin"));
|
||||
{
|
||||
playerData.setAccruedClaimBlocks(results.getInt("accruedblocks"));
|
||||
playerData.setBonusClaimBlocks(results.getInt("bonusblocks"));
|
||||
}
|
||||
|
|
@ -531,9 +530,10 @@ public class DatabaseDataStore extends DataStore
|
|||
try
|
||||
{
|
||||
this.refreshDataConnection();
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(playerID));
|
||||
|
||||
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.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"));
|
||||
Iterator<String> iterator = lines.iterator();
|
||||
|
||||
//first line is last login timestamp
|
||||
String lastLoginTimestampString = iterator.next();
|
||||
|
||||
//convert that to a date and store it
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
||||
try
|
||||
{
|
||||
playerData.setLastLogin(dateFormat.parse(lastLoginTimestampString));
|
||||
}
|
||||
catch(ParseException parseException)
|
||||
{
|
||||
GriefPrevention.AddLogEntry("Unable to load last login for \"" + playerFile.getName() + "\".");
|
||||
playerData.setLastLogin(null);
|
||||
}
|
||||
//first line is last login timestamp //RoboMWM - not using this anymore
|
||||
// String lastLoginTimestampString = iterator.next();
|
||||
//
|
||||
// //convert that to a date and store it
|
||||
// DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
||||
// try
|
||||
// {
|
||||
// playerData.setLastLogin(dateFormat.parse(lastLoginTimestampString));
|
||||
// }
|
||||
// catch(ParseException parseException)
|
||||
// {
|
||||
// GriefPrevention.AddLogEntry("Unable to load last login for \"" + playerFile.getName() + "\".");
|
||||
// playerData.setLastLogin(null);
|
||||
// }
|
||||
|
||||
//second line is accrued claim blocks
|
||||
String accruedBlocksString = iterator.next();
|
||||
|
|
@ -683,10 +683,10 @@ public class FlatFileDataStore extends DataStore
|
|||
StringBuilder fileContent = new StringBuilder();
|
||||
try
|
||||
{
|
||||
//first line is last login timestamp
|
||||
if(playerData.getLastLogin() == null) playerData.setLastLogin(new Date());
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
||||
fileContent.append(dateFormat.format(playerData.getLastLogin()));
|
||||
//first line is last login timestamp //RoboMWM - no longer storing/using
|
||||
//if(playerData.getLastLogin() == null) playerData.setLastLogin(new Date());
|
||||
//DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
||||
//fileContent.append(dateFormat.format(playerData.getLastLogin()));
|
||||
fileContent.append("\n");
|
||||
|
||||
//second line is accrued claim blocks
|
||||
|
|
|
|||
|
|
@ -776,7 +776,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
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("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("But if you truly have absolutely no choice, then please download the Java 7 version of GriefPrevention.");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
|
|
|
|||
|
|
@ -83,9 +83,6 @@ public class PlayerData
|
|||
|
||||
//whether the player was kicked (set and used during logout)
|
||||
boolean wasKicked = false;
|
||||
|
||||
//spam
|
||||
private Date lastLogin = null; //when the player last logged into the server
|
||||
|
||||
//visualization
|
||||
public Visualization currentVisualization = null;
|
||||
|
|
@ -216,41 +213,12 @@ public class PlayerData
|
|||
{
|
||||
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()
|
||||
{
|
||||
//reach out to secondary storage to get any data there
|
||||
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(storageData.accruedClaimBlocks != null)
|
||||
|
|
|
|||
|
|
@ -627,7 +627,6 @@ class PlayerEventHandler implements Listener
|
|||
long now = nowDate.getTime();
|
||||
PlayerData playerData = this.dataStore.getPlayerData(playerID);
|
||||
playerData.lastSpawn = now;
|
||||
playerData.setLastLogin(nowDate);
|
||||
this.lastLoginThisServerSessionMap.put(playerID, nowDate);
|
||||
|
||||
//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;
|
||||
}
|
||||
PlayerData otherPlayerData = this.dataStore.getPlayerData(claim.ownerID);
|
||||
Date lastLogin = otherPlayerData.getLastLogin();
|
||||
Date lastLogin = new Date(Bukkit.getOfflinePlayer(claim.ownerID).getLastPlayed());
|
||||
Date now = new Date();
|
||||
long daysElapsed = (now.getTime() - lastLogin.getTime()) / (1000 * 60 * 60 * 24);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user