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

Slime split protection

This commit is contained in:
Zrips 2015-09-10 13:41:19 +03:00
parent 0dcb81210d
commit 401c6c1c6d
15 changed files with 4190 additions and 3935 deletions

View File

@ -39,12 +39,14 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Log;
import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.economy.BufferedEconomy;
import com.gamingmesh.jobs.economy.Economy;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.ActionBar;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.JobsClassLoader;
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
@ -324,10 +326,10 @@ public class Jobs {
return economy;
}
public static boolean isUnderLimit(OfflinePlayer player, Double amount) {
public static boolean isUnderMoneyLimit(OfflinePlayer player, Double amount) {
if (player == null)
return false;
return true;
String playername = player.getName();
@ -335,23 +337,26 @@ public class Jobs {
return true;
if (!paymentLimit.containsKey(playername)) {
PaymentData data = new PaymentData(System.currentTimeMillis(), amount, 0L, false);
PaymentData data = new PaymentData(System.currentTimeMillis(), amount, 0.0, 0L, false);
//data.AddNewAmount(amount);
paymentLimit.put(playername, data);
} else {
PaymentData data = paymentLimit.get(playername);
if (data.IsReachedLimit(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit, ConfigManager.getJobsConfiguration().EconomyLimitMoneyLimit)) {
if (player.isOnline() && !data.Informed) {
if (data.IsReachedMoneyLimit(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit, ConfigManager.getJobsConfiguration().EconomyLimitMoneyLimit)) {
if (player.isOnline() && !data.Informed && !data.isReseted()) {
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit"));
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit2"));
data.Setinformed();
}
if (data.IsAnnounceTime(ConfigManager.getJobsConfiguration().EconomyLimitAnnouncmentDelay) && player.isOnline()) {
String message = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit)));
String message = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager
.getJobsConfiguration().EconomyLimitTimeLimit)));
message = message.replace("%min%", String.valueOf(data.GetLeftMin(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit)));
message = message.replace("%sec%", String.valueOf(data.GetLeftsec(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit)));
ActionBar.send(((Player) player), ChatColor.RED + message);
}
if (data.isReseted())
data.setReseted(false);
return false;
} else
data.AddAmount(amount);
@ -370,32 +375,32 @@ public class Jobs {
return true;
if (!ExpLimit.containsKey(playername)) {
PaymentData data = new PaymentData();
data.AddNewAmount(amount);
PaymentData data = new PaymentData(System.currentTimeMillis(), 0.0, amount, 0L, false);
//data.AddNewAmount(amount);
ExpLimit.put(playername, data);
} else {
PaymentData data = ExpLimit.get(playername);
if (data.IsReachedExpLimit(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit, ConfigManager.getJobsConfiguration().EconomyExpLimit)) {
final PaymentData data = ExpLimit.get(playername);
if (data.IsReachedLimit(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit, ConfigManager.getJobsConfiguration().EconomyExpLimit)) {
if (player.isOnline() && !data.Informed) {
Debug.D("exp limit reached");
if (player.isOnline() && !data.Informed && !data.isReseted()) {
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit"));
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit2"));
data.Setinformed();
}
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
@Override
public void run() {
if (data.IsAnnounceTime(ConfigManager.getJobsConfiguration().EconomyLimitAnnouncmentExpDelay) && player.isOnline()) {
String message = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit)));
String message = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager
.getJobsConfiguration().EconomyExpTimeLimit)));
message = message.replace("%min%", String.valueOf(data.GetLeftMin(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit)));
message = message.replace("%sec%", String.valueOf(data.GetLeftsec(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit)));
ActionBar.send(((Player) player), ChatColor.RED + message);
}
}
});
if (data.isReseted())
data.setReseted(false);
return false;
} else
data.AddAmount(amount);
data.AddExpAmount(amount);
ExpLimit.put(playername, data);
}
return true;
@ -427,7 +432,6 @@ public class Jobs {
Double income = jobNone.getIncome(info, 1, numjobs);
if (income != null) {
Double amount = income + ((income * multiplier) - income) + ((income * 1.0) - income) + ((income * Jobs.getNoneJob().getMoneyBoost()) - income);
if (ConfigManager.getJobsConfiguration().useDynamicPayment) {
@ -435,7 +439,7 @@ public class Jobs {
amount += moneyBonus;
}
if (!isUnderLimit(dude, amount))
if (!isUnderMoneyLimit(dude, amount))
return;
Jobs.getEconomy().pay(jPlayer, amount, 0.0);
@ -524,7 +528,8 @@ public class Jobs {
OfflinePlayer dude = jPlayer.getPlayer();
// Calculate income
Double amount = income + ((income * multiplier) - income) + ((income * prog.getJob().getMoneyBoost()) - income) + ((income * prog.getMoneyBoost()) - income) + itemMoneyBoost + armorMoneyBoost;
Double amount = income + ((income * multiplier) - income) + ((income * prog.getJob().getMoneyBoost()) - income) + ((income * prog.getMoneyBoost())
- income) + itemMoneyBoost + armorMoneyBoost;
if (ConfigManager.getJobsConfiguration().useDynamicPayment) {
double moneyBonus = (income * (prog.getJob().getBonus() / 100));
@ -532,14 +537,15 @@ public class Jobs {
}
// Calculate exp
double expAmount = exp + ((exp * multiplier) - exp) + ((exp * prog.getJob().getExpBoost()) - exp) + ((exp * prog.getExpBoost()) - exp) + itemExpBoost + armorExpBoost;
double expAmount = exp + ((exp * multiplier) - exp) + ((exp * prog.getJob().getExpBoost()) - exp) + ((exp * prog.getExpBoost()) - exp) + itemExpBoost
+ armorExpBoost;
if (ConfigManager.getJobsConfiguration().useDynamicPayment) {
double expBonus = (exp * (prog.getJob().getBonus() / 100));
expAmount += expBonus;
}
if (!isUnderLimit(dude, amount)) {
if (!isUnderMoneyLimit(dude, amount)) {
amount = 0.0000000001;
if (ConfigManager.getJobsConfiguration().EconomyExpStop)
expAmount = 0.0;
@ -557,6 +563,8 @@ public class Jobs {
Jobs.getEconomy().pay(jPlayer, amount, expAmount);
int oldLevel = prog.getLevel();
recordToLog(jPlayer, info, amount, expAmount);
if (prog.addExperience(expAmount))
Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
@ -564,4 +572,28 @@ public class Jobs {
}
}
}
private static void recordToLog(JobsPlayer jPlayer, ActionInfo info, double amount, double expAmount) {
List<Log> logList = jPlayer.getLog();
boolean found = false;
for (Log one : logList) {
if (!one.getActionType().getName().equalsIgnoreCase(info.getType().getName()))
continue;
one.add(info.getNameWithSub(), amount, expAmount);
found = true;
Debug.D(info.getNameWithSub() + " : " + one.getCount(info.getNameWithSub()) + " money: " + one.getMoney(info.getNameWithSub()) + " exp:" + one.getExp(info
.getNameWithSub()));
}
if (!found) {
Log log = new Log(info.getType());
log.add(info.getNameWithSub(), amount, expAmount);
logList.add(log);
String msg = info.getNameWithSub() + " : " + log.getCount(info.getNameWithSub()) + " money: " + log.getMoney(info.getNameWithSub()) + " exp:" + log.getExp(info
.getNameWithSub());
Debug.D(msg);
}
}
}

View File

@ -44,10 +44,11 @@ public class PermissionHandler {
if (jPlayer == null)
return;
Player player = (Player) jPlayer.getPlayer();
if (player == null)
Player player = this.plugin.getServer().getPlayer(jPlayer.getPlayerUUID());
if (player == null) {
return;
}
boolean changed = false;

View File

@ -52,8 +52,8 @@ public class PlayerManager {
* Handles join of new player
* @param playername
*/
public void playerJoin(final Player player) {
//synchronized (players) {
public void playerJoin(Player player) {
synchronized (players) {
JobsPlayer jPlayer = players.get(player.getName().toLowerCase());
if (jPlayer == null) {
jPlayer = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), player);
@ -63,15 +63,14 @@ public class PlayerManager {
jPlayer.reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
return;
//}
}
}
/**
* Handles player quit
* @param playername
*/
public void playerQuit(Player player) {
//synchronized (players) {
synchronized (players) {
if (ConfigManager.getJobsConfiguration().saveOnDisconnect()) {
JobsPlayer jPlayer = players.remove(player.getName().toLowerCase());
if (jPlayer != null) {
@ -84,7 +83,7 @@ public class PlayerManager {
jPlayer.onDisconnect();
}
}
//}
}
}
/**

View File

@ -24,7 +24,9 @@ import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -48,6 +50,8 @@ import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Log;
import com.gamingmesh.jobs.container.LogAmounts;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.i18n.Language;
@ -90,7 +94,8 @@ public class JobsCommands implements CommandExecutor {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {}
} catch (NoSuchMethodException e) {
}
return help(sender);
}
@ -201,7 +206,9 @@ public class JobsCommands implements CommandExecutor {
to = "MySQL";
}
sender.sendMessage(ChatColor.GOLD + "Data base was converted from " + ChatColor.GREEN + from + ChatColor.GOLD + " to " + ChatColor.GREEN + to + ChatColor.GOLD + "! Now you can stop the server, change storage-method to " + ChatColor.GREEN + to + ChatColor.GOLD + " in general config file and start server again on your new database system.");
sender.sendMessage(ChatColor.GOLD + "Data base was converted from " + ChatColor.GREEN + from + ChatColor.GOLD + " to " + ChatColor.GREEN + to + ChatColor.GOLD
+ "! Now you can stop the server, change storage-method to " + ChatColor.GREEN + to + ChatColor.GOLD
+ " in general config file and start server again on your new database system.");
return true;
}
@ -477,7 +484,8 @@ public class JobsCommands implements CommandExecutor {
return true;
}
job.setExpBoost(rate);
sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.expboost.output.boostadded").replace("%boost%", String.valueOf(rate)).replace("%jobname%", job.getName()));
sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.expboost.output.boostadded").replace("%boost%", String.valueOf(rate)).replace("%jobname%",
job.getName()));
return true;
}
}
@ -546,7 +554,8 @@ public class JobsCommands implements CommandExecutor {
return true;
}
job.setMoneyBoost(rate);
sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.moneyboost.output.boostadded").replace("%boost%", String.valueOf(rate)).replace("%jobname%", job.getName()));
sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.moneyboost.output.boostadded").replace("%boost%", String.valueOf(rate)).replace("%jobname%",
job.getName()));
return true;
}
}
@ -1056,7 +1065,8 @@ public class JobsCommands implements CommandExecutor {
for (TopList One : FullList) {
i++;
String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown";
player.sendMessage(Language.getMessage("command.gtop.output.list").replace("%number%", String.valueOf(i)).replace("%playername%", PlayerName).replace("%level%", String.valueOf(One.getLevel())).replace("%exp%", String.valueOf(One.getExp())));
player.sendMessage(Language.getMessage("command.gtop.output.list").replace("%number%", String.valueOf(i)).replace("%playername%", PlayerName).replace(
"%level%", String.valueOf(One.getLevel())).replace("%exp%", String.valueOf(One.getExp())));
}
} else {
@ -1087,8 +1097,12 @@ public class JobsCommands implements CommandExecutor {
from = start - 15;
int until = start + 15;
String prev = "[\"\",{\"text\":\"" + Language.getMessage("command.gtop.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs gtop " + from + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage("command.gtop.output.show").replace("[from]", String.valueOf(from)).replace("[until]", String.valueOf((from + 15))) + "\"}]}}}";
String next = " {\"text\":\"" + Language.getMessage("command.gtop.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs gtop " + until + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage("command.gtop.output.show").replace("[from]", String.valueOf(until + 1)).replace("[until]", String.valueOf((until + 15))) + "\"}]}}}]";
String prev = "[\"\",{\"text\":\"" + Language.getMessage("command.gtop.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs gtop "
+ from + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage("command.gtop.output.show")
.replace("[from]", String.valueOf(from)).replace("[until]", String.valueOf((from + 15))) + "\"}]}}}";
String next = " {\"text\":\"" + Language.getMessage("command.gtop.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs gtop "
+ until + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage(
"command.gtop.output.show").replace("[from]", String.valueOf(until + 1)).replace("[until]", String.valueOf((until + 15))) + "\"}]}}}]";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + prev + "," + next);
}
@ -1139,7 +1153,8 @@ public class JobsCommands implements CommandExecutor {
for (TopList One : FullList) {
i++;
String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown";
player.sendMessage(Language.getMessage("command.top.output.list").replace("%number%", String.valueOf(i)).replace("%playername%", PlayerName).replace("%level%", String.valueOf(One.getLevel())).replace("%exp%", String.valueOf(One.getExp())));
player.sendMessage(Language.getMessage("command.top.output.list").replace("%number%", String.valueOf(i)).replace("%playername%", PlayerName).replace(
"%level%", String.valueOf(One.getLevel())).replace("%exp%", String.valueOf(One.getExp())));
}
} else {
@ -1169,8 +1184,12 @@ public class JobsCommands implements CommandExecutor {
from = start - 15;
int until = start + 15;
String prev = "[\"\",{\"text\":\"" + Language.getMessage("command.top.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs top " + jobName + " " + from + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage("command.top.output.show").replace("[from]", String.valueOf(from)).replace("[until]", String.valueOf((from + 15))) + "\"}]}}}";
String next = " {\"text\":\"" + Language.getMessage("command.top.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs top " + jobName + " " + until + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage("command.top.output.show").replace("[from]", String.valueOf(until + 1)).replace("[until]", String.valueOf((until + 15))) + "\"}]}}}]";
String prev = "[\"\",{\"text\":\"" + Language.getMessage("command.top.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs top "
+ jobName + " " + from + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage(
"command.top.output.show").replace("[from]", String.valueOf(from)).replace("[until]", String.valueOf((from + 15))) + "\"}]}}}";
String next = " {\"text\":\"" + Language.getMessage("command.top.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs top "
+ jobName + " " + until + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage(
"command.top.output.show").replace("[from]", String.valueOf(until + 1)).replace("[until]", String.valueOf((until + 15))) + "\"}]}}}]";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + prev + "," + next);
}
@ -1236,10 +1255,12 @@ public class JobsCommands implements CommandExecutor {
String playername = player.getName();
if (ConfigManager.getJobsConfiguration().EconomyLimitUse)
if (Jobs.paymentLimit.containsKey(playername) && Jobs.paymentLimit.get(playername).GetLeftTime(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit) > 0) {
if (Jobs.paymentLimit.containsKey(playername) && Jobs.paymentLimit.get(playername).GetLeftTime(ConfigManager
.getJobsConfiguration().EconomyLimitTimeLimit) > 0) {
PaymentData data = Jobs.paymentLimit.get(playername);
String lefttimemessage = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit)));
String lefttimemessage = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager
.getJobsConfiguration().EconomyLimitTimeLimit)));
lefttimemessage = lefttimemessage.replace("%min%", String.valueOf(data.GetLeftMin(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit)));
lefttimemessage = lefttimemessage.replace("%sec%", String.valueOf(data.GetLeftsec(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit)));
player.sendMessage(lefttimemessage);
@ -1285,13 +1306,14 @@ public class JobsCommands implements CommandExecutor {
if (Jobs.ExpLimit.containsKey(playername) && Jobs.ExpLimit.get(playername).GetLeftTime(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit) > 0) {
PaymentData data = Jobs.ExpLimit.get(playername);
String lefttimemessage = Language.getMessage("command.limit.output.leftexptime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit)));
String lefttimemessage = Language.getMessage("command.limit.output.leftexptime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager
.getJobsConfiguration().EconomyExpTimeLimit)));
lefttimemessage = lefttimemessage.replace("%min%", String.valueOf(data.GetLeftMin(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit)));
lefttimemessage = lefttimemessage.replace("%sec%", String.valueOf(data.GetLeftsec(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit)));
player.sendMessage(lefttimemessage);
String message = Language.getMessage("command.limit.output.explimit");
message = message.replace("%exp%", String.valueOf(data.GetAmountBylimit(ConfigManager.getJobsConfiguration().EconomyExpLimit)));
message = message.replace("%exp%", String.valueOf(data.GetExpBylimit(ConfigManager.getJobsConfiguration().EconomyExpLimit)));
message = message.replace("%totalexp%", String.valueOf(ConfigManager.getJobsConfiguration().EconomyExpLimit));
player.sendMessage(message);
@ -1330,6 +1352,38 @@ public class JobsCommands implements CommandExecutor {
return true;
}
// @JobCommand
// public boolean log(CommandSender sender, String[] args) {
// if (args.length != 1) {
// sendUsage(sender, "log");
// return true;
// }
//
// JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
//
// if (JPlayer == null)
// return true;
//
// List<Log> logList = JPlayer.getLog();
//
// if (logList.size() == 0)
// return true;
//
// for (Log one : logList) {
//
// HashMap<String, LogAmounts> AmountList = one.getAmountList();
//
// for (Entry<String, LogAmounts> oneMap : AmountList.entrySet()) {
// String msg = "&e" + one.getActionType().getName() + ": &6" + oneMap.getValue().getItemName() + " &ecount: &6" + oneMap.getValue().getCount()
// + " &emoney: &6" + oneMap.getValue().getMoney() + " &eexp: &6" + oneMap.getValue().getExp();
// msg = org.bukkit.ChatColor.translateAlternateColorCodes('&', msg);
// sender.sendMessage(msg);
// }
// }
//
// return true;
// }
/**
* Displays info about a job
* @param player - the player of the job
@ -1367,9 +1421,11 @@ public class JobsCommands implements CommandExecutor {
if (ConfigManager.getJobsConfiguration().useDynamicPayment)
if (job.getBonus() < 0)
message.append(ChatColor.GOLD + Language.getMessage("command.info.help.penalty").replace("[penalty]", String.valueOf((int) (job.getBonus() * 100) / 100.0 * -1)) + "\n");
message.append(ChatColor.GOLD + Language.getMessage("command.info.help.penalty").replace("[penalty]", String.valueOf((int) (job.getBonus() * 100) / 100.0
* -1)) + "\n");
else
message.append(ChatColor.GOLD + Language.getMessage("command.info.help.bonus").replace("[bonus]", String.valueOf((int) (job.getBonus() * 100) / 100.0)) + "\n");
message.append(ChatColor.GOLD + Language.getMessage("command.info.help.bonus").replace("[bonus]", String.valueOf((int) (job.getBonus() * 100) / 100.0))
+ "\n");
for (ActionType actionType : ActionType.values()) {
if (showAllTypes == 1 || type.startsWith(actionType.getName().toLowerCase())) {

View File

@ -72,7 +72,7 @@ public class JobsConfiguration {
public boolean EconomyLimitUse, EconomyExpLimitUse, PayForRenaming, PayForEachCraft, SignsEnabled,
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse,
EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop,
EconomyExpStop, UseJobsBrowse;
EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit;
public int EconomyLimitMoneyLimit, EconomyExpLimit;
public int EconomyLimitTimeLimit, EconomyExpTimeLimit;
public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer,
@ -364,7 +364,9 @@ public class JobsConfiguration {
}
savePeriod = config.getInt("save-period");
writer.addComment("save-on-disconnect", "Should player data be saved on disconnect?", "Player data is always periodically auto-saved and autosaved during a clean shutdown.", "Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance.");
writer.addComment("save-on-disconnect", "Should player data be saved on disconnect?",
"Player data is always periodically auto-saved and autosaved during a clean shutdown.",
"Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance.");
saveOnDisconnect = getBoolean("save-on-disconnect", false, config, writer);
writer.addComment("broadcast.on-skill-up.use", "Do all players get a message when somone goes up a skill level?");
@ -387,10 +389,12 @@ public class JobsConfiguration {
writer.addComment("enable-pay-near-spawner", "Option to allow payment to be made when killing mobs from a spawner");
payNearSpawner = getBoolean("enable-pay-near-spawner", false, config, writer);
writer.addComment("pay-near-spawner-multiplier", "enable-pay-near-spawner should be enabled for this to work", "0.5 means that players will get only 50% exp/money from monsters spawned from spawner");
writer.addComment("pay-near-spawner-multiplier", "enable-pay-near-spawner should be enabled for this to work",
"0.5 means that players will get only 50% exp/money from monsters spawned from spawner");
payNearSpawnerMultiplier = getDouble("pay-near-spawner-multiplier", 1.0, config, writer);
writer.addComment("VIP-pay-near-spawner-multiplier", "VIP multiplier to pay for monsters from spawners, this will ignore global multiplier", "Use jobs.vipspawner permission node for this to be enabled");
writer.addComment("VIP-pay-near-spawner-multiplier", "VIP multiplier to pay for monsters from spawners, this will ignore global multiplier",
"Use jobs.vipspawner permission node for this to be enabled");
VIPpayNearSpawnerMultiplier = getDouble("VIP-pay-near-spawner-multiplier", 1.0, config, writer);
writer.addComment("enable-pay-creative", "Option to allow payment to be made in creative mode");
@ -399,19 +403,23 @@ public class JobsConfiguration {
writer.addComment("add-xp-player", "Adds the Jobs xp recieved to the player's Minecraft XP bar");
addXpPlayer = getBoolean("add-xp-player", false, config, writer);
writer.addComment("modify-chat", "Modifys chat to add chat titles. If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this.");
writer.addComment("modify-chat",
"Modifys chat to add chat titles. If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this.");
modifyChat = getBoolean("modify-chat", true, config, writer);
writer.addComment("UseCustomNames", "Do you want to use custom item/block/mob/enchant/color names", "With this set to true names like Stone:1 will be translated to Granite", "Name list is in ItemList.yml file");
writer.addComment("UseCustomNames", "Do you want to use custom item/block/mob/enchant/color names",
"With this set to true names like Stone:1 will be translated to Granite", "Name list is in ItemList.yml file");
UseCustomNames = getBoolean("UseCustomNames", true, config, writer);
writer.addComment("economy-batch-delay", "Changes how often, in seconds, players are paid out. Default is 5 seconds.", "Setting this too low may cause tick lag. Increase this to improve economy performance (at the cost of delays in payment)");
writer.addComment("economy-batch-delay", "Changes how often, in seconds, players are paid out. Default is 5 seconds.",
"Setting this too low may cause tick lag. Increase this to improve economy performance (at the cost of delays in payment)");
economyBatchDelay = getInt("economy-batch-delay", 5, config, writer);
writer.addComment("economy-async", "Enable async economy calls.", "Disabl this if you have issues with payments or your plugin is not thread safe.");
economyAsync = getBoolean("economy-async", true, config, writer);
writer.addComment("Economy.DynamicPayment.use", "Do you want to use dinamic payment dependent on how many players already working for jobs", "This can help automaticaly lift up payments for not so popular jobs and lower for most popular ones");
writer.addComment("Economy.DynamicPayment.use", "Do you want to use dinamic payment dependent on how many players already working for jobs",
"This can help automaticaly lift up payments for not so popular jobs and lower for most popular ones");
useDynamicPayment = getBoolean("Economy.DynamicPayment.use", false, config, writer);
String maxExpEquationInput = getString("Economy.DynamicPayment.equation", "((totalworkers / totaljobs) - jobstotalplayers)/10.0", config, writer);
@ -433,7 +441,8 @@ public class JobsConfiguration {
writer.addComment("Economy.EnabledJobsToglle", "Do you want to enable jobs toggle by default");
JobsToggleEnabled = getBoolean("Economy.EnabledJobsToglle", true, config, writer);
writer.addComment("Economy.UseServerAcount", "Server economy acount", "With this enabled, players will get money from defined user (server account)", "If this acount dont have enough money to pay for players for, player will get message");
writer.addComment("Economy.UseServerAcount", "Server economy acount", "With this enabled, players will get money from defined user (server account)",
"If this acount dont have enough money to pay for players for, player will get message");
UseServerAccount = getBoolean("Economy.UseServerAcount", false, config, writer);
writer.addComment("Economy.AcountName", "Username should be with Correct capitalization");
ServerAcountName = getString("Economy.AcountName", "Server", config, writer);
@ -445,83 +454,119 @@ public class JobsConfiguration {
TaxesAmount = getDouble("Economy.Taxes.Amount", 15.0, config, writer);
writer.addComment("Economy.Taxes.TransferToServerAccount", "Do you want to transfer taxes to server account");
TransferToServerAccount = getBoolean("Economy.Taxes.TransferToServerAccount", true, config, writer);
writer.addComment("Economy.Taxes.TakeFromPlayersPayment", "With this true, taxes will be taken from players payment and he will get less money than its shown in jobs info", "When its false player will get full payment and server account will get taxes amount to hes account");
writer.addComment("Economy.Taxes.TakeFromPlayersPayment",
"With this true, taxes will be taken from players payment and he will get less money than its shown in jobs info",
"When its false player will get full payment and server account will get taxes amount to hes account");
TakeFromPlayersPayment = getBoolean("Economy.Taxes.TakeFromPlayersPayment", false, config, writer);
writer.addComment("Economy.Limit.Money", "Money gain limit", "With this enabled, players will be limited how much they can make in defined time", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
writer.addComment("Economy.Limit.Money", "Money gain limit", "With this enabled, players will be limited how much they can make in defined time",
"Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
EconomyLimitUse = getBoolean("Economy.Limit.Money.Use", false, config, writer);
writer.addComment("Economy.Limit.Money.StopWithExp", "Do you want to stop money gain when exp limit reached?");
EconomyMoneyStop = getBoolean("Economy.Limit.Money.StopWithExp", false, config, writer);
EconomyLimitMoneyLimit = getInt("Economy.Limit.Money.MoneyLimit", 500, config, writer);
writer.addComment("Economy.Limit.Money.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
EconomyLimitTimeLimit = getInt("Economy.Limit.Money.TimeLimit", 3600, config, writer);
writer.addComment("Economy.Limit.Money.AnnouncmentDelay", "Delay between announcements about reached money limit", "Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
writer.addComment("Economy.Limit.Money.AnnouncmentDelay", "Delay between announcements about reached money limit",
"Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
EconomyLimitAnnouncmentDelay = getInt("Economy.Limit.Money.AnnouncmentDelay", 30, config, writer);
writer.addComment("Economy.Limit.Exp", "Exp gain limit", "With this enabled, players will be limited how much they can get in defined time", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
writer.addComment("Economy.Limit.Exp", "Exp gain limit", "With this enabled, players will be limited how much they can get in defined time",
"Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
EconomyExpLimitUse = getBoolean("Economy.Limit.Exp.Use", false, config, writer);
writer.addComment("Economy.Limit.Exp.StopWithMoney", "Do you want to stop exp gain when money limit reached?");
EconomyExpStop = getBoolean("Economy.Limit.Exp.StopWithMoney", false, config, writer);
EconomyExpLimit = getInt("Economy.Limit.Exp.Limit", 5000, config, writer);
writer.addComment("Economy.Limit.Exp.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
EconomyExpTimeLimit = getInt("Economy.Limit.Exp.TimeLimit", 3600, config, writer);
writer.addComment("Economy.Limit.Exp.AnnouncmentDelay", "Delay between announcements about reached Exp limit", "Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
writer.addComment("Economy.Limit.Exp.AnnouncmentDelay", "Delay between announcements about reached Exp limit",
"Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
EconomyLimitAnnouncmentExpDelay = getInt("Economy.Limit.Exp.AnnouncmentDelay", 30, config, writer);
writer.addComment("Economy.Repair.PayForRenaming", "Do you want to give money for only renaming items in anvil", "Players will get full pay as they would for remairing two items when they only renaming one", "This is not big issue, but if you want to disable it, you can");
writer.addComment("Economy.Repair.PayForRenaming", "Do you want to give money for only renaming items in anvil",
"Players will get full pay as they would for remairing two items when they only renaming one",
"This is not big issue, but if you want to disable it, you can");
PayForRenaming = getBoolean("Economy.Repair.PayForRenaming", true, config, writer);
writer.addComment("Economy.Crafting.PayForEachCraft", "With this true, player will get money for all crafted items instead of each crafting action (like with old payment mechanic)", "By default its false, as you can make ALOT of money if prices kept from old payment mechanics");
writer.addComment("Economy.Crafting.PayForEachCraft",
"With this true, player will get money for all crafted items instead of each crafting action (like with old payment mechanic)",
"By default its false, as you can make ALOT of money if prices kept from old payment mechanics");
PayForEachCraft = getBoolean("Economy.Crafting.PayForEachCraft", false, config, writer);
writer.addComment("Economy.MilkingCow.CancelMilking", "With this true, when timer is still going, cow milking event will be canceled", "With this false, player will get bucket of milk, but still no payment");
writer.addComment("Economy.MilkingCow.CancelMilking", "With this true, when timer is still going, cow milking event will be canceled",
"With this false, player will get bucket of milk, but still no payment");
CancelCowMilking = getBoolean("Economy.MilkingCow.CancelMilking", false, config, writer);
writer.addComment("Economy.MilkingCow.Timer", "How ofter player can milk cows in seconds. Keep in mind that by default player can milk cow indefinetly and as often as he wants", "Set to 0 if you want to disable timer");
writer.addComment("Economy.MilkingCow.Timer",
"How ofter player can milk cows in seconds. Keep in mind that by default player can milk cow indefinetly and as often as he wants",
"Set to 0 if you want to disable timer");
CowMilkingTimer = getInt("Economy.MilkingCow.Timer", 30, config, writer) * 1000;
writer.addComment("ExploitProtections.Coreprotect.Use", "Requires to have CoreProtect plugin and there should be block place/break logging enabled in core protect config file.", "This will prevent players from abusing by placing and breaking blocks again and again", "This will work even after server restart");
writer.addComment("ExploitProtections.Coreprotect.Use",
"Requires to have CoreProtect plugin and there should be block place/break logging enabled in core protect config file.",
"This will prevent players from abusing by placing and breaking blocks again and again", "This will work even after server restart");
useCoreProtect = getBoolean("ExploitProtections.Coreprotect.Use", false, config, writer);
writer.addComment("ExploitProtections.Coreprotect.TimeLimit", "Time limit in minutes to protect blocks from repeating place/breake action.", "10080 equals to 7 days, keep it in reasonable time range");
writer.addComment("ExploitProtections.Coreprotect.TimeLimit", "Time limit in minutes to protect blocks from repeating place/breake action.",
"10080 equals to 7 days, keep it in reasonable time range");
CoreProtectInterval = getInt("ExploitProtections.Coreprotect.TimeLimit", 604800, config, writer);
writer.addComment("ExploitProtections.Coreprotect.BlockPlace.Use", "Do you want to use block place interval protection");
BlockPlaceUse = getBoolean("ExploitProtections.Coreprotect.BlockPlace.Use", true, config, writer);
EnableAnounceMessage = getBoolean("ExploitProtections.Coreprotect.BlockPlace.EnableAnounceMessage", true, config, writer);
writer.addComment("ExploitProtections.Coreprotect.BlockPlace.Interval", "Time interval in seconds in how fast you can place block in same place.", "Keep it on low interval, 3-5 sec will be enough to prevent fast block place in same place and dont annoy peps", "Edit block list in restrictedBlocks.yml under PlacedBlockTimer");
writer.addComment("ExploitProtections.Coreprotect.BlockPlace.Interval", "Time interval in seconds in how fast you can place block in same place.",
"Keep it on low interval, 3-5 sec will be enough to prevent fast block place in same place and dont annoy peps",
"Edit block list in restrictedBlocks.yml under PlacedBlockTimer");
BlockPlaceInterval = getInt("ExploitProtections.Coreprotect.BlockPlace.Interval", 2, config, writer);
writer.addComment("ExploitProtections.General.PlaceAndBreakProtection", "Enable blocks protection, like ore, from exploiting by placing and destroying same block again and again.", "This works only until server restart", "Modify restrictedBlocks.yml for blocks you want to protect");
writer.addComment("ExploitProtections.General.PlaceAndBreakProtection",
"Enable blocks protection, like ore, from exploiting by placing and destroying same block again and again.", "This works only until server restart",
"Modify restrictedBlocks.yml for blocks you want to protect");
useBlockProtection = getBoolean("ExploitProtections.General.PlaceAndBreakProtection", true, config, writer);
writer.addComment("ExploitProtections.General.SilkTouchProtection", "Enable silk touch protection.", "With this enabled players wont get paid for breaked blocks from restrictedblocks list with silk touch tool.");
writer.addComment("ExploitProtections.General.SilkTouchProtection", "Enable silk touch protection.",
"With this enabled players wont get paid for breaked blocks from restrictedblocks list with silk touch tool.");
useSilkTouchProtection = getBoolean("ExploitProtections.General.SilkTouchProtection", false, config, writer);
writer.addComment("ExploitProtections.General.StopPistonBlockMove", "Enable piston moving blocks from restrictedblocks list.", "If piston moves block then it will be like new block and BlockPlaceAndBreakProtection wont work properly", "If you using core protect and its being logging piston block moving, then you can disable this");
writer.addComment("ExploitProtections.General.StopPistonBlockMove", "Enable piston moving blocks from restrictedblocks list.",
"If piston moves block then it will be like new block and BlockPlaceAndBreakProtection wont work properly",
"If you using core protect and its being logging piston block moving, then you can disable this");
useBlockPiston = getBoolean("ExploitProtections.General.StopPistonBlockMove", true, config, writer);
writer.addComment("ExploitProtections.General.BlocksTimer", "Enable blocks timer protection.", "Only enable if you want to protect block from beying broken to fast, useful for vegetables.", "Modify restrictedBlocks.yml for blocks you want to protect");
writer.addComment("ExploitProtections.General.BlocksTimer", "Enable blocks timer protection.",
"Only enable if you want to protect block from beying broken to fast, useful for vegetables.", "Modify restrictedBlocks.yml for blocks you want to protect");
useBlockTimer = getBoolean("ExploitProtections.General.BlocksTimer", true, config, writer);
writer.addComment("ExploitProtections.General.GlobalBlockTimer", "All blocks will be protected X sec after player places it on ground.");
useGlobalTimer = getBoolean("ExploitProtections.General.GlobalBlockTimer.use", false, config, writer);
globalblocktimer = getInt("ExploitProtections.General.GlobalBlockTimer.timer", 30, config, writer);
writer.addComment("ExploitProtections.General.PetPay", "Do you want to pay when players pet kills monster/player", "Can be exploited with mob farms", "0.2 means 20% of original reward", "Optionaly you can give jobs.petpay permission node for specific players/ranks to get paid by VipPetPay multiplier");
writer.addComment("ExploitProtections.General.PetPay", "Do you want to pay when players pet kills monster/player", "Can be exploited with mob farms",
"0.2 means 20% of original reward", "Optionaly you can give jobs.petpay permission node for specific players/ranks to get paid by VipPetPay multiplier");
PetPay = getDouble("ExploitProtections.General.PetPay", 0.1, config, writer);
VipPetPay = getDouble("ExploitProtections.General.VipPetPay", 1.0, config, writer);
writer.addComment("ExploitProtections.McMMO", "McMMO abilities");
writer.addComment("ExploitProtections.McMMO.TreeFellerMultiplier", "Players will get part of money from cutting trees with treefeller ability enabled.", "0.2 means 20% of original price");
writer.addComment("ExploitProtections.McMMO.TreeFellerMultiplier", "Players will get part of money from cutting trees with treefeller ability enabled.",
"0.2 means 20% of original price");
TreeFellerMultiplier = getDouble("ExploitProtections.McMMO.TreeFellerMultiplier", 0.2, config, writer);
writer.addComment("use-breeder-finder", "Breeder finder.", "If you are not using breeding payment, you can disable this to save little resources. Really little.");
writer.addComment("ExploitProtections.Spawner.PreventSlimeSplit", "Prevent slime spliting when they are from spawner","Protects agains exploiting as new splited slimes is treated as naturaly spawned and not from spawner");
PreventSlimeSplit = getBoolean("ExploitProtections.Spawner.PreventSlimeSplit", true, config, writer);
writer.addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube spliting when they are from spawner");
PreventMagmaCubeSplit = getBoolean("ExploitProtections.Spawner.PreventMagmaCubeSplit", true, config, writer);
writer.addComment("use-breeder-finder", "Breeder finder.",
"If you are not using breeding payment, you can disable this to save little resources. Really little.");
useBreederFinder = getBoolean("use-breeder-finder", true, config, writer);
writer.addComment("boost", "Money exp boost with special permision.", "You will need to add special permision for groups or players to have money/exp boost.", "Use: jobs.boost.[jobname].money or jobs.boost.[jobname].exp or jobs.boost.[jobname].both for both of them with specific jobs name.", "Use: jobs.boost.all.money or jobs.boost.all.exp or jobs.boost.all.both to get boost for all jobs", "1.25 means that player will get 25% more than others, you can set less than 1 to get less from anothers");
writer.addComment("boost", "Money exp boost with special permision.", "You will need to add special permision for groups or players to have money/exp boost.",
"Use: jobs.boost.[jobname].money or jobs.boost.[jobname].exp or jobs.boost.[jobname].both for both of them with specific jobs name.",
"Use: jobs.boost.all.money or jobs.boost.all.exp or jobs.boost.all.both to get boost for all jobs",
"1.25 means that player will get 25% more than others, you can set less than 1 to get less from anothers");
BoostExp = getDouble("boost.exp", 1.25, config, writer);
BoostMoney = getDouble("boost.money", 1.25, config, writer);
writer.addComment("old-job", "Old job save", "Players can leave job and return later with some level loss during that", "You can fix players level if hes job level is at max level");
writer.addComment("old-job", "Old job save", "Players can leave job and return later with some level loss during that",
"You can fix players level if hes job level is at max level");
levelLossPercentage = getInt("old-job.level-loss-percentage", 30, config, writer);
fixAtMaxLevel = getBoolean("old-job.fix-at-max-level", true, config, writer);
@ -551,8 +596,10 @@ public class JobsConfiguration {
writer.addComment("Signs", "You can disable this to save SMALL amount of server resources");
SignsEnabled = getBoolean("Signs.Enable", true, config, writer);
SignsColorizeJobName = getBoolean("Signs.Colors.ColorizeJobName", true, config, writer);
writer.addComment("Signs.InfoUpdateInterval", "This is interval in sec in which signs will be updated. This is not continues update, signs are updated only on levelup, job leave, job join or similar action.");
writer.addComment("Signs.InfoUpdateInterval", "This is update for same job signs, to avoid huge lag if you have bunch of same type signs. Keep it from 1 to as many sec you want");
writer.addComment("Signs.InfoUpdateInterval",
"This is interval in sec in which signs will be updated. This is not continues update, signs are updated only on levelup, job leave, job join or similar action.");
writer.addComment("Signs.InfoUpdateInterval",
"This is update for same job signs, to avoid huge lag if you have bunch of same type signs. Keep it from 1 to as many sec you want");
InfoUpdateInterval = getInt("Signs.InfoUpdateInterval", 5, config, writer);
writer.addComment("Scoreboard.ShowToplist", "This will enables to show top list in scoreboard instead of chat");
@ -623,7 +670,26 @@ public class JobsConfiguration {
this.titles.clear();
File f = new File(plugin.getDataFolder(), "titleConfig.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
StringBuilder header = new StringBuilder().append("Title configuration").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("Stores the titles people gain at certain levels.").append(System.getProperty("line.separator")).append("Each title requres to have a name, short name (used when the player has more than").append(System.getProperty("line.separator")).append("1 job) the colour of the title and the level requrirement to attain the title.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("It is recommended but not required to have a title at level 0.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("Titles are completely optional.").append(System.getProperty("line.separator")).append("Posible variable are {level} to add current jobs level.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("Titles:").append(System.getProperty("line.separator")).append(" Apprentice:").append(System.getProperty("line.separator")).append(" Name: Apprentice").append(System.getProperty("line.separator")).append(" ShortName: A").append(System.getProperty("line.separator")).append(" ChatColour: WHITE").append(System.getProperty("line.separator")).append(" levelReq: 0").append(System.getProperty("line.separator")).append(" Novice:").append(System.getProperty("line.separator")).append(" Name: Novice").append(System.getProperty("line.separator")).append(" ShortName: N").append(System.getProperty("line.separator")).append(" ChatColour: GRAY").append(System.getProperty("line.separator")).append(" levelReq: 30").append(System.getProperty("line.separator")).append(" Journeyman:").append(System.getProperty("line.separator")).append(" Name: Journeyman").append(System.getProperty("line.separator")).append(" ShortName: J").append(System.getProperty("line.separator")).append(" ChatColour: GOLD").append(System.getProperty("line.separator")).append(" levelReq: 60").append(System.getProperty("line.separator")).append(" Master:").append(System.getProperty("line.separator")).append(" Name: Master").append(System.getProperty("line.separator")).append(" ShortName: '{level} M'").append(System.getProperty("line.separator")).append(" ChatColour: BLACK").append(System.getProperty("line.separator")).append(" levelReq: 90").append(System.getProperty("line.separator")).append(System.getProperty("line.separator"));
StringBuilder header = new StringBuilder().append("Title configuration").append(System.getProperty("line.separator")).append(System.getProperty("line.separator"))
.append("Stores the titles people gain at certain levels.").append(System.getProperty("line.separator")).append(
"Each title requres to have a name, short name (used when the player has more than").append(System.getProperty("line.separator")).append(
"1 job) the colour of the title and the level requrirement to attain the title.").append(System.getProperty("line.separator")).append(System
.getProperty("line.separator")).append("It is recommended but not required to have a title at level 0.").append(System.getProperty(
"line.separator")).append(System.getProperty("line.separator")).append("Titles are completely optional.").append(System.getProperty(
"line.separator")).append("Posible variable are {level} to add current jobs level.").append(System.getProperty("line.separator")).append(
System.getProperty("line.separator")).append("Titles:").append(System.getProperty("line.separator")).append(" Apprentice:").append(
System.getProperty("line.separator")).append(" Name: Apprentice").append(System.getProperty("line.separator")).append(
" ShortName: A").append(System.getProperty("line.separator")).append(" ChatColour: WHITE").append(System.getProperty(
"line.separator")).append(" levelReq: 0").append(System.getProperty("line.separator")).append(" Novice:").append(
System.getProperty("line.separator")).append(" Name: Novice").append(System.getProperty("line.separator")).append(
" ShortName: N").append(System.getProperty("line.separator")).append(" ChatColour: GRAY").append(System
.getProperty("line.separator")).append(" levelReq: 30").append(System.getProperty("line.separator"))
.append(" Journeyman:").append(System.getProperty("line.separator")).append(" Name: Journeyman").append(System.getProperty("line.separator")).append(
" ShortName: J").append(System.getProperty("line.separator")).append(" ChatColour: GOLD").append(System.getProperty("line.separator")).append(
" levelReq: 60").append(System.getProperty("line.separator")).append(" Master:").append(System.getProperty("line.separator")).append(
" Name: Master").append(System.getProperty("line.separator")).append(" ShortName: '{level} M'").append(System.getProperty("line.separator"))
.append(" ChatColour: BLACK").append(System.getProperty("line.separator")).append(" levelReq: 90").append(System.getProperty("line.separator")).append(
System.getProperty("line.separator"));
conf.options().header(header.toString());
conf.options().copyDefaults(true);
conf.options().indent(2);
@ -685,7 +751,22 @@ public class JobsConfiguration {
StringBuilder header = new StringBuilder();
header.append("Restricted area configuration");
header.append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("Configures restricted areas where you cannot get experience or money").append(System.getProperty("line.separator")).append("when performing a job.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("The multiplier changes the experience/money gains in an area.").append(System.getProperty("line.separator")).append("A multiplier of 0.0 means no money or xp, while 0.5 means you will get half the normal money/exp").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("restrictedareas:").append(System.getProperty("line.separator")).append(" area1:").append(System.getProperty("line.separator")).append(" world: 'world'").append(System.getProperty("line.separator")).append(" multiplier: 0.0").append(System.getProperty("line.separator")).append(" point1:").append(System.getProperty("line.separator")).append(" x: 125").append(System.getProperty("line.separator")).append(" y: 0").append(System.getProperty("line.separator")).append(" z: 125").append(System.getProperty("line.separator")).append(" point2:").append(System.getProperty("line.separator")).append(" x: 150").append(System.getProperty("line.separator")).append(" y: 100").append(System.getProperty("line.separator")).append(" z: 150").append(System.getProperty("line.separator")).append(" area2:").append(System.getProperty("line.separator")).append(" world: 'world_nether'").append(System.getProperty("line.separator")).append(" multiplier: 0.0").append(System.getProperty("line.separator")).append(" point1:").append(System.getProperty("line.separator")).append(" x: -100").append(System.getProperty("line.separator")).append(" y: 0").append(System.getProperty("line.separator")).append(" z: -100").append(System.getProperty("line.separator")).append(" point2:").append(System.getProperty("line.separator")).append(" x: -150").append(System.getProperty("line.separator")).append(" y: 100").append(System.getProperty("line.separator")).append(" z: -150");
header.append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append(
"Configures restricted areas where you cannot get experience or money").append(System.getProperty("line.separator")).append("when performing a job.").append(
System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("The multiplier changes the experience/money gains in an area.")
.append(System.getProperty("line.separator")).append("A multiplier of 0.0 means no money or xp, while 0.5 means you will get half the normal money/exp")
.append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("restrictedareas:").append(System.getProperty(
"line.separator")).append(" area1:").append(System.getProperty("line.separator")).append(" world: 'world'").append(System.getProperty(
"line.separator")).append(" multiplier: 0.0").append(System.getProperty("line.separator")).append(" point1:").append(System.getProperty(
"line.separator")).append(" x: 125").append(System.getProperty("line.separator")).append(" y: 0").append(System.getProperty(
"line.separator")).append(" z: 125").append(System.getProperty("line.separator")).append(" point2:").append(System.getProperty(
"line.separator")).append(" x: 150").append(System.getProperty("line.separator")).append(" y: 100").append(System.getProperty(
"line.separator")).append(" z: 150").append(System.getProperty("line.separator")).append(" area2:").append(System.getProperty(
"line.separator")).append(" world: 'world_nether'").append(System.getProperty("line.separator")).append(" multiplier: 0.0")
.append(System.getProperty("line.separator")).append(" point1:").append(System.getProperty("line.separator")).append(" x: -100").append(System
.getProperty("line.separator")).append(" y: 0").append(System.getProperty("line.separator")).append(" z: -100").append(System.getProperty(
"line.separator")).append(" point2:").append(System.getProperty("line.separator")).append(" x: -150").append(System.getProperty(
"line.separator")).append(" y: 100").append(System.getProperty("line.separator")).append(" z: -150");
conf.options().header(header.toString());
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
if (areaSection != null) {
@ -695,9 +776,11 @@ public class JobsConfiguration {
World world = Bukkit.getServer().getWorld(worldName);
if (world == null)
continue;
Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point1.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point1.z", 0.0));
Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x", 0.0), conf.getDouble("restrictedareas." + areaKey
+ ".point1.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point1.z", 0.0));
Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point2.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point2.z", 0.0));
Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x", 0.0), conf.getDouble("restrictedareas." + areaKey
+ ".point2.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point2.z", 0.0));
this.restrictedAreas.add(new RestrictedArea(point1, point2, multiplier));
}
}
@ -721,7 +804,8 @@ public class JobsConfiguration {
config.options().copyDefaults(true);
writer.addComment("restrictedblocks", "All block to be protected from place/break exploit.", "This will prevent piston moving all blocks in list", "Dont count in vegetables or any single click break blocks");
writer.addComment("restrictedblocks", "All block to be protected from place/break exploit.", "This will prevent piston moving all blocks in list",
"Dont count in vegetables or any single click break blocks");
restrictedBlocks.add("14");
restrictedBlocks.add("15");
restrictedBlocks.add("16");
@ -736,7 +820,8 @@ public class JobsConfiguration {
restrictedBlocks = (ArrayList<String>) config.getStringList("restrictedblocks");
copySetting(config, writer, "restrictedblocks");
writer.addComment("blockstimer", "Block protected by timer in sec", "141-60 means that carrot can be harvested after 60 sec (remember to use id's from placed objects, not from your inventory)");
writer.addComment("blockstimer", "Block protected by timer in sec",
"141-60 means that carrot can be harvested after 60 sec (remember to use id's from placed objects, not from your inventory)");
restrictedBlocksTimer.add("2-60");
restrictedBlocksTimer.add("3-60");
restrictedBlocksTimer.add("6-60");
@ -1057,7 +1142,8 @@ public class JobsConfiguration {
GetConfigString("command.expboost.output.boostadded", "Exp boost of &e%boost% &aadded for &e%jobname%!", writer, conf, true);
GetConfigString("command.expboost.output.infostats", "&c-----> &aExp rate x%boost% enabled&c <-------", writer, conf, true);
GetConfigString("command.convert.help.info", "Converts data base system from one system to another. if you currently running sqlite, this will convert to Mysql and vise versa.", writer, conf, true);
GetConfigString("command.convert.help.info",
"Converts data base system from one system to another. if you currently running sqlite, this will convert to Mysql and vise versa.", writer, conf, true);
GetConfigString("command.convert.help.args", "", writer, conf, true);
GetConfigString("command.limit.help.info", "Shows payment limits for jobs", writer, conf, true);

View File

@ -18,3 +18,5 @@
/JobsLeaveEvent.class
/NameList.class
/Schedule.class
/Log.class
/LogAmounts.class

View File

@ -53,6 +53,9 @@ public class JobsPlayer {
// save lock
public final Object saveLock = new Object();
// log
private List<Log> logList = new ArrayList<Log>();
private JobsPlayer(String userName, OfflinePlayer player) {
this.userName = userName;
this.player = player;
@ -63,7 +66,7 @@ public class JobsPlayer {
JobsPlayer jPlayer = new JobsPlayer(player.getName(), player);
jPlayer.playerUUID = player.getUniqueId();
List<JobsDAOData> list = dao.getAllJobs(player);
//synchronized (jPlayer.saveLock) {
synchronized (jPlayer.saveLock) {
jPlayer.progression.clear();
for (JobsDAOData jobdata : list) {
if (Jobs.getJob(jobdata.getJobName()) == null)
@ -81,10 +84,14 @@ public class JobsPlayer {
}
jPlayer.reloadMaxExperience();
//}
}
return jPlayer;
}
public List<Log> getLog() {
return this.logList;
}
/**
* Get the player
* @return the player
@ -119,7 +126,8 @@ public class JobsPlayer {
public static double getMoneyBoost(String JobName, OfflinePlayer player) {
double MoneyBoost = 1.0;
if (JobName != null) {
if (Perm.hasPermission(player, "jobs.boost." + JobName + ".money") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(player, "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.money")) {
if (Perm.hasPermission(player, "jobs.boost." + JobName + ".money") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(
player, "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.money")) {
MoneyBoost = ConfigManager.getJobsConfiguration().BoostMoney;
}
}
@ -134,7 +142,8 @@ public class JobsPlayer {
Double ExpBoost = 1.0;
if (player == null || JobName == null)
return 1.0;
if (Perm.hasPermission(player, "jobs.boost." + JobName + ".exp") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(player, "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.exp")) {
if (Perm.hasPermission(player, "jobs.boost." + JobName + ".exp") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(player,
"jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.exp")) {
ExpBoost = ConfigManager.getJobsConfiguration().BoostExp;
}
return ExpBoost;
@ -251,7 +260,8 @@ public class JobsPlayer {
synchronized (saveLock) {
progression.clear();
reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this);;
Jobs.getPermissionHandler().recalculatePermissions(this);
;
return true;
}
}
@ -316,7 +326,8 @@ public class JobsPlayer {
if (level != prog.getLevel()) {
prog.setLevel(level);
reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this);;
Jobs.getPermissionHandler().recalculatePermissions(this);
;
}
}
}
@ -346,7 +357,8 @@ public class JobsPlayer {
}
reloadMaxExperience();
reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this);;
Jobs.getPermissionHandler().recalculatePermissions(this);
;
return true;
}
}
@ -409,7 +421,8 @@ public class JobsPlayer {
}
}
if (numJobs > 1 && (method.equals(DisplayMethod.FULL) || method.equals(DisplayMethod.TITLE)) || method.equals(DisplayMethod.SHORT_FULL) || method.equals(DisplayMethod.SHORT_TITLE)) {
if (numJobs > 1 && (method.equals(DisplayMethod.FULL) || method.equals(DisplayMethod.TITLE)) || method.equals(DisplayMethod.SHORT_FULL) || method.equals(
DisplayMethod.SHORT_TITLE)) {
// add title to honorific
if (title != null) {
String honorificpart = title.getChatColor() + title.getShortName() + ChatColor.WHITE;
@ -420,7 +433,8 @@ public class JobsPlayer {
}
}
if (numJobs > 1 && (method.equals(DisplayMethod.FULL) || method.equals(DisplayMethod.JOB)) || method.equals(DisplayMethod.SHORT_FULL) || method.equals(DisplayMethod.SHORT_JOB)) {
if (numJobs > 1 && (method.equals(DisplayMethod.FULL) || method.equals(DisplayMethod.JOB)) || method.equals(DisplayMethod.SHORT_FULL) || method.equals(
DisplayMethod.SHORT_JOB)) {
String honorificpart = prog.getJob().getChatColor() + prog.getJob().getShortName() + ChatColor.WHITE;
if (honorificpart.contains("{level}"))
honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel()));

View File

@ -141,7 +141,8 @@ public class BufferedEconomy {
if (!Jobs.actionbartoggle.containsKey(ServerTaxesAccountname) && ConfigManager.getJobsConfiguration().JobsToggleEnabled)
Jobs.actionbartoggle.put(ServerTaxesAccountname, true);
if (Jobs.actionbartoggle.containsKey(ServerTaxesAccountname) && Jobs.actionbartoggle.get(ServerTaxesAccountname)) {
ActionBar.send((Player) ServerTaxesAccount, Language.getMessage("message.taxes").replace("[amount]", String.valueOf((int) (TotalAmount * 100) / 100.0)));
ActionBar.send((Player) ServerTaxesAccount, Language.getMessage("message.taxes").replace("[amount]", String.valueOf((int) (TotalAmount * 100)
/ 100.0)));
}
}
}

View File

@ -5,11 +5,14 @@ public class PaymentData {
Long time = 0L;
Long lastAnnouced = 0L;
Double Payment = 0.0;
Double Exp = 0.0;
public boolean Informed = false;
public boolean Reseted = false;
public PaymentData(Long time, Double Payment, Long lastAnnouced, boolean Informed) {
public PaymentData(Long time, Double Payment, Double Exp, Long lastAnnouced, boolean Informed) {
this.time = time;
this.Payment = Payment;
this.Exp = Exp;
this.lastAnnouced = lastAnnouced;
this.Informed = Informed;
}
@ -21,6 +24,14 @@ public class PaymentData {
return this.time;
}
public void setReseted(boolean state) {
this.Reseted = state;
}
public boolean isReseted() {
return this.Reseted;
}
public Double GetAmount() {
return this.Payment;
}
@ -31,6 +42,12 @@ public class PaymentData {
return (int) (this.Payment * 100) / 100.0;
}
public Double GetExpBylimit(int limit) {
if (this.Exp > limit)
return (double) limit;
return (int) (this.Exp * 100) / 100.0;
}
public Long GetLastAnnounced() {
return this.lastAnnouced;
}
@ -62,6 +79,9 @@ public class PaymentData {
public void AddAmount(Double Payment) {
this.Payment = this.Payment + Payment;
}
public void AddExpAmount(Double Exp) {
this.Exp = this.Exp + Exp;
}
public int GetLeftTime(int time) {
int left = 0;
@ -76,19 +96,38 @@ public class PaymentData {
return true;
}
public boolean IsOverExpLimit(int limit) {
if (this.Exp < limit)
return false;
return true;
}
public boolean IsOverTimeLimit(int time) {
if (this.time + (time * 1000) > System.currentTimeMillis())
return false;
if (this.Informed)
this.Informed = false;
this.time = System.currentTimeMillis();
this.Payment = 0.0;
this.Exp = 0.0;
this.Reseted = true;
return true;
}
public boolean IsReachedLimit(int time, int limit) {
if (IsOverMoneyLimit(limit) && !IsOverTimeLimit(time))
public boolean IsReachedMoneyLimit(int time, int money) {
if (IsOverTimeLimit(time))
return true;
if (IsOverMoneyLimit(money))
return true;
return false;
}
public boolean IsReachedExpLimit(int time, int exp) {
if (IsOverTimeLimit(time))
return true;
if (IsOverExpLimit(exp))
return true;
return false;
}

View File

@ -154,7 +154,7 @@ public class JobsListener implements Listener {
// }
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(final PlayerJoinEvent event) {
public void onPlayerJoin(PlayerJoinEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
@ -173,7 +173,7 @@ public class JobsListener implements Listener {
* necessary to call this twice in case somebody is relying on permissions from this
* plugin on entry to the world.
*/
final JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
}

View File

@ -48,6 +48,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.SlimeSplitEvent;
import org.bukkit.event.inventory.BrewEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
@ -935,6 +936,25 @@ public class JobsPaymentListener implements Listener {
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(SlimeSplitEvent event) {
if (!event.getEntity().hasMetadata(mobSpawnerMetadata))
return;
EntityType type = event.getEntityType();
if (type == EntityType.SLIME && ConfigManager.getJobsConfiguration().PreventSlimeSplit) {
event.setCancelled(true);
return;
}
if (type == EntityType.MAGMA_CUBE && ConfigManager.getJobsConfiguration().PreventMagmaCubeSplit) {
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureBreed(CreatureSpawnEvent event) {

View File

@ -83,8 +83,6 @@ public class ActionBar {
Message = Message.replace("[amount]", String.valueOf((((int) (payment.getAmount() * 100)) / 100.0)));
Message = Message.replace("[exp]", String.valueOf((((int) (payment.getExp() * 100)) / 100.0)));
ActionBar.send(abp, ChatColor.GREEN + Message);
} else {
Jobs.actionbartoggle.remove(playername);
}
}
}
@ -146,7 +144,7 @@ public class ActionBar {
if (cleanVersion < 182) {
return "net.minecraft.server." + version + ".ChatSerializer";
} 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

@ -34,7 +34,9 @@ public class ScheduleUtil {
List<String> days = one.GetDays();
if (((one.isNextDay() && (Current >= From && Current < one.GetUntil() || Current >= one.GetNextFrom() && Current < one.GetNextUntil()) && !one.isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one.isStarted()) {
if (((one.isNextDay() && (Current >= From && Current < one.GetUntil() || Current >= one.GetNextFrom() && Current < one.GetNextUntil()) && !one
.isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one
.isStarted()) {
if (one.isBroadcastOnStart())
if (one.GetMessageOnStart().size() == 0)
@ -51,7 +53,8 @@ public class ScheduleUtil {
one.setStarted(true);
one.setStoped(false);
break;
} else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until && ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) {
} else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until
&& ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) {
if (one.isBroadcastOnStop())
if (one.GetMessageOnStop().size() == 0)
Bukkit.broadcastMessage(Language.getMessage("message.boostStoped"));
@ -59,6 +62,10 @@ public class ScheduleUtil {
for (String oneMsg : one.GetMessageOnStop()) {
Bukkit.broadcastMessage(oneMsg);
}
for (Job onejob : one.GetJobs()) {
onejob.setExpBoost(1.0);
onejob.setMoneyBoost(1.0);
}
one.setStoped(true);
one.setStarted(false);
}
@ -70,7 +77,7 @@ public class ScheduleUtil {
scheduler();
return;
}
}, 1 * 20L);
}, 30 * 20L);
}
return true;
}

View File

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