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

Lowercase some method names in paymentData

This commit is contained in:
montlikadani 2020-10-08 21:02:36 +02:00
parent 20594c3e91
commit ee21d95a43
14 changed files with 114 additions and 197 deletions

View File

@ -2657,7 +2657,7 @@ public enum CMIMaterial {
} }
public boolean equals(Material mat) { public boolean equals(Material mat) {
return getMaterial() != null && getMaterial() == mat; return getMaterial() == mat;
} }
public List<String> getLegacyNames() { public List<String> getLegacyNames() {

View File

@ -456,10 +456,10 @@ public class Placeholder {
return Integer.toString(user.getLimit(t)); return Integer.toString(user.getLimit(t));
case plimit_$1: case plimit_$1:
t = CurrencyType.getByName(vals.get(0)); t = CurrencyType.getByName(vals.get(0));
return Double.toString(user.getPaymentLimit().GetAmount(t)); return Double.toString(user.getPaymentLimit().getAmount(t));
case plimit_tleft_$1: case plimit_tleft_$1:
t = CurrencyType.getByName(vals.get(0)); t = CurrencyType.getByName(vals.get(0));
return TimeManage.to24hourShort(user.getPaymentLimit().GetLeftTime(t)); return TimeManage.to24hourShort(user.getPaymentLimit().getLeftTime(t));
case user_jlevel_$1: case user_jlevel_$1:
return j == null ? "0" : Integer.toString(j.getLevel()); return j == null ? "0" : Integer.toString(j.getLevel());
case user_jexp_$1: case user_jexp_$1:

View File

@ -351,7 +351,7 @@ public class SignUtil {
return; return;
Skull skull = (Skull) b.getState(); Skull skull = (Skull) b.getState();
if (skull.getOwner() != null && skull.getOwner().equalsIgnoreCase(Playername)) if (Playername.equalsIgnoreCase(skull.getOwner()))
return; return;
skull.setOwner(Playername); skull.setOwner(Playername);

View File

@ -81,9 +81,7 @@ public class jobsSign {
} }
public static String locToBlockString(Location loc) { public static String locToBlockString(Location loc) {
if (loc == null) return loc == null ? "" : loc.getWorld().getName() + ";" + loc.getBlockX() + ";" + loc.getBlockY() + ";" + loc.getBlockZ();
return "";
return loc.getWorld().getName() + ";" + loc.getBlockX() + ";" + loc.getBlockY() + ";" + loc.getBlockZ();
} }
public void setLoc(Location loc) { public void setLoc(Location loc) {
@ -101,7 +99,7 @@ public class jobsSign {
if (!string.contains(";")) if (!string.contains(";"))
return; return;
String[] split = string.replace(",", ".").split(";"); String[] split = string.replace(',', '.').split(";");
int x = 0, y = 0, z = 0; int x = 0, y = 0, z = 0;

View File

@ -60,10 +60,10 @@ public class limit implements Cmd {
"%total%", JPlayer.getLimit(type))); "%total%", JPlayer.getLimit(type)));
continue; continue;
} }
if (limit.GetLeftTime(type) > 0) { if (limit.getLeftTime(type) > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.GetLeftTime(type)))); sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.getLeftTime(type))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit", sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit",
"%current%", (int) (limit.GetAmount(type) * 100) / 100D, "%current%", (int) (limit.getAmount(type) * 100) / 100D,
"%total%", JPlayer.getLimit(type))); "%total%", JPlayer.getLimit(type)));
} }
} }

View File

@ -25,6 +25,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -161,7 +162,7 @@ public class JobsPlayer {
return true; return true;
PaymentData data = getPaymentLimit(); PaymentData data = getPaymentLimit();
Integer value = limits.get(type); Integer value = limits.get(type);
if (data.IsReachedLimit(type, value == null ? 0 : value)) { if (data.isReachedLimit(type, value == null ? 0 : value)) {
String name = type.getName().toLowerCase(); String name = type.getName().toLowerCase();
if (player.isOnline() && !data.isInformed() && !data.isReseted()) { if (player.isOnline() && !data.isInformed() && !data.isReseted()) {
@ -173,15 +174,15 @@ public class JobsPlayer {
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reached" + name + "limit")); player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reached" + name + "limit"));
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reached" + name + "limit2")); player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reached" + name + "limit2"));
} }
data.setInformed(); data.setInformed(true);
} }
if (data.IsAnnounceTime(limit.getAnnouncementDelay()) && player.isOnline()) if (data.isAnnounceTime(limit.getAnnouncementDelay()) && player.isOnline())
ActionBarManager.send(player, Jobs.getLanguage().getMessage("command.limit.output." + name + "time", "%time%", TimeManage.to24hourShort(data.GetLeftTime(type)))); ActionBarManager.send(player, Jobs.getLanguage().getMessage("command.limit.output." + name + "time", "%time%", TimeManage.to24hourShort(data.getLeftTime(type))));
if (data.isReseted()) if (data.isReseted())
data.setReseted(false); data.setReseted(false);
return false; return false;
} }
data.AddAmount(type, amount); data.addAmount(type, amount);
return true; return true;
} }
@ -1067,10 +1068,7 @@ public class JobsPlayer {
} }
} }
List<QuestProgression> pr = new ArrayList<>(); return tmp.values().stream().collect(Collectors.toList());
tmp.values().forEach(pr::add);
return pr;
} }
public String getQuestProgressionString() { public String getQuestProgressionString() {
@ -1203,7 +1201,7 @@ public class JobsPlayer {
public int getMaxBrewingStandsAllowed() { public int getMaxBrewingStandsAllowed() {
Double maxV = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxbrewingstands"); Double maxV = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxbrewingstands");
if (maxV == null || maxV == 0) if (maxV == 0)
maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault(); maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault();
return maxV.intValue(); return maxV.intValue();

View File

@ -1281,15 +1281,15 @@ public abstract class JobsDAO {
for (CurrencyType type : CurrencyType.values()) { for (CurrencyType type : CurrencyType.values()) {
if (limit == null) if (limit == null)
continue; continue;
if (limit.GetAmount(type) == 0D) if (limit.getAmount(type) == 0D)
continue; continue;
if (limit.GetLeftTime(type) < 0) if (limit.getLeftTime(type) < 0)
continue; continue;
prest.setInt(1, jPlayer.getUserId()); prest.setInt(1, jPlayer.getUserId());
prest.setInt(2, type.getId()); prest.setInt(2, type.getId());
prest.setDouble(3, limit.GetAmount(type)); prest.setDouble(3, limit.getAmount(type));
prest.setLong(4, limit.GetTime(type)); prest.setLong(4, limit.getTime(type));
prest.setString(5, type.toString()); prest.setString(5, type.toString());
prest.addBatch(); prest.addBatch();
} }
@ -1333,7 +1333,7 @@ public abstract class JobsDAO {
if (type == null) if (type == null)
continue; continue;
data.AddNewAmount(type, res.getDouble(LimitTableFields.collected.getCollumn()), res.getLong(LimitTableFields.started.getCollumn())); data.addNewAmount(type, res.getDouble(LimitTableFields.collected.getCollumn()), res.getLong(LimitTableFields.started.getCollumn()));
} }
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
@ -1372,7 +1372,7 @@ public abstract class JobsDAO {
if (type == null) if (type == null)
continue; continue;
data.AddNewAmount(type, res.getDouble(LimitTableFields.collected.getCollumn()), res.getLong(LimitTableFields.started.getCollumn())); data.addNewAmount(type, res.getDouble(LimitTableFields.collected.getCollumn()), res.getLong(LimitTableFields.started.getCollumn()));
map.put(id, data); map.put(id, data);
} }
} catch (SQLException e) { } catch (SQLException e) {

View File

@ -207,31 +207,25 @@ public class BufferedEconomy {
} }
public void ShowActionBar(BufferedPayment payment) { public void ShowActionBar(BufferedPayment payment) {
if (payment.getOfflinePlayer() == null || !payment.getOfflinePlayer().isOnline()) if (payment.getOfflinePlayer() == null || !payment.getOfflinePlayer().isOnline()
|| !Jobs.getGCManager().ActionBarsMessageByDefault || !payment.containsPayment())
return; return;
if (!Jobs.getGCManager().ActionBarsMessageByDefault) UUID playerUUID = payment.getOfflinePlayer().getUniqueId();
return; Boolean show = ToggleBarHandling.getActionBarToggle().getOrDefault(playerUUID.toString(), true);
Player abp = Bukkit.getPlayer(playerUUID);
if (!payment.containsPayment()) if (abp != null && show.booleanValue()) {
return;
String playerUUID = payment.getOfflinePlayer().getUniqueId().toString();
Boolean show = ToggleBarHandling.getActionBarToggle().getOrDefault(playerUUID, true);
Player abp = Bukkit.getPlayer(payment.getOfflinePlayer().getUniqueId());
if ((abp != null) && (show.booleanValue())) {
String Message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main"); String Message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main");
if (payment.get(CurrencyType.MONEY) != 0D) { if (payment.get(CurrencyType.MONEY) != 0D) {
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format(Jobs.getGCManager().getDecimalPlacesMoney(), Message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format(Jobs.getGCManager().getDecimalPlacesMoney(),
payment.get(CurrencyType.MONEY))); payment.get(CurrencyType.MONEY)));
} }
if (payment.get(CurrencyType.POINTS) != 0D) { if (payment.get(CurrencyType.POINTS) != 0D) {
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format(Jobs.getGCManager().getDecimalPlacesPoints(), Message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format(Jobs.getGCManager().getDecimalPlacesPoints(),
payment.get(CurrencyType.POINTS))); payment.get(CurrencyType.POINTS)));
} }
if (payment.get(CurrencyType.EXP) != 0D) { if (payment.get(CurrencyType.EXP) != 0D) {
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(), Message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(),
payment.get(CurrencyType.EXP))); payment.get(CurrencyType.EXP)));
} }
ActionBarManager.send(abp, Message); ActionBarManager.send(abp, Message);

View File

@ -8,10 +8,12 @@ import com.gamingmesh.jobs.container.CurrencyType;
public class PaymentData { public class PaymentData {
private Long lastAnnouced = 0L; private Long lastAnnouced = 0L;
private HashMap<CurrencyType, Double> payments = new HashMap<>();
private HashMap<CurrencyType, Long> paymentsTimes = new HashMap<>(); private final HashMap<CurrencyType, Double> payments = new HashMap<>();
private boolean Informed = false; private final HashMap<CurrencyType, Long> paymentsTimes = new HashMap<>();
private boolean Reseted = false;
private boolean informed = false;
private boolean reseted = false;
public PaymentData(Long time, Double Payment, Double Points, Double Exp, Long lastAnnouced, boolean Informed) { public PaymentData(Long time, Double Payment, Double Points, Double Exp, Long lastAnnouced, boolean Informed) {
paymentsTimes.put(CurrencyType.EXP, time); paymentsTimes.put(CurrencyType.EXP, time);
@ -20,127 +22,114 @@ public class PaymentData {
payments.put(CurrencyType.EXP, Exp); payments.put(CurrencyType.EXP, Exp);
payments.put(CurrencyType.MONEY, Payment); payments.put(CurrencyType.MONEY, Payment);
payments.put(CurrencyType.POINTS, Points); payments.put(CurrencyType.POINTS, Points);
this.lastAnnouced = lastAnnouced; this.lastAnnouced = lastAnnouced;
this.Informed = Informed; this.informed = Informed;
} }
public PaymentData(CurrencyType type, Double amount) { public PaymentData(CurrencyType type, Double amount) {
paymentsTimes.put(type, System.currentTimeMillis()); paymentsTimes.put(type, System.currentTimeMillis());
payments.put(type, amount); payments.put(type, amount);
this.lastAnnouced = 0L; this.lastAnnouced = 0L;
this.Informed = false; this.informed = false;
} }
public PaymentData() { public PaymentData() {
resetLimits(); resetLimits();
} }
public Long GetTime(CurrencyType type) { public Long getTime(CurrencyType type) {
return paymentsTimes.get(type); return paymentsTimes.get(type);
} }
public void setReseted(boolean Reseted) { public void setReseted(boolean reseted) {
this.Reseted = Reseted; this.reseted = reseted;
} }
public boolean isReseted() { public boolean isReseted() {
return Reseted; return reseted;
} }
public Double GetAmount(CurrencyType type) { public Double getAmount(CurrencyType type) {
if (!payments.containsKey(type)) return !payments.containsKey(type) ? 0D : (int) (payments.get(type) * 100) / 100D;
return 0D;
return (int) (payments.get(type) * 100) / 100D;
} }
public Double GetAmountBylimit(CurrencyType type, int limit) { public Double getAmountBylimit(CurrencyType type, int limit) {
if (GetAmount(type) > limit) return getAmount(type) > limit ? (double) limit : (int) (getAmount(type) * 100) / 100D;
return (double) limit;
return (int) (GetAmount(type) * 100) / 100D;
} }
public Long GetLastAnnounced() { public Long getLastAnnounced() {
return lastAnnouced; return lastAnnouced;
} }
public boolean IsAnnounceTime(int t) { public boolean isAnnounceTime(int t) {
if (this.lastAnnouced + (t * 1000) > System.currentTimeMillis()) if (lastAnnouced + (t * 1000) > System.currentTimeMillis())
return false; return false;
SetAnnouncmentTime();
setAnnouncementTime();
return true; return true;
} }
public void SetAnnouncmentTime() { public void setAnnouncementTime() {
this.lastAnnouced = System.currentTimeMillis(); this.lastAnnouced = System.currentTimeMillis();
} }
public void AddNewAmount(CurrencyType type, Double Payment) { public void addNewAmount(CurrencyType type, Double Payment) {
AddNewAmount(type, Payment, null); addNewAmount(type, Payment, null);
} }
public void AddNewAmount(CurrencyType type, Double Payment, Long time) { public void addNewAmount(CurrencyType type, Double Payment, Long time) {
paymentsTimes.put(type, time == null ? System.currentTimeMillis() : time); paymentsTimes.put(type, time == null ? System.currentTimeMillis() : time);
payments.put(type, Payment); payments.put(type, Payment);
} }
public void setInformed() { public void addAmount(CurrencyType type, Double Payment) {
this.Informed = true;
}
public void setNotInformed() {
this.Informed = false;
}
public void AddAmount(CurrencyType type, Double Payment) {
payments.put(type, payments.get(type) + Payment); payments.put(type, payments.get(type) + Payment);
} }
public long GetLeftTime(CurrencyType type) { public long getLeftTime(CurrencyType type) {
long left = 0; long left = 0;
if (this.GetTime(type) + (Jobs.getGCManager().getLimit(type).getTimeLimit() * 1000) > System.currentTimeMillis()) if (getTime(type) + (Jobs.getGCManager().getLimit(type).getTimeLimit() * 1000) > System.currentTimeMillis())
left = (this.GetTime(type) + (Jobs.getGCManager().getLimit(type).getTimeLimit() * 1000) - System.currentTimeMillis()); left = (getTime(type) + (Jobs.getGCManager().getLimit(type).getTimeLimit() * 1000) - System.currentTimeMillis());
return left; return left;
} }
public boolean IsOverLimit(CurrencyType type, int limit) { public boolean isOverLimit(CurrencyType type, int limit) {
if (this.payments.get(type) < limit) if (payments.get(type) < limit)
return false; return false;
return true; return true;
} }
public double percentOverLimit(CurrencyType type, int limit) { public double percentOverLimit(CurrencyType type, int limit) {
return ((this.payments.get(type) / limit) - 1) * 100; return ((payments.get(type) / limit) - 1) * 100;
} }
public boolean IsOverTimeLimit(CurrencyType type) { public boolean isOverTimeLimit(CurrencyType type) {
if (this.GetTime(type) + (Jobs.getGCManager().getLimit(type).getTimeLimit() * 1000) > System.currentTimeMillis()) if (getTime(type) + (Jobs.getGCManager().getLimit(type).getTimeLimit() * 1000) > System.currentTimeMillis())
return false; return false;
if (this.Informed) if (informed)
this.Informed = false; informed = false;
resetLimits(); resetLimits();
return true; return true;
} }
public void resetLimits() { public void resetLimits() {
for (CurrencyType type : CurrencyType.values()) { for (CurrencyType type : CurrencyType.values()) {
AddNewAmount(type, 0D); addNewAmount(type, 0D);
} }
this.Reseted = true; reseted = true;
} }
public boolean IsReachedLimit(CurrencyType type, int money) { public boolean isReachedLimit(CurrencyType type, int money) {
if (IsOverTimeLimit(type)) return isOverTimeLimit(type) || isOverLimit(type, money);
return true;
if (IsOverLimit(type, money))
return true;
return false;
} }
public boolean isInformed() { public boolean isInformed() {
return Informed; return informed;
} }
public void setInformed(boolean Informed) { public void setInformed(boolean informed) {
this.Informed = Informed; this.informed = informed;
} }
} }

View File

@ -2,7 +2,6 @@ package com.gamingmesh.jobs.hooks.McMMO;
import java.util.HashMap; import java.util.HashMap;
import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -50,10 +49,7 @@ public class McMMO1_X_listener implements Listener {
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
return; return;
if (!JobsPaymentListener.payForItemDurabilityLoss(player)) if (!JobsPaymentListener.payForItemDurabilityLoss(player) || event.getTreasure() == null)
return;
if (event.getTreasure() == null)
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
@ -71,7 +67,7 @@ public class McMMO1_X_listener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
//disabling plugin in world //disabling plugin in world
if (player == null || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
return; return;
ItemStack resultStack = event.getRepairedObject(); ItemStack resultStack = event.getRepairedObject();
@ -82,7 +78,7 @@ public class McMMO1_X_listener implements Listener {
return; return;
// check if in creative // check if in creative
if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) if (!JobsPaymentListener.payIfCreative(player))
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);

View File

@ -3,7 +3,6 @@ package com.gamingmesh.jobs.hooks.WorldGuard;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -38,16 +37,14 @@ public class WorldGuardManager {
if (useOld) { if (useOld) {
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc); ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
for (ProtectedRegion one : regions.getRegions()) { for (ProtectedRegion one : regions.getRegions()) {
if (!Jobs.getRestrictedAreaManager().isExist(one.getId())) if (Jobs.getRestrictedAreaManager().isExist(one.getId()))
continue;
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId()); return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
} }
} else { } else {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld())); RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
for (ProtectedRegion one : regions.getRegions().values()) { for (ProtectedRegion one : regions.getRegions().values()) {
if (!Jobs.getRestrictedAreaManager().isExist(one.getId())) if (Jobs.getRestrictedAreaManager().isExist(one.getId()))
continue;
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId()); return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
} }
} }
@ -61,16 +58,14 @@ public class WorldGuardManager {
if (useOld) { if (useOld) {
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc); ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
for (ProtectedRegion one : regions.getRegions()) { for (ProtectedRegion one : regions.getRegions()) {
if (!one.getId().equalsIgnoreCase(name) || !one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) if (one.getId().equalsIgnoreCase(name) && one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
continue;
return true; return true;
} }
} else { } else {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld())); RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
for (ProtectedRegion one : regions.getRegions().values()) { for (ProtectedRegion one : regions.getRegions().values()) {
if (!one.getId().equalsIgnoreCase(name) || !one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) if (one.getId().equalsIgnoreCase(name) && one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
continue;
return true; return true;
} }
} }
@ -79,17 +74,16 @@ public class WorldGuardManager {
public String getNameByName(String name) { public String getNameByName(String name) {
for (World one : Bukkit.getWorlds()) { for (World one : Bukkit.getWorlds()) {
Map<String, ProtectedRegion> regions = null; Map<String, ProtectedRegion> regions;
if (useOld) { if (useOld) {
regions = wg.getRegionContainer().get(one).getRegions(); regions = wg.getRegionContainer().get(one).getRegions();
} else { } else {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
regions = container.get(BukkitAdapter.adapt(one)).getRegions(); regions = container.get(BukkitAdapter.adapt(one)).getRegions();
} }
for (Entry<String, ProtectedRegion> oneR : regions.entrySet()) { for (String oneR : regions.keySet()) {
if (!oneR.getKey().equalsIgnoreCase(name)) if (oneR.equalsIgnoreCase(name))
continue; return oneR;
return oneR.getKey();
} }
} }
return null; return null;

View File

@ -97,10 +97,7 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void AsyncPlayerChatEvent(final AsyncPlayerChatEvent event) { public void AsyncPlayerChatEvent(final AsyncPlayerChatEvent event) {
if (event.isCancelled()) if (event.isCancelled() || Util.getJobsEditorMap().isEmpty())
return;
if (Util.getJobsEditorMap().isEmpty())
return; return;
final Player player = event.getPlayer(); final Player player = event.getPlayer();
@ -133,10 +130,7 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onSelection(PlayerInteractEvent event) { public void onSelection(PlayerInteractEvent event) {
if (event.getClickedBlock() == null) if (event.getClickedBlock() == null || event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -147,10 +141,7 @@ public class JobsListener implements Listener {
if (iih.getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial()) if (iih.getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())
return; return;
if (!Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()) || !player.hasPermission("jobs.area.select"))
return;
if (!player.hasPermission("jobs.area.select"))
return; return;
if (player.getGameMode() == GameMode.CREATIVE) if (player.getGameMode() == GameMode.CREATIVE)
@ -218,10 +209,7 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSignInteract(PlayerInteractEvent event) { public void onSignInteract(PlayerInteractEvent event) {
if (!Jobs.getGCManager().SignsEnabled) if (!Jobs.getGCManager().SignsEnabled || event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return; return;
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
@ -396,7 +384,7 @@ public class JobsListener implements Listener {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equalsIgnoreCase(" ")) if (honorific.equals(" "))
honorific = ""; honorific = "";
String format = event.getFormat(); String format = event.getFormat();
@ -412,7 +400,7 @@ public class JobsListener implements Listener {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equalsIgnoreCase(" ")) if (honorific.equals(" "))
honorific = ""; honorific = "";
String format = event.getFormat(); String format = event.getFormat();
@ -431,7 +419,7 @@ public class JobsListener implements Listener {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equalsIgnoreCase(" ")) if (honorific.equals(" "))
honorific = ""; honorific = "";
String format = event.getFormat(); String format = event.getFormat();
@ -489,9 +477,8 @@ public class JobsListener implements Listener {
} }
String meinOk = null; String meinOk = null;
List<JobProgression> prog = JPlayer.getJobProgression();
mein: for (JobProgression one : prog) { mein: for (JobProgression one : JPlayer.getJobProgression()) {
for (JobLimitedItems oneItem : one.getJob().getLimitedItems().values()) { for (JobLimitedItems oneItem : one.getJob().getLimitedItems().values()) {
if (one.getLevel() >= oneItem.getLevel()) if (one.getLevel() >= oneItem.getLevel())
continue; continue;
@ -535,10 +522,7 @@ public class JobsListener implements Listener {
@EventHandler @EventHandler
public void onChunkChangeMove(PlayerMoveEvent event) { public void onChunkChangeMove(PlayerMoveEvent event) {
if (event.isCancelled()) if (event.isCancelled() || !event.getPlayer().isOnline())
return;
if (!event.getPlayer().isOnline())
return; return;
//disabling plugin in world //disabling plugin in world

View File

@ -232,9 +232,6 @@ public class JobsPaymentListener implements Listener {
// pay // pay
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
if (!Jobs.isPlayerHaveAction(jPlayer, ActionType.MILK)) { if (!Jobs.isPlayerHaveAction(jPlayer, ActionType.MILK)) {
return; return;
} }
@ -414,11 +411,7 @@ public class JobsPaymentListener implements Listener {
return; return;
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), bInfo, block);
if (jPlayer == null)
return;
Jobs.action(jPlayer, bInfo, block);
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -464,11 +457,7 @@ public class JobsPaymentListener implements Listener {
return; return;
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new BlockActionInfo(block, ActionType.PLACE), block);
if (jPlayer == null)
return;
Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.PLACE), block);
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -1070,11 +1059,7 @@ public class JobsPaymentListener implements Listener {
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new ItemActionInfo(event.getResult(), ActionType.SMELT));
if (jPlayer == null)
return;
Jobs.action(jPlayer, new ItemActionInfo(event.getResult(), ActionType.SMELT));
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@ -1297,11 +1282,7 @@ public class JobsPaymentListener implements Listener {
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new EntityActionInfo(event.getEntity(), ActionType.PLACE));
if (jPlayer == null)
return;
Jobs.action(jPlayer, new EntityActionInfo(event.getEntity(), ActionType.PLACE));
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -1328,11 +1309,7 @@ public class JobsPaymentListener implements Listener {
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new EntityActionInfo(event.getEntity(), ActionType.BREAK));
if (jPlayer == null)
return;
Jobs.action(jPlayer, new EntityActionInfo(event.getEntity(), ActionType.BREAK));
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -1380,11 +1357,7 @@ public class JobsPaymentListener implements Listener {
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new EntityActionInfo(ent, ActionType.PLACE));
if (jPlayer == null)
return;
Jobs.action(jPlayer, new EntityActionInfo(ent, ActionType.PLACE));
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -1419,11 +1392,7 @@ public class JobsPaymentListener implements Listener {
return; return;
// pay // pay
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager); Jobs.action(Jobs.getPlayerManager().getJobsPlayer(pDamager), new EntityActionInfo(ent, ActionType.BREAK), e.getDamager());
if (jDamager == null)
return;
Jobs.action(jDamager, new EntityActionInfo(ent, ActionType.BREAK), e.getDamager());
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -1487,10 +1456,7 @@ public class JobsPaymentListener implements Listener {
return; return;
// pay // pay
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new EntityActionInfo(animal, ActionType.BREED));
if (jPlayer == null)
return;
Jobs.action(jPlayer, new EntityActionInfo(animal, ActionType.BREED));
} }
} }
@ -1698,7 +1664,7 @@ public class JobsPaymentListener implements Listener {
} }
} else if (Version.isCurrentEqualOrHigher(Version.v1_13_R1) && } else if (Version.isCurrentEqualOrHigher(Version.v1_13_R1) &&
block.getType().toString().startsWith("STRIPPED_") && block.getType().toString().startsWith("STRIPPED_") &&
event.getAction() == Action.RIGHT_CLICK_BLOCK) { event.getAction() == Action.RIGHT_CLICK_BLOCK && jPlayer != null) {
ItemStack iih = Jobs.getNms().getItemInMainHand(p); ItemStack iih = Jobs.getNms().getItemInMainHand(p);
if (iih.getType().toString().endsWith("_AXE")) { if (iih.getType().toString().endsWith("_AXE")) {
// check if player is riding // check if player is riding
@ -1710,10 +1676,8 @@ public class JobsPaymentListener implements Listener {
- Jobs.getNms().getDurability(iih) != iih.getType().getMaxDurability()) - Jobs.getNms().getDurability(iih) != iih.getType().getMaxDurability())
return; return;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { Bukkit.getScheduler().runTaskLater(plugin, () ->
if (jPlayer != null) Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.STRIPLOGS), block), 3);
Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.STRIPLOGS), block);
}, 1);
} }
} }
} }

View File

@ -226,7 +226,7 @@ public class Util {
JarEntry entry = en.nextElement(); JarEntry entry = en.nextElement();
String entryName = entry.getName(); String entryName = entry.getName();
packageName = packageName.replace(".", "/"); packageName = packageName.replace('.', '/');
if (entryName != null && entryName.endsWith("." + fileType) && entryName.startsWith(packageName)) { if (entryName != null && entryName.endsWith("." + fileType) && entryName.startsWith(packageName)) {
String name = entryName.replace(packageName, "").replace("." + fileType, "").replace("/", ""); String name = entryName.replace(packageName, "").replace("." + fileType, "").replace("/", "");