1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-21 06:42:29 +01:00
This commit is contained in:
montlikadani 2020-09-05 14:23:48 +02:00
parent 08e4893e81
commit fe66a49c56
43 changed files with 270 additions and 386 deletions

View File

@ -59,9 +59,6 @@ public class HookEconomyTask implements Runnable {
return false;
Economy economy = provider.getProvider();
if (economy == null)
return false;
Jobs.setEconomy(new VaultEconomy(economy));
Jobs.consoleMsg("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault.");
return true;

View File

@ -138,14 +138,14 @@ public class ItemBoostManager {
}
List<String> lore = new ArrayList<>();
if (cfg.getC().contains(one + ".lore") && !cfg.getC().getStringList(one + ".lore").isEmpty()) {
if (cfg.getC().isList(one + ".lore")) {
for (String eachLine : cfg.get(one + ".lore", Arrays.asList(""))) {
lore.add(CMIChatColor.translate(eachLine));
}
}
HashMap<Enchantment, Integer> enchants = new HashMap<>();
if (cfg.getC().contains(one + ".enchants") && !cfg.getC().getStringList(one + ".enchants").isEmpty())
if (cfg.getC().isList(one + ".enchants"))
for (String eachLine : cfg.get(one + ".enchants", Arrays.asList(""))) {
if (!eachLine.contains("="))
continue;

View File

@ -64,71 +64,71 @@ import java.util.logging.Logger;
public class Jobs extends JavaPlugin {
private static PlayerManager pManager = null;
private static JobsCommands cManager = null;
private static Language lManager = null;
private static LanguageManager lmManager = null;
private static SignUtil signManager = null;
private CMIScoreboardManager CMIScoreboardManager = null;
private static ScheduleManager scheduleManager = null;
private static NameTranslatorManager NameTranslatorManager = null;
private static GuiManager GUIManager = null;
private static ExploreManager exploreManager = null;
private static TitleManager titleManager = null;
private static RestrictedBlockManager RBManager = null;
private static RestrictedAreaManager RAManager = null;
private static BossBarManager BBManager = null;
private static ShopManager shopManager = null;
private static Loging loging = null;
private static BlockProtectionManager BpManager = null;
private static JobsManager DBManager = null;
private static PlayerManager pManager;
private static JobsCommands cManager;
private static Language lManager;
private static LanguageManager lmManager;
private static SignUtil signManager;
private CMIScoreboardManager cmiScoreboardManager;
private static ScheduleManager scheduleManager;
private static NameTranslatorManager nameTranslatorManager;
private static GuiManager guiManager;
private static ExploreManager exploreManager;
private static TitleManager titleManager;
private static RestrictedBlockManager rbManager;
private static RestrictedAreaManager raManager;
private static BossBarManager bbManager;
private static ShopManager shopManager;
private static Loging loging;
private static BlockProtectionManager bpManager;
private static JobsManager dbManager;
private static PistonProtectionListener PistonProtectionListener = null;
private static PistonProtectionListener pistonProtectionListener;
private static ConfigManager configManager = null;
private static GeneralConfigManager GconfigManager = null;
private static ConfigManager configManager;
private static GeneralConfigManager gConfigManager;
private static CMIReflections reflections = null;
private static CMIReflections reflections;
private static JobsDAO dao = null;
private static List<Job> jobs = null;
private static Job noneJob = null;
private static JobsDAO dao;
private static List<Job> jobs;
private static Job noneJob;
private static WeakHashMap<Job, Integer> usedSlots = new WeakHashMap<>();
private static HashMap<Integer, Job> jobsIds = new HashMap<>();
// public static WeakHashMap<String, Double> GlobalBoost = new WeakHashMap<String, Double>();
private static BufferedEconomy economy = null;
private static PermissionHandler permissionHandler = null;
private static PermissionManager permissionManager = null;
private static BufferedEconomy economy;
private static PermissionHandler permissionHandler;
private static PermissionManager permissionManager;
// private static ItemManager itemManager;
public static BufferedPaymentThread paymentThread = null;
private static DatabaseSaveThread saveTask = null;
public static BufferedPaymentThread paymentThread;
private static DatabaseSaveThread saveTask;
public static HashMap<UUID, FastPayment> FastPayment = new HashMap<>();
public static final HashMap<UUID, FastPayment> FASTPAYMENT = new HashMap<>();
private static NMS nms = null;
private static NMS nms;
protected static VersionChecker versionCheckManager = null;
protected static VersionChecker versionCheckManager;
protected static SelectionManager smanager = null;
protected static SelectionManager smanager;
private static PointsData pointsDatabase = null;
private static PointsData pointsDatabase;
public static PistonProtectionListener getPistonProtectionListener() {
if (PistonProtectionListener == null)
PistonProtectionListener = new PistonProtectionListener();
return PistonProtectionListener;
if (pistonProtectionListener == null)
pistonProtectionListener = new PistonProtectionListener();
return pistonProtectionListener;
}
private Placeholder Placeholder;
private boolean PlaceholderAPIEnabled = false;
private Placeholder placeholder;
private boolean placeholderAPIEnabled = false;
public Placeholder getPlaceholderAPIManager() {
if (Placeholder == null)
Placeholder = new Placeholder(this);
return Placeholder;
if (placeholder == null)
placeholder = new Placeholder(this);
return placeholder;
}
private boolean setupPlaceHolderAPI() {
@ -152,9 +152,9 @@ public class Jobs extends JavaPlugin {
}
public static BlockProtectionManager getBpManager() {
if (BpManager == null)
BpManager = new BlockProtectionManager();
return BpManager;
if (bpManager == null)
bpManager = new BlockProtectionManager();
return bpManager;
}
public static CMIReflections getReflections() {
@ -164,9 +164,9 @@ public class Jobs extends JavaPlugin {
}
public static JobsManager getDBManager() {
if (DBManager == null)
DBManager = new JobsManager(instance);
return DBManager;
if (dbManager == null)
dbManager = new JobsManager(instance);
return dbManager;
}
/**
@ -196,9 +196,9 @@ public class Jobs extends JavaPlugin {
}
public static GeneralConfigManager getGCManager() {
if (GconfigManager == null)
GconfigManager = new GeneralConfigManager();
return GconfigManager;
if (gConfigManager == null)
gConfigManager = new GeneralConfigManager();
return gConfigManager;
}
public static NMS getNms() {
@ -216,19 +216,19 @@ public class Jobs extends JavaPlugin {
}
public static RestrictedBlockManager getRestrictedBlockManager() {
if (RBManager == null) {
RBManager = new RestrictedBlockManager();
if (rbManager == null) {
rbManager = new RestrictedBlockManager();
}
return RBManager;
return rbManager;
}
public static RestrictedAreaManager getRestrictedAreaManager() {
if (RAManager == null) {
RAManager = new RestrictedAreaManager();
if (raManager == null) {
raManager = new RestrictedAreaManager();
}
return RAManager;
return raManager;
}
public static TitleManager gettitleManager() {
@ -240,11 +240,11 @@ public class Jobs extends JavaPlugin {
}
private void setBBManager() {
BBManager = new BossBarManager(this);
bbManager = new BossBarManager(this);
}
public static BossBarManager getBBManager() {
return BBManager;
return bbManager;
}
/**
@ -260,17 +260,17 @@ public class Jobs extends JavaPlugin {
}
public static NameTranslatorManager getNameTranslatorManager() {
if (NameTranslatorManager == null) {
NameTranslatorManager = new NameTranslatorManager();
if (nameTranslatorManager == null) {
nameTranslatorManager = new NameTranslatorManager();
}
return NameTranslatorManager;
return nameTranslatorManager;
}
public static GuiManager getGUIManager() {
if (GUIManager == null)
GUIManager = new GuiManager();
return GUIManager;
if (guiManager == null)
guiManager = new GuiManager();
return guiManager;
}
public static JobsCommands getCommandManager() {
@ -291,10 +291,10 @@ public class Jobs extends JavaPlugin {
* @return the scoreboard manager
*/
public CMIScoreboardManager getCMIScoreboardManager() {
if (CMIScoreboardManager == null)
CMIScoreboardManager = new CMIScoreboardManager();
if (cmiScoreboardManager == null)
cmiScoreboardManager = new CMIScoreboardManager();
return CMIScoreboardManager;
return cmiScoreboardManager;
}
protected static Jobs instance;
@ -414,7 +414,7 @@ public class Jobs extends JavaPlugin {
}
public boolean isPlaceholderAPIEnabled() {
return PlaceholderAPIEnabled;
return placeholderAPIEnabled;
}
public static HashMap<Integer, Job> getJobsIds() {
@ -453,10 +453,8 @@ public class Jobs extends JavaPlugin {
playersLogs.get(id),
playersArchives.get(id),
playersLimits.get(id));
if (jPlayer == null)
continue;
getPlayerManager().addPlayerToCache(jPlayer);
if (jPlayer != null)
getPlayerManager().addPlayerToCache(jPlayer);
}
if (!getPlayerManager().getPlayersCache().isEmpty())
@ -639,7 +637,7 @@ public class Jobs extends JavaPlugin {
return;
}
PlaceholderAPIEnabled = setupPlaceHolderAPI();
placeholderAPIEnabled = setupPlaceHolderAPI();
try {
YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml");
@ -864,24 +862,24 @@ public class Jobs extends JavaPlugin {
Boost boost = getPlayerManager().getFinalBonus(jPlayer, noneJob);
JobsPrePaymentEvent JobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), noneJob, income,
JobsPrePaymentEvent jobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), noneJob, income,
pointAmount, block, ent, victim, info);
Bukkit.getServer().getPluginManager().callEvent(JobsPrePaymentEvent);
Bukkit.getServer().getPluginManager().callEvent(jobsPrePaymentEvent);
// If event is canceled, don't do anything
if (JobsPrePaymentEvent.isCancelled()) {
if (jobsPrePaymentEvent.isCancelled()) {
income = 0D;
pointAmount = 0D;
} else {
income = JobsPrePaymentEvent.getAmount();
pointAmount = JobsPrePaymentEvent.getPoints();
income = jobsPrePaymentEvent.getAmount();
pointAmount = jobsPrePaymentEvent.getPoints();
}
// Calculate income
if (income != 0D) {
income = boost.getFinalAmount(CurrencyType.MONEY, income);
if (GconfigManager.useMinimumOveralPayment && income > 0) {
double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit;
if (gConfigManager.useMinimumOveralPayment && income > 0) {
double maxLimit = income * gConfigManager.MinimumOveralPaymentLimit;
if (income < maxLimit)
income = maxLimit;
}
@ -891,27 +889,27 @@ public class Jobs extends JavaPlugin {
if (pointAmount != 0D) {
pointAmount = boost.getFinalAmount(CurrencyType.POINTS, pointAmount);
if (GconfigManager.useMinimumOveralPoints && pointAmount > 0) {
double maxLimit = pointAmount * GconfigManager.MinimumOveralPaymentLimit;
if (gConfigManager.useMinimumOveralPoints && pointAmount > 0) {
double maxLimit = pointAmount * gConfigManager.MinimumOveralPaymentLimit;
if (pointAmount < maxLimit)
pointAmount = maxLimit;
}
}
if (!jPlayer.isUnderLimit(CurrencyType.MONEY, income)) {
if (GconfigManager.useMaxPaymentCurve) {
if (gConfigManager.useMaxPaymentCurve) {
double percentOver = jPlayer.percentOverLimit(CurrencyType.MONEY);
float factor = GconfigManager.maxPaymentCurveFactor;
float factor = gConfigManager.maxPaymentCurveFactor;
double percentLoss = 100 / ((1 / factor * percentOver * percentOver) + 1);
income = income - (income * percentLoss / 100);
} else
income = 0D;
if (GconfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.POINTS))
if (gConfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.POINTS))
pointAmount = 0D;
}
if (!jPlayer.isUnderLimit(CurrencyType.POINTS, pointAmount)) {
pointAmount = 0D;
if (GconfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.MONEY))
if (gConfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.MONEY))
income = 0D;
}
@ -932,14 +930,14 @@ public class Jobs extends JavaPlugin {
economy.pay(jPlayer, payments);
if (GconfigManager.LoggingUse) {
if (gConfigManager.LoggingUse) {
HashMap<CurrencyType, Double> amounts = new HashMap<>();
amounts.put(CurrencyType.MONEY, income);
getLoging().recordToLog(jPlayer, info, amounts);
}
} else {
FastPayment.clear();
FASTPAYMENT.clear();
List<Job> expiredJobs = new ArrayList<>();
for (JobProgression prog : progression) {
@ -957,10 +955,7 @@ public class Jobs extends JavaPlugin {
checkDailyQuests(jPlayer, prog.getJob(), info);
if (jobinfo == null)
continue;
if (GconfigManager.disablePaymentIfMaxLevelReached && prog.getLevel() >= prog.getJob().getMaxLevel()) {
if (jobinfo == null || gConfigManager.disablePaymentIfMaxLevelReached && prog.getLevel() >= prog.getJob().getMaxLevel()) {
continue;
}
@ -971,7 +966,7 @@ public class Jobs extends JavaPlugin {
if (income == 0D && pointAmount == 0D && expAmount == 0D)
continue;
if (GconfigManager.addXpPlayer()) {
if (gConfigManager.addXpPlayer()) {
Player player = jPlayer.getPlayer();
if (player != null) {
/*
@ -1000,24 +995,24 @@ public class Jobs extends JavaPlugin {
Boost boost = getPlayerManager().getFinalBonus(jPlayer, prog.getJob(), ent, victim);
JobsPrePaymentEvent JobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), prog.getJob(), income,
JobsPrePaymentEvent jobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), prog.getJob(), income,
pointAmount, block, ent, victim, info);
Bukkit.getServer().getPluginManager().callEvent(JobsPrePaymentEvent);
Bukkit.getServer().getPluginManager().callEvent(jobsPrePaymentEvent);
// If event is canceled, don't do anything
if (JobsPrePaymentEvent.isCancelled()) {
if (jobsPrePaymentEvent.isCancelled()) {
income = 0D;
pointAmount = 0D;
} else {
income = JobsPrePaymentEvent.getAmount();
pointAmount = JobsPrePaymentEvent.getPoints();
income = jobsPrePaymentEvent.getAmount();
pointAmount = jobsPrePaymentEvent.getPoints();
}
// Calculate income
if (income != 0D) {
income = boost.getFinalAmount(CurrencyType.MONEY, income);
if (GconfigManager.useMinimumOveralPayment && income > 0) {
double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit;
if (gConfigManager.useMinimumOveralPayment && income > 0) {
double maxLimit = income * gConfigManager.MinimumOveralPaymentLimit;
if (income < maxLimit)
income = maxLimit;
}
@ -1026,8 +1021,8 @@ public class Jobs extends JavaPlugin {
// Calculate points
if (pointAmount != 0D) {
pointAmount = boost.getFinalAmount(CurrencyType.POINTS, pointAmount);
if (GconfigManager.useMinimumOveralPoints && pointAmount > 0) {
double maxLimit = pointAmount * GconfigManager.MinimumOveralPaymentLimit;
if (gConfigManager.useMinimumOveralPoints && pointAmount > 0) {
double maxLimit = pointAmount * gConfigManager.MinimumOveralPaymentLimit;
if (pointAmount < maxLimit)
pointAmount = maxLimit;
}
@ -1036,33 +1031,33 @@ public class Jobs extends JavaPlugin {
// Calculate exp
expAmount = boost.getFinalAmount(CurrencyType.EXP, expAmount);
if (GconfigManager.useMinimumOveralPayment && expAmount > 0) {
double maxLimit = expAmount * GconfigManager.MinimumOveralPaymentLimit;
if (gConfigManager.useMinimumOveralPayment && expAmount > 0) {
double maxLimit = expAmount * gConfigManager.MinimumOveralPaymentLimit;
if (expAmount < maxLimit)
expAmount = maxLimit;
}
if (!jPlayer.isUnderLimit(CurrencyType.MONEY, income)) {
income = 0D;
if (GconfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.EXP))
if (gConfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.EXP))
expAmount = 0D;
if (GconfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.POINTS))
if (gConfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.POINTS))
pointAmount = 0D;
}
if (!jPlayer.isUnderLimit(CurrencyType.EXP, expAmount)) {
expAmount = 0D;
if (GconfigManager.getLimit(CurrencyType.EXP).getStopWith().contains(CurrencyType.MONEY))
if (gConfigManager.getLimit(CurrencyType.EXP).getStopWith().contains(CurrencyType.MONEY))
income = 0D;
if (GconfigManager.getLimit(CurrencyType.EXP).getStopWith().contains(CurrencyType.POINTS))
if (gConfigManager.getLimit(CurrencyType.EXP).getStopWith().contains(CurrencyType.POINTS))
pointAmount = 0D;
}
if (!jPlayer.isUnderLimit(CurrencyType.POINTS, pointAmount)) {
pointAmount = 0D;
if (GconfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.MONEY))
if (gConfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.MONEY))
income = 0D;
if (GconfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.EXP))
if (gConfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.EXP))
expAmount = 0D;
}
@ -1070,19 +1065,16 @@ public class Jobs extends JavaPlugin {
continue;
// JobsPayment event
JobsExpGainEvent JobsExpGainEvent = new JobsExpGainEvent(jPlayer.getPlayer(), prog.getJob(), expAmount,
JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(jPlayer.getPlayer(), prog.getJob(), expAmount,
block, ent, victim, info);
Bukkit.getServer().getPluginManager().callEvent(JobsExpGainEvent);
Bukkit.getServer().getPluginManager().callEvent(jobsExpGainEvent);
// If event is canceled, don't do anything
if (JobsExpGainEvent.isCancelled())
expAmount = 0D;
else
expAmount = JobsExpGainEvent.getExp();
expAmount = jobsExpGainEvent.isCancelled() ? 0D : jobsExpGainEvent.getExp();
try {
if (expAmount != 0D && GconfigManager.BossBarEnabled)
if (GconfigManager.BossBarShowOnEachAction)
BBManager.ShowJobProgression(jPlayer, prog, expAmount);
if (expAmount != 0D && gConfigManager.BossBarEnabled)
if (gConfigManager.BossBarShowOnEachAction)
bbManager.ShowJobProgression(jPlayer, prog, expAmount);
else
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName());
} catch (Throwable e) {
@ -1098,13 +1090,13 @@ public class Jobs extends JavaPlugin {
if (expAmount != 0D)
payments.put(CurrencyType.EXP, expAmount);
FastPayment.put(jPlayer.getUniqueId(), new FastPayment(jPlayer, info, new BufferedPayment(jPlayer.getPlayer(), payments), prog
FASTPAYMENT.put(jPlayer.getUniqueId(), new FastPayment(jPlayer, info, new BufferedPayment(jPlayer.getPlayer(), payments), prog
.getJob()));
economy.pay(jPlayer, payments);
int oldLevel = prog.getLevel();
if (GconfigManager.LoggingUse) {
if (gConfigManager.LoggingUse) {
HashMap<CurrencyType, Double> amounts = new HashMap<>();
amounts.put(CurrencyType.MONEY, income);
amounts.put(CurrencyType.EXP, expAmount);
@ -1128,7 +1120,7 @@ public class Jobs extends JavaPlugin {
}
private static boolean isBpOk(JobsPlayer player, ActionInfo info, Block block, boolean inform) {
if (block == null || !GconfigManager.useBlockProtection)
if (block == null || !gConfigManager.useBlockProtection)
return true;
if (info.getType() == ActionType.BREAK) {
@ -1163,12 +1155,12 @@ public class Jobs extends JavaPlugin {
getBpManager().add(block, cd);
if ((cd == null || cd == 0) && GconfigManager.useGlobalTimer) {
getBpManager().add(block, GconfigManager.globalblocktimer);
if ((cd == null || cd == 0) && gConfigManager.useGlobalTimer) {
getBpManager().add(block, gConfigManager.globalblocktimer);
}
} else if (GconfigManager.useGlobalTimer) {
getBpManager().add(block, GconfigManager.globalblocktimer);
} else if (gConfigManager.useGlobalTimer) {
getBpManager().add(block, gConfigManager.globalblocktimer);
}
} else if (info.getType() == ActionType.PLACE) {
BlockProtection bp = getBpManager().getBp(block.getLocation());
@ -1246,10 +1238,10 @@ public class Jobs extends JavaPlugin {
public static void perform(JobsPlayer jPlayer, ActionInfo info, BufferedPayment payment, Job job) {
// JobsPayment event
JobsExpGainEvent JobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, payment.get(CurrencyType.EXP));
Bukkit.getServer().getPluginManager().callEvent(JobsExpGainEvent);
JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, payment.get(CurrencyType.EXP));
Bukkit.getServer().getPluginManager().callEvent(jobsExpGainEvent);
// If event is canceled, don't do anything
if (JobsExpGainEvent.isCancelled())
if (jobsExpGainEvent.isCancelled())
return;
for (CurrencyType one : CurrencyType.values()) {
@ -1263,7 +1255,7 @@ public class Jobs extends JavaPlugin {
int oldLevel = prog.getLevel();
if (GconfigManager.LoggingUse) {
if (gConfigManager.LoggingUse) {
getLoging().recordToLog(jPlayer, info, payment.getPayment());
}

View File

@ -67,7 +67,7 @@ public class PermissionHandler {
// calculate new permissions
HashMap<String, Boolean> permissions = new HashMap<>();
if (progression.size() == 0) {
if (progression.isEmpty()) {
Job job = Jobs.getNoneJob();
if (job != null) {
for (JobPermission perm : job.getPermissions()) {

View File

@ -303,9 +303,8 @@ public class Placeholder {
return null;
if (message.contains("%"))
message = translateOwnPlaceHolder(player, message);
if (plugin.isPlaceholderAPIEnabled()) {
if (message.contains("%"))
message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders((OfflinePlayer) player, message);
if (plugin.isPlaceholderAPIEnabled() && message.contains("%")) {
message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders((OfflinePlayer) player, message);
}
// For MVdWPlaceholderAPI
// if (plugin.isMVdWPlaceholderAPIEnabled()) {
@ -390,7 +389,7 @@ public class Placeholder {
JobsPlayer user = uuid == null ? null : Jobs.getPlayerManager().getJobsPlayer(uuid);
// Placeholders by JobsPlayer object
if (user != null) {
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
NumberFormat format;
switch (placeHolder) {
case user_dailyquests_pending:
Integer pendingQuests = (int) user.getQuestProgressions().stream().filter(q -> !q.isCompleted()).count();

View File

@ -202,7 +202,6 @@ public class PlayerManager {
jPlayer.onConnect();
jPlayer.reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
return;
}
/**
@ -659,7 +658,7 @@ public class PlayerManager {
for (int i = 0; i < 3; i++) {
String colorInt = sSplit[i];
try {
colorRGB[i] = Integer.valueOf(colorInt).intValue();
colorRGB[i] = Integer.parseInt(colorInt);
} catch (NumberFormatException e) {
Jobs.consoleMsg("[Jobs] &cInvalid color component " + colorInt + ", it must be an integer.");
}
@ -987,7 +986,7 @@ public class PlayerManager {
if (HookManager.getMcMMOManager().mcMMOPresent || HookManager.getMcMMOManager().mcMMOOverHaul)
boost.add(BoostOf.McMMO, new BoostMultiplier().add(HookManager.getMcMMOManager().getMultiplier(player.getPlayer())));
if (ent != null && (ent instanceof Tameable)) {
if (ent instanceof Tameable) {
Tameable t = (Tameable) ent;
if (t.isTamed() && t.getOwner() instanceof Player) {
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay");
@ -1060,8 +1059,6 @@ public class PlayerManager {
if (player.hasPermission("jobs.autojoin." + one.getName().toLowerCase()))
joinJob(jPlayer, one);
}
return;
}
}, Jobs.getGCManager().AutoJobJoinDelay * 20L);
}

View File

@ -58,7 +58,7 @@ public class SignUtil {
HashMap<String, jobsSign> old = SignsByType.get(jSign.getIdentifier().toLowerCase());
if (old == null) {
old = new HashMap<String, jobsSign>();
old = new HashMap<>();
SignsByType.put(jSign.getIdentifier().toLowerCase(), old);
}
@ -109,7 +109,7 @@ public class SignUtil {
HashMap<String, jobsSign> old = SignsByType.get(newTemp.getIdentifier().toLowerCase());
if (old == null) {
old = new HashMap<String, jobsSign>();
old = new HashMap<>();
SignsByType.put(newTemp.getIdentifier().toLowerCase(), old);
}
String loc = newTemp.locToBlockString();
@ -344,20 +344,17 @@ public class SignUtil {
loc.add(0, 1, 0);
Block block = loc.getBlock();
if (directionFacing != null && (block == null || !(block.getState() instanceof Skull)))
if (directionFacing != null && !(block.getState() instanceof Skull))
loc.add(directionFacing.getOppositeFace().getModX(), 0, directionFacing.getOppositeFace().getModZ());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), new Runnable() {
@Override
public void run() {
Block b = loc.getBlock();
if (b == null || !(b.getState() instanceof Skull))
if (!(b.getState() instanceof Skull))
return;
Skull skull = (Skull) b.getState();
if (skull == null)
return;
if (skull.getOwner() != null && skull.getOwner().equalsIgnoreCase(Playername))
return;

View File

@ -28,8 +28,8 @@ public class jobsSign {
return special;
}
public void setJobName(String JobName) {
this.jobName = JobName;
public void setJobName(String jobName) {
this.jobName = jobName;
}
public String getJobName() {
@ -48,8 +48,8 @@ public class jobsSign {
this.z = z;
}
public void setWorldName(String World) {
this.worldName = World;
public void setWorldName(String worldName) {
this.worldName = worldName;
}
public String getWorldName() {
@ -68,8 +68,8 @@ public class jobsSign {
return loc;
}
public void setNumber(int Number) {
this.number = Number;
public void setNumber(int number) {
this.number = number;
}
public int getNumber() {

View File

@ -49,11 +49,9 @@ public class JobsCommands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
if (!Jobs.getGCManager().canPerformActionInWorld(((Player) sender).getWorld()) && !sender.hasPermission("jobs.disabledworld.commands")) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.worldisdisabled"));
return true;
}
if (sender instanceof Player && !Jobs.getGCManager().canPerformActionInWorld(((Player) sender).getWorld()) && !sender.hasPermission("jobs.disabledworld.commands")) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.worldisdisabled"));
return true;
}
if (args.length == 0)
@ -88,11 +86,9 @@ public class JobsCommands implements CommandExecutor {
}
String[] myArgs = reduceArgs(args);
if (myArgs.length > 0) {
if (myArgs[myArgs.length - 1].equals("?")) {
sendUsage(sender, cmd);
return true;
}
if (myArgs.length > 0 && myArgs[myArgs.length - 1].equals("?")) {
sendUsage(sender, cmd);
return true;
}
boolean back = cmdClass.perform(plugin, sender, myArgs);
@ -423,13 +419,18 @@ public class JobsCommands implements CommandExecutor {
}
public String jobProgressMessage(double max, double current) {
if (current < 0)
current = 0;
if (max < current)
max = current;
if (max < 1)
max = 2;
String message = "";
String pos = ChatColor.DARK_GREEN + "\u258F";
String pros = ChatColor.YELLOW + "\u258F";
if (current < 0)
current = 0;
if (max < current)
max = current;
int percentage = (int) ((current * 50.0) / max);
for (int i = 0; i < percentage; i++) {
message += pos;

View File

@ -39,10 +39,10 @@ public class leave implements Cmd {
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (!Util.leaveConfirm.contains(uuid)) {
Util.leaveConfirm.add(uuid);
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.leaveConfirm.remove(uuid),
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]",
@ -50,7 +50,7 @@ public class leave implements Cmd {
return true;
}
Util.leaveConfirm.remove(uuid);
Util.LEAVECONFIRM.remove(uuid);
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);

View File

@ -34,10 +34,10 @@ public class leaveall implements Cmd {
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (!Util.leaveConfirm.contains(uuid)) {
Util.leaveConfirm.add(uuid);
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.leaveConfirm.remove(uuid),
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]",
@ -45,7 +45,7 @@ public class leaveall implements Cmd {
return true;
}
Util.leaveConfirm.remove(uuid);
Util.LEAVECONFIRM.remove(uuid);
}
Jobs.getPlayerManager().leaveAllJobs(jPlayer);

View File

@ -151,8 +151,7 @@ public class BlockProtectionManager {
if (chunk == null)
return null;
String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
BlockProtection Bp = chunk.get(v);
return Bp;
return chunk.get(v);
}
private static String locToChunk(Location loc) {
@ -164,8 +163,7 @@ public class BlockProtectionManager {
private static String locToRegion(Location loc) {
int x = (int) Math.floor(loc.getBlockX() / 16);
int z = (int) Math.floor(loc.getBlockZ() / 16);
String reg = (int) Math.floor(x / 32) + ":" + (int) Math.floor(z / 32);
return reg;
return (int) Math.floor(x / 32) + ":" + (int) Math.floor(z / 32);
}
public Integer getBlockDelayTime(Block block) {

View File

@ -71,7 +71,7 @@ public class BossBarManager {
}
String message = Jobs.getLanguage().getMessage("command.stats.bossBarOutput",
"%joblevel%", Integer.valueOf(jobProg.getLevel()).toString(),
"%joblevel%", Integer.toString(jobProg.getLevel()),
"%jobname%", jobProg.getJob().getNameWithColor(),
"%jobxp%", formatter.format(Math.round(jobProg.getExperience() * 100.0) / 100.0),
"%jobmaxxp%", jobProg.getMaxExperience(),
@ -104,7 +104,7 @@ public class BossBarManager {
break;
}
}
BarStyle style = BarStyle.SOLID;
BarStyle style;
switch (Jobs.getGCManager().SegmentCount) {
case 6:
style = BarStyle.SEGMENTED_6;
@ -152,7 +152,6 @@ public class BossBarManager {
tempBar.setVisible(false);
break;
}
return;
}
}, Jobs.getGCManager().BossBarTimer * 20L));

View File

@ -1149,7 +1149,7 @@ public class ConfigManager {
quest.addObjective(objective);
}
}
} catch (Exception | Error e) {
} catch (Throwable e) {
log.warning("Job " + jobKey + " has incorrect quest objective (" + oneObjective + ")!");
}
}

View File

@ -256,17 +256,11 @@ public class GeneralConfigManager {
}
public boolean canPerformActionInWorld(Entity ent) {
if (ent == null || ent.getWorld() == null)
return true;
return canPerformActionInWorld(ent.getWorld());
return ent == null || canPerformActionInWorld(ent.getWorld());
}
public boolean canPerformActionInWorld(Player player) {
if (player == null)
return true;
return canPerformActionInWorld(player.getWorld());
return player == null || canPerformActionInWorld(player.getWorld());
}
public boolean canPerformActionInWorld(World world) {
@ -278,15 +272,7 @@ public class GeneralConfigManager {
return true;
if (UseAsWhiteListWorldList) {
if (DisabledWorldsList.isEmpty()) {
return false;
}
if (DisabledWorldsList.contains(world)) {
return true;
}
return false;
return DisabledWorldsList.isEmpty() && DisabledWorldsList.contains(world);
}
if (DisabledWorldsList.isEmpty())

View File

@ -309,10 +309,8 @@ public class NameTranslatorManager {
name = c.getC().getString("ItemList." + one.toString());
}
if (name == null) {
if (c.getC().isConfigurationSection("ItemList." + n)) {
name = c.getC().getString("ItemList." + n + ".Name");
}
if (name == null && c.getC().isConfigurationSection("ItemList." + n)) {
name = c.getC().getString("ItemList." + n + ".Name");
}
if (name == null) {
@ -394,7 +392,7 @@ public class NameTranslatorManager {
if (one == null || CMIEnchantment.getName(one) == null)
continue;
String name = Util.firstToUpperCase(CMIEnchantment.getName(one).toString()).replace("_", " ");
String name = Util.firstToUpperCase(CMIEnchantment.getName(one)).replace("_", " ");
if (c.getC().isConfigurationSection("EnchantList"))
for (String onek : c.getC().getConfigurationSection("EnchantList").getKeys(false)) {
String old = c.getC().getString("EnchantList." + onek + ".MCName");

View File

@ -55,8 +55,7 @@ public class RestrictedAreaManager {
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
StringBuilder header = new StringBuilder();
header = addHeader(header);
addHeader(new StringBuilder());
conf.set("restrictedareas." + name, null);
try {
conf.save(f);
@ -75,8 +74,7 @@ public class RestrictedAreaManager {
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
StringBuilder header = new StringBuilder();
header = addHeader(header);
addHeader(new StringBuilder());
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
String areaKey = area.getKey();
CuboidArea cuboid = area.getValue().getCuboidArea();
@ -185,13 +183,13 @@ public class RestrictedAreaManager {
restrictedAreas.clear();
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
StringBuilder header = new StringBuilder();
header = addHeader(header);
StringBuilder header = addHeader(new StringBuilder());
conf.options().header(header.toString());
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
if (areaSection != null) {
for (String areaKey : areaSection.getKeys(false)) {

View File

@ -57,7 +57,7 @@ public class ScheduleManager {
String currenttime = dateFormat.format(date);
int Current = Integer.valueOf(currenttime.replace(":", ""));
int Current = Integer.parseInt(currenttime.replace(":", ""));
String CurrentDayName = getWeekDay();

View File

@ -470,7 +470,5 @@ public class ShopManager {
if (!list.isEmpty())
Jobs.consoleMsg("&e[Jobs] Loaded " + list.size() + " shop items!");
return;
}
}

View File

@ -66,7 +66,7 @@ public class TitleManager {
ConfigurationSection titleSection = c.getC().getConfigurationSection("Titles");
if (titleSection == null) {
titleSection = c.getC().createSection("Titles");
c.getC().createSection("Titles");
titles.add(new Title(
c.get("Titles.Novice.Name", "N"),

View File

@ -71,7 +71,7 @@ public class YmlMaker {
}
public boolean exists() {
return ConfigFile != null && ConfigFile.exists() ? true : ConfigFile.exists();
return ConfigFile != null && ConfigFile.exists();
}
public void createNewFile() {

View File

@ -43,7 +43,7 @@ public class CuboidArea {
int xsize = (highPoints.getBlockX() - lowPoints.getBlockX()) + 1;
int zsize = (highPoints.getBlockZ() - lowPoints.getBlockZ()) + 1;
int ysize = (highPoints.getBlockY() - lowPoints.getBlockY()) + 1;
return xsize * ysize * zsize;
return (long) xsize * ysize * zsize;
}
public int getXSize() {

View File

@ -50,7 +50,7 @@ public class ExploreChunk {
}
public boolean isAlreadyVisited(int playerId) {
return isFullyExplored() ? true : playerIds.contains(playerId);
return isFullyExplored() || playerIds.contains(playerId);
}
public int getCount() {
@ -100,7 +100,7 @@ public class ExploreChunk {
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(id);
if (info != null)
playerIds.add(id);
} catch (Exception | Error e) {
} catch (Throwable e) {
updated = true;
JobsPlayer jp = Jobs.getPlayerManager().getJobsPlayer(one);
if (jp != null)

View File

@ -562,9 +562,6 @@ public class Job {
if (block != null && worldBlacklist.contains(block.getWorld().getName()))
return true;
if (ent != null && worldBlacklist.contains(ent.getWorld().getName()))
return true;
return false;
return ent != null && worldBlacklist.contains(ent.getWorld().getName());
}
}

View File

@ -240,9 +240,7 @@ public class JobProgression {
return true;
if (this.leftOn + this.getJob().getRejoinCd() < System.currentTimeMillis())
return true;
if (this.jPlayer != null && jPlayer.getPlayer() != null && jPlayer.getPlayer().hasPermission("jobs.rejoinbypass"))
return true;
return false;
return jPlayer != null && jPlayer.getPlayer() != null && jPlayer.getPlayer().hasPermission("jobs.rejoinbypass");
}
public String getRejoinTimeMessage() {

View File

@ -467,7 +467,7 @@ public class JobsPlayer {
level = jp.getLevel();
else {
level = jp.getLevel();
level = (int) ((level - (level * (Jobs.getGCManager().levelLossPercentageFromMax / 100.0))));
level = (int) (level - (level * (Jobs.getGCManager().levelLossPercentageFromMax / 100.0)));
if (level < 1)
level = 1;
}
@ -1003,7 +1003,7 @@ public class JobsPlayer {
HashMap<String, QuestProgression> g = new HashMap<>();
if (qProgression.get(job.getName()) != null)
g = new HashMap<String, QuestProgression>(qProgression.get(job.getName()));
g = new HashMap<>(qProgression.get(job.getName()));
HashMap<String, QuestProgression> tmp = new HashMap<>();
for (Entry<String, QuestProgression> one : (new HashMap<String, QuestProgression>(g)).entrySet()) {
@ -1012,7 +1012,6 @@ public class JobsPlayer {
if (qp.isEnded()) {
g.remove(one.getKey().toLowerCase());
skippedQuests = 0;
continue;
}
}
@ -1164,7 +1163,7 @@ public class JobsPlayer {
if (qp.isCompleted())
qp.setGivenReward(true);
} catch (Exception | Error e) {
} catch (Throwable e) {
e.printStackTrace();
}
}

View File

@ -169,7 +169,7 @@ public class Quest {
for (QuestObjective one : old.values()) {
if (one.getTargetId() == objective.getTargetId() &&
one.getAction() == objective.getAction() && objective.getAmount() == one.getAmount()
&& objective.getTargetName() == one.getTargetName())
&& objective.getTargetName().equals(one.getTargetName()))
return true;
}
return false;

View File

@ -24,8 +24,7 @@ public class QuestProgression {
}
public Quest getQuest() {
Quest q = quest == null ? null : (quest.getJob() == null ? null : quest.getJob().getQuest(quest.getConfigName()));
return q;
return (quest == null || quest.getJob() == null) ? null : quest.getJob().getQuest(quest.getConfigName());
}
public void setQuest(Quest quest) {

View File

@ -942,8 +942,6 @@ public abstract class JobsDAO {
if (Util.getJobsWorld(one.getName()) == null)
recordNewWorld(one.getName());
}
return;
}
public void triggerTableIdUpdate() {
@ -2592,11 +2590,10 @@ public abstract class JobsDAO {
try {
prest = conn.prepareStatement("VACUUM;");
prest.execute();
} catch (Exception | Error e) {
} catch (Throwable e) {
} finally {
close(prest);
}
return;
}
/**

View File

@ -28,19 +28,22 @@ public class JobsManager {
public void switchDataBase() {
if (dao != null)
dao.closeConnections();
// Picking opposite database then it is currently
switch (DbType) {
case MySQL:
// If it MySQL lets change to SqLite
DbType = DataBaseType.SqLite;
dao = startSqlite();
dao.setDbType(DbType);
if (dao != null)
dao.setDbType(DbType);
break;
case SqLite:
// If it SqLite lets change to MySQL
DbType = DataBaseType.MySQL;
dao = startMysql();
dao.setDbType(DbType);
if (dao != null)
dao.setDbType(DbType);
break;
default:
break;

View File

@ -89,17 +89,12 @@ public class BufferedEconomy {
*/
@SuppressWarnings("deprecation")
public void payAll() {
if (payments.isEmpty())
return;
if (!plugin.isEnabled())
if (payments.isEmpty() || !plugin.isEnabled())
return;
synchronized (paymentCache) {
Double TotalAmount = 0.0;
Double TotalPoints = 0.0;
Double TaxesAmount = 0.0;
Double TaxesPoints = 0.0;
Double TotalAmount = 0.0, TotalPoints = 0.0, TaxesAmount = 0.0, TaxesPoints = 0.0;
// combine all payments using paymentCache
while (!payments.isEmpty()) {
@ -158,11 +153,9 @@ public class BufferedEconomy {
economy.depositPlayer(ServerTaxesAccount, TaxesAmount);
}
if (ServerTaxesAccount.isOnline()) {
if (Jobs.getGCManager().ActionBarsMessageByDefault) {
ActionBarManager.send(Bukkit.getPlayer(ServerAccountname),
Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100) / 100.0));
}
if (ServerTaxesAccount.isOnline() && Jobs.getGCManager().ActionBarsMessageByDefault) {
ActionBarManager.send(Bukkit.getPlayer(ServerAccountname),
Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100) / 100.0));
}
}
@ -190,11 +183,9 @@ public class BufferedEconomy {
// Do we need this?
payment.getPayment().putAll(JobsPaymentEvent.getPayment());
if (Jobs.getGCManager().UseServerAccount) {
if (!hasMoney) {
ActionBarManager.send(payment.getOfflinePlayer().getPlayer(), Jobs.getLanguage().getMessage("economy.error.nomoney"));
continue;
}
if (Jobs.getGCManager().UseServerAccount && !hasMoney) {
ActionBarManager.send(payment.getOfflinePlayer().getPlayer(), Jobs.getLanguage().getMessage("economy.error.nomoney"));
continue;
}
if (Jobs.getGCManager().isEconomyAsync())
@ -232,16 +223,16 @@ public class BufferedEconomy {
if ((abp != null) && (show.booleanValue())) {
String Message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main");
if (payment.get(CurrencyType.MONEY) != 0D) {
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", new Object[] { "[amount]", String.format(Jobs.getGCManager().getDecimalPlacesMoney(),
new Object[] { Double.valueOf(payment.get(CurrencyType.MONEY)) }) });
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format(Jobs.getGCManager().getDecimalPlacesMoney(),
Double.valueOf(payment.get(CurrencyType.MONEY))));
}
if (payment.get(CurrencyType.POINTS) != 0D) {
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", new Object[] { "[points]", String.format(Jobs.getGCManager().getDecimalPlacesPoints(),
new Object[] { Double.valueOf(payment.get(CurrencyType.POINTS)) }) });
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format(Jobs.getGCManager().getDecimalPlacesPoints(),
Double.valueOf(payment.get(CurrencyType.POINTS))));
}
if (payment.get(CurrencyType.EXP) != 0D) {
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", new Object[] { "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(), new Object[] {
Double.valueOf(payment.get(CurrencyType.EXP)) }) });
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(),
Double.valueOf(payment.get(CurrencyType.EXP))));
}
ActionBarManager.send(abp, Message);
}

View File

@ -20,25 +20,20 @@ public class MyPetManager {
}
public boolean isMyPet(Object ent) {
if (!enabled || ent == null)
return false;
if (!(ent instanceof MyPetBukkitEntity))
if (!enabled || !(ent instanceof MyPetBukkitEntity))
return false;
return true;
}
public UUID getOwnerOfPet(Object ent) {
if (!enabled || ent == null)
return null;
if (!(ent instanceof MyPetBukkitEntity))
if (!enabled || !(ent instanceof MyPetBukkitEntity))
return null;
MyPet myPet = ((MyPetBukkitEntity) ent).getMyPet();
try {
UUID uuid = myPet.getOwner().getPlayer().getUniqueId();
return uuid;
return myPet.getOwner().getPlayer().getUniqueId();
} catch (Exception e) {
return null;
}

View File

@ -27,11 +27,9 @@ public class WorldGuardManager {
public WorldGuardManager() {
Plugin pl = Bukkit.getPluginManager().getPlugin("WorldGuard");
if (pl != null && (pl instanceof WorldGuardPlugin)) {
if (pl.getDescription().getVersion().equals("6.1")) {
wg = (WorldGuardPlugin) pl;
useOld = true;
}
if (pl instanceof WorldGuardPlugin && pl.getDescription().getVersion().equals("6.1")) {
wg = (WorldGuardPlugin) pl;
useOld = true;
}
}
@ -56,16 +54,14 @@ public class WorldGuardManager {
} catch (Throwable e) {
}
return new ArrayList<RestrictedArea>();
return new ArrayList<>();
}
public boolean inArea(Location loc, String name) {
if (useOld) {
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
for (ProtectedRegion one : regions.getRegions()) {
if (!one.getId().equalsIgnoreCase(name))
continue;
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
if (!one.getId().equalsIgnoreCase(name) || !one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
continue;
return true;
}
@ -73,9 +69,7 @@ public class WorldGuardManager {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
for (ProtectedRegion one : regions.getRegions().values()) {
if (!one.getId().equalsIgnoreCase(name))
continue;
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
if (!one.getId().equalsIgnoreCase(name) || !one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
continue;
return true;
}

View File

@ -80,7 +80,7 @@ public class Language {
try {
List<String> ls = null;
if (customlocale.isList(key))
if (customlocale != null && customlocale.isList(key))
ls = ColorsArray(customlocale.getStringList(key), true);
else if (enlocale.isList(key))
ls = !enlocale.getStringList(key).isEmpty() ? ColorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing);

View File

@ -122,9 +122,7 @@ public class JobsListener implements Listener {
}
long time = System.currentTimeMillis() - interactDelay.get(player.getUniqueId());
interactDelay.put(player.getUniqueId(), System.currentTimeMillis());
if (time > 100)
return true;
return false;
return time > 100;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -263,12 +261,10 @@ public class JobsListener implements Listener {
Player player = event.getPlayer();
Sign sign = (Sign) block.getState();
String FirstLine = sign.getLine(0);
if (FirstLine.contains(Jobs.getLanguage().getMessage("signs.topline"))) {
if (!player.hasPermission("jobs.command.signs")) {
event.setCancelled(true);
player.sendMessage(Jobs.getLanguage().getMessage("signs.cantdestroy"));
return;
}
if (FirstLine.contains(Jobs.getLanguage().getMessage("signs.topline")) && !player.hasPermission("jobs.command.signs")) {
event.setCancelled(true);
player.sendMessage(Jobs.getLanguage().getMessage("signs.cantdestroy"));
return;
}
jobsSign jSign = Jobs.getSignUtil().getSign(block.getLocation());
@ -516,10 +512,8 @@ public class JobsListener implements Listener {
if (oneItem.getType() != mat)
return false;
if (oneItem.getName() != null && name != null) {
if (!CMIChatColor.translate(oneItem.getName()).equalsIgnoreCase(name)) {
return false;
}
if (oneItem.getName() != null && name != null && !CMIChatColor.translate(oneItem.getName()).equalsIgnoreCase(name)) {
return false;
}
for (String onelore : oneItem.getLore()) {
@ -530,18 +524,13 @@ public class JobsListener implements Listener {
boolean foundEnc = false;
for (Entry<Enchantment, Integer> oneE : enchants.entrySet()) {
if (oneItem.getenchants().containsKey(oneE.getKey())) {
if (oneItem.getenchants().get(oneE.getKey()) <= oneE.getValue()) {
foundEnc = true;
break;
}
if (oneItem.getenchants().containsKey(oneE.getKey()) && oneItem.getenchants().get(oneE.getKey()) <= oneE.getValue()) {
foundEnc = true;
break;
}
}
if (!foundEnc)
return false;
return true;
return foundEnc;
}
@EventHandler

View File

@ -355,16 +355,14 @@ public class JobsPaymentListener implements Listener {
BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.BREAK);
FastPayment fp = Jobs.FastPayment.get(player.getUniqueId());
FastPayment fp = Jobs.FASTPAYMENT.get(player.getUniqueId());
if (fp != null) {
if (fp.getTime() > System.currentTimeMillis()) {
if (fp.getInfo().getName().equalsIgnoreCase(bInfo.getName()) ||
fp.getInfo().getNameWithSub().equalsIgnoreCase(bInfo.getNameWithSub())) {
Jobs.perform(fp.getPlayer(), fp.getInfo(), fp.getPayment(), fp.getJob());
return;
}
if (fp.getTime() > System.currentTimeMillis() && fp.getInfo().getName().equalsIgnoreCase(bInfo.getName()) ||
fp.getInfo().getNameWithSub().equalsIgnoreCase(bInfo.getNameWithSub())) {
Jobs.perform(fp.getPlayer(), fp.getInfo(), fp.getPayment(), fp.getJob());
return;
}
Jobs.FastPayment.remove(player.getUniqueId());
Jobs.FASTPAYMENT.remove(player.getUniqueId());
}
if (!payForItemDurabilityLoss(player))
@ -375,9 +373,8 @@ public class JobsPaymentListener implements Listener {
// Protection for block break with silktouch
if (Jobs.getGCManager().useSilkTouchProtection) {
for (Enchantment one : item.getEnchantments().keySet()) {
if (CMIEnchantment.get(one) == CMIEnchantment.SILK_TOUCH) {
if (Jobs.getBpManager().isInBp(block))
return;
if (CMIEnchantment.get(one) == CMIEnchantment.SILK_TOUCH && Jobs.getBpManager().isInBp(block)) {
return;
}
}
}
@ -640,24 +637,20 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null)
return;
if (y == 2) {
if (first == second && third == second) {
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
return;
}
if (y == 2 && first == second && third == second) {
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
return;
}
// Check Dyes
if (y >= 2) {
if ((third != null && third.isDye() || second != null && second.isDye() || first != null && first.isDye())
if (y >= 2 && (third != null && third.isDye() || second != null && second.isDye() || first != null && first.isDye())
&& (leather || shulker)) {
Jobs.action(jPlayer, new ItemActionInfo(sourceItems[0], ActionType.DYE));
for (ItemStack OneDye : DyeStack) {
Jobs.action(jPlayer, new ItemActionInfo(OneDye, ActionType.DYE));
}
return;
Jobs.action(jPlayer, new ItemActionInfo(sourceItems[0], ActionType.DYE));
for (ItemStack OneDye : DyeStack) {
Jobs.action(jPlayer, new ItemActionInfo(OneDye, ActionType.DYE));
}
return;
}
// If we need to pay only by each craft action we will skip calculation how much was crafted
@ -732,8 +725,6 @@ public class JobsPaymentListener implements Listener {
Jobs.action(jPlayer, new ItemActionInfo(resultStack, type));
}
}
return;
}
}, 1);
}
@ -824,9 +815,8 @@ public class JobsPaymentListener implements Listener {
if (resultStack.hasItemMeta())
NewName = resultStack.getItemMeta().getDisplayName();
if (OriginalName != NewName && inv.getItem(1) == null)
if (!Jobs.getGCManager().PayForRenaming)
return;
if (OriginalName != null && !OriginalName.equals(NewName) && inv.getItem(1) == null && !Jobs.getGCManager().PayForRenaming)
return;
// Check for world permissions
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
@ -1118,7 +1108,7 @@ public class JobsPaymentListener implements Listener {
if (damage > s)
damage = s;
if (shooter != null && shooter instanceof Player) {
if (shooter instanceof Player) {
if (ent.hasMetadata(entityDamageByPlayer) && !ent.getMetadata(entityDamageByPlayer).isEmpty())
damage += ent.getMetadata(entityDamageByPlayer).get(0).asDouble();
@ -1132,7 +1122,7 @@ public class JobsPaymentListener implements Listener {
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return;
if (event.getEntity().getLastDamageCause() == null || !(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent))
if (!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent))
return;
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause();
@ -1144,9 +1134,8 @@ public class JobsPaymentListener implements Listener {
LivingEntity lVictim = (LivingEntity) e.getEntity();
//extra check for Citizens 2 sentry kills
if (e.getDamager() instanceof Player)
if (e.getDamager().hasMetadata("NPC"))
return;
if (e.getDamager() instanceof Player && e.getDamager().hasMetadata("NPC"))
return;
if (Jobs.getGCManager().MythicMobsEnabled && HookManager.getMythicManager() != null
&& HookManager.getMythicManager().isMythicMob(lVictim)) {
@ -1413,7 +1402,6 @@ public class JobsPaymentListener implements Listener {
if (type == EntityType.MAGMA_CUBE && Jobs.getGCManager().PreventMagmaCubeSplit) {
event.setCancelled(true);
return;
}
}
@ -1566,9 +1554,8 @@ public class JobsPaymentListener implements Listener {
&& block.hasMetadata(brewingOwnerMetadata))
FurnaceBrewingHandling.removeBrewing(block);
if (Jobs.getGCManager().useBlockProtection)
if (block.getState().hasMetadata(BlockMetadata))
return;
if (Jobs.getGCManager().useBlockProtection && block.getState().hasMetadata(BlockMetadata))
return;
BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.TNTBREAK);
Jobs.action(jPlayer, bInfo, block);
@ -1606,14 +1593,13 @@ public class JobsPaymentListener implements Listener {
}
if (Version.isCurrentEqualOrHigher(Version.v1_15_R1) && event.useInteractedBlock() != org.bukkit.event.Event.Result.DENY
&& event.getAction() == Action.RIGHT_CLICK_BLOCK && !p.isSneaking()) {
if (jPlayer != null && (cmat == CMIMaterial.BEEHIVE || cmat == CMIMaterial.BEE_NEST)) {
&& event.getAction() == Action.RIGHT_CLICK_BLOCK && !p.isSneaking() && jPlayer != null
&& (cmat == CMIMaterial.BEEHIVE || cmat == CMIMaterial.BEE_NEST)) {
org.bukkit.block.data.type.Beehive beehive = (org.bukkit.block.data.type.Beehive) block.getBlockData();
if (beehive.getHoneyLevel() == beehive.getMaximumHoneyLevel() && (hand == CMIMaterial.SHEARS.getMaterial()
|| hand == CMIMaterial.GLASS_BOTTLE.getMaterial())) {
Jobs.action(jPlayer, new BlockCollectInfo(block, ActionType.COLLECT, beehive.getHoneyLevel()), block);
}
}
}
if (cmat == CMIMaterial.FURNACE || cmat == CMIMaterial.LEGACY_BURNING_FURNACE
@ -1760,9 +1746,7 @@ public class JobsPaymentListener implements Listener {
return true;
for (Entry<Enchantment, Integer> oneG : got.entrySet()) {
if (!hand.getEnchantments().containsKey(oneG.getKey()))
return false;
if (oneG.getValue() != null && hand.getEnchantments().get(oneG.getKey()) != oneG.getValue())
if (!hand.getEnchantments().containsKey(oneG.getKey()) || hand.getEnchantments().get(oneG.getKey()) != oneG.getValue())
return false;
}

View File

@ -333,9 +333,6 @@ public class FurnaceBrewingHandling {
for (blockLoc one : ls) {
Block block = one.getBlock();
if (block == null)
continue;
CMIMaterial cmat = CMIMaterial.get(block);
if (cmat != CMIMaterial.FURNACE && cmat != CMIMaterial.LEGACY_BURNING_FURNACE && cmat != CMIMaterial.SMOKER && cmat != CMIMaterial.BLAST_FURNACE)
continue;
@ -353,9 +350,6 @@ public class FurnaceBrewingHandling {
for (blockLoc one : ls) {
Block block = one.getBlock();
if (block == null)
continue;
if (CMIMaterial.get(block) == CMIMaterial.BREWING_STAND)
block.removeMetadata(JobsPaymentListener.brewingOwnerMetadata, Jobs.getInstance());
}

View File

@ -16,11 +16,7 @@ public class Loging {
public void recordToLog(JobsPlayer jPlayer, String ActionName, String item, HashMap<CurrencyType, Double> amounts) {
HashMap<String, Log> logList = jPlayer.getLog();
Log l = null;
for (Log one : logList.values()) {
l = one;
break;
}
Log l = logList.values().stream().findFirst().orElse(null);
if (l != null && Jobs.getScheduleManager().getDateByInt() != l.getDate()) {
Jobs.getJobsDAO().saveLog(jPlayer);
jPlayer.getLog().clear();

View File

@ -37,7 +37,7 @@ public class PageInfo {
}
public boolean isInRange(int place) {
return place >= start && place <= end ? true : false;
return place >= start && place <= end;
}
public boolean isEntryOk() {

View File

@ -10,22 +10,14 @@ import com.gamingmesh.jobs.container.JobsPlayer;
public class PerformCommands {
public static void PerformCommandsOnLeave(JobsPlayer jPlayer, Job job) {
List<String> cmds = job.getCmdOnLeave();
if (cmds.size() == 0)
return;
for (String one : cmds) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getName()).replace("[jobname]", job.getName()));
}
}
public static void PerformCommandsOnJoin(JobsPlayer jPlayer, Job job) {
List<String> cmds = job.getCmdOnJoin();
if (cmds.size() == 0)
return;
for (String one : cmds) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getName()).replace("[jobname]", job.getName()));
}

View File

@ -55,22 +55,19 @@ public class TimeManage {
}
public static long toDays(Long ticks) {
long days = ticks / 1000 / 60 / 60 / 24;
return days;
return ticks / 1000 / 60 / 60 / 24;
}
public static long toMinutes(Long ticks) {
long d = toDays(ticks);
ticks = ticks - (d * 1000 * 60 * 60 * 24);
long h = toHours(ticks);
long minutes = (ticks - (h * 60 * 60 * 1000)) / 1000 / 60;
return minutes;
return (ticks - (h * 60 * 60 * 1000)) / 1000 / 60;
}
public static long toHours(Long ticks) {
long d = toDays(ticks);
long hours = (ticks - (d * 1000 * 60 * 60 * 24)) / 1000 / 60 / 60;
return hours;
return (ticks - (d * 1000 * 60 * 60 * 24)) / 1000 / 60 / 60;
}
public static long toSec(Long ticks) {

View File

@ -35,7 +35,7 @@ public class Util {
private static HashMap<String, JobsWorld> jobsWorlds = new HashMap<>();
public static List<UUID> leaveConfirm = new ArrayList<>();
public static final List<UUID> LEAVECONFIRM = new ArrayList<>();
@SuppressWarnings("deprecation")
public static ItemStack getSkull(String skullOwner) {

View File

@ -92,7 +92,6 @@ public class blockLoc {
this.w = w;
Location loc = new Location(w, x, y, z);
return loc;
return new Location(w, x, y, z);
}
}