mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 23:13:48 +01:00
A bit more improvements
This commit is contained in:
parent
7a17a982da
commit
4e2928460e
@ -155,8 +155,7 @@ public class Jobs extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (addNew && b == null) {
|
||||
b = new BlockOwnerShip(type);
|
||||
blockOwnerShips.add(b);
|
||||
blockOwnerShips.add(b = new BlockOwnerShip(type));
|
||||
}
|
||||
|
||||
return Optional.ofNullable(b);
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
@ -111,7 +111,7 @@ public class editquests implements Cmd {
|
||||
return false;
|
||||
}
|
||||
|
||||
HashMap<String, QuestObjective> obj = quest.getObjectives().get(actionT);
|
||||
Map<String, QuestObjective> obj = quest.getObjectives().get(actionT);
|
||||
|
||||
if (obj == null || obj.isEmpty())
|
||||
return false;
|
||||
@ -179,7 +179,7 @@ public class editquests implements Cmd {
|
||||
return false;
|
||||
}
|
||||
|
||||
HashMap<String, QuestObjective> obj = quest.getObjectives().get(actionT);
|
||||
Map<String, QuestObjective> obj = quest.getObjectives().get(actionT);
|
||||
if (obj == null || obj.isEmpty())
|
||||
return false;
|
||||
|
||||
@ -207,7 +207,7 @@ public class editquests implements Cmd {
|
||||
return false;
|
||||
}
|
||||
|
||||
HashMap<String, QuestObjective> obj = q.getObjectives().get(actionT);
|
||||
Map<String, QuestObjective> obj = q.getObjectives().get(actionT);
|
||||
if (obj == null || obj.isEmpty())
|
||||
return false;
|
||||
|
||||
@ -610,11 +610,9 @@ public class editquests implements Cmd {
|
||||
if (action != null && job != null && jInfo != null && q != null) {
|
||||
rm = new RawMessage();
|
||||
|
||||
String materialName = jInfo.getRealisticName();
|
||||
|
||||
rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.list.quests", "%questname%", q.getConfigName()))
|
||||
.addHover(jInfo.getName()).addCommand("jobs editquests list " + job.getName() + " " + action.getName() + " " + q.getConfigName()
|
||||
+ " " + materialName);
|
||||
+ " " + jInfo.getRealisticName());
|
||||
rm.show(player);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -104,7 +103,7 @@ public class quests implements Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
for (HashMap<String, QuestObjective> oneAction : q.getQuest().getObjectives().values()) {
|
||||
for (java.util.Map<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()
|
||||
|
@ -28,11 +28,6 @@ public class ArchivedJobs {
|
||||
}
|
||||
|
||||
public void removeArchivedJob(Job job) {
|
||||
for (JobProgression one : jobs) {
|
||||
if (one.getJob().isSame(job)) {
|
||||
jobs.remove(one);
|
||||
break;
|
||||
}
|
||||
}
|
||||
jobs.remove(getArchivedJobProgression(job));
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.gamingmesh.jobs.PlayerManager.BoostOf;
|
||||
|
||||
public class Boost {
|
||||
|
||||
private HashMap<BoostOf, BoostMultiplier> map = new HashMap<>();
|
||||
private java.util.Map<BoostOf, BoostMultiplier> map = new HashMap<>();
|
||||
|
||||
public Boost() {
|
||||
for (BoostOf one : BoostOf.values()) {
|
||||
@ -15,38 +15,38 @@ public class Boost {
|
||||
}
|
||||
}
|
||||
|
||||
public void add(BoostOf boostoff, BoostMultiplier BM) {
|
||||
map.put(boostoff, BM);
|
||||
public void add(BoostOf boostoff, BoostMultiplier multiplier) {
|
||||
map.put(boostoff, multiplier);
|
||||
}
|
||||
|
||||
public BoostMultiplier get(BoostOf boostoff) {
|
||||
return map.getOrDefault(boostoff, new BoostMultiplier());
|
||||
public BoostMultiplier get(BoostOf boostOf) {
|
||||
return map.getOrDefault(boostOf, new BoostMultiplier());
|
||||
}
|
||||
|
||||
public double get(BoostOf boostoff, CurrencyType BT) {
|
||||
return get(boostoff, BT, false);
|
||||
public double get(BoostOf boostOf, CurrencyType type) {
|
||||
return get(boostOf, type, false);
|
||||
}
|
||||
|
||||
public double get(BoostOf boostoff, CurrencyType BT, boolean percent) {
|
||||
if (!map.containsKey(boostoff))
|
||||
public double get(BoostOf boostOf, CurrencyType type, boolean percent) {
|
||||
if (!map.containsKey(boostOf))
|
||||
return 0D;
|
||||
double r = map.get(boostoff).get(BT);
|
||||
|
||||
double r = map.get(boostOf).get(type);
|
||||
if (r < -1)
|
||||
r = -1;
|
||||
if (percent)
|
||||
return (int) (r * 100);
|
||||
return r;
|
||||
|
||||
return percent ? (int) (r * 100) : r;
|
||||
}
|
||||
|
||||
public double getFinal(CurrencyType BT) {
|
||||
return getFinal(BT, false, false);
|
||||
public double getFinal(CurrencyType type) {
|
||||
return getFinal(type, false, false);
|
||||
}
|
||||
|
||||
public double getFinalAmount(CurrencyType BT, double income) {
|
||||
public double getFinalAmount(CurrencyType type, double income) {
|
||||
double f = income;
|
||||
|
||||
if (income > 0 || income < 0 && Jobs.getGCManager().applyToNegativeIncome)
|
||||
f = income + income * getFinal(BT, false, false);
|
||||
f = income + income * getFinal(type, false, false);
|
||||
|
||||
if (income > 0 && f < 0 || income < 0 && f > 0)
|
||||
f = 0;
|
||||
@ -54,7 +54,7 @@ public class Boost {
|
||||
return f;
|
||||
}
|
||||
|
||||
public double getFinal(CurrencyType BT, boolean percent, boolean excludeExtra) {
|
||||
public double getFinal(CurrencyType type, boolean percent, boolean excludeExtra) {
|
||||
double r = 0D;
|
||||
|
||||
for (BoostOf one : BoostOf.values()) {
|
||||
@ -64,10 +64,9 @@ public class Boost {
|
||||
if (excludeExtra && (one == BoostOf.NearSpawner || one == BoostOf.PetPay))
|
||||
continue;
|
||||
|
||||
if (!map.get(one).isValid(BT))
|
||||
continue;
|
||||
|
||||
r += map.get(one).get(BT);
|
||||
BoostMultiplier bm = map.get(one);
|
||||
if (bm.isValid(type))
|
||||
r += bm.get(type);
|
||||
}
|
||||
|
||||
if (r < -1)
|
||||
|
@ -4,7 +4,7 @@ import java.util.HashMap;
|
||||
|
||||
public class BoostMultiplier implements Cloneable {
|
||||
|
||||
private final HashMap<CurrencyType, Double> map = new HashMap<>();
|
||||
private final java.util.Map<CurrencyType, Double> map = new HashMap<>();
|
||||
|
||||
private Long time = 0L;
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
public class ExploreChunk {
|
||||
|
||||
private ArrayList<Integer> playerIds = new ArrayList<>();
|
||||
private List<Integer> playerIds = new ArrayList<>();
|
||||
private int dbId = -1;
|
||||
private boolean updated = false;
|
||||
|
||||
@ -16,12 +15,14 @@ public class ExploreChunk {
|
||||
if (isFullyExplored()) {
|
||||
return new ExploreRespond(Jobs.getExplore().getPlayerAmount() + 1, false);
|
||||
}
|
||||
|
||||
boolean newChunkForPlayer = false;
|
||||
if (!playerIds.contains(playerId)) {
|
||||
if (playerIds.size() < Jobs.getExplore().getPlayerAmount()) {
|
||||
playerIds.add(playerId);
|
||||
updated = true;
|
||||
}
|
||||
|
||||
newChunkForPlayer = true;
|
||||
}
|
||||
|
||||
@ -29,7 +30,8 @@ public class ExploreChunk {
|
||||
playerIds = null;
|
||||
}
|
||||
|
||||
return new ExploreRespond(newChunkForPlayer ? getPlayers().size() : getPlayers().size() + 1, newChunkForPlayer);
|
||||
List<Integer> players = getPlayers();
|
||||
return new ExploreRespond(newChunkForPlayer ? players.size() : players.size() + 1, newChunkForPlayer);
|
||||
}
|
||||
|
||||
public boolean isAlreadyVisited(int playerId) {
|
||||
@ -40,7 +42,7 @@ public class ExploreChunk {
|
||||
return isFullyExplored() ? Jobs.getExplore().getPlayerAmount() : playerIds.size();
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getPlayers() {
|
||||
public List<Integer> getPlayers() {
|
||||
return playerIds == null ? new ArrayList<>() : playerIds;
|
||||
}
|
||||
|
||||
@ -67,14 +69,13 @@ public class ExploreChunk {
|
||||
playerIds = new ArrayList<>();
|
||||
}
|
||||
|
||||
List<String> split = Arrays.asList(names.split(";"));
|
||||
for (String one : split) {
|
||||
for (String one : names.split(";")) {
|
||||
try {
|
||||
int id = Integer.parseInt(one);
|
||||
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(id);
|
||||
if (info != null)
|
||||
playerIds.add(id);
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
updated = true;
|
||||
JobsPlayer jp = Jobs.getPlayerManager().getJobsPlayer(one);
|
||||
if (jp != null)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
@ -9,7 +10,7 @@ public class ExploreRegion {
|
||||
int x;
|
||||
int z;
|
||||
|
||||
private final HashMap<Short, ExploreChunk> chunks = new HashMap<>();
|
||||
private final Map<Short, ExploreChunk> chunks = new HashMap<>();
|
||||
|
||||
public ExploreRegion(int x, int z) {
|
||||
this.x = x;
|
||||
@ -20,7 +21,7 @@ public class ExploreRegion {
|
||||
chunks.put(getPlace(x, z), chunk);
|
||||
}
|
||||
|
||||
public HashMap<Short, ExploreChunk> getChunks() {
|
||||
public Map<Short, ExploreChunk> getChunks() {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
|
@ -21,14 +21,15 @@ package com.gamingmesh.jobs.container;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JobConditions {
|
||||
|
||||
private String node;
|
||||
|
||||
private final List<String> requiresPerm = new ArrayList<>();
|
||||
private final HashMap<String, Integer> requiresJobs = new HashMap<>();
|
||||
private final HashMap<String, Boolean> performPerm = new HashMap<>();
|
||||
private final Map<String, Integer> requiresJobs = new HashMap<>();
|
||||
private final Map<String, Boolean> performPerm = new HashMap<>();
|
||||
|
||||
public JobConditions(String node, List<String> requires, List<String> perform) {
|
||||
this.node = node;
|
||||
@ -73,11 +74,11 @@ public class JobConditions {
|
||||
return requiresPerm;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getRequiredJobs() {
|
||||
public Map<String, Integer> getRequiredJobs() {
|
||||
return requiresJobs;
|
||||
}
|
||||
|
||||
public HashMap<String, Boolean> getPerformPerm() {
|
||||
public Map<String, Boolean> getPerformPerm() {
|
||||
return performPerm;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
@ -92,7 +93,7 @@ public class JobProgression {
|
||||
public boolean addExperience(double experience) {
|
||||
jPlayer.setSaved(false);
|
||||
this.experience += experience;
|
||||
this.lastExperience = getLastExperience() + experience;
|
||||
lastExperience = getLastExperience() + experience;
|
||||
return checkLevelUp();
|
||||
}
|
||||
|
||||
@ -115,7 +116,7 @@ public class JobProgression {
|
||||
public boolean takeExperience(double experience) {
|
||||
jPlayer.setSaved(false);
|
||||
this.experience -= experience;
|
||||
this.lastExperience = getLastExperience() + experience;
|
||||
lastExperience = getLastExperience() + experience;
|
||||
return checkLevelUp();
|
||||
}
|
||||
|
||||
@ -151,14 +152,14 @@ public class JobProgression {
|
||||
* Reloads max experience
|
||||
*/
|
||||
public void reloadMaxExperience() {
|
||||
HashMap<String, Double> param = new HashMap<>();
|
||||
Map<String, Double> param = new HashMap<>();
|
||||
param.put("joblevel", (double) level);
|
||||
param.put("numjobs", (double) jPlayer.getJobProgression().size());
|
||||
this.maxExperience = (int) job.getMaxExp(param);
|
||||
maxExperience = (int) job.getMaxExp(param);
|
||||
}
|
||||
|
||||
public int getMaxExperience(int level) {
|
||||
HashMap<String, Double> param = new HashMap<>();
|
||||
Map<String, Double> param = new HashMap<>();
|
||||
param.put("joblevel", (double) level);
|
||||
param.put("numjobs", (double) jPlayer.getJobProgression().size());
|
||||
return (int) job.getMaxExp(param);
|
||||
@ -171,18 +172,19 @@ public class JobProgression {
|
||||
private boolean checkLevelUp() {
|
||||
if (level == 1 && experience < 0)
|
||||
experience = 0;
|
||||
|
||||
if (experience < 0)
|
||||
return checkLevelDown();
|
||||
|
||||
boolean ret = false;
|
||||
while (canLevelUp()) {
|
||||
int maxLevel = jPlayer.getMaxJobLevelAllowed(job);
|
||||
// Don't level up at max level
|
||||
if (job.getMaxLevel() > 0 && level >= maxLevel)
|
||||
if (job.getMaxLevel() > 0 && level >= jPlayer.getMaxJobLevelAllowed(job))
|
||||
break;
|
||||
|
||||
level++;
|
||||
experience -= maxExperience;
|
||||
|
||||
ret = true;
|
||||
reloadMaxExperience();
|
||||
jPlayer.reloadLimits();
|
||||
@ -205,12 +207,13 @@ public class JobProgression {
|
||||
// Don't level down at 1
|
||||
if (level <= 1)
|
||||
break;
|
||||
|
||||
level--;
|
||||
int exp = getMaxExperience(level);
|
||||
experience += exp;
|
||||
experience += getMaxExperience(level);
|
||||
|
||||
ret = true;
|
||||
reloadMaxExperience();
|
||||
this.jPlayer.reloadLimits();
|
||||
jPlayer.reloadLimits();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -220,7 +223,6 @@ public class JobProgression {
|
||||
* Do this whenever job or level changes
|
||||
* @return if leveled up
|
||||
*/
|
||||
|
||||
private boolean reloadMaxExperienceAndCheckLevelUp() {
|
||||
reloadMaxExperience();
|
||||
return checkLevelUp();
|
||||
@ -238,7 +240,9 @@ public class JobProgression {
|
||||
public boolean canRejoin() {
|
||||
if (leftOn == null || leftOn + job.getRejoinCd() < System.currentTimeMillis())
|
||||
return true;
|
||||
return jPlayer != null && jPlayer.getPlayer() != null && jPlayer.getPlayer().hasPermission("jobs.rejoinbypass");
|
||||
|
||||
org.bukkit.entity.Player player = jPlayer != null ? jPlayer.getPlayer() : null;
|
||||
return player != null && player.hasPermission("jobs.rejoinbypass");
|
||||
}
|
||||
|
||||
public String getRejoinTimeMessage() {
|
||||
|
@ -210,12 +210,14 @@ public class JobsPlayer {
|
||||
Player player = getPlayer();
|
||||
if (player == null || amount == 0)
|
||||
return true;
|
||||
|
||||
CurrencyLimit limit = Jobs.getGCManager().getLimit(type);
|
||||
if (!limit.isEnabled())
|
||||
return true;
|
||||
|
||||
PaymentData data = getPaymentLimit();
|
||||
Integer value = limits.getOrDefault(type, 0);
|
||||
if (data.isReachedLimit(type, value)) {
|
||||
|
||||
if (data.isReachedLimit(type, limits.getOrDefault(type, 0))) {
|
||||
String name = type.getName().toLowerCase();
|
||||
|
||||
if (player.isOnline() && !data.isInformed() && !data.isReseted(type)) {
|
||||
@ -311,12 +313,12 @@ public class JobsPlayer {
|
||||
/**
|
||||
* Attempts to get the boost from specific job and {@link CurrencyType}
|
||||
*
|
||||
* @param JobName
|
||||
* @param jobName
|
||||
* @param type {@link CurrencyType}
|
||||
* @param force whenever to retrieve as soon as possible without time
|
||||
* @return amount of boost
|
||||
*/
|
||||
public double getBoost(String JobName, CurrencyType type, boolean force) {
|
||||
public double getBoost(String jobName, CurrencyType type, boolean force) {
|
||||
double boost = 0D;
|
||||
|
||||
if (!isOnline() || type == null)
|
||||
@ -324,14 +326,14 @@ public class JobsPlayer {
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
if (boostCounter.containsKey(JobName)) {
|
||||
List<BoostCounter> counterList = boostCounter.get(JobName);
|
||||
if (boostCounter.containsKey(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);
|
||||
boost = getPlayerBoostNew(jobName, type);
|
||||
counter.setBoost(boost);
|
||||
counter.setTime(time);
|
||||
return boost;
|
||||
@ -340,17 +342,17 @@ public class JobsPlayer {
|
||||
return counter.getBoost();
|
||||
}
|
||||
|
||||
boost = getPlayerBoostNew(JobName, type);
|
||||
boost = getPlayerBoostNew(jobName, type);
|
||||
counterList.add(new BoostCounter(type, boost, time));
|
||||
return boost;
|
||||
}
|
||||
|
||||
boost = getPlayerBoostNew(JobName, type);
|
||||
boost = getPlayerBoostNew(jobName, type);
|
||||
|
||||
List<BoostCounter> counterList = new ArrayList<>();
|
||||
counterList.add(new BoostCounter(type, boost, time));
|
||||
|
||||
boostCounter.put(JobName, counterList);
|
||||
boostCounter.put(jobName, counterList);
|
||||
return boost;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public final class Log {
|
||||
LogAmounts logAmount = amountMap.getOrDefault(item, new LogAmounts(item));
|
||||
logAmount.addCount();
|
||||
logAmount.add(amounts);
|
||||
this.amountMap.put(item, logAmount);
|
||||
amountMap.put(item, logAmount);
|
||||
}
|
||||
|
||||
public void add(String item, int count, Map<CurrencyType, Double> amounts) {
|
||||
@ -32,7 +32,7 @@ public final class Log {
|
||||
logAmount.setCount(count);
|
||||
logAmount.add(amounts);
|
||||
logAmount.setNewEntry(false);
|
||||
this.amountMap.put(item, logAmount);
|
||||
amountMap.put(item, logAmount);
|
||||
}
|
||||
|
||||
public void setDate() {
|
||||
|
@ -42,13 +42,11 @@ public final class LogAmounts {
|
||||
if (amount == null)
|
||||
return;
|
||||
|
||||
Double a = amounts.getOrDefault(type, 0D);
|
||||
amounts.put(type, a + amount);
|
||||
amounts.put(type, amounts.getOrDefault(type, 0D) + amount);
|
||||
}
|
||||
|
||||
public Double get(CurrencyType type) {
|
||||
Double a = amounts.getOrDefault(type, 0D);
|
||||
return ((int) (a * 100D)) / 100D;
|
||||
public double get(CurrencyType type) {
|
||||
return ((int) (amounts.getOrDefault(type, 0D) * 100D)) / 100D;
|
||||
}
|
||||
|
||||
public void addCount() {
|
||||
|
@ -5,6 +5,7 @@ import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
@ -23,7 +24,7 @@ public class Quest {
|
||||
|
||||
private boolean stopped = false;
|
||||
|
||||
private HashMap<ActionType, HashMap<String, QuestObjective>> objectives = new HashMap<>();
|
||||
private Map<ActionType, Map<String, QuestObjective>> objectives = new HashMap<>();
|
||||
private final Set<ActionType> actions = new HashSet<>();
|
||||
|
||||
public Quest(String questName, Job job) {
|
||||
@ -154,12 +155,12 @@ public class Quest {
|
||||
return true;
|
||||
}
|
||||
|
||||
public HashMap<ActionType, HashMap<String, QuestObjective>> getObjectives() {
|
||||
public Map<ActionType, Map<String, QuestObjective>> getObjectives() {
|
||||
return objectives;
|
||||
}
|
||||
|
||||
public boolean hasObjective(QuestObjective objective) {
|
||||
HashMap<String, QuestObjective> old = objectives.get(objective.getAction());
|
||||
Map<String, QuestObjective> old = objectives.get(objective.getAction());
|
||||
if (old == null)
|
||||
return false;
|
||||
|
||||
@ -172,7 +173,7 @@ public class Quest {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setObjectives(HashMap<ActionType, HashMap<String, QuestObjective>> objectives) {
|
||||
public void setObjectives(Map<ActionType, Map<String, QuestObjective>> objectives) {
|
||||
if (objectives == null) {
|
||||
objectives = new HashMap<>();
|
||||
}
|
||||
@ -182,7 +183,7 @@ public class Quest {
|
||||
}
|
||||
|
||||
public void addObjective(QuestObjective objective) {
|
||||
HashMap<String, QuestObjective> old = objectives.get(objective.getAction());
|
||||
Map<String, QuestObjective> old = objectives.get(objective.getAction());
|
||||
if (old == null) {
|
||||
old = new HashMap<>();
|
||||
old.put(objective.getTargetName(), objective);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -15,7 +16,7 @@ public class QuestProgression {
|
||||
private long validUntil;
|
||||
private boolean givenReward = false;
|
||||
|
||||
private final HashMap<QuestObjective, Integer> done = new HashMap<>();
|
||||
private final Map<QuestObjective, Integer> done = new HashMap<>();
|
||||
|
||||
public QuestProgression(Quest quest) {
|
||||
this.quest = quest;
|
||||
@ -33,7 +34,7 @@ public class QuestProgression {
|
||||
|
||||
public int getTotalAmountNeeded() {
|
||||
int amountNeeded = 0;
|
||||
for (HashMap<String, QuestObjective> oneA : quest.getObjectives().values()) {
|
||||
for (Map<String, QuestObjective> oneA : quest.getObjectives().values()) {
|
||||
for (QuestObjective one : oneA.values()) {
|
||||
amountNeeded += one.getAmount();
|
||||
}
|
||||
@ -77,7 +78,7 @@ public class QuestProgression {
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
for (HashMap<String, QuestObjective> oneA : quest.getObjectives().values()) {
|
||||
for (Map<String, QuestObjective> oneA : quest.getObjectives().values()) {
|
||||
for (QuestObjective one : oneA.values()) {
|
||||
Integer amountDone = done.get(one);
|
||||
if (amountDone == null || amountDone < one.getAmount())
|
||||
@ -112,7 +113,7 @@ public class QuestProgression {
|
||||
}
|
||||
|
||||
if (!isCompleted()) {
|
||||
HashMap<String, QuestObjective> byAction = quest.getObjectives().get(action.getType());
|
||||
Map<String, QuestObjective> byAction = quest.getObjectives().get(action.getType());
|
||||
|
||||
QuestObjective objective = null;
|
||||
if (byAction != null) {
|
||||
|
@ -3,6 +3,7 @@ package com.gamingmesh.jobs.container;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ShopItem {
|
||||
|
||||
@ -17,7 +18,7 @@ public class ShopItem {
|
||||
|
||||
private int requiredTotalLevels = -1;
|
||||
|
||||
private HashMap<String, Integer> requiredJobs = new HashMap<>();
|
||||
private Map<String, Integer> requiredJobs = new HashMap<>();
|
||||
|
||||
private final List<String> iconLore = new ArrayList<>(), requiredPerm = new ArrayList<>(), commands = new ArrayList<>();
|
||||
private final List<JobItems> items = new ArrayList<>();
|
||||
@ -64,11 +65,11 @@ public class ShopItem {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public void setRequiredJobs(HashMap<String, Integer> requiredJobs) {
|
||||
public void setRequiredJobs(Map<String, Integer> requiredJobs) {
|
||||
this.requiredJobs = requiredJobs;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getRequiredJobs() {
|
||||
public Map<String, Integer> getRequiredJobs() {
|
||||
return requiredJobs;
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -26,7 +26,7 @@ public class BlockOwnerShip {
|
||||
private BlockTypes type;
|
||||
private String metadataName = "";
|
||||
|
||||
private final HashMap<UUID, List<blockLoc>> blockOwnerShips = new HashMap<>();
|
||||
private final Map<UUID, List<blockLoc>> blockOwnerShips = new HashMap<>();
|
||||
|
||||
public BlockOwnerShip(CMIMaterial type) {
|
||||
// Type should be any type of furnace, smoker or brewing stand
|
||||
@ -69,7 +69,7 @@ public class BlockOwnerShip {
|
||||
return metadataName;
|
||||
}
|
||||
|
||||
public HashMap<UUID, List<blockLoc>> getBlockOwnerShips() {
|
||||
public Map<UUID, List<blockLoc>> getBlockOwnerShips() {
|
||||
return blockOwnerShips;
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ public class BlockOwnerShip {
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
f.getConfig().set(path, null);
|
||||
|
||||
for (Entry<UUID, List<blockLoc>> one : blockOwnerShips.entrySet()) {
|
||||
for (Map.Entry<UUID, List<blockLoc>> one : blockOwnerShips.entrySet()) {
|
||||
String full = "";
|
||||
for (blockLoc oneL : one.getValue()) {
|
||||
if (!full.isEmpty())
|
||||
|
@ -103,15 +103,7 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Jobs#getBlockOwnerShip(CMIMaterial)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String furnaceOwnerMetadata = "jobsFurnaceOwner", blastFurnaceOwnerMetadata = "jobsBlastFurnaceOwner",
|
||||
brewingOwnerMetadata = "jobsBrewingOwner", smokerOwnerMetadata = "jobsSmokerOwner";
|
||||
public static final String VegyMetadata = "VegyTimer";
|
||||
|
||||
private final String BlockMetadata = "BlockOwner", CowMetadata = "CowTimer", entityDamageByPlayer = "JobsEntityDamagePlayer";
|
||||
private final String blockMetadata = "BlockOwner", cowMetadata = "CowTimer", entityDamageByPlayer = "JobsEntityDamagePlayer";
|
||||
|
||||
public JobsPaymentListener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -175,7 +167,7 @@ public class JobsPaymentListener implements Listener {
|
||||
ItemStack currentItem = event.getCurrentItem();
|
||||
|
||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(Jobs.getInstance()
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.VTRADE));
|
||||
} else if (currentItem != null) {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.VTRADE));
|
||||
@ -198,7 +190,7 @@ public class JobsPaymentListener implements Listener {
|
||||
while (newItemsCount >= 1) {
|
||||
newItemsCount--;
|
||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName())
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(Jobs.getInstance()
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.VTRADE));
|
||||
else
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.VTRADE));
|
||||
@ -247,8 +239,8 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().CowMilkingTimer > 0) {
|
||||
if (cow.hasMetadata(CowMetadata)) {
|
||||
long time = cow.getMetadata(CowMetadata).get(0).asLong();
|
||||
if (cow.hasMetadata(cowMetadata)) {
|
||||
long time = cow.getMetadata(cowMetadata).get(0).asLong();
|
||||
if (System.currentTimeMillis() < time + Jobs.getGCManager().CowMilkingTimer) {
|
||||
long timer = ((Jobs.getGCManager().CowMilkingTimer - (System.currentTimeMillis() - time)) / 1000);
|
||||
jPlayer.getPlayer().sendMessage(Jobs.getLanguage().getMessage("message.cowtimer", "%time%", timer));
|
||||
@ -263,7 +255,7 @@ public class JobsPaymentListener implements Listener {
|
||||
Jobs.action(jPlayer, new EntityActionInfo(cow, ActionType.MILK));
|
||||
|
||||
Long timer = System.currentTimeMillis();
|
||||
cow.setMetadata(CowMetadata, new FixedMetadataValue(plugin, timer));
|
||||
cow.setMetadata(cowMetadata, new FixedMetadataValue(plugin, timer));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@ -320,7 +312,7 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
|
||||
return;
|
||||
|
||||
BlockOwnerShip ownerShip = Jobs.getInstance().getBlockOwnerShip(CMIMaterial.get(block), false).orElse(null);
|
||||
BlockOwnerShip ownerShip = plugin.getBlockOwnerShip(CMIMaterial.get(block), false).orElse(null);
|
||||
if (ownerShip == null || !block.hasMetadata(ownerShip.getMetadataName()))
|
||||
return;
|
||||
|
||||
@ -690,7 +682,7 @@ public class JobsPaymentListener implements Listener {
|
||||
PotionMeta potion = (PotionMeta) currentItem.getItemMeta();
|
||||
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.CRAFT, potion.getBasePotionData().getType()));
|
||||
} else if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(Jobs.getInstance()
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.CRAFT));
|
||||
} else if (currentItem != null) {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.CRAFT));
|
||||
@ -713,7 +705,7 @@ public class JobsPaymentListener implements Listener {
|
||||
while (newItemsCount >= 1) {
|
||||
newItemsCount--;
|
||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName())
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(Jobs.getInstance()
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.CRAFT));
|
||||
else
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
||||
@ -841,10 +833,10 @@ public class JobsPaymentListener implements Listener {
|
||||
String originalName = null;
|
||||
String newName = null;
|
||||
if (firstSlot.hasItemMeta())
|
||||
originalName = Jobs.getInstance().getComplement().getDisplayName(firstSlot.getItemMeta());
|
||||
originalName = plugin.getComplement().getDisplayName(firstSlot.getItemMeta());
|
||||
|
||||
if (resultStack.hasItemMeta())
|
||||
newName = Jobs.getInstance().getComplement().getDisplayName(resultStack.getItemMeta());
|
||||
newName = plugin.getComplement().getDisplayName(resultStack.getItemMeta());
|
||||
|
||||
if (originalName != null && !originalName.equals(newName) && inv.getItem(1) == null && !Jobs.getGCManager().PayForRenaming)
|
||||
return;
|
||||
@ -1533,7 +1525,7 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
plugin.getBlockOwnerShips().forEach(b -> b.remove(block));
|
||||
|
||||
if (Jobs.getGCManager().useBlockProtection && block.getState().hasMetadata(BlockMetadata))
|
||||
if (Jobs.getGCManager().useBlockProtection && block.getState().hasMetadata(blockMetadata))
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.TNTBREAK), block);
|
||||
|
@ -1,373 +0,0 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
|
||||
/**
|
||||
* @deprecated As of new blocks (smoker, blast furnace) this has been deprecated and
|
||||
* marked as "removeable". In the future this class will get removed
|
||||
* and not used anymore by anyone. Instead use {@link Jobs#getBlockOwnerShips()}
|
||||
*/
|
||||
@Deprecated
|
||||
public class FurnaceBrewingHandling {
|
||||
|
||||
static HashMap<UUID, List<blockLoc>> furnaceMap = new HashMap<>();
|
||||
static HashMap<UUID, List<blockLoc>> brewingMap = new HashMap<>();
|
||||
|
||||
public static void load() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
if (!f.exists())
|
||||
return;
|
||||
|
||||
int totalf = 0;
|
||||
int totalb = 0;
|
||||
|
||||
FileConfiguration config = f.getConfig();
|
||||
|
||||
if (Jobs.getGCManager().isFurnacesReassign()) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Furnace");
|
||||
if (section == null)
|
||||
return;
|
||||
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
|
||||
UUID uuid = UUID.fromString(one);
|
||||
if (uuid == null)
|
||||
continue;
|
||||
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
Block block = bl.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
|
||||
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
|
||||
block.setMetadata(JobsPaymentListener.furnaceOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
|
||||
|
||||
blist.add(bl);
|
||||
}
|
||||
|
||||
if (!blist.isEmpty()) {
|
||||
furnaceMap.put(uuid, blist);
|
||||
totalf++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().isBrewingStandsReassign()) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Brewing");
|
||||
if (section == null)
|
||||
return;
|
||||
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
|
||||
UUID uuid = UUID.fromString(one);
|
||||
if (uuid == null)
|
||||
continue;
|
||||
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
Block block = bl.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
|
||||
block.removeMetadata(JobsPaymentListener.brewingOwnerMetadata, Jobs.getInstance());
|
||||
block.setMetadata(JobsPaymentListener.brewingOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
|
||||
|
||||
blist.add(bl);
|
||||
}
|
||||
|
||||
if (!blist.isEmpty()) {
|
||||
brewingMap.put(uuid, blist);
|
||||
totalb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totalf > 0 || totalb > 0)
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + totalf + " furnaces and " + totalb + " brewing stands for reassigning.");
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
if (!f.exists())
|
||||
f.createNewFile();
|
||||
|
||||
f.saveDefaultConfig();
|
||||
|
||||
FileConfiguration config = f.getConfig();
|
||||
|
||||
if (Jobs.getGCManager().isFurnacesReassign()) {
|
||||
config.set("Furnace", null);
|
||||
for (Entry<UUID, List<blockLoc>> one : furnaceMap.entrySet()) {
|
||||
String full = "";
|
||||
for (blockLoc oneL : one.getValue()) {
|
||||
if (!full.isEmpty())
|
||||
full += ";";
|
||||
|
||||
full += oneL.toString();
|
||||
}
|
||||
if (!full.isEmpty())
|
||||
config.set("Furnace." + one.getKey().toString(), full);
|
||||
}
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().isBrewingStandsReassign()) {
|
||||
config.set("Brewing", null);
|
||||
for (Entry<UUID, List<blockLoc>> one : brewingMap.entrySet()) {
|
||||
String full = "";
|
||||
|
||||
for (blockLoc oneL : one.getValue()) {
|
||||
if (!full.isEmpty())
|
||||
full += ";";
|
||||
|
||||
full += oneL.toString();
|
||||
}
|
||||
if (!full.isEmpty())
|
||||
config.set("Brewing." + one.getKey().toString(), full);
|
||||
}
|
||||
}
|
||||
|
||||
f.saveConfig();
|
||||
|
||||
}
|
||||
|
||||
public static int getTotalFurnaces(UUID uuid) {
|
||||
List<blockLoc> ls = furnaceMap.get(uuid);
|
||||
return ls == null ? 0 : ls.size();
|
||||
}
|
||||
|
||||
public static int getTotalBrewingStands(UUID uuid) {
|
||||
List<blockLoc> ls = brewingMap.get(uuid);
|
||||
return ls == null ? 0 : ls.size();
|
||||
}
|
||||
|
||||
public static boolean removeFurnace(Block block) {
|
||||
UUID uuid = null;
|
||||
if (block.hasMetadata(JobsPaymentListener.furnaceOwnerMetadata)) {
|
||||
List<MetadataValue> data = block.getMetadata(JobsPaymentListener.furnaceOwnerMetadata);
|
||||
if (!data.isEmpty()) {
|
||||
// only care about first
|
||||
MetadataValue value = data.get(0);
|
||||
String uuidS = value.asString();
|
||||
uuid = UUID.fromString(uuidS);
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<blockLoc> ls = furnaceMap.get(uuid);
|
||||
if (ls == null)
|
||||
return false;
|
||||
|
||||
for (blockLoc one : ls) {
|
||||
if (!one.getLocation().equals(block.getLocation()))
|
||||
continue;
|
||||
|
||||
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
|
||||
ls.remove(one);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean removeBrewing(Block block) {
|
||||
UUID uuid = null;
|
||||
if (block.hasMetadata(JobsPaymentListener.brewingOwnerMetadata)) {
|
||||
List<MetadataValue> data = block.getMetadata(JobsPaymentListener.brewingOwnerMetadata);
|
||||
if (!data.isEmpty()) {
|
||||
// only care about first
|
||||
MetadataValue value = data.get(0);
|
||||
String uuidS = value.asString();
|
||||
uuid = UUID.fromString(uuidS);
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<blockLoc> ls = brewingMap.get(uuid);
|
||||
if (ls == null)
|
||||
return false;
|
||||
|
||||
for (blockLoc one : ls) {
|
||||
if (!one.getLocation().equals(block.getLocation()))
|
||||
continue;
|
||||
|
||||
block.removeMetadata(JobsPaymentListener.brewingOwnerMetadata, Jobs.getInstance());
|
||||
ls.remove(one);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum ownershipFeedback {
|
||||
invalid, tooMany, newReg, old, notOwn
|
||||
}
|
||||
|
||||
public static ownershipFeedback registerFurnaces(Player player, Block block) {
|
||||
CMIMaterial cmat = CMIMaterial.get(block);
|
||||
if (cmat != CMIMaterial.FURNACE && cmat != CMIMaterial.LEGACY_BURNING_FURNACE && cmat != CMIMaterial.SMOKER && cmat != CMIMaterial.BLAST_FURNACE)
|
||||
return ownershipFeedback.invalid;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
int max = jPlayer.getMaxFurnacesAllowed();
|
||||
int have = jPlayer.getFurnaceCount();
|
||||
|
||||
boolean owner = false;
|
||||
if (block.hasMetadata(JobsPaymentListener.furnaceOwnerMetadata)) {
|
||||
List<MetadataValue> data = block.getMetadata(JobsPaymentListener.furnaceOwnerMetadata);
|
||||
if (!data.isEmpty()) {
|
||||
// only care about first
|
||||
MetadataValue value = data.get(0);
|
||||
String uuid = value.asString();
|
||||
|
||||
if (uuid.equals(player.getUniqueId().toString())) {
|
||||
if (have > max && max > 0)
|
||||
removeFurnace(block);
|
||||
owner = true;
|
||||
} else
|
||||
return ownershipFeedback.notOwn;
|
||||
}
|
||||
}
|
||||
|
||||
if (owner)
|
||||
return ownershipFeedback.old;
|
||||
|
||||
if (have >= max && max > 0)
|
||||
return ownershipFeedback.tooMany;
|
||||
|
||||
block.setMetadata(JobsPaymentListener.furnaceOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), player.getUniqueId().toString()));
|
||||
|
||||
if (!Jobs.getGCManager().isFurnacesReassign() && !Jobs.getGCManager().BlastFurnacesReassign && !Jobs.getGCManager().SmokerReassign) {
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
List<blockLoc> ls = furnaceMap.get(player.getUniqueId());
|
||||
if (ls == null)
|
||||
ls = new ArrayList<>();
|
||||
|
||||
ls.add(new blockLoc(block.getLocation()));
|
||||
furnaceMap.put(player.getUniqueId(), ls);
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
public static ownershipFeedback registerBrewingStand(Player player, Block block) {
|
||||
if (CMIMaterial.get(block) != CMIMaterial.BREWING_STAND && CMIMaterial.get(block) != CMIMaterial.LEGACY_BREWING_STAND)
|
||||
return ownershipFeedback.invalid;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
int max = jPlayer.getMaxBrewingStandsAllowed();
|
||||
int have = jPlayer.getBrewingStandCount();
|
||||
|
||||
boolean owner = false;
|
||||
if (block.hasMetadata(JobsPaymentListener.brewingOwnerMetadata)) {
|
||||
List<MetadataValue> data = block.getMetadata(JobsPaymentListener.brewingOwnerMetadata);
|
||||
if (!data.isEmpty()) {
|
||||
// only care about first
|
||||
MetadataValue value = data.get(0);
|
||||
String uuid = value.asString();
|
||||
|
||||
if (uuid.equals(player.getUniqueId().toString())) {
|
||||
if (have > max && max > 0)
|
||||
removeBrewing(block);
|
||||
owner = true;
|
||||
} else
|
||||
return ownershipFeedback.notOwn;
|
||||
}
|
||||
}
|
||||
|
||||
if (owner)
|
||||
return ownershipFeedback.old;
|
||||
|
||||
if (have >= max && max > 0)
|
||||
return ownershipFeedback.tooMany;
|
||||
|
||||
block.setMetadata(JobsPaymentListener.brewingOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), player.getUniqueId().toString()));
|
||||
|
||||
if (!Jobs.getGCManager().isBrewingStandsReassign()) {
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
List<blockLoc> ls = brewingMap.get(player.getUniqueId());
|
||||
if (ls == null)
|
||||
ls = new ArrayList<>();
|
||||
|
||||
ls.add(new blockLoc(block.getLocation()));
|
||||
brewingMap.put(player.getUniqueId(), ls);
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
public static int clearFurnaces(UUID uuid) {
|
||||
List<blockLoc> ls = furnaceMap.remove(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
|
||||
for (blockLoc one : ls) {
|
||||
Block block = one.getBlock();
|
||||
CMIMaterial cmat = CMIMaterial.get(block);
|
||||
if (cmat != CMIMaterial.FURNACE && cmat != CMIMaterial.LEGACY_BURNING_FURNACE && cmat != CMIMaterial.SMOKER && cmat != CMIMaterial.BLAST_FURNACE)
|
||||
continue;
|
||||
|
||||
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
|
||||
}
|
||||
|
||||
return ls.size();
|
||||
}
|
||||
|
||||
public static int clearBrewingStands(UUID uuid) {
|
||||
List<blockLoc> ls = brewingMap.remove(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
|
||||
for (blockLoc one : ls) {
|
||||
Block block = one.getBlock();
|
||||
if (CMIMaterial.get(block) == CMIMaterial.BREWING_STAND)
|
||||
block.removeMetadata(JobsPaymentListener.brewingOwnerMetadata, Jobs.getInstance());
|
||||
}
|
||||
|
||||
return ls.size();
|
||||
}
|
||||
|
||||
public static HashMap<UUID, List<blockLoc>> getBrewingMap() {
|
||||
return brewingMap;
|
||||
}
|
||||
|
||||
public static HashMap<UUID, List<blockLoc>> getFurnaceMap() {
|
||||
return furnaceMap;
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ public class Complement2 implements Complement {
|
||||
}
|
||||
|
||||
protected Component deserialize(String t) {
|
||||
return PlainComponentSerializer.plain().deserialize(t);
|
||||
return Component.text(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user