1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 12:05:16 +01:00

Fix for incorrect player data caching on player quit and delayed save

Small fix for bp check and NULL block
This commit is contained in:
Zrips 2017-05-12 14:42:12 +03:00
parent a84161585d
commit 9635ade759
8 changed files with 92 additions and 53 deletions

View File

@ -1,16 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/Vault1.5.3.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/mcMMO#127.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/CoreProtect_2.12.0.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/CheckMyInventory/lib/spigot-1.11.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Residence/lib/iConomy7.0.6.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Residence/lib/worldedit-bukkit-6.1.1-SNAPSHOT-dist.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/craftconomy3-3.3.1-20160221.070622-13.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-4.1.0.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MyPet-2.3.0-SNAPSHOT.jar"/>
<classpathentry kind="output" path=""/>
<classpathentry kind="src" path="" />
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Jobs/lib/Vault1.5.3.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Jobs/lib/mcMMO#127.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Jobs/lib/CoreProtect_2.12.0.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/CheckMyInventory/lib/spigot-1.11.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Residence/lib/iConomy7.0.6.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Residence/lib/worldedit-bukkit-6.1.1-SNAPSHOT-dist.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Jobs/lib/craftconomy3-3.3.1-20160221.070622-13.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-4.1.0.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar" />
<classpathentry kind="lib"
path="C:/Users/Arte/Desktop/Jobs/lib/MyPet-2.3.0-SNAPSHOT.jar" />
<classpathentry kind="output" path="" />
</classpath>

View File

@ -1,27 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Jobs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/Create jar file.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Jobs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/Create jar file.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1041,9 +1041,11 @@ public class Jobs extends JavaPlugin {
}
//need to update bp
BlockProtection bp = BpManager.getBp(block.getLocation());
if (bp != null)
bp.setPaid(true);
if (block != null) {
BlockProtection bp = BpManager.getBp(block.getLocation());
if (bp != null)
bp.setPaid(true);
}
}
}

View File

@ -175,15 +175,12 @@ public class PlayerManager {
* @param playername
*/
public void playerQuit(Player player) {
JobsPlayer jPlayer = this.removePlayer(player);
if (jPlayer == null)
jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
JobsPlayer jPlayer = this.getJobsPlayer(player);
if (jPlayer == null)
return;
addPlayerToCache(jPlayer);
if (Jobs.getGCManager().saveOnDisconnect()) {
jPlayer.save();
jPlayer.onDisconnect();
jPlayer.save();
} else {
jPlayer.onDisconnect();
}

View File

@ -29,6 +29,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -283,6 +284,14 @@ public class GeneralConfigManager {
return locale;
}
public boolean canPerformActionInWorld(Entity ent) {
if (ent == null)
return true;
if (ent.getWorld() == null)
return true;
return canPerformActionInWorld(ent.getWorld());
}
public boolean canPerformActionInWorld(Player player) {
if (player == null)
return true;
@ -414,7 +423,7 @@ public class GeneralConfigManager {
"Player data is always periodically auto-saved and autosaved during a clean shutdown.",
"Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance.");
saveOnDisconnect = c.get("save-on-disconnect", false);
c.getW().addComment("selectionTool", "Tool used when selecting bounds for restricted area");
getSelectionTooldID = c.get("selectionTool", 294);
if (Material.getMaterial(Jobs.getGCManager().getSelectionTooldID) == null)

View File

@ -168,8 +168,14 @@ public class JobsPlayer {
* @return the player
*/
public Player getPlayer() {
if (this.playerUUID != null)
this.player = Bukkit.getPlayer(this.playerUUID);
if (this.playerUUID != null){
Player p = Bukkit.getPlayer(this.playerUUID);
if (p != null){
this.player = p;
this.OffPlayer = p;
this.userName = player.getName();
}
}
return this.player;
}
@ -625,6 +631,11 @@ public class JobsPlayer {
dao.recordPlayersLimits(this);
dao.updateSeen(this);
setSaved(true);
if (this.getPlayer() == null || !this.getPlayer().isOnline()){
Jobs.getPlayerManager().addPlayerToCache(this);
Jobs.getPlayerManager().removePlayer(this.getPlayer());
}
}
// }
}
@ -644,6 +655,7 @@ public class JobsPlayer {
// Jobs.getJobsDAO().savePoints(this);
clearBossMaps();
isOnline = false;
Jobs.getPlayerManager().addPlayerToCache(this);
}
public void clearBossMaps() {

View File

@ -53,6 +53,7 @@ import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.TimeManage;
/**
@ -923,6 +924,7 @@ public abstract class JobsDAO {
* @param jobInfo - the information getting saved
*/
public void save(JobsPlayer player) {
Debug.D("saving player data " + player.getUserName());
JobsConnection conn = getConnection();
if (conn == null)
return;
@ -1277,7 +1279,7 @@ public abstract class JobsDAO {
Jobs.getBpManager().timer += System.currentTimeMillis() - t;
}
if (i > 0) {
String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] loaded " + i + " block protection entries. " + Jobs.getBpManager().timer);
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] loaded " + i + " block protection entries. " + Jobs.getBpManager().timer);
Bukkit.getServer().getConsoleSender().sendMessage(message);
}
} catch (SQLException e) {

View File

@ -1041,7 +1041,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTntExplode(EntityExplodeEvent event) {
//disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity()))
return;
// make sure plugin is enabled
if (!this.plugin.isEnabled())