1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Some things

This commit is contained in:
montlikadani 2021-05-04 14:50:28 +02:00
parent 7f6fb86335
commit 21ff1801cd
30 changed files with 191 additions and 150 deletions

View File

@ -1284,7 +1284,7 @@ public class Jobs extends JavaPlugin {
BlockProtection bp = getBpManager().getBp(block.getLocation());
if (bp != null) {
Long time = bp.getTime();
long time = bp.getTime();
Integer cd = getBpManager().getBlockDelayTime(block);
if (time == -1L) {
@ -1338,8 +1338,7 @@ public class Jobs extends JavaPlugin {
// Lets add protection in any case
getBpManager().add(block, cd);
} else if (bp.isPaid().booleanValue() && bp.getTime() == -1L && cd != null && cd == -1) {
} else if (bp.isPaid() && bp.getTime() == -1L && cd != null && cd == -1) {
getBpManager().add(block, cd);
return false;
} else

View File

@ -251,7 +251,8 @@ public class PermissionHandler {
}
public boolean hasWorldPermission(JobsPlayer player) {
return player.getPlayer() != null && hasWorldPermission(player, player.getPlayer().getWorld().getName());
Player pl = player.getPlayer();
return pl != null && hasWorldPermission(player, pl.getWorld().getName());
}
public boolean hasWorldPermission(JobsPlayer player, String world) {

View File

@ -461,7 +461,7 @@ public class PlayerManager {
* @param job {@link Job}
*/
public void joinJob(JobsPlayer jPlayer, Job job) {
if (jPlayer == null || job == null || jPlayer.isInJob(job))
if (jPlayer == null || jPlayer.isInJob(job))
return;
// let the user join the job
@ -494,7 +494,7 @@ public class PlayerManager {
* @param job {@link Job}
*/
public boolean leaveJob(JobsPlayer jPlayer, Job job) {
if (jPlayer == null || job == null || !jPlayer.isInJob(job))
if (jPlayer == null || !jPlayer.isInJob(job))
return false;
JobsLeaveEvent jobsLeaveEvent = new JobsLeaveEvent(jPlayer, job);
@ -587,11 +587,15 @@ public class PlayerManager {
* @param experience - experience gained
*/
public void addExperience(JobsPlayer jPlayer, Job job, double experience) {
if (experience > Double.MAX_VALUE)
return;
JobProgression prog = jPlayer.getJobProgression(job);
if (prog == null || experience > Double.MAX_VALUE)
if (prog == null)
return;
int oldLevel = prog.getLevel();
if (prog.addExperience(experience)) {
performLevelUp(jPlayer, job, oldLevel);
Jobs.getSignUtil().updateAllSign(job);
@ -608,8 +612,11 @@ public class PlayerManager {
* @param experience - experience gained
*/
public void removeExperience(JobsPlayer jPlayer, Job job, double experience) {
if (experience > Double.MAX_VALUE)
return;
JobProgression prog = jPlayer.getJobProgression(job);
if (prog == null || experience > Double.MAX_VALUE)
if (prog == null)
return;
prog.addExperience(-experience);

View File

@ -145,8 +145,10 @@ public class JobsCommands implements CommandExecutor {
public Set<String> getCommands(CommandSender sender) {
Set<String> temp = new TreeSet<>();
boolean senderIsPlayer = sender instanceof Player;
for (String cmd : commandList) {
if (sender instanceof Player && !hasCommandPermission(sender, cmd))
if (senderIsPlayer && !hasCommandPermission(sender, cmd))
continue;
temp.add(cmd);
@ -288,7 +290,7 @@ public class JobsCommands implements CommandExecutor {
String t = type.isEmpty() ? "" : " " + type;
if (sender instanceof Player) {
if (isPlayer) {
String pName = player.getName();
if (sender.getName().equalsIgnoreCase(pName))

View File

@ -58,11 +58,13 @@ public class area implements Cmd {
return true;
}
if (wg && HookManager.getWorldGuardManager() != null) {
if (HookManager.getWorldGuardManager().getProtectedRegionByName(name) == null) {
com.sk89q.worldguard.protection.regions.ProtectedRegion protectedRegion = HookManager.getWorldGuardManager().getProtectedRegionByName(name);
if (protectedRegion == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgDontExist"));
return true;
}
name = HookManager.getWorldGuardManager().getProtectedRegionByName(name).getId();
name = protectedRegion.getId();
}
if (!wg)

View File

@ -28,13 +28,14 @@ public class blockinfo implements Cmd {
if (block == null || CMIMaterial.isAir(block.getType()))
return true;
String dataString = CMIMaterial.getBlockData(block) == 0 ? "" : "-" + CMIMaterial.getBlockData(block);
byte blockData = CMIMaterial.getBlockData(block);
String dataString = blockData == 0 ? "" : "-" + blockData;
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.name", "%blockname%", block.getType().name()));
if (Version.isCurrentEqualOrLower(Version.v1_13_R2))
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getType().getId()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", CMIMaterial.getBlockData(block)));
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", blockData));
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1))
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.usage", "%first%", "",
"%second%", block.getType().name() + dataString));

View File

@ -80,7 +80,7 @@ public class bonus implements Cmd {
"%points%", formatText(boost.get(type, CurrencyType.POINTS, true)),
"%exp%", formatText(boost.get(type, CurrencyType.EXP, true)));
if (msg.startsWith(" ") && (type == BoostOf.NearSpawner || type == BoostOf.PetPay))
if ((type == BoostOf.NearSpawner || type == BoostOf.PetPay) && msg.startsWith(" "))
msg = msg.substring(1, msg.length());
sender.sendMessage(prefix + msg);

View File

@ -17,14 +17,16 @@ public class browse implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, final String[] args) {
boolean senderIsPlayer = sender instanceof Player;
if (Jobs.getGCManager().BrowseUseNewLook) {
List<Job> jobList = new ArrayList<>(Jobs.getJobs());
if (jobList.isEmpty()) {
if (Jobs.getJobs().isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
return true;
}
if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
List<Job> jobList = new ArrayList<>(Jobs.getJobs());
if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
try {
plugin.getGUIManager().openJobsBrowseGUI((Player) sender);
} catch (Throwable e) {
@ -35,7 +37,7 @@ public class browse implements Cmd {
}
int page = 1;
if (sender instanceof Player) {
if (senderIsPlayer) {
for (String one : args) {
if (one.startsWith("-p:")) {
try {
@ -54,7 +56,7 @@ public class browse implements Cmd {
}
}
if (sender instanceof Player) {
if (senderIsPlayer) {
if (j == null) {
PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size()));
@ -112,8 +114,9 @@ public class browse implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
if (j.getMaxLevel(sender) > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", j.getMaxLevel(sender)));
int maxLevel = j.getMaxLevel(sender);
if (maxLevel > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel));
if (Jobs.getGCManager().ShowTotalWorkers)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
@ -125,10 +128,8 @@ public class browse implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100)));
}
if (!j.getFullDescription().isEmpty()) {
for (String one : j.getFullDescription()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one));
}
for (String one : j.getFullDescription()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one));
}
RawMessage rm = new RawMessage();
@ -154,8 +155,9 @@ public class browse implements Cmd {
}
}
if (one.getMaxLevel(sender) > 0)
msg += Jobs.getLanguage().getMessage("command.browse.output.console.newMax", "[max]", one.getMaxLevel(sender));
int maxLevel = one.getMaxLevel(sender);
if (maxLevel > 0)
msg += Jobs.getLanguage().getMessage("command.browse.output.console.newMax", "[max]", maxLevel);
if (Jobs.getGCManager().ShowTotalWorkers)
msg += Jobs.getLanguage().getMessage("command.browse.output.console.totalWorkers", "[amount]", one.getTotalPlayers());
@ -174,8 +176,9 @@ public class browse implements Cmd {
} else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
if (j.getMaxLevel(sender) > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", j.getMaxLevel(sender)));
int maxLevel = j.getMaxLevel(sender);
if (maxLevel > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel));
if (Jobs.getGCManager().ShowTotalWorkers)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
@ -204,10 +207,12 @@ public class browse implements Cmd {
builder.append(" ");
builder.append(job.getChatColor().toString());
builder.append(job.getName());
if (job.getMaxLevel(sender) > 0) {
int maxLevel = job.getMaxLevel(sender);
if (maxLevel > 0) {
builder.append(CMIChatColor.WHITE.toString());
builder.append(Jobs.getLanguage().getMessage("command.info.help.max"));
builder.append(job.getMaxLevel(sender));
builder.append(maxLevel);
}
if (Jobs.getGCManager().ShowTotalWorkers)
@ -220,6 +225,7 @@ public class browse implements Cmd {
builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
lines.add(builder.toString());
if (!job.getDescription().isEmpty())
lines.add(" - " + job.getDescription().replaceAll("/n|\n", ""));
else {
@ -234,7 +240,7 @@ public class browse implements Cmd {
return true;
}
if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
try {
plugin.getGUIManager().openJobsBrowseGUI((Player) sender);
} catch (Throwable e) {

View File

@ -1,6 +1,5 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -34,10 +33,16 @@ public class demote implements Cmd {
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
Integer levelsLost = Integer.parseInt(args[2]);
int levelsLost = 0;
try {
levelsLost = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return true;
}
Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost);
Player player = Bukkit.getServer().getPlayer(jPlayer.getUniqueId());
Player player = jPlayer.getPlayer();
if (player != null) {
String message = Jobs.getLanguage().getMessage("command.demote.output.target",
"%jobname%", job.getNameWithColor() + CMIChatColor.WHITE,

View File

@ -25,8 +25,10 @@ public class expboost implements Cmd {
return true;
}
int[] times = parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.EXP, rate, parseTime(args));
job.addBoost(CurrencyType.EXP, rate, times);
}
sender.sendMessage(
@ -78,6 +80,7 @@ public class expboost implements Cmd {
private int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
}
@ -89,7 +92,7 @@ public class expboost implements Cmd {
if (time.contains("h") || time.contains("hour")) {
try {
arr[2] = Integer.parseInt(time.split("h|hour")[0]);
arr[2] = Integer.parseInt(time.split("h|hour", 2)[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
@ -99,7 +102,7 @@ public class expboost implements Cmd {
if (time.contains("m") || time.contains("minute")) {
try {
arr[1] = Integer.parseInt(time.split("m|minute")[0]);
arr[1] = Integer.parseInt(time.split("m|minute", 2)[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
@ -109,7 +112,7 @@ public class expboost implements Cmd {
if (time.contains("s") || time.contains("second")) {
try {
arr[0] = Integer.parseInt(time.split("s|second")[0]);
arr[0] = Integer.parseInt(time.split("s|second", 2)[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}

View File

@ -17,15 +17,14 @@ public class explored implements Cmd {
return false;
Player player = (Player) sender;
ExploreRegion exploreRegion = Jobs.getExplore().getWorlds().get(player.getWorld().getName());
java.util.Map<String, ExploreRegion> worlds = Jobs.getExplore().getWorlds();
if (!worlds.containsKey(player.getWorld().getName())) {
if (exploreRegion == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
return true;
}
ExploreChunk chunk = worlds.get(player.getWorld().getName()).getChunk(player.getLocation().getChunk());
ExploreChunk chunk = exploreRegion.getChunk(player.getLocation().getChunk());
if (chunk == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
return false;

View File

@ -45,7 +45,7 @@ public class fireall implements Cmd {
return true;
}
if (jPlayer.getJobProgression().isEmpty()) {
if (jPlayer.progression.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fireall.error.nojobs"));
return true;
}

View File

@ -3,6 +3,7 @@ package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.ItemBoostManager;
import com.gamingmesh.jobs.Jobs;
@ -72,12 +73,14 @@ public class give implements Cmd {
switch (name) {
case items:
JobItems jItem = ItemBoostManager.getItemByKey(itemName);
if (jItem == null || jItem.getItemStack(player) == null) {
ItemStack item = jItem == null ? null : jItem.getItemStack(player);
if (item == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
}
GiveItem.giveItemForPlayer(player, jItem.getItemStack(player));
GiveItem.giveItemForPlayer(player, item);
break;
case limiteditems:
if (job == null) {
@ -86,12 +89,14 @@ public class give implements Cmd {
}
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
if (jLItem == null || jLItem.getItemStack(player) == null) {
ItemStack limItem = jLItem == null ? null : jLItem.getItemStack(player);
if (limItem == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
}
GiveItem.giveItemForPlayer(player, jLItem.getItemStack(player));
GiveItem.giveItemForPlayer(player, limItem);
break;
default:
break;

View File

@ -65,7 +65,7 @@ public class join implements Cmd {
return true;
}
if (!Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.getJobProgression().size())) {
if (!Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.progression.size())) {
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.maxjobs"));
return true;
}

View File

@ -55,8 +55,10 @@ public class limit implements Cmd {
limit.resetLimits(type);
if (limit.getLeftTime(type) > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.getLeftTime(type))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit",
String typeName = type.getName().toLowerCase();
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + typeName + "time", "%time%", TimeManage.to24hourShort(limit.getLeftTime(type))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + typeName + "Limit",
"%current%", (int) (limit.getAmount(type) * 100) / 100D,
"%total%", JPlayer.getLimit(type)));
}

View File

@ -73,11 +73,10 @@ public class log implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getName()));
for (Log one : logList.values()) {
Map<String, LogAmounts> AmountList = one.getAmountList();
double totalMoney = 0, totalExp = 0, totalPoints = 0;
for (String oneSorted : unsortMap.keySet()) {
for (Entry<String, LogAmounts> oneMap : AmountList.entrySet()) {
for (Entry<String, LogAmounts> oneMap : one.getAmountList().entrySet()) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted)) {
count++;

View File

@ -25,8 +25,10 @@ public class moneyboost implements Cmd {
return true;
}
int[] times = parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.MONEY, rate, parseTime(args));
job.addBoost(CurrencyType.MONEY, rate, times);
}
sender.sendMessage(
@ -78,6 +80,7 @@ public class moneyboost implements Cmd {
private int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
}
@ -89,7 +92,7 @@ public class moneyboost implements Cmd {
if (time.contains("h") || time.contains("hour")) {
try {
arr[2] = Integer.parseInt(time.split("h|hour")[0]);
arr[2] = Integer.parseInt(time.split("h|hour", 2)[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
@ -99,7 +102,7 @@ public class moneyboost implements Cmd {
if (time.contains("m") || time.contains("minute")) {
try {
arr[1] = Integer.parseInt(time.split("m|minute")[0]);
arr[1] = Integer.parseInt(time.split("m|minute", 2)[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
@ -109,7 +112,7 @@ public class moneyboost implements Cmd {
if (time.contains("s") || time.contains("second")) {
try {
arr[0] = Integer.parseInt(time.split("s|second")[0]);
arr[0] = Integer.parseInt(time.split("s|second", 2)[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}

View File

@ -25,8 +25,10 @@ public class pointboost implements Cmd {
return true;
}
int[] times = parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.POINTS, rate, parseTime(args));
job.addBoost(CurrencyType.POINTS, rate, times);
}
sender.sendMessage(
@ -78,6 +80,7 @@ public class pointboost implements Cmd {
private int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
}
@ -89,7 +92,7 @@ public class pointboost implements Cmd {
if (time.contains("h") || time.contains("hour")) {
try {
arr[2] = Integer.parseInt(time.split("h|hour")[0]);
arr[2] = Integer.parseInt(time.split("h|hour", 2)[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
@ -99,7 +102,7 @@ public class pointboost implements Cmd {
if (time.contains("m") || time.contains("minute")) {
try {
arr[1] = Integer.parseInt(time.split("m|minute")[0]);
arr[1] = Integer.parseInt(time.split("m|minute", 2)[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
@ -109,7 +112,7 @@ public class pointboost implements Cmd {
if (time.contains("s") || time.contains("second")) {
try {
arr[0] = Integer.parseInt(time.split("s|second")[0]);
arr[0] = Integer.parseInt(time.split("s|second", 2)[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}

View File

@ -31,7 +31,13 @@ public class promote implements Cmd {
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
Integer levelsGained = Integer.parseInt(args[2]);
int levelsGained = -1;
try {
levelsGained = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return true;
}
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained);
Player player = jPlayer.getPlayer();

View File

@ -44,7 +44,9 @@ public class quests implements Cmd {
return true;
}
if (jPlayer.getQuestProgressions().isEmpty()) {
List<QuestProgression> questProgs = jPlayer.getQuestProgressions();
if (questProgs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.error.noquests"));
return true;
}
@ -60,7 +62,7 @@ public class quests implements Cmd {
}
if (stopped != null) {
for (QuestProgression q : jPlayer.getQuestProgressions()) {
for (QuestProgression q : questProgs) {
q.getQuest().setStopped(stopped);
}
@ -77,7 +79,7 @@ public class quests implements Cmd {
return true;
}
for (JobProgression jobProg : jPlayer.getJobProgression()) {
for (JobProgression jobProg : jPlayer.progression) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
for (QuestProgression q : list) {
@ -97,7 +99,7 @@ public class quests implements Cmd {
.replace("[time]", TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
if (current.contains("[desc]")) {
q.getQuest().getDescription().forEach(hoverList::add);
hoverList.addAll(q.getQuest().getDescription());
} else {
hoverList.add(current);
}

View File

@ -30,9 +30,7 @@ public class stats implements Cmd {
return true;
}
java.util.List<JobProgression> progressions = jPlayer.getJobProgression();
if (progressions.isEmpty()) {
if (jPlayer.progression.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.stats.error.nojob"));
return true;
}
@ -41,7 +39,7 @@ public class stats implements Cmd {
String leftClick = Jobs.getLanguage().getMessage("command.info.gui.leftClick");
for (JobProgression jobProg : progressions) {
for (JobProgression jobProg : jPlayer.progression) {
for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg).split("\n")) {
new RawMessage().addText(msg).addHover(leftClick).addCommand("jobs info " + jobProg.getJob().getName()).show(sender);
}

View File

@ -18,51 +18,40 @@ public class toggle implements Cmd {
return false;
}
if (args.length != 1) {
boolean isBossbar = false, isActionbar = false;
if (args.length != 1 || (!(isBossbar = args[0].equalsIgnoreCase("bossbar")) && !(isActionbar = args[0].equalsIgnoreCase("actionbar")))) {
Jobs.getCommandManager().sendUsage(sender, "toggle");
return true;
}
Player player = (Player) sender;
if (!args[0].equalsIgnoreCase("bossbar") && !args[0].equalsIgnoreCase("actionbar")) {
Jobs.getCommandManager().sendUsage(sender, "toggle");
return true;
}
String playerUUID = player.getUniqueId().toString();
if (args[0].equalsIgnoreCase("actionbar")) {
if (ToggleBarHandling.getActionBarToggle().containsKey(playerUUID)) {
if (ToggleBarHandling.getActionBarToggle().get(playerUUID)) {
ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
} else {
ToggleBarHandling.getActionBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
} else {
if (isActionbar) {
Boolean ex = ToggleBarHandling.getActionBarToggle().get(playerUUID);
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
} else {
ToggleBarHandling.getActionBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
}
if (args[0].equalsIgnoreCase("bossbar")) {
if (ToggleBarHandling.getBossBarToggle().containsKey(playerUUID)) {
if (ToggleBarHandling.getBossBarToggle().get(playerUUID)) {
ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
if (isBossbar) {
Boolean ex = ToggleBarHandling.getBossBarToggle().get(playerUUID);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
if (jPlayer != null)
jPlayer.hideBossBars();
} else {
ToggleBarHandling.getBossBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
} else {
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
if (jPlayer != null)
jPlayer.hideBossBars();
} else {
ToggleBarHandling.getBossBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
}

View File

@ -938,6 +938,9 @@ public class ConfigManager {
for (String str4 : guiSection.getStringList("Enchantments")) {
String[] id = str4.split(":", 2);
if (id.length < 2)
continue;
Enchantment enchant = CMIEnchantment.getEnchantment(id[0]);
if (enchant == null)
continue;

View File

@ -912,34 +912,36 @@ public class GeneralConfigManager {
List<String> fwColors = c.get("Fireworks.LevelUp.colors", Arrays.asList("230,0,0", "0,90,0", "0,0,104"));
Color[] colors = new Color[fwColors.size()];
Pattern comma = Pattern.compile(",", 16);
if (!UseRandom) {
Color[] colors = new Color[fwColors.size()];
Pattern comma = Pattern.compile(",", 16);
for (int s = 0; s < colors.length; s++) {
String[] sSplit = comma.split(fwColors.get(s));
if (sSplit.length < 3)
continue;
for (int s = 0; s < colors.length; s++) {
String[] sSplit = comma.split(fwColors.get(s));
if (sSplit.length < 3)
continue;
int[] colorRGB = new int[3];
for (int i = 0; i < 3; i++) {
try {
int parsed = Integer.parseInt(sSplit[i]);
colorRGB[i] = (parsed > 255 || parsed < 0) ? 1 : parsed;
} catch (NumberFormatException e) {
int[] colorRGB = new int[3];
for (int i = 0; i < 3; i++) {
try {
int parsed = Integer.parseInt(sSplit[i]);
colorRGB[i] = (parsed > 255 || parsed < 0) ? 1 : parsed;
} catch (NumberFormatException e) {
}
}
colors[s] = Color.fromRGB(colorRGB[0], colorRGB[1], colorRGB[2]);
}
colors[s] = Color.fromRGB(colorRGB[0], colorRGB[1], colorRGB[2]);
fireworkEffect = FireworkEffect.builder()
.flicker(useFlicker)
.trail(useTrail)
.with(fwType)
.withColor(colors)
.withFade(colors)
.build();
}
fireworkEffect = FireworkEffect.builder()
.flicker(useFlicker)
.trail(useTrail)
.with(fwType)
.withColor(colors)
.withFade(colors)
.build();
FireworkPower = c.get("Fireworks.LevelUp.power", 1);
c.addComment("Fireworks.LevelUp.ShootTime", "Fire shooting time in ticks.", "20 tick = 1 second");
ShootTime = c.get("Fireworks.LevelUp.ShootTime", 20);

View File

@ -33,7 +33,7 @@ public class BlockProtection {
this.z = z;
}
public Long getTime() {
public long getTime() {
return deconvert(time);
}
@ -41,11 +41,11 @@ public class BlockProtection {
return time == -1L ? -1 : (int) ((time - pre) / 1000L);
}
private static Long deconvert(Integer time) {
private static long deconvert(Integer time) {
return time == null ? -1L : ((time.longValue() * 1000L) + pre);
}
public void setTime(Long time) {
public void setTime(long time) {
this.time = time == -1 ? null : convert(time);
this.recorded = convert(System.currentTimeMillis());
}
@ -60,19 +60,19 @@ public class BlockProtection {
this.action = action;
}
public Long getRecorded() {
public long getRecorded() {
return deconvert(recorded);
}
public Boolean isPaid() {
return paid == null ? true : paid;
public boolean isPaid() {
return paid == null ? true : paid.booleanValue();
}
public void setPaid(Boolean paid) {
public void setPaid(boolean paid) {
this.paid = !paid ? paid : null;
}
public void setRecorded(Long recorded) {
public void setRecorded(long recorded) {
this.recorded = convert(recorded);
}

View File

@ -96,10 +96,12 @@ public class BufferedEconomy {
// combine all payments using paymentCache
while (!payments.isEmpty()) {
BufferedPayment payment = payments.remove();
totalAmount += payment.get(CurrencyType.MONEY);
double money = payment.get(CurrencyType.MONEY);
totalAmount += money;
if (Jobs.getGCManager().UseTaxes) {
taxesAmount += payment.get(CurrencyType.MONEY) * (Jobs.getGCManager().TaxesAmount / 100.0);
taxesAmount += money * (Jobs.getGCManager().TaxesAmount / 100.0);
}
OfflinePlayer offPlayer = payment.getOfflinePlayer();
@ -108,7 +110,6 @@ public class BufferedEconomy {
BufferedPayment existing = paymentCache.get(offPlayer.getUniqueId());
if (existing != null) {
double money = payment.get(CurrencyType.MONEY);
double points = payment.get(CurrencyType.POINTS);
double exp = payment.get(CurrencyType.EXP);
@ -133,7 +134,6 @@ public class BufferedEconomy {
existing.set(CurrencyType.POINTS, existing.get(CurrencyType.POINTS) + points);
existing.set(CurrencyType.EXP, existing.get(CurrencyType.EXP) + exp);
} else {
double money = payment.get(CurrencyType.MONEY);
double points = payment.get(CurrencyType.POINTS);
if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes &&
@ -213,7 +213,7 @@ public class BufferedEconomy {
// Show players payment stuff
showPayment(payment);
if (payment.getOfflinePlayer().isOnline() && Version.getCurrent().isHigher(Version.v1_8_R3)) {
if (Version.getCurrent().isHigher(Version.v1_8_R3) && payment.getOfflinePlayer().isOnline()) {
Jobs.getBBManager().ShowJobProgression(Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getUniqueId()));
}
}

View File

@ -15,10 +15,10 @@ import com.gamingmesh.jobs.listeners.JobsPaymentListener;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
public class MythicMobs4Listener implements Listener {
public final class MythicMobs4Listener implements Listener {
@EventHandler
public void OnMythicMobDeath(MythicMobDeathEvent event) {
public void onMythicMobDeath(MythicMobDeathEvent event) {
// Entity that died must be living
if (!(event.getEntity() instanceof LivingEntity))
return;

View File

@ -984,10 +984,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) {
if (!Jobs.getGCManager().PreventHopperFillUps)
return;
if (event.getItem().getType() == Material.AIR)
if (!Jobs.getGCManager().PreventHopperFillUps || event.getItem().getType() == Material.AIR)
return;
String type = event.getDestination().getType().toString();
@ -1075,10 +1072,10 @@ public class JobsPaymentListener implements Listener {
return;
Entity ent = event.getEntity();
if (ent instanceof Player || !(event instanceof EntityDamageByEntityEvent))
if (ent instanceof Player || !(ent instanceof Damageable) || !(event instanceof EntityDamageByEntityEvent))
return;
if (!(((EntityDamageByEntityEvent) event).getDamager() instanceof Player) || !(ent instanceof Damageable))
if (!(((EntityDamageByEntityEvent) event).getDamager() instanceof Player))
return;
double damage = event.getFinalDamage();
@ -1272,13 +1269,13 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHangingPlaceEvent(HangingPlaceEvent event) {
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return;
Player player = event.getPlayer();
if (player == null || !player.isOnline())
return;
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return;
// check if in creative
if (!payIfCreative(player))
return;

View File

@ -52,8 +52,11 @@ public class ToggleBarHandling {
public static void save() {
YmlMaker f = new YmlMaker(Jobs.getFolder(), "actionBarBossbar.yml");
if (f.exists() && f.getConfigFile().length() == 0L && bossBarToggle.isEmpty() && actionBarToggle.isEmpty()) {
f.getConfigFile().delete();
if (bossBarToggle.isEmpty() && actionBarToggle.isEmpty()) {
if (f.exists() && f.getConfigFile().length() == 0L) {
f.getConfigFile().delete();
}
return;
}

View File

@ -40,8 +40,12 @@ public class BufferedPaymentTask implements Runnable {
public void run() {
double money = payment.get(CurrencyType.MONEY);
if (money > 0) {
org.bukkit.Bukkit.getScheduler().runTaskLater(bufferedEconomy.getPlugin(), () ->
economy.depositPlayer(payment.getOfflinePlayer(), money), 1L);
if (Jobs.getGCManager().isEconomyAsync()) {
org.bukkit.Bukkit.getScheduler().runTaskLater(bufferedEconomy.getPlugin(), () ->
economy.depositPlayer(payment.getOfflinePlayer(), money), 1L);
} else {
economy.depositPlayer(payment.getOfflinePlayer(), money);
}
} else if (!economy.withdrawPlayer(payment.getOfflinePlayer(), -money)) {
bufferedEconomy.pay(payment);
}