1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-29 04:18:07 +01:00

Merge branch 'Zrips:master' into bucket-entity-action

This commit is contained in:
FireML 2023-07-21 05:52:43 +01:00 committed by GitHub
commit 2fab19974c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
130 changed files with 4855 additions and 4778 deletions

Binary file not shown.

BIN
libs/CMILib1.4.0.0.jar Normal file

Binary file not shown.

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId>
<artifactId>jobs</artifactId>
<version>5.1.2.2</version>
<version>5.2.1.0</version>
<name>Jobs</name>
<url>http://maven.apache.org</url>
@ -197,7 +197,7 @@
<artifactId>CMILib</artifactId>
<version>latest</version>
<scope>system</scope>
<systemPath>${basedir}/libs/CMILib1.2.4.5.jar</systemPath>
<systemPath>${basedir}/libs/CMILib1.4.0.0.jar</systemPath>
</dependency>
<!-- WildStacker -->
<dependency>
@ -286,7 +286,7 @@
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>D:\MC\Server 1.19\plugins\</outputDirectory>
<outputDirectory>D:\MC\Server 1.20\plugins\</outputDirectory>
</configuration>
</plugin>
</plugins>

View File

@ -27,6 +27,7 @@ import net.Zrips.CMILib.GUI.CMIGuiButton;
import net.Zrips.CMILib.GUI.GUIManager.GUIClickType;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Version.Version;
public class GuiManager {
@ -285,6 +286,7 @@ public class GuiManager {
}
double income = jInfo.getIncome(level, numjobs, jPlayer.maxJobsEquation);
income = boost.getFinalAmount(CurrencyType.MONEY, income);
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();

View File

@ -18,13 +18,14 @@
package com.gamingmesh.jobs;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import com.gamingmesh.jobs.economy.BlackholeEconomy;
import com.gamingmesh.jobs.economy.VaultEconomy;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.milkbowl.vault.economy.Economy;
public class HookEconomyTask implements Runnable {
private Jobs plugin;
@ -72,7 +73,7 @@ public class HookEconomyTask implements Runnable {
}
Jobs.setEconomy(new VaultEconomy(provider.getProvider()));
Jobs.consoleMsg("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault. (" + provider.getProvider().getName() + ")");
CMIMessages.consoleMessage("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault. (" + provider.getProvider().getName() + ")");
return hookResult.pass;
}

View File

@ -22,6 +22,7 @@ import com.gamingmesh.jobs.container.JobItems;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Messages.CMIMessages;
public final class ItemBoostManager {
@ -228,7 +229,7 @@ public final class ItemBoostManager {
}
cfg.save();
Jobs.consoleMsg("&eLoaded &6" + ITEMS.size() + " &eboosted items");
CMIMessages.consoleMessage("&eLoaded &6" + ITEMS.size() + " &eboosted items");
}
/**

View File

@ -34,7 +34,6 @@ import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -112,14 +111,12 @@ import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public final class Jobs extends JavaPlugin {
@ -168,7 +165,7 @@ public final class Jobs extends JavaPlugin {
private static boolean hasLimitedItems = false;
private static final int MAX_ENTRIES = 5;
private static final int MAX_ENTRIES = 20;
public static final LinkedHashMap<UUID, FastPayment> FASTPAYMENT = new LinkedHashMap<UUID, FastPayment>(MAX_ENTRIES + 1, .75F, false) {
protected boolean removeEldestEntry(Map.Entry<UUID, FastPayment> eldest) {
return size() > MAX_ENTRIES;
@ -268,7 +265,7 @@ public final class Jobs extends JavaPlugin {
try {
if (Integer.parseInt(papi
.getDescription().getVersion().replaceAll("[^\\d]", "")) >= 2100 && new PlaceholderAPIHook(this).register()) {
consoleMsg("&6PlaceholderAPI &ehooked.");
CMIMessages.consoleMessage("&6PlaceholderAPI &ehooked.");
}
} catch (NumberFormatException ex) {
return false;
@ -567,7 +564,7 @@ public final class Jobs extends JavaPlugin {
getPlayerManager().addPlayerToCache(jPlayer);
}
if (!getPlayerManager().getPlayersCache().isEmpty())
consoleMsg("&ePreloaded &6" + getPlayerManager().getPlayersCache().size() + " &eplayers data in &6" + ((int) ((System.currentTimeMillis() - time) / 1000.0D * 100.0D) / 100.0D));
CMIMessages.consoleMessage("&ePreloaded &6" + getPlayerManager().getPlayersCache().size() + " &eplayers data in &6" + ((int) ((System.currentTimeMillis() - time) / 1000.0D * 100.0D) / 100.0D));
}
public static void convertDatabase() {
@ -597,7 +594,7 @@ public final class Jobs extends JavaPlugin {
// Jobs.getJobsDAO().saveBlockProtection();
} catch (SQLException e) {
e.printStackTrace();
Jobs.consoleMsg("&cCan't write data to data base, please send error log to dev's.");
CMIMessages.consoleMessage("&cCan't write data to data base, please send error log to dev's.");
return;
}
@ -767,14 +764,14 @@ public final class Jobs extends JavaPlugin {
}
// register economy
getServer().getScheduler().runTask(this, new HookEconomyTask(this));
CMIScheduler.get().runTask(new HookEconomyTask(this));
dao.loadBlockProtection();
getExploreManager().load();
getCommandManager().fillCommands();
getDBManager().getDB().triggerTableIdUpdate();
consoleMsg("&ePlugin has been enabled successfully.");
CMIMessages.consoleMessage("&ePlugin has been enabled successfully.");
} catch (Throwable e) {
e.printStackTrace();
System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled.");
@ -916,6 +913,9 @@ public final class Jobs extends JavaPlugin {
}
private static void checkDailyQuests(JobsPlayer jPlayer, Job job, ActionInfo info) {
if (!Jobs.getGCManager().DailyQuestsEnabled) {
return;
}
if (!job.getQuests().isEmpty()) {
for (QuestProgression one : jPlayer.getQuestProgressions(job, info.getType())) {
one.processQuest(jPlayer, info);
@ -1258,7 +1258,7 @@ public final class Jobs extends JavaPlugin {
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName());
} catch (Throwable e) {
e.printStackTrace();
consoleMsg("&c[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it.");
CMIMessages.consoleMessage("&c[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it.");
}
Map<CurrencyType, Double> payments = new HashMap<>();
@ -1416,15 +1416,27 @@ public final class Jobs extends JavaPlugin {
return 9 * level - 158;
}
public static void perform(JobsPlayer jPlayer, ActionInfo info, BufferedPayment payment, Job job) {
public static void perform(JobsPlayer jPlayer, ActionInfo info, BufferedPayment payment, Job job, Block block, Entity ent, LivingEntity victim) {
double expPayment = payment.get(CurrencyType.EXP);
JobsPrePaymentEvent jobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), noneJob, payment.get(CurrencyType.MONEY),
payment.get(CurrencyType.POINTS), block, ent, victim, info);
Bukkit.getServer().getPluginManager().callEvent(jobsPrePaymentEvent);
// If event is canceled, don't do anything
if (jobsPrePaymentEvent.isCancelled())
return;
payment.set(CurrencyType.MONEY, jobsPrePaymentEvent.getAmount());
payment.set(CurrencyType.POINTS, jobsPrePaymentEvent.getPoints());
JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, expPayment);
Bukkit.getServer().getPluginManager().callEvent(jobsExpGainEvent);
// If event is canceled, don't do anything
if (jobsExpGainEvent.isCancelled())
return;
payment.set(CurrencyType.EXP, jobsExpGainEvent.getExp());
boolean limited = true;
for (CurrencyType one : CurrencyType.values()) {
if (jPlayer.isUnderLimit(one, payment.get(one))) {
@ -1449,12 +1461,6 @@ public final class Jobs extends JavaPlugin {
getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
}
public static void consoleMsg(String msg) {
if (msg != null) {
Bukkit.getServer().getConsoleSender().sendMessage(CMIChatColor.translate(msg));
}
}
public static SelectionManager getSelectionManager() {
return smanager;
}
@ -1472,50 +1478,6 @@ public final class Jobs extends JavaPlugin {
}
public void showPagination(CommandSender sender, PageInfo pi, String cmd) {
showPagination(sender, pi.getTotalPages(), pi.getCurrentPage(), pi.getTotalEntries(), cmd, null);
}
public void showPagination(CommandSender sender, PageInfo pi, String cmd, String pagePref) {
showPagination(sender, pi.getTotalPages(), pi.getCurrentPage(), pi.getTotalEntries(), cmd, pagePref);
}
public void showPagination(CommandSender sender, int pageCount, int currentPage, int totalEntries, String cmd, String pagePref) {
if (!(sender instanceof Player))
return;
if (!cmd.startsWith("/"))
cmd = "/" + cmd;
if (pageCount == 1)
return;
String pagePrefix = pagePref == null ? "" : pagePref;
int nextPage = currentPage + 1;
nextPage = currentPage < pageCount ? nextPage : currentPage;
int prevpage = currentPage - 1;
if (currentPage <= 1) {
prevpage = currentPage;
}
RawMessage rm = new RawMessage()
.addText((currentPage > 1 ? LC.info_prevPage.getLocale() : LC.info_prevPageOff.getLocale()))
.addHover(currentPage > 1 ? LC.info_prevPageHover.getLocale() : LC.info_lastPageHover.getLocale())
.addCommand(currentPage > 1 ? cmd + " " + pagePrefix + prevpage : cmd + " " + pagePrefix + pageCount);
rm.addText(LC.info_pageCount.getLocale("[current]", currentPage, "[total]", pageCount))
.addHover(LC.info_pageCountHover.getLocale("[totalEntries]", totalEntries));
rm.addText(pageCount > currentPage ? LC.info_nextPage.getLocale() : LC.info_nextPageOff.getLocale())
.addHover(pageCount > currentPage ? LC.info_nextPageHover.getLocale() : LC.info_firstPageHover.getLocale())
.addCommand(pageCount > currentPage ? cmd + " " + pagePrefix + nextPage : cmd + " " + pagePrefix + 1);
if (pageCount != 0)
rm.show(sender);
}
public static boolean hasLimitedItems() {
return hasLimitedItems;
}

View File

@ -53,7 +53,9 @@ public class PermissionManager {
jobs_maxblastfurnaces_AMOUNT(remade("jobs.maxblastfurnaces.%AMOUNT%"), 30),
jobs_maxsmokers_AMOUNT(remade("jobs.maxsmokers.%AMOUNT%"), 30),
jobs_maxbrewingstands_AMOUNT(remade("jobs.maxbrewingstands.%AMOUNT%"), 30),
jobs_world_WORLDNAME(remade("jobs.world.%WORLDNAME%"), 2);
jobs_world_WORLDNAME(remade("jobs.world.%WORLDNAME%"), 2),
jobs_maxquest_JOBNAME_AMOUNT(remade("jobs.maxquest.%JOBNAME%.%AMOUNT%"), 30),
jobs_maxquest_all_AMOUNT(remade("jobs.maxquest.all.%AMOUNT%"), 30);
private int reload;
private List<String> perms;
@ -93,7 +95,7 @@ public class PermissionManager {
}
private int getDelay(String perm) {
return permDelay.getOrDefault(perm, 1);
return permDelay.getOrDefault(perm, 1000);
}
public PermissionManager() {
@ -165,9 +167,11 @@ public class PermissionManager {
double amount = Double.NEGATIVE_INFINITY;
permissionInfo permInfo = jPlayer.getPermissionsCache(perm);
if (force || getDelay(perm) + permInfo.getTime() < System.currentTimeMillis()) {
Map<String, Boolean> perms = getAll(player, perm);
for (Map.Entry<String, Boolean> permission : perms.entrySet()) {
for (Map.Entry<String, Boolean> permission : perms.entrySet()) {
if (!permission.getKey().startsWith(perm) || !permission.getValue())
continue;
try {
@ -176,7 +180,7 @@ public class PermissionManager {
if (amount == Double.NEGATIVE_INFINITY)
amount = 0D;
amount += temp;
}else if (temp > amount)
} else if (temp > amount)
amount = temp;
} catch (NumberFormatException ex) {
Jobs.getPluginLogger().log(java.util.logging.Level.WARNING, ex.getLocalizedMessage());

View File

@ -88,6 +88,7 @@ public class Placeholder {
user_archived_jobs_exp_$1("jname/number"),
jtop_name_$1_$2("jname/number", "[1-15]"),
jtop_displayname_$1_$2("jname/number", "[1-15]"),
jtop_level_$1_$2("jname/number", "[1-15]"),
maxjobs,
@ -616,6 +617,26 @@ public class Placeholder {
List<TopList> list = Jobs.getJobsDAO().getTopListByJob(jo, 15);
if (list.size() < place)
return "";
return list.get(place - 1).getPlayerInfo().getName();
case jtop_displayname_$1_$2:
if (values.size() < 2)
return "";
place = 0;
try {
place = Integer.parseInt(values.get(1));
} catch (NumberFormatException e) {
return "";
}
if (place < 1)
return "";
list = Jobs.getJobsDAO().getTopListByJob(jo, 15);
if (list.size() < place)
return "";

View File

@ -31,8 +31,8 @@ import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity;
@ -40,8 +40,6 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.gamingmesh.jobs.api.JobsJoinEvent;
import com.gamingmesh.jobs.api.JobsLeaveEvent;
@ -62,7 +60,6 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.dao.JobsDAOData;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.stuff.PerformCommands;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
@ -72,6 +69,7 @@ import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.NBT.CMINBT;
import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class PlayerManager {
@ -336,7 +334,7 @@ public class PlayerManager {
i++;
if (y++ >= 1000) {
Jobs.consoleMsg("&e[Jobs] Saved " + i + "/" + total + " players data");
CMIMessages.consoleMessage("&e[Jobs] Saved " + i + "/" + total + " players data");
y = 0;
}
}
@ -452,6 +450,14 @@ public class PlayerManager {
return jPlayer;
}
private static void performCommandsOnJoin(JobsPlayer jPlayer, Job job) {
String pName = jPlayer.getName();
for (String one : job.getCmdOnJoin()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", pName).replace("[jobname]", job.getName()));
}
}
/**
* Causes player to join to the given job.
*
@ -476,13 +482,23 @@ public class PlayerManager {
Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(job));
jPlayer.setLeftTime(job);
PerformCommands.performCommandsOnJoin(jPlayer, job);
performCommandsOnJoin(jPlayer, job);
Jobs.takeSlot(job);
Jobs.getSignUtil().updateAllSign(job);
job.updateTotalPlayers();
jPlayer.maxJobsEquation = getMaxJobs(jPlayer);
// Removing from cached item boost for recalculation
cache.remove(jPlayer.getUniqueId());
}
private static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) {
String pName = jPlayer.getName();
for (String one : job.getCmdOnLeave()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", pName).replace("[jobname]", job.getName()));
}
}
/**
@ -510,13 +526,17 @@ public class PlayerManager {
if (!Jobs.getJobsDAO().quitJob(jPlayer, job))
return false;
PerformCommands.performCommandsOnLeave(jPlayer, job);
performCommandsOnLeave(jPlayer, job);
Jobs.leaveSlot(job);
jPlayer.getLeftTimes().remove(jPlayer.getUniqueId());
Jobs.getSignUtil().updateAllSign(job);
job.updateTotalPlayers();
// Removing from cached item boost for recalculation
cache.remove(jPlayer.getUniqueId());
return true;
}
@ -712,7 +732,7 @@ public class PlayerManager {
}
if (Jobs.getGCManager().FireworkLevelupUse && player != null) {
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
CMIScheduler.get().runTaskLater(new Runnable() {
@Override
public void run() {
if (!player.isOnline())
@ -1044,6 +1064,7 @@ public class PlayerManager {
continue;
}
}
jitems.add(getJobsItemByNbt(item));
}
}
@ -1180,7 +1201,7 @@ public class PlayerManager {
if (!Jobs.getGCManager().AutoJobJoinUse || player == null || player.isOp())
return;
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
CMIScheduler.get().runTaskLater(new Runnable() {
@Override
public void run() {
if (!player.isOnline())
@ -1199,7 +1220,7 @@ public class PlayerManager {
for (Job one : Jobs.getJobs()) {
if (jPlayer.progression.size() >= playerMaxJobs)
return;
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())
continue;

View File

@ -21,8 +21,9 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.TopList;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class SignUtil {
@ -32,345 +33,342 @@ public class SignUtil {
private Jobs plugin;
public SignUtil(Jobs plugin) {
this.plugin = plugin;
this.plugin = plugin;
}
public Map<String, Map<String, jobsSign>> getSigns() {
return signsByType;
return signsByType;
}
public boolean removeSign(Location loc) {
jobsSign jSign = signsByLocation.remove(jobsSign.locToBlockString(loc));
if (jSign == null)
return false;
jobsSign jSign = signsByLocation.remove(jobsSign.locToBlockString(loc));
if (jSign == null)
return false;
Map<String, jobsSign> sub = signsByType.get(jSign.getIdentifier().toLowerCase());
if (sub != null) {
sub.remove(jSign.locToBlockString());
}
Map<String, jobsSign> sub = signsByType.get(jSign.getIdentifier().toLowerCase());
if (sub != null) {
sub.remove(jSign.locToBlockString());
}
return true;
return true;
}
public jobsSign getSign(Location loc) {
return loc == null ? null : signsByLocation.get(jobsSign.locToBlockString(loc));
return loc == null ? null : signsByLocation.get(jobsSign.locToBlockString(loc));
}
public void addSign(jobsSign jSign) {
if (jSign == null)
return;
if (jSign == null)
return;
String locToBlockString = jSign.locToBlockString();
String locToBlockString = jSign.locToBlockString();
signsByLocation.put(locToBlockString, jSign);
signsByLocation.put(locToBlockString, jSign);
String identifier = jSign.getIdentifier().toLowerCase();
Map<String, jobsSign> old = signsByType.get(identifier);
if (old == null) {
old = new HashMap<>();
signsByType.put(identifier, old);
}
String identifier = jSign.getIdentifier().toLowerCase();
Map<String, jobsSign> old = signsByType.get(identifier);
if (old == null) {
old = new HashMap<>();
signsByType.put(identifier, old);
}
old.put(locToBlockString, jSign);
signsByType.put(identifier, old);
old.put(locToBlockString, jSign);
signsByType.put(identifier, old);
}
public void loadSigns() {
if (!Jobs.getGCManager().SignsEnabled)
return;
if (!Jobs.getGCManager().SignsEnabled)
return;
signsByType.clear();
signsByLocation.clear();
signsByType.clear();
signsByLocation.clear();
File file = new File(Jobs.getFolder(), "Signs.yml");
ConfigurationSection confCategory = YamlConfiguration.loadConfiguration(file).getConfigurationSection("Signs");
if (confCategory == null)
return;
File file = new File(Jobs.getFolder(), "Signs.yml");
ConfigurationSection confCategory = YamlConfiguration.loadConfiguration(file).getConfigurationSection("Signs");
if (confCategory == null)
return;
List<String> categoriesList = new ArrayList<>(confCategory.getKeys(false));
if (categoriesList.isEmpty())
return;
List<String> categoriesList = new ArrayList<>(confCategory.getKeys(false));
if (categoriesList.isEmpty())
return;
for (String category : categoriesList) {
ConfigurationSection nameSection = confCategory.getConfigurationSection(category);
if (nameSection == null)
continue;
for (String category : categoriesList) {
ConfigurationSection nameSection = confCategory.getConfigurationSection(category);
if (nameSection == null)
continue;
jobsSign newTemp = new jobsSign();
jobsSign newTemp = new jobsSign();
if (nameSection.isString("World")) {
newTemp.setWorldName(nameSection.getString("World"));
newTemp.setX((int) nameSection.getDouble("X"));
newTemp.setY((int) nameSection.getDouble("Y"));
newTemp.setZ((int) nameSection.getDouble("Z"));
} else {
newTemp.setLoc(nameSection.getString("Loc"));
}
if (nameSection.isString("Type"))
newTemp.setType(SignTopType.getType(nameSection.getString("Type")));
if (nameSection.isString("World")) {
newTemp.setWorldName(nameSection.getString("World"));
newTemp.setX((int) nameSection.getDouble("X"));
newTemp.setY((int) nameSection.getDouble("Y"));
newTemp.setZ((int) nameSection.getDouble("Z"));
} else {
newTemp.setLoc(nameSection.getString("Loc"));
}
if (nameSection.isString("Type"))
newTemp.setType(SignTopType.getType(nameSection.getString("Type")));
newTemp.setNumber(nameSection.getInt("Number"));
if (nameSection.isString("JobName")) {
SignTopType t = SignTopType.getType(nameSection.getString("JobName"));
if (t == null)
newTemp.setJobName(nameSection.getString("JobName"));
}
newTemp.setSpecial(nameSection.getBoolean("Special"));
newTemp.setNumber(nameSection.getInt("Number"));
if (nameSection.isString("JobName")) {
SignTopType t = SignTopType.getType(nameSection.getString("JobName"));
if (t == null)
newTemp.setJobName(nameSection.getString("JobName"));
}
newTemp.setSpecial(nameSection.getBoolean("Special"));
String identifier = newTemp.getIdentifier().toLowerCase();
Map<String, jobsSign> old = signsByType.get(identifier);
if (old == null) {
old = new HashMap<>();
signsByType.put(identifier, old);
}
String identifier = newTemp.getIdentifier().toLowerCase();
Map<String, jobsSign> old = signsByType.get(identifier);
if (old == null) {
old = new HashMap<>();
signsByType.put(identifier, old);
}
String loc = newTemp.locToBlockString();
old.put(loc, newTemp);
signsByLocation.put(loc, newTemp);
}
String loc = newTemp.locToBlockString();
old.put(loc, newTemp);
signsByLocation.put(loc, newTemp);
}
if (!signsByLocation.isEmpty()) {
Jobs.consoleMsg("&e[Jobs] Loaded " + signsByLocation.size() + " top list signs");
}
if (!signsByLocation.isEmpty()) {
CMIMessages.consoleMessage("&e[Jobs] Loaded " + signsByLocation.size() + " top list signs");
}
}
public void saveSigns() {
File f = new File(Jobs.getFolder(), "Signs.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
File f = new File(Jobs.getFolder(), "Signs.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
ConfigReader reader = null;
try {
reader = new ConfigReader(f);
} catch (Exception e1) {
e1.printStackTrace();
}
if (reader == null)
return;
conf.options().copyDefaults(true);
reader.addComment("Signs", "DO NOT EDIT THIS FILE BY HAND!");
ConfigReader reader = null;
try {
reader = new ConfigReader(f);
} catch (Exception e1) {
e1.printStackTrace();
}
if (reader == null)
return;
conf.options().copyDefaults(true);
reader.addComment("Signs", "DO NOT EDIT THIS FILE BY HAND!");
if (!conf.isConfigurationSection("Signs"))
conf.createSection("Signs");
if (!conf.isConfigurationSection("Signs"))
conf.createSection("Signs");
int i = 0;
for (jobsSign sign : signsByLocation.values()) {
String path = "Signs." + ++i;
reader.set(path + ".Loc", sign.locToBlockString());
reader.set(path + ".Number", sign.getNumber());
reader.set(path + ".Type", sign.getType().toString());
reader.set(path + ".JobName", sign.getJobName());
reader.set(path + ".Special", sign.isSpecial());
}
int i = 0;
for (jobsSign sign : signsByLocation.values()) {
String path = "Signs." + ++i;
reader.set(path + ".Loc", sign.locToBlockString());
reader.set(path + ".Number", sign.getNumber());
reader.set(path + ".Type", sign.getType().toString());
reader.set(path + ".JobName", sign.getJobName());
reader.set(path + ".Special", sign.isSpecial());
}
try {
reader.save(f);
} catch (IOException e) {
e.printStackTrace();
}
try {
reader.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
public void updateAllSign(Job job) {
for (SignTopType types : SignTopType.values()) {
if (types != SignTopType.questtoplist)
signUpdate(job, types);
}
for (SignTopType types : SignTopType.values()) {
if (types != SignTopType.questtoplist)
signUpdate(job, types);
}
}
public boolean signUpdate(Job job) {
return signUpdate(job, SignTopType.toplist);
return signUpdate(job, SignTopType.toplist);
}
public boolean signUpdate(Job job, SignTopType type) {
if (!Jobs.getGCManager().SignsEnabled)
return true;
if (!Jobs.getGCManager().SignsEnabled)
return true;
if (type == null)
type = SignTopType.toplist;
if (type == null)
type = SignTopType.toplist;
String jobNameOrType = jobsSign.getIdentifier(job, type).toLowerCase();
String jobNameOrType = jobsSign.getIdentifier(job, type).toLowerCase();
Map<String, jobsSign> signs = signsByType.get(jobNameOrType);
if (signs == null || signs.isEmpty())
return false;
Map<String, jobsSign> signs = signsByType.get(jobNameOrType);
if (signs == null || signs.isEmpty())
return false;
List<TopList> playerList = new ArrayList<>();
List<TopList> playerList = new ArrayList<>();
switch (type) {
case gtoplist:
playerList = Jobs.getJobsDAO().getGlobalTopList(0);
break;
case questtoplist:
playerList = Jobs.getJobsDAO().getQuestTopList(0);
break;
default:
break;
}
switch (type) {
case gtoplist:
playerList = Jobs.getJobsDAO().getGlobalTopList(0);
break;
case questtoplist:
playerList = Jobs.getJobsDAO().getQuestTopList(0);
break;
default:
break;
}
int timelapse = 1;
int timelapse = 1;
Map<String, List<TopList>> temp = new HashMap<>();
Map<String, List<TopList>> temp = new HashMap<>();
boolean save = false;
for (jobsSign jSign : new HashMap<>(signs).values()) {
Location loc = jSign.getLocation();
if (loc == null)
continue;
boolean save = false;
for (jobsSign jSign : new HashMap<>(signs).values()) {
Location loc = jSign.getLocation();
if (loc == null)
continue;
Block block = loc.getBlock();
if (!(block.getState() instanceof Sign)) {
if (!jobNameOrType.isEmpty()) {
Map<String, jobsSign> tt = signsByType.get(jobNameOrType);
if (tt != null) {
tt.remove(jSign.locToBlockString());
}
}
Block block = loc.getBlock();
if (!(block.getState() instanceof Sign)) {
if (!jobNameOrType.isEmpty()) {
Map<String, jobsSign> tt = signsByType.get(jobNameOrType);
if (tt != null) {
tt.remove(jSign.locToBlockString());
}
}
signsByLocation.remove(jSign.locToBlockString());
save = true;
continue;
}
signsByLocation.remove(jSign.locToBlockString());
save = true;
continue;
}
String signJobName = jSign.getJobName();
if (type == SignTopType.toplist && (playerList = temp.get(signJobName)) == null) {
playerList = Jobs.getJobsDAO().toplist(signJobName);
temp.put(signJobName, playerList);
}
String signJobName = jSign.getJobName();
if (type == SignTopType.toplist && (playerList = temp.get(signJobName)) == null) {
playerList = Jobs.getJobsDAO().toplist(signJobName);
temp.put(signJobName, playerList);
}
if (Jobs.getJob(jSign.getJobName()) != null)
signJobName = Jobs.getJob(jSign.getJobName()).getDisplayName();
if (Jobs.getJob(jSign.getJobName()) != null)
signJobName = Jobs.getJob(jSign.getJobName()).getDisplayName();
if (playerList.isEmpty())
continue;
if (playerList.isEmpty())
continue;
int number = jSign.getNumber() - 1;
Sign sign = (Sign) block.getState();
int number = jSign.getNumber() - 1;
Sign sign = (Sign) block.getState();
if (!jSign.isSpecial()) {
for (int i = 0; i < 4; i++) {
if (i + number >= playerList.size()) {
plugin.getComplement().setLine(sign, i, "");
continue;
}
if (!jSign.isSpecial()) {
for (int i = 0; i < 4; i++) {
if (i + number >= playerList.size()) {
plugin.getComplement().setLine(sign, i, "");
continue;
}
TopList pl = playerList.get(i + number);
String playerName = pl.getPlayerInfo().getName();
if (playerName.length() > 15) {
// We need to split 10 char of name, because of sign rows
playerName = playerName.split("(?<=\\G.{10})", 2)[0] + "~";
}
TopList pl = playerList.get(i + number);
String playerName = pl.getPlayerInfo().getName();
if (playerName.length() > 15) {
// We need to split 10 char of name, because of sign rows
playerName = playerName.split("(?<=\\G.{10})", 2)[0] + "~";
}
String line = "";
switch (type) {
case toplist:
case gtoplist:
line = Jobs.getLanguage().getMessage("signs.List", "[number]", i + number + 1, "[player]", playerName, "[level]", pl.getLevel());
break;
case questtoplist:
line = Jobs.getLanguage().getMessage("signs.questList", "[number]", i + number + 1, "[player]", playerName, "[quests]", pl.getLevel());
break;
default:
break;
}
String line = "";
switch (type) {
case toplist:
case gtoplist:
line = Jobs.getLanguage().getMessage("signs.List", "[number]", i + number + 1, "[player]", playerName, "[level]", pl.getLevel());
break;
case questtoplist:
line = Jobs.getLanguage().getMessage("signs.questList", "[number]", i + number + 1, "[player]", playerName, "[quests]", pl.getLevel());
break;
default:
break;
}
if (!line.isEmpty())
sign.setLine(i, line);
}
sign.update();
if (!updateHead(sign, playerList.get(0).getPlayerInfo().getName(), timelapse)) {
timelapse--;
}
} else {
if (jSign.getNumber() > playerList.size())
continue;
if (!line.isEmpty())
sign.setLine(i, line);
}
sign.update();
if (!updateHead(sign, playerList.get(0).getPlayerInfo().getName(), timelapse)) {
timelapse--;
}
} else {
if (jSign.getNumber() > playerList.size())
continue;
TopList pl = playerList.get(jSign.getNumber() - 1);
String playerName = pl.getPlayerInfo().getName();
if (playerName.length() > 15) {
playerName = playerName.split("(?<=\\G.{10})", 2)[0] + "~";
}
TopList pl = playerList.get(jSign.getNumber() - 1);
String playerName = pl.getPlayerInfo().getName();
if (playerName.length() > 15) {
playerName = playerName.split("(?<=\\G.{10})", 2)[0] + "~";
}
int no = jSign.getNumber() + number + 1;
sign.setLine(0, translateSignLine("signs.SpecialList.p" + jSign.getNumber(), no, playerName, pl.getLevel(), signJobName));
sign.setLine(1, translateSignLine("signs.SpecialList.name", no, playerName, pl.getLevel(), signJobName));
int no = jSign.getNumber() + number + 1;
sign.setLine(0, translateSignLine("signs.SpecialList.p" + jSign.getNumber(), no, playerName, pl.getLevel(), signJobName));
sign.setLine(1, translateSignLine("signs.SpecialList.name", no, playerName, pl.getLevel(), signJobName));
switch (type) {
case toplist:
case gtoplist:
sign.setLine(2, translateSignLine("signs.SpecialList.level", no, playerName, pl.getLevel(), signJobName));
break;
case questtoplist:
sign.setLine(2, Jobs.getLanguage().getMessage("signs.SpecialList.quests", "[number]", no, "[player]", playerName, "[quests]", pl.getLevel(), "[job]", signJobName));
break;
default:
break;
}
switch (type) {
case toplist:
case gtoplist:
sign.setLine(2, translateSignLine("signs.SpecialList.level", no, playerName, pl.getLevel(), signJobName));
break;
case questtoplist:
sign.setLine(2, Jobs.getLanguage().getMessage("signs.SpecialList.quests", "[number]", no, "[player]", playerName, "[quests]", pl.getLevel(), "[job]", signJobName));
break;
default:
break;
}
sign.setLine(3, translateSignLine("signs.SpecialList.bottom", no, playerName, pl.getLevel(), signJobName));
sign.update();
if (!updateHead(sign, pl.getPlayerInfo().getName(), timelapse)) {
timelapse--;
}
}
timelapse++;
}
sign.setLine(3, translateSignLine("signs.SpecialList.bottom", no, playerName, pl.getLevel(), signJobName));
sign.update();
if (!updateHead(sign, pl.getPlayerInfo().getName(), timelapse)) {
timelapse--;
}
}
timelapse++;
}
if (save)
saveSigns();
if (save)
saveSigns();
return true;
return true;
}
private static String translateSignLine(String path, int number, String playerName, int level, String jobname) {
return Jobs.getLanguage().getMessage(path,
"[number]", number,
"[player]", playerName,
"[level]", level,
"[job]", jobname);
return Jobs.getLanguage().getMessage(path,
"[number]", number,
"[player]", playerName,
"[level]", level,
"[job]", jobname);
}
@SuppressWarnings("deprecation")
public boolean updateHead(final Sign sign, final String playerName, int timelapse) {
if (playerName == null)
return false;
if (playerName == null)
return false;
if (timelapse < 1) {
timelapse = 1;
}
if (timelapse < 1) {
timelapse = 1;
}
BlockFace directionFacing = null;
if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) {
org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) sign.getData();
directionFacing = signMat.getFacing();
} else {
if (CMIMaterial.isWallSign(sign.getType())) {
org.bukkit.block.data.type.WallSign data = (org.bukkit.block.data.type.WallSign) sign.getBlockData();
directionFacing = data.getFacing();
} else {
org.bukkit.block.data.type.Sign data = (org.bukkit.block.data.type.Sign) sign.getBlockData();
directionFacing = data.getRotation();
}
}
BlockFace directionFacing = null;
if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) {
org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) sign.getData();
directionFacing = signMat.getFacing();
} else {
if (sign.getBlockData() instanceof org.bukkit.block.data.type.WallSign)
directionFacing = ((org.bukkit.block.data.type.WallSign) sign.getBlockData()).getFacing();
else if (sign.getBlockData() instanceof org.bukkit.block.data.type.Sign)
directionFacing = ((org.bukkit.block.data.type.Sign) sign.getBlockData()).getRotation();
}
final Location loc = sign.getLocation().clone();
loc.add(0, 1, 0);
final Location loc = sign.getLocation().clone();
loc.add(0, 1, 0);
if (directionFacing != null && !(loc.getBlock().getState() instanceof Skull))
loc.add(directionFacing.getOppositeFace().getModX(), 0, directionFacing.getOppositeFace().getModZ());
if (directionFacing != null && !(loc.getBlock().getState() instanceof Skull))
loc.add(directionFacing.getOppositeFace().getModX(), 0, directionFacing.getOppositeFace().getModZ());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (!(loc.getBlock().getState() instanceof Skull))
return;
CMIScheduler.get().runTaskLater(new Runnable() {
@Override
public void run() {
if (!(loc.getBlock().getState() instanceof Skull))
return;
Skull skull = (Skull) loc.getBlock().getState();
if (playerName.equalsIgnoreCase(skull.getOwner()))
return;
Skull skull = (Skull) loc.getBlock().getState();
if (playerName.equalsIgnoreCase(skull.getOwner()))
return;
skull.setOwner(playerName);
skull.update();
}
}, timelapse * Jobs.getGCManager().InfoUpdateInterval * 20L);
return true;
skull.setOwner(playerName);
skull.update();
}
}, timelapse * Jobs.getGCManager().InfoUpdateInterval * 20L);
return true;
}
}

View File

@ -5,5 +5,5 @@ import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
public interface Cmd {
boolean perform(Jobs plugin, CommandSender sender, String[] args);
Boolean perform(Jobs plugin, CommandSender sender, String[] args);
}

View File

@ -14,6 +14,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.list.info;
import com.gamingmesh.jobs.commands.list.playerinfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.Boost;
import com.gamingmesh.jobs.container.CurrencyType;
@ -22,13 +24,13 @@ import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Title;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Container.CMIArray;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage;
@ -113,7 +115,12 @@ public class JobsCommands implements CommandExecutor {
return true;
}
return cmdClass.perform(plugin, sender, myArgs) || help(sender, 1);
Boolean result = cmdClass.perform(plugin, sender, myArgs);
if (result != null && !result)
sendUsage(sender, cmd);
return result == null || !result ? false : true;
}
private static String[] reduceArgs(String[] args) {
@ -162,18 +169,12 @@ public class JobsCommands implements CommandExecutor {
boolean pl = sender instanceof Player;
// Old format
// sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.title"));
for (String one : commands) {
if (!pi.isEntryOk())
continue;
if (pi.isBreak())
break;
// Old format
// sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one), "[description]", Jobs.getLanguage().getMessage("command." + one
// + ".help.info")));
if (pl) {
rm.addText("\n" + getUsage(one));
rm.addHover(Jobs.getLanguage().getMessage("command." + one + ".help.info"));
@ -182,12 +183,10 @@ public class JobsCommands implements CommandExecutor {
rm.addText("\n" + Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one), "[description]", Jobs.getLanguage().getMessage("command." + one
+ ".help.info")));
}
}
rm.show(sender);
plugin.showPagination(sender, pi, LABEL + " ?");
pi.autoPagination(sender, LABEL + " ?");
return true;
}
@ -269,7 +268,7 @@ public class JobsCommands implements CommandExecutor {
public void jobInfoMessage(CommandSender sender, JobsPlayer player, Job job, String type, int page) {
if (job == null) {
// job doesn't exist
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
Language.sendMessage(sender, "general.error.job");
return;
}
@ -277,21 +276,24 @@ public class JobsCommands implements CommandExecutor {
List<String> message = new ArrayList<>();
if (job.getBoost().get(CurrencyType.EXP) != 0D)
message.add(Jobs.getLanguage().getMessage("command.expboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.EXP)) + 1));
for (CurrencyType one : CurrencyType.values()) {
double boost = job.getBoost().get(one);
if (boost != 0D) {
if (job.getBoost().get(CurrencyType.MONEY) != 0D)
message.add(Jobs.getLanguage().getMessage("command.moneyboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.MONEY)) + 1));
String boostAmount = String.valueOf(boost + 1);
if (boost % 1 == 0)
boostAmount = String.valueOf((int) boost + 1);
if (job.getBoost().get(CurrencyType.POINTS) != 0D)
message.add(Jobs.getLanguage().getMessage("command.pointboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.POINTS)) + 1));
message.add(Jobs.getLanguage().getMessage("command.boost.output.infostats", "%boost%", boostAmount, "%type%", one.getDisplayName()));
}
}
if (Jobs.getGCManager().useDynamicPayment) {
int bonus = (int) ((job.getBonus() * 100) / 100.0);
int bonus = (int) (job.getBonus() * 100);
if (bonus != 0) {
if (bonus < 0)
message.add(Jobs.getLanguage().getMessage("command.info.help.penalty", "[penalty]", (int) (job.getBonus() * 100) / 100.0 * -1));
message.add(Jobs.getLanguage().getMessage("command.info.help.penalty", "[penalty]", bonus * -1));
else
message.add(Jobs.getLanguage().getMessage("command.info.help.bonus", "[bonus]", bonus));
}
@ -315,7 +317,7 @@ public class JobsCommands implements CommandExecutor {
PageInfo pi = new PageInfo(15, message.size(), page);
if (page > pi.getTotalPages()) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.invalidPage"));
Language.sendMessage(sender, "general.info.invalidPage");
return;
}
@ -333,9 +335,9 @@ public class JobsCommands implements CommandExecutor {
String pName = player.getName();
if (sender.getName().equalsIgnoreCase(pName))
plugin.showPagination(sender, pi, "jobs info " + job.getName() + t);
pi.autoPagination(sender, LABEL + " " + info.class.getSimpleName() + " " + job.getName() + t);
else
plugin.showPagination(sender, pi, "jobs playerinfo " + pName + " " + job.getName() + t);
pi.autoPagination(sender, LABEL + " " + playerinfo.class.getSimpleName() + " " + job.getName() + t);
}
}
@ -356,11 +358,11 @@ public class JobsCommands implements CommandExecutor {
message.append(":\n");
JobProgression prog = player.getJobProgression(job);
if (prog == null) {
prog = player.getArchivedJobProgression(job);
}
prog = player.getArchivedJobProgression(job);
}
int level = prog != null ? prog.getLevel() : 1;
int numjobs = player.progression.size();
@ -421,6 +423,10 @@ public class JobsCommands implements CommandExecutor {
* @return the message
*/
public String jobStatsMessage(JobProgression jobProg) {
return jobStatsMessage(jobProg, true);
}
public String jobStatsMessage(JobProgression jobProg, boolean progressBar) {
boolean isMaxLevelReached = jobProg.getLevel() == jobProg.getJob().getMaxLevel();
String path = "command.stats.output." + (isMaxLevelReached ? "max-level"
: "message");
@ -432,7 +438,7 @@ public class JobsCommands implements CommandExecutor {
"%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0,
"%jobmaxxp%", jobProg.getMaxExperience(),
"%titlename%", title == null ? "Unknown" : title.getName());
return " " + (isMaxLevelReached ? "" : jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience())) + " " + message;
return " " + (isMaxLevelReached ? "" : progressBar ? jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience()) : "") + " " + message;
}
public String jobProgressMessage(double max, double current) {

View File

@ -10,50 +10,51 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.RawMessages.RawMessage;
public class archive implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.archive", true)) {
return true;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.archive", true)) {
return null;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
}
} else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
}
if (jPlayer == null) {
if (args.length >= 1)
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
if (jPlayer == null) {
if (args.length >= 1)
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return null;
}
Set<JobProgression> allJobs = jPlayer.getArchivedJobs().getArchivedJobs();
if (allJobs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.archive.error.nojob"));
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName()));
for (JobProgression jobInfo : allJobs) {
RawMessage rm = new RawMessage();
if (jobInfo.canRejoin())
rm.addText(ChatColor.GREEN + "+" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo))
.addHover(Jobs.getLanguage().getMessage("command.join.rejoin")).addCommand("jobs join " + jobInfo.getJob().getName());
else
rm.addText(ChatColor.RED + "-" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo))
.addHover(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", jobInfo
.getRejoinTimeMessage()));
rm.show(sender);
}
Set<JobProgression> allJobs = jPlayer.getArchivedJobs().getArchivedJobs();
if (allJobs.isEmpty()) {
Language.sendMessage(sender, "command.archive.error.nojob");
return null;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
Language.sendMessage(sender, "general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
for (JobProgression jobInfo : allJobs) {
RawMessage rm = new RawMessage();
if (jobInfo.canRejoin())
rm.addText(ChatColor.GREEN + "+" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo))
.addHover(Jobs.getLanguage().getMessage("command.join.rejoin")).addCommand("jobs join " + jobInfo.getJob().getName());
else
rm.addText(ChatColor.RED + "-" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo))
.addHover(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", jobInfo
.getRejoinTimeMessage()));
rm.show(sender);
}
Language.sendMessage(sender, "general.info.separator");
return true;
}
}

View File

@ -12,6 +12,7 @@ import com.gamingmesh.jobs.config.RestrictedAreaManager;
import com.gamingmesh.jobs.container.CuboidArea;
import com.gamingmesh.jobs.container.RestrictedArea;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC;
@ -20,151 +21,151 @@ import net.Zrips.CMILib.Messages.CMIMessages;
public class area implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
Player player = (Player) sender;
Player player = (Player) sender;
if (args.length == 3) {
if (args[0].equalsIgnoreCase("add")) {
if (!Jobs.hasPermission(player, "jobs.area.add", true))
return true;
if (args.length == 3) {
if (args[0].equalsIgnoreCase("add")) {
if (!Jobs.hasPermission(player, "jobs.area.add", true))
return true;
double bonus = 0D;
try {
bonus = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
return false;
}
double bonus = 0D;
try {
bonus = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
return false;
}
boolean wg = false;
boolean wg = false;
String name = args[1];
if (name.startsWith("wg:")) {
wg = true;
name = name.substring("wg:".length(), name.length());
}
String name = args[1];
if (name.startsWith("wg:")) {
wg = true;
name = name.substring("wg:".length(), name.length());
}
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
if (ra.isExist(name)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist"));
return true;
}
if (ra.isExist(name)) {
Language.sendMessage(sender, "command.area.output.exist");
return true;
}
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select",
"%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName()));
return true;
}
if (wg && HookManager.getWorldGuardManager() != null) {
com.sk89q.worldguard.protection.regions.ProtectedRegion protectedRegion = HookManager.getWorldGuardManager().getProtectedRegionByName(name);
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
Language.sendMessage(sender, "command.area.output.select",
"%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName());
return true;
}
if (wg && HookManager.getWorldGuardManager() != null) {
com.sk89q.worldguard.protection.regions.ProtectedRegion protectedRegion = HookManager.getWorldGuardManager().getProtectedRegionByName(name);
if (protectedRegion == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgDontExist"));
return true;
}
name = protectedRegion.getId();
}
if (protectedRegion == null) {
Language.sendMessage(sender, "command.area.output.wgDontExist");
return true;
}
name = protectedRegion.getId();
}
if (!wg)
ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), true);
else
ra.addNew(new RestrictedArea(name, name, bonus), true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.addedNew", "%bonus%", bonus));
return true;
}
}
if (!wg)
ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), true);
else
ra.addNew(new RestrictedArea(name, name, bonus), true);
Language.sendMessage(sender, "command.area.output.addedNew", "%bonus%", bonus);
return true;
}
}
if (args.length == 2) {
if (args[0].equalsIgnoreCase("remove")) {
if (!Jobs.hasPermission(player, "jobs.area.remove", true))
return true;
if (args.length == 2) {
if (args[0].equalsIgnoreCase("remove")) {
if (!Jobs.hasPermission(player, "jobs.area.remove", true))
return true;
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
String name = args[1];
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
String name = args[1];
if (!ra.isExist(name)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.dontExist"));
return true;
}
if (!ra.isExist(name)) {
Language.sendMessage(sender, "command.area.output.dontExist");
return true;
}
ra.remove(name);
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.removed", "%name%", name));
return true;
}
}
ra.remove(name);
Language.sendMessage(sender, "command.area.output.removed", "%name%", name);
return true;
}
}
if (args.length == 1 && args[0].equalsIgnoreCase("info")) {
if (args.length == 1 && args[0].equalsIgnoreCase("info")) {
List<RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreasByLoc(player.getLocation());
List<RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreasByLoc(player.getLocation());
String msg = "";
String msg = "";
for (RestrictedArea area : areas) {
if (!msg.isEmpty())
msg += ", ";
msg += area.getName();
}
for (RestrictedArea area : areas) {
if (!msg.isEmpty())
msg += ", ";
msg += area.getName();
}
if (msg.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreasByLoc"));
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.areaList", "%list%", msg));
return true;
}
if (msg.isEmpty()) {
Language.sendMessage(sender, "command.area.output.noAreasByLoc");
return true;
}
Language.sendMessage(sender, "command.area.output.areaList", "%list%", msg);
return true;
}
if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
java.util.Map<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreas();
if (areas.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
return true;
}
java.util.Map<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreas();
if (areas.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
int i = 0;
for (Entry<String, RestrictedArea> area : areas.entrySet()) {
i++;
CuboidArea cuboid = area.getValue().getCuboidArea();
if (area.getValue().getWgName() == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.list", "%number%", i,
"%areaname%", area.getKey(),
"%worldname%", cuboid.getWorld().getName(),
"%x1%", cuboid.getLowLoc().getBlockX(),
"%y1%", cuboid.getLowLoc().getBlockY(),
"%z1%", cuboid.getLowLoc().getBlockZ(),
"%x2%", cuboid.getHighLoc().getBlockX(),
"%y2%", cuboid.getHighLoc().getBlockY(),
"%z2%", cuboid.getHighLoc().getBlockZ(),
"%bonus%", area.getValue().getMultiplier()));
} else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgList", "%number%", i,
"%areaname%", area.getKey(),
"%bonus%", area.getValue().getMultiplier()));
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
int i = 0;
for (Entry<String, RestrictedArea> area : areas.entrySet()) {
i++;
CuboidArea cuboid = area.getValue().getCuboidArea();
if (area.getValue().getWgName() == null) {
Language.sendMessage(sender, "command.area.output.list", "%number%", i,
"%areaname%", area.getKey(),
"%worldname%", cuboid.getWorld().getName(),
"%x1%", cuboid.getLowLoc().getBlockX(),
"%y1%", cuboid.getLowLoc().getBlockY(),
"%z1%", cuboid.getLowLoc().getBlockZ(),
"%x2%", cuboid.getHighLoc().getBlockX(),
"%y2%", cuboid.getHighLoc().getBlockY(),
"%z2%", cuboid.getHighLoc().getBlockZ(),
"%bonus%", area.getValue().getMultiplier());
} else {
Language.sendMessage(sender, "command.area.output.wgList", "%number%", i,
"%areaname%", area.getKey(),
"%bonus%", area.getValue().getMultiplier());
}
}
Language.sendMessage(sender, "general.info.separator");
return true;
}
if (args.length > 0) {
if (args[0].equalsIgnoreCase("add")) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.addUsage"));
return true;
}
if (args.length > 0) {
if (args[0].equalsIgnoreCase("add")) {
Language.sendMessage(sender, "command.area.help.addUsage");
return true;
}
if (args[0].equalsIgnoreCase("remove")) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.removeUsage"));
return true;
}
}
if (args[0].equalsIgnoreCase("remove")) {
Language.sendMessage(sender, "command.area.help.removeUsage");
return true;
}
}
return false;
return false;
}
}

View File

@ -18,15 +18,10 @@ public class blockinfo implements Cmd {
@Override
@SuppressWarnings("deprecation")
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "blockinfo");
return true;
return null;
}
Block block = Util.getTargetBlock((Player) sender, 15);

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -21,87 +22,85 @@ import net.Zrips.CMILib.RawMessages.RawMessage;
public class bonus implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "bonus");
return true;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "bonus");
return true;
}
Player player = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
player.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Player player = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job, true, true);
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job, true, true);
player.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));
Language.sendMessage(sender, "command.bonus.output.topline");
printBoost(sender, boost, BoostOf.Permission);
printBoost(sender, boost, BoostOf.Item);
printBoost(sender, boost, BoostOf.Global);
if (Jobs.getGCManager().useDynamicPayment)
printBoost(sender, boost, BoostOf.Dynamic);
printBoost(sender, boost, BoostOf.Area);
if (Jobs.getGCManager().payNearSpawner())
printBoost(sender, boost, BoostOf.NearSpawner);
printBoost(sender, boost, BoostOf.PetPay);
printBoost(sender, boost, BoostOf.Permission);
printBoost(sender, boost, BoostOf.Item);
printBoost(sender, boost, BoostOf.Global);
if (Jobs.getGCManager().useDynamicPayment)
printBoost(sender, boost, BoostOf.Dynamic);
printBoost(sender, boost, BoostOf.Area);
if (Jobs.getGCManager().payNearSpawner())
printBoost(sender, boost, BoostOf.NearSpawner);
printBoost(sender, boost, BoostOf.PetPay);
if (HookManager.getMcMMOManager().mcMMOPresent ||
HookManager.getMcMMOManager().mcMMOOverHaul && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D)
printBoost(sender, boost, BoostOf.McMMO);
if (HookManager.getMcMMOManager().mcMMOPresent ||
HookManager.getMcMMOManager().mcMMOOverHaul && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D)
printBoost(sender, boost, BoostOf.McMMO);
player.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
Language.sendMessage(sender, "general.info.separator");
RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, true)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, true)),
"%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, true)));
String msg2 = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, false)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, false)),
"%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, false)));
RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, true)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, true)),
"%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, true)));
rm.addText(msg).addHover(Arrays.asList(Jobs.getLanguage().getMessage("command.bonus.output.finalExplanation"), msg2));
rm.build();
rm.show(player);
String msg2 = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, false)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, false)),
"%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, false)));
return true;
rm.addText(msg).addHover(Arrays.asList(Jobs.getLanguage().getMessage("command.bonus.output.finalExplanation"), msg2));
rm.build();
rm.show(player);
return true;
}
private static void printBoost(CommandSender sender, Boost boost, BoostOf type) {
String prefix = Jobs.getLanguage().getMessage("command.bonus.output.specialPrefix");
if (type != BoostOf.NearSpawner && type != BoostOf.PetPay)
prefix = "";
String prefix = Jobs.getLanguage().getMessage("command.bonus.output.specialPrefix");
if (type != BoostOf.NearSpawner && type != BoostOf.PetPay)
prefix = "";
String msg = Jobs.getLanguage().getMessage("command.bonus.output." + type.name().toLowerCase(),
"%money%", formatText(boost.get(type, CurrencyType.MONEY, true)),
"%points%", formatText(boost.get(type, CurrencyType.POINTS, true)),
"%exp%", formatText(boost.get(type, CurrencyType.EXP, true)));
String msg = Jobs.getLanguage().getMessage("command.bonus.output." + type.name().toLowerCase(),
"%money%", formatText(boost.get(type, CurrencyType.MONEY, true)),
"%points%", formatText(boost.get(type, CurrencyType.POINTS, true)),
"%exp%", formatText(boost.get(type, CurrencyType.EXP, true)));
if ((type == BoostOf.NearSpawner || type == BoostOf.PetPay) && msg.startsWith(" "))
msg = msg.substring(1, msg.length());
if ((type == BoostOf.NearSpawner || type == BoostOf.PetPay) && msg.startsWith(" "))
msg = msg.substring(1, msg.length());
sender.sendMessage(prefix + msg);
CMIMessages.sendMessage(sender, prefix + msg);
}
private static String formatText(double amount) {
return ((amount > 0 ? "+" : "") + amount + "%");
return ((amount > 0 ? "+" : "") + amount + "%");
}
}

View File

@ -0,0 +1,174 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Time.CMITimeManager;
import net.Zrips.CMILib.Time.timeModifier;
public class boost implements Cmd {
@Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
Double rate = null;
Long timeDuration = null;
Job job = null;
boolean allJobs = false;
boolean reset = false;
CurrencyType type = null;
for (String one : args) {
if (type == null) {
type = CurrencyType.getByName(one);
if (type != null)
continue;
}
if (one.equalsIgnoreCase("all")) {
allJobs = true;
continue;
}
if (one.equalsIgnoreCase("reset")) {
reset = true;
continue;
}
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
if (rate == null) {
try {
rate = Double.parseDouble(one);
continue;
} catch (NumberFormatException e) {
}
}
try {
Long t = timeModifier.getTimeRangeFromString(one);
if (timeDuration == null && t != null) {
timeDuration = t;
continue;
}
} catch (Exception e) {
}
}
if (job == null && rate == null && !reset) {
LC.info_Spliter.sendMessage(sender);
for (Job one : Jobs.getJobs()) {
showBoosts(sender, one);
}
return true;
}
if (job != null && rate == null) {
LC.info_Spliter.sendMessage(sender);
showBoosts(sender, job);
return true;
}
if (rate == null)
rate = 1D;
if (timeDuration == null)
timeDuration = 0L;
if (reset) {
if (job == null) {
if (type == null) {
for (Job one : Jobs.getJobs()) {
for (CurrencyType curr : CurrencyType.values()) {
one.addBoost(curr, 0);
}
}
Language.sendMessage(sender, "command.boost.output.allreset");
} else {
for (Job one : Jobs.getJobs()) {
one.addBoost(type, 0);
}
Language.sendMessage(sender, "command.boost.output.alltypereset", "%type%", type.getDisplayName());
}
} else {
if (type == null) {
for (CurrencyType curr : CurrencyType.values()) {
job.addBoost(curr, 0);
}
Language.sendMessage(sender, "command.moneyboost.output.jobsboostreset", "%jobname%", job.getName());
} else {
job.addBoost(type, 0);
Language.sendMessage(sender, "command.moneyboost.output.jobstypeboostreset", "%jobname%", job.getName(), "%type%", type.getDisplayName());
}
}
return true;
}
if (job == null || allJobs) {
for (Job one : Jobs.getJobs()) {
if (type == null) {
for (CurrencyType curr : CurrencyType.values()) {
one.addBoost(curr, rate, timeDuration);
}
} else {
one.addBoost(type, rate, timeDuration);
}
Language.sendMessage(sender, "command.boost.output.boostadded", "%boost%", rate, "%jobname%", one.getName());
}
} else {
if (type == null) {
for (CurrencyType curr : CurrencyType.values()) {
job.addBoost(curr, rate, timeDuration);
}
} else {
job.addBoost(type, rate, timeDuration);
}
Language.sendMessage(sender, "command.boost.output.boostadded", "%boost%", rate, "%jobname%", job.getName());
}
return true;
}
private static void showBoosts(CommandSender sender, Job job) {
RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.boost.output.boostStats", "%jobname%", job.getDisplayName());
String[] split = msg.split("%payments%");
rm.addText(split[0]);
// String msg = Jobs.getLanguage().getMessage("command.boost.output.boostStats", "%jobname%", job.getDisplayName());
for (CurrencyType curr : CurrencyType.values()) {
double boost = job.getBoost().get(curr);
String boostAmount = String.valueOf(boost);
if (boost % 1 == 0)
boostAmount = String.valueOf((int) boost);
if (curr.isEnabled()) {
rm.addText(Jobs.getLanguage().getMessage("general.info.paymentTypeValued." + curr.toString(), "%amount%", boostAmount) + " ");
}
if (job.getBoost().getTime(curr) != null && job.getBoost().isValid(curr)) {
rm.addHover(CMITimeManager.to24hourShort(job.getBoost().getTime(curr) - System.currentTimeMillis()));
}
}
if (split.length > 1)
rm.addText(split[1]);
rm.show(sender);
}
}

View File

@ -13,17 +13,19 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.BlockProtection;
import com.gamingmesh.jobs.container.DBAction;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class bp implements Cmd {
@SuppressWarnings("deprecation")
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
@ -73,23 +75,24 @@ public class bp implements Cmd {
}
if (changedBlocks.isEmpty())
sender.sendMessage(Jobs.getLanguage().getMessage("command.bp.output.notFound"));
Language.sendMessage(sender, "command.bp.output.notFound");
else
sender.sendMessage(Jobs.getLanguage().getMessage("command.bp.output.found", "%amount%", changedBlocks.size()));
Language.sendMessage(sender, "command.bp.output.found", "%amount%", changedBlocks.size());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (Version.isCurrentEqualOrHigher(Version.v1_15_R1))
if (!changedBlocks.isEmpty()) {
Location bloc = changedBlocks.get(0).getLocation();
CMIScheduler.get().runAtLocationLater(bloc, () -> {
if (Version.isCurrentEqualOrHigher(Version.v1_15_R1)) {
for (Block one : changedBlocks) {
player.sendBlockChange(one.getLocation(), one.getBlockData());
}
else
} else {
for (Block one : changedBlocks) {
player.sendBlockChange(one.getLocation(), one.getType(), one.getData());
}
}
}, 120L);
}
}, 120L);
}
return true;
}

View File

@ -9,20 +9,22 @@ import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage;
public class browse implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, CommandSender sender, final String[] args) {
boolean senderIsPlayer = sender instanceof Player;
if (Jobs.getGCManager().BrowseUseNewLook) {
if (Jobs.getJobs().isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
Language.sendMessage(sender, "command.browse.error.nojobs");
return true;
}
@ -60,7 +62,7 @@ public class browse implements Cmd {
if (senderIsPlayer) {
if (j == null) {
PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size()));
Language.sendMessage(sender, "command.browse.output.newHeader", "[amount]", jobList.size());
for (Job one : jobList) {
if (!pi.isEntryOk())
continue;
@ -113,28 +115,28 @@ public class browse implements Cmd {
rm.show(sender);
}
plugin.showPagination(sender, pi, "jobs browse", "-p:");
pi.autoPagination(sender, "jobs browse", "-p:");
} else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
Language.sendMessage(sender, "command.browse.output.jobHeader", "[jobname]", j.getName());
int maxLevel = j.getMaxLevel(sender);
if (maxLevel > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel));
Language.sendMessage(sender, "command.info.help.newMax", "[max]", maxLevel);
if (Jobs.getGCManager().ShowTotalWorkers)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
Language.sendMessage(sender, "command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers());
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
int bonus = (int) (j.getBonus() * 100);
if (bonus < 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1));
Language.sendMessage(sender, "command.browse.output.penalty", "[amount]", bonus * -1);
else
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus));
Language.sendMessage(sender, "command.browse.output.bonus", "[amount]", bonus);
}
for (String one : j.getFullDescription()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one));
Language.sendMessage(sender, "command.browse.output.description", "[description]", one);
}
RawMessage rm = new RawMessage();
@ -148,7 +150,7 @@ public class browse implements Cmd {
}
} else {
if (j == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n"));
Language.sendMessage(sender, "command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n");
for (Job one : jobList) {
String msg = "";
@ -177,14 +179,14 @@ public class browse implements Cmd {
msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName());
sender.sendMessage(msg);
CMIMessages.sendMessage(sender, msg);
}
} else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
Language.sendMessage(sender, "command.browse.output.jobHeader", "[jobname]", j.getName());
int maxLevel = j.getMaxLevel(sender);
if (maxLevel > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel));
Language.sendMessage(sender, "command.info.help.newMax", "[max]", maxLevel);
if (Jobs.getGCManager().ShowTotalWorkers)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
@ -192,13 +194,13 @@ public class browse implements Cmd {
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
int bonus = (int) (j.getBonus() * 100);
if (bonus < 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1));
Language.sendMessage(sender, "command.browse.output.penalty", "[amount]", bonus * -1);
else
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus));
Language.sendMessage(sender, "command.browse.output.bonus", "[amount]", bonus);
}
for (String one : j.getFullDescription()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one));
Language.sendMessage(sender, "command.browse.output.description", "[description]", one);
}
}
}
@ -245,7 +247,7 @@ public class browse implements Cmd {
}
if (lines.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
Language.sendMessage(sender, "command.browse.error.nojobs");
return true;
}
@ -260,9 +262,9 @@ public class browse implements Cmd {
}
if (Jobs.getGCManager().JobsGUIShowChatBrowse) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header"));
Language.sendMessage(sender, "command.browse.output.header");
lines.forEach(sender::sendMessage);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer"));
Language.sendMessage(sender, "command.browse.output.footer");
}
}
return true;

View File

@ -11,6 +11,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -18,7 +19,7 @@ import net.Zrips.CMILib.Messages.CMIMessages;
public class clearownership implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
String location = null;
@ -47,8 +48,8 @@ public class clearownership implements Cmd {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "clearownership");
return true;
return false;
return null;
}
final UUID uuid = jPlayer.getUniqueId();
@ -64,8 +65,8 @@ public class clearownership implements Cmd {
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.clearownership.output.cleared", "[furnaces]", amounts.getOrDefault(BlockTypes.FURNACE, 0), "[brewing]", amounts.getOrDefault(
BlockTypes.BREWING_STAND, 0), "[smoker]", amounts.getOrDefault(BlockTypes.SMOKER, 0), "[blast]", amounts.getOrDefault(BlockTypes.BLAST_FURNACE, 0)));
Language.sendMessage(sender,"command.clearownership.output.cleared", "[furnaces]", amounts.getOrDefault(BlockTypes.FURNACE, 0), "[brewing]", amounts.getOrDefault(
BlockTypes.BREWING_STAND, 0), "[smoker]", amounts.getOrDefault(BlockTypes.SMOKER, 0), "[blast]", amounts.getOrDefault(BlockTypes.BLAST_FURNACE, 0));
return true;
}
}

View File

@ -1,6 +1,5 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -10,29 +9,29 @@ import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class convert implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (sender instanceof Player) {
CMIMessages.sendMessage(sender, LC.info_FromConsole);
return true;
}
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (sender instanceof Player) {
CMIMessages.sendMessage(sender, LC.info_FromConsole);
return true;
}
if (args.length > 0) {
Jobs.getCommandManager().sendUsage(sender, "convert");
return true;
}
if (args.length > 0) {
return false;
}
String from = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "SQLite" : "MySQL";
String to = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "MySQL" : "SQLite";
String from = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "SQLite" : "MySQL";
String to = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "MySQL" : "SQLite";
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
Jobs.convertDatabase();
Jobs.consoleMsg("&eDatabase was converted from &2" + from + " &eto &2" + to + "&e!");
});
CMIScheduler.get().runTaskAsynchronously(() -> {
Jobs.convertDatabase();
CMIMessages.consoleMessage("&eDatabase was converted from &2" + from + " &eto &2" + to + "&e!");
});
return true;
return true;
}
}

View File

@ -7,55 +7,54 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor;
public class demote implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "demote");
return true;
}
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
int levelsLost = 0;
try {
levelsLost = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return true;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
int levelsLost = 0;
try {
levelsLost = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return true;
}
Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost);
Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost);
Player player = jPlayer.getPlayer();
if (player != null) {
String message = Jobs.getLanguage().getMessage("command.demote.output.target",
"%jobname%", job.getDisplayName() + CMIChatColor.WHITE,
"%levelslost%", levelsLost);
player.sendMessage(message);
}
Player player = jPlayer.getPlayer();
if (player != null) {
Language.sendMessage(sender, "command.demote.output.target",
"%jobname%", job.getDisplayName() + CMIChatColor.WHITE,
"%levelslost%", levelsLost);
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
}
} catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
Language.sendMessage(sender, "general.admin.success");
}
} catch (Throwable e) {
Language.sendMessage(sender, "general.admin.error");
}
return true;
}
}

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Items.CMIItemStack;
@ -23,37 +24,37 @@ import net.Zrips.CMILib.NBT.CMINBT;
public class edititembonus implements Cmd {
private enum actions {
list, add, remove;
list, add, remove;
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
}
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length < 1)
return false;
if (args.length < 1)
return false;
actions action = null;
actions action = null;
// Job job = null;
JobItems jobitem = null;
JobItems jobitem = null;
for (String one : args) {
if (action == null) {
action = actions.getByname(one);
if (action != null)
continue;
}
for (String one : args) {
if (action == null) {
action = actions.getByname(one);
if (action != null)
continue;
}
// if (job == null) {
// job = Jobs.getJob(one);
// if (job != null)
@ -61,68 +62,67 @@ public class edititembonus implements Cmd {
// }
// if (job != null) {
jobitem = ItemBoostManager.getItemByKey(one);
jobitem = ItemBoostManager.getItemByKey(one);
// }
}
}
if (action == null)
return false;
if (action == null)
return false;
Player player = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
Player player = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
ItemStack iih = CMIItemStack.getItemInMainHand(player);
if (iih == null || iih.getType() == Material.AIR)
return false;
ItemStack iih = CMIItemStack.getItemInMainHand(player);
if (iih == null || iih.getType() == Material.AIR)
return false;
switch (action) {
case add:
if (jobitem == null)
return false;
iih = (ItemStack) new CMINBT(iih).setString("JobsItemBoost", jobitem.getNode());
CMIItemStack.setItemInMainHand(player, iih);
break;
case list:
break;
case remove:
iih = (ItemStack) new CMINBT(iih).remove("JobsItemBoost");
CMIItemStack.setItemInMainHand(player, iih);
break;
default:
break;
}
switch (action) {
case add:
if (jobitem == null)
return false;
iih = (ItemStack) new CMINBT(iih).setString("JobsItemBoost", jobitem.getNode());
CMIItemStack.setItemInMainHand(player, iih);
break;
case list:
break;
case remove:
iih = (ItemStack) new CMINBT(iih).remove("JobsItemBoost");
CMIItemStack.setItemInMainHand(player, iih);
break;
default:
break;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));
Language.sendMessage(sender, "command.bonus.output.topline");
Object key = new CMINBT(iih).getString("JobsItemBoost");
if (key == null)
return true;
Object key = new CMINBT(iih).getString("JobsItemBoost");
if (key == null)
return true;
JobItems item = ItemBoostManager.getItemByKey(key.toString());
if (item == null)
return true;
JobItems item = ItemBoostManager.getItemByKey(key.toString());
if (item == null)
return true;
BoostMultiplier boost = item.getBoost();
BoostMultiplier boost = item.getBoost();
String mc = CMIChatColor.DARK_GREEN.toString(),
pc = CMIChatColor.GOLD.toString(),
ec = CMIChatColor.YELLOW.toString();
String mc = CMIChatColor.DARK_GREEN.toString();
String pc = CMIChatColor.GOLD.toString();
String ec = CMIChatColor.YELLOW.toString();
for (Job one : item.getJobs()) {
String msg = Jobs.getLanguage().getMessage("command.itembonus.output.list",
"[jobname]", one.getName(),
"%money%", mc + formatText((int) (boost.get(CurrencyType.MONEY) * 100)),
"%points%", pc + formatText((int) (boost.get(CurrencyType.POINTS) * 100)),
"%exp%", ec + formatText((int) (boost.get(CurrencyType.EXP) * 100)));
sender.sendMessage(msg);
}
return true;
for (Job one : item.getJobs()) {
Language.sendMessage(sender, "command.itembonus.output.list",
"[jobname]", one.getName(),
"%money%", mc + formatText((int) (boost.get(CurrencyType.MONEY) * 100)),
"%points%", pc + formatText((int) (boost.get(CurrencyType.POINTS) * 100)),
"%exp%", ec + formatText((int) (boost.get(CurrencyType.EXP) * 100)));
}
return true;
}
private static String formatText(double amount) {
return ((amount > 0 ? "+" : "") + amount + "%");
return ((amount > 0 ? "+" : "") + amount + "%");
}
}

View File

@ -20,6 +20,7 @@ import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version;
@ -27,410 +28,415 @@ public class editjobs implements Cmd {
@SuppressWarnings("deprecation")
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (args.length == 0)
args = new String[] { "list" };
switch (args[0]) {
case "list":
if (args.length == 1) {
showPath(player, null, null, null);
for (Job one : Jobs.getJobs()) {
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", one.getJobDisplayName()), one.getName(), "jobs editjobs list " + one.getName());
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 2) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
showPath(player, job, null, null);
for (ActionType oneI : ActionType.values()) {
List<JobInfo> action = job.getJobInfo(oneI);
if (action == null || action.isEmpty())
continue;
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", oneI.getName()), oneI.getName(), "jobs editjobs list " + job.getName() + " " + oneI.getName()
+ " 1");
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 4) {
Integer page = null;
try {
page = Integer.parseInt(args[3]);
} catch (NumberFormatException e) {
}
if (page != null) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
showPath(player, job, actionT, null);
PageInfo pi = new PageInfo(15, action.size(), page);
for (JobInfo one : action) {
if (!pi.isEntryOk())
continue;
String materialName = one.getRealisticName();
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", materialName), one.getName(), "jobs editjobs list " + job.getName() + " " + actionT
.getName() + " " + one.getName());
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialRemove"), "&cRemove", "jobs editjobs remove " + job.getName() + " " + actionT.getName() + " " + one
.getName());
rm.show(sender);
}
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialAdd"), "&eAdd new", "jobs editjobs add " + job.getName() + " " + actionT.getName());
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
plugin.showPagination(sender, pi, "jobs editjobs list " + job.getName() + " " + actionT.getName());
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
showPath(player, job, actionT, jInfo);
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.money", "%amount%", jInfo.getBaseIncome()), "&e" + jInfo.getBaseIncome(), "jobs editjobs modify " + job.getName() + " "
+ actionT.getName() + " " + jInfo.getName() + " money ");
rm.show(sender);
rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.points", "%amount%", jInfo.getBasePoints()), "&e" + jInfo.getBasePoints(), "jobs editjobs modify " + job.getName() + " "
+ actionT.getName() + " " + jInfo.getName()
+ " points ");
rm.show(sender);
rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.exp", "%amount%", jInfo.getBaseXp()), "&e" + jInfo.getBaseXp(), "jobs editjobs modify " + job.getName() + " " + actionT
.getName() + " " + jInfo.getName() + " exp ");
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "modify":
if (args.length == 5) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs modify " + job.getName() + " " + actionT.getName() + " " + jInfo.getName() + " " + type.getName() + " ");
sender.sendMessage(Jobs.getLanguage().getMessage("command.editjobs.help.modify.newValue"));
return true;
}
if (args.length == 6) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
Double value = null;
try {
value = Double.parseDouble(args[5]);
} catch (Exception e) {
return false;
}
String sType = null;
switch (type) {
case EXP:
sType = "experience";
jInfo.setBaseXp(value);
break;
case MONEY:
sType = "income";
jInfo.setBaseIncome(value);
break;
case POINTS:
sType = "points";
jInfo.setBasePoints(value);
break;
default:
break;
}
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/" + sType, value);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "remove":
// remove miner break stone:1
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo info : action) {
if (!info.getName().equalsIgnoreCase(args[3]))
continue;
jInfo = info;
break;
}
if (jInfo == null) {
return true;
}
action.remove(jInfo);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath(), null);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " 1");
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "add":
// add miner break stone:1
if (args.length == 3) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.enter"));
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.hand"), Jobs.getLanguage().getMessage("command.editjobs.help.modify.handHover"), "jobs editjobs add " + job.getName()
+ " " + actionT.getName() + " hand");
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.or"));
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.look"), Jobs.getLanguage().getMessage("command.editjobs.help.modify.lookHover"), "jobs editjobs add " + job.getName()
+ " " + actionT.getName() + " looking");
rm.show(sender);
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs add " + job.getName() + " " + actionT.getName() + " ");
return true;
}
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
String key = args[3];
switch (args[3]) {
case "hand":
ItemStack item = CMIItemStack.getItemInMainHand(player);
key = CMIMaterial.get(item).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + item.getData().getData());
break;
case "offhand":
item = CMIItemStack.getItemInOffHand(player);
key = CMIMaterial.get(item).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + item.getData().getData());
break;
case "looking":
case "lookingat":
Block block = Util.getTargetBlock(player, 30);
key = CMIMaterial.get(block).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + block.getData());
break;
default:
break;
}
KeyValues keyValue = Jobs.getConfigManager().getKeyValue(key, actionT, job.getName());
if (keyValue == null)
return false;
String type = keyValue.getType(),
subType = keyValue.getSubType(),
meta = keyValue.getMeta();
int id = keyValue.getId();
double income = 0D,
points = 0D,
experience = 0D;
int fromlevel = 1;
int untilLevel = -1;
JobInfo jInfo = new JobInfo(actionT, id, meta, type + subType, income, job.getMoneyEquation(), experience, job.getXpEquation(), job.getPointsEquation(), points, fromlevel,
untilLevel, job.getName() + "/" + actionT.getName() + "/" + (type + subType).replace(":", "-"));
for (JobInfo info : job.getJobInfo(actionT)) {
if (info.getName().equalsIgnoreCase(jInfo.getName())) {
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
return true;
}
}
action.add(jInfo);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/income", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/points", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/experience", 0);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
default:
break;
}
return true;
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
LC.info_Ingame.sendMessage(sender);
return false;
}
Player player = (Player) sender;
if (args.length == 0)
args = new String[] { "list" };
switch (args[0]) {
case "list":
if (args.length == 1) {
showPath(player, null, null, null);
for (Job one : Jobs.getJobs()) {
RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", one.getDisplayName()))
.addHover(one.getName())
.addCommand("jobs editjobs list " + one.getName());
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 2) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
showPath(player, job, null, null);
for (ActionType oneI : ActionType.values()) {
List<JobInfo> action = job.getJobInfo(oneI);
if (action == null || action.isEmpty())
continue;
RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", oneI.getName()))
.addHover(oneI.getName())
.addCommand("jobs editjobs list " + job.getName() + " " + oneI.getName() + " 1");
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 4) {
Integer page = null;
try {
page = Integer.parseInt(args[3]);
} catch (NumberFormatException e) {
}
if (page != null) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
showPath(player, job, actionT, null);
PageInfo pi = new PageInfo(15, action.size(), page);
for (JobInfo one : action) {
if (!pi.isEntryOk())
continue;
String materialName = one.getRealisticName();
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", materialName), one.getName(), "jobs editjobs list " + job.getName() + " " + actionT
.getName() + " " + one.getName());
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialRemove"), "&cRemove", "jobs editjobs remove " + job.getName() + " " + actionT.getName() + " " + one
.getName());
rm.show(sender);
}
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialAdd"), "&eAdd new", "jobs editjobs add " + job.getName() + " " + actionT.getName());
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
pi.autoPagination(sender, "jobs editjobs list " + job.getName() + " " + actionT.getName());
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
showPath(player, job, actionT, jInfo);
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.money", "%amount%", jInfo.getBaseIncome()), "&e" + jInfo.getBaseIncome(), "jobs editjobs modify " + job.getName() + " "
+ actionT.getName() + " " + jInfo.getName() + " money ");
rm.show(sender);
rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.points", "%amount%", jInfo.getBasePoints()), "&e" + jInfo.getBasePoints(), "jobs editjobs modify " + job.getName() + " "
+ actionT.getName() + " " + jInfo.getName()
+ " points ");
rm.show(sender);
rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.exp", "%amount%", jInfo.getBaseXp()), "&e" + jInfo.getBaseXp(), "jobs editjobs modify " + job.getName() + " " + actionT
.getName() + " " + jInfo.getName() + " exp ");
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "modify":
if (args.length == 5) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs modify " + job.getName() + " " + actionT.getName() + " " + jInfo.getName() + " " + type.getName() + " ");
sender.sendMessage(Jobs.getLanguage().getMessage("command.editjobs.help.modify.newValue"));
return true;
}
if (args.length == 6) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
Double value = null;
try {
value = Double.parseDouble(args[5]);
} catch (Exception e) {
return false;
}
String sType = null;
switch (type) {
case EXP:
sType = "experience";
jInfo.setBaseXp(value);
break;
case MONEY:
sType = "income";
jInfo.setBaseIncome(value);
break;
case POINTS:
sType = "points";
jInfo.setBasePoints(value);
break;
default:
break;
}
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/" + sType, value);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "remove":
// remove miner break stone:1
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo info : action) {
if (!info.getName().equalsIgnoreCase(args[3]))
continue;
jInfo = info;
break;
}
if (jInfo == null) {
return true;
}
action.remove(jInfo);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath(), null);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " 1");
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "add":
// add miner break stone:1
if (args.length == 3) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.enter"));
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.hand"), Jobs.getLanguage().getMessage("command.editjobs.help.modify.handHover"), "jobs editjobs add " + job.getName()
+ " " + actionT.getName() + " hand");
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.or"));
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.look"), Jobs.getLanguage().getMessage("command.editjobs.help.modify.lookHover"), "jobs editjobs add " + job.getName()
+ " " + actionT.getName() + " looking");
rm.show(sender);
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs add " + job.getName() + " " + actionT.getName() + " ");
return true;
}
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
String key = args[3];
switch (args[3]) {
case "hand":
ItemStack item = CMIItemStack.getItemInMainHand(player);
key = CMIMaterial.get(item).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + item.getData().getData());
break;
case "offhand":
item = CMIItemStack.getItemInOffHand(player);
key = CMIMaterial.get(item).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + item.getData().getData());
break;
case "looking":
case "lookingat":
Block block = Util.getTargetBlock(player, 30);
key = CMIMaterial.get(block).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + block.getData());
break;
default:
break;
}
KeyValues keyValue = Jobs.getConfigManager().getKeyValue(key, actionT, job.getName());
if (keyValue == null)
return false;
String type = keyValue.getType(),
subType = keyValue.getSubType(),
meta = keyValue.getMeta();
int id = keyValue.getId();
double income = 0D,
points = 0D,
experience = 0D;
int fromlevel = 1;
int untilLevel = -1;
JobInfo jInfo = new JobInfo(actionT, id, meta, type + subType, income, job.getMoneyEquation(), experience, job.getXpEquation(), job.getPointsEquation(), points, fromlevel,
untilLevel, job.getName() + "/" + actionT.getName() + "/" + (type + subType).replace(":", "-"));
for (JobInfo info : job.getJobInfo(actionT)) {
if (info.getName().equalsIgnoreCase(jInfo.getName())) {
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
return true;
}
}
action.add(jInfo);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/income", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/points", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/experience", 0);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
default:
break;
}
return true;
}
private static void showPath(Player player, Job job, ActionType action, JobInfo jInfo) {
RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.job")).addHover("&eJob list")
.addCommand("jobs editjobs").show(player);
RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.job")).addHover("&eJob list")
.addCommand("jobs editjobs").show(player);
if (job != null) {
rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getDisplayName()))
.addHover(job.getName()).addCommand("jobs editjobs list " + job.getName());
rm.show(player);
}
if (job != null) {
rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getDisplayName()))
.addHover(job.getName()).addCommand("jobs editjobs list " + job.getName());
rm.show(player);
}
if (action != null && job != null) {
rm = new RawMessage();
if (action != null && job != null) {
rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", action.getName()))
.addHover(action.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName() + " 1")
.show(player);
}
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", action.getName()))
.addHover(action.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName() + " 1")
.show(player);
}
if (action != null && job != null && jInfo != null) {
rm = new RawMessage();
if (action != null && job != null && jInfo != null) {
rm = new RawMessage();
String materialName = jInfo.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().translate(materialName, jInfo);
materialName = CMIChatColor.translate(materialName);
String materialName = jInfo.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().translate(materialName, jInfo);
materialName = CMIChatColor.translate(materialName);
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName()))
.addHover(jInfo.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName()
+ " " + materialName).show(player);
}
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName()))
.addHover(jInfo.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName()
+ " " + materialName).show(player);
}
}
}

View File

@ -5,6 +5,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -12,56 +13,55 @@ import net.Zrips.CMILib.Messages.CMIMessages;
public class editpoints implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length != 3) {
Jobs.getCommandManager().sendUsage(sender, "editpoints");
return true;
}
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length != 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[1]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[1]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[1]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[1]);
return true;
}
double amount = 0;
try {
amount = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
CMIMessages.sendMessage(sender, LC.info_UseInteger);
return true;
}
double amount = 0;
try {
amount = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
CMIMessages.sendMessage(sender, LC.info_UseInteger);
return false;
}
PlayerPoints pointInfo = jPlayer.getPointsData();
switch (args[0].toLowerCase()) {
case "take":
pointInfo.takePoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.take",
"%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount,
"%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D));
break;
case "add":
pointInfo.addPoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.add",
"%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount,
"%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D));
break;
case "set":
pointInfo.setPoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.set",
"%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount));
break;
default:
break;
}
PlayerPoints pointInfo = jPlayer.getPointsData();
switch (args[0].toLowerCase()) {
case "take":
pointInfo.takePoints(amount);
Language.sendMessage(sender, "command.editpoints.output.take",
"%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount,
"%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D);
break;
case "add":
pointInfo.addPoints(amount);
Language.sendMessage(sender, "command.editpoints.output.add",
"%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount,
"%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D);
break;
case "set":
pointInfo.setPoints(amount);
Language.sendMessage(sender, "command.editpoints.output.set",
"%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount);
break;
default:
break;
}
Jobs.getJobsDAO().savePoints(jPlayer);
return true;
Jobs.getJobsDAO().savePoints(jPlayer);
return true;
}
}

View File

@ -28,7 +28,6 @@ import net.Zrips.CMILib.Container.CMIText;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.RawMessages.RawMessageCommand;
@ -50,12 +49,17 @@ public class editquests implements Cmd {
static HashMap<String, List<String>> tempObjectives = new HashMap<String, List<String>>();
@Override
public boolean perform(Jobs plugin, final CommandSender sender, String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, String[] args) {
int page = 0;
Action action = null;
// Only informing here and not canceling command
if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
}
for (String one : args) {
if (page == 0) {
try {

View File

@ -7,52 +7,50 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class employ implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "employ");
return true;
}
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 2) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getDisplayName()));
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
Language.sendMessage(sender, "command.employ.error.alreadyin", "%jobname%", job.getDisplayName());
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
String message = Jobs.getLanguage().getMessage("command.employ.error.fullslots");
message = message.replace("%jobname%", job.getDisplayName());
sender.sendMessage(message);
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
Language.sendMessage(sender, "command.employ.error.fullslots", "%jobname%", job.getDisplayName());
return true;
}
try {
// check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getDisplayName()));
try {
// check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.employ.output.target", "%jobname%", job.getDisplayName());
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
Language.sendMessage(sender, "general.admin.success");
} catch (Throwable e) {
Language.sendMessage(sender, "general.admin.error");
}
return true;
}
}

View File

@ -6,43 +6,41 @@ import org.bukkit.entity.EntityType;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.CMIText;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
public class entitylist implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "entitylist");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
StringBuilder msg = new StringBuilder();
String c1 = "&e";
String c2 = "&6";
String msg = "",
c1 = "&e",
c2 = "&6";
int i = 0;
for (EntityType type : EntityType.values()) {
if (!type.isAlive() || !type.isSpawnable())
continue;
int i = 0;
for (EntityType type : EntityType.values()) {
if (!type.isAlive() || !type.isSpawnable())
continue;
i++;
i++;
if (!msg.isEmpty())
msg.append(LC.info_ListSpliter.getLocale());
if (!msg.isEmpty())
msg += ", ";
if (i > 1) {
msg.append(c1);
i = 0;
} else {
msg.append(c2);
}
if (i > 1) {
msg += c1;
i = 0;
} else {
msg += c2;
}
msg.append(CMIText.everyFirstToUpperCase(type.name()));
}
msg += type.name().toLowerCase();
}
sender.sendMessage(CMIChatColor.translate(msg));
return true;
CMIMessages.sendMessage(sender, msg.toString());
return true;
}
}

View File

@ -21,11 +21,10 @@ public class exp implements Cmd {
Random rand = new Random();
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 4) {
Jobs.getCommandManager().sendUsage(sender, "exp");
return true;
return false;
}
boolean silent = false;
@ -120,20 +119,20 @@ public class exp implements Cmd {
Player player = jPlayer.getPlayer();
if (player == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.give.output.notonline"));
Language.sendMessage(sender, "general.give.output.notonline");
return true;
}
if (!silent)
player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
.getExperience()));
Language.sendMessage(player, "command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
.getExperience());
if (!silentAdmin)
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
Language.sendMessage(sender, "general.admin.success");
} catch (Exception e) {
if (!silentAdmin)
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
Language.sendMessage(sender, "general.admin.error");
e.printStackTrace();
}
return true;

View File

@ -1,106 +0,0 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import net.Zrips.CMILib.Time.timeModifier;
public class expboost implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true;
}
Double rate = null;
Long timeDuration = null;
String jobName = null;
boolean reset = false;
for (String one : args) {
if (one.equalsIgnoreCase("reset")) {
reset = true;
continue;
}
if (jobName == null) {
jobName = one;
continue;
}
if (rate == null) {
try {
rate = Double.parseDouble(one);
continue;
} catch (NumberFormatException e) {
}
}
try {
Long t = timeModifier.getTimeRangeFromString(one);
if (t != null)
timeDuration = t;
continue;
} catch (Exception e) {
}
}
if (!reset && rate == null || jobName == null) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return false;
}
if (rate == null)
rate = 1D;
if (timeDuration == null)
timeDuration = 0L;
if (!reset && jobName.equalsIgnoreCase("all")) {
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.EXP, rate, timeDuration);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
return true;
}
if (reset) {
if (jobName.equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.EXP, 1.0);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(jobName);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.EXP, 1.0);
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", "%jobname%", job.getName()));
}
return true;
}
Job job = Jobs.getJob(jobName);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.EXP, rate, timeDuration);
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
return true;
}
}

View File

@ -10,51 +10,56 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.ExploreChunk;
import com.gamingmesh.jobs.container.ExploreRegion;
import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
public class explored implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
LC.info_Ingame.sendMessage(sender);
return null;
}
Player player = (Player) sender;
Map<String, ExploreRegion> exploreRegion = Jobs.getExploreManager().getWorlds().get(player.getWorld().getName());
Player player = (Player) sender;
Map<String, ExploreRegion> exploreRegion = Jobs.getExploreManager().getWorlds().get(player.getWorld().getName());
if (exploreRegion == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
return true;
}
if (exploreRegion == null) {
Language.sendMessage(sender, "command.explored.error.noexplore");
return true;
}
int RegionX = (int) Math.floor(player.getLocation().getChunk().getX() / 32D);
int RegionZ = (int) Math.floor(player.getLocation().getChunk().getZ() / 32D);
ExploreRegion region = exploreRegion.get(RegionX + ":" + RegionZ);
if (region == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
return true;
}
int RegionX = (int) Math.floor(player.getLocation().getChunk().getX() / 32D);
int RegionZ = (int) Math.floor(player.getLocation().getChunk().getZ() / 32D);
ExploreRegion region = exploreRegion.get(RegionX + ":" + RegionZ);
if (region == null) {
Language.sendMessage(sender, "command.explored.error.noexplore");
return true;
}
ExploreChunk chunk = region.getChunk(player.getLocation().getChunk());
ExploreChunk chunk = region.getChunk(player.getLocation().getChunk());
if (chunk == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
return true;
}
if (chunk == null) {
Language.sendMessage(sender, "command.explored.error.noexplore");
return true;
}
if (Jobs.getGCManager().ExploreCompact && chunk.isFullyExplored()) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.fullExplore"));
return true;
}
if (Jobs.getGCManager().ExploreCompact && chunk.isFullyExplored()) {
Language.sendMessage(sender, "command.explored.fullExplore");
return true;
}
java.util.List<Integer> players = chunk.getPlayers();
java.util.List<Integer> players = chunk.getPlayers();
for (int i = 0; i < players.size(); i++) {
PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(players.get(i));
if (ji != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.list", "%place%", i + 1, "%playername%", ji.getName()));
}
player.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
for (int i = 0; i < players.size(); i++) {
PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(players.get(i));
if (ji != null)
Language.sendMessage(sender, "command.explored.list", "%place%", i + 1, "%playername%", ji.getName());
}
Language.sendMessage(sender, "general.info.separator");
return true;
return true;
}
}

View File

@ -7,41 +7,41 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class fire implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "fire");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 2) {
return false;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
if (!jPlayer.isInJob(job)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getDisplayName()));
return true;
}
if (!jPlayer.isInJob(job)) {
Language.sendMessage(sender, "command.fire.error.nojob", "%jobname%", job.getDisplayName());
return true;
}
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) {
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getDisplayName()));
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) {
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.fire.output.target", "%jobname%", job.getDisplayName());
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
}
Language.sendMessage(sender, "general.admin.success");
}
return true;
return true;
}
}

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.dao.JobsDAO.DBTables;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -15,50 +16,49 @@ import net.Zrips.CMILib.Messages.CMIMessages;
public class fireall implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "fireall");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 1) {
return false;
}
if (args[0].equalsIgnoreCase("all")) {
if (sender instanceof Player) {
CMIMessages.sendMessage(sender, LC.info_FromConsole);
return true;
}
if (args[0].equalsIgnoreCase("all")) {
if (sender instanceof Player) {
CMIMessages.sendMessage(sender, LC.info_FromConsole);
return true;
}
Jobs.getDBManager().getDB().truncate(DBTables.JobsTable.getTableName());
Jobs.getDBManager().getDB().truncate(DBTables.JobsTable.getTableName());
for (JobsPlayer one : Jobs.getPlayerManager().getPlayersCache().values()) {
for (JobProgression job : one.getJobProgression()) {
Jobs.getJobsDAO().recordToArchive(one, job.getJob());
}
one.leaveAllJobs();
// No need to save as we are clearing database with more efficient method
one.setSaved(true);
}
for (JobsPlayer one : Jobs.getPlayerManager().getPlayersCache().values()) {
for (JobProgression job : one.getJobProgression()) {
Jobs.getJobsDAO().recordToArchive(one, job.getJob());
}
one.leaveAllJobs();
// No need to save as we are clearing database with more efficient method
one.setSaved(true);
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
return true;
}
Language.sendMessage(sender, "general.admin.success");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
if (jPlayer.progression.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fireall.error.nojobs"));
return true;
}
if (jPlayer.progression.isEmpty()) {
Language.sendMessage(sender, "command.fireall.error.nojobs");
return true;
}
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.fireall.output.target"));
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.fireall.output.target");
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
return true;
Language.sendMessage(sender, "general.admin.success");
return true;
}
}

View File

@ -11,96 +11,98 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobLimitedItems;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.GiveItem;
public class give implements Cmd {
private enum actions {
items, limiteditems;
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
items, limiteditems;
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
}
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Player player = null;
Job job = null;
actions name = null;
String itemName = null;
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Player player = null;
Job job = null;
actions name = null;
String itemName = null;
for (String one : args) {
if (player == null) {
player = Bukkit.getPlayer(one);
if (player != null)
continue;
}
for (String one : args) {
if (player == null) {
player = Bukkit.getPlayer(one);
if (player != null)
continue;
}
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
if (name == null) {
name = actions.getByname(one);
if (name != null)
continue;
}
itemName = one;
}
if (name == null) {
name = actions.getByname(one);
if (name != null)
continue;
}
itemName = one;
}
if (player == null && sender instanceof Player)
player = (Player) sender;
if (player == null && sender instanceof Player)
player = (Player) sender;
if (player == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.notonline"));
return true;
}
if (player == null) {
Language.sendMessage(sender, "command.give.output.notonline");
return null;
}
if (name == null)
name = actions.items;
if (name == null)
name = actions.items;
if (itemName == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
if (itemName == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
switch (name) {
case items:
JobItems jItem = ItemBoostManager.getItemByKey(itemName);
ItemStack item = jItem == null ? null : jItem.getItemStack(player);
switch (name) {
case items:
JobItems jItem = ItemBoostManager.getItemByKey(itemName);
ItemStack item = jItem == null ? null : jItem.getItemStack(player);
if (item == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
}
if (item == null) {
Language.sendMessage(sender, "command.give.output.noitem");
return true;
}
GiveItem.giveItemForPlayer(player, item);
break;
case limiteditems:
if (job == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
GiveItem.giveItemForPlayer(player, item);
break;
case limiteditems:
if (job == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
ItemStack limItem = jLItem == null ? null : jLItem.getItemStack(player);
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
ItemStack limItem = jLItem == null ? null : jLItem.getItemStack(player);
if (limItem == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
}
if (limItem == null) {
Language.sendMessage(sender, "command.give.output.noitem");
return true;
}
GiveItem.giveItemForPlayer(player, limItem);
break;
default:
break;
}
return true;
GiveItem.giveItemForPlayer(player, limItem);
break;
default:
break;
}
return true;
}
}

View File

@ -15,107 +15,109 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Log;
import com.gamingmesh.jobs.container.LogAmounts;
import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Sorting;
import com.gamingmesh.jobs.stuff.TimeManage;
import net.Zrips.CMILib.Time.CMITimeManager;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class glog implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "glog");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0) {
return false;
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
Map<LogAmounts, Double> unsortMap = new HashMap<>();
int time = TimeManage.timeInInt();
CMIScheduler.get().runTaskAsynchronously(new Runnable() {
@Override
public void run() {
Map<LogAmounts, Double> unsortMap = new HashMap<>();
int time = CMITimeManager.timeInInt();
for (Integer oneP : Jobs.getJobsDAO().getLognameList(time, time)) {
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(oneP);
if (info == null)
continue;
for (Integer oneP : Jobs.getJobsDAO().getLognameList(time, time)) {
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(oneP);
if (info == null)
continue;
String name = info.getName();
if (name == null)
continue;
String name = info.getName();
if (name == null)
continue;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(info.getUuid());
if (jPlayer == null)
continue;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(info.getUuid());
if (jPlayer == null)
continue;
Map<String, Log> logList = jPlayer.getLog();
if (logList == null || logList.isEmpty())
continue;
Map<String, Log> logList = jPlayer.getLog();
if (logList == null || logList.isEmpty())
continue;
for (Log l : logList.values()) {
for (LogAmounts amounts : l.getAmountList().values()) {
amounts.setUsername(name);
amounts.setAction(l.getActionType());
unsortMap.put(amounts, amounts.get(CurrencyType.MONEY));
}
}
}
for (Log l : logList.values()) {
for (LogAmounts amounts : l.getAmountList().values()) {
amounts.setUsername(name);
amounts.setAction(l.getActionType());
unsortMap.put(amounts, amounts.get(CurrencyType.MONEY));
}
}
}
unsortMap = Sorting.sortDoubleDESCByLog(unsortMap);
if (unsortMap.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.nodata"));
return;
}
unsortMap = Sorting.sortDoubleDESCByLog(unsortMap);
if (unsortMap.isEmpty()) {
Language.sendMessage(sender, "command.glog.output.nodata");
return;
}
int count = 1, max = 10;
int count = 1, max = 10;
double totalMoney = 0,
totalExp = 0,
totalPoints = 0;
double totalMoney = 0,
totalExp = 0,
totalPoints = 0;
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.topline"));
for (LogAmounts info : unsortMap.keySet()) {
double money = info.get(CurrencyType.MONEY);
totalMoney += money;
Language.sendMessage(sender, "command.glog.output.topline");
for (LogAmounts info : unsortMap.keySet()) {
double money = info.get(CurrencyType.MONEY);
totalMoney += money;
String moneyS = "";
if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.glog.output.money", "%amount%", money);
String moneyS = "";
if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.glog.output.money", "%amount%", money);
double exp = info.get(CurrencyType.EXP);
totalExp += exp;
double exp = info.get(CurrencyType.EXP);
totalExp += exp;
String expS = "";
if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.glog.output.exp", "%amount%", exp);
String expS = "";
if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.glog.output.exp", "%amount%", exp);
double points = info.get(CurrencyType.POINTS);
totalPoints += points;
double points = info.get(CurrencyType.POINTS);
totalPoints += points;
String pointsS = "";
if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.glog.output.points", "%amount%", points);
String pointsS = "";
if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.glog.output.points", "%amount%", points);
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.ls",
"%number%", count,
"%action%", info.getAction(),
"%item%", info.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", info.getCount(),
"%money%", moneyS,
"%exp%", expS,
"%points%", pointsS));
Language.sendMessage(sender, "command.glog.output.ls",
"%number%", count,
"%action%", info.getAction(),
"%item%", info.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", info.getCount(),
"%money%", moneyS,
"%exp%", expS,
"%points%", pointsS);
count++;
count++;
if (count > max)
break;
}
if (count > max)
break;
}
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints)));
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
Language.sendMessage(sender, "command.glog.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints));
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.bottomline"));
}
});
return true;
Language.sendMessage(sender, "command.glog.output.bottomline");
}
});
return true;
}
}

View File

@ -8,53 +8,53 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class grantxp implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "grantxp");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
double xpGained;
try {
xpGained = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
return true;
}
if (xpGained <= 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
double xpGained;
try {
xpGained = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
Language.sendMessage(sender, "general.admin.error");
return true;
}
if (xpGained <= 0) {
Language.sendMessage(sender, "general.admin.error");
return true;
}
// check if player already has the job
if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().addExperience(jPlayer, job, xpGained);
// check if player already has the job
if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().addExperience(jPlayer, job, xpGained);
Player player = jPlayer.getPlayer();
if (player != null) {
String message = Jobs.getLanguage().getMessage("command.grantxp.output.target",
"%jobname%", job.getDisplayName(),
"%xpgained%", xpGained);
player.sendMessage(message);
}
Player player = jPlayer.getPlayer();
if (player != null) {
String message = Jobs.getLanguage().getMessage("command.grantxp.output.target",
"%jobname%", job.getDisplayName(),
"%xpgained%", xpGained);
player.sendMessage(message);
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
}
return true;
Language.sendMessage(sender, "general.admin.success");
}
return true;
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.scoreboard.DisplaySlot;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Locale.LC;
@ -19,80 +20,79 @@ import net.Zrips.CMILib.Scoreboards.CMIScoreboard;
public class gtop implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length > 1) {
Jobs.getCommandManager().sendUsage(sender, "gtop");
return true;
}
if (args.length > 1) {
return false;
}
Player player = (Player) sender;
int page = 1;
if (args.length == 1) {
if (args[0].equalsIgnoreCase("clear")) {
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
CMIScoreboard.removeScoreBoard(player);
return true;
}
Player player = (Player) sender;
int page = 1;
if (args.length == 1) {
if (args[0].equalsIgnoreCase("clear")) {
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
CMIScoreboard.removeScoreBoard(player);
return true;
}
try {
page = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
return true;
}
}
try {
page = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
return true;
}
}
if (page < 1)
page = 1;
if (page < 1)
page = 1;
int amount = Jobs.getGCManager().JobsTopAmount;
PageInfo pi = new PageInfo(amount, Jobs.getPlayerManager().getPlayersCache().size(), page);
int amount = Jobs.getGCManager().JobsTopAmount;
PageInfo pi = new PageInfo(amount, Jobs.getPlayerManager().getPlayersCache().size(), page);
List<TopList> FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart());
if (FullList.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.error.nojob"));
return true;
}
List<TopList> FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart());
if (FullList.isEmpty()) {
Language.sendMessage(sender, "command.gtop.error.nojob");
return true;
}
if (!Jobs.getGCManager().ShowToplistInScoreboard) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.topline", "%amount%", amount));
if (!Jobs.getGCManager().ShowToplistInScoreboard) {
Language.sendMessage(sender, "command.gtop.output.topline", "%amount%", amount);
int i = 0;
for (TopList One : FullList) {
if (i >= amount)
break;
int i = 0;
for (TopList One : FullList) {
if (i >= amount)
break;
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list",
"%number%", pi.getPositionForOutput(i),
"%playername%", One.getPlayerInfo().getName(),
"%playerdisplayname%", One.getPlayerInfo().getDisplayName(),
"%level%", One.getLevel(),
"%exp%", One.getExp()));
++i;
}
} else {
List<String> ls = new ArrayList<>();
int i = 0;
for (TopList one : FullList) {
if (i >= amount)
break;
Language.sendMessage(sender, "command.gtop.output.list",
"%number%", pi.getPositionForOutput(i),
"%playername%", One.getPlayerInfo().getName(),
"%playerdisplayname%", One.getPlayerInfo().getDisplayName(),
"%level%", One.getLevel(),
"%exp%", One.getExp());
++i;
}
} else {
List<String> ls = new ArrayList<>();
int i = 0;
for (TopList one : FullList) {
if (i >= amount)
break;
ls.add(Jobs.getLanguage().getMessage("scoreboard.line",
"%number%", pi.getPositionForOutput(i),
"%playername%", one.getPlayerInfo().getName(),
"%playerdisplayname%", one.getPlayerInfo().getDisplayName(),
"%level%", one.getLevel()));
++i;
}
ls.add(Jobs.getLanguage().getMessage("scoreboard.line",
"%number%", pi.getPositionForOutput(i),
"%playername%", one.getPlayerInfo().getName(),
"%playerdisplayname%", one.getPlayerInfo().getDisplayName(),
"%level%", one.getLevel()));
++i;
}
CMIScoreboard.show(player, Jobs.getLanguage().getMessage("scoreboard.gtopline"), ls, Jobs.getGCManager().ToplistInScoreboardInterval);
}
CMIScoreboard.show(player, Jobs.getLanguage().getMessage("scoreboard.gtopline"), ls, Jobs.getGCManager().ToplistInScoreboardInterval);
}
plugin.showPagination(sender, pi, "jobs gtop");
return true;
pi.autoPagination(sender, "jobs gtop");
return true;
}
}

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -15,62 +16,61 @@ import net.Zrips.CMILib.Messages.CMIMessages;
public class info implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "info");
Jobs.getCommandManager().sendValidActions(sender);
return true;
}
if (args.length < 1) {
Jobs.getCommandManager().sendValidActions(sender);
return false;
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (jPlayer == null) {
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", pSender.getName()));
return true;
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", pSender.getName());
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
if (Jobs.getGCManager().hideJobsInfoWithoutPermission && !Jobs.getCommandManager().hasJobPermission(pSender, job)) {
CMIMessages.sendMessage(pSender, LC.info_NoPermission);
return true;
}
if (Jobs.getGCManager().hideJobsInfoWithoutPermission && !Jobs.getCommandManager().hasJobPermission(pSender, job)) {
CMIMessages.sendMessage(pSender, LC.info_NoPermission);
return true;
}
if (Jobs.getGCManager().jobsInfoOpensBrowse) {
plugin.getGUIManager().openJobsBrowseGUI(pSender, job, true);
return true;
}
if (Jobs.getGCManager().jobsInfoOpensBrowse) {
plugin.getGUIManager().openJobsBrowseGUI(pSender, job, true);
return true;
}
int page = 1;
String type = null;
int page = 1;
String type = null;
for (int i = 1; i < args.length; i++) {
String one = args[i];
if (type == null) {
ActionType t = ActionType.getByName(one);
if (t != null) {
type = t.getName();
continue;
}
}
try {
page = Integer.parseInt(args[i]);
} catch (NumberFormatException e) {
}
}
for (int i = 1; i < args.length; i++) {
String one = args[i];
if (type == null) {
ActionType t = ActionType.getByName(one);
if (t != null) {
type = t.getName();
continue;
}
}
try {
page = Integer.parseInt(args[i]);
} catch (NumberFormatException e) {
}
}
Jobs.getCommandManager().jobInfoMessage(pSender, jPlayer, job, type, page);
return true;
Jobs.getCommandManager().jobInfoMessage(pSender, jPlayer, job, type, page);
return true;
}
}

View File

@ -27,10 +27,10 @@ import net.Zrips.CMILib.RawMessages.RawMessage;
public class itembonus implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
return null;
}
Player player = (Player) sender;

View File

@ -19,15 +19,14 @@ public class iteminfo implements Cmd {
@Override
@SuppressWarnings("deprecation")
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
return null;
}
if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "iteminfo");
return true;
return false;
}
ItemStack iih = CMIItemStack.getItemInMainHand((Player) sender);

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -16,77 +17,76 @@ import net.Zrips.CMILib.RawMessages.RawMessage;
public class join implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length != 1 && args.length != 0 && args.length != 2) {
Jobs.getCommandManager().sendUsage(sender, "join");
return true;
}
if (args.length != 1 && args.length != 0 && args.length != 2) {
return false;
}
if (args.length == 0) {
plugin.getServer().dispatchCommand(sender, "jobs browse");
return true;
}
if (args.length == 0) {
plugin.getServer().dispatchCommand(sender, "jobs browse");
return null;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
// job does not exist
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
// job does not exist
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
if (!Jobs.getCommandManager().hasJobPermission(sender, job)) {
// The player do not have permission to join the job
CMIMessages.sendMessage(sender, LC.info_NoPermission);
return true;
}
if (!Jobs.getCommandManager().hasJobPermission(sender, job)) {
// The player do not have permission to join the job
CMIMessages.sendMessage(sender, LC.info_NoPermission);
return true;
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (jPlayer == null) { // Load player into cache
Jobs.getPlayerManager().playerJoin(pSender);
jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (jPlayer == null) { // Load player into cache
Jobs.getPlayerManager().playerJoin(pSender);
jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
}
if (jPlayer == null) {
return true;
}
if (jPlayer == null) {
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getDisplayName()));
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
Language.sendMessage(sender, "command.join.error.alreadyin", "%jobname%", job.getDisplayName());
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getDisplayName()));
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
Language.sendMessage(sender, "command.join.error.fullslots", "%jobname%", job.getDisplayName());
return true;
}
if (!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.progression.size())) {
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.maxjobs"));
return true;
}
if (!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.progression.size())) {
Language.sendMessage(sender, "command.join.error.maxjobs");
return true;
}
if (args.length == 2 && args[1].equalsIgnoreCase("-needConfirmation")) {
new RawMessage().addText(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()))
.addHover(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()))
.addCommand("jobs join " + job.getName()).show(pSender);
return true;
}
if (args.length == 2 && args[1].equalsIgnoreCase("-needConfirmation")) {
new RawMessage().addText(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()))
.addHover(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()))
.addCommand("jobs join " + job.getName()).show(pSender);
return true;
}
JobProgression ajp = jPlayer.getArchivedJobProgression(job);
if (ajp != null && !ajp.canRejoin()) {
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", ajp.getRejoinTimeMessage()));
return true;
}
JobProgression ajp = jPlayer.getArchivedJobProgression(job);
if (ajp != null && !ajp.canRejoin()) {
Language.sendMessage(sender, "command.join.error.rejoin", "[time]", ajp.getRejoinTimeMessage());
return true;
}
Jobs.getPlayerManager().joinJob(jPlayer, job);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getDisplayName()));
return true;
Jobs.getPlayerManager().joinJob(jPlayer, job);
Language.sendMessage(sender, "command.join.success", "%jobname%", job.getDisplayName());
return true;
}
}

View File

@ -7,59 +7,62 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class leave implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player))
return false;
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
LC.info_Ingame.sendMessage(sender);
return null;
}
if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "leave");
return true;
}
if (args.length < 1) {
return false;
}
Player pSender = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Player pSender = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
if (Jobs.getGCManager().UsePerPermissionForLeaving && !pSender.hasPermission("jobs.command.leave." + args[0].toLowerCase())) {
CMIMessages.sendMessage(pSender, LC.info_NoPermission);
return true;
}
if (Jobs.getGCManager().UsePerPermissionForLeaving && !pSender.hasPermission("jobs.command.leave." + args[0].toLowerCase())) {
CMIMessages.sendMessage(sender, LC.info_NoPermission);
return true;
}
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
CMIScheduler.get().runTaskLater(() -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]",
job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime));
return true;
}
Language.sendMessage(sender, "command.leave.confirmationNeed", "[jobname]",
job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime);
return true;
}
Util.LEAVECONFIRM.remove(uuid);
}
Util.LEAVECONFIRM.remove(uuid);
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (Jobs.getPlayerManager().leaveJob(jPlayer, job))
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getDisplayName(), "[jobname]", job.getDisplayName()));
else
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
if (Jobs.getPlayerManager().leaveJob(jPlayer, job))
Language.sendMessage(sender, "command.leave.success", "%jobname%", job.getDisplayName(), "[jobname]", job.getDisplayName());
else
Language.sendMessage(sender, "general.error.job");
return true;
return true;
}
}

View File

@ -9,48 +9,50 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class leaveall implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.error.nojobs"));
return true;
}
List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.isEmpty()) {
Language.sendMessage(sender, "command.leaveall.error.nojobs");
return true;
}
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
CMIScheduler.get().runTaskLater(() -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]",
Jobs.getGCManager().ConfirmExpiryTime));
return true;
}
Language.sendMessage(pSender, "command.leaveall.confirmationNeed", "[time]",
Jobs.getGCManager().ConfirmExpiryTime);
return true;
}
Util.LEAVECONFIRM.remove(uuid);
}
Util.LEAVECONFIRM.remove(uuid);
}
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.success"));
return true;
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Language.sendMessage(sender, "command.leaveall.success");
return true;
}
}

View File

@ -9,118 +9,118 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class level implements Cmd {
private enum Action {
Set, Add, Take
Set, Add, Take
}
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 4) {
Jobs.getCommandManager().sendUsage(sender, "level");
return true;
}
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 4) {
return false;
}
Action action = Action.Add;
int amount = 0;
String playerName = null;
Job job = null;
Action action = Action.Add;
int amount = 0;
String playerName = null;
Job job = null;
for (String one : args) {
switch (one.toLowerCase()) {
case "set":
action = Action.Set;
continue;
case "add":
action = Action.Add;
continue;
case "take":
action = Action.Take;
continue;
default:
break;
}
for (String one : args) {
switch (one.toLowerCase()) {
case "set":
action = Action.Set;
continue;
case "add":
action = Action.Add;
continue;
case "take":
action = Action.Take;
continue;
default:
break;
}
try {
amount = Integer.parseInt(one);
continue;
} catch (NumberFormatException e) {
}
try {
amount = Integer.parseInt(one);
continue;
} catch (NumberFormatException e) {
}
if (job == null && (job = Jobs.getJob(one)) != null)
continue;
if (job == null && (job = Jobs.getJob(one)) != null)
continue;
playerName = one;
}
playerName = one;
}
if (playerName == null)
return false;
if (playerName == null)
return false;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerName);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerName);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
JobProgression prog = jPlayer.getJobProgression(job);
int total = 0;
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
JobProgression prog = jPlayer.getJobProgression(job);
int total = 0;
switch (action) {
case Set:
prog.setLevel(amount);
break;
case Add:
int oldLevel = prog.getLevel();
total = (oldLevel + amount);
switch (action) {
case Set:
prog.setLevel(amount);
break;
case Add:
int oldLevel = prog.getLevel();
total = (oldLevel + amount);
if (prog.setLevel(total)) {
JobsLevelUpEvent levelUpEvent = new JobsLevelUpEvent(jPlayer, job, prog.getLevel(),
Jobs.getTitleManager().getTitle(oldLevel, prog.getJob().getName()),
Jobs.getTitleManager().getTitle(prog.getLevel(), prog.getJob().getName()),
Jobs.getGCManager().SoundLevelupSound,
Jobs.getGCManager().SoundLevelupVolume,
Jobs.getGCManager().SoundLevelupPitch,
Jobs.getGCManager().SoundTitleChangeSound,
Jobs.getGCManager().SoundTitleChangeVolume,
Jobs.getGCManager().SoundTitleChangePitch);
if (prog.setLevel(total)) {
JobsLevelUpEvent levelUpEvent = new JobsLevelUpEvent(jPlayer, job, prog.getLevel(),
Jobs.getTitleManager().getTitle(oldLevel, prog.getJob().getName()),
Jobs.getTitleManager().getTitle(prog.getLevel(), prog.getJob().getName()),
Jobs.getGCManager().SoundLevelupSound,
Jobs.getGCManager().SoundLevelupVolume,
Jobs.getGCManager().SoundLevelupPitch,
Jobs.getGCManager().SoundTitleChangeSound,
Jobs.getGCManager().SoundTitleChangeVolume,
Jobs.getGCManager().SoundTitleChangePitch);
plugin.getServer().getPluginManager().callEvent(levelUpEvent);
plugin.getServer().getPluginManager().callEvent(levelUpEvent);
// If event is cancelled, don't do anything
if (levelUpEvent.isCancelled())
return true;
}
// If event is cancelled, don't do anything
if (levelUpEvent.isCancelled())
return true;
}
break;
case Take:
total = (prog.getLevel() - amount);
prog.setLevel(total);
break;
default:
break;
}
break;
case Take:
total = (prog.getLevel() - amount);
prog.setLevel(total);
break;
default:
break;
}
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.level.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevel(),
"%exp%", String.format(Jobs.getGCManager().getDecimalPlacesExp(), prog.getExperience())));
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.level.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevel(),
"%exp%", String.format(Jobs.getGCManager().getDecimalPlacesExp(), prog.getExperience()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} else
sender.sendMessage(Jobs.getLanguage().getMessage("command.level.error.nojob"));
} catch (Exception e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
Language.sendMessage(sender, "general.admin.success");
} else
Language.sendMessage(sender, "command.level.error.nojob");
} catch (Exception e) {
Language.sendMessage(sender, "general.admin.error");
}
return true;
}
}

View File

@ -8,64 +8,66 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Time.CMITimeManager;
public class limit implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "limit");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0 && args.length != 1) {
return false;
}
JobsPlayer JPlayer = null;
if (args.length >= 1)
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
else if (sender instanceof Player)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
JobsPlayer JPlayer = null;
if (args.length >= 1)
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
else if (sender instanceof Player)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
boolean disabled = true;
for (CurrencyType type : CurrencyType.values()) {
if (Jobs.getGCManager().getLimit(type).isEnabled()) {
disabled = false;
break;
}
}
boolean disabled = true;
for (CurrencyType type : CurrencyType.values()) {
if (Jobs.getGCManager().getLimit(type).isEnabled()) {
disabled = false;
break;
}
}
if (disabled) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.notenabled"));
return true;
}
if (disabled) {
Language.sendMessage(sender,"command.limit.output.notenabled");
return true;
}
if (JPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else if (!(sender instanceof Player))
Jobs.getCommandManager().sendUsage(sender, "limit");
return true;
}
if (JPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else if (!(sender instanceof Player))
Jobs.getCommandManager().sendUsage(sender, "limit");
return true;
}
for (CurrencyType type : CurrencyType.values()) {
if (!Jobs.getGCManager().getLimit(type).isEnabled())
continue;
PaymentData limit = JPlayer.getPaymentLimit();
for (CurrencyType type : CurrencyType.values()) {
if (!Jobs.getGCManager().getLimit(type).isEnabled())
continue;
PaymentData limit = JPlayer.getPaymentLimit();
if (limit.getLeftTime(type) <= 0)
limit.resetLimits(type);
if (limit.getLeftTime(type) <= 0) {
limit.resetLimits(type);
}
if (limit.getLeftTime(type) > 0) {
String typeName = type.getName().toLowerCase();
if (limit.getLeftTime(type) > 0) {
String typeName = type.getName().toLowerCase();
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + typeName + "Limit",
"%current%", (int) (limit.getAmount(type) * 100) / 100D,
"%total%", JPlayer.getLimit(type)));
}
}
return true;
Language.sendMessage(sender, "command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type)));
Language.sendMessage(sender, "command.limit.output." + typeName + "Limit",
"%current%", (int) (limit.getAmount(type) * 100) / 100D,
"%total%", JPlayer.getLimit(type));
}
}
return true;
}
}

View File

@ -15,122 +15,122 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Log;
import com.gamingmesh.jobs.container.LogAmounts;
import com.gamingmesh.jobs.stuff.Sorting;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.CMISort;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
public class log implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player) && args.length != 1) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player) && args.length != 1) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length != 1 && args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "log");
return true;
}
if (args.length != 1 && args.length != 0) {
return false;
}
JobsPlayer JPlayer = null;
if (args.length == 0)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
else if (args.length == 1) {
if (!Jobs.hasPermission(sender, "jobs.command.log.others", true))
return true;
JobsPlayer JPlayer = null;
if (args.length == 0)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
else if (args.length == 1) {
if (!Jobs.hasPermission(sender, "jobs.command.log.others", true))
return null;
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
}
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
}
if (JPlayer == null) {
Jobs.getCommandManager().sendUsage(sender, "log");
return true;
}
if (JPlayer == null) {
Jobs.getCommandManager().sendUsage(sender, "log");
return true;
}
Map<String, Log> logList = JPlayer.getLog();
if (logList == null || logList.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline"));
return true;
}
Map<String, Log> logList = JPlayer.getLog();
if (logList == null || logList.isEmpty()) {
Language.sendMessage(sender, "command.log.output.bottomline");
Language.sendMessage(sender, "command.log.output.nodata");
Language.sendMessage(sender, "command.log.output.bottomline");
return true;
}
Map<String, Double> unsortMap = new HashMap<>();
Map<String, Double> unsortMap = new HashMap<>();
for (Log l : logList.values()) {
for (Entry<String, LogAmounts> oneMap : l.getAmountList().entrySet()) {
unsortMap.put(oneMap.getKey(), oneMap.getValue().get(CurrencyType.MONEY));
}
}
for (Log l : logList.values()) {
for (Entry<String, LogAmounts> oneMap : l.getAmountList().entrySet()) {
unsortMap.put(oneMap.getKey(), oneMap.getValue().get(CurrencyType.MONEY));
}
}
unsortMap = Sorting.sortDoubleDESC(unsortMap);
if (unsortMap.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata"));
return true;
}
unsortMap = CMISort.sortDoubleDESC(unsortMap);
if (unsortMap.isEmpty()) {
Language.sendMessage(sender, "command.log.output.nodata");
return true;
}
int count = 0;
int max = 10;
int count = 0;
int max = 10;
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getName(), "%playerdisplayname%", JPlayer.getDisplayName()));
for (Log one : logList.values()) {
double totalMoney = 0, totalExp = 0, totalPoints = 0;
Language.sendMessage(sender, "command.log.output.topline", "%playername%", JPlayer.getName(), "%playerdisplayname%", JPlayer.getDisplayName());
for (Log one : logList.values()) {
double totalMoney = 0, totalExp = 0, totalPoints = 0;
for (String oneSorted : unsortMap.keySet()) {
for (Entry<String, LogAmounts> oneMap : one.getAmountList().entrySet()) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted)) {
count++;
for (String oneSorted : unsortMap.keySet()) {
for (Entry<String, LogAmounts> oneMap : one.getAmountList().entrySet()) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted)) {
count++;
LogAmounts amounts = oneMap.getValue();
LogAmounts amounts = oneMap.getValue();
double money = amounts.get(CurrencyType.MONEY);
totalMoney = totalMoney + money;
double money = amounts.get(CurrencyType.MONEY);
totalMoney = totalMoney + money;
String moneyS = "";
if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.log.output.money", "%amount%", money);
String moneyS = "";
if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.log.output.money", "%amount%", money);
double exp = amounts.get(CurrencyType.EXP);
totalExp = totalExp + exp;
double exp = amounts.get(CurrencyType.EXP);
totalExp = totalExp + exp;
String expS = "";
if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.log.output.exp", "%amount%", exp);
String expS = "";
if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.log.output.exp", "%amount%", exp);
double points = amounts.get(CurrencyType.POINTS);
totalPoints = totalPoints + points;
double points = amounts.get(CurrencyType.POINTS);
totalPoints = totalPoints + points;
String pointsS = "";
if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.log.output.points", "%amount%", points);
String pointsS = "";
if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.log.output.points", "%amount%", points);
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.ls",
"%number%", count,
"%action%", one.getActionType(),
"%item%", amounts.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", amounts.getCount(),
"%money%", moneyS,
"%exp%", expS,
"%points%", pointsS));
break;
}
}
Language.sendMessage(sender, "command.log.output.ls",
"%number%", count,
"%action%", one.getActionType(),
"%item%", amounts.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", amounts.getCount(),
"%money%", moneyS,
"%exp%", expS,
"%points%", pointsS);
break;
}
}
if (count > max)
break;
}
if (count > max)
break;
}
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints)));
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
Language.sendMessage(sender, "command.log.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints));
if (count > max)
break;
}
if (count > max)
break;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline"));
return true;
Language.sendMessage(sender, "command.log.output.bottomline");
return true;
}
}

View File

@ -1,106 +0,0 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import net.Zrips.CMILib.Time.timeModifier;
public class moneyboost implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
Double rate = null;
Long timeDuration = null;
String jobName = null;
boolean reset = false;
for (String one : args) {
if (one.equalsIgnoreCase("reset")) {
reset = true;
continue;
}
if (jobName == null) {
jobName = one;
continue;
}
if (rate == null) {
try {
rate = Double.parseDouble(one);
continue;
} catch (NumberFormatException e) {
}
}
try {
Long t = timeModifier.getTimeRangeFromString(one);
if (t != null)
timeDuration = t;
continue;
} catch (Exception e) {
}
}
if (!reset && rate == null || jobName == null) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return false;
}
if (rate == null)
rate = 1D;
if (timeDuration == null)
timeDuration = 0L;
if (!reset && jobName.equalsIgnoreCase("all")) {
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.MONEY, rate, timeDuration);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
return true;
}
if (reset) {
if (jobName.equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.MONEY, 1.0);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(jobName);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.MONEY, 1.0);
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%", job.getName()));
}
return true;
}
Job job = Jobs.getJob(jobName);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.MONEY, rate, timeDuration);
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
return true;
}
}

View File

@ -26,66 +26,66 @@ import net.Zrips.CMILib.RawMessages.RawMessage;
public class ownedblocks implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.ownedblocks", true))
return true;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.ownedblocks", true))
return null;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "ownedblocks");
return true;
}
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
return false;
return null;
}
final JobsPlayer jp = jPlayer;
final JobsPlayer jp = jPlayer;
RawMessage rm = new RawMessage();
RawMessage rm = new RawMessage();
Snd snd = new Snd();
snd.setSender(sender);
snd.setTargetName(jp.getName());
Snd snd = new Snd();
snd.setSender(sender);
snd.setTargetName(jp.getName());
rm.addText(LC.info_PlayerSpliter.getLocale(snd));
rm.addText(LC.info_PlayerSpliter.getLocale(snd));
int i = 0;
for (BlockTypes type : BlockTypes.values()) {
int i = 0;
for (BlockTypes type : BlockTypes.values()) {
Optional<BlockOwnerShip> ownerShip = plugin.getBlockOwnerShip(type);
Optional<BlockOwnerShip> ownerShip = plugin.getBlockOwnerShip(type);
if (!ownerShip.isPresent())
continue;
if (!ownerShip.isPresent())
continue;
HashMap<String, blockLoc> records = ownerShip.get().getBlockOwnerShips().get(jp.getUniqueId());
if (records == null)
continue;
HashMap<String, blockLoc> records = ownerShip.get().getBlockOwnerShips().get(jp.getUniqueId());
if (records == null)
continue;
for (Entry<String, blockLoc> record : records.entrySet()) {
i++;
rm.addText("\n");
for (Entry<String, blockLoc> record : records.entrySet()) {
i++;
rm.addText("\n");
CMIMaterial material = CMIMaterial.get(type.toString());
CMIMaterial material = CMIMaterial.get(type.toString());
CMILocation loc = CMILocation.fromString(record.getKey(), ":");
CMILocation loc = CMILocation.fromString(record.getKey(), ":");
rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.list", "[place]", i, "[type]", material.getName(), "[location]", LC.Location_Full.getLocale((Location) loc)));
rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.listHover", "[location]", LC.Location_Full.getLocale((Location) loc)));
rm.addCommand(JobsCommands.LABEL + " " + clearownership.class.getSimpleName() + " " + jp.getName() + " " + record.getKey());
if (record.getValue().isDisabled()) {
rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabled"));
rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabledHover"));
}
}
}
rm.show(sender);
if (i == 0)
LC.info_nothingToShow.sendMessage(sender);
rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.list", "[place]", i, "[type]", material.getName(), "[location]", LC.Location_Full.getLocale((Location) loc)));
rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.listHover", "[location]", LC.Location_Full.getLocale((Location) loc)));
rm.addCommand(JobsCommands.LABEL + " " + clearownership.class.getSimpleName() + " " + jp.getName() + " " + record.getKey());
if (record.getValue().isDisabled()) {
rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabled"));
rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabledHover"));
}
}
}
rm.show(sender);
if (i == 0)
LC.info_nothingToShow.sendMessage(sender);
return true;
return true;
}
}

View File

@ -8,86 +8,77 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceHolders;
import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceholderType;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage;
public class placeholders implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
boolean isPlayer = sender instanceof Player;
Player player = isPlayer ? (Player) sender : null;
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
boolean isPlayer = sender instanceof Player;
Player player = isPlayer ? (Player) sender : null;
int page = 1;
if (args.length > 0) {
if (isPlayer) {
if (args[0].startsWith("-p:")) {
try {
page = Integer.parseInt(args[0].substring("-p:".length()));
} catch (NumberFormatException e) {
}
}
} else {
player = Bukkit.getPlayer(args[0]);
if (player == null) {
Jobs.consoleMsg("&cPlayer cannot be null!");
return false;
}
}
}
int page = 1;
if (args.length > 0) {
if (isPlayer) {
if (args[0].startsWith("-p:")) {
try {
page = Integer.parseInt(args[0].substring("-p:".length()));
} catch (NumberFormatException e) {
}
}
} else {
player = Bukkit.getPlayer(args[0]);
if (player == null) {
CMIMessages.consoleMessage("&cPlayer cannot be null!");
return false;
}
}
}
if (args.length >= 2 && args[0].equalsIgnoreCase("parse")) {
String placeholder = args[1];
JobsPlaceholderType type = plugin.getPlaceholderAPIManager().getPlaceHolderType(player, placeholder);
if (args.length >= 2 && args[0].equalsIgnoreCase("parse")) {
String placeholder = args[1];
JobsPlaceholderType type = plugin.getPlaceholderAPIManager().getPlaceHolderType(player, placeholder);
sender.sendMessage(Jobs.getLanguage().getMessage("command.placeholders.output.parse",
"[placeholder]", placeholder,
"[source]", type == null ? "Unknown" : type.name(),
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, placeholder)));
Language.sendMessage(sender, "command.placeholders.output.parse",
"[placeholder]", placeholder,
"[source]", type == null ? "Unknown" : type.name(),
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, placeholder));
return true;
}
return true;
}
JobsPlaceHolders[] values = JobsPlaceHolders.values();
PageInfo pi = new PageInfo(isPlayer ? Jobs.getGCManager().PlaceholdersPage : values.length, values.length, page);
JobsPlaceHolders[] values = JobsPlaceHolders.values();
PageInfo pi = new PageInfo(isPlayer ? Jobs.getGCManager().PlaceholdersPage : values.length, values.length, page);
for (JobsPlaceHolders one : values) {
if (pi.isBreak())
break;
for (JobsPlaceHolders one : values) {
if (pi.isBreak())
break;
if (!pi.isEntryOk())
continue;
if (!pi.isEntryOk())
continue;
RawMessage rm = new RawMessage();
String extra = "";
RawMessage rm = new RawMessage();
String extra = "";
if (player != null && !one.isComplex())
extra = plugin.getPlaceholderAPIManager().updatePlaceHolders(player, Jobs.getLanguage().getMessage("command.placeholders.output.outputResult",
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, one.getFull())));
if (player != null && !one.isComplex())
extra = plugin.getPlaceholderAPIManager().updatePlaceHolders(player, Jobs.getLanguage().getMessage("command.placeholders.output.outputResult",
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, one.getFull())));
String place = one.getFull();
String hover = "";
if (plugin.isPlaceholderAPIEnabled()) {
hover = place = one.getFull();
}
// For MVdWPlaceholderAPI
// if (plugin.isMVdWPlaceholderAPIEnabled()) {
// if (!plugin.isPlaceholderAPIEnabled()) {
// place = one.getFull().substring(1, one.getFull().length() - 2);
// place = "{" + place + "}";
// }
// if (hover.isEmpty())
// hover = one.getFull();
// else
// hover += "\n" + "{" + one.getFull().substring(1, one.getFull().length() - 2) + "}";
// }
rm.addText(Jobs.getLanguage().getMessage("command.placeholders.output.list", "[place]", pi.getPositionForOutput(), "[placeholder]", place) + extra)
.addHover(hover).addSuggestion(one.getFull()).show(sender);
}
String place = one.getFull();
String hover = "";
if (plugin.isPlaceholderAPIEnabled()) {
hover = place = one.getFull();
}
rm.addText(Jobs.getLanguage().getMessage("command.placeholders.output.list", "[place]", pi.getPositionForOutput(), "[placeholder]", place) + extra)
.addHover(hover).addSuggestion(one.getFull()).show(sender);
}
if (player != null)
plugin.showPagination(sender, pi, "jobs placeholders", "-p:");
return true;
if (player != null)
pi.autoPagination(sender, "jobs placeholders", "-p:");
return true;
}
}

View File

@ -6,40 +6,40 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class playerinfo implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "playerinfo");
Jobs.getCommandManager().sendValidActions(sender);
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendValidActions(sender);
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
int page = 1;
String type = "";
if (args.length >= 3) {
try {
page = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
type = args[2];
}
}
int page = 1;
String type = "";
if (args.length >= 3) {
try {
page = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
type = args[2];
}
}
Jobs.getCommandManager().jobInfoMessage(sender, jPlayer, job, type, page);
return true;
Jobs.getCommandManager().jobInfoMessage(sender, jPlayer, job, type, page);
return true;
}
}

View File

@ -1,106 +0,0 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import net.Zrips.CMILib.Time.timeModifier;
public class pointboost implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "pointboost");
return true;
}
Double rate = null;
Long timeDuration = null;
String jobName = null;
boolean reset = false;
for (String one : args) {
if (one.equalsIgnoreCase("reset")) {
reset = true;
continue;
}
if (jobName == null) {
jobName = one;
continue;
}
if (rate == null) {
try {
rate = Double.parseDouble(one);
continue;
} catch (NumberFormatException e) {
}
}
try {
Long t = timeModifier.getTimeRangeFromString(one);
if (t != null)
timeDuration = t;
continue;
} catch (Exception e) {
}
}
if (!reset && rate == null || jobName == null) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return false;
}
if (rate == null)
rate = 1D;
if (timeDuration == null)
timeDuration = 0L;
if (!reset && jobName.equalsIgnoreCase("all")) {
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.POINTS, rate, timeDuration);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
return true;
}
if (reset) {
if (jobName.equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.POINTS, 1.0);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(jobName);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.POINTS, 1.0);
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", "%jobname%", job.getName()));
}
return true;
}
Job job = Jobs.getJob(jobName);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.POINTS, rate, timeDuration);
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
return true;
}
}

View File

@ -7,6 +7,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -14,37 +15,36 @@ import net.Zrips.CMILib.Messages.CMIMessages;
public class points implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "points");
return true;
}
if (args.length != 0 && args.length != 1) {
return false;
}
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.points", true)) {
return true;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
}
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.points", true)) {
return true;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
}
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "points");
return true;
}
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "points");
return true;
}
PlayerPoints pointInfo = jPlayer.getPointsData();
PlayerPoints pointInfo = jPlayer.getPointsData();
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.points.currentpoints", "%currentpoints%", (int) (pointInfo.getCurrentPoints() * 100) / 100D));
sender.sendMessage(Jobs.getLanguage().getMessage("command.points.totalpoints", "%totalpoints%", (int) (pointInfo.getTotalPoints() * 100) / 100D));
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
Language.sendMessage(sender, "general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
Language.sendMessage(sender, "command.points.currentpoints", "%currentpoints%", (int) (pointInfo.getCurrentPoints() * 100) / 100D);
Language.sendMessage(sender, "command.points.totalpoints", "%totalpoints%", (int) (pointInfo.getTotalPoints() * 100) / 100D);
Language.sendMessage(sender, "general.info.separator");
return true;
}
}

View File

@ -7,62 +7,62 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class promote implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "promote");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
// check if player already has the job
if (!jPlayer.isInJob(job))
return false;
// check if player already has the job
if (!jPlayer.isInJob(job))
return false;
try {
try {
int levelsGained = -1;
try {
levelsGained = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return false;
}
int levelsGained = -1;
try {
levelsGained = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return false;
}
boolean commands = false;
for (String one : args) {
if (one.equalsIgnoreCase("-cmd")) {
commands = true;
continue;
}
}
boolean commands = false;
for (String one : args) {
if (one.equalsIgnoreCase("-cmd")) {
commands = true;
continue;
}
}
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained, commands);
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained, commands);
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target",
"%jobname%", job.getDisplayName(),
"%levelsgained%", levelsGained));
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.promote.output.target",
"%jobname%", job.getDisplayName(),
"%levelsgained%", levelsGained);
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
Language.sendMessage(sender, "general.admin.success");
} catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
} catch (Throwable e) {
Language.sendMessage(sender, "general.admin.error");
}
return true;
}
}

View File

@ -14,7 +14,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Quest;
import com.gamingmesh.jobs.container.QuestObjective;
import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -24,128 +24,134 @@ import net.Zrips.CMILib.Time.CMITimeManager;
public class quests implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, String[] args) {
JobsPlayer jPlayer = null;
boolean isPlayer = sender instanceof Player;
public Boolean perform(Jobs plugin, final CommandSender sender, String[] args) {
if (args.length >= 1 && !args[0].equalsIgnoreCase("stop") && !args[0].equalsIgnoreCase("start")) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true))
return true;
if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return null;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (isPlayer)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
JobsPlayer jPlayer = null;
boolean isPlayer = sender instanceof Player;
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "quests");
return true;
}
if (args.length >= 1 && !args[0].equalsIgnoreCase("stop") && !args[0].equalsIgnoreCase("start")) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true))
return null;
List<QuestProgression> questProgs = jPlayer.getQuestProgressions();
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (isPlayer)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (questProgs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.error.noquests"));
return true;
}
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "quests");
return true;
}
if (args.length >= 1) {
Boolean stopped = null;
String cmd = args[args.length == 1 ? 0 : 1];
List<QuestProgression> questProgs = jPlayer.getQuestProgressions();
if (cmd.equalsIgnoreCase("stop") && Jobs.hasPermission(sender, "jobs.command.admin.quests.stop", false)) {
stopped = true;
} else if (cmd.equalsIgnoreCase("start") && Jobs.hasPermission(sender, "jobs.command.admin.quests.start", false)) {
stopped = false;
}
if (questProgs.isEmpty()) {
Language.sendMessage(sender, "command.quests.error.noquests");
return true;
}
if (stopped != null) {
for (QuestProgression q : questProgs) {
q.getQuest().setStopped(stopped);
}
if (args.length >= 1) {
Boolean stopped = null;
String cmd = args[args.length == 1 ? 0 : 1];
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.status.changed", "%status%",
stopped ? Jobs.getLanguage().getMessage("command.quests.status.stopped") : Jobs.getLanguage().getMessage("command.quests.status.started")));
return true;
}
}
if (cmd.equalsIgnoreCase("stop") && Jobs.hasPermission(sender, "jobs.command.admin.quests.stop", false)) {
stopped = true;
} else if (cmd.equalsIgnoreCase("start") && Jobs.hasPermission(sender, "jobs.command.admin.quests.start", false)) {
stopped = false;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests()));
if (stopped != null) {
for (QuestProgression q : questProgs) {
q.getQuest().setStopped(stopped);
}
for (JobProgression jobProg : jPlayer.progression) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
Language.sendMessage(sender, "command.quests.status.changed", "%status%",
stopped ? Jobs.getLanguage().getMessage("command.quests.status.stopped") : Jobs.getLanguage().getMessage("command.quests.status.started"));
return true;
}
}
for (QuestProgression q : list) {
int totalAmountNeeded = q.getTotalAmountNeeded();
int totalAmountDone = q.getTotalAmountDone();
Language.sendMessage(sender, "command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests());
String progressLine = Jobs.getCommandManager().jobProgressMessage(totalAmountNeeded, totalAmountDone);
for (JobProgression jobProg : jPlayer.progression) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
boolean completed = q.isCompleted();
for (QuestProgression q : list) {
int totalAmountNeeded = q.getTotalAmountNeeded();
int totalAmountDone = q.getTotalAmountDone();
if (completed)
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
String progressLine = Jobs.getCommandManager().jobProgressMessage(totalAmountNeeded, totalAmountDone);
Quest quest = q.getQuest();
boolean completed = q.isCompleted();
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
progressLine, "[questName]", quest.getQuestName(), "[done]", totalAmountDone, "[required]", totalAmountNeeded);
if (completed)
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
if (!isPlayer) {
sender.sendMessage(msg);
continue;
}
Quest quest = q.getQuest();
RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
progressLine, "[questName]", quest.getQuestName(), "[done]", totalAmountDone, "[required]", totalAmountNeeded);
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
List<String> hoverList = new ArrayList<>();
if (!isPlayer) {
sender.sendMessage(msg);
continue;
}
for (String current : hoverMsg.split("\n")) {
current = current.replace("[jobName]", jobProg.getJob().getName())
.replace("[time]", CMITimeManager.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
RawMessage rm = new RawMessage();
if (current.contains("[desc]")) {
hoverList.addAll(quest.getDescription());
} else {
hoverList.add(current);
}
}
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
List<String> hoverList = new ArrayList<>();
for (java.util.Map<String, QuestObjective> oneAction : quest.getObjectives().values()) {
for (Entry<String, QuestObjective> oneObjective : oneAction.entrySet()) {
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
Jobs.getNameTranslatorManager().translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
.getTargetMeta(), oneObjective.getValue().getTargetName())
+ " " + q.getAmountDone(oneObjective.getValue()) + "/"
+ oneObjective.getValue().getAmount());
}
}
for (String current : hoverMsg.split("\n")) {
current = current.replace("[jobName]", jobProg.getJob().getName())
.replace("[time]", CMITimeManager.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
String hover = "";
for (String one : hoverList) {
if (!hover.isEmpty())
hover += "\n";
if (current.contains("[desc]")) {
hoverList.addAll(quest.getDescription());
} else {
hoverList.add(current);
}
}
hover += one;
}
for (java.util.Map<String, QuestObjective> oneAction : quest.getObjectives().values()) {
for (Entry<String, QuestObjective> oneObjective : oneAction.entrySet()) {
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
Jobs.getNameTranslatorManager().translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
.getTargetMeta(), oneObjective.getValue().getTargetName())
+ " " + q.getAmountDone(oneObjective.getValue()) + "/"
+ oneObjective.getValue().getAmount());
}
}
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests() && !completed) {
if (Jobs.getGCManager().getDailyQuestsSkips() > 0) {
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skip");
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skips", "[skips]", (Jobs.getGCManager().getDailyQuestsSkips() - jPlayer.getSkippedQuests()));
}
rm.addText(msg).addHover(hover).addCommand("jobs skipquest " + jobProg.getJob().getName() + " " + quest.getConfigName() + " " + jPlayer.getName());
} else
rm.addText(msg).addHover(hover);
String hover = "";
for (String one : hoverList) {
if (!hover.isEmpty())
hover += "\n";
rm.show(sender);
}
}
hover += one;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests() && !completed) {
if (Jobs.getGCManager().getDailyQuestsSkips() > 0) {
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skip");
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skips", "[skips]", (Jobs.getGCManager().getDailyQuestsSkips() - jPlayer.getSkippedQuests()));
}
rm.addText(msg).addHover(hover).addCommand("jobs skipquest " + jobProg.getJob().getName() + " " + quest.getConfigName() + " " + jPlayer.getName());
} else
rm.addText(msg).addHover(hover);
rm.show(sender);
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
}
}

View File

@ -4,13 +4,14 @@ import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.i18n.Language;
public class reload implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Jobs.reload();
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
return true;
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Jobs.reload();
Language.sendMessage(sender, "general.admin.success");
return true;
}
}

View File

@ -7,52 +7,52 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class removexp implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "removexp");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
double xpLost = 0D;
try {
xpLost = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
return true;
}
if (xpLost <= 0 || xpLost > Double.MAX_VALUE) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
return true;
}
// check if player already has the job
if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost);
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return null;
}
double xpLost = 0D;
try {
xpLost = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
Language.sendMessage(sender, "general.admin.error");
return true;
}
if (xpLost <= 0 || xpLost > Double.MAX_VALUE) {
Language.sendMessage(sender, "general.admin.error");
return true;
}
// check if player already has the job
if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost);
Player player = jPlayer.getPlayer();
if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.removexp.output.target",
"%jobname%", job.getDisplayName(),
"%xplost%", xpLost));
}
Player player = jPlayer.getPlayer();
if (player != null) {
Language.sendMessage(player, "command.removexp.output.target",
"%jobname%", job.getDisplayName(),
"%xplost%", xpLost);
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
}
return true;
Language.sendMessage(sender, "general.admin.success");
}
return true;
}
}

View File

@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.i18n.Language;
public class resetexploreregion implements Cmd {
@ -11,25 +12,24 @@ public class resetexploreregion implements Cmd {
private static String REGEX = "^[0-9a-zA-Z_-]+$";
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length != 2 || !WORLD.equals(args[0])) {
Jobs.getCommandManager().sendUsage(sender, "resetexploreregion");
return true;
}
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length != 2 || !WORLD.equals(args[0])) {
return false;
}
if (!Jobs.getGCManager().resetExploringData) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.notenabled"));
return true;
}
if (!Jobs.getGCManager().resetExploringData) {
Language.sendMessage(sender, "command.resetexploreregion.output.notenabled");
return true;
}
final String worldName = args[1];
if (!worldName.matches(REGEX)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.invalidname"));
return true;
}
final String worldName = args[1];
if (!worldName.matches(REGEX)) {
Language.sendMessage(sender, "command.resetexploreregion.output.invalidname");
return true;
}
Jobs.getExploreManager().resetRegion(worldName);
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.reseted", "%worldname%", worldName));
return true;
Jobs.getExploreManager().resetRegion(worldName);
Language.sendMessage(sender, "command.resetexploreregion.output.reseted", "%worldname%", worldName);
return true;
}
}

View File

@ -4,36 +4,36 @@ import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class resetlimit implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "resetlimit");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 1) {
return false;
}
if (args[0].equalsIgnoreCase("all")) {
for (org.bukkit.entity.Player pl : org.bukkit.Bukkit.getOnlinePlayers()) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pl);
if (jPlayer != null) {
jPlayer.resetPaymentLimit();
}
}
if (args[0].equalsIgnoreCase("all")) {
for (org.bukkit.entity.Player pl : org.bukkit.Bukkit.getOnlinePlayers()) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pl);
if (jPlayer != null) {
jPlayer.resetPaymentLimit();
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", ""));
return true;
}
Language.sendMessage(sender, "command.resetlimit.output.reseted", "%playername%", "");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
jPlayer.resetPaymentLimit();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName()));
return true;
jPlayer.resetPaymentLimit();
Language.sendMessage(sender, "command.resetlimit.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
return true;
}
}

View File

@ -10,48 +10,56 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
public class resetquest implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0 && args.length != 1 && args.length != 2) {
Jobs.getCommandManager().sendUsage(sender, "resetquest");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
Job job = null;
if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return true;
}
for (String one : args) {
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(one);
}
if (args.length != 0 && args.length != 1 && args.length != 2) {
return false;
}
if (jPlayer == null && sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
JobsPlayer jPlayer = null;
Job job = null;
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : ""));
return true;
}
for (String one : args) {
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(one);
}
List<QuestProgression> quests = jPlayer.getQuestProgressions();
if (jPlayer == null && sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (job != null)
quests = jPlayer.getQuestProgressions(job);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "");
return true;
}
if (quests.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.noQuests"));
return true;
}
List<QuestProgression> quests = jPlayer.getQuestProgressions();
jPlayer.resetQuests(quests);
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getName()));
return true;
if (job != null)
quests = jPlayer.getQuestProgressions(job);
if (quests.isEmpty()) {
Language.sendMessage(sender, "command.resetquest.output.noQuests");
return true;
}
jPlayer.resetQuests(quests);
Language.sendMessage(sender, "command.resetquest.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getName());
return true;
}
}

View File

@ -10,49 +10,56 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
public class resetquesttotal implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "resetquesttotal");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return true;
}
if (args.length != 0 && args.length != 1) {
return false;
}
if (args.length > 0 && args[0].equalsIgnoreCase("all")) {
for (Entry<UUID, JobsPlayer> pl : Jobs.getPlayerManager().getPlayersCache().entrySet()) {
pl.getValue().setDoneQuests(0);
}
Jobs.getJobsDAO().resetDoneQuests();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquesttotal.output.reseted", "%playername%", Jobs.getPlayerManager().getPlayersCache().size()));
return true;
}
if (args.length > 0 && args[0].equalsIgnoreCase("all")) {
for (Entry<UUID, JobsPlayer> pl : Jobs.getPlayerManager().getPlayersCache().entrySet()) {
pl.getValue().setDoneQuests(0);
}
Jobs.getJobsDAO().resetDoneQuests();
Language.sendMessage(sender,"command.resetquesttotal.output.reseted", "%playername%", Jobs.getPlayerManager().getPlayersCache().size());
return true;
}
JobsPlayer jPlayer = null;
Job job = null;
JobsPlayer jPlayer = null;
Job job = null;
for (String one : args) {
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(one);
}
for (String one : args) {
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(one);
}
if (jPlayer == null && sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null && sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : ""));
return true;
}
if (jPlayer == null) {
Language.sendMessage(sender,"general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "");
return true;
}
jPlayer.setDoneQuests(0);
jPlayer.setSaved(false);
jPlayer.save();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquesttotal.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName()));
return true;
jPlayer.setDoneQuests(0);
jPlayer.setSaved(false);
jPlayer.save();
Language.sendMessage(sender,"command.resetquesttotal.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
return true;
}
}

View File

@ -9,14 +9,15 @@ import org.bukkit.configuration.file.FileConfiguration;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.i18n.Language;
public class schedule implements Cmd {
@Override
public boolean perform(final Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(final Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "schedule");
return true;
return null;
}
if (args[0].equalsIgnoreCase("enable")) {
@ -32,12 +33,12 @@ public class schedule implements Cmd {
ConfigurationSection path = c.getConfigurationSection("Boost." + name);
if (path == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.schedule.output.noScheduleFound"));
return false;
Language.sendMessage(sender,"command.schedule.output.noScheduleFound");
return null;
}
if (path.getBoolean("Enabled")) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.schedule.output.alreadyEnabled"));
Language.sendMessage(sender,"command.schedule.output.alreadyEnabled");
return true;
}
@ -63,7 +64,7 @@ public class schedule implements Cmd {
Jobs.getScheduleManager().load();
Jobs.getScheduleManager().start();
sender.sendMessage(Jobs.getLanguage().getMessage("command.schedule.output.enabled", "%until%", until, "%from%", from));
Language.sendMessage(sender,"command.schedule.output.enabled", "%until%", until, "%from%", from);
}
return true;

View File

@ -2,35 +2,39 @@ package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
public class shop implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return true;
}
if (!Jobs.getGCManager().jobsshopenabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return null;
}
if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "shop");
return true;
}
if (!(sender instanceof Player)) {
LC.info_Ingame.sendMessage(sender);
return null;
}
int page = 1;
if (args.length == 1)
try {
page = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
}
if (args.length != 0 && args.length != 1) {
return false;
}
Jobs.getShopManager().openShopGui((Player) sender, page);
return true;
int page = 1;
if (args.length == 1)
try {
page = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
}
Jobs.getShopManager().openShopGui((Player) sender, page);
return true;
}
}

View File

@ -6,40 +6,43 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.Signs.SignTopType;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
public class signupdate implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!Jobs.getGCManager().SignsEnabled)
return true;
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!Jobs.getGCManager().SignsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return null;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "signupdate");
return true;
}
if (args.length != 1) {
return false;
}
if (args[0].equalsIgnoreCase("all")) {
Jobs.getJobs().forEach(Jobs.getSignUtil()::signUpdate);
return true;
}
if (args[0].equalsIgnoreCase("all")) {
Jobs.getJobs().forEach(Jobs.getSignUtil()::signUpdate);
return true;
}
Job oldjob = Jobs.getJob(args[0]);
if (oldjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job oldjob = Jobs.getJob(args[0]);
if (oldjob == null) {
Language.sendMessage(sender, "general.error.job");
return null;
}
if (args.length == 2) {
SignTopType type = SignTopType.getType(args[1]);
if (type != null) {
Jobs.getSignUtil().signUpdate(oldjob, type);
}
if (args.length == 2) {
SignTopType type = SignTopType.getType(args[1]);
if (type != null) {
Jobs.getSignUtil().signUpdate(oldjob, type);
}
return true;
}
return true;
}
Jobs.getSignUtil().signUpdate(oldjob);
return true;
Jobs.getSignUtil().signUpdate(oldjob);
return true;
}
}

View File

@ -2,6 +2,7 @@ package com.gamingmesh.jobs.commands.list;
import java.util.List;
import com.gamingmesh.jobs.stuff.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -12,103 +13,128 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Quest;
import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.economy.BufferedEconomy;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class skipquest implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 2 && args.length != 3) {
Jobs.getCommandManager().sendUsage(sender, "skipquest");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return null;
}
// Needs to allow longer so multiword quest names work
if (args.length < 2) {
return false;
}
JobsPlayer jPlayer = null;
Job job = null;
String questName = "";
JobsPlayer jPlayer = null;
Job job = null;
String questName = "";
for (String one : args) {
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
if (jPlayer == null) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer(one);
if (jPlayer != null)
continue;
}
for (String one : args) {
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
if (jPlayer == null) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer(one);
if (jPlayer != null)
continue;
}
if (!questName.isEmpty())
questName += " ";
questName += one;
}
if (!questName.isEmpty())
questName += " ";
questName += one;
}
if (jPlayer == null && sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null && sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : ""));
return true;
}
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "");
return null;
}
List<QuestProgression> quests = jPlayer.getQuestProgressions();
List<QuestProgression> quests = jPlayer.getQuestProgressions();
if (job != null)
quests = jPlayer.getQuestProgressions(job);
if (job != null)
quests = jPlayer.getQuestProgressions(job);
if (quests == null || quests.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.noQuests"));
return true;
}
if (quests == null || quests.isEmpty()) {
Language.sendMessage(sender, "command.resetquest.output.noQuests");
return null;
}
Quest old = null;
Quest old = null;
for (QuestProgression one : quests) {
Quest q = one.getQuest();
for (QuestProgression one : quests) {
Quest q = one.getQuest();
if (q.getQuestName().equalsIgnoreCase(questName) || q.getConfigName().equalsIgnoreCase(questName)) {
old = q;
break;
}
}
if (q.getQuestName().equalsIgnoreCase(questName) || q.getConfigName().equalsIgnoreCase(questName)) {
old = q;
break;
}
}
if (old == null) {
return false;
}
if (old == null) {
return false;
}
// Do not skip the completed quests
for (QuestProgression q : quests) {
if (q.getQuest().getQuestName().equals(old.getQuestName()) && q.isCompleted()) {
return false;
}
}
// Do not skip the completed quests
for (QuestProgression q : quests) {
if (q.getQuest().getQuestName().equals(old.getQuestName()) && q.isCompleted()) {
return false;
}
}
if (Jobs.getGCManager().getDailyQuestsSkips() <= jPlayer.getSkippedQuests()) {
return false;
}
if (Jobs.getGCManager().getDailyQuestsSkips() <= jPlayer.getSkippedQuests()) {
return false;
}
double amount = Jobs.getGCManager().skipQuestCost;
BufferedEconomy econ = Jobs.getEconomy();
Player player = jPlayer.getPlayer();
double amount = Jobs.getGCManager().skipQuestCost;
BufferedEconomy econ = Jobs.getEconomy();
Player player = jPlayer.getPlayer();
if (amount > 0 && player != null) {
if (!econ.getEconomy().hasMoney(player, amount)) {
sender.sendMessage(Jobs.getLanguage().getMessage("economy.error.nomoney"));
return false;
}
if (amount > 0 && player != null) {
if (!econ.getEconomy().hasMoney(player, amount)) {
Language.sendMessage(sender, "economy.error.nomoney");
return null;
}
econ.getEconomy().withdrawPlayer(player, amount);
}
econ.getEconomy().withdrawPlayer(player, amount);
}
// Add confirmation if configured
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = jPlayer.getUniqueId();
jPlayer.replaceQuest(old);
if (!Util.SKIPCONFIRM.contains(uuid)) {
Util.SKIPCONFIRM.add(uuid);
if (player != null)
plugin.getServer().dispatchCommand(player, "jobs quests");
CMIScheduler.get().runTaskLater(() -> Util.SKIPCONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
if (amount > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.skipquest.output.questSkipForCost", "%amount%", amount));
}
Language.sendMessage(sender, "command.skipquest.confirmationNeed", "[questName]",
old.getQuestName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime);
return true;
}
return true;
Util.SKIPCONFIRM.remove(uuid);
}
jPlayer.replaceQuest(old);
if (player != null)
plugin.getServer().dispatchCommand(player, "jobs quests");
if (amount > 0) {
Language.sendMessage(sender, "command.skipquest.output.questSkipForCost", "%amount%", amount);
}
return true;
}
}

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobsCommands;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -16,42 +17,42 @@ import net.Zrips.CMILib.RawMessages.RawMessage;
public class stats implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.stats", true))
return true;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.stats", true))
return true;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "stats");
return true;
}
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "stats");
return true;
}
if (jPlayer.progression.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.stats.error.nojob"));
return true;
}
if (jPlayer.progression.isEmpty()) {
Language.sendMessage(sender, "command.stats.error.nojob");
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName()));
Language.sendMessage(sender, "general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
String leftClick = Jobs.getLanguage().getMessage("command.info.gui.leftClick");
String leftClick = Jobs.getLanguage().getMessage("command.info.gui.leftClick");
String pref = JobsCommands.LABEL + " " + info.class.getSimpleName() + " ";
String pref = JobsCommands.LABEL + " " + info.class.getSimpleName() + " ";
for (JobProgression jobProg : jPlayer.getJobProgression()) {
for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg).split("\n")) {
new RawMessage().addText(msg).addHover(leftClick).addCommand(pref + jobProg.getJob().getName()).show(sender);
}
}
for (JobProgression jobProg : jPlayer.getJobProgression()) {
for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg, sender instanceof Player).split("\n")) {
new RawMessage().addText(msg).addHover(leftClick).addCommand(pref + jobProg.getJob().getName()).show(sender);
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
Language.sendMessage(sender, "general.info.separator");
return true;
}
}

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
import net.Zrips.CMILib.Locale.LC;
@ -15,49 +16,48 @@ import net.Zrips.CMILib.Messages.CMIMessages;
public class toggle implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
boolean isBossbar = false, isActionbar = false;
if (args.length != 1 || (!(isBossbar = args[0].equalsIgnoreCase("bossbar")) && !(isActionbar = args[0].equalsIgnoreCase("actionbar")))) {
Jobs.getCommandManager().sendUsage(sender, "toggle");
return true;
}
boolean isBossbar = false, isActionbar = false;
if (args.length != 1 || (!(isBossbar = args[0].equalsIgnoreCase("bossbar")) && !(isActionbar = args[0].equalsIgnoreCase("actionbar")))) {
return false;
}
Player player = (Player) sender;
String playerUUID = player.getUniqueId().toString();
Player player = (Player) sender;
String playerUUID = player.getUniqueId().toString();
if (isActionbar) {
Boolean ex = ToggleBarHandling.getActionBarToggle().get(playerUUID);
if (isActionbar) {
Boolean ex = ToggleBarHandling.getActionBarToggle().get(playerUUID);
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
} else {
ToggleBarHandling.getActionBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
}
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
Language.sendMessage(sender, "command.toggle.output.off");
} else {
ToggleBarHandling.getActionBarToggle().put(playerUUID, true);
Language.sendMessage(sender, "command.toggle.output.on");
}
}
if (isBossbar) {
Boolean ex = ToggleBarHandling.getBossBarToggle().get(playerUUID);
if (isBossbar) {
Boolean ex = ToggleBarHandling.getBossBarToggle().get(playerUUID);
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
Language.sendMessage(sender, "command.toggle.output.off");
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
if (jPlayer != null)
jPlayer.hideBossBars();
} else {
ToggleBarHandling.getBossBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
if (jPlayer != null)
jPlayer.hideBossBars();
} else {
ToggleBarHandling.getBossBarToggle().put(playerUUID, true);
Language.sendMessage(sender, "command.toggle.output.on");
}
}
return true;
return true;
}
}

View File

@ -11,6 +11,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Locale.LC;
@ -20,84 +21,81 @@ import net.Zrips.CMILib.Scoreboards.CMIScoreboard;
public class top implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 1 && args.length != 2) {
Jobs.getCommandManager().sendUsage(sender, "top");
return false;
}
if (args.length != 1 && args.length != 2) {
return false;
}
Player player = (Player) sender;
if (args[0].equalsIgnoreCase("clear")) {
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
CMIScoreboard.removeScoreBoard(player);
return true;
}
Player player = sender instanceof Player ? (Player) sender : null;
int page = 1;
if (args.length == 2) {
try {
page = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
return true;
}
}
if (page < 1)
page = 1;
if (args[0].equalsIgnoreCase("clear")) {
if (player != null) {
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
CMIScoreboard.removeScoreBoard(player);
}
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.top.error.nojob"));
return false;
}
int page = 1;
if (args.length == 2) {
try {
page = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
return false;
}
}
if (page < 1)
page = 1;
int workingIn = Jobs.getUsedSlots(job);
PageInfo pi = new PageInfo(Jobs.getGCManager().JobsTopAmount, workingIn, page);
Job job = Jobs.getJob(args[0]);
if (job == null) {
Language.sendMessage(sender, "command.top.error.nojob");
return null;
}
List<TopList> fullList = Jobs.getJobsDAO().toplist(job.getName(), pi.getStart());
if (fullList.isEmpty()) {
CMIMessages.sendMessage(sender, LC.info_NoInformation);
return true;
}
int workingIn = Jobs.getUsedSlots(job);
PageInfo pi = new PageInfo(Jobs.getGCManager().JobsTopAmount, workingIn, page);
player.sendMessage(Jobs.getLanguage().getMessage("command.top.help.info"));
List<TopList> fullList = Jobs.getJobsDAO().toplist(job.getName(), pi.getStart());
if (fullList.isEmpty()) {
CMIMessages.sendMessage(sender, LC.info_NoInformation);
return true;
}
int place = 1;
int place = 1;
if (!Jobs.getGCManager().ShowToplistInScoreboard) {
player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.topline", "%jobname%", job.getName(), "%amount%", Jobs.getGCManager().JobsTopAmount));
for (TopList one : fullList) {
if (place > Jobs.getGCManager().JobsTopAmount)
break;
if (!Jobs.getGCManager().ShowToplistInScoreboard || player == null) {
Language.sendMessage(sender, "command.top.output.topline", "%jobname%", job.getName(), "%amount%", Jobs.getGCManager().JobsTopAmount);
player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.list",
"%number%", ((page - 1) * Jobs.getGCManager().JobsTopAmount) + place,
"%playername%", one.getPlayerInfo().getName(),
"%playerdisplayname%", one.getPlayerInfo().getDisplayName(),
"%level%", one.getLevel(),
"%exp%", one.getExp()));
place++;
}
plugin.showPagination(sender, pi, "jobs top " + job.getName());
} else {
List<String> ls = new ArrayList<>();
for (TopList one : fullList) {
if (place > Jobs.getGCManager().JobsTopAmount)
break;
for (TopList one : fullList) {
if (place > Jobs.getGCManager().JobsTopAmount)
break;
ls.add(Jobs.getLanguage().getMessage("scoreboard.line", "%number%", ((page - 1) * Jobs.getGCManager().JobsTopAmount) + place,
"%playername%", one.getPlayerInfo().getName(), "%playerdisplayname%", one.getPlayerInfo().getDisplayName(), "%level%", one.getLevel()));
place++;
}
Language.sendMessage(sender, "command.top.output.list",
"%number%", ((page - 1) * Jobs.getGCManager().JobsTopAmount) + place,
"%playername%", one.getPlayerInfo().getName(),
"%playerdisplayname%", one.getPlayerInfo().getDisplayName(),
"%level%", one.getLevel(),
"%exp%", one.getExp());
place++;
}
pi.autoPagination(sender, "jobs top " + job.getName());
} else {
List<String> ls = new ArrayList<>();
CMIScoreboard.show(player, Jobs.getLanguage().getMessage("scoreboard.topline", "%jobname%", job.getName()), ls, Jobs.getGCManager().ToplistInScoreboardInterval);
for (TopList one : fullList) {
if (place > Jobs.getGCManager().JobsTopAmount)
break;
ls.add(Jobs.getLanguage().getMessage("scoreboard.line", "%number%", ((page - 1) * Jobs.getGCManager().JobsTopAmount) + place,
"%playername%", one.getPlayerInfo().getName(), "%playerdisplayname%", one.getPlayerInfo().getDisplayName(), "%level%", one.getLevel()));
place++;
}
plugin.showPagination(sender, pi, "jobs top " + job.getName());
}
return true;
CMIScoreboard.show(player, Jobs.getLanguage().getMessage("scoreboard.topline", "%jobname%", job.getName()), ls, Jobs.getGCManager().ToplistInScoreboardInterval);
pi.autoPagination(sender, "jobs top " + job.getName());
}
return true;
}
}

View File

@ -7,51 +7,50 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class transfer implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "transfer");
return true;
}
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job oldjob = Jobs.getJob(args[1]);
if (oldjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job oldjob = Jobs.getJob(args[1]);
if (oldjob == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
Job newjob = Jobs.getJob(args[2]);
if (newjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job newjob = Jobs.getJob(args[2]);
if (newjob == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
try {
if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) {
Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob);
try {
if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) {
Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob);
Player player = jPlayer.getPlayer();
if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.transfer.output.target",
"%oldjobname%", oldjob.getDisplayName(),
"%newjobname%", newjob.getDisplayName()));
}
Player player = jPlayer.getPlayer();
if (player != null) {
Language.sendMessage(player, "command.transfer.output.target",
"%oldjobname%", oldjob.getDisplayName(),
"%newjobname%", newjob.getDisplayName());
}
Language.sendMessage(sender, "general.admin.success");
}
} catch (Exception e) {
Language.sendMessage(sender, "general.admin.error");
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
}
} catch (Exception e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
return true;
}
}

View File

@ -13,14 +13,15 @@ import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Util.CMIVersionChecker;
import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
import net.milkbowl.vault.economy.Economy;
public class version implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
CMIScheduler.get().runTaskAsynchronously(new Runnable() {
@Override
public void run() {
@ -62,7 +63,7 @@ public class version implements Cmd {
final String vault = preVault;
final String vaultProvider = vProvider;
Bukkit.getScheduler().runTask(plugin, new Runnable() {
CMIScheduler.get().runTask(new Runnable() {
@Override
public void run() {

View File

@ -16,7 +16,7 @@ import com.gamingmesh.jobs.container.DBAction;
import net.Zrips.CMILib.Container.CMIBlock;
import net.Zrips.CMILib.Container.CMIBlock.Bisect;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class BlockProtectionManager {
@ -40,7 +40,7 @@ public class BlockProtectionManager {
}
public void add(Block block, Integer cd) {
if (cd == null || cd == 0)
return;
@ -80,9 +80,9 @@ public class BlockProtectionManager {
public BlockProtection addP(Location loc, Long time, boolean paid, boolean cache) {
if (time == 0)
if (time == null || time == 0)
return null;
String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
HashMap<String, HashMap<String, HashMap<String, BlockProtection>>> regions = map.getOrDefault(loc.getWorld(), new HashMap<>());
@ -98,8 +98,8 @@ public class BlockProtectionManager {
Bp = new BlockProtection(DBAction.INSERT, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
else {
Bp.setAction(DBAction.UPDATE);
if (Bp.getSchedId() > -1)
Bukkit.getServer().getScheduler().cancelTask(Bp.getSchedId());
if (Bp.getScheduler() != null)
Bp.getScheduler().cancel();
}
Bp.setPaid(paid);
@ -107,7 +107,7 @@ public class BlockProtectionManager {
// If timer is under 2 hours, we can run scheduler to remove it when time comes
if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2)
Bp.setSchedId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), () -> {
Bp.setScheduler(CMIScheduler.get().runTaskLater(() -> {
remove(loc);
}, (time - System.currentTimeMillis()) / 50));
@ -117,7 +117,7 @@ public class BlockProtectionManager {
map.put(loc.getWorld(), regions);
// Only saving into save cache if timer is higher than 5 minutes
if (cache && ((time - System.currentTimeMillis()) / 1000 > 60 * 5 || time < 0) )
if (cache && ((time - System.currentTimeMillis()) / 1000 > 60 * 5 || time < 0))
addToCache(loc, Bp);
return Bp;
}
@ -187,7 +187,7 @@ public class BlockProtectionManager {
world.remove(locToRegion(loc));
return bp;
}
}
public Long getTime(Block block) {
return getTime(block.getLocation());

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class BossBarManager {
@ -36,7 +37,7 @@ public class BossBarManager {
public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) {
if (Jobs.getGCManager().isBossBarAsync()) {
Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () -> ShowJobProgressionInTask(player, jobProg, expGain));
CMIScheduler.get().runTaskAsynchronously(() -> ShowJobProgressionInTask(player, jobProg, expGain));
} else {
ShowJobProgressionInTask(player, jobProg, expGain);
}
@ -139,7 +140,7 @@ public class BossBarManager {
bar.setVisible(true);
if (oldOne != null)
oldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
oldOne.setScheduler(CMIScheduler.get().runTaskLater(new Runnable() {
@Override
public void run() {
for (BossBarInfo one : player.getBossBarInfo()) {

View File

@ -60,7 +60,7 @@ import net.Zrips.CMILib.Equations.ParseError;
import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Version;
public class ConfigManager {
@ -965,7 +965,7 @@ public class ConfigManager {
Jobs.setJobs(jobs);
if (!jobs.isEmpty()) {
Jobs.consoleMsg("&eLoaded &6" + jobs.size() + " &ejobs");
CMIMessages.consoleMessage("&eLoaded &6" + jobs.size() + " &ejobs");
}
ItemBoostManager.load();
@ -1315,7 +1315,7 @@ public class ConfigManager {
jobItems.put(node.toLowerCase(), new JobItems(node, CMIMaterial.get(id), 1, name, lore, enchants, b, new ArrayList<Job>()));
}
Jobs.consoleMsg("&cRemove Items section from " + jobKey + " job, as of Jobs 4.10.0 version this was moved to boostedItems.yml file!");
CMIMessages.consoleMessage("&cRemove Items section from " + jobKey + " job, as of Jobs 4.10.0 version this was moved to boostedItems.yml file!");
}
// Limited Items
@ -1416,8 +1416,8 @@ public class ConfigManager {
}
}
for (String oneObjective : sqsection.getStringList("Objectives")) {
List<QuestObjective> objectives = QuestObjective.get(oneObjective, jobFullName);
for (String oneObjective : sqsection.getStringList("Objectives")) {
List<QuestObjective> objectives = QuestObjective.get(oneObjective, jobFullName);
quest.addObjectives(objectives);
}
@ -1435,13 +1435,13 @@ public class ConfigManager {
quests.add(quest);
} catch (Exception e) {
Jobs.consoleMsg("&cCan't load &6" + one + " &cquest for &6" + jobFullName);
CMIMessages.consoleMessage("&cCan't load &6" + one + " &cquest for &6" + jobFullName);
e.printStackTrace();
}
}
job.setQuests(quests);
Jobs.consoleMsg("&eLoaded &6" + quests.size() + " &equests for &6" + jobFullName);
CMIMessages.consoleMessage("&eLoaded &6" + quests.size() + " &equests for &6" + jobFullName);
}
job.setMaxDailyQuests(jobSection.getInt("maxDailyQuests", 1));

View File

@ -17,7 +17,7 @@ import com.gamingmesh.jobs.container.JobsWorld;
import com.gamingmesh.jobs.dao.JobsDAO.ExploreDataTableFields;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
public class ExploreManager {
@ -48,11 +48,11 @@ public class ExploreManager {
if (!exploreEnabled)
return;
Jobs.consoleMsg("&eLoading explorer data");
CMIMessages.consoleMessage("&eLoading explorer data");
Long time = System.currentTimeMillis();
Jobs.getJobsDAO().loadExplore();
int size = getSize();
Jobs.consoleMsg("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : " ") + " in " + (System.currentTimeMillis() - time) + " ms");
CMIMessages.consoleMessage("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : " ") + " in " + (System.currentTimeMillis() - time) + " ms");
}
public Map<String, Map<String, ExploreRegion>> getWorlds() {
@ -149,17 +149,17 @@ public class ExploreManager {
}
public void resetRegion(String worldname) {
Jobs.consoleMsg("&eReseting explorer data. World: " + worldname);
CMIMessages.consoleMessage("&eReseting explorer data. World: " + worldname);
Map<String, Map<String, ExploreRegion>> worlds = getWorlds();
worlds.put(worldname, new HashMap<String, ExploreRegion>());
boolean r = Jobs.getJobsDAO().deleteExploredWorld(worldname);
if (!r) {
Jobs.consoleMsg("&eFailed in DAO.");
CMIMessages.consoleMessage("&eFailed in DAO.");
return;
}
Jobs.consoleMsg("&eCompleted to reset explorer data.");
CMIMessages.consoleMessage("&eCompleted to reset explorer data.");
}
}

View File

@ -40,12 +40,12 @@ import com.gamingmesh.jobs.container.CurrencyLimit;
import com.gamingmesh.jobs.container.CurrencyType;
import net.Zrips.CMILib.CMILib;
import net.Zrips.CMILib.Container.CMIArray;
import net.Zrips.CMILib.Container.CMIList;
import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Version;
public class GeneralConfigManager {
@ -95,7 +95,8 @@ public class GeneralConfigManager {
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames,
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps, informOnPaymentDisable,
BrowseUseNewLook, payExploringWhenGliding = false, resetExploringData = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding,
boostedItemsInOffHand = false, boostedItemsInMainHand, boostedArmorItems, boostedItemsSlotSpecific, multiplyBoostedExtraValues, addPermissionBoost, highestPermissionBoost /*, preventCropResizePayment*/,
boostedItemsInOffHand = false, boostedItemsInMainHand, boostedArmorItems, boostedItemsSlotSpecific, multiplyBoostedExtraValues, addPermissionBoost,
highestPermissionBoost,
payItemDurabilityLoss,
applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useMinimumOveralExp, useBreederFinder,
CancelCowMilking, fixAtMaxLevel, TitleChangeChat, TitleChangeActionBar, LevelChangeChat,
@ -106,9 +107,12 @@ public class GeneralConfigManager {
EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve, blockOwnershipTakeOver,
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel, RomanNumbers,
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
DisabledWorldsUse, UseAsWhiteListWorldList, MythicMobsEnabled,
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false,
payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false, preventShopItemEnchanting;
public boolean jobsshopenabled;
public boolean DailyQuestsEnabled;
public ItemStack guiInfoButton;
public int InfoButtonSlot = 9;
@ -419,6 +423,9 @@ public class GeneralConfigManager {
c.addComment("broadcast.on-level-up.levels", "For what levels you want to broadcast message? Keep it at 0 if you want for all of them");
BroadcastingLevelUpLevels = c.getIntList("broadcast.on-level-up.levels", Arrays.asList(0));
c.addComment("DailyQuests.Enabled", "Enables or disables daily quests");
DailyQuestsEnabled = c.get("DailyQuests.Enabled", true);
c.addComment("DailyQuests.ResetTime", "Defines time in 24hour format when we want to give out new daily quests",
"Any daily quests given before reset will be invalid and new ones will be given out");
ResetTimeHour = c.get("DailyQuests.ResetTime.Hour", 4);
@ -449,6 +456,9 @@ public class GeneralConfigManager {
c.addComment("prevent-shop-item-enchanting", "Prevent players to enchant items from the shop in the anvil with enchanted books");
preventShopItemEnchanting = c.get("prevent-shop-item-enchanting", true);
c.addComment("jobs-shop-enabled", "Enables or disables jobs shop");
jobsshopenabled = c.get("jobs-shop-enabled", true);
c.addComment("enable-pay-near-spawner",
"Option to allow payment to be made when killing mobs from a spawner.",
@ -543,7 +553,7 @@ public class GeneralConfigManager {
CMIMaterial mat = CMIMaterial.get(mName);
if (mat == CMIMaterial.NONE) {
Jobs.consoleMsg("Failed to recognize " + one + " entry from config file");
CMIMessages.consoleMessage("Failed to recognize " + one + " entry from config file");
continue;
}
@ -585,9 +595,10 @@ public class GeneralConfigManager {
c.addComment("Economy.PaymentMethods",
"By disabling one of these, players no longer will get particular payment.",
"Useful for removing particular payment method without editing whole jobConfig file");
PaymentMethodsMoney = c.get("Economy.PaymentMethods.Money", true);
PaymentMethodsPoints = c.get("Economy.PaymentMethods.Points", true);
PaymentMethodsExp = c.get("Economy.PaymentMethods.Exp", true);
for (CurrencyType one : CurrencyType.values()) {
one.setEnabled(c.get("Economy.PaymentMethods." + one.getName(), true));
}
c.addComment("Economy.GeneralMulti",
"Can be used to change payment amounts for all jobs and all actions if you want to readjust them",
@ -644,7 +655,7 @@ public class GeneralConfigManager {
DynamicPaymentEquation.setVariable("totaljobs", 10);
DynamicPaymentEquation.setVariable("jobstotalplayers", 10);
} catch (Throwable e) {
Jobs.consoleMsg("&cDynamic payment equation has an invalid property. Disabling feature!");
CMIMessages.consoleMessage("&cDynamic payment equation has an invalid property. Disabling feature!");
useDynamicPayment = false;
}
@ -702,8 +713,14 @@ public class GeneralConfigManager {
Jobs.getPluginLogger().warning("MoneyLimit has an invalid value. Disabling money limit!");
limit.setEnabled(false);
}
c.addComment("Economy.Limit.Money.TimeLimit", "Time in seconds: 60 = 1 min, 3600 = 1 hour, 86400 = 24 hours");
limit.setTimeLimit(c.get("Economy.Limit.Money.TimeLimit", 3600));
c.addComment("Economy.Limit.Money.ResetTime", "Time in 24 hour format when limit should reset. This will override TimeLimit if defined",
"Example: '00:00:00' will reset timer at midnight, '04:30:00' will reset at 4:30 in the morning", "Set to empty field if you want to use TimeLimit");
limit.setResetsAt(c.get("Economy.Limit.Money.ResetTime", ""));
c.addComment("Economy.Limit.Money.AnnouncementDelay", "Delay between announcements about reached money limit",
"Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
limit.setAnnouncementDelay(c.get("Economy.Limit.Money.AnnouncementDelay", 30));
@ -736,6 +753,11 @@ public class GeneralConfigManager {
}
c.addComment("Economy.Limit.Point.TimeLimit", "Time in seconds: 60 = 1 min, 3600 = 1 hour, 86400 = 24 hours");
limit.setTimeLimit(c.get("Economy.Limit.Point.TimeLimit", 3600));
c.addComment("Economy.Limit.Point.ResetTime", "Time in 24 hour format when limit should reset. This will override TimeLimit if defined",
"Example: '00:00:00' will reset timer at midnight, '04:30:00' will reset at 4:30 in the morning", "Set to empty field if you want to use TimeLimit");
limit.setResetsAt(c.get("Economy.Limit.Point.ResetTime", ""));
c.addComment("Economy.Limit.Point.AnnouncementDelay", "Delay between announcements about reached limit",
"Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
limit.setAnnouncementDelay(c.get("Economy.Limit.Point.AnnouncementDelay", 30));
@ -768,6 +790,11 @@ public class GeneralConfigManager {
}
c.addComment("Economy.Limit.Exp.TimeLimit", "Time in seconds: 60 = 1 min, 3600 = 1 hour, 86400 = 24 hours");
limit.setTimeLimit(c.get("Economy.Limit.Exp.TimeLimit", 3600));
c.addComment("Economy.Limit.Exp.ResetTime", "Time in 24 hour format when limit should reset. This will override TimeLimit if defined",
"Example: '00:00:00' will reset timer at midnight, '04:30:00' will reset at 4:30 in the morning", "Set to empty field if you want to use TimeLimit");
limit.setResetsAt(c.get("Economy.Limit.Exp.ResetTime", ""));
c.addComment("Economy.Limit.Exp.AnnouncementDelay", "Delay between announcements about reached Exp limit",
"Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
limit.setAnnouncementDelay(c.get("Economy.Limit.Exp.AnnouncementDelay", 30));

View File

@ -7,6 +7,7 @@ import java.util.Iterator;
import java.util.List;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.FileHandler.ConfigReader;
@ -79,6 +80,19 @@ public class LanguageManager {
c.get("limitedItem.error.levelup", "&cYou need to level up in [jobname] to use this item!");
c.get("general.info.toplineseparator", "&7*********************** &6%playerdisplayname% &7***********************");
c.get("general.info.separator", "&7*******************************************************");
for (CurrencyType curr : CurrencyType.values()) {
c.get("general.info.paymentType." + curr.toString(), curr.getName());
String color = "&2";
if (curr.equals(CurrencyType.POINTS))
color = "&6";
else if (curr.equals(CurrencyType.EXP))
color = "&e";
c.get("general.info.paymentTypeValued." + curr.toString(), color + curr.getName() + ": %amount%");
}
c.get("general.info.invalidPage", "&cInvalid page");
c.get("general.info.blocks.furnace", "Furnace");
c.get("general.info.blocks.smoker", "Smoker");
@ -107,35 +121,17 @@ public class LanguageManager {
c.get("command.help.output.title", "&e-------&e ======= &6Jobs &e======= &e-------");
c.get("command.moneyboost.help.info", "Boosts money gain for all players");
c.get("command.moneyboost.help.args", "[jobname]/all/reset [time]/[rate]");
Jobs.getGCManager().getCommandArgs().put("moneyboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%2", "%%2"));
c.get("command.moneyboost.output.allreset", "All money boosts turned off");
c.get("command.moneyboost.output.jobsboostreset", "Money boost has been turned off for %jobname%");
c.get("command.moneyboost.output.nothingtoreset", "Nothing to reset");
c.get("command.moneyboost.output.boostalladded", "Money boost of %boost% added for all jobs!");
c.get("command.moneyboost.output.boostadded", "Money boost of &e%boost% &aadded for &e%jobname%!");
c.get("command.moneyboost.output.infostats", "&c-----> &aMoney rate x%boost% enabled&c <-------");
c.get("command.pointboost.help.info", "Boosts point gain for all players");
c.get("command.pointboost.help.args", "[jobname]/all/reset [time]/[rate]");
Jobs.getGCManager().getCommandArgs().put("pointboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%2", "%%2"));
c.get("command.pointboost.output.allreset", "All point boosts turned off");
c.get("command.pointboost.output.jobsboostreset", "Point boost has been turned off for %jobname%");
c.get("command.pointboost.output.nothingtoreset", "Nothing to reset");
c.get("command.pointboost.output.boostalladded", "Points boost of %boost% added for all jobs!");
c.get("command.pointboost.output.boostadded", "Points boost of &e%boost% &aadded for &e%jobname%!");
c.get("command.pointboost.output.infostats", "&c-----> &aPoints rate x%boost% enabled&c <-------");
c.get("command.expboost.help.info", "Boosts exp gain for all players");
c.get("command.expboost.help.args", "[jobname]/all/reset [time]/[rate]");
Jobs.getGCManager().getCommandArgs().put("expboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%2", "%%2"));
c.get("command.expboost.output.allreset", "All exp boosts turned off");
c.get("command.expboost.output.jobsboostreset", "Exp boost has been turned off for %jobname%");
c.get("command.expboost.output.nothingtoreset", "Nothing to reset");
c.get("command.expboost.output.boostalladded", "Exp boost of %boost% added for all jobs!");
c.get("command.expboost.output.boostadded", "Exp boost of &e%boost% &aadded for &e%jobname%!");
c.get("command.expboost.output.infostats", "&c-----> &aExp rate x%boost% enabled&c <-------");
c.get("command.boost.help.info", "Boosts jobs gains for all players");
c.get("command.boost.help.args", "exp/money/points [jobname]/all/reset [rate] [time]");
Jobs.getGCManager().getCommandArgs().put("boost", Arrays.asList("[jobname]", "reset%%exp%%money%%points", "[time]%%2", "%%2"));
c.get("command.boost.output.allreset", "&aAll boosts turned off");
c.get("command.boost.output.alltypereset", "&aAll &e%type% &aboosts turned off");
c.get("command.boost.output.jobsboostreset", "&aBoost has been turned off for &e%jobname%");
c.get("command.boost.output.jobstypeboostreset", "&e%type% &aboost has been turned off for &e%jobname%");
c.get("command.boost.output.nothingtoreset", "Nothing to reset");
c.get("command.boost.output.boostadded", "&aBoost of &e%boost% &aadded for &e%jobname%!");
c.get("command.boost.output.infostats", "&c-----> &a%type% rate x%boost% enabled&c <-------");
c.get("command.boost.output.boostStats", "&6%payments% &e%jobname%");
c.get("command.schedule.help.info", "Enables the given scheduler");
c.get("command.schedule.help.args", "enable [scheduleName] [untilTime]");
@ -248,9 +244,9 @@ public class LanguageManager {
c.get("command.editjobs.help.modify.lookHover", "&6Press to grab info from block you are looking");
c.get("command.editquests.help.info", "Edit job quests.");
c.get("command.editquests.help.args", "(page)");
c.get("command.editquests.help.args", "(page)");
c.get("command.editquests.help.output.list", "&6[questName] &7- &f[jobName]");
c.get("command.editquests.help.output.name", "&eName: &f");
c.get("command.editquests.help.output.job", " &eJob: &f");
c.get("command.editquests.help.output.chance", " &eChance: &f");
@ -301,11 +297,11 @@ public class LanguageManager {
c.get("command.shop.help.info", "Opens special jobs shop.");
c.get("command.shop.help.args", "");
c.get("command.shop.info.title", "&e------- &8Jobs shop &e-------");
c.get("command.shop.info.haveColor", "&2");
c.get("command.shop.info.pointsPrice", "&ePoint cost: &c%currentpoints%&e/&6%price%");
c.get("command.shop.info.moneyPrice", "&eMoney cost: &c%currentbalance%&e/&6%price%");
c.get("command.shop.info.reqJobs", "&eRequired jobs:");
c.get("command.shop.info.reqJobsList", " &6%jobsname%&e: &e%level% lvl");
c.get("command.shop.info.reqTotalLevel", "&6Required total level: &e%totalLevel%");
@ -486,6 +482,7 @@ public class LanguageManager {
c.get("command.skipquest.help.info", "Skip defined quest and get new one");
c.get("command.skipquest.help.args", "[jobname] [questname] (playerName)");
c.get("command.skipquest.output.questSkipForCost", "&2You skipped the quest and paid:&e %amount%$");
c.get("command.skipquest.confirmationNeed", "&cAre you sure you want to skip&e [questName]&c quest? Type the command again within&6 [time] seconds &cto confirm!");
Jobs.getGCManager().getCommandArgs().put("skipquest", Arrays.asList("[jobname]", "[questname]", "[playername]"));
c.get("command.quests.help.info", "List available quests");

View File

@ -26,7 +26,7 @@ import net.Zrips.CMILib.Container.CMIText;
import net.Zrips.CMILib.Entities.CMIEntityType;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
public class NameTranslatorManager {
@ -231,9 +231,9 @@ public class NameTranslatorManager {
}
if (listOfNames.size() > 0)
Jobs.consoleMsg("&eLoaded &6" + listOfNames.size() + " &ecustom item names");
CMIMessages.consoleMessage("&eLoaded &6" + listOfNames.size() + " &ecustom item names");
} else
Jobs.consoleMsg("&cThe ItemList section not found in &6" + itemFile.fileName + " &cfile.");
CMIMessages.consoleMessage("&cThe ItemList section not found in &6" + itemFile.fileName + " &cfile.");
if ((section = itemFile.getConfig().getConfigurationSection("EntityList")) != null) {
listOfEntities.clear();
@ -252,9 +252,9 @@ public class NameTranslatorManager {
}
if (!listOfEntities.isEmpty())
Jobs.consoleMsg("&eLoaded &6" + listOfEntities.size() + " &ecustom entity names");
CMIMessages.consoleMessage("&eLoaded &6" + listOfEntities.size() + " &ecustom entity names");
} else
Jobs.consoleMsg("&cThe EntityList section not found in &6" + itemFile.fileName + " &cfile.");
CMIMessages.consoleMessage("&cThe EntityList section not found in &6" + itemFile.fileName + " &cfile.");
if ((section = itemFile.getConfig().getConfigurationSection("MythicEntityList")) != null) {
listOfMMEntities.clear();
@ -265,9 +265,9 @@ public class NameTranslatorManager {
}
if (listOfMMEntities.size() > 0)
Jobs.consoleMsg("&eLoaded &6" + listOfMMEntities.size() + " &ecustom MythicMobs names");
CMIMessages.consoleMessage("&eLoaded &6" + listOfMMEntities.size() + " &ecustom MythicMobs names");
} else
Jobs.consoleMsg("&cThe MythicEntityList section not found in &6" + itemFile.fileName + " &cfile.");
CMIMessages.consoleMessage("&cThe MythicEntityList section not found in &6" + itemFile.fileName + " &cfile.");
if ((section = itemFile.getConfig().getConfigurationSection("EnchantList")) != null) {
listOfEnchants.clear();
@ -277,9 +277,9 @@ public class NameTranslatorManager {
}
if (listOfEnchants.size() > 0)
Jobs.consoleMsg("&eLoaded &6" + listOfEnchants.size() + " &ecustom enchant names");
CMIMessages.consoleMessage("&eLoaded &6" + listOfEnchants.size() + " &ecustom enchant names");
} else
Jobs.consoleMsg("&cThe EnchantList section not found in &6" + itemFile.fileName + " &cfile.");
CMIMessages.consoleMessage("&cThe EnchantList section not found in &6" + itemFile.fileName + " &cfile.");
if ((section = itemFile.getConfig().getConfigurationSection("PotionEffects")) != null) {
listOfPotionEffects.clear();
@ -289,9 +289,9 @@ public class NameTranslatorManager {
}
if (listOfPotionEffects.size() > 0)
Jobs.consoleMsg("&eLoaded &6" + listOfPotionEffects.size() + " &ecustom enchant names");
CMIMessages.consoleMessage("&eLoaded &6" + listOfPotionEffects.size() + " &ecustom enchant names");
} else
Jobs.consoleMsg("&cThe PotionEffects section not found in &6" + itemFile.fileName + " &cfile.");
CMIMessages.consoleMessage("&cThe PotionEffects section not found in &6" + itemFile.fileName + " &cfile.");
if ((section = itemFile.getConfig().getConfigurationSection("ColorList")) != null) {
listOfColors.clear();
@ -304,9 +304,9 @@ public class NameTranslatorManager {
}
if (!listOfColors.isEmpty())
Jobs.consoleMsg("&eLoaded &6" + listOfColors.size() + " &ecustom color names");
CMIMessages.consoleMessage("&eLoaded &6" + listOfColors.size() + " &ecustom color names");
} else
Jobs.consoleMsg("&cThe ColorList section not found in &6" + itemFile.fileName + " &cfile.");
CMIMessages.consoleMessage("&cThe ColorList section not found in &6" + itemFile.fileName + " &cfile.");
}
@SuppressWarnings("deprecation")

View File

@ -20,6 +20,8 @@ import com.gamingmesh.jobs.container.CuboidArea;
import com.gamingmesh.jobs.container.RestrictedArea;
import com.gamingmesh.jobs.hooks.HookManager;
import net.Zrips.CMILib.Messages.CMIMessages;
public class RestrictedAreaManager {
protected final Map<String, RestrictedArea> restrictedAreas = new HashMap<>();
@ -27,43 +29,43 @@ public class RestrictedAreaManager {
private boolean worldGuardArea = false;
public boolean isExist(String name) {
for (String area : restrictedAreas.keySet()) {
if (area.equalsIgnoreCase(name))
return true;
}
return false;
for (String area : restrictedAreas.keySet()) {
if (area.equalsIgnoreCase(name))
return true;
}
return false;
}
public void addNew(RestrictedArea ra) {
addNew(ra, false);
addNew(ra, false);
}
public void addNew(RestrictedArea ra, boolean save) {
restrictedAreas.put(ra.getName(), ra);
if (save)
save();
restrictedAreas.put(ra.getName(), ra);
if (save)
save();
}
public void remove(String name) {
for (String area : restrictedAreas.keySet()) {
if (area.equalsIgnoreCase(name)) {
restrictedAreas.remove(area);
break;
}
}
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
if (f.exists()) {
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
addHeader(new StringBuilder());
conf.set("restrictedareas." + name, null);
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
for (String area : restrictedAreas.keySet()) {
if (area.equalsIgnoreCase(name)) {
restrictedAreas.remove(area);
break;
}
}
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
if (f.exists()) {
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
addHeader(new StringBuilder());
conf.set("restrictedareas." + name, null);
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
@ -74,44 +76,44 @@ public class RestrictedAreaManager {
*/
@Deprecated
public Map<String, RestrictedArea> getRestrictedAres() {
return restrictedAreas;
return restrictedAreas;
}
public Map<String, RestrictedArea> getRestrictedAreas() {
return restrictedAreas;
return restrictedAreas;
}
private void save() {
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
conf.options().indent(2);
conf.options().copyDefaults(true);
addHeader(new StringBuilder());
addHeader(new StringBuilder());
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
String areaKey = area.getKey();
CuboidArea cuboid = area.getValue().getCuboidArea();
conf.set("restrictedareas." + areaKey + ".multiplier", area.getValue().getMultiplier());
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
String areaKey = area.getKey();
CuboidArea cuboid = area.getValue().getCuboidArea();
conf.set("restrictedareas." + areaKey + ".multiplier", area.getValue().getMultiplier());
if (area.getValue().getWgName() == null) {
conf.set("restrictedareas." + areaKey + ".world", cuboid.getWorld().getName());
conf.set("restrictedareas." + areaKey + ".point1.x", cuboid.getLowLoc().getBlockX());
conf.set("restrictedareas." + areaKey + ".point1.y", cuboid.getLowLoc().getBlockY());
conf.set("restrictedareas." + areaKey + ".point1.z", cuboid.getLowLoc().getBlockZ());
conf.set("restrictedareas." + areaKey + ".point2.x", cuboid.getHighLoc().getBlockX());
conf.set("restrictedareas." + areaKey + ".point2.y", cuboid.getHighLoc().getBlockY());
conf.set("restrictedareas." + areaKey + ".point2.z", cuboid.getHighLoc().getBlockZ());
} else
conf.set("restrictedareas." + areaKey + ".WG", true);
}
if (area.getValue().getWgName() == null) {
conf.set("restrictedareas." + areaKey + ".world", cuboid.getWorld().getName());
conf.set("restrictedareas." + areaKey + ".point1.x", cuboid.getLowLoc().getBlockX());
conf.set("restrictedareas." + areaKey + ".point1.y", cuboid.getLowLoc().getBlockY());
conf.set("restrictedareas." + areaKey + ".point1.z", cuboid.getLowLoc().getBlockZ());
conf.set("restrictedareas." + areaKey + ".point2.x", cuboid.getHighLoc().getBlockX());
conf.set("restrictedareas." + areaKey + ".point2.y", cuboid.getHighLoc().getBlockY());
conf.set("restrictedareas." + areaKey + ".point2.z", cuboid.getHighLoc().getBlockZ());
} else
conf.set("restrictedareas." + areaKey + ".WG", true);
}
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
@ -120,74 +122,74 @@ public class RestrictedAreaManager {
* @return - the multiplier
*/
public double getRestrictedMultiplier(Player player) {
if (player == null)
return 0D;
for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) {
if (area.inRestrictedArea(player.getLocation()) || (area.getWgName() != null && HookManager.getWorldGuardManager() != null
&& HookManager.getWorldGuardManager().inArea(player.getLocation(), area.getWgName())))
return area.getMultiplier();
}
return 0D;
if (player == null)
return 0D;
for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) {
if (area.inRestrictedArea(player.getLocation()) || (area.getWgName() != null && HookManager.getWorldGuardManager() != null
&& HookManager.getWorldGuardManager().inArea(player.getLocation(), area.getWgName())))
return area.getMultiplier();
}
return 0D;
}
public List<RestrictedArea> getRestrictedAreasByLoc(Location loc) {
List<RestrictedArea> areas = new ArrayList<>();
for (RestrictedArea area : restrictedAreas.values()) {
if (area.inRestrictedArea(loc))
areas.add(area);
}
List<RestrictedArea> areas = new ArrayList<>();
for (RestrictedArea area : restrictedAreas.values()) {
if (area.inRestrictedArea(loc))
areas.add(area);
}
if (worldGuardArea && HookManager.getWorldGuardManager() != null)
areas.addAll(HookManager.getWorldGuardManager().getArea(loc));
if (worldGuardArea && HookManager.getWorldGuardManager() != null)
areas.addAll(HookManager.getWorldGuardManager().getArea(loc));
return areas;
return areas;
}
public List<RestrictedArea> getRestrictedAreasByName(String name) {
List<RestrictedArea> areas = new ArrayList<>();
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
if (area.getKey().equalsIgnoreCase(name))
areas.add(area.getValue());
}
return areas;
List<RestrictedArea> areas = new ArrayList<>();
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
if (area.getKey().equalsIgnoreCase(name))
areas.add(area.getValue());
}
return areas;
}
private static StringBuilder addHeader(StringBuilder header) {
String sep = System.lineSeparator();
String sep = System.lineSeparator();
header.append("Restricted area configuration");
header.append(sep)
.append(sep)
.append("Configures restricted areas where you cannot get experience or money").append(sep)
.append("when performing a job.").append(sep).append(sep)
.append("The multiplier changes the experience/money gains in an area.").append(sep)
.append("A multiplier of 0.0 means no bonus, while 0.5 means you will get 50% more the normal income").append(sep)
.append("While -0.5 means that you will get 50% less the normal income").append(sep)
.append(sep)
.append("restrictedareas:").append(sep)
.append(" area1:").append(sep)
.append(" world: 'world'").append(sep)
.append(" multiplier: 0.0").append(sep)
.append(" point1:").append(sep)
.append(" x: 125").append(sep)
.append(" y: 0").append(sep)
.append(" z: 125").append(sep)
.append(" point2:").append(sep)
.append(" x: 150").append(sep)
.append(" y: 100").append(sep)
.append(" z: 150").append(sep)
.append(" area2:").append(sep)
.append(" world: 'world_nether'").append(sep)
.append(" multiplier: 0.0").append(sep)
.append(" point1:").append(sep)
.append(" x: -100").append(sep)
.append(" y: 0").append(sep)
.append(" z: -100").append(sep)
.append(" point2:").append(sep)
.append(" x: -150").append(sep)
.append(" y: 100").append(sep)
.append(" z: -150");
return header;
header.append("Restricted area configuration");
header.append(sep)
.append(sep)
.append("Configures restricted areas where you cannot get experience or money").append(sep)
.append("when performing a job.").append(sep).append(sep)
.append("The multiplier changes the experience/money gains in an area.").append(sep)
.append("A multiplier of 0.0 means no bonus, while 0.5 means you will get 50% more the normal income").append(sep)
.append("While -0.5 means that you will get 50% less the normal income").append(sep)
.append(sep)
.append("restrictedareas:").append(sep)
.append(" area1:").append(sep)
.append(" world: 'world'").append(sep)
.append(" multiplier: 0.0").append(sep)
.append(" point1:").append(sep)
.append(" x: 125").append(sep)
.append(" y: 0").append(sep)
.append(" z: 125").append(sep)
.append(" point2:").append(sep)
.append(" x: 150").append(sep)
.append(" y: 100").append(sep)
.append(" z: 150").append(sep)
.append(" area2:").append(sep)
.append(" world: 'world_nether'").append(sep)
.append(" multiplier: 0.0").append(sep)
.append(" point1:").append(sep)
.append(" x: -100").append(sep)
.append(" y: 0").append(sep)
.append(" z: -100").append(sep)
.append(" point2:").append(sep)
.append(" x: -150").append(sep)
.append(" y: 100").append(sep)
.append(" z: -150");
return header;
}
/**
@ -196,47 +198,47 @@ public class RestrictedAreaManager {
* loads from Jobs/restrictedAreas.yml
*/
public void load() {
restrictedAreas.clear();
restrictedAreas.clear();
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
conf.options().indent(2);
conf.options().copyDefaults(true);
conf.options().indent(2);
conf.options().copyDefaults(true);
StringBuilder header = addHeader(new StringBuilder());
conf.options().header(header.toString());
StringBuilder header = addHeader(new StringBuilder());
conf.options().header(header.toString());
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
if (areaSection != null) {
for (String areaKey : areaSection.getKeys(false)) {
double multiplier = areaSection.getDouble(areaKey + ".multiplier");
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
if (areaSection != null) {
for (String areaKey : areaSection.getKeys(false)) {
double multiplier = areaSection.getDouble(areaKey + ".multiplier");
if (areaSection.isBoolean(areaKey + ".WG")) {
addNew(new RestrictedArea(areaKey, areaKey, multiplier));
worldGuardArea = true;
} else {
World world = Bukkit.getServer().getWorld(areaSection.getString(areaKey + ".world", ""));
if (world == null)
continue;
Location point1 = new Location(world, areaSection.getDouble(areaKey + ".point1.x"), areaSection.getDouble(areaKey
+ ".point1.y"), areaSection.getDouble(areaKey + ".point1.z"));
if (areaSection.isBoolean(areaKey + ".WG")) {
addNew(new RestrictedArea(areaKey, areaKey, multiplier));
worldGuardArea = true;
} else {
World world = Bukkit.getServer().getWorld(areaSection.getString(areaKey + ".world", ""));
if (world == null)
continue;
Location point1 = new Location(world, areaSection.getDouble(areaKey + ".point1.x"), areaSection.getDouble(areaKey
+ ".point1.y"), areaSection.getDouble(areaKey + ".point1.z"));
Location point2 = new Location(world, areaSection.getDouble(areaKey + ".point2.x"), areaSection.getDouble(areaKey
+ ".point2.y"), areaSection.getDouble(areaKey + ".point2.z"));
addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier));
}
}
}
Location point2 = new Location(world, areaSection.getDouble(areaKey + ".point2.x"), areaSection.getDouble(areaKey
+ ".point2.y"), areaSection.getDouble(areaKey + ".point2.z"));
addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier));
}
}
}
int size = restrictedAreas.size();
if (size > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + size + " restricted areas!");
int size = restrictedAreas.size();
if (size > 0)
CMIMessages.consoleMessage("&e[Jobs] Loaded " + size + " restricted areas!");
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.Jobs;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Messages.CMIMessages;
public class RestrictedBlockManager {
@ -18,69 +19,69 @@ public class RestrictedBlockManager {
* loads from Jobs/restrictedBlocks.yml
*/
public void load() {
if (!Jobs.getGCManager().useBlockProtection)
return;
if (!Jobs.getGCManager().useBlockProtection)
return;
ConfigReader cfg = null;
try {
cfg = new ConfigReader(Jobs.getInstance(), "restrictedBlocks.yml");
} catch (Exception e) {
e.printStackTrace();
}
ConfigReader cfg = null;
try {
cfg = new ConfigReader(Jobs.getInstance(), "restrictedBlocks.yml");
} catch (Exception e) {
e.printStackTrace();
}
if (cfg == null)
return;
if (cfg == null)
return;
cfg.addComment("blocksTimer", "Block protected by timer in sec",
"Category name can be any you like to be easily recognized",
"id can be actual block id (use /jobs blockinfo to get correct id) or use block name",
"By setting time to -1 will keep block protected until global cleanup, mainly used for structure blocks like diamond",
"Set to 0 if you want to disable protection on specific blocks",
"If you want to have default value for all blocks, enable GlobalBlockTimer in generalConfig file");
cfg.addComment("blocksTimer", "Block protected by timer in sec",
"Category name can be any you like to be easily recognized",
"id can be actual block id (use /jobs blockinfo to get correct id) or use block name",
"By setting time to -1 will keep block protected until global cleanup, mainly used for structure blocks like diamond",
"Set to 0 if you want to disable protection on specific blocks",
"If you want to have default value for all blocks, enable GlobalBlockTimer in generalConfig file");
org.bukkit.configuration.ConfigurationSection section = cfg.getC().getConfigurationSection("blocksTimer");
if (section != null) {
for (String one : section.getKeys(false)) {
if ((section.isString(one + ".id") || section.isInt(one + ".id")) && section.isInt(one + ".cd")) {
CMIItemStack cm = CMIMaterial.get(section.getString(one + ".id")).newCMIItemStack();
CMIMaterial mat = cm == null ? null : cm.getCMIType();
org.bukkit.configuration.ConfigurationSection section = cfg.getC().getConfigurationSection("blocksTimer");
if (section != null) {
for (String one : section.getKeys(false)) {
if ((section.isString(one + ".id") || section.isInt(one + ".id")) && section.isInt(one + ".cd")) {
CMIItemStack cm = CMIMaterial.get(section.getString(one + ".id")).newCMIItemStack();
CMIMaterial mat = cm == null ? null : cm.getCMIType();
if (mat == null || !mat.isBlock()) {
Jobs.consoleMsg("&eYour defined (&6" + one + "&e) protected block id/name is not correct!");
continue;
}
if (mat == null || !mat.isBlock()) {
CMIMessages.consoleMessage("&eYour defined (&6" + one + "&e) protected block id/name is not correct!");
continue;
}
int cd = section.getInt(one + ".cd");
restrictedBlocksTimer.put(mat, cd);
cfg.set("blocksTimer." + mat.name(), cd);
} else {
CMIMaterial mat = CMIMaterial.get(one);
if (mat == CMIMaterial.NONE)
continue;
int cd = section.getInt(one + ".cd");
restrictedBlocksTimer.put(mat, cd);
cfg.set("blocksTimer." + mat.name(), cd);
} else {
CMIMaterial mat = CMIMaterial.get(one);
if (mat == CMIMaterial.NONE)
continue;
int timer = cfg.get("blocksTimer." + one, -99);
if (timer == -99) {
cfg.set("blocksTimer." + one, null);
continue;
}
int timer = cfg.get("blocksTimer." + one, -99);
if (timer == -99) {
cfg.set("blocksTimer." + one, null);
continue;
}
cfg.set("blocksTimer." + one, null);
cfg.get("blocksTimer." + mat.name(), timer);
cfg.set("blocksTimer." + one, null);
cfg.get("blocksTimer." + mat.name(), timer);
if (!mat.isBlock()) {
Jobs.consoleMsg("&e[Jobs] Your defined (" + one + ") protected block id/name is not correct!");
continue;
}
if (!mat.isBlock()) {
CMIMessages.consoleMessage("&e[Jobs] Your defined (" + one + ") protected block id/name is not correct!");
continue;
}
restrictedBlocksTimer.put(mat, timer);
}
}
}
restrictedBlocksTimer.put(mat, timer);
}
}
}
int size = restrictedBlocksTimer.size();
if (size > 0)
Jobs.consoleMsg("&eLoaded &6" + size + " &eprotected blocks timers");
int size = restrictedBlocksTimer.size();
if (size > 0)
CMIMessages.consoleMessage("&eLoaded &6" + size + " &eprotected blocks timers");
cfg.save();
cfg.save();
}
}

View File

@ -7,26 +7,27 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
import com.gamingmesh.jobs.api.JobsScheduleStartEvent;
import com.gamingmesh.jobs.api.JobsScheduleStopEvent;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.scheduler.BukkitTask;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.api.JobsScheduleStartEvent;
import com.gamingmesh.jobs.api.JobsScheduleStopEvent;
import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.Schedule;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
import net.Zrips.CMILib.Version.Schedulers.CMITask;
public class ScheduleManager {
private Jobs plugin;
private BukkitTask timer;
private CMITask timer;
private YmlMaker jobSchedule;
public static final List<Schedule> BOOSTSCHEDULE = new ArrayList<>();
@ -44,7 +45,7 @@ public class ScheduleManager {
return;
cancel();
timer = Bukkit.getScheduler().runTaskTimer(plugin, this::scheduler, 20, 30 * 20L);
timer = CMIScheduler.get().scheduleSyncRepeatingTask(this::scheduler, 20, 30 * 20L);
}
public void cancel() {
@ -180,7 +181,7 @@ public class ScheduleManager {
!path.isList("Days") && !path.isString("Days") ||
!path.isList("Jobs") && !path.isString("Jobs")) {
Jobs.consoleMsg("&cIncorect scheduler format detected for " + oneSection + " scheduler!");
CMIMessages.consoleMessage("&cIncorect scheduler format detected for " + oneSection + " scheduler!");
continue;
}
@ -228,6 +229,6 @@ public class ScheduleManager {
}
if (!BOOSTSCHEDULE.isEmpty())
Jobs.consoleMsg("&eLoaded " + BOOSTSCHEDULE.size() + " schedulers!");
CMIMessages.consoleMessage("&eLoaded " + BOOSTSCHEDULE.size() + " schedulers!");
}
}

View File

@ -113,11 +113,14 @@ public class ShopManager {
List<String> lore = new ArrayList<>();
CMIMaterial mat = CMIMaterial.get(item.getIconMaterial());
boolean hiddenLore = false;
if (item.isHideWithoutPerm()) {
for (String onePerm : item.getRequiredPerm()) {
if (!player.hasPermission(onePerm)) {
mat = CMIMaterial.STONE_BUTTON;
lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
hiddenLore = true;
break;
}
}
@ -127,6 +130,7 @@ public class ShopManager {
jPlayer.getTotalLevels() < item.getRequiredTotalLevels()) {
mat = CMIMaterial.STONE_BUTTON;
lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
hiddenLore = true;
}
if (mat == CMIMaterial.NONE)
@ -142,48 +146,50 @@ public class ShopManager {
if (item.getIconName() != null)
meta.setDisplayName(item.getIconName());
lore.addAll(item.getIconLore());
if (!hiddenLore) {
lore.addAll(item.getIconLore());
if (item.getPointPrice() > 0) {
String color = item.getPointPrice() >= points ? "" : Jobs.getLanguage().getMessage("command.shop.info.haveColor");
lore.add(Jobs.getLanguage().getMessage("command.shop.info.pointsPrice", "%currentpoints%", color + points, "%price%", item.getPointPrice()));
}
if (item.getVaultPrice() > 0) {
String color = item.getVaultPrice() >= balance ? "" : Jobs.getLanguage().getMessage("command.shop.info.haveColor");
lore.add(Jobs.getLanguage().getMessage("command.shop.info.moneyPrice", "%currentbalance%", color + Jobs.getEconomy().getEconomy().format(balance), "%price%", item.getVaultPrice()));
}
if (!item.getRequiredJobs().isEmpty()) {
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobs"));
for (Entry<String, Integer> one : item.getRequiredJobs().entrySet()) {
Job job = Jobs.getJob(one.getKey());
if (job == null) {
continue;
}
String jobColor = "";
String levelColor = "";
JobProgression prog = jPlayer.getJobProgression(job);
if (prog == null) {
jobColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsColor");
levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor");
}
if (prog != null && prog.getLevel() < one.getValue())
levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor");
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobsList", "%jobsname%",
jobColor + one.getKey(), "%level%", levelColor + one.getValue()));
if (item.getPointPrice() > 0) {
String color = item.getPointPrice() >= points ? "" : Jobs.getLanguage().getMessage("command.shop.info.haveColor");
lore.add(Jobs.getLanguage().getMessage("command.shop.info.pointsPrice", "%currentpoints%", color + points, "%price%", item.getPointPrice()));
}
}
if (item.getRequiredTotalLevels() != -1) {
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevel",
"%totalLevel%", (jPlayer.getTotalLevels() < item.getRequiredTotalLevels()
? Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevelColor") : "") + item.getRequiredTotalLevels()));
if (item.getVaultPrice() > 0) {
String color = item.getVaultPrice() >= balance ? "" : Jobs.getLanguage().getMessage("command.shop.info.haveColor");
lore.add(Jobs.getLanguage().getMessage("command.shop.info.moneyPrice", "%currentbalance%", color + Jobs.getEconomy().getEconomy().format(balance), "%price%", item.getVaultPrice()));
}
if (!item.getRequiredJobs().isEmpty()) {
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobs"));
for (Entry<String, Integer> one : item.getRequiredJobs().entrySet()) {
Job job = Jobs.getJob(one.getKey());
if (job == null) {
continue;
}
String jobColor = "";
String levelColor = "";
JobProgression prog = jPlayer.getJobProgression(job);
if (prog == null) {
jobColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsColor");
levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor");
}
if (prog != null && prog.getLevel() < one.getValue())
levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor");
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobsList", "%jobsname%",
jobColor + one.getKey(), "%level%", levelColor + one.getValue()));
}
}
if (item.getRequiredTotalLevels() != -1) {
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevel",
"%totalLevel%", (jPlayer.getTotalLevels() < item.getRequiredTotalLevels()
? Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevelColor") : "") + item.getRequiredTotalLevels()));
}
}
meta.setLore(lore);
@ -497,6 +503,6 @@ public class ShopManager {
}
if (!list.isEmpty())
Jobs.consoleMsg("&eLoaded &6" + list.size() + " &eshop items");
CMIMessages.consoleMessage("&eLoaded &6" + list.size() + " &eshop items");
}
}

View File

@ -11,6 +11,7 @@ import com.gamingmesh.jobs.container.Title;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Messages.CMIMessages;
public class TitleManager {
@ -157,6 +158,6 @@ public class TitleManager {
int size = titles.size();
if (size > 0)
Jobs.consoleMsg("&eLoaded &6" + size + " &etitles");
CMIMessages.consoleMessage("&eLoaded &6" + size + " &etitles");
}
}

View File

@ -2,13 +2,15 @@ package com.gamingmesh.jobs.container;
import org.bukkit.util.Vector;
import net.Zrips.CMILib.Version.Schedulers.CMITask;
public class BlockProtection {
private static long pre = (int) (System.currentTimeMillis() / 10000000000L) * 10000000000L;
private int id = -1;
private int schedId = - 1;
private int time = -1;
private CMITask scheduler = null;
private int time = -1;
private int recorded = -1;
private DBAction action;
private boolean paid = false;
@ -17,109 +19,109 @@ public class BlockProtection {
private int z = 0;
public BlockProtection(Vector pos) {
this(DBAction.INSERT, pos);
this(DBAction.INSERT, pos);
}
@Deprecated
public BlockProtection(DBAction action, Vector pos) {
this(action, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
this(action, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
}
public BlockProtection(DBAction action, int x, int y, int z) {
this.action = action;
if (action == DBAction.NONE)
action = null;
this.x = x;
this.y = y;
this.z = z;
this.action = action;
if (action == DBAction.NONE)
action = null;
this.x = x;
this.y = y;
this.z = z;
}
public long getTime() {
return deconvert(time);
return deconvert(time);
}
private static int convert(long time) {
return time == -1L ? -1 : (int) ((time - pre) / 1000L);
return time == -1L ? -1 : (int) ((time - pre) / 1000L);
}
private static long deconvert(int time) {
return time == -1 ? -1 : (time * 1000L) + pre;
return time == -1 ? -1 : (time * 1000L) + pre;
}
public void setTime(long time) {
this.time = time == -1 ? -1 : convert(time);
this.recorded = convert(System.currentTimeMillis());
this.time = time == -1 ? -1 : convert(time);
this.recorded = convert(System.currentTimeMillis());
}
public DBAction getAction() {
return action == null ? DBAction.NONE : action;
return action == null ? DBAction.NONE : action;
}
public void setAction(DBAction action) {
if (action == DBAction.NONE)
action = null;
this.action = action;
if (action == DBAction.NONE)
action = null;
this.action = action;
}
public long getRecorded() {
return deconvert(recorded);
return deconvert(recorded);
}
public boolean isPaid() {
return paid;
return paid;
}
public void setPaid(boolean paid) {
this.paid = paid;
this.paid = paid;
}
public void setRecorded(long recorded) {
this.recorded = convert(recorded);
this.recorded = convert(recorded);
}
public int getId() {
return id;
return id;
}
public void setId(int id) {
this.id = id;
this.id = id;
}
@Deprecated
public Vector getPos() {
return new Vector(x, y, z);
return new Vector(x, y, z);
}
@Deprecated
public void setPos(Vector pos) {
x = pos.getBlockX();
y = pos.getBlockY();
z = pos.getBlockZ();
x = pos.getBlockX();
y = pos.getBlockY();
z = pos.getBlockZ();
}
public void setPos(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
this.x = x;
this.y = y;
this.z = z;
}
public int getX() {
return x;
return x;
}
public int getY() {
return y;
return y;
}
public int getZ() {
return z;
return z;
}
public int getSchedId() {
return schedId;
public CMITask getScheduler() {
return scheduler;
}
public void setSchedId(int schedId) {
this.schedId = schedId;
public void setScheduler(CMITask cmiTask) {
this.scheduler = cmiTask;
}
}

View File

@ -12,94 +12,95 @@ public class Boost {
private java.util.Map<BoostOf, BoostMultiplier> map = new HashMap<>();
public Boost() {
for (BoostOf one : BoostOf.values()) {
map.put(one, new BoostMultiplier());
}
for (BoostOf one : BoostOf.values()) {
map.put(one, new BoostMultiplier());
}
}
public void add(BoostOf boostoff, BoostMultiplier multiplier) {
map.put(boostoff, multiplier);
map.put(boostoff, multiplier);
}
public BoostMultiplier get(BoostOf boostOf) {
return map.getOrDefault(boostOf, new BoostMultiplier());
return map.getOrDefault(boostOf, new BoostMultiplier());
}
public double get(BoostOf boostOf, CurrencyType type) {
return get(boostOf, type, false);
return get(boostOf, type, false);
}
public double get(BoostOf boostOf, CurrencyType type, boolean percent) {
BoostMultiplier bm = map.get(boostOf);
if (bm == null)
return 0D;
BoostMultiplier bm = map.get(boostOf);
if (bm == null)
return 0D;
double r = bm.get(type);
if (r < -1)
r = -1;
double r = bm.get(type);
if (r < -1)
r = -1;
return percent ? (int) (r * 100) : r;
return percent ? (int) (r * 100) : r;
}
public double getFinal(CurrencyType type) {
return getFinal(type, false, false);
return getFinal(type, false, false);
}
public double getFinalAmount(CurrencyType type, double income) {
double f = income;
double f = income;
if (income > 0 || (income < 0 && Jobs.getGCManager().applyToNegativeIncome))
f = income + income * getFinal(type, false, false);
if (income > 0 || (income < 0 && Jobs.getGCManager().applyToNegativeIncome))
f = income + income * getFinal(type, false, false);
if (income > 0 && f < 0 || income < 0 && f > 0)
f = 0;
if (income > 0 && f < 0 || income < 0 && f > 0)
f = 0;
return f;
return f;
}
public double getFinal(CurrencyType type, boolean percent, boolean excludeExtra) {
double r = 0D;
double r = 0D;
for (BoostOf one : BoostOf.values()) {
BoostMultiplier bm = map.get(one);
if (bm == null)
continue;
for (BoostOf one : BoostOf.values()) {
BoostMultiplier bm = map.get(one);
if (bm == null)
continue;
if (one == BoostOf.NearSpawner || one == BoostOf.PetPay)
continue;
if (one == BoostOf.NearSpawner || one == BoostOf.PetPay)
continue;
if (bm.isValid(type))
r += bm.get(type);
}
if (bm.isValid(type)) {
r += bm.get(type);
}
}
if (!excludeExtra) {
if (Jobs.getGCManager().multiplyBoostedExtraValues) {
BoostMultiplier bm = map.get(BoostOf.NearSpawner);
if (bm != null && bm.isValid(type) && bm.get(type) != 0) {
r = (r + 1) * (bm.get(type) + 1);
r -= 1;
}
if (!excludeExtra) {
if (Jobs.getGCManager().multiplyBoostedExtraValues) {
BoostMultiplier bm = map.get(BoostOf.NearSpawner);
if (bm != null && bm.isValid(type) && bm.get(type) != 0) {
r = (r + 1) * (bm.get(type) + 1);
r -= 1;
}
bm = map.get(BoostOf.PetPay);
if (bm != null && bm.isValid(type) && bm.get(type) != 0) {
r = (r + 1) * (bm.get(type) + 1);
r -= 1;
}
} else {
BoostMultiplier bm = map.get(BoostOf.NearSpawner);
if (bm != null && bm.isValid(type)) {
r += bm.get(type);
}
bm = map.get(BoostOf.PetPay);
if (bm != null && bm.isValid(type)) {
r += bm.get(type);
}
}
}
bm = map.get(BoostOf.PetPay);
if (bm != null && bm.isValid(type) && bm.get(type) != 0) {
r = (r + 1) * (bm.get(type) + 1);
r -= 1;
}
} else {
BoostMultiplier bm = map.get(BoostOf.NearSpawner);
if (bm != null && bm.isValid(type)) {
r += bm.get(type);
}
bm = map.get(BoostOf.PetPay);
if (bm != null && bm.isValid(type)) {
r += bm.get(type);
}
}
}
if (r < -1)
r = -1;
if (r < -1)
r = -1;
return percent ? (int) (r * 100) : r;
return percent ? (int) (r * 100) : r;
}
}

View File

@ -9,65 +9,68 @@ public class BoostMultiplier implements Cloneable {
@Override
public BoostMultiplier clone() {
BoostMultiplier boost = new BoostMultiplier();
for (CurrencyType type : CurrencyType.values()) {
boost.add(type, map.get(type));
}
return boost;
BoostMultiplier boost = new BoostMultiplier();
for (CurrencyType type : CurrencyType.values()) {
boost.add(type, map.get(type));
}
return boost;
}
public BoostMultiplier() {
for (CurrencyType one : CurrencyType.values()) {
map.put(one, 0D);
}
for (CurrencyType one : CurrencyType.values()) {
map.put(one, 0D);
}
}
public BoostMultiplier add(CurrencyType type, double amount) {
map.put(type, amount);
return this;
if (!Double.isNaN(amount))
map.put(type, amount);
timers.remove(type);
return this;
}
public BoostMultiplier add(CurrencyType type, double amount, long time) {
timers.put(type, time);
return add(type, amount);
add(type, amount);
timers.put(type, time);
return this;
}
public BoostMultiplier add(double amount) {
if (amount != 0) {
for (CurrencyType one : CurrencyType.values()) {
map.put(one, amount);
}
}
return this;
if (amount != 0 && !Double.isNaN(amount)) {
for (CurrencyType one : CurrencyType.values()) {
map.put(one, amount);
}
}
return this;
}
public double get(CurrencyType type) {
if (!isValid(type))
return 0D;
return map.getOrDefault(type, 0D);
if (!isValid(type))
return 0D;
return map.getOrDefault(type, 0D);
}
public Long getTime(CurrencyType type) {
return timers.get(type);
return timers.get(type);
}
public boolean isValid(CurrencyType type) {
Long time = getTime(type);
if (time == null)
return true;
Long time = getTime(type);
if (time == null)
return true;
if (time < System.currentTimeMillis()) {
map.remove(type);
timers.remove(type);
return false;
}
if (time < System.currentTimeMillis()) {
map.remove(type);
timers.remove(type);
return false;
}
return true;
return true;
}
public void add(BoostMultiplier armorboost) {
for (CurrencyType one : CurrencyType.values()) {
map.put(one, get(one) + armorboost.get(one));
}
for (CurrencyType one : CurrencyType.values()) {
map.put(one, get(one) + armorboost.get(one));
}
}
}

View File

@ -1,13 +1,14 @@
package com.gamingmesh.jobs.container;
import org.bukkit.Bukkit;
import org.bukkit.boss.BossBar;
import net.Zrips.CMILib.Version.Schedulers.CMITask;
public class BossBarInfo {
private String jobName;
private String PlayerName;
private BossBar bar;
private int id = -1;
private CMITask scheduler = null;
public BossBarInfo(String PlayerName, String jobName, BossBar bar) {
this.PlayerName = PlayerName;
@ -15,14 +16,14 @@ public class BossBarInfo {
this.bar = bar;
}
public void setId(int id) {
public void setScheduler(CMITask cmiTask) {
cancel();
this.id = id;
this.scheduler = cmiTask;
}
public void cancel() {
if (id != -1)
Bukkit.getScheduler().cancelTask(this.id);
if (scheduler != null)
scheduler.cancel();
}
public String getPlayerName() {

View File

@ -4,66 +4,104 @@ import java.util.ArrayList;
import java.util.List;
import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.Messages.CMIMessages;
public class CurrencyLimit {
private boolean enabled;
private List<CurrencyType> stopWith;
private int timeLimit;
private int timeLimit = 0;
private resetTime resetsAt = null;
private int announcementDelay;
private Parser maxEquation;
public CurrencyLimit(boolean enabled, List<CurrencyType> stopWith, int timeLimit, int announcementDelay, Parser maxEquation) {
this.enabled = enabled;
setStopWith(stopWith);
this.timeLimit = timeLimit;
this.announcementDelay = announcementDelay;
this.enabled = enabled;
setStopWith(stopWith);
this.timeLimit = timeLimit;
this.announcementDelay = announcementDelay;
setMaxEquation(maxEquation);
setMaxEquation(maxEquation);
}
public CurrencyLimit() {
}
public boolean isEnabled() {
return enabled;
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
this.enabled = enabled;
}
public List<CurrencyType> getStopWith() {
return stopWith;
return stopWith;
}
public void setStopWith(List<CurrencyType> stopWith) {
this.stopWith = stopWith == null ? new ArrayList<>() : stopWith;
this.stopWith = stopWith == null ? new ArrayList<>() : stopWith;
}
public int getTimeLimit() {
return timeLimit;
return timeLimit;
}
public void setTimeLimit(int timeLimit) {
this.timeLimit = timeLimit;
this.timeLimit = timeLimit;
}
public int getAnnouncementDelay() {
return announcementDelay;
return announcementDelay;
}
public void setAnnouncementDelay(int announcementDelay) {
this.announcementDelay = announcementDelay;
this.announcementDelay = announcementDelay;
}
public Parser getMaxEquation() {
return maxEquation;
return maxEquation;
}
public void setMaxEquation(Parser maxEquation) {
if (maxEquation != null)
this.maxEquation = maxEquation;
if (maxEquation != null)
this.maxEquation = maxEquation;
}
public resetTime getResetsAt() {
return resetsAt;
}
public void setResetsAt(int hour, int minute, int second) {
this.resetsAt = new resetTime(hour, minute, second);
}
public void setResetsAt(String resetsAt) {
if (resetsAt.isEmpty())
return;
int hour = 0;
int minute = 0;
int second = 0;
String[] split = resetsAt.split(":");
try {
hour = Integer.parseInt(split[0]);
if (split.length >= 2) {
minute = Integer.parseInt(split[1]);
}
if (split.length >= 3) {
second = Integer.parseInt(split[2]);
}
} catch (Throwable e) {
CMIMessages.consoleMessage("Failed to recognize reset time as " + resetsAt);
return;
}
setResetsAt(hour, minute, second);
}
}

View File

@ -18,6 +18,8 @@
package com.gamingmesh.jobs.container;
import com.gamingmesh.jobs.Jobs;
public enum CurrencyType {
MONEY("Money", 1),
EXP("Exp", 2),
@ -25,33 +27,46 @@ public enum CurrencyType {
private String name;
private int id = 0;
private boolean enabled = true;
CurrencyType(String name, int id) {
this.name = name;
this.id = id;
this.name = name;
this.id = id;
}
public String getName() {
return name;
return name;
}
public static CurrencyType getByName(String name) {
for (CurrencyType one : values()) {
if (one.getName().equalsIgnoreCase(name))
return one;
}
return null;
for (CurrencyType one : values()) {
if (one.getName().equalsIgnoreCase(name))
return one;
}
return null;
}
public static CurrencyType get(int id) {
for (CurrencyType one : values()) {
if (one.getId() == id)
return one;
}
return null;
for (CurrencyType one : values()) {
if (one.getId() == id)
return one;
}
return null;
}
public int getId() {
return id;
return id;
}
public String getDisplayName() {
return Jobs.getLanguage().getMessage("general.info.paymentType." + this.toString());
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}

View File

@ -101,41 +101,41 @@ public class Job {
@Deprecated
public Job(String jobName, String jobDisplayName, String fullName, String jobShortName, String description, CMIChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, Map<String, JobItems> jobItems,
Map<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, String bossbar, Long rejoinCD, List<String> worldBlacklist) {
this(jobName, jobDisplayName, fullName, jobShortName, jobColour, maxExpEquation, displayMethod, maxLevel,
vipmaxLevel, maxSlots, jobPermissions, jobCommands, jobConditions,
jobLimitedItems, cmdOnJoin, cmdOnLeave, guiItem, guiSlot, worldBlacklist);
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, Map<String, JobItems> jobItems,
Map<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, String bossbar, Long rejoinCD, List<String> worldBlacklist) {
this(jobName, jobDisplayName, fullName, jobShortName, jobColour, maxExpEquation, displayMethod, maxLevel,
vipmaxLevel, maxSlots, jobPermissions, jobCommands, jobConditions,
jobLimitedItems, cmdOnJoin, cmdOnLeave, guiItem, guiSlot, worldBlacklist);
this.jobItems = jobItems;
this.description = description;
this.jobItems = jobItems;
this.description = description;
}
public Job(String jobName, String jobDisplayName, String fullName, String jobShortName, CMIChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions,
Map<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, List<String> worldBlacklist) {
this.jobName = jobName == null ? "" : jobName;
this.fullName = fullName == null ? "" : fullName;
this.jobShortName = jobShortName;
this.jobColour = jobColour;
this.maxExpEquation = maxExpEquation;
this.displayMethod = displayMethod;
this.maxLevel = maxLevel;
this.vipmaxLevel = vipmaxLevel;
this.maxSlots = maxSlots;
this.jobPermissions = jobPermissions;
this.jobCommands = jobCommands;
this.jobConditions = jobConditions;
this.jobLimitedItems = jobLimitedItems;
this.cmdOnJoin = cmdOnJoin;
this.cmdOnLeave = cmdOnLeave;
this.guiItem = guiItem;
this.guiSlot = guiSlot;
this.jobDisplayName = CMIChatColor.translate(jobDisplayName);
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions,
Map<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, List<String> worldBlacklist) {
this.jobName = jobName == null ? "" : jobName;
this.fullName = fullName == null ? "" : fullName;
this.jobShortName = jobShortName;
this.jobColour = jobColour;
this.maxExpEquation = maxExpEquation;
this.displayMethod = displayMethod;
this.maxLevel = maxLevel;
this.vipmaxLevel = vipmaxLevel;
this.maxSlots = maxSlots;
this.jobPermissions = jobPermissions;
this.jobCommands = jobCommands;
this.jobConditions = jobConditions;
this.jobLimitedItems = jobLimitedItems;
this.cmdOnJoin = cmdOnJoin;
this.cmdOnLeave = cmdOnLeave;
this.guiItem = guiItem;
this.guiSlot = guiSlot;
this.jobDisplayName = CMIChatColor.translate(jobDisplayName);
if (worldBlacklist != null) {
this.worldBlacklist = worldBlacklist;
}
if (worldBlacklist != null) {
this.worldBlacklist = worldBlacklist;
}
}
/**
@ -146,7 +146,7 @@ public class Job {
* @param point the amount of boost to add
*/
public void addBoost(CurrencyType type, double point) {
boost.add(type, point);
boost.add(type, point);
}
/**
@ -163,20 +163,20 @@ public class Job {
*/
public void addBoost(CurrencyType type, double point, long duration) {
if (duration <= 0) {
addBoost(type, point);
return;
}
if (duration <= 0) {
addBoost(type, point);
return;
}
boost.add(type, point, System.currentTimeMillis() + (duration * 1000L));
boost.add(type, point, System.currentTimeMillis() + (duration * 1000L));
}
public void setBoost(BoostMultiplier boost) {
this.boost = boost;
this.boost = boost;
}
public BoostMultiplier getBoost() {
return boost;
return boost;
}
/**
@ -186,8 +186,8 @@ public class Job {
* @return true if same
*/
public boolean isSame(Job job) {
return job != null && (id == job.getId() || jobName.equalsIgnoreCase(job.getName())
|| fullName.equalsIgnoreCase(job.getJobFullName()) || fullName.equalsIgnoreCase(job.getName()));
return job != null && (id == job.getId() || jobName.equalsIgnoreCase(job.getName())
|| fullName.equalsIgnoreCase(job.getJobFullName()) || fullName.equalsIgnoreCase(job.getName()));
}
/**
@ -196,66 +196,75 @@ public class Job {
* @return the amount of total players in this job
*/
public int getTotalPlayers() {
if (totalPlayers == -1) {
updateTotalPlayers();
}
if (totalPlayers == -1) {
updateTotalPlayers();
}
return totalPlayers;
return totalPlayers;
}
/**
* Updates the total players property from database synchronously.
*/
public void updateTotalPlayers() {
totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(jobName);
totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(jobName);
if (totalPlayers <= 0) {
totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(fullName);
}
if (totalPlayers <= 0) {
totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(fullName);
}
updateBonus();
updateBonus();
}
public void updateBonus() {
if (!Jobs.getGCManager().useDynamicPayment)
return;
if (!Jobs.getGCManager().useDynamicPayment)
return;
Parser eq = Jobs.getGCManager().DynamicPaymentEquation;
eq.setVariable("totalworkers", Jobs.getJobsDAO().getTotalPlayers());
eq.setVariable("totaljobs", Jobs.getJobs().size());
eq.setVariable("jobstotalplayers", getTotalPlayers());
Parser eq = Jobs.getGCManager().DynamicPaymentEquation;
eq.setVariable("totalworkers", Jobs.getJobsDAO().getTotalPlayers());
eq.setVariable("totaljobs", Jobs.getJobs().size());
eq.setVariable("jobstotalplayers", getTotalPlayers());
double now = eq.getValue();
if (now > Jobs.getGCManager().DynamicPaymentMaxBonus)
now = Jobs.getGCManager().DynamicPaymentMaxBonus;
double now = 0D;
try {
now = eq.getValue();
} catch (Throwable e) {
e.printStackTrace();
}
if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty)
now = Jobs.getGCManager().DynamicPaymentMaxPenalty;
if (now > Jobs.getGCManager().DynamicPaymentMaxBonus)
now = Jobs.getGCManager().DynamicPaymentMaxBonus;
this.bonus = now;
if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty)
now = Jobs.getGCManager().DynamicPaymentMaxPenalty;
if (Double.isNaN(now))
now = 0;
this.bonus = now;
}
public double getBonus() {
if (bonus == null)
updateBonus();
if (bonus == null)
updateBonus();
return bonus == null ? 0D : bonus;
return bonus == null ? 0D : bonus;
}
public List<String> getCmdOnJoin() {
return cmdOnJoin;
return cmdOnJoin;
}
public List<String> getCmdOnLeave() {
return cmdOnLeave;
return cmdOnLeave;
}
public ItemStack getGuiItem() {
return guiItem;
return guiItem;
}
public int getGuiSlot() {
return guiSlot;
return guiSlot;
}
/**
@ -264,7 +273,7 @@ public class Job {
* @param info - the job info
*/
public void setJobInfo(ActionType type, List<JobInfo> info) {
jobInfo.put(type, info);
jobInfo.put(type, info);
}
/**
@ -273,7 +282,7 @@ public class Job {
* @return Job info list
*/
public List<JobInfo> getJobInfo(ActionType type) {
return jobInfo.get(type);
return jobInfo.get(type);
}
/**
@ -281,41 +290,42 @@ public class Job {
* @return Job info list
*/
public Map<ActionType, List<JobInfo>> getJobInfoList() {
return jobInfo;
return jobInfo;
}
public JobInfo getJobInfo(ActionInfo action, int level) {
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) -> {
if (actionInfo instanceof PotionItemActionInfo) {
String subName = ((PotionItemActionInfo) action).getNameWithSub();
return jobInfo.getName().equalsIgnoreCase(subName) || (jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(subName);
}
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) -> {
if (actionInfo instanceof PotionItemActionInfo) {
String subName = ((PotionItemActionInfo) action).getNameWithSub();
return jobInfo.getName().equalsIgnoreCase(subName) || (jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(subName);
}
if (actionInfo instanceof EnchantActionInfo) {
return Util.enchantMatchesActionInfo(jobInfo.getName(), (EnchantActionInfo) actionInfo);
}
if (actionInfo instanceof EnchantActionInfo) {
return Util.enchantMatchesActionInfo(jobInfo.getName(), (EnchantActionInfo) actionInfo);
}
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(action.getNameWithSub()) ||
jobInfo.getName().equalsIgnoreCase(action.getName());
};
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(action.getNameWithSub()) ||
jobInfo.getName().equalsIgnoreCase(action.getName());
};
String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName());
for (JobInfo info : getJobInfo(action.getType())) {
if (condition.test(info, action)) {
if (!info.isInLevelRange(level)) {
break;
}
String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName());
for (JobInfo info : getJobInfo(action.getType())) {
if (condition.test(info, action)) {
if (!info.isInLevelRange(level)) {
break;
}
return info;
}
return info;
}
if ((shortActionName + ":ALL").equalsIgnoreCase(info.getName())) {
return info;
}
}
if ((shortActionName + ":ALL").equalsIgnoreCase(info.getName())) {
return info;
}
}
return null;
return null;
}
/**
@ -324,20 +334,20 @@ public class Job {
* @return the name of this job
*/
public String getName() {
return jobName;
return jobName;
}
public String getJobFullName() {
return fullName;
return fullName;
}
@Deprecated
public String getJobDisplayName() {
return getDisplayName();
return getDisplayName();
}
public String getDisplayName() {
return jobDisplayName == null ? jobColour + fullName : jobDisplayName;
return jobDisplayName == null ? jobColour + fullName : jobDisplayName;
}
/**
@ -348,7 +358,7 @@ public class Job {
*/
@Deprecated
public String getNameWithColor() {
return jobColour + fullName;
return jobColour + fullName;
}
/**
@ -357,7 +367,7 @@ public class Job {
* @return the shortened version of the jobName
*/
public String getShortName() {
return jobShortName;
return jobShortName;
}
/**
@ -369,7 +379,7 @@ public class Job {
*/
@Deprecated
public String getDescription() {
return description;
return description;
}
/**
@ -377,7 +387,7 @@ public class Job {
* @return the Color of the job for chat
*/
public CMIChatColor getChatColor() {
return jobColour;
return jobColour;
}
/**
@ -385,7 +395,7 @@ public class Job {
* @return the MaxExpEquation of the job
*/
public Parser getMaxExpEquation() {
return maxExpEquation;
return maxExpEquation;
}
/**
@ -394,10 +404,10 @@ public class Job {
* @return the correct max exp for this level
*/
public double getMaxExp(Map<String, Double> level) {
for (Map.Entry<String, Double> temp : level.entrySet()) {
maxExpEquation.setVariable(temp.getKey(), temp.getValue());
}
return maxExpEquation.getValue();
for (Map.Entry<String, Double> temp : level.entrySet()) {
maxExpEquation.setVariable(temp.getKey(), temp.getValue());
}
return maxExpEquation.getValue();
}
/**
@ -405,7 +415,7 @@ public class Job {
* @return the display method
*/
public DisplayMethod getDisplayMethod() {
return displayMethod;
return displayMethod;
}
/**
@ -414,7 +424,7 @@ public class Job {
* @return the max level
*/
public int getMaxLevel() {
return maxLevel;
return maxLevel;
}
/**
@ -424,20 +434,20 @@ public class Job {
* @return the max level of player
*/
public int getMaxLevel(JobsPlayer player) {
return player == null ? maxLevel : player.getMaxJobLevelAllowed(this);
return player == null ? maxLevel : player.getMaxJobLevelAllowed(this);
}
public int getMaxLevel(CommandSender sender) {
if (sender == null)
return maxLevel;
if (sender == null)
return maxLevel;
if (sender instanceof Player) {
JobsPlayer player = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (player != null)
return player.getMaxJobLevelAllowed(this);
}
if (sender instanceof Player) {
JobsPlayer player = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (player != null)
return player.getMaxJobLevelAllowed(this);
}
return maxLevel > vipmaxLevel ? maxLevel : vipmaxLevel;
return maxLevel > vipmaxLevel ? maxLevel : vipmaxLevel;
}
/**
@ -446,7 +456,7 @@ public class Job {
* @return null - no max level
*/
public int getVipMaxLevel() {
return vipmaxLevel;
return vipmaxLevel;
}
/**
@ -455,7 +465,7 @@ public class Job {
* @return null - no max slots
*/
public Integer getMaxSlots() {
return maxSlots;
return maxSlots;
}
/**
@ -463,7 +473,7 @@ public class Job {
* @return Permissions for this job
*/
public List<JobPermission> getPermissions() {
return Collections.unmodifiableList(jobPermissions);
return Collections.unmodifiableList(jobPermissions);
}
/**
@ -471,7 +481,7 @@ public class Job {
* @return Commands for this job
*/
public List<JobCommands> getCommands() {
return Collections.unmodifiableList(jobCommands);
return Collections.unmodifiableList(jobCommands);
}
/**
@ -479,7 +489,7 @@ public class Job {
* @return Conditions for this job
*/
public List<JobConditions> getConditions() {
return Collections.unmodifiableList(jobConditions);
return Collections.unmodifiableList(jobConditions);
}
/**
@ -488,14 +498,14 @@ public class Job {
*/
@Deprecated
public Map<String, JobItems> getItemBonus() {
if (jobItems == null)
jobItems = new HashMap<String, JobItems>();
return jobItems;
if (jobItems == null)
jobItems = new HashMap<String, JobItems>();
return jobItems;
}
@Deprecated
public JobItems getItemBonus(String key) {
return jobItems.get(key.toLowerCase());
return jobItems.get(key.toLowerCase());
}
/**
@ -503,192 +513,192 @@ public class Job {
* @return Limited items for this job
*/
public Map<String, JobLimitedItems> getLimitedItems() {
return jobLimitedItems;
return jobLimitedItems;
}
public JobLimitedItems getLimitedItems(String key) {
return jobLimitedItems.get(key.toLowerCase());
return jobLimitedItems.get(key.toLowerCase());
}
public String getBossbar() {
return bossbar;
return bossbar;
}
public void setBossbar(String bossbar) {
this.bossbar = bossbar;
this.bossbar = bossbar;
}
public Parser getMoneyEquation() {
return moneyEquation;
return moneyEquation;
}
public void setMoneyEquation(Parser moneyEquation) {
this.moneyEquation = moneyEquation;
this.moneyEquation = moneyEquation;
}
public Parser getXpEquation() {
return xpEquation;
return xpEquation;
}
public void setXpEquation(Parser xpEquation) {
this.xpEquation = xpEquation;
this.xpEquation = xpEquation;
}
public Parser getPointsEquation() {
return pointsEquation;
return pointsEquation;
}
public void setPointsEquation(Parser pointsEquation) {
this.pointsEquation = pointsEquation;
this.pointsEquation = pointsEquation;
}
public Long getRejoinCd() {
return rejoinCd;
return rejoinCd;
}
public void setRejoinCd(Long rejoinCd) {
this.rejoinCd = rejoinCd;
this.rejoinCd = rejoinCd;
}
public List<String> getFullDescription() {
return fDescription;
return fDescription;
}
public void setFullDescription(List<String> fDescription) {
this.fDescription.clear();
this.fDescription.clear();
if (fDescription != null) {
this.fDescription.addAll(fDescription);
this.description = String.join("\n", this.fDescription);
}
if (fDescription != null) {
this.fDescription.addAll(fDescription);
this.description = String.join("\n", this.fDescription);
}
}
public void setMaxLevelCommands(List<String> commands) {
maxLevelCommands.clear();
maxLevelCommands.clear();
if (commands != null) {
maxLevelCommands.addAll(commands);
}
if (commands != null) {
maxLevelCommands.addAll(commands);
}
}
public List<String> getMaxLevelCommands() {
return maxLevelCommands;
return maxLevelCommands;
}
public List<Quest> getQuests() {
return quests;
return quests;
}
public Quest getQuest(String name) {
if (name == null || name.trim().isEmpty()) {
return null;
}
if (name == null || name.trim().isEmpty()) {
return null;
}
for (Quest one : quests) {
if (one.getConfigName().equalsIgnoreCase(name))
return one;
}
for (Quest one : quests) {
if (one.getConfigName().equalsIgnoreCase(name))
return one;
}
return null;
return null;
}
public void setQuests(List<Quest> quests) {
this.quests.clear();
this.quests.clear();
if (quests != null) {
this.quests.addAll(quests);
}
if (quests != null) {
this.quests.addAll(quests);
}
}
public Quest getNextQuest(List<String> excludeQuests, Integer level) {
List<Quest> ls = new ArrayList<>(quests);
Collections.shuffle(ls);
List<Quest> ls = new ArrayList<>(quests);
Collections.shuffle(ls);
int i = 0;
while (true) {
i++;
int i = 0;
while (true) {
i++;
int target = new Random(System.nanoTime()).nextInt(100);
for (Quest one : ls) {
if (one.isEnabled() && one.getChance() >= target && (excludeQuests == null || !excludeQuests.contains(one.getConfigName().toLowerCase()))
&& one.isInLevelRange(level)) {
return one;
}
}
int target = new Random(System.nanoTime()).nextInt(100);
for (Quest one : ls) {
if (one.isEnabled() && one.getChance() >= target && (excludeQuests == null || !excludeQuests.contains(one.getConfigName().toLowerCase()))
&& one.isInLevelRange(level)) {
return one;
}
}
if (i > 20)
return null;
}
if (i > 20)
return null;
}
}
public int getMaxDailyQuests() {
return maxDailyQuests;
return maxDailyQuests;
}
public void setMaxDailyQuests(int maxDailyQuests) {
this.maxDailyQuests = maxDailyQuests;
this.maxDailyQuests = maxDailyQuests;
}
public int getId() {
return id;
return id;
}
public void setId(int id) {
this.id = id;
this.id = id;
}
public List<String> getWorldBlacklist() {
return worldBlacklist;
return worldBlacklist;
}
public boolean isWorldBlackListed(Entity ent) {
return isWorldBlackListed(null, ent);
return isWorldBlackListed(null, ent);
}
public boolean isWorldBlackListed(Block block) {
return isWorldBlackListed(block, null);
return isWorldBlackListed(block, null);
}
public boolean isWorldBlackListed(Block block, Entity ent) {
if (worldBlacklist.isEmpty())
return reversedWorldBlacklist;
if (worldBlacklist.isEmpty())
return reversedWorldBlacklist;
if (block != null)
return worldBlacklist.contains(block.getWorld().getName()) != reversedWorldBlacklist;
if (block != null)
return worldBlacklist.contains(block.getWorld().getName()) != reversedWorldBlacklist;
return ent != null && worldBlacklist.contains(ent.getWorld().getName()) != reversedWorldBlacklist;
return ent != null && worldBlacklist.contains(ent.getWorld().getName()) != reversedWorldBlacklist;
}
public boolean isReversedWorldBlacklist() {
return reversedWorldBlacklist;
return reversedWorldBlacklist;
}
public void setReversedWorldBlacklist(boolean reversedWorldBlacklist) {
this.reversedWorldBlacklist = reversedWorldBlacklist;
this.reversedWorldBlacklist = reversedWorldBlacklist;
}
public boolean isIgnoreMaxJobs() {
return ignoreMaxJobs;
return ignoreMaxJobs;
}
public void setIgnoreMaxJobs(boolean ignoreMaxJobs) {
this.ignoreMaxJobs = ignoreMaxJobs;
this.ignoreMaxJobs = ignoreMaxJobs;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Job && isSame((Job) obj);
return obj instanceof Job && isSame((Job) obj);
}
public void setJobDisplayName(String jobDisplayName) {
this.jobDisplayName = jobDisplayName;
this.jobDisplayName = jobDisplayName;
}
public int getLegacyId() {
return legacyId;
return legacyId;
}
public void setLegacyId(int legacyId) {
this.legacyId = legacyId;
this.legacyId = legacyId;
}
}

View File

@ -38,127 +38,127 @@ public class JobInfo {
private Integer softIncomeLevelLimit, softExpLevelLimit, softPointsLevelLimit;
public JobInfo(ActionType actionType, int id, String meta, String name, double baseIncome, Parser moneyEquation, double baseXp, Parser xpEquation,
Parser pointsEquation, double basePoints, int fromLevel, int untilLevel, String configPath) {
this(actionType, id, meta, name, baseIncome, moneyEquation, baseXp, xpEquation, pointsEquation, basePoints, fromLevel, untilLevel, configPath, null, null, null);
Parser pointsEquation, double basePoints, int fromLevel, int untilLevel, String configPath) {
this(actionType, id, meta, name, baseIncome, moneyEquation, baseXp, xpEquation, pointsEquation, basePoints, fromLevel, untilLevel, configPath, null, null, null);
}
public JobInfo(ActionType actionType, int id, String meta, String name, double baseIncome, Parser moneyEquation, double baseXp, Parser xpEquation,
Parser pointsEquation, double basePoints, int fromLevel, int untilLevel, String configPath, Integer softIncomeLevelLimit, Integer softExpLevelLimit, Integer softPointsLevelLimit) {
this.actionType = actionType;
this.id = id;
this.meta = meta;
this.name = name;
this.baseIncome = baseIncome;
this.moneyEquation = moneyEquation;
this.pointsEquation = pointsEquation;
this.basePoints = basePoints;
this.baseXp = baseXp;
this.xpEquation = xpEquation;
this.fromLevel = fromLevel;
this.untilLevel = untilLevel;
this.configPath = configPath;
this.softIncomeLevelLimit = softIncomeLevelLimit;
this.softExpLevelLimit = softExpLevelLimit;
this.softPointsLevelLimit = softPointsLevelLimit;
Parser pointsEquation, double basePoints, int fromLevel, int untilLevel, String configPath, Integer softIncomeLevelLimit, Integer softExpLevelLimit, Integer softPointsLevelLimit) {
this.actionType = actionType;
this.id = id;
this.meta = meta;
this.name = name;
this.baseIncome = baseIncome;
this.moneyEquation = moneyEquation;
this.pointsEquation = pointsEquation;
this.basePoints = basePoints;
this.baseXp = baseXp;
this.xpEquation = xpEquation;
this.fromLevel = fromLevel;
this.untilLevel = untilLevel;
this.configPath = configPath;
this.softIncomeLevelLimit = softIncomeLevelLimit;
this.softExpLevelLimit = softExpLevelLimit;
this.softPointsLevelLimit = softPointsLevelLimit;
}
public int getFromLevel() {
return fromLevel;
return fromLevel;
}
public int getUntilLevel() {
return untilLevel;
return untilLevel;
}
public boolean isInLevelRange(int level) {
return level >= fromLevel && (level <= untilLevel || untilLevel == -1);
return level >= fromLevel && (level <= untilLevel || untilLevel == -1);
}
public String getName() {
return name;
return name;
}
public String getRealisticName() {
String materialName = name.toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().translate(actionType == ActionType.MMKILL ? name : materialName, this);
materialName = CMIChatColor.translate(materialName);
return materialName;
String materialName = name.toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().translate(actionType == ActionType.MMKILL ? name : materialName, this);
materialName = CMIChatColor.translate(materialName);
return materialName;
}
public int getId() {
return id;
return id;
}
public ActionType getActionType() {
return actionType;
return actionType;
}
public String getMeta() {
return meta;
return meta;
}
public double getBaseIncome() {
return baseIncome;
return baseIncome;
}
public double getBaseXp() {
return baseXp;
return baseXp;
}
public double getBasePoints() {
return basePoints;
return basePoints;
}
public double getIncome(double level, int numjobs, int maxJobs) {
if (softIncomeLevelLimit != null && level > softIncomeLevelLimit)
level = softIncomeLevelLimit;
if (baseIncome == 0 || !Jobs.getGCManager().PaymentMethodsMoney)
return 0;
moneyEquation.setVariable("joblevel", level);
moneyEquation.setVariable("numjobs", numjobs);
moneyEquation.setVariable("maxjobs", maxJobs);
moneyEquation.setVariable("baseincome", baseIncome);
return moneyEquation.getValue();
if (softIncomeLevelLimit != null && level > softIncomeLevelLimit)
level = softIncomeLevelLimit;
if (baseIncome == 0 || !CurrencyType.MONEY.isEnabled())
return 0;
moneyEquation.setVariable("joblevel", level);
moneyEquation.setVariable("numjobs", numjobs);
moneyEquation.setVariable("maxjobs", maxJobs);
moneyEquation.setVariable("baseincome", baseIncome);
return moneyEquation.getValue();
}
public double getExperience(double level, int numjobs, int maxJobs) {
if (softExpLevelLimit != null && level > softExpLevelLimit)
level = softExpLevelLimit;
if (baseXp == 0 || !Jobs.getGCManager().PaymentMethodsExp)
return 0;
xpEquation.setVariable("joblevel", level);
xpEquation.setVariable("numjobs", numjobs);
xpEquation.setVariable("maxjobs", maxJobs);
xpEquation.setVariable("baseexperience", baseXp);
return xpEquation.getValue();
if (softExpLevelLimit != null && level > softExpLevelLimit)
level = softExpLevelLimit;
if (baseXp == 0 || !CurrencyType.EXP.isEnabled())
return 0;
xpEquation.setVariable("joblevel", level);
xpEquation.setVariable("numjobs", numjobs);
xpEquation.setVariable("maxjobs", maxJobs);
xpEquation.setVariable("baseexperience", baseXp);
return xpEquation.getValue();
}
public double getPoints(double level, int numjobs, int maxJobs) {
if (softPointsLevelLimit != null && level > softPointsLevelLimit)
level = softPointsLevelLimit;
if (basePoints == 0 || !Jobs.getGCManager().PaymentMethodsPoints)
return 0;
pointsEquation.setVariable("joblevel", level);
pointsEquation.setVariable("numjobs", numjobs);
pointsEquation.setVariable("maxjobs", maxJobs);
pointsEquation.setVariable("basepoints", basePoints);
return pointsEquation.getValue();
if (softPointsLevelLimit != null && level > softPointsLevelLimit)
level = softPointsLevelLimit;
if (basePoints == 0 || !CurrencyType.POINTS.isEnabled())
return 0;
pointsEquation.setVariable("joblevel", level);
pointsEquation.setVariable("numjobs", numjobs);
pointsEquation.setVariable("maxjobs", maxJobs);
pointsEquation.setVariable("basepoints", basePoints);
return pointsEquation.getValue();
}
public String getConfigPath() {
return configPath;
return configPath;
}
public void setBaseIncome(double baseIncome) {
this.baseIncome = baseIncome;
this.baseIncome = baseIncome;
}
public void setBaseXp(double baseXp) {
this.baseXp = baseXp;
this.baseXp = baseXp;
}
public void setBasePoints(double basePoints) {
this.basePoints = basePoints;
this.basePoints = basePoints;
}
}

View File

@ -22,9 +22,9 @@ import java.util.HashMap;
import java.util.Map;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Container.CMINumber;
import net.Zrips.CMILib.Time.CMITimeManager;
public class JobProgression {
@ -146,7 +146,7 @@ public class JobProgression {
*/
public String getLevelFormatted() {
if (Jobs.getGCManager().RomanNumbers)
return Util.toRoman(level);
return CMINumber.toRoman(level);
return String.valueOf(level);
}

View File

@ -47,6 +47,8 @@ import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Time.CMITimeManager;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
import net.Zrips.CMILib.Version.Schedulers.CMITask;
public class JobsPlayer {
@ -1347,14 +1349,14 @@ public class JobsPlayer {
this.doneQuests = doneQuests;
}
private Integer questSignUpdateShed;
private CMITask questSignUpdateShed;
public void addDoneQuest(final Job job) {
doneQuests++;
setSaved(false);
if (questSignUpdateShed == null) {
questSignUpdateShed = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
questSignUpdateShed = CMIScheduler.get().runTaskLater(() -> {
Jobs.getSignUtil().signUpdate(job, SignTopType.questtoplist);
questSignUpdateShed = null;
}, Jobs.getGCManager().getSavePeriod() * 60 * 20L);

View File

@ -3,7 +3,7 @@ package com.gamingmesh.jobs.container;
import java.util.HashMap;
import java.util.Map;
import com.gamingmesh.jobs.stuff.TimeManage;
import net.Zrips.CMILib.Time.CMITimeManager;
public final class Log {
@ -36,7 +36,7 @@ public final class Log {
}
public void setDate() {
this.day = TimeManage.timeInInt();
this.day = CMITimeManager.timeInInt();
}
public int getDate() {

View File

@ -26,6 +26,7 @@ public class PlayerPoints {
public void takePoints(double points) {
current -= points;
total -= points;
}
public boolean havePoints(double points) {

View File

@ -4,15 +4,12 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.gamingmesh.jobs.actions.EnchantActionInfo;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Logs.CMIDebug;
import org.bukkit.Bukkit;
import org.bukkit.event.server.ServerCommandEvent;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.EnchantActionInfo;
import com.gamingmesh.jobs.stuff.Util;
public class QuestProgression {
@ -160,22 +157,24 @@ public class QuestProgression {
}
}
boolean completed = isCompleted();
Job questJob = quest.getJob();
if (questJob != null) {
if (questJob != null && completed) {
int maxQuest = jPlayer.getPlayerMaxQuest(questJob.getName());
if (maxQuest > 0 && jPlayer.getDoneQuests() >= maxQuest) {
return;
}
}
if (!isCompleted() &&
objective != null) {
if (!completed && objective != null) {
Integer old = done.getOrDefault(objective, 0);
done.put(objective, old < objective.getAmount() ? old + 1 : objective.getAmount());
}
jPlayer.setSaved(false);
//needs to re-call isCompleted() because it might have changed above.
if (!isCompleted() || !player.isOnline() || givenReward)
return;

View File

@ -24,6 +24,7 @@ import com.gamingmesh.jobs.stuff.blockLoc;
import net.Zrips.CMILib.Container.CMILocation;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Messages.CMIMessages;
public class BlockOwnerShip {
@ -380,7 +381,7 @@ public class BlockOwnerShip {
}
if (total > 0) {
Jobs.consoleMsg("&eLoaded &6" + total + " " + path.toLowerCase() + " &efor reassigning.");
CMIMessages.consoleMessage("&eLoaded &6" + total + " " + path.toLowerCase() + " &efor reassigning.");
}
}

View File

@ -0,0 +1,58 @@
package com.gamingmesh.jobs.container;
import java.util.Calendar;
import java.util.Date;
public class resetTime {
private int hour = 0;
private int minute = 0;
private int second = 0;
public resetTime(int hour, int minute, int second) {
this.hour = hour % 24;
this.minute = minute % 60;
this.second = second % 60;
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
this.hour = hour;
}
public int getMinute() {
return minute;
}
public void setMinute(int minute) {
this.minute = minute;
}
public int getSecond() {
return second;
}
public void setSecond(int second) {
this.second = second;
}
public long toMili() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, second);
if (calendar.getTimeInMillis() < System.currentTimeMillis()) {
calendar.add(Calendar.DAY_OF_YEAR, 1);
}
return calendar.getTimeInMillis();
}
}

View File

@ -41,10 +41,11 @@ import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Time.CMITimeManager;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public abstract class JobsDAO {
@ -819,7 +820,7 @@ public abstract class JobsDAO {
PreparedStatement prest = null;
ResultSet res = null;
try {
int time = TimeManage.timeInInt();
int time = CMITimeManager.timeInInt();
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.LogTable.getTableName() + "` WHERE `" + LogTableFields.time.getCollumn() + "` = ? ;");
prest.setInt(1, time);
res = prest.executeQuery();
@ -1016,10 +1017,10 @@ public abstract class JobsDAO {
public void triggerTableIdUpdate() {
// Lets convert old fields
if (!converted) {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
Jobs.consoleMsg("&6[Jobs] Converting to new database format");
CMIScheduler.get().runTaskLater(() -> {
CMIMessages.consoleMessage("&6[Jobs] Converting to new database format");
convertID();
Jobs.consoleMsg("&6[Jobs] Converted to new database format");
CMIMessages.consoleMessage("&6[Jobs] Converted to new database format");
converted = true;
}, 60L);
}
@ -2311,7 +2312,7 @@ public abstract class JobsDAO {
PreparedStatement prest = null;
ResultSet res = null;
try {
int time = TimeManage.timeInInt();
int time = CMITimeManager.timeInInt();
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.LogTable.getTableName()
+ "` WHERE `" + LogTableFields.userid.getCollumn() + "` = ? AND `" + LogTableFields.time.getCollumn() + "` = ? ;");
prest.setInt(1, player.getUserId());
@ -2508,12 +2509,12 @@ public abstract class JobsDAO {
i++;
if (ii++ >= 100000) {
Jobs.consoleMsg("&6[Jobs] Loading (" + i + ") BP");
CMIMessages.consoleMessage("&6[Jobs] Loading (" + i + ") BP");
ii = 0;
}
}
if (i > 0) {
Jobs.consoleMsg("&e[Jobs] Loaded " + i + " block protection entries. " + (System.currentTimeMillis() - timer) + "ms");
CMIMessages.consoleMessage("&e[Jobs] Loaded " + i + " block protection entries. " + (System.currentTimeMillis() - timer) + "ms");
}
} catch (SQLException e) {
e.printStackTrace();
@ -2577,7 +2578,7 @@ public abstract class JobsDAO {
conn.setAutoCommit(true);
if (i > 0)
Jobs.consoleMsg("&e[Jobs] Saved " + i + " new explorer entries.");
CMIMessages.consoleMessage("&e[Jobs] Saved " + i + " new explorer entries.");
} catch (SQLException e) {
e.printStackTrace();
} finally {
@ -2624,7 +2625,7 @@ public abstract class JobsDAO {
conn.setAutoCommit(true);
if (i > 0)
Jobs.consoleMsg("&e[Jobs] Updated " + i + " explorer entries.");
CMIMessages.consoleMessage("&e[Jobs] Updated " + i + " explorer entries.");
} catch (SQLException e) {
e.printStackTrace();

View File

@ -6,7 +6,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.LoadStatus;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
public class JobsManager {
private JobsDAO dao;
@ -70,9 +70,9 @@ public class JobsManager {
public void start() {
if (Jobs.getJobsDAO() != null) {
Jobs.consoleMsg("&eClosing existing database connection...");
CMIMessages.consoleMessage("&eClosing existing database connection...");
Jobs.getJobsDAO().closeConnections();
Jobs.consoleMsg("&eClosed");
CMIMessages.consoleMessage("&eClosed");
}
ConfigReader c = Jobs.getGCManager().getConfig();
@ -100,7 +100,7 @@ public class JobsManager {
}
} else {
if (!storageMethod.equalsIgnoreCase("sqlite")) {
Jobs.consoleMsg("&cInvalid storage method! Changing method to sqlite!");
CMIMessages.consoleMessage("&cInvalid storage method! Changing method to sqlite!");
c.set("storage.method", "sqlite");
}

View File

@ -8,7 +8,7 @@ import java.sql.Statement;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
public class JobsMySQL extends JobsDAO {
@ -52,7 +52,7 @@ public class JobsMySQL extends JobsDAO {
protected void checkUpdate() throws SQLException {
JobsConnection conn = getConnection();
if (conn == null) {
Jobs.consoleMsg("&cCould not run database updates! Could not connect to MySQL!");
CMIMessages.consoleMessage("&cCould not run database updates! Could not connect to MySQL!");
return;
}
@ -77,7 +77,7 @@ public class JobsMySQL extends JobsDAO {
@Override
public boolean createTable(String query) {
if (query == null || query.isEmpty()) {
Jobs.consoleMsg("&cCould not create table: query is empty or null.");
CMIMessages.consoleMessage("&cCould not create table: query is empty or null.");
return false;
}
JobsConnection conn = getConnection();
@ -88,7 +88,7 @@ public class JobsMySQL extends JobsDAO {
statement = conn.createStatement();
statement.execute(query);
} catch (SQLException e) {
Jobs.consoleMsg("&cCould not create table, SQLException: " + e.getMessage());
CMIMessages.consoleMessage("&cCould not create table, SQLException: " + e.getMessage());
return false;
} finally {
close(statement);
@ -111,7 +111,7 @@ public class JobsMySQL extends JobsDAO {
tables.close();
return false;
} catch (SQLException e) {
Jobs.consoleMsg("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|");
CMIMessages.consoleMessage("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|");
}
PreparedStatement insert = null;
@ -125,7 +125,7 @@ public class JobsMySQL extends JobsDAO {
return true;
}
} catch (SQLException e) {
Jobs.consoleMsg("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|");
CMIMessages.consoleMessage("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|");
} finally {
close(res);
close(insert);
@ -140,14 +140,14 @@ public class JobsMySQL extends JobsDAO {
try {
statement = getConnection().createStatement();
} catch (SQLException e) {
Jobs.consoleMsg("&cCould not check if its collumn, SQLException: " + e.getMessage());
CMIMessages.consoleMessage("&cCould not check if its collumn, SQLException: " + e.getMessage());
return false;
}
try {
statement.executeQuery("SELECT `" + collumn + "` FROM `" + table + "`;");
return true;
} catch (SQLException e) {
Jobs.consoleMsg("Not a collumn |" + "SELECT " + collumn + " FROM " + table + "|");
CMIMessages.consoleMessage("Not a collumn |" + "SELECT " + collumn + " FROM " + table + "|");
return false;
} finally {
close(statement);
@ -160,11 +160,11 @@ public class JobsMySQL extends JobsDAO {
try {
statement = getConnection().createStatement();
} catch (SQLException e) {
Jobs.consoleMsg("&cCould not add new collumn, SQLException: " + e.getMessage());
CMIMessages.consoleMessage("&cCould not add new collumn, SQLException: " + e.getMessage());
return false;
}
try {
Jobs.consoleMsg("Creating collumn |" + "ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";" + "|");
CMIMessages.consoleMessage("Creating collumn |" + "ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";" + "|");
statement.executeUpdate("ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";");
return true;
} catch (SQLException e) {
@ -179,14 +179,14 @@ public class JobsMySQL extends JobsDAO {
Statement statement = null;
try {
if (!isTable(table)) {
Jobs.consoleMsg("&cTable \"" + table + "\" does not exist.");
CMIMessages.consoleMessage("&cTable \"" + table + "\" does not exist.");
return false;
}
statement = getConnection().createStatement();
statement.executeUpdate("DELETE FROM " + table + ";");
return true;
} catch (SQLException e) {
Jobs.consoleMsg("&cCould not wipe table, SQLException: " + e.getMessage());
CMIMessages.consoleMessage("&cCould not wipe table, SQLException: " + e.getMessage());
e.printStackTrace();
return false;
} finally {
@ -199,14 +199,14 @@ public class JobsMySQL extends JobsDAO {
Statement statement = null;
try {
if (!isTable(table)) {
Jobs.consoleMsg("&cTable \"" + table + "\" does not exist.");
CMIMessages.consoleMessage("&cTable \"" + table + "\" does not exist.");
return false;
}
statement = getConnection().createStatement();
statement.executeUpdate("DROP TABLE IF EXISTS `" + table + "`;");
return true;
} catch (SQLException e) {
Jobs.consoleMsg("&cCould not wipe table, SQLException: " + e.getMessage());
CMIMessages.consoleMessage("&cCould not wipe table, SQLException: " + e.getMessage());
e.printStackTrace();
return false;
} finally {

Some files were not shown because too many files have changed in this diff Show More