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

Trying to follow naming conventions and some cleanup

This commit is contained in:
montlikadani 2021-03-10 19:14:52 +01:00
parent ab38a64fb4
commit fc5c5bfd08
48 changed files with 441 additions and 544 deletions

View File

@ -27,7 +27,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
public class GuiManager {
public void openJobsBrowseGUI(final Player player) {
ArrayList<Job> jobsList = new ArrayList<>();
List<Job> jobsList = new ArrayList<>();
for (Job job : Jobs.getJobs()) {
if (Jobs.getGCManager().getHideJobsWithoutPermission())
if (!Jobs.getCommandManager().hasJobPermission(player, job))
@ -102,9 +102,7 @@ public class GuiManager {
lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
if (job.getDescription().isEmpty()) {
for (String desc : job.getFullDescription()) {
lore.add(desc);
}
lore.addAll(job.getFullDescription());
} else
lore.addAll(Arrays.asList(job.getDescription().split("/n|\\n")));
@ -209,7 +207,7 @@ public class GuiManager {
if (info == null || info.isEmpty())
continue;
ArrayList<String> lore = new ArrayList<>();
List<String> lore = new ArrayList<>();
lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
int y = 1;

View File

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

View File

@ -251,7 +251,7 @@ public class Jobs extends JavaPlugin {
public static ShopManager getShopManager() {
if (shopManager == null) {
shopManager = new ShopManager();
shopManager = new ShopManager(instance);
}
return shopManager;
}
@ -396,7 +396,7 @@ public class Jobs extends JavaPlugin {
*/
public static Language getLanguage() {
if (lManager == null)
lManager = new Language(instance);
lManager = new Language();
return lManager;
}

View File

@ -65,7 +65,7 @@ public class PermissionHandler {
if (hasWorldPermission(player)) {
List<JobProgression> progression = jPlayer.getJobProgression();
// calculate new permissions
HashMap<String, Boolean> permissions = new HashMap<>();
java.util.Map<String, Boolean> permissions = new HashMap<>();
if (progression.isEmpty()) {
Job job = Jobs.getNoneJob();
@ -85,17 +85,17 @@ public class PermissionHandler {
}
}
for (JobConditions Condition : job.getConditions()) {
for (JobConditions condition : job.getConditions()) {
boolean ok = true;
for (String oneReq : Condition.getRequiredPerm()) {
for (String oneReq : condition.getRequiredPerm()) {
if (!player.hasPermission(oneReq)) {
ok = false;
break;
}
}
for (Entry<String, Integer> oneReq : Condition.getRequiredJobs().entrySet()) {
for (Entry<String, Integer> oneReq : condition.getRequiredJobs().entrySet()) {
String jobName = oneReq.getKey();
int jobLevel = oneReq.getValue();
boolean found = false;
@ -116,7 +116,7 @@ public class PermissionHandler {
if (!ok)
continue;
for (Entry<String, Boolean> one : Condition.getPerformPerm().entrySet()) {
for (Entry<String, Boolean> one : condition.getPerformPerm().entrySet()) {
String perm = one.getKey();
boolean node = one.getValue();
if (node)
@ -151,17 +151,17 @@ public class PermissionHandler {
}
}
for (JobConditions Condition : prog.getJob().getConditions()) {
for (JobConditions condition : prog.getJob().getConditions()) {
boolean ok = true;
for (String oneReq : Condition.getRequiredPerm()) {
for (String oneReq : condition.getRequiredPerm()) {
if (!player.hasPermission(oneReq)) {
ok = false;
break;
}
}
for (Entry<String, Integer> oneReq : Condition.getRequiredJobs().entrySet()) {
for (Entry<String, Integer> oneReq : condition.getRequiredJobs().entrySet()) {
String jobName = oneReq.getKey();
int jobLevel = oneReq.getValue();
boolean found = false;
@ -183,7 +183,7 @@ public class PermissionHandler {
if (!ok)
continue;
for (Entry<String, Boolean> one : Condition.getPerformPerm().entrySet()) {
for (Entry<String, Boolean> one : condition.getPerformPerm().entrySet()) {
String perm = one.getKey();
boolean node = one.getValue();
if (node)

View File

@ -32,7 +32,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
public class PermissionManager {
private final HashMap<String, Integer> permDelay = new HashMap<>();
private final Map<String, Integer> permDelay = new HashMap<>();
private enum prm {
// jobs_join_JOBNAME(remade("jobs.join.%JOBNAME%"), 60 * 1000),
@ -106,8 +106,8 @@ public class PermissionManager {
}
}
private static HashMap<String, Boolean> getAll(Player player) {
HashMap<String, Boolean> mine = new HashMap<>();
private static Map<String, Boolean> getAll(Player player) {
Map<String, Boolean> mine = new HashMap<>();
for (PermissionAttachmentInfo permission : player.getEffectivePermissions()) {
if (permission.getPermission().startsWith("jobs."))
mine.put(permission.getPermission(), permission.getValue());
@ -160,7 +160,7 @@ public class PermissionManager {
if (!perm.endsWith("."))
perm += ".";
HashMap<String, Boolean> permissions = jPlayer.getPermissionsCache();
Map<String, Boolean> permissions = jPlayer.getPermissionsCache();
if (force || permissions == null || getDelay(perm) + jPlayer.getLastPermissionUpdate() < System.currentTimeMillis()) {
permissions = getAll(jPlayer.getPlayer());
jPlayer.setPermissionsCache(permissions);
@ -190,7 +190,7 @@ public class PermissionManager {
if (jPlayer == null || jPlayer.getPlayer() == null)
return false;
HashMap<String, Boolean> permissions = jPlayer.getPermissionsCache();
Map<String, Boolean> permissions = jPlayer.getPermissionsCache();
if (permissions == null || getDelay(perm) + jPlayer.getLastPermissionUpdate() < System.currentTimeMillis()) {
permissions = getAll(jPlayer.getPlayer());
jPlayer.setPermissionsCache(permissions);

View File

@ -20,13 +20,11 @@ public class ChatFilterRule {
return id;
}
}
private String replaceWith;
private String replaceWith, ruleName, messageToStaff, group;
private ChatFilterBlockType blockType;
private String ruleName;
private List<Pattern> pattern = new ArrayList<>();
private String messageToStaff;
private List<String> commands = new ArrayList<>();
private String group;
private final List<Pattern> pattern = new ArrayList<>();
private List<String> commands;
public ChatFilterRule(String ruleName, String group, List<String> list, String replaceWith, ChatFilterBlockType blockType, String messageToStaff, List<String> commands) {
this.group = group;

View File

@ -30,7 +30,9 @@ import com.gamingmesh.jobs.stuff.TimeManage;
public class Placeholder {
private Jobs plugin;
Pattern placeholderPatern = Pattern.compile("(%)([^\"^%]*)(%)");
private final AtomicInteger jobLevel = new AtomicInteger();
private final Pattern placeholderPatern = Pattern.compile("(%)([^\"^%]*)(%)");
public Placeholder(Jobs plugin) {
this.plugin = plugin;
@ -330,8 +332,6 @@ public class Placeholder {
return message;
}
private final AtomicInteger jobLevel = new AtomicInteger();
private String translateOwnPlaceHolder(Player player, String message) {
if (message == null)
return null;
@ -342,8 +342,7 @@ public class Placeholder {
if (!message.contains("%"))
break;
String cmd = match.group(2);
JobsPlaceHolders place = JobsPlaceHolders.getByNameExact(cmd);
JobsPlaceHolders place = JobsPlaceHolders.getByNameExact(match.group(2));
if (place == null)
continue;

View File

@ -22,8 +22,10 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern;
@ -69,16 +71,16 @@ import com.gamingmesh.jobs.stuff.Util;
public class PlayerManager {
private final ConcurrentHashMap<String, JobsPlayer> playersCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<UUID, JobsPlayer> playersUUIDCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<>();
private final ConcurrentHashMap<UUID, JobsPlayer> playersUUID = new ConcurrentHashMap<>();
private final ConcurrentMap<String, JobsPlayer> playersCache = new ConcurrentHashMap<>();
private final ConcurrentMap<UUID, JobsPlayer> playersUUIDCache = new ConcurrentHashMap<>();
private final ConcurrentMap<String, JobsPlayer> players = new ConcurrentHashMap<>();
private final ConcurrentMap<UUID, JobsPlayer> playersUUID = new ConcurrentHashMap<>();
private final String mobSpawnerMetadata = "jobsMobSpawner";
private final HashMap<UUID, PlayerInfo> PlayerUUIDMap = new HashMap<>();
private final HashMap<Integer, PlayerInfo> PlayerIDMap = new HashMap<>();
private final HashMap<String, PlayerInfo> PlayerNameMap = new HashMap<>();
private final Map<UUID, PlayerInfo> playerUUIDMap = new HashMap<>();
private final Map<Integer, PlayerInfo> playerIdMap = new HashMap<>();
private final Map<String, PlayerInfo> playerNameMap = new HashMap<>();
/**
* @deprecated Use {@link JobsPlayer#getPointsData} instead
@ -98,13 +100,13 @@ public class PlayerManager {
@Deprecated
public int getMapSize() {
return PlayerUUIDMap.size();
return playerUUIDMap.size();
}
public void clearMaps() {
PlayerUUIDMap.clear();
PlayerIDMap.clear();
PlayerNameMap.clear();
playerUUIDMap.clear();
playerIdMap.clear();
playerNameMap.clear();
}
public void clearCache() {
@ -115,9 +117,9 @@ public class PlayerManager {
}
public void addPlayerToMap(PlayerInfo info) {
PlayerUUIDMap.put(info.getUuid(), info);
PlayerIDMap.put(info.getID(), info);
PlayerNameMap.put(info.getName().toLowerCase(), info);
playerUUIDMap.put(info.getUuid(), info);
playerIdMap.put(info.getID(), info);
playerNameMap.put(info.getName().toLowerCase(), info);
}
public void addPlayerToCache(JobsPlayer jPlayer) {
@ -149,16 +151,12 @@ public class PlayerManager {
return playersUUID.remove(player.getUniqueId());
}
public ConcurrentHashMap<UUID, JobsPlayer> getPlayersCache() {
public ConcurrentMap<UUID, JobsPlayer> getPlayersCache() {
return playersUUIDCache;
}
// public ConcurrentHashMap<String, JobsPlayer> getPlayers() {
// return this.players;
// }
public HashMap<UUID, PlayerInfo> getPlayersInfoUUIDMap() {
return PlayerUUIDMap;
public Map<UUID, PlayerInfo> getPlayersInfoUUIDMap() {
return playerUUIDMap;
}
/**
@ -181,7 +179,7 @@ public class PlayerManager {
* @return the identifier
*/
public int getPlayerId(UUID uuid) {
PlayerInfo info = PlayerUUIDMap.get(uuid);
PlayerInfo info = playerUUIDMap.get(uuid);
return info == null ? -1 : info.getID();
}
@ -193,7 +191,7 @@ public class PlayerManager {
* @return {@link PlayerInfo}
*/
public PlayerInfo getPlayerInfo(String name) {
return PlayerNameMap.get(name.toLowerCase());
return playerNameMap.get(name.toLowerCase());
}
/**
@ -204,7 +202,7 @@ public class PlayerManager {
* @return {@link PlayerInfo}
*/
public PlayerInfo getPlayerInfo(int id) {
return PlayerIDMap.get(id);
return playerIdMap.get(id);
}
/**
@ -215,7 +213,7 @@ public class PlayerManager {
* @return {@link PlayerInfo}
*/
public PlayerInfo getPlayerInfo(UUID uuid) {
return PlayerUUIDMap.get(uuid);
return playerUUIDMap.get(uuid);
}
/**
@ -299,9 +297,7 @@ public class PlayerManager {
* 2) Perform save on all players on copied list.
* 3) Garbage collect the real list to remove any offline players with saved data
*/
ArrayList<JobsPlayer> list = new ArrayList<>(players.values());
for (JobsPlayer jPlayer : list)
for (JobsPlayer jPlayer : new ArrayList<>(players.values()))
jPlayer.save();
Iterator<JobsPlayer> iter = players.values().iterator();

View File

@ -5,22 +5,22 @@ import java.util.List;
public class SignInfo {
private final List<jobsSign> AllSigns = new ArrayList<>();
private final List<jobsSign> allSigns = new ArrayList<>();
public void setAllSigns(List<jobsSign> AllSigns) {
this.AllSigns.clear();
this.AllSigns.addAll(AllSigns == null ? new ArrayList<>() : AllSigns);
this.allSigns.clear();
this.allSigns.addAll(AllSigns == null ? new ArrayList<>() : AllSigns);
}
public List<jobsSign> GetAllSigns() {
return AllSigns;
public List<jobsSign> getAllSigns() {
return allSigns;
}
public void removeSign(jobsSign sign) {
this.AllSigns.remove(sign);
this.allSigns.remove(sign);
}
public void addSign(jobsSign sign) {
this.AllSigns.add(sign);
this.allSigns.add(sign);
}
}

View File

@ -310,7 +310,9 @@ public class SignUtil {
if (playerName == null)
return false;
timelapse = timelapse < 1 ? 1 : timelapse;
if (timelapse < 1) {
timelapse = 1;
}
BlockFace directionFacing = null;
if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) {

View File

@ -61,8 +61,7 @@ public class jobsSign {
return loc;
if (worldName == null)
return null;
world = Bukkit.getWorld(worldName);
if (world == null)
if ((world = Bukkit.getWorld(worldName)) == null)
return null;
return loc = new Location(world, x, y, z);
}
@ -139,13 +138,13 @@ public class jobsSign {
}
public String getIdentifier() {
if (getType() != SignTopType.toplist)
if (getType() != SignTopType.toplist)
return getType().toString();
return jobName != null ? jobName + ":" + getType().toString() : getType().toString();
}
public static String getIdentifier(Job job, SignTopType type) {
if (type != SignTopType.toplist)
if (type != SignTopType.toplist)
return type.toString();
return job != null ? job.getName() + ":" + type.toString() : type.toString();
}

View File

@ -183,7 +183,7 @@ public class JobsCommands implements CommandExecutor {
private Cmd getCmdClass(String cmd) {
try {
Class<?> nmsClass = Class.forName(PACKAGEPATH + "." + cmd.toLowerCase());
Class<?> nmsClass = getClass(cmd);
if (Cmd.class.isAssignableFrom(nmsClass)) {
return (Cmd) nmsClass.getConstructor().newInstance();
}

View File

@ -1,6 +1,5 @@
package com.gamingmesh.jobs.commands.list;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
@ -114,7 +113,7 @@ public class area implements Cmd {
if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
HashMap<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAres();
java.util.Map<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAres();
if (areas.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
return true;

View File

@ -1,7 +1,5 @@
package com.gamingmesh.jobs.commands.list;
import java.util.HashMap;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -20,7 +18,7 @@ public class explored implements Cmd {
Player player = (Player) sender;
HashMap<String, ExploreRegion> worlds = Jobs.getExplore().getWorlds();
java.util.Map<String, ExploreRegion> worlds = Jobs.getExplore().getWorlds();
if (!worlds.containsKey(player.getWorld().getName())) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));

View File

@ -77,7 +77,7 @@ public class give implements Cmd {
return true;
}
GiveItem.GiveItemForPlayer(player, jItem.getItemStack(player));
GiveItem.giveItemForPlayer(player, jItem.getItemStack(player));
break;
case limiteditems:
if (job == null) {
@ -91,7 +91,7 @@ public class give implements Cmd {
return true;
}
GiveItem.GiveItemForPlayer(player, jLItem.getItemStack(player));
GiveItem.giveItemForPlayer(player, jLItem.getItemStack(player));
break;
default:
break;

View File

@ -46,7 +46,7 @@ public class glog implements Cmd {
if (jPlayer == null)
continue;
HashMap<String, Log> logList = jPlayer.getLog();
Map<String, Log> logList = jPlayer.getLog();
if (logList == null || logList.isEmpty())
continue;

View File

@ -46,7 +46,7 @@ public class log implements Cmd {
return true;
}
HashMap<String, Log> logList = JPlayer.getLog();
Map<String, Log> logList = JPlayer.getLog();
if (logList == null || logList.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata"));
@ -73,7 +73,7 @@ public class log implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getName()));
for (Log one : logList.values()) {
HashMap<String, LogAmounts> AmountList = one.getAmountList();
Map<String, LogAmounts> AmountList = one.getAmountList();
double totalMoney = 0, totalExp = 0, totalPoints = 0;
for (String oneSorted : unsortMap.keySet()) {

View File

@ -3,6 +3,7 @@ package com.gamingmesh.jobs.config;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Chunk;
import org.bukkit.entity.Player;
@ -17,7 +18,7 @@ import com.gamingmesh.jobs.stuff.Util;
public class ExploreManager {
private final HashMap<String, ExploreRegion> worlds = new HashMap<>();
private final Map<String, ExploreRegion> worlds = new HashMap<>();
private boolean exploreEnabled = false;
private int playerAmount = 1;
@ -48,7 +49,7 @@ public class ExploreManager {
Jobs.consoleMsg("&e[Jobs] Loaded explorer data" + (getSize() != 0 ? " (" + getSize() + ")" : "."));
}
public HashMap<String, ExploreRegion> getWorlds() {
public Map<String, ExploreRegion> getWorlds() {
return worlds;
}
@ -69,7 +70,6 @@ public class ExploreManager {
}
public ExploreRespond ChunkRespond(int playerId, String world, int x, int z) {
ExploreRegion eRegions = worlds.get(world);
if (eRegions == null) {
int RegionX = (int) Math.floor(x / 32D);

View File

@ -43,8 +43,6 @@ import com.gamingmesh.jobs.resources.jfep.Parser;
public class GeneralConfigManager {
public ArrayList<String> keys;
public List<Integer> BroadcastingLevelUpLevels = new ArrayList<>();
public List<String> FwColors = new ArrayList<>(), DisabledWorldsList = new ArrayList<>();
/**

View File

@ -12,6 +12,8 @@ import com.gamingmesh.jobs.stuff.Util;
public class LanguageManager {
public final List<String> signKeys = new ArrayList<>();
private List<String> languages = new ArrayList<>();
public List<String> getLanguages() {
@ -676,7 +678,8 @@ public class LanguageManager {
c.get("scoreboard.gtopline", "&2Global top list");
c.get("scoreboard.line", "&2%number%. &e%playername% (&6%level%&e)");
Jobs.getGCManager().keys = new ArrayList<String>(c.getC().getConfigurationSection("signs.secondline").getKeys(false));
signKeys.clear();
signKeys.addAll(c.getC().getConfigurationSection("signs.secondline").getKeys(false));
// Write back config
c.save();

View File

@ -156,87 +156,88 @@ public class NameTranslatorManager {
}
public void readFile() {
YmlMaker ItemFile = new YmlMaker(Jobs.getFolder(), "TranslatableWords" + File.separator + "Words_"
YmlMaker itemFile = new YmlMaker(Jobs.getFolder(), "TranslatableWords" + File.separator + "Words_"
+ Jobs.getGCManager().localeString + ".yml");
if (!ItemFile.getConfigFile().getName().equalsIgnoreCase("en")) {
ItemFile.saveDefaultConfig();
if (!itemFile.getConfigFile().getName().equalsIgnoreCase("en")) {
itemFile.saveDefaultConfig();
}
if (ItemFile.getConfig().isConfigurationSection("ItemList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("ItemList");
Set<String> keys = section.getKeys(false);
if (itemFile.getConfig().isConfigurationSection("ItemList")) {
ListOfNames.clear();
for (String one : keys) {
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] : "";
String MCName = one.contains("-") && one.split("-").length > 1 ? one.split("-")[1] : one;
String Name = ItemFile.getConfig().getString("ItemList." + one);
String Name = itemFile.getConfig().getString("ItemList." + one);
ListOfNames.put(CMIMaterial.get(one), new NameList(id, meta, Name, MCName));
}
if (ListOfNames.size() > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + ListOfNames.size() + " custom item names!");
} else
Jobs.consoleMsg("&c[Jobs] The ItemList section not found in " + ItemFile.fileName + " file.");
Jobs.consoleMsg("&c[Jobs] The ItemList section not found in " + itemFile.fileName + " file.");
if (ItemFile.getConfig().isConfigurationSection("EntityList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("EntityList");
Set<String> keys = section.getKeys(false);
if (itemFile.getConfig().isConfigurationSection("EntityList")) {
ListOfEntities.clear();
for (String one : keys) {
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);
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));
}
if (ListOfEntities.size() > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + ListOfEntities.size() + " custom entity names!");
} else
Jobs.consoleMsg("&c[Jobs] The EntityList section not found in " + ItemFile.fileName + " file.");
Jobs.consoleMsg("&c[Jobs] The EntityList section not found in " + itemFile.fileName + " file.");
if (ItemFile.getConfig().isConfigurationSection("MythicEntityList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("MythicEntityList");
Set<String> keys = section.getKeys(false);
if (itemFile.getConfig().isConfigurationSection("MythicEntityList")) {
ListOfMMEntities.clear();
for (String one : keys) {
String Name = ItemFile.getConfig().getString("MythicEntityList." + one);
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));
}
if (ListOfMMEntities.size() > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + ListOfMMEntities.size() + " custom MythicMobs names!");
} else
Jobs.consoleMsg("&c[Jobs] The MythicEntityList section not found in " + ItemFile.fileName + " file.");
Jobs.consoleMsg("&c[Jobs] The MythicEntityList section not found in " + itemFile.fileName + " file.");
if (ItemFile.getConfig().isConfigurationSection("EnchantList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("EnchantList");
Set<String> keys = section.getKeys(false);
if (itemFile.getConfig().isConfigurationSection("EnchantList")) {
ListOfEnchants.clear();
for (String one : keys) {
String name = section.getString(one);
ListOfEnchants.put(one.replace("_", "").toLowerCase(), new NameList(one, one, one, name));
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)));
}
if (ListOfEnchants.size() > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + ListOfEnchants.size() + " custom enchant names!");
} else
Jobs.consoleMsg("&c[Jobs] The EnchantList section not found in " + ItemFile.fileName + " file.");
Jobs.consoleMsg("&c[Jobs] The EnchantList section not found in " + itemFile.fileName + " file.");
if (ItemFile.getConfig().isConfigurationSection("ColorList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("ColorList");
Set<String> keys = section.getKeys(false);
if (itemFile.getConfig().isConfigurationSection("ColorList")) {
ListOfColors.clear();
for (String one : keys) {
String id = one.contains("-") ? one.split("-")[0] : one;
String MCName = one.split("-")[1];
String Name = ItemFile.getConfig().getString("ColorList." + one);
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));
}
if (ListOfColors.size() > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + ListOfColors.size() + " custom color names!");
} else
Jobs.consoleMsg("&c[Jobs] The ColorList section not found in " + ItemFile.fileName + " file.");
Jobs.consoleMsg("&c[Jobs] The ColorList section not found in " + itemFile.fileName + " file.");
}
@SuppressWarnings("deprecation")
@ -359,7 +360,7 @@ public class NameTranslatorManager {
if (ent == null || !ent.isAlive())
continue;
String n = String.valueOf(ent.getId());
String n = Integer.toString(ent.getId());
String name = null;

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
@ -21,7 +22,7 @@ import com.gamingmesh.jobs.hooks.HookManager;
public class RestrictedAreaManager {
protected final HashMap<String, RestrictedArea> restrictedAreas = new HashMap<>();
protected final Map<String, RestrictedArea> restrictedAreas = new HashMap<>();
private boolean worldGuardArea = false;
@ -65,7 +66,7 @@ public class RestrictedAreaManager {
}
}
public HashMap<String, RestrictedArea> getRestrictedAres() {
public Map<String, RestrictedArea> getRestrictedAres() {
return restrictedAreas;
}
@ -108,9 +109,8 @@ public class RestrictedAreaManager {
if (player == null)
return 0D;
for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) {
if (area.inRestrictedArea(player.getLocation()))
return area.getMultiplier();
if (area.getWgName() != null && HookManager.getWorldGuardManager() != null && HookManager.getWorldGuardManager().inArea(player.getLocation(), area.getWgName()))
if (area.inRestrictedArea(player.getLocation()) || (area.getWgName() != null && HookManager.getWorldGuardManager() != null
&& HookManager.getWorldGuardManager().inArea(player.getLocation(), area.getWgName())))
return area.getMultiplier();
}
return 0D;
@ -138,38 +138,40 @@ public class RestrictedAreaManager {
return areas;
}
private static StringBuilder addHeader(StringBuilder header) {
private StringBuilder addHeader(StringBuilder header) {
String sep = System.getProperty("line.separator");
header.append("Restricted area configuration");
header.append(System.getProperty("line.separator"))
.append(System.getProperty("line.separator"))
.append("Configures restricted areas where you cannot get experience or money").append(System.getProperty("line.separator"))
.append("when performing a job.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator"))
.append("The multiplier changes the experience/money gains in an area.").append(System.getProperty("line.separator"))
.append("A multiplier of 0.0 means no bonus, while 0.5 means you will get 50% more the normal income").append(System.getProperty("line.separator"))
.append("While -0.5 means that you will get 50% less the normal income").append(System.getProperty("line.separator"))
.append(System.getProperty("line.separator"))
.append("restrictedareas:").append(System.getProperty("line.separator"))
.append(" area1:").append(System.getProperty("line.separator"))
.append(" world: 'world'").append(System.getProperty("line.separator"))
.append(" multiplier: 0.0").append(System.getProperty("line.separator"))
.append(" point1:").append(System.getProperty("line.separator"))
.append(" x: 125").append(System.getProperty("line.separator"))
.append(" y: 0").append(System.getProperty("line.separator"))
.append(" z: 125").append(System.getProperty("line.separator"))
.append(" point2:").append(System.getProperty("line.separator"))
.append(" x: 150").append(System.getProperty("line.separator"))
.append(" y: 100").append(System.getProperty("line.separator"))
.append(" z: 150").append(System.getProperty("line.separator"))
.append(" area2:").append(System.getProperty("line.separator"))
.append(" world: 'world_nether'").append(System.getProperty("line.separator"))
.append(" multiplier: 0.0").append(System.getProperty("line.separator"))
.append(" point1:").append(System.getProperty("line.separator"))
.append(" x: -100").append(System.getProperty("line.separator"))
.append(" y: 0").append(System.getProperty("line.separator"))
.append(" z: -100").append(System.getProperty("line.separator"))
.append(" point2:").append(System.getProperty("line.separator"))
.append(" x: -150").append(System.getProperty("line.separator"))
.append(" y: 100").append(System.getProperty("line.separator"))
header.append(sep)
.append(sep)
.append("Configures restricted areas where you cannot get experience or money").append(sep)
.append("when performing a job.").append(sep).append(sep)
.append("The multiplier changes the experience/money gains in an area.").append(sep)
.append("A multiplier of 0.0 means no bonus, while 0.5 means you will get 50% more the normal income").append(sep)
.append("While -0.5 means that you will get 50% less the normal income").append(sep)
.append(sep)
.append("restrictedareas:").append(sep)
.append(" area1:").append(sep)
.append(" world: 'world'").append(sep)
.append(" multiplier: 0.0").append(sep)
.append(" point1:").append(sep)
.append(" x: 125").append(sep)
.append(" y: 0").append(sep)
.append(" z: 125").append(sep)
.append(" point2:").append(sep)
.append(" x: 150").append(sep)
.append(" y: 100").append(sep)
.append(" z: 150").append(sep)
.append(" area2:").append(sep)
.append(" world: 'world_nether'").append(sep)
.append(" multiplier: 0.0").append(sep)
.append(" point1:").append(sep)
.append(" x: -100").append(sep)
.append(" y: 0").append(sep)
.append(" z: -100").append(sep)
.append(" point2:").append(sep)
.append(" x: -150").append(sep)
.append(" y: 100").append(sep)
.append(" z: -150");
return header;
}
@ -199,9 +201,7 @@ public class RestrictedAreaManager {
addNew(new RestrictedArea(areaKey, areaKey, multiplier));
worldGuardArea = true;
} else {
String worldName = conf.getString("restrictedareas." + areaKey + ".world");
World world = Bukkit.getServer().getWorld(worldName);
World world = Bukkit.getServer().getWorld(conf.getString("restrictedareas." + areaKey + ".world", ""));
if (world == null)
continue;
Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x", 0d), conf.getDouble("restrictedareas." + areaKey

View File

@ -1,6 +1,7 @@
package com.gamingmesh.jobs.config;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.gamingmesh.jobs.Jobs;
@ -11,7 +12,7 @@ import com.gamingmesh.jobs.CMILib.ItemManager;
public class RestrictedBlockManager {
public final HashMap<CMIMaterial, Integer> restrictedBlocksTimer = new HashMap<>();
public final Map<CMIMaterial, Integer> restrictedBlocksTimer = new HashMap<>();
/**
* Method to load the restricted blocks configuration

View File

@ -56,14 +56,14 @@ public class ScheduleManager {
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
String currenttime = dateFormat.format(new Date());
String CurrentDayName = getWeekDay();
String currentDayName = getWeekDay();
int Current = Integer.parseInt(currenttime.replace(":", ""));
int current = Integer.parseInt(currenttime.replace(":", ""));
for (Schedule one : BOOSTSCHEDULE) {
int From = one.getFrom();
int Until = one.getUntil();
int from = one.getFrom();
int until = one.getUntil();
List<String> days = one.getDays();
@ -72,8 +72,8 @@ public class ScheduleManager {
Jobs.getInstance().getComplement().broadcastMessage(one.getMessageToBroadcast());
}
if (((one.isNextDay() && (Current >= From && Current < Until || Current >= one.getNextFrom() && Current < one.getNextUntil()) && !one
.isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one
if (((one.isNextDay() && (current >= from && current < until || current >= one.getNextFrom() && current < one.getNextUntil()) && !one
.isStarted()) || !one.isNextDay() && (current >= from && current < until)) && (days.contains(currentDayName) || days.contains("all")) && !one
.isStarted()) {
JobsScheduleStartEvent event = new JobsScheduleStartEvent(one);
@ -97,8 +97,8 @@ public class ScheduleManager {
one.setStarted(true);
one.setStoped(false);
break;
} else if (((one.isNextDay() && Current > one.getNextUntil() && Current < one.getFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until
&& ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) {
} else if (((one.isNextDay() && current > one.getNextUntil() && current < one.getFrom() && !one.isStoped()) || !one.isNextDay() && current > until
&& ((days.contains(currentDayName)) || days.contains("all"))) && !one.isStoped()) {
JobsScheduleStopEvent event = new JobsScheduleStopEvent(one);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
@ -124,8 +124,7 @@ public class ScheduleManager {
}
public static String getWeekDay() {
int dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
switch (dayOfWeek) {
switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) {
case 2:
return "monday";
case 3:
@ -164,7 +163,7 @@ public class ScheduleManager {
if (!conf.isConfigurationSection("Boost"))
return;
ArrayList<String> sections = new ArrayList<>(conf.getConfigurationSection("Boost").getKeys(false));
List<String> sections = new ArrayList<>(conf.getConfigurationSection("Boost").getKeys(false));
for (String oneSection : sections) {
ConfigurationSection path = conf.getConfigurationSection("Boost." + oneSection);
@ -178,8 +177,8 @@ public class ScheduleManager {
sched.setName(oneSection);
sched.setDays(path.getStringList("Days"));
sched.setJobs(path.getStringList("Jobs"));
sched.setFrom(Integer.valueOf(path.getString("From").replace(":", "")));
sched.setUntil(Integer.valueOf(path.getString("Until").replace(":", "")));
sched.setFrom(Integer.parseInt(path.getString("From").replace(":", "")));
sched.setUntil(Integer.parseInt(path.getString("Until").replace(":", "")));
if (path.isList("MessageOnStart"))
sched.setMessageOnStart(path.getStringList("MessageOnStart"), path.getString("From"), path.getString("Until"));

View File

@ -43,8 +43,14 @@ import com.gamingmesh.jobs.stuff.GiveItem;
@SuppressWarnings("deprecation")
public class ShopManager {
private Jobs plugin;
private final List<ShopItem> list = new ArrayList<>();
public ShopManager(Jobs plugin) {
this.plugin = plugin;
}
public List<ShopItem> getShopItemList() {
return list;
}
@ -117,7 +123,7 @@ public class ShopManager {
for (int i = 0; i < ls.size(); i++) {
ShopItem item = ls.get(i);
ArrayList<String> lore = new ArrayList<>();
List<String> lore = new ArrayList<>();
CMIMaterial mat = CMIMaterial.get(item.getIconMaterial());
if (item.isHideWithoutPerm()) {
@ -147,7 +153,7 @@ public class ShopManager {
continue;
if (item.getIconName() != null)
meta.setDisplayName(item.getIconName());
plugin.getComplement().setDisplayName(meta, item.getIconName());
lore.addAll(item.getIconLore());
@ -185,7 +191,7 @@ public class ShopManager {
? Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevelColor") : "") + item.getRequiredTotalLevels()));
}
meta.setLore(lore);
plugin.getComplement().setLore(meta, lore);
if (item.getCustomHead() != null) {
guiItem = CMIMaterial.PLAYER_HEAD.newItemStack();
@ -194,9 +200,8 @@ public class ShopManager {
if (skullMeta == null)
continue;
// Fix skull meta
skullMeta.setDisplayName(item.getIconName());
skullMeta.setLore(lore);
plugin.getComplement().setDisplayName(skullMeta, item.getIconName());
plugin.getComplement().setLore(skullMeta, lore);
if (item.isHeadOwner()) {
Jobs.getNms().setSkullOwner(skullMeta, jPlayer.getPlayer());
@ -253,7 +258,7 @@ public class ShopManager {
}
for (JobItems one : item.getitems()) {
GiveItem.GiveItemForPlayer(player, one.getItemStack(player));
GiveItem.giveItemForPlayer(player, one.getItemStack(player));
}
pointsInfo.takePoints(item.getPrice());
@ -271,7 +276,7 @@ public class ShopManager {
int prevSlot = getPrevButtonSlot(guiSize.getFields(), page);
if (prevSlot != -1 && page > 1) {
meta.setDisplayName(Jobs.getLanguage().getMessage("command.help.output.prevPage"));
plugin.getComplement().setDisplayName(meta, Jobs.getLanguage().getMessage("command.help.output.prevPage"));
item.setItemMeta(meta);
gui.addButton(new CMIGuiButton(prevSlot, item) {
@ -284,7 +289,7 @@ public class ShopManager {
int nextSlot = getNextButtonSlot(guiSize.getFields(), page);
if (nextSlot != -1 && !getItemsByPage(page + 1).isEmpty()) {
meta.setDisplayName(Jobs.getLanguage().getMessage("command.help.output.nextPage"));
plugin.getComplement().setDisplayName(meta, Jobs.getLanguage().getMessage("command.help.output.nextPage"));
item.setItemMeta(meta);
gui.addButton(new CMIGuiButton(nextSlot, item) {
@Override
@ -309,13 +314,14 @@ public class ShopManager {
return;
ConfigurationSection confCategory = f.getConfigurationSection("Items");
if (confCategory.getKeys(false).isEmpty()) {
java.util.Set<String> categories = confCategory.getKeys(false);
if (categories.isEmpty()) {
return;
}
int i = 0;
int y = 1;
for (String category : new ArrayList<>(confCategory.getKeys(false))) {
for (String category : new java.util.HashSet<>(categories)) {
ConfigurationSection nameSection = confCategory.getConfigurationSection(category);
if (nameSection == null) {
continue;

View File

@ -19,8 +19,8 @@
package com.gamingmesh.jobs.container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.enchantments.Enchantment;
@ -42,10 +42,10 @@ public class JobLimitedItems {
private int amount;
private String name;
private List<String> lore;
private HashMap<Enchantment, Integer> enchants;
private Map<Enchantment, Integer> enchants;
private int level;
public JobLimitedItems(String node, int id, int data, int amount, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, int level) {
public JobLimitedItems(String node, int id, int data, int amount, String name, List<String> lore, Map<Enchantment, Integer> enchants, int level) {
this.node = node;
this.id = id;
this.data = data;
@ -96,7 +96,7 @@ public class JobLimitedItems {
public int getId() {
return id;
}
public CMIMaterial getType(){
return mat;
}
@ -109,7 +109,7 @@ public class JobLimitedItems {
return lore;
}
public HashMap<Enchantment, Integer> getenchants() {
public Map<Enchantment, Integer> getEnchants() {
return enchants;
}

View File

@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.UUID;
@ -49,14 +50,14 @@ public class JobsPlayer {
public UUID playerUUID;
// progression of the player in each job
public final ArrayList<JobProgression> progression = new ArrayList<>();
public final List<JobProgression> progression = new ArrayList<>();
public int maxJobsEquation = 0;
private ArchivedJobs archivedJobs = new ArchivedJobs();
private PaymentData paymentLimits;
private final HashMap<String, ArrayList<BoostCounter>> boostCounter = new HashMap<>();
private final Map<String, List<BoostCounter>> boostCounter = new HashMap<>();
// display honorific
private String honorific;
@ -65,7 +66,7 @@ public class JobsPlayer {
// player online status
private volatile boolean isOnline = false;
private final HashMap<CurrencyType, Integer> limits = new HashMap<>();
private final Map<CurrencyType, Integer> limits = new HashMap<>();
private int userid = -1;
@ -74,18 +75,18 @@ public class JobsPlayer {
// save lock
// public final Object saveLock = new Object();
private HashMap<String, Log> logList = new HashMap<>();
private Map<String, Log> logList = new HashMap<>();
private Long seen = System.currentTimeMillis();
private HashMap<String, Boolean> permissionsCache;
private Map<String, Boolean> permissionsCache;
private Long lastPermissionUpdate = -1L;
private final HashMap<String, HashMap<String, QuestProgression>> qProgression = new HashMap<>();
private final Map<String, Map<String, QuestProgression>> qProgression = new HashMap<>();
private int doneQuests = 0;
private int skippedQuests = 0;
private final HashMap<UUID, HashMap<Job, Long>> leftTimes = new HashMap<>();
private final Map<UUID, Map<Job, Long>> leftTimes = new HashMap<>();
private PlayerPoints pointsData;
@ -272,7 +273,7 @@ public class JobsPlayer {
}
}
public HashMap<String, Log> getLog() {
public Map<String, Log> getLog() {
return logList;
}
@ -316,60 +317,60 @@ public class JobsPlayer {
* @return amount of boost
*/
public double getBoost(String JobName, CurrencyType type, boolean force) {
double Boost = 0D;
double boost = 0D;
if (!isOnline() || type == null)
return Boost;
return boost;
long time = System.currentTimeMillis();
if (boostCounter.containsKey(JobName)) {
ArrayList<BoostCounter> counterList = boostCounter.get(JobName);
List<BoostCounter> counterList = boostCounter.get(JobName);
for (BoostCounter counter : counterList) {
if (counter.getType() != type)
continue;
if (force || time - counter.getTime() > 1000 * 60) {
Boost = getPlayerBoostNew(JobName, type);
counter.setBoost(Boost);
boost = getPlayerBoostNew(JobName, type);
counter.setBoost(boost);
counter.setTime(time);
return Boost;
return boost;
}
return counter.getBoost();
}
Boost = getPlayerBoostNew(JobName, type);
counterList.add(new BoostCounter(type, Boost, time));
return Boost;
boost = getPlayerBoostNew(JobName, type);
counterList.add(new BoostCounter(type, boost, time));
return boost;
}
Boost = getPlayerBoostNew(JobName, type);
boost = getPlayerBoostNew(JobName, type);
ArrayList<BoostCounter> counterList = new ArrayList<>();
counterList.add(new BoostCounter(type, Boost, time));
List<BoostCounter> counterList = new ArrayList<>();
counterList.add(new BoostCounter(type, boost, time));
boostCounter.put(JobName, counterList);
return Boost;
return boost;
}
private Double getPlayerBoostNew(String JobName, CurrencyType type) {
Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + JobName + "." + type.getName(), true, false);
Double Boost = v1;
private Double getPlayerBoostNew(String jobName, CurrencyType type) {
Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, false);
Double boost = v1;
v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + JobName + ".all", false, false);
if (v1 != 0d && (v1 > Boost || v1 < Boost))
Boost = v1;
v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + ".all", false, false);
if (v1 != 0d && (v1 > boost || v1 < boost))
boost = v1;
v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all.all", false, false);
if (v1 != 0d && (v1 > Boost || v1 < Boost))
Boost = v1;
if (v1 != 0d && (v1 > boost || v1 < boost))
boost = v1;
v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all." + type.getName(), false, false);
if (v1 != 0d && (v1 > Boost || v1 < Boost))
Boost = v1;
if (v1 != 0d && (v1 > boost || v1 < boost))
boost = v1;
return Boost;
return boost;
}
public int getPlayerMaxQuest(String jobName) {
@ -395,9 +396,9 @@ public class JobsPlayer {
* Reloads limit for this player.
*/
public void reload(CurrencyType type) {
int TotalLevel = getTotalLevels();
int totalLevel = getTotalLevels();
Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation();
eq.setVariable("totallevel", TotalLevel);
eq.setVariable("totallevel", totalLevel);
maxJobsEquation = Jobs.getPlayerManager().getMaxJobs(this);
limits.put(type, (int) eq.getValue());
setSaved(false);
@ -530,13 +531,10 @@ public class JobsPlayer {
if (level < 1)
level = 1;
Job job = jp.getJob();
int maxLevel = getMaxJobLevelAllowed(job);
if (jp.getLevel() == maxLevel) {
if (Jobs.getGCManager().fixAtMaxLevel)
level = jp.getLevel();
else {
level = jp.getLevel();
if (jp.getLevel() == getMaxJobLevelAllowed(jp.getJob())) {
level = jp.getLevel();
if (!Jobs.getGCManager().fixAtMaxLevel) {
level = (int) (level - (level * (Jobs.getGCManager().levelLossPercentageFromMax / 100.0)));
if (level < 1)
level = 1;
@ -556,9 +554,7 @@ public class JobsPlayer {
exp = max.doubleValue();
if (exp > 0) {
Job job = jp.getJob();
int maxLevel = getMaxJobLevelAllowed(job);
if (jp.getLevel() == maxLevel) {
if (jp.getLevel() == getMaxJobLevelAllowed(jp.getJob())) {
if (!Jobs.getGCManager().fixAtMaxLevel)
exp = (exp - (exp * (Jobs.getGCManager().levelLossPercentageFromMax / 100.0)));
} else
@ -753,8 +749,7 @@ public class JobsPlayer {
}
private static void processesChat(DisplayMethod method, StringBuilder builder, int level, Title title, Job job) {
String levelS = level < 0 ? "" : String.valueOf(level);
String levelS = level < 0 ? "" : Integer.toString(level);
switch (method) {
case FULL:
processesTitle(builder, title, levelS);
@ -893,11 +888,11 @@ public class JobsPlayer {
this.seen = seen;
}
public HashMap<String, Boolean> getPermissionsCache() {
public Map<String, Boolean> getPermissionsCache() {
return permissionsCache;
}
public void setPermissionsCache(HashMap<String, Boolean> permissionsCache) {
public void setPermissionsCache(Map<String, Boolean> permissionsCache) {
this.permissionsCache = permissionsCache;
}
@ -952,7 +947,7 @@ public class JobsPlayer {
}
public boolean inDailyQuest(Job job, String questName) {
HashMap<String, QuestProgression> qpl = qProgression.get(job.getName());
Map<String, QuestProgression> qpl = qProgression.get(job.getName());
if (qpl == null)
return false;
@ -969,7 +964,7 @@ public class JobsPlayer {
if (!isInJob(job))
return ls;
HashMap<String, QuestProgression> qpl = qProgression.get(job.getName());
Map<String, QuestProgression> qpl = qProgression.get(job.getName());
if (qpl == null)
return ls;
@ -977,7 +972,7 @@ public class JobsPlayer {
if (prog.isEnded() || prog.getQuest() == null)
continue;
for (HashMap<String, QuestObjective> oneAction : prog.getQuest().getObjectives().values()) {
for (Map<String, QuestObjective> oneAction : prog.getQuest().getObjectives().values()) {
for (QuestObjective oneObjective : oneAction.values()) {
if (type == null || type.name().equals(oneObjective.getAction().name())) {
ls.add(prog.getQuest().getConfigName().toLowerCase());
@ -1002,9 +997,7 @@ public class JobsPlayer {
Job job = oneQ.getQuest().getJob();
getNewQuests(job);
if (qProgression.containsKey(job.getName())) {
qProgression.remove(job.getName());
}
qProgression.remove(job.getName());
}
}
@ -1017,11 +1010,11 @@ public class JobsPlayer {
}
public void getNewQuests(Job job) {
java.util.Optional.ofNullable(qProgression.get(job.getName())).ifPresent(HashMap::clear);
java.util.Optional.ofNullable(qProgression.get(job.getName())).ifPresent(Map::clear);
}
public void replaceQuest(Quest quest) {
HashMap<String, QuestProgression> orprog = qProgression.get(quest.getJob().getName());
Map<String, QuestProgression> orProg = qProgression.get(quest.getJob().getName());
Quest q = quest.getJob().getNextQuest(getQuestNameList(quest.getJob(), null), getJobProgression(quest.getJob()).getLevel());
if (q == null) {
@ -1037,7 +1030,7 @@ public class JobsPlayer {
if (q == null)
return;
HashMap<String, QuestProgression> prog = qProgression.get(q.getJob().getName());
Map<String, QuestProgression> prog = qProgression.get(q.getJob().getName());
if (prog == null) {
prog = new HashMap<>();
qProgression.put(q.getJob().getName(), prog);
@ -1052,9 +1045,10 @@ public class JobsPlayer {
if (q.getJob() != quest.getJob() && prog.size() >= q.getJob().getMaxDailyQuests())
return;
if (orprog != null) {
orprog.remove(quest.getConfigName().toLowerCase());
if (orProg != null) {
orProg.remove(quest.getConfigName().toLowerCase());
}
prog.put(q.getConfigName().toLowerCase(), new QuestProgression(q));
skippedQuests++;
}
@ -1075,12 +1069,13 @@ public class JobsPlayer {
if (!isInJob(job))
return new ArrayList<>();
HashMap<String, QuestProgression> g = new HashMap<>();
Map<String, QuestProgression> g = new HashMap<>();
if (qProgression.get(job.getName()) != null)
g = new HashMap<>(qProgression.get(job.getName()));
Map<String, QuestProgression> qProg = qProgression.get(job.getName());
if (qProg != null)
g = new HashMap<>(qProg);
HashMap<String, QuestProgression> tmp = new HashMap<>();
Map<String, QuestProgression> tmp = new HashMap<>();
for (Entry<String, QuestProgression> one : (new HashMap<String, QuestProgression>(g)).entrySet()) {
QuestProgression qp = one.getValue();
@ -1134,7 +1129,7 @@ public class JobsPlayer {
continue;
}
HashMap<String, QuestObjective> old = q.getObjectives().get(type);
Map<String, QuestObjective> old = q.getObjectives().get(type);
if (old != null)
for (QuestObjective one : old.values()) {
if (type.name().equals(one.getAction().name())) {
@ -1160,7 +1155,7 @@ public class JobsPlayer {
prog += q.getJob().getName() + ":" + q.getConfigName() + ":" + one.getValidUntil() + ":";
for (HashMap<String, QuestObjective> oneA : q.getObjectives().values()) {
for (Map<String, QuestObjective> oneA : q.getObjectives().values()) {
for (Entry<String, QuestObjective> oneO : oneA.entrySet()) {
prog += oneO.getValue().getAction().toString() + ";" + oneO.getKey() + ";" + one.getAmountDone(oneO.getValue()) + ":;:";
}
@ -1176,8 +1171,7 @@ public class JobsPlayer {
if (qprog == null || qprog.isEmpty())
return;
String[] byJob = qprog.split(";:;");
for (String one : byJob) {
for (String one : qprog.split(";:;")) {
try {
String jname = one.split(":")[0];
Job job = Jobs.getJob(jname);
@ -1185,17 +1179,19 @@ public class JobsPlayer {
continue;
one = one.substring(jname.length() + 1);
String qname = one.split(":")[0];
Quest quest = job.getQuest(qname);
if (quest == null)
continue;
one = one.substring(qname.length() + 1);
String longS = one.split(":")[0];
Long validUntil = Long.parseLong(longS);
long validUntil = Long.parseLong(longS);
one = one.substring(longS.length() + 1);
HashMap<String, QuestProgression> currentProgression = qProgression.get(job.getName());
Map<String, QuestProgression> currentProgression = qProgression.get(job.getName());
if (currentProgression == null) {
currentProgression = new HashMap<>();
@ -1218,7 +1214,7 @@ public class JobsPlayer {
oneA = oneA.substring(prog.length() + 1);
String target = oneA.split(";")[0];
HashMap<String, QuestObjective> old = quest.getObjectives().get(action);
Map<String, QuestObjective> old = quest.getObjectives().get(action);
if (old == null)
continue;
@ -1227,15 +1223,13 @@ public class JobsPlayer {
continue;
oneA = oneA.substring(target.length() + 1);
String doneS = oneA.split(";")[0];
int done = Integer.parseInt(doneS);
qp.setAmountDone(obj, done);
qp.setAmountDone(obj, Integer.parseInt(oneA.split(";")[0]));
}
if (qp.isCompleted())
qp.setGivenReward(true);
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@ -1329,7 +1323,7 @@ public class JobsPlayer {
if (maxV == 0D && type == BlockTypes.SMOKER)
maxV = (double) Jobs.getGCManager().SmokersMaxDefault;
if (maxV == 0 && type == BlockTypes.BREWING_STAND)
if (maxV == 0D && type == BlockTypes.BREWING_STAND)
maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault();
return maxV.intValue();
@ -1343,7 +1337,7 @@ public class JobsPlayer {
this.skippedQuests = skippedQuests;
}
public HashMap<UUID, HashMap<Job, Long>> getLeftTimes() {
public Map<UUID, Map<Job, Long>> getLeftTimes() {
return leftTimes;
}
@ -1352,7 +1346,7 @@ public class JobsPlayer {
if (!leftTimes.containsKey(uuid))
return false;
HashMap<Job, Long> map = leftTimes.get(uuid);
Map<Job, Long> map = leftTimes.get(uuid);
return map.containsKey(job) && map.get(job).longValue() < System.currentTimeMillis();
}
@ -1371,7 +1365,7 @@ public class JobsPlayer {
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + hour);
HashMap<Job, Long> map = new HashMap<>();
Map<Job, Long> map = new HashMap<>();
map.put(job, cal.getTimeInMillis());
leftTimes.put(uuid, map);
}

View File

@ -1,13 +1,15 @@
package com.gamingmesh.jobs.container;
import java.util.HashMap;
import java.util.Map;
import com.gamingmesh.jobs.stuff.TimeManage;
public final class Log {
private String action;
private int day;
private HashMap<String, LogAmounts> amountMap = new HashMap<>();
private Map<String, LogAmounts> amountMap = new HashMap<>();
public Log(String action) {
this.action = action;
@ -18,19 +20,19 @@ public final class Log {
return action;
}
public void add(String item, HashMap<CurrencyType, Double> amounts) {
LogAmounts LAmount = amountMap.getOrDefault(item, new LogAmounts(item));
LAmount.addCount();
LAmount.add(amounts);
this.amountMap.put(item, LAmount);
public void add(String item, Map<CurrencyType, Double> amounts) {
LogAmounts logAmount = amountMap.getOrDefault(item, new LogAmounts(item));
logAmount.addCount();
logAmount.add(amounts);
this.amountMap.put(item, logAmount);
}
public void add(String item, int count, HashMap<CurrencyType, Double> amounts) {
LogAmounts LAmount = amountMap.getOrDefault(item, new LogAmounts(item));
LAmount.setCount(count);
LAmount.add(amounts);
LAmount.setNewEntry(false);
this.amountMap.put(item, LAmount);
public void add(String item, int count, Map<CurrencyType, Double> amounts) {
LogAmounts logAmount = amountMap.getOrDefault(item, new LogAmounts(item));
logAmount.setCount(count);
logAmount.add(amounts);
logAmount.setNewEntry(false);
this.amountMap.put(item, logAmount);
}
public void setDate() {
@ -41,19 +43,15 @@ public final class Log {
return day;
}
public HashMap<String, LogAmounts> getAmountList() {
public Map<String, LogAmounts> getAmountList() {
return amountMap;
}
public int getCount(String item) {
if (this.amountMap.containsKey(item))
return this.amountMap.get(item).getCount();
return 0;
return amountMap.containsKey(item) ? amountMap.get(item).getCount() : 0;
}
public double get(String item, CurrencyType type) {
if (this.amountMap.containsKey(item))
return this.amountMap.get(item).get(type);
return 0;
return amountMap.containsKey(item) ? amountMap.get(item).get(type) : 0;
}
}

View File

@ -1,6 +1,7 @@
package com.gamingmesh.jobs.container;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public final class LogAmounts {
@ -11,7 +12,7 @@ public final class LogAmounts {
private String item;
private int count = 0;
private HashMap<CurrencyType, Double> amounts = new HashMap<>();
private Map<CurrencyType, Double> amounts = new HashMap<>();
private boolean newEntry = true;
@ -31,7 +32,7 @@ public final class LogAmounts {
return item;
}
public void add(HashMap<CurrencyType, Double> amounts) {
public void add(Map<CurrencyType, Double> amounts) {
for (Entry<CurrencyType, Double> one : amounts.entrySet()) {
add(one.getKey(), one.getValue());
}

View File

@ -1779,10 +1779,10 @@ public abstract class JobsDAO {
}
public PlayerInfo loadPlayerData(UUID uuid) {
PlayerInfo pInfo = null;
JobsConnection conn = getConnection();
if (conn == null)
return pInfo;
return null;
PlayerInfo pInfo = null;
PreparedStatement prest = null;
ResultSet res = null;
try {

View File

@ -24,7 +24,6 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import com.gamingmesh.jobs.Jobs;
@ -32,13 +31,10 @@ import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.config.YmlMaker;
public class Language {
public FileConfiguration enlocale;
public FileConfiguration customlocale;
private Jobs plugin;
public Language(Jobs plugin) {
this.plugin = plugin;
}
public FileConfiguration enlocale, customlocale;
private final Pattern patern = Pattern.compile("([ ]?[\\/][n][$|\\s])");
/**
* Reloads the config
@ -68,11 +64,10 @@ public class Language {
msg = enlocale.isString(key) ? CMIChatColor.translate(enlocale.getString(key)) : missing;
else
msg = customlocale.isString(key) ? CMIChatColor.translate(customlocale.getString(key)) : missing;
} catch (Throwable e) {
} catch (Exception e) {
Jobs.consoleMsg("&e[Jobs] &2Can't read language file for: " + key);
Bukkit.getServer().getPluginManager().disablePlugin(plugin);
e.printStackTrace();
throw e;
Jobs.consoleMsg(e.getLocalizedMessage());
return "";
}
if (msg.isEmpty() || msg.equals(missing)) {
@ -81,20 +76,19 @@ public class Language {
List<String> ls = null;
if (customlocale != null && customlocale.isList(key))
ls = ColorsArray(customlocale.getStringList(key), true);
ls = colorsArray(customlocale.getStringList(key), true);
else if (enlocale.isList(key))
ls = !enlocale.getStringList(key).isEmpty() ? ColorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing);
ls = !enlocale.getStringList(key).isEmpty() ? colorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing);
if (ls != null)
for (String one : ls) {
if (!msg.isEmpty())
msg += "\n";
msg += one;
}
} catch (Throwable e) {
} catch (Exception e) {
Jobs.consoleMsg("&e[Jobs] &2Can't read language file for: " + key);
Bukkit.getServer().getPluginManager().disablePlugin(plugin);
e.printStackTrace();
throw e;
Jobs.consoleMsg(e.getLocalizedMessage());
return "";
}
}
@ -118,9 +112,9 @@ public class Language {
List<String> ls;
if (customlocale.isList(key))
ls = ColorsArray(customlocale.getStringList(key), true);
ls = colorsArray(customlocale.getStringList(key), true);
else
ls = !enlocale.getStringList(key).isEmpty() ? ColorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing);
ls = !enlocale.getStringList(key).isEmpty() ? colorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing);
if (variables != null && variables.length > 0)
for (int i = 0; i < ls.size(); i++) {
@ -128,15 +122,14 @@ public class Language {
for (int y = 0; y < variables.length; y += 2) {
msg = msg.replace(String.valueOf(variables[y]), String.valueOf(variables[y + 1]));
}
msg = filterNewLine(msg);
ls.set(i, CMIChatColor.translate(msg));
ls.set(i, CMIChatColor.translate(filterNewLine(msg)));
}
return ls;
}
public String filterNewLine(String msg) {
Pattern patern = Pattern.compile("([ ]?[\\/][n][$|\\s])");
Matcher match = patern.matcher(msg);
while (match.find()) {
msg = msg.replace(match.group(0), "\n");
@ -144,7 +137,7 @@ public class Language {
return msg;
}
public List<String> ColorsArray(List<String> text, boolean colorize) {
public List<String> colorsArray(List<String> text, boolean colorize) {
List<String> temp = new ArrayList<>();
for (String part : text) {
if (colorize)

View File

@ -196,13 +196,13 @@ public class JobsListener implements Listener {
return;
Sign sign = (Sign) block.getState();
String FirstLine = plugin.getComplement().getLine(sign, 0);
if (!CMIChatColor.stripColor(FirstLine).equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))))
if (!CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 0)).equalsIgnoreCase(
CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))))
return;
String command = CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 1));
for (String key : Jobs.getGCManager().keys) {
for (String key : Jobs.getLanguageManager().signKeys) {
if (command.equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.secondline." + key)))) {
command = key;
break;
@ -224,8 +224,8 @@ public class JobsListener implements Listener {
Player player = event.getPlayer();
Sign sign = (Sign) block.getState();
String firstLine = plugin.getComplement().getLine(sign, 0);
if (firstLine.contains(Jobs.getLanguage().getMessage("signs.topline")) && !player.hasPermission("jobs.command.signs")) {
if (plugin.getComplement().getLine(sign, 0).contains(Jobs.getLanguage().getMessage("signs.topline"))
&& !player.hasPermission("jobs.command.signs")) {
event.setCancelled(true);
player.sendMessage(Jobs.getLanguage().getMessage("signs.cantdestroy"));
return;
@ -270,8 +270,7 @@ public class JobsListener implements Listener {
return;
}
String jobname = CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 2)).toLowerCase();
final Job job = Jobs.getJob(jobname);
final Job job = Jobs.getJob(CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 2)).toLowerCase());
if (type == SignTopType.toplist && job == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.top.error.nojob"));
return;
@ -294,8 +293,7 @@ public class JobsListener implements Listener {
jobsSign signInfo = new jobsSign();
Location loc = sign.getLocation();
signInfo.setLoc(loc);
signInfo.setLoc(sign.getLocation());
signInfo.setNumber(number);
if (job != null)
signInfo.setJobName(job.getName());
@ -331,7 +329,7 @@ public class JobsListener implements Listener {
}
String command = CMIChatColor.stripColor(plugin.getComplement().getLine(event, 1)).toLowerCase();
for (String key : Jobs.getGCManager().keys) {
for (String key : Jobs.getLanguageManager().signKeys) {
if (command.equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.secondline." + key)))) {
plugin.getComplement().setLine(event, 1, convert(Jobs.getLanguage().getMessage("signs.secondline." + key)));
break;
@ -346,8 +344,10 @@ public class JobsListener implements Listener {
plugin.getComplement().setLine(event, 2, convert(color + job.getName()));
}
private final Pattern pattern = Pattern.compile("&([0-9a-fk-or])");
private String convert(String line) {
return Pattern.compile("&([0-9a-fk-or])").matcher(CMIChatColor.translate(line)).replaceAll("\u00a7$1");
return pattern.matcher(CMIChatColor.translate(line)).replaceAll("\u00a7$1");
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -425,15 +425,13 @@ public class JobsListener implements Listener {
}
}
boolean foundEnc = false;
for (Entry<Enchantment, Integer> oneE : enchants.entrySet()) {
if (oneItem.getenchants().containsKey(oneE.getKey()) && oneItem.getenchants().get(oneE.getKey()) <= oneE.getValue()) {
foundEnc = true;
break;
if (oneItem.getEnchants().containsKey(oneE.getKey()) && oneItem.getEnchants().get(oneE.getKey()) <= oneE.getValue()) {
return true;
}
}
return foundEnc;
return false;
}
@EventHandler

View File

@ -25,9 +25,7 @@ public class v1_10 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -19,9 +19,7 @@ public class v1_11 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -20,9 +20,7 @@ public class v1_12 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -20,9 +20,7 @@ public class v1_13 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -20,9 +20,7 @@ public class v1_14 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -20,9 +20,7 @@ public class v1_15 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -20,9 +20,7 @@ public class v1_16 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -25,9 +25,7 @@ public class v1_8 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -25,9 +25,7 @@ public class v1_9 implements NMS {
@Override
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
List<Block> blocks = new ArrayList<>();
blocks.addAll(event.getBlocks());
return blocks;
return new ArrayList<>(event.getBlocks());
}
@Override

View File

@ -1,8 +1,6 @@
package com.gamingmesh.jobs.stuff;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
@ -13,7 +11,6 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
@ -25,20 +22,20 @@ public class CMIScoreboardManager {
private ConcurrentHashMap<UUID, ScoreboardInfo> timerMap = new ConcurrentHashMap<>();
private void RunScheduler() {
Iterator<Entry<UUID, ScoreboardInfo>> MeinMapIter = timerMap.entrySet().iterator();
while (MeinMapIter.hasNext()) {
Entry<UUID, ScoreboardInfo> Map = MeinMapIter.next();
private void runScheduler() {
Iterator<Entry<UUID, ScoreboardInfo>> meinMapIter = timerMap.entrySet().iterator();
while (meinMapIter.hasNext()) {
Entry<UUID, ScoreboardInfo> map = meinMapIter.next();
if (System.currentTimeMillis() > Map.getValue().getTime() + (Jobs.getGCManager().ToplistInScoreboardInterval * 1000)) {
Player player = Bukkit.getPlayer(Map.getKey());
if (System.currentTimeMillis() > map.getValue().getTime() + (Jobs.getGCManager().ToplistInScoreboardInterval * 1000)) {
Player player = Bukkit.getPlayer(map.getKey());
if (player != null) {
removeScoreBoard(player);
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (Map.getValue().getObj() != null) {
if (map.getValue().getObj() != null) {
try {
Objective obj = player.getScoreboard().getObjective(Map.getValue().getObj().getName());
Objective obj = player.getScoreboard().getObjective(map.getValue().getObj().getName());
if (obj != null)
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
} catch (IllegalStateException e) {
@ -46,47 +43,92 @@ public class CMIScoreboardManager {
}
}
timerMap.remove(Map.getKey());
timerMap.remove(map.getKey());
}
}
if (timerMap.size() > 0)
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), this::RunScheduler, 20L);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), this::runScheduler, 20L);
}
public void addNew(Player player) {
Scoreboard scoreBoard = player.getScoreboard();
timerMap.put(player.getUniqueId(), new ScoreboardInfo(scoreBoard, DisplaySlot.SIDEBAR));
RunScheduler();
timerMap.put(player.getUniqueId(), new ScoreboardInfo(player.getScoreboard(), DisplaySlot.SIDEBAR));
runScheduler();
}
private final String objName = "CMIScoreboard";
public void removeScoreBoard(Player player) {
try {
Class<?> boardClass = getNMSClass("Scoreboard");
Object boards = boardClass.getConstructor().newInstance();
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
Class<?> p0 = getNMSClass("PacketPlayOutScoreboardObjective");
Constructor<?> p00 = p0.getConstructor();
Object pp1 = p00.newInstance();
Object pp1 = getNMSClass("PacketPlayOutScoreboardObjective").getConstructor().newInstance();
setField(pp1, "a", player.getName());
setField(pp1, "d", 1);
sendPacket(player, pp1);
} else {
Method m = boards.getClass().getMethod("registerObjective", String.class, getNMSClass("IScoreboardCriteria"));
Object boards = getNMSClass("Scoreboard").getConstructor().newInstance();
Class<?> IScoreboardCriterias = getNMSClass("ScoreboardBaseCriteria");
Constructor<?> IScoreboardCriteriasConst = IScoreboardCriterias.getConstructor(String.class);
Object IScoreboardCriteria = IScoreboardCriteriasConst.newInstance("JobsDummy");
Object obj = boards.getClass().getMethod("registerObjective", String.class,
getNMSClass("IScoreboardCriteria")).invoke(boards, objName,
getNMSClass("ScoreboardBaseCriteria").getConstructor(String.class).newInstance("JobsDummy"));
sendPacket(player, getNMSClass("PacketPlayOutScoreboardObjective").getConstructor(obj.getClass(), int.class).newInstance(obj, 1));
}
} catch (Exception e) {
e.printStackTrace();
}
}
Object obj = m.invoke(boards, objName, IScoreboardCriteria);
Class<?> p1 = getNMSClass("PacketPlayOutScoreboardObjective");
Constructor<?> p11 = p1.getConstructor(obj.getClass(), int.class);
Object pp1 = p11.newInstance(obj, 1);
public void setScoreBoard(Player player, String displayName, List<String> lines) {
removeScoreBoard(player);
try {
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
Object pp1 = getNMSClass("PacketPlayOutScoreboardObjective").getConstructor().newInstance();
setField(pp1, "a", player.getName());
setField(pp1, "d", 0);
setField(pp1, "b", getNMSClass("ChatComponentText").getConstructor(String.class).newInstance(CMIChatColor.translate(displayName)));
setField(pp1, "c", getNMSClass("IScoreboardCriteria$EnumScoreboardHealthDisplay").getEnumConstants()[1]);
sendPacket(player, pp1);
Object d0 = getNMSClass("PacketPlayOutScoreboardDisplayObjective").getConstructor().newInstance();
setField(d0, "a", 1);
setField(d0, "b", player.getName());
sendPacket(player, d0);
for (int i = 0; i < 15; i++) {
if (i >= lines.size())
break;
Object PacketPlayOutScoreboardScore = getNMSClass("PacketPlayOutScoreboardScore").getConstructor().newInstance();
setField(PacketPlayOutScoreboardScore, "a", CMIChatColor.translate(lines.get(i)));
setField(PacketPlayOutScoreboardScore, "b", player.getName());
setField(PacketPlayOutScoreboardScore, "c", 15 - i);
setField(PacketPlayOutScoreboardScore, "d", getNMSClass("ScoreboardServer$Action").getEnumConstants()[0]);
sendPacket(player, PacketPlayOutScoreboardScore);
}
} else {
Object boards = getNMSClass("Scoreboard").getConstructor().newInstance();
Object obj = boards.getClass().getMethod("registerObjective", String.class, getNMSClass("IScoreboardCriteria"))
.invoke(boards, objName, getNMSClass("ScoreboardBaseCriteria").getConstructor(String.class).newInstance("JobsDummy"));
obj.getClass().getMethod("setDisplayName", String.class).invoke(obj, CMIChatColor.translate(displayName));
sendPacket(player, getNMSClass("PacketPlayOutScoreboardObjective").getConstructor(obj.getClass(), int.class).newInstance(obj, 1));
sendPacket(player, getNMSClass("PacketPlayOutScoreboardObjective").getConstructor(obj.getClass(), int.class).newInstance(obj, 0));
sendPacket(player, getNMSClass("PacketPlayOutScoreboardDisplayObjective").getConstructor(int.class,
getNMSClass("ScoreboardObjective")).newInstance(1, obj));
for (int i = 0; i < 15; i++) {
if (i >= lines.size())
break;
Object packet2 = getNMSClass("ScoreboardScore").getConstructor(getNMSClass("Scoreboard"),
getNMSClass("ScoreboardObjective"), String.class).newInstance(boards, obj, CMIChatColor.translate(lines.get(i)));
packet2.getClass().getMethod("setScore", int.class).invoke(packet2, 15 - i);
sendPacket(player, getNMSClass("PacketPlayOutScoreboardScore").getConstructor(getNMSClass("ScoreboardScore")).newInstance(packet2));
}
}
} catch (Exception e) {
e.printStackTrace();
@ -103,101 +145,9 @@ public class CMIScoreboardManager {
}
}
public void setScoreBoard(Player player, String displayName, List<String> lines) {
removeScoreBoard(player);
try {
Class<?> boardClass = getNMSClass("Scoreboard");
Object boards = boardClass.getConstructor().newInstance();
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
Class<?> enums = getNMSClass("IScoreboardCriteria$EnumScoreboardHealthDisplay");
Class<?> p0 = getNMSClass("PacketPlayOutScoreboardObjective");
Constructor<?> p00 = p0.getConstructor();
Object pp1 = p00.newInstance();
setField(pp1, "a", player.getName());
setField(pp1, "d", 0);
Object chatComponentText = getNMSClass("ChatComponentText").getConstructor(String.class).newInstance(CMIChatColor.translate(displayName));
setField(pp1, "b", chatComponentText);
setField(pp1, "c", enums.getEnumConstants()[1]);
sendPacket(player, pp1);
Object d0 = getNMSClass("PacketPlayOutScoreboardDisplayObjective").getConstructor().newInstance();
setField(d0, "a", 1);
setField(d0, "b", player.getName());
sendPacket(player, d0);
for (int i = 0; i < 15; i++) {
if (i >= lines.size())
break;
String ln = CMIChatColor.translate(lines.get(i));
Class<?> PacketPlayOutScoreboardScoreClass = getNMSClass("PacketPlayOutScoreboardScore");
Constructor<?> PacketPlayOutScoreboardScoreConstructor = PacketPlayOutScoreboardScoreClass.getConstructor();
Object PacketPlayOutScoreboardScore = PacketPlayOutScoreboardScoreConstructor.newInstance();
Class<?> aenums = getNMSClass("ScoreboardServer$Action");
setField(PacketPlayOutScoreboardScore, "a", ln);
setField(PacketPlayOutScoreboardScore, "b", player.getName());
setField(PacketPlayOutScoreboardScore, "c", 15 - i);
setField(PacketPlayOutScoreboardScore, "d", aenums.getEnumConstants()[0]);
sendPacket(player, PacketPlayOutScoreboardScore);
}
} else {
Method m = boards.getClass().getMethod("registerObjective", String.class, getNMSClass("IScoreboardCriteria"));
Class<?> IScoreboardCriterias = getNMSClass("ScoreboardBaseCriteria");
Constructor<?> IScoreboardCriteriasConst = IScoreboardCriterias.getConstructor(String.class);
Object IScoreboardCriteria = IScoreboardCriteriasConst.newInstance("JobsDummy");
Object obj = m.invoke(boards, objName, IScoreboardCriteria);
Method mm = obj.getClass().getMethod("setDisplayName", String.class);
mm.invoke(obj, CMIChatColor.translate(displayName));
Class<?> p1 = getNMSClass("PacketPlayOutScoreboardObjective");
Constructor<?> p11 = p1.getConstructor(obj.getClass(), int.class);
Object pp1 = p11.newInstance(obj, 1);
sendPacket(player, pp1);
Class<?> p2 = getNMSClass("PacketPlayOutScoreboardObjective");
Constructor<?> p12 = p2.getConstructor(obj.getClass(), int.class);
Object pp2 = p12.newInstance(obj, 0);
sendPacket(player, pp2);
Class<?> packetClass = getNMSClass("PacketPlayOutScoreboardDisplayObjective");
Constructor<?> packetConstructor = packetClass.getConstructor(int.class, getNMSClass("ScoreboardObjective"));
Object packet = packetConstructor.newInstance(1, obj);
sendPacket(player, packet);
for (int i = 0; i < 15; i++) {
if (i >= lines.size())
break;
String ln = CMIChatColor.translate(lines.get(i));
Class<?> ScoreboardScoreClass = getNMSClass("ScoreboardScore");
Constructor<?> packetConstructor2 = ScoreboardScoreClass.getConstructor(getNMSClass("Scoreboard"), getNMSClass("ScoreboardObjective"), String.class);
Object packet2 = packetConstructor2.newInstance(boards, obj, ln);
Method mc = packet2.getClass().getMethod("setScore", int.class);
mc.invoke(packet2, 15 - i);
Class<?> PacketPlayOutScoreboardScoreClass = getNMSClass("PacketPlayOutScoreboardScore");
Constructor<?> PacketPlayOutScoreboardScoreConstructor = PacketPlayOutScoreboardScoreClass.getConstructor(getNMSClass("ScoreboardScore"));
Object PacketPlayOutScoreboardScore = PacketPlayOutScoreboardScoreConstructor.newInstance(packet2);
sendPacket(player, PacketPlayOutScoreboardScore);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void sendPacket(Player player, Object packet) {
Method sendPacket;
try {
sendPacket = getNMSClass("PlayerConnection").getMethod("sendPacket", getNMSClass("Packet"));
sendPacket.invoke(getConnection(player), packet);
getNMSClass("PlayerConnection").getMethod("sendPacket", getNMSClass("Packet")).invoke(getConnection(player), packet);
} catch (Exception e) {
e.printStackTrace();
}
@ -208,10 +158,7 @@ public class CMIScoreboardManager {
}
private static Object getConnection(Player player) throws Exception {
Method getHandle = player.getClass().getMethod("getHandle");
Object nmsPlayer = getHandle.invoke(player);
Field conField = nmsPlayer.getClass().getField("playerConnection");
Object con = conField.get(nmsPlayer);
return con;
Object nmsPlayer = player.getClass().getMethod("getHandle").invoke(player);
return nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer);
}
}

View File

@ -16,11 +16,15 @@ import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
public class GiveItem {
public static void GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore,
public static void giveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore,
HashMap<Enchantment, Integer> enchants) {
ItemStack itemStack = CMIMaterial.get(id, meta).newItemStack();
itemStack.setAmount(qty);
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null) {
return;
}
if (lore != null && !lore.isEmpty()) {
List<String> translatedLore = new ArrayList<>();
@ -48,10 +52,10 @@ public class GiveItem {
Jobs.getInstance().getComplement().setDisplayName(itemMeta, CMIChatColor.translate(name));
itemStack.setItemMeta(itemMeta);
GiveItemForPlayer(player, itemStack);
giveItemForPlayer(player, itemStack);
}
public static void GiveItemForPlayer(Player player, ItemStack item) {
public static void giveItemForPlayer(Player player, ItemStack item) {
player.getInventory().addItem(item);
player.updateInventory();
}

View File

@ -1,6 +1,6 @@
package com.gamingmesh.jobs.stuff;
import java.util.HashMap;
import java.util.Map;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.ActionInfo;
@ -10,26 +10,25 @@ import com.gamingmesh.jobs.container.Log;
public class Loging {
public void recordToLog(JobsPlayer jPlayer, ActionInfo info, HashMap<CurrencyType, Double> amounts) {
public void recordToLog(JobsPlayer jPlayer, ActionInfo info, Map<CurrencyType, Double> amounts) {
recordToLog(jPlayer, info.getType().getName(), info.getNameWithSub(), amounts);
}
public void recordToLog(JobsPlayer jPlayer, String ActionName, String item, HashMap<CurrencyType, Double> amounts) {
HashMap<String, Log> logList = jPlayer.getLog();
public void recordToLog(JobsPlayer jPlayer, String actionName, String item, Map<CurrencyType, Double> amounts) {
Map<String, Log> logList = jPlayer.getLog();
Log l = logList.values().stream().findFirst().orElse(null);
if (l != null && TimeManage.timeInInt() != l.getDate()) {
Jobs.getJobsDAO().saveLog(jPlayer);
jPlayer.getLog().clear();
}
Log log = logList.getOrDefault(ActionName, new Log(ActionName));
Log log = logList.getOrDefault(actionName, new Log(actionName));
log.add(item, amounts);
logList.put(ActionName, log);
logList.put(actionName, log);
}
public void loadToLog(JobsPlayer jPlayer, String ActionName, String item, int count, HashMap<CurrencyType, Double> amounts) {
Log log = jPlayer.getLog().getOrDefault(ActionName, new Log(ActionName));
log.add(item, count, amounts);
public void loadToLog(JobsPlayer jPlayer, String actionName, String item, int count, Map<CurrencyType, Double> amounts) {
jPlayer.getLog().getOrDefault(actionName, new Log(actionName)).add(item, count, amounts);
}
}

View File

@ -9,7 +9,6 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.util.StringUtil;
import com.gamingmesh.jobs.ItemBoostManager;
@ -29,25 +28,24 @@ public class TabComplete implements TabCompleter {
List<String> completionList = new ArrayList<>();
if (args.length == 1) {
String PartOfCommand = args[0];
List<String> temp = new ArrayList<>();
Jobs.getCommandManager().getCommands(sender).forEach(temp::add);
StringUtil.copyPartialMatches(PartOfCommand, temp, completionList);
temp.addAll(Jobs.getCommandManager().getCommands(sender));
StringUtil.copyPartialMatches(args[0], temp, completionList);
}
if (args.length > 1)
for (int i = 1; i <= args.length; i++)
if (args.length == i + 1) {
String PartOfCommand = args[i];
String partOfCommand = args[i];
if (!Jobs.getGCManager().getCommandArgs().containsKey(args[0].toLowerCase()))
break;
List<String> ArgsList = Jobs.getGCManager().getCommandArgs().get(args[0].toLowerCase());
if (ArgsList.size() < i)
List<String> argsList = Jobs.getGCManager().getCommandArgs().get(args[0].toLowerCase());
if (argsList.size() < i)
continue;
String arg = ArgsList.get(i - 1);
String arg = argsList.get(i - 1);
List<String> t2 = new ArrayList<>();
if (arg.contains("%%"))
@ -61,7 +59,7 @@ public class TabComplete implements TabCompleter {
for (String ar : t2) {
switch (ar) {
case "[scheduleName]":
Jobs.getScheduleManager().getConf().getConfig().getConfigurationSection("Boost").getKeys(false).forEach(temp::add);
temp.addAll(Jobs.getScheduleManager().getConf().getConfig().getConfigurationSection("Boost").getKeys(false));
break;
case "[time]":
temp.add("1hour10minute20s");
@ -82,15 +80,11 @@ public class TabComplete implements TabCompleter {
}
break;
case "[playername]":
pl: for (Player player : Bukkit.getOnlinePlayers()) {
for (Player player : Bukkit.getOnlinePlayers()) {
// ignore hidden players
if (Jobs.getGCManager().FilterHiddenPlayerFromTabComplete && player.hasMetadata("vanished")) {
// TODO add essentials & cmi support
for (MetadataValue meta : player.getMetadata("vanished")) {
if (meta.asBoolean()) {
continue pl;
}
}
if (Jobs.getGCManager().FilterHiddenPlayerFromTabComplete && (player.hasMetadata("vanished")
|| (sender instanceof Player && ((Player) sender).canSee(player)))) {
continue;
}
temp.add(player.getName());
@ -127,8 +121,7 @@ public class TabComplete implements TabCompleter {
break;
case "[oldplayerjob]":
if (sender instanceof Player) {
onePlayerJob = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (onePlayerJob != null)
if ((onePlayerJob = Jobs.getPlayerManager().getJobsPlayer((Player) sender)) != null)
for (JobProgression oneOldJob : onePlayerJob.getJobProgression()) {
temp.add(oneOldJob.getJob().getName());
}
@ -140,7 +133,7 @@ public class TabComplete implements TabCompleter {
}
}
StringUtil.copyPartialMatches(PartOfCommand, temp, completionList);
StringUtil.copyPartialMatches(partOfCommand, temp, completionList);
}
Collections.sort(completionList);

View File

@ -1,4 +1,3 @@
package com.gamingmesh.jobs.stuff;
import java.text.SimpleDateFormat;

View File

@ -80,7 +80,8 @@ public class Util {
}
public static String firstToUpperCase(String name) {
return name.toLowerCase().replace('_', ' ').substring(0, 1).toUpperCase() + name.toLowerCase().replace('_', ' ').substring(1);
name = name.toLowerCase().replace('_', ' ');
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
public static HashMap<UUID, String> getJobsEditorMap() {
@ -109,7 +110,7 @@ public class Util {
if (distance < 1)
distance = 1;
ArrayList<Block> blocks = new ArrayList<>();
List<Block> blocks = new ArrayList<>();
try {
Block bl = player.getTargetBlock(null, distance);
@ -208,10 +209,6 @@ public class Util {
return getFilesFromPackage(pckgname, null, "class");
}
public static List<String> getFilesFromPackage(String pckgname, String cleaner) throws ClassNotFoundException {
return getFilesFromPackage(pckgname, cleaner, "class");
}
public static List<String> getFilesFromPackage(String pckgname, String cleaner, String fileType) throws ClassNotFoundException {
List<String> result = new ArrayList<>();
try {
@ -234,8 +231,7 @@ public class Util {
jarFile = new JarFile(jarPath);
Enumeration<JarEntry> en = jarFile.entries();
while (en.hasMoreElements()) {
JarEntry entry = en.nextElement();
String entryName = entry.getName();
String entryName = en.nextElement().getName();
packageName = packageName.replace('.', '/');

View File

@ -13,7 +13,7 @@ public class blockLoc {
private World w;
public blockLoc(String loc) {
this.fromString(loc);
fromString(loc);
}
public blockLoc(Location loc) {
@ -77,17 +77,14 @@ public class blockLoc {
}
public Block getBlock() {
Location loc = this.getLocation();
if (loc == null)
return null;
return loc.getBlock();
Location loc = getLocation();
return loc == null ? null : loc.getBlock();
}
public Location getLocation() {
if (worldName == null && this.w == null)
if (worldName == null && w == null)
return null;
World w = this.w == null ? Bukkit.getWorld(worldName) : this.w;
if (w == null)
return null;