1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00
This commit is contained in:
Zrips 2022-01-13 12:37:50 +02:00
parent 93f5423300
commit 5e066dfda7
38 changed files with 249 additions and 400 deletions

Binary file not shown.

BIN
libs/CMILib1.1.0.2.jar Normal file

Binary file not shown.

View File

@ -146,7 +146,7 @@ public class GuiManager {
ItemStack guiItem = job.getGuiItem();
ItemMeta meta = guiItem.getItemMeta();
meta.setDisplayName(job.getJobDisplayName());
meta.setDisplayName(job.getDisplayName());
meta.setLore(lore);
if (Jobs.getGCManager().hideItemAttributes) {
@ -280,7 +280,7 @@ public class GuiManager {
continue;
ItemMeta meta = guiItem.getItemMeta();
meta.setDisplayName(job.getJobDisplayName());
meta.setDisplayName(job.getDisplayName());
meta.setLore(lore);
guiItem.setItemMeta(meta);
tempInv.setItem(i, guiItem.clone());
@ -300,7 +300,7 @@ public class GuiManager {
}
ItemMeta meta = guiItem.getItemMeta();
meta.setDisplayName(job.getJobDisplayName());
meta.setDisplayName(job.getDisplayName());
meta.setLore(lore);
guiItem.setItemMeta(meta);
tempInv.setItem(i, guiItem.clone());
@ -431,7 +431,7 @@ public class GuiManager {
}
ItemMeta meta = guiItem.getItemMeta();
meta.setDisplayName(job.getJobDisplayName());
meta.setDisplayName(job.getDisplayName());
meta.setLore(lore);
guiItem.setItemMeta(meta);
tempInv.setItem(i, guiItem.clone());
@ -450,7 +450,7 @@ public class GuiManager {
}
ItemMeta meta = guiItem.getItemMeta();
meta.setDisplayName(job.getJobDisplayName());
meta.setDisplayName(job.getDisplayName());
meta.setLore(lore);
guiItem.setItemMeta(meta);
tempInv.setItem(i, guiItem.clone());

View File

@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.WeakHashMap;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
@ -92,7 +91,6 @@ import com.gamingmesh.jobs.economy.BufferedEconomy;
import com.gamingmesh.jobs.economy.BufferedPayment;
import com.gamingmesh.jobs.economy.Economy;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.economy.PointsData;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.listeners.JobsListener;
@ -116,7 +114,6 @@ import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version;
@ -174,8 +171,6 @@ public final class Jobs extends JavaPlugin {
protected static VersionChecker versionCheckManager;
protected static SelectionManager smanager;
private static PointsData pointsDatabase;
public Complement getComplement() {
return complement;
}
@ -289,23 +284,10 @@ public final class Jobs extends JavaPlugin {
public static JobsManager getDBManager() {
if (dbManager == null)
dbManager = new JobsManager(instance);
dbManager = new JobsManager(getInstance());
return dbManager;
}
/**
* Gets the PointsData
* @deprecated Use {@link JobsPlayer#getPointsData()}
* @return {@link PointsData}
*/
@Deprecated
public static PointsData getPointsData() {
if (pointsDatabase == null)
pointsDatabase = new PointsData();
return pointsDatabase;
}
public static ShopManager getShopManager() {
if (shopManager == null) {
shopManager = new ShopManager();
@ -330,7 +312,7 @@ public final class Jobs extends JavaPlugin {
*/
public static PlayerManager getPlayerManager() {
if (pManager == null)
pManager = new PlayerManager(instance);
pManager = new PlayerManager(getInstance());
return pManager;
}
@ -371,7 +353,7 @@ public final class Jobs extends JavaPlugin {
*/
public static ScheduleManager getScheduleManager() {
if (scheduleManager == null) {
scheduleManager = new ScheduleManager(instance);
scheduleManager = new ScheduleManager(getInstance());
}
return scheduleManager;
@ -393,7 +375,7 @@ public final class Jobs extends JavaPlugin {
public static JobsCommands getCommandManager() {
if (cManager == null) {
cManager = new JobsCommands(instance);
cManager = new JobsCommands(getInstance());
}
return cManager;
}
@ -404,17 +386,11 @@ public final class Jobs extends JavaPlugin {
return exploreManager;
}
// TODO Get rid of this entirely from project
// There are better implementations than this
protected static Jobs instance;
/**
* This shouldn't be used.
* @return returns this class object instance
*/
@Deprecated
public static Jobs getInstance() {
return instance;
return JavaPlugin.getPlugin(Jobs.class);
}
/**
@ -423,7 +399,7 @@ public final class Jobs extends JavaPlugin {
*/
public static SignUtil getSignUtil() {
if (signManager == null) {
signManager = new SignUtil(instance);
signManager = new SignUtil(getInstance());
}
return signManager;
@ -452,11 +428,11 @@ public final class Jobs extends JavaPlugin {
* @return the plugin logger
*/
public static Logger getPluginLogger() {
return instance.getLogger();
return getInstance().getLogger();
}
public static File getFolder() {
File folder = instance.getDataFolder();
File folder = getInstance().getDataFolder();
folder.mkdirs();
return folder;
}
@ -544,7 +520,7 @@ public final class Jobs extends JavaPlugin {
return placeholderAPIEnabled;
}
private void startup() {
private static void startup() {
reload(true);
// This goes in sync to avoid issues while loading data
@ -686,7 +662,7 @@ public final class Jobs extends JavaPlugin {
*/
public static PermissionHandler getPermissionHandler() {
if (permissionHandler == null)
permissionHandler = new PermissionHandler(instance);
permissionHandler = new PermissionHandler(getInstance());
return permissionHandler;
}
@ -701,7 +677,7 @@ public final class Jobs extends JavaPlugin {
* @param eco - the economy handler
*/
public static void setEconomy(Economy eco) {
economy = new BufferedEconomy(instance, eco);
economy = new BufferedEconomy(getInstance(), eco);
}
/**
@ -718,7 +694,7 @@ public final class Jobs extends JavaPlugin {
*/
public static VersionChecker getVersionCheckManager() {
if (versionCheckManager == null)
versionCheckManager = new VersionChecker(instance);
versionCheckManager = new VersionChecker(getInstance());
return versionCheckManager;
}
@ -729,7 +705,6 @@ public final class Jobs extends JavaPlugin {
@Override
public void onEnable() {
CMIMessages.consoleMessage(prefix);
instance = this;
try {
Class.forName("net.kyori.adventure.text.Component");
@ -759,7 +734,7 @@ public final class Jobs extends JavaPlugin {
// register the listeners
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
getServer().getPluginManager().registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), instance);
getServer().getPluginManager().registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), getInstance());
}
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
@ -807,22 +782,22 @@ public final class Jobs extends JavaPlugin {
public static void reload(boolean startup) {
// unregister all registered listeners by this plugin and register again
if (!startup) {
org.bukkit.plugin.PluginManager pm = instance.getServer().getPluginManager();
org.bukkit.plugin.PluginManager pm = getInstance().getServer().getPluginManager();
HandlerList.unregisterAll(instance);
HandlerList.unregisterAll(getInstance());
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), instance);
pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), getInstance());
}
pm.registerEvents(new JobsListener(instance), instance);
pm.registerEvents(new JobsPaymentListener(instance), instance);
pm.registerEvents(new JobsListener(getInstance()), getInstance());
pm.registerEvents(new JobsPaymentListener(getInstance()), getInstance());
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
pm.registerEvents(new JobsPayment14Listener(), instance);
pm.registerEvents(new JobsPayment14Listener(), getInstance());
}
if (getGCManager().useBlockProtection) {
pm.registerEvents(new PistonProtectionListener(), instance);
pm.registerEvents(new PistonProtectionListener(), getInstance());
}
if (HookManager.getMcMMOManager().CheckmcMMO()) {
@ -851,15 +826,15 @@ public final class Jobs extends JavaPlugin {
getDBManager().getDB().loadAllJobsNames();
if (Version.isCurrentEqualOrLower(Version.v1_13_R1)) {
instance.getBlockOwnerShip(CMIMaterial.LEGACY_BREWING_STAND).ifPresent(BlockOwnerShip::load);
instance.getBlockOwnerShip(CMIMaterial.LEGACY_BURNING_FURNACE).ifPresent(BlockOwnerShip::load);
getInstance().getBlockOwnerShip(CMIMaterial.LEGACY_BREWING_STAND).ifPresent(BlockOwnerShip::load);
getInstance().getBlockOwnerShip(CMIMaterial.LEGACY_BURNING_FURNACE).ifPresent(BlockOwnerShip::load);
} else {
instance.getBlockOwnerShip(CMIMaterial.FURNACE).ifPresent(BlockOwnerShip::load);
instance.getBlockOwnerShip(CMIMaterial.BREWING_STAND).ifPresent(BlockOwnerShip::load);
getInstance().getBlockOwnerShip(CMIMaterial.FURNACE).ifPresent(BlockOwnerShip::load);
getInstance().getBlockOwnerShip(CMIMaterial.BREWING_STAND).ifPresent(BlockOwnerShip::load);
}
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
instance.getBlockOwnerShip(CMIMaterial.BLAST_FURNACE).ifPresent(BlockOwnerShip::load);
instance.getBlockOwnerShip(CMIMaterial.SMOKER).ifPresent(BlockOwnerShip::load);
getInstance().getBlockOwnerShip(CMIMaterial.BLAST_FURNACE).ifPresent(BlockOwnerShip::load);
getInstance().getBlockOwnerShip(CMIMaterial.SMOKER).ifPresent(BlockOwnerShip::load);
}
ToggleBarHandling.load();

View File

@ -30,8 +30,6 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import net.Zrips.CMILib.Logs.CMIDebug;
public class PermissionManager {
private final Map<String, Integer> permDelay = new HashMap<>();

View File

@ -650,7 +650,7 @@ public class Placeholder {
return null;
}
private String convert(boolean state) {
private static String convert(boolean state) {
return Jobs.getLanguage().getMessage("general.info." + (state ? "true" : "false"));
}
}

View File

@ -86,15 +86,6 @@ public class PlayerManager {
this.plugin = plugin;
}
/**
* @deprecated Use {@link JobsPlayer#getPointsData} instead
* @return {@link com.gamingmesh.jobs.economy.PointsData}
*/
@Deprecated
public com.gamingmesh.jobs.economy.PointsData getPointsData() {
return Jobs.getPointsData();
}
/**
* @return the cached mob spawner meta name
*/
@ -677,7 +668,7 @@ public class PlayerManager {
if (prog.getLevel() < oldLevel) {
String message = Jobs.getLanguage().getMessage("message.leveldown.message");
message = message.replace("%jobname%", job.getJobDisplayName());
message = message.replace("%jobname%", job.getDisplayName());
message = message.replace("%playername%", player != null ? plugin.getComplement().getDisplayName(player) : jPlayer.getName());
message = message.replace("%joblevel%", prog.getLevelFormatted());
message = message.replace("%lostLevel%", Integer.toString(oldLevel));
@ -780,7 +771,7 @@ public class PlayerManager {
String message = Jobs.getLanguage().getMessage("message.levelup." + (Jobs.getGCManager().isBroadcastingLevelups()
? "broadcast" : "nobroadcast"));
message = message.replace("%jobname%", job.getJobDisplayName());
message = message.replace("%jobname%", job.getDisplayName());
if (levelUpEvent.getOldTitle() != null)
message = message.replace("%titlename%", levelUpEvent.getOldTitle()
@ -821,7 +812,7 @@ public class PlayerManager {
message = message.replace("%playername%", player != null ? plugin.getComplement().getDisplayName(player) : jPlayer.getName());
message = message.replace("%titlename%", levelUpEvent.getNewTitle()
.getChatColor().toString() + levelUpEvent.getNewTitle().getName());
message = message.replace("%jobname%", job.getJobDisplayName());
message = message.replace("%jobname%", job.getDisplayName());
if (Jobs.getGCManager().isBroadcastingSkillups() || Jobs.getGCManager().TitleChangeActionBar || Jobs.getGCManager().TitleChangeChat) {
for (String line : message.split("\n")) {

View File

@ -22,7 +22,6 @@ import com.gamingmesh.jobs.container.TopList;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Version.Version;
public class SignUtil {
@ -238,7 +237,7 @@ public class SignUtil {
}
if (Jobs.getJob(jSign.getJobName()) != null)
signJobName = Jobs.getJob(jSign.getJobName()).getJobDisplayName();
signJobName = Jobs.getJob(jSign.getJobName()).getDisplayName();
if (playerList.isEmpty())
continue;

View File

@ -44,7 +44,7 @@ public final class JobsLevelUpEvent extends BaseEvent implements Cancellable {
this.titleChangePitch = titleChangePitch;
}
private Sound getSound(String soundName) {
private static Sound getSound(String soundName) {
if (soundName != null) {
for (Sound one : Sound.values()) {
if (one.name().equalsIgnoreCase(soundName))

View File

@ -25,7 +25,6 @@ import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.RawMessages.RawMessage;
public class JobsCommands implements CommandExecutor {
@ -94,15 +93,15 @@ public class JobsCommands implements CommandExecutor {
return cmdClass.perform(plugin, sender, myArgs) || help(sender, 1);
}
private String[] reduceArgs(String[] args) {
private static String[] reduceArgs(String[] args) {
return args.length <= 1 ? new String[0] : Arrays.copyOfRange(args, 1, args.length);
}
private boolean hasCommandPermission(CommandSender sender, String cmd) {
private static boolean hasCommandPermission(CommandSender sender, String cmd) {
return sender.hasPermission("jobs.command." + cmd);
}
private String getUsage(String cmd) {
private static String getUsage(String cmd) {
String cmdString = Jobs.getLanguage().getMessage("command.help.output.cmdFormat", "[command]", Jobs.getLanguage().getMessage("command.help.output.label") + " " + cmd);
String msg = Jobs.getLanguage().getMessage("command." + cmd + ".help.args");
@ -179,7 +178,7 @@ public class JobsCommands implements CommandExecutor {
}
}
private Class<?> getClass(String cmd) {
private static Class<?> getClass(String cmd) {
try {
return Class.forName(PACKAGEPATH + "." + cmd.toLowerCase());
} catch (ClassNotFoundException e) {
@ -187,7 +186,7 @@ public class JobsCommands implements CommandExecutor {
return null;
}
private Cmd getCmdClass(String cmd) {
private static Cmd getCmdClass(String cmd) {
try {
Class<?> nmsClass = getClass(cmd);
if (nmsClass != null && Cmd.class.isAssignableFrom(nmsClass)) {
@ -266,7 +265,7 @@ public class JobsCommands implements CommandExecutor {
else
message.add(m);
} else if (!type.isEmpty()) {
message.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none", "%jobname%", job.getJobDisplayName()));
message.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none", "%jobname%", job.getDisplayName()));
}
}
}
@ -382,7 +381,7 @@ public class JobsCommands implements CommandExecutor {
Title title = Jobs.getTitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName());
String message = Jobs.getLanguage().getMessage(path,
"%joblevel%", jobProg.getLevelFormatted(),
"%jobname%", jobProg.getJob().getJobDisplayName(),
"%jobname%", jobProg.getJob().getDisplayName(),
"%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0,
"%jobmaxxp%", jobProg.getMaxExperience(),
"%titlename%", title == null ? "Unknown" : title.getName());
@ -428,7 +427,7 @@ public class JobsCommands implements CommandExecutor {
String message = Jobs.getLanguage().getMessage("command.stats.output.message",
"%joblevel%", level,
"%jobname%", jobProg.getJob().getJobDisplayName(),
"%jobname%", jobProg.getJob().getDisplayName(),
"%jobxp%", Math.round(exp * 100.0) / 100.0,
"%jobmaxxp%", maxExperience);
return " " + jobProgressMessage(maxExperience, exp) + " " + message;

View File

@ -12,7 +12,6 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.hooks.HookManager;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.RawMessages.RawMessage;
public class bonus implements Cmd {

View File

@ -46,7 +46,7 @@ public class demote implements Cmd {
Player player = jPlayer.getPlayer();
if (player != null) {
String message = Jobs.getLanguage().getMessage("command.demote.output.target",
"%jobname%", job.getJobDisplayName() + CMIChatColor.WHITE,
"%jobname%", job.getDisplayName() + CMIChatColor.WHITE,
"%levelslost%", levelsLost);
player.sendMessage(message);
}

View File

@ -20,7 +20,6 @@ import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version;
@ -408,7 +407,7 @@ public class editjobs implements Cmd {
if (job != null) {
rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getJobDisplayName()))
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getDisplayName()))
.addHover(job.getName()).addCommand("jobs editjobs list " + job.getName());
rm.show(player);
}

View File

@ -31,13 +31,13 @@ public class employ implements Cmd {
if (jPlayer.isInJob(job)) {
// already in job message
sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getJobDisplayName()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getDisplayName()));
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
String message = Jobs.getLanguage().getMessage("command.employ.error.fullslots");
message = message.replace("%jobname%", job.getJobDisplayName());
message = message.replace("%jobname%", job.getDisplayName());
sender.sendMessage(message);
return true;
}
@ -47,7 +47,7 @@ public class employ implements Cmd {
Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getJobDisplayName()));
player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getDisplayName()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} catch (Throwable e) {

View File

@ -81,7 +81,7 @@ public class exp implements Cmd {
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getJobDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
.getExperience()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} else

View File

@ -6,126 +6,76 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.Util;
public class expboost implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
double rate = 1.0;
if (args[0].equalsIgnoreCase("all")) {
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
int[] times = parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.EXP, rate, times);
}
sender.sendMessage(
Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
return true;
}
if (args[0].equalsIgnoreCase("reset")) {
if (args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.EXP, 1.0);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.EXP, 1.0);
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset",
"%jobname%", job.getName()));
}
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
job.addBoost(CurrencyType.EXP, rate, parseTime(args));
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
double rate = 1.0;
if (args[0].equalsIgnoreCase("all")) {
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
int[] times = Util.parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.EXP, rate, times);
}
sender.sendMessage(
Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
return true;
}
private int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
if (args[0].equalsIgnoreCase("reset")) {
if (args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.EXP, 1.0);
}
String time = args[1].toLowerCase();
if (time.isEmpty()) {
return arr;
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
String[] split = time.split("h|hour", 2);
job.addBoost(CurrencyType.EXP, 1.0);
if (split.length > 0) {
try {
arr[2] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset",
"%jobname%", job.getName()));
}
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
}
if ((split = time.split("m|minute", 2)).length > 0) {
try {
arr[1] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
}
if ((split = time.split("s|second", 2)).length > 0) {
try {
arr[0] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}
time = time.replaceAll(arr[0] + "+[s|second]+", "");
}
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
return new int[3];
}
return arr;
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
job.addBoost(CurrencyType.EXP, rate, Util.parseTime(args));
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
return true;
}
}

View File

@ -30,14 +30,14 @@ public class fire implements Cmd {
}
if (!jPlayer.isInJob(job)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getJobDisplayName()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getDisplayName()));
return true;
}
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) {
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getJobDisplayName()));
player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getDisplayName()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
}

View File

@ -48,7 +48,7 @@ public class grantxp implements Cmd {
Player player = jPlayer.getPlayer();
if (player != null) {
String message = Jobs.getLanguage().getMessage("command.grantxp.output.target",
"%jobname%", job.getJobDisplayName(),
"%jobname%", job.getDisplayName(),
"%xpgained%", xpGained);
player.sendMessage(message);
}

View File

@ -56,12 +56,12 @@ public class join implements Cmd {
if (jPlayer.isInJob(job)) {
// already in job message
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getJobDisplayName()));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getDisplayName()));
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getJobDisplayName()));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getDisplayName()));
return true;
}
@ -84,7 +84,7 @@ public class join implements Cmd {
}
Jobs.getPlayerManager().joinJob(jPlayer, job);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getJobDisplayName()));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getDisplayName()));
return true;
}
}

View File

@ -40,10 +40,10 @@ public class leave implements Cmd {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
(long) (20 * Jobs.getGCManager().ConfirmExpiryTime));
20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]",
job.getJobDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime));
job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime));
return true;
}
@ -53,7 +53,7 @@ public class leave implements Cmd {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (Jobs.getPlayerManager().leaveJob(jPlayer, job))
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getJobDisplayName()));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getDisplayName()));
else
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));

View File

@ -36,7 +36,7 @@ public class leaveall implements Cmd {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
(long) (20 * Jobs.getGCManager().ConfirmExpiryTime));
20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]",
Jobs.getGCManager().ConfirmExpiryTime));

View File

@ -6,6 +6,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.Util;
public class moneyboost implements Cmd {
@ -25,7 +26,7 @@ public class moneyboost implements Cmd {
return true;
}
int[] times = parseTime(args);
int[] times = Util.parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.MONEY, rate, times);
@ -72,60 +73,10 @@ public class moneyboost implements Cmd {
return true;
}
job.addBoost(CurrencyType.MONEY, rate, parseTime(args));
job.addBoost(CurrencyType.MONEY, rate, Util.parseTime(args));
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
return true;
}
private int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
}
String time = args[1].toLowerCase();
if (time.isEmpty()) {
return arr;
}
String[] split = time.split("h|hour", 2);
if (split.length > 0) {
try {
arr[2] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
}
if ((split = time.split("m|minute", 2)).length > 0) {
try {
arr[1] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
}
if ((split = time.split("s|second", 2)).length > 0) {
try {
arr[0] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}
time = time.replaceAll(arr[0] + "+[s|second]+", "");
}
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
return new int[3];
}
return arr;
}
}

View File

@ -6,126 +6,76 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.Util;
public class pointboost implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
double rate = 1.0;
if (args[0].equalsIgnoreCase("all")) {
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
int[] times = parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.POINTS, rate, times);
}
sender.sendMessage(
Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
return true;
}
if (args[0].equalsIgnoreCase("reset")) {
if (args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.POINTS, 1.0);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.POINTS, 1.0);
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset",
"%jobname%", job.getName()));
}
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
job.addBoost(CurrencyType.POINTS, rate, parseTime(args));
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
double rate = 1.0;
if (args[0].equalsIgnoreCase("all")) {
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
int[] times = Util.parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.POINTS, rate, times);
}
sender.sendMessage(
Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
return true;
}
private int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
if (args[0].equalsIgnoreCase("reset")) {
if (args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.POINTS, 1.0);
}
String time = args[1].toLowerCase();
if (time.isEmpty()) {
return arr;
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
String[] split = time.split("h|hour", 2);
job.addBoost(CurrencyType.POINTS, 1.0);
if (split.length > 0) {
try {
arr[2] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset",
"%jobname%", job.getName()));
}
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
}
if ((split = time.split("m|minute", 2)).length > 0) {
try {
arr[1] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
}
if ((split = time.split("s|second", 2)).length > 0) {
try {
arr[0] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}
time = time.replaceAll(arr[0] + "+[s|second]+", "");
}
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
return new int[3];
}
return arr;
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
job.addBoost(CurrencyType.POINTS, rate, Util.parseTime(args));
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
return true;
}
}

View File

@ -43,7 +43,7 @@ public class promote implements Cmd {
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target",
"%jobname%", job.getJobDisplayName(),
"%jobname%", job.getDisplayName(),
"%levelsgained%", levelsGained));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));

View File

@ -47,7 +47,7 @@ public class removexp implements Cmd {
Player player = jPlayer.getPlayer();
if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.removexp.output.target",
"%jobname%", job.getJobDisplayName(),
"%jobname%", job.getDisplayName(),
"%xplost%", xpLost));
}

View File

@ -42,8 +42,8 @@ public class transfer implements Cmd {
Player player = jPlayer.getPlayer();
if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.transfer.output.target",
"%oldjobname%", oldjob.getJobDisplayName(),
"%newjobname%", newjob.getJobDisplayName()));
"%oldjobname%", oldjob.getDisplayName(),
"%newjobname%", newjob.getDisplayName()));
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));

View File

@ -1,8 +1,5 @@
package com.gamingmesh.jobs.config;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import org.bukkit.Bukkit;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
@ -64,7 +61,7 @@ public class BossBarManager {
String message = Jobs.getLanguage().getMessage("command.stats.bossBarOutput",
"%joblevel%", jobProg.getLevelFormatted(),
"%jobname%", jobProg.getJob().getJobDisplayName(),
"%jobname%", jobProg.getJob().getDisplayName(),
"%jobxp%", String.format(Jobs.getGCManager().getDecimalPlacesMoney(), jobProg.getExperience()),
"%jobmaxxp%", jobProg.getMaxExperience(),
"%gain%", gain);

View File

@ -94,7 +94,6 @@ public class ConfigManager {
if (!cfg.getFile().isFile())
return;
cfg.load();
cfg.header(Arrays.asList("Jobs configuration.", "", "Edited by roracle to include 1.13 items and item names, prepping for 1.14 as well.",
"",
@ -488,7 +487,7 @@ public class ConfigManager {
cfg.save();
}
private void generate(ConfigReader cfg, String pt) {
private static void generate(ConfigReader cfg, String pt) {
cfg.get(pt + ".income", 1D);
cfg.get(pt + ".points", 1D);
cfg.get(pt + ".experience", 1D);

View File

@ -26,7 +26,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.World;

View File

@ -24,7 +24,6 @@ import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Entities.CMIEntityType;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
public class NameTranslatorManager {

View File

@ -152,7 +152,7 @@ public class RestrictedAreaManager {
return areas;
}
private StringBuilder addHeader(StringBuilder header) {
private static StringBuilder addHeader(StringBuilder header) {
String sep = System.lineSeparator();
header.append("Restricted area configuration");

View File

@ -5,8 +5,6 @@ import java.util.List;
import com.gamingmesh.jobs.Jobs;
import net.Zrips.CMILib.Logs.CMIDebug;
public class ExploreChunk {
private List<Integer> playerIds = new ArrayList<>();

View File

@ -22,7 +22,6 @@ import com.gamingmesh.jobs.Jobs;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.Logs.CMIDebug;
public class JobInfo {
private ActionType actionType;

View File

@ -43,7 +43,6 @@ import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
public class JobsPlayer {
@ -1386,16 +1385,16 @@ public class JobsPlayer {
maxV = Jobs.getPermissionManager().getMaxPermission(this, perm);
if (maxV == 0D && type == BlockTypes.FURNACE)
maxV = (double) Jobs.getGCManager().getFurnacesMaxDefault();
maxV = Jobs.getGCManager().getFurnacesMaxDefault();
if (maxV == 0D && type == BlockTypes.BLAST_FURNACE)
maxV = (double) Jobs.getGCManager().BlastFurnacesMaxDefault;
maxV = Jobs.getGCManager().BlastFurnacesMaxDefault;
if (maxV == 0D && type == BlockTypes.SMOKER)
maxV = (double) Jobs.getGCManager().SmokersMaxDefault;
maxV = Jobs.getGCManager().SmokersMaxDefault;
if (maxV == 0D && type == BlockTypes.BREWING_STAND)
maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault();
maxV = Jobs.getGCManager().getBrewingStandsMaxDefault();
return (int) maxV;
}

View File

@ -156,7 +156,7 @@ public class QuestProgression {
this.givenReward = givenReward;
}
private boolean objectiveKeyMatches(String objectiveKey, ActionInfo actionInfo) {
private static boolean objectiveKeyMatches(String objectiveKey, ActionInfo actionInfo) {
if (actionInfo instanceof EnchantActionInfo) {
return Util.enchantMatchesActionInfo(objectiveKey, (EnchantActionInfo) actionInfo);
}

View File

@ -42,7 +42,6 @@ import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
public abstract class JobsDAO {

View File

@ -125,7 +125,6 @@ import net.Zrips.CMILib.Container.CMILocation;
import net.Zrips.CMILib.Entities.CMIEntityType;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Version.Version;
public final class JobsPaymentListener implements Listener {
@ -819,11 +818,11 @@ public final class JobsPaymentListener implements Listener {
}, 1);
}
private boolean hasItems(ItemStack stack) {
private static boolean hasItems(ItemStack stack) {
return stack != null && stack.getAmount() > 0;
}
private boolean hasSameItem(ItemStack a, ItemStack b) {
private static boolean hasSameItem(ItemStack a, ItemStack b) {
if (a == null)
return b == null;
else if (b == null)

View File

@ -99,6 +99,57 @@ public final class Util {
}
}
public static int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
}
String time = args[1].toLowerCase();
if (time.isEmpty()) {
return arr;
}
String[] split = time.split("h|hour", 2);
if (split.length > 0) {
try {
arr[2] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
}
if ((split = time.split("m|minute", 2)).length > 0) {
try {
arr[1] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
}
if ((split = time.split("s|second", 2)).length > 0) {
try {
arr[0] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}
time = time.replaceAll(arr[0] + "+[s|second]+", "");
}
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
return new int[3];
}
return arr;
}
public static String getRealType(Entity entity) {
if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) {
return entity.getType().name();
@ -412,10 +463,9 @@ public final class Util {
String enchantName = CMIEnchantment.get(actionInfo.getName()).toString();
return (
// Enchantment without level e.g. silk_touch
enchant.equalsIgnoreCase(enchantName) ||
// Enchantment with level e.g. fire_aspect:1
enchant.equalsIgnoreCase(enchantName + ":" + actionInfo.getLevel())
);
// Enchantment without level e.g. silk_touch
enchant.equalsIgnoreCase(enchantName) ||
// Enchantment with level e.g. fire_aspect:1
enchant.equalsIgnoreCase(enchantName + ":" + actionInfo.getLevel()));
}
}