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

Code cleaning and preventing self killing income

This commit is contained in:
Zrips 2016-01-06 15:40:27 +02:00
parent 5c715e35f8
commit 19f9175072
16 changed files with 803 additions and 691 deletions

View File

@ -33,6 +33,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.Signs.SignUtil;
import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.config.ConfigManager;
import com.gamingmesh.jobs.container.ActionInfo; import com.gamingmesh.jobs.container.ActionInfo;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
@ -47,12 +48,19 @@ import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.ActionBar; import com.gamingmesh.jobs.stuff.ActionBar;
import com.gamingmesh.jobs.stuff.JobsClassLoader; import com.gamingmesh.jobs.stuff.JobsClassLoader;
import com.gamingmesh.jobs.stuff.Loging; import com.gamingmesh.jobs.stuff.Loging;
import com.gamingmesh.jobs.stuff.Scboard;
import com.gamingmesh.jobs.stuff.ScheduleUtil;
import com.gamingmesh.jobs.tasks.BufferedPaymentThread; import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
import com.gamingmesh.jobs.tasks.DatabaseSaveThread; import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
public class Jobs { public class Jobs {
public static Jobs instance = new Jobs(); public static Jobs instance = new Jobs();
// public static JobsPlugin plugin = new JobsPlugin();
private static PlayerManager pManager = new PlayerManager(); private static PlayerManager pManager = new PlayerManager();
private static Language lManager = new Language();
private static SignUtil signManager = new SignUtil();
private static Scboard scboardManager = new Scboard();
private static ScheduleUtil scheduleManager = new ScheduleUtil();
private static Logger pLogger; private static Logger pLogger;
private static File dataFolder; private static File dataFolder;
@ -83,6 +91,54 @@ public class Jobs {
return pManager; return pManager;
} }
/**
* Returns schedule manager
* @return the schedule manager
*/
public static ScheduleUtil getSchedule() {
return scheduleManager;
}
public static void setSchedule(JobsPlugin plugin) {
scheduleManager = new ScheduleUtil(plugin);
}
/**
* Returns scoreboard manager
* @return the scoreboard manager
*/
public static Scboard getScboard() {
return scboardManager;
}
public static void setScboard(JobsPlugin plugin) {
scboardManager = new Scboard(plugin);
}
/**
* Returns sign manager
* @return the sign manager
*/
public static SignUtil getSignUtil() {
return signManager;
}
public static void setSignUtil(JobsPlugin plugin) {
signManager = new SignUtil(plugin);
}
/**
* Returns language manager
* @return the language manager
*/
public static Language getLanguage() {
return lManager;
}
public static void setLanguage(JobsPlugin plugin) {
lManager = new Language(plugin);
}
/** /**
* Sets the plugin logger * Sets the plugin logger
*/ */
@ -207,7 +263,7 @@ public class Jobs {
} }
ConfigManager.getJobsConfiguration().reload(); ConfigManager.getJobsConfiguration().reload();
Language.reload(ConfigManager.getJobsConfiguration().getLocale()); Jobs.getLanguage().reload(ConfigManager.getJobsConfiguration().getLocale());
ConfigManager.getJobConfig().reload(); ConfigManager.getJobConfig().reload();
usedSlots.clear(); usedSlots.clear();
for (Job job : jobs) { for (Job job : jobs) {

View File

@ -27,7 +27,6 @@ import net.elseland.xikage.MythicMobs.API.MythicMobsAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -42,12 +41,10 @@ import com.gamingmesh.jobs.listeners.McMMOlistener;
import com.gamingmesh.jobs.listeners.MythicMobsListener; import com.gamingmesh.jobs.listeners.MythicMobsListener;
import com.gamingmesh.jobs.listeners.PistonProtectionListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener;
import com.gamingmesh.jobs.stuff.OfflinePlayerList; import com.gamingmesh.jobs.stuff.OfflinePlayerList;
import com.gamingmesh.jobs.stuff.ScheduleUtil;
import com.gamingmesh.jobs.stuff.TabComplete; import com.gamingmesh.jobs.stuff.TabComplete;
import com.gamingmesh.jobs.config.YmlMaker; import com.gamingmesh.jobs.config.YmlMaker;
public class JobsPlugin extends JavaPlugin { public class JobsPlugin extends JavaPlugin {
public static Plugin instance;
public static CoreProtectAPI CPAPI; public static CoreProtectAPI CPAPI;
public static MythicMobsAPI MMAPI; public static MythicMobsAPI MMAPI;
public static boolean CPPresent = false; public static boolean CPPresent = false;
@ -96,7 +93,6 @@ public class JobsPlugin extends JavaPlugin {
this.setEnabled(false); this.setEnabled(false);
} }
instance = this;
OfflinePlayerList.fillList(); OfflinePlayerList.fillList();
YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml"); YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml");
jobConfig.saveDefaultConfig(); jobConfig.saveDefaultConfig();
@ -109,6 +105,11 @@ public class JobsPlugin extends JavaPlugin {
Jobs.setPermissionHandler(new PermissionHandler(this)); Jobs.setPermissionHandler(new PermissionHandler(this));
Jobs.setSignUtil(this);
Jobs.setScboard(this);
Jobs.setSchedule(this);
Jobs.setLanguage(this);
Jobs.setPluginLogger(getLogger()); Jobs.setPluginLogger(getLogger());
Jobs.setDataFolder(getDataFolder()); Jobs.setDataFolder(getDataFolder());
@ -116,7 +117,7 @@ public class JobsPlugin extends JavaPlugin {
ConfigManager.registerJobsConfiguration(new JobsConfiguration(this)); ConfigManager.registerJobsConfiguration(new JobsConfiguration(this));
ConfigManager.registerJobConfig(new JobConfig(this)); ConfigManager.registerJobConfig(new JobConfig(this));
getCommand("jobs").setExecutor(new JobsCommands()); getCommand("jobs").setExecutor(new JobsCommands(this));
this.getCommand("jobs").setTabCompleter(new TabComplete()); this.getCommand("jobs").setTabCompleter(new TabComplete());
@ -154,12 +155,13 @@ public class JobsPlugin extends JavaPlugin {
// all loaded properly. // all loaded properly.
if (ConfigManager.getJobsConfiguration().useGlobalBoostScheduler) if (ConfigManager.getJobsConfiguration().useGlobalBoostScheduler)
ScheduleUtil.scheduler(); Jobs.getSchedule().scheduler();
ScheduleUtil.DateUpdater(); Jobs.getSchedule().DateUpdater();
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6Plugin has been enabled succesfully."); String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6Plugin has been enabled succesfully.");
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message); console.sendMessage(message);
Jobs.getLanguage().reload(ConfigManager.getJobsConfiguration().getLocale());
} }
@Override @Override

View File

@ -180,8 +180,8 @@ public class PlayerManager {
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()); Jobs.getSignUtil().SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
job.updateTotalPlayers(); job.updateTotalPlayers();
// } // }
} }
@ -211,8 +211,8 @@ public class PlayerManager {
PerformCommands.PerformCommandsOnLeave(jPlayer, job); PerformCommands.PerformCommandsOnLeave(jPlayer, job);
Jobs.leaveSlot(job); Jobs.leaveSlot(job);
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName()); Jobs.getSignUtil().SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
job.updateTotalPlayers(); job.updateTotalPlayers();
// } // }
} }
@ -228,8 +228,8 @@ public class PlayerManager {
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()); Jobs.getSignUtil().SignUpdate(job.getJob().getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
job.getJob().updateTotalPlayers(); job.getJob().updateTotalPlayers();
} }
@ -268,8 +268,8 @@ public class PlayerManager {
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()); Jobs.getSignUtil().SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
// } // }
} }
@ -283,8 +283,8 @@ public class PlayerManager {
// 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()); Jobs.getSignUtil().SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
// } // }
} }
@ -304,8 +304,8 @@ public class PlayerManager {
performLevelUp(jPlayer, job, oldLevel); performLevelUp(jPlayer, job, oldLevel);
jPlayer.save(Jobs.getJobsDAO()); jPlayer.save(Jobs.getJobsDAO());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName()); Jobs.getSignUtil().SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
// } // }
} }
@ -323,8 +323,8 @@ public class PlayerManager {
prog.addExperience(-experience); prog.addExperience(-experience);
jPlayer.save(Jobs.getJobsDAO()); jPlayer.save(Jobs.getJobsDAO());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName()); Jobs.getSignUtil().SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
// } // }
} }
@ -419,8 +419,8 @@ public class PlayerManager {
jPlayer.reloadHonorific(); jPlayer.reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer); Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel); performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel);
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName()); Jobs.getSignUtil().SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
} }
/** /**

View File

@ -22,15 +22,27 @@ import com.gamingmesh.jobs.i18n.Language;
public class SignUtil { public class SignUtil {
public static SignInfo Signs = new SignInfo(); public SignUtil() {
}
public SignInfo Signs = new SignInfo();
private JobsPlugin plugin;
public SignUtil(JobsPlugin plugin) {
this.plugin = plugin;
}
public SignInfo getSigns(){
return Signs;
}
// Sign file // Sign file
public static void LoadSigns() { public void LoadSigns() {
Thread threadd = new Thread() { Thread threadd = new Thread() {
public void run() { public void run() {
Signs.GetAllSigns().clear(); Signs.GetAllSigns().clear();
File file = new File(JobsPlugin.instance.getDataFolder(), "Signs.yml"); File file = new File(plugin.getDataFolder(), "Signs.yml");
YamlConfiguration f = YamlConfiguration.loadConfiguration(file); YamlConfiguration f = YamlConfiguration.loadConfiguration(file);
if (!f.isConfigurationSection("Signs")) if (!f.isConfigurationSection("Signs"))
@ -60,11 +72,11 @@ public class SignUtil {
} }
// Signs save file // Signs save file
public static void saveSigns() { public void saveSigns() {
Thread threadd = new Thread() { Thread threadd = new Thread() {
public void run() { public void run() {
File f = new File(JobsPlugin.instance.getDataFolder(), "Signs.yml"); File f = new File(plugin.getDataFolder(), "Signs.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); CommentedYamlConfiguration writer = new CommentedYamlConfiguration();
@ -98,7 +110,7 @@ public class SignUtil {
threadd.start(); threadd.start();
} }
public static boolean SignUpdate(String JobName) { public boolean SignUpdate(String JobName) {
List<com.gamingmesh.jobs.Signs.Sign> Copy = new ArrayList<com.gamingmesh.jobs.Signs.Sign>(Signs.GetAllSigns().size()); List<com.gamingmesh.jobs.Signs.Sign> Copy = new ArrayList<com.gamingmesh.jobs.Signs.Sign>(Signs.GetAllSigns().size());
for (com.gamingmesh.jobs.Signs.Sign foo : Signs.GetAllSigns()) { for (com.gamingmesh.jobs.Signs.Sign foo : Signs.GetAllSigns()) {
Copy.add(foo); Copy.add(foo);
@ -199,9 +211,9 @@ public class SignUtil {
return true; return true;
} }
public static void UpdateHead(final Location loc, final String Playername, final int timelapse) { public void UpdateHead(final Location loc, final String Playername, final int timelapse) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() { public void run() {
loc.setY(loc.getY() + 1); loc.setY(loc.getY() + 1);

View File

@ -62,13 +62,17 @@ import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.GiveItem; import com.gamingmesh.jobs.stuff.GiveItem;
import com.gamingmesh.jobs.stuff.OfflinePlayerList; import com.gamingmesh.jobs.stuff.OfflinePlayerList;
import com.gamingmesh.jobs.stuff.Perm; import com.gamingmesh.jobs.stuff.Perm;
import com.gamingmesh.jobs.stuff.Scboard;
import com.gamingmesh.jobs.stuff.Sorting; import com.gamingmesh.jobs.stuff.Sorting;
import com.gamingmesh.jobs.stuff.TimeManage; import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.TranslateName; import com.gamingmesh.jobs.stuff.TranslateName;
public class JobsCommands implements CommandExecutor { public class JobsCommands implements CommandExecutor {
private static final String label = "jobs"; private static final String label = "jobs";
private JobsPlugin plugin;
public JobsCommands(JobsPlugin plugin) {
this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) if (args.length == 0)
@ -1066,9 +1070,9 @@ public class JobsCommands implements CommandExecutor {
return true; return true;
} }
if (!args[0].equalsIgnoreCase("gtoplist")) if (!args[0].equalsIgnoreCase("gtoplist"))
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(oldjob.getName()); Jobs.getSignUtil().SignUpdate(oldjob.getName());
else else
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
return true; return true;
} }
@ -1135,7 +1139,7 @@ public class JobsCommands implements CommandExecutor {
} }
player.setScoreboard(board); player.setScoreboard(board);
Scboard.addNew(player); Jobs.getScboard().addNew(player);
//player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear")); //player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear"));
@ -1224,7 +1228,7 @@ public class JobsCommands implements CommandExecutor {
player.setScoreboard(board); player.setScoreboard(board);
//player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear")); //player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear"));
Scboard.addNew(player); Jobs.getScboard().addNew(player);
int from = start; int from = start;
if (start >= 15) if (start >= 15)
@ -1485,7 +1489,7 @@ public class JobsCommands implements CommandExecutor {
sendUsage(sender, "glog"); sendUsage(sender, "glog");
return true; return true;
} }
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
Map<LogAmounts, Double> unsortMap = new HashMap<LogAmounts, Double>(); Map<LogAmounts, Double> unsortMap = new HashMap<LogAmounts, Double>();

View File

@ -264,8 +264,8 @@ public class JobsConfiguration {
loadRestrictedBlocks(); loadRestrictedBlocks();
// Item/Block/mobs name list // Item/Block/mobs name list
loadItemList(); loadItemList();
// Item/Block/mobs name list // signs information
com.gamingmesh.jobs.Signs.SignUtil.LoadSigns(); Jobs.getSignUtil().LoadSigns();
// loadScheduler(); // loadScheduler();
} }
@ -1100,7 +1100,7 @@ public class JobsConfiguration {
} }
private synchronized void loadItemList() { private synchronized void loadItemList() {
YmlMaker ItemFile = new YmlMaker((JavaPlugin) JobsPlugin.instance, "ItemList.yml"); YmlMaker ItemFile = new YmlMaker((JavaPlugin) plugin, "ItemList.yml");
ItemFile.saveDefaultConfig(); ItemFile.saveDefaultConfig();
List<String> section = ItemFile.getConfig().getStringList("ItemList"); List<String> section = ItemFile.getConfig().getStringList("ItemList");
ListOfNames.clear(); ListOfNames.clear();
@ -1208,7 +1208,7 @@ public class JobsConfiguration {
languages.add("ru"); languages.add("ru");
for (String lang : languages) { for (String lang : languages) {
YmlMaker langFile = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale" + File.separator + "messages_" + lang + ".yml"); YmlMaker langFile = new YmlMaker((JavaPlugin) plugin, "locale" + File.separator + "messages_" + lang + ".yml");
if (langFile != null) if (langFile != null)
langFile.saveDefaultConfig(); langFile.saveDefaultConfig();
} }

View File

@ -60,6 +60,11 @@ public abstract class JobsDAO {
private JobsConnectionPool pool; private JobsConnectionPool pool;
private String prefix; private String prefix;
private JobsPlugin plugin;
public JobsDAO(JobsPlugin plugin) {
this.plugin = plugin;
}
protected JobsDAO(String driverName, String url, String username, String password, String prefix) { protected JobsDAO(String driverName, String url, String username, String password, String prefix) {
this.prefix = prefix; this.prefix = prefix;
@ -492,7 +497,7 @@ public abstract class JobsDAO {
} }
public void fixUuid(final CommandSender sender) { public void fixUuid(final CommandSender sender) {
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
JobsConnection conn = getConnection(); JobsConnection conn = getConnection();
@ -539,7 +544,7 @@ public abstract class JobsDAO {
} }
public void fixName(final CommandSender sender) { public void fixName(final CommandSender sender) {
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
JobsConnection conn = getConnection(); JobsConnection conn = getConnection();

View File

@ -30,23 +30,28 @@ import com.gamingmesh.jobs.config.YmlMaker;
public class Language { public class Language {
public static FileConfiguration enlocale; public static FileConfiguration enlocale;
public static FileConfiguration customlocale; public static FileConfiguration customlocale;
private JobsPlugin plugin;
static { public Language(JobsPlugin plugin) {
customlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig(); this.plugin = plugin;
enlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_en.yml").getConfig();
if (customlocale == null)
customlocale = enlocale;
} }
private Language() { // static {
// customlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig();
// enlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_en.yml").getConfig();
// if (customlocale == null)
// customlocale = enlocale;
// }
public Language() {
} }
/** /**
* Reloads the config * Reloads the config
*/ */
public static void reload(Locale locale) { public void reload(Locale locale) {
customlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig(); customlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig();
enlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_en.yml").getConfig(); enlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_en.yml").getConfig();
if (customlocale == null) if (customlocale == null)
customlocale = enlocale; customlocale = enlocale;
} }

View File

@ -53,7 +53,6 @@ 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.GuiInfoList;
import com.gamingmesh.jobs.Gui.GuiTools; import com.gamingmesh.jobs.Gui.GuiTools;
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;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
@ -229,7 +228,7 @@ public class JobsListener implements Listener {
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 : Jobs.getSignUtil().getSigns().GetAllSigns()) {
if (one.GetX() != loc.getBlockX()) if (one.GetX() != loc.getBlockX())
continue; continue;
@ -244,8 +243,8 @@ public class JobsListener implements Listener {
return; return;
} }
SignUtil.Signs.removeSign(one); Jobs.getSignUtil().getSigns().removeSign(one);
SignUtil.saveSigns(); Jobs.getSignUtil().saveSigns();
break; break;
} }
} }
@ -310,8 +309,8 @@ public class JobsListener implements Listener {
Location loc = sign.getLocation(); Location loc = sign.getLocation();
int category = 1; int category = 1;
if (com.gamingmesh.jobs.Signs.SignUtil.Signs.GetAllSigns().size() > 0) if (Jobs.getSignUtil().getSigns().GetAllSigns().size() > 0)
category = com.gamingmesh.jobs.Signs.SignUtil.Signs.GetAllSigns().get(com.gamingmesh.jobs.Signs.SignUtil.Signs.GetAllSigns().size() - 1).GetCategory() + 1; category = Jobs.getSignUtil().getSigns().GetAllSigns().get(Jobs.getSignUtil().getSigns().GetAllSigns().size() - 1).GetCategory() + 1;
signInfo.setNumber(Number); signInfo.setNumber(Number);
signInfo.setWorld(loc.getWorld().getName()); signInfo.setWorld(loc.getWorld().getName());
signInfo.setX(loc.getX()); signInfo.setX(loc.getX());
@ -324,16 +323,16 @@ public class JobsListener implements Listener {
signInfo.setJobName("gtoplist"); signInfo.setJobName("gtoplist");
signInfo.setSpecial(special); signInfo.setSpecial(special);
com.gamingmesh.jobs.Signs.SignUtil.Signs.addSign(signInfo); Jobs.getSignUtil().getSigns().addSign(signInfo);
com.gamingmesh.jobs.Signs.SignUtil.saveSigns(); Jobs.getSignUtil().saveSigns();
event.setCancelled(true); event.setCancelled(true);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() { public void run() {
if (!signtype.equalsIgnoreCase("gtoplist")) if (!signtype.equalsIgnoreCase("gtoplist"))
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName()); Jobs.getSignUtil().SignUpdate(job.getName());
else else
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist"); Jobs.getSignUtil().SignUpdate("gtoplist");
return; return;
} }
}, 1L); }, 1L);
@ -466,7 +465,7 @@ public class JobsListener implements Listener {
if (!ConfigManager.getJobsConfiguration().WaterBlockBreake) if (!ConfigManager.getJobsConfiguration().WaterBlockBreake)
return; return;
if (event.getBlock().getState().hasMetadata(JobsPaymentListener.PlacedBlockMetadata)) { if (event.getBlock().getState().hasMetadata(JobsPaymentListener.PlacedBlockMetadata)) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() { public void run() {
event.getBlock().getState().removeMetadata(JobsPaymentListener.PlacedBlockMetadata, plugin); event.getBlock().getState().removeMetadata(JobsPaymentListener.PlacedBlockMetadata, plugin);
return; return;

View File

@ -931,6 +931,12 @@ public class JobsPaymentListener implements Listener {
// Calulating multiplaier // Calulating multiplaier
multiplier = multiplier * NearSpawnerMultiplier * PetPayMultiplier; multiplier = multiplier * NearSpawnerMultiplier * PetPayMultiplier;
if (lVictim instanceof Player && !lVictim.hasMetadata("NPC")) {
Player VPlayer = (Player) lVictim;
if (jDamager.getUserName().equalsIgnoreCase(VPlayer.getName()))
return;
}
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), multiplier, item, armor); Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), multiplier, item, armor);
// Payment for killing player with particular job, except NPC's // Payment for killing player with particular job, except NPC's

View File

@ -19,7 +19,7 @@ import com.gamingmesh.jobs.i18n.Language;
* @author hamzaxx * @author hamzaxx
*/ */
public class ActionBar { public class ActionBar {
private static int cleanVersion = 182; private static int cleanVersion = 1820;
private static String version = ""; private static String version = "";
private static Object packet; private static Object packet;
private static Method getHandle; private static Method getHandle;
@ -39,21 +39,24 @@ public class ActionBar {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// Fail save if it for some reason can't translate version to integer // Fail save if it for some reason can't translate version to integer
if (version.contains("v1_7")) if (version.contains("v1_7"))
cleanVersion = 170; cleanVersion = 1700;
if (version.contains("v1_6")) if (version.contains("v1_6"))
cleanVersion = 160; cleanVersion = 1600;
if (version.contains("v1_5")) if (version.contains("v1_5"))
cleanVersion = 150; cleanVersion = 1500;
if (version.contains("v1_4")) if (version.contains("v1_4"))
cleanVersion = 140; cleanVersion = 1400;
if (version.contains("v1_8_R1")) if (version.contains("v1_8_R1"))
cleanVersion = 181; cleanVersion = 1810;
if (version.contains("v1_8_R2")) if (version.contains("v1_8_R2"))
cleanVersion = 182; cleanVersion = 1820;
if (version.contains("v1_8_R3")) if (version.contains("v1_8_R3"))
cleanVersion = 183; cleanVersion = 1830;
} }
if (cleanVersion < 1000)
cleanVersion = cleanVersion * 10;
packetType = Class.forName(getPacketPlayOutChat()); packetType = Class.forName(getPacketPlayOutChat());
Class<?> typeCraftPlayer = Class.forName(getCraftPlayerClasspath()); Class<?> typeCraftPlayer = Class.forName(getCraftPlayerClasspath());
Class<?> typeNMSPlayer = Class.forName(getNMSPlayerClasspath()); Class<?> typeNMSPlayer = Class.forName(getNMSPlayerClasspath());
@ -80,8 +83,8 @@ public class ActionBar {
Player abp = (Player) payment.getOfflinePlayer(); Player abp = (Player) payment.getOfflinePlayer();
if (abp != null && show) { if (abp != null && show) {
String Message = Language.getMessage("command.toggle.output.paid"); String Message = Language.getMessage("command.toggle.output.paid");
Message = Message.replace("[amount]", String.valueOf((((int) (payment.getAmount() * 100)) / 100.0))); Message = Message.replace("[amount]", String.format("%.2f", payment.getAmount()));
Message = Message.replace("[exp]", String.valueOf((((int) (payment.getExp() * 100)) / 100.0))); Message = Message.replace("[exp]", String.format("%.2f", payment.getExp()));
ActionBar.send(abp, ChatColor.GREEN + Message); ActionBar.send(abp, ChatColor.GREEN + Message);
} }
} }
@ -92,13 +95,13 @@ public class ActionBar {
if (msg == null || nmsChatSerializer == null) if (msg == null || nmsChatSerializer == null)
return; return;
if (cleanVersion < 180) { if (cleanVersion < 1800) {
receivingPacket.sendMessage(ChatColor.translateAlternateColorCodes('&', msg)); receivingPacket.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
return; return;
} }
Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', msg) + "\"}"); Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', msg) + "\"}");
if (cleanVersion > 180) { if (cleanVersion > 1800) {
packet = packetType.getConstructor(nmsIChatBaseComponent, byte.class).newInstance(serialized, (byte) 2); packet = packetType.getConstructor(nmsIChatBaseComponent, byte.class).newInstance(serialized, (byte) 2);
} else { } else {
packet = packetType.getConstructor(nmsIChatBaseComponent, int.class).newInstance(serialized, 2); packet = packetType.getConstructor(nmsIChatBaseComponent, int.class).newInstance(serialized, 2);
@ -141,7 +144,7 @@ public class ActionBar {
private static String getChatSerializerClasspath() { private static String getChatSerializerClasspath() {
if (cleanVersion < 182) { if (cleanVersion < 1820) {
return "net.minecraft.server." + version + ".ChatSerializer"; return "net.minecraft.server." + version + ".ChatSerializer";
} else { } else {
return "net.minecraft.server." + version + ".IChatBaseComponent$ChatSerializer";// 1_8_R2 moved to IChatBaseComponent return "net.minecraft.server." + version + ".IChatBaseComponent$ChatSerializer";// 1_8_R2 moved to IChatBaseComponent

View File

@ -6,13 +6,10 @@ import org.bukkit.entity.Player;
public class Debug { public class Debug {
public static void D(String message) { public static void D(String message) {
Player player = Bukkit.getPlayer("Zrips"); Player player = Bukkit.getPlayer("Zrips");
if (player == null) if (player == null)
return; return;
player.sendMessage(ChatColor.DARK_GRAY + "[Debug] " + ChatColor.DARK_AQUA + ChatColor.translateAlternateColorCodes('&', message)); player.sendMessage(ChatColor.DARK_GRAY + "[Debug] " + ChatColor.DARK_AQUA + ChatColor.translateAlternateColorCodes('&', message));
return; return;
} }
} }

View File

@ -17,9 +17,9 @@ public class Loging {
List<Log> logList = jPlayer.getLog(); List<Log> logList = jPlayer.getLog();
boolean found = false; boolean found = false;
if (jPlayer.getLog().size() > 0 && ScheduleUtil.dateByInt != jPlayer.getLog().get(0).getDate()) { if (jPlayer.getLog().size() > 0 && Jobs.getSchedule().getDateByInt() != jPlayer.getLog().get(0).getDate()) {
ScheduleUtil.dateByInt = TimeManage.timeInInt(); Jobs.getSchedule().setDateByInt(TimeManage.timeInInt());
if (ScheduleUtil.dateByInt != jPlayer.getLog().get(0).getDate()) { if (Jobs.getSchedule().getDateByInt() != jPlayer.getLog().get(0).getDate()) {
Jobs.getJobsDAO().saveLog(jPlayer); Jobs.getJobsDAO().saveLog(jPlayer);
jPlayer.getLog().clear(); jPlayer.getLog().clear();
} }

View File

@ -13,10 +13,17 @@ import com.gamingmesh.jobs.config.ConfigManager;
public class Scboard { public class Scboard {
private static ConcurrentHashMap<String, Long> timerMap = new ConcurrentHashMap<String, Long>(); private ConcurrentHashMap<String, Long> timerMap = new ConcurrentHashMap<String, Long>();
private JobsPlugin plugin;
private static void RunScheduler() { public Scboard() {
}
public Scboard(JobsPlugin plugin) {
this.plugin = plugin;
}
private void RunScheduler() {
Iterator<Entry<String, Long>> MeinMapIter = timerMap.entrySet().iterator(); Iterator<Entry<String, Long>> MeinMapIter = timerMap.entrySet().iterator();
while (MeinMapIter.hasNext()) { while (MeinMapIter.hasNext()) {
Entry<String, Long> Map = MeinMapIter.next(); Entry<String, Long> Map = MeinMapIter.next();
@ -31,7 +38,7 @@ public class Scboard {
} }
if (timerMap.size() > 0) if (timerMap.size() > 0)
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() { public void run() {
RunScheduler(); RunScheduler();
return; return;
@ -40,7 +47,7 @@ public class Scboard {
return; return;
} }
public static void addNew(Player player) { public void addNew(Player player) {
timerMap.put(player.getName(), System.currentTimeMillis()); timerMap.put(player.getName(), System.currentTimeMillis());
RunScheduler(); RunScheduler();
} }

View File

@ -16,12 +16,28 @@ import com.gamingmesh.jobs.i18n.Language;
public class ScheduleUtil { public class ScheduleUtil {
public static int dateByInt = 0; public int dateByInt = 0;
public static void DateUpdater() { private JobsPlugin plugin;
public ScheduleUtil() {
}
public ScheduleUtil(JobsPlugin plugin) {
this.plugin = plugin;
}
public int getDateByInt(){
return dateByInt;
}
public void setDateByInt(int time){
dateByInt = time;
}
public void DateUpdater() {
if (dateByInt == 0) if (dateByInt == 0)
dateByInt = TimeManage.timeInInt(); dateByInt = TimeManage.timeInInt();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() { public void run() {
dateByInt = TimeManage.timeInInt(); dateByInt = TimeManage.timeInInt();
@ -32,7 +48,7 @@ public class ScheduleUtil {
}, 60 * 20L); }, 60 * 20L);
} }
public static boolean scheduler() { public boolean scheduler() {
if (ConfigManager.getJobsConfiguration().BoostSchedule.size() > 0 && ConfigManager.getJobsConfiguration().useGlobalBoostScheduler) { if (ConfigManager.getJobsConfiguration().BoostSchedule.size() > 0 && ConfigManager.getJobsConfiguration().useGlobalBoostScheduler) {
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
@ -99,7 +115,7 @@ public class ScheduleUtil {
} }
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() { public void run() {
scheduler(); scheduler();
return; return;

View File

@ -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.55.1 version: 2.56.0
author: phrstbrn author: phrstbrn
softdepend: [Vault, CoreProtect, MythicMobs, McMMO] softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
commands: commands: