mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 23:13:48 +01:00
parent
865bcca5c0
commit
c858b53340
@ -14,8 +14,8 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
|
||||||
public class VersionChecker {
|
public class VersionChecker {
|
||||||
|
|
||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
private static int resource = 4216;
|
|
||||||
|
|
||||||
public VersionChecker(Jobs plugin) {
|
public VersionChecker(Jobs plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -69,7 +69,7 @@ public class VersionChecker {
|
|||||||
|
|
||||||
public String getNewVersion() {
|
public String getNewVersion() {
|
||||||
try {
|
try {
|
||||||
URLConnection con = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + resource).openConnection();
|
URLConnection con = new URL("https://api.spigotmc.org/legacy/update.php?resource=4216").openConnection();
|
||||||
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
||||||
if (version.length() <= 8)
|
if (version.length() <= 8)
|
||||||
return version;
|
return version;
|
||||||
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -22,15 +23,15 @@ import com.gamingmesh.jobs.container.JobItems;
|
|||||||
|
|
||||||
public class ItemBoostManager {
|
public class ItemBoostManager {
|
||||||
|
|
||||||
private static HashMap<String, JobItems> items = new HashMap<>();
|
private static final Map<String, JobItems> ITEMS = new HashMap<>();
|
||||||
private static HashMap<String, JobItems> legacy = new HashMap<>();
|
private static final Map<String, JobItems> LEGACY = new HashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void load() {
|
public static void load() {
|
||||||
ConfigReader cfg = new ConfigReader("boostedItems.yml");
|
ConfigReader cfg = new ConfigReader("boostedItems.yml");
|
||||||
|
|
||||||
items.clear();
|
ITEMS.clear();
|
||||||
legacy.clear();
|
LEGACY.clear();
|
||||||
|
|
||||||
// Converting from existing records in Jobs from old format which was located in jobConfig.yml file
|
// Converting from existing records in Jobs from old format which was located in jobConfig.yml file
|
||||||
boolean save = false;
|
boolean save = false;
|
||||||
@ -151,10 +152,8 @@ public class ItemBoostManager {
|
|||||||
b.add(oneC, cfg.get(one + "." + oneC.toString().toLowerCase() + "Boost", 1D) - 1);
|
b.add(oneC, cfg.get(one + "." + oneC.toString().toLowerCase() + "Boost", 1D) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> jobsS = cfg.get(one + ".jobs", Arrays.asList(""));
|
|
||||||
|
|
||||||
List<Job> jobs = new ArrayList<>();
|
List<Job> jobs = new ArrayList<>();
|
||||||
for (String oneJ : jobsS) {
|
for (String oneJ : cfg.get(one + ".jobs", Arrays.asList(""))) {
|
||||||
Job job = Jobs.getJob(oneJ);
|
Job job = Jobs.getJob(oneJ);
|
||||||
if (job == null && !oneJ.equalsIgnoreCase("all")) {
|
if (job == null && !oneJ.equalsIgnoreCase("all")) {
|
||||||
Jobs.getPluginLogger().warning("Cant determine job by " + oneJ + " name for " + one + " boosted item!");
|
Jobs.getPluginLogger().warning("Cant determine job by " + oneJ + " name for " + one + " boosted item!");
|
||||||
@ -179,58 +178,76 @@ public class ItemBoostManager {
|
|||||||
item.setUntilLevel(cfg.get(one + ".levelUntil", 1000));
|
item.setUntilLevel(cfg.get(one + ".levelUntil", 1000));
|
||||||
|
|
||||||
for (Job oneJ : jobs) {
|
for (Job oneJ : jobs) {
|
||||||
if (oneJ == null)
|
|
||||||
continue;
|
|
||||||
oneJ.getItemBonus().put(one.toLowerCase(), item);
|
oneJ.getItemBonus().put(one.toLowerCase(), item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lets add into legacy map
|
// Lets add into legacy map
|
||||||
if (one.contains("_")) {
|
if (one.contains("_")) {
|
||||||
item.setLegacyKey((one.split("_")[1]).toLowerCase());
|
item.setLegacyKey((one.split("_")[1]).toLowerCase());
|
||||||
legacy.put(item.getLegacyKey(), item);
|
LEGACY.put(item.getLegacyKey(), item);
|
||||||
}
|
}
|
||||||
items.put(one.toLowerCase(), item);
|
ITEMS.put(one.toLowerCase(), item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.save();
|
cfg.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy list of {@link JobItems} from the specific job.
|
||||||
|
*
|
||||||
|
* @param job {@link Job}
|
||||||
|
* @return List of {@link JobItems}
|
||||||
|
*/
|
||||||
public static List<JobItems> getItemsByJob(Job job) {
|
public static List<JobItems> getItemsByJob(Job job) {
|
||||||
List<JobItems> ls = new ArrayList<>();
|
List<JobItems> ls = new ArrayList<>();
|
||||||
for (JobItems one : items.values()) {
|
for (JobItems one : ITEMS.values()) {
|
||||||
if (one.getJobs().contains(job))
|
if (one.getJobs().contains(job))
|
||||||
ls.add(one);
|
ls.add(one);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ls;
|
return ls;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, JobItems> getItemsMapByJob(Job job) {
|
/** Returns a map of items from the specific job.
|
||||||
HashMap<String, JobItems> i = new HashMap<>();
|
*
|
||||||
for (Entry<String, JobItems> one : items.entrySet()) {
|
* @param job {@link Job}
|
||||||
|
* @return map of items
|
||||||
|
*/
|
||||||
|
public static Map<String, JobItems> getItemsMapByJob(Job job) {
|
||||||
|
Map<String, JobItems> i = new HashMap<>();
|
||||||
|
for (Entry<String, JobItems> one : ITEMS.entrySet()) {
|
||||||
if (one.getValue().getJobs().contains(job))
|
if (one.getValue().getJobs().contains(job))
|
||||||
i.put(one.getKey(), one.getValue());
|
i.put(one.getKey(), one.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@link JobItems} from specific key.
|
||||||
|
*
|
||||||
|
* @param key items or legacy key name
|
||||||
|
* @return {@link JobItems}
|
||||||
|
*/
|
||||||
public static JobItems getItemByKey(String key) {
|
public static JobItems getItemByKey(String key) {
|
||||||
JobItems item = items.get(key.toLowerCase());
|
key = key.toLowerCase();
|
||||||
if (item != null) {
|
|
||||||
return item;
|
JobItems item = ITEMS.get(key);
|
||||||
}
|
return item != null ? item : LEGACY.get(key);
|
||||||
return legacy.get(key.toLowerCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, JobItems> getItems() {
|
/**
|
||||||
return items;
|
* @return the current cached map of items.
|
||||||
|
*/
|
||||||
|
public static Map<String, JobItems> getItems() {
|
||||||
|
return ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, JobItems> getLegacyItems() {
|
/**
|
||||||
return legacy;
|
* @return the current cached map of legacy items.
|
||||||
}
|
*/
|
||||||
|
public static Map<String, JobItems> getLegacyItems() {
|
||||||
public static void setItems(HashMap<String, JobItems> items) {
|
return LEGACY;
|
||||||
ItemBoostManager.items = items;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
private static List<Job> jobs;
|
private static List<Job> jobs;
|
||||||
private static Job noneJob;
|
private static Job noneJob;
|
||||||
private static WeakHashMap<Job, Integer> usedSlots = new WeakHashMap<>();
|
private static WeakHashMap<Job, Integer> usedSlots = new WeakHashMap<>();
|
||||||
private static HashMap<Integer, Job> jobsIds = new HashMap<>();
|
private static Map<Integer, Job> jobsIds = new HashMap<>();
|
||||||
|
|
||||||
private static BufferedEconomy economy;
|
private static BufferedEconomy economy;
|
||||||
private static PermissionHandler permissionHandler;
|
private static PermissionHandler permissionHandler;
|
||||||
@ -118,10 +118,26 @@ public class Jobs extends JavaPlugin {
|
|||||||
|
|
||||||
private static PointsData pointsDatabase;
|
private static PointsData pointsDatabase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the block owner ship for specific {@link CMIMaterial} type.
|
||||||
|
*
|
||||||
|
* @param type {@link CMIMaterial}
|
||||||
|
* @see #getBlockOwnerShip(CMIMaterial, boolean)
|
||||||
|
* @return {@link BlockOwnerShip}, otherwise {@link Optional#empty()}
|
||||||
|
*/
|
||||||
public Optional<BlockOwnerShip> getBlockOwnerShip(CMIMaterial type) {
|
public Optional<BlockOwnerShip> getBlockOwnerShip(CMIMaterial type) {
|
||||||
return getBlockOwnerShip(type, true);
|
return getBlockOwnerShip(type, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the block owner ship for specific {@link CMIMaterial} type.
|
||||||
|
* If the addNew parameter is enabled, it will cache a new owner ship for specific
|
||||||
|
* {@link CMIMaterial} type.
|
||||||
|
*
|
||||||
|
* @param type {@link CMIMaterial}
|
||||||
|
* @param addNew whenever to add a new owner ship
|
||||||
|
* @return {@link BlockOwnerShip}, otherwise {@link Optional#empty()}
|
||||||
|
*/
|
||||||
public Optional<BlockOwnerShip> getBlockOwnerShip(CMIMaterial type, boolean addNew) {
|
public Optional<BlockOwnerShip> getBlockOwnerShip(CMIMaterial type, boolean addNew) {
|
||||||
BlockOwnerShip b = null;
|
BlockOwnerShip b = null;
|
||||||
for (BlockOwnerShip ship : blockOwnerShips) {
|
for (BlockOwnerShip ship : blockOwnerShips) {
|
||||||
@ -139,6 +155,12 @@ public class Jobs extends JavaPlugin {
|
|||||||
return Optional.ofNullable(b);
|
return Optional.ofNullable(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the block owner ship for specific {@link BlockTypes} type.
|
||||||
|
*
|
||||||
|
* @param type {@link BlockTypes}
|
||||||
|
* @return {@link BlockOwnerShip}, otherwise {@link Optional#empty()}
|
||||||
|
*/
|
||||||
public Optional<BlockOwnerShip> getBlockOwnerShip(BlockTypes type) {
|
public Optional<BlockOwnerShip> getBlockOwnerShip(BlockTypes type) {
|
||||||
for (BlockOwnerShip ship : blockOwnerShips) {
|
for (BlockOwnerShip ship : blockOwnerShips) {
|
||||||
if (ship.getType() == type) {
|
if (ship.getType() == type) {
|
||||||
@ -149,6 +171,9 @@ public class Jobs extends JavaPlugin {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a set of block owner ships.
|
||||||
|
*/
|
||||||
public Set<BlockOwnerShip> getBlockOwnerShips() {
|
public Set<BlockOwnerShip> getBlockOwnerShips() {
|
||||||
return blockOwnerShips;
|
return blockOwnerShips;
|
||||||
}
|
}
|
||||||
@ -241,8 +266,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns player manager
|
* @return {@link PlayerManager}
|
||||||
* @return the player manager
|
|
||||||
*/
|
*/
|
||||||
public static PlayerManager getPlayerManager() {
|
public static PlayerManager getPlayerManager() {
|
||||||
if (pManager == null)
|
if (pManager == null)
|
||||||
@ -266,7 +290,20 @@ public class Jobs extends JavaPlugin {
|
|||||||
return raManager;
|
return raManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated miss named
|
||||||
|
* @see #getTitleManager()
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static TitleManager gettitleManager() {
|
public static TitleManager gettitleManager() {
|
||||||
|
return getTitleManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link TitleManager}
|
||||||
|
*/
|
||||||
|
public static TitleManager getTitleManager() {
|
||||||
if (titleManager == null) {
|
if (titleManager == null) {
|
||||||
titleManager = new TitleManager();
|
titleManager = new TitleManager();
|
||||||
}
|
}
|
||||||
@ -440,6 +477,12 @@ public class Jobs extends JavaPlugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a job by identifier.
|
||||||
|
*
|
||||||
|
* @param id the id of job
|
||||||
|
* @return {@link Job}
|
||||||
|
*/
|
||||||
public static Job getJob(int id) {
|
public static Job getJob(int id) {
|
||||||
return jobsIds.get(id);
|
return jobsIds.get(id);
|
||||||
}
|
}
|
||||||
@ -448,7 +491,10 @@ public class Jobs extends JavaPlugin {
|
|||||||
return placeholderAPIEnabled;
|
return placeholderAPIEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Integer, Job> getJobsIds() {
|
/**
|
||||||
|
* @return the cached job id map.
|
||||||
|
*/
|
||||||
|
public static Map<Integer, Job> getJobsIds() {
|
||||||
return jobsIds;
|
return jobsIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,9 +539,6 @@ public class Jobs extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes close connections
|
|
||||||
*/
|
|
||||||
public static void convertDatabase() {
|
public static void convertDatabase() {
|
||||||
try {
|
try {
|
||||||
List<Convert> archivelist = dao.convertDatabase();
|
List<Convert> archivelist = dao.convertDatabase();
|
||||||
@ -524,7 +567,8 @@ public class Jobs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if player have the given {@link ActionType} in jobs.
|
* Checks if the given {@link JobsPlayer} have the given {@link ActionType} in one of jobs.
|
||||||
|
*
|
||||||
* @param jPlayer {@link JobsPlayer}
|
* @param jPlayer {@link JobsPlayer}
|
||||||
* @param type {@link ActionType}
|
* @param type {@link ActionType}
|
||||||
* @return true if the player have the given action
|
* @return true if the player have the given action
|
||||||
@ -708,9 +752,6 @@ public class Jobs extends JavaPlugin {
|
|||||||
reload(false);
|
reload(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reloads all data
|
|
||||||
*/
|
|
||||||
public static void reload(boolean startup) {
|
public static void reload(boolean startup) {
|
||||||
// unregister all registered listeners by this plugin and register again
|
// unregister all registered listeners by this plugin and register again
|
||||||
if (!startup) {
|
if (!startup) {
|
||||||
@ -839,29 +880,76 @@ public class Jobs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performed an action
|
* Perform an action for the given {@link JobsPlayer} with the given action info.
|
||||||
*
|
*
|
||||||
* Give correct experience and income
|
* @param jPlayer {@link JobsPlayer}
|
||||||
* @param jPlayer - the player
|
* @param info {@link ActionInfo}
|
||||||
* @param info - the action
|
* @see #action(JobsPlayer, ActionInfo, Block, Entity, LivingEntity)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void action(JobsPlayer jPlayer, ActionInfo info) {
|
public static void action(JobsPlayer jPlayer, ActionInfo info) {
|
||||||
action(jPlayer, info, null, null, null);
|
action(jPlayer, info, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action for the given {@link JobsPlayer} with the given action info and block.
|
||||||
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param info {@link ActionInfo}
|
||||||
|
* @param block {@link Block}
|
||||||
|
* @see #action(JobsPlayer, ActionInfo, Block, Entity, LivingEntity)
|
||||||
|
*/
|
||||||
public static void action(JobsPlayer jPlayer, ActionInfo info, Block block) {
|
public static void action(JobsPlayer jPlayer, ActionInfo info, Block block) {
|
||||||
action(jPlayer, info, block, null, null);
|
action(jPlayer, info, block, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action for the given {@link JobsPlayer} with the given action info and entity.
|
||||||
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param info {@link ActionInfo}
|
||||||
|
* @param ent {@link Entity}
|
||||||
|
* @see #action(JobsPlayer, ActionInfo, Block, Entity, LivingEntity)
|
||||||
|
*/
|
||||||
public static void action(JobsPlayer jPlayer, ActionInfo info, Entity ent) {
|
public static void action(JobsPlayer jPlayer, ActionInfo info, Entity ent) {
|
||||||
action(jPlayer, info, null, ent, null);
|
action(jPlayer, info, null, ent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action for the given {@link JobsPlayer} with the given action info,
|
||||||
|
* entity and living entity.
|
||||||
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param info {@link ActionInfo}
|
||||||
|
* @param ent {@link Entity}
|
||||||
|
* @param victim {@link LivingEntity}
|
||||||
|
* @see #action(JobsPlayer, ActionInfo, Block, Entity, LivingEntity)
|
||||||
|
*/
|
||||||
public static void action(JobsPlayer jPlayer, ActionInfo info, Entity ent, LivingEntity victim) {
|
public static void action(JobsPlayer jPlayer, ActionInfo info, Entity ent, LivingEntity victim) {
|
||||||
action(jPlayer, info, null, ent, victim);
|
action(jPlayer, info, null, ent, victim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action for the given {@link JobsPlayer} with the parameters.
|
||||||
|
* <p>
|
||||||
|
* The process:
|
||||||
|
* <p>
|
||||||
|
* If the player does not have any job progression cached into memory, the player
|
||||||
|
* only retrieve the "noneJob" by default. This means that there will be no any
|
||||||
|
* extra income calculations and the player does no get the full income from jobs,
|
||||||
|
* but the half of it.<br>
|
||||||
|
* In other cases if player have at least 1 job cached, they will get the full income
|
||||||
|
* with the extra calculated multiplications including bonuses and limits.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* <b>This usually not be called in your code, to avoid misbehaviour working ability.</b>
|
||||||
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param info {@link ActionInfo}
|
||||||
|
* @param ent {@link Entity}
|
||||||
|
* @param victim {@link LivingEntity}
|
||||||
|
* @param block {@link Block}
|
||||||
|
* @see #action(JobsPlayer, ActionInfo, Block, Entity, LivingEntity)
|
||||||
|
*/
|
||||||
public static void action(JobsPlayer jPlayer, ActionInfo info, Block block, Entity ent, LivingEntity victim) {
|
public static void action(JobsPlayer jPlayer, ActionInfo info, Block block, Entity ent, LivingEntity victim) {
|
||||||
if (jPlayer == null)
|
if (jPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
@ -241,9 +241,6 @@ public class PermissionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check World permissions
|
|
||||||
*/
|
|
||||||
public boolean hasWorldPermission(Player player) {
|
public boolean hasWorldPermission(Player player) {
|
||||||
return hasWorldPermission(player, player.getWorld().getName());
|
return hasWorldPermission(player, player.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
@ -116,14 +116,42 @@ public class PermissionManager {
|
|||||||
return mine;
|
return mine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a maximum permission value for example "jobs.max.5".
|
||||||
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param perm the permission to search
|
||||||
|
* @see #getMaxPermission(JobsPlayer, String, boolean, boolean)
|
||||||
|
* @return the max value
|
||||||
|
*/
|
||||||
public Double getMaxPermission(JobsPlayer jPlayer, String perm) {
|
public Double getMaxPermission(JobsPlayer jPlayer, String perm) {
|
||||||
return getMaxPermission(jPlayer, perm, false, false);
|
return getMaxPermission(jPlayer, perm, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a maximum permission value for example "jobs.max.5" with force condition.
|
||||||
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param perm the permission to search
|
||||||
|
* @param force to force cache player permissions which includes jobs
|
||||||
|
* @see #getMaxPermission(JobsPlayer, String, boolean, boolean)
|
||||||
|
* @return the max value
|
||||||
|
*/
|
||||||
public Double getMaxPermission(JobsPlayer jPlayer, String perm, boolean force) {
|
public Double getMaxPermission(JobsPlayer jPlayer, String perm, boolean force) {
|
||||||
return getMaxPermission(jPlayer, perm, force, false);
|
return getMaxPermission(jPlayer, perm, force, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a maximum permission value for example "jobs.max.5".
|
||||||
|
* If the force condition is true it will caches all the jobs
|
||||||
|
* permissions into memory and tries to find a max permission value.
|
||||||
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param perm the permission to search
|
||||||
|
* @param force whenever to force permission cache for specific player
|
||||||
|
* @param cumulative if true it sums the maximum values of fount permissions
|
||||||
|
* @return the max value
|
||||||
|
*/
|
||||||
public Double getMaxPermission(JobsPlayer jPlayer, String perm, boolean force, boolean cumulative) {
|
public Double getMaxPermission(JobsPlayer jPlayer, String perm, boolean force, boolean cumulative) {
|
||||||
if (jPlayer == null || jPlayer.getPlayer() == null)
|
if (jPlayer == null || jPlayer.getPlayer() == null)
|
||||||
return 0D;
|
return 0D;
|
||||||
@ -150,8 +178,8 @@ public class PermissionManager {
|
|||||||
amount += temp;
|
amount += temp;
|
||||||
else if (temp > amount)
|
else if (temp > amount)
|
||||||
amount = temp;
|
amount = temp;
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ex) {
|
||||||
ignored.printStackTrace();
|
Jobs.getPluginLogger().log(java.util.logging.Level.WARNING, ex.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ public class Placeholder {
|
|||||||
case user_title_$1:
|
case user_title_$1:
|
||||||
if (j == null)
|
if (j == null)
|
||||||
return "";
|
return "";
|
||||||
Title title = Jobs.gettitleManager().getTitle(j.getLevel(), j.getJob().getName());
|
Title title = Jobs.getTitleManager().getTitle(j.getLevel(), j.getJob().getName());
|
||||||
return title == null ? "" : title.getChatColor() + title.getName();
|
return title == null ? "" : title.getChatColor() + title.getName();
|
||||||
case user_archived_jobs_level_$1:
|
case user_archived_jobs_level_$1:
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
|
@ -81,7 +81,7 @@ public class PlayerManager {
|
|||||||
private final HashMap<String, PlayerInfo> PlayerNameMap = new HashMap<>();
|
private final HashMap<String, PlayerInfo> PlayerNameMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link Jobs#getPointsData} instead
|
* @deprecated Use {@link JobsPlayer#getPointsData} instead
|
||||||
* @return {@link com.gamingmesh.jobs.economy.PointsData}
|
* @return {@link com.gamingmesh.jobs.economy.PointsData}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -89,10 +89,14 @@ public class PlayerManager {
|
|||||||
return Jobs.getPointsData();
|
return Jobs.getPointsData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the cached mob spawner meta name
|
||||||
|
*/
|
||||||
public String getMobSpawnerMetadata() {
|
public String getMobSpawnerMetadata() {
|
||||||
return mobSpawnerMetadata;
|
return mobSpawnerMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public int getMapSize() {
|
public int getMapSize() {
|
||||||
return PlayerUUIDMap.size();
|
return PlayerUUIDMap.size();
|
||||||
}
|
}
|
||||||
@ -130,6 +134,12 @@ public class PlayerManager {
|
|||||||
playersUUID.put(jPlayer.getUniqueId(), jPlayer);
|
playersUUID.put(jPlayer.getUniqueId(), jPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the given player from the memory.
|
||||||
|
*
|
||||||
|
* @param player {@link Player}
|
||||||
|
* @return {@link JobsPlayer}
|
||||||
|
*/
|
||||||
public JobsPlayer removePlayer(Player player) {
|
public JobsPlayer removePlayer(Player player) {
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return null;
|
return null;
|
||||||
@ -152,31 +162,69 @@ public class PlayerManager {
|
|||||||
return PlayerUUIDMap;
|
return PlayerUUIDMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player identifier by its name. This will returns
|
||||||
|
* -1 if the player is not cached.
|
||||||
|
*
|
||||||
|
* @param name the player name
|
||||||
|
* @return the identifier
|
||||||
|
*/
|
||||||
public int getPlayerId(String name) {
|
public int getPlayerId(String name) {
|
||||||
PlayerInfo info = getPlayerInfo(name);
|
PlayerInfo info = getPlayerInfo(name);
|
||||||
return info == null ? -1 : info.getID();
|
return info == null ? -1 : info.getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player identifier by its uuid. This will returns
|
||||||
|
* -1 if the player is not cached.
|
||||||
|
*
|
||||||
|
* @param uuid player {@link UUID}
|
||||||
|
* @return the identifier
|
||||||
|
*/
|
||||||
public int getPlayerId(UUID uuid) {
|
public int getPlayerId(UUID uuid) {
|
||||||
PlayerInfo info = PlayerUUIDMap.get(uuid);
|
PlayerInfo info = PlayerUUIDMap.get(uuid);
|
||||||
return info == null ? -1 : info.getID();
|
return info == null ? -1 : info.getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link PlayerInfo} for the given name. This will returns
|
||||||
|
* null if the player is not cached.
|
||||||
|
*
|
||||||
|
* @param name the player name
|
||||||
|
* @return {@link PlayerInfo}
|
||||||
|
*/
|
||||||
public PlayerInfo getPlayerInfo(String name) {
|
public PlayerInfo getPlayerInfo(String name) {
|
||||||
return PlayerNameMap.get(name.toLowerCase());
|
return PlayerNameMap.get(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link PlayerInfo} for the given identifier. This will returns
|
||||||
|
* null if the player is not cached.
|
||||||
|
*
|
||||||
|
* @param id the player id
|
||||||
|
* @return {@link PlayerInfo}
|
||||||
|
*/
|
||||||
public PlayerInfo getPlayerInfo(int id) {
|
public PlayerInfo getPlayerInfo(int id) {
|
||||||
return PlayerIDMap.get(id);
|
return PlayerIDMap.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link PlayerInfo} for the given uuid. This will returns
|
||||||
|
* null if the player is not cached.
|
||||||
|
*
|
||||||
|
* @param uuid player {@link UUID}
|
||||||
|
* @return {@link PlayerInfo}
|
||||||
|
*/
|
||||||
public PlayerInfo getPlayerInfo(UUID uuid) {
|
public PlayerInfo getPlayerInfo(UUID uuid) {
|
||||||
return PlayerUUIDMap.get(uuid);
|
return PlayerUUIDMap.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles join of new player
|
* Handles join of new player synchronously. This can be called
|
||||||
* @param playername
|
* within an asynchronous operation in order to load the player
|
||||||
|
* from database if it is not cached into memory.
|
||||||
|
*
|
||||||
|
* @param player {@link Player}
|
||||||
*/
|
*/
|
||||||
public void playerJoin(Player player) {
|
public void playerJoin(Player player) {
|
||||||
|
|
||||||
@ -204,7 +252,7 @@ public class PlayerManager {
|
|||||||
jPlayer.setQuestProgressionFromString(info.getQuestProgression());
|
jPlayer.setQuestProgressionFromString(info.getQuestProgression());
|
||||||
}
|
}
|
||||||
|
|
||||||
jPlayer.loadLogFromDao();
|
Jobs.getJobsDAO().loadLog(jPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayer(jPlayer);
|
addPlayer(jPlayer);
|
||||||
@ -216,7 +264,8 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles player quit
|
* Handles player quit
|
||||||
* @param playername
|
*
|
||||||
|
* @param player {@link Player}
|
||||||
*/
|
*/
|
||||||
public void playerQuit(Player player) {
|
public void playerQuit(Player player) {
|
||||||
JobsPlayer jPlayer = getJobsPlayer(player);
|
JobsPlayer jPlayer = getJobsPlayer(player);
|
||||||
@ -230,15 +279,18 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all jobs player miscellaneous settings like boss bar.
|
||||||
|
*/
|
||||||
public void removePlayerAdditions() {
|
public void removePlayerAdditions() {
|
||||||
for (JobsPlayer jPlayer : players.values()) {
|
for (JobsPlayer jPlayer : players.values()) {
|
||||||
jPlayer.clearBossMaps();
|
jPlayer.clearBossMaps();
|
||||||
jPlayer.clearUpdateBossBarFor();
|
jPlayer.getUpdateBossBarFor().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save all the information of all of the players in the game
|
* Save all the information of all of the players
|
||||||
*/
|
*/
|
||||||
public void saveAll() {
|
public void saveAll() {
|
||||||
/*
|
/*
|
||||||
@ -264,7 +316,9 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save all the information of all of the players
|
* Converts the cache of all the players into a new one.
|
||||||
|
*
|
||||||
|
* @param resetID true to not insert into database and reset the players id
|
||||||
*/
|
*/
|
||||||
public void convertChacheOfPlayers(boolean resetID) {
|
public void convertChacheOfPlayers(boolean resetID) {
|
||||||
int y = 0, i = 0, total = playersUUIDCache.size();
|
int y = 0, i = 0, total = playersUUIDCache.size();
|
||||||
@ -296,25 +350,40 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player job info for specific player
|
* Gets the player job info for specific player if exist.
|
||||||
* @param player - the player who's job you're getting
|
* <p>
|
||||||
* @return the player job info of the player
|
* This can return null sometimes if the given player
|
||||||
|
* is not cached into memory.
|
||||||
|
*
|
||||||
|
* @param player {@link Player}
|
||||||
|
* @return {@link JobsPlayer} the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayer(Player player) {
|
public JobsPlayer getJobsPlayer(Player player) {
|
||||||
return getJobsPlayer(player.getUniqueId());
|
return getJobsPlayer(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the player job info for specific player uuid if exist.
|
||||||
|
* <p>
|
||||||
|
* This can return null sometimes if the given player
|
||||||
|
* is not cached into memory.
|
||||||
|
*
|
||||||
|
* @param player the player uuid
|
||||||
|
* @return {@link JobsPlayer} the player job info of the player
|
||||||
|
*/
|
||||||
public JobsPlayer getJobsPlayer(UUID uuid) {
|
public JobsPlayer getJobsPlayer(UUID uuid) {
|
||||||
JobsPlayer jPlayer = playersUUID.get(uuid);
|
JobsPlayer jPlayer = playersUUID.get(uuid);
|
||||||
if (jPlayer != null)
|
return jPlayer != null ? jPlayer : playersUUIDCache.get(uuid);
|
||||||
return jPlayer;
|
|
||||||
return playersUUIDCache.get(uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player job info for specific player
|
* Get the player job info for specific player name if exist.
|
||||||
|
* <p>
|
||||||
|
* This can return null sometimes if the given player
|
||||||
|
* is not cached into memory.
|
||||||
|
*
|
||||||
* @param player name - the player name who's job you're getting
|
* @param player name - the player name who's job you're getting
|
||||||
* @return the player job info of the player
|
* @return {@link JobsPlayer} the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayer(String playerName) {
|
public JobsPlayer getJobsPlayer(String playerName) {
|
||||||
JobsPlayer jPlayer = players.get(playerName.toLowerCase());
|
JobsPlayer jPlayer = players.get(playerName.toLowerCase());
|
||||||
@ -322,10 +391,15 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player job info for specific player
|
* Gets the player job offline data for specific {@link PlayerInfo}
|
||||||
* @param archivedJobs
|
*
|
||||||
* @param player - the player who's job you're getting
|
* @param info {@link PlayerInfo}
|
||||||
* @return the player job info of the player
|
* @param jobs the list of jobs data from database
|
||||||
|
* @param points {@link PlayerPoints}
|
||||||
|
* @param logs the map of logs
|
||||||
|
* @param archivedJobs {@link ArchivedJobs}
|
||||||
|
* @param limits {@link PaymentData}
|
||||||
|
* @return {@link JobsPlayer}
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayerOffline(PlayerInfo info, List<JobsDAOData> jobs, PlayerPoints points,
|
public JobsPlayer getJobsPlayerOffline(PlayerInfo info, List<JobsDAOData> jobs, PlayerPoints points,
|
||||||
HashMap<String, Log> logs, ArchivedJobs archivedJobs, PaymentData limits) {
|
HashMap<String, Log> logs, ArchivedJobs archivedJobs, PaymentData limits) {
|
||||||
@ -375,9 +449,10 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes player to join their job
|
* Causes player to join to the given job.
|
||||||
* @param jPlayer
|
*
|
||||||
* @param job
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param job {@link Job}
|
||||||
*/
|
*/
|
||||||
public void joinJob(JobsPlayer jPlayer, Job job) {
|
public void joinJob(JobsPlayer jPlayer, Job job) {
|
||||||
if (jPlayer.isInJob(job))
|
if (jPlayer.isInJob(job))
|
||||||
@ -406,9 +481,10 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes player to leave their job
|
* Causes player to leave the given job.
|
||||||
* @param jPlayer
|
*
|
||||||
* @param job
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param job {@link Job}
|
||||||
*/
|
*/
|
||||||
public boolean leaveJob(JobsPlayer jPlayer, Job job) {
|
public boolean leaveJob(JobsPlayer jPlayer, Job job) {
|
||||||
if (!jPlayer.isInJob(job))
|
if (!jPlayer.isInJob(job))
|
||||||
@ -439,7 +515,8 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes player to leave all their jobs
|
* Causes player to leave all their jobs
|
||||||
* @param jPlayer
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
*/
|
*/
|
||||||
public void leaveAllJobs(JobsPlayer jPlayer) {
|
public void leaveAllJobs(JobsPlayer jPlayer) {
|
||||||
List<JobProgression> jobs = new ArrayList<>();
|
List<JobProgression> jobs = new ArrayList<>();
|
||||||
@ -450,8 +527,9 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfers player job
|
* Transfers player job to a new one
|
||||||
* @param jPlayer
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
* @param oldjob - the old job
|
* @param oldjob - the old job
|
||||||
* @param newjob - the new job
|
* @param newjob - the new job
|
||||||
*/
|
*/
|
||||||
@ -471,7 +549,8 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Promotes player in their job
|
* Promotes player in their job
|
||||||
* @param jPlayer
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
* @param job - the job
|
* @param job - the job
|
||||||
* @param levels - number of levels to promote
|
* @param levels - number of levels to promote
|
||||||
*/
|
*/
|
||||||
@ -484,7 +563,8 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Demote player in their job
|
* Demote player in their job
|
||||||
* @param jPlayer
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
* @param job - the job
|
* @param job - the job
|
||||||
* @param levels - number of levels to demote
|
* @param levels - number of levels to demote
|
||||||
*/
|
*/
|
||||||
@ -497,7 +577,8 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds experience to the player
|
* Adds experience to the player
|
||||||
* @param jPlayer
|
*
|
||||||
|
* @param jPlayer {@link JobsPlayer}
|
||||||
* @param job - the job
|
* @param job - the job
|
||||||
* @param experience - experience gained
|
* @param experience - experience gained
|
||||||
*/
|
*/
|
||||||
@ -516,9 +597,10 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes experience to the player
|
* Removes experience from the player
|
||||||
* @param jPlayer
|
*
|
||||||
* @param job - the job
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param job {@link Job}
|
||||||
* @param experience - experience gained
|
* @param experience - experience gained
|
||||||
*/
|
*/
|
||||||
public void removeExperience(JobsPlayer jPlayer, Job job, double experience) {
|
public void removeExperience(JobsPlayer jPlayer, Job job, double experience) {
|
||||||
@ -534,8 +616,9 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts level up about a player
|
* Broadcasts level up about a player
|
||||||
* @param jPlayer
|
*
|
||||||
* @param job
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param job {@link Job}
|
||||||
* @param oldLevel
|
* @param oldLevel
|
||||||
*/
|
*/
|
||||||
public void performLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) {
|
public void performLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) {
|
||||||
@ -575,8 +658,8 @@ public class PlayerManager {
|
|||||||
jPlayer,
|
jPlayer,
|
||||||
job.getName(),
|
job.getName(),
|
||||||
prog.getLevel(),
|
prog.getLevel(),
|
||||||
Jobs.gettitleManager().getTitle(oldLevel, prog.getJob().getName()),
|
Jobs.getTitleManager().getTitle(oldLevel, prog.getJob().getName()),
|
||||||
Jobs.gettitleManager().getTitle(prog.getLevel(), prog.getJob().getName()),
|
Jobs.getTitleManager().getTitle(prog.getLevel(), prog.getJob().getName()),
|
||||||
Jobs.getGCManager().SoundLevelupSound.toUpperCase(),
|
Jobs.getGCManager().SoundLevelupSound.toUpperCase(),
|
||||||
Jobs.getGCManager().SoundLevelupVolume,
|
Jobs.getGCManager().SoundLevelupVolume,
|
||||||
Jobs.getGCManager().SoundLevelupPitch,
|
Jobs.getGCManager().SoundLevelupPitch,
|
||||||
@ -651,25 +734,31 @@ public class PlayerManager {
|
|||||||
String colorString = colorStrings.get(s);
|
String colorString = colorStrings.get(s);
|
||||||
String[] sSplit = comma.split(colorString);
|
String[] sSplit = comma.split(colorString);
|
||||||
if (sSplit.length < 3) {
|
if (sSplit.length < 3) {
|
||||||
Jobs.consoleMsg("[Jobs] &cInvalid color " + colorString + "! Colors must be 3 comma-separated numbers ranging from 0 to 255.");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] colorRGB = new int[3];
|
int[] colorRGB = new int[3];
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
String colorInt = sSplit[i];
|
|
||||||
try {
|
try {
|
||||||
colorRGB[i] = Integer.parseInt(colorInt);
|
colorRGB[i] = Integer.parseInt(sSplit[i]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Jobs.consoleMsg("[Jobs] &cInvalid color component " + colorInt + ", it must be an integer.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
int r = colorRGB[0], g = colorRGB[1], b = colorRGB[2];
|
||||||
colors[s] = Color.fromRGB(colorRGB[0], colorRGB[1], colorRGB[2]);
|
if (r > 255 || r < 0) {
|
||||||
} catch (IllegalArgumentException e) {
|
r = 1;
|
||||||
Jobs.consoleMsg("[Jobs] &cFailed to add color! " + e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g > 255 || g < 0) {
|
||||||
|
g = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b > 255 || b < 0) {
|
||||||
|
b = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
colors[s] = Color.fromRGB(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
fm.addEffect(FireworkEffect.builder()
|
fm.addEffect(FireworkEffect.builder()
|
||||||
@ -688,11 +777,8 @@ public class PlayerManager {
|
|||||||
}, Jobs.getGCManager().ShootTime);
|
}, Jobs.getGCManager().ShootTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
String message;
|
String message = Jobs.getLanguage().getMessage("message.levelup." + (Jobs.getGCManager().isBroadcastingLevelups()
|
||||||
if (Jobs.getGCManager().isBroadcastingLevelups())
|
? "broadcast" : "nobroadcast"));
|
||||||
message = Jobs.getLanguage().getMessage("message.levelup.broadcast");
|
|
||||||
else
|
|
||||||
message = Jobs.getLanguage().getMessage("message.levelup.nobroadcast");
|
|
||||||
|
|
||||||
message = message.replace("%jobname%", job.getNameWithColor());
|
message = message.replace("%jobname%", job.getNameWithColor());
|
||||||
|
|
||||||
@ -728,10 +814,8 @@ public class PlayerManager {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
// user would skill up
|
// user would skill up
|
||||||
if (Jobs.getGCManager().isBroadcastingSkillups())
|
message = Jobs.getLanguage().getMessage("message.skillup." + (Jobs.getGCManager().isBroadcastingSkillups()
|
||||||
message = Jobs.getLanguage().getMessage("message.skillup.broadcast");
|
? "broadcast" : "nobroadcast"));
|
||||||
else
|
|
||||||
message = Jobs.getLanguage().getMessage("message.skillup.nobroadcast");
|
|
||||||
|
|
||||||
message = message.replace("%playername%", player != null ? player.getDisplayName() : jPlayer.getName());
|
message = message.replace("%playername%", player != null ? player.getDisplayName() : jPlayer.getName());
|
||||||
message = message.replace("%titlename%", levelUpEvent.getNewTitle()
|
message = message.replace("%titlename%", levelUpEvent.getNewTitle()
|
||||||
@ -765,8 +849,9 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs command on level up
|
* Performs command on level up
|
||||||
* @param jPlayer
|
*
|
||||||
* @param job
|
* @param jPlayer {@link JobsPlayer}
|
||||||
|
* @param job {@link Job}
|
||||||
* @param oldLevel
|
* @param oldLevel
|
||||||
*/
|
*/
|
||||||
public void performCommandOnLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) {
|
public void performCommandOnLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) {
|
||||||
@ -792,6 +877,7 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whenever the given jobs player is under the max allowed jobs.
|
* Checks whenever the given jobs player is under the max allowed jobs.
|
||||||
|
*
|
||||||
* @param player {@link JobsPlayer}
|
* @param player {@link JobsPlayer}
|
||||||
* @param currentCount the current jobs size
|
* @param currentCount the current jobs size
|
||||||
* @return true if the player is under the given jobs size
|
* @return true if the player is under the given jobs size
|
||||||
@ -802,6 +888,7 @@ public class PlayerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the maximum jobs from player.
|
* Gets the maximum jobs from player.
|
||||||
|
*
|
||||||
* @param jPlayer {@link JobsPlayer}
|
* @param jPlayer {@link JobsPlayer}
|
||||||
* @return the maximum allowed jobs
|
* @return the maximum allowed jobs
|
||||||
*/
|
*/
|
||||||
@ -835,7 +922,7 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform reload
|
* Perform reload for all jobs players.
|
||||||
*/
|
*/
|
||||||
public void reload() {
|
public void reload() {
|
||||||
for (JobsPlayer jPlayer : players.values()) {
|
for (JobsPlayer jPlayer : players.values()) {
|
||||||
@ -881,51 +968,44 @@ public class PlayerManager {
|
|||||||
if (player == null || prog == null)
|
if (player == null || prog == null)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
ItemStack iih;
|
ItemStack iih;
|
||||||
List<JobItems> jitems = new ArrayList<>();
|
List<JobItems> jitems = new ArrayList<>();
|
||||||
|
|
||||||
// Check mainhand slot
|
// Check mainhand slot
|
||||||
if (Jobs.getGCManager().boostedItemsInMainHand) {
|
if (Jobs.getGCManager().boostedItemsInMainHand && (iih = Jobs.getNms().getItemInMainHand(player)) != null) {
|
||||||
iih = Jobs.getNms().getItemInMainHand(player);
|
jitems.add(getJobsItemByNbt(iih));
|
||||||
|
}
|
||||||
|
|
||||||
if (iih != null) {
|
// Check offhand slot
|
||||||
jitems.add(getJobsItemByNbt(iih));
|
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1) && Jobs.getGCManager().boostedItemsInOffHand
|
||||||
}
|
&& (iih = CMIReflections.getItemInOffHand(player)) != null) {
|
||||||
}
|
jitems.add(getJobsItemByNbt(iih));
|
||||||
|
}
|
||||||
|
|
||||||
// Check offhand slot
|
// Check armor slots
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1) && Jobs.getGCManager().boostedItemsInOffHand) {
|
if (Jobs.getGCManager().boostedArmorItems) {
|
||||||
iih = CMIReflections.getItemInOffHand(player);
|
for (ItemStack oneArmor : player.getInventory().getArmorContents()) {
|
||||||
|
if (oneArmor != null && oneArmor.getType() != org.bukkit.Material.AIR) {
|
||||||
|
jitems.add(getJobsItemByNbt(oneArmor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (iih != null) {
|
for (JobItems jitem : jitems) {
|
||||||
jitems.add(getJobsItemByNbt(iih));
|
if (jitem != null && jitem.getJobs().contains(prog)) {
|
||||||
}
|
data.add(jitem.getBoost(getJobsPlayer(player).getJobProgression(prog)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check armor slots
|
return data;
|
||||||
if (Jobs.getGCManager().boostedArmorItems) {
|
|
||||||
for (ItemStack oneArmor : player.getInventory().getArmorContents()) {
|
|
||||||
if (oneArmor != null && oneArmor.getType() != org.bukkit.Material.AIR) {
|
|
||||||
jitems.add(getJobsItemByNbt(oneArmor));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (JobItems jitem : jitems) {
|
|
||||||
if (jitem != null && jitem.getJobs().contains(prog)) {
|
|
||||||
data.add(jitem.getBoost(getJobsPlayer(player).getJobProgression(prog)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final String JobsItemBoost = "JobsItemBoost";
|
||||||
|
|
||||||
public boolean containsItemBoostByNBT(ItemStack item) {
|
public boolean containsItemBoostByNBT(ItemStack item) {
|
||||||
return item != null && Jobs.getReflections().hasNbtString(item, JobsItemBoost);
|
return item != null && Jobs.getReflections().hasNbtString(item, JobsItemBoost);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String JobsItemBoost = "JobsItemBoost";
|
|
||||||
|
|
||||||
public JobItems getJobsItemByNbt(ItemStack item) {
|
public JobItems getJobsItemByNbt(ItemStack item) {
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -380,7 +380,7 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
String path = "command.stats.output." + (isMaxLevelReached ? "max-level"
|
String path = "command.stats.output." + (isMaxLevelReached ? "max-level"
|
||||||
: "message");
|
: "message");
|
||||||
|
|
||||||
Title title = Jobs.gettitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName());
|
Title title = Jobs.getTitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName());
|
||||||
String message = Jobs.getLanguage().getMessage(path,
|
String message = Jobs.getLanguage().getMessage(path,
|
||||||
"%joblevel%", jobProg.getLevel(),
|
"%joblevel%", jobProg.getLevel(),
|
||||||
"%jobname%", jobProg.getJob().getNameWithColor(),
|
"%jobname%", jobProg.getJob().getNameWithColor(),
|
||||||
|
@ -33,7 +33,7 @@ public class BossBarManager {
|
|||||||
ShowJobProgression(player, oneJob, oneJob.getLastExperience());
|
ShowJobProgression(player, oneJob, oneJob.getLastExperience());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.clearUpdateBossBarFor();
|
player.getUpdateBossBarFor().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) {
|
public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) {
|
||||||
|
@ -264,7 +264,7 @@ public class GeneralConfigManager {
|
|||||||
// Load locale
|
// Load locale
|
||||||
Jobs.getLanguageManager().load();
|
Jobs.getLanguageManager().load();
|
||||||
// title settings
|
// title settings
|
||||||
Jobs.gettitleManager().load();
|
Jobs.getTitleManager().load();
|
||||||
// restricted areas
|
// restricted areas
|
||||||
Jobs.getRestrictedAreaManager().load();
|
Jobs.getRestrictedAreaManager().load();
|
||||||
// restricted blocks
|
// restricted blocks
|
||||||
|
@ -22,18 +22,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class JobCommands {
|
public class JobCommands {
|
||||||
|
|
||||||
private String node;
|
private String node;
|
||||||
private final List<String> commands = new ArrayList<>();
|
|
||||||
private int levelFrom;
|
private int levelFrom;
|
||||||
private int levelUntil;
|
private int levelUntil;
|
||||||
|
|
||||||
@Deprecated
|
private final List<String> commands = new ArrayList<>();
|
||||||
public JobCommands(String node, String command, int levelFrom, int levelUntil) {
|
|
||||||
this.node = node;
|
|
||||||
this.commands.add(command);
|
|
||||||
this.levelFrom = levelFrom;
|
|
||||||
this.levelUntil = levelUntil;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JobCommands(String node, List<String> commands, int levelFrom, int levelUntil) {
|
public JobCommands(String node, List<String> commands, int levelFrom, int levelUntil) {
|
||||||
this.node = node;
|
this.node = node;
|
||||||
@ -46,11 +40,6 @@ public class JobCommands {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public String getCommand() {
|
|
||||||
return commands.isEmpty() ? "" : commands.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getCommands() {
|
public List<String> getCommands() {
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
@ -57,9 +57,8 @@ public class JobConditions {
|
|||||||
|
|
||||||
String clean = one.toLowerCase().substring("p:".length());
|
String clean = one.toLowerCase().substring("p:".length());
|
||||||
if (clean.contains("-")) {
|
if (clean.contains("-")) {
|
||||||
String perm = clean.split("-")[0];
|
String[] split = clean.split("-");
|
||||||
boolean n = clean.split("-")[1].equalsIgnoreCase("true");
|
performPerm.put(split[0], split[1].equalsIgnoreCase("true"));
|
||||||
performPerm.put(perm, n);
|
|
||||||
} else {
|
} else {
|
||||||
performPerm.put(clean, true);
|
performPerm.put(clean, true);
|
||||||
}
|
}
|
||||||
|
@ -93,38 +93,76 @@ public class JobsPlayer {
|
|||||||
this.userName = userName == null ? "Unknown" : userName;
|
this.userName = userName == null ? "Unknown" : userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the cached or new instance of {@link PlayerPoints}
|
||||||
|
*/
|
||||||
public PlayerPoints getPointsData() {
|
public PlayerPoints getPointsData() {
|
||||||
if (pointsData == null)
|
if (pointsData == null)
|
||||||
pointsData = new PlayerPoints();
|
pointsData = new PlayerPoints();
|
||||||
return pointsData;
|
return pointsData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPoints(Double points) {
|
/**
|
||||||
|
* Adds points to this player.
|
||||||
|
*
|
||||||
|
* @param points the amount of points
|
||||||
|
*/
|
||||||
|
public void addPoints(double points) {
|
||||||
getPointsData().addPoints(points);
|
getPointsData().addPoints(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takePoints(Double points) {
|
/**
|
||||||
|
* Takes points from this player.
|
||||||
|
*
|
||||||
|
* @param points the amount of points
|
||||||
|
*/
|
||||||
|
public void takePoints(double points) {
|
||||||
getPointsData().takePoints(points);
|
getPointsData().takePoints(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPoints(Double points) {
|
/**
|
||||||
|
* Sets points for this player.
|
||||||
|
*
|
||||||
|
* @param points the amount of points
|
||||||
|
*/
|
||||||
|
public void setPoints(double points) {
|
||||||
getPointsData().setPoints(points);
|
getPointsData().setPoints(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets points for this player from the given {@link PlayerPoints}
|
||||||
|
*
|
||||||
|
* @param points {@link PlayerPoints}
|
||||||
|
*/
|
||||||
public void setPoints(PlayerPoints points) {
|
public void setPoints(PlayerPoints points) {
|
||||||
getPointsData().setPoints(points.getCurrentPoints());
|
getPointsData().setPoints(points.getCurrentPoints());
|
||||||
getPointsData().setTotalPoints(points.getTotalPoints());
|
getPointsData().setTotalPoints(points.getTotalPoints());
|
||||||
getPointsData().setDbId(points.getDbId());
|
getPointsData().setDbId(points.getDbId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whenever have enough points for the given one.
|
||||||
|
*
|
||||||
|
* @param points amount of points
|
||||||
|
* @return true if yes
|
||||||
|
*/
|
||||||
public boolean havePoints(double points) {
|
public boolean havePoints(double points) {
|
||||||
return getPointsData().getCurrentPoints() >= points;
|
return getPointsData().getCurrentPoints() >= points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the cached instance of {@link ArchivedJobs}
|
||||||
|
*/
|
||||||
public ArchivedJobs getArchivedJobs() {
|
public ArchivedJobs getArchivedJobs() {
|
||||||
return archivedJobs;
|
return archivedJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the given archived job progression.
|
||||||
|
*
|
||||||
|
* @param job {@link Job}
|
||||||
|
* @return the given archived job progression
|
||||||
|
*/
|
||||||
public JobProgression getArchivedJobProgression(Job job) {
|
public JobProgression getArchivedJobProgression(Job job) {
|
||||||
return archivedJobs.getArchivedJobProgression(job);
|
return archivedJobs.getArchivedJobProgression(job);
|
||||||
}
|
}
|
||||||
@ -133,6 +171,9 @@ public class JobsPlayer {
|
|||||||
this.archivedJobs = archivedJob;
|
this.archivedJobs = archivedJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the total level of all jobs for this player
|
||||||
|
*/
|
||||||
public int getTotalLevels() {
|
public int getTotalLevels() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (JobProgression job : progression) {
|
for (JobProgression job : progression) {
|
||||||
@ -145,6 +186,9 @@ public class JobsPlayer {
|
|||||||
this.paymentLimits = paymentLimits;
|
this.paymentLimits = paymentLimits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the limit of {@link PaymentData}
|
||||||
|
*/
|
||||||
public PaymentData getPaymentLimit() {
|
public PaymentData getPaymentLimit() {
|
||||||
if (paymentLimits == null)
|
if (paymentLimits == null)
|
||||||
paymentLimits = Jobs.getJobsDAO().getPlayersLimits(this);
|
paymentLimits = Jobs.getJobsDAO().getPlayersLimits(this);
|
||||||
@ -154,6 +198,13 @@ public class JobsPlayer {
|
|||||||
return paymentLimits;
|
return paymentLimits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whenever this player is under limit for specific {@link CurrencyType}
|
||||||
|
*
|
||||||
|
* @param type {@link CurrencyType}
|
||||||
|
* @param amount amount of points
|
||||||
|
* @return true if it is under
|
||||||
|
*/
|
||||||
public boolean isUnderLimit(CurrencyType type, Double amount) {
|
public boolean isUnderLimit(CurrencyType type, Double amount) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
if (player == null || amount == 0)
|
if (player == null || amount == 0)
|
||||||
@ -192,23 +243,30 @@ public class JobsPlayer {
|
|||||||
return getPaymentLimit().percentOverLimit(type, value == null ? 0 : value);
|
return getPaymentLimit().percentOverLimit(type, value == null ? 0 : value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to load log for this player.
|
||||||
|
*
|
||||||
|
* @deprecated use {@link JobsDAO#loadLog(JobsPlayer)} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void loadLogFromDao() {
|
public void loadLogFromDao() {
|
||||||
Jobs.getJobsDAO().loadLog(this);
|
Jobs.getJobsDAO().loadLog(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<String> getUpdateBossBarFor() {
|
public List<String> getUpdateBossBarFor() {
|
||||||
return updateBossBarFor;
|
return updateBossBarFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void clearUpdateBossBarFor() {
|
@Deprecated
|
||||||
|
public void clearUpdateBossBarFor() {
|
||||||
updateBossBarFor.clear();
|
updateBossBarFor.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<BossBarInfo> getBossBarInfo() {
|
public List<BossBarInfo> getBossBarInfo() {
|
||||||
return barMap;
|
return barMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void hideBossBars() {
|
public void hideBossBars() {
|
||||||
for (BossBarInfo one : barMap) {
|
for (BossBarInfo one : barMap) {
|
||||||
one.getBar().setVisible(false);
|
one.getBar().setVisible(false);
|
||||||
}
|
}
|
||||||
@ -231,21 +289,32 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player
|
* @return {@link Player} or null if not exist
|
||||||
* @return the player
|
|
||||||
*/
|
*/
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return playerUUID != null ? Bukkit.getPlayer(playerUUID) : null;
|
return playerUUID != null ? Bukkit.getPlayer(playerUUID) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Boost
|
* Attempts to get the boost from specific job and {@link CurrencyType}
|
||||||
* @return the Boost
|
*
|
||||||
|
* @param JobName
|
||||||
|
* @param type {@link CurrencyType}
|
||||||
|
* @see #getBoost(String, CurrencyType, boolean)
|
||||||
|
* @return amount of boost
|
||||||
*/
|
*/
|
||||||
public double getBoost(String JobName, CurrencyType type) {
|
public double getBoost(String JobName, CurrencyType type) {
|
||||||
return getBoost(JobName, type, false);
|
return getBoost(JobName, type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to get the boost from specific job and {@link CurrencyType}
|
||||||
|
*
|
||||||
|
* @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;
|
double Boost = 0D;
|
||||||
|
|
||||||
@ -316,7 +385,7 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reloads max experience for this job.
|
* Reloads max experience for all jobs for this player.
|
||||||
*/
|
*/
|
||||||
public void reloadMaxExperience() {
|
public void reloadMaxExperience() {
|
||||||
progression.forEach(JobProgression::reloadMaxExperience);
|
progression.forEach(JobProgression::reloadMaxExperience);
|
||||||
@ -353,16 +422,17 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of job progressions
|
* @return an unmodifiable list of job progressions
|
||||||
* @return the list of job progressions
|
|
||||||
*/
|
*/
|
||||||
public List<JobProgression> getJobProgression() {
|
public List<JobProgression> getJobProgression() {
|
||||||
return Collections.unmodifiableList(progression);
|
return Collections.unmodifiableList(progression);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the job progression with the certain job
|
* Get the job progression from the certain job
|
||||||
* @return the job progression
|
*
|
||||||
|
* @param job {@link Job}
|
||||||
|
* @return the job progression or null if job not exists
|
||||||
*/
|
*/
|
||||||
public JobProgression getJobProgression(Job job) {
|
public JobProgression getJobProgression(Job job) {
|
||||||
for (JobProgression prog : progression) {
|
for (JobProgression prog : progression) {
|
||||||
@ -382,8 +452,7 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the getName
|
* @return the name of this player
|
||||||
* @return the getName
|
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
Player player = Bukkit.getPlayer(getUniqueId());
|
Player player = Bukkit.getPlayer(getUniqueId());
|
||||||
@ -402,8 +471,7 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the playerUUID
|
* @return the {@link UUID} of this player
|
||||||
* @return the playerUUID
|
|
||||||
*/
|
*/
|
||||||
public UUID getUniqueId() {
|
public UUID getUniqueId() {
|
||||||
return playerUUID;
|
return playerUUID;
|
||||||
@ -424,8 +492,9 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player joins a job
|
* Attempts to join this player to the given job.
|
||||||
* @param job - the job joined
|
*
|
||||||
|
* @param job where to join
|
||||||
*/
|
*/
|
||||||
public boolean joinJob(Job job) {
|
public boolean joinJob(Job job) {
|
||||||
// synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
@ -519,8 +588,8 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leave all jobs
|
* Attempts to leave all jobs from this player.
|
||||||
* @return on success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
public boolean leaveAllJobs() {
|
public boolean leaveAllJobs() {
|
||||||
// synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
@ -639,10 +708,10 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the player is in this job.
|
* Checks if the player is in the given job.
|
||||||
* @param job - the job
|
*
|
||||||
* @return true - they are in the job
|
* @param job {@link Job}
|
||||||
* @return false - they are not in the job
|
* @return true if this player is in the given job, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean isInJob(Job job) {
|
public boolean isInJob(Job job) {
|
||||||
if (job == null)
|
if (job == null)
|
||||||
@ -655,7 +724,7 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that reloads your honorific
|
* Function that reloads this player honorific
|
||||||
*/
|
*/
|
||||||
public void reloadHonorific() {
|
public void reloadHonorific() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -669,7 +738,7 @@ public class JobsPlayer {
|
|||||||
if (!builder.toString().isEmpty()) {
|
if (!builder.toString().isEmpty()) {
|
||||||
builder.append(Jobs.getGCManager().modifyChatSeparator);
|
builder.append(Jobs.getGCManager().modifyChatSeparator);
|
||||||
}
|
}
|
||||||
Title title = Jobs.gettitleManager().getTitle(prog.getLevel(), prog.getJob().getName());
|
Title title = Jobs.getTitleManager().getTitle(prog.getLevel(), prog.getJob().getName());
|
||||||
processesChat(method, builder, prog.getLevel(), title, prog.getJob());
|
processesChat(method, builder, prog.getLevel(), title, prog.getJob());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -755,7 +824,7 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs player save
|
* Performs player save into database
|
||||||
*/
|
*/
|
||||||
public void save() {
|
public void save() {
|
||||||
// synchronized (saveLock) {
|
// synchronized (saveLock) {
|
||||||
@ -784,8 +853,7 @@ public class JobsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform disconnect
|
* Perform disconnect for this player
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void onDisconnect() {
|
public void onDisconnect() {
|
||||||
// Jobs.getJobsDAO().savePoints(this);
|
// Jobs.getJobsDAO().savePoints(this);
|
||||||
@ -847,6 +915,12 @@ public class JobsPlayer {
|
|||||||
this.lastPermissionUpdate = lastPermissionUpdate;
|
this.lastPermissionUpdate = lastPermissionUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whenever this player can get paid for the given action.
|
||||||
|
*
|
||||||
|
* @param info {@link ActionInfo}
|
||||||
|
* @return true if yes
|
||||||
|
*/
|
||||||
public boolean canGetPaid(ActionInfo info) {
|
public boolean canGetPaid(ActionInfo info) {
|
||||||
List<JobProgression> progression = getJobProgression();
|
List<JobProgression> progression = getJobProgression();
|
||||||
int numjobs = progression.size();
|
int numjobs = progression.size();
|
||||||
@ -868,11 +942,11 @@ public class JobsPlayer {
|
|||||||
JobInfo jobinfo = prog.getJob().getJobInfo(info, level);
|
JobInfo jobinfo = prog.getJob().getJobInfo(info, level);
|
||||||
if (jobinfo == null)
|
if (jobinfo == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Double income = jobinfo.getIncome(level, numjobs, maxJobsEquation);
|
Double income = jobinfo.getIncome(level, numjobs, maxJobsEquation);
|
||||||
Double pointAmount = jobinfo.getPoints(level, numjobs, maxJobsEquation);
|
Double pointAmount = jobinfo.getPoints(level, numjobs, maxJobsEquation);
|
||||||
Double expAmount = jobinfo.getExperience(level, numjobs, maxJobsEquation);
|
Double expAmount = jobinfo.getExperience(level, numjobs, maxJobsEquation);
|
||||||
if (income != 0D || pointAmount != 0D || expAmount != 0D)
|
return income != 0D || pointAmount != 0D || expAmount != 0D;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -1176,7 +1250,7 @@ public class JobsPlayer {
|
|||||||
this.doneQuests = doneQuests;
|
this.doneQuests = doneQuests;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer questSignUpdateShed = null;
|
private Integer questSignUpdateShed;
|
||||||
|
|
||||||
public void addDoneQuest(final Job job) {
|
public void addDoneQuest(final Job job) {
|
||||||
this.doneQuests++;
|
this.doneQuests++;
|
||||||
|
Loading…
Reference in New Issue
Block a user