1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-31 21:37:57 +01:00

Changing boost calculation to more clean way and more accurate

This commit is contained in:
Zrips 2016-11-19 10:27:43 +02:00
parent d2847dd2fe
commit e44b208fad
28 changed files with 4677 additions and 4671 deletions

View File

@ -7,3 +7,4 @@
/PlayerManager$1.class
/NMS.class
/JobsPlugin.class
/PlayerManager$BoostOf.class

View File

@ -1,277 +1,277 @@
package com.gamingmesh.jobs.Gui;
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.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Perm;
public class GuiManager {
public HashMap<String, GuiInfoList> GuiList = new HashMap<String, GuiInfoList>();
public void CloseInventories() {
for (Entry<String, GuiInfoList> one : GuiList.entrySet()) {
Player player = Bukkit.getPlayer(one.getKey());
if (player != null) {
player.closeInventory();
}
}
}
public Inventory CreateJobsGUI(Player player) {
ArrayList<Job> JobsList = new ArrayList<Job>();
for (Job job : Jobs.getJobs()) {
if (Jobs.getGCManager().getHideJobsWithoutPermission())
if (!Jobs.getCommandManager().hasJobPermission(player, job))
continue;
JobsList.add(job);
}
GuiInfoList guiInfo = new GuiInfoList(player.getName());
guiInfo.setJobList(JobsList);
Inventory topinv = player.getOpenInventory().getTopInventory();
if (topinv != null)
player.closeInventory();
GuiList.put(player.getName(), guiInfo);
int GuiSize = 9;
if (JobsList.size() > 9)
GuiSize = 18;
if (JobsList.size() > 18)
GuiSize = 27;
if (JobsList.size() > 27)
GuiSize = 36;
if (JobsList.size() > 36)
GuiSize = 45;
if (JobsList.size() > 45)
GuiSize = 54;
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
List<JobProgression> pJobs = JPlayer.getJobProgression();
String title = Jobs.getLanguage().getMessage("command.info.gui.pickjob");
if (title.length() > 32)
title = title.substring(0, 30) + "..";
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
for (int i = 0; i < JobsList.size(); i++) {
Job job = JobsList.get(i);
ArrayList<String> Lore = new ArrayList<String>();
for (JobProgression onePJob : pJobs) {
if (onePJob.getJob().getName().equalsIgnoreCase(job.getName()))
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.working"));
}
int maxlevel = 0;
if (Perm.hasPermission(player, "jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0)
maxlevel = job.getVipMaxLevel();
else
maxlevel = job.getMaxLevel();
if (maxlevel > 0)
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel);
if (Jobs.getGCManager().ShowTotalWorkers)
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
if (job.getBonus() < 0)
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) / 100.0 * -1));
else
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100) / 100.0));
Lore.addAll(Arrays.asList(job.getDescription().split("/n")));
if (job.getMaxSlots() != null)
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs
.getUsedSlots(
job)) : 0));
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions"));
for (ActionType actionType : ActionType.values()) {
List<JobInfo> info = job.getJobInfo(actionType);
if (info != null && !info.isEmpty()) {
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase()
+ ".info")));
}
}
Lore.add("");
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick"));
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick"));
ItemStack GuiItem = job.getGuiItem();
ItemMeta meta = GuiItem.getItemMeta();
meta.setDisplayName(job.getName());
meta.setLore(Lore);
GuiItem.setItemMeta(meta);
GuiInv.setItem(i, GuiItem);
}
return GuiInv;
}
public Inventory CreateJobsSubGUI(Player player, Job job) {
Inventory tempInv = Bukkit.createInventory(null, 54, "");
ItemStack GuiItem = job.getGuiItem();
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
// money exp boost
Double MoneyBoost = JPlayer.getBoost(job.getName(), BoostType.MONEY);
Double ExpBoost = JPlayer.getBoost(job.getName(), BoostType.EXP);
int level = 1;
JobProgression prog = JPlayer.getJobProgression(job);
if (prog != null)
level = prog.getLevel();
int numjobs = JPlayer.getJobProgression().size();
List<ItemStack> items = new ArrayList<ItemStack>();
int i = 0;
for (ActionType actionType : ActionType.values()) {
List<JobInfo> info = job.getJobInfo(actionType);
if (info == null || info.isEmpty())
continue;
ArrayList<String> Lore = new ArrayList<String>();
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase()
+ ".info")));
int y = 1;
for (int z = 0; z < info.size(); z++) {
String itemName = Jobs.getNameTranslatorManager().Translate(info.get(z).getName(), info.get(z));
double income = info.get(z).getIncome(level, numjobs);
income = income + ((income * MoneyBoost) - income) + ((income * job.getMoneyBoost()) - income);
ChatColor incomeColor = income >= 0 ? ChatColor.GREEN : ChatColor.DARK_RED;
double xp = info.get(z).getExperience(level, numjobs);
xp = xp + ((xp * ExpBoost) - xp) + ((xp * job.getExpBoost()) - xp);
ChatColor xpColor = xp >= 0 ? ChatColor.YELLOW : ChatColor.GRAY;
String xpString = String.format("%.2fxp", xp);
Lore.add(ChatColor.translateAlternateColorCodes('&', "&7" + itemName + " " + xpColor + xpString + " " + incomeColor + Jobs.getEconomy().format(income)));
if (y >= 10) {
y = 1;
if (z == info.size() - 1)
continue;
ItemMeta meta = GuiItem.getItemMeta();
meta.setDisplayName(job.getName());
meta.setLore(Lore);
GuiItem.setItemMeta(meta);
//GuiInv.setItem(i, GuiItem);
tempInv.setItem(i, GuiItem);
GuiItem = job.getGuiItem();
Lore = new ArrayList<String>();
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase()
+ ".info")));
i++;
}
y++;
}
ItemMeta meta = GuiItem.getItemMeta();
meta.setDisplayName(job.getName());
meta.setLore(Lore);
GuiItem.setItemMeta(meta);
//GuiInv.setItem(i, GuiItem);
tempInv.setItem(i, GuiItem);
i++;
}
for (ItemStack one : tempInv.getContents()) {
if (one != null)
items.add(one);
}
int GuiSize = 18;
int backButton = 9;
if (items.size() > 9) {
GuiSize = 27;
backButton = 18;
}
if (items.size() > 18) {
GuiSize = 36;
backButton = 27;
}
if (items.size() > 27) {
GuiSize = 45;
backButton = 36;
}
if (items.size() > 36) {
GuiSize = 54;
backButton = 45;
}
// if (items.size() > 45) {
// GuiSize = 54;
// backButton = 53;
// }
String title = Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName());
if (title.length() > 32)
title = title.substring(0, 30) + "..";
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
for (int i1 = 0; i1 < items.size(); i1++) {
GuiInv.setItem(i1, items.get(i1));
}
ItemStack skull = new ItemStack(Material.JACK_O_LANTERN, 1, (byte) 0);
ItemMeta skullMeta = skull.getItemMeta();
skullMeta.setDisplayName(Jobs.getLanguage().getMessage("command.info.gui.back"));
skull.setItemMeta(skullMeta);
GuiInv.setItem(backButton, skull);
GuiInfoList guiInfo = new GuiInfoList(player.getName());
guiInfo.setJobInfo(true);
guiInfo.setbackButton(backButton);
GuiList.put(player.getName(), guiInfo);
return GuiInv;
}
}
package com.gamingmesh.jobs.Gui;
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.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.Boost;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Perm;
public class GuiManager {
public HashMap<String, GuiInfoList> GuiList = new HashMap<String, GuiInfoList>();
public void CloseInventories() {
for (Entry<String, GuiInfoList> one : GuiList.entrySet()) {
Player player = Bukkit.getPlayer(one.getKey());
if (player != null) {
player.closeInventory();
}
}
}
public Inventory CreateJobsGUI(Player player) {
ArrayList<Job> JobsList = new ArrayList<Job>();
for (Job job : Jobs.getJobs()) {
if (Jobs.getGCManager().getHideJobsWithoutPermission())
if (!Jobs.getCommandManager().hasJobPermission(player, job))
continue;
JobsList.add(job);
}
GuiInfoList guiInfo = new GuiInfoList(player.getName());
guiInfo.setJobList(JobsList);
Inventory topinv = player.getOpenInventory().getTopInventory();
if (topinv != null)
player.closeInventory();
GuiList.put(player.getName(), guiInfo);
int GuiSize = 9;
if (JobsList.size() > 9)
GuiSize = 18;
if (JobsList.size() > 18)
GuiSize = 27;
if (JobsList.size() > 27)
GuiSize = 36;
if (JobsList.size() > 36)
GuiSize = 45;
if (JobsList.size() > 45)
GuiSize = 54;
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
List<JobProgression> pJobs = JPlayer.getJobProgression();
String title = Jobs.getLanguage().getMessage("command.info.gui.pickjob");
if (title.length() > 32)
title = title.substring(0, 30) + "..";
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
for (int i = 0; i < JobsList.size(); i++) {
Job job = JobsList.get(i);
ArrayList<String> Lore = new ArrayList<String>();
for (JobProgression onePJob : pJobs) {
if (onePJob.getJob().getName().equalsIgnoreCase(job.getName()))
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.working"));
}
int maxlevel = 0;
if (Perm.hasPermission(player, "jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0)
maxlevel = job.getVipMaxLevel();
else
maxlevel = job.getMaxLevel();
if (maxlevel > 0)
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel);
if (Jobs.getGCManager().ShowTotalWorkers)
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
if (job.getBonus() < 0)
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) / 100.0 * -1));
else
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100) / 100.0));
Lore.addAll(Arrays.asList(job.getDescription().split("/n")));
if (job.getMaxSlots() != null)
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs
.getUsedSlots(
job)) : 0));
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions"));
for (ActionType actionType : ActionType.values()) {
List<JobInfo> info = job.getJobInfo(actionType);
if (info != null && !info.isEmpty()) {
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase()
+ ".info")));
}
}
Lore.add("");
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick"));
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick"));
ItemStack GuiItem = job.getGuiItem();
ItemMeta meta = GuiItem.getItemMeta();
meta.setDisplayName(job.getName());
meta.setLore(Lore);
GuiItem.setItemMeta(meta);
GuiInv.setItem(i, GuiItem);
}
return GuiInv;
}
public Inventory CreateJobsSubGUI(Player player, Job job) {
Inventory tempInv = Bukkit.createInventory(null, 54, "");
ItemStack GuiItem = job.getGuiItem();
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
Boost boost = Jobs.getPlayerManager().getFinalBonus(JPlayer, job);
int level = 1;
JobProgression prog = JPlayer.getJobProgression(job);
if (prog != null)
level = prog.getLevel();
int numjobs = JPlayer.getJobProgression().size();
List<ItemStack> items = new ArrayList<ItemStack>();
int i = 0;
for (ActionType actionType : ActionType.values()) {
List<JobInfo> info = job.getJobInfo(actionType);
if (info == null || info.isEmpty())
continue;
ArrayList<String> Lore = new ArrayList<String>();
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase()
+ ".info")));
int y = 1;
for (int z = 0; z < info.size(); z++) {
String itemName = Jobs.getNameTranslatorManager().Translate(info.get(z).getName(), info.get(z));
double income = info.get(z).getIncome(level, numjobs);
income = income + (income * boost.getFinal(BoostType.MONEY));
ChatColor incomeColor = income >= 0 ? ChatColor.GREEN : ChatColor.DARK_RED;
double xp = info.get(z).getExperience(level, numjobs);
xp = xp + (xp * boost.getFinal(BoostType.EXP));
ChatColor xpColor = xp >= 0 ? ChatColor.YELLOW : ChatColor.GRAY;
String xpString = String.format("%.2fxp", xp);
Lore.add(ChatColor.translateAlternateColorCodes('&', "&7" + itemName + " " + xpColor + xpString + " " + incomeColor + Jobs.getEconomy().format(income)));
if (y >= 10) {
y = 1;
if (z == info.size() - 1)
continue;
ItemMeta meta = GuiItem.getItemMeta();
meta.setDisplayName(job.getName());
meta.setLore(Lore);
GuiItem.setItemMeta(meta);
//GuiInv.setItem(i, GuiItem);
tempInv.setItem(i, GuiItem);
GuiItem = job.getGuiItem();
Lore = new ArrayList<String>();
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase()
+ ".info")));
i++;
}
y++;
}
ItemMeta meta = GuiItem.getItemMeta();
meta.setDisplayName(job.getName());
meta.setLore(Lore);
GuiItem.setItemMeta(meta);
//GuiInv.setItem(i, GuiItem);
tempInv.setItem(i, GuiItem);
i++;
}
for (ItemStack one : tempInv.getContents()) {
if (one != null)
items.add(one);
}
int GuiSize = 18;
int backButton = 9;
if (items.size() > 9) {
GuiSize = 27;
backButton = 18;
}
if (items.size() > 18) {
GuiSize = 36;
backButton = 27;
}
if (items.size() > 27) {
GuiSize = 45;
backButton = 36;
}
if (items.size() > 36) {
GuiSize = 54;
backButton = 45;
}
// if (items.size() > 45) {
// GuiSize = 54;
// backButton = 53;
// }
String title = Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName());
if (title.length() > 32)
title = title.substring(0, 30) + "..";
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
for (int i1 = 0; i1 < items.size(); i1++) {
GuiInv.setItem(i1, items.get(i1));
}
ItemStack skull = new ItemStack(Material.JACK_O_LANTERN, 1, (byte) 0);
ItemMeta skullMeta = skull.getItemMeta();
skullMeta.setDisplayName(Jobs.getLanguage().getMessage("command.info.gui.back"));
skull.setItemMeta(skullMeta);
GuiInv.setItem(backButton, skull);
GuiInfoList guiInfo = new GuiInfoList(player.getName());
guiInfo.setJobInfo(true);
guiInfo.setbackButton(backButton);
GuiList.put(player.getName(), guiInfo);
return GuiInv;
}
}

View File

@ -32,6 +32,8 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -56,7 +58,8 @@ import com.gamingmesh.jobs.config.YmlMaker;
import com.gamingmesh.jobs.container.ActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.BlockProtection;
import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.Boost;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.DBAction;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobInfo;
@ -127,11 +130,11 @@ public class Jobs extends JavaPlugin {
public static BufferedPaymentThread paymentThread = null;
private static DatabaseSaveThread saveTask = null;
public final static HashMap<String, PaymentData> paymentLimit = new HashMap<String, PaymentData>();
public final static HashMap<String, PaymentData> ExpLimit = new HashMap<String, PaymentData>();
public final static HashMap<String, PaymentData> PointLimit = new HashMap<String, PaymentData>();
public static HashMap<String, PaymentData> paymentLimit = new HashMap<String, PaymentData>();
public static HashMap<String, PaymentData> ExpLimit = new HashMap<String, PaymentData>();
public static HashMap<String, PaymentData> PointLimit = new HashMap<String, PaymentData>();
public final static HashMap<String, FastPayment> FastPayment = new HashMap<String, FastPayment>();
public static HashMap<String, FastPayment> FastPayment = new HashMap<String, FastPayment>();
private static NMS nms;
@ -759,11 +762,24 @@ public class Jobs extends JavaPlugin {
* @param action - the action
* @param multiplier - the payment/xp multiplier
*/
public static void action(JobsPlayer jPlayer, ActionInfo info, double multiplier) {
action(jPlayer, info, multiplier, null);
public static void action(JobsPlayer jPlayer, ActionInfo info) {
action(jPlayer, info, null, null, null);
}
public static void action(JobsPlayer jPlayer, ActionInfo info, double multiplier, Block block) {
public static void action(JobsPlayer jPlayer, ActionInfo info, Block block) {
action(jPlayer, info, block, null, null);
}
public static void action(JobsPlayer jPlayer, ActionInfo info, Entity ent) {
action(jPlayer, info, null, ent, null);
}
public static void action(JobsPlayer jPlayer, ActionInfo info, Entity ent, LivingEntity victim) {
action(jPlayer, info, null, ent, victim);
}
public static void action(JobsPlayer jPlayer, ActionInfo info, Block block, Entity ent, LivingEntity victim) {
if (jPlayer == null)
return;
@ -774,76 +790,75 @@ public class Jobs extends JavaPlugin {
if (numjobs == 0) {
if (noneJob != null) {
JobInfo jobinfo = noneJob.getJobInfo(info, 1);
if (noneJob == null)
return;
JobInfo jobinfo = noneJob.getJobInfo(info, 1);
if (jobinfo == null)
return;
if (jobinfo == null)
return;
Double income = jobinfo.getIncome(1, numjobs);
Double points = jobinfo.getPoints(1, numjobs);
Double income = jobinfo.getIncome(1, numjobs);
Double pointAmount = jobinfo.getPoints(1, numjobs);
if (income != 0D || points != 0D) {
if (income != 0D || pointAmount != 0D) {
// jPlayer
BoostMultiplier FinalBoost = pManager.getFinalBonus(jPlayer, Jobs.getNoneJob());
Boost boost = pManager.getFinalBonus(jPlayer, Jobs.getNoneJob());
// Calculate income
// Calculate income
Double amount = 0D;
if (income != 0D) {
amount = income + (income * FinalBoost.getMoneyBoost() / 100);
if (GconfigManager.useMinimumOveralPayment && income > 0) {
double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit;
if (amount < maxLimit) {
amount = maxLimit;
}
if (income != 0D) {
income = income + (income * boost.getFinal(BoostType.MONEY));
if (GconfigManager.useMinimumOveralPayment && income > 0) {
double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit;
if (income < maxLimit) {
income = maxLimit;
}
}
// Calculate points
Double pointAmount = 0D;
if (points != 0D) {
pointAmount = points + (points * FinalBoost.getPointsBoost() / 100);
if (GconfigManager.useMinimumOveralPoints && points > 0) {
double maxLimit = points * GconfigManager.MinimumOveralPaymentLimit;
if (pointAmount < maxLimit) {
pointAmount = maxLimit;
}
}
}
if (!isUnderMoneyLimit(jPlayer, amount)) {
amount = 0D;
if (GconfigManager.MoneyStopPoint)
pointAmount = 0D;
}
if (!isUnderPointLimit(jPlayer, pointAmount)) {
pointAmount = 0D;
if (GconfigManager.PointStopMoney)
amount = 0D;
}
if (!isBpOk(jPlayer, info, block))
return;
if (amount == 0D && pointAmount == 0D)
return;
if (info.getType() == ActionType.BREAK && block != null)
Jobs.getBpManager().remove(block);
if (pointAmount != 0D)
jPlayer.setSaved(false);
Jobs.getEconomy().pay(jPlayer, amount, pointAmount, 0.0);
if (GconfigManager.LoggingUse)
loging.recordToLog(jPlayer, info, amount, 0);
}
// Calculate points
if (pointAmount != 0D) {
pointAmount = pointAmount + (pointAmount * boost.getFinal(BoostType.POINTS));
if (GconfigManager.useMinimumOveralPoints && pointAmount > 0) {
double maxLimit = pointAmount * GconfigManager.MinimumOveralPaymentLimit;
if (pointAmount < maxLimit) {
pointAmount = maxLimit;
}
}
}
if (!isUnderMoneyLimit(jPlayer, income)) {
income = 0D;
if (GconfigManager.MoneyStopPoint)
pointAmount = 0D;
}
if (!isUnderPointLimit(jPlayer, pointAmount)) {
pointAmount = 0D;
if (GconfigManager.PointStopMoney)
income = 0D;
}
if (!isBpOk(jPlayer, info, block))
return;
if (income == 0D && pointAmount == 0D)
return;
if (info.getType() == ActionType.BREAK && block != null)
Jobs.getBpManager().remove(block);
if (pointAmount != 0D)
jPlayer.setSaved(false);
Jobs.getEconomy().pay(jPlayer, income, pointAmount, 0.0);
if (GconfigManager.LoggingUse)
loging.recordToLog(jPlayer, info, income, 0);
}
} else {
for (JobProgression prog : progression) {
int level = prog.getLevel();
@ -853,10 +868,10 @@ public class Jobs extends JavaPlugin {
continue;
Double income = jobinfo.getIncome(level, numjobs);
Double points = jobinfo.getPoints(level, numjobs);
Double exp = jobinfo.getExperience(level, numjobs);
Double pointAmount = jobinfo.getPoints(level, numjobs);
Double expAmount = jobinfo.getExperience(level, numjobs);
if (income == 0D && points == 0D && exp == 0D)
if (income == 0D && pointAmount == 0D && expAmount == 0D)
continue;
if (GconfigManager.addXpPlayer()) {
@ -868,10 +883,10 @@ public class Jobs extends JavaPlugin {
* That way jobs that give fractions of experience points will slowly give
* experience in the aggregate
*/
int expInt = exp.intValue();
double remainder = exp.doubleValue() - expInt;
int expInt = expAmount.intValue();
double remainder = expAmount.doubleValue() - expInt;
if (Math.abs(remainder) > Math.random()) {
if (exp.doubleValue() < 0) {
if (expAmount.doubleValue() < 0) {
expInt--;
} else {
expInt++;
@ -887,35 +902,26 @@ public class Jobs extends JavaPlugin {
}
}
BoostMultiplier FinalBoost = Jobs.getPlayerManager().getFinalBonus(jPlayer, prog.getJob());
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, prog.getJob(), ent, victim);
if (multiplier != 0.0)
FinalBoost = new BoostMultiplier(FinalBoost.getMoneyBoost() + multiplier,
FinalBoost.getPointsBoost() + multiplier,
FinalBoost.getExpBoost() + multiplier);
// OfflinePlayer dude = jPlayer.getPlayer();
// Debug.D(FinalBoost.getMoneyBoost() + " : " + FinalBoost.getPointsBoost() + " : " + FinalBoost.getExpBoost());
// Calculate income
Double amount = 0D;
if (income != 0D) {
amount = income + (income * FinalBoost.getMoneyBoost() / 100);
income = income + (income * boost.getFinal(BoostType.MONEY));
if (GconfigManager.useMinimumOveralPayment && income > 0) {
double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit;
if (amount < maxLimit) {
amount = maxLimit;
if (income < maxLimit) {
income = maxLimit;
}
}
}
// Calculate points
Double pointAmount = 0D;
if (points != 0D) {
pointAmount = points + (points * FinalBoost.getPointsBoost() / 100);
if (GconfigManager.useMinimumOveralPoints && points > 0) {
double maxLimit = points * GconfigManager.MinimumOveralPaymentLimit;
if (pointAmount != 0D) {
pointAmount = pointAmount + (pointAmount * boost.getFinal(BoostType.POINTS));
if (GconfigManager.useMinimumOveralPoints && pointAmount > 0) {
double maxLimit = pointAmount * GconfigManager.MinimumOveralPaymentLimit;
if (pointAmount < maxLimit) {
pointAmount = maxLimit;
}
@ -923,17 +929,17 @@ public class Jobs extends JavaPlugin {
}
// Calculate exp
double expAmount = exp + (exp * FinalBoost.getExpBoost() / 100);
expAmount = expAmount + (expAmount * boost.getFinal(BoostType.EXP));
if (GconfigManager.useMinimumOveralPayment && exp > 0) {
double maxLimit = exp * GconfigManager.MinimumOveralPaymentLimit;
if (exp < maxLimit) {
exp = maxLimit;
if (GconfigManager.useMinimumOveralPayment && expAmount > 0) {
double maxLimit = expAmount * GconfigManager.MinimumOveralPaymentLimit;
if (expAmount < maxLimit) {
expAmount = maxLimit;
}
}
if (!isUnderMoneyLimit(jPlayer, amount)) {
amount = 0D;
if (!isUnderMoneyLimit(jPlayer, income)) {
income = 0D;
if (GconfigManager.MoneyStopExp)
expAmount = 0D;
if (GconfigManager.MoneyStopPoint)
@ -943,7 +949,7 @@ public class Jobs extends JavaPlugin {
if (!isUnderExpLimit(jPlayer, expAmount)) {
expAmount = 0D;
if (GconfigManager.ExpStopMoney)
amount = 0D;
income = 0D;
if (GconfigManager.ExpStopPoint)
pointAmount = 0D;
}
@ -951,7 +957,7 @@ public class Jobs extends JavaPlugin {
if (!isUnderPointLimit(jPlayer, pointAmount)) {
pointAmount = 0D;
if (GconfigManager.PointStopMoney)
amount = 0D;
income = 0D;
if (GconfigManager.PointStopExp)
expAmount = 0D;
}
@ -959,7 +965,7 @@ public class Jobs extends JavaPlugin {
if (!isBpOk(jPlayer, info, block))
return;
if (amount == 0D && pointAmount == 0D && expAmount == 0D)
if (income == 0D && pointAmount == 0D && expAmount == 0D)
continue;
try {
@ -981,17 +987,19 @@ public class Jobs extends JavaPlugin {
else
expAmount = JobsExpGainEvent.getExp();
economy.pay(jPlayer, amount, pointAmount, expAmount);
FastPayment.clear();
FastPayment.put(jPlayer.getUserName(), new FastPayment(jPlayer, info, new BufferedPayment(jPlayer.getPlayer(), income, pointAmount, expAmount), prog
.getJob()));
economy.pay(jPlayer, income, pointAmount, expAmount);
int oldLevel = prog.getLevel();
if (GconfigManager.LoggingUse)
loging.recordToLog(jPlayer, info, amount, expAmount);
loging.recordToLog(jPlayer, info, income, expAmount);
if (prog.addExperience(expAmount))
pManager.performLevelUp(jPlayer, prog.getJob(), oldLevel);
FastPayment.clear();
FastPayment.put(jPlayer.getUserName(), new FastPayment(jPlayer, info, new BufferedPayment(jPlayer.getPlayer(), amount, points, exp), prog.getJob()));
}
}
}

View File

@ -30,12 +30,16 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.api.JobsJoinEvent;
import com.gamingmesh.jobs.api.JobsLeaveEvent;
import com.gamingmesh.jobs.api.JobsLevelUpEvent;
import com.gamingmesh.jobs.container.Boost;
import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
@ -48,6 +52,7 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.dao.JobsDAOData;
import com.gamingmesh.jobs.economy.PointsData;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.PerformCommands;
import com.gamingmesh.jobs.stuff.Perm;
@ -56,6 +61,7 @@ public class PlayerManager {
private ConcurrentHashMap<String, JobsPlayer> playersCache = new ConcurrentHashMap<String, JobsPlayer>();
private ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<String, JobsPlayer>();
private PointsData PointsDatabase = new PointsData();
private final String mobSpawnerMetadata = "jobsMobSpawner";
private HashMap<String, PlayerInfo> PlayerMap = new HashMap<String, PlayerInfo>();
Jobs plugin;
@ -428,7 +434,7 @@ public class PlayerManager {
Jobs.getGCManager().SoundLevelupVolume,
Jobs.getGCManager().SoundLevelupPitch,
Jobs.getGCManager().SoundTitleChangeSound.toUpperCase(),
Jobs.getGCManager().SoundTitleChangeVolume,
Jobs.getGCManager().SoundTitleChangeVolume,
Jobs.getGCManager().SoundTitleChangePitch);
Bukkit.getServer().getPluginManager().callEvent(levelUpEvent);
// If event is canceled, dont do anything
@ -560,13 +566,20 @@ public class PlayerManager {
return false;
}
public double GetBoostInPerc(JobsPlayer player, Job job, BoostType type) {
return GetBoostInPerc(player, job, type, false);
public BoostMultiplier getBoost(JobsPlayer player, Job job) {
BoostMultiplier b = new BoostMultiplier();
for (BoostType one : BoostType.values()) {
b.add(one, getBoost(player, job, one, false));
}
return b;
}
public double GetBoostInPerc(JobsPlayer player, Job job, BoostType type, boolean force) {
double Boost = player.getBoost(job.getName(), type, force) * 100.0 - 100.0;
return Boost;
public double getBoost(JobsPlayer player, Job job, BoostType type) {
return getBoost(player, job, type, false);
}
public double getBoost(JobsPlayer player, Job job, BoostType type, boolean force) {
return player.getBoost(job.getName(), type, force);
}
/**
@ -590,35 +603,25 @@ public class PlayerManager {
}
public BoostMultiplier getItemBoost(Player player, Job prog) {
BoostMultiplier data = new BoostMultiplier(1D, 1D, 1D);
BoostMultiplier data = new BoostMultiplier();
if (player == null)
return data;
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
if (iih == null || prog == null)
return data;
BoostMultiplier itemboost = Jobs.getPlayerManager().getItemBoost(prog, iih);
data = new BoostMultiplier(data.getMoneyBoost() + itemboost.getMoneyBoost(),
data.getPointsBoost() + itemboost.getPointsBoost(),
data.getExpBoost() + itemboost.getExpBoost());
data = Jobs.getPlayerManager().getItemBoost(prog, iih);
for (ItemStack OneArmor : player.getInventory().getArmorContents()) {
BoostMultiplier armorboost = Jobs.getPlayerManager().getItemBoost(prog, OneArmor);
data = new BoostMultiplier(data.getMoneyBoost() + armorboost.getMoneyBoost(),
data.getPointsBoost() + armorboost.getPointsBoost(),
data.getExpBoost() + armorboost.getExpBoost());
BoostMultiplier armorboost = Jobs.getPlayerManager().getItemBoost(prog, OneArmor);
data.add(armorboost);
}
return data;
}
@SuppressWarnings("deprecation")
public BoostMultiplier getItemBoost(Job prog, ItemStack item) {
BoostMultiplier bonus = new BoostMultiplier();
if (item == null)
return new BoostMultiplier(0D, 0D, 0D);
return bonus;
ItemMeta meta = item.getItemMeta();
String name = null;
@ -655,52 +658,53 @@ public class PlayerManager {
continue main;
}
return new BoostMultiplier(oneItem.getMoneyBoost() - 1D, oneItem.getPointBoost() - 1D, oneItem.getExpBoost() - 1D);
return oneItem.getBoost();
}
return new BoostMultiplier(0D, 0D, 0D);
return bonus;
}
public BoostMultiplier getFinalBonus(JobsPlayer player, Job prog) {
BoostMultiplier multiplier = new BoostMultiplier(0D, 0D, 0D);
public enum BoostOf {
McMMO, PetPay, NearSpawner, Permission, Global, Dynamic, Item, Area
}
public Boost getFinalBonus(JobsPlayer player, Job prog) {
return getFinalBonus(player, prog, null, null);
}
public Boost getFinalBonus(JobsPlayer player, Job prog, Entity ent, LivingEntity victim) {
Boost boost = new Boost();
if (player == null || prog == null)
return multiplier;
return boost;
double PMoneyBoost = Jobs.getPlayerManager().GetBoostInPerc(player, prog, BoostType.MONEY);
PMoneyBoost = (int) (PMoneyBoost * 100D) / 100D;
double PPointBoost = Jobs.getPlayerManager().GetBoostInPerc(player, prog, BoostType.POINTS);
PPointBoost = (int) (PPointBoost * 100D) / 100D;
double PExpBoost = Jobs.getPlayerManager().GetBoostInPerc(player, prog, BoostType.EXP);
PExpBoost = (int) (PExpBoost * 100D) / 100D;
if (Jobs.getMcMMOlistener().mcMMOPresent)
boost.add(BoostOf.McMMO, new BoostMultiplier().add(Jobs.getMcMMOlistener().getMultiplier(player.getPlayer())));
double GMoneyBoost = prog.getMoneyBoost() * 100.0 - 100.0;
GMoneyBoost = (int) (GMoneyBoost * 100D) / 100D;
double GPointBoost = prog.getPointBoost() * 100.0 - 100.0;
GPointBoost = (int) (GPointBoost * 100D) / 100D;
double GExpBoost = prog.getExpBoost() * 100.0 - 100.0;
GExpBoost = (int) (GExpBoost * 100D) / 100D;
if (ent != null && ent instanceof Tameable) {
Tameable t = (Tameable) ent;
if (t.isTamed() && t.getOwner() instanceof Player) {
Player pDamager = (Player) t.getOwner();
double PetPayMultiplier = 0D;
if (Perm.hasPermission(pDamager, "jobs.petpay") || Perm.hasPermission(pDamager, "jobs.vippetpay"))
PetPayMultiplier = Jobs.getGCManager().VipPetPay;
else
PetPayMultiplier = Jobs.getGCManager().PetPay;
boost.add(BoostOf.PetPay, new BoostMultiplier().add(PetPayMultiplier));
}
}
double DBoost = (int) (prog.getBonus() * 100D) / 100D;
if (!Jobs.getGCManager().useDynamicPayment)
DBoost = 0.0;
if (victim != null && victim.hasMetadata(this.getMobSpawnerMetadata()))
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(player.getVipSpawnerMultiplier()));
boost.add(BoostOf.Permission, Jobs.getPlayerManager().getBoost(player, prog));
boost.add(BoostOf.Global, prog.getBoost());
if (Jobs.getGCManager().useDynamicPayment)
boost.add(BoostOf.Dynamic, new BoostMultiplier().add(prog.getBonus()));
boost.add(BoostOf.Item, Jobs.getPlayerManager().getItemBoost(player.getPlayer(), prog));
boost.add(BoostOf.Item, Jobs.getPlayerManager().getItemBoost(player.getPlayer(), prog));
boost.add(BoostOf.Area, new BoostMultiplier().add(Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player.getPlayer())));
BoostMultiplier itemboost = Jobs.getPlayerManager().getItemBoost(player.getPlayer(), prog);
double IMoneyBoost = itemboost.getMoneyBoost() * 100.0 - 100.0;
IMoneyBoost = (int) (IMoneyBoost * 100D) / 100D;
double IPointBoost = itemboost.getPointsBoost() * 100.0 - 100.0;
IPointBoost = (int) (IPointBoost * 100D) / 100D;
double IExpBoost = itemboost.getExpBoost() * 100.0 - 100.0;
IExpBoost = (int) (IExpBoost * 100D) / 100D;
double RBoost = Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player.getPlayer()) * 100.0 - 100.0;
RBoost = (int) (RBoost * 100D) / 100D;
double Fmoney = (int) ((IMoneyBoost + DBoost + GMoneyBoost + PMoneyBoost + RBoost) * 100) / 100D;
double Fpoints = (int) ((IPointBoost + DBoost + GPointBoost + PPointBoost + RBoost) * 100) / 100D;
double Fexp = (int) ((IExpBoost + DBoost + GExpBoost + PExpBoost + RBoost) * 100) / 100D;
return new BoostMultiplier(Fmoney, Fpoints, Fexp);
return boost;
}
public void AutoJoinJobs(final Player player) {
@ -736,4 +740,8 @@ public class PlayerManager {
}
}, Jobs.getGCManager().AutoJobJoinDelay * 20L);
}
public String getMobSpawnerMetadata() {
return mobSpawnerMetadata;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,116 +1,93 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor;
public class bonus implements Cmd {
@Override
@JobCommand(300)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
return false;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "bonus");
return true;
}
Player player = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
// sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", job.getChatColor() + job.getName()));
double PMoneyBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.MONEY, true);
PMoneyBoost = (int) (PMoneyBoost * 100D) / 100D;
double PPointBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.POINTS, true);
PPointBoost = (int) (PPointBoost * 100D) / 100D;
double PExpBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.EXP, true);
PExpBoost = (int) (PExpBoost * 100D) / 100D;
double GMoneyBoost = job.getMoneyBoost() * 100.0 - 100.0;
GMoneyBoost = (int) (GMoneyBoost * 100D) / 100D;
double GPointBoost = job.getPointBoost() * 100.0 - 100.0;
GPointBoost = (int) (GPointBoost * 100D) / 100D;
double GExpBoost = job.getExpBoost() * 100.0 - 100.0;
GExpBoost = (int) (GExpBoost * 100D) / 100D;
double DBoost = (int) (job.getBonus() * 100D) / 100D;
BoostMultiplier itemboost = Jobs.getPlayerManager().getItemBoost(player, job);
double IMoneyBoost = itemboost.getMoneyBoost() * 100.0 - 100.0;
IMoneyBoost = (int) (IMoneyBoost * 100D) / 100D;
double IPointBoost = itemboost.getPointsBoost() * 100.0 - 100.0;
IPointBoost = (int) (IPointBoost * 100D) / 100D;
double IExpBoost = itemboost.getExpBoost() * 100.0 - 100.0;
IExpBoost = (int) (IExpBoost * 100D) / 100D;
double RBoost = Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player) * 100.0 - 100.0;
RBoost = (int) (RBoost * 100D) / 100D;
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.permission",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(PMoneyBoost),
"%points%", ChatColor.GOLD.toString() + formatText(PPointBoost),
"%exp%", ChatColor.YELLOW.toString() + formatText(PExpBoost)));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.item",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(IMoneyBoost),
"%points%", ChatColor.GOLD.toString() + formatText(IPointBoost),
"%exp%", ChatColor.YELLOW.toString() + formatText(IExpBoost)));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.global",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(GMoneyBoost),
"%points%", ChatColor.GOLD.toString() + formatText(GPointBoost),
"%exp%", ChatColor.YELLOW.toString() + formatText(GExpBoost)));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.dynamic",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(DBoost),
"%points%", ChatColor.GOLD.toString() + formatText(DBoost),
"%exp%", ChatColor.YELLOW.toString() + formatText(DBoost)));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.area",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(RBoost),
"%points%", ChatColor.GOLD.toString() + formatText(RBoost),
"%exp%", ChatColor.YELLOW.toString() + formatText(RBoost)));
double Fmoney = Math.rint((IMoneyBoost + DBoost + GMoneyBoost + PMoneyBoost + RBoost) * 100) / 100;
double Fpoints = Math.rint((IPointBoost + DBoost + GPointBoost + PPointBoost + RBoost) * 100) / 100;
double Fexp = Math.rint((IExpBoost + DBoost + GExpBoost + PExpBoost + RBoost) * 100) / 100;
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(Fmoney),
"%points%", ChatColor.GOLD.toString() + formatText(Fpoints),
"%exp%", ChatColor.YELLOW.toString() + formatText(Fexp)));
return true;
}
private static String formatText(double amount) {
return ((amount > 0 ? "+" : "") + amount + "%");
}
}
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.PlayerManager.BoostOf;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Boost;
import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor;
public class bonus implements Cmd {
@Override
@JobCommand(300)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
return false;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "bonus");
return true;
}
Player player = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.permission",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Permission, BoostType.MONEY, true)),
"%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Permission, BoostType.POINTS, true)),
"%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Permission, BoostType.EXP, true))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.item",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Item, BoostType.MONEY, true)),
"%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Item, BoostType.POINTS, true)),
"%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Item, BoostType.EXP, true))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.global",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Global, BoostType.MONEY, true)),
"%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Global, BoostType.POINTS, true)),
"%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Global, BoostType.EXP, true))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.dynamic",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Dynamic, BoostType.MONEY, true)),
"%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Dynamic, BoostType.POINTS, true)),
"%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Dynamic, BoostType.EXP, true))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.area",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Area, BoostType.MONEY, true)),
"%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Area, BoostType.POINTS, true)),
"%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Area, BoostType.EXP, true))));
if (Jobs.getMcMMOlistener().mcMMOPresent && boost.get(BoostOf.McMMO, BoostType.EXP) != 0D)
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.mcmmo",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.McMMO, BoostType.MONEY, true)),
"%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.McMMO, BoostType.POINTS, true)),
"%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.McMMO, BoostType.EXP, true))));
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.getFinal(BoostType.MONEY, true)),
"%points%", ChatColor.GOLD.toString() + formatText(boost.getFinal(BoostType.POINTS, true)),
"%exp%", ChatColor.YELLOW.toString() + formatText(boost.getFinal(BoostType.EXP, true))));
return true;
}
private static String formatText(double amount) {
return ((amount > 0 ? "+" : "") + amount + "%");
}
}

View File

@ -1,78 +1,79 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor;
public class expboost implements Cmd {
@Override
@JobCommand(2300)
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 2 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
double rate = 1.0;
if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset"))
try {
rate = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
String PlayerName = sender.getName();
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.setExpBoost(1.0);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
return true;
} else if (args[0].equalsIgnoreCase("reset")) {
boolean found = false;
for (Job one : Jobs.getJobs()) {
if (one.getName().equalsIgnoreCase(args[1])) {
one.setExpBoost(1.0);
found = true;
break;
}
}
if (found) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", "%jobname%", job.getName()));
return true;
}
}
if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.setExpBoost(rate);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
return true;
}
if (job == null) {
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.setExpBoost(rate);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true;
}
}
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor;
public class expboost implements Cmd {
@Override
@JobCommand(2300)
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 2 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
double rate = 1.0;
if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset"))
try {
rate = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
String PlayerName = sender.getName();
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(BoostType.EXP, 1.0);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
return true;
} else if (args[0].equalsIgnoreCase("reset")) {
boolean found = false;
for (Job one : Jobs.getJobs()) {
if (one.getName().equalsIgnoreCase(args[1])) {
one.addBoost(BoostType.EXP, 1.0);
found = true;
break;
}
}
if (found) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", "%jobname%", job.getName()));
return true;
}
}
if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(BoostType.EXP, rate);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
return true;
}
if (job == null) {
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(BoostType.EXP, rate);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true;
}
}

View File

@ -1,79 +1,80 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor;
public class moneyboost implements Cmd {
@Override
@JobCommand(2400)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length > 2 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
double rate = 1.0;
if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset"))
try {
rate = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
String PlayerName = sender.getName();
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.setMoneyBoost(1.0);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
return true;
} else if (args[0].equalsIgnoreCase("reset")) {
boolean found = false;
for (Job one : Jobs.getJobs()) {
if (one.getName().equalsIgnoreCase(args[1])) {
one.setMoneyBoost(1.0);
found = true;
break;
}
}
if (found) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%", job.getName()));
return true;
}
}
if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.setMoneyBoost(rate);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
return true;
}
if (job == null) {
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.setMoneyBoost(rate);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true;
}
}
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor;
public class moneyboost implements Cmd {
@Override
@JobCommand(2400)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length > 2 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
double rate = 1.0;
if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset"))
try {
rate = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
String PlayerName = sender.getName();
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(BoostType.MONEY, 1.0);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
return true;
} else if (args[0].equalsIgnoreCase("reset")) {
boolean found = false;
for (Job one : Jobs.getJobs()) {
if (one.getName().equalsIgnoreCase(args[1])) {
one.addBoost(BoostType.MONEY, 1.0);
found = true;
break;
}
}
if (found) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%", job.getName()));
return true;
}
}
if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(BoostType.MONEY, rate);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
return true;
}
if (job == null) {
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(BoostType.MONEY, rate);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true;
}
}

View File

@ -1,79 +1,80 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor;
public class pointboost implements Cmd {
@Override
@JobCommand(2400)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length > 2 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
double rate = 1.0;
if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset"))
try {
rate = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
String PlayerName = sender.getName();
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.setPointBoost(1.0);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
return true;
} else if (args[0].equalsIgnoreCase("reset")) {
boolean found = false;
for (Job one : Jobs.getJobs()) {
if (one.getName().equalsIgnoreCase(args[1])) {
one.setPointBoost(1.0);
found = true;
break;
}
}
if (found) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", "%jobname%", job.getName()));
return true;
}
}
if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.setPointBoost(rate);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
return true;
}
if (job == null) {
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.setPointBoost(rate);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true;
}
}
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor;
public class pointboost implements Cmd {
@Override
@JobCommand(2400)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length > 2 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
double rate = 1.0;
if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset"))
try {
rate = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
String PlayerName = sender.getName();
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(BoostType.POINTS, 1.0);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
return true;
} else if (args[0].equalsIgnoreCase("reset")) {
boolean found = false;
for (Job one : Jobs.getJobs()) {
if (one.getName().equalsIgnoreCase(args[1])) {
one.addBoost(BoostType.POINTS, 1.0);
found = true;
break;
}
}
if (found) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", "%jobname%", job.getName()));
return true;
}
}
if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(BoostType.POINTS, rate);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
return true;
}
if (job == null) {
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(BoostType.POINTS, rate);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true;
}
}

View File

@ -37,6 +37,8 @@ import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.DisplayMethod;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobCommands;
@ -47,6 +49,7 @@ import com.gamingmesh.jobs.container.JobLimitedItems;
import com.gamingmesh.jobs.container.JobPermission;
import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
public class ConfigManager {
private Jobs plugin;
@ -341,19 +344,15 @@ public class ConfigManager {
enchants.put(ench, level);
}
Double moneyBoost = 1D;
BoostMultiplier b = new BoostMultiplier();
if (itemSection.isDouble("moneyBoost"))
moneyBoost = itemSection.getDouble("moneyBoost");
Double pointBoost = 1D;
b.add(BoostType.MONEY, itemSection.getDouble("moneyBoost") - 1);
if (itemSection.isDouble("pointBoost"))
pointBoost = itemSection.getDouble("pointBoost");
Double expBoost = 1D;
b.add(BoostType.POINTS, itemSection.getDouble("pointBoost") - 1);
if (itemSection.isDouble("expBoost"))
expBoost = itemSection.getDouble("expBoost");
jobItems.add(new JobItems(node, id, 0, 1, name, lore, enchants, moneyBoost, pointBoost, expBoost));
b.add(BoostType.EXP, itemSection.getDouble("expBoost") - 1);
jobItems.add(new JobItems(node, id, 0, 1, name, lore, enchants, b));
}
}

View File

@ -709,8 +709,8 @@ public class GeneralConfigManager {
c.getW().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 = c.get("ExploitProtections.General.PetPay", 0.1);
VipPetPay = c.get("ExploitProtections.General.VipPetPay", 1.0);
PetPay = c.get("ExploitProtections.General.PetPay", 0.1) - 1D;
VipPetPay = c.get("ExploitProtections.General.VipPetPay", 1.0) - 1D;
c.getW().addComment("ExploitProtections.McMMO", "McMMO abilities");
c.getW().addComment("ExploitProtections.McMMO.TreeFellerMultiplier", "Players will get part of money from cutting trees with treefeller ability enabled.",
@ -741,9 +741,9 @@ public class GeneralConfigManager {
"Use: jobs.boost.[jobname].money or jobs.boost.[jobname].exp or jobs.boost.[jobname].points or jobs.boost.[jobname].all for all of them with specific jobs name.",
"Use: jobs.boost.all.money or jobs.boost.all.exp or jobs.boost.all.points or jobs.boost.all.all 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");
Boost.put(BoostType.EXP, c.get("boost.exp", 1.00));
Boost.put(BoostType.MONEY, c.get("boost.money", 1.00));
Boost.put(BoostType.POINTS, c.get("boost.points", 1.00));
Boost.put(BoostType.EXP, c.get("boost.exp", 1D) - 1D);
Boost.put(BoostType.MONEY, c.get("boost.money", 1D) - 1D);
Boost.put(BoostType.POINTS, c.get("boost.points", 1D) - 1D);
c.getW().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");

View File

@ -112,6 +112,7 @@ public class LanguageManager {
c.get("command.bonus.output.global", " &eGlobal bonus: %money% %points% %exp%");
c.get("command.bonus.output.dynamic", " &eDynamic payment bonus: %money% %points% %exp%");
c.get("command.bonus.output.area", " &eArea bonus: %money% %points% %exp%");
c.get("command.bonus.output.mcmmo", " &eMcMMO bonus: %money% %points% %exp%");
c.get("command.bonus.output.final", " &eFinal bonus: %money% %points% %exp%");
c.get("command.convert.help.info",

View File

@ -1,112 +1,112 @@
package com.gamingmesh.jobs.config;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.RestrictedArea;
import com.gamingmesh.jobs.stuff.ChatColor;
public class RestrictedAreaManager {
protected ArrayList<RestrictedArea> restrictedAreas = new ArrayList<RestrictedArea>();
private Jobs plugin;
public RestrictedAreaManager(Jobs plugin) {
this.plugin = plugin;
}
/**
* Gets the area multiplier for the player
* @param player
* @return - the multiplier
*/
public synchronized double getRestrictedMultiplier(Player player) {
for (RestrictedArea area : restrictedAreas) {
if (area.inRestrictedArea(player))
return area.getMultiplier();
}
return 1.0;
}
/**
* Method to load the restricted areas configuration
*
* loads from Jobs/restrictedAreas.yml
*/
public synchronized void load() {
this.restrictedAreas.clear();
File f = new File(plugin.getDataFolder(), "restrictedAreas.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
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");
conf.options().header(header.toString());
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
if (areaSection != null) {
for (String areaKey : areaSection.getKeys(false)) {
String worldName = conf.getString("restrictedareas." + areaKey + ".world");
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0.0);
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 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));
}
}
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!");
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
}
package com.gamingmesh.jobs.config;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.RestrictedArea;
import com.gamingmesh.jobs.stuff.ChatColor;
public class RestrictedAreaManager {
protected ArrayList<RestrictedArea> restrictedAreas = new ArrayList<RestrictedArea>();
private Jobs plugin;
public RestrictedAreaManager(Jobs plugin) {
this.plugin = plugin;
}
/**
* Gets the area multiplier for the player
* @param player
* @return - the multiplier
*/
public synchronized double getRestrictedMultiplier(Player player) {
for (RestrictedArea area : restrictedAreas) {
if (area.inRestrictedArea(player))
return area.getMultiplier();
}
return 0D;
}
/**
* Method to load the restricted areas configuration
*
* loads from Jobs/restrictedAreas.yml
*/
public synchronized void load() {
this.restrictedAreas.clear();
File f = new File(plugin.getDataFolder(), "restrictedAreas.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
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");
conf.options().header(header.toString());
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
if (areaSection != null) {
for (String areaKey : areaSection.getKeys(false)) {
String worldName = conf.getString("restrictedareas." + areaKey + ".world");
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0.0);
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 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));
}
}
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!");
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -13,6 +13,8 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.BoostType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.Schedule;
import com.gamingmesh.jobs.stuff.ChatColor;
@ -90,8 +92,7 @@ public class ScheduleManager {
}
for (Job onejob : one.GetJobs()) {
onejob.setExpBoost(one.GetExpBoost());
onejob.setMoneyBoost(one.GetMoneyBoost());
onejob.setBoost(one.getBoost());
}
one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000);
@ -109,8 +110,7 @@ public class ScheduleManager {
Bukkit.broadcastMessage(oneMsg);
}
for (Job onejob : one.GetJobs()) {
onejob.setExpBoost(1.0);
onejob.setMoneyBoost(1.0);
onejob.setBoost(new BoostMultiplier());
}
one.setStoped(true);
one.setStarted(false);
@ -191,12 +191,6 @@ public class ScheduleManager {
if (!path.contains("Jobs") || !path.isList("Jobs"))
continue;
if (!path.contains("Exp") || !path.isDouble("Exp"))
continue;
if (!path.contains("Money") || !path.isDouble("Money"))
continue;
sched.setDays(path.getStringList("Days"));
sched.setJobs(path.getStringList("Jobs"));
sched.setFrom(Integer.valueOf(path.getString("From").replace(":", "")));
@ -220,8 +214,12 @@ public class ScheduleManager {
if (path.contains("BroadcastMessage") && path.isList("BroadcastMessage"))
sched.setMessageToBroadcast(path.getStringList("BroadcastMessage"), path.getString("From"), path.getString("Until"));
sched.setExpBoost(path.getDouble("Exp"));
sched.setMoneyBoost(path.getDouble("Money"));
if (path.contains("Exp") && path.isDouble("Exp"))
sched.setBoost(BoostType.EXP, path.getDouble("Exp", 0D));
if (path.contains("Money") && path.isDouble("Money"))
sched.setBoost(BoostType.MONEY, path.getDouble("Money", 0D));
if (path.contains("Points") && path.isDouble("Points"))
sched.setBoost(BoostType.POINTS, path.getDouble("Points", 0D));
Jobs.getGCManager().BoostSchedule.add(sched);
}
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + Jobs.getGCManager().BoostSchedule.size() + " schedulers!");

View File

@ -1,479 +1,480 @@
package com.gamingmesh.jobs.config;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.Jobs;
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.PlayerPoints;
import com.gamingmesh.jobs.container.ShopItem;
import com.gamingmesh.jobs.stuff.Perm;
public class ShopManager {
private Jobs plugin;
public List<ShopItem> list = new ArrayList<ShopItem>();
public HashMap<String, Integer> GuiList = new HashMap<String, Integer>();
public ShopManager(Jobs plugin) {
this.plugin = plugin;
}
public List<ShopItem> getShopItemList() {
return list;
}
public void openInventory(Player player, int page) {
Inventory inv = Jobs.getShopManager().CreateJobsGUI(player, page);
if (inv == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.cantOpen"));
return;
}
Inventory topinv = player.getOpenInventory().getTopInventory();
if (topinv != null)
player.closeInventory();
Jobs.getShopManager().GuiList.put(player.getName(), page);
player.openInventory(inv);
}
public void checkSlot(Player player, int slot, int page) {
List<ShopItem> ls = getItemsByPage(page);
int GuiSize = getGuiSize(ls, page);
if (slot == getPrevButtonSlot(GuiSize, page)) {
openInventory(player, page - 1);
return;
}
if (slot == getnextButtonSlot(GuiSize, page)) {
openInventory(player, page + 1);
return;
}
if (slot > ls.size() - 1)
return;
ShopItem item = ls.get(slot);
PlayerPoints pointsInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getUniqueId());
if (!Perm.hasPermission(player, "jobs.items.bypass")) {
for (String onePerm : item.getRequiredPerm()) {
if (!Perm.hasPermission(player, onePerm)) {
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPermForItem"));
return;
}
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
for (Entry<String, Integer> oneJob : item.getRequiredJobs().entrySet()) {
Job tempJob = Jobs.getJob(oneJob.getKey());
if (tempJob == null)
continue;
JobProgression playerJob = jPlayer.getJobProgression(tempJob);
if (playerJob == null || playerJob.getLevel() < oneJob.getValue()) {
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoJobReqForitem",
"%jobname%", tempJob.getName(),
"%joblevel%", oneJob.getValue()));
return;
}
}
if (pointsInfo == null || pointsInfo.getCurrentPoints() < item.getPrice()) {
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
return;
}
}
for (String one : item.getCommands()) {
if (one.toLowerCase().startsWith("msg "))
player.sendMessage(one.substring(4, one.length()).replace("[player]", player.getName()));
else
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[player]", player.getName()));
}
for (JobItems one : item.getitems()) {
@SuppressWarnings("deprecation")
Material mat = Material.getMaterial(one.getId());
if (mat == null)
continue;
ItemStack itemStack = new ItemStack(mat, one.getAmount(), (byte) one.getData());
ItemMeta meta = itemStack.getItemMeta();
if (one.getName() != null)
meta.setDisplayName(one.getName());
if (one.getLore() != null)
meta.setLore(one.getLore());
itemStack.setItemMeta(meta);
if (itemStack.getType() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) itemStack.getItemMeta();
for (Entry<Enchantment, Integer> oneEnch : one.getEnchants().entrySet()) {
bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true);
}
if (bookMeta != null)
itemStack.setItemMeta(bookMeta);
} else
for (Entry<Enchantment, Integer> oneEnch : one.getEnchants().entrySet()) {
itemStack.addUnsafeEnchantment(oneEnch.getKey(), oneEnch.getValue());
}
player.getInventory().addItem(itemStack);
}
if (!Perm.hasPermission(player, "jobs.items.bypass")) {
pointsInfo.takePoints(item.getPrice());
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPrice()));
}
player.getOpenInventory().getTopInventory().setContents(CreateJobsGUI(player, page).getContents());
}
private List<ShopItem> getItemsByPage(Integer page) {
List<ShopItem> ls = new ArrayList<ShopItem>();
for (ShopItem one : list) {
if (one.getPage() == page)
ls.add(one);
}
return ls;
}
private static int getGuiSize(List<ShopItem> ls, int page) {
int GuiSize = 9;
if (ls.size() > 9)
GuiSize = 18;
if (ls.size() > 18)
GuiSize = 27;
if (ls.size() > 27)
GuiSize = 36;
if (ls.size() > 36)
GuiSize = 45;
if (ls.size() == 45)
GuiSize = 54;
if (page > 1 && GuiSize < 54)
GuiSize += 9;
return GuiSize;
}
private static int getPrevButtonSlot(int GuiSize, int page) {
int prev = -1;
if (page > 1)
prev = GuiSize - 9;
return prev;
}
private int getnextButtonSlot(int GuiSize, int page) {
int next = -1;
List<ShopItem> lsnext = getItemsByPage(page + 1);
if (!lsnext.isEmpty())
next = GuiSize - 1;
return next;
}
public Inventory CreateJobsGUI(Player player, Integer page) {
List<ShopItem> ls = getItemsByPage(page);
if (ls.isEmpty())
return null;
int GuiSize = getGuiSize(ls, page);
String title = Jobs.getLanguage().getMessage("command.shop.info.title");
if (title.length() > 32)
title = title.substring(0, 30) + "..";
PlayerPoints pointsInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getUniqueId());
double points = 0D;
if (pointsInfo != null)
points = (int) (pointsInfo.getCurrentPoints() * 100.0) / 100.0;
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
for (int i = 0; i < ls.size(); i++) {
ShopItem item = ls.get(i);
ArrayList<String> Lore = new ArrayList<String>();
@SuppressWarnings("deprecation")
Material mat = Material.getMaterial(item.getIconId());
if (item.isHideWithoutPerm()) {
for (String onePerm : item.getRequiredPerm()) {
if (!Perm.hasPermission(player, onePerm)) {
mat = Material.STONE_BUTTON;
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
break;
}
}
}
if (mat == null)
mat = Material.STONE_BUTTON;
ItemStack GUIitem = new ItemStack(mat, item.getIconAmount(), (byte) item.getIconData());
ItemMeta meta = GUIitem.getItemMeta();
if (item.getIconName() != null)
meta.setDisplayName(item.getIconName());
Lore.addAll(item.getIconLore());
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.currentPoints", "%currentpoints%", points));
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.price", "%price%", item.getPrice()));
if (!item.getRequiredJobs().isEmpty()) {
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobs"));
for (Entry<String, Integer> one : item.getRequiredJobs().entrySet()) {
String jobColor = "";
String levelColor = "";
Job job = Jobs.getJob(one.getKey());
JobProgression prog = Jobs.getPlayerManager().getJobsPlayer(player).getJobProgression(job);
if (prog == null) {
jobColor = ChatColor.DARK_RED.toString();
levelColor = ChatColor.DARK_RED.toString();
}
if (prog != null && prog.getLevel() < one.getValue())
levelColor = ChatColor.DARK_RED.toString();
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobsList", "%jobsname%", jobColor + one.getKey(), "%level%", levelColor + one
.getValue()));
}
}
meta.setLore(Lore);
GUIitem.setItemMeta(meta);
GuiInv.setItem(i, GUIitem);
}
ItemStack Item = new ItemStack(Material.ARROW);
ItemMeta meta = Item.getItemMeta();
int pervSlot = getPrevButtonSlot(GuiSize, page);
if (pervSlot != -1) {
meta.setDisplayName(Jobs.getLanguage().getMessage("command.help.output.prev"));
Item.setItemMeta(meta);
GuiInv.setItem(pervSlot, Item);
}
int nextSlot = getnextButtonSlot(GuiSize, page);
if (nextSlot != -1) {
meta.setDisplayName(Jobs.getLanguage().getMessage("command.help.output.next"));
Item.setItemMeta(meta);
GuiInv.setItem(nextSlot, Item);
}
return GuiInv;
}
public void load() {
list.clear();
File file = new File(plugin.getDataFolder(), "shopItems.yml");
YamlConfiguration f = YamlConfiguration.loadConfiguration(file);
if (!f.isConfigurationSection("Items"))
return;
ConfigurationSection ConfCategory = f.getConfigurationSection("Items");
ArrayList<String> categoriesList = new ArrayList<String>(ConfCategory.getKeys(false));
if (categoriesList.size() == 0)
return;
int i = 0;
int y = 1;
for (String category : categoriesList) {
ConfigurationSection NameSection = ConfCategory.getConfigurationSection(category);
if (!NameSection.isDouble("Price")) {
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Price property. Skipping!");
continue;
}
double price = NameSection.getDouble("Price");
if (!NameSection.isInt("Icon.Id")) {
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Icon Id property. Skipping!");
continue;
}
int IconId = NameSection.getInt("Icon.Id");
ShopItem Sitem = new ShopItem(category, price, IconId);
if (NameSection.isInt("Icon.Data"))
Sitem.setIconData(NameSection.getInt("Icon.Data"));
if (NameSection.isInt("Icon.Amount"))
Sitem.setIconAmount(NameSection.getInt("Icon.Amount"));
if (NameSection.isString("Icon.Name"))
Sitem.setIconName(ChatColor.translateAlternateColorCodes('&', NameSection.getString("Icon.Name")));
if (NameSection.isList("Icon.Lore")) {
List<String> lore = new ArrayList<String>();
if (NameSection.getStringList("Icon.Lore") != null)
for (String eachLine : NameSection.getStringList("Icon.Lore")) {
lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
}
Sitem.setIconLore(lore);
}
if (NameSection.isBoolean("Icon.HideWithoutPermission")) {
Sitem.setHideWithoutPerm(NameSection.getBoolean("Icon.HideWithoutPermission"));
}
if (NameSection.isList("RequiredPermission"))
Sitem.setRequiredPerm(NameSection.getStringList("RequiredPermission"));
if (NameSection.isList("RequiredJobLevels")) {
HashMap<String, Integer> RequiredJobs = new HashMap<String, Integer>();
for (String one : NameSection.getStringList("RequiredJobLevels")) {
if (!one.contains("-"))
continue;
String job = one.split("-")[0];
int lvl = -1;
try {
lvl = Integer.parseInt(one.split("-")[1]);
} catch (NumberFormatException e) {
continue;
}
RequiredJobs.put(job, lvl);
}
Sitem.setRequiredJobs(RequiredJobs);
}
if (NameSection.isList("PerformCommands")) {
List<String> cmd = new ArrayList<String>();
if (NameSection.getStringList("PerformCommands") != null)
for (String eachLine : NameSection.getStringList("PerformCommands")) {
cmd.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
}
Sitem.setCommands(cmd);
}
if (NameSection.isConfigurationSection("GiveItems")) {
ConfigurationSection itemsSection = NameSection.getConfigurationSection("GiveItems");
Set<String> itemKeys = itemsSection.getKeys(false);
List<JobItems> items = new ArrayList<JobItems>();
for (String oneItemName : itemKeys) {
ConfigurationSection itemSection = itemsSection.getConfigurationSection(oneItemName);
String node = oneItemName.toLowerCase();
int id = itemSection.getInt("Id");
int data = 0;
if (itemSection.isInt("Data"))
data = itemSection.getInt("Data");
int amount = 1;
if (itemSection.isInt("Amount"))
amount = itemSection.getInt("Amount");
String name = null;
if (itemSection.isString("Name"))
name = org.bukkit.ChatColor.translateAlternateColorCodes('&', itemSection.getString("Name"));
List<String> lore = new ArrayList<String>();
if (itemSection.getStringList("Lore") != null)
for (String eachLine : itemSection.getStringList("Lore")) {
lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
}
HashMap<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
if (itemSection.getStringList("Enchants") != null)
for (String eachLine : itemSection.getStringList("Enchants")) {
if (!eachLine.contains("="))
continue;
Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]);
Integer level = -1;
try {
level = Integer.parseInt(eachLine.split("=")[1]);
} catch (NumberFormatException e) {
continue;
}
if (ench != null && level != -1)
enchants.put(ench, level);
}
items.add(new JobItems(node, id, data, amount, name, lore, enchants, 0, 0, 0));
}
Sitem.setitems(items);
}
// if (list.size() >= 54) {
// Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Jobs] To many jobs shop items, max allowed is 54! Only first 54 items will be used!");
// break;
// }
i++;
if (i > 45) {
i = 1;
y++;
}
Sitem.setSlot(i);
Sitem.setPage(y);
list.add(Sitem);
}
if (!list.isEmpty())
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] " + list.size() + " shop items loaded!");
return;
}
public void CloseInventories() {
for (Entry<String, Integer> one : GuiList.entrySet()) {
Player player = Bukkit.getPlayer(one.getKey());
if (player != null) {
player.closeInventory();
}
}
}
}
package com.gamingmesh.jobs.config;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.BoostMultiplier;
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.PlayerPoints;
import com.gamingmesh.jobs.container.ShopItem;
import com.gamingmesh.jobs.stuff.Perm;
public class ShopManager {
private Jobs plugin;
public List<ShopItem> list = new ArrayList<ShopItem>();
public HashMap<String, Integer> GuiList = new HashMap<String, Integer>();
public ShopManager(Jobs plugin) {
this.plugin = plugin;
}
public List<ShopItem> getShopItemList() {
return list;
}
public void openInventory(Player player, int page) {
Inventory inv = Jobs.getShopManager().CreateJobsGUI(player, page);
if (inv == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.cantOpen"));
return;
}
Inventory topinv = player.getOpenInventory().getTopInventory();
if (topinv != null)
player.closeInventory();
Jobs.getShopManager().GuiList.put(player.getName(), page);
player.openInventory(inv);
}
public void checkSlot(Player player, int slot, int page) {
List<ShopItem> ls = getItemsByPage(page);
int GuiSize = getGuiSize(ls, page);
if (slot == getPrevButtonSlot(GuiSize, page)) {
openInventory(player, page - 1);
return;
}
if (slot == getnextButtonSlot(GuiSize, page)) {
openInventory(player, page + 1);
return;
}
if (slot > ls.size() - 1)
return;
ShopItem item = ls.get(slot);
PlayerPoints pointsInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getUniqueId());
if (!Perm.hasPermission(player, "jobs.items.bypass")) {
for (String onePerm : item.getRequiredPerm()) {
if (!Perm.hasPermission(player, onePerm)) {
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPermForItem"));
return;
}
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
for (Entry<String, Integer> oneJob : item.getRequiredJobs().entrySet()) {
Job tempJob = Jobs.getJob(oneJob.getKey());
if (tempJob == null)
continue;
JobProgression playerJob = jPlayer.getJobProgression(tempJob);
if (playerJob == null || playerJob.getLevel() < oneJob.getValue()) {
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoJobReqForitem",
"%jobname%", tempJob.getName(),
"%joblevel%", oneJob.getValue()));
return;
}
}
if (pointsInfo == null || pointsInfo.getCurrentPoints() < item.getPrice()) {
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
return;
}
}
for (String one : item.getCommands()) {
if (one.toLowerCase().startsWith("msg "))
player.sendMessage(one.substring(4, one.length()).replace("[player]", player.getName()));
else
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[player]", player.getName()));
}
for (JobItems one : item.getitems()) {
@SuppressWarnings("deprecation")
Material mat = Material.getMaterial(one.getId());
if (mat == null)
continue;
ItemStack itemStack = new ItemStack(mat, one.getAmount(), (byte) one.getData());
ItemMeta meta = itemStack.getItemMeta();
if (one.getName() != null)
meta.setDisplayName(one.getName());
if (one.getLore() != null)
meta.setLore(one.getLore());
itemStack.setItemMeta(meta);
if (itemStack.getType() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) itemStack.getItemMeta();
for (Entry<Enchantment, Integer> oneEnch : one.getEnchants().entrySet()) {
bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true);
}
if (bookMeta != null)
itemStack.setItemMeta(bookMeta);
} else
for (Entry<Enchantment, Integer> oneEnch : one.getEnchants().entrySet()) {
itemStack.addUnsafeEnchantment(oneEnch.getKey(), oneEnch.getValue());
}
player.getInventory().addItem(itemStack);
}
if (!Perm.hasPermission(player, "jobs.items.bypass")) {
pointsInfo.takePoints(item.getPrice());
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPrice()));
}
player.getOpenInventory().getTopInventory().setContents(CreateJobsGUI(player, page).getContents());
}
private List<ShopItem> getItemsByPage(Integer page) {
List<ShopItem> ls = new ArrayList<ShopItem>();
for (ShopItem one : list) {
if (one.getPage() == page)
ls.add(one);
}
return ls;
}
private static int getGuiSize(List<ShopItem> ls, int page) {
int GuiSize = 9;
if (ls.size() > 9)
GuiSize = 18;
if (ls.size() > 18)
GuiSize = 27;
if (ls.size() > 27)
GuiSize = 36;
if (ls.size() > 36)
GuiSize = 45;
if (ls.size() == 45)
GuiSize = 54;
if (page > 1 && GuiSize < 54)
GuiSize += 9;
return GuiSize;
}
private static int getPrevButtonSlot(int GuiSize, int page) {
int prev = -1;
if (page > 1)
prev = GuiSize - 9;
return prev;
}
private int getnextButtonSlot(int GuiSize, int page) {
int next = -1;
List<ShopItem> lsnext = getItemsByPage(page + 1);
if (!lsnext.isEmpty())
next = GuiSize - 1;
return next;
}
public Inventory CreateJobsGUI(Player player, Integer page) {
List<ShopItem> ls = getItemsByPage(page);
if (ls.isEmpty())
return null;
int GuiSize = getGuiSize(ls, page);
String title = Jobs.getLanguage().getMessage("command.shop.info.title");
if (title.length() > 32)
title = title.substring(0, 30) + "..";
PlayerPoints pointsInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getUniqueId());
double points = 0D;
if (pointsInfo != null)
points = (int) (pointsInfo.getCurrentPoints() * 100.0) / 100.0;
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
for (int i = 0; i < ls.size(); i++) {
ShopItem item = ls.get(i);
ArrayList<String> Lore = new ArrayList<String>();
@SuppressWarnings("deprecation")
Material mat = Material.getMaterial(item.getIconId());
if (item.isHideWithoutPerm()) {
for (String onePerm : item.getRequiredPerm()) {
if (!Perm.hasPermission(player, onePerm)) {
mat = Material.STONE_BUTTON;
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
break;
}
}
}
if (mat == null)
mat = Material.STONE_BUTTON;
ItemStack GUIitem = new ItemStack(mat, item.getIconAmount(), (byte) item.getIconData());
ItemMeta meta = GUIitem.getItemMeta();
if (item.getIconName() != null)
meta.setDisplayName(item.getIconName());
Lore.addAll(item.getIconLore());
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.currentPoints", "%currentpoints%", points));
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.price", "%price%", item.getPrice()));
if (!item.getRequiredJobs().isEmpty()) {
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobs"));
for (Entry<String, Integer> one : item.getRequiredJobs().entrySet()) {
String jobColor = "";
String levelColor = "";
Job job = Jobs.getJob(one.getKey());
JobProgression prog = Jobs.getPlayerManager().getJobsPlayer(player).getJobProgression(job);
if (prog == null) {
jobColor = ChatColor.DARK_RED.toString();
levelColor = ChatColor.DARK_RED.toString();
}
if (prog != null && prog.getLevel() < one.getValue())
levelColor = ChatColor.DARK_RED.toString();
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobsList", "%jobsname%", jobColor + one.getKey(), "%level%", levelColor + one
.getValue()));
}
}
meta.setLore(Lore);
GUIitem.setItemMeta(meta);
GuiInv.setItem(i, GUIitem);
}
ItemStack Item = new ItemStack(Material.ARROW);
ItemMeta meta = Item.getItemMeta();
int pervSlot = getPrevButtonSlot(GuiSize, page);
if (pervSlot != -1) {
meta.setDisplayName(Jobs.getLanguage().getMessage("command.help.output.prev"));
Item.setItemMeta(meta);
GuiInv.setItem(pervSlot, Item);
}
int nextSlot = getnextButtonSlot(GuiSize, page);
if (nextSlot != -1) {
meta.setDisplayName(Jobs.getLanguage().getMessage("command.help.output.next"));
Item.setItemMeta(meta);
GuiInv.setItem(nextSlot, Item);
}
return GuiInv;
}
public void load() {
list.clear();
File file = new File(plugin.getDataFolder(), "shopItems.yml");
YamlConfiguration f = YamlConfiguration.loadConfiguration(file);
if (!f.isConfigurationSection("Items"))
return;
ConfigurationSection ConfCategory = f.getConfigurationSection("Items");
ArrayList<String> categoriesList = new ArrayList<String>(ConfCategory.getKeys(false));
if (categoriesList.size() == 0)
return;
int i = 0;
int y = 1;
for (String category : categoriesList) {
ConfigurationSection NameSection = ConfCategory.getConfigurationSection(category);
if (!NameSection.isDouble("Price")) {
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Price property. Skipping!");
continue;
}
double price = NameSection.getDouble("Price");
if (!NameSection.isInt("Icon.Id")) {
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Icon Id property. Skipping!");
continue;
}
int IconId = NameSection.getInt("Icon.Id");
ShopItem Sitem = new ShopItem(category, price, IconId);
if (NameSection.isInt("Icon.Data"))
Sitem.setIconData(NameSection.getInt("Icon.Data"));
if (NameSection.isInt("Icon.Amount"))
Sitem.setIconAmount(NameSection.getInt("Icon.Amount"));
if (NameSection.isString("Icon.Name"))
Sitem.setIconName(ChatColor.translateAlternateColorCodes('&', NameSection.getString("Icon.Name")));
if (NameSection.isList("Icon.Lore")) {
List<String> lore = new ArrayList<String>();
if (NameSection.getStringList("Icon.Lore") != null)
for (String eachLine : NameSection.getStringList("Icon.Lore")) {
lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
}
Sitem.setIconLore(lore);
}
if (NameSection.isBoolean("Icon.HideWithoutPermission")) {
Sitem.setHideWithoutPerm(NameSection.getBoolean("Icon.HideWithoutPermission"));
}
if (NameSection.isList("RequiredPermission"))
Sitem.setRequiredPerm(NameSection.getStringList("RequiredPermission"));
if (NameSection.isList("RequiredJobLevels")) {
HashMap<String, Integer> RequiredJobs = new HashMap<String, Integer>();
for (String one : NameSection.getStringList("RequiredJobLevels")) {
if (!one.contains("-"))
continue;
String job = one.split("-")[0];
int lvl = -1;
try {
lvl = Integer.parseInt(one.split("-")[1]);
} catch (NumberFormatException e) {
continue;
}
RequiredJobs.put(job, lvl);
}
Sitem.setRequiredJobs(RequiredJobs);
}
if (NameSection.isList("PerformCommands")) {
List<String> cmd = new ArrayList<String>();
if (NameSection.getStringList("PerformCommands") != null)
for (String eachLine : NameSection.getStringList("PerformCommands")) {
cmd.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
}
Sitem.setCommands(cmd);
}
if (NameSection.isConfigurationSection("GiveItems")) {
ConfigurationSection itemsSection = NameSection.getConfigurationSection("GiveItems");
Set<String> itemKeys = itemsSection.getKeys(false);
List<JobItems> items = new ArrayList<JobItems>();
for (String oneItemName : itemKeys) {
ConfigurationSection itemSection = itemsSection.getConfigurationSection(oneItemName);
String node = oneItemName.toLowerCase();
int id = itemSection.getInt("Id");
int data = 0;
if (itemSection.isInt("Data"))
data = itemSection.getInt("Data");
int amount = 1;
if (itemSection.isInt("Amount"))
amount = itemSection.getInt("Amount");
String name = null;
if (itemSection.isString("Name"))
name = org.bukkit.ChatColor.translateAlternateColorCodes('&', itemSection.getString("Name"));
List<String> lore = new ArrayList<String>();
if (itemSection.getStringList("Lore") != null)
for (String eachLine : itemSection.getStringList("Lore")) {
lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
}
HashMap<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
if (itemSection.getStringList("Enchants") != null)
for (String eachLine : itemSection.getStringList("Enchants")) {
if (!eachLine.contains("="))
continue;
Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]);
Integer level = -1;
try {
level = Integer.parseInt(eachLine.split("=")[1]);
} catch (NumberFormatException e) {
continue;
}
if (ench != null && level != -1)
enchants.put(ench, level);
}
items.add(new JobItems(node, id, data, amount, name, lore, enchants, new BoostMultiplier()));
}
Sitem.setitems(items);
}
// if (list.size() >= 54) {
// Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Jobs] To many jobs shop items, max allowed is 54! Only first 54 items will be used!");
// break;
// }
i++;
if (i > 45) {
i = 1;
y++;
}
Sitem.setSlot(i);
Sitem.setPage(y);
list.add(Sitem);
}
if (!list.isEmpty())
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] " + list.size() + " shop items loaded!");
return;
}
public void CloseInventories() {
for (Entry<String, Integer> one : GuiList.entrySet()) {
Player player = Bukkit.getPlayer(one.getKey());
if (player != null) {
player.closeInventory();
}
}
}
}

View File

@ -41,3 +41,4 @@
/BlockProtection.class
/BpDBAction.class
/DBAction.class
/Boost.class

View File

@ -0,0 +1,59 @@
package com.gamingmesh.jobs.container;
import java.util.HashMap;
import com.gamingmesh.jobs.PlayerManager.BoostOf;
public class Boost {
HashMap<BoostOf, BoostMultiplier> map = new HashMap<BoostOf, BoostMultiplier>();
public Boost() {
for (BoostOf one : BoostOf.values()) {
map.put(one, new BoostMultiplier());
}
}
public void add(BoostOf boostoff, BoostMultiplier BM) {
map.put(boostoff, BM);
}
public BoostMultiplier get(BoostOf boostoff) {
if (!map.containsKey(boostoff))
return new BoostMultiplier();
return map.get(boostoff);
}
public double get(BoostOf boostoff, BoostType BT) {
return get(boostoff, BT, false);
}
public double get(BoostOf boostoff, BoostType BT, boolean percent) {
if (!map.containsKey(boostoff))
return 0D;
double r = map.get(boostoff).get(BT);
if (r < -1)
r = -1;
if (percent)
return (int)(r * 100);
return r;
}
public double getFinal(BoostType BT) {
return getFinal(BT, false);
}
public double getFinal(BoostType BT, boolean percent) {
double r = 0D;
for (BoostOf one : BoostOf.values()) {
if (!map.containsKey(one))
continue;
r += map.get(one).get(BT);
}
if (r < -1)
r = -1;
if (percent)
return (int)(r * 100);
return r;
}
}

View File

@ -1,25 +1,39 @@
package com.gamingmesh.jobs.container;
public class BoostMultiplier {
double money;
double points;
double exp;
public BoostMultiplier(double money, double points, double exp) {
this.money = money;
this.points = points;
this.exp = exp;
}
public double getMoneyBoost() {
return this.money;
}
public double getPointsBoost() {
return this.points;
}
public double getExpBoost() {
return this.exp;
}
}
package com.gamingmesh.jobs.container;
import java.util.HashMap;
public class BoostMultiplier {
HashMap<BoostType, Double> map = new HashMap<BoostType, Double>();
public BoostMultiplier() {
for (BoostType one : BoostType.values()) {
map.put(one, 0D);
}
}
public BoostMultiplier add(BoostType type, double amount) {
map.put(type, amount);
return this;
}
public BoostMultiplier add(double amount) {
for (BoostType one : BoostType.values()) {
map.put(one, amount);
}
return this;
}
public double get(BoostType type) {
if (!map.containsKey(type))
return 0D;
return this.map.get(type);
}
public void add(BoostMultiplier armorboost) {
for (BoostType one : BoostType.values()) {
double r = armorboost.get(one);
map.put(one, get(one) + r);
}
}
}

View File

@ -71,11 +71,7 @@ public class Job {
private int totalPlayers = -1;
private double bonus = 0.0;
private double ExpBoost = 1.0;
private double MoneyBoost = 1.0;
private double PointBoost = 1.0;
private BoostMultiplier boost = new BoostMultiplier();
/**
* Constructor
@ -117,34 +113,22 @@ public class Job {
this.CmdOnLeave = CmdOnLeave;
this.GUIitem = GUIitem;
}
public void addBoost(BoostType type, double Point) {
this.boost.add(type, Point - 1D);
}
public void setPointBoost(double Point) {
this.PointBoost = Point;
public void setBoost(BoostMultiplier BM) {
this.boost = BM;
}
public BoostMultiplier getBoost() {
return this.boost;
}
public boolean isSame(Job job) {
return this.getName().equalsIgnoreCase(job.getName());
}
public double getPointBoost() {
return this.PointBoost;
}
public void setMoneyBoost(double amount) {
this.MoneyBoost = amount;
}
public double getMoneyBoost() {
return this.MoneyBoost;
}
public void setExpBoost(double amount) {
this.ExpBoost = amount;
}
public double getExpBoost() {
return this.ExpBoost;
}
public int getTotalPlayers() {
if (this.totalPlayers == -1) {
@ -220,10 +204,10 @@ public class Job {
public EnumMap<ActionType, List<JobInfo>> getJobInfoList() {
return jobInfo;
}
public JobInfo getJobInfo(ActionInfo action, int level) {
for (JobInfo info : getJobInfo(action.getType())) {
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub())){
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub())) {
if (!info.isInLevelRange(level))
break;
return info;

View File

@ -31,12 +31,9 @@ public class JobItems {
private String name;
private List<String> lore;
private HashMap<Enchantment, Integer> enchants;
private Double moneyBoost = 0D;
private Double pointBoost = 0D;
private Double expBoost = 0D;
private BoostMultiplier boostMultiplier = new BoostMultiplier();
public JobItems(String node, int id, int data, int amount, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, double moneyBoost,
double pointBoost, double expBoost) {
public JobItems(String node, int id, int data, int amount, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, BoostMultiplier boostMultiplier) {
this.node = node;
this.id = id;
this.data = data;
@ -44,9 +41,7 @@ public class JobItems {
this.name = name;
this.lore = lore;
this.enchants = enchants;
this.moneyBoost = moneyBoost;
this.pointBoost = pointBoost;
this.expBoost = expBoost;
this.boostMultiplier = boostMultiplier;
}
public String getNode() {
@ -77,15 +72,7 @@ public class JobItems {
return this.enchants;
}
public Double getMoneyBoost() {
return this.moneyBoost;
}
public Double getPointBoost() {
return this.pointBoost;
}
public Double getExpBoost() {
return this.expBoost;
public BoostMultiplier getBoost() {
return this.boostMultiplier;
}
}

View File

@ -53,7 +53,7 @@ public class JobsPlayer {
private OfflinePlayer OffPlayer = null;
private Player player = null;
private double VipSpawnerMultiplier = -1;
private double VipSpawnerMultiplier = 0D;
private int MoneyLimit = 0;
private int ExpLimit = 0;
@ -70,7 +70,7 @@ public class JobsPlayer {
private List<Log> logList = new ArrayList<Log>();
private Long seen;
public JobsPlayer(String userName, OfflinePlayer player) {
this.userName = userName;
this.OffPlayer = player;
@ -131,7 +131,7 @@ public class JobsPlayer {
*/
public double getVipSpawnerMultiplier() {
if (this.getPlayer() == null || !this.getPlayer().isOnline())
return 1.0;
return 0D;
if (VipSpawnerMultiplier < 0)
updateVipSpawnerMultiplier();
return this.VipSpawnerMultiplier;
@ -139,9 +139,9 @@ public class JobsPlayer {
public void updateVipSpawnerMultiplier() {
if (Perm.hasPermission(this.player, "jobs.vipspawner"))
this.VipSpawnerMultiplier = Jobs.getGCManager().VIPpayNearSpawnerMultiplier;
this.VipSpawnerMultiplier = Jobs.getGCManager().VIPpayNearSpawnerMultiplier - 1;
else
this.VipSpawnerMultiplier = Jobs.getGCManager().payNearSpawnerMultiplier;
this.VipSpawnerMultiplier = Jobs.getGCManager().payNearSpawnerMultiplier - 1;
}
/**

View File

@ -33,20 +33,20 @@ public class RestrictedArea {
private Location location1;
private Location location2;
private double multiplier;
public RestrictedArea(Location location1, Location location2, double multiplier) {
this.location1 = location1;
this.location2 = location2;
this.multiplier = multiplier;
this.location1 = location1;
this.location2 = location2;
this.multiplier = multiplier;
}
/**
* The multipler for the restricted area
* @return - the multipler for this restricted area
*/
public double getMultiplier() {
return this.multiplier;
return this.multiplier - 1;
}
/**
@ -56,16 +56,16 @@ public class RestrictedArea {
* @return false - the location is outside the restricted area
*/
public boolean inRestrictedArea(Player player) {
if(isBetween(player.getLocation().getX(), this.location1.getX(), this.location2.getX()) &&
isBetween(player.getLocation().getY(), this.location1.getY(), this.location2.getY()) &&
isBetween(player.getLocation().getZ(), this.location1.getZ(), this.location2.getZ()) &&
this.location1.getWorld().equals(player.getLocation().getWorld()) &&
this.location2.getWorld().equals(player.getLocation().getWorld())) {
return true;
}
return false;
if (isBetween(player.getLocation().getX(), this.location1.getX(), this.location2.getX()) &&
isBetween(player.getLocation().getY(), this.location1.getY(), this.location2.getY()) &&
isBetween(player.getLocation().getZ(), this.location1.getZ(), this.location2.getZ()) &&
this.location1.getWorld().equals(player.getLocation().getWorld()) &&
this.location2.getWorld().equals(player.getLocation().getWorld())) {
return true;
}
return false;
}
/**
* Function check if number is between bounds
* @param number - the number to be checked
@ -75,11 +75,11 @@ public class RestrictedArea {
* @return false - number is out of bounds
*/
private static boolean isBetween(double number, double bound1, double bound2) {
if(bound1 < bound2 && number > bound1 && number < bound2) {
return true;
} else if (bound1 > bound2 && number < bound1 && number > bound2) {
return true;
}
return false;
if (bound1 < bound2 && number > bound1 && number < bound2) {
return true;
} else if (bound1 > bound2 && number < bound1 && number > bound2) {
return true;
}
return false;
}
}

View File

@ -18,8 +18,7 @@ public class Schedule {
boolean nextDay = false;
double MoneyBoost = 1.0;
double ExpBoost = 1.0;
BoostMultiplier BM = new BoostMultiplier();
String Name = null;
@ -83,20 +82,16 @@ public class Schedule {
return this.stoped;
}
public void setMoneyBoost(double MoneyBoost) {
this.MoneyBoost = MoneyBoost;
public void setBoost(BoostType type, double amount) {
this.BM.add(type, amount - 1);
}
public double GetMoneyBoost() {
return this.MoneyBoost;
public double getBoost(BoostType type) {
return this.BM.get(type);
}
public void setExpBoost(double ExpBoost) {
this.ExpBoost = ExpBoost;
}
public double GetExpBoost() {
return this.ExpBoost;
public BoostMultiplier getBoost() {
return this.BM;
}
public void setName(String Name) {

View File

@ -83,14 +83,12 @@ import com.gamingmesh.jobs.container.FastPayment;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Perm;
import com.google.common.base.Objects;
public class JobsPaymentListener implements Listener {
private Jobs plugin;
private final String furnaceOwnerMetadata = "jobsFurnaceOwner";
public final static String brewingOwnerMetadata = "jobsBrewingOwner";
private final String mobSpawnerMetadata = "jobsMobSpawner";
public static final String BlockMetadata = "BlockOwner";
public static final String PlacedBlockMetadata = "JobsBlockOwner";
public static final String VegyMetadata = "VegyTimer";
@ -157,7 +155,7 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null)
return;
Jobs.action(jPlayer, new EntityActionInfo(cow, ActionType.MILK), 0.0);
Jobs.action(jPlayer, new EntityActionInfo(cow, ActionType.MILK));
Long Timer = System.currentTimeMillis();
@ -175,8 +173,8 @@ public class JobsPaymentListener implements Listener {
Sheep sheep = (Sheep) event.getEntity();
// mob spawner, no payment or experience
if (sheep.hasMetadata(this.mobSpawnerMetadata)) {
sheep.removeMetadata(this.mobSpawnerMetadata, this.plugin);
if (sheep.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
sheep.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), this.plugin);
return;
}
@ -201,7 +199,7 @@ public class JobsPaymentListener implements Listener {
if (jDamager == null)
return;
Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR), 0.0);
Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -239,7 +237,7 @@ public class JobsPaymentListener implements Listener {
if (contents == null)
return;
Jobs.action(jPlayer, new ItemActionInfo(contents, ActionType.BREW), 0.0);
Jobs.action(jPlayer, new ItemActionInfo(contents, ActionType.BREW));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -280,10 +278,6 @@ public class JobsPaymentListener implements Listener {
}
// restricted area multiplier
double multiplier = 0.0;
if (Jobs.getMcMMOlistener().mcMMOPresent)
multiplier = Jobs.getMcMMOlistener().getMultiplier(player) * 100 - 100;
// Item in hand
ItemStack item = Jobs.getNms().getItemInMainHand(player);
@ -299,7 +293,7 @@ public class JobsPaymentListener implements Listener {
return;
BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.BREAK);
Jobs.action(jPlayer, bInfo, multiplier, block);
Jobs.action(jPlayer, bInfo, block);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -342,7 +336,7 @@ public class JobsPaymentListener implements Listener {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.PLACE), 0.0, block);
Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.PLACE), block);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -368,7 +362,7 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null)
return;
ItemStack items = ((Item) event.getCaught()).getItemStack();
Jobs.action(jPlayer, new ItemActionInfo(items, ActionType.FISH), 0.0);
Jobs.action(jPlayer, new ItemActionInfo(items, ActionType.FISH));
}
}
@ -382,8 +376,8 @@ public class JobsPaymentListener implements Listener {
LivingEntity animal = event.getEntity();
// mob spawner, no payment or experience
if (animal.hasMetadata(this.mobSpawnerMetadata)) {
animal.removeMetadata(this.mobSpawnerMetadata, this.plugin);
if (animal.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
animal.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), this.plugin);
return;
}
@ -406,7 +400,7 @@ public class JobsPaymentListener implements Listener {
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player);
if (jDamager == null)
return;
Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.TAME), 0.0);
Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.TAME));
}
@ -460,8 +454,6 @@ public class JobsPaymentListener implements Listener {
if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative())
return;
double multiplier = 0.0;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
// Checking if item is been repaired, not crafted. Combining 2 items
@ -497,7 +489,7 @@ public class JobsPaymentListener implements Listener {
if (y == 2) {
if (first == second && third == second) {
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), multiplier);
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
return;
}
}
@ -505,9 +497,9 @@ public class JobsPaymentListener implements Listener {
// Check Dyes
if (y >= 2) {
if ((third == 351 || second == 351) && leather) {
Jobs.action(jPlayer, new ItemActionInfo(sourceItems[0], ActionType.DYE), multiplier);
Jobs.action(jPlayer, new ItemActionInfo(sourceItems[0], ActionType.DYE));
for (ItemStack OneDye : DyeStack) {
Jobs.action(jPlayer, new ItemActionInfo(OneDye, ActionType.DYE), multiplier);
Jobs.action(jPlayer, new ItemActionInfo(OneDye, ActionType.DYE));
}
return;
}
@ -515,7 +507,7 @@ public class JobsPaymentListener implements Listener {
// If we need to pay only by each craft action we will skip calculation how much was crafted
if (!Jobs.getGCManager().PayForEachCraft) {
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier);
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
return;
}
@ -525,14 +517,14 @@ public class JobsPaymentListener implements Listener {
// Make sure we are actually crafting anything
if (hasItems(toCraft))
if (event.isShiftClick())
schedulePostDetection(player, toCraft, jPlayer, resultStack, multiplier);
schedulePostDetection(player, toCraft, jPlayer, resultStack);
else {
// The items are stored in the cursor. Make sure there's enough space.
if (isStackSumLegal(toCraft, toStore)) {
int newItemsCount = toCraft.getAmount();
while (newItemsCount >= 0) {
newItemsCount--;
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier);
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
}
}
}
@ -541,8 +533,7 @@ public class JobsPaymentListener implements Listener {
// HACK! The API doesn't allow us to easily determine the resulting number of
// crafted items, so we're forced to compare the inventory before and after.
private Integer schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack,
final double multiplier) {
private Integer schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack) {
final ItemStack[] preInv = player.getInventory().getContents();
// Clone the array. The content may (was for me) be mutable.
for (int i = 0; i < preInv.length; i++) {
@ -566,7 +557,7 @@ public class JobsPaymentListener implements Listener {
if (newItemsCount > 0) {
while (newItemsCount >= 0) {
newItemsCount--;
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier);
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
}
}
return;
@ -668,7 +659,7 @@ public class JobsPaymentListener implements Listener {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), 0.0);
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -721,9 +712,9 @@ public class JobsPaymentListener implements Listener {
if (level == null)
continue;
Jobs.action(jPlayer, new EnchantActionInfo(enchantName, level, ActionType.ENCHANT), 0.0);
Jobs.action(jPlayer, new EnchantActionInfo(enchantName, level, ActionType.ENCHANT));
}
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT), 0.0);
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT));
}
@ -757,7 +748,7 @@ public class JobsPaymentListener implements Listener {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
Jobs.action(jPlayer, new ItemActionInfo(event.getResult(), ActionType.SMELT), 0.0);
Jobs.action(jPlayer, new ItemActionInfo(event.getResult(), ActionType.SMELT));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -788,7 +779,7 @@ public class JobsPaymentListener implements Listener {
}
// mob spawner, no payment or experience
if (lVictim.hasMetadata(this.mobSpawnerMetadata) && !Jobs.getGCManager().payNearSpawner()) {
if (lVictim.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata()) && !Jobs.getGCManager().payNearSpawner()) {
//lVictim.removeMetadata(mobSpawnerMetadata, plugin);
return;
}
@ -799,20 +790,11 @@ public class JobsPaymentListener implements Listener {
Player pDamager = null;
Double PetPayMultiplier = 0.0;
// Checking if killer is player
if (e.getDamager() instanceof Player) {
pDamager = (Player) e.getDamager();
// Checking if killer is tamed animal
} else if (e.getDamager() instanceof Tameable) {
Tameable t = (Tameable) (e).getDamager();
if (t.isTamed() && t.getOwner() instanceof Player) {
pDamager = (Player) t.getOwner();
if (Perm.hasPermission(pDamager, "jobs.petpay") || Perm.hasPermission(pDamager, "jobs.vippetpay"))
PetPayMultiplier = Jobs.getGCManager().VipPetPay * 100 - 100;
else
PetPayMultiplier = Jobs.getGCManager().PetPay * 100 - 100;
}
} else if (e.getDamager() instanceof Projectile) {
Projectile pr = (Projectile) e.getDamager();
if (pr.getShooter() instanceof Player)
@ -835,20 +817,13 @@ public class JobsPaymentListener implements Listener {
if (jDamager == null)
return;
Double NearSpawnerMultiplier = 0.0;
if (lVictim.hasMetadata(this.mobSpawnerMetadata))
NearSpawnerMultiplier = jDamager.getVipSpawnerMultiplier() * 100 - 100;
// Calulating multiplaier
double 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);
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), e.getDamager(), lVictim);
// Payment for killing player with particular job, except NPC's
if (lVictim instanceof Player && !lVictim.hasMetadata("NPC")) {
@ -860,7 +835,7 @@ public class JobsPaymentListener implements Listener {
if (jobs == null)
return;
for (JobProgression job : jobs) {
Jobs.action(jDamager, new CustomKillInfo(job.getJob().getName(), ActionType.CUSTOMKILL), multiplier);
Jobs.action(jDamager, new CustomKillInfo(job.getJob().getName(), ActionType.CUSTOMKILL), e.getDamager(), lVictim);
}
}
}
@ -872,7 +847,7 @@ public class JobsPaymentListener implements Listener {
return;
if (event.getSpawnReason() == SpawnReason.SPAWNER) {
LivingEntity creature = event.getEntity();
creature.setMetadata(this.mobSpawnerMetadata, new FixedMetadataValue(this.plugin, true));
creature.setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(this.plugin, true));
}
}
@ -881,7 +856,7 @@ public class JobsPaymentListener implements Listener {
//disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return;
if (!event.getEntity().hasMetadata(this.mobSpawnerMetadata))
if (!event.getEntity().hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata()))
return;
EntityType type = event.getEntityType();
@ -941,7 +916,7 @@ public class JobsPaymentListener implements Listener {
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player);
if (jDamager == null)
return;
Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.BREED), 0.0);
Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.BREED));
}
}
@ -983,7 +958,7 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null)
return;
Jobs.action(jPlayer, new ItemActionInfo(item, ActionType.EAT), 0.0);
Jobs.action(jPlayer, new ItemActionInfo(item, ActionType.EAT));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -1045,7 +1020,7 @@ public class JobsPaymentListener implements Listener {
return;
BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.TNTBREAK);
Jobs.action(jPlayer, bInfo, 0.0);
Jobs.action(jPlayer, bInfo);
}
}
@ -1112,6 +1087,6 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null)
return;
Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE), 0.0);
Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE));
}
}

View File

@ -16,6 +16,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.ItemActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Debug;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
@ -56,10 +57,10 @@ public class McMMOlistener implements Listener {
return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), 0.0);
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
HashMap<AbilityType, Long> InfoMap = new HashMap<AbilityType, Long>();
if (map.containsKey(event.getPlayer().getName()))
@ -68,7 +69,7 @@ public class McMMOlistener implements Listener {
map.put(event.getPlayer().getName(), InfoMap);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void OnAbilityOff(McMMOPlayerAbilityDeactivateEvent event) {
if (map.containsKey(event.getPlayer().getName())) {
HashMap<AbilityType, Long> InfoMap = map.get(event.getPlayer().getName());
@ -81,30 +82,32 @@ public class McMMOlistener implements Listener {
public double getMultiplier(Player player) {
HashMap<AbilityType, Long> InfoMap = map.get(player.getName());
if (InfoMap == null)
return 1.0;
if (InfoMap == null) {
return 0D;
}
Long t = InfoMap.get(AbilityType.TREE_FELLER);
if (t != null) {
if (t < System.currentTimeMillis())
return Jobs.getGCManager().TreeFellerMultiplier;
return -(1-Jobs.getGCManager().TreeFellerMultiplier);
map.remove(AbilityType.TREE_FELLER);
}
t = InfoMap.get(AbilityType.GIGA_DRILL_BREAKER);
if (t != null) {
if (t < System.currentTimeMillis())
return Jobs.getGCManager().gigaDrillMultiplier;
return -(1-Jobs.getGCManager().gigaDrillMultiplier);
map.remove(AbilityType.GIGA_DRILL_BREAKER);
}
t = InfoMap.get(AbilityType.SUPER_BREAKER);
if (t != null) {
if (t < System.currentTimeMillis())
return Jobs.getGCManager().superBreakerMultiplier;
return -(1-Jobs.getGCManager().superBreakerMultiplier);
map.remove(AbilityType.SUPER_BREAKER);
}
return 1.0;
return 0D;
}
public boolean CheckmcMMO() {

View File

@ -1,108 +1,97 @@
package com.gamingmesh.jobs.listeners;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.Plugin;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.MMKillInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Perm;
import net.elseland.xikage.MythicMobs.MythicMobs;
import net.elseland.xikage.MythicMobs.API.MythicMobsAPI;
import net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent;
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
public class MythicMobsListener implements Listener {
private Jobs plugin;
public MythicMobsAPI MMAPI = null;
public MythicMobsListener(Jobs plugin) {
this.plugin = plugin;
}
@EventHandler
public void OnMythicMobDeath(MythicMobDeathEvent event) {
//disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return;
// Entity that died must be living
if (!(event.getEntity() instanceof LivingEntity))
return;
MythicMob lVictim = event.getMobType();
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Player pDamager = null;
Double PetPayMultiplier = 0.0;
// Checking if killer is player
if (event.getKiller() instanceof Player)
pDamager = (Player) event.getKiller();
// Checking if killer is tamed animal
else if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
if (((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager() instanceof Tameable) {
Tameable t = (Tameable) ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
if (t.isTamed() && t.getOwner() instanceof Player) {
pDamager = (Player) t.getOwner();
if (Perm.hasPermission(pDamager, "jobs.petpay") || Perm.hasPermission(pDamager, "jobs.vippetpay"))
PetPayMultiplier = Jobs.getGCManager().VipPetPay;
else
PetPayMultiplier = Jobs.getGCManager().PetPay;
}
}
} else
return;
if (pDamager == null)
return;
// check if in creative
if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative())
return;
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
return;
// pay
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
if (jDamager == null)
return;
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), PetPayMultiplier);
}
public boolean Check() {
Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs");
if (mm == null)
return false;
try {
Class.forName("net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent");
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
Class.forName("net.elseland.xikage.MythicMobs.Mobs.MythicMob");
} catch (ClassNotFoundException e) {
// Disabling
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
"&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."));
return false;
}
MMAPI = ((MythicMobs) mm).getAPI();
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MythicMobs was found - Enabling capabilities."));
return true;
}
}
package com.gamingmesh.jobs.listeners;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.Plugin;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.MMKillInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import net.elseland.xikage.MythicMobs.MythicMobs;
import net.elseland.xikage.MythicMobs.API.MythicMobsAPI;
import net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent;
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
public class MythicMobsListener implements Listener {
private Jobs plugin;
public MythicMobsAPI MMAPI = null;
public MythicMobsListener(Jobs plugin) {
this.plugin = plugin;
}
@EventHandler
public void OnMythicMobDeath(MythicMobDeathEvent event) {
//disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return;
// Entity that died must be living
if (!(event.getEntity() instanceof LivingEntity))
return;
MythicMob lVictim = event.getMobType();
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Player pDamager = null;
// Checking if killer is player
Entity ent = null;
if (event.getKiller() instanceof Player)
pDamager = (Player) event.getKiller();
// Checking if killer is tamed animal
else if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
ent = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
} else
return;
if (pDamager == null)
return;
// check if in creative
if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative())
return;
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
return;
// pay
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
if (jDamager == null)
return;
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
}
public boolean Check() {
Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs");
if (mm == null)
return false;
try {
Class.forName("net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent");
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
Class.forName("net.elseland.xikage.MythicMobs.Mobs.MythicMob");
} catch (ClassNotFoundException e) {
// Disabling
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
"&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."));
return false;
}
MMAPI = ((MythicMobs) mm).getAPI();
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MythicMobs was found - Enabling capabilities."));
return true;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.Jobs
version: 3.6.3
version: 3.7.0
author: phrstbrn
depend: [Vault]
softdepend: [MythicMobs, McMMO]