mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Improvements
This commit is contained in:
parent
3239b5decf
commit
c2a80802f7
@ -174,12 +174,10 @@ public enum CMIEnchantment {
|
||||
CMIEnchantment ec = map.get(name);
|
||||
|
||||
if (ec == null) {
|
||||
Enchantment enchant = gmap.get(name);
|
||||
if (enchant != null)
|
||||
return enchant;
|
||||
return gmap.get(name);
|
||||
}
|
||||
|
||||
return ec == null ? null : ec.getEnchantment();
|
||||
return ec.getEnchantment();
|
||||
}
|
||||
|
||||
public static CMIEnchantment get(Enchantment enchantment) {
|
||||
@ -212,7 +210,7 @@ public enum CMIEnchantment {
|
||||
}
|
||||
|
||||
public static String getName(Enchantment enchant) {
|
||||
CMIEnchantment ce = CMIEnchantment.get(enchant);
|
||||
CMIEnchantment ce = get(enchant);
|
||||
if (ce == null)
|
||||
return "Unknown";
|
||||
|
||||
|
@ -15,7 +15,6 @@ import com.gamingmesh.jobs.CMIGUI.CMIGui;
|
||||
import com.gamingmesh.jobs.CMIGUI.CMIGuiButton;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIClickType;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.Boost;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
@ -34,19 +33,22 @@ public class GuiManager {
|
||||
|
||||
public void openJobsBrowseGUI(final Player player) {
|
||||
List<Job> jobsList = new ArrayList<>();
|
||||
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
if (Jobs.getGCManager().getHideJobsWithoutPermission())
|
||||
if (!Jobs.getCommandManager().hasJobPermission(player, job))
|
||||
if (Jobs.getGCManager().getHideJobsWithoutPermission() && !Jobs.getCommandManager().hasJobPermission(player, job))
|
||||
continue;
|
||||
|
||||
jobsList.add(job);
|
||||
}
|
||||
|
||||
int jobsListSize = jobsList.size();
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.pickjob"));
|
||||
gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller));
|
||||
gui.setFiller(Jobs.getGCManager().guiFiller);
|
||||
|
||||
int guiSize = Jobs.getGCManager().getJobsGUIRows() * 9,
|
||||
neededSlots = jobsList.size() + ((jobsList.size() / Jobs.getGCManager().getJobsGUIGroupAmount())
|
||||
neededSlots = jobsListSize + ((jobsListSize / Jobs.getGCManager().getJobsGUIGroupAmount())
|
||||
* Jobs.getGCManager().getJobsGUISkipAmount()) + Jobs.getGCManager().getJobsGUIStartPosition(),
|
||||
neededRows = (int) Math.ceil(neededSlots / 9D);
|
||||
|
||||
@ -66,24 +68,24 @@ public class GuiManager {
|
||||
int pos = Jobs.getGCManager().getJobsGUIStartPosition() - 1;
|
||||
|
||||
// Changing start position to 0 in case we have more jobs then we can fit in current setup
|
||||
pos = jobsList.size() > 28 ? jobsList.size() <= 42 ? 0 : -1 : pos;
|
||||
pos = jobsListSize > 28 ? jobsListSize <= 42 ? 0 : -1 : pos;
|
||||
|
||||
int group = 0;
|
||||
main: for (int z = 0; z < jobsList.size(); z++) {
|
||||
main: for (int z = 0; z < jobsListSize; z++) {
|
||||
group++;
|
||||
|
||||
if (group > Jobs.getGCManager().getJobsGUIGroupAmount()) {
|
||||
group = 1;
|
||||
|
||||
// Only add skip if we can fit all of them in max sized Gui
|
||||
if (jobsList.size() <= 42) {
|
||||
if (jobsListSize <= 42) {
|
||||
pos += Jobs.getGCManager().getJobsGUISkipAmount();
|
||||
}
|
||||
}
|
||||
|
||||
pos++;
|
||||
|
||||
if (i >= jobsList.size())
|
||||
if (i >= jobsListSize)
|
||||
break main;
|
||||
|
||||
Job job = jobsList.get(i);
|
||||
@ -300,7 +302,7 @@ public class GuiManager {
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName()));
|
||||
gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller));
|
||||
gui.setFiller(Jobs.getGCManager().guiFiller);
|
||||
gui.setInvSize(guiSize);
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
@ -451,7 +453,7 @@ public class GuiManager {
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName()));
|
||||
gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller));
|
||||
gui.setFiller(Jobs.getGCManager().guiFiller);
|
||||
gui.setInvSize(guiSize);
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
|
@ -191,10 +191,11 @@ public class Jobs extends JavaPlugin {
|
||||
}
|
||||
|
||||
private boolean setupPlaceHolderAPI() {
|
||||
if (!getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"))
|
||||
org.bukkit.plugin.Plugin papi = getServer().getPluginManager().getPlugin("PlaceholderAPI");
|
||||
if (papi == null || !papi.isEnabled())
|
||||
return false;
|
||||
|
||||
if (Integer.parseInt(getServer().getPluginManager().getPlugin("PlaceholderAPI")
|
||||
if (Integer.parseInt(papi
|
||||
.getDescription().getVersion().replaceAll("[^\\d]", "")) >= 2100 && new PlaceholderAPIHook(this).register()) {
|
||||
consoleMsg("&e[Jobs] PlaceholderAPI hooked.");
|
||||
}
|
||||
@ -496,7 +497,7 @@ public class Jobs extends JavaPlugin {
|
||||
CompletableFuture<Void> pd = loadAllPlayersData();
|
||||
|
||||
// attempt to add all online players to cache
|
||||
pd.thenAccept(e -> Bukkit.getServer().getOnlinePlayers().forEach(getPlayerManager()::playerJoin));
|
||||
pd.thenAccept(e -> getServer().getOnlinePlayers().forEach(getPlayerManager()::playerJoin));
|
||||
}
|
||||
|
||||
public static CompletableFuture<Void> loadAllPlayersData() {
|
||||
@ -738,7 +739,7 @@ public class Jobs extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new JobsChatEvent(this), this);
|
||||
|
||||
// register economy
|
||||
Bukkit.getScheduler().runTask(this, new HookEconomyTask(this));
|
||||
getServer().getScheduler().runTask(this, new HookEconomyTask(this));
|
||||
|
||||
dao.loadBlockProtection();
|
||||
getExplore().load();
|
||||
|
@ -462,17 +462,18 @@ public class PlayerManager {
|
||||
* @param job {@link Job}
|
||||
*/
|
||||
public void joinJob(JobsPlayer jPlayer, Job job) {
|
||||
if (jPlayer.isInJob(job))
|
||||
if (jPlayer == null || job == null || jPlayer.isInJob(job))
|
||||
return;
|
||||
|
||||
// let the user join the job
|
||||
if (!jPlayer.joinJob(job))
|
||||
return;
|
||||
|
||||
// JobsJoin event
|
||||
JobsJoinEvent jobsjoinevent = new JobsJoinEvent(jPlayer, job);
|
||||
Bukkit.getServer().getPluginManager().callEvent(jobsjoinevent);
|
||||
JobsJoinEvent jobsJoinEvent = new JobsJoinEvent(jPlayer, job);
|
||||
Bukkit.getServer().getPluginManager().callEvent(jobsJoinEvent);
|
||||
// If event is canceled, dont do anything
|
||||
if (jobsjoinevent.isCancelled())
|
||||
if (jobsJoinEvent.isCancelled())
|
||||
return;
|
||||
|
||||
Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(job));
|
||||
@ -494,13 +495,13 @@ public class PlayerManager {
|
||||
* @param job {@link Job}
|
||||
*/
|
||||
public boolean leaveJob(JobsPlayer jPlayer, Job job) {
|
||||
if (!jPlayer.isInJob(job))
|
||||
if (jPlayer == null || job == null || !jPlayer.isInJob(job))
|
||||
return false;
|
||||
|
||||
JobsLeaveEvent jobsleaveevent = new JobsLeaveEvent(jPlayer, job);
|
||||
Bukkit.getServer().getPluginManager().callEvent(jobsleaveevent);
|
||||
JobsLeaveEvent jobsLeaveEvent = new JobsLeaveEvent(jPlayer, job);
|
||||
Bukkit.getServer().getPluginManager().callEvent(jobsLeaveEvent);
|
||||
// If event is canceled, don't do anything
|
||||
if (jobsleaveevent.isCancelled())
|
||||
if (jobsLeaveEvent.isCancelled())
|
||||
return false;
|
||||
|
||||
Jobs.getJobsDAO().recordToArchive(jPlayer, job);
|
||||
@ -510,6 +511,7 @@ public class PlayerManager {
|
||||
|
||||
if (!Jobs.getJobsDAO().quitJob(jPlayer, job))
|
||||
return false;
|
||||
|
||||
PerformCommands.performCommandsOnLeave(jPlayer, job);
|
||||
Jobs.leaveSlot(job);
|
||||
|
||||
@ -644,6 +646,7 @@ public class PlayerManager {
|
||||
for (String line : message.split("\n")) {
|
||||
if (Jobs.getGCManager().LevelChangeActionBar)
|
||||
ActionBarManager.send(player, line);
|
||||
|
||||
if (Jobs.getGCManager().LevelChangeChat)
|
||||
player.sendMessage(line);
|
||||
}
|
||||
@ -716,18 +719,14 @@ public class PlayerManager {
|
||||
break;
|
||||
}
|
||||
|
||||
int r1i = r.nextInt(17) + 1;
|
||||
int r2i = r.nextInt(17) + 1;
|
||||
|
||||
Color c1 = Util.getColor(r1i);
|
||||
Color c2 = Util.getColor(r2i);
|
||||
Color c1 = Util.getColor(r.nextInt(17) + 1);
|
||||
Color c2 = Util.getColor(r.nextInt(17) + 1);
|
||||
|
||||
FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1)
|
||||
.withFade(c2).with(type).trail(r.nextBoolean()).build();
|
||||
fm.addEffect(effect);
|
||||
|
||||
int rp = r.nextInt(2) + 1;
|
||||
fm.setPower(rp);
|
||||
fm.setPower(r.nextInt(2) + 1);
|
||||
} else {
|
||||
Pattern comma = Pattern.compile(",", 16);
|
||||
List<String> colorStrings = Jobs.getGCManager().FwColors;
|
||||
@ -1113,7 +1112,7 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
if (victim != null && victim.hasMetadata(mobSpawnerMetadata)) {
|
||||
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", false, false);
|
||||
double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", false, false);
|
||||
if (amount != 0D)
|
||||
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));
|
||||
}
|
||||
@ -1121,10 +1120,11 @@ public class PlayerManager {
|
||||
if (getall) {
|
||||
if (petPay == 0D)
|
||||
petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force, false);
|
||||
else
|
||||
|
||||
if (petPay != 0D)
|
||||
boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay));
|
||||
|
||||
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force);
|
||||
double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force);
|
||||
if (amount != 0D)
|
||||
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ public class ConfigManager {
|
||||
|
||||
if (jobFiles.isEmpty()) {
|
||||
File[] files = jobsPathFolder.listFiles((dir, name) -> name.toLowerCase().endsWith(".yml")
|
||||
&& !name.toLowerCase().equalsIgnoreCase(EXAMPLEJOBNAME + ".yml"));
|
||||
&& !name.equalsIgnoreCase(EXAMPLEJOBNAME + ".yml"));
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
jobFiles.add(new YmlMaker(jobsPathFolder, file));
|
||||
@ -798,18 +798,19 @@ public class ConfigManager {
|
||||
fDescription.add(jobSection.getString("FullDescription"));
|
||||
else if (jobSection.isList("FullDescription"))
|
||||
fDescription.addAll(jobSection.getStringList("FullDescription"));
|
||||
|
||||
for (int i = 0; i < fDescription.size(); i++) {
|
||||
fDescription.set(i, CMIChatColor.translate(fDescription.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
CMIChatColor color = CMIChatColor.WHITE;
|
||||
if (jobSection.contains("ChatColour")) {
|
||||
String c = jobSection.getString("ChatColour", "");
|
||||
|
||||
String c = jobSection.getString("ChatColour");
|
||||
if (c != null) {
|
||||
color = CMIChatColor.getColor(c);
|
||||
|
||||
if (color == null && !c.isEmpty())
|
||||
color = CMIChatColor.getColor(String.valueOf("&" + c.charAt(0)));
|
||||
color = CMIChatColor.getColor("&" + c.charAt(0));
|
||||
|
||||
if (color == null) {
|
||||
color = CMIChatColor.WHITE;
|
||||
@ -817,14 +818,11 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
String bossbar = "";
|
||||
if (jobSection.contains("BossBarColour")) {
|
||||
bossbar = jobSection.getString("BossBarColour", "");
|
||||
if (bossbar.isEmpty()) {
|
||||
String bossbar = jobSection.getString("BossBarColour");
|
||||
if (bossbar != null && bossbar.isEmpty()) {
|
||||
bossbar = "GREEN";
|
||||
log.warning("Job " + jobKey + " has an invalid BossBarColour property.");
|
||||
}
|
||||
}
|
||||
|
||||
DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", ""));
|
||||
if (displayMethod == null) {
|
||||
@ -846,8 +844,8 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
Parser incomeEquation = new Parser("0");
|
||||
if (jobSection.isString("income-progression-equation")) {
|
||||
String incomeEquationInput = jobSection.getString("income-progression-equation");
|
||||
if (incomeEquationInput != null) {
|
||||
try {
|
||||
incomeEquation = new Parser(incomeEquationInput);
|
||||
// test equation
|
||||
@ -876,8 +874,8 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
Parser pointsEquation = new Parser("0");
|
||||
if (jobSection.isString("points-progression-equation")) {
|
||||
String pointsEquationInput = jobSection.getString("points-progression-equation");
|
||||
if (pointsEquationInput != null) {
|
||||
try {
|
||||
pointsEquation = new Parser(pointsEquationInput);
|
||||
// test equation
|
||||
@ -894,16 +892,17 @@ public class ConfigManager {
|
||||
// Gui item
|
||||
int guiSlot = -1;
|
||||
ItemStack guiItem = CMIMaterial.GREEN_WOOL.newItemStack();
|
||||
if (jobSection.contains("Gui")) {
|
||||
ConfigurationSection guiSection = jobSection.getConfigurationSection("Gui");
|
||||
|
||||
if (guiSection != null) {
|
||||
if (guiSection.isString("Item")) {
|
||||
String item = guiSection.getString("Item");
|
||||
String subType = "";
|
||||
|
||||
if (item.contains("-")) {
|
||||
// uses subType
|
||||
subType = ":" + item.split("-", 2)[1];
|
||||
item = item.split("-")[0];
|
||||
String[] split = item.split("-", 2);
|
||||
subType = ":" + split[1];
|
||||
item = split[0];
|
||||
} else if (item.contains(":")) { // when we uses tipped arrow effect types
|
||||
item = item.split(":", 2)[0];
|
||||
}
|
||||
@ -937,21 +936,34 @@ public class ConfigManager {
|
||||
log.warning("Job " + jobKey + " has an invalid Gui property. Please fix this if you want to use it!");
|
||||
|
||||
for (String str4 : guiSection.getStringList("Enchantments")) {
|
||||
String[] id = str4.split(":");
|
||||
String[] id = str4.split(":", 2);
|
||||
|
||||
Enchantment enchant = CMIEnchantment.getEnchantment(id[0]);
|
||||
if (enchant == null)
|
||||
continue;
|
||||
|
||||
int level = 1;
|
||||
try {
|
||||
level = Integer.parseInt(id[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
}
|
||||
|
||||
if (guiItem.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) guiItem.getItemMeta();
|
||||
enchantMeta.addStoredEnchant(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]), true);
|
||||
enchantMeta.addStoredEnchant(enchant, level, true);
|
||||
guiItem.setItemMeta(enchantMeta);
|
||||
} else
|
||||
guiItem.addUnsafeEnchantment(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]));
|
||||
guiItem.addUnsafeEnchantment(enchant, level);
|
||||
}
|
||||
|
||||
if (guiSection.isString("CustomSkull")) {
|
||||
guiItem = Util.getSkull(guiSection.getString("CustomSkull"));
|
||||
String customSkull = guiSection.getString("CustomSkull", "");
|
||||
if (!customSkull.isEmpty()) {
|
||||
guiItem = Util.getSkull(customSkull);
|
||||
}
|
||||
|
||||
if (guiSection.getInt("slot", -1) >= 0)
|
||||
guiSlot = guiSection.getInt("slot");
|
||||
int slot = guiSection.getInt("slot", -1);
|
||||
if (slot >= 0)
|
||||
guiSlot = slot;
|
||||
}
|
||||
|
||||
// Permissions
|
||||
@ -1081,14 +1093,17 @@ public class ConfigManager {
|
||||
if (limitedItemsSection != null) {
|
||||
for (String itemKey : limitedItemsSection.getKeys(false)) {
|
||||
ConfigurationSection itemSection = limitedItemsSection.getConfigurationSection(itemKey);
|
||||
|
||||
if (itemSection == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid item key " + itemKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (itemSection.isList("lore"))
|
||||
itemSection.getStringList("lore").stream().map(CMIChatColor::translate).forEach(lore::add);
|
||||
List<String> lore = itemSection.getStringList("lore");
|
||||
|
||||
for (int a = 0; a < lore.size(); a++) {
|
||||
lore.set(a, CMIChatColor.translate(lore.get(a)));
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||
if (itemSection.isList("enchants"))
|
||||
@ -1098,18 +1113,21 @@ public class ConfigManager {
|
||||
|
||||
String[] split = eachLine.split("=", 2);
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||
Integer level = -1;
|
||||
if (ench == null)
|
||||
continue;
|
||||
|
||||
int level = -1;
|
||||
try {
|
||||
level = Integer.parseInt(split[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ench != null && level != -1)
|
||||
if (level != -1)
|
||||
enchants.put(ench, level);
|
||||
}
|
||||
|
||||
String node = itemKey.toLowerCase();
|
||||
|
||||
jobLimitedItems.put(node, new JobLimitedItems(node, itemSection.getInt("id"), 0, 1, itemSection.getString("name"),
|
||||
lore, enchants, itemSection.getInt("level")));
|
||||
}
|
||||
@ -1169,8 +1187,8 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
if (co.length > 0) {
|
||||
for (String c : co) {
|
||||
KeyValues kv = getKeyValue(c, actionType, jobFullName);
|
||||
for (String materials : co) {
|
||||
KeyValues kv = getKeyValue(materials, actionType, jobFullName);
|
||||
if (kv == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -92,12 +92,11 @@ public class ExploreManager {
|
||||
|
||||
public void load(ResultSet res) {
|
||||
try {
|
||||
int worldId = res.getInt(ExploreDataTableFields.worldid.getCollumn());
|
||||
String worldName = res.getString(ExploreDataTableFields.worldname.getCollumn());
|
||||
|
||||
JobsWorld jobsWorld = Util.getJobsWorld(worldName);
|
||||
if (jobsWorld == null)
|
||||
jobsWorld = Util.getJobsWorld(worldId);
|
||||
jobsWorld = Util.getJobsWorld(res.getInt(ExploreDataTableFields.worldid.getCollumn()));
|
||||
|
||||
if (jobsWorld == null)
|
||||
return;
|
||||
|
@ -98,7 +98,8 @@ public class GeneralConfigManager {
|
||||
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities,
|
||||
payForEachVTradeItem, allowEnchantingBoostedItems;
|
||||
|
||||
public ItemStack guiBackButton, guiNextButton, guiFiller;
|
||||
public ItemStack guiBackButton, guiNextButton;
|
||||
public CMIMaterial guiFiller;
|
||||
|
||||
public Parser DynamicPaymentEquation;
|
||||
|
||||
@ -954,14 +955,14 @@ public class GeneralConfigManager {
|
||||
c.addComment("Commands.JobsInfo.open-browse", "Open up the jobs browse action list, when your performed /jobs info command?");
|
||||
jobsInfoOpensBrowse = c.get("Commands.JobsInfo.open-browse", false);
|
||||
|
||||
CMIMaterial tmat = CMIMaterial.get(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN").toUpperCase());
|
||||
CMIMaterial tmat = CMIMaterial.get(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN"));
|
||||
guiBackButton = (tmat == CMIMaterial.NONE ? CMIMaterial.JACK_O_LANTERN : tmat).newItemStack();
|
||||
|
||||
tmat = CMIMaterial.get(c.get("JobsGUI.NextButton.Material", "ARROW").toUpperCase());
|
||||
tmat = CMIMaterial.get(c.get("JobsGUI.NextButton.Material", "ARROW"));
|
||||
guiNextButton = (tmat == CMIMaterial.NONE ? CMIMaterial.ARROW : tmat).newItemStack();
|
||||
|
||||
tmat = CMIMaterial.get(c.get("JobsGUI.Filler.Material", "GREEN_STAINED_GLASS_PANE").toUpperCase());
|
||||
guiFiller = (tmat == CMIMaterial.NONE ? CMIMaterial.GREEN_STAINED_GLASS_PANE : tmat).newItemStack();
|
||||
tmat = CMIMaterial.get(c.get("JobsGUI.Filler.Material", "GREEN_STAINED_GLASS_PANE"));
|
||||
guiFiller = (tmat == CMIMaterial.NONE ? CMIMaterial.GREEN_STAINED_GLASS_PANE : tmat);
|
||||
|
||||
c.save();
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class NameTranslatorManager {
|
||||
return translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName());
|
||||
}
|
||||
|
||||
public String translate(String materialName, ActionType action, Integer id, String meta, String name) {
|
||||
public String translate(String materialName, ActionType action, int id, String meta, String name) {
|
||||
// Translating name to user friendly
|
||||
if (Jobs.getGCManager().UseCustomNames)
|
||||
switch (action) {
|
||||
@ -91,7 +91,7 @@ public class NameTranslatorManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (id != null && id > 0 && meta != null && !meta.isEmpty()) {
|
||||
if (id > 0 && meta != null && !meta.isEmpty()) {
|
||||
mat = CMIMaterial.get(id + ":" + meta);
|
||||
nameLs = ListOfNames.get(mat);
|
||||
if (nameLs == null) {
|
||||
@ -110,7 +110,7 @@ public class NameTranslatorManager {
|
||||
return one.getName();
|
||||
}
|
||||
ids = one.getId();
|
||||
if (ids.equalsIgnoreCase(String.valueOf(id)) && !one.getId().equals("0")) {
|
||||
if (ids.equalsIgnoreCase(Integer.toString(id)) && !one.getId().equals("0")) {
|
||||
return one.getName();
|
||||
}
|
||||
ids = one.getMinecraftName();
|
||||
@ -159,21 +159,28 @@ public class NameTranslatorManager {
|
||||
public void readFile() {
|
||||
YmlMaker itemFile = new YmlMaker(Jobs.getFolder(), "TranslatableWords" + File.separator + "Words_"
|
||||
+ Jobs.getGCManager().localeString + ".yml");
|
||||
|
||||
if (!itemFile.getConfigFile().getName().equalsIgnoreCase("en")) {
|
||||
itemFile.saveDefaultConfig();
|
||||
}
|
||||
|
||||
if (itemFile.getConfig().isConfigurationSection("ItemList")) {
|
||||
ConfigurationSection section = itemFile.getConfig().getConfigurationSection("ItemList");
|
||||
|
||||
if (section != null) {
|
||||
ListOfNames.clear();
|
||||
|
||||
for (String one : itemFile.getConfig().getConfigurationSection("ItemList").getKeys(false)) {
|
||||
String split = one.contains("-") ? one.split("-")[0] : one;
|
||||
String id = split.contains(":") ? split.split(":")[0] : split;
|
||||
String meta = split.contains(":") && split.split(":").length > 1 ? split.split(":")[1] : "";
|
||||
for (String one : section.getKeys(false)) {
|
||||
String[] firstSplit = one.split("-", 2);
|
||||
String split = firstSplit.length > 0 ? firstSplit[0] : one;
|
||||
|
||||
String MCName = one.contains("-") && one.split("-").length > 1 ? one.split("-")[1] : one;
|
||||
String Name = itemFile.getConfig().getString("ItemList." + one);
|
||||
ListOfNames.put(CMIMaterial.get(one), new NameList(id, meta, Name, MCName));
|
||||
String[] splitted = split.split(":", 2);
|
||||
|
||||
String id = splitted.length > 0 ? splitted[0] : split;
|
||||
String meta = splitted.length > 1 ? splitted[1] : "";
|
||||
|
||||
String mcName = firstSplit.length > 1 ? firstSplit[1] : one;
|
||||
|
||||
ListOfNames.put(CMIMaterial.get(one), new NameList(id, meta, section.getString(one), mcName));
|
||||
}
|
||||
|
||||
if (ListOfNames.size() > 0)
|
||||
@ -181,16 +188,20 @@ public class NameTranslatorManager {
|
||||
} else
|
||||
Jobs.consoleMsg("&c[Jobs] The ItemList section not found in " + itemFile.fileName + " file.");
|
||||
|
||||
if (itemFile.getConfig().isConfigurationSection("EntityList")) {
|
||||
if ((section = itemFile.getConfig().getConfigurationSection("EntityList")) != null) {
|
||||
ListOfEntities.clear();
|
||||
|
||||
for (String one : itemFile.getConfig().getConfigurationSection("EntityList").getKeys(false)) {
|
||||
String split = one.contains("-") ? one.split("-")[0] : one;
|
||||
String id = split.contains(":") ? split.split(":")[0] : split;
|
||||
String meta = split.contains(":") ? split.split(":")[1] : "";
|
||||
String MCName = one.contains("-") && one.split("-").length > 1 ? one.split("-")[1] : one;
|
||||
String Name = itemFile.getConfig().getString("EntityList." + one);
|
||||
ListOfEntities.add(new NameList(id, meta, Name, MCName));
|
||||
for (String one : section.getKeys(false)) {
|
||||
String[] firstSplit = one.split("-", 2);
|
||||
String split = firstSplit.length > 0 ? firstSplit[0] : one;
|
||||
|
||||
String[] splitted = split.split(":", 2);
|
||||
|
||||
String id = splitted.length > 0 ? splitted[0] : split;
|
||||
String meta = splitted.length > 1 ? splitted[1] : "";
|
||||
String mcName = firstSplit.length > 1 ? firstSplit[1] : one;
|
||||
|
||||
ListOfEntities.add(new NameList(id, meta, section.getString(one), mcName));
|
||||
}
|
||||
|
||||
if (ListOfEntities.size() > 0)
|
||||
@ -198,12 +209,12 @@ public class NameTranslatorManager {
|
||||
} else
|
||||
Jobs.consoleMsg("&c[Jobs] The EntityList section not found in " + itemFile.fileName + " file.");
|
||||
|
||||
if (itemFile.getConfig().isConfigurationSection("MythicEntityList")) {
|
||||
if ((section = itemFile.getConfig().getConfigurationSection("MythicEntityList")) != null) {
|
||||
ListOfMMEntities.clear();
|
||||
|
||||
for (String one : itemFile.getConfig().getConfigurationSection("MythicEntityList").getKeys(false)) {
|
||||
String Name = itemFile.getConfig().getString("MythicEntityList." + one);
|
||||
ListOfMMEntities.put(one.toLowerCase(), new NameList(null, null, Name, Name));
|
||||
for (String one : section.getKeys(false)) {
|
||||
String name = section.getString(one);
|
||||
ListOfMMEntities.put(one.toLowerCase(), new NameList(null, null, name, name));
|
||||
}
|
||||
|
||||
if (ListOfMMEntities.size() > 0)
|
||||
@ -211,10 +222,9 @@ public class NameTranslatorManager {
|
||||
} else
|
||||
Jobs.consoleMsg("&c[Jobs] The MythicEntityList section not found in " + itemFile.fileName + " file.");
|
||||
|
||||
if (itemFile.getConfig().isConfigurationSection("EnchantList")) {
|
||||
if ((section = itemFile.getConfig().getConfigurationSection("EnchantList")) != null) {
|
||||
ListOfEnchants.clear();
|
||||
|
||||
ConfigurationSection section = itemFile.getConfig().getConfigurationSection("EnchantList");
|
||||
for (String one : section.getKeys(false)) {
|
||||
ListOfEnchants.put(one.replace("_", "").toLowerCase(), new NameList(one, one, one, section.getString(one)));
|
||||
}
|
||||
@ -224,15 +234,14 @@ public class NameTranslatorManager {
|
||||
} else
|
||||
Jobs.consoleMsg("&c[Jobs] The EnchantList section not found in " + itemFile.fileName + " file.");
|
||||
|
||||
if (itemFile.getConfig().isConfigurationSection("ColorList")) {
|
||||
if ((section = itemFile.getConfig().getConfigurationSection("ColorList")) != null) {
|
||||
ListOfColors.clear();
|
||||
|
||||
for (String one : itemFile.getConfig().getConfigurationSection("ColorList").getKeys(false)) {
|
||||
String[] split = one.contains("-") ? one.split("-") : new String[0];
|
||||
String id = split.length != 0 ? split[0] : one;
|
||||
String MCName = split.length > 1 ? split[1] : "";
|
||||
String Name = itemFile.getConfig().getString("ColorList." + one);
|
||||
ListOfColors.add(new NameList(id, "", Name, MCName));
|
||||
for (String one : section.getKeys(false)) {
|
||||
String[] split = one.split("-", 2);
|
||||
String id = split.length > 0 ? split[0] : one;
|
||||
String mcName = split.length > 1 ? split[1] : "";
|
||||
ListOfColors.add(new NameList(id, "", section.getString(one), mcName));
|
||||
}
|
||||
|
||||
if (ListOfColors.size() > 0)
|
||||
@ -382,19 +391,25 @@ public class NameTranslatorManager {
|
||||
}
|
||||
|
||||
for (Enchantment one : Enchantment.values()) {
|
||||
if (CMIEnchantment.getName(one) == null)
|
||||
String enchName = CMIEnchantment.getName(one);
|
||||
if (enchName == null)
|
||||
continue;
|
||||
|
||||
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");
|
||||
if (old != null && old.equalsIgnoreCase(CMIEnchantment.getName(one))) {
|
||||
name = c.getC().getString("EnchantList." + onek + ".Name");
|
||||
String name = Util.firstToUpperCase(enchName).replace('_', ' ');
|
||||
|
||||
ConfigurationSection section = c.getC().getConfigurationSection("EnchantList");
|
||||
if (section != null) {
|
||||
for (String onek : section.getKeys(false)) {
|
||||
String old = section.getString(onek + ".MCName");
|
||||
|
||||
if (old != null && old.equalsIgnoreCase(enchName)) {
|
||||
name = section.getString(onek + ".Name");
|
||||
break;
|
||||
}
|
||||
}
|
||||
c.get("EnchantList." + CMIEnchantment.getName(one), name);
|
||||
}
|
||||
|
||||
c.get("EnchantList." + enchName, name);
|
||||
}
|
||||
|
||||
// Color list
|
||||
|
@ -73,9 +73,12 @@ public class RestrictedAreaManager {
|
||||
private void save() {
|
||||
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
|
||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
conf.options().indent(2);
|
||||
conf.options().copyDefaults(true);
|
||||
|
||||
addHeader(new StringBuilder());
|
||||
|
||||
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
||||
String areaKey = area.getKey();
|
||||
CuboidArea cuboid = area.getValue().getCuboidArea();
|
||||
@ -139,7 +142,7 @@ public class RestrictedAreaManager {
|
||||
}
|
||||
|
||||
private StringBuilder addHeader(StringBuilder header) {
|
||||
String sep = System.getProperty("line.separator");
|
||||
String sep = System.lineSeparator();
|
||||
|
||||
header.append("Restricted area configuration");
|
||||
header.append(sep)
|
||||
|
@ -29,11 +29,12 @@ public class RestrictedBlockManager {
|
||||
"By setting time to -1 will keep block protected until global cleanup, mainly used for structure blocks like diamond",
|
||||
"If you want to have default value for all blocks, enable GlobalBlockTimer in generalConfig file");
|
||||
|
||||
if (cfg.getC().isConfigurationSection("blocksTimer")) {
|
||||
org.bukkit.configuration.ConfigurationSection section = cfg.getC().getConfigurationSection("blocksTimer");
|
||||
if (section != null) {
|
||||
for (String one : section.getKeys(false)) {
|
||||
if (((section.isString(one + ".id")) || (section.isInt(one + ".id"))) && (section.isInt(one + ".cd"))) {
|
||||
if ((section.isString(one + ".id") || section.isInt(one + ".id")) && section.isInt(one + ".cd")) {
|
||||
CMIItemStack cm = ItemManager.getItem(CMIMaterial.get(section.getString(one + ".id")));
|
||||
|
||||
if (cm == null || !cm.getCMIType().isBlock()) {
|
||||
Jobs.consoleMsg("&e[Jobs] Your defined (" + one + ") protected block id/name is not correct!");
|
||||
continue;
|
||||
@ -68,6 +69,7 @@ public class RestrictedBlockManager {
|
||||
|
||||
if (restrictedBlocksTimer.size() > 0)
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + restrictedBlocksTimer.size() + " protected blocks timers!");
|
||||
|
||||
cfg.save();
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -55,7 +53,7 @@ public class ShopManager {
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<ShopItem> getItemsByPage(Integer page) {
|
||||
private List<ShopItem> getItemsByPage(int page) {
|
||||
List<ShopItem> ls = new ArrayList<>();
|
||||
for (ShopItem one : list) {
|
||||
if (one.getPage() == page)
|
||||
@ -66,19 +64,21 @@ public class ShopManager {
|
||||
|
||||
private static GUIRows getGuiSize(List<ShopItem> ls, int page) {
|
||||
GUIRows guiSize = GUIRows.r1;
|
||||
if (ls.size() > 9)
|
||||
int size = ls.size();
|
||||
|
||||
if (size > 9)
|
||||
guiSize = GUIRows.r2;
|
||||
|
||||
if (ls.size() > 18)
|
||||
if (size > 18)
|
||||
guiSize = GUIRows.r3;
|
||||
|
||||
if (ls.size() > 27)
|
||||
if (size > 27)
|
||||
guiSize = GUIRows.r4;
|
||||
|
||||
if (ls.size() > 36)
|
||||
if (size > 36)
|
||||
guiSize = GUIRows.r5;
|
||||
|
||||
if (ls.size() == 45)
|
||||
if (size == 45)
|
||||
guiSize = GUIRows.r6;
|
||||
|
||||
if (page > 1 && guiSize != GUIRows.r6)
|
||||
@ -95,7 +95,7 @@ public class ShopManager {
|
||||
return !getItemsByPage(page + 1).isEmpty() ? guiSize - 1 : -1;
|
||||
}
|
||||
|
||||
public boolean openShopGui(Player player, Integer page) {
|
||||
public boolean openShopGui(Player player, int page) {
|
||||
List<ShopItem> ls = getItemsByPage(page);
|
||||
if (ls.isEmpty()) {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.cantOpen"));
|
||||
@ -140,12 +140,12 @@ public class ShopManager {
|
||||
mat = CMIMaterial.STONE_BUTTON;
|
||||
|
||||
ItemStack guiItem = mat.newItemStack();
|
||||
guiItem.setAmount(item.getIconAmount());
|
||||
|
||||
ItemMeta meta = guiItem.getItemMeta();
|
||||
if (meta == null)
|
||||
continue;
|
||||
|
||||
guiItem.setAmount(item.getIconAmount());
|
||||
|
||||
if (item.getIconName() != null)
|
||||
plugin.getComplement().setDisplayName(meta, item.getIconName());
|
||||
|
||||
@ -156,6 +156,7 @@ public class ShopManager {
|
||||
|
||||
if (!item.getRequiredJobs().isEmpty()) {
|
||||
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobs"));
|
||||
|
||||
for (Entry<String, Integer> one : item.getRequiredJobs().entrySet()) {
|
||||
Job job = Jobs.getJob(one.getKey());
|
||||
if (job == null) {
|
||||
@ -200,12 +201,12 @@ public class ShopManager {
|
||||
if (item.isHeadOwner()) {
|
||||
Jobs.getNms().setSkullOwner(skullMeta, jPlayer.getPlayer());
|
||||
} else {
|
||||
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(item.getCustomHead());
|
||||
Jobs.getNms().setSkullOwner(skullMeta, offPlayer);
|
||||
Jobs.getNms().setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(item.getCustomHead()));
|
||||
}
|
||||
guiItem.setItemMeta(skullMeta);
|
||||
} else
|
||||
guiItem.setItemMeta(meta);
|
||||
|
||||
gui.addButton(new CMIGuiButton(i, guiItem) {
|
||||
@Override
|
||||
public void click(GUIClickType type) {
|
||||
@ -220,6 +221,7 @@ public class ShopManager {
|
||||
Job tempJob = Jobs.getJob(oneJob.getKey());
|
||||
if (tempJob == null)
|
||||
continue;
|
||||
|
||||
JobProgression playerJob = jPlayer.getJobProgression(tempJob);
|
||||
if (playerJob == null || playerJob.getLevel() < oneJob.getValue()) {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoJobReqForitem",
|
||||
@ -245,6 +247,9 @@ public class ShopManager {
|
||||
}
|
||||
|
||||
for (String one : item.getCommands()) {
|
||||
if (one.isEmpty())
|
||||
continue;
|
||||
|
||||
if (one.toLowerCase().startsWith("msg "))
|
||||
player.sendMessage(one.substring(4, one.length()).replace("[player]", player.getName()));
|
||||
else
|
||||
@ -258,7 +263,6 @@ public class ShopManager {
|
||||
pointsInfo.takePoints(item.getPrice());
|
||||
Jobs.getJobsDAO().savePoints(jPlayer);
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPrice()));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -292,7 +296,7 @@ public class ShopManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller));
|
||||
gui.setFiller(Jobs.getGCManager().guiFiller);
|
||||
gui.fillEmptyButtons();
|
||||
gui.open();
|
||||
return true;
|
||||
@ -301,13 +305,11 @@ public class ShopManager {
|
||||
public void load() {
|
||||
list.clear();
|
||||
|
||||
File file = new File(Jobs.getFolder(), "shopItems.yml");
|
||||
YamlConfiguration f = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
if (!f.isConfigurationSection("Items"))
|
||||
YamlConfiguration f = YamlConfiguration.loadConfiguration(new File(Jobs.getFolder(), "shopItems.yml"));
|
||||
ConfigurationSection confCategory = f.getConfigurationSection("Items");
|
||||
if (confCategory == null)
|
||||
return;
|
||||
|
||||
ConfigurationSection confCategory = f.getConfigurationSection("Items");
|
||||
java.util.Set<String> categories = confCategory.getKeys(false);
|
||||
if (categories.isEmpty()) {
|
||||
return;
|
||||
@ -315,6 +317,7 @@ public class ShopManager {
|
||||
|
||||
int i = 0;
|
||||
int y = 1;
|
||||
|
||||
for (String category : new ArrayList<>(categories)) {
|
||||
ConfigurationSection nameSection = confCategory.getConfigurationSection(category);
|
||||
if (nameSection == null) {
|
||||
@ -340,39 +343,32 @@ public class ShopManager {
|
||||
if (nameSection.isString("Icon.Name"))
|
||||
sItem.setIconName(CMIChatColor.translate(nameSection.getString("Icon.Name")));
|
||||
|
||||
if (nameSection.isList("Icon.Lore")) {
|
||||
sItem.setIconLore(nameSection.getStringList("Icon.Lore").stream().map(CMIChatColor::translate)
|
||||
.collect(Collectors.toList()));
|
||||
List<String> lore = nameSection.getStringList("Icon.Lore");
|
||||
for (int b = 0; b < lore.size(); b++) {
|
||||
lore.set(b, CMIChatColor.translate(lore.get(b)));
|
||||
}
|
||||
|
||||
sItem.setIconLore(lore);
|
||||
|
||||
if (nameSection.isString("Icon.CustomHead.PlayerName"))
|
||||
sItem.setCustomHead(nameSection.getString("Icon.CustomHead.PlayerName"));
|
||||
|
||||
if (nameSection.isBoolean("Icon.CustomHead.UseCurrentPlayer"))
|
||||
sItem.setCustomHeadOwner(nameSection.getBoolean("Icon.CustomHead.UseCurrentPlayer"));
|
||||
|
||||
if (nameSection.isBoolean("Icon.HideIfThereIsNoEnoughPoints")) {
|
||||
sItem.setCustomHeadOwner(nameSection.getBoolean("Icon.CustomHead.UseCurrentPlayer", true));
|
||||
sItem.setHideIfThereIsNoEnoughPoints(nameSection.getBoolean("Icon.HideIfThereIsNoEnoughPoints"));
|
||||
}
|
||||
|
||||
if (nameSection.isBoolean("Icon.HideWithoutPermission"))
|
||||
sItem.setHideWithoutPerm(nameSection.getBoolean("Icon.HideWithoutPermission"));
|
||||
|
||||
if (nameSection.isList("RequiredPermission")) {
|
||||
sItem.setRequiredPerm(nameSection.getStringList("RequiredPermission"));
|
||||
}
|
||||
|
||||
if (nameSection.isInt("RequiredTotalLevels"))
|
||||
sItem.setRequiredTotalLevels(nameSection.getInt("RequiredTotalLevels"));
|
||||
|
||||
if (nameSection.isList("RequiredJobLevels")) {
|
||||
Map<String, Integer> requiredJobs = new HashMap<>();
|
||||
|
||||
for (String one : nameSection.getStringList("RequiredJobLevels")) {
|
||||
if (!one.contains("-"))
|
||||
continue;
|
||||
|
||||
String[] split = one.split("-", 2);
|
||||
String job = split[0];
|
||||
int lvl = 1;
|
||||
if (split.length > 1) {
|
||||
try {
|
||||
@ -382,18 +378,18 @@ public class ShopManager {
|
||||
}
|
||||
}
|
||||
|
||||
requiredJobs.put(job, lvl);
|
||||
requiredJobs.put(split[0], lvl);
|
||||
}
|
||||
sItem.setRequiredJobs(requiredJobs);
|
||||
}
|
||||
|
||||
if (nameSection.isList("PerformCommands")) {
|
||||
sItem.setCommands(nameSection.getStringList("PerformCommands").stream().map(CMIChatColor::translate)
|
||||
.collect(Collectors.toList()));
|
||||
List<String> performCommands = nameSection.getStringList("PerformCommands");
|
||||
for (int k = 0; k < performCommands.size(); k++) {
|
||||
performCommands.set(k, CMIChatColor.translate(performCommands.get(k)));
|
||||
}
|
||||
|
||||
if (nameSection.isConfigurationSection("GiveItems")) {
|
||||
ConfigurationSection itemsSection = nameSection.getConfigurationSection("GiveItems");
|
||||
if (itemsSection != null) {
|
||||
List<JobItems> items = new ArrayList<>();
|
||||
|
||||
for (String oneItemName : itemsSection.getKeys(false)) {
|
||||
@ -401,8 +397,6 @@ public class ShopManager {
|
||||
if (itemSection == null)
|
||||
continue;
|
||||
|
||||
String node = oneItemName.toLowerCase();
|
||||
|
||||
String id = null;
|
||||
if (itemSection.isString("Id"))
|
||||
id = itemSection.getString("Id");
|
||||
@ -414,9 +408,9 @@ public class ShopManager {
|
||||
int amount = itemSection.getInt("Amount", 1);
|
||||
String name = CMIChatColor.translate(itemSection.getString("Name"));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String eachLine : itemSection.getStringList("Lore")) {
|
||||
lore.add(CMIChatColor.translate(eachLine));
|
||||
List<String> giveLore = itemSection.getStringList("Lore");
|
||||
for (int v = 0; v < giveLore.size(); v++) {
|
||||
giveLore.set(v, CMIChatColor.translate(giveLore.get(v)));
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||
@ -426,6 +420,9 @@ public class ShopManager {
|
||||
|
||||
String[] split = eachLine.split("=", 2);
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||
if (ench == null)
|
||||
continue;
|
||||
|
||||
Integer level = 1;
|
||||
if (split.length > 1) {
|
||||
try {
|
||||
@ -435,7 +432,6 @@ public class ShopManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (ench != null)
|
||||
enchants.put(ench, level);
|
||||
}
|
||||
|
||||
@ -453,16 +449,12 @@ public class ShopManager {
|
||||
}
|
||||
}
|
||||
|
||||
items.add(new JobItems(node, id == null ? CMIMaterial.STONE : CMIMaterial.get(id), amount, name, lore,
|
||||
items.add(new JobItems(oneItemName.toLowerCase(), id == null ? CMIMaterial.STONE : CMIMaterial.get(id), amount, name, giveLore,
|
||||
enchants, new BoostMultiplier(), new ArrayList<Job>(), potionData, null));
|
||||
}
|
||||
sItem.setitems(items);
|
||||
}
|
||||
|
||||
// if (list.size() >= 54) {
|
||||
// Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Jobs] To many jobs shop items, max allowed is 54! Only first 54 items will be used!");
|
||||
// break;
|
||||
// }
|
||||
i++;
|
||||
|
||||
if (i > 45) {
|
||||
|
@ -120,34 +120,34 @@ public class TitleManager {
|
||||
c.save();
|
||||
} else
|
||||
for (String titleKey : titleSection.getKeys(false)) {
|
||||
String jobName = "",
|
||||
titleName = titleSection.getString(titleKey + ".Name", ""),
|
||||
titleShortName = titleSection.getString(titleKey + ".ShortName", "");
|
||||
CMIChatColor titleColor = CMIChatColor.getColor(titleSection.getString(titleKey + ".ChatColour"));
|
||||
int levelReq = titleSection.getInt(titleKey + ".levelReq", -1);
|
||||
|
||||
if (titleSection.isString(titleKey + ".JobName"))
|
||||
jobName = titleSection.getString(titleKey + ".JobName", "");
|
||||
String titleName = titleSection.getString(titleKey + ".Name", "");
|
||||
|
||||
if (titleName.isEmpty()) {
|
||||
Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid Name property. Skipping!");
|
||||
continue;
|
||||
}
|
||||
|
||||
String titleShortName = titleSection.getString(titleKey + ".ShortName", "");
|
||||
if (titleShortName.isEmpty()) {
|
||||
Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid ShortName property. Skipping!");
|
||||
continue;
|
||||
}
|
||||
|
||||
CMIChatColor titleColor = CMIChatColor.getColor(titleSection.getString(titleKey + ".ChatColour"));
|
||||
if (titleColor == null) {
|
||||
Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid ChatColour property. Skipping!");
|
||||
continue;
|
||||
}
|
||||
|
||||
int levelReq = titleSection.getInt(titleKey + ".levelReq", -1);
|
||||
if (levelReq <= -1) {
|
||||
Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid levelReq property. Skipping!");
|
||||
continue;
|
||||
}
|
||||
|
||||
titles.add(new Title(titleName, titleShortName, titleColor, levelReq, jobName));
|
||||
titles.add(new Title(titleName, titleShortName, titleColor, levelReq, titleSection.getString(titleKey + ".JobName")));
|
||||
}
|
||||
|
||||
if (titles.size() > 0)
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + titles.size() + " titles!");
|
||||
}
|
||||
|
@ -49,7 +49,9 @@ public class ShopItem {
|
||||
|
||||
public void setitems(List<JobItems> items) {
|
||||
this.items.clear();
|
||||
this.items.addAll(items == null ? new ArrayList<>() : items);
|
||||
|
||||
if (items != null)
|
||||
this.items.addAll(items);
|
||||
}
|
||||
|
||||
public List<JobItems> getitems() {
|
||||
@ -58,7 +60,9 @@ public class ShopItem {
|
||||
|
||||
public void setCommands(List<String> commands) {
|
||||
this.commands.clear();
|
||||
this.commands.addAll(commands == null ? new ArrayList<>() : commands);
|
||||
|
||||
if (commands != null)
|
||||
this.commands.addAll(commands);
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
@ -75,7 +79,9 @@ public class ShopItem {
|
||||
|
||||
public void setRequiredPerm(List<String> requiredPerm) {
|
||||
this.requiredPerm.clear();
|
||||
this.requiredPerm.addAll(requiredPerm == null ? new ArrayList<>() : requiredPerm);
|
||||
|
||||
if (requiredPerm != null)
|
||||
this.requiredPerm.addAll(requiredPerm);
|
||||
}
|
||||
|
||||
public List<String> getRequiredPerm() {
|
||||
@ -100,7 +106,9 @@ public class ShopItem {
|
||||
|
||||
public void setIconLore(List<String> iconLore) {
|
||||
this.iconLore.clear();
|
||||
this.iconLore.addAll(iconLore == null ? new ArrayList<>() : iconLore);
|
||||
|
||||
if (iconLore != null)
|
||||
this.iconLore.addAll(iconLore);
|
||||
}
|
||||
|
||||
public List<String> getIconLore() {
|
||||
|
@ -465,7 +465,7 @@ public abstract class JobsDAO {
|
||||
try {
|
||||
Class.forName(driverName);
|
||||
} catch (ClassNotFoundException c) {
|
||||
c.printStackTrace();
|
||||
plugin.getLogger().log(java.util.logging.Level.WARNING, c.getLocalizedMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -106,10 +106,8 @@ public class BufferedEconomy {
|
||||
if (offPlayer == null)
|
||||
continue;
|
||||
|
||||
UUID uuid = offPlayer.getUniqueId();
|
||||
if (paymentCache.containsKey(uuid)) {
|
||||
BufferedPayment existing = paymentCache.get(uuid);
|
||||
|
||||
BufferedPayment existing = paymentCache.get(offPlayer.getUniqueId());
|
||||
if (existing != null) {
|
||||
double money = payment.get(CurrencyType.MONEY);
|
||||
double points = payment.get(CurrencyType.POINTS);
|
||||
double exp = payment.get(CurrencyType.EXP);
|
||||
@ -158,7 +156,7 @@ public class BufferedEconomy {
|
||||
payment.set(CurrencyType.POINTS, points);
|
||||
}
|
||||
|
||||
paymentCache.put(uuid, payment);
|
||||
paymentCache.put(offPlayer.getUniqueId(), payment);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,8 +374,6 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
// check if player is riding
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
@ -438,10 +436,6 @@ public class JobsPaymentListener implements Listener {
|
||||
if (CMIMaterial.get(event.getItemInHand().getType()).isTool())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
|
||||
@ -451,6 +445,8 @@ public class JobsPaymentListener implements Listener {
|
||||
&& ItemManager.getItem(event.getItemInHand()).isSimilar(CMIMaterial.BONE_MEAL.newCMIItemStack()))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// check if player is riding
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
return;
|
||||
@ -796,9 +792,6 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryRepair(InventoryClickEvent event) {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
|
||||
return;
|
||||
|
||||
// If event is nothing or place, do nothing
|
||||
switch (event.getAction()) {
|
||||
case NOTHING:
|
||||
@ -810,6 +803,13 @@ public class JobsPaymentListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(event.getWhoClicked() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
Inventory inv = event.getInventory();
|
||||
|
||||
// must be an inventory
|
||||
@ -827,10 +827,6 @@ public class JobsPaymentListener implements Listener {
|
||||
|| (Version.isCurrentEqualOrHigher(Version.v1_16_R1) && !(inv instanceof SmithingInventory))) && slot == 1)
|
||||
return;
|
||||
|
||||
if (!(event.getWhoClicked() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
//Check if inventory is full and using shift click, possible money dupping fix
|
||||
if (player.getInventory().firstEmpty() == -1 && event.isShiftClick()) {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("message.crafting.fullinventory"));
|
||||
@ -841,27 +837,6 @@ public class JobsPaymentListener implements Listener {
|
||||
if (resultStack == null)
|
||||
return;
|
||||
|
||||
// Checking if this is only item rename
|
||||
ItemStack firstSlot = null;
|
||||
try {
|
||||
firstSlot = inv.getItem(0);
|
||||
} catch (NullPointerException e) {
|
||||
return;
|
||||
}
|
||||
if (firstSlot == null)
|
||||
return;
|
||||
|
||||
String originalName = null;
|
||||
String newName = null;
|
||||
if (firstSlot.hasItemMeta())
|
||||
originalName = plugin.getComplement().getDisplayName(firstSlot.getItemMeta());
|
||||
|
||||
if (resultStack.hasItemMeta())
|
||||
newName = plugin.getComplement().getDisplayName(resultStack.getItemMeta());
|
||||
|
||||
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()))
|
||||
return;
|
||||
@ -885,6 +860,27 @@ public class JobsPaymentListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
// Checking if this is only item rename
|
||||
ItemStack firstSlot = null;
|
||||
try {
|
||||
firstSlot = inv.getItem(0);
|
||||
} catch (NullPointerException e) {
|
||||
return;
|
||||
}
|
||||
if (firstSlot == null)
|
||||
return;
|
||||
|
||||
String originalName = null;
|
||||
String newName = null;
|
||||
if (firstSlot.hasItemMeta())
|
||||
originalName = plugin.getComplement().getDisplayName(firstSlot.getItemMeta());
|
||||
|
||||
if (resultStack.hasItemMeta())
|
||||
newName = plugin.getComplement().getDisplayName(resultStack.getItemMeta());
|
||||
|
||||
if (originalName != null && !originalName.equals(newName) && inv.getItem(1) == null && !Jobs.getGCManager().PayForRenaming)
|
||||
return;
|
||||
|
||||
// Possible payment exploit when clicking continuously in the result item #438
|
||||
if (event.isLeftClick() && event.getCursor().getType() != Material.AIR)
|
||||
return;
|
||||
@ -1179,12 +1175,13 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
|
||||
Player pDamager = null;
|
||||
boolean isMyPet = HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null);
|
||||
|
||||
// Checking if killer is player
|
||||
if (e.getDamager() instanceof Player) {
|
||||
pDamager = (Player) e.getDamager();
|
||||
// Checking if killer is MyPet animal
|
||||
} else if (HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null)) {
|
||||
} else if (isMyPet) {
|
||||
UUID uuid = HookManager.getMyPetManager().getOwnerOfPet(e.getDamager());
|
||||
if (uuid != null)
|
||||
pDamager = Bukkit.getPlayer(uuid);
|
||||
@ -1203,11 +1200,10 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
|
||||
// Prevent payment for killing mobs with pet by denying permission
|
||||
if ((HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null))
|
||||
|| (e.getDamager() instanceof Tameable && ((Tameable) e.getDamager()).isTamed() &&
|
||||
if (isMyPet || (e.getDamager() instanceof Tameable && ((Tameable) e.getDamager()).isTamed() &&
|
||||
((Tameable) e.getDamager()).getOwner() instanceof Player)) {
|
||||
for (PermissionAttachmentInfo perm : pDamager.getEffectivePermissions()) {
|
||||
if ("jobs.petpay".equals(perm.getPermission()) && !perm.getValue()) {
|
||||
if (!perm.getValue() && "jobs.petpay".equals(perm.getPermission())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
@ -43,9 +42,13 @@ public class Util {
|
||||
public static ItemStack getSkull(String skullOwner) {
|
||||
ItemStack item = CMIMaterial.PLAYER_HEAD.newItemStack();
|
||||
SkullMeta skullMeta = (SkullMeta) item.getItemMeta();
|
||||
|
||||
if (skullOwner.length() == 36) {
|
||||
try {
|
||||
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(skullOwner));
|
||||
Jobs.getNms().setSkullOwner(skullMeta, offPlayer);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
} else
|
||||
skullMeta.setOwner(skullOwner);
|
||||
|
||||
@ -201,6 +204,7 @@ public class Util {
|
||||
public static void addJobsWorld(JobsWorld jobsWorld) {
|
||||
if (jobsWorld == null || jobsWorld.getId() == 0)
|
||||
return;
|
||||
|
||||
jobsWorlds.put(jobsWorld.getName().toLowerCase(), jobsWorld);
|
||||
jobsWorldsId.put(jobsWorld.getId(), jobsWorld);
|
||||
}
|
||||
@ -225,20 +229,20 @@ public class Util {
|
||||
}
|
||||
|
||||
public static List<String> getFilesInSamePackageFromJar(String packageName, String jarPath, String cleaner, String fileType) {
|
||||
JarFile jarFile = null;
|
||||
packageName = packageName.replace('.', '/');
|
||||
|
||||
List<String> listOfCommands = new ArrayList<>();
|
||||
try {
|
||||
jarFile = new JarFile(jarPath);
|
||||
|
||||
try (JarFile jarFile = new JarFile(jarPath)) {
|
||||
Enumeration<JarEntry> en = jarFile.entries();
|
||||
while (en.hasMoreElements()) {
|
||||
String entryName = en.nextElement().getName();
|
||||
|
||||
packageName = packageName.replace('.', '/');
|
||||
|
||||
if (entryName.endsWith("." + fileType) && entryName.startsWith(packageName)) {
|
||||
String name = entryName.replace(packageName, "").replace("." + fileType, "").replace("/", "");
|
||||
|
||||
if (name.contains("$"))
|
||||
name = name.split("\\$")[0];
|
||||
name = name.split("\\$", 2)[0];
|
||||
|
||||
if (cleaner != null && !cleaner.isEmpty())
|
||||
name = name.replace(cleaner, "");
|
||||
@ -246,14 +250,9 @@ public class Util {
|
||||
listOfCommands.add(name);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} finally {
|
||||
if (jarFile != null)
|
||||
try {
|
||||
jarFile.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
} catch (java.io.IOException e) {
|
||||
}
|
||||
|
||||
return listOfCommands;
|
||||
}
|
||||
}
|
||||
|
@ -62,9 +62,6 @@ public class JobsChatEvent implements Listener {
|
||||
if (honorific.equals(" "))
|
||||
honorific = "";
|
||||
|
||||
String format = event.getFormat();
|
||||
if (format.contains("{jobs}")) {
|
||||
event.setFormat(format.replace("{jobs}", honorific));
|
||||
}
|
||||
event.setFormat(event.getFormat().replace("{jobs}", honorific));
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import io.papermc.paper.chat.ChatComposer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
|
||||
@ -43,16 +44,19 @@ public final class KyoriChatEvent extends Complement2 implements Listener {
|
||||
if (honorific.equals(" "))
|
||||
honorific = "";
|
||||
|
||||
final String h = honorific;
|
||||
|
||||
// TODO displayName returns the player display name not the chat component from
|
||||
// chat plugins, like Essentials
|
||||
// Now there is a parameter "player", so literally we need to add 800+ chat plugins
|
||||
// to this plugin as dependency?
|
||||
// 3rd attempt: now we tried to use text replacement config builder to match the variable
|
||||
// result: instead of replacing the variable, now the chat message never been sent
|
||||
event.composer((player, displayName, msg) -> msg
|
||||
.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build()));
|
||||
//event.composer((player, displayName, msg) -> msg
|
||||
//.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build()));
|
||||
|
||||
// 4th attempt: composeChat -> doing nothing
|
||||
event.message(ChatComposer.DEFAULT
|
||||
.composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message())
|
||||
.replaceText(TextReplacementConfig.builder().match("\\{jobs\\}").replacement(honorific).build()));
|
||||
}
|
||||
|
||||
// Changing chat prefix variable to job name
|
||||
@ -72,8 +76,8 @@ public final class KyoriChatEvent extends Complement2 implements Listener {
|
||||
if (honorific.equals(" "))
|
||||
honorific = "";
|
||||
|
||||
final String h = honorific;
|
||||
event.composer((player, displayName, msg) -> msg
|
||||
.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build()));
|
||||
event.message(ChatComposer.DEFAULT
|
||||
.composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message())
|
||||
.replaceText(TextReplacementConfig.builder().match("\\{jobs\\}").replacement(honorific).build()));
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ exampleJob:
|
||||
income: 2.5
|
||||
points: 2.5
|
||||
experience: 2.5
|
||||
# Payment for cooking raw foods
|
||||
# Payment for cooking raw foods in camp fire
|
||||
Bake:
|
||||
beef:
|
||||
income: 1.0
|
||||
@ -460,7 +460,7 @@ exampleJob:
|
||||
tipped_arrow:slowness:
|
||||
income: 3.0
|
||||
points: 3.0
|
||||
# Smelting ores
|
||||
# Smelting ores in any type of furnaces
|
||||
Smelt:
|
||||
iron_ingot:
|
||||
income: 2.0
|
||||
|
Loading…
Reference in New Issue
Block a user