1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +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.meta.ItemMeta;
import com.gamingmesh.jobs.Signs.SignUtil;
import com.gamingmesh.jobs.config.ConfigManager;
import com.gamingmesh.jobs.container.ActionInfo;
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.JobsClassLoader;
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.DatabaseSaveThread;
public class Jobs {
public static Jobs instance = new Jobs();
// public static JobsPlugin plugin = new JobsPlugin();
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 File dataFolder;
@ -83,6 +91,54 @@ public class Jobs {
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
*/
@ -207,7 +263,7 @@ public class Jobs {
}
ConfigManager.getJobsConfiguration().reload();
Language.reload(ConfigManager.getJobsConfiguration().getLocale());
Jobs.getLanguage().reload(ConfigManager.getJobsConfiguration().getLocale());
ConfigManager.getJobConfig().reload();
usedSlots.clear();
for (Job job : jobs) {

View File

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

View File

@ -180,8 +180,8 @@ public class PlayerManager {
Jobs.getJobsDAO().joinJob(jPlayer, job);
PerformCommands.PerformCommandsOnJoin(jPlayer, job);
Jobs.takeSlot(job);
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate(job.getName());
Jobs.getSignUtil().SignUpdate("gtoplist");
job.updateTotalPlayers();
// }
}
@ -211,8 +211,8 @@ public class PlayerManager {
PerformCommands.PerformCommandsOnLeave(jPlayer, job);
Jobs.leaveSlot(job);
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate(job.getName());
Jobs.getSignUtil().SignUpdate("gtoplist");
job.updateTotalPlayers();
// }
}
@ -228,8 +228,8 @@ public class PlayerManager {
PerformCommands.PerformCommandsOnLeave(jPlayer, job.getJob());
Jobs.leaveSlot(job.getJob());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getJob().getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate(job.getJob().getName());
Jobs.getSignUtil().SignUpdate("gtoplist");
job.getJob().updateTotalPlayers();
}
@ -268,8 +268,8 @@ public class PlayerManager {
jPlayer.promoteJob(job, levels, jPlayer);
jPlayer.save(Jobs.getJobsDAO());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate(job.getName());
Jobs.getSignUtil().SignUpdate("gtoplist");
// }
}
@ -283,8 +283,8 @@ public class PlayerManager {
// synchronized (jPlayer.saveLock) {
jPlayer.demoteJob(job, levels);
jPlayer.save(Jobs.getJobsDAO());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate(job.getName());
Jobs.getSignUtil().SignUpdate("gtoplist");
// }
}
@ -304,8 +304,8 @@ public class PlayerManager {
performLevelUp(jPlayer, job, oldLevel);
jPlayer.save(Jobs.getJobsDAO());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate(job.getName());
Jobs.getSignUtil().SignUpdate("gtoplist");
// }
}
@ -323,8 +323,8 @@ public class PlayerManager {
prog.addExperience(-experience);
jPlayer.save(Jobs.getJobsDAO());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate(job.getName());
Jobs.getSignUtil().SignUpdate("gtoplist");
// }
}
@ -419,8 +419,8 @@ public class PlayerManager {
jPlayer.reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel);
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate(job.getName());
Jobs.getSignUtil().SignUpdate("gtoplist");
}
/**

View File

@ -22,15 +22,27 @@ import com.gamingmesh.jobs.i18n.Language;
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
public static void LoadSigns() {
public void LoadSigns() {
Thread threadd = new Thread() {
public void run() {
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);
if (!f.isConfigurationSection("Signs"))
@ -60,11 +72,11 @@ public class SignUtil {
}
// Signs save file
public static void saveSigns() {
public void saveSigns() {
Thread threadd = new Thread() {
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);
CommentedYamlConfiguration writer = new CommentedYamlConfiguration();
@ -98,7 +110,7 @@ public class SignUtil {
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());
for (com.gamingmesh.jobs.Signs.Sign foo : Signs.GetAllSigns()) {
Copy.add(foo);
@ -199,9 +211,9 @@ public class SignUtil {
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() {
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.OfflinePlayerList;
import com.gamingmesh.jobs.stuff.Perm;
import com.gamingmesh.jobs.stuff.Scboard;
import com.gamingmesh.jobs.stuff.Sorting;
import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.TranslateName;
public class JobsCommands implements CommandExecutor {
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) {
if (args.length == 0)
@ -1066,9 +1070,9 @@ public class JobsCommands implements CommandExecutor {
return true;
}
if (!args[0].equalsIgnoreCase("gtoplist"))
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(oldjob.getName());
Jobs.getSignUtil().SignUpdate(oldjob.getName());
else
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
Jobs.getSignUtil().SignUpdate("gtoplist");
return true;
}
@ -1135,7 +1139,7 @@ public class JobsCommands implements CommandExecutor {
}
player.setScoreboard(board);
Scboard.addNew(player);
Jobs.getScboard().addNew(player);
//player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear"));
@ -1224,7 +1228,7 @@ public class JobsCommands implements CommandExecutor {
player.setScoreboard(board);
//player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear"));
Scboard.addNew(player);
Jobs.getScboard().addNew(player);
int from = start;
if (start >= 15)
@ -1485,7 +1489,7 @@ public class JobsCommands implements CommandExecutor {
sendUsage(sender, "glog");
return true;
}
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
Map<LogAmounts, Double> unsortMap = new HashMap<LogAmounts, Double>();

View File

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

View File

@ -60,6 +60,11 @@ public abstract class JobsDAO {
private JobsConnectionPool pool;
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) {
this.prefix = prefix;
@ -492,7 +497,7 @@ public abstract class JobsDAO {
}
public void fixUuid(final CommandSender sender) {
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
JobsConnection conn = getConnection();
@ -539,7 +544,7 @@ public abstract class JobsDAO {
}
public void fixName(final CommandSender sender) {
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
JobsConnection conn = getConnection();

View File

@ -28,57 +28,62 @@ import com.gamingmesh.jobs.config.ConfigManager;
import com.gamingmesh.jobs.config.YmlMaker;
public class Language {
public static FileConfiguration enlocale;
public static FileConfiguration customlocale;
public static FileConfiguration enlocale;
public static FileConfiguration customlocale;
private JobsPlugin plugin;
static {
customlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "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(JobsPlugin plugin) {
this.plugin = plugin;
}
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;
// }
/**
* Reloads the config
*/
public static void reload(Locale locale) {
customlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "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() {
}
/**
* Get the message with the correct key
* @param key - the key of the message
* @return the message
*/
/**
* Reloads the config
*/
public void reload(Locale locale) {
customlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig();
enlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_en.yml").getConfig();
if (customlocale == null)
customlocale = enlocale;
}
/**
* Get the message with the correct key
* @param key - the key of the message
* @return the message
*/
public static String getMessage(String key) {
if (customlocale == null || !customlocale.contains(key))
return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale";
return customlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', customlocale.getString(key)) : "Cant find locale";
}
if (customlocale == null || !customlocale.contains(key))
return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale";
return customlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', customlocale.getString(key)) : "Cant find locale";
}
/**
* Get the message with the correct key
* @param key - the key of the message
* @return the message
*/
public static String getDefaultMessage(String key) {
return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale";
}
/**
* Get the message with the correct key
* @param key - the key of the message
* @return the message
*/
public static String getDefaultMessage(String key) {
return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale";
}
/**
* Check if key exists
* @param key - the key of the message
* @return true/false
*/
public static boolean containsKey(String key) {
if (customlocale == null || !customlocale.contains(key))
return enlocale.contains(key);
return customlocale.contains(key);
}
/**
* Check if key exists
* @param key - the key of the message
* @return true/false
*/
public static boolean containsKey(String key) {
if (customlocale == null || !customlocale.contains(key))
return enlocale.contains(key);
return customlocale.contains(key);
}
}

View File

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

View File

@ -931,6 +931,12 @@ public class JobsPaymentListener implements Listener {
// Calulating multiplaier
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);
// Payment for killing player with particular job, except NPC's

View File

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

View File

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

View File

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

View File

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

View File

@ -16,12 +16,28 @@ import com.gamingmesh.jobs.i18n.Language;
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)
dateByInt = TimeManage.timeInInt();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
dateByInt = TimeManage.timeInInt();
@ -32,7 +48,7 @@ public class ScheduleUtil {
}, 60 * 20L);
}
public static boolean scheduler() {
public boolean scheduler() {
if (ConfigManager.getJobsConfiguration().BoostSchedule.size() > 0 && ConfigManager.getJobsConfiguration().useGlobalBoostScheduler) {
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() {
scheduler();
return;

View File

@ -1,7 +1,7 @@
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin
version: 2.55.1
version: 2.56.0
author: phrstbrn
softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
commands: