1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +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)) {
short legacyData = material.getLegacyData();
if (legacyData > 0)
subType = ":" + legacyData;
if (legacyData > 0)
subType = ":" + legacyData;
}
id = material.getId();

View File

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

View File

@ -53,10 +53,6 @@ public class PaymentData {
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() {
return lastAnnouced;
}

View File

@ -439,7 +439,7 @@ public class JobsListener implements Listener {
@EventHandler(ignoreCancelled = true)
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;
Chunk from = event.getFrom().getChunk();

View File

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

View File

@ -1662,13 +1662,13 @@ public class JobsPaymentListener implements Listener {
&& !Jobs.getGCManager().payExploringWhenGliding && player.isGliding())
return;
org.bukkit.World playerWorld = player.getWorld();
// check if in creative
if (!Jobs.getGCManager().canPerformActionInWorld(playerWorld) || !payIfCreative(player))
if (!payIfCreative(player))
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;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
@ -1715,7 +1715,9 @@ public class JobsPaymentListener implements Listener {
for (Entry<Enchantment, Integer> oneG : got.entrySet()) {
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;
}