mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 15:03:36 +01:00
Moving to ConcurentHashMap
This commit is contained in:
parent
ba506a1e62
commit
3d05def4b6
@ -30,36 +30,36 @@ import com.gamingmesh.jobs.economy.BlackholeEconomy;
|
|||||||
import com.gamingmesh.jobs.economy.VaultEconomy;
|
import com.gamingmesh.jobs.economy.VaultEconomy;
|
||||||
|
|
||||||
public class HookEconomyTask implements Runnable {
|
public class HookEconomyTask implements Runnable {
|
||||||
private JobsPlugin plugin;
|
private JobsPlugin plugin;
|
||||||
|
|
||||||
public HookEconomyTask(JobsPlugin plugin) {
|
public HookEconomyTask(JobsPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
Plugin eco = Bukkit.getServer().getPluginManager().getPlugin("Vault");
|
Plugin eco = Bukkit.getServer().getPluginManager().getPlugin("Vault");
|
||||||
if (eco != null) {
|
if (eco != null) {
|
||||||
RegisteredServiceProvider<Economy> provider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> provider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
Economy economy = provider.getProvider();
|
Economy economy = provider.getProvider();
|
||||||
if (economy != null) {
|
if (economy != null) {
|
||||||
Jobs.setEconomy(plugin, new VaultEconomy(economy));
|
Jobs.setEconomy(plugin, new VaultEconomy(economy));
|
||||||
String message = ChatColor.translateAlternateColorCodes('&', "&2[" + plugin.getDescription().getName() + "] Successfully linked with Vault.");
|
String message = ChatColor.translateAlternateColorCodes('&', "&2[" + plugin.getDescription().getName() + "] Successfully linked with Vault.");
|
||||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||||
console.sendMessage(message);
|
console.sendMessage(message);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// no Vault found
|
|
||||||
Jobs.setEconomy(plugin, new BlackholeEconomy());
|
|
||||||
Bukkit.getServer().getLogger().severe("==================== " + plugin.getDescription().getName() + " ====================");
|
|
||||||
Bukkit.getServer().getLogger().severe("Vault is required by this plugin for economy support!");
|
|
||||||
Bukkit.getServer().getLogger().severe("Please install Vault first!");
|
|
||||||
Bukkit.getServer().getLogger().severe("You can find the latest version here:");
|
|
||||||
Bukkit.getServer().getLogger().severe("http://dev.bukkit.org/server-mods/vault/");
|
|
||||||
Bukkit.getServer().getLogger().severe("==============================================");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no Vault found
|
||||||
|
Jobs.setEconomy(plugin, new BlackholeEconomy());
|
||||||
|
Bukkit.getServer().getLogger().severe("==================== " + plugin.getDescription().getName() + " ====================");
|
||||||
|
Bukkit.getServer().getLogger().severe("Vault is required by this plugin for economy support!");
|
||||||
|
Bukkit.getServer().getLogger().severe("Please install Vault first!");
|
||||||
|
Bukkit.getServer().getLogger().severe("You can find the latest version here:");
|
||||||
|
Bukkit.getServer().getLogger().severe("http://dev.bukkit.org/server-mods/vault/");
|
||||||
|
Bukkit.getServer().getLogger().severe("==============================================");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,8 @@
|
|||||||
package com.gamingmesh.jobs;
|
package com.gamingmesh.jobs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -44,26 +42,26 @@ import com.gamingmesh.jobs.stuff.ChatColor;
|
|||||||
import com.gamingmesh.jobs.stuff.PerformCommands;
|
import com.gamingmesh.jobs.stuff.PerformCommands;
|
||||||
|
|
||||||
public class PlayerManager {
|
public class PlayerManager {
|
||||||
private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
// private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
||||||
//private Map<String, JobsPlayer> players = new HashMap<String, JobsPlayer>();
|
private ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<String, JobsPlayer>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles join of new player
|
* Handles join of new player
|
||||||
* @param playername
|
* @param playername
|
||||||
*/
|
*/
|
||||||
public void playerJoin(Player player) {
|
public void playerJoin(Player player) {
|
||||||
synchronized (players) {
|
// synchronized (players) {
|
||||||
JobsPlayer jPlayer = players.get(player.getName().toLowerCase());
|
JobsPlayer jPlayer = players.get(player.getName().toLowerCase());
|
||||||
if (jPlayer == null) {
|
if (jPlayer == null) {
|
||||||
jPlayer = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), player);
|
jPlayer = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), player);
|
||||||
JobsPlayer.loadLogFromDao(jPlayer);
|
JobsPlayer.loadLogFromDao(jPlayer);
|
||||||
players.put(player.getName().toLowerCase(), jPlayer);
|
players.put(player.getName().toLowerCase(), jPlayer);
|
||||||
}
|
|
||||||
jPlayer.onConnect();
|
|
||||||
jPlayer.reloadHonorific();
|
|
||||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
jPlayer.onConnect();
|
||||||
|
jPlayer.reloadHonorific();
|
||||||
|
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
||||||
|
return;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,20 +69,20 @@ public class PlayerManager {
|
|||||||
* @param playername
|
* @param playername
|
||||||
*/
|
*/
|
||||||
public void playerQuit(Player player) {
|
public void playerQuit(Player player) {
|
||||||
synchronized (players) {
|
// synchronized (players) {
|
||||||
if (ConfigManager.getJobsConfiguration().saveOnDisconnect()) {
|
if (ConfigManager.getJobsConfiguration().saveOnDisconnect()) {
|
||||||
JobsPlayer jPlayer = players.remove(player.getName().toLowerCase());
|
JobsPlayer jPlayer = players.remove(player.getName().toLowerCase());
|
||||||
if (jPlayer != null) {
|
if (jPlayer != null) {
|
||||||
jPlayer.save(Jobs.getJobsDAO());
|
jPlayer.save(Jobs.getJobsDAO());
|
||||||
jPlayer.onDisconnect();
|
jPlayer.onDisconnect();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
JobsPlayer jPlayer = players.get(player.getName().toLowerCase());
|
JobsPlayer jPlayer = players.get(player.getName().toLowerCase());
|
||||||
if (jPlayer != null) {
|
if (jPlayer != null) {
|
||||||
jPlayer.onDisconnect();
|
jPlayer.onDisconnect();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,25 +99,25 @@ public class PlayerManager {
|
|||||||
* 3) Garbage collect the real list to remove any offline players with saved data
|
* 3) Garbage collect the real list to remove any offline players with saved data
|
||||||
*/
|
*/
|
||||||
ArrayList<JobsPlayer> list = null;
|
ArrayList<JobsPlayer> list = null;
|
||||||
synchronized (players) {
|
// synchronized (players) {
|
||||||
list = new ArrayList<JobsPlayer>(players.values());
|
list = new ArrayList<JobsPlayer>(players.values());
|
||||||
}
|
// }
|
||||||
|
|
||||||
for (JobsPlayer jPlayer : list) {
|
for (JobsPlayer jPlayer : list) {
|
||||||
jPlayer.save(dao);
|
jPlayer.save(dao);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (players) {
|
// synchronized (players) {
|
||||||
Iterator<JobsPlayer> iter = players.values().iterator();
|
Iterator<JobsPlayer> iter = players.values().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
JobsPlayer jPlayer = iter.next();
|
JobsPlayer jPlayer = iter.next();
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
if (!jPlayer.isOnline() && jPlayer.isSaved()) {
|
if (!jPlayer.isOnline() && jPlayer.isSaved()) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,7 +126,9 @@ public class PlayerManager {
|
|||||||
* @return the player job info of the player
|
* @return the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayer(Player player) {
|
public JobsPlayer getJobsPlayer(Player player) {
|
||||||
|
// synchronized (players) {
|
||||||
return players.get(player.getName().toLowerCase());
|
return players.get(player.getName().toLowerCase());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +137,9 @@ public class PlayerManager {
|
|||||||
* @return the player job info of the player
|
* @return the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayer(String playerName) {
|
public JobsPlayer getJobsPlayer(String playerName) {
|
||||||
|
// synchronized (players) {
|
||||||
return players.get(playerName.toLowerCase());
|
return players.get(playerName.toLowerCase());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,27 +163,27 @@ public class PlayerManager {
|
|||||||
* @param job
|
* @param job
|
||||||
*/
|
*/
|
||||||
public void joinJob(JobsPlayer jPlayer, Job job) {
|
public void joinJob(JobsPlayer jPlayer, Job job) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
if (jPlayer.isInJob(job))
|
if (jPlayer.isInJob(job))
|
||||||
return;
|
return;
|
||||||
// let the user join the job
|
// let the user join the job
|
||||||
if (!jPlayer.joinJob(job, jPlayer))
|
if (!jPlayer.joinJob(job, jPlayer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// JobsJoin event
|
// JobsJoin event
|
||||||
JobsJoinEvent jobsjoinevent = new JobsJoinEvent(jPlayer, job);
|
JobsJoinEvent jobsjoinevent = new JobsJoinEvent(jPlayer, job);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(jobsjoinevent);
|
Bukkit.getServer().getPluginManager().callEvent(jobsjoinevent);
|
||||||
// If event is canceled, dont do anything
|
// If event is canceled, dont do anything
|
||||||
if (jobsjoinevent.isCancelled())
|
if (jobsjoinevent.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Jobs.getJobsDAO().joinJob(jPlayer, job);
|
Jobs.getJobsDAO().joinJob(jPlayer, job);
|
||||||
PerformCommands.PerformCommandsOnJoin(jPlayer, job);
|
PerformCommands.PerformCommandsOnJoin(jPlayer, job);
|
||||||
Jobs.takeSlot(job);
|
Jobs.takeSlot(job);
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||||
job.updateTotalPlayers();
|
job.updateTotalPlayers();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,29 +192,29 @@ public class PlayerManager {
|
|||||||
* @param job
|
* @param job
|
||||||
*/
|
*/
|
||||||
public void leaveJob(JobsPlayer jPlayer, Job job) {
|
public void leaveJob(JobsPlayer jPlayer, Job job) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
if (!jPlayer.isInJob(job))
|
if (!jPlayer.isInJob(job))
|
||||||
return;
|
return;
|
||||||
Jobs.getJobsDAO().recordToArchive(jPlayer, job);
|
Jobs.getJobsDAO().recordToArchive(jPlayer, job);
|
||||||
// let the user leave the job
|
// let the user leave the job
|
||||||
if (!jPlayer.leaveJob(job))
|
if (!jPlayer.leaveJob(job))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// JobsJoin event
|
// JobsJoin event
|
||||||
JobsLeaveEvent jobsleaveevent = new JobsLeaveEvent(jPlayer, job);
|
JobsLeaveEvent jobsleaveevent = new JobsLeaveEvent(jPlayer, job);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(jobsleaveevent);
|
Bukkit.getServer().getPluginManager().callEvent(jobsleaveevent);
|
||||||
// If event is canceled, dont do anything
|
// If event is canceled, dont do anything
|
||||||
if (jobsleaveevent.isCancelled())
|
if (jobsleaveevent.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Jobs.getJobsDAO().quitJob(jPlayer, job);
|
Jobs.getJobsDAO().quitJob(jPlayer, job);
|
||||||
PerformCommands.PerformCommandsOnLeave(jPlayer, job);
|
PerformCommands.PerformCommandsOnLeave(jPlayer, job);
|
||||||
Jobs.leaveSlot(job);
|
Jobs.leaveSlot(job);
|
||||||
|
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||||
job.updateTotalPlayers();
|
job.updateTotalPlayers();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,19 +222,19 @@ public class PlayerManager {
|
|||||||
* @param jPlayer
|
* @param jPlayer
|
||||||
*/
|
*/
|
||||||
public void leaveAllJobs(JobsPlayer jPlayer) {
|
public void leaveAllJobs(JobsPlayer jPlayer) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
for (JobProgression job : jPlayer.getJobProgression()) {
|
for (JobProgression job : jPlayer.getJobProgression()) {
|
||||||
Jobs.getJobsDAO().quitJob(jPlayer, job.getJob());
|
Jobs.getJobsDAO().quitJob(jPlayer, job.getJob());
|
||||||
PerformCommands.PerformCommandsOnLeave(jPlayer, job.getJob());
|
PerformCommands.PerformCommandsOnLeave(jPlayer, job.getJob());
|
||||||
Jobs.leaveSlot(job.getJob());
|
Jobs.leaveSlot(job.getJob());
|
||||||
|
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getJob().getName());
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getJob().getName());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||||
job.getJob().updateTotalPlayers();
|
job.getJob().updateTotalPlayers();
|
||||||
}
|
|
||||||
|
|
||||||
jPlayer.leaveAllJobs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jPlayer.leaveAllJobs();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -242,17 +244,17 @@ public class PlayerManager {
|
|||||||
* @param newjob - the new job
|
* @param newjob - the new job
|
||||||
*/
|
*/
|
||||||
public void transferJob(JobsPlayer jPlayer, Job oldjob, Job newjob) {
|
public void transferJob(JobsPlayer jPlayer, Job oldjob, Job newjob) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
if (!jPlayer.transferJob(oldjob, newjob, jPlayer))
|
if (!jPlayer.transferJob(oldjob, newjob, jPlayer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
JobsDAO dao = Jobs.getJobsDAO();
|
JobsDAO dao = Jobs.getJobsDAO();
|
||||||
dao.quitJob(jPlayer, oldjob);
|
dao.quitJob(jPlayer, oldjob);
|
||||||
oldjob.updateTotalPlayers();
|
oldjob.updateTotalPlayers();
|
||||||
dao.joinJob(jPlayer, newjob);
|
dao.joinJob(jPlayer, newjob);
|
||||||
newjob.updateTotalPlayers();
|
newjob.updateTotalPlayers();
|
||||||
jPlayer.save(dao);
|
jPlayer.save(dao);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -262,13 +264,13 @@ public class PlayerManager {
|
|||||||
* @param levels - number of levels to promote
|
* @param levels - number of levels to promote
|
||||||
*/
|
*/
|
||||||
public void promoteJob(JobsPlayer jPlayer, Job job, int levels) {
|
public void promoteJob(JobsPlayer jPlayer, Job job, int levels) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
jPlayer.promoteJob(job, levels, jPlayer);
|
jPlayer.promoteJob(job, levels, jPlayer);
|
||||||
jPlayer.save(Jobs.getJobsDAO());
|
jPlayer.save(Jobs.getJobsDAO());
|
||||||
|
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -278,12 +280,12 @@ public class PlayerManager {
|
|||||||
* @param levels - number of levels to demote
|
* @param levels - number of levels to demote
|
||||||
*/
|
*/
|
||||||
public void demoteJob(JobsPlayer jPlayer, Job job, int levels) {
|
public void demoteJob(JobsPlayer jPlayer, Job job, int levels) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
jPlayer.demoteJob(job, levels);
|
jPlayer.demoteJob(job, levels);
|
||||||
jPlayer.save(Jobs.getJobsDAO());
|
jPlayer.save(Jobs.getJobsDAO());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,18 +295,18 @@ public class PlayerManager {
|
|||||||
* @param experience - experience gained
|
* @param experience - experience gained
|
||||||
*/
|
*/
|
||||||
public void addExperience(JobsPlayer jPlayer, Job job, double experience) {
|
public void addExperience(JobsPlayer jPlayer, Job job, double experience) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
JobProgression prog = jPlayer.getJobProgression(job);
|
JobProgression prog = jPlayer.getJobProgression(job);
|
||||||
if (prog == null)
|
if (prog == null)
|
||||||
return;
|
return;
|
||||||
int oldLevel = prog.getLevel();
|
int oldLevel = prog.getLevel();
|
||||||
if (prog.addExperience(experience))
|
if (prog.addExperience(experience))
|
||||||
performLevelUp(jPlayer, job, oldLevel);
|
performLevelUp(jPlayer, job, oldLevel);
|
||||||
|
|
||||||
jPlayer.save(Jobs.getJobsDAO());
|
jPlayer.save(Jobs.getJobsDAO());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -314,16 +316,16 @@ public class PlayerManager {
|
|||||||
* @param experience - experience gained
|
* @param experience - experience gained
|
||||||
*/
|
*/
|
||||||
public void removeExperience(JobsPlayer jPlayer, Job job, double experience) {
|
public void removeExperience(JobsPlayer jPlayer, Job job, double experience) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
JobProgression prog = jPlayer.getJobProgression(job);
|
JobProgression prog = jPlayer.getJobProgression(job);
|
||||||
if (prog == null)
|
if (prog == null)
|
||||||
return;
|
return;
|
||||||
prog.addExperience(-experience);
|
prog.addExperience(-experience);
|
||||||
|
|
||||||
jPlayer.save(Jobs.getJobsDAO());
|
jPlayer.save(Jobs.getJobsDAO());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -558,20 +560,20 @@ public class PlayerManager {
|
|||||||
* Perform reload
|
* Perform reload
|
||||||
*/
|
*/
|
||||||
public void reload() {
|
public void reload() {
|
||||||
synchronized (players) {
|
// synchronized (players) {
|
||||||
for (JobsPlayer jPlayer : players.values()) {
|
for (JobsPlayer jPlayer : players.values()) {
|
||||||
for (JobProgression progression : jPlayer.getJobProgression()) {
|
for (JobProgression progression : jPlayer.getJobProgression()) {
|
||||||
String jobName = progression.getJob().getName();
|
String jobName = progression.getJob().getName();
|
||||||
Job job = Jobs.getJob(jobName);
|
Job job = Jobs.getJob(jobName);
|
||||||
if (job != null) {
|
if (job != null) {
|
||||||
progression.setJob(job);
|
progression.setJob(job);
|
||||||
}
|
|
||||||
}
|
|
||||||
if (jPlayer.isOnline()) {
|
|
||||||
jPlayer.reloadHonorific();
|
|
||||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (jPlayer.isOnline()) {
|
||||||
|
jPlayer.reloadHonorific();
|
||||||
|
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import org.bukkit.scoreboard.ScoreboardManager;
|
|||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.JobsPlugin;
|
import com.gamingmesh.jobs.JobsPlugin;
|
||||||
|
import com.gamingmesh.jobs.Gui.GuiTools;
|
||||||
import com.gamingmesh.jobs.config.ConfigManager;
|
import com.gamingmesh.jobs.config.ConfigManager;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.Convert;
|
import com.gamingmesh.jobs.container.Convert;
|
||||||
@ -643,9 +644,9 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// ((Player) sender).openInventory(GuiTools.CreateJobsGUI((Player) sender));
|
((Player) sender).openInventory(GuiTools.CreateJobsGUI((Player) sender));
|
||||||
// }
|
}
|
||||||
|
|
||||||
sender.sendMessage(Language.getMessage("command.browse.output.header"));
|
sender.sendMessage(Language.getMessage("command.browse.output.header"));
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
|
@ -80,11 +80,11 @@ public class JobProgression {
|
|||||||
* @param job - the new job to be set
|
* @param job - the new job to be set
|
||||||
*/
|
*/
|
||||||
public void setJob(Job job) {
|
public void setJob(Job job) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
jPlayer.setSaved(false);
|
jPlayer.setSaved(false);
|
||||||
this.job = job;
|
this.job = job;
|
||||||
reloadMaxExperienceAndCheckLevelUp();
|
reloadMaxExperienceAndCheckLevelUp();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,11 +101,11 @@ public class JobProgression {
|
|||||||
* @return - job level up
|
* @return - job level up
|
||||||
*/
|
*/
|
||||||
public boolean addExperience(double experience) {
|
public boolean addExperience(double experience) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
jPlayer.setSaved(false);
|
jPlayer.setSaved(false);
|
||||||
this.experience += experience;
|
this.experience += experience;
|
||||||
return checkLevelUp();
|
return checkLevelUp();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,11 +129,11 @@ public class JobProgression {
|
|||||||
* @param level - the new level for this job
|
* @param level - the new level for this job
|
||||||
*/
|
*/
|
||||||
public void setLevel(int level) {
|
public void setLevel(int level) {
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
jPlayer.setSaved(false);
|
jPlayer.setSaved(false);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
reloadMaxExperienceAndCheckLevelUp();
|
reloadMaxExperienceAndCheckLevelUp();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +51,7 @@ public class JobsPlayer {
|
|||||||
private double VipSpawnerMultiplier = -1;
|
private double VipSpawnerMultiplier = -1;
|
||||||
|
|
||||||
// save lock
|
// save lock
|
||||||
public final Object saveLock = new Object();
|
// public final Object saveLock = new Object();
|
||||||
|
|
||||||
// log
|
// log
|
||||||
private List<Log> logList = new ArrayList<Log>();
|
private List<Log> logList = new ArrayList<Log>();
|
||||||
@ -66,7 +66,7 @@ public class JobsPlayer {
|
|||||||
JobsPlayer jPlayer = new JobsPlayer(player.getName(), player);
|
JobsPlayer jPlayer = new JobsPlayer(player.getName(), player);
|
||||||
jPlayer.playerUUID = player.getUniqueId();
|
jPlayer.playerUUID = player.getUniqueId();
|
||||||
List<JobsDAOData> list = dao.getAllJobs(player);
|
List<JobsDAOData> list = dao.getAllJobs(player);
|
||||||
synchronized (jPlayer.saveLock) {
|
// synchronized (jPlayer.saveLock) {
|
||||||
jPlayer.progression.clear();
|
jPlayer.progression.clear();
|
||||||
for (JobsDAOData jobdata : list) {
|
for (JobsDAOData jobdata : list) {
|
||||||
if (Jobs.getJob(jobdata.getJobName()) == null)
|
if (Jobs.getJob(jobdata.getJobName()) == null)
|
||||||
@ -84,7 +84,7 @@ public class JobsPlayer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
jPlayer.reloadMaxExperience();
|
jPlayer.reloadMaxExperience();
|
||||||
}
|
// }
|
||||||
return jPlayer;
|
return jPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ public class JobsPlayer {
|
|||||||
* @param job - the job joined
|
* @param job - the job joined
|
||||||
*/
|
*/
|
||||||
public boolean joinJob(Job job, JobsPlayer jPlayer) {
|
public boolean joinJob(Job job, JobsPlayer jPlayer) {
|
||||||
synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
if (!isInJob(job)) {
|
if (!isInJob(job)) {
|
||||||
int level = 1;
|
int level = 1;
|
||||||
int exp = 0;
|
int exp = 0;
|
||||||
@ -235,7 +235,7 @@ public class JobsPlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,7 +243,7 @@ public class JobsPlayer {
|
|||||||
* @param job - the job left
|
* @param job - the job left
|
||||||
*/
|
*/
|
||||||
public boolean leaveJob(Job job) {
|
public boolean leaveJob(Job job) {
|
||||||
synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
JobProgression prog = getJobProgression(job);
|
JobProgression prog = getJobProgression(job);
|
||||||
if (prog != null) {
|
if (prog != null) {
|
||||||
progression.remove(prog);
|
progression.remove(prog);
|
||||||
@ -253,7 +253,7 @@ public class JobsPlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -261,13 +261,13 @@ public class JobsPlayer {
|
|||||||
* @return on success
|
* @return on success
|
||||||
*/
|
*/
|
||||||
public boolean leaveAllJobs() {
|
public boolean leaveAllJobs() {
|
||||||
synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
progression.clear();
|
progression.clear();
|
||||||
reloadHonorific();
|
reloadHonorific();
|
||||||
Jobs.getPermissionHandler().recalculatePermissions(this);
|
Jobs.getPermissionHandler().recalculatePermissions(this);
|
||||||
;
|
;
|
||||||
return true;
|
return true;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -276,7 +276,7 @@ public class JobsPlayer {
|
|||||||
* @param levels - number of levels to promote
|
* @param levels - number of levels to promote
|
||||||
*/
|
*/
|
||||||
public void promoteJob(Job job, int levels, JobsPlayer player) {
|
public void promoteJob(Job job, int levels, JobsPlayer player) {
|
||||||
synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
JobProgression prog = getJobProgression(job);
|
JobProgression prog = getJobProgression(job);
|
||||||
if (prog == null)
|
if (prog == null)
|
||||||
return;
|
return;
|
||||||
@ -293,7 +293,7 @@ public class JobsPlayer {
|
|||||||
newLevel = maxLevel;
|
newLevel = maxLevel;
|
||||||
}
|
}
|
||||||
setLevel(job, newLevel);
|
setLevel(job, newLevel);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,7 +302,7 @@ public class JobsPlayer {
|
|||||||
* @param levels - number of levels to demote
|
* @param levels - number of levels to demote
|
||||||
*/
|
*/
|
||||||
public void demoteJob(Job job, int levels) {
|
public void demoteJob(Job job, int levels) {
|
||||||
synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
JobProgression prog = getJobProgression(job);
|
JobProgression prog = getJobProgression(job);
|
||||||
if (prog == null)
|
if (prog == null)
|
||||||
return;
|
return;
|
||||||
@ -313,7 +313,7 @@ public class JobsPlayer {
|
|||||||
newLevel = 1;
|
newLevel = 1;
|
||||||
}
|
}
|
||||||
setLevel(job, newLevel);
|
setLevel(job, newLevel);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,7 +322,7 @@ public class JobsPlayer {
|
|||||||
* @param level - the level
|
* @param level - the level
|
||||||
*/
|
*/
|
||||||
private void setLevel(Job job, int level) {
|
private void setLevel(Job job, int level) {
|
||||||
synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
JobProgression prog = getJobProgression(job);
|
JobProgression prog = getJobProgression(job);
|
||||||
if (prog == null)
|
if (prog == null)
|
||||||
return;
|
return;
|
||||||
@ -333,7 +333,7 @@ public class JobsPlayer {
|
|||||||
Jobs.getPermissionHandler().recalculatePermissions(this);
|
Jobs.getPermissionHandler().recalculatePermissions(this);
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,7 +342,7 @@ public class JobsPlayer {
|
|||||||
* @param newjob - the new job
|
* @param newjob - the new job
|
||||||
*/
|
*/
|
||||||
public boolean transferJob(Job oldjob, Job newjob, JobsPlayer jPlayer) {
|
public boolean transferJob(Job oldjob, Job newjob, JobsPlayer jPlayer) {
|
||||||
synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
if (!isInJob(newjob)) {
|
if (!isInJob(newjob)) {
|
||||||
for (JobProgression prog : progression) {
|
for (JobProgression prog : progression) {
|
||||||
if (!prog.getJob().equals(oldjob))
|
if (!prog.getJob().equals(oldjob))
|
||||||
@ -367,7 +367,7 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -474,13 +474,13 @@ public class JobsPlayer {
|
|||||||
* @param dao
|
* @param dao
|
||||||
*/
|
*/
|
||||||
public void save(JobsDAO dao) {
|
public void save(JobsDAO dao) {
|
||||||
synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
if (!isSaved()) {
|
if (!isSaved()) {
|
||||||
dao.save(this);
|
dao.save(this);
|
||||||
dao.saveLog(this);
|
dao.saveLog(this);
|
||||||
setSaved(true);
|
setSaved(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,8 +80,11 @@ public abstract class JobsDAO {
|
|||||||
|
|
||||||
checkUpdate4();
|
checkUpdate4();
|
||||||
checkUpdate5();
|
checkUpdate5();
|
||||||
|
|
||||||
|
if (version <= 5)
|
||||||
|
checkUpdate6();
|
||||||
|
|
||||||
version = 5;
|
version = 6;
|
||||||
} finally {
|
} finally {
|
||||||
updateSchemaVersion(version);
|
updateSchemaVersion(version);
|
||||||
}
|
}
|
||||||
@ -97,6 +100,8 @@ public abstract class JobsDAO {
|
|||||||
|
|
||||||
protected abstract void checkUpdate5() throws SQLException;
|
protected abstract void checkUpdate5() throws SQLException;
|
||||||
|
|
||||||
|
protected abstract void checkUpdate6() throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the database prefix
|
* Gets the database prefix
|
||||||
* @return the prefix
|
* @return the prefix
|
||||||
@ -168,6 +173,7 @@ public abstract class JobsDAO {
|
|||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
count = res.getInt(1);
|
count = res.getInt(1);
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
prest.close();
|
prest.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -193,6 +199,7 @@ public abstract class JobsDAO {
|
|||||||
jobs.add(new JobsDAOData(UUIDUtil.fromBytes(res.getBytes(1)), res.getString(2), res.getInt(3), res.getInt(4)));
|
jobs.add(new JobsDAOData(UUIDUtil.fromBytes(res.getBytes(1)), res.getString(2), res.getInt(3), res.getInt(4)));
|
||||||
}
|
}
|
||||||
prest.close();
|
prest.close();
|
||||||
|
res.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -249,6 +256,7 @@ public abstract class JobsDAO {
|
|||||||
list.add(new Convert(res.getInt("id"), res.getString("username"), UUIDUtil.fromBytes(res.getBytes("player_uuid")), res.getString("job"), res.getInt(
|
list.add(new Convert(res.getInt("id"), res.getString("username"), UUIDUtil.fromBytes(res.getBytes("player_uuid")), res.getString("job"), res.getInt(
|
||||||
"level"), res.getInt("experience")));
|
"level"), res.getInt("experience")));
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
prest.close();
|
prest.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -292,6 +300,7 @@ public abstract class JobsDAO {
|
|||||||
insert.executeBatch();
|
insert.executeBatch();
|
||||||
conns.commit();
|
conns.commit();
|
||||||
conns.setAutoCommit(true);
|
conns.setAutoCommit(true);
|
||||||
|
statement.close();
|
||||||
} finally {
|
} finally {
|
||||||
if (insert != null) {
|
if (insert != null) {
|
||||||
try {
|
try {
|
||||||
@ -385,6 +394,7 @@ public abstract class JobsDAO {
|
|||||||
info.add(level);
|
info.add(level);
|
||||||
info.add(res.getInt(2));
|
info.add(res.getInt(2));
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
prest.close();
|
prest.close();
|
||||||
return info;
|
return info;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -421,7 +431,7 @@ public abstract class JobsDAO {
|
|||||||
|
|
||||||
names.add(top);
|
names.add(top);
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
prest.close();
|
prest.close();
|
||||||
return names;
|
return names;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -461,6 +471,7 @@ public abstract class JobsDAO {
|
|||||||
|
|
||||||
info.add(res.getString(1) + ":" + res.getInt(2) + ":" + level + ":" + res.getInt(3));
|
info.add(res.getString(1) + ":" + res.getInt(2) + ":" + level + ":" + res.getInt(3));
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
prest.close();
|
prest.close();
|
||||||
return info;
|
return info;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -653,6 +664,7 @@ public abstract class JobsDAO {
|
|||||||
} else
|
} else
|
||||||
jobs.add(new TopList(res.getString(1), res.getInt(2), res.getInt(3), res.getBytes(4)));
|
jobs.add(new TopList(res.getString(1), res.getInt(2), res.getInt(3), res.getBytes(4)));
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
prest.close();
|
prest.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -677,6 +689,7 @@ public abstract class JobsDAO {
|
|||||||
if (res.next()) {
|
if (res.next()) {
|
||||||
slot = res.getInt(1);
|
slot = res.getInt(1);
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
prest.close();
|
prest.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -700,6 +713,7 @@ public abstract class JobsDAO {
|
|||||||
if (res.next()) {
|
if (res.next()) {
|
||||||
return Integer.valueOf(res.getString(1));
|
return Integer.valueOf(res.getString(1));
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
@ -185,11 +185,11 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "" + y + " of " + usernames.size());
|
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "" + y + " of " + usernames.size());
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer offPlayer = OfflinePlayerList.getPlayer(names);
|
OfflinePlayer offPlayer = OfflinePlayerList.getPlayer(names);
|
||||||
if (offPlayer == null)
|
if (offPlayer == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pst2.setBytes(1, UUIDUtil.toBytes(offPlayer.getUniqueId()));
|
pst2.setBytes(1, UUIDUtil.toBytes(offPlayer.getUniqueId()));
|
||||||
pst2.setString(2, names);
|
pst2.setString(2, names);
|
||||||
pst2.execute();
|
pst2.execute();
|
||||||
@ -316,8 +316,18 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
try {
|
try {
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
+ "log` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `time` bigint, `action` varchar(20), `itemname` varchar(20), `count` int, `money` double, `exp` double);");
|
+ "log` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
|
||||||
} finally {
|
} finally {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected synchronized void checkUpdate6() throws SQLException {
|
||||||
|
JobsConnection conn = getConnection();
|
||||||
|
if (conn == null) {
|
||||||
|
Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to MySQL!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
executeSQL("ALTER TABLE `" + getPrefix() + "log` MODIFY `itemname` VARCHAR(60);");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,8 +287,27 @@ public class JobsDAOSQLite extends JobsDAO {
|
|||||||
try {
|
try {
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
+ "log` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `time` bigint, `action` varchar(20), `itemname` varchar(20), `count` int, `money` double, `exp` double);");
|
+ "log` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
|
||||||
} finally {
|
} finally {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected synchronized void checkUpdate6() throws SQLException {
|
||||||
|
JobsConnection conn = getConnection();
|
||||||
|
if (conn == null) {
|
||||||
|
Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to MySQL!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
|
||||||
|
|
||||||
|
executeSQL("INSERT INTO `" + getPrefix() + "log_temp` SELECT `id`, `player_uuid`, `username`, `time`, `action`, `itemname`, `count`, `money`, `exp` FROM `"
|
||||||
|
+ getPrefix() + "log`;");
|
||||||
|
|
||||||
|
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;");
|
||||||
|
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,9 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@ -45,6 +48,8 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.JobsPlugin;
|
import com.gamingmesh.jobs.JobsPlugin;
|
||||||
|
import com.gamingmesh.jobs.Gui.GuiInfoList;
|
||||||
|
import com.gamingmesh.jobs.Gui.GuiTools;
|
||||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||||
import com.gamingmesh.jobs.config.ConfigManager;
|
import com.gamingmesh.jobs.config.ConfigManager;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
@ -60,100 +65,100 @@ public class JobsListener implements Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
||||||
// public void onGuiRightClick(InventoryClickEvent event) {
|
public void onGuiRightClick(InventoryClickEvent event) {
|
||||||
// if (Gui.GuiTools.GuiList.size() == 0)
|
if (GuiTools.GuiList.size() == 0)
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
//
|
|
||||||
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
|
if (!GuiTools.GuiList.containsKey(player.getName()))
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// if (event.getClick() != ClickType.RIGHT)
|
if (event.getClick() != ClickType.RIGHT)
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
//
|
|
||||||
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
|
GuiInfoList joblist = GuiTools.GuiList.get(player.getName());
|
||||||
//
|
|
||||||
// if (joblist.isJobInfo())
|
if (joblist.isJobInfo())
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// int slot = event.getRawSlot();
|
int slot = event.getRawSlot();
|
||||||
//
|
|
||||||
// if (slot < joblist.getJobList().size()) {
|
if (slot < joblist.getJobList().size()) {
|
||||||
// Bukkit.dispatchCommand(player, "jobs join " + joblist.getJobList().get(slot).getName());
|
Bukkit.dispatchCommand(player, "jobs join " + joblist.getJobList().get(slot).getName());
|
||||||
// player.getOpenInventory().getTopInventory().setContents(GuiTools.CreateJobsGUI(player).getContents());
|
player.getOpenInventory().getTopInventory().setContents(GuiTools.CreateJobsGUI(player).getContents());
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
||||||
// public void onGuiLeftClick(InventoryClickEvent event) {
|
public void onGuiLeftClick(InventoryClickEvent event) {
|
||||||
// if (Gui.GuiTools.GuiList.size() == 0)
|
if (GuiTools.GuiList.size() == 0)
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
//
|
|
||||||
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
|
if (!GuiTools.GuiList.containsKey(player.getName()))
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
//
|
|
||||||
// if (event.getClick() != ClickType.LEFT)
|
if (event.getClick() != ClickType.LEFT)
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
|
GuiInfoList joblist = GuiTools.GuiList.get(player.getName());
|
||||||
//
|
|
||||||
// if (joblist.isJobInfo())
|
if (joblist.isJobInfo())
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// int slot = event.getRawSlot();
|
int slot = event.getRawSlot();
|
||||||
//
|
|
||||||
// if (slot < joblist.getJobList().size()) {
|
if (slot < joblist.getJobList().size()) {
|
||||||
// player.closeInventory();
|
player.closeInventory();
|
||||||
// player.openInventory(GuiTools.CreateJobsSubGUI(player, joblist.getJobList().get(slot)));
|
player.openInventory(GuiTools.CreateJobsSubGUI(player, joblist.getJobList().get(slot)));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
||||||
// public void onGuiLeftSubClick(InventoryClickEvent event) {
|
public void onGuiLeftSubClick(InventoryClickEvent event) {
|
||||||
// if (Gui.GuiTools.GuiList.size() == 0)
|
if (GuiTools.GuiList.size() == 0)
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
//
|
|
||||||
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
|
if (!GuiTools.GuiList.containsKey(player.getName()))
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
//
|
|
||||||
// if (event.getClick() != ClickType.LEFT)
|
if (event.getClick() != ClickType.LEFT)
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
|
GuiInfoList joblist = GuiTools.GuiList.get(player.getName());
|
||||||
//
|
|
||||||
// if (!joblist.isJobInfo())
|
if (!joblist.isJobInfo())
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// int slot = event.getRawSlot();
|
int slot = event.getRawSlot();
|
||||||
//
|
|
||||||
// if (slot == joblist.getbackButton()) {
|
if (slot == joblist.getbackButton()) {
|
||||||
// player.closeInventory();
|
player.closeInventory();
|
||||||
// player.openInventory(GuiTools.CreateJobsGUI(player));
|
player.openInventory(GuiTools.CreateJobsGUI(player));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
|
||||||
// public void onGuiClose(InventoryCloseEvent event) {
|
public void onGuiClose(InventoryCloseEvent event) {
|
||||||
// if (Gui.GuiTools.GuiList.size() == 0)
|
if (GuiTools.GuiList.size() == 0)
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// Player player = (Player) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
//
|
|
||||||
// if (Gui.GuiTools.GuiList.containsKey(player.getName()))
|
if (GuiTools.GuiList.containsKey(player.getName()))
|
||||||
// Gui.GuiTools.GuiList.remove(player.getName());
|
GuiTools.GuiList.remove(player.getName());
|
||||||
// }
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
@ -253,9 +258,8 @@ public class JobsListener implements Listener {
|
|||||||
if (!(block.getState() instanceof Sign))
|
if (!(block.getState() instanceof Sign))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
Player player = (Player) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
|
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
String FirstLine = sign.getLine(0);
|
String FirstLine = sign.getLine(0);
|
||||||
if (FirstLine.equalsIgnoreCase(Language.getMessage("signs.topline")))
|
if (FirstLine.equalsIgnoreCase(Language.getMessage("signs.topline")))
|
||||||
@ -264,7 +268,7 @@ public class JobsListener implements Listener {
|
|||||||
player.sendMessage(Language.getMessage("signs.cantdestroy"));
|
player.sendMessage(Language.getMessage("signs.cantdestroy"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location loc = block.getLocation();
|
Location loc = block.getLocation();
|
||||||
|
|
||||||
for (com.gamingmesh.jobs.Signs.Sign one : SignUtil.Signs.GetAllSigns()) {
|
for (com.gamingmesh.jobs.Signs.Sign one : SignUtil.Signs.GetAllSigns()) {
|
||||||
|
@ -646,6 +646,7 @@ public class JobsPaymentListener implements Listener {
|
|||||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier, null, armor);
|
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier, null, armor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,26 @@
|
|||||||
package com.gamingmesh.jobs.stuff;
|
package com.gamingmesh.jobs.stuff;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.JobsPlugin;
|
|
||||||
import com.gamingmesh.jobs.config.ConfigManager;
|
import com.gamingmesh.jobs.config.ConfigManager;
|
||||||
|
|
||||||
public class OfflinePlayerList {
|
public class OfflinePlayerList {
|
||||||
|
|
||||||
private static HashMap<String, OfflinePlayer> map = new HashMap<String, OfflinePlayer>();
|
private static ConcurrentHashMap<String, OfflinePlayer> map = new ConcurrentHashMap<String, OfflinePlayer>();
|
||||||
private static HashMap<UUID, OfflinePlayer> uuidmap = new HashMap<UUID, OfflinePlayer>();
|
private static ConcurrentHashMap<UUID, OfflinePlayer> uuidmap = new ConcurrentHashMap<UUID, OfflinePlayer>();
|
||||||
|
|
||||||
public static void fillList() {
|
public static void fillList() {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
|
for (OfflinePlayer one : Bukkit.getOfflinePlayers()) {
|
||||||
@Override
|
if (one == null)
|
||||||
public void run() {
|
continue;
|
||||||
OfflinePlayer[] players = Bukkit.getOfflinePlayers();
|
map.put(one.getName().toLowerCase(), one);
|
||||||
for (OfflinePlayer one : players) {
|
uuidmap.put(one.getUniqueId(), one);
|
||||||
if (one == null)
|
}
|
||||||
continue;
|
return;
|
||||||
map.put(one.getName().toLowerCase(), one);
|
|
||||||
uuidmap.put(one.getUniqueId(), one);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OfflinePlayer getPlayer(UUID uuid) {
|
public static OfflinePlayer getPlayer(UUID uuid) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: Jobs
|
name: Jobs
|
||||||
description: Jobs Plugin for the BukkitAPI
|
description: Jobs Plugin for the BukkitAPI
|
||||||
main: com.gamingmesh.jobs.JobsPlugin
|
main: com.gamingmesh.jobs.JobsPlugin
|
||||||
version: 2.51.2
|
version: 2.51.4
|
||||||
author: phrstbrn
|
author: phrstbrn
|
||||||
softdepend: [Vault]
|
softdepend: [Vault]
|
||||||
commands:
|
commands:
|
||||||
|
Loading…
Reference in New Issue
Block a user