1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Some code clean up

- Fix 1 color not work (lime)
- We using the default data folder from main class
- We don't need to copy and create a lot of message file
This commit is contained in:
montlikadani 2018-11-25 20:09:48 +01:00
parent 717b0edebe
commit ed0eadad69
13 changed files with 112 additions and 141 deletions

View File

@ -30,7 +30,7 @@ public class ConfigReader extends YamlConfiguration {
private File file = null; private File file = null;
public ConfigReader(String fileName) throws Exception { public ConfigReader(String fileName) throws Exception {
this(new File(Jobs.getInstance().getDataFolder(), fileName)); this(new File(Jobs.getFolder(), fileName));
} }
public ConfigReader(File file) throws Exception { public ConfigReader(File file) throws Exception {
@ -227,7 +227,7 @@ public class ConfigReader extends YamlConfiguration {
} }
public void saveToBackup() { public void saveToBackup() {
File cc = new File(Jobs.getInstance().getDataFolder(), "FileBackups"); File cc = new File(Jobs.getFolder(), "FileBackups");
if (!cc.isDirectory()) if (!cc.isDirectory())
cc.mkdir(); cc.mkdir();
@ -235,10 +235,10 @@ public class ConfigReader extends YamlConfiguration {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss "); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss ");
String newFileName = dateFormat.format(date) + file.getName(); String newFileName = dateFormat.format(date) + file.getName();
Jobs.consoleMsg("&cFailed to load " + file.getName() + "! Backup have been saved into " + Jobs.getInstance().getDataFolder().getPath() + File.separator + "FileBackups" Jobs.consoleMsg("&cFailed to load " + file.getName() + "! Backup have been saved into " + Jobs.getFolder().getPath() + File.separator + "FileBackups"
+ File.separator + newFileName); + File.separator + newFileName);
File f = new File(Jobs.getInstance().getDataFolder(), "FileBackups" + File.separator + newFileName); File f = new File(Jobs.getFolder(), "FileBackups" + File.separator + newFileName);
// file.renameTo(f); // file.renameTo(f);
try { try {
Files.copy(file, f); Files.copy(file, f);

View File

@ -324,7 +324,7 @@ public class ItemManager {
Magenta(2, "Magenta"), Magenta(2, "Magenta"),
LIGHT_BLUE(3, "Light Blue"), // TODO: Not work, github issue: #267 LIGHT_BLUE(3, "Light Blue"), // TODO: Not work, github issue: #267
Yellow(4, "Yellow"), Yellow(4, "Yellow"),
LIME_GREEN(5, "Lime Green"), // TODO: Not work, github issue: #267 Lime(5, "Lime Green"),
Pink(6, "Pink"), Pink(6, "Pink"),
Gray(7, "Gray"), Gray(7, "Gray"),
LIGHT_GRAY(8, "Light Gray"), // TODO: Not work, github issue: #267 LIGHT_GRAY(8, "Light Gray"), // TODO: Not work, github issue: #267

View File

@ -135,7 +135,6 @@ public class Jobs extends JavaPlugin {
private static Reflections reflections = null; private static Reflections reflections = null;
private static Logger pLogger = null; private static Logger pLogger = null;
private static File dataFolder = null;
private static JobsClassLoader classLoader = null; private static JobsClassLoader classLoader = null;
private static JobsDAO dao = null; private static JobsDAO dao = null;
private static List<Job> jobs = null; private static List<Job> jobs = null;
@ -248,8 +247,8 @@ public class Jobs extends JavaPlugin {
return DBManager; return DBManager;
} }
public static void setShopManager(Jobs plugin) { public static void setShopManager() {
shopManager = new ShopManager(plugin); shopManager = new ShopManager();
} }
public static ShopManager getShopManager() { public static ShopManager getShopManager() {
@ -257,7 +256,7 @@ public class Jobs extends JavaPlugin {
} }
public void setConfigManager() { public void setConfigManager() {
configManager = new ConfigManager(this); configManager = new ConfigManager();
} }
public static ConfigManager getConfigManager() { public static ConfigManager getConfigManager() {
@ -308,16 +307,16 @@ public class Jobs extends JavaPlugin {
return RBManager; return RBManager;
} }
public static void setRestrictedAreaManager(Jobs plugin) { public static void setRestrictedAreaManager() {
RAManager = new RestrictedAreaManager(plugin); RAManager = new RestrictedAreaManager();
} }
public static RestrictedAreaManager getRestrictedAreaManager() { public static RestrictedAreaManager getRestrictedAreaManager() {
return RAManager; return RAManager;
} }
public static void setTitleManager(Jobs plugin) { public static void setTitleManager() {
titleManager = new TitleManager(plugin); titleManager = new TitleManager();
} }
public static TitleManager gettitleManager() { public static TitleManager gettitleManager() {
@ -356,8 +355,8 @@ public class Jobs extends JavaPlugin {
return NameTranslatorManager; return NameTranslatorManager;
} }
public static void setNameTranslatorManager(Jobs plugin) { public static void setNameTranslatorManager() {
NameTranslatorManager = new NameTranslatorManager(plugin); NameTranslatorManager = new NameTranslatorManager();
} }
public static GuiManager getGUIManager() { public static GuiManager getGUIManager() {
@ -428,8 +427,8 @@ public class Jobs extends JavaPlugin {
return lmManager; return lmManager;
} }
public static void setLanguageManager(Jobs plugin) { public static void setLanguageManager() {
lmManager = new LanguageManager(plugin); lmManager = new LanguageManager();
} }
/** /**
@ -447,20 +446,11 @@ public class Jobs extends JavaPlugin {
return pLogger; return pLogger;
} }
/**
* Sets the data folder
* @param dir - the data folder
*/
public void setDataFolder(File dataFolder) {
Jobs.dataFolder = dataFolder;
}
/**
* Retrieves the data folder
* @return data folder
*/
public static File getFolder() { public static File getFolder() {
return dataFolder; File folder = Jobs.getInstance().getDataFolder();
if (!folder.exists())
folder.mkdirs();
return folder;
} }
/** /**
@ -795,7 +785,6 @@ public class Jobs extends JavaPlugin {
setExplore(); setExplore();
setBBManager(); setBBManager();
setPluginLogger(getLogger()); setPluginLogger(getLogger());
setDataFolder(getDataFolder());
setLoging(); setLoging();
setGCManager(); setGCManager();
setConfigManager(); setConfigManager();

View File

@ -62,10 +62,8 @@ import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version; import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
public class ConfigManager { public class ConfigManager {
private Jobs plugin;
public ConfigManager(Jobs plugin) { public ConfigManager() {
this.plugin = plugin;
} }
public void reload() throws IOException { public void reload() throws IOException {
@ -74,7 +72,7 @@ public class ConfigManager {
} }
public void changeJobsSettings(String path, Object value) { public void changeJobsSettings(String path, Object value) {
File f = new File(plugin.getDataFolder(), "jobConfig.yml"); File f = new File(Jobs.getFolder(), "jobConfig.yml");
InputStreamReader s = null; InputStreamReader s = null;
try { try {
s = new InputStreamReader(new FileInputStream(f), "UTF-8"); s = new InputStreamReader(new FileInputStream(f), "UTF-8");
@ -402,7 +400,7 @@ public class ConfigManager {
* @throws IOException * @throws IOException
*/ */
private void loadJobSettings() throws IOException { private void loadJobSettings() throws IOException {
File f = new File(plugin.getDataFolder(), "jobConfig.yml"); File f = new File(Jobs.getFolder(), "jobConfig.yml");
InputStreamReader s = new InputStreamReader(new FileInputStream(f), "UTF-8"); InputStreamReader s = new InputStreamReader(new FileInputStream(f), "UTF-8");
ArrayList<Job> jobs = new ArrayList<>(); ArrayList<Job> jobs = new ArrayList<>();

View File

@ -342,19 +342,19 @@ public class GeneralConfigManager {
Jobs.getJobsDAO().cleanJobs(); Jobs.getJobsDAO().cleanJobs();
Jobs.getJobsDAO().cleanUsers(); Jobs.getJobsDAO().cleanUsers();
// Load locale // Load locale
Jobs.setLanguageManager(this.plugin); Jobs.setLanguageManager();
Jobs.getLanguageManager().load(); Jobs.getLanguageManager().load();
// title settings // title settings
Jobs.setTitleManager(this.plugin); Jobs.setTitleManager();
Jobs.gettitleManager().load(); Jobs.gettitleManager().load();
// restricted areas // restricted areas
Jobs.setRestrictedAreaManager(this.plugin); Jobs.setRestrictedAreaManager();
Jobs.getRestrictedAreaManager().load(); Jobs.getRestrictedAreaManager().load();
// restricted blocks // restricted blocks
Jobs.setRestrictedBlockManager(); Jobs.setRestrictedBlockManager();
Jobs.getRestrictedBlockManager().load(); Jobs.getRestrictedBlockManager().load();
// Item/Block/mobs name list // Item/Block/mobs name list
Jobs.setNameTranslatorManager(this.plugin); Jobs.setNameTranslatorManager();
Jobs.getNameTranslatorManager().load(); Jobs.getNameTranslatorManager().load();
// signs information // signs information
Jobs.setSignUtil(this.plugin); Jobs.setSignUtil(this.plugin);
@ -362,7 +362,7 @@ public class GeneralConfigManager {
// Schedule // Schedule
Jobs.setScheduleManager(this.plugin); Jobs.setScheduleManager(this.plugin);
// Shop // Shop
Jobs.setShopManager(this.plugin); Jobs.setShopManager();
Jobs.getShopManager().load(); Jobs.getShopManager().load();
} }
@ -372,7 +372,7 @@ public class GeneralConfigManager {
* loads from Jobs/generalConfig.yml * loads from Jobs/generalConfig.yml
*/ */
private synchronized void loadGeneralSettings() { private synchronized void loadGeneralSettings() {
File f = new File(plugin.getDataFolder(), "generalConfig.yml"); File f = new File(Jobs.getFolder(), "generalConfig.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
CommentedYamlConfiguration write = new CommentedYamlConfiguration(); CommentedYamlConfiguration write = new CommentedYamlConfiguration();
LocaleReader c = new LocaleReader(conf, write); LocaleReader c = new LocaleReader(conf, write);

View File

@ -2,25 +2,17 @@ package com.gamingmesh.jobs.config;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.LocaleReader; import com.gamingmesh.jobs.container.LocaleReader;
public class LanguageManager { public class LanguageManager {
private Jobs plugin;
public LanguageManager(Jobs plugin) { public LanguageManager() {
this.plugin = plugin;
} }
private List<String> languages = new ArrayList<>(); private List<String> languages = new ArrayList<>();
@ -29,7 +21,7 @@ public class LanguageManager {
return languages; return languages;
} }
public static List<String> getClassesFromPackage(String pckgname, String cleaner) throws ClassNotFoundException { /** public static List<String> getClassesFromPackage(String pckgname, String cleaner) throws ClassNotFoundException {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
try { try {
for (URL jarURL : ((URLClassLoader) Jobs.class.getClassLoader()).getURLs()) { for (URL jarURL : ((URLClassLoader) Jobs.class.getClassLoader()).getURLs()) {
@ -72,7 +64,7 @@ public class LanguageManager {
} }
} }
return listOfCommands; return listOfCommands;
} }*/
/** /**
* Method to load the language file configuration * Method to load the language file configuration
@ -81,29 +73,31 @@ public class LanguageManager {
*/ */
synchronized void load() { synchronized void load() {
languages = new ArrayList<>(); languages = new ArrayList<>();
/** try {
try {
languages.addAll(getClassesFromPackage("locale", "messages_")); languages.addAll(getClassesFromPackage("locale", "messages_"));
} catch (ClassNotFoundException e1) { } catch (ClassNotFoundException e) {
e1.printStackTrace(); e.printStackTrace();
} }*/
String ls = Jobs.getGCManager().localeString; String ls = Jobs.getGCManager().localeString;
if (ls == null || ls.equals(""))
return;
languages.clear(); languages.clear();
languages.add("en"); languages.add("en");
File customLocaleFile = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + ls + ".yml"); File customLocaleFile = new File(Jobs.getFolder(), "locale" + File.separator + "messages_" + ls + ".yml");
if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en")) if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en"))
languages.add(ls); languages.add(ls);
for (String lang : languages) { for (String lang : languages) {
File f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml"); File f = new File(Jobs.getFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
// Fail safe if file get corrupted and being created with corrupted data, we need to recreate it // Fail safe if file get corrupted and being created with corrupted data, we need to recreate it
if ((f.length() / 1024) > 1024) { if ((f.length() / 1024) > 1024) {
f.delete(); f.delete();
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml"); f = new File(Jobs.getFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
} }
YamlConfiguration config = YamlConfiguration.loadConfiguration(f); YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
@ -196,8 +190,8 @@ public class LanguageManager {
c.get("command.itembonus.output.list", "&e[jobname]: %money% %points% %exp%"); c.get("command.itembonus.output.list", "&e[jobname]: %money% %points% %exp%");
c.get("command.edititembonus.help.info", "Edit item boost bonus"); c.get("command.edititembonus.help.info", "Edit item boost bonus");
c.get("command.edititembonus.help.args", "[list/add/remove] [jobname] [itemBoostName]"); c.get("command.edititembonus.help.args", "list/add/remove [jobname] [itemBoostName]");
Jobs.getGCManager().commandArgs.put("edititembonus", Arrays.asList("[list%%add%%remove]", "[jobname]", "[jobitemname]")); Jobs.getGCManager().commandArgs.put("edititembonus", Arrays.asList("list%%add%%remove", "[jobname]", "[jobitemname]"));
c.get("command.bonus.help.info", "Show job bonuses"); c.get("command.bonus.help.info", "Show job bonuses");
c.get("command.bonus.help.args", "[jobname]"); c.get("command.bonus.help.args", "[jobname]");
@ -252,8 +246,8 @@ public class LanguageManager {
c.get("command.points.totalpoints", " &eTotal amount of collected points until now: &6%totalpoints%"); c.get("command.points.totalpoints", " &eTotal amount of collected points until now: &6%totalpoints%");
c.get("command.editpoints.help.info", "Edit players points."); c.get("command.editpoints.help.info", "Edit players points.");
c.get("command.editpoints.help.args", "[set/add/take] [playername] [amount]"); c.get("command.editpoints.help.args", "set/add/take [playername] [amount]");
Jobs.getGCManager().commandArgs.put("editpoints", Arrays.asList("[set%%add%%take]", "[playername]")); Jobs.getGCManager().commandArgs.put("editpoints", Arrays.asList("set%%add%%take", "[playername]"));
c.get("command.editpoints.output.set", "&ePlayers (&6%playername%&e) points was set to &6%amount%"); c.get("command.editpoints.output.set", "&ePlayers (&6%playername%&e) points was set to &6%amount%");
c.get("command.editpoints.output.add", "&ePlayer (&6%playername%&e) got aditinal &6%amount% &epoints. Now he has &6%total%"); c.get("command.editpoints.output.add", "&ePlayer (&6%playername%&e) got aditinal &6%amount% &epoints. Now he has &6%total%");
c.get("command.editpoints.output.take", "&ePlayer (&6%playername%&e) lost &6%amount% &epoints. Now he has &6%total%"); c.get("command.editpoints.output.take", "&ePlayer (&6%playername%&e) lost &6%amount% &epoints. Now he has &6%total%");
@ -507,8 +501,8 @@ public class LanguageManager {
c.get("command.gtop.output.show", "&2Show from &e[from] &2until &e[until] &2global top list"); c.get("command.gtop.output.show", "&2Show from &e[from] &2until &e[until] &2global top list");
c.get("command.area.help.info", "Modify restricted areas."); c.get("command.area.help.info", "Modify restricted areas.");
c.get("command.area.help.args", "[add/remove/info/list]"); c.get("command.area.help.args", "add/remove/info/list");
Jobs.getGCManager().commandArgs.put("area", Arrays.asList("[add%%remove%%info%%list]")); Jobs.getGCManager().commandArgs.put("area", Arrays.asList("add%%remove%%info%%list"));
c.get("command.area.help.addUsage", "&eUsage: &6/Jobs area add [areaName/wg:worldGuardAreaName] [bonus]"); c.get("command.area.help.addUsage", "&eUsage: &6/Jobs area add [areaName/wg:worldGuardAreaName] [bonus]");
c.get("command.area.help.removeUsage", "&eUsage: &6/Jobs area remove [areaName]"); c.get("command.area.help.removeUsage", "&eUsage: &6/Jobs area remove [areaName]");
c.get("command.area.output.addedNew", "&eAdded new restricted area with &6%bonus% &ebonus"); c.get("command.area.output.addedNew", "&eAdded new restricted area with &6%bonus% &ebonus");
@ -559,8 +553,8 @@ public class LanguageManager {
c.get("command.promote.output.target", "You have been promoted %levelsgained% levels in %jobname%."); c.get("command.promote.output.target", "You have been promoted %levelsgained% levels in %jobname%.");
c.get("command.exp.help.info", "Change the player exp for job."); c.get("command.exp.help.info", "Change the player exp for job.");
c.get("command.exp.help.args", "[playername] [jobname] [set/add/take] [amount]"); c.get("command.exp.help.args", "[playername] [jobname] set/add/take [amount]");
Jobs.getGCManager().commandArgs.put("exp", Arrays.asList("[playername]", "[jobname]", "[set%%add%%take]")); Jobs.getGCManager().commandArgs.put("exp", Arrays.asList("[playername]", "[jobname]", "set%%add%%take"));
c.get("command.exp.output.target", "&eYour exp was changed for %jobname% &eand now you at &6%level%lvl &eand with &6%exp%exp."); c.get("command.exp.output.target", "&eYour exp was changed for %jobname% &eand now you at &6%level%lvl &eand with &6%exp%exp.");
c.get("command.demote.help.info", "Demote the player X levels in a job."); c.get("command.demote.help.info", "Demote the player X levels in a job.");
@ -590,8 +584,8 @@ public class LanguageManager {
c.get("command.reload.help.info", "Reload configurations."); c.get("command.reload.help.info", "Reload configurations.");
c.get("command.toggle.help.info", "Toggles payment output on action bar or bossbar."); c.get("command.toggle.help.info", "Toggles payment output on action bar or bossbar.");
c.get("command.toggle.help.args", "[actionbar/bossbar]"); c.get("command.toggle.help.args", "actionbar/bossbar");
Jobs.getGCManager().commandArgs.put("toggle", Arrays.asList("[actionbar%%bossbar]")); Jobs.getGCManager().commandArgs.put("toggle", Arrays.asList("actionbar%%bossbar"));
c.get("command.toggle.output.turnedoff", "&4This feature are turned off!"); c.get("command.toggle.output.turnedoff", "&4This feature are turned off!");
c.get("command.toggle.output.paid.main", "&aYou got:"); c.get("command.toggle.output.paid.main", "&aYou got:");
c.get("command.toggle.output.paid.money", "&e[amount] money"); c.get("command.toggle.output.paid.money", "&e[amount] money");

View File

@ -18,16 +18,13 @@ import com.gamingmesh.jobs.container.NameList;
public class NameTranslatorManager { public class NameTranslatorManager {
private Jobs plugin;
public ArrayList<NameList> ListOfNames = new ArrayList<>(); public ArrayList<NameList> ListOfNames = new ArrayList<>();
public ArrayList<NameList> ListOfPotionNames = new ArrayList<>(); public ArrayList<NameList> ListOfPotionNames = new ArrayList<>();
public ArrayList<NameList> ListOfEntities = new ArrayList<>(); public ArrayList<NameList> ListOfEntities = new ArrayList<>();
public ArrayList<NameList> ListOfEnchants = new ArrayList<>(); public ArrayList<NameList> ListOfEnchants = new ArrayList<>();
public ArrayList<NameList> ListOfColors = new ArrayList<>(); public ArrayList<NameList> ListOfColors = new ArrayList<>();
public NameTranslatorManager(Jobs plugin) { public NameTranslatorManager() {
this.plugin = plugin;
} }
public String Translate(String materialName, JobInfo info) { public String Translate(String materialName, JobInfo info) {
@ -134,7 +131,7 @@ public class NameTranslatorManager {
} }
public void readFile() { public void readFile() {
YmlMaker ItemFile = new YmlMaker(plugin, "TranslatableWords" + File.separator + "Words_" + Jobs.getGCManager().localeString + ".yml"); YmlMaker ItemFile = new YmlMaker(Jobs.getInstance(), "TranslatableWords" + File.separator + "Words_" + Jobs.getGCManager().localeString + ".yml");
ItemFile.saveDefaultConfig(); ItemFile.saveDefaultConfig();
if (ItemFile.getConfig().isConfigurationSection("ItemList")) { if (ItemFile.getConfig().isConfigurationSection("ItemList")) {
@ -228,35 +225,35 @@ public class NameTranslatorManager {
if (ls == null || ls.equals("")) if (ls == null || ls.equals(""))
return; return;
File file = new File(plugin.getDataFolder(), "TranslatableWords.yml"); File file = new File(Jobs.getFolder(), "TranslatableWords.yml");
File file2 = new File(plugin.getDataFolder(), "TranslatableWords" + File.separator + "Words_" + ls + ".yml"); File file2 = new File(Jobs.getFolder(), "TranslatableWords" + File.separator + "Words_" + ls + ".yml");
if (file.exists()) if (file.exists())
file.renameTo(file2); file.renameTo(file2);
// Just copying default language files, except en, that one will be generated // Just copying default language files, except en, that one will be generated
List<String> languages = new ArrayList<>(); List<String> languages = new ArrayList<>();
try { /** try {
languages.addAll(LanguageManager.getClassesFromPackage("TranslatableWords", "Words_")); languages.addAll(LanguageManager.getClassesFromPackage("TranslatableWords", "Words_"));
} catch (ClassNotFoundException e1) { } catch (ClassNotFoundException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }*/
languages.clear(); languages.clear();
languages.add("en"); languages.add("en");
File customLocaleFile = new File(plugin.getDataFolder(), "TranslatableWords" + File.separator + "Words_" + ls + ".yml"); File customLocaleFile = new File(Jobs.getFolder(), "TranslatableWords" + File.separator + "Words_" + ls + ".yml");
if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en")) if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en"))
languages.add(ls); languages.add(ls);
for (String lang : languages) { for (String lang : languages) {
File f = new File(plugin.getDataFolder(), "TranslatableWords" + File.separator + "Words_" + lang + ".yml"); File f = new File(Jobs.getFolder(), "TranslatableWords" + File.separator + "Words_" + lang + ".yml");
// Fail safe if file get corrupted and being created with corrupted data, we need to recreate it // Fail safe if file get corrupted and being created with corrupted data, we need to recreate it
if ((f.length() / 1024) > 1024) { if ((f.length() / 1024) > 1024) {
f.delete(); f.delete();
f = new File(plugin.getDataFolder(), "TranslatableWords" + File.separator + "Words_" + lang + ".yml"); f = new File(Jobs.getFolder(), "TranslatableWords" + File.separator + "Words_" + lang + ".yml");
} }
YamlConfiguration config = YamlConfiguration.loadConfiguration(f); YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
@ -429,7 +426,7 @@ public class NameTranslatorManager {
c.get("ColorList.2-magenta", "&dMagenta"); c.get("ColorList.2-magenta", "&dMagenta");
c.get("ColorList.3-LIGHT_BLUE", "&9Light blue"); c.get("ColorList.3-LIGHT_BLUE", "&9Light blue");
c.get("ColorList.4-yellow", "&eYellow"); c.get("ColorList.4-yellow", "&eYellow");
c.get("ColorList.5-LIME_GREEN", "&aLime"); c.get("ColorList.5-lime", "&aLime");
c.get("ColorList.6-pink", "&dPink"); c.get("ColorList.6-pink", "&dPink");
c.get("ColorList.7-gray", "&8Gray"); c.get("ColorList.7-gray", "&8Gray");
c.get("ColorList.8-LIGHT_GRAY", "&7Light gray"); c.get("ColorList.8-LIGHT_GRAY", "&7Light gray");

View File

@ -170,7 +170,7 @@ public class ScheduleManager {
* loads from Jobs/schedule.yml * loads from Jobs/schedule.yml
*/ */
public void load() { public void load() {
File f = new File(plugin.getDataFolder(), "schedule.yml"); File f = new File(Jobs.getFolder(), "schedule.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().copyDefaults(true); conf.options().copyDefaults(true);

View File

@ -33,12 +33,10 @@ import com.gamingmesh.jobs.container.ShopItem;
import com.gamingmesh.jobs.stuff.Perm; import com.gamingmesh.jobs.stuff.Perm;
public class ShopManager { public class ShopManager {
private Jobs plugin;
public List<ShopItem> list = new ArrayList<>(); public List<ShopItem> list = new ArrayList<>();
public HashMap<String, Integer> GuiList = new HashMap<>(); public HashMap<String, Integer> GuiList = new HashMap<>();
public ShopManager(Jobs plugin) { public ShopManager() {
this.plugin = plugin;
} }
public List<ShopItem> getShopItemList() { public List<ShopItem> getShopItemList() {
@ -310,7 +308,7 @@ public class ShopManager {
skullMeta.setDisplayName(item.getIconName()); skullMeta.setDisplayName(item.getIconName());
skullMeta.setLore(Lore); skullMeta.setLore(Lore);
if (item.getCustomHeadOwner()) if (item.isHeadOwner())
skullMeta.setOwner(Jobs.getPlayerManager().getJobsPlayer(player).getUserName()); skullMeta.setOwner(Jobs.getPlayerManager().getJobsPlayer(player).getUserName());
else { else {
try { try {
@ -350,7 +348,7 @@ public class ShopManager {
public void load() { public void load() {
list.clear(); list.clear();
File file = new File(plugin.getDataFolder(), "shopItems.yml"); File file = new File(Jobs.getFolder(), "shopItems.yml");
YamlConfiguration f = YamlConfiguration.loadConfiguration(file); YamlConfiguration f = YamlConfiguration.loadConfiguration(file);
if (!f.isConfigurationSection("Items")) if (!f.isConfigurationSection("Items"))

View File

@ -17,10 +17,7 @@ public class TitleManager {
protected List<Title> titles = new ArrayList<>(); protected List<Title> titles = new ArrayList<>();
private Jobs plugin; public TitleManager() {
public TitleManager(Jobs plugin) {
this.plugin = plugin;
} }
/** /**
@ -52,7 +49,7 @@ public class TitleManager {
synchronized void load() { synchronized void load() {
this.titles.clear(); this.titles.clear();
File f = new File(plugin.getDataFolder(), "titleConfig.yml"); File f = new File(Jobs.getFolder(), "titleConfig.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(f); YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); CommentedYamlConfiguration writer = new CommentedYamlConfiguration();

View File

@ -154,7 +154,7 @@ public class ShopItem {
this.PlayerName = PlayerName; this.PlayerName = PlayerName;
} }
public boolean getCustomHeadOwner() { public boolean isHeadOwner() {
return useCurrentPlayer; return useCurrentPlayer;
} }

View File

@ -163,13 +163,14 @@ public class JobsListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
Location loc = null;
if (event.getAction() == Action.LEFT_CLICK_BLOCK) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
Location loc = block.getLocation(); loc = block.getLocation();
Jobs.getSelectionManager().placeLoc1(player, loc); Jobs.getSelectionManager().placeLoc1(player, loc);
player.sendMessage(Jobs.getLanguage().getMessage("command.area.output.selected1", "%x%", loc.getBlockX(), "%y%", loc.getBlockY(), "%z%", loc.getBlockZ())); player.sendMessage(Jobs.getLanguage().getMessage("command.area.output.selected1", "%x%", loc.getBlockX(), "%y%", loc.getBlockY(), "%z%", loc.getBlockZ()));
event.setCancelled(true); event.setCancelled(true);
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location loc = block.getLocation(); loc = block.getLocation();
Jobs.getSelectionManager().placeLoc2(player, loc); Jobs.getSelectionManager().placeLoc2(player, loc);
player.sendMessage(Jobs.getLanguage().getMessage("command.area.output.selected2", "%x%", loc.getBlockX(), "%y%", loc.getBlockY(), "%z%", loc.getBlockZ())); player.sendMessage(Jobs.getLanguage().getMessage("command.area.output.selected2", "%x%", loc.getBlockX(), "%y%", loc.getBlockY(), "%z%", loc.getBlockZ()));
event.setCancelled(true); event.setCancelled(true);
@ -209,9 +210,8 @@ public class JobsListener implements Listener {
public void onShopGuiClose(InventoryCloseEvent event) { public void onShopGuiClose(InventoryCloseEvent event) {
if (Jobs.getShopManager().GuiList.isEmpty()) if (Jobs.getShopManager().GuiList.isEmpty())
return; return;
Player player = (Player) event.getPlayer(); if (Jobs.getShopManager().GuiList.containsKey(event.getPlayer().getName())) {
if (Jobs.getShopManager().GuiList.containsKey(player.getName())) { Jobs.getShopManager().GuiList.remove(event.getPlayer().getName());
Jobs.getShopManager().GuiList.remove(player.getName());
} }
} }
@ -219,8 +219,7 @@ public class JobsListener implements Listener {
public void onGuiClose(InventoryCloseEvent event) { public void onGuiClose(InventoryCloseEvent event) {
if (Jobs.getGUIManager().GuiList.isEmpty()) if (Jobs.getGUIManager().GuiList.isEmpty())
return; return;
Player player = (Player) event.getPlayer(); Jobs.getGUIManager().GuiList.remove(event.getPlayer().getUniqueId());
Jobs.getGUIManager().GuiList.remove(player.getUniqueId());
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -831,7 +830,6 @@ public class JobsListener implements Listener {
@EventHandler @EventHandler
public void playerInteractEvent(PlayerInteractEvent event) { public void playerInteractEvent(PlayerInteractEvent event) {
Action action = event.getAction(); Action action = event.getAction();
if (action == Action.PHYSICAL) if (action == Action.PHYSICAL)
return; return;

View File

@ -74,14 +74,14 @@ command:
infostats: '&c-----> &aPontszám x%boost% engedélyezve&c <-------' infostats: '&c-----> &aPontszám x%boost% engedélyezve&c <-------'
expboost: expboost:
help: help:
info: 'Növeli az összes játékos nyereségét.' info: 'Növeli az összes játékos xp nyereségét.'
args: '[jobname] [arány]' args: '[jobname] [arány]'
output: output:
allreset: '&aMinden tapasztalat növelés kikapcsolva.' allreset: '&aMinden tapasztalat növelés kikapcsolva.'
jobsboostreset: '&cTapasztalat lendület a(z) %jobname% munkánál kikapcsolva.' jobsboostreset: '&cTapasztalat lendület a(z) %jobname% munkánál kikapcsolva.'
nothingtoreset: '&cSemmi nem állítható vissza.' nothingtoreset: '&cSemmi nem állítható vissza.'
boostalladded: '&aTapasztalat növelése %boost% minden munkához hozzáadva!' boostalladded: '&aTapasztalat növelése %boost% minden munkához hozzáadva!'
boostadded: '&aTapasztalat növelése &e%boost% &ahozzáadva &e%jobname% &amunkához!' boostadded: '&aTapasztalat növelése &e%boost% &ahozzáadva a(z) &e%jobname% &amunkához!'
infostats: '&c-----> &aTapasztalat arány x%boost% engedélyezve&c <-------' infostats: '&c-----> &aTapasztalat arány x%boost% engedélyezve&c <-------'
bonus: bonus:
help: help:
@ -151,9 +151,9 @@ command:
editpoints: editpoints:
help: help:
info: 'Játékos pontok szerkesztése.' info: 'Játékos pontok szerkesztése.'
args: '[set/add/take] [playername] [összeg]' args: 'set/add/take [playername] [összeg]'
output: output:
set: '&e(&6%playername%&e) játékosnak pont beállítva &6%amount%' set: '&e(&6%playername%&e) játékosnak &6%amount%&e pont beállítva'
add: '&e(&6%playername%&e) játékosnak van további &6%amount% &epontja. Most van &6%total%' add: '&e(&6%playername%&e) játékosnak van további &6%amount% &epontja. Most van &6%total%'
take: '&e(&6%playername%&e) játékos vesztett &6%amount% &epontot. Most van &6%total%' take: '&e(&6%playername%&e) játékos vesztett &6%amount% &epontot. Most van &6%total%'
editjobs: editjobs:
@ -180,7 +180,7 @@ command:
lookHover: '&6A bal gombbal kattintva információt kapsz a blokkról, amit keresel.' lookHover: '&6A bal gombbal kattintva információt kapsz a blokkról, amit keresel.'
blockinfo: blockinfo:
help: help:
info: 'Megjeleníti a megtekinteni kívánt blokkadatokat.' info: 'Megjeleníti az éppen látótérben lévő blokk adatokat.'
args: '' args: ''
output: output:
name: ' &eBlokk név: &6%blockname%' name: ' &eBlokk név: &6%blockname%'
@ -215,7 +215,7 @@ command:
title: '&e------- &8Munkák piac &e-------' title: '&e------- &8Munkák piac &e-------'
currentPoints: '&eNeked van: &6%currentpoints%' currentPoints: '&eNeked van: &6%currentpoints%'
price: '&eEgyenleg: &6%price%' price: '&eEgyenleg: &6%price%'
reqJobs: '&eKötelező munkák:' reqJobs: '&eSzükséges munkák:'
reqJobsList: ' &6%jobsname%&e: &e%level% lvl' reqJobsList: ' &6%jobsname%&e: &e%level% lvl'
reqTotalLevel: '&6Szükséges teljes szint: &e%totalLevel%' reqTotalLevel: '&6Szükséges teljes szint: &e%totalLevel%'
cantOpen: '&cNem nyithatod meg ezt az oldalt!' cantOpen: '&cNem nyithatod meg ezt az oldalt!'
@ -249,7 +249,7 @@ command:
args: '[jobname] [action]' args: '[jobname] [action]'
actions: '&eÉrvényes akciók: &f%actions%' actions: '&eÉrvényes akciók: &f%actions%'
max: ' - &eMax. szint:&f ' max: ' - &eMax. szint:&f '
newMax: '&eMaximális szint: &f[max]' newMax: ' &eMaximális szint: &f[max]'
material: '&7%material%' material: '&7%material%'
levelRange: ' &a(&e%levelFrom% &a- &e%levelUntil% &aszintek)' levelRange: ' &a(&e%levelFrom% &a- &e%levelUntil% &aszintek)'
levelFrom: ' &a(&e%levelFrom% &aszint)' levelFrom: ' &a(&e%levelFrom% &aszint)'
@ -306,7 +306,7 @@ command:
none: '%jobname%&c nem kap pénzt, ha fest.' none: '%jobname%&c nem kap pénzt, ha fest.'
enchant: enchant:
info: '&eVarázs' info: '&eVarázs'
none: '%jobname%&c nem kap pénzt, ha varázsól.' none: '%jobname%&c nem kap pénzt, ha varázsol.'
vtrade: vtrade:
info: '&eFalusi kereskedelem' info: '&eFalusi kereskedelem'
none: '%jobname%&c nem kap pénzt, ha kereskedik egy falusival.' none: '%jobname%&c nem kap pénzt, ha kereskedik egy falusival.'
@ -343,7 +343,7 @@ command:
alreadyin: '&cMár csatlakoztál a(z) %jobname%&c munkához!' alreadyin: '&cMár csatlakoztál a(z) %jobname%&c munkához!'
fullslots: '&cNem tudsz csatlakozni a(z) %jobname%&c munkához, mert nincsenek rendelkezésre álló helyek.' fullslots: '&cNem tudsz csatlakozni a(z) %jobname%&c munkához, mert nincsenek rendelkezésre álló helyek.'
maxjobs: '&cMár túl sok munkát vállaltál.' maxjobs: '&cMár túl sok munkát vállaltál.'
rejoin: '&cNem csatlakozhatsz ebbe a munkába. Várj [time].' rejoin: '&cNem csatlakozhatsz ebbe a munkába időintervallum miatt. Várj [time].'
rejoin: '&aKattints ide, hogy újra csatlakozz ebbe a munkába: ' rejoin: '&aKattints ide, hogy újra csatlakozz ebbe a munkába: '
success: '&aSikeresen csatlakoztál a(z) %jobname%&a munkához!' success: '&aSikeresen csatlakoztál a(z) %jobname%&a munkához!'
confirm: '&2Kattints ide, hogy a(z) &7[jobname]&2 munkát megerősítse.' confirm: '&2Kattints ide, hogy a(z) &7[jobname]&2 munkát megerősítse.'
@ -362,7 +362,7 @@ command:
help: help:
info: 'Ellenőrzi, ki látogatta meg ezt a darabot.' info: 'Ellenőrzi, ki látogatta meg ezt a darabot.'
error: error:
noexplore: '&cSenki nem látogatta meg ezt a darabot.' noexplore: '&cSenki sem látogatta meg ezt a darabot.'
list: '&a%place%. %playername%' list: '&a%place%. %playername%'
browse: browse:
help: help:
@ -459,11 +459,11 @@ command:
list: '&e%number%&a. &e%playername% &alvl &e%level%&e %exp% &aexp' list: '&e%number%&a. &e%playername% &alvl &e%level%&e %exp% &aexp'
prev: '&e<<< Előző oldal &2|' prev: '&e<<< Előző oldal &2|'
next: '&2|&e Következő oldal >>>' next: '&2|&e Következő oldal >>>'
show: '&2Megjelenítés innen &e[from]&2, amíg &e[until] &2a globális top lista.' show: '&2Megjelenítés &e[from]&2-tól/-től, &e[until]&2-ig &2a globális top listán.'
area: area:
help: help:
info: 'Korlátozott területek módosítása.' info: 'Korlátozott területek módosítása.'
args: '[add/remove/info/list]' args: 'add/remove/info/list'
addUsage: '&eHasználat: &6/Jobs area add [arénanév/wg:worldGuardarénanév] [bónusz]' addUsage: '&eHasználat: &6/Jobs area add [arénanév/wg:worldGuardarénanév] [bónusz]'
removeUsage: '&eHasználat: &6/Jobs area remove [arénanév]' removeUsage: '&eHasználat: &6/Jobs area remove [arénanév]'
output: output:
@ -508,7 +508,7 @@ command:
info: 'A játékos munkájának áthelyezése régi munkáról egy új munkába.' info: 'A játékos munkájának áthelyezése régi munkáról egy új munkába.'
args: '[playername] [oldjob] [newjob]' args: '[playername] [oldjob] [newjob]'
output: output:
target: '&cÁtkerültél %oldjobname%&c munkából a(z) %newjobname%&c munkába.' target: '&cÁtkerültél a(z) %oldjobname%&c munkából a(z) %newjobname%&c munkába.'
promote: promote:
help: help:
info: 'Támogasd a játékos X szintjét egy munkában.' info: 'Támogasd a játékos X szintjét egy munkában.'
@ -518,7 +518,7 @@ command:
exp: exp:
help: help:
info: 'Módosítsa a játékos tapasztalat feladatát.' info: 'Módosítsa a játékos tapasztalat feladatát.'
args: '[playername] [jobname] [set/add/take] [amount]' args: '[playername] [jobname] set/add/take [amount]'
output: output:
target: '&eA tapasztalat változott %jobname%&e, most van &6%level%lvl &eés &6%exp%&eexp.' target: '&eA tapasztalat változott %jobname%&e, most van &6%level%lvl &eés &6%exp%&eexp.'
demote: demote:
@ -556,7 +556,7 @@ command:
toggle: toggle:
help: help:
info: 'A fizetős kimenet a cselekvési sávon (actionbar) vagy a bossbar-on.' info: 'A fizetős kimenet a cselekvési sávon (actionbar) vagy a bossbar-on.'
args: '[actionbar/bossbar]' args: 'actionbar/bossbar'
output: output:
turnedoff: '&4Ez a funkció ki van kapcsolva!' turnedoff: '&4Ez a funkció ki van kapcsolva!'
paid: paid:
@ -575,7 +575,7 @@ command:
edititembonus: edititembonus:
help: help:
info: 'Tárgybónusz szerkesztése.' info: 'Tárgybónusz szerkesztése.'
args: '[list/add/remove] [jobname] [itemBoostName]' args: 'list/add/remove [jobname] [itemBoostName]'
message: message:
skillup: skillup:
broadcast: '%playername% játékost előléptették a %titlename% %jobname% munkában.' broadcast: '%playername% játékost előléptették a %titlename% %jobname% munkában.'