1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +01:00

Removed redundant method from PaymentData

This commit is contained in:
montlikadani 2021-06-01 17:25:50 +02:00
parent 47f47bd3df
commit 28b9ebfab3
6 changed files with 36 additions and 29 deletions

View File

@ -698,8 +698,8 @@ public class ConfigManager {
if (Version.isCurrentEqualOrLower(Version.v1_12_R1)) { if (Version.isCurrentEqualOrLower(Version.v1_12_R1)) {
short legacyData = material.getLegacyData(); short legacyData = material.getLegacyData();
if (legacyData > 0) if (legacyData > 0)
subType = ":" + legacyData; subType = ":" + legacyData;
} }
id = material.getId(); id = material.getId();

View File

@ -54,11 +54,13 @@ public class NameTranslatorManager {
if (nameLs == null) { if (nameLs == null) {
mat = CMIMaterial.get(materialName.replace(" ", "")); mat = CMIMaterial.get(materialName.replace(" ", ""));
nameLs = listOfNames.get(mat);
NameList nameMeta = listOfNames.get(CMIMaterial.get(meta.replace(" ", ""))); if ((nameLs = listOfNames.get(mat)) != null) {
if (nameLs != null && nameMeta != null) { NameList nameMeta = listOfNames.get(CMIMaterial.get(meta.replace(" ", "")));
return nameLs + ":" + nameMeta;
if (nameMeta != null) {
return nameLs + ":" + nameMeta;
}
} }
if (mat == CMIMaterial.NONE) { if (mat == CMIMaterial.NONE) {
@ -76,15 +78,15 @@ public class NameTranslatorManager {
CMIMaterial mat = CMIMaterial.get(materialName); CMIMaterial mat = CMIMaterial.get(materialName);
NameList nameLs = listOfNames.get(mat); NameList nameLs = listOfNames.get(mat);
if (nameLs != null) { if (nameLs != null) {
if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) { if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) {
return nameLs.getName() + ":" + meta; return nameLs.getName() + ":" + meta;
} }
if (name != null && !name.isEmpty()) { if (name != null && !name.isEmpty()) {
return nameLs.getName(); return nameLs.getName();
}
} }
}
if (id > 0 && meta != null && !meta.isEmpty()) { if (id > 0 && meta != null && !meta.isEmpty()) {
mat = CMIMaterial.get(id + ":" + meta); mat = CMIMaterial.get(id + ":" + meta);

View File

@ -53,10 +53,6 @@ public class PaymentData {
return data == null ? 0D : (int) (data.getAmount() * 100) / 100D; return data == null ? 0D : (int) (data.getAmount() * 100) / 100D;
} }
public Double getAmountBylimit(CurrencyType type, int limit) {
return getAmount(type) > limit ? (double) limit : (int) (getAmount(type) * 100) / 100D;
}
public Long getLastAnnounced() { public Long getLastAnnounced() {
return lastAnnouced; return lastAnnouced;
} }

View File

@ -439,7 +439,7 @@ public class JobsListener implements Listener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onChunkChangeMove(PlayerMoveEvent event) { public void onChunkChangeMove(PlayerMoveEvent event) {
if (!event.getPlayer().isOnline() || event.getTo() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getTo().getWorld())) if (!event.getPlayer().isOnline() || !Jobs.getGCManager().canPerformActionInWorld(event.getTo().getWorld()))
return; return;
Chunk from = event.getFrom().getChunk(); Chunk from = event.getFrom().getChunk();

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -32,6 +33,8 @@ public final class JobsPayment14Listener implements Listener {
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
return; return;
Location blockLoc = event.getBlock().getLocation();
for (Map.Entry<UUID, List<PlayerCamp>> map : campPlayers.entrySet()) { for (Map.Entry<UUID, List<PlayerCamp>> map : campPlayers.entrySet()) {
List<PlayerCamp> camps = map.getValue(); List<PlayerCamp> camps = map.getValue();
@ -41,7 +44,7 @@ public final class JobsPayment14Listener implements Listener {
} }
for (PlayerCamp camp : new ArrayList<>(camps)) { for (PlayerCamp camp : new ArrayList<>(camps)) {
if (camp.getBlock().getLocation().equals(event.getBlock().getLocation())) { if (camp.getBlock().getLocation().equals(blockLoc)) {
if (camp.getItem().equals(event.getSource())) { if (camp.getItem().equals(event.getSource())) {
camps.remove(camp); camps.remove(camp);
@ -64,23 +67,27 @@ public final class JobsPayment14Listener implements Listener {
if (event.getBlock().getType() != Material.CAMPFIRE || campPlayers.isEmpty()) if (event.getBlock().getType() != Material.CAMPFIRE || campPlayers.isEmpty())
return; return;
List<PlayerCamp> camps = campPlayers.get(event.getPlayer().getUniqueId()); UUID playerUId = event.getPlayer().getUniqueId();
List<PlayerCamp> camps = campPlayers.get(playerUId);
if (camps == null) if (camps == null)
return; return;
if (camps.isEmpty()) { if (camps.isEmpty()) {
campPlayers.remove(event.getPlayer().getUniqueId()); campPlayers.remove(playerUId);
return; return;
} }
Location blockLoc = event.getBlock().getLocation();
for (PlayerCamp camp : new ArrayList<>(camps)) { for (PlayerCamp camp : new ArrayList<>(camps)) {
if (camp.getBlock().getLocation().equals(event.getBlock().getLocation())) { if (camp.getBlock().getLocation().equals(blockLoc)) {
camps.remove(camp); camps.remove(camp);
if (camps.isEmpty()) { if (camps.isEmpty()) {
campPlayers.remove(event.getPlayer().getUniqueId()); campPlayers.remove(event.getPlayer().getUniqueId());
campPlayers.remove(playerUId);
} else { } else {
campPlayers.put(event.getPlayer().getUniqueId(), camps); campPlayers.put(playerUId, camps);
} }
break; break;

View File

@ -1662,13 +1662,13 @@ public class JobsPaymentListener implements Listener {
&& !Jobs.getGCManager().payExploringWhenGliding && player.isGliding()) && !Jobs.getGCManager().payExploringWhenGliding && player.isGliding())
return; return;
org.bukkit.World playerWorld = player.getWorld(); if (!payIfCreative(player))
// check if in creative
if (!Jobs.getGCManager().canPerformActionInWorld(playerWorld) || !payIfCreative(player))
return; return;
if (!Jobs.getPermissionHandler().hasWorldPermission(player, playerWorld.getName())) org.bukkit.World playerWorld = player.getWorld();
if (!Jobs.getGCManager().canPerformActionInWorld(playerWorld)
|| !Jobs.getPermissionHandler().hasWorldPermission(player, playerWorld.getName()))
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
@ -1715,7 +1715,9 @@ public class JobsPaymentListener implements Listener {
for (Entry<Enchantment, Integer> oneG : got.entrySet()) { for (Entry<Enchantment, Integer> oneG : got.entrySet()) {
Map<Enchantment, Integer> map = hand.getEnchantments(); Map<Enchantment, Integer> map = hand.getEnchantments();
if (!map.containsKey(oneG.getKey()) || map.get(oneG.getKey()).equals(oneG.getValue())) Integer key = map.get(oneG.getKey());
if (key == null || key.equals(oneG.getValue()))
return false; return false;
} }