1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Some things

This commit is contained in:
montlikadani 2020-08-22 20:40:25 +02:00
parent a1840098ba
commit 94f4a46cd3
31 changed files with 161 additions and 188 deletions

View File

@ -16,3 +16,25 @@ A fully configurable plugin that allows you to get paid for breaking, placing, k
Main pages:
- Bukkit: https://dev.bukkit.org/projects/jobs-reborn
- Spigot: https://www.spigotmc.org/resources/4216/
# Jobs API
You can manually add the jar file to your build path or you can use jitpack if you use maven (don't know gradle):
```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.Zrips</groupId>
<artifactId>Jobs</artifactId>
<version>LATEST</version> <!-- Change the LATEST to the current version of jobs -->
<scope>provided</scope>
</dependency>
</dependencies>
```
For API events: https://github.com/Zrips/Jobs/wiki/API

View File

@ -1,14 +1,10 @@
package com.gamingmesh.jobs.CMILib;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;

View File

@ -140,7 +140,7 @@ public class ItemBoostManager {
List<String> lore = new ArrayList<>();
if (cfg.getC().contains(one + ".lore") && !cfg.getC().getStringList(one + ".lore").isEmpty()) {
for (String eachLine : cfg.get(one + ".lore", Arrays.asList(""))) {
lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
lore.add(CMIChatColor.translate(eachLine));
}
}
@ -213,9 +213,9 @@ public class ItemBoostManager {
public static List<JobItems> getItemsByJob(Job job) {
List<JobItems> ls = new ArrayList<>();
for (Entry<String, JobItems> one : items.entrySet()) {
if (one.getValue().getJobs().contains(job))
ls.add(one.getValue());
for (JobItems one : items.values()) {
if (one.getJobs().contains(job))
ls.add(one);
}
return ls;
}

View File

@ -60,7 +60,6 @@ import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Logger;
public class Jobs extends JavaPlugin {
@ -444,11 +443,11 @@ public class Jobs extends JavaPlugin {
HashMap<Integer, HashMap<String, Log>> playersLogs = dao.getAllLogs();
HashMap<Integer, ArchivedJobs> playersArchives = dao.getAllArchivedJobs();
HashMap<Integer, PaymentData> playersLimits = dao.loadPlayerLimits();
for (Iterator<Entry<UUID, PlayerInfo>> it = temp.entrySet().iterator(); it.hasNext();) {
Entry<UUID, PlayerInfo> one = it.next();
int id = one.getValue().getID();
for (Iterator<PlayerInfo> it = temp.values().iterator(); it.hasNext();) {
PlayerInfo one = it.next();
int id = one.getID();
JobsPlayer jPlayer = getPlayerManager().getJobsPlayerOffline(
one.getValue(),
one,
playersJobs.get(id),
playersPoints.get(id),
playersLogs.get(id),
@ -1181,12 +1180,13 @@ public class Jobs extends JavaPlugin {
getBpManager().add(block, cd);
return true;
}
if (time > System.currentTimeMillis() || bp.isPaid() && bp.getAction() != DBAction.DELETE) {
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
if (inform) {
if (player.canGetPaid(info))
if (inform && player.canGetPaid(info)) {
ActionBarManager.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
}
getBpManager().add(block, cd);
return false;
}

View File

@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
@ -63,30 +62,29 @@ import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.dao.JobsDAOData;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.economy.PointsData;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.stuff.PerformCommands;
import com.gamingmesh.jobs.stuff.Util;
public class PlayerManager {
private ConcurrentHashMap<String, JobsPlayer> playersCache = new ConcurrentHashMap<>();
private ConcurrentHashMap<UUID, JobsPlayer> playersUUIDCache = new ConcurrentHashMap<>();
private ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<>();
private ConcurrentHashMap<UUID, JobsPlayer> playersUUID = new ConcurrentHashMap<>();
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 String mobSpawnerMetadata = "jobsMobSpawner";
private HashMap<UUID, PlayerInfo> PlayerUUIDMap = new HashMap<>();
private HashMap<Integer, PlayerInfo> PlayerIDMap = new HashMap<>();
private HashMap<String, PlayerInfo> PlayerNameMap = new HashMap<>();
private final HashMap<UUID, PlayerInfo> PlayerUUIDMap = new HashMap<>();
private final HashMap<Integer, PlayerInfo> PlayerIDMap = new HashMap<>();
private final HashMap<String, PlayerInfo> PlayerNameMap = new HashMap<>();
/**
* @deprecated Use {@link Jobs#getPointsData} instead
* @return {@link PointsData}
* @return {@link com.gamingmesh.jobs.economy.PointsData}
*/
@Deprecated
public PointsData getPointsData() {
public com.gamingmesh.jobs.economy.PointsData getPointsData() {
return Jobs.getPointsData();
}
@ -264,9 +262,7 @@ public class PlayerManager {
int i = 0;
int total = playersUUIDCache.size();
for (Entry<UUID, JobsPlayer> one : playersUUIDCache.entrySet()) {
JobsPlayer jPlayer = one.getValue();
for (JobsPlayer jPlayer : playersUUIDCache.values()) {
if (resetID)
jPlayer.setUserId(-1);

View File

@ -5,7 +5,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -142,8 +141,7 @@ public class SignUtil {
conf.createSection("Signs");
int i = 0;
for (Entry<String, jobsSign> one : SignsByLocation.entrySet()) {
jobsSign sign = one.getValue();
for (jobsSign sign : SignsByLocation.values()) {
++i;
String path = "Signs." + i;
reader.set(path + ".Loc", sign.locToBlockString());
@ -204,8 +202,7 @@ public class SignUtil {
HashMap<String, List<TopList>> temp = new HashMap<>();
boolean save = false;
for (Entry<String, jobsSign> one : (new HashMap<String, jobsSign>(signs)).entrySet()) {
jobsSign jSign = one.getValue();
for (jobsSign jSign : (new HashMap<String, jobsSign>(signs)).values()) {
String SignJobName = jSign.getJobName();
Location loc = jSign.getLocation();
if (loc == null)

View File

@ -147,13 +147,13 @@ public class JobsCommands implements CommandExecutor {
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.title"));
for (Entry<String, Integer> one : commands.entrySet()) {
for (String one : commands.keySet()) {
if (!pi.isEntryOk())
continue;
if (pi.isBreak())
break;
String msg = Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one.getKey()), "[description]", Jobs.getLanguage().getMessage("command." + one.getKey()
String msg = Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one), "[description]", Jobs.getLanguage().getMessage("command." + one
+ ".help.info"));
sender.sendMessage(msg);
}
@ -259,10 +259,7 @@ public class JobsCommands implements CommandExecutor {
return;
}
if (type == null) {
type = "";
} else
type = type.toLowerCase();
type = type == null ? "" : type.toLowerCase();
List<String> message = new ArrayList<>();

View File

@ -58,8 +58,8 @@ public class log implements Cmd {
Map<String, Double> unsortMap = new HashMap<>();
for (Entry<String, Log> l : logList.entrySet()) {
for (Entry<String, LogAmounts> oneMap : l.getValue().getAmountList().entrySet()) {
for (Log l : logList.values()) {
for (Entry<String, LogAmounts> oneMap : l.getAmountList().entrySet()) {
unsortMap.put(oneMap.getKey(), oneMap.getValue().get(CurrencyType.MONEY));
}
}
@ -74,15 +74,14 @@ public class log implements Cmd {
int max = 10;
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getName()));
for (Entry<String, Log> l : logList.entrySet()) {
Log one = l.getValue();
for (Log one : logList.values()) {
HashMap<String, LogAmounts> AmountList = one.getAmountList();
double totalMoney = 0,
totalExp = 0,
totalPoints = 0;
for (Entry<String, Double> oneSorted : unsortMap.entrySet()) {
for (String oneSorted : unsortMap.keySet()) {
for (Entry<String, LogAmounts> oneMap : AmountList.entrySet()) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted.getKey())) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted)) {
count++;
LogAmounts amounts = oneMap.getValue();

View File

@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.QuestObjective;
@ -109,8 +108,8 @@ public class quests implements Cmd {
}
}
for (Entry<ActionType, HashMap<String, QuestObjective>> oneAction : q.getQuest().getObjectives().entrySet()) {
for (Entry<String, QuestObjective> oneObjective : oneAction.getValue().entrySet()) {
for (HashMap<String, QuestObjective> oneAction : q.getQuest().getObjectives().values()) {
for (Entry<String, QuestObjective> oneObjective : oneAction.entrySet()) {
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
Jobs.getNameTranslatorManager().Translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
.getTargetMeta(), oneObjective.getValue().getTargetName())

View File

@ -2,7 +2,6 @@ package com.gamingmesh.jobs.commands.list;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -10,7 +9,6 @@ import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.QuestObjective;
@ -58,9 +56,9 @@ public class resetquest implements Cmd {
for (QuestProgression one : quests) {
one.setValidUntil(System.currentTimeMillis());
for (Entry<ActionType, HashMap<String, QuestObjective>> actions : one.getQuest().getObjectives().entrySet()) {
for (java.util.Map.Entry<String, QuestObjective> obj : actions.getValue().entrySet()) {
one.setAmountDone(obj.getValue(), 0);
for (HashMap<String, QuestObjective> actions : one.getQuest().getObjectives().values()) {
for (QuestObjective obj : actions.values()) {
one.setAmountDone(obj, 0);
}
}
}

View File

@ -18,7 +18,7 @@ import com.gamingmesh.jobs.stuff.Util;
public class ExploreManager {
private HashMap<String, ExploreRegion> worlds = new HashMap<>();
private final HashMap<String, ExploreRegion> worlds = new HashMap<>();
private boolean exploreEnabled = false;
private int playerAmount = 1;

View File

@ -21,13 +21,13 @@ import com.gamingmesh.jobs.hooks.HookManager;
public class RestrictedAreaManager {
protected HashMap<String, RestrictedArea> restrictedAreas = new HashMap<>();
protected final HashMap<String, RestrictedArea> restrictedAreas = new HashMap<>();
private boolean worldGuardArea = false;
public boolean isExist(String name) {
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
if (area.getKey().equalsIgnoreCase(name))
for (String area : restrictedAreas.keySet()) {
if (area.equalsIgnoreCase(name))
return true;
}
return false;
@ -44,9 +44,9 @@ public class RestrictedAreaManager {
}
public void remove(String name) {
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
if (area.getKey().equalsIgnoreCase(name)) {
restrictedAreas.remove(area.getKey());
for (String area : restrictedAreas.keySet()) {
if (area.equalsIgnoreCase(name)) {
restrictedAreas.remove(area);
break;
}
}
@ -120,9 +120,9 @@ public class RestrictedAreaManager {
public synchronized List<RestrictedArea> getRestrictedAreasByLoc(Location loc) {
List<RestrictedArea> areas = new ArrayList<>();
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
if (area.getValue().inRestrictedArea(loc))
areas.add(area.getValue());
for (RestrictedArea area : restrictedAreas.values()) {
if (area.inRestrictedArea(loc))
areas.add(area);
}
if (worldGuardArea && HookManager.getWorldGuardManager() != null)

View File

@ -11,7 +11,7 @@ import com.gamingmesh.jobs.CMILib.ItemManager;
public class RestrictedBlockManager {
public HashMap<CMIMaterial, Integer> restrictedBlocksTimer = new HashMap<>();
public final HashMap<CMIMaterial, Integer> restrictedBlocksTimer = new HashMap<>();
/**
* Method to load the restricted blocks configuration

View File

@ -13,7 +13,7 @@ import com.gamingmesh.jobs.stuff.ChatColor;
public class TitleManager {
protected List<Title> titles = new ArrayList<>();
protected final List<Title> titles = new ArrayList<>();
/**
* Function to return the title for a given level

View File

@ -38,9 +38,7 @@ public class BlockProtection {
}
private static int convert(long time) {
if (time == -1L)
return -1;
return (int) ((time - pre) / 1000L);
return time == -1L ? -1 : (int) ((time - pre) / 1000L);
}
private static Long deconvert(Integer time) {
@ -48,10 +46,7 @@ public class BlockProtection {
}
public void setTime(Long time) {
if (time == -1)
this.time = null;
else
this.time = convert(time);
this.time = time == -1 ? null : convert(time);
this.recorded = convert(System.currentTimeMillis());
}
@ -74,10 +69,7 @@ public class BlockProtection {
}
public void setPaid(Boolean paid) {
if (!paid)
this.paid = paid;
else
this.paid = null;
this.paid = !paid ? paid : null;
}
public void setRecorded(Long recorded) {

View File

@ -50,15 +50,11 @@ public class ExploreChunk {
}
public boolean isAlreadyVisited(int playerId) {
if (isFullyExplored())
return true;
return playerIds.contains(playerId);
return isFullyExplored() ? true : playerIds.contains(playerId);
}
public int getCount() {
if (isFullyExplored())
return Jobs.getExplore().getPlayerAmount();
return playerIds.size();
return isFullyExplored() ? Jobs.getExplore().getPlayerAmount() : playerIds.size();
}
public int getX() {
@ -135,13 +131,10 @@ public class ExploreChunk {
}
public void setUpdated(boolean updated) {
if (!updated)
this.updated = null;
else
this.updated = true;
this.updated = !updated ? null : true;
}
public boolean isFullyExplored() {
return full == null ? false : full;
return full != null && full;
}
}

View File

@ -8,7 +8,8 @@ public class ExploreRegion {
int x;
int z;
private HashMap<String, ExploreChunk> chunks = new HashMap<>();
private final HashMap<String, ExploreChunk> chunks = new HashMap<>();
public ExploreRegion(int x, int z) {
this.x = x;

View File

@ -23,7 +23,7 @@ import java.util.List;
public class JobCommands {
private String node;
private List<String> commands = new ArrayList<>();
private final List<String> commands = new ArrayList<>();
private int levelFrom;
private int levelUntil;

View File

@ -23,12 +23,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
public class JobLimitedItems {
@ -66,11 +66,11 @@ public class JobLimitedItems {
item.setAmount(amount);
ItemMeta meta = item.getItemMeta();
if (this.name != null)
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
meta.setDisplayName(CMIChatColor.translate(name));
if (lore != null && !lore.isEmpty()) {
List<String> TranslatedLore = new ArrayList<>();
for (String oneLore : lore) {
TranslatedLore.add(ChatColor.translateAlternateColorCodes('&', oneLore.replace("[player]", player.getName())));
TranslatedLore.add(CMIChatColor.translate(oneLore.replace("[player]", player.getName())));
}
meta.setLore(TranslatedLore);
}

View File

@ -47,12 +47,12 @@ public class JobsPlayer {
private String userName = "Unknown";
// progression of the player in each job
public UUID playerUUID;
public ArrayList<JobProgression> progression = new ArrayList<>();
public final ArrayList<JobProgression> progression = new ArrayList<>();
private ArchivedJobs archivedJobs = new ArchivedJobs();
private PaymentData paymentLimits;
private HashMap<String, ArrayList<BoostCounter>> boostCounter = new HashMap<>();
private final HashMap<String, ArrayList<BoostCounter>> boostCounter = new HashMap<>();
// display honorific
private String honorific;
@ -61,12 +61,12 @@ public class JobsPlayer {
// player online status
private volatile boolean isOnline = false;
private HashMap<CurrencyType, Integer> limits = new HashMap<>();
private final HashMap<CurrencyType, Integer> limits = new HashMap<>();
private int userid = -1;
private List<BossBarInfo> barMap = new ArrayList<>();
private List<String> updateBossBarFor = new ArrayList<>();
private final List<BossBarInfo> barMap = new ArrayList<>();
private final List<String> updateBossBarFor = new ArrayList<>();
// save lock
// public final Object saveLock = new Object();
@ -78,7 +78,7 @@ public class JobsPlayer {
private HashMap<String, Boolean> permissionsCache;
private Long lastPermissionUpdate = -1L;
private HashMap<String, HashMap<String, QuestProgression>> qProgression = new HashMap<>();
private final HashMap<String, HashMap<String, QuestProgression>> qProgression = new HashMap<>();
private int doneQuests = 0;
private int skippedQuests = 0;
@ -340,10 +340,8 @@ public class JobsPlayer {
}
public int getLimit(CurrencyType type) {
if (type == null)
return 0;
Integer value = limits.get(type);
return value == null ? 0 : value;
Integer value = type == null ? 0 : limits.get(type);
return value;
}
public void resetPaymentLimit() {

View File

@ -31,9 +31,7 @@ public class PlayerInfo {
public String getName() {
if (player == null)
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
if (player != null)
return player.getName();
return name;
return player != null ? player.getName() : name;
}
public int getID() {

View File

@ -5,7 +5,6 @@ import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import com.gamingmesh.jobs.Jobs;
@ -21,14 +20,14 @@ public class Quest {
private Integer minLvl = null;
private Integer maxLvl = null;
private List<String> rewardCmds = new ArrayList<>();
private List<String> rewards = new ArrayList<>();
private List<String> area = new ArrayList<>();
private final List<String> rewardCmds = new ArrayList<>();
private final List<String> rewards = new ArrayList<>();
private final List<String> area = new ArrayList<>();
private boolean stopped = false;
private HashMap<ActionType, HashMap<String, QuestObjective>> objectives = new HashMap<>();
private Set<ActionType> actions = new HashSet<>();
private final Set<ActionType> actions = new HashSet<>();
public Quest(String questName, Job job) {
this.questName = questName;
@ -167,11 +166,10 @@ public class Quest {
if (old == null)
return false;
for (Entry<String, QuestObjective> one : old.entrySet()) {
if (one.getValue().getTargetId() == objective.getTargetId() &&
one.getValue().getAction() == objective.getAction() &&
objective.getAmount() == one.getValue().getAmount() &&
objective.getTargetName() == one.getValue().getTargetName())
for (QuestObjective one : old.values()) {
if (one.getTargetId() == objective.getTargetId() &&
one.getAction() == objective.getAction() && objective.getAmount() == one.getAmount()
&& objective.getTargetName() == one.getTargetName())
return true;
}
return false;
@ -179,9 +177,7 @@ public class Quest {
public void setObjectives(HashMap<ActionType, HashMap<String, QuestObjective>> objectives) {
this.objectives = objectives;
for (Entry<ActionType, HashMap<String, QuestObjective>> one : objectives.entrySet()) {
actions.add(one.getKey());
}
objectives.keySet().forEach(actions::add);
}
public void addObjective(QuestObjective objective) {

View File

@ -15,7 +15,7 @@ public class QuestProgression {
private long validUntil;
private boolean givenReward = false;
private HashMap<QuestObjective, Integer> done = new HashMap<>();
private final HashMap<QuestObjective, Integer> done = new HashMap<>();
public QuestProgression(Quest quest) {
this.quest = quest;
@ -34,9 +34,9 @@ public class QuestProgression {
public int getTotalAmountNeeded() {
int amountNeeded = 0;
for (Entry<ActionType, HashMap<String, QuestObjective>> oneA : quest.getObjectives().entrySet()) {
for (Entry<String, QuestObjective> one : oneA.getValue().entrySet()) {
amountNeeded += one.getValue().getAmount();
for (HashMap<String, QuestObjective> oneA : quest.getObjectives().values()) {
for (QuestObjective one : oneA.values()) {
amountNeeded += one.getAmount();
}
}
return amountNeeded;
@ -44,9 +44,10 @@ public class QuestProgression {
public int getTotalAmountDone() {
int amountDone = 0;
for (Entry<QuestObjective, Integer> one : done.entrySet()) {
amountDone += one.getValue();
for (Integer one : done.values()) {
amountDone += one;
}
return amountDone;
}
@ -77,10 +78,10 @@ public class QuestProgression {
}
public boolean isCompleted() {
for (Entry<ActionType, HashMap<String, QuestObjective>> oneA : quest.getObjectives().entrySet()) {
for (Entry<String, QuestObjective> one : oneA.getValue().entrySet()) {
Integer amountDone = done.get(one.getValue());
if (amountDone == null || amountDone < one.getValue().getAmount())
for (HashMap<String, QuestObjective> oneA : quest.getObjectives().values()) {
for (QuestObjective one : oneA.values()) {
Integer amountDone = done.get(one);
if (amountDone == null || amountDone < one.getAmount())
return false;
}
}
@ -99,7 +100,7 @@ public class QuestProgression {
.containsKey(action.getName()))
return;
if (quest.getRestrictedAreas() != null && !quest.getRestrictedAreas().isEmpty()) {
if (!quest.getRestrictedAreas().isEmpty()) {
for (String area : quest.getRestrictedAreas()) {
for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) {
if (quest.getRestrictedAreas().contains(a.getKey()) && a.getKey().equalsIgnoreCase(area)

View File

@ -17,14 +17,14 @@ public class Schedule {
private boolean nextDay = false;
private BoostMultiplier BM = new BoostMultiplier();
private final BoostMultiplier BM = new BoostMultiplier();
private String Name = null;
private List<String> Days = new ArrayList<>(Arrays.asList("all"));
private List<Job> JobsList = new ArrayList<>();
private final List<Job> JobsList = new ArrayList<>();
private List<String> MessageOnStart = new ArrayList<>(),
private final List<String> MessageOnStart = new ArrayList<>(),
MessageOnStop = new ArrayList<>(),
MessageToBroadcast = new ArrayList<>();

View File

@ -969,9 +969,9 @@ public abstract class JobsDAO {
try {
exploreStatement = conn.prepareStatement("UPDATE `" + DBTables.ExploreDataTable.getTableName() + "` SET `" + ExploreDataTableFields.worldid.getCollumn() + "` = ? WHERE `"
+ ExploreDataTableFields.worldname.getCollumn() + "` = ?;");
for (Entry<String, JobsWorld> jobsWorld : Util.getJobsWorlds().entrySet()) {
exploreStatement.setInt(1, jobsWorld.getValue().getId());
exploreStatement.setString(2, jobsWorld.getValue().getName());
for (JobsWorld jobsWorld : Util.getJobsWorlds().values()) {
exploreStatement.setInt(1, jobsWorld.getId());
exploreStatement.setString(2, jobsWorld.getName());
exploreStatement.execute();
}
} catch (SQLException e) {
@ -984,9 +984,9 @@ public abstract class JobsDAO {
try {
exploreStatementBack = conn.prepareStatement("UPDATE `" + DBTables.ExploreDataTable.getTableName() + "` SET `" + ExploreDataTableFields.worldname.getCollumn() + "` = ? WHERE `"
+ ExploreDataTableFields.worldid.getCollumn() + "` = ?;");
for (Entry<String, JobsWorld> jobsWorld : Util.getJobsWorlds().entrySet()) {
exploreStatementBack.setString(1, jobsWorld.getValue().getName());
exploreStatementBack.setInt(2, jobsWorld.getValue().getId());
for (JobsWorld jobsWorld : Util.getJobsWorlds().values()) {
exploreStatementBack.setString(1, jobsWorld.getName());
exploreStatementBack.setInt(2, jobsWorld.getId());
exploreStatementBack.execute();
}
} catch (SQLException e) {
@ -999,9 +999,9 @@ public abstract class JobsDAO {
try {
bpStatement = conn.prepareStatement("UPDATE `" + DBTables.BlocksTable.getTableName() + "` SET `" + BlockTableFields.worldid.getCollumn() + "` = ? WHERE `" + BlockTableFields.world
.getCollumn() + "` = ?;");
for (Entry<String, JobsWorld> jobsWorld : Util.getJobsWorlds().entrySet()) {
bpStatement.setInt(1, jobsWorld.getValue().getId());
bpStatement.setString(2, jobsWorld.getValue().getName());
for (JobsWorld jobsWorld : Util.getJobsWorlds().values()) {
bpStatement.setInt(1, jobsWorld.getId());
bpStatement.setString(2, jobsWorld.getName());
bpStatement.execute();
}
} catch (SQLException e) {
@ -1014,9 +1014,9 @@ public abstract class JobsDAO {
try {
bpStatementback = conn.prepareStatement("UPDATE `" + DBTables.BlocksTable.getTableName() + "` SET `" + BlockTableFields.world.getCollumn() + "` = ? WHERE `" + BlockTableFields.worldid
.getCollumn() + "` = ?;");
for (Entry<String, JobsWorld> jobsWorld : Util.getJobsWorlds().entrySet()) {
bpStatementback.setString(1, jobsWorld.getValue().getName());
bpStatementback.setInt(2, jobsWorld.getValue().getId());
for (JobsWorld jobsWorld : Util.getJobsWorlds().values()) {
bpStatementback.setString(1, jobsWorld.getName());
bpStatementback.setInt(2, jobsWorld.getId());
bpStatementback.execute();
}
} catch (SQLException e) {
@ -1997,8 +1997,7 @@ public abstract class JobsDAO {
+ "` = ? AND `" + LogTableFields.action.getCollumn() + "` = ? AND `" + LogTableFields.itemname.getCollumn() + "` = ?;");
boolean added = false;
for (Entry<String, Log> l : player.getLog().entrySet()) {
Log log = l.getValue();
for (Log log : player.getLog().values()) {
for (Entry<String, LogAmounts> one : log.getAmountList().entrySet()) {
if (one.getValue().isNewEntry())
continue;
@ -2025,8 +2024,7 @@ public abstract class JobsDAO {
+ "` (`" + LogTableFields.userid.getCollumn() + "`, `" + LogTableFields.time.getCollumn() + "`, `" + LogTableFields.action.getCollumn()
+ "`, `" + LogTableFields.itemname.getCollumn() + "`, `" + LogTableFields.count.getCollumn() + "`, `" + LogTableFields.money.getCollumn()
+ "`, `" + LogTableFields.exp.getCollumn() + "`, `" + LogTableFields.points.getCollumn() + "`) VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
for (Entry<String, Log> l : player.getLog().entrySet()) {
Log log = l.getValue();
for (Log log : player.getLog().values()) {
for (Entry<String, LogAmounts> one : log.getAmountList().entrySet()) {
if (!one.getValue().isNewEntry())
continue;
@ -2317,13 +2315,13 @@ public abstract class JobsDAO {
int id = jobsWorld == null ? 0 : jobsWorld.getId();
if (id != 0)
for (Entry<String, ExploreChunk> oneChunk : worlds.getValue().getChunks().entrySet()) {
if (oneChunk.getValue().getDbId() != null)
for (ExploreChunk oneChunk : worlds.getValue().getChunks().values()) {
if (oneChunk.getDbId() != null)
continue;
prest2.setInt(1, id);
prest2.setInt(2, oneChunk.getValue().getX());
prest2.setInt(3, oneChunk.getValue().getZ());
prest2.setString(4, oneChunk.getValue().serializeNames());
prest2.setInt(2, oneChunk.getX());
prest2.setInt(3, oneChunk.getZ());
prest2.setString(4, oneChunk.serializeNames());
prest2.setString(5, jobsWorld != null ? jobsWorld.getName() : "");
prest2.addBatch();
i++;
@ -2364,14 +2362,14 @@ public abstract class JobsDAO {
HashMap<String, ExploreRegion> temp = new HashMap<>(Jobs.getExplore().getWorlds());
for (Entry<String, ExploreRegion> worlds : temp.entrySet()) {
for (Entry<String, ExploreChunk> oneChunk : worlds.getValue().getChunks().entrySet()) {
if (oneChunk.getValue().getDbId() == null)
for (ExploreRegion worlds : temp.values()) {
for (ExploreChunk oneChunk : worlds.getChunks().values()) {
if (oneChunk.getDbId() == null)
continue;
if (!oneChunk.getValue().isUpdated())
if (!oneChunk.isUpdated())
continue;
prest.setString(1, oneChunk.getValue().serializeNames());
prest.setInt(2, oneChunk.getValue().getDbId());
prest.setString(1, oneChunk.serializeNames());
prest.setInt(2, oneChunk.getDbId());
prest.addBatch();
i++;
}

View File

@ -5,19 +5,17 @@ import java.util.UUID;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.PlayerPoints;
@Deprecated
public class PointsData {
@Deprecated
public void addPlayer(UUID uuid) {
Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData();
}
@Deprecated
public void addPlayer(UUID uuid, double points) {
Jobs.getPlayerManager().getJobsPlayer(uuid).addPoints(points);
}
@Deprecated
public void addPlayer(UUID uuid, double points, double total) {
addPlayer(uuid, new PlayerPoints(points, total));
@ -25,7 +23,6 @@ public class PointsData {
Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData().setTotalPoints(total);
}
@Deprecated
public void addPlayer(UUID uuid, PlayerPoints points) {
PlayerPoints pi = Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData();
pi.setPoints(points.getCurrentPoints());
@ -33,12 +30,10 @@ public class PointsData {
pi.setNewEntry(points.isNewEntry());
}
@Deprecated
public void addPoints(UUID uuid, Double points) {
Jobs.getPlayerManager().getJobsPlayer(uuid).addPoints(points);
}
@Deprecated
public PlayerPoints getPlayerPointsInfo(UUID uuid) {
return Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData();
}

View File

@ -496,10 +496,10 @@ public class JobsListener implements Listener {
List<JobProgression> prog = JPlayer.getJobProgression();
mein: for (JobProgression one : prog) {
for (Entry<String, JobLimitedItems> oneItem : one.getJob().getLimitedItems().entrySet()) {
if (one.getLevel() >= oneItem.getValue().getLevel())
for (JobLimitedItems oneItem : one.getJob().getLimitedItems().values()) {
if (one.getLevel() >= oneItem.getLevel())
continue;
if (!isThisItem(oneItem.getValue(), CMIMaterial.get(iih), name, lore, enchants))
if (!isThisItem(oneItem, CMIMaterial.get(iih), name, lore, enchants))
continue;
meinOk = one.getJob().getName();
break mein;

View File

@ -376,8 +376,8 @@ public class JobsPaymentListener implements Listener {
if (item != null && item.getType() != Material.AIR) {
// Protection for block break with silktouch
if (Jobs.getGCManager().useSilkTouchProtection) {
for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet()) {
if (CMIEnchantment.get(one.getKey()) == CMIEnchantment.SILK_TOUCH) {
for (Enchantment one : item.getEnchantments().keySet()) {
if (CMIEnchantment.get(one) == CMIEnchantment.SILK_TOUCH) {
if (Jobs.getBpManager().isInBp(block))
return;
}

View File

@ -1,7 +1,6 @@
package com.gamingmesh.jobs.stuff;
import java.util.HashMap;
import java.util.Map.Entry;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.ActionInfo;
@ -18,8 +17,8 @@ public class Loging {
public void recordToLog(JobsPlayer jPlayer, String ActionName, String item, HashMap<CurrencyType, Double> amounts) {
HashMap<String, Log> logList = jPlayer.getLog();
Log l = null;
for (Entry<String, Log> one : logList.entrySet()) {
l = one.getValue();
for (Log one : logList.values()) {
l = one;
break;
}
if (l != null && Jobs.getScheduleManager().getDateByInt() != l.getDate()) {

View File

@ -3,7 +3,6 @@ package com.gamingmesh.jobs.stuff;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@ -32,8 +31,8 @@ public class TabComplete implements TabCompleter {
String PartOfCommand = args[0];
List<String> temp = new ArrayList<>();
for (Entry<String, Integer> BCmd : Jobs.getCommandManager().GetCommands(sender).entrySet()) {
temp.add(BCmd.getKey());
for (String BCmd : Jobs.getCommandManager().GetCommands(sender).keySet()) {
temp.add(BCmd);
}
StringUtil.copyPartialMatches(PartOfCommand, temp, completionList);
}
@ -91,20 +90,20 @@ public class TabComplete implements TabCompleter {
}
break;
case "[jobitemname]":
for (Entry<String, JobItems> one : ItemBoostManager.getItems().entrySet()) {
temp.add(one.getValue().getNode());
for (JobItems one : ItemBoostManager.getItems().values()) {
temp.add(one.getNode());
}
if (args.length > 3 && args[3].equalsIgnoreCase("limiteditems")) {
Job oneJob = Jobs.getJob(args[i - 1]);
if (oneJob != null)
for (Entry<String, JobLimitedItems> limitedItem : oneJob.getLimitedItems().entrySet()) {
temp.add(limitedItem.getValue().getNode());
for (JobLimitedItems limitedItem : oneJob.getLimitedItems().values()) {
temp.add(limitedItem.getNode());
}
}
break;
case "[boosteditems]":
for (Entry<String, JobItems> one : ItemBoostManager.getItems().entrySet()) {
temp.add(one.getValue().getNode());
for (JobItems one : ItemBoostManager.getItems().values()) {
temp.add(one.getNode());
}
break;
case "[oldjob]":

View File

@ -9,7 +9,6 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.UUID;
@ -179,9 +178,9 @@ public class Util {
}
public static JobsWorld getJobsWorld(int id) {
for (Entry<String, JobsWorld> one : jobsWorlds.entrySet()) {
if (one.getValue().getId() == id)
return one.getValue();
for (JobsWorld one : jobsWorlds.values()) {
if (one.getId() == id)
return one;
}
return null;
}