diff --git a/.classpath b/.classpath index e92c2d02..1e8eb336 100644 --- a/.classpath +++ b/.classpath @@ -5,7 +5,7 @@ - + diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index 52a9ac6e..7a9e413e 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -181,7 +181,7 @@ public class Jobs { } public static void setPlayerManager(JobsPlugin jobsPlugin) { - pManager = new PlayerManager (jobsPlugin); + pManager = new PlayerManager(jobsPlugin); } public static void setRestrictedBlockManager(JobsPlugin plugin) { @@ -776,12 +776,11 @@ public class Jobs { Double income = jobinfo.getIncome(level, numjobs); Double points = jobinfo.getPoints(level, numjobs); - - if (income == 0D && points == 0D) - continue; - Double exp = jobinfo.getExperience(level, numjobs); + if (income == 0D && points == 0D && exp == 0D) + continue; + if (Jobs.getGCManager().addXpPlayer()) { Player player = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()); if (player != null) { @@ -873,12 +872,12 @@ public class Jobs { expAmount = 0D; } - if ((amount == 0D || pointAmount == 0D) && expAmount == 0D) + if (amount == 0D && pointAmount == 0D && expAmount == 0D) continue; - if (Jobs.getGCManager().BossBarEnabled && Jobs.getGCManager().BossBarShowOnEachAction) + if (Jobs.getGCManager().BossBarEnabled && Jobs.getGCManager().BossBarShowOnEachAction){ Jobs.getBBManager().ShowJobProgression(jPlayer, prog); - else if (Jobs.getGCManager().BossBarEnabled && !Jobs.getGCManager().BossBarShowOnEachAction) + }else if (Jobs.getGCManager().BossBarEnabled && !Jobs.getGCManager().BossBarShowOnEachAction) jPlayer.getUpdateBossBarFor().add(prog.getJob().getName()); Jobs.getEconomy().pay(jPlayer, amount, pointAmount, expAmount); diff --git a/com/gamingmesh/jobs/JobsPlugin.java b/com/gamingmesh/jobs/JobsPlugin.java index ba7ab173..d9510814 100644 --- a/com/gamingmesh/jobs/JobsPlugin.java +++ b/com/gamingmesh/jobs/JobsPlugin.java @@ -95,7 +95,7 @@ public class JobsPlugin extends JavaPlugin { Jobs.setPermissionHandler(new PermissionHandler(this)); Jobs.setPlayerManager(this); - + Jobs.setScboard(this); Jobs.setLanguage(this); Jobs.setGUIManager(this); diff --git a/com/gamingmesh/jobs/commands/JobsCommands.java b/com/gamingmesh/jobs/commands/JobsCommands.java index c0feeb57..af62bf28 100644 --- a/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/com/gamingmesh/jobs/commands/JobsCommands.java @@ -460,6 +460,9 @@ public class JobsCommands implements CommandExecutor { points = points + (points * finalBoost.getPointsBoost() / 100); String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString(); + if (income == 0D && points == 0D && xp == 0D) + continue; + message.append(" "); message.append(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", materialName)); diff --git a/com/gamingmesh/jobs/commands/list/.gitignore b/com/gamingmesh/jobs/commands/list/.gitignore index afb25108..53e3466a 100644 --- a/com/gamingmesh/jobs/commands/list/.gitignore +++ b/com/gamingmesh/jobs/commands/list/.gitignore @@ -44,3 +44,4 @@ /bonus.class /editpoints.class /blockinfo.class +/test.class diff --git a/com/gamingmesh/jobs/config/ConfigManager.java b/com/gamingmesh/jobs/config/ConfigManager.java index 8192d238..9792871c 100644 --- a/com/gamingmesh/jobs/config/ConfigManager.java +++ b/com/gamingmesh/jobs/config/ConfigManager.java @@ -551,13 +551,7 @@ public class ConfigManager { Jobs.getGCManager().setTntFinder(true); double income = section.getDouble("income", 0.0); - if (income == 0) - incomeEquation = new Parser("0"); - double points = section.getDouble("points", 0.0); - if (points == 0) - pointsEquation = new Parser("0"); - double experience = section.getDouble("experience", 0.0); int fromlevel = 1; diff --git a/com/gamingmesh/jobs/config/GeneralConfigManager.java b/com/gamingmesh/jobs/config/GeneralConfigManager.java index 5534ff6c..22395420 100644 --- a/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -62,6 +62,9 @@ public class GeneralConfigManager { public boolean LocalOfflinePlayersData; public boolean MythicMobsEnabled; public boolean LoggingUse; + public boolean PaymentMethodsMoney; + public boolean PaymentMethodsPoints; + public boolean PaymentMethodsExp; // Money limit public boolean MoneyLimitUse; @@ -480,6 +483,13 @@ public class GeneralConfigManager { c.getW().addComment("economy-async", "Enable async economy calls.", "Disable this if you have issues with payments or your plugin is not thread safe."); economyAsync = c.get("economy-async", true); + c.getW().addComment("Economy.PaymentMethods", + "By disabling one of thies, players no longer will get particular payment.", + "Usefull for removing particular payment method without editing whole jobConfig file"); + PaymentMethodsMoney = c.get("Economy.PaymentMethods.Money", true); + PaymentMethodsPoints = c.get("Economy.PaymentMethods.Points", true); + PaymentMethodsExp = c.get("Economy.PaymentMethods.Exp", true); + c.getW().addComment("Economy.MinimumOveralPayment.use", "Determines minimum payment. In example if player uses McMMO treefeller and earns only 20%, but at same time he gets 25% penalty from dynamic payment. He can 'get' negative amount of money", "This will limit it to particular percentage", "Works only when original payment is above 0"); diff --git a/com/gamingmesh/jobs/config/NameTranslatorManager.java b/com/gamingmesh/jobs/config/NameTranslatorManager.java index d2efe2be..e44e7121 100644 --- a/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -886,9 +886,9 @@ public class NameTranslatorManager { c.get("ItemList.179.MCName", "red_sandstone"); c.get("ItemList.179.Name", "Red Sandstone"); c.get("ItemList.179:1.MCName", "red_sandstone"); - c.get("ItemList.179:1.Name", "Smooth Red Sandstone"); + c.get("ItemList.179:1.Name", "Chiseled Red Sandstone"); c.get("ItemList.179:2.MCName", "red_sandstone"); - c.get("ItemList.179:2.Name", "Chiseled Red Sandstone"); + c.get("ItemList.179:2.Name", "Smooth Red Sandstone"); c.get("ItemList.180.MCName", "red_sandstone_stairs"); c.get("ItemList.180.Name", "Red Sandstone Stairs"); c.get("ItemList.181.MCName", "stone_slab2"); @@ -943,6 +943,8 @@ public class NameTranslatorManager { c.get("ItemList.205.Name", "Purpur Slab"); c.get("ItemList.206.MCName", "end_bricks"); c.get("ItemList.206.Name", "End Stone Bricks"); + c.get("ItemList.207.MCName", "beetroots"); + c.get("ItemList.207.Name", "Beetroot Block"); c.get("ItemList.208.MCName", "grass_path"); c.get("ItemList.208.Name", "Grass Path"); c.get("ItemList.209.MCName", "end_gateway"); @@ -1453,6 +1455,8 @@ public class NameTranslatorManager { c.get("ItemList.2267.Name", "Wait Disc"); // Entity list + c.get("EntityList.-1.MCName", "Player"); + c.get("EntityList.-1.Name", "Player"); c.get("EntityList.50.MCName", "Creeper"); c.get("EntityList.50.Name", "Creeper"); c.get("EntityList.51.MCName", "Skeleton"); @@ -1497,8 +1501,8 @@ public class NameTranslatorManager { c.get("EntityList.68.Name", "Guardian"); c.get("EntityList.68:1.MCName", "Guardian"); c.get("EntityList.68:1.Name", "Elder Guardian"); - c.get("EntityList.68.MCName", "Shulker"); - c.get("EntityList.68.Name", "Shulker"); + c.get("EntityList.69.MCName", "Shulker"); + c.get("EntityList.69.Name", "Shulker"); c.get("EntityList.90.MCName", "Pig"); c.get("EntityList.90.Name", "Pig"); c.get("EntityList.91.MCName", "Sheep"); @@ -1525,6 +1529,8 @@ public class NameTranslatorManager { c.get("EntityList.101.Name", "Rabbit"); c.get("EntityList.120.MCName", "Villager"); c.get("EntityList.120.Name", "Villager"); + c.get("EntityList.200.MCName", "EnderCrystal"); + c.get("EntityList.200.Name", "Ender Crystal"); // Enchant list c.get("EnchantList.0.MCName", "PROTECTION_ENVIRONMENTAL"); diff --git a/com/gamingmesh/jobs/container/JobInfo.java b/com/gamingmesh/jobs/container/JobInfo.java index cf64bc74..18828ae6 100644 --- a/com/gamingmesh/jobs/container/JobInfo.java +++ b/com/gamingmesh/jobs/container/JobInfo.java @@ -18,6 +18,7 @@ package com.gamingmesh.jobs.container; +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.resources.jfep.Parser; public class JobInfo { @@ -88,6 +89,8 @@ public class JobInfo { } public double getIncome(double level, double numjobs) { + if (baseIncome == 0 || !Jobs.getGCManager().PaymentMethodsMoney) + return 0; moneyEquation.setVariable("joblevel", level); moneyEquation.setVariable("numjobs", numjobs); moneyEquation.setVariable("baseincome", baseIncome); @@ -95,6 +98,8 @@ public class JobInfo { } public double getExperience(double level, double numjobs) { + if (baseXp == 0 || !Jobs.getGCManager().PaymentMethodsExp) + return 0; xpEquation.setVariable("joblevel", level); xpEquation.setVariable("numjobs", numjobs); xpEquation.setVariable("baseexperience", baseXp); @@ -102,6 +107,8 @@ public class JobInfo { } public double getPoints(double level, double numjobs) { + if (basePoints == 0 || !Jobs.getGCManager().PaymentMethodsPoints) + return 0; pointsEquation.setVariable("joblevel", level); pointsEquation.setVariable("numjobs", numjobs); pointsEquation.setVariable("basepoints", basePoints); diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index 41a6f3a7..9b747d6c 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -31,7 +31,6 @@ import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.dao.JobsDAOData; import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.stuff.ChatColor; -import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.Perm; public class JobsPlayer { @@ -595,7 +594,6 @@ public class JobsPlayer { */ public void save(JobsDAO dao) { // synchronized (saveLock) { - Debug.D("saved: " + isSaved); if (!isSaved()) { dao.save(this); dao.saveLog(this); @@ -642,7 +640,6 @@ public class JobsPlayer { } public void setSaved(boolean value) { - Debug.D("setting saved " + value); isSaved = value; } } diff --git a/com/gamingmesh/jobs/dao/JobsDAO.java b/com/gamingmesh/jobs/dao/JobsDAO.java index 08eeff24..81e64400 100644 --- a/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/com/gamingmesh/jobs/dao/JobsDAO.java @@ -43,7 +43,6 @@ import com.gamingmesh.jobs.container.LogAmounts; import com.gamingmesh.jobs.container.PlayerInfo; import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.container.TopList; -import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.Loging; import com.gamingmesh.jobs.stuff.TimeManage; @@ -643,7 +642,6 @@ public abstract class JobsDAO { if (conn == null) return; try { - Debug.D("saving points"); PlayerPoints pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getPlayerUUID()); String req = "UPDATE `" + prefix + "points` SET `totalpoints` = ?, `currentpoints` = ? WHERE `userid` = ?;"; diff --git a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java index 59edc0ad..651949ff 100644 --- a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java +++ b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java @@ -506,8 +506,8 @@ public class JobsDAOSQLite extends JobsDAO { } } - executeSQL("CREATE TABLE `" + getPrefix() + "users` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` varchar(36) NOT NULL, `username` varchar(20));"); try { + executeSQL("CREATE TABLE `" + getPrefix() + "users` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` varchar(36) NOT NULL, `username` varchar(20));"); prest = conn.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`player_uuid`, `username`) VALUES (?, ?);"); conn.setAutoCommit(false); for (Entry users : tempMap.entrySet()) { @@ -545,8 +545,8 @@ public class JobsDAOSQLite extends JobsDAO { } // Modifying jobs main table - executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `userid` int;"); try { + executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `userid` int;"); prest = conn.prepareStatement("UPDATE `" + getPrefix() + "jobs` SET `userid` = ? WHERE `player_uuid` = ?;"); conn.setAutoCommit(false); for (Entry users : tempPlayerMap.entrySet()) { @@ -567,8 +567,11 @@ public class JobsDAOSQLite extends JobsDAO { } // dropping 2 columns - executeSQL("CREATE TABLE `" + getPrefix() - + "jobs_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);"); + try { + executeSQL("CREATE TABLE `" + getPrefix() + + "jobs_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);"); + } catch (Exception e) { + } PreparedStatement pst111 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "jobs`;"); ResultSet rs11 = pst111.executeQuery(); @@ -589,13 +592,15 @@ public class JobsDAOSQLite extends JobsDAO { rs11.close(); if (insert11 != null) insert11.close(); - - executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "jobs`;"); - executeSQL("ALTER TABLE `" + getPrefix() + "jobs_temp` RENAME TO `" + getPrefix() + "jobs`;"); + try { + executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "jobs`;"); + executeSQL("ALTER TABLE `" + getPrefix() + "jobs_temp` RENAME TO `" + getPrefix() + "jobs`;"); + } catch (Exception e) { + } // Modifying jobs archive table - executeSQL("ALTER TABLE `" + getPrefix() + "archive` ADD COLUMN `userid` int;"); try { + executeSQL("ALTER TABLE `" + getPrefix() + "archive` ADD COLUMN `userid` int;"); prest = conn.prepareStatement("UPDATE `" + getPrefix() + "archive` SET `userid` = ? WHERE `player_uuid` = ?;"); conn.setAutoCommit(false); for (Entry users : tempPlayerMap.entrySet()) { @@ -616,8 +621,11 @@ public class JobsDAOSQLite extends JobsDAO { } // dropping 2 columns - executeSQL("CREATE TABLE `" + getPrefix() - + "archive_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);"); + try { + executeSQL("CREATE TABLE `" + getPrefix() + + "archive_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);"); + } catch (Exception e) { + } PreparedStatement pst = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "archive`;"); ResultSet rs = pst.executeQuery(); @@ -633,13 +641,14 @@ public class JobsDAOSQLite extends JobsDAO { insert.execute(); } } - - executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;"); - executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;"); - - // Modifying jobs log table - executeSQL("ALTER TABLE `" + getPrefix() + "log` ADD COLUMN `userid` int;"); try { + executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;"); + executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;"); + } catch (Exception e) { + } + // Modifying jobs log table + try { + executeSQL("ALTER TABLE `" + getPrefix() + "log` ADD COLUMN `userid` int;"); prest = conn.prepareStatement("UPDATE `" + getPrefix() + "log` SET `userid` = ? WHERE `player_uuid` = ?;"); conn.setAutoCommit(false); for (Entry users : tempPlayerMap.entrySet()) { @@ -660,8 +669,11 @@ public class JobsDAOSQLite extends JobsDAO { } // dropping 2 columns - executeSQL("CREATE TABLE `" + getPrefix() - + "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);"); + try { + executeSQL("CREATE TABLE `" + getPrefix() + + "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);"); + } catch (Exception e) { + } pst = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;"); rs = pst.executeQuery(); @@ -684,12 +696,15 @@ public class JobsDAOSQLite extends JobsDAO { rs.close(); if (insert != null) insert.close(); + + try { + executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;"); + executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;"); - executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;"); - executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;"); - - // Create new points table - executeSQL("CREATE TABLE `" + getPrefix() - + "points` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `totalpoints` double, `currentpoints` double);"); + // Create new points table + executeSQL("CREATE TABLE `" + getPrefix() + + "points` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `totalpoints` double, `currentpoints` double);"); + } catch (Exception e) { + } } } diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index a7089b2d..857c410c 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -82,7 +82,6 @@ import com.gamingmesh.jobs.container.ExploreRespond; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.stuff.ChatColor; -import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.Perm; import com.google.common.base.Objects; @@ -887,8 +886,6 @@ public class JobsPaymentListener implements Listener { // Calulating multiplaier double multiplier = NearSpawnerMultiplier + PetPayMultiplier; - Debug.D(multiplier + " " + NearSpawnerMultiplier + " " + PetPayMultiplier); - if (lVictim instanceof Player && !lVictim.hasMetadata("NPC")) { Player VPlayer = (Player) lVictim; if (jDamager.getUserName().equalsIgnoreCase(VPlayer.getName())) diff --git a/plugin.yml b/plugin.yml index f79fb34c..9feb44d3 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,9 +1,10 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.JobsPlugin -version: 3.2.0 +version: 3.3.0 author: phrstbrn -softdepend: [Vault, CoreProtect, MythicMobs, McMMO] +depend: [Vault] +softdepend: [CoreProtect, MythicMobs, McMMO] commands: jobs: description: Jobs