1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Fix nearspawner does not accepts minus values

Fixes #998
This commit is contained in:
montlikadani 2020-11-13 08:04:03 +01:00
parent f7313be846
commit f55c02570e
5 changed files with 60 additions and 73 deletions

View File

@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.16.3-R0.1-SNAPSHOT</version> <version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- McMMO --> <!-- McMMO -->
@ -153,6 +153,7 @@
<groupId>com.github.Nathat23</groupId> <groupId>com.github.Nathat23</groupId>
<artifactId>StackMob-5</artifactId> <artifactId>StackMob-5</artifactId>
<version>master-SNAPSHOT</version> <version>master-SNAPSHOT</version>
<scope>provided</scope>
</dependency> </dependency>
<!-- MyPet --> <!-- MyPet -->
<dependency> <dependency>
@ -220,7 +221,7 @@
<!-- Make a Jar --> <!-- Make a Jar -->
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version> <version>3.8.1</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>

View File

@ -258,9 +258,7 @@ public class PlayerManager {
* Save all the information of all of the players * Save all the information of all of the players
*/ */
public void convertChacheOfPlayers(boolean resetID) { public void convertChacheOfPlayers(boolean resetID) {
int y = 0; int y = 0, i = 0, total = playersUUIDCache.size();
int i = 0;
int total = playersUUIDCache.size();
for (JobsPlayer jPlayer : playersUUIDCache.values()) { for (JobsPlayer jPlayer : playersUUIDCache.values()) {
if (resetID) if (resetID)
@ -917,11 +915,8 @@ public class PlayerManager {
if (itemName == null) if (itemName == null)
return null; return null;
} }
JobItems b = ItemBoostManager.getItemByKey(itemName.toString());
if (b == null)
return null;
return b; return ItemBoostManager.getItemByKey(itemName.toString());
} }
// public BoostMultiplier getJobsBoostByNbt(ItemStack item) { // public BoostMultiplier getJobsBoostByNbt(ItemStack item) {
@ -960,34 +955,34 @@ public class PlayerManager {
if (HookManager.getMcMMOManager().mcMMOPresent || HookManager.getMcMMOManager().mcMMOOverHaul) if (HookManager.getMcMMOManager().mcMMOPresent || HookManager.getMcMMOManager().mcMMOOverHaul)
boost.add(BoostOf.McMMO, new BoostMultiplier().add(HookManager.getMcMMOManager().getMultiplier(player.getPlayer()))); boost.add(BoostOf.McMMO, new BoostMultiplier().add(HookManager.getMcMMOManager().getMultiplier(player.getPlayer())));
Double petPay = null; double petPay = 0D;
if (ent instanceof Tameable) { if (ent instanceof Tameable) {
Tameable t = (Tameable) ent; Tameable t = (Tameable) ent;
if (t.isTamed() && t.getOwner() instanceof Player) { if (t.isTamed() && t.getOwner() instanceof Player) {
petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false, true); petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false, true);
if (petPay != null) if (petPay != 0D)
boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay));
} }
} }
if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent, player.getPlayer())) { if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent, player.getPlayer())) {
if (petPay == null) if (petPay == 0D)
petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false, true); petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false, true);
if (petPay != null) if (petPay != 0D)
boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay));
} }
if (victim != null && victim.hasMetadata(getMobSpawnerMetadata())) { if (victim != null && victim.hasMetadata(getMobSpawnerMetadata())) {
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner"); Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", false, false, true);
if (amount != null) if (amount != 0D)
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount)); boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));
} }
if (getall) { if (getall) {
if (petPay == null) if (petPay == 0D)
petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force, false, true); petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force, false, true);
if (petPay != null) if (petPay != 0D)
boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay));
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force); Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force);
if (amount != null) if (amount != null)

View File

@ -51,7 +51,7 @@ public class ExploreChunk {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
for (Integer one : playerIds) { for (Integer one : playerIds) {
if (!s.toString().isEmpty()) if (!s.toString().isEmpty())
s.append(";"); s.append(';');
s.append(one); s.append(one);
} }
return s.toString(); return s.toString();

View File

@ -153,16 +153,14 @@ public class JobsPlayer {
public boolean isUnderLimit(CurrencyType type, Double amount) { public boolean isUnderLimit(CurrencyType type, Double amount) {
Player player = getPlayer(); Player player = getPlayer();
if (player == null) if (player == null || amount == 0)
return true;
if (amount == 0)
return true; return true;
CurrencyLimit limit = Jobs.getGCManager().getLimit(type); CurrencyLimit limit = Jobs.getGCManager().getLimit(type);
if (!limit.isEnabled()) if (!limit.isEnabled())
return true; return true;
PaymentData data = getPaymentLimit(); PaymentData data = getPaymentLimit();
Integer value = limits.get(type); Integer value = limits.getOrDefault(type, 0);
if (data.isReachedLimit(type, value == null ? 0 : value)) { if (data.isReachedLimit(type, value)) {
String name = type.getName().toLowerCase(); String name = type.getName().toLowerCase();
if (player.isOnline() && !data.isInformed() && !data.isReseted(type)) { if (player.isOnline() && !data.isInformed() && !data.isReseted(type)) {

View File

@ -6,34 +6,27 @@ import java.util.List;
public class ShopItem { public class ShopItem {
private String NodeName = null;
private double price = 0D; private double price = 0D;
private int slot = -1; private int slot = -1, page = -1, iconAmount = 1;
private int page = -1;
private String IconMaterial = null; private String nodeName = null, iconMaterial = null, iconName = null;
private int IconAmount = 1;
private String IconName = null;
private final List<String> IconLore = new ArrayList<>();
private boolean HideWithoutPerm = false; private boolean hideWithoutPerm = false;
private boolean hideNoEnoughPoint = false; private boolean hideNoEnoughPoint = false;
private int RequiredTotalLevels = -1; private int requiredTotalLevels = -1;
private HashMap<String, Integer> RequiredJobs = new HashMap<>(); private HashMap<String, Integer> requiredJobs = new HashMap<>();
private final List<String> RequiredPerm = new ArrayList<>(); private final List<String> iconLore = new ArrayList<>(), requiredPerm = new ArrayList<>(), commands = new ArrayList<>();
private final List<String> Commands = new ArrayList<>();
private final List<JobItems> items = new ArrayList<>(); private final List<JobItems> items = new ArrayList<>();
private String PlayerName; private String playerName;
private boolean useCurrentPlayer = false; private boolean useCurrentPlayer = false;
public ShopItem(String NodeName, double price) { public ShopItem(String nodeName, double price) {
this.NodeName = NodeName; this.nodeName = nodeName;
this.price = price; this.price = price;
} }
@ -62,30 +55,30 @@ public class ShopItem {
return items; return items;
} }
public void setCommands(List<String> Commands) { public void setCommands(List<String> commands) {
this.Commands.clear(); this.commands.clear();
this.Commands.addAll(Commands == null ? new ArrayList<>() : Commands); this.commands.addAll(commands == null ? new ArrayList<>() : commands);
} }
public List<String> getCommands() { public List<String> getCommands() {
return Commands; return commands;
} }
public void setRequiredJobs(HashMap<String, Integer> RequiredJobs) { public void setRequiredJobs(HashMap<String, Integer> requiredJobs) {
this.RequiredJobs = RequiredJobs; this.requiredJobs = requiredJobs;
} }
public HashMap<String, Integer> getRequiredJobs() { public HashMap<String, Integer> getRequiredJobs() {
return RequiredJobs; return requiredJobs;
} }
public void setRequiredPerm(List<String> RequiredPerm) { public void setRequiredPerm(List<String> requiredPerm) {
this.RequiredPerm.clear(); this.requiredPerm.clear();
this.RequiredPerm.addAll(RequiredPerm == null ? new ArrayList<>() : RequiredPerm); this.requiredPerm.addAll(requiredPerm == null ? new ArrayList<>() : requiredPerm);
} }
public List<String> getRequiredPerm() { public List<String> getRequiredPerm() {
return RequiredPerm; return requiredPerm;
} }
public void setHideIfThereIsNoEnoughPoints(boolean hideNoEnoughPoint) { public void setHideIfThereIsNoEnoughPoints(boolean hideNoEnoughPoint) {
@ -96,69 +89,69 @@ public class ShopItem {
return hideNoEnoughPoint; return hideNoEnoughPoint;
} }
public void setHideWithoutPerm(boolean HideWithoutPerm) { public void setHideWithoutPerm(boolean hideWithoutPerm) {
this.HideWithoutPerm = HideWithoutPerm; this.hideWithoutPerm = hideWithoutPerm;
} }
public boolean isHideWithoutPerm() { public boolean isHideWithoutPerm() {
return HideWithoutPerm; return hideWithoutPerm;
} }
public void setIconLore(List<String> IconLore) { public void setIconLore(List<String> iconLore) {
this.IconLore.clear(); this.iconLore.clear();
this.IconLore.addAll(IconLore == null ? new ArrayList<>() : IconLore); this.iconLore.addAll(iconLore == null ? new ArrayList<>() : iconLore);
} }
public List<String> getIconLore() { public List<String> getIconLore() {
return IconLore; return iconLore;
} }
public String getNodeName() { public String getNodeName() {
return NodeName; return nodeName;
} }
public String getIconMaterial() { public String getIconMaterial() {
return IconMaterial; return iconMaterial;
} }
public void setIconMaterial(String IconMaterial) { public void setIconMaterial(String iconMaterial) {
this.IconMaterial = IconMaterial; this.iconMaterial = iconMaterial;
} }
public double getPrice() { public double getPrice() {
return price; return price;
} }
public void setIconAmount(int IconAmount) { public void setIconAmount(int iconAmount) {
this.IconAmount = IconAmount; this.iconAmount = iconAmount;
} }
public int getIconAmount() { public int getIconAmount() {
return IconAmount; return iconAmount;
} }
public void setIconName(String IconName) { public void setIconName(String iconName) {
this.IconName = IconName; this.iconName = iconName;
} }
public String getIconName() { public String getIconName() {
return IconName; return iconName;
} }
public int getRequiredTotalLevels() { public int getRequiredTotalLevels() {
return RequiredTotalLevels; return requiredTotalLevels;
} }
public void setRequiredTotalLevels(int RequiredTotalLevels) { public void setRequiredTotalLevels(int requiredTotalLevels) {
this.RequiredTotalLevels = RequiredTotalLevels; this.requiredTotalLevels = requiredTotalLevels;
} }
public String getCustomHead() { public String getCustomHead() {
return PlayerName; return playerName;
} }
public void setCustomHead(String PlayerName) { public void setCustomHead(String playerName) {
this.PlayerName = PlayerName; this.playerName = playerName;
} }
public boolean isHeadOwner() { public boolean isHeadOwner() {