mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-16 13:11:19 +01:00
Reforming jobs constructions
This commit is contained in:
parent
613be4780e
commit
3a27125977
30
src/main/java/com/gamingmesh/jobs/Gui/GuiItem.java
Normal file
30
src/main/java/com/gamingmesh/jobs/Gui/GuiItem.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.gamingmesh.jobs.Gui;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Zrips.CMILib.Container.CMINumber;
|
||||
|
||||
public class GuiItem {
|
||||
|
||||
private ItemStack guiItem = null;
|
||||
private int guiSlot = 0;
|
||||
|
||||
public ItemStack getGuiItem() {
|
||||
return guiItem;
|
||||
}
|
||||
|
||||
public GuiItem setGuiItem(ItemStack guiItem) {
|
||||
this.guiItem = guiItem;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getGuiSlot() {
|
||||
return guiSlot;
|
||||
}
|
||||
|
||||
public GuiItem setGuiSlot(int guiSlot) {
|
||||
this.guiSlot = CMINumber.clamp(guiSlot, 0, 54);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -18,6 +18,28 @@
|
||||
|
||||
package com.gamingmesh.jobs;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.gamingmesh.jobs.Gui.GuiManager;
|
||||
import com.gamingmesh.jobs.Placeholders.Placeholder;
|
||||
import com.gamingmesh.jobs.Placeholders.PlaceholderAPIHook;
|
||||
@ -25,8 +47,40 @@ import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
||||
import com.gamingmesh.jobs.api.JobsPrePaymentEvent;
|
||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
||||
import com.gamingmesh.jobs.config.*;
|
||||
import com.gamingmesh.jobs.container.*;
|
||||
import com.gamingmesh.jobs.config.BlockProtectionManager;
|
||||
import com.gamingmesh.jobs.config.BossBarManager;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.config.ExploreManager;
|
||||
import com.gamingmesh.jobs.config.GeneralConfigManager;
|
||||
import com.gamingmesh.jobs.config.LanguageManager;
|
||||
import com.gamingmesh.jobs.config.NameTranslatorManager;
|
||||
import com.gamingmesh.jobs.config.RestrictedAreaManager;
|
||||
import com.gamingmesh.jobs.config.RestrictedBlockManager;
|
||||
import com.gamingmesh.jobs.config.ScheduleManager;
|
||||
import com.gamingmesh.jobs.config.ShopManager;
|
||||
import com.gamingmesh.jobs.config.TitleManager;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.ArchivedJobs;
|
||||
import com.gamingmesh.jobs.container.BlockProtection;
|
||||
import com.gamingmesh.jobs.container.Boost;
|
||||
import com.gamingmesh.jobs.container.Convert;
|
||||
import com.gamingmesh.jobs.container.CurrencyLimit;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.DBAction;
|
||||
import com.gamingmesh.jobs.container.FastPayment;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.JobsWorld;
|
||||
import com.gamingmesh.jobs.container.LoadStatus;
|
||||
import com.gamingmesh.jobs.container.Log;
|
||||
import com.gamingmesh.jobs.container.PlayerInfo;
|
||||
import com.gamingmesh.jobs.container.PlayerPoints;
|
||||
import com.gamingmesh.jobs.container.Quest;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes;
|
||||
import com.gamingmesh.jobs.dao.JobsClassLoader;
|
||||
@ -39,35 +93,33 @@ import com.gamingmesh.jobs.economy.Economy;
|
||||
import com.gamingmesh.jobs.economy.PaymentData;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.listeners.*;
|
||||
import com.gamingmesh.jobs.listeners.JobsListener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPayment1_14Listener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPayment1_16Listener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.listeners.PlayerSignEdit1_20Listeners;
|
||||
import com.gamingmesh.jobs.selection.SelectionManager;
|
||||
import com.gamingmesh.jobs.stuff.*;
|
||||
import com.gamingmesh.jobs.stuff.Loging;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gamingmesh.jobs.stuff.VersionChecker;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement1;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement2;
|
||||
import com.gamingmesh.jobs.stuff.complement.JobsChatEvent;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
|
||||
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
|
||||
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Locale.LC;
|
||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public final class Jobs extends JavaPlugin {
|
||||
|
||||
@ -754,9 +806,11 @@ public final class Jobs extends JavaPlugin {
|
||||
|
||||
pm.registerEvents(new JobsListener(getInstance()), getInstance());
|
||||
pm.registerEvents(new JobsPaymentListener(getInstance()), getInstance());
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
||||
pm.registerEvents(new JobsPayment1_14Listener(), getInstance());
|
||||
}
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_16_R3)) {
|
||||
pm.registerEvents(new JobsPayment1_16Listener(), getInstance());
|
||||
}
|
||||
@ -764,6 +818,7 @@ public final class Jobs extends JavaPlugin {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_20_R1)) {
|
||||
pm.registerEvents(new PlayerSignEdit1_20Listeners(), getInstance());
|
||||
}
|
||||
|
||||
if (getGCManager().useBlockProtection) {
|
||||
pm.registerEvents(new PistonProtectionListener(), getInstance());
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.Gui.GuiItem;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
@ -58,6 +59,8 @@ import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.Equations.ParseError;
|
||||
import net.Zrips.CMILib.Equations.Parser;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIAsyncHead;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
@ -203,7 +206,7 @@ public class ConfigManager {
|
||||
" CustomSkull: Notch",
|
||||
"",
|
||||
"Name of the material");
|
||||
cfg.get(pt + ".Gui.Item", "LOG:2");
|
||||
cfg.get(pt + ".Gui.Item", "oaklog");
|
||||
cfg.addComment(pt + ".Gui.slot", "Slot number to show the item in the specified row");
|
||||
cfg.get(pt + ".Gui.slot", 5);
|
||||
cfg.addComment(pt + ".Gui.Enchantments", "Enchants of the item");
|
||||
@ -1017,65 +1020,55 @@ public class ConfigManager {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
boolean informed = false;
|
||||
|
||||
private Job loadJobs(ConfigurationSection jobsSection) {
|
||||
informed = false;
|
||||
java.util.logging.Logger log = Jobs.getPluginLogger();
|
||||
|
||||
for (String jobKey : jobsSection.getKeys(false)) {
|
||||
for (String jobConfigName : jobsSection.getKeys(false)) {
|
||||
// Ignore example job
|
||||
if (jobKey.equalsIgnoreCase(EXAMPLEJOBINTERNALNAME))
|
||||
if (jobConfigName.equalsIgnoreCase(EXAMPLEJOBINTERNALNAME))
|
||||
continue;
|
||||
|
||||
// Translating unicode
|
||||
jobKey = escapeUnicode(jobKey);
|
||||
jobConfigName = escapeUnicode(jobConfigName);
|
||||
|
||||
ConfigurationSection jobSection = jobsSection.getConfigurationSection(jobKey);
|
||||
ConfigurationSection jobSection = jobsSection.getConfigurationSection(jobConfigName);
|
||||
if (jobSection == null)
|
||||
continue;
|
||||
|
||||
Job job = new Job(jobConfigName)
|
||||
.setDisplayName(jobSection.getString("displayName"));
|
||||
|
||||
String jobFullName = jobSection.getString("fullname");
|
||||
if (jobFullName == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid fullname property. Skipping job!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid fullname property. Skipping job!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Translating unicode
|
||||
jobFullName = escapeUnicode(jobFullName);
|
||||
|
||||
int maxLevel = jobSection.getInt("max-level");
|
||||
if (maxLevel < 0)
|
||||
maxLevel = 0;
|
||||
|
||||
int vipmaxLevel = jobSection.getInt("vip-max-level");
|
||||
if (vipmaxLevel < 0)
|
||||
vipmaxLevel = 0;
|
||||
|
||||
Integer maxSlots = jobSection.getInt("slots");
|
||||
if (maxSlots.intValue() <= 0)
|
||||
maxSlots = null;
|
||||
|
||||
Long rejoinCd = jobSection.getLong("rejoinCooldown");
|
||||
if (rejoinCd < 0L) {
|
||||
rejoinCd = 0L;
|
||||
} else {
|
||||
rejoinCd *= 1000L;
|
||||
}
|
||||
job.setJobFullName(escapeUnicode(jobFullName));
|
||||
|
||||
String jobShortName = jobSection.getString("shortname");
|
||||
if (jobShortName == null) {
|
||||
log.warning("Job " + jobKey + " is missing the shortname property. Skipping job!");
|
||||
log.warning("Job " + jobConfigName + " is missing the shortname property. Skipping job!");
|
||||
continue;
|
||||
}
|
||||
job.setShortName(jobShortName);
|
||||
job.setMaxLevel(jobSection.getInt("max-level"));
|
||||
job.setVipMaxLevel(jobSection.getInt("vip-max-level"));
|
||||
job.setMaxSlots(jobSection.getInt("slots"));
|
||||
job.setRejoinCd(jobSection.getLong("rejoinCooldown", 0L) * 1000L);
|
||||
|
||||
String description = CMIChatColor.translate(jobSection.getString("description", ""));
|
||||
job.setDescription(CMIChatColor.translate(jobSection.getString("description", "")));
|
||||
|
||||
List<String> fDescription = jobSection.getStringList("FullDescription");
|
||||
|
||||
if (jobSection.isString("FullDescription"))
|
||||
fDescription.add(jobSection.getString("FullDescription"));
|
||||
|
||||
for (int i = 0; i < fDescription.size(); i++) {
|
||||
fDescription.set(i, CMIChatColor.translate(fDescription.get(i)));
|
||||
}
|
||||
job.setFullDescription(fDescription);
|
||||
|
||||
CMIChatColor color = CMIChatColor.WHITE;
|
||||
String c = jobSection.getString("ChatColour");
|
||||
@ -1087,23 +1080,26 @@ public class ConfigManager {
|
||||
|
||||
if (color == null) {
|
||||
color = CMIChatColor.WHITE;
|
||||
log.warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid ChatColour property. Defaulting to WHITE!");
|
||||
}
|
||||
}
|
||||
job.setChatColor(color);
|
||||
|
||||
String bossbar = jobSection.getString("BossBarColour");
|
||||
if (bossbar != null && bossbar.isEmpty()) {
|
||||
bossbar = "GREEN";
|
||||
log.warning("Job " + jobKey + " has an invalid BossBarColour property.");
|
||||
log.warning("Job " + jobConfigName + " has an invalid BossBarColour property.");
|
||||
}
|
||||
job.setBossbar(bossbar);
|
||||
|
||||
DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", ""));
|
||||
if (displayMethod == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid chat-display property. Defaulting to None!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid chat-display property. Defaulting to None!");
|
||||
displayMethod = DisplayMethod.NONE;
|
||||
}
|
||||
job.setDisplayMethod(displayMethod);
|
||||
|
||||
boolean isNoneJob = jobKey.equalsIgnoreCase("none");
|
||||
boolean isNoneJob = jobConfigName.equalsIgnoreCase("none");
|
||||
|
||||
Parser maxExpEquation;
|
||||
String maxExpEquationInput = isNoneJob ? "0" : jobSection.getString("leveling-progression-equation", "0");
|
||||
@ -1114,9 +1110,10 @@ public class ConfigManager {
|
||||
maxExpEquation.setVariable("maxjobs", 2);
|
||||
maxExpEquation.setVariable("joblevel", 1);
|
||||
} catch (ParseError e) {
|
||||
log.warning("Job " + jobKey + " has an invalid leveling-progression-equation property. Skipping job!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid leveling-progression-equation property. Skipping job!");
|
||||
continue;
|
||||
}
|
||||
job.setMaxExpEquation(maxExpEquation);
|
||||
|
||||
Parser incomeEquation = new Parser("0");
|
||||
String incomeEquationInput = jobSection.getString("income-progression-equation");
|
||||
@ -1129,10 +1126,11 @@ public class ConfigManager {
|
||||
incomeEquation.setVariable("joblevel", 1);
|
||||
incomeEquation.setVariable("baseincome", 1);
|
||||
} catch (ParseError e) {
|
||||
log.warning("Job " + jobKey + " has an invalid income-progression-equation property. Skipping job!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid income-progression-equation property. Skipping job!");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
job.setMoneyEquation(incomeEquation);
|
||||
|
||||
Parser expEquation;
|
||||
String expEquationInput = isNoneJob ? "0" : jobSection.getString("experience-progression-equation", "0");
|
||||
@ -1144,9 +1142,10 @@ public class ConfigManager {
|
||||
expEquation.setVariable("joblevel", 1);
|
||||
expEquation.setVariable("baseexperience", 1);
|
||||
} catch (ParseError e) {
|
||||
log.warning("Job " + jobKey + " has an invalid experience-progression-equation property. Skipping job!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid experience-progression-equation property. Skipping job!");
|
||||
continue;
|
||||
}
|
||||
job.setXpEquation(expEquation);
|
||||
|
||||
Parser pointsEquation = new Parser("0");
|
||||
String pointsEquationInput = jobSection.getString("points-progression-equation");
|
||||
@ -1159,19 +1158,35 @@ public class ConfigManager {
|
||||
pointsEquation.setVariable("joblevel", 1);
|
||||
pointsEquation.setVariable("basepoints", 1);
|
||||
} catch (ParseError e) {
|
||||
log.warning("Job " + jobKey + " has an invalid points-progression-equation property. Skipping job!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid points-progression-equation property. Skipping job!");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
job.setPointsEquation(pointsEquation);
|
||||
|
||||
// Gui item
|
||||
int guiSlot = -1;
|
||||
|
||||
ItemStack guiItem = CMIMaterial.GREEN_WOOL.newItemStack();
|
||||
ConfigurationSection guiSection = jobSection.getConfigurationSection("Gui");
|
||||
|
||||
GuiItem gItem = new GuiItem();
|
||||
if (guiSection != null) {
|
||||
if (guiSection.isString("Item")) {
|
||||
if (guiSection.isString("ItemStack")) {
|
||||
|
||||
CMIAsyncHead ahead = new CMIAsyncHead() {
|
||||
@Override
|
||||
public void afterAsyncUpdate(ItemStack item) {
|
||||
gItem.setGuiItem(item);
|
||||
}
|
||||
};
|
||||
|
||||
CMIItemStack item = CMIItemStack.deserialize(guiSection.getString("ItemStack"), ahead);
|
||||
if (!ahead.isAsyncHead() && item != null && item.getCMIType().isNone())
|
||||
gItem.setGuiItem(item.getItemStack());
|
||||
|
||||
} else if (guiSection.isString("Item")) {
|
||||
String item = guiSection.getString("Item");
|
||||
|
||||
String subType = "";
|
||||
|
||||
String[] itemSplit = item.split("-", 2);
|
||||
@ -1203,10 +1218,17 @@ public class ConfigManager {
|
||||
|
||||
if (material != CMIMaterial.NONE)
|
||||
guiItem = material.newItemStack();
|
||||
|
||||
if (!informed) {
|
||||
CMIMessages.consoleMessage("Update " + jobConfigName + " jobs gui item section to use `ItemStack` instead of `Item` sections format");
|
||||
CMIMessages.consoleMessage("More information inside example job file");
|
||||
informed = true;
|
||||
}
|
||||
} else if (guiSection.isInt("Id") && guiSection.isInt("Data")) {
|
||||
guiItem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
|
||||
CMIMessages.consoleMessage("Update " + jobConfigName + " jobs gui item section to use `Item` instead of `Id` and `Data` sections");
|
||||
} else
|
||||
log.warning("Job " + jobKey + " has an invalid (" + guiSection.getString("Item") + ") Gui property. Please fix this if you want to use it!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid (" + guiSection.getString("Item") + ") Gui property. Please fix this if you want to use it!");
|
||||
|
||||
for (String str4 : guiSection.getStringList("Enchantments")) {
|
||||
String[] id = str4.split(":", 2);
|
||||
@ -1237,11 +1259,11 @@ public class ConfigManager {
|
||||
guiItem = Util.getSkull(customSkull);
|
||||
}
|
||||
|
||||
int slot = guiSection.getInt("slot", -1);
|
||||
if (slot >= 0)
|
||||
guiSlot = slot;
|
||||
gItem.setGuiSlot(guiSection.getInt("slot", -1));
|
||||
}
|
||||
|
||||
job.setGuiItem(gItem);
|
||||
|
||||
// Permissions
|
||||
List<JobPermission> jobPermissions = new ArrayList<>();
|
||||
ConfigurationSection permissionsSection = jobSection.getConfigurationSection("permissions");
|
||||
@ -1249,7 +1271,7 @@ public class ConfigManager {
|
||||
for (String permissionKey : permissionsSection.getKeys(false)) {
|
||||
ConfigurationSection permissionSection = permissionsSection.getConfigurationSection(permissionKey);
|
||||
if (permissionSection == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid permission key " + permissionKey + "!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid permission key " + permissionKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1259,6 +1281,7 @@ public class ConfigManager {
|
||||
jobPermissions.add(new JobPermission(node, value, levelRequirement));
|
||||
}
|
||||
}
|
||||
job.setPermissions(jobPermissions);
|
||||
|
||||
// Conditions
|
||||
List<JobConditions> jobConditions = new ArrayList<>();
|
||||
@ -1268,7 +1291,7 @@ public class ConfigManager {
|
||||
ConfigurationSection permissionSection = conditionsSection.getConfigurationSection(conditionKey);
|
||||
|
||||
if (permissionSection == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid condition key " + conditionKey + "!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid condition key " + conditionKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1276,13 +1299,14 @@ public class ConfigManager {
|
||||
List<String> perform = permissionSection.getStringList("perform");
|
||||
|
||||
if (requires.isEmpty() || perform.isEmpty()) {
|
||||
log.warning("Job " + jobKey + " has an invalid condition requirement " + conditionKey + "!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid condition requirement " + conditionKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
jobConditions.add(new JobConditions(conditionKey.toLowerCase(), requires, perform));
|
||||
}
|
||||
}
|
||||
job.setConditions(jobConditions);
|
||||
|
||||
// Commands
|
||||
List<JobCommands> jobCommand = new ArrayList<>();
|
||||
@ -1292,7 +1316,7 @@ public class ConfigManager {
|
||||
ConfigurationSection commandSection = commandsSection.getConfigurationSection(commandKey);
|
||||
|
||||
if (commandSection == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid command key " + commandKey + "!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid command key " + commandKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1302,10 +1326,11 @@ public class ConfigManager {
|
||||
commands.add(commandSection.getString("command"));
|
||||
|
||||
int levelFrom = commandSection.getInt("levelFrom", 0);
|
||||
int levelUntil = commandSection.getInt("levelUntil", maxLevel);
|
||||
int levelUntil = commandSection.getInt("levelUntil", job.getMaxLevel());
|
||||
jobCommand.add(new JobCommands(commandKey.toLowerCase(), commands, levelFrom, levelUntil));
|
||||
}
|
||||
}
|
||||
job.setCommands(jobCommand);
|
||||
|
||||
// Items **OUTDATED** Moved to ItemBoostManager!!
|
||||
HashMap<String, JobItems> jobItems = new HashMap<>();
|
||||
@ -1316,7 +1341,7 @@ public class ConfigManager {
|
||||
|
||||
String node = itemKey.toLowerCase();
|
||||
if (itemSection == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid item key " + itemKey + "!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid item key " + itemKey + "!");
|
||||
continue;
|
||||
}
|
||||
int id = itemSection.getInt("id");
|
||||
@ -1361,8 +1386,9 @@ public class ConfigManager {
|
||||
jobItems.put(node.toLowerCase(), new JobItems(node, CMIMaterial.get(id), 1, name, lore, enchants, b, new ArrayList<Job>()));
|
||||
}
|
||||
|
||||
CMIMessages.consoleMessage("&cRemove Items section from " + jobKey + " job, as of Jobs 4.10.0 version this was moved to boostedItems.yml file!");
|
||||
CMIMessages.consoleMessage("&cRemove Items section from " + jobConfigName + " job, as of Jobs 4.10.0 version this was moved to boostedItems.yml file!");
|
||||
}
|
||||
job.setItemBonus(jobItems);
|
||||
|
||||
// Limited Items
|
||||
Map<String, JobLimitedItems> jobLimitedItems = new HashMap<>();
|
||||
@ -1372,7 +1398,7 @@ public class ConfigManager {
|
||||
ConfigurationSection itemSection = limitedItemsSection.getConfigurationSection(itemKey);
|
||||
|
||||
if (itemSection == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid item key " + itemKey + "!");
|
||||
log.warning("Job " + jobConfigName + " has an invalid item key " + itemKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1385,7 +1411,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
if (mat == CMIMaterial.NONE) {
|
||||
log.warning("Job " + jobKey + " has incorrect limitedItems material id!");
|
||||
log.warning("Job " + jobConfigName + " has incorrect limitedItems material id!");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1423,19 +1449,11 @@ public class ConfigManager {
|
||||
jobLimitedItems.put(node, new JobLimitedItems(node, mat, 1, itemSection.getString("name"), lore, enchants, itemSection.getInt("level")));
|
||||
}
|
||||
}
|
||||
job.setLimitedItems(jobLimitedItems);
|
||||
|
||||
Job job = new Job(jobKey, jobSection.getString("displayName"), jobFullName, jobShortName, description,
|
||||
color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
|
||||
jobConditions, jobItems, jobLimitedItems, jobSection.getStringList("cmd-on-join"),
|
||||
jobSection.getStringList("cmd-on-leave"), guiItem, guiSlot, bossbar, rejoinCd,
|
||||
jobSection.getStringList("world-blacklist"));
|
||||
|
||||
job.setFullDescription(fDescription);
|
||||
job.setMoneyEquation(incomeEquation);
|
||||
job.setXpEquation(expEquation);
|
||||
job.setPointsEquation(pointsEquation);
|
||||
job.setBossbar(bossbar);
|
||||
job.setRejoinCd(rejoinCd);
|
||||
job.setCmdOnJoin(jobSection.getStringList("cmd-on-join"));
|
||||
job.setCmdOnLeave(jobSection.getStringList("cmd-on-leave"));
|
||||
job.setWorldBlacklist(jobSection.getStringList("world-blacklist"));
|
||||
job.setMaxLevelCommands(jobSection.getStringList("commands-on-max-level"));
|
||||
job.setIgnoreMaxJobs(jobSection.getBoolean("ignore-jobs-max"));
|
||||
job.setReversedWorldBlacklist(jobSection.getBoolean("reverse-world-blacklist-functionality"));
|
||||
@ -1467,8 +1485,6 @@ public class ConfigManager {
|
||||
for (String oneObjective : sqsection.getStringList("Objectives")) {
|
||||
List<QuestObjective> objectives = QuestObjective.get(oneObjective, jobFullName);
|
||||
|
||||
|
||||
|
||||
quest.addObjectives(objectives);
|
||||
}
|
||||
|
||||
@ -1495,9 +1511,10 @@ public class ConfigManager {
|
||||
}
|
||||
job.setMaxDailyQuests(jobSection.getInt("maxDailyQuests", 1));
|
||||
|
||||
Integer softIncomeLimit = null,
|
||||
softExpLimit = null,
|
||||
softPointsLimit = null;
|
||||
Integer softIncomeLimit = null;
|
||||
Integer softExpLimit = null;
|
||||
Integer softPointsLimit = null;
|
||||
|
||||
if (jobSection.isInt("softIncomeLimit"))
|
||||
softIncomeLimit = jobSection.getInt("softIncomeLimit");
|
||||
if (jobSection.isInt("softExpLimit"))
|
||||
@ -1518,7 +1535,7 @@ public class ConfigManager {
|
||||
KeyValues keyValue = null;
|
||||
String[] sep = mat.split(";", 4);
|
||||
if (sep.length >= 1) {
|
||||
keyValue = getKeyValue(sep[0], actionType, jobKey);
|
||||
keyValue = getKeyValue(sep[0], actionType, jobConfigName);
|
||||
}
|
||||
|
||||
if (keyValue == null) {
|
||||
@ -1571,7 +1588,7 @@ public class ConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
KeyValues keyValue = getKeyValue(key, actionType, jobKey);
|
||||
KeyValues keyValue = getKeyValue(key, actionType, jobConfigName);
|
||||
if (keyValue == null)
|
||||
continue;
|
||||
|
||||
@ -1593,7 +1610,7 @@ public class ConfigManager {
|
||||
if (section.isInt("until-level")) {
|
||||
untilLevel = section.getInt("until-level");
|
||||
if (untilLevel < fromlevel) {
|
||||
log.warning("Job " + jobKey + " has an invalid until-level in " + actionType.getName() + " for type property: " + key
|
||||
log.warning("Job " + jobConfigName + " has an invalid until-level in " + actionType.getName() + " for type property: " + key
|
||||
+ "! It will be not set.");
|
||||
untilLevel = -1;
|
||||
}
|
||||
|
@ -41,9 +41,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.Gui.GuiItem;
|
||||
import com.gamingmesh.jobs.actions.PotionItemActionInfo;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.CMINumber;
|
||||
import net.Zrips.CMILib.Equations.Parser;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||
@ -79,8 +81,7 @@ public class Job {
|
||||
|
||||
private List<String> cmdOnJoin = new ArrayList<>(), cmdOnLeave = new ArrayList<>();
|
||||
|
||||
private ItemStack guiItem;
|
||||
private int guiSlot = 0;
|
||||
private GuiItem guiItem = null;
|
||||
|
||||
private Long rejoinCd = 0L;
|
||||
|
||||
@ -102,6 +103,15 @@ public class Job {
|
||||
private int legacyId = 0;
|
||||
private boolean ignoreMaxJobs = false;
|
||||
|
||||
public Job(String jobName) {
|
||||
this.jobName = jobName == null ? "" : jobName;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Job(List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, String bossbar, Long rejoinCD, List<String> worldBlacklist) {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Job(String jobName, String jobDisplayName, String fullName, String jobShortName, String description, CMIChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
|
||||
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, Map<String, JobItems> jobItems,
|
||||
@ -114,6 +124,7 @@ public class Job {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Job(String jobName, String jobDisplayName, String fullName, String jobShortName, CMIChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
|
||||
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions,
|
||||
Map<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, List<String> worldBlacklist) {
|
||||
@ -132,13 +143,13 @@ public class Job {
|
||||
this.jobLimitedItems = jobLimitedItems;
|
||||
this.cmdOnJoin = cmdOnJoin;
|
||||
this.cmdOnLeave = cmdOnLeave;
|
||||
this.guiItem = guiItem;
|
||||
this.guiSlot = guiSlot;
|
||||
|
||||
this.guiItem = (new GuiItem()).setGuiItem(guiItem).setGuiSlot(guiSlot);
|
||||
|
||||
this.jobDisplayName = CMIChatColor.translate(jobDisplayName);
|
||||
|
||||
if (worldBlacklist != null) {
|
||||
this.worldBlacklist = worldBlacklist;
|
||||
}
|
||||
this.worldBlacklist = worldBlacklist != null ? worldBlacklist : null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,16 +269,30 @@ public class Job {
|
||||
return cmdOnJoin;
|
||||
}
|
||||
|
||||
public Job setCmdOnJoin(List<String> cmdOnJoin) {
|
||||
this.cmdOnJoin = cmdOnJoin;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getCmdOnLeave() {
|
||||
return cmdOnLeave;
|
||||
}
|
||||
|
||||
public Job setCmdOnLeave(List<String> cmdOnLeave) {
|
||||
this.cmdOnLeave = cmdOnLeave;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setGuiItem(GuiItem guiItem) {
|
||||
this.guiItem = guiItem;
|
||||
}
|
||||
|
||||
public ItemStack getGuiItem() {
|
||||
return guiItem;
|
||||
return guiItem == null ? null : guiItem.getGuiItem();
|
||||
}
|
||||
|
||||
public int getGuiSlot() {
|
||||
return guiSlot;
|
||||
return guiItem == null ? 0 : guiItem.getGuiSlot();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,6 +369,11 @@ public class Job {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public Job setJobFullName(String fullName) {
|
||||
this.fullName = fullName == null ? "" : fullName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getJobDisplayName() {
|
||||
return getDisplayName();
|
||||
@ -353,6 +383,11 @@ public class Job {
|
||||
return jobDisplayName == null ? jobColour + fullName : jobDisplayName;
|
||||
}
|
||||
|
||||
public Job setDisplayName(String jobDisplayName) {
|
||||
this.jobDisplayName = CMIChatColor.translate(jobDisplayName);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the job full name with the set of color.
|
||||
*
|
||||
@ -373,6 +408,11 @@ public class Job {
|
||||
return jobShortName;
|
||||
}
|
||||
|
||||
public Job setShortName(String jobShortName) {
|
||||
this.jobShortName = jobShortName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description
|
||||
*
|
||||
@ -385,6 +425,11 @@ public class Job {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Job setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Color of the job for chat
|
||||
* @return the Color of the job for chat
|
||||
@ -393,6 +438,11 @@ public class Job {
|
||||
return jobColour;
|
||||
}
|
||||
|
||||
public Job setChatColor(CMIChatColor jobColour) {
|
||||
this.jobColour = jobColour;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MaxExpEquation of the job
|
||||
* @return the MaxExpEquation of the job
|
||||
@ -401,6 +451,11 @@ public class Job {
|
||||
return maxExpEquation;
|
||||
}
|
||||
|
||||
public Job setMaxExpEquation(Parser maxExpEquation) {
|
||||
this.maxExpEquation = maxExpEquation;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the appropriate max exp for this level
|
||||
* @param level - current level
|
||||
@ -421,6 +476,11 @@ public class Job {
|
||||
return displayMethod;
|
||||
}
|
||||
|
||||
public Job setDisplayMethod(DisplayMethod displayMethod) {
|
||||
this.displayMethod = displayMethod;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the maximum level of this job.
|
||||
*
|
||||
@ -430,6 +490,11 @@ public class Job {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public Job setMaxLevel(int maxLevel) {
|
||||
this.maxLevel = CMINumber.clamp(maxLevel, 0, Integer.MAX_VALUE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level of the specific {@link JobsPlayer}.
|
||||
*
|
||||
@ -462,6 +527,11 @@ public class Job {
|
||||
return vipmaxLevel;
|
||||
}
|
||||
|
||||
public Job setVipMaxLevel(int vipmaxLevel) {
|
||||
this.vipmaxLevel = CMINumber.clamp(vipmaxLevel, 0, Integer.MAX_VALUE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the maximum slots
|
||||
* @return the max slots
|
||||
@ -471,6 +541,11 @@ public class Job {
|
||||
return maxSlots;
|
||||
}
|
||||
|
||||
public Job setMaxSlots(Integer maxSlots) {
|
||||
this.maxSlots = maxSlots <= 0 ? null : maxSlots;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permission nodes for this job
|
||||
* @return Permissions for this job
|
||||
@ -479,6 +554,11 @@ public class Job {
|
||||
return Collections.unmodifiableList(jobPermissions);
|
||||
}
|
||||
|
||||
public Job setPermissions(List<JobPermission> jobPermissions) {
|
||||
this.jobPermissions = jobPermissions;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the command nodes for this job
|
||||
* @return Commands for this job
|
||||
@ -487,6 +567,11 @@ public class Job {
|
||||
return Collections.unmodifiableList(jobCommands);
|
||||
}
|
||||
|
||||
public Job setCommands(List<JobCommands> jobCommands) {
|
||||
this.jobCommands = jobCommands;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the conditions for this job
|
||||
* @return Conditions for this job
|
||||
@ -495,8 +580,13 @@ public class Job {
|
||||
return Collections.unmodifiableList(jobConditions);
|
||||
}
|
||||
|
||||
public Job setConditions(List<JobConditions> jobConditions) {
|
||||
this.jobConditions = jobConditions;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item nodes for this job
|
||||
* No longer used, moved to ItemBoostManager
|
||||
* @return Items for this job
|
||||
*/
|
||||
@Deprecated
|
||||
@ -506,11 +596,25 @@ public class Job {
|
||||
return jobItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* No longer used, moved to ItemBoostManager
|
||||
* @return Items for this job
|
||||
*/
|
||||
@Deprecated
|
||||
public JobItems getItemBonus(String key) {
|
||||
return jobItems.get(key.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* No longer used, moved to ItemBoostManager
|
||||
* @return Items for this job
|
||||
*/
|
||||
@Deprecated
|
||||
public Job setItemBonus(HashMap<String, JobItems> jobItems) {
|
||||
this.jobItems = jobItems;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the limited item nodes for this job
|
||||
* @return Limited items for this job
|
||||
@ -519,6 +623,11 @@ public class Job {
|
||||
return jobLimitedItems;
|
||||
}
|
||||
|
||||
public Job setLimitedItems(Map<String, JobLimitedItems> jobLimitedItems) {
|
||||
this.jobLimitedItems = jobLimitedItems;
|
||||
return this;
|
||||
}
|
||||
|
||||
public JobLimitedItems getLimitedItems(String key) {
|
||||
return jobLimitedItems.get(key.toLowerCase());
|
||||
}
|
||||
@ -560,7 +669,7 @@ public class Job {
|
||||
}
|
||||
|
||||
public void setRejoinCd(Long rejoinCd) {
|
||||
this.rejoinCd = rejoinCd;
|
||||
this.rejoinCd = CMINumber.clamp(rejoinCd, 0, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public List<String> getFullDescription() {
|
||||
@ -654,6 +763,11 @@ public class Job {
|
||||
return worldBlacklist;
|
||||
}
|
||||
|
||||
public Job setWorldBlacklist(List<String> worldBlacklist) {
|
||||
this.worldBlacklist = worldBlacklist != null ? worldBlacklist : null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isWorldBlackListed(Entity ent) {
|
||||
return isWorldBlackListed(null, ent, null);
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.CMILocation;
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMC;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Locale.LC;
|
||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||
@ -687,36 +688,11 @@ public final class JobsPaymentListener implements Listener {
|
||||
third = mat;
|
||||
}
|
||||
|
||||
switch (mat) {
|
||||
case LEATHER_BOOTS:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_LEGGINGS:
|
||||
case LEATHER_HORSE_ARMOR:
|
||||
leather = true;
|
||||
break;
|
||||
case SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
if (mat.isShulkerBox())
|
||||
shulker = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (mat.containsCriteria(CMIMC.LEATHER))
|
||||
leather = true;
|
||||
}
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
@ -1605,20 +1581,11 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
LivingEntity animal = event.getEntity();
|
||||
|
||||
double closest = 30.0;
|
||||
Player player = null;
|
||||
for (Player i : Bukkit.getOnlinePlayers()) {
|
||||
if (!i.getWorld().getName().equals(animal.getWorld().getName()))
|
||||
continue;
|
||||
Player player = Util.getClosestPlayer(animal.getLocation());
|
||||
|
||||
double dist = i.getLocation().distance(animal.getLocation());
|
||||
if (closest > dist) {
|
||||
closest = dist;
|
||||
player = i;
|
||||
}
|
||||
}
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (player != null && closest < 30.0) {
|
||||
// check if in creative
|
||||
if (!payIfCreative(player))
|
||||
return;
|
||||
@ -1633,7 +1600,6 @@ public final class JobsPaymentListener implements Listener {
|
||||
// pay
|
||||
Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new EntityActionInfo(animal, ActionType.BREED));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerEat(FoodLevelChangeEvent event) {
|
||||
|
@ -70,6 +70,22 @@ public final class Util {
|
||||
return dcf.format(number);
|
||||
}
|
||||
|
||||
public static Player getClosestPlayer(Location loc) {
|
||||
double closest = 30.0;
|
||||
Player player = null;
|
||||
for (Player i : Bukkit.getOnlinePlayers()) {
|
||||
if (!i.getWorld().getName().equals(loc.getWorld().getName()))
|
||||
continue;
|
||||
|
||||
double dist = i.getLocation().distance(loc);
|
||||
if (closest > dist) {
|
||||
closest = dist;
|
||||
player = i;
|
||||
}
|
||||
}
|
||||
return closest > 30 ? null : player;
|
||||
}
|
||||
|
||||
public static String getRealType(Entity entity) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) {
|
||||
return entity.getType().name();
|
||||
|
Loading…
Reference in New Issue
Block a user