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

New placeholders to get user points

- /jobs employ command needs max slots check
This commit is contained in:
montlikadani 2019-02-02 21:11:21 +01:00
parent 80f43d3f47
commit 82f5ad0fd4
15 changed files with 88 additions and 84 deletions

View File

@ -31,9 +31,9 @@
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.0.0</version>
<version>2.1.2</version>
<scope>system</scope>
<systemPath>${basedir}/libs/mcMMO.jar</systemPath>
<systemPath>${basedir}/libs/mcMMO2.1.2.jar</systemPath>
</dependency>
<!-- Vault -->
<dependency>

View File

@ -21,7 +21,7 @@ import com.gamingmesh.jobs.container.JobItems;
public class ItemBoostManager {
private static HashMap<String, JobItems> items = new HashMap<String, JobItems>();
private static HashMap<String, JobItems> items = new HashMap<>();
public ItemBoostManager() {
@ -32,7 +32,7 @@ public class ItemBoostManager {
ConfigReader cfg = null;
try {
cfg = new ConfigReader("boostedItems.yml");
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
@ -50,7 +50,7 @@ public class ItemBoostManager {
cfg.getC().set(oneI.getKey() + ".name", item.getItemStack(null).getItemMeta().hasDisplayName() ? CMIChatColor.deColorize(item.getItemStack(null).getItemMeta().getDisplayName()) : null);
cfg.getC().set(oneI.getKey() + ".lore", item.getItemStack(null).getItemMeta().hasLore() ? CMIChatColor.deColorize(item.getItemStack(null).getItemMeta().getLore()) : null);
}
List<String> ench = new ArrayList<String>();
List<String> ench = new ArrayList<>();
for (Entry<Enchantment, Integer> oneE : item.getItemStack(null).getEnchantments().entrySet()) {
ench.add(oneE.getKey().getName() + "=" + oneE.getValue());
}
@ -72,7 +72,7 @@ public class ItemBoostManager {
cfg = null;
try {
cfg = new ConfigReader("boostedItems.yml");
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
if (cfg == null)
@ -159,16 +159,16 @@ public class ItemBoostManager {
List<String> jobsS = cfg.get(one + ".jobs", Arrays.asList(""));
List<Job> jobs = new ArrayList<Job>();
List<Job> jobs = new ArrayList<>();
for (String oneJ : jobsS) {
Job job = Jobs.getJob(oneJ);
if (job == null && !oneJ.equalsIgnoreCase("all")) {
Jobs.getPluginLogger().warning("Cant determine job by " + oneJ + " name for " + one + " boosted item!");
continue;
}
if (oneJ.equalsIgnoreCase("all")) {
if (oneJ.equalsIgnoreCase("all"))
jobs.addAll(Jobs.getJobs());
} else if (job != null)
else if (job != null)
jobs.add(job);
}
@ -178,12 +178,11 @@ public class ItemBoostManager {
}
JobItems item = new JobItems(one.toLowerCase(), mat, 1, name, lore, enchants, b, jobs);
if (cfg.getC().isInt(one + ".levelFrom")) {
if (cfg.getC().isInt(one + ".levelFrom"))
item.setFromLevel(cfg.get(one + ".levelFrom", 0));
}
if (cfg.getC().isInt(one + ".levelUntil")) {
if (cfg.getC().isInt(one + ".levelUntil"))
item.setUntilLevel(cfg.get(one + ".levelUntil", 1000));
}
for (Job oneJ : jobs) {
if (oneJ == null)
@ -199,7 +198,7 @@ public class ItemBoostManager {
}
public static List<JobItems> getItemsByJob(Job job) {
List<JobItems> ls = new ArrayList<JobItems>();
List<JobItems> ls = new ArrayList<>();
for (Entry<String, JobItems> one : items.entrySet()) {
if (one.getValue().getJobs().contains(job))
ls.add(one.getValue());
@ -208,7 +207,7 @@ public class ItemBoostManager {
}
public static HashMap<String, JobItems> getItemsMapByJob(Job job) {
HashMap<String, JobItems> i = new HashMap<String, JobItems>();
HashMap<String, JobItems> i = new HashMap<>();
for (Entry<String, JobItems> one : items.entrySet()) {
if (one.getValue().getJobs().contains(job))
i.put(one.getKey(), one.getValue());

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.stuff.TimeManage;
public class Placeholder {
@ -39,6 +40,8 @@ public class Placeholder {
user_issaved,
user_displayhonorific,
user_joinedjobcount,
user_points,
user_total_points,
user_boost_$1_$2("jname/number", "money/exp/points"),
user_isin_$1("jname/number"),
user_canjoin_$1("jname/number"),
@ -103,26 +106,23 @@ public class Placeholder {
if (one.isComplex())
continue;
// String n = one.name().replace("_", "");
if (one.getName().equalsIgnoreCase(name)) {
if (one.getName().equalsIgnoreCase(name))
return one;
}
}
name = pref + name;
for (JobsPlaceHolders one : JobsPlaceHolders.values()) {
if (one.isComplex())
continue;
String n = one.getName();
if (n.equalsIgnoreCase(name)) {
if (n.equalsIgnoreCase(name))
return one;
}
}
name = "%" + pref + "_" + original + "%";
for (JobsPlaceHolders one : JobsPlaceHolders.values()) {
if (!one.isComplex())
continue;
if (!one.getComplexRegexMatchers(name).isEmpty()) {
if (!one.getComplexRegexMatchers(name).isEmpty())
return one;
}
}
// For MVdWPlaceholderAPI
// if (Jobs.getInstance().isMVdWPlaceholderAPIEnabled() && original.startsWith(pref+"_")) {
@ -379,7 +379,7 @@ public class Placeholder {
if (placeHolder == null)
return null;
// Placeholders by JobsPLayer object
// Placeholders by JobsPlayer object
if (user != null) {
switch (placeHolder) {
case user_id:
@ -398,6 +398,12 @@ public class Placeholder {
return TimeManage.to24hourShort(System.currentTimeMillis() - user.getSeen());
case user_totallevels:
return String.valueOf(user.getTotalLevels());
case user_points:
PlayerPoints pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(user.getPlayerUUID());
return String.valueOf(pointInfo.getCurrentPoints());
case user_total_points:
pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(user.getPlayerUUID());
return String.valueOf(pointInfo.getTotalPoints());
case user_issaved:
return convert(user.isSaved());
case user_displayhonorific:
@ -469,23 +475,19 @@ public class Placeholder {
if (job == null)
return "";
if (!Jobs.getCommandManager().hasJobPermission(player, job)) {
if (!Jobs.getCommandManager().hasJobPermission(player, job))
return convert(false);
}
if (user.isInJob(job)) {
if (user.isInJob(job))
return convert(false);
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots())
return convert(false);
}
int confMaxJobs = Jobs.getGCManager().getMaxJobs();
short PlayerMaxJobs = (short) user.getJobProgression().size();
if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(user, PlayerMaxJobs)) {
if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(user, PlayerMaxJobs))
return convert(false);
}
return convert(true);

View File

@ -22,21 +22,17 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.api.JobsJoinEvent;
import com.gamingmesh.jobs.api.JobsLeaveEvent;
@ -58,7 +54,6 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.dao.JobsDAOData;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.economy.PointsData;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.PerformCommands;
public class PlayerManager {
@ -727,19 +722,13 @@ public class PlayerManager {
public BoostMultiplier getItemBoostNBT(Player player, Job prog) {
HashMap<Job, ItemBonusCache> cj = cache.get(player.getUniqueId());
HashMap<Job, ItemBonusCache> cj = cache == null ? new HashMap<Job, ItemBonusCache>() : cache.get(player.getUniqueId());
if (cj == null) {
cj = new HashMap<>();
cache.put(player.getUniqueId(), cj);
}
if (cache.get(player.getUniqueId()) != null)
cj = cache.get(player.getUniqueId());
if (cj == null)
return null;
ItemBonusCache c = cj.get(prog);
if (c == null) {
c = new ItemBonusCache(player, prog);
@ -762,7 +751,7 @@ public class PlayerManager {
data.add(jitem.getBoost(this.getJobsPlayer(player).getJobProgression(prog)));
for (ItemStack OneArmor : player.getInventory().getArmorContents()) {
if (OneArmor == null || OneArmor.getType() == Material.AIR)
if (OneArmor == null || OneArmor.getType() == org.bukkit.Material.AIR)
continue;
JobItems armorboost = getJobsItemByNbt(OneArmor);

View File

@ -3,7 +3,6 @@ package com.gamingmesh.jobs.Signs;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
@ -17,10 +16,8 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.config.CommentedYamlConfiguration;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.stuff.Debug;
public class SignUtil {
@ -279,7 +276,7 @@ public class SignUtil {
return;
}
}, timelapse * Jobs.getGCManager().InfoUpdateInterval * 20L);
} catch (Exception | Error e) {
} catch (Throwable e) {
e.printStackTrace();
}
return true;

View File

@ -39,6 +39,14 @@ public class employ implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getChatColor() + job.getName()));
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
String message = Jobs.getLanguage().getMessage("command.join.error.fullslots");
message = message.replace("%jobname%", job.getChatColor() + job.getName());
sender.sendMessage(message);
return true;
}
try {
// check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job);

View File

@ -505,6 +505,7 @@ public class LanguageManager {
c.get("command.employ.help.args", "[playername] [jobname]");
Jobs.getGCManager().commandArgs.put("employ", Arrays.asList("[playername]", "[jobname]"));
c.get("command.employ.error.alreadyin", "Player is already in the job %jobname%.");
c.get("command.employ.error.fullslots", "You cannot join the job %jobname%, there are no slots available.");
c.get("command.employ.output.target", "You have been employed as a %jobname%.");
c.get("command.top.help.info", "Shows top %amount% players by jobs name.");

View File

@ -1,14 +1,12 @@
package com.gamingmesh.jobs.config;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import com.gamingmesh.jobs.Jobs;

View File

@ -1,13 +1,10 @@
package com.gamingmesh.jobs.config;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ConfigReader;
@ -53,7 +50,7 @@ public class TitleManager {
ConfigReader c = null;
try {
c = new ConfigReader("titleConfig.yml");
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
if (c == null)

View File

@ -33,7 +33,6 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
import com.gamingmesh.jobs.stuff.TimeManage;

View File

@ -157,7 +157,7 @@ public class JobsListener implements Listener {
if (!player.hasPermission("jobs.area.select"))
return;
if (player.getGameMode() == GameMode.CREATIVE)
if (player.getGameMode().equals(GameMode.CREATIVE))
event.setCancelled(true);
Block block = event.getClickedBlock();
@ -190,6 +190,9 @@ public class JobsListener implements Listener {
Player player = (Player) event.getWhoClicked();
if (player == null)
return;
if (!Jobs.getShopManager().GuiList.containsKey(player.getName()))
return;
@ -348,6 +351,9 @@ public class JobsListener implements Listener {
Player player = event.getPlayer();
if (player == null)
return;
if (!isInteractOk(player))
return;
@ -388,6 +394,9 @@ public class JobsListener implements Listener {
Player player = event.getPlayer();
if (player == null)
return;
Sign sign = (Sign) block.getState();
String FirstLine = sign.getLine(0);
if (FirstLine.equalsIgnoreCase(Jobs.getLanguage().getMessage("signs.topline")))
@ -445,6 +454,9 @@ public class JobsListener implements Listener {
Player player = event.getPlayer();
if (player == null)
return;
if (!player.hasPermission("jobs.command.signs")) {
event.setCancelled(true);
player.sendMessage(Jobs.getLanguage().getMessage("signs.cantcreate"));
@ -640,7 +652,10 @@ public class JobsListener implements Listener {
return;
Player player = event.getPlayer();
ItemStack iih = player.getItemInHand();
if (player == null)
return;
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
if (iih == null)
return;
@ -810,22 +825,20 @@ public class JobsListener implements Listener {
newArmorType = ArmorTypes.matchType(hotbarItem);
newArmorPiece = hotbarItem;
oldArmorPiece = event.getClickedInventory().getItem(event.getSlot());
} else {
} else
newArmorType = ArmorTypes.matchType(oldArmorPiece != null && oldArmorPiece.getType() != Material.AIR ? oldArmorPiece : event.getCursor());
}
}
} else {
} else
newArmorType = ArmorTypes.matchType(oldArmorPiece != null && oldArmorPiece.getType() != Material.AIR ? oldArmorPiece : event.getCursor());
}
if (newArmorType != null && event.getRawSlot() == newArmorType.getSlot()) {
EquipMethod method = EquipMethod.DRAG;
if (event.getAction().equals(InventoryAction.HOTBAR_SWAP) || numberkey)
method = EquipMethod.HOTBAR_SWAP;
JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent((Player) event.getWhoClicked(), method, newArmorType, oldArmorPiece, newArmorPiece);
Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent);
if (armorEquipEvent.isCancelled()) {
if (armorEquipEvent.isCancelled())
event.setCancelled(true);
}
}
}
}

View File

@ -99,7 +99,6 @@ import com.gamingmesh.jobs.container.ExploreRespond;
import com.gamingmesh.jobs.container.FastPayment;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling.ownershipFeedback;
import com.google.common.base.Objects;

View File

@ -86,10 +86,8 @@ public class TabComplete implements TabCompleter {
if (args.length > 3 && args[3].equals("limiteditems")) {
Job oneJob = Jobs.getJob(args[i - 1]);
if (oneJob != null)
if (args[3].equals("limiteditems")) {
for (Entry<String, JobLimitedItems> limitedItem : oneJob.getLimitedItems().entrySet()) {
temp.add(limitedItem.getValue().getNode());
}
for (Entry<String, JobLimitedItems> limitedItem : oneJob.getLimitedItems().entrySet()) {
temp.add(limitedItem.getValue().getNode());
}
}
break;

View File

@ -196,17 +196,17 @@ Jobs:
# if not given, then there is no limit
# this can be used for any action
until-level: 30
13:
gravel:
# you can use minuses to take away money if the player break this block
income: -1.0
experience: -1.0
experience: -1.0
# payment for stripping wood logs, only for 1.13+ servers
StripLogs:
STRIPPED_ACACIA_LOG:
stripped_acacia_log:
income: 1.0
points: 1.0
experience: 1.0
STRIPPED_OAK_LOG:
stripped_oak_log:
income: 1.0
points: 1.0
experience: 1.0
@ -314,7 +314,7 @@ Jobs:
Green:
income: 2.0
experience: 5.0
Light_Blue:
Navy:
income: 2.0
experience: 5.0
Lime:
@ -1723,7 +1723,7 @@ Jobs:
income: 4.0
points: 4.0
experience: 5.0
Light_Blue:
Navy:
income: 4.0
points: 4.0
experience: 5.0

View File

@ -85,6 +85,16 @@ command:
boostalladded: '&aTapasztalat növelése %boost% minden munkához hozzáadva!'
boostadded: '&aTapasztalat növelése &e%boost% &ahozzáadva a(z) &e%jobname% &amunkához!'
infostats: '&c-----> &aTapasztalat arány x%boost% engedélyezve&c <-------'
itembonus:
help:
info: 'Ellenőrzi az elem bónuszt.'
args: ''
output:
list: '&e[jobname]: %money% %points% %exp%'
edititembonus:
help:
info: 'Tárgybónusz szerkesztése.'
args: 'list/add/remove [jobname] [boosteditems]'
bonus:
help:
info: 'A munkabónuszok megjelenítése.'
@ -247,7 +257,7 @@ command:
give:
help:
info: 'A tárgyakat a feladatok neve és az elemek kategóriája alapján adja meg. A játékos neve opcionális.'
args: '[playername] [jobname] [items/limiteditems] [jobitemname]'
args: '[playername] [jobname]/[jobitemname] [items/limiteditems] [jobitemname]'
output:
notonline: '&4[%playername%] nem elérhető!'
noitem: '&4Nincs találat ezzel a névvel lévő tárgyról!'
@ -288,6 +298,9 @@ command:
place:
info: '&eLerak'
none: '%jobname%&c nem kap pénzt, ha blokkot helyez le.'
striplogs:
info: '&eFa hántolás'
none: '%jobname% nem kap pénzt a fák hántolásáért.'
kill:
info: '&eMegöl'
none: '%jobname%&c nem kap pénzt, ha szörnyet gyilkol.'
@ -445,6 +458,7 @@ command:
args: '[playername] [jobname]'
error:
alreadyin: '&cA játékos már dolgozik %jobname% munkánál.'
fullslots: '&cNem tudsz csatlakozni a(z) %jobname%&c munkához, mert nincsenek rendelkezésre álló helyek.'
output:
target: '&aMost már a(z) %jobname%&a munkánál dolgozik.'
top:
@ -587,16 +601,6 @@ command:
points: '&6[points] pontot,'
'on': '&aEngedélyezve: &aIgen'
'off': '&aEngedélyezve: &4Nem'
itembonus:
help:
info: 'Ellenőrzi a bónuszt.'
args: ''
output:
list: '&e[jobname]: %money% %points% %exp%'
edititembonus:
help:
info: 'Tárgybónusz szerkesztése.'
args: 'list/add/remove [jobname] [itemBoostName]'
message:
skillup:
broadcast: '%playername% játékost előléptették a %titlename% %jobname% munkában.'