Remove vault / economy
This commit is contained in:
1 parent
2ecb5b2ee1
commit
809ac9fcfa
142 files changed
+350
-9263
No files matched your search
@@ -6,10 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.milkbowl:VaultAPI:1.7") {
|
||||
exclude(group = "org.bukkit", module = "bukkit")
|
||||
}
|
||||
compileOnly("net.luckperms:api:5.0")
|
||||
compileOnly("net.luckperms:api:5.5")
|
||||
api("io.papermc:paperlib:1.0.6")
|
||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
||||
implementation("org.checkerframework:checker-qual:3.14.0")
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -52,20 +51,15 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
public boolean cooldown(final boolean check, final CompletableFuture<Boolean> future) {
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (teleportOwner.getLastTeleportTimestamp() > 0) {
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int) cooldown);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int) ((cooldown * 1000.0) % 1000.0));
|
||||
// This value contains the most recent time a teleportPlayer could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last teleportPlayer used?
|
||||
final long lastTime = teleportOwner.getLastTeleportTimestamp();
|
||||
|
||||
if (lastTime > time.getTimeInMillis()) {
|
||||
// This is to make sure time didn't get messed up on last teleportPlayer use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
return false;
|
||||
} else if (lastTime > earliestLong
|
||||
@@ -77,7 +71,6 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check) {
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
}
|
||||
@@ -171,7 +164,7 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
|
||||
try {
|
||||
runOnMain(() -> teleportee.getBase().eject()); //EntityDismountEvent requires a sync context.
|
||||
runOnMain(() -> teleportee.getBase().eject());
|
||||
} catch (final ExecutionException | InterruptedException e) {
|
||||
future.completeExceptionally(e);
|
||||
return;
|
||||
@@ -192,11 +185,9 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
if (LocationUtil.isBlockUnsafeForUser(ess, teleportee, chunk.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||
if (ess.getSettings().isTeleportSafetyEnabled()) {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
//The chunk we're teleporting to is 100% going to be loaded here, no need to teleport async.
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
} else {
|
||||
try {
|
||||
//There's a chance the safer location is outside the loaded chunk so still teleport async here.
|
||||
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
|
||||
} catch (final Exception e) {
|
||||
future.completeExceptionally(e);
|
||||
@@ -209,13 +200,11 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
} else {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
//The chunk we're teleporting to is 100% going to be loaded here, no need to teleport async.
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
} else {
|
||||
if (ess.getSettings().isTeleportToCenterLocation()) {
|
||||
loc = LocationUtil.getRoundedDestination(loc);
|
||||
}
|
||||
//There's a *small* chance the rounded destination produces a location outside the loaded chunk so still teleport async here.
|
||||
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
|
||||
}
|
||||
}
|
||||
@@ -227,25 +216,25 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Location loc, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
teleport(teleportOwner, new LocationTarget(loc), chargeFor, cause, future);
|
||||
public void teleport(final Location loc, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
teleport(teleportOwner, new LocationTarget(loc), cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Player entity, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
public void teleport(final Player entity, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
teleportOwner.sendMessage(tl("teleportToPlayer", entity.getDisplayName()));
|
||||
teleport(teleportOwner, new PlayerTarget(entity), chargeFor, cause, future);
|
||||
teleport(teleportOwner, new PlayerTarget(entity), cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportPlayer(final IUser otherUser, final Location loc, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
teleport(otherUser, new LocationTarget(loc), chargeFor, cause, future);
|
||||
public void teleportPlayer(final IUser otherUser, final Location loc, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
teleport(otherUser, new LocationTarget(loc), cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportPlayer(final IUser otherUser, final Player entity, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
public void teleportPlayer(final IUser otherUser, final Player entity, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
teleport(otherUser, target, chargeFor, cause, future);
|
||||
teleport(otherUser, target, cause, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
otherUser.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
@@ -254,7 +243,7 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
});
|
||||
}
|
||||
|
||||
private void teleport(final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
private void teleport(final IUser teleportee, final ITarget target, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportee, cause, target, delay);
|
||||
@@ -265,21 +254,6 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
if (chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleportOwner, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess);
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown(true, future)) {
|
||||
future.complete(false);
|
||||
return;
|
||||
@@ -290,22 +264,16 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
return;
|
||||
}
|
||||
nowAsync(teleportee, target, cause, future);
|
||||
if (cashCharge != null) {
|
||||
cashCharge.charge(teleportOwner, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
future.complete(true);
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false, future);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cause, false, future);
|
||||
}
|
||||
|
||||
private void teleportOther(final IUser teleporter, final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
private void teleportOther(final IUser teleporter, final IUser teleportee, final ITarget target, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleporter, teleportee, cause, target, delay);
|
||||
@@ -315,21 +283,6 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
if (teleporter != null && chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleporter, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleporter).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleporter), ess);
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown(true, future)) {
|
||||
return;
|
||||
}
|
||||
@@ -342,23 +295,17 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
|
||||
nowAsync(teleportee, target, cause, future);
|
||||
if (teleporter != null && cashCharge != null) {
|
||||
cashCharge.charge(teleporter, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
future.complete(true);
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false, future);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cause, false, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void respawn(final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
public void respawn(final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportOwner, cause, null, delay);
|
||||
@@ -368,12 +315,6 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
if (chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleportOwner, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (cooldown(true, future)) {
|
||||
return;
|
||||
}
|
||||
@@ -382,16 +323,13 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
return;
|
||||
}
|
||||
respawnNow(teleportOwner, cause, future);
|
||||
if (chargeFor != null) {
|
||||
chargeFor.charge(teleportOwner, future);
|
||||
}
|
||||
future.complete(true);
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportOwner, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportOwner, null, chargeFor, cause, true, future);
|
||||
initTimer((long) (delay * 1000.0), teleportOwner, null, cause, true, future);
|
||||
}
|
||||
|
||||
void respawnNow(final IUser teleportee, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
@@ -414,8 +352,8 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warp(final IUser otherUser, String warp, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
final UserWarpEvent event = new UserWarpEvent(otherUser, warp, chargeFor);
|
||||
public void warp(final IUser otherUser, String warp, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
final UserWarpEvent event = new UserWarpEvent(otherUser, warp);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@@ -438,20 +376,7 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
}
|
||||
});
|
||||
teleport(otherUser, new LocationTarget(loc), chargeFor, cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void back(final Trade chargeFor, final CompletableFuture<Boolean> future) {
|
||||
back(teleportOwner, chargeFor, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void back(final IUser teleporter, final Trade chargeFor, final CompletableFuture<Boolean> future) {
|
||||
tpType = TeleportType.BACK;
|
||||
final Location loc = teleportOwner.getLastLocation();
|
||||
teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleportOther(teleporter, teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND, future);
|
||||
teleport(otherUser, new LocationTarget(loc), cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -459,11 +384,18 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
nowAsync(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), TeleportCause.COMMAND, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void back(final IUser teleporter, final CompletableFuture<Boolean> future) {
|
||||
tpType = TeleportType.BACK;
|
||||
final Location loc = teleportOwner.getLastLocation();
|
||||
teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleportOther(teleporter, teleportOwner, new LocationTarget(loc), TeleportCause.COMMAND, future);
|
||||
}
|
||||
|
||||
public void setTpType(final TeleportType tpType) {
|
||||
this.tpType = tpType;
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
private void cancel(final boolean notifyUser) {
|
||||
if (timedTeleport != null) {
|
||||
timedTeleport.cancelTimer(notifyUser);
|
||||
@@ -471,8 +403,8 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||
}
|
||||
}
|
||||
|
||||
private void initTimer(final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn, CompletableFuture<Boolean> future) {
|
||||
timedTeleport = new AsyncTimedTeleport(teleportOwner, ess, this, delay, future, teleportUser, target, chargeFor, cause, respawn);
|
||||
private void initTimer(final long delay, final IUser teleportUser, final ITarget target, final TeleportCause cause, final boolean respawn, CompletableFuture<Boolean> future) {
|
||||
timedTeleport = new AsyncTimedTeleport(teleportOwner, ess, this, delay, future, teleportUser, target, cause, respawn);
|
||||
}
|
||||
|
||||
public enum TeleportType {
|
||||
|
||||
@@ -16,28 +16,24 @@ public class AsyncTimedTeleport implements Runnable {
|
||||
private final IEssentials ess;
|
||||
private final AsyncTeleport teleport;
|
||||
private final UUID timer_teleportee;
|
||||
private final long timer_started; // time this task was initiated
|
||||
private final long timer_delay; // how long to delay the teleportPlayer
|
||||
private final long timer_started;
|
||||
private final long timer_delay;
|
||||
private final CompletableFuture<Boolean> parentFuture;
|
||||
// note that I initially stored a clone of the location for reference, but...
|
||||
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
|
||||
// so, the X/Y/Z values are stored instead and rounded off
|
||||
private final long timer_initX;
|
||||
private final long timer_initY;
|
||||
private final long timer_initZ;
|
||||
private final ITarget timer_teleportTarget;
|
||||
private final boolean timer_respawn;
|
||||
private final boolean timer_canMove;
|
||||
private final Trade timer_chargeFor;
|
||||
private final TeleportCause timer_cause;
|
||||
private int timer_task;
|
||||
private double timer_health;
|
||||
|
||||
AsyncTimedTeleport(final IUser user, final IEssentials ess, final AsyncTeleport teleport, final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
|
||||
this(user, ess, teleport, delay, null, teleportUser, target, chargeFor, cause, respawn);
|
||||
AsyncTimedTeleport(final IUser user, final IEssentials ess, final AsyncTeleport teleport, final long delay, final IUser teleportUser, final ITarget target, final TeleportCause cause, final boolean respawn) {
|
||||
this(user, ess, teleport, delay, null, teleportUser, target, cause, respawn);
|
||||
}
|
||||
|
||||
AsyncTimedTeleport(final IUser user, final IEssentials ess, final AsyncTeleport teleport, final long delay, final CompletableFuture<Boolean> future, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
|
||||
AsyncTimedTeleport(final IUser user, final IEssentials ess, final AsyncTeleport teleport, final long delay, final CompletableFuture<Boolean> future, final IUser teleportUser, final ITarget target, final TeleportCause cause, final boolean respawn) {
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
this.teleport = teleport;
|
||||
@@ -49,7 +45,6 @@ public class AsyncTimedTeleport implements Runnable {
|
||||
this.timer_initZ = Math.round(teleportUser.getBase().getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.timer_teleportee = teleportUser.getBase().getUniqueId();
|
||||
this.timer_teleportTarget = target;
|
||||
this.timer_chargeFor = chargeFor;
|
||||
this.timer_cause = cause;
|
||||
this.timer_respawn = respawn;
|
||||
this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move");
|
||||
@@ -89,9 +84,8 @@ public class AsyncTimedTeleport implements Runnable {
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!timer_canMove && (Math.round(currLocation.getX() * MOVE_CONSTANT) != timer_initX || Math.round(currLocation.getY() * MOVE_CONSTANT) != timer_initY || Math.round(currLocation.getZ() * MOVE_CONSTANT) != timer_initZ || (ess.getConfig().getBoolean("teleport-cancel-on-damage") && teleportUser.getBase().getHealth() < timer_health))) {
|
||||
// user moved, cancelTimer teleportPlayer
|
||||
cancelTimer(true);
|
||||
return;
|
||||
}
|
||||
@@ -100,7 +94,7 @@ public class AsyncTimedTeleport implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
timer_health = teleportUser.getBase().getHealth(); // in case user healed, then later gets injured
|
||||
timer_health = teleportUser.getBase().getHealth();
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > timer_started + timer_delay) {
|
||||
try {
|
||||
@@ -115,25 +109,11 @@ public class AsyncTimedTeleport implements Runnable {
|
||||
cancelTimer(false);
|
||||
teleportUser.sendMessage(tl("teleportationCommencing"));
|
||||
|
||||
if (timer_chargeFor != null) {
|
||||
timer_chargeFor.isAffordableFor(teleportOwner);
|
||||
}
|
||||
|
||||
if (timer_respawn) {
|
||||
teleport.respawnNow(teleportUser, timer_cause, parentFuture);
|
||||
} else {
|
||||
teleport.nowAsync(teleportUser, timer_teleportTarget, timer_cause, parentFuture);
|
||||
}
|
||||
parentFuture.thenAccept(success -> {
|
||||
if (timer_chargeFor != null) {
|
||||
try {
|
||||
timer_chargeFor.charge(teleportOwner);
|
||||
} catch (final ChargeException ex) {
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} catch (final Exception ex) {
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
@@ -144,7 +124,6 @@ public class AsyncTimedTeleport implements Runnable {
|
||||
ess.scheduleSyncDelayedTask(new DelayedTeleportTask());
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
void cancelTimer(final boolean notifyUser) {
|
||||
if (timer_task == -1) {
|
||||
return;
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.essentialsx.api.v2.services.BalanceTop;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class BalanceTopImpl implements BalanceTop {
|
||||
private final IEssentials ess;
|
||||
private LinkedHashMap<UUID, BalanceTop.Entry> topCache = new LinkedHashMap<>();
|
||||
private BigDecimal balanceTopTotal = BigDecimal.ZERO;
|
||||
private long cacheAge = 0;
|
||||
private CompletableFuture<Void> cacheLock;
|
||||
|
||||
public BalanceTopImpl(IEssentials ess) {
|
||||
this.ess = ess;
|
||||
ess.getServer().getServicesManager().register(BalanceTop.class, this, ess, ServicePriority.Normal);
|
||||
}
|
||||
|
||||
private void calculateBalanceTopMap() {
|
||||
final List<Entry> entries = new LinkedList<>();
|
||||
BigDecimal newTotal = BigDecimal.ZERO;
|
||||
for (UUID u : ess.getUsers().getAllUserUUIDs()) {
|
||||
final User user = ess.getUsers().loadUncachedUser(u);
|
||||
if (user != null) {
|
||||
if (!ess.getSettings().isNpcsInBalanceRanking() && user.isNPC()) {
|
||||
// Don't list NPCs in output
|
||||
continue;
|
||||
}
|
||||
if (!user.isBaltopExempt()) {
|
||||
final BigDecimal userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
newTotal = newTotal.add(userMoney);
|
||||
final String name;
|
||||
if (user.getBase() instanceof OfflinePlayerStub) {
|
||||
name = user.getLastAccountName();
|
||||
} else if (user.isHidden()) {
|
||||
name = user.getName();
|
||||
} else {
|
||||
name = user.getDisplayName();
|
||||
}
|
||||
entries.add(new BalanceTop.Entry(user.getUUID(), name, userMoney));
|
||||
}
|
||||
}
|
||||
}
|
||||
final LinkedHashMap<UUID, Entry> sortedMap = new LinkedHashMap<>();
|
||||
entries.sort((entry1, entry2) -> entry2.getBalance().compareTo(entry1.getBalance()));
|
||||
for (Entry entry : entries) {
|
||||
sortedMap.put(entry.getUuid(), entry);
|
||||
}
|
||||
topCache = sortedMap;
|
||||
balanceTopTotal = newTotal;
|
||||
cacheAge = System.currentTimeMillis();
|
||||
cacheLock.complete(null);
|
||||
cacheLock = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> calculateBalanceTopMapAsync() {
|
||||
if (cacheLock != null) {
|
||||
return cacheLock;
|
||||
}
|
||||
cacheLock = new CompletableFuture<>();
|
||||
ess.runTaskAsynchronously(this::calculateBalanceTopMap);
|
||||
return cacheLock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, Entry> getBalanceTopCache() {
|
||||
return Collections.unmodifiableMap(topCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCacheAge() {
|
||||
return cacheAge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getBalanceTopTotal() {
|
||||
return balanceTopTotal;
|
||||
}
|
||||
|
||||
public boolean isCacheLocked() {
|
||||
return cacheLock != null;
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,6 @@ import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.commands.PlayerNotFoundException;
|
||||
import com.earth2me.essentials.commands.QuietAbortException;
|
||||
import com.earth2me.essentials.economy.EconomyLayers;
|
||||
import com.earth2me.essentials.economy.vault.VaultEconomyProvider;
|
||||
import com.earth2me.essentials.items.AbstractItemDb;
|
||||
import com.earth2me.essentials.items.CustomItemResolver;
|
||||
import com.earth2me.essentials.items.FlatItemDb;
|
||||
@@ -42,7 +40,6 @@ import com.earth2me.essentials.userstorage.ModernUserMap;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.api.Economy;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IItemDb;
|
||||
import net.ess3.api.IJails;
|
||||
@@ -92,7 +89,6 @@ import net.ess3.provider.providers.PaperMaterialTagProvider;
|
||||
import net.ess3.provider.providers.PaperRecipeBookListener;
|
||||
import net.ess3.provider.providers.PaperSerializationProvider;
|
||||
import net.ess3.provider.providers.PaperServerStateProvider;
|
||||
import net.essentialsx.api.v2.services.BalanceTop;
|
||||
import net.essentialsx.api.v2.services.mail.MailService;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@@ -146,7 +142,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
private transient ISettings settings;
|
||||
private transient Jails jails;
|
||||
private transient Warps warps;
|
||||
private transient Worth worth;
|
||||
private transient List<IConf> confList;
|
||||
private transient Backup backup;
|
||||
private transient AbstractItemDb itemDb;
|
||||
@@ -156,7 +151,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
@Deprecated
|
||||
private transient UserMap legacyUserMap;
|
||||
private transient ModernUserMap userMap;
|
||||
private transient BalanceTopImpl balanceTop;
|
||||
private transient ExecuteTimer execTimer;
|
||||
private transient MailService mail;
|
||||
private transient I18n i18n;
|
||||
@@ -183,10 +177,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
private transient UpdateChecker updateChecker;
|
||||
private transient Map<String, IEssentialsCommand> commandMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
EconomyLayers.init();
|
||||
}
|
||||
|
||||
public Essentials() {
|
||||
}
|
||||
|
||||
@@ -222,9 +212,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
settings = new Settings(this);
|
||||
mail = new MailServiceImpl(this);
|
||||
userMap = new ModernUserMap(this);
|
||||
balanceTop = new BalanceTopImpl(this);
|
||||
permissionsHandler = new PermissionsHandler(this, false);
|
||||
Economy.setEss(this);
|
||||
confList = new ArrayList<>();
|
||||
jails = new Jails(this);
|
||||
registerListeners(server.getPluginManager());
|
||||
@@ -233,13 +221,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
try {
|
||||
// Vault registers their Essentials provider at low priority, so we have to use normal priority here
|
||||
Class.forName("net.milkbowl.vault.economy.Economy");
|
||||
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, new VaultEconomyProvider(this), this, ServicePriority.Normal);
|
||||
} catch (final ClassNotFoundException ignored) {
|
||||
// Probably safer than fetching for the plugin as bukkit may not have marked it as enabled at this point in time
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -310,9 +291,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
legacyUserMap = new UserMap(userMap);
|
||||
execTimer.mark("Init(Usermap)");
|
||||
|
||||
balanceTop = new BalanceTopImpl(this);
|
||||
execTimer.mark("Init(BalanceTop)");
|
||||
|
||||
kits = new Kits(this);
|
||||
confList.add(kits);
|
||||
upgrade.convertKits();
|
||||
@@ -325,10 +303,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
confList.add(warps);
|
||||
execTimer.mark("Init(Warp)");
|
||||
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
execTimer.mark("Init(Worth)");
|
||||
|
||||
itemDb = getItemDbFromConfig();
|
||||
confList.add(itemDb);
|
||||
execTimer.mark("Init(ItemDB)");
|
||||
@@ -354,8 +328,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
confList.add(jails);
|
||||
execTimer.mark("Init(Jails)");
|
||||
|
||||
EconomyLayers.onEnable(this);
|
||||
|
||||
//Spawner item provider only uses one but it's here for legacy...
|
||||
spawnerItemProvider = new BlockMetaSpawnerItemProvider();
|
||||
|
||||
@@ -462,7 +434,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
timer = new EssentialsTimer(this);
|
||||
scheduleSyncRepeatingTask(timer, 1000, 50);
|
||||
|
||||
Economy.setEss(this);
|
||||
execTimer.mark("RegHandler");
|
||||
|
||||
// Register /hat and /back default permissions
|
||||
@@ -579,8 +550,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
|
||||
this.getPermissionsHandler().unregisterContexts();
|
||||
|
||||
Economy.setEss(null);
|
||||
Trade.closeLog();
|
||||
getUsers().shutdown();
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
@@ -588,7 +557,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
Trade.closeLog();
|
||||
|
||||
for (final IConf iConf : confList) {
|
||||
iConf.reloadConfig();
|
||||
@@ -882,11 +850,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
return warps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worth getWorth() {
|
||||
return worth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Backup getBackup() {
|
||||
return backup;
|
||||
@@ -1185,11 +1148,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
return userMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BalanceTop getBalanceTop() {
|
||||
return balanceTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public I18n getI18n() {
|
||||
return i18n;
|
||||
|
||||
@@ -441,7 +441,6 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||
}
|
||||
|
||||
user.setConfirmingClearCommand(null);
|
||||
user.getConfirmingPayments().clear();
|
||||
|
||||
user.stopTransaction();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.economy.EconomyLayer;
|
||||
import com.earth2me.essentials.economy.EconomyLayers;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -9,8 +7,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class EssentialsPluginListener implements Listener, IConf {
|
||||
private final transient IEssentials ess;
|
||||
|
||||
@@ -26,12 +22,6 @@ public class EssentialsPluginListener implements Listener, IConf {
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (EconomyLayers.isServerStarted()) {
|
||||
final EconomyLayer layer = EconomyLayers.onPluginEnable(event.getPlugin());
|
||||
if (layer != null) {
|
||||
ess.getLogger().log(Level.INFO, "Essentials found a compatible payment resolution method: " + layer.getName() + " (v" + layer.getPluginVersion() + ")!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@@ -41,14 +31,6 @@ public class EssentialsPluginListener implements Listener, IConf {
|
||||
}
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
|
||||
if (EconomyLayers.onPluginDisable(event.getPlugin())) {
|
||||
final EconomyLayer layer = EconomyLayers.getSelectedLayer();
|
||||
if (layer != null) {
|
||||
ess.getLogger().log(Level.INFO, "Essentials found a new compatible payment resolution method: " + layer.getName() + " (v" + layer.getPluginVersion() + ")!");
|
||||
} else {
|
||||
ess.getLogger().log(Level.INFO, "Active payment resolution method has been disabled! Falling back to Essentials' default payment resolution system!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -249,142 +249,6 @@ public class EssentialsUpgrade {
|
||||
ess.getLogger().info("Done converting legacy userdata keys to Configurate.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This migration cleans up unused files left behind by the chaos resulting from Vault's questionable economy
|
||||
* integration, and upstream Essentials' rushed and untested 1.7.10 UUID support.
|
||||
* Both of these have been fixed in EssentialsX as of 2.18.x and 2.19.x respectively, but the leftover userdata
|
||||
* files can reach into the tens of thousands and can cause excessive memory and storage usage, so this migration
|
||||
* relocates these files to a backup folder to be removed by the server owner at a later date.
|
||||
* <p>
|
||||
* To quote JRoy, who suffered immensely while trying to debug and fix various related issues:
|
||||
* <p>
|
||||
* "Essentials decided when adding its initial support for UUIDs, it wanted an implementation which would cause
|
||||
* eternal pain and suffering for any person who dared touch any of the code in the future. This code that was made
|
||||
* was so bad, it managed to somehow not maintain any actual UUID support for any external integrations/plugins.
|
||||
* Up until 2.19.0 and 2.18.0 respectively, our Vault integration and entire Economy system was entirely based off
|
||||
* username strings, and thanks to Vault being a flawed standard, for some reason exposes account create to third
|
||||
* party plugins rather than letting the implementation handle it. That doesn't seem like a huge problem at the
|
||||
* surface, but there was one small problem: whoever made the Vault integration for Essentials suffered a stroke in
|
||||
* the process of creating it. The implementation for the createAccount method, regardless of whether it was an
|
||||
* actual player or an NPC account (which the Vault spec NEVER accounted for but plugins just have to guess when
|
||||
* to support them), it would always create an NPC account. This caused any plugin integrating with Vault, creating
|
||||
* NPC accounts for pretty much every single player on the server. It still, to this day, amazes me how nobody saw
|
||||
* this code and didn't die without rewriting it; Or how everybody simply didn't stop using this plugin because how
|
||||
* awful that godforsaken code was. Anyways, this upgrade does its best to delete NPC accounts created by the
|
||||
* horrible economy code, as any operation which loads all user data into memory will load all these NPC accounts
|
||||
* and spam the console with warnings."
|
||||
*/
|
||||
public void purgeBrokenNpcAccounts() {
|
||||
if (doneFile.getBoolean("updatePurgeBrokenNpcAccounts", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
if (userFiles.length == 0) {
|
||||
return;
|
||||
}
|
||||
final File backupFolder = new File(ess.getDataFolder(), "userdata-npc-backup");
|
||||
if (backupFolder.exists()) {
|
||||
ess.getLogger().info("NPC backup folder already exists; skipping NPC purge.");
|
||||
ess.getLogger().info("To finish purging broken NPC accounts, rename the \"plugins/Essentials/userdata-npc-backup\" folder and restart your server.");
|
||||
return;
|
||||
} else if (!backupFolder.mkdir()) {
|
||||
ess.getLogger().info("Skipping NPC purge due to error creating backup folder.");
|
||||
return;
|
||||
}
|
||||
|
||||
ess.getLogger().info("#===========================================================================#");
|
||||
ess.getLogger().info(" EssentialsX will now purge any NPC accounts which were incorrectly created.");
|
||||
ess.getLogger().info(" Only NPC accounts with the default starting balance will be deleted. If");
|
||||
ess.getLogger().info(" they turn out to be valid NPC accounts, they will be re-created as needed.");
|
||||
ess.getLogger().info(" Any files deleted here will be backed up to the ");
|
||||
ess.getLogger().info(" \"plugins/Essentials/userdata-npc-backup\" folder. If you notice any files");
|
||||
ess.getLogger().info(" have been purged incorrectly, you should restore it from the backup and");
|
||||
ess.getLogger().info(" report it to us on GitHub:");
|
||||
ess.getLogger().info(" https://github.com/EssentialsX/Essentials/issues/new/choose");
|
||||
ess.getLogger().info("");
|
||||
ess.getLogger().info(" NOTE: This is a one-time process and will take several minutes if you have");
|
||||
ess.getLogger().info(" a lot of userdata files! If you interrupt this process, EssentialsX will");
|
||||
ess.getLogger().info(" skip the process until you rename or remove the backup folder.");
|
||||
ess.getLogger().info("#===========================================================================#");
|
||||
|
||||
final int totalUserFiles = userFiles.length;
|
||||
ess.getLogger().info("Found ~" + totalUserFiles + " files under \"plugins/Essentials/userdata\"...");
|
||||
|
||||
final AtomicInteger movedAccounts = new AtomicInteger(0);
|
||||
final AtomicInteger totalAccounts = new AtomicInteger(0);
|
||||
|
||||
// Less spammy feedback for greater userdata counts, eg 100 files -> 5 seconds, 1k -> 7s, 10k -> 9s, 100k -> 11s, 1m -> 14s
|
||||
final long feedbackInterval = Math.min(15, 1 + Math.round(2.1 * Math.log10(userFiles.length)));
|
||||
|
||||
final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
final ScheduledFuture<?> feedbackTask = executor.scheduleWithFixedDelay(
|
||||
() -> ess.getLogger().info("Scanned " + totalAccounts.get() + "/" + totalUserFiles + " accounts; moved " + movedAccounts.get() + " accounts"),
|
||||
5, feedbackInterval, TimeUnit.SECONDS);
|
||||
|
||||
for (final File file : userFiles) {
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml")) {
|
||||
continue;
|
||||
}
|
||||
final EssentialsConfiguration config = new EssentialsConfiguration(file);
|
||||
try {
|
||||
totalAccounts.incrementAndGet();
|
||||
config.load();
|
||||
|
||||
if (config.getKeys().size() > 4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!config.getBoolean("npc", false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final BigDecimal money = config.getBigDecimal("money", null);
|
||||
if (money == null || money.compareTo(ess.getSettings().getStartingBalance()) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config.getKeys().size() == 4 && !config.hasProperty("last-account-name") && config.hasProperty("mail")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
//noinspection UnstableApiUsage
|
||||
Files.move(file, new File(backupFolder, file.getName()));
|
||||
movedAccounts.incrementAndGet();
|
||||
} catch (IOException e) {
|
||||
ess.getLogger().log(Level.SEVERE, "Error while moving NPC file", e);
|
||||
}
|
||||
} catch (final RuntimeException ex) {
|
||||
ess.getLogger().log(Level.INFO, "File: " + file);
|
||||
feedbackTask.cancel(false);
|
||||
executor.shutdown();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
feedbackTask.cancel(false);
|
||||
executor.shutdown();
|
||||
doneFile.setProperty("updatePurgeBrokenNpcAccounts", true);
|
||||
doneFile.save();
|
||||
|
||||
ess.getLogger().info("#===========================================================================#");
|
||||
ess.getLogger().info(" EssentialsX has finished purging NPC accounts.");
|
||||
ess.getLogger().info("");
|
||||
ess.getLogger().info(" Deleted accounts: " + movedAccounts);
|
||||
ess.getLogger().info(" Total accounts processed: " + totalAccounts);
|
||||
ess.getLogger().info("");
|
||||
ess.getLogger().info(" Purged accounts have been backed up to");
|
||||
ess.getLogger().info(" \"plugins/Essentials/userdata-npc-backup\", and can be restored from there");
|
||||
ess.getLogger().info(" if needed. Please report any files which have been incorrectly deleted");
|
||||
ess.getLogger().info(" to us on GitHub:");
|
||||
ess.getLogger().info(" https://github.com/EssentialsX/Essentials/issues/new/choose");
|
||||
ess.getLogger().info("#===========================================================================#");
|
||||
}
|
||||
|
||||
public void convertIgnoreList() {
|
||||
final Pattern pattern = Pattern.compile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
|
||||
if (doneFile.getBoolean("updateUsersIgnoreListUUID", false)) {
|
||||
@@ -1011,6 +875,5 @@ public class EssentialsUpgrade {
|
||||
convertIgnoreList();
|
||||
convertStupidCamelCaseUserdataKeys();
|
||||
convertMailList();
|
||||
purgeBrokenNpcAccounts();
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import net.ess3.provider.SpawnerBlockProvider;
|
||||
import net.ess3.provider.SpawnerItemProvider;
|
||||
import net.ess3.provider.SyncCommandsProvider;
|
||||
import net.ess3.provider.WorldInfoProvider;
|
||||
import net.essentialsx.api.v2.services.BalanceTop;
|
||||
import net.essentialsx.api.v2.services.mail.MailService;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@@ -88,8 +87,6 @@ public interface IEssentials extends Plugin {
|
||||
|
||||
IWarps getWarps();
|
||||
|
||||
Worth getWorth();
|
||||
|
||||
Backup getBackup();
|
||||
|
||||
Kits getKits();
|
||||
@@ -123,8 +120,6 @@ public interface IEssentials extends Plugin {
|
||||
@Deprecated
|
||||
UserMap getUserMap();
|
||||
|
||||
BalanceTop getBalanceTop();
|
||||
|
||||
EssentialsTimer getTimer();
|
||||
|
||||
MailService getMail();
|
||||
|
||||
@@ -8,8 +8,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -52,14 +50,6 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean isChatQuestionEnabled();
|
||||
|
||||
BigDecimal getCommandCost(IEssentialsCommand cmd);
|
||||
|
||||
BigDecimal getCommandCost(String label);
|
||||
|
||||
String getCurrencySymbol();
|
||||
|
||||
boolean isCurrencySymbolSuffixed();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
int getDefaultStackSize();
|
||||
@@ -111,8 +101,6 @@ public interface ISettings extends IConf {
|
||||
|
||||
int getSpawnMobLimit();
|
||||
|
||||
BigDecimal getStartingBalance();
|
||||
|
||||
boolean isTeleportSafetyEnabled();
|
||||
|
||||
boolean isForceDisableTeleportSafety();
|
||||
@@ -143,8 +131,6 @@ public interface ISettings extends IConf {
|
||||
|
||||
void setDebug(boolean debug);
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
@Deprecated
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
@@ -162,14 +148,6 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean warnOnSmite();
|
||||
|
||||
BigDecimal getMaxMoney();
|
||||
|
||||
BigDecimal getMinMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean isEcoLogUpdateEnabled();
|
||||
|
||||
boolean realNamesOnList();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
@@ -260,8 +238,6 @@ public interface ISettings extends IConf {
|
||||
|
||||
int getMailsPerMinute();
|
||||
|
||||
long getEconomyLagWarning();
|
||||
|
||||
long getPermissionsLagWarning();
|
||||
|
||||
void setEssentialsChatActive(boolean b);
|
||||
@@ -302,10 +278,6 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean isLastMessageReplyRecipient();
|
||||
|
||||
BigDecimal getMinimumPayAmount();
|
||||
|
||||
boolean isPayExcludesIgnoreList();
|
||||
|
||||
long getLastMessageReplyRecipientTimeout();
|
||||
|
||||
boolean isMilkBucketEasterEggEnabled();
|
||||
@@ -334,10 +306,6 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean isCommandCooldownPersistent(String label);
|
||||
|
||||
boolean isNpcsInBalanceRanking();
|
||||
|
||||
NumberFormat getCurrencyFormat();
|
||||
|
||||
List<EssentialsSign> getUnprotectedSignNames();
|
||||
|
||||
boolean isKitAutoEquip();
|
||||
@@ -398,8 +366,6 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean isUpdateCheckEnabled();
|
||||
|
||||
boolean showZeroBaltop();
|
||||
|
||||
int getMaxItemLore();
|
||||
|
||||
enum KeepInvPolicy {
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.earth2me.essentials.api.IAsyncTeleport;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.config.entities.CommandCooldown;
|
||||
import net.ess3.api.ITeleport;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||
import net.essentialsx.api.v2.services.mail.MailMessage;
|
||||
import net.essentialsx.api.v2.services.mail.MailSender;
|
||||
@@ -14,8 +13,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -41,18 +38,6 @@ public interface IUser {
|
||||
|
||||
void healCooldown() throws Exception;
|
||||
|
||||
void giveMoney(BigDecimal value) throws MaxMoneyException;
|
||||
|
||||
void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException;
|
||||
|
||||
void payUser(final User reciever, final BigDecimal value) throws Exception;
|
||||
|
||||
void takeMoney(BigDecimal value);
|
||||
|
||||
void takeMoney(final BigDecimal value, final CommandSource initiator);
|
||||
|
||||
boolean canAfford(BigDecimal value);
|
||||
|
||||
Boolean canSpawnItem(final Material material);
|
||||
|
||||
void setLastLocation();
|
||||
@@ -79,10 +64,6 @@ public interface IUser {
|
||||
|
||||
IAsyncTeleport getAsyncTeleport();
|
||||
|
||||
BigDecimal getMoney();
|
||||
|
||||
void setMoney(final BigDecimal value) throws MaxMoneyException;
|
||||
|
||||
void setAfk(final boolean set, final AfkStatusChangeEvent.Cause cause);
|
||||
|
||||
/**
|
||||
@@ -216,14 +197,6 @@ public interface IUser {
|
||||
|
||||
long getAfkSince();
|
||||
|
||||
boolean isAcceptingPay();
|
||||
|
||||
void setAcceptingPay(boolean acceptingPay);
|
||||
|
||||
boolean isPromptingPayConfirm();
|
||||
|
||||
void setPromptingPayConfirm(boolean prompt);
|
||||
|
||||
boolean isPromptingClearConfirm();
|
||||
|
||||
void setPromptingClearConfirm(boolean prompt);
|
||||
@@ -232,8 +205,6 @@ public interface IUser {
|
||||
|
||||
void setLastMessageReplyRecipient(boolean enabled);
|
||||
|
||||
Map<User, BigDecimal> getConfirmingPayments();
|
||||
|
||||
Block getTargetBlock(int maxDistance);
|
||||
|
||||
void setToggleShout(boolean toggleShout);
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.Trade.OverflowType;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.events.KitClaimEvent;
|
||||
import net.essentialsx.api.v2.events.KitPreExpandItemsEvent;
|
||||
@@ -16,7 +14,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
@@ -31,13 +28,11 @@ public class Kit {
|
||||
final IEssentials ess;
|
||||
final String kitName;
|
||||
final Map<String, Object> kit;
|
||||
final Trade charge;
|
||||
|
||||
public Kit(final String kitName, final IEssentials ess) throws Exception {
|
||||
this.kitName = kitName;
|
||||
this.ess = ess;
|
||||
this.kit = ess.getKits().getKit(kitName);
|
||||
this.charge = new Trade("kit-" + kitName, new Trade("kit-kit", ess), ess);
|
||||
|
||||
if (kit == null) {
|
||||
throw new Exception(tl("kitNotFound"));
|
||||
@@ -67,10 +62,6 @@ public class Kit {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkAffordable(final User user) throws Exception {
|
||||
charge.isAffordableFor(user);
|
||||
}
|
||||
|
||||
public void setTime(final User user) throws Exception {
|
||||
final Calendar time = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
@@ -80,10 +71,6 @@ public class Kit {
|
||||
user.setKitTimestamp(kitName, 0);
|
||||
}
|
||||
|
||||
public void chargeUser(final User user) throws Exception {
|
||||
charge.charge(user);
|
||||
}
|
||||
|
||||
public long getNextUse(final User user) throws Exception {
|
||||
if (user.isAuthorized("essentials.kit.exemptdelay")) {
|
||||
return 0L;
|
||||
@@ -172,14 +159,7 @@ public class Kit {
|
||||
final boolean autoEquip = ess.getSettings().isKitAutoEquip();
|
||||
final List<ItemStack> itemList = new ArrayList<>();
|
||||
final List<String> commandQueue = new ArrayList<>();
|
||||
final List<String> moneyQueue = new ArrayList<>();
|
||||
final String currencySymbol = ess.getSettings().getCurrencySymbol().isEmpty() ? "$" : ess.getSettings().getCurrencySymbol();
|
||||
for (final String kitItem : output.getLines()) {
|
||||
if (kitItem.startsWith("$") || kitItem.startsWith(currencySymbol)) {
|
||||
moneyQueue.add(NumberUtil.sanitizeCurrencyString(kitItem, ess));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (kitItem.startsWith("/")) {
|
||||
String command = kitItem.substring(1);
|
||||
final String name = user.getName();
|
||||
@@ -249,15 +229,6 @@ public class Kit {
|
||||
}
|
||||
user.getBase().updateInventory();
|
||||
|
||||
// Process money & command queues
|
||||
// Done after all items have been processed so commands are not run and money is not given if
|
||||
// an error occurs during the item giving process
|
||||
for (final String valueString : moneyQueue) {
|
||||
final BigDecimal value = new BigDecimal(valueString.trim());
|
||||
final Trade t = new Trade(value, ess);
|
||||
t.pay(user, OverflowType.DROP);
|
||||
}
|
||||
|
||||
for (final String cmd : commandQueue) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.config.ConfigurateUtil;
|
||||
import com.earth2me.essentials.config.EssentialsConfiguration;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -143,10 +141,6 @@ public class Kits implements IConf {
|
||||
} else if (user.isAuthorized("essentials.kits." + kitItem.toLowerCase(Locale.ENGLISH))) {
|
||||
String cost = "";
|
||||
String name = capitalCase(kitItem);
|
||||
final BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
|
||||
if (costPrice.signum() > 0) {
|
||||
cost = tl("kitCost", NumberUtil.displayCurrency(costPrice, ess));
|
||||
}
|
||||
|
||||
final Kit kit = new Kit(kitItem, ess);
|
||||
final double nextUse = kit.getNextUse(user);
|
||||
|
||||
@@ -46,8 +46,6 @@ import java.util.regex.PatternSyntaxException;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Settings implements net.ess3.api.ISettings {
|
||||
private static final BigDecimal DEFAULT_MAX_MONEY = new BigDecimal("10000000000000");
|
||||
private static final BigDecimal DEFAULT_MIN_MONEY = new BigDecimal("-10000000000000");
|
||||
private final transient EssentialsConfiguration config;
|
||||
private final transient IEssentials ess;
|
||||
private final transient AtomicInteger reloadCount = new AtomicInteger(0);
|
||||
@@ -63,7 +61,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
private List<String> overriddenCommands = Collections.emptyList();
|
||||
private List<String> playerCommands = Collections.emptyList();
|
||||
private final transient Map<String, Command> disabledBukkitCommands = new HashMap<>();
|
||||
private Map<String, BigDecimal> commandCosts;
|
||||
private Set<String> socialSpyCommands = new HashSet<>();
|
||||
private Set<String> muteCommands = new HashSet<>();
|
||||
private String nicknamePrefix = "~";
|
||||
@@ -74,13 +71,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
private boolean warnOnBuildDisallow;
|
||||
private boolean debug = false;
|
||||
private boolean configDebug = false;
|
||||
// #easteregg
|
||||
private boolean economyDisabled = false;
|
||||
private BigDecimal maxMoney = DEFAULT_MAX_MONEY;
|
||||
private BigDecimal minMoney = DEFAULT_MIN_MONEY;
|
||||
private boolean economyLog = false;
|
||||
// #easteregg
|
||||
private boolean economyLogUpdate = false;
|
||||
private boolean changeDisplayName = true;
|
||||
private boolean changePlayerListName = false;
|
||||
private boolean prefixsuffixconfigured = false;
|
||||
@@ -108,8 +98,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
private int signUsePerSecond;
|
||||
private int mailsPerMinute;
|
||||
// #easteregg
|
||||
private long economyLagWarning;
|
||||
// #easteregg
|
||||
private long permissionsLagWarning;
|
||||
private boolean allowSilentJoin;
|
||||
private String customJoinMessage;
|
||||
@@ -120,8 +108,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
private boolean isCustomNewUsernameMessage;
|
||||
private List<String> spawnOnJoinGroups;
|
||||
private Map<Pattern, Long> commandCooldowns;
|
||||
private boolean npcsInBalanceRanking = false;
|
||||
private NumberFormat currencyFormat;
|
||||
private List<EssentialsSign> unprotectedSigns = Collections.emptyList();
|
||||
private List<String> defaultEnabledConfirmCommands;
|
||||
private TeleportWhenFreePolicy teleportWhenFreePolicy;
|
||||
@@ -287,11 +273,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getInt("default-stack-size", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getStartingBalance() {
|
||||
return config.getBigDecimal("starting-balance", BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(final IEssentialsCommand cmd) {
|
||||
return isCommandDisabled(cmd.getName());
|
||||
@@ -372,52 +353,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getCommandCost(final IEssentialsCommand cmd) {
|
||||
return getCommandCost(cmd.getName());
|
||||
}
|
||||
|
||||
private Map<String, BigDecimal> _getCommandCosts() {
|
||||
final Map<String, CommentedConfigurationNode> section = ConfigurateUtil.getMap(config.getSection("command-costs"));
|
||||
if (!section.isEmpty()) {
|
||||
final Map<String, BigDecimal> newMap = new HashMap<>();
|
||||
for (Map.Entry<String, CommentedConfigurationNode> entry : section.entrySet()) {
|
||||
final String command = entry.getKey();
|
||||
final CommentedConfigurationNode node = entry.getValue();
|
||||
if (command.charAt(0) == '/') {
|
||||
ess.getLogger().warning("Invalid command cost. '" + command + "' should not start with '/'.");
|
||||
}
|
||||
try {
|
||||
if (ConfigurateUtil.isDouble(node)) {
|
||||
newMap.put(command.toLowerCase(Locale.ENGLISH), BigDecimal.valueOf(node.getDouble()));
|
||||
} else if (ConfigurateUtil.isInt(node)) {
|
||||
newMap.put(command.toLowerCase(Locale.ENGLISH), BigDecimal.valueOf(node.getInt()));
|
||||
} else if (ConfigurateUtil.isString(node)) {
|
||||
final String costString = node.getString();
|
||||
//noinspection ConstantConditions
|
||||
final double cost = Double.parseDouble(costString.trim().replace("$", "").replace(getCurrencySymbol(), "").replaceAll("\\W", ""));
|
||||
newMap.put(command.toLowerCase(Locale.ENGLISH), BigDecimal.valueOf(cost));
|
||||
} else {
|
||||
ess.getLogger().warning("Invalid command cost for: " + command);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
ess.getLogger().warning("Invalid command cost for: " + command);
|
||||
}
|
||||
}
|
||||
return newMap;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getCommandCost(String name) {
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (commandCosts != null && commandCosts.containsKey(name)) {
|
||||
return commandCosts.get(name);
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
private Set<String> _getSocialSpyCommands() {
|
||||
final Set<String> socialspyCommands = new HashSet<>();
|
||||
|
||||
@@ -739,17 +674,10 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
chatRadius = _getChatRadius();
|
||||
chatShout = _getChatShout();
|
||||
chatQuestion = _getChatQuestion();
|
||||
commandCosts = _getCommandCosts();
|
||||
socialSpyCommands = _getSocialSpyCommands();
|
||||
warnOnBuildDisallow = _warnOnBuildDisallow();
|
||||
mailsPerMinute = _getMailsPerMinute();
|
||||
maxMoney = _getMaxMoney();
|
||||
minMoney = _getMinMoney();
|
||||
permissionsLagWarning = _getPermissionsLagWarning();
|
||||
economyLagWarning = _getEconomyLagWarning();
|
||||
economyLog = _isEcoLogEnabled();
|
||||
economyLogUpdate = _isEcoLogUpdateEnabled();
|
||||
economyDisabled = _isEcoDisabled();
|
||||
allowSilentJoin = _allowSilentJoinQuit();
|
||||
customJoinMessage = _getCustomJoinMessage();
|
||||
isCustomJoinMessage = !customJoinMessage.equals("none");
|
||||
@@ -760,8 +688,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
muteCommands = _getMuteCommands();
|
||||
spawnOnJoinGroups = _getSpawnOnJoinGroups();
|
||||
commandCooldowns = _getCommandCooldowns();
|
||||
npcsInBalanceRanking = _isNpcsInBalanceRanking();
|
||||
currencyFormat = _getCurrencyFormat();
|
||||
unprotectedSigns = _getUnprotectedSign();
|
||||
defaultEnabledConfirmCommands = _getDefaultEnabledConfirmCommands();
|
||||
teleportWhenFreePolicy = _getTeleportWhenFreePolicy();
|
||||
@@ -777,7 +703,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
removeEffectsOnHeal = _isRemovingEffectsOnHeal();
|
||||
vanishingItemPolicy = _getVanishingItemsPolicy();
|
||||
bindingItemPolicy = _getBindingItemsPolicy();
|
||||
currencySymbol = _getCurrencySymbol();
|
||||
worldAliases = _getWorldAliases();
|
||||
|
||||
reloadCount.incrementAndGet();
|
||||
@@ -883,27 +808,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getString("locale", "");
|
||||
}
|
||||
|
||||
private String currencySymbol = "$";
|
||||
|
||||
// A valid currency symbol value must be one non-integer character.
|
||||
private String _getCurrencySymbol() {
|
||||
String value = config.getString("currency-symbol", "$").trim();
|
||||
if (value.length() > 1 || value.matches("\\d")) {
|
||||
value = "$";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrencySymbol() {
|
||||
return currencySymbol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySymbolSuffixed() {
|
||||
return config.getBoolean("currency-symbol-suffix", false);
|
||||
}
|
||||
|
||||
// #easteregg
|
||||
@Override
|
||||
@Deprecated
|
||||
@@ -917,15 +821,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("trade-in-stacks." + type.toString().toLowerCase().replace("_", ""), false);
|
||||
}
|
||||
|
||||
public boolean _isEcoDisabled() {
|
||||
return config.getBoolean("disable-eco", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoDisabled() {
|
||||
return economyDisabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectPreventSpawn(final String creatureName) {
|
||||
return config.getBoolean("protect.prevent.spawn." + creatureName, false);
|
||||
@@ -969,51 +864,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
|
||||
private BigDecimal _getMaxMoney() {
|
||||
return config.getBigDecimal("max-money", DEFAULT_MAX_MONEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMaxMoney() {
|
||||
return maxMoney;
|
||||
}
|
||||
|
||||
private BigDecimal _getMinMoney() {
|
||||
BigDecimal min = config.getBigDecimal("min-money", DEFAULT_MIN_MONEY);
|
||||
if (min.signum() > 0) {
|
||||
min = min.negate();
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMinMoney() {
|
||||
return minMoney;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogEnabled() {
|
||||
return economyLog;
|
||||
}
|
||||
|
||||
public boolean _isEcoLogEnabled() {
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogUpdateEnabled() {
|
||||
return economyLogUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean realNamesOnList() {
|
||||
return config.getBoolean("real-names-on-list", false);
|
||||
}
|
||||
|
||||
public boolean _isEcoLogUpdateEnabled() {
|
||||
return config.getBoolean("economy-log-update-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeGodOnDisconnect() {
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
@@ -1340,16 +1195,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return mailsPerMinute;
|
||||
}
|
||||
|
||||
private long _getEconomyLagWarning() {
|
||||
// Default to 25ms
|
||||
return (long) (config.getDouble("economy-lag-warning", 25.0) * 1000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEconomyLagWarning() {
|
||||
return economyLagWarning;
|
||||
}
|
||||
|
||||
private long _getPermissionsLagWarning() {
|
||||
// Default to 25ms
|
||||
return (long) (config.getDouble("permissions-lag-warning", 25.0) * 1000000);
|
||||
@@ -1474,16 +1319,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("last-message-reply-recipient", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMinimumPayAmount() {
|
||||
return new BigDecimal(config.getString("minimum-pay-amount", "0.001"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPayExcludesIgnoreList() {
|
||||
return config.getBoolean("pay-excludes-ignore-list", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastMessageReplyRecipientTimeout() {
|
||||
return config.getLong("last-message-reply-recipient-timeout", 180);
|
||||
@@ -1634,40 +1469,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("command-cooldown-persistence", true);
|
||||
}
|
||||
|
||||
private boolean _isNpcsInBalanceRanking() {
|
||||
return config.getBoolean("npcs-in-balance-ranking", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNpcsInBalanceRanking() {
|
||||
return npcsInBalanceRanking;
|
||||
}
|
||||
|
||||
private NumberFormat _getCurrencyFormat() {
|
||||
final String currencyFormatString = config.getString("currency-format", "#,##0.00");
|
||||
|
||||
final String symbolLocaleString = config.getString("currency-symbol-format-locale", null);
|
||||
final DecimalFormatSymbols decimalFormatSymbols;
|
||||
if (symbolLocaleString != null) {
|
||||
decimalFormatSymbols = DecimalFormatSymbols.getInstance(Locale.forLanguageTag(symbolLocaleString));
|
||||
} else {
|
||||
// Fallback to the JVM's default locale
|
||||
decimalFormatSymbols = DecimalFormatSymbols.getInstance(Locale.US);
|
||||
}
|
||||
|
||||
final DecimalFormat currencyFormat = new DecimalFormat(currencyFormatString, decimalFormatSymbols);
|
||||
currencyFormat.setRoundingMode(RoundingMode.FLOOR);
|
||||
|
||||
// Updates NumberUtil#PRETTY_FORMAT field so that all of Essentials can follow a single format.
|
||||
NumberUtil.internalSetPrettyFormat(currencyFormat);
|
||||
return currencyFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NumberFormat getCurrencyFormat() {
|
||||
return this.currencyFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EssentialsSign> getUnprotectedSignNames() {
|
||||
return this.unprotectedSigns;
|
||||
@@ -1924,11 +1725,6 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("update-check", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showZeroBaltop() {
|
||||
return config.getBoolean("show-zero-baltop", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemLore() {
|
||||
return config.getInt("max-itemlore-lines", 10);
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
@@ -43,20 +42,15 @@ public class Teleport implements ITeleport {
|
||||
public void cooldown(final boolean check) throws Exception {
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (teleportOwner.getLastTeleportTimestamp() > 0) {
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int) cooldown);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int) ((cooldown * 1000.0) % 1000.0));
|
||||
// This value contains the most recent time a teleportPlayer could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last teleportPlayer used?
|
||||
final long lastTime = teleportOwner.getLastTeleportTimestamp();
|
||||
|
||||
if (lastTime > time.getTimeInMillis()) {
|
||||
// This is to make sure time didn't get messed up on last teleportPlayer use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
return;
|
||||
} else if (lastTime > earliestLong
|
||||
@@ -67,7 +61,6 @@ public class Teleport implements ITeleport {
|
||||
throw new Exception(tl("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check) {
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
}
|
||||
@@ -101,7 +94,6 @@ public class Teleport implements ITeleport {
|
||||
user.sendMessage(tl("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
|
||||
}
|
||||
|
||||
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
|
||||
@Override
|
||||
@Deprecated
|
||||
public void now(final Location loc, final boolean cooldown, final TeleportCause cause) throws Exception {
|
||||
@@ -167,48 +159,43 @@ public class Teleport implements ITeleport {
|
||||
}
|
||||
}
|
||||
|
||||
//The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player.
|
||||
//This method is nolonger used internally and will be removed.
|
||||
@Deprecated
|
||||
@Override
|
||||
public void teleport(final Location loc, final Trade chargeFor) throws Exception {
|
||||
teleport(loc, chargeFor, TeleportCause.PLUGIN);
|
||||
public void teleport(final Location loc) throws Exception {
|
||||
teleport(loc, TeleportCause.PLUGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleport(final Location loc, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
teleport(teleportOwner, new LocationTarget(loc), chargeFor, cause);
|
||||
public void teleport(final Location loc, final TeleportCause cause) throws Exception {
|
||||
teleport(teleportOwner, new LocationTarget(loc), cause);
|
||||
}
|
||||
|
||||
//This is used when teleporting to a player
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleport(final Player entity, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
public void teleport(final Player entity, final TeleportCause cause) throws Exception {
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
teleportOwner.sendMessage(tl("teleportToPlayer", entity.getDisplayName()));
|
||||
teleport(teleportOwner, target, chargeFor, cause);
|
||||
teleport(teleportOwner, target, cause);
|
||||
}
|
||||
|
||||
//This is used when teleporting to stored location
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportPlayer(final IUser teleportee, final Location loc, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
|
||||
public void teleportPlayer(final IUser teleportee, final Location loc, final TeleportCause cause) throws Exception {
|
||||
teleport(teleportee, new LocationTarget(loc), cause);
|
||||
}
|
||||
|
||||
//This is used on /tphere
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportPlayer(final IUser teleportee, final Player entity, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
public void teleportPlayer(final IUser teleportee, final Player entity, final TeleportCause cause) throws Exception {
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
teleport(teleportee, target, chargeFor, cause);
|
||||
teleport(teleportee, target, cause);
|
||||
teleportee.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void teleport(final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
private void teleport(final IUser teleportee, final ITarget target, final TeleportCause cause) throws Exception {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportee, cause, target, delay);
|
||||
@@ -218,35 +205,20 @@ public class Teleport implements ITeleport {
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
if (chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleportOwner);
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess);
|
||||
}
|
||||
}
|
||||
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass") || teleportee.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
cooldown(false);
|
||||
now(teleportee, target, cause);
|
||||
if (cashCharge != null) {
|
||||
cashCharge.charge(teleportOwner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cause, false);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void teleportOther(final IUser teleporter, final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
private void teleportOther(final IUser teleporter, final IUser teleportee, final ITarget target, final TeleportCause cause) throws Exception {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleporter, teleportee, cause, target, delay);
|
||||
@@ -256,18 +228,6 @@ public class Teleport implements ITeleport {
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
if (teleporter != null && chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleporter);
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleporter).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleporter), ess);
|
||||
}
|
||||
}
|
||||
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleporter == null
|
||||
|| teleporter.isAuthorized("essentials.teleport.timer.bypass")
|
||||
@@ -275,21 +235,17 @@ public class Teleport implements ITeleport {
|
||||
|| teleportee.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
cooldown(false);
|
||||
now(teleportee, target, cause);
|
||||
if (teleporter != null && cashCharge != null) {
|
||||
cashCharge.charge(teleporter);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cause, false);
|
||||
}
|
||||
|
||||
//The respawn function is a wrapper used to handle tp fallback, on /jail and /home
|
||||
@Override
|
||||
@Deprecated
|
||||
public void respawn(final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
public void respawn(final TeleportCause cause) throws Exception {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportOwner, cause, null, delay);
|
||||
@@ -299,22 +255,16 @@ public class Teleport implements ITeleport {
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
if (chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleportOwner);
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
cooldown(false);
|
||||
respawnNow(teleportOwner, cause);
|
||||
if (chargeFor != null) {
|
||||
chargeFor.charge(teleportOwner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportOwner, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
|
||||
initTimer((long) (delay * 1000.0), teleportOwner, null, cause, true);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -333,11 +283,10 @@ public class Teleport implements ITeleport {
|
||||
}
|
||||
}
|
||||
|
||||
//The warp function is a wrapper used to teleportPlayer a player to a /warp
|
||||
@Override
|
||||
@Deprecated
|
||||
public void warp(final IUser teleportee, String warp, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
final UserWarpEvent event = new UserWarpEvent(teleportee, warp, chargeFor);
|
||||
public void warp(final IUser teleportee, String warp, final TeleportCause cause) throws Exception {
|
||||
final UserWarpEvent event = new UserWarpEvent(teleportee, warp);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@@ -349,39 +298,29 @@ public class Teleport implements ITeleport {
|
||||
if (!teleportee.equals(teleportOwner)) {
|
||||
teleportOwner.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
|
||||
teleport(teleportee, new LocationTarget(loc), cause);
|
||||
}
|
||||
|
||||
//The back function is a wrapper used to teleportPlayer a player /back to their previous location.
|
||||
@Override
|
||||
@Deprecated
|
||||
public void back(final Trade chargeFor) throws Exception {
|
||||
back(teleportOwner, chargeFor);
|
||||
}
|
||||
|
||||
//This function is a wrapper over the other back function for cases where another player performs back for them
|
||||
@Override
|
||||
@Deprecated
|
||||
public void back(final IUser teleporter, final Trade chargeFor) throws Exception {
|
||||
tpType = TeleportType.BACK;
|
||||
final Location loc = teleportOwner.getLastLocation();
|
||||
teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleportOther(teleporter, teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
//This function is used to throw a user back after a jail sentence
|
||||
@Override
|
||||
@Deprecated
|
||||
public void back() throws Exception {
|
||||
now(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void back(final IUser teleporter) throws Exception {
|
||||
tpType = TeleportType.BACK;
|
||||
final Location loc = teleportOwner.getLastLocation();
|
||||
teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleportOther(teleporter, teleportOwner, new LocationTarget(loc), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTpType(final TeleportType tpType) {
|
||||
this.tpType = tpType;
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
@Deprecated
|
||||
private void cancel(final boolean notifyUser) {
|
||||
if (timedTeleport != null) {
|
||||
@@ -391,8 +330,8 @@ public class Teleport implements ITeleport {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void initTimer(final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
|
||||
timedTeleport = new TimedTeleport(teleportOwner, ess, this, delay, teleportUser, target, chargeFor, cause, respawn);
|
||||
private void initTimer(final long delay, final IUser teleportUser, final ITarget target, final TeleportCause cause, final boolean respawn) {
|
||||
timedTeleport = new TimedTeleport(teleportOwner, ess, this, delay, teleportUser, target, cause, respawn);
|
||||
}
|
||||
|
||||
public enum TeleportType {
|
||||
|
||||
@@ -27,12 +27,11 @@ public class TimedTeleport implements Runnable {
|
||||
private final ITarget timer_teleportTarget;
|
||||
private final boolean timer_respawn;
|
||||
private final boolean timer_canMove;
|
||||
private final Trade timer_chargeFor;
|
||||
private final TeleportCause timer_cause;
|
||||
private int timer_task;
|
||||
private double timer_health;
|
||||
|
||||
TimedTeleport(final IUser user, final IEssentials ess, final Teleport teleport, final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
|
||||
TimedTeleport(final IUser user, final IEssentials ess, final Teleport teleport, final long delay, final IUser teleportUser, final ITarget target, final TeleportCause cause, final boolean respawn) {
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
this.teleport = teleport;
|
||||
@@ -44,7 +43,6 @@ public class TimedTeleport implements Runnable {
|
||||
this.timer_initZ = Math.round(teleportUser.getBase().getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.timer_teleportee = teleportUser.getBase().getUniqueId();
|
||||
this.timer_teleportTarget = target;
|
||||
this.timer_chargeFor = chargeFor;
|
||||
this.timer_cause = cause;
|
||||
this.timer_respawn = respawn;
|
||||
this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move");
|
||||
@@ -98,18 +96,11 @@ public class TimedTeleport implements Runnable {
|
||||
cancelTimer(false);
|
||||
teleportUser.sendMessage(tl("teleportationCommencing"));
|
||||
|
||||
if (timer_chargeFor != null) {
|
||||
timer_chargeFor.isAffordableFor(teleportOwner);
|
||||
}
|
||||
if (timer_respawn) {
|
||||
teleport.respawnNow(teleportUser, timer_cause);
|
||||
} else {
|
||||
teleport.now(teleportUser, timer_teleportTarget, timer_cause);
|
||||
}
|
||||
if (timer_chargeFor != null) {
|
||||
timer_chargeFor.charge(teleportOwner);
|
||||
}
|
||||
|
||||
} catch (final Exception ex) {
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
|
||||
@@ -1,383 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Trade {
|
||||
private static FileWriter fw = null;
|
||||
private final transient String command;
|
||||
private final transient Trade fallbackTrade;
|
||||
private final transient BigDecimal money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient Integer exp;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public Trade(final String command, final IEssentials ess) {
|
||||
this(command, null, null, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final String command, final Trade fallback, final IEssentials ess) {
|
||||
this(command, fallback, null, null, null, ess);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Trade(final double money, final com.earth2me.essentials.IEssentials ess) {
|
||||
this(null, null, BigDecimal.valueOf(money), null, null, (IEssentials) ess);
|
||||
}
|
||||
|
||||
public Trade(final BigDecimal money, final IEssentials ess) {
|
||||
this(null, null, money, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final ItemStack items, final IEssentials ess) {
|
||||
this(null, null, null, items, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final int exp, final IEssentials ess) {
|
||||
this(null, null, null, null, exp, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final Trade fallback, final BigDecimal money, final ItemStack item, final Integer exp, final IEssentials ess) {
|
||||
this.command = command;
|
||||
this.fallbackTrade = fallback;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.exp = exp;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public static void log(final String type, final String subtype, final String event, final String sender, final Trade charge, final String receiver, final Trade pay, final Location loc, final BigDecimal endBalance, final IEssentials ess) {
|
||||
//isEcoLogUpdateEnabled() - This refers to log entries with no location, ie API updates #EasterEgg
|
||||
//isEcoLogEnabled() - This refers to log entries with with location, ie /pay /sell and eco signs.
|
||||
|
||||
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled()) || (loc != null && !ess.getSettings().isEcoLogEnabled())) {
|
||||
return;
|
||||
}
|
||||
if (fw == null) {
|
||||
try {
|
||||
fw = new FileWriter(new File(ess.getDataFolder(), "trade.log"), true);
|
||||
} catch (final IOException ex) {
|
||||
Essentials.getWrappedLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(type).append(",").append(subtype).append(",").append(event).append(",\"");
|
||||
sb.append(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date()));
|
||||
sb.append("\",\"");
|
||||
if (sender != null) {
|
||||
sb.append(sender);
|
||||
}
|
||||
sb.append("\",");
|
||||
if (charge == null) {
|
||||
sb.append("\"\",\"\",\"\"");
|
||||
} else {
|
||||
if (charge.getItemStack() != null) {
|
||||
sb.append(charge.getItemStack().getAmount()).append(",");
|
||||
sb.append(charge.getItemStack().getType()).append(",");
|
||||
if (VersionUtil.PRE_FLATTENING) {
|
||||
sb.append(charge.getItemStack().getDurability());
|
||||
}
|
||||
}
|
||||
if (charge.getMoney() != null) {
|
||||
sb.append(charge.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
if (charge.getExperience() != null) {
|
||||
sb.append(charge.getExperience()).append(",");
|
||||
sb.append("exp").append(",");
|
||||
sb.append("\"\"");
|
||||
}
|
||||
}
|
||||
sb.append(",\"");
|
||||
if (receiver != null) {
|
||||
sb.append(receiver);
|
||||
}
|
||||
sb.append("\",");
|
||||
if (pay == null) {
|
||||
sb.append("\"\",\"\",\"\"");
|
||||
} else {
|
||||
if (pay.getItemStack() != null) {
|
||||
sb.append(pay.getItemStack().getAmount()).append(",");
|
||||
sb.append(pay.getItemStack().getType()).append(",");
|
||||
if (VersionUtil.PRE_FLATTENING) {
|
||||
sb.append(pay.getItemStack().getDurability());
|
||||
}
|
||||
}
|
||||
if (pay.getMoney() != null) {
|
||||
sb.append(pay.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
if (pay.getExperience() != null) {
|
||||
sb.append(pay.getExperience()).append(",");
|
||||
sb.append("exp").append(",");
|
||||
sb.append("\"\"");
|
||||
}
|
||||
}
|
||||
if (loc == null) {
|
||||
sb.append(",\"\",\"\",\"\",\"\"");
|
||||
} else {
|
||||
sb.append(",\"");
|
||||
sb.append(loc.getWorld().getName()).append("\",");
|
||||
sb.append(loc.getBlockX()).append(",");
|
||||
sb.append(loc.getBlockY()).append(",");
|
||||
sb.append(loc.getBlockZ()).append(",");
|
||||
}
|
||||
|
||||
if (endBalance == null) {
|
||||
sb.append(",");
|
||||
} else {
|
||||
sb.append(endBalance);
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("\n");
|
||||
try {
|
||||
fw.write(sb.toString());
|
||||
fw.flush();
|
||||
} catch (final IOException ex) {
|
||||
Essentials.getWrappedLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeLog() {
|
||||
if (fw != null) {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (final IOException ex) {
|
||||
Essentials.getWrappedLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
fw = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException {
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
isAffordableFor(user, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (final InterruptedException e) { //If this happens, we have bigger problems...
|
||||
e.printStackTrace();
|
||||
} catch (final ExecutionException e) {
|
||||
throw (ChargeException) e.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void isAffordableFor(final IUser user, final CompletableFuture<Boolean> future) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "checking if " + user.getName() + " can afford charge.");
|
||||
}
|
||||
|
||||
if (getMoney() != null && getMoney().signum() > 0 && !user.canAfford(getMoney())) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess))));
|
||||
return;
|
||||
}
|
||||
|
||||
if (getItemStack() != null && !Inventories.containsAtLeast(user.getBase(), itemStack, itemStack.getAmount())) {
|
||||
future.completeExceptionally(new ChargeException(tl("missingItems", getItemStack().getAmount(), ess.getItemDb().name(getItemStack()))));
|
||||
return;
|
||||
}
|
||||
|
||||
final BigDecimal money;
|
||||
if (command != null && !command.isEmpty() && (money = getCommandCost(user)).signum() > 0 && !user.canAfford(money)) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(money, ess))));
|
||||
return;
|
||||
}
|
||||
|
||||
if (exp != null && exp > 0 && SetExpFix.getTotalExperience(user.getBase()) < exp) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughExperience")));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean pay(final IUser user) throws MaxMoneyException {
|
||||
return pay(user, OverflowType.ABORT) == null;
|
||||
}
|
||||
|
||||
public Map<Integer, ItemStack> pay(final IUser user, final OverflowType type) throws MaxMoneyException {
|
||||
if (getMoney() != null && getMoney().signum() > 0) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "paying user " + user.getName() + " via trade " + getMoney().toPlainString());
|
||||
}
|
||||
user.giveMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null) {
|
||||
if (type == OverflowType.ABORT && !Inventories.hasSpace(user.getBase(), 0, false, getItemStack())) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "abort paying " + user.getName() + " itemstack " + getItemStack().toString() + " due to lack of inventory space ");
|
||||
}
|
||||
return Collections.singletonMap(0, getItemStack());
|
||||
}
|
||||
|
||||
final Map<Integer, ItemStack> leftover = Inventories.addItem(user.getBase(), getItemStack());
|
||||
user.getBase().updateInventory();
|
||||
if (!leftover.isEmpty()) {
|
||||
if (type == OverflowType.RETURN) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " with overflow " + leftover.get(0).toString());
|
||||
}
|
||||
return leftover;
|
||||
} else {
|
||||
for (final ItemStack itemStack : leftover.values()) {
|
||||
int spillAmount = itemStack.getAmount();
|
||||
itemStack.setAmount(Math.min(spillAmount, itemStack.getMaxStackSize()));
|
||||
while (spillAmount > 0) {
|
||||
user.getBase().getWorld().dropItemNaturally(user.getBase().getLocation(), itemStack);
|
||||
spillAmount -= itemStack.getAmount();
|
||||
}
|
||||
}
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " and dropping overflow " + leftover.get(0).toString());
|
||||
}
|
||||
}
|
||||
} else if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " itemstack " + getItemStack().toString());
|
||||
}
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
if (getExperience() != null) {
|
||||
SetExpFix.setTotalExperience(user.getBase(), SetExpFix.getTotalExperience(user.getBase()) + getExperience());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void charge(final IUser user) throws ChargeException {
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
charge(user, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (final InterruptedException e) { //If this happens, we have bigger problems...
|
||||
e.printStackTrace();
|
||||
} catch (final ExecutionException e) {
|
||||
throw (ChargeException) e.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void charge(final IUser user, final CompletableFuture<Boolean> future) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "attempting to charge user " + user.getName());
|
||||
}
|
||||
if (getMoney() != null) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " money " + getMoney().toPlainString());
|
||||
}
|
||||
if (!user.canAfford(getMoney()) && getMoney().signum() > 0) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess))));
|
||||
return;
|
||||
}
|
||||
user.takeMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
|
||||
}
|
||||
if (!Inventories.containsAtLeast(user.getBase(), getItemStack(), getItemStack().getAmount())) {
|
||||
future.completeExceptionally(new ChargeException(tl("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " "))));
|
||||
return;
|
||||
}
|
||||
Inventories.removeItemAmount(user.getBase(), getItemStack(), getItemStack().getAmount());
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
if (command != null) {
|
||||
final BigDecimal cost = getCommandCost(user);
|
||||
if (!user.canAfford(cost) && cost.signum() > 0) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(cost, ess))));
|
||||
return;
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
if (getExperience() != null) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " exp " + getExperience());
|
||||
}
|
||||
final int experience = SetExpFix.getTotalExperience(user.getBase());
|
||||
if (experience < getExperience() && getExperience() > 0) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughExperience")));
|
||||
return;
|
||||
}
|
||||
SetExpFix.setTotalExperience(user.getBase(), experience - getExperience());
|
||||
}
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "charge user " + user.getName() + " completed");
|
||||
}
|
||||
}
|
||||
|
||||
public BigDecimal getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public Integer getExperience() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public TradeType getType() {
|
||||
if (getExperience() != null) {
|
||||
return TradeType.EXP;
|
||||
}
|
||||
|
||||
if (getItemStack() != null) {
|
||||
return TradeType.ITEM;
|
||||
}
|
||||
|
||||
return TradeType.MONEY;
|
||||
}
|
||||
|
||||
public BigDecimal getCommandCost(final IUser user) {
|
||||
BigDecimal cost = BigDecimal.ZERO;
|
||||
if (command != null && !command.isEmpty()) {
|
||||
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (cost.signum() == 0 && fallbackTrade != null) {
|
||||
cost = fallbackTrade.getCommandCost(user);
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "calculated command (" + command + ") cost for " + user.getName() + " as " + cost);
|
||||
}
|
||||
}
|
||||
if (cost.signum() != 0 && (user.isAuthorized("essentials.nocommandcost.all") || user.isAuthorized("essentials.nocommandcost." + command))) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
public enum TradeType {
|
||||
MONEY,
|
||||
EXP,
|
||||
ITEM
|
||||
}
|
||||
|
||||
public enum OverflowType {
|
||||
ABORT,
|
||||
DROP,
|
||||
RETURN
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,18 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.economy.EconomyLayer;
|
||||
import com.earth2me.essentials.economy.EconomyLayers;
|
||||
import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import com.earth2me.essentials.messaging.SimpleMessageRecipient;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.TriState;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||
import net.ess3.api.events.JailStatusChangeEvent;
|
||||
import net.ess3.api.events.MuteStatusChangeEvent;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import net.essentialsx.api.v2.events.TransactionEvent;
|
||||
import net.essentialsx.api.v2.services.mail.MailSender;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -30,7 +24,6 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
@@ -39,9 +32,7 @@ import java.util.GregorianCalendar;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
@@ -56,9 +47,6 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
private transient final AsyncTeleport teleport;
|
||||
private transient final Teleport legacyTeleport;
|
||||
|
||||
// User command confirmation strings
|
||||
private final Map<User, BigDecimal> confirmingPayments = new WeakHashMap<>();
|
||||
|
||||
// User teleport variables
|
||||
private final transient LinkedHashMap<String, TpaRequest> teleportRequestQueue = new LinkedHashMap<>();
|
||||
|
||||
@@ -214,90 +202,6 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveMoney(final BigDecimal value) throws MaxMoneyException {
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException {
|
||||
giveMoney(value, initiator, UserBalanceUpdateEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
public void giveMoney(final BigDecimal value, final CommandSource initiator, final UserBalanceUpdateEvent.Cause cause) throws MaxMoneyException {
|
||||
if (value.signum() == 0) {
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney().add(value), cause);
|
||||
sendMessage(tl("addedToAccount", NumberUtil.displayCurrency(value, ess)));
|
||||
if (initiator != null) {
|
||||
initiator.sendMessage(tl("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void payUser(final User reciever, final BigDecimal value) throws Exception {
|
||||
payUser(reciever, value, UserBalanceUpdateEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
public void payUser(final User reciever, final BigDecimal value, final UserBalanceUpdateEvent.Cause cause) throws Exception {
|
||||
if (value.compareTo(BigDecimal.ZERO) < 1) {
|
||||
throw new Exception(tl("payMustBePositive"));
|
||||
}
|
||||
|
||||
if (canAfford(value)) {
|
||||
setMoney(getMoney().subtract(value), cause);
|
||||
reciever.setMoney(reciever.getMoney().add(value), cause);
|
||||
sendMessage(tl("moneySentTo", NumberUtil.displayCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(tl("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), getDisplayName()));
|
||||
final TransactionEvent transactionEvent = new TransactionEvent(this.getSource(), reciever, value);
|
||||
ess.getServer().getPluginManager().callEvent(transactionEvent);
|
||||
} else {
|
||||
throw new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(value, ess)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeMoney(final BigDecimal value) {
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeMoney(final BigDecimal value, final CommandSource initiator) {
|
||||
takeMoney(value, initiator, UserBalanceUpdateEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
public void takeMoney(final BigDecimal value, final CommandSource initiator, final UserBalanceUpdateEvent.Cause cause) {
|
||||
if (value.signum() == 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setMoney(getMoney().subtract(value), cause);
|
||||
} catch (final MaxMoneyException ex) {
|
||||
ess.getLogger().log(Level.WARNING, "Invalid call to takeMoney, total balance can't be more than the max-money limit.", ex);
|
||||
}
|
||||
sendMessage(tl("takenFromAccount", NumberUtil.displayCurrency(value, ess)));
|
||||
if (initiator != null) {
|
||||
initiator.sendMessage(tl("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAfford(final BigDecimal cost) {
|
||||
return canAfford(cost, true);
|
||||
}
|
||||
|
||||
public boolean canAfford(final BigDecimal cost, final boolean permcheck) {
|
||||
if (cost.signum() <= 0) {
|
||||
return true;
|
||||
}
|
||||
final BigDecimal remainingBalance = getMoney().subtract(cost);
|
||||
if (!permcheck || isAuthorized("essentials.eco.loan")) {
|
||||
return remainingBalance.compareTo(ess.getSettings().getMinMoney()) >= 0;
|
||||
}
|
||||
return remainingBalance.signum() >= 0;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
ess.runTaskAsynchronously(this::_dispose);
|
||||
}
|
||||
@@ -560,68 +464,6 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
lastOnlineActivity = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMoney() {
|
||||
final long start = System.nanoTime();
|
||||
final BigDecimal value = _getMoney();
|
||||
final long elapsed = System.nanoTime() - start;
|
||||
if (elapsed > ess.getSettings().getEconomyLagWarning()) {
|
||||
ess.getLogger().log(Level.INFO, "Lag Notice - Slow Economy Response - Request took over {0}ms!", elapsed / 1000000.0);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(final BigDecimal value) throws MaxMoneyException {
|
||||
setMoney(value, UserBalanceUpdateEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
private BigDecimal _getMoney() {
|
||||
if (ess.getSettings().isEcoDisabled()) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Internal economy functions disabled, aborting balance check.");
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
final EconomyLayer layer = EconomyLayers.getSelectedLayer();
|
||||
if (layer != null && (layer.hasAccount(getBase()) || layer.createPlayerAccount(getBase()))) {
|
||||
return layer.getBalance(getBase());
|
||||
}
|
||||
return super.getMoney();
|
||||
}
|
||||
|
||||
public void setMoney(final BigDecimal value, final UserBalanceUpdateEvent.Cause cause) throws MaxMoneyException {
|
||||
if (ess.getSettings().isEcoDisabled()) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Internal economy functions disabled, aborting balance change.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
final BigDecimal oldBalance = _getMoney();
|
||||
|
||||
final UserBalanceUpdateEvent updateEvent = new UserBalanceUpdateEvent(this.getBase(), oldBalance, value, cause);
|
||||
ess.getServer().getPluginManager().callEvent(updateEvent);
|
||||
final BigDecimal newBalance = updateEvent.getNewBalance();
|
||||
|
||||
final EconomyLayer layer = EconomyLayers.getSelectedLayer();
|
||||
if (layer != null && (layer.hasAccount(getBase()) || layer.createPlayerAccount(getBase()))) {
|
||||
layer.set(getBase(), newBalance);
|
||||
}
|
||||
super.setMoney(newBalance, true);
|
||||
Trade.log("Update", "Set", "API", getName(), new Trade(newBalance, ess), null, null, null, newBalance, ess);
|
||||
}
|
||||
|
||||
public void updateMoneyCache(final BigDecimal value) {
|
||||
if (ess.getSettings().isEcoDisabled() || !EconomyLayers.isLayerSelected() || super.getMoney().equals(value)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
super.setMoney(value, false);
|
||||
} catch (final MaxMoneyException ex) {
|
||||
// We don't want to throw any errors here, just updating a cache
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAfk(final boolean set) {
|
||||
setAfk(set, AfkStatusChangeEvent.Cause.UNKNOWN);
|
||||
@@ -728,11 +570,11 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
getAsyncTeleport().back(future);
|
||||
future.exceptionally(e -> {
|
||||
getAsyncTeleport().respawn(null, TeleportCause.PLUGIN, new CompletableFuture<>());
|
||||
getAsyncTeleport().respawn(TeleportCause.PLUGIN, new CompletableFuture<>());
|
||||
return false;
|
||||
});
|
||||
} else if (ess.getSettings().getTeleportWhenFreePolicy() == ISettings.TeleportWhenFreePolicy.SPAWN) {
|
||||
getAsyncTeleport().respawn(null, TeleportCause.PLUGIN, new CompletableFuture<>());
|
||||
getAsyncTeleport().respawn(TeleportCause.PLUGIN, new CompletableFuture<>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1067,11 +909,6 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
return afkSince;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<User, BigDecimal> getConfirmingPayments() {
|
||||
return confirmingPayments;
|
||||
}
|
||||
|
||||
public String getConfirmingClearCommand() {
|
||||
return confirmingClearCommand;
|
||||
}
|
||||
@@ -1144,15 +981,6 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
this.freeze = freeze;
|
||||
}
|
||||
|
||||
public boolean isBaltopExempt() {
|
||||
if (getBase().isOnline()) {
|
||||
final boolean exempt = isAuthorized("essentials.balancetop.exclude");
|
||||
setBaltopExemptCache(exempt);
|
||||
return exempt;
|
||||
}
|
||||
return isBaltopExcludeCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getTargetBlock(int maxDistance) {
|
||||
final Block block;
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.essentialsx.api.v2.services.mail.MailMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -19,7 +18,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -37,7 +35,6 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
protected final transient IEssentials ess;
|
||||
private final EssentialsUserConfiguration config;
|
||||
private UserConfigHolder holder;
|
||||
private BigDecimal money;
|
||||
|
||||
protected UserData(final Player base, final IEssentials ess) {
|
||||
super(base);
|
||||
@@ -86,53 +83,6 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
ess.getLogger().log(Level.SEVERE, "Error while reading user config: " + config.getFile().getName(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
money = _getMoney();
|
||||
}
|
||||
|
||||
private BigDecimal _getMoney() {
|
||||
BigDecimal result = ess.getSettings().getStartingBalance();
|
||||
final BigDecimal maxMoney = ess.getSettings().getMaxMoney();
|
||||
final BigDecimal minMoney = ess.getSettings().getMinMoney();
|
||||
|
||||
// NPC banks are not actual player banks, as such they do not have player starting balance.
|
||||
if (isNPC()) {
|
||||
result = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
if (holder.money() != null) {
|
||||
result = holder.money();
|
||||
}
|
||||
if (result.compareTo(maxMoney) > 0) {
|
||||
result = maxMoney;
|
||||
}
|
||||
if (result.compareTo(minMoney) < 0) {
|
||||
result = minMoney;
|
||||
}
|
||||
holder.money(result);
|
||||
|
||||
return holder.money();
|
||||
}
|
||||
|
||||
public BigDecimal getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(final BigDecimal value, final boolean throwError) throws MaxMoneyException {
|
||||
final BigDecimal maxMoney = ess.getSettings().getMaxMoney();
|
||||
final BigDecimal minMoney = ess.getSettings().getMinMoney();
|
||||
if (value.compareTo(maxMoney) > 0) {
|
||||
if (throwError) {
|
||||
throw new MaxMoneyException();
|
||||
}
|
||||
money = maxMoney;
|
||||
} else {
|
||||
money = value;
|
||||
}
|
||||
if (money.compareTo(minMoney) < 0) {
|
||||
money = minMoney;
|
||||
}
|
||||
holder.money(money);
|
||||
stopTransaction();
|
||||
}
|
||||
|
||||
private String getHomeName(String search) {
|
||||
@@ -681,24 +631,6 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAcceptingPay() {
|
||||
return holder.acceptingPay();
|
||||
}
|
||||
|
||||
public void setAcceptingPay(final boolean acceptingPay) {
|
||||
holder.acceptingPay(acceptingPay);
|
||||
save();
|
||||
}
|
||||
|
||||
public boolean isPromptingPayConfirm() {
|
||||
return holder.confirmPay() != null ? holder.confirmPay() : ess.getSettings().isConfirmCommandEnabledByDefault("pay");
|
||||
}
|
||||
|
||||
public void setPromptingPayConfirm(final boolean prompt) {
|
||||
holder.confirmPay(prompt);
|
||||
save();
|
||||
}
|
||||
|
||||
public boolean isPromptingClearConfirm() {
|
||||
return holder.confirmClear() != null ? holder.confirmClear() : ess.getSettings().isConfirmCommandEnabledByDefault("clearinventory");
|
||||
}
|
||||
@@ -717,15 +649,6 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
save();
|
||||
}
|
||||
|
||||
public boolean isBaltopExcludeCache() {
|
||||
return holder.baltopExempt();
|
||||
}
|
||||
|
||||
public void setBaltopExemptCache(boolean baltopExempt) {
|
||||
holder.baltopExempt(baltopExempt);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public List<String> getPastUsernames() {
|
||||
return holder.pastUsernames();
|
||||
}
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.config.ConfigurateUtil;
|
||||
import com.earth2me.essentials.config.EssentialsConfiguration;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Worth implements IConf {
|
||||
private final EssentialsConfiguration config;
|
||||
|
||||
public Worth(final File dataFolder) {
|
||||
config = new EssentialsConfiguration(new File(dataFolder, "worth.yml"), "/worth.yml");
|
||||
config.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of an item stack from the config.
|
||||
*
|
||||
* @param ess The Essentials instance.
|
||||
* @param itemStack The item stack to look up in the config.
|
||||
* @return The price from the config.
|
||||
*/
|
||||
public BigDecimal getPrice(final IEssentials ess, final ItemStack itemStack) {
|
||||
BigDecimal result = BigDecimal.ONE.negate();
|
||||
|
||||
final String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
|
||||
if (VersionUtil.PRE_FLATTENING) {
|
||||
// Check for matches with data value from stack
|
||||
// Note that we always default to BigDecimal.ONE.negate(), equivalent to -1
|
||||
result = config.getBigDecimal("worth." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
|
||||
}
|
||||
|
||||
// Check for matches with data value 0
|
||||
if (result.signum() < 0) {
|
||||
final CommentedConfigurationNode itemNameMatch = config.getSection("worth." + itemname);
|
||||
if (itemNameMatch != null && ConfigurateUtil.getKeys(itemNameMatch).size() == 1) {
|
||||
result = config.getBigDecimal("worth." + itemname + ".0", BigDecimal.ONE.negate());
|
||||
}
|
||||
}
|
||||
|
||||
// Check for matches with data value wildcard
|
||||
if (result.signum() < 0) {
|
||||
result = config.getBigDecimal("worth." + itemname + ".*", BigDecimal.ONE.negate());
|
||||
}
|
||||
|
||||
// Check for matches with item name alone
|
||||
if (result.signum() < 0) {
|
||||
result = config.getBigDecimal("worth." + itemname, BigDecimal.ONE.negate());
|
||||
}
|
||||
|
||||
if (result.signum() < 0) {
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of items to be sold from a player's inventory.
|
||||
*
|
||||
* @param ess The Essentials instance.
|
||||
* @param user The user attempting to sell the item.
|
||||
* @param is A stack of the item to search the inventory for.
|
||||
* @param args The amount to try to sell.
|
||||
* @param isBulkSell Whether or not to try and bulk sell all items.
|
||||
* @return The amount of items to sell from the player's inventory.
|
||||
* @throws Exception Thrown if trying to sell air or an invalid amount.
|
||||
*/
|
||||
public int getAmount(final IEssentials ess, final User user, final ItemStack is, final String[] args, final boolean isBulkSell) throws Exception {
|
||||
if (is == null || is.getType() == Material.AIR) {
|
||||
throw new Exception(tl("itemSellAir"));
|
||||
}
|
||||
|
||||
int amount = 0;
|
||||
|
||||
if (args.length > 1) {
|
||||
try {
|
||||
amount = Integer.parseInt(args[1].replaceAll("[^0-9]", ""));
|
||||
} catch (final NumberFormatException ex) {
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
if (args[1].startsWith("-")) {
|
||||
amount = -amount;
|
||||
}
|
||||
}
|
||||
|
||||
final boolean stack = args.length > 1 && args[1].endsWith("s");
|
||||
final boolean requireStack = ess.getSettings().isTradeInStacks(is.getType());
|
||||
|
||||
if (requireStack && !stack) {
|
||||
throw new Exception(tl("itemMustBeStacked"));
|
||||
}
|
||||
|
||||
int max = 0;
|
||||
for (final ItemStack s : Inventories.getInventory(user.getBase(), false)) {
|
||||
if (s == null || !s.isSimilar(is)) {
|
||||
continue;
|
||||
}
|
||||
max += s.getAmount();
|
||||
}
|
||||
|
||||
if (stack) {
|
||||
amount *= is.getType().getMaxStackSize();
|
||||
}
|
||||
if (amount < 1) {
|
||||
amount += max;
|
||||
}
|
||||
|
||||
if (requireStack) {
|
||||
amount -= amount % is.getType().getMaxStackSize();
|
||||
}
|
||||
if (amount > max || amount < 1) {
|
||||
if (!isBulkSell) {
|
||||
user.sendMessage(tl("itemNotEnough2"));
|
||||
user.sendMessage(tl("itemNotEnough3"));
|
||||
throw new Exception(tl("itemNotEnough1"));
|
||||
} else {
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the price of an item and save it to the config.
|
||||
*
|
||||
* @param ess The Essentials instance.
|
||||
* @param itemStack A stack of the item to save.
|
||||
* @param price The new price of the item.
|
||||
*/
|
||||
public void setPrice(final IEssentials ess, final ItemStack itemStack, final double price) {
|
||||
String path = "worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
|
||||
// Spigot 1.13+ throws an exception if a 1.13+ plugin even *attempts* to do set data.
|
||||
if (VersionUtil.PRE_FLATTENING && itemStack.getType().getData() == null) {
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
path = path + "." + itemStack.getDurability();
|
||||
}
|
||||
|
||||
config.setProperty(path, price);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return config.getFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
config.load();
|
||||
}
|
||||
}
|
||||
@@ -1,922 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.config.EssentialsUserConfiguration;
|
||||
import com.earth2me.essentials.userstorage.ModernUserMap;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* You should use Vault instead of directly using this class.
|
||||
*/
|
||||
public class Economy {
|
||||
public static final MathContext MATH_CONTEXT = MathContext.DECIMAL128;
|
||||
private static IEssentials ess;
|
||||
|
||||
private static final String WARN_CALL_BEFORE_LOAD = "Essentials API is called before Essentials is loaded.";
|
||||
private static final String WARN_EXISTING_NPC_CREATE = "Account creation was requested for NPC account {0}, but account already exists (UUID: {1}). Not creating an account.";
|
||||
private static final String WARN_PLAYER_UUID_NO_NAME = "Found player {0} by UUID {1} but not by their actual name. They may have changed their username.";
|
||||
private static final String WARN_NPC_RECREATE_1 = "Account creation was requested for NPC user {0}, but an account file with UUID {1} already exists.";
|
||||
private static final String WARN_NPC_RECREATE_2 = "Essentials will create a new account as requested by the other plugin, but this is almost certainly a bug and should be reported.";
|
||||
|
||||
protected Economy() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aEss the ess to set
|
||||
*/
|
||||
public static void setEss(final IEssentials aEss) {
|
||||
ess = aEss;
|
||||
}
|
||||
|
||||
private static void createNPCFile(final String unsanitizedName) {
|
||||
final File folder = new File(ess.getDataFolder(), "userdata");
|
||||
final String name = ess.getSettings().isSafeUsermap() ? StringUtil.safeString(unsanitizedName) : unsanitizedName;
|
||||
if (!folder.exists()) {
|
||||
if (!folder.mkdirs()) {
|
||||
throw new RuntimeException("Error while creating userdata directory!");
|
||||
}
|
||||
}
|
||||
final UUID npcUUID = UUID.nameUUIDFromBytes(("NPC:" + name).getBytes(Charsets.UTF_8));
|
||||
final File npcFile = new File(folder, npcUUID + ".yml");
|
||||
if (npcFile.exists()) {
|
||||
ess.getLogger().log(Level.SEVERE, MessageFormat.format(WARN_NPC_RECREATE_1, name, npcUUID.toString()), new RuntimeException());
|
||||
ess.getLogger().log(Level.SEVERE, WARN_NPC_RECREATE_2);
|
||||
}
|
||||
final EssentialsUserConfiguration npcConfig = new EssentialsUserConfiguration(name, npcUUID, npcFile);
|
||||
npcConfig.load();
|
||||
npcConfig.setProperty("npc", true);
|
||||
npcConfig.setProperty("last-account-name", name);
|
||||
npcConfig.setProperty("npc-name", unsanitizedName);
|
||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||
npcConfig.blockingSave();
|
||||
// This will load the NPC into the UserMap + UUID cache
|
||||
((ModernUserMap) ess.getUsers()).addCachedNpcName(npcUUID, name);
|
||||
ess.getUsers().getUser(npcUUID);
|
||||
}
|
||||
|
||||
private static void deleteNPC(final String name) {
|
||||
final User user = ess.getUser(name);
|
||||
user.reset();
|
||||
}
|
||||
|
||||
private static User getUserByName(final String name) {
|
||||
if (ess == null) {
|
||||
throw new RuntimeException(WARN_CALL_BEFORE_LOAD);
|
||||
}
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Economy username cannot be null");
|
||||
}
|
||||
|
||||
User user = ess.getUser(name);
|
||||
if (user == null) {
|
||||
/*
|
||||
Attempt lookup using UUID - this prevents balance resets when accessing economy
|
||||
via Vault during player join.
|
||||
See: https://github.com/EssentialsX/Essentials/issues/2400
|
||||
*/
|
||||
final Player player = ess.getServer().getPlayerExact(name);
|
||||
if (player != null) {
|
||||
user = ess.getUser(player.getUniqueId());
|
||||
if (user != null) {
|
||||
ess.getLogger().log(Level.INFO, MessageFormat.format(WARN_PLAYER_UUID_NO_NAME, name, player.getUniqueId().toString()), new RuntimeException());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
user = getUserByUUID(UUID.nameUUIDFromBytes(("NPC:" + StringUtil.safeString(name)).getBytes(Charsets.UTF_8)));
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
private static User getUserByUUID(final UUID uuid) {
|
||||
if (ess == null) {
|
||||
throw new RuntimeException(WARN_CALL_BEFORE_LOAD);
|
||||
}
|
||||
if (uuid == null) {
|
||||
throw new IllegalArgumentException("Economy uuid cannot be null");
|
||||
}
|
||||
return ess.getUser(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the balance of a user
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @return balance
|
||||
* @throws UserDoesNotExistException
|
||||
* @deprecated Use {@link Economy#getMoneyExact(UUID)} or {@link Economy#getMoneyExact(User)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static double getMoney(final String name) throws UserDoesNotExistException {
|
||||
final BigDecimal exactAmount = getMoneyExact(name);
|
||||
double amount = exactAmount.doubleValue();
|
||||
if (new BigDecimal(amount).compareTo(exactAmount) > 0) {
|
||||
// closest double is bigger than the exact amount
|
||||
// -> get the previous double value to not return more money than the user has
|
||||
amount = Math.nextAfter(amount, Double.NEGATIVE_INFINITY);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of user
|
||||
* @return Exact balance of user
|
||||
* @throws UserDoesNotExistException
|
||||
* @deprecated Usernames can change, use {@link Economy#getMoneyExact(UUID)} or {@link Economy#getMoneyExact(User)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BigDecimal getMoneyExact(final String name) throws UserDoesNotExistException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return getMoneyExact(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the exact balance of the account with the given UUID.
|
||||
*
|
||||
* @param uuid The UUID of the user account to retrieve the balance for
|
||||
* @return The account's balance
|
||||
* @throws UserDoesNotExistException If the user does not exist
|
||||
*/
|
||||
public static BigDecimal getMoneyExact(final UUID uuid) throws UserDoesNotExistException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
return getMoneyExact(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the exact balance of the account with the given UUID.
|
||||
*
|
||||
* @param user The user account to retrieve the balance for
|
||||
* @return The account's balance
|
||||
*/
|
||||
public static BigDecimal getMoneyExact(final User user) {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
return user.getMoney();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the balance of a user
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param balance The balance you want to set
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Use {@link Economy#setMoney(UUID, BigDecimal)} or {@link Economy#setMoney(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setMoney(final String name, final double balance) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException {
|
||||
try {
|
||||
setMoney(name, BigDecimal.valueOf(balance));
|
||||
} catch (final ArithmeticException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to set balance of " + name + " to " + balance + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the balance of a user
|
||||
*
|
||||
* @param name Name of user
|
||||
* @param balance The balance you want to set
|
||||
* @throws UserDoesNotExistException If a user by that name does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Usernames can change use {@link Economy#setMoney(UUID, BigDecimal)} or {@link Economy#setMoney(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setMoney(final String name, final BigDecimal balance) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
setMoney(user, balance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the balance of a user
|
||||
*
|
||||
* @param uuid UUID of user
|
||||
* @param balance The balance you want to set
|
||||
* @throws UserDoesNotExistException If a user by that uuid does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void setMoney(final UUID uuid, final BigDecimal balance) throws NoLoanPermittedException, UserDoesNotExistException, MaxMoneyException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
setMoney(user, balance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the balance of a user
|
||||
*
|
||||
* @param user User
|
||||
* @param balance The balance you want to set
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void setMoney(final User user, final BigDecimal balance) throws NoLoanPermittedException, MaxMoneyException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
if (balance.compareTo(ess.getSettings().getMinMoney()) < 0) {
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
if (balance.signum() < 0 && !user.isAuthorized("essentials.eco.loan")) {
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
user.setMoney(balance, UserBalanceUpdateEvent.Cause.API);
|
||||
Trade.log("API", "Set", "API", user.getName(), new Trade(balance, ess), null, null, null, balance, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds money to the balance of a user
|
||||
* <p>
|
||||
* Use {@link Economy#add(UUID, BigDecimal)} or {@link Economy#add(User, BigDecimal)}
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param amount The money you want to add
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
@Deprecated
|
||||
public static void add(final String name, final double amount) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException {
|
||||
try {
|
||||
add(name, BigDecimal.valueOf(amount));
|
||||
} catch (final ArithmeticException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to add " + amount + " to balance of " + name + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds money to the balance of a user
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param amount The amount of money to be added to the user's account
|
||||
* @throws UserDoesNotExistException If a user by that name does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Usernames can change, use {@link Economy#add(UUID, BigDecimal)} or {@link Economy#add(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void add(final String name, final BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException, MaxMoneyException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
add(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds money to the balance of a user
|
||||
*
|
||||
* @param uuid UUID of the user
|
||||
* @param amount The money you want to add
|
||||
* @throws UserDoesNotExistException If a user by that uuid does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void add(final UUID uuid, final BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, UserDoesNotExistException, MaxMoneyException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
add(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds money to the balance of a user
|
||||
*
|
||||
* @param user User
|
||||
* @param amount The money you want to add
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void add(final User user, final BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, MaxMoneyException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
final BigDecimal result = getMoneyExact(user).add(amount, MATH_CONTEXT);
|
||||
setMoney(user, result);
|
||||
Trade.log("API", "Add", "API", user.getName(), new Trade(amount, ess), null, null, null, result, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts money from the balance of a user
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param amount The money you want to subtract
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Use {@link Economy#subtract(UUID, BigDecimal)} or {@link Economy#subtract(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void subtract(final String name, final double amount) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException {
|
||||
try {
|
||||
substract(name, BigDecimal.valueOf(amount));
|
||||
} catch (final ArithmeticException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to subtract " + amount + " of balance of " + name + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts money from the balance of a user
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param amount The money you want to subtract
|
||||
* @throws UserDoesNotExistException If a user by that name does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Usernames can change, use {@link Economy#subtract(UUID, BigDecimal)} or {@link Economy#subtract(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void substract(final String name, final BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException, MaxMoneyException {
|
||||
final BigDecimal result = getMoneyExact(name).subtract(amount, MATH_CONTEXT);
|
||||
setMoney(name, result);
|
||||
Trade.log("API", "Subtract", "API", name, new Trade(amount, ess), null, null, null, result, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts money from the balance of a user
|
||||
*
|
||||
* @param uuid UUID of the user
|
||||
* @param amount The money you want to subtract
|
||||
* @throws UserDoesNotExistException If a user by that UUID does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void subtract(final UUID uuid, final BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, UserDoesNotExistException, MaxMoneyException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
subtract(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts money from the balance of a user
|
||||
*
|
||||
* @param user User
|
||||
* @param amount The money you want to subtract
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void subtract(final User user, final BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, MaxMoneyException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
final BigDecimal result = getMoneyExact(user).subtract(amount, MATH_CONTEXT);
|
||||
setMoney(user, result);
|
||||
Trade.log("API", "Subtract", "API", user.getName(), new Trade(amount, ess), null, null, null, result, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divides the balance of a user by a value
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param amount The balance is divided by this value
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Use {@link Economy#divide(UUID, BigDecimal)} or {@link Economy#divide(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void divide(final String name, final double amount) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException {
|
||||
try {
|
||||
divide(name, BigDecimal.valueOf(amount));
|
||||
} catch (final ArithmeticException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to divide balance of " + name + " by " + amount + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Divides the balance of a user by a value
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param amount The balance is divided by this value
|
||||
* @throws UserDoesNotExistException If a user by that name does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Usernames can change, use {@link Economy#divide(UUID, BigDecimal)} or {@link Economy#divide(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void divide(final String name, final BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException, MaxMoneyException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
divide(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divides the balance of a user by a value
|
||||
*
|
||||
* @param uuid Name of the user
|
||||
* @param amount The balance is divided by this value
|
||||
* @throws UserDoesNotExistException If a user by that UUID does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void divide(final UUID uuid, final BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, UserDoesNotExistException, MaxMoneyException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
divide(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divides the balance of a user by a value
|
||||
*
|
||||
* @param user Name of the user
|
||||
* @param amount The balance is divided by this value
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void divide(final User user, final BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, MaxMoneyException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
final BigDecimal result = getMoneyExact(user).divide(amount, MATH_CONTEXT);
|
||||
setMoney(user, result);
|
||||
Trade.log("API", "Divide", "API", user.getName(), new Trade(amount, ess), null, null, null, result, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the balance of a user by a value
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param amount The balance is multiplied by this value
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Use {@link Economy#multiply(UUID, BigDecimal)} or {@link Economy#multiply(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void multiply(final String name, final double amount) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException {
|
||||
try {
|
||||
multiply(name, BigDecimal.valueOf(amount));
|
||||
} catch (final ArithmeticException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to multiply balance of " + name + " by " + amount + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the balance of a user by a value
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @param amount The balance is multiplied by the this value
|
||||
* @throws UserDoesNotExistException If a user by that name does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Usernames can change, use {@link Economy#multiply(UUID, BigDecimal)} or {@link Economy#multiply(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void multiply(final String name, final BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException, MaxMoneyException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
multiply(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the balance of a user by a value
|
||||
*
|
||||
* @param uuid Name of the user
|
||||
* @param amount The balance is multiplied by the this value
|
||||
* @throws UserDoesNotExistException If a user by that uuid does not exist
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void multiply(final UUID uuid, final BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, UserDoesNotExistException, MaxMoneyException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
multiply(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the balance of a user by a value
|
||||
*
|
||||
* @param user Name of the user
|
||||
* @param amount The balance is multiplied by the this value
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void multiply(final User user, final BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, MaxMoneyException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
final BigDecimal result = getMoneyExact(user).multiply(amount, MATH_CONTEXT);
|
||||
setMoney(user, result);
|
||||
Trade.log("API", "Multiply", "API", user.getName(), new Trade(amount, ess), null, null, null, result, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the balance of a user to the starting balance
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
* @deprecated Usernames can change, use {@link Economy#resetBalance(UUID)} or {@link Economy#resetBalance(User)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void resetBalance(final String name) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException {
|
||||
if (ess == null) {
|
||||
throw new RuntimeException(WARN_CALL_BEFORE_LOAD);
|
||||
}
|
||||
setMoney(name, ess.getSettings().getStartingBalance());
|
||||
Trade.log("API", "Reset", "API", name, new Trade(BigDecimal.ZERO, ess), null, null, null, ess.getSettings().getStartingBalance(), ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the balance of a user to the starting balance
|
||||
*
|
||||
* @param uuid UUID of the user
|
||||
* @throws UserDoesNotExistException If a user by that UUID does not exists
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void resetBalance(final UUID uuid) throws NoLoanPermittedException, UserDoesNotExistException, MaxMoneyException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
resetBalance(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the balance of a user to the starting balance
|
||||
*
|
||||
* @param user User
|
||||
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
|
||||
* @throws MaxMoneyException If this transaction has but the user over the maximum amount of money
|
||||
*/
|
||||
public static void resetBalance(final User user) throws NoLoanPermittedException, MaxMoneyException {
|
||||
if (ess == null) {
|
||||
throw new RuntimeException(WARN_CALL_BEFORE_LOAD);
|
||||
}
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
setMoney(user, ess.getSettings().getStartingBalance());
|
||||
Trade.log("API", "Reset", "API", user.getName(), new Trade(BigDecimal.ZERO, ess), null, null, null, ess.getSettings().getStartingBalance(), ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the user
|
||||
* @param amount The amount of money the user should have
|
||||
* @return true, if the user has more or an equal amount of money
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @deprecated Use {@link Economy#hasEnough(UUID, BigDecimal)} or {@link Economy#hasEnough(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean hasEnough(final String name, final double amount) throws UserDoesNotExistException {
|
||||
try {
|
||||
return hasEnough(name, BigDecimal.valueOf(amount));
|
||||
} catch (final ArithmeticException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the user
|
||||
* @param amount The amount of money the user should have
|
||||
* @return true, if the user has more or an equal amount of money
|
||||
* @throws UserDoesNotExistException If a user by that name does not exist
|
||||
* @throws ArithmeticException
|
||||
* @deprecated Usernames can change, use {@link Economy#hasEnough(UUID, BigDecimal)} or {@link Economy#hasEnough(User, BigDecimal)}
|
||||
*/
|
||||
public static boolean hasEnough(final String name, final BigDecimal amount) throws UserDoesNotExistException, ArithmeticException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return hasEnough(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uuid UUID of the user
|
||||
* @param amount The amount of money the user should have
|
||||
* @return true, if the user has more or an equal amount of money
|
||||
* @throws UserDoesNotExistException If a user by that UUID does not exist
|
||||
* @throws ArithmeticException
|
||||
*/
|
||||
public static boolean hasEnough(final UUID uuid, final BigDecimal amount) throws ArithmeticException, UserDoesNotExistException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
return hasEnough(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user User
|
||||
* @param amount The amount of money the user should have
|
||||
* @return true, if the user has more or an equal amount of money
|
||||
* @throws ArithmeticException
|
||||
*/
|
||||
public static boolean hasEnough(final User user, final BigDecimal amount) throws ArithmeticException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
return amount.compareTo(getMoneyExact(user)) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the user
|
||||
* @param amount The amount of money the user should have
|
||||
* @return true, if the user has more money
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @deprecated Use {@link Economy#hasMore(UUID, BigDecimal)} or {@link Economy#hasMore(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean hasMore(final String name, final double amount) throws UserDoesNotExistException {
|
||||
try {
|
||||
return hasMore(name, BigDecimal.valueOf(amount));
|
||||
} catch (final ArithmeticException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the user
|
||||
* @param amount The amount of money the user should have
|
||||
* @return true, if the user has more money
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @throws ArithmeticException
|
||||
* @deprecated Usernames can change, use {@link Economy#hasMore(UUID, BigDecimal)} or {@link Economy#hasMore(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean hasMore(final String name, final BigDecimal amount) throws UserDoesNotExistException, ArithmeticException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return hasMore(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uuid UUID of the user
|
||||
* @param amount The amount of money the user should have
|
||||
* @return true, if the user has more money
|
||||
* @throws UserDoesNotExistException If a user by that UUID does not exists
|
||||
* @throws ArithmeticException
|
||||
*/
|
||||
public static boolean hasMore(final UUID uuid, final BigDecimal amount) throws ArithmeticException, UserDoesNotExistException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
return hasMore(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user User
|
||||
* @param amount The amount of money the user should have
|
||||
* @return true, if the user has more money
|
||||
* @throws ArithmeticException
|
||||
*/
|
||||
public static boolean hasMore(final User user, final BigDecimal amount) throws ArithmeticException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
return amount.compareTo(getMoneyExact(user)) < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the user
|
||||
* @param amount The amount of money the user should not have
|
||||
* @return true, if the user has less money
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @deprecated Use {@link Economy#hasLess(UUID, BigDecimal)} or {@link Economy#hasLess(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean hasLess(final String name, final double amount) throws UserDoesNotExistException {
|
||||
try {
|
||||
return hasLess(name, BigDecimal.valueOf(amount));
|
||||
} catch (final ArithmeticException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the user
|
||||
* @param amount The amount of money the user should not have
|
||||
* @return true, if the user has less money
|
||||
* @throws UserDoesNotExistException If a user by that name does not exist
|
||||
* @throws ArithmeticException
|
||||
* @deprecated Usernames can change, use {@link Economy#hasLess(UUID, BigDecimal)} or {@link Economy#hasLess(User, BigDecimal)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean hasLess(final String name, final BigDecimal amount) throws UserDoesNotExistException, ArithmeticException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return hasLess(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uuid UUID of the user
|
||||
* @param amount The amount of money the user should not have
|
||||
* @return true, if the user has less money
|
||||
* @throws UserDoesNotExistException If a user by that UUID does not exist
|
||||
* @throws ArithmeticException
|
||||
*/
|
||||
public static boolean hasLess(final UUID uuid, final BigDecimal amount) throws ArithmeticException, UserDoesNotExistException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
return hasLess(user, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user User
|
||||
* @param amount The amount of money the user should not have
|
||||
* @return true, if the user has less money
|
||||
* @throws ArithmeticException
|
||||
*/
|
||||
public static boolean hasLess(final User user, final BigDecimal amount) throws ArithmeticException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
return amount.compareTo(getMoneyExact(user)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the user has a negative balance
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @return true, if the user has a negative balance
|
||||
* @throws UserDoesNotExistException If a user by that name does not exists
|
||||
* @deprecated Usernames can change, use {@link Economy#isNegative(UUID)} or {@link Economy#isNegative(User)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isNegative(final String name) throws UserDoesNotExistException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return isNegative(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the user has a negative balance
|
||||
*
|
||||
* @param uuid UUID of the user
|
||||
* @return true, if the user has a negative balance
|
||||
* @throws UserDoesNotExistException If a user by that UUID does not exists
|
||||
*/
|
||||
public static boolean isNegative(final UUID uuid) throws UserDoesNotExistException {
|
||||
final User user = getUserByUUID(uuid);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(uuid);
|
||||
}
|
||||
return isNegative(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the user has a negative balance
|
||||
*
|
||||
* @param user User
|
||||
* @return true, if the user has a negative balance
|
||||
*/
|
||||
public static boolean isNegative(final User user) {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("Economy user cannot be null");
|
||||
}
|
||||
return getMoneyExact(user).signum() < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67
|
||||
*
|
||||
* @param amount The amount of money
|
||||
* @return Formatted money
|
||||
* @deprecated Use {@link #format(BigDecimal)} if your input is already a {@link BigDecimal}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String format(final double amount) {
|
||||
try {
|
||||
return format(BigDecimal.valueOf(amount));
|
||||
} catch (final NumberFormatException e) {
|
||||
ess.getLogger().log(Level.WARNING, "Failed to display " + amount + ": " + e.getMessage(), e);
|
||||
return "NaN";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67
|
||||
*
|
||||
* @param amount The amount of money
|
||||
* @return Formatted money
|
||||
*/
|
||||
public static String format(final BigDecimal amount) {
|
||||
if (ess == null) {
|
||||
throw new RuntimeException(WARN_CALL_BEFORE_LOAD);
|
||||
}
|
||||
return NumberUtil.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a player exists to avoid the UserDoesNotExistException
|
||||
*
|
||||
* @param name Name of the user
|
||||
* @return true, if the user exists
|
||||
* @deprecated Essentials is moving away from username based economy methods. This may be removed in the future.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean playerExists(final String name) {
|
||||
return getUserByName(name) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a player exists to avoid the UserDoesNotExistException
|
||||
*
|
||||
* @param uuid UUID of the user
|
||||
* @return true, if the user exists
|
||||
*/
|
||||
public static boolean playerExists(final UUID uuid) {
|
||||
return getUserByUUID(uuid) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a player is a npc
|
||||
*
|
||||
* @param name Name of the player
|
||||
* @return true, if it's a npc
|
||||
* @throws UserDoesNotExistException
|
||||
*/
|
||||
public static boolean isNPC(final String name) throws UserDoesNotExistException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return user.isNPC();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates dummy files for a npc, if there is no player yet with that name.
|
||||
*
|
||||
* @param name Name of the player
|
||||
* @return true, if a new npc was created
|
||||
*/
|
||||
public static boolean createNPC(final String name) {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
createNPCFile(name);
|
||||
return true;
|
||||
}
|
||||
ess.getLogger().log(Level.WARNING, MessageFormat.format(WARN_EXISTING_NPC_CREATE, name, user.getConfigUUID()), new RuntimeException());
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a user, if it is marked as npc.
|
||||
*
|
||||
* @param name Name of the player
|
||||
* @throws UserDoesNotExistException
|
||||
*/
|
||||
public static void removeNPC(final String name) throws UserDoesNotExistException {
|
||||
final User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
deleteNPC(name);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -8,128 +7,27 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Manages EssentialsX's teleport functionality for a player.
|
||||
* Use this if you want to access EssentialsX's async/safe teleport functionality and teleport warmups and cooldowns.
|
||||
*/
|
||||
public interface IAsyncTeleport {
|
||||
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void now(Location loc, boolean cooldown, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void now(Player entity, boolean cooldown, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Used to skip all safety checks while teleporting a player asynchronously.
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void nowUnsafe(Location loc, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause.
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void teleport(Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
void teleport(Location loc, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void teleport(Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
void teleport(Player entity, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void teleportPlayer(IUser otherUser, Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
void teleportPlayer(IUser otherUser, Location loc, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void teleportPlayer(IUser otherUser, Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
void teleportPlayer(IUser otherUser, Player entity, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle tp fallback on /jail and /home
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void respawn(final Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
void respawn(PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /warp teleports
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param warp - The name of the warp the user will be teleported too.
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void warp(IUser otherUser, String warp, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
void warp(IUser otherUser, String warp, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void back(Trade chargeFor, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports that
|
||||
* are executed by a different player with this
|
||||
* instance of teleport as a target.
|
||||
*
|
||||
* @param teleporter - The user performing the /back command.
|
||||
* This value may be {@code null} to indicate console.
|
||||
* @param chargeFor - What the {@code teleporter} will be charged if teleportPlayer is successful
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void back(IUser teleporter, Trade chargeFor, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle throwing user home after a jail sentence
|
||||
*
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void back(CompletableFuture<Boolean> future);
|
||||
|
||||
void back(IUser teleporter, CompletableFuture<Boolean> future);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -10,134 +9,36 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
* @deprecated This API is not asynchronous and is no longer maintained. Use {@link com.earth2me.essentials.api.IAsyncTeleport IAsyncTeleport}.
|
||||
*/
|
||||
public interface ITeleport {
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void now(Location loc, boolean cooldown, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void now(Player entity, boolean cooldown, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleport(Location loc, Trade chargeFor) throws Exception;
|
||||
void teleport(Location loc) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleport(Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
void teleport(Location loc, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleport(Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
void teleport(Player entity, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleportPlayer(IUser otherUser, Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
void teleportPlayer(IUser otherUser, Location loc, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleportPlayer(IUser otherUser, Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
void teleportPlayer(IUser otherUser, Player entity, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle tp fallback on /jail and /home
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void respawn(final Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
void respawn(PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /warp teleports
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param warp - The name of the warp the user will be teleported too.
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void warp(IUser otherUser, String warp, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
void warp(IUser otherUser, String warp, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void back(Trade chargeFor) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports that
|
||||
* are executed by a different player with this
|
||||
* instance of teleport as a target.
|
||||
*
|
||||
* @param teleporter - The user performing the /back command.
|
||||
* This value may be {@code null} to indicate console.
|
||||
* @param chargeFor - What the {@code teleporter} will be charged if teleportPlayer is successful
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void back(IUser teleporter, Trade chargeFor) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle throwing user home after a jail sentence
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void back() throws Exception;
|
||||
|
||||
@Deprecated
|
||||
void back(IUser teleporter) throws Exception;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
/**
|
||||
* Thrown when a user does not have the balance for a transaction and cannot take a loan.
|
||||
*/
|
||||
public class NoLoanPermittedException extends net.ess3.api.NoLoanPermittedException {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
@@ -62,17 +61,12 @@ public class Commandback extends EssentialsCommand {
|
||||
}
|
||||
|
||||
if (requester == null) {
|
||||
user.getAsyncTeleport().back(null, null, getNewExceptionFuture(sender, commandLabel));
|
||||
user.getAsyncTeleport().back(null, getNewExceptionFuture(sender, commandLabel));
|
||||
} else if (!requester.equals(user)) {
|
||||
final Trade charge = new Trade(this.getName(), this.ess);
|
||||
charge.isAffordableFor(requester);
|
||||
user.getAsyncTeleport().back(requester, charge, getNewExceptionFuture(sender, commandLabel));
|
||||
user.getAsyncTeleport().back(requester, getNewExceptionFuture(sender, commandLabel));
|
||||
} else {
|
||||
final Trade charge = new Trade(this.getName(), this.ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getAsyncTeleport().back(charge, getNewExceptionFuture(sender, commandLabel));
|
||||
user.getAsyncTeleport().back(getNewExceptionFuture(sender, commandLabel));
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbalance extends EssentialsCommand {
|
||||
public Commandbalance() {
|
||||
super("balance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final User target = getPlayer(server, args, 0, false, true);
|
||||
sender.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 1 && user.isAuthorized("essentials.balance.others")) {
|
||||
final User target = getPlayer(server, args, 0, true, true);
|
||||
user.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
|
||||
} else if (args.length < 2) {
|
||||
user.sendMessage(tl("balance", NumberUtil.displayCurrency(user.getMoney(), ess)));
|
||||
} else {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1 && sender.isAuthorized("essentials.balance.others", ess)) {
|
||||
return getPlayers(server, sender);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.essentialsx.api.v2.services.BalanceTop;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbalancetop extends EssentialsCommand {
|
||||
public static final int MINUSERS = 50;
|
||||
private static final int CACHETIME = 2 * 60 * 1000;
|
||||
private static SimpleTextInput cache = new SimpleTextInput();
|
||||
|
||||
public Commandbalancetop() {
|
||||
super("balancetop");
|
||||
}
|
||||
|
||||
private void outputCache(final CommandSource sender, final int page) {
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(ess.getBalanceTop().getCacheAge());
|
||||
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
final Runnable runnable = () -> {
|
||||
sender.sendMessage(tl("balanceTop", format.format(cal.getTime())));
|
||||
new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
|
||||
};
|
||||
if (sender.getSender() instanceof BlockCommandSender) {
|
||||
ess.scheduleSyncDelayedTask(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
int page = 0;
|
||||
boolean force = false;
|
||||
if (args.length > 0) {
|
||||
try {
|
||||
page = Integer.parseInt(args[0]);
|
||||
} catch (final NumberFormatException ex) {
|
||||
if (args[0].equalsIgnoreCase("force") && (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.balancetop.force"))) {
|
||||
force = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!force && ess.getBalanceTop().getCacheAge() > System.currentTimeMillis() - CACHETIME) {
|
||||
outputCache(sender, page);
|
||||
return;
|
||||
}
|
||||
|
||||
// If there are less than 50 users in our usermap, there is no need to display a warning as these calculations should be done quickly
|
||||
if (ess.getUsers().getUserCount() > MINUSERS) {
|
||||
sender.sendMessage(tl("orderBalances", ess.getUsers().getUserCount()));
|
||||
}
|
||||
|
||||
ess.runTaskAsynchronously(new Viewer(sender, page, force));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
final List<String> options = Lists.newArrayList("1");
|
||||
if (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.balancetop.force")) {
|
||||
options.add("force");
|
||||
}
|
||||
return options;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private class Viewer implements Runnable {
|
||||
private final transient CommandSource sender;
|
||||
private final transient int page;
|
||||
private final transient boolean force;
|
||||
|
||||
Viewer(final CommandSource sender, final int page, final boolean force) {
|
||||
this.sender = sender;
|
||||
this.page = page;
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (ess.getSettings().isEcoDisabled()) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Internal economy functions disabled, aborting baltop.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean fresh = force || ess.getBalanceTop().isCacheLocked() || ess.getBalanceTop().getCacheAge() <= System.currentTimeMillis() - CACHETIME;
|
||||
final CompletableFuture<Void> future = fresh ? ess.getBalanceTop().calculateBalanceTopMapAsync() : CompletableFuture.completedFuture(null);
|
||||
future.thenRun(() -> {
|
||||
if (fresh) {
|
||||
final SimpleTextInput newCache = new SimpleTextInput();
|
||||
newCache.getLines().add(tl("serverTotal", NumberUtil.displayCurrency(ess.getBalanceTop().getBalanceTopTotal(), ess)));
|
||||
int pos = 1;
|
||||
for (final Map.Entry<UUID, BalanceTop.Entry> entry : ess.getBalanceTop().getBalanceTopCache().entrySet()) {
|
||||
if (ess.getSettings().showZeroBaltop() || entry.getValue().getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
||||
newCache.getLines().add(tl("balanceTopLine", pos, entry.getValue().getDisplayName(), NumberUtil.displayCurrency(entry.getValue().getBalance(), ess)));
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
cache = newCache;
|
||||
}
|
||||
|
||||
outputCache(sender, page);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import org.bukkit.Location;
|
||||
@@ -31,6 +30,6 @@ public class Commandbottom extends EssentialsCommand {
|
||||
user.sendMessage(tl("teleportBottom", safe.getWorld().getName(), safe.getBlockX(), safe.getBlockY(), safe.getBlockZ()));
|
||||
}
|
||||
});
|
||||
user.getAsyncTeleport().teleport(safe, new Trade(this.getName(), ess), PlayerTeleportEvent.TeleportCause.COMMAND, future);
|
||||
user.getAsyncTeleport().teleport(safe, PlayerTeleportEvent.TeleportCause.COMMAND, future);
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.Trade.OverflowType;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandcondense extends EssentialsCommand {
|
||||
private final Map<ItemStack, SimpleRecipe> condenseList = new HashMap<>();
|
||||
|
||||
public Commandcondense() {
|
||||
super("condense");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
List<ItemStack> is = new ArrayList<>();
|
||||
|
||||
boolean validateReverse = false;
|
||||
if (args.length > 0) {
|
||||
is = ess.getItemDb().getMatching(user, args);
|
||||
} else {
|
||||
for (final ItemStack stack : Inventories.getInventory(user.getBase(), false)) {
|
||||
if (stack == null || stack.getType() == Material.AIR) {
|
||||
continue;
|
||||
}
|
||||
is.add(stack);
|
||||
}
|
||||
validateReverse = true;
|
||||
}
|
||||
|
||||
boolean didConvert = false;
|
||||
for (final ItemStack itemStack : is) {
|
||||
if (condenseStack(user, itemStack, validateReverse)) {
|
||||
didConvert = true;
|
||||
}
|
||||
}
|
||||
user.getBase().updateInventory();
|
||||
|
||||
if (didConvert) {
|
||||
user.sendMessage(tl("itemsConverted"));
|
||||
} else {
|
||||
user.sendMessage(tl("itemsNotConverted"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean condenseStack(final User user, final ItemStack stack, final boolean validateReverse) throws ChargeException, MaxMoneyException {
|
||||
final SimpleRecipe condenseType = getCondenseType(stack);
|
||||
if (condenseType != null) {
|
||||
final ItemStack input = condenseType.getInput();
|
||||
final ItemStack result = condenseType.getResult();
|
||||
|
||||
if (validateReverse) {
|
||||
boolean pass = false;
|
||||
for (final Recipe revRecipe : ess.getServer().getRecipesFor(input)) {
|
||||
if (getStackOnRecipeMatch(revRecipe, result) != null) {
|
||||
pass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pass) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int amount = 0;
|
||||
|
||||
for (final ItemStack contents : Inventories.getInventory(user.getBase(), false)) {
|
||||
if (contents != null && contents.isSimilar(stack)) {
|
||||
amount += contents.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
final int output = (amount / input.getAmount()) * result.getAmount();
|
||||
amount -= amount % input.getAmount();
|
||||
|
||||
if (amount > 0) {
|
||||
input.setAmount(amount);
|
||||
result.setAmount(output);
|
||||
final Trade remove = new Trade(input, ess);
|
||||
final Trade add = new Trade(result, ess);
|
||||
remove.charge(user);
|
||||
add.pay(user, OverflowType.DROP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private SimpleRecipe getCondenseType(final ItemStack stack) {
|
||||
if (condenseList.containsKey(stack)) {
|
||||
return condenseList.get(stack);
|
||||
}
|
||||
|
||||
final Iterator<Recipe> intr = ess.getServer().recipeIterator();
|
||||
final List<SimpleRecipe> bestRecipes = new ArrayList<>();
|
||||
while (intr.hasNext()) {
|
||||
final Recipe recipe = intr.next();
|
||||
final Collection<ItemStack> recipeItems = getStackOnRecipeMatch(recipe, stack);
|
||||
|
||||
if (recipeItems != null && (recipeItems.size() == 4 || recipeItems.size() == 9) && (recipeItems.size() > recipe.getResult().getAmount())) {
|
||||
final ItemStack input = stack.clone();
|
||||
input.setAmount(recipeItems.size());
|
||||
final SimpleRecipe newRecipe = new SimpleRecipe(recipe.getResult(), input);
|
||||
bestRecipes.add(newRecipe);
|
||||
}
|
||||
}
|
||||
if (!bestRecipes.isEmpty()) {
|
||||
if (bestRecipes.size() > 1) {
|
||||
bestRecipes.sort(SimpleRecipeComparator.INSTANCE);
|
||||
}
|
||||
final SimpleRecipe recipe = bestRecipes.get(0);
|
||||
condenseList.put(stack, recipe);
|
||||
return recipe;
|
||||
}
|
||||
condenseList.put(stack, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Collection<ItemStack> getStackOnRecipeMatch(final Recipe recipe, final ItemStack stack) {
|
||||
final Collection<ItemStack> inputList;
|
||||
|
||||
if (recipe instanceof ShapedRecipe) {
|
||||
final ShapedRecipe sRecipe = (ShapedRecipe) recipe;
|
||||
if (sRecipe.getShape().length != sRecipe.getShape()[0].length()) {
|
||||
// Only accept square recipes
|
||||
return null;
|
||||
}
|
||||
inputList = sRecipe.getIngredientMap().values();
|
||||
} else if (recipe instanceof ShapelessRecipe) {
|
||||
final ShapelessRecipe slRecipe = (ShapelessRecipe) recipe;
|
||||
inputList = slRecipe.getIngredientList();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean match = true;
|
||||
final Iterator<ItemStack> iter = inputList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final ItemStack inputSlot = iter.next();
|
||||
if (inputSlot == null) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
if (VersionUtil.PRE_FLATTENING && inputSlot.getDurability() == Short.MAX_VALUE) {
|
||||
inputSlot.setDurability((short) 0);
|
||||
}
|
||||
if (!inputSlot.isSimilar(stack)) {
|
||||
match = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
return inputList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getMatchingItems(args[0]);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class SimpleRecipe implements Recipe {
|
||||
private final ItemStack result;
|
||||
private final ItemStack input;
|
||||
|
||||
private SimpleRecipe(final ItemStack result, final ItemStack input) {
|
||||
this.result = result;
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResult() {
|
||||
return result.clone();
|
||||
}
|
||||
|
||||
public ItemStack getInput() {
|
||||
return input.clone();
|
||||
}
|
||||
}
|
||||
|
||||
private static class SimpleRecipeComparator implements Comparator<SimpleRecipe> {
|
||||
|
||||
private static final SimpleRecipeComparator INSTANCE = new SimpleRecipeComparator();
|
||||
|
||||
@Override
|
||||
public int compare(final SimpleRecipe o1, final SimpleRecipe o2) {
|
||||
return Integer.compare(o2.getInput().getAmount(), o1.getInput().getAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandeco extends EssentialsLoopCommand {
|
||||
|
||||
public Commandeco() {
|
||||
super("eco");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final EcoCommands cmd;
|
||||
final boolean isPercent;
|
||||
final BigDecimal amount;
|
||||
try {
|
||||
cmd = EcoCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH));
|
||||
isPercent = cmd != EcoCommands.RESET && args[2].endsWith("%");
|
||||
amount = (cmd == EcoCommands.RESET) ? ess.getSettings().getStartingBalance() : new BigDecimal(args[2].replaceAll("[^0-9\\.]", ""));
|
||||
} catch (final Exception ex) {
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
|
||||
loopOfflinePlayersConsumer(server, sender, false, true, args[1], player -> {
|
||||
BigDecimal userAmount = amount;
|
||||
if (isPercent) {
|
||||
userAmount = player.getMoney().multiply(userAmount).scaleByPowerOfTen(-2);
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case GIVE: {
|
||||
player.giveMoney(userAmount, sender, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
|
||||
break;
|
||||
}
|
||||
case TAKE: {
|
||||
if (player.getMoney().subtract(userAmount).compareTo(ess.getSettings().getMinMoney()) >= 0) {
|
||||
player.takeMoney(userAmount, sender, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
|
||||
} else {
|
||||
ess.showError(sender, new Exception(tl("minimumBalanceError", NumberUtil.displayCurrency(ess.getSettings().getMinMoney(), ess))), commandLabel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RESET:
|
||||
case SET: {
|
||||
final BigDecimal minBal = ess.getSettings().getMinMoney();
|
||||
final BigDecimal maxBal = ess.getSettings().getMaxMoney();
|
||||
final boolean underMin = userAmount.compareTo(minBal) < 0;
|
||||
final boolean aboveMax = userAmount.compareTo(maxBal) > 0;
|
||||
player.setMoney(underMin ? minBal : aboveMax ? maxBal : userAmount, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
|
||||
player.sendMessage(tl("setBal", NumberUtil.displayCurrency(player.getMoney(), ess)));
|
||||
sender.sendMessage(tl("setBalOthers", player.getDisplayName(), NumberUtil.displayCurrency(player.getMoney(), ess)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updatePlayer(final Server server, final CommandSource sender, final User user, final String[] args) throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
final List<String> options = Lists.newArrayList();
|
||||
for (final EcoCommands command : EcoCommands.values()) {
|
||||
options.add(command.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return options;
|
||||
} else if (args.length == 2) {
|
||||
return getPlayers(server, sender);
|
||||
} else if (args.length == 3 && !args[0].equalsIgnoreCase(EcoCommands.RESET.name())) {
|
||||
if (args[0].equalsIgnoreCase(EcoCommands.SET.name())) {
|
||||
return Lists.newArrayList("0", ess.getSettings().getStartingBalance().toString());
|
||||
} else {
|
||||
return Lists.newArrayList("1", "10", "100", "1000");
|
||||
}
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private enum EcoCommands {
|
||||
GIVE, TAKE, SET, RESET
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ public class Commandenchant extends EssentialsCommand {
|
||||
super("enchant");
|
||||
}
|
||||
|
||||
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
|
||||
@@ -4,8 +4,6 @@ import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.EssentialsUpgrade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.economy.EconomyLayer;
|
||||
import com.earth2me.essentials.economy.EconomyLayers;
|
||||
import com.earth2me.essentials.userstorage.ModernUserMap;
|
||||
import com.earth2me.essentials.utils.CommandMapUtil;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
@@ -73,8 +71,6 @@ public class Commandessentials extends EssentialsCommand {
|
||||
private static final String[] CONSOLE_MOO = new String[] {" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."};
|
||||
private static final String[] PLAYER_MOO = new String[] {" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."};
|
||||
private static final List<String> versionPlugins = Arrays.asList(
|
||||
"Vault", // API
|
||||
"Reserve", // API
|
||||
"PlaceholderAPI", // API
|
||||
"CMI", // potential for issues
|
||||
"Towny", // past issues; admins should ensure latest
|
||||
@@ -283,14 +279,6 @@ public class Commandessentials extends EssentialsCommand {
|
||||
updateData.addProperty("branch", ess.getUpdateChecker().getVersionBranch());
|
||||
updateData.addProperty("dev", ess.getUpdateChecker().isDevBuild());
|
||||
essData.add("update-data", updateData);
|
||||
final JsonObject econLayer = new JsonObject();
|
||||
econLayer.addProperty("enabled", !ess.getSettings().isEcoDisabled());
|
||||
econLayer.addProperty("selected-layer", EconomyLayers.isLayerSelected());
|
||||
final EconomyLayer layer = EconomyLayers.getSelectedLayer();
|
||||
econLayer.addProperty("name", layer == null ? "null" : layer.getName());
|
||||
econLayer.addProperty("layer-version", layer == null ? "null" : layer.getPluginVersion());
|
||||
econLayer.addProperty("backend-name", layer == null ? "null" : layer.getBackendName());
|
||||
essData.add("economy-layer", econLayer);
|
||||
final JsonArray addons = new JsonArray();
|
||||
final JsonArray plugins = new JsonArray();
|
||||
final ArrayList<Plugin> alphabetical = new ArrayList<>();
|
||||
@@ -340,7 +328,6 @@ public class Commandessentials extends EssentialsCommand {
|
||||
boolean discord = false;
|
||||
boolean kits = false;
|
||||
boolean log = false;
|
||||
boolean worth = false;
|
||||
boolean tpr = false;
|
||||
boolean spawns = false;
|
||||
boolean commands = false;
|
||||
@@ -350,7 +337,6 @@ public class Commandessentials extends EssentialsCommand {
|
||||
discord = true;
|
||||
kits = true;
|
||||
log = true;
|
||||
worth = true;
|
||||
tpr = true;
|
||||
spawns = true;
|
||||
commands = true;
|
||||
@@ -363,8 +349,6 @@ public class Commandessentials extends EssentialsCommand {
|
||||
kits = true;
|
||||
} else if (arg.equalsIgnoreCase("log")) {
|
||||
log = true;
|
||||
} else if (arg.equalsIgnoreCase("worth")) {
|
||||
worth = true;
|
||||
} else if (arg.equalsIgnoreCase("tpr")) {
|
||||
tpr = true;
|
||||
} else if (arg.equalsIgnoreCase("spawns")) {
|
||||
@@ -419,14 +403,6 @@ public class Commandessentials extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (worth) {
|
||||
try {
|
||||
files.add(new PasteUtil.PasteFile("worth.yml", new String(Files.readAllBytes(ess.getWorth().getFile().toPath()), StandardCharsets.UTF_8)));
|
||||
} catch (IOException e) {
|
||||
sender.sendMessage(tl("dumpErrorUpload", "worth.yml", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
if (tpr) {
|
||||
try {
|
||||
files.add(new PasteUtil.PasteFile("tpr.yml", new String(Files.readAllBytes(ess.getRandomTeleport().getFile().toPath()), StandardCharsets.UTF_8)));
|
||||
@@ -532,15 +508,14 @@ public class Commandessentials extends EssentialsCommand {
|
||||
if (args.length < 2 || !NumberUtil.isInt(args[1])) {
|
||||
sender.sendMessage("This sub-command will delete users who haven't logged in in the last <days> days.");
|
||||
sender.sendMessage("Optional parameters define the minimum amount required to prevent deletion.");
|
||||
sender.sendMessage("Unless you define larger default values, this command will ignore people who have more than 0 money/homes.");
|
||||
throw new Exception("/<command> cleanup <days> [money] [homes]");
|
||||
sender.sendMessage("Unless you define larger default values, this command will ignore people who have more than 0 homes.");
|
||||
throw new Exception("/<command> cleanup <days> [homes]");
|
||||
}
|
||||
|
||||
sender.sendMessage(tl("cleaning"));
|
||||
|
||||
final long daysArg = Long.parseLong(args[1]);
|
||||
final double moneyArg = args.length >= 3 ? FloatUtil.parseDouble(args[2].replaceAll("[^0-9\\.]", "")) : 0;
|
||||
final int homesArg = args.length >= 4 && NumberUtil.isInt(args[3]) ? Integer.parseInt(args[3]) : 0;
|
||||
final int homesArg = args.length >= 3 && NumberUtil.isInt(args[2]) ? Integer.parseInt(args[2]) : 0;
|
||||
|
||||
ess.runTaskAsynchronously(() -> {
|
||||
final long currTime = System.currentTimeMillis();
|
||||
@@ -565,14 +540,13 @@ public class Commandessentials extends EssentialsCommand {
|
||||
final long timeDiff = currTime - lastLog;
|
||||
final long milliDays = daysArg * 24L * 60L * 60L * 1000L;
|
||||
final int homeCount = user.getHomes().size();
|
||||
final double moneyCount = user.getMoney().doubleValue();
|
||||
|
||||
if ((lastLog == 0) || (timeDiff < milliDays) || (homeCount > homesArg) || (moneyCount > moneyArg)) {
|
||||
if ((lastLog == 0) || (timeDiff < milliDays) || (homeCount > homesArg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Deleting user: " + user.getName() + " Money: " + moneyCount + " Homes: " + homeCount + " Last seen: " + DateUtil.formatDateDiff(lastLog));
|
||||
ess.getLogger().info("Deleting user: " + user.getName() + " Homes: " + homeCount + " Last seen: " + DateUtil.formatDateDiff(lastLog));
|
||||
}
|
||||
|
||||
user.reset();
|
||||
@@ -723,7 +697,7 @@ public class Commandessentials extends EssentialsCommand {
|
||||
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.version")) return;
|
||||
|
||||
boolean isMismatched = false;
|
||||
boolean isVaultInstalled = false;
|
||||
boolean isLuckPermsInstalled = false;
|
||||
boolean isUnsupported = false;
|
||||
final VersionUtil.SupportStatus supportStatus = VersionUtil.getServerSupportStatus();
|
||||
final PluginManager pm = server.getPluginManager();
|
||||
@@ -773,26 +747,15 @@ public class Commandessentials extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (name.equals("Vault")) isVaultInstalled = true;
|
||||
if (name.equals("LuckPerms")) isLuckPermsInstalled = true;
|
||||
}
|
||||
|
||||
final String layer;
|
||||
if (ess.getSettings().isEcoDisabled()) {
|
||||
layer = "Disabled";
|
||||
} else if (EconomyLayers.isLayerSelected()) {
|
||||
final EconomyLayer economyLayer = EconomyLayers.getSelectedLayer();
|
||||
layer = economyLayer.getName() + " (" + economyLayer.getBackendName() + ")";
|
||||
} else {
|
||||
layer = "None";
|
||||
}
|
||||
sender.sendMessage(tl("versionOutputEconLayer", layer));
|
||||
|
||||
if (isMismatched) {
|
||||
sender.sendMessage(tl("versionMismatchAll"));
|
||||
}
|
||||
|
||||
if (!isVaultInstalled) {
|
||||
sender.sendMessage(tl("versionOutputVaultMissing"));
|
||||
if (!isLuckPermsInstalled) {
|
||||
sender.sendMessage(tl("versionOutputLuckPermsMissing"));
|
||||
}
|
||||
|
||||
if (isUnsupported) {
|
||||
@@ -875,7 +838,7 @@ public class Commandessentials extends EssentialsCommand {
|
||||
}
|
||||
break;
|
||||
case "dump":
|
||||
final List<String> list = Lists.newArrayList("config", "kits", "log", "discord", "worth", "tpr", "spawns", "commands", "all");
|
||||
final List<String> list = Lists.newArrayList("config", "kits", "log", "discord", "tpr", "spawns", "commands", "all");
|
||||
for (String arg : args) {
|
||||
if (arg.equals("*") || arg.equalsIgnoreCase("all")) {
|
||||
list.clear();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.OfflinePlayerStub;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
@@ -25,7 +24,6 @@ public class Commandhome extends EssentialsCommand {
|
||||
// This method contains an undocumented translation parameters #EasterEgg
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
User player = user;
|
||||
String homeName = "";
|
||||
final String[] nameParts;
|
||||
@@ -58,14 +56,14 @@ public class Commandhome extends EssentialsCommand {
|
||||
user.sendMessage(tl("teleportHome", "bed"));
|
||||
}
|
||||
});
|
||||
user.getAsyncTeleport().teleport(location, charge, TeleportCause.COMMAND, future);
|
||||
user.getAsyncTeleport().teleport(location, TeleportCause.COMMAND, future);
|
||||
} else {
|
||||
showError(user.getBase(), new Exception(tl("bedMissing")), commandLabel);
|
||||
}
|
||||
});
|
||||
throw new NoChargeException();
|
||||
return;
|
||||
}
|
||||
goHome(user, player, homeName.toLowerCase(Locale.ENGLISH), charge, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
goHome(user, player, homeName.toLowerCase(Locale.ENGLISH), getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
} catch (final NotEnoughArgumentsException e) {
|
||||
final User finalPlayer = player;
|
||||
final CompletableFuture<Location> message = new CompletableFuture<>();
|
||||
@@ -76,7 +74,7 @@ public class Commandhome extends EssentialsCommand {
|
||||
final UserTeleportHomeEvent event = new UserTeleportHomeEvent(user, null, bed != null ? bed : finalPlayer.getWorld().getSpawnLocation(), bed != null ? UserTeleportHomeEvent.HomeType.BED : UserTeleportHomeEvent.HomeType.SPAWN);
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
user.getAsyncTeleport().respawn(charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
user.getAsyncTeleport().respawn(TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
}
|
||||
} else {
|
||||
showError(user.getBase(), new Exception(tl("noHomeSetPlayer")), commandLabel);
|
||||
@@ -85,7 +83,7 @@ public class Commandhome extends EssentialsCommand {
|
||||
showError(user.getBase(), new Exception(tl("noHomeSetPlayer")), commandLabel);
|
||||
} else if (homes.size() == 1 && finalPlayer.equals(user)) {
|
||||
try {
|
||||
goHome(user, finalPlayer, homes.get(0), charge, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
goHome(user, finalPlayer, homes.get(0), getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
} catch (final Exception exception) {
|
||||
showError(user.getBase(), exception, commandLabel);
|
||||
}
|
||||
@@ -107,7 +105,6 @@ public class Commandhome extends EssentialsCommand {
|
||||
}
|
||||
PaperLib.getBedSpawnLocationAsync(player.getBase(), true).thenAccept(message::complete);
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
private String getHomeLimit(final User player) {
|
||||
@@ -120,7 +117,7 @@ public class Commandhome extends EssentialsCommand {
|
||||
return Integer.toString(ess.getSettings().getHomeLimit(player));
|
||||
}
|
||||
|
||||
private void goHome(final User user, final User player, final String home, final Trade charge, final CompletableFuture<Boolean> future) throws Exception {
|
||||
private void goHome(final User user, final User player, final String home, final CompletableFuture<Boolean> future) throws Exception {
|
||||
if (home.length() < 1) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
@@ -134,7 +131,7 @@ public class Commandhome extends EssentialsCommand {
|
||||
final UserTeleportHomeEvent event = new UserTeleportHomeEvent(user, home, loc, UserTeleportHomeEvent.HomeType.HOME);
|
||||
user.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
user.getAsyncTeleport().teleport(loc, charge, TeleportCause.COMMAND, future);
|
||||
user.getAsyncTeleport().teleport(loc, TeleportCause.COMMAND, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
user.sendMessage(tl("teleportHome", home));
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -38,7 +36,7 @@ public class Commandice extends EssentialsLoopCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updatePlayer(Server server, CommandSource sender, User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
|
||||
protected void updatePlayer(Server server, CommandSource sender, User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException {
|
||||
freezePlayer(user);
|
||||
sender.sendMessage(tl("iceOther", user.getDisplayName()));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -44,11 +43,7 @@ public class Commandjump extends EssentialsCommand {
|
||||
throw new Exception(tl("jumpError"), ex);
|
||||
}
|
||||
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getAsyncTeleport().teleport(loc, charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
|
||||
throw new NoChargeException();
|
||||
user.getAsyncTeleport().teleport(loc, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,6 @@ public class Commandkit extends EssentialsCommand {
|
||||
final Kit kit = new Kit(kitName, ess);
|
||||
kit.checkPerms(userFrom);
|
||||
kit.checkDelay(userFrom);
|
||||
kit.checkAffordable(userFrom);
|
||||
kits.add(kit);
|
||||
}
|
||||
|
||||
@@ -73,11 +72,9 @@ public class Commandkit extends EssentialsCommand {
|
||||
try {
|
||||
|
||||
kit.checkDelay(userFrom);
|
||||
kit.checkAffordable(userFrom);
|
||||
if (!kit.expandItems(userTo))
|
||||
continue;
|
||||
kit.setTime(userFrom);
|
||||
kit.chargeUser(userTo);
|
||||
|
||||
if (!userFrom.equals(userTo)) {
|
||||
userFrom.sendMessage(tl("kitGiveTo", kit.getName(), userTo.getDisplayName()));
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandpay extends EssentialsLoopCommand {
|
||||
private static final BigDecimal THOUSAND = new BigDecimal(1000);
|
||||
private static final BigDecimal MILLION = new BigDecimal(1_000_000);
|
||||
private static final BigDecimal BILLION = new BigDecimal(1_000_000_000);
|
||||
private static final BigDecimal TRILLION = new BigDecimal(1_000_000_000_000L);
|
||||
|
||||
public Commandpay() {
|
||||
super("pay");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final String ogStr = args[1];
|
||||
|
||||
if (ogStr.contains("-")) {
|
||||
throw new Exception(tl("payMustBePositive"));
|
||||
}
|
||||
|
||||
final String sanitizedString = ogStr.replaceAll("[^0-9.]", "");
|
||||
|
||||
if (sanitizedString.isEmpty()) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
BigDecimal tempAmount = new BigDecimal(sanitizedString);
|
||||
switch (Character.toLowerCase(ogStr.charAt(ogStr.length() - 1))) {
|
||||
case 'k': {
|
||||
tempAmount = tempAmount.multiply(THOUSAND);
|
||||
break;
|
||||
}
|
||||
case 'm': {
|
||||
tempAmount = tempAmount.multiply(MILLION);
|
||||
break;
|
||||
}
|
||||
case 'b': {
|
||||
tempAmount = tempAmount.multiply(BILLION);
|
||||
break;
|
||||
}
|
||||
case 't': {
|
||||
tempAmount = tempAmount.multiply(TRILLION);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final BigDecimal amount = tempAmount;
|
||||
|
||||
if (amount.compareTo(ess.getSettings().getMinimumPayAmount()) < 0) { // Check if amount is less than minimum-pay-amount
|
||||
throw new Exception(tl("minimumPayAmount", NumberUtil.displayCurrencyExactly(ess.getSettings().getMinimumPayAmount(), ess)));
|
||||
}
|
||||
final AtomicBoolean informToConfirm = new AtomicBoolean(false);
|
||||
final boolean canPayOffline = user.isAuthorized("essentials.pay.offline");
|
||||
if (!canPayOffline && args[0].equals("**")) {
|
||||
user.sendMessage(tl("payOffline"));
|
||||
return;
|
||||
}
|
||||
loopOfflinePlayersConsumer(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], player -> {
|
||||
try {
|
||||
if (player.getBase() != null && (!player.getBase().isOnline() || player.isHidden(user.getBase())) && !canPayOffline) {
|
||||
user.sendMessage(tl("payOffline"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.isAcceptingPay() || (ess.getSettings().isPayExcludesIgnoreList() && player.isIgnoredPlayer(user))) {
|
||||
user.sendMessage(tl("notAcceptingPay", player.getDisplayName()));
|
||||
return;
|
||||
}
|
||||
if (user.isPromptingPayConfirm() && !amount.equals(user.getConfirmingPayments().get(player))) { // checks if exists and if command needs to be repeated.
|
||||
// Used to reset confirmations and inform to confirm when a new pay command has been inserted.
|
||||
if (!informToConfirm.get()) {
|
||||
// User hasnt been asked to confirm payment to this player, reset all confirmed payments and ask to confirm again.
|
||||
// Clear previous confirmations to ensure that a new confirmation message is brought up.
|
||||
user.getConfirmingPayments().clear();
|
||||
informToConfirm.set(true);
|
||||
}
|
||||
user.getConfirmingPayments().put(player, amount);
|
||||
return;
|
||||
}
|
||||
user.payUser(player, amount, UserBalanceUpdateEvent.Cause.COMMAND_PAY);
|
||||
user.getConfirmingPayments().remove(player);
|
||||
Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), user.getMoney(), ess);
|
||||
} catch (final MaxMoneyException ex) {
|
||||
user.sendMessage(tl("maxMoney"));
|
||||
try {
|
||||
user.setMoney(user.getMoney().add(amount));
|
||||
} catch (final MaxMoneyException ignored) {
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
user.sendMessage(e.getMessage());
|
||||
}
|
||||
});
|
||||
if (informToConfirm.get()) {
|
||||
final String cmd = "/" + commandLabel + " " + StringUtil.joinList(" ", args);
|
||||
user.sendMessage(tl("confirmPayment", NumberUtil.displayCurrency(amount, ess), cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getPlayers(server, sender);
|
||||
} else if (args.length == 2) {
|
||||
return Lists.newArrayList(ess.getSettings().getMinimumPayAmount().toString());
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandpayconfirmtoggle extends EssentialsCommand {
|
||||
|
||||
public Commandpayconfirmtoggle() {
|
||||
super("payconfirmtoggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
boolean confirmingPay = !user.isPromptingPayConfirm();
|
||||
if (commandLabel.contains("payconfirmon")) {
|
||||
confirmingPay = true;
|
||||
} else if (commandLabel.contains("payconfirmoff")) {
|
||||
confirmingPay = false;
|
||||
}
|
||||
user.setPromptingPayConfirm(confirmingPay);
|
||||
user.sendMessage(confirmingPay ? tl("payConfirmToggleOn") : tl("payConfirmToggleOff"));
|
||||
user.getConfirmingPayments().clear(); // Clear any outstanding confirmations.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandpaytoggle extends EssentialsToggleCommand {
|
||||
|
||||
public Commandpaytoggle() {
|
||||
super("paytoggle", "essentials.paytoggle.others");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
toggleOtherPlayers(server, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (commandLabel.contains("payon")) {
|
||||
togglePlayer(user.getSource(), user, true);
|
||||
} else if (commandLabel.contains("payoff")) {
|
||||
togglePlayer(user.getSource(), user, false);
|
||||
} else {
|
||||
handleToggleWithArgs(server, user, args);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void togglePlayer(final CommandSource sender, final User user, Boolean enabled) {
|
||||
if (enabled == null) {
|
||||
enabled = !user.isAcceptingPay();
|
||||
}
|
||||
|
||||
user.setAcceptingPay(enabled);
|
||||
|
||||
user.sendMessage(enabled ? tl("payToggleOn") : tl("payToggleOff"));
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendMessage(enabled ? tl("payEnabledFor", user.getDisplayName()) : tl("payDisabledFor", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Material;
|
||||
@@ -30,10 +27,7 @@ public class Commandrepair extends EssentialsCommand {
|
||||
if (args.length == 0 || args[0].equalsIgnoreCase("hand") || !user.isAuthorized("essentials.repair.all")) {
|
||||
repairHand(user);
|
||||
} else if (args[0].equalsIgnoreCase("all")) {
|
||||
final Trade charge = new Trade("repair-all", ess);
|
||||
charge.isAffordableFor(user);
|
||||
repairAll(user);
|
||||
charge.charge(user);
|
||||
} else {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
@@ -50,13 +44,9 @@ public class Commandrepair extends EssentialsCommand {
|
||||
}
|
||||
|
||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final Trade charge = getCharge(item.getType());
|
||||
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
repairItem(item);
|
||||
|
||||
charge.charge(user);
|
||||
user.getBase().updateInventory();
|
||||
user.sendMessage(tl("repair", itemName.replace('_', ' ')));
|
||||
}
|
||||
@@ -97,14 +87,7 @@ public class Commandrepair extends EssentialsCommand {
|
||||
}
|
||||
|
||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final Trade charge = getCharge(item.getType());
|
||||
|
||||
try {
|
||||
charge.isAffordableFor(user);
|
||||
} catch (final ChargeException ex) {
|
||||
user.sendMessage(ex.getMessage());
|
||||
continue;
|
||||
}
|
||||
if (!item.getEnchantments().isEmpty() && !ess.getSettings().getRepairEnchanted() && !user.isAuthorized("essentials.repair.enchanted")) {
|
||||
continue;
|
||||
}
|
||||
@@ -114,25 +97,10 @@ public class Commandrepair extends EssentialsCommand {
|
||||
} catch (final Exception e) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
charge.charge(user);
|
||||
} catch (final ChargeException ex) {
|
||||
user.sendMessage(ex.getMessage());
|
||||
}
|
||||
repaired.add(itemName.replace('_', ' '));
|
||||
}
|
||||
}
|
||||
|
||||
private Trade getCharge(final Material material) {
|
||||
final String itemName = material.toString().toLowerCase(Locale.ENGLISH);
|
||||
if (VersionUtil.PRE_FLATTENING) {
|
||||
final int itemId = material.getId();
|
||||
return new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + itemId, new Trade("repair-item", ess), ess), ess);
|
||||
} else {
|
||||
return new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-item", ess), ess);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandsell extends EssentialsCommand {
|
||||
public Commandsell() {
|
||||
super("sell");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
BigDecimal totalWorth = BigDecimal.ZERO;
|
||||
if (args.length < 1) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("hand") && !user.isAuthorized("essentials.sell.hand")) {
|
||||
throw new Exception(tl("sellHandPermission"));
|
||||
} else if ((args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("invent") || args[0].equalsIgnoreCase("all")) && !user.isAuthorized("essentials.sell.bulk")) {
|
||||
throw new Exception(tl("sellBulkPermission"));
|
||||
}
|
||||
|
||||
final List<ItemStack> is = ess.getItemDb().getMatching(user, args);
|
||||
int count = 0;
|
||||
|
||||
final boolean isBulk = is.size() > 1;
|
||||
|
||||
final List<ItemStack> notSold = new ArrayList<>();
|
||||
for (ItemStack stack : is) {
|
||||
if (!ess.getSettings().isAllowSellNamedItems()) {
|
||||
if (stack.getItemMeta() != null && stack.getItemMeta().hasDisplayName()) {
|
||||
if (isBulk) {
|
||||
notSold.add(stack);
|
||||
continue;
|
||||
}
|
||||
throw new Exception(tl("cannotSellNamedItem"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (stack.getAmount() > 0) {
|
||||
totalWorth = totalWorth.add(sellItem(user, stack, args, isBulk));
|
||||
stack = stack.clone();
|
||||
count++;
|
||||
for (final ItemStack zeroStack : is) {
|
||||
if (zeroStack.isSimilar(stack)) {
|
||||
zeroStack.setAmount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
if (!isBulk) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!notSold.isEmpty()) {
|
||||
final List<String> names = new ArrayList<>();
|
||||
for (final ItemStack stack : notSold) {
|
||||
if (stack.getItemMeta() != null) { //This was already validated but IDE still freaks out
|
||||
names.add(stack.getItemMeta().getDisplayName());
|
||||
}
|
||||
}
|
||||
ess.showError(user.getSource(), new Exception(tl("cannotSellTheseNamedItems", String.join(ChatColor.RESET + ", ", names))), commandLabel);
|
||||
}
|
||||
if (count != 1) {
|
||||
final String totalWorthStr = NumberUtil.displayCurrency(totalWorth, ess);
|
||||
if (args[0].equalsIgnoreCase("blocks")) {
|
||||
user.sendMessage(tl("totalWorthBlocks", totalWorthStr, totalWorthStr));
|
||||
} else {
|
||||
user.sendMessage(tl("totalWorthAll", totalWorthStr, totalWorthStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BigDecimal sellItem(final User user, final ItemStack is, final String[] args, final boolean isBulkSell) throws Exception {
|
||||
final int amount = ess.getWorth().getAmount(ess, user, is, args, isBulkSell);
|
||||
final BigDecimal worth = ess.getWorth().getPrice(ess, is);
|
||||
|
||||
if (worth == null) {
|
||||
throw new Exception(tl("itemCannotBeSold"));
|
||||
}
|
||||
|
||||
if (amount <= 0) {
|
||||
if (!isBulkSell) {
|
||||
user.sendMessage(tl("itemSold", NumberUtil.displayCurrency(BigDecimal.ZERO, ess), BigDecimal.ZERO, is.getType().toString().toLowerCase(Locale.ENGLISH), NumberUtil.displayCurrency(worth, ess)));
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
final BigDecimal result = worth.multiply(BigDecimal.valueOf(amount));
|
||||
|
||||
//TODO: Prices for Enchantments
|
||||
final ItemStack ris = is.clone();
|
||||
ris.setAmount(amount);
|
||||
if (!Inventories.containsAtLeast(user.getBase(), ris, amount)) {
|
||||
// This should never happen.
|
||||
throw new IllegalStateException("Trying to remove more items than are available.");
|
||||
}
|
||||
Inventories.removeItemAmount(user.getBase(), ris, ris.getAmount());
|
||||
user.getBase().updateInventory();
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(result, ess), user.getLocation(), user.getMoney(), ess);
|
||||
user.giveMoney(result, null, UserBalanceUpdateEvent.Cause.COMMAND_SELL);
|
||||
user.sendMessage(tl("itemSold", NumberUtil.displayCurrency(result, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), NumberUtil.displayCurrency(worth, ess)));
|
||||
ess.getLogger().log(Level.INFO, tl("itemSoldConsole", user.getName(), is.getType().toString().toLowerCase(Locale.ENGLISH), NumberUtil.displayCurrency(result, ess), amount, NumberUtil.displayCurrency(worth, ess), user.getDisplayName()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getMatchingItems(args[0]);
|
||||
} else if (args.length == 2) {
|
||||
return Lists.newArrayList("1", "64");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FloatUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandsetworth extends EssentialsCommand {
|
||||
public Commandsetworth() {
|
||||
super("setworth");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 1) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final ItemStack stack;
|
||||
final String price;
|
||||
if (args.length == 1) {
|
||||
stack = user.getItemInHand();
|
||||
price = args[0];
|
||||
} else {
|
||||
stack = ess.getItemDb().get(args[0]);
|
||||
price = args[1];
|
||||
}
|
||||
|
||||
ess.getWorth().setPrice(ess, stack, FloatUtil.parseDouble(price));
|
||||
user.sendMessage(tl("worthSet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.getWorth().setPrice(ess, ess.getItemDb().get(args[0]), FloatUtil.parseDouble(args[1]));
|
||||
sender.sendMessage(tl("worthSet"));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
@@ -55,8 +54,6 @@ public class Commandspawner extends EssentialsCommand {
|
||||
if (args.length > 1 && NumberUtil.isInt(args[1]) && user.isAuthorized("essentials.spawner.delay")) {
|
||||
delay = Integer.parseInt(args[1]);
|
||||
}
|
||||
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
|
||||
charge.isAffordableFor(user);
|
||||
try {
|
||||
final CreatureSpawner spawner = (CreatureSpawner) target.getBlock().getState();
|
||||
spawner.setSpawnedType(mob.getType());
|
||||
@@ -72,7 +69,6 @@ public class Commandspawner extends EssentialsCommand {
|
||||
} catch (final Throwable ex) {
|
||||
throw new Exception(tl("mobSpawnError"), ex);
|
||||
}
|
||||
charge.charge(user);
|
||||
user.sendMessage(tl("setSpawner", mob.name));
|
||||
|
||||
}
|
||||
|
||||
@@ -142,12 +142,12 @@ public class Commandtogglejail extends EssentialsCommand {
|
||||
if (ess.getSettings().getTeleportWhenFreePolicy() == ISettings.TeleportWhenFreePolicy.BACK) {
|
||||
player.getAsyncTeleport().back(future);
|
||||
future.exceptionally(e -> {
|
||||
player.getAsyncTeleport().respawn(null, PlayerTeleportEvent.TeleportCause.PLUGIN, new CompletableFuture<>());
|
||||
player.getAsyncTeleport().respawn(PlayerTeleportEvent.TeleportCause.PLUGIN, new CompletableFuture<>());
|
||||
sender.sendMessage(tl("jailReleased", player.getName()));
|
||||
return false;
|
||||
});
|
||||
} else if (ess.getSettings().getTeleportWhenFreePolicy() == ISettings.TeleportWhenFreePolicy.SPAWN) {
|
||||
player.getAsyncTeleport().respawn(null, PlayerTeleportEvent.TeleportCause.PLUGIN, future);
|
||||
player.getAsyncTeleport().respawn(PlayerTeleportEvent.TeleportCause.PLUGIN, future);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import org.bukkit.Location;
|
||||
@@ -30,6 +29,6 @@ public class Commandtop extends EssentialsCommand {
|
||||
user.sendMessage(tl("teleportTop", safe.getWorld().getName(), safe.getBlockX(), safe.getBlockY(), safe.getBlockZ()));
|
||||
}
|
||||
});
|
||||
user.getAsyncTeleport().teleport(safe, new Trade(this.getName(), ess), TeleportCause.COMMAND, future);
|
||||
user.getAsyncTeleport().teleport(safe, TeleportCause.COMMAND, future);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@@ -42,10 +41,8 @@ public class Commandtp extends EssentialsCommand {
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + player.getWorld().getName())) {
|
||||
throw new Exception(tl("noPerm", "essentials.worlds." + player.getWorld().getName()));
|
||||
}
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getAsyncTeleport().teleport(player.getBase(), charge, TeleportCause.COMMAND, future);
|
||||
throw new NoChargeException();
|
||||
user.getAsyncTeleport().teleport(player.getBase(), TeleportCause.COMMAND, future);
|
||||
break;
|
||||
case 3:
|
||||
if (!user.isAuthorized("essentials.tp.position")) {
|
||||
throw new Exception(tl("noPerm", "essentials.tp.position"));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.AsyncTeleport;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.events.TPARequestEvent;
|
||||
import org.bukkit.Server;
|
||||
@@ -44,18 +43,17 @@ public class Commandtpa extends EssentialsCommand {
|
||||
}
|
||||
|
||||
if (player.isAutoTeleportEnabled() && !player.isIgnoredPlayer(user)) {
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
final AsyncTeleport teleport = user.getAsyncTeleport();
|
||||
teleport.setTpType(AsyncTeleport.TeleportType.TPA);
|
||||
final CompletableFuture<Boolean> future = getNewExceptionFuture(user.getSource(), commandLabel);
|
||||
teleport.teleport(player.getBase(), charge, PlayerTeleportEvent.TeleportCause.COMMAND, future);
|
||||
teleport.teleport(player.getBase(), PlayerTeleportEvent.TeleportCause.COMMAND, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
player.sendMessage(tl("requestAcceptedAuto", user.getDisplayName()));
|
||||
user.sendMessage(tl("requestAcceptedFromAuto", player.getDisplayName()));
|
||||
}
|
||||
});
|
||||
throw new NoChargeException();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.isIgnoredPlayer(user)) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.AsyncTeleport;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.essentialsx.api.v2.events.TeleportRequestResponseEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -38,7 +37,7 @@ public class Commandtpaccept extends EssentialsCommand {
|
||||
if (args.length > 0) {
|
||||
if (acceptAll) {
|
||||
acceptAllRequests(user, commandLabel);
|
||||
throw new NoChargeException();
|
||||
return;
|
||||
}
|
||||
user.sendMessage(tl("requestAccepted"));
|
||||
handleTeleport(user, user.getOutstandingTpaRequest(getPlayer(server, user, args, 0).getName(), true), commandLabel);
|
||||
@@ -46,7 +45,6 @@ public class Commandtpaccept extends EssentialsCommand {
|
||||
user.sendMessage(tl("requestAccepted"));
|
||||
handleTeleport(user, user.getNextTpaRequest(true, false, false), commandLabel);
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
private void acceptAllRequests(final User user, final String commandLabel) throws Exception {
|
||||
@@ -104,7 +102,6 @@ public class Commandtpaccept extends EssentialsCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
requester.sendMessage(tl("requestAcceptedFrom", user.getDisplayName()));
|
||||
|
||||
final CompletableFuture<Boolean> future = getNewExceptionFuture(requester.getSource(), commandLabel);
|
||||
@@ -121,11 +118,11 @@ public class Commandtpaccept extends EssentialsCommand {
|
||||
requester.sendMessage(tl("teleporting", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
});
|
||||
teleport.teleportPlayer(user, loc, charge, TeleportCause.COMMAND, future);
|
||||
teleport.teleportPlayer(user, loc, TeleportCause.COMMAND, future);
|
||||
} else {
|
||||
final AsyncTeleport teleport = requester.getAsyncTeleport();
|
||||
teleport.setTpType(AsyncTeleport.TeleportType.TPA);
|
||||
teleport.teleport(user.getBase(), charge, TeleportCause.COMMAND, future);
|
||||
teleport.teleport(user.getBase(), TeleportCause.COMMAND, future);
|
||||
}
|
||||
user.removeTpaRequest(request.getName());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
@@ -24,8 +23,7 @@ public class Commandtphere extends EssentialsCommand {
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + user.getWorld().getName())) {
|
||||
throw new Exception(tl("noPerm", "essentials.worlds." + user.getWorld().getName()));
|
||||
}
|
||||
user.getAsyncTeleport().teleportPlayer(player, user.getBase(), new Trade(this.getName(), ess), TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
throw new NoChargeException();
|
||||
user.getAsyncTeleport().teleportPlayer(player, user.getBase(), TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FloatUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -51,12 +50,8 @@ public class Commandtppos extends EssentialsCommand {
|
||||
if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000) {
|
||||
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
|
||||
}
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(tl("teleporting", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
user.getAsyncTeleport().teleport(loc, charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
|
||||
throw new NoChargeException();
|
||||
user.getAsyncTeleport().teleport(loc, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +80,7 @@ public class Commandtppos extends EssentialsCommand {
|
||||
}
|
||||
sender.sendMessage(tl("teleporting", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
user.sendMessage(tl("teleporting", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
user.getAsyncTeleport().teleport(loc, null, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
user.getAsyncTeleport().teleport(loc, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.RandomTeleport;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.events.UserRandomTeleportEvent;
|
||||
import org.bukkit.Server;
|
||||
@@ -21,8 +20,6 @@ public class Commandtpr extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
final RandomTeleport randomTeleport = ess.getRandomTeleport();
|
||||
final UserRandomTeleportEvent event = new UserRandomTeleportEvent(user, randomTeleport.getCenter(), randomTeleport.getMinRange(), randomTeleport.getMaxRange());
|
||||
server.getPluginManager().callEvent(event);
|
||||
@@ -31,14 +28,13 @@ public class Commandtpr extends EssentialsCommand {
|
||||
}
|
||||
randomTeleport.getRandomLocation(event.getCenter(), event.getMinRange(), event.getMaxRange()).thenAccept(location -> {
|
||||
final CompletableFuture<Boolean> future = getNewExceptionFuture(user.getSource(), commandLabel);
|
||||
user.getAsyncTeleport().teleport(location, charge, PlayerTeleportEvent.TeleportCause.COMMAND, future);
|
||||
user.getAsyncTeleport().teleport(location, PlayerTeleportEvent.TeleportCause.COMMAND, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
user.sendMessage(tl("tprSuccess"));
|
||||
}
|
||||
});
|
||||
});
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IWarps;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
@@ -10,11 +9,9 @@ import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
@@ -33,28 +30,26 @@ public class Commandwarp extends EssentialsCommand {
|
||||
throw new Exception(tl("warpListPermission"));
|
||||
}
|
||||
warpList(user.getSource(), args, user);
|
||||
throw new NoChargeException();
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: Remove 'otherplayers' permission.
|
||||
if (args.length == 2 && (user.isAuthorized("essentials.warp.otherplayers") || user.isAuthorized("essentials.warp.others"))) {
|
||||
final User otherUser = getPlayer(server, user, args, 1);
|
||||
warpUser(user, otherUser, args[0], commandLabel);
|
||||
throw new NoChargeException();
|
||||
return;
|
||||
}
|
||||
warpUser(user, user, args[0], commandLabel);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2 || NumberUtil.isInt(args[0])) {
|
||||
warpList(sender, args, null);
|
||||
throw new NoChargeException();
|
||||
return;
|
||||
}
|
||||
final User otherUser = getPlayer(server, args, 1, true, false);
|
||||
otherUser.getAsyncTeleport().warp(otherUser, args[0], null, TeleportCause.COMMAND, getNewExceptionFuture(sender, commandLabel));
|
||||
throw new NoChargeException();
|
||||
otherUser.getAsyncTeleport().warp(otherUser, args[0], TeleportCause.COMMAND, getNewExceptionFuture(sender, commandLabel));
|
||||
}
|
||||
|
||||
//TODO: Use one of the new text classes, like /help ?
|
||||
@@ -88,15 +83,10 @@ public class Commandwarp extends EssentialsCommand {
|
||||
}
|
||||
|
||||
private void warpUser(final User owner, final User user, final String name, final String commandLabel) throws Exception {
|
||||
final Trade chargeWarp = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess);
|
||||
final Trade chargeCmd = new Trade(this.getName(), ess);
|
||||
final BigDecimal fullCharge = chargeWarp.getCommandCost(user).add(chargeCmd.getCommandCost(user));
|
||||
final Trade charge = new Trade(fullCharge, ess);
|
||||
charge.isAffordableFor(owner);
|
||||
if (ess.getSettings().getPerWarpPermission() && !owner.isAuthorized("essentials.warps." + name)) {
|
||||
throw new Exception(tl("warpUsePermission"));
|
||||
}
|
||||
owner.getAsyncTeleport().warp(user, name, charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
owner.getAsyncTeleport().warp(user, name, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
}
|
||||
|
||||
private List<String> getAvailableWarpsFor(final IUser user) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Statistic;
|
||||
|
||||
@@ -42,9 +41,6 @@ public class Commandwhois extends EssentialsCommand {
|
||||
sender.sendMessage(tl("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
|
||||
final long playtimeMs = System.currentTimeMillis() - (user.getBase().getStatistic(PLAY_ONE_TICK) * 50L);
|
||||
sender.sendMessage(tl("whoisPlaytime", DateUtil.formatDateDiff(playtimeMs)));
|
||||
if (!ess.getSettings().isEcoDisabled()) {
|
||||
sender.sendMessage(tl("whoisMoney", NumberUtil.displayCurrency(user.getMoney(), ess)));
|
||||
}
|
||||
if (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.whois.ip")) {
|
||||
sender.sendMessage(tl("whoisIPAddress", user.getBase().getAddress().getAddress().toString()));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Location;
|
||||
@@ -43,7 +42,7 @@ public class Commandworld extends EssentialsCommand {
|
||||
user.sendMessage(tl("invalidWorld"));
|
||||
user.sendMessage(tl("possibleWorlds", server.getWorlds().size() - 1));
|
||||
user.sendMessage(tl("typeWorldName"));
|
||||
throw new NoChargeException();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,11 +62,7 @@ public class Commandworld extends EssentialsCommand {
|
||||
final Location loc = user.getLocation();
|
||||
final Location target = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
|
||||
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getAsyncTeleport().teleport(target, charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
|
||||
throw new NoChargeException();
|
||||
user.getAsyncTeleport().teleport(target, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandworth extends EssentialsCommand {
|
||||
public Commandworth() {
|
||||
super("worth");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final List<ItemStack> is = ess.getItemDb().getMatching(user, args);
|
||||
int count = 0;
|
||||
final boolean isBulk = is.size() > 1;
|
||||
BigDecimal totalWorth = BigDecimal.ZERO;
|
||||
for (ItemStack stack : is) {
|
||||
try {
|
||||
if (stack.getAmount() > 0) {
|
||||
totalWorth = totalWorth.add(itemWorth(user.getSource(), user, stack, args));
|
||||
stack = stack.clone();
|
||||
count++;
|
||||
for (final ItemStack zeroStack : is) {
|
||||
if (zeroStack.isSimilar(stack)) {
|
||||
zeroStack.setAmount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (final Exception e) {
|
||||
if (!isBulk) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 1) {
|
||||
final String totalWorthStr = NumberUtil.displayCurrency(totalWorth, ess);
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("blocks")) {
|
||||
user.sendMessage(tl("totalSellableBlocks", totalWorthStr, totalWorthStr));
|
||||
return;
|
||||
}
|
||||
user.sendMessage(tl("totalSellableAll", totalWorthStr, totalWorthStr));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
itemWorth(sender, null, ess.getItemDb().get(args[0]), args);
|
||||
}
|
||||
|
||||
private BigDecimal itemWorth(final CommandSource sender, final User user, final ItemStack is, final String[] args) throws Exception {
|
||||
int amount = 1;
|
||||
if (user == null) {
|
||||
if (args.length > 1) {
|
||||
try {
|
||||
amount = Integer.parseInt(args[1].replaceAll("[^0-9]", ""));
|
||||
} catch (final NumberFormatException ex) {
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
amount = ess.getWorth().getAmount(ess, user, is, args, true);
|
||||
}
|
||||
|
||||
final BigDecimal worth = ess.getWorth().getPrice(ess, is);
|
||||
if (worth == null) {
|
||||
throw new Exception(tl("itemCannotBeSold"));
|
||||
}
|
||||
|
||||
if (amount < 0) {
|
||||
amount = 0;
|
||||
}
|
||||
|
||||
final BigDecimal result = worth.multiply(BigDecimal.valueOf(amount));
|
||||
sender.sendMessage(MaterialUtil.getDamage(is) != 0 ? tl("worthMeta", is.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), MaterialUtil.getDamage(is), NumberUtil.displayCurrency(result, ess), amount, NumberUtil.displayCurrency(worth, ess)) : tl("worth", is.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), NumberUtil.displayCurrency(result, ess), amount, NumberUtil.displayCurrency(worth, ess)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getMatchingItems(args[0]);
|
||||
} else if (args.length == 2) {
|
||||
return Lists.newArrayList("1", "64");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getItems();
|
||||
} else if (args.length == 2) {
|
||||
return Lists.newArrayList("1", "64");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.IEssentialsModule;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -165,10 +164,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
||||
|
||||
@Override
|
||||
public final void run(final Server server, final User user, final String commandLabel, final Command cmd, final String[] args) throws Exception {
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
run(server, user, commandLabel, args);
|
||||
charge.charge(user);
|
||||
}
|
||||
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
|
||||
+6
-8
@@ -1,11 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -18,11 +16,11 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand {
|
||||
super(command);
|
||||
}
|
||||
|
||||
protected void loopOfflinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
|
||||
protected void loopOfflinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException {
|
||||
loopOfflinePlayersConsumer(server, sender, multipleStringMatches, matchWildcards, searchTerm, user -> updatePlayer(server, sender, user, commandArgs));
|
||||
}
|
||||
|
||||
protected void loopOfflinePlayersConsumer(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final UserConsumer userConsumer) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
|
||||
protected void loopOfflinePlayersConsumer(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final UserConsumer userConsumer) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException {
|
||||
if (searchTerm.isEmpty()) {
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
@@ -67,11 +65,11 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
protected void loopOnlinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
|
||||
protected void loopOnlinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException {
|
||||
loopOnlinePlayersConsumer(server, sender, multipleStringMatches, matchWildcards, searchTerm, user -> updatePlayer(server, sender, user, commandArgs));
|
||||
}
|
||||
|
||||
protected void loopOnlinePlayersConsumer(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final UserConsumer userConsumer) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
|
||||
protected void loopOnlinePlayersConsumer(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final UserConsumer userConsumer) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException {
|
||||
if (searchTerm.isEmpty()) {
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
@@ -121,7 +119,7 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void updatePlayer(Server server, CommandSource sender, User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException;
|
||||
protected abstract void updatePlayer(Server server, CommandSource sender, User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException;
|
||||
|
||||
@Override
|
||||
protected List<String> getPlayers(final Server server, final CommandSource interactor) {
|
||||
@@ -140,6 +138,6 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand {
|
||||
}
|
||||
|
||||
public interface UserConsumer {
|
||||
void accept(User user) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException;
|
||||
void accept(User user) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.earth2me.essentials.economy;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public interface EconomyLayer {
|
||||
String getName();
|
||||
|
||||
String getBackendName();
|
||||
|
||||
void enable(Plugin plugin);
|
||||
|
||||
boolean onServerLoad();
|
||||
|
||||
void disable();
|
||||
|
||||
String getPluginName();
|
||||
|
||||
String getPluginVersion();
|
||||
|
||||
boolean hasAccount(OfflinePlayer player);
|
||||
|
||||
boolean createPlayerAccount(OfflinePlayer player);
|
||||
|
||||
BigDecimal getBalance(OfflinePlayer player);
|
||||
|
||||
boolean deposit(OfflinePlayer player, BigDecimal amount);
|
||||
|
||||
boolean withdraw(OfflinePlayer player, BigDecimal amount);
|
||||
|
||||
default boolean set(OfflinePlayer player, BigDecimal amount) {
|
||||
if (!withdraw(player, getBalance(player))) {
|
||||
return false;
|
||||
}
|
||||
return amount.equals(BigDecimal.ZERO) || deposit(player, amount);
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
package com.earth2me.essentials.economy;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.economy.layers.VaultLayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Abstraction layer for economy abstraction layers.
|
||||
*/
|
||||
public final class EconomyLayers {
|
||||
private static final Map<String, EconomyLayer> registeredLayers = new HashMap<>();
|
||||
private static final List<String> availableLayers = new ArrayList<>();
|
||||
private static EconomyLayer selectedLayer = null;
|
||||
private static boolean serverStarted = false;
|
||||
|
||||
private EconomyLayers() {
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
if (!registeredLayers.isEmpty()) {
|
||||
throw new IllegalStateException("Economy layers have already been registered!");
|
||||
}
|
||||
|
||||
registerLayer(new VaultLayer());
|
||||
}
|
||||
|
||||
public static void onEnable(final Essentials ess) {
|
||||
ess.scheduleSyncDelayedTask(() -> {
|
||||
serverStarted = true;
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (!plugin.isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
final EconomyLayer layer = onPluginEnable(plugin);
|
||||
if (layer != null) {
|
||||
ess.getLogger().log(Level.INFO, "Essentials found a compatible payment resolution method: " + layer.getName() + " (v" + layer.getPluginVersion() + ")!");
|
||||
}
|
||||
}
|
||||
|
||||
onServerLoad();
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isServerStarted() {
|
||||
return serverStarted;
|
||||
}
|
||||
|
||||
public static EconomyLayer getSelectedLayer() {
|
||||
return selectedLayer;
|
||||
}
|
||||
|
||||
public static boolean isLayerSelected() {
|
||||
return getSelectedLayer() != null;
|
||||
}
|
||||
|
||||
public static EconomyLayer onPluginEnable(final Plugin plugin) {
|
||||
if (!registeredLayers.containsKey(plugin.getName())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final EconomyLayer layer = registeredLayers.get(plugin.getName());
|
||||
layer.enable(plugin);
|
||||
availableLayers.add(plugin.getName());
|
||||
if (selectedLayer != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
selectedLayer = layer;
|
||||
selectedLayer.enable(plugin);
|
||||
return selectedLayer;
|
||||
}
|
||||
|
||||
public static boolean onPluginDisable(final Plugin plugin) {
|
||||
if (!availableLayers.contains(plugin.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
registeredLayers.get(plugin.getName()).disable();
|
||||
availableLayers.remove(plugin.getName());
|
||||
|
||||
if (selectedLayer.getPluginName().equals(plugin.getName())) {
|
||||
selectedLayer = availableLayers.isEmpty() ? null : registeredLayers.get(availableLayers.get(0));
|
||||
if (selectedLayer != null && serverStarted) {
|
||||
selectedLayer.onServerLoad();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onServerLoad() {
|
||||
if (!isLayerSelected() || getSelectedLayer().onServerLoad()) {
|
||||
return;
|
||||
}
|
||||
|
||||
availableLayers.remove(getSelectedLayer().getPluginName());
|
||||
selectedLayer = null;
|
||||
if (!availableLayers.isEmpty()) {
|
||||
selectedLayer = registeredLayers.get(availableLayers.get(0));
|
||||
onServerLoad();
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerLayer(final EconomyLayer economyLayer) {
|
||||
registeredLayers.put(economyLayer.getPluginName(), economyLayer);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.earth2me.essentials.economy.layers;
|
||||
|
||||
import com.earth2me.essentials.economy.EconomyLayer;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class VaultLayer implements EconomyLayer {
|
||||
private Plugin plugin;
|
||||
private Economy adapter;
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(OfflinePlayer player) {
|
||||
return adapter.hasAccount(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(OfflinePlayer player) {
|
||||
return adapter.createPlayerAccount(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getBalance(OfflinePlayer player) {
|
||||
return BigDecimal.valueOf(adapter.getBalance(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deposit(OfflinePlayer player, BigDecimal amount) {
|
||||
return adapter.depositPlayer(player, amount.doubleValue()).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withdraw(OfflinePlayer player, BigDecimal amount) {
|
||||
return adapter.withdrawPlayer(player, amount.doubleValue()).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Vault Compatibility Layer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackendName() {
|
||||
return adapter.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onServerLoad() {
|
||||
this.adapter = Bukkit.getServicesManager().load(Economy.class);
|
||||
return adapter != null && !adapter.getName().equals("Essentials Economy") && !adapter.getName().equals("EssentialsX Economy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
this.plugin = null;
|
||||
this.adapter = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "Vault";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginVersion() {
|
||||
return plugin == null ? null : plugin.getDescription().getVersion();
|
||||
}
|
||||
}
|
||||
-405
@@ -1,405 +0,0 @@
|
||||
package com.earth2me.essentials.economy.vault;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.OfflinePlayerStub;
|
||||
import com.earth2me.essentials.api.NoLoanPermittedException;
|
||||
import com.earth2me.essentials.api.UserDoesNotExistException;
|
||||
import com.earth2me.essentials.config.EssentialsUserConfiguration;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* A goddamn Vault adapter, what more do you want?
|
||||
* Provides access to the EssentialsX economy for plugins that use the Vault API.
|
||||
* <p>
|
||||
* Developer note: for accessing Essentials/Vault economy functions from EssentialsX code, see
|
||||
* {@link com.earth2me.essentials.User}.
|
||||
*/
|
||||
public class VaultEconomyProvider implements Economy {
|
||||
private static final String WARN_NPC_RECREATE_1 = "Account creation was requested for NPC user {0}, but an account file with UUID {1} already exists.";
|
||||
private static final String WARN_NPC_RECREATE_2 = "Essentials will create a new account as requested by the other plugin, but this is almost certainly a bug and should be reported.";
|
||||
|
||||
private final Essentials ess;
|
||||
|
||||
public VaultEconomyProvider(Essentials essentials) {
|
||||
this.ess = essentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return ess.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "EssentialsX Economy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return NumberUtil.displayCurrency(BigDecimal.valueOf(amount), ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return currencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return ess.getSettings().getCurrencySymbol();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
if (com.earth2me.essentials.api.Economy.playerExists(playerName)) {
|
||||
return true;
|
||||
}
|
||||
// We may not have the player name in the usermap, let's double check an NPC account with this name doesn't exist.
|
||||
return com.earth2me.essentials.api.Economy.playerExists(UUID.nameUUIDFromBytes(("NPC:" + StringUtil.safeString(playerName)).getBytes(Charsets.UTF_8)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(OfflinePlayer player) {
|
||||
return com.earth2me.essentials.api.Economy.playerExists(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(OfflinePlayer player, String worldName) {
|
||||
return hasAccount(player);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
try {
|
||||
return getDoubleValue(com.earth2me.essentials.api.Economy.getMoneyExact(playerName));
|
||||
} catch (UserDoesNotExistException e) {
|
||||
createPlayerAccount(playerName);
|
||||
return getDoubleValue(ess.getSettings().getStartingBalance());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(OfflinePlayer player) {
|
||||
try {
|
||||
return getDoubleValue(com.earth2me.essentials.api.Economy.getMoneyExact(player.getUniqueId()));
|
||||
} catch (UserDoesNotExistException e) {
|
||||
createPlayerAccount(player);
|
||||
return getDoubleValue(ess.getSettings().getStartingBalance());
|
||||
}
|
||||
}
|
||||
|
||||
private double getDoubleValue(final BigDecimal value) {
|
||||
double amount = value.doubleValue();
|
||||
if (new BigDecimal(amount).compareTo(value) > 0) {
|
||||
// closest double is bigger than the exact amount
|
||||
// -> get the previous double value to not return more money than the user has
|
||||
amount = Math.nextAfter(amount, Double.NEGATIVE_INFINITY);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(OfflinePlayer player, String world) {
|
||||
return getBalance(player);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
try {
|
||||
return com.earth2me.essentials.api.Economy.hasEnough(playerName, amount);
|
||||
} catch (UserDoesNotExistException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(OfflinePlayer player, double amount) {
|
||||
try {
|
||||
return com.earth2me.essentials.api.Economy.hasEnough(player.getUniqueId(), BigDecimal.valueOf(amount));
|
||||
} catch (UserDoesNotExistException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(OfflinePlayer player, String worldName, double amount) {
|
||||
return has(player, amount);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
if (playerName == null) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Player name cannot be null!");
|
||||
}
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Cannot withdraw negative funds!");
|
||||
}
|
||||
|
||||
try {
|
||||
com.earth2me.essentials.api.Economy.subtract(playerName, amount);
|
||||
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.SUCCESS, null);
|
||||
} catch (UserDoesNotExistException e) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "User does not exist!");
|
||||
} catch (NoLoanPermittedException e) {
|
||||
return new EconomyResponse(0, getBalance(playerName), EconomyResponse.ResponseType.FAILURE, "Loan was not permitted!");
|
||||
} catch (MaxMoneyException e) {
|
||||
return new EconomyResponse(0, getBalance(playerName), EconomyResponse.ResponseType.FAILURE, "User goes over maximum money limit!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) {
|
||||
if (player == null) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Player cannot be null!");
|
||||
}
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Cannot withdraw negative funds!");
|
||||
}
|
||||
|
||||
try {
|
||||
com.earth2me.essentials.api.Economy.subtract(player.getUniqueId(), BigDecimal.valueOf(amount));
|
||||
return new EconomyResponse(amount, getBalance(player), EconomyResponse.ResponseType.SUCCESS, null);
|
||||
} catch (UserDoesNotExistException e) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "User does not exist!");
|
||||
} catch (NoLoanPermittedException e) {
|
||||
return new EconomyResponse(0, getBalance(player), EconomyResponse.ResponseType.FAILURE, "Loan was not permitted!");
|
||||
} catch (MaxMoneyException e) {
|
||||
return new EconomyResponse(0, getBalance(player), EconomyResponse.ResponseType.FAILURE, "User goes over maximum money limit!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount) {
|
||||
return withdrawPlayer(player, amount);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
if (playerName == null) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Player name can not be null.");
|
||||
}
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||
}
|
||||
|
||||
try {
|
||||
com.earth2me.essentials.api.Economy.add(playerName, amount);
|
||||
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.SUCCESS, null);
|
||||
} catch (UserDoesNotExistException e) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "User does not exist!");
|
||||
} catch (NoLoanPermittedException e) {
|
||||
return new EconomyResponse(0, getBalance(playerName), EconomyResponse.ResponseType.FAILURE, "Loan was not permitted!");
|
||||
} catch (MaxMoneyException e) {
|
||||
return new EconomyResponse(0, getBalance(playerName), EconomyResponse.ResponseType.FAILURE, "User goes over maximum money limit!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(OfflinePlayer player, double amount) {
|
||||
if (player == null) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Player can not be null.");
|
||||
}
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||
}
|
||||
|
||||
try {
|
||||
com.earth2me.essentials.api.Economy.add(player.getUniqueId(), BigDecimal.valueOf(amount));
|
||||
return new EconomyResponse(amount, getBalance(player), EconomyResponse.ResponseType.SUCCESS, null);
|
||||
} catch (UserDoesNotExistException e) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "User does not exist!");
|
||||
} catch (NoLoanPermittedException e) {
|
||||
return new EconomyResponse(0, getBalance(player), EconomyResponse.ResponseType.FAILURE, "Loan was not permitted!");
|
||||
} catch (MaxMoneyException e) {
|
||||
return new EconomyResponse(0, getBalance(player), EconomyResponse.ResponseType.FAILURE, "User goes over maximum money limit!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount) {
|
||||
return depositPlayer(player, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
// Assume we're creating an NPC here? If not, it's a lost cause anyway!
|
||||
return com.earth2me.essentials.api.Economy.createNPC(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(OfflinePlayer player) {
|
||||
if (hasAccount(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// String based UUIDs are version 3 and are used for NPC and OfflinePlayers
|
||||
// Citizens uses v2 UUIDs, yeah I don't know either!
|
||||
if (player.getUniqueId().version() == 3 || player.getUniqueId().version() == 2) {
|
||||
final File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists()) {
|
||||
if (!folder.mkdirs()) {
|
||||
throw new RuntimeException("Error while creating userdata directory!");
|
||||
}
|
||||
}
|
||||
final File npcFile = new File(folder, player.getUniqueId() + ".yml");
|
||||
if (npcFile.exists()) {
|
||||
ess.getLogger().log(Level.SEVERE, MessageFormat.format(WARN_NPC_RECREATE_1, player.getName(), player.getUniqueId().toString()), new RuntimeException());
|
||||
ess.getLogger().log(Level.SEVERE, WARN_NPC_RECREATE_2);
|
||||
}
|
||||
final EssentialsUserConfiguration npcConfig = new EssentialsUserConfiguration(player.getName(), player.getUniqueId(), npcFile);
|
||||
npcConfig.load();
|
||||
npcConfig.setProperty("npc", true);
|
||||
npcConfig.setProperty("last-account-name", player.getName());
|
||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||
npcConfig.blockingSave();
|
||||
// This will load the NPC into the UserMap + UUID cache
|
||||
ess.getUsers().addCachedNpcName(player.getUniqueId(), player.getName());
|
||||
ess.getUsers().getUser(player.getUniqueId());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Loading a v4 UUID that we somehow didn't track, mark it as a normal player and hope for the best, vault sucks :/
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Vault requested a player account creation for a v4 UUID: " + player);
|
||||
}
|
||||
|
||||
final Player userPlayer;
|
||||
if (player instanceof Player) {
|
||||
userPlayer = (Player) player;
|
||||
} else {
|
||||
final OfflinePlayerStub essPlayer = new OfflinePlayerStub(player.getUniqueId(), ess.getServer());
|
||||
essPlayer.setName(player.getName());
|
||||
userPlayer = essPlayer;
|
||||
}
|
||||
ess.getUsers().getUser(userPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(OfflinePlayer player, String worldName) {
|
||||
return createPlayerAccount(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, OfflinePlayer player) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, OfflinePlayer player) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, OfflinePlayer player) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "EssentialsX does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,8 @@ package com.earth2me.essentials.perm;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.perm.impl.AbstractVaultHandler;
|
||||
import com.earth2me.essentials.perm.impl.ConfigPermissionsHandler;
|
||||
import com.earth2me.essentials.perm.impl.GenericVaultHandler;
|
||||
import com.earth2me.essentials.perm.impl.LuckPermsHandler;
|
||||
import com.earth2me.essentials.perm.impl.ModernVaultHandler;
|
||||
import com.earth2me.essentials.perm.impl.SuperpermsHandler;
|
||||
import com.earth2me.essentials.utils.TriState;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -157,8 +154,6 @@ public class PermissionsHandler implements IPermissionsHandler {
|
||||
// load and assign a handler
|
||||
final List<Class<? extends SuperpermsHandler>> providerClazz = Arrays.asList(
|
||||
LuckPermsHandler.class,
|
||||
ModernVaultHandler.class,
|
||||
GenericVaultHandler.class,
|
||||
SuperpermsHandler.class
|
||||
);
|
||||
for (final Class<? extends IPermissionsHandler> providerClass : providerClazz) {
|
||||
@@ -194,16 +189,14 @@ public class PermissionsHandler implements IPermissionsHandler {
|
||||
lastHandler = handlerClass;
|
||||
|
||||
// output handler info
|
||||
if (handler instanceof AbstractVaultHandler) {
|
||||
String enabledPermsPlugin = ((AbstractVaultHandler) handler).getEnabledPermsPlugin();
|
||||
if (enabledPermsPlugin == null) enabledPermsPlugin = "generic";
|
||||
ess.getLogger().info("Using Vault based permissions (" + enabledPermsPlugin + ")");
|
||||
if (handler instanceof LuckPermsHandler) {
|
||||
ess.getLogger().info("Using LuckPerms permissions.");
|
||||
} else if (handler.getClass() == SuperpermsHandler.class) {
|
||||
if (handler.tryProvider(ess)) {
|
||||
ess.getLogger().warning("Detected supported permissions plugin " +
|
||||
((SuperpermsHandler) handler).getEnabledPermsPlugin() + " without Vault installed.");
|
||||
((SuperpermsHandler) handler).getEnabledPermsPlugin() + " without LuckPerms installed.");
|
||||
ess.getLogger().warning("Features such as chat prefixes/suffixes and group-related functionality will not " +
|
||||
"work until you install Vault.");
|
||||
"work until you install LuckPerms.");
|
||||
}
|
||||
ess.getLogger().info("Using superperms-based permissions.");
|
||||
} else if (handler.getClass() == ConfigPermissionsHandler.class) {
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.earth2me.essentials.perm.impl;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractVaultHandler extends SuperpermsHandler {
|
||||
protected static Permission perms = null;
|
||||
protected static Chat chat = null;
|
||||
|
||||
private boolean setupProviders() {
|
||||
try {
|
||||
Class.forName("net.milkbowl.vault.permission.Permission");
|
||||
Class.forName("net.milkbowl.vault.chat.Chat");
|
||||
} catch (final ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final RegisteredServiceProvider<Permission> permsProvider = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
final RegisteredServiceProvider<Chat> chatProvider = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
|
||||
if (permsProvider == null || chatProvider == null) return false;
|
||||
|
||||
perms = permsProvider.getProvider();
|
||||
chat = chatProvider.getProvider();
|
||||
return perms != null && chat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final OfflinePlayer base) {
|
||||
if (base.isOnline()) {
|
||||
return perms.getPrimaryGroup(base.getPlayer());
|
||||
}
|
||||
return perms.getPrimaryGroup(null, base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final OfflinePlayer base) {
|
||||
if (base.isOnline()) {
|
||||
return Arrays.asList(perms.getPlayerGroups(base.getPlayer()));
|
||||
}
|
||||
return Arrays.asList(perms.getPlayerGroups(null, base));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups() {
|
||||
return Arrays.asList(perms.getGroups());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addToGroup(OfflinePlayer base, String group) {
|
||||
return perms.playerAddGroup(null, base, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFromGroup(OfflinePlayer base, String group) {
|
||||
return perms.playerRemoveGroup(null, base, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group) {
|
||||
return perms.playerInGroup(base, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base) {
|
||||
final String playerPrefix = chat.getPlayerPrefix(base);
|
||||
if (playerPrefix != null) {
|
||||
return playerPrefix;
|
||||
}
|
||||
|
||||
final String playerGroup = perms.getPrimaryGroup(base);
|
||||
if (playerGroup != null) {
|
||||
return chat.getGroupPrefix(base.getWorld().getName(), playerGroup);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base) {
|
||||
final String playerSuffix = chat.getPlayerSuffix(base);
|
||||
if (playerSuffix != null) {
|
||||
return playerSuffix;
|
||||
}
|
||||
|
||||
final String playerGroup = perms.getPrimaryGroup(base);
|
||||
if (playerGroup != null) {
|
||||
return chat.getGroupSuffix(base.getWorld().getName(), playerGroup);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackendName() {
|
||||
final String reportedPlugin = perms.getName();
|
||||
final String classPlugin = JavaPlugin.getProvidingPlugin(perms.getClass()).getName();
|
||||
|
||||
if (reportedPlugin.equals(classPlugin)) {
|
||||
return reportedPlugin;
|
||||
}
|
||||
return reportedPlugin + " (" + classPlugin + ")";
|
||||
}
|
||||
|
||||
boolean canLoad() {
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") == null) return false;
|
||||
try {
|
||||
return setupProviders();
|
||||
} catch (final Throwable t) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.earth2me.essentials.perm.impl;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
|
||||
public class GenericVaultHandler extends AbstractVaultHandler {
|
||||
@Override
|
||||
public boolean tryProvider(Essentials ess) {
|
||||
return super.canLoad();
|
||||
}
|
||||
}
|
||||
@@ -4,24 +4,194 @@ import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.cacheddata.CachedMetaData;
|
||||
import net.luckperms.api.context.ContextCalculator;
|
||||
import net.luckperms.api.context.ContextConsumer;
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.UserManager;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LuckPermsHandler extends ModernVaultHandler {
|
||||
public class LuckPermsHandler extends SuperpermsHandler {
|
||||
private LuckPerms luckPerms;
|
||||
private Essentials ess;
|
||||
private CombinedCalculator calculator;
|
||||
|
||||
@Override
|
||||
protected boolean emulateWildcards() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryProvider(Essentials ess) {
|
||||
if (Bukkit.getPluginManager().getPlugin("LuckPerms") == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Class.forName("net.luckperms.api.LuckPerms");
|
||||
} catch (final ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
final RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
|
||||
if (provider == null) {
|
||||
return false;
|
||||
}
|
||||
this.luckPerms = provider.getProvider();
|
||||
this.ess = ess;
|
||||
return this.luckPerms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackendName() {
|
||||
return "LuckPerms";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnabledPermsPlugin() {
|
||||
return "LuckPerms";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group) {
|
||||
if (super.canBuild(base, group)) {
|
||||
return true;
|
||||
}
|
||||
final CachedMetaData meta = playerMeta(base);
|
||||
if (meta == null) {
|
||||
return false;
|
||||
}
|
||||
final String value = meta.getMetaValue("build");
|
||||
return value != null && Boolean.parseBoolean(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final OfflinePlayer base) {
|
||||
final net.luckperms.api.model.user.User lpUser = loadUser(base.getUniqueId());
|
||||
if (lpUser == null) {
|
||||
return null;
|
||||
}
|
||||
return lpUser.getPrimaryGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final OfflinePlayer base) {
|
||||
final net.luckperms.api.model.user.User lpUser = loadUser(base.getUniqueId());
|
||||
if (lpUser == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final QueryOptions options = lpUser.getQueryOptions();
|
||||
return lpUser.resolveInheritedNodes(options).stream()
|
||||
.filter(NodeType.INHERITANCE::matches)
|
||||
.map(NodeType.INHERITANCE::cast)
|
||||
.map(InheritanceNode::getGroupName)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups() {
|
||||
final List<String> groups = new ArrayList<>();
|
||||
for (final Group group : luckPerms.getGroupManager().getLoadedGroups()) {
|
||||
groups.add(group.getName());
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group) {
|
||||
final net.luckperms.api.model.user.User lpUser = luckPerms.getUserManager().getUser(base.getUniqueId());
|
||||
if (lpUser == null) {
|
||||
return super.inGroup(base, group);
|
||||
}
|
||||
return lpUser.resolveInheritedNodes(lpUser.getQueryOptions()).stream()
|
||||
.filter(NodeType.INHERITANCE::matches)
|
||||
.map(NodeType.INHERITANCE::cast)
|
||||
.anyMatch(node -> node.getGroupName().equalsIgnoreCase(group));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addToGroup(OfflinePlayer base, String group) {
|
||||
return modifyGroup(base.getUniqueId(), group, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFromGroup(OfflinePlayer base, String group) {
|
||||
return modifyGroup(base.getUniqueId(), group, false);
|
||||
}
|
||||
|
||||
private boolean modifyGroup(final UUID uuid, final String group, final boolean add) {
|
||||
final Group lpGroup = luckPerms.getGroupManager().getGroup(group);
|
||||
if (lpGroup == null) {
|
||||
return false;
|
||||
}
|
||||
final UserManager userManager = luckPerms.getUserManager();
|
||||
try {
|
||||
return userManager.modifyUser(uuid, user -> {
|
||||
final InheritanceNode node = InheritanceNode.builder(lpGroup).build();
|
||||
if (add) {
|
||||
user.data().add(node);
|
||||
} else {
|
||||
user.data().remove(node);
|
||||
}
|
||||
}).thenApply(v -> true).get();
|
||||
} catch (final InterruptedException | ExecutionException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base) {
|
||||
final CachedMetaData meta = playerMeta(base);
|
||||
return meta == null ? null : meta.getPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base) {
|
||||
final CachedMetaData meta = playerMeta(base);
|
||||
return meta == null ? null : meta.getSuffix();
|
||||
}
|
||||
|
||||
private CachedMetaData playerMeta(final Player base) {
|
||||
final net.luckperms.api.model.user.User lpUser = luckPerms.getUserManager().getUser(base.getUniqueId());
|
||||
if (lpUser == null) {
|
||||
return null;
|
||||
}
|
||||
return lpUser.getCachedData().getMetaData(QueryOptions.contextual(luckPerms.getContextManager().getContext(base)));
|
||||
}
|
||||
|
||||
private net.luckperms.api.model.user.User loadUser(final UUID uuid) {
|
||||
final UserManager userManager = luckPerms.getUserManager();
|
||||
net.luckperms.api.model.user.User lpUser = userManager.getUser(uuid);
|
||||
if (lpUser != null) {
|
||||
return lpUser;
|
||||
}
|
||||
try {
|
||||
final CompletableFuture<net.luckperms.api.model.user.User> future = userManager.loadUser(uuid);
|
||||
return future.get();
|
||||
} catch (final InterruptedException | ExecutionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerContext(final String context, final Function<User, Iterable<String>> calculator, final Supplier<Iterable<String>> suggestions) {
|
||||
if (this.calculator == null) {
|
||||
@@ -39,16 +209,6 @@ public class LuckPermsHandler extends ModernVaultHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryProvider(Essentials ess) {
|
||||
final RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
|
||||
if (provider != null) {
|
||||
this.luckPerms = provider.getProvider();
|
||||
this.ess = ess;
|
||||
}
|
||||
return luckPerms != null && super.tryProvider(ess);
|
||||
}
|
||||
|
||||
private static final class Calculator {
|
||||
private final String id;
|
||||
private final Function<User, Iterable<String>> function;
|
||||
@@ -61,24 +221,16 @@ public class LuckPermsHandler extends ModernVaultHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// By combining all calculators into one, we only need to make one call to ess.getUser().
|
||||
private class CombinedCalculator implements ContextCalculator<Player> {
|
||||
private final Set<Calculator> calculators = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void calculate(final Player target, final ContextConsumer consumer) {
|
||||
// If the player doesn't exist in the UserMap, just skip
|
||||
// Ess will cause performance problems for permissions checks if it attempts to
|
||||
// perform i/o to load the user data otherwise.
|
||||
if (!ess.getUsers().getAllUserUUIDs().contains(target.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUsers().loadUncachedUser(target.getUniqueId());
|
||||
|
||||
// This will occur for first time players during join,
|
||||
// None of our contexts would apply to that kind of person anyway,
|
||||
// lets just skip :O
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
@@ -94,7 +246,6 @@ public class LuckPermsHandler extends ModernVaultHandler {
|
||||
for (Calculator calculator : this.calculators) {
|
||||
calculator.suggestions.get().forEach(value -> builder.add(calculator.id, value));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.earth2me.essentials.perm.impl;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ModernVaultHandler extends AbstractVaultHandler {
|
||||
private final List<String> supportedPlugins = Arrays.asList("PermissionsEx", "LuckPerms");
|
||||
|
||||
@Override
|
||||
protected boolean emulateWildcards() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group) {
|
||||
Objects.requireNonNull(base, "Can't check build override for nonexistent player!");
|
||||
return super.canBuild(base, group) || chat.getPlayerInfoBoolean(base.getWorld().getName(), base, "build", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryProvider(Essentials ess) {
|
||||
return super.canLoad() && supportedPlugins.contains(getEnabledPermsPlugin());
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.SignBreakEvent;
|
||||
import net.ess3.api.events.SignCreateEvent;
|
||||
import net.ess3.api.events.SignInteractEvent;
|
||||
@@ -24,7 +20,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
@@ -33,7 +28,6 @@ import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class EssentialsSign {
|
||||
private static final String SIGN_OWNER_KEY = "sign-owner";
|
||||
protected static final BigDecimal MINTRANSACTION = new BigDecimal("0.01");
|
||||
private static final Set<Material> EMPTY_SET = new HashSet<>();
|
||||
protected transient final String signName;
|
||||
|
||||
@@ -120,7 +114,7 @@ public class EssentialsSign {
|
||||
sign.setLine(0, getSuccessName(ess));
|
||||
}
|
||||
return ret;
|
||||
} catch (final ChargeException | SignException ex) {
|
||||
} catch (final SignException ex) {
|
||||
showError(ess, user.getSource(), ex, signName);
|
||||
}
|
||||
setOwnerData(ess, user, sign);
|
||||
@@ -213,7 +207,7 @@ public class EssentialsSign {
|
||||
}
|
||||
}
|
||||
|
||||
protected final boolean onSignBreak(final Block block, final Player player, final IEssentials ess) throws MaxMoneyException {
|
||||
protected final boolean onSignBreak(final Block block, final Player player, final IEssentials ess) {
|
||||
final ISign sign = new BlockSign(block);
|
||||
final User user = ess.getUser(player);
|
||||
try {
|
||||
@@ -234,15 +228,15 @@ public class EssentialsSign {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException {
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, MaxMoneyException {
|
||||
protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -250,7 +244,7 @@ public class EssentialsSign {
|
||||
final User user = ess.getUser(player);
|
||||
try {
|
||||
return onBlockPlace(block, user, getUsername(user), ess);
|
||||
} catch (final ChargeException | SignException ex) {
|
||||
} catch (final SignException ex) {
|
||||
showError(ess, user.getSource(), ex, signName);
|
||||
}
|
||||
return false;
|
||||
@@ -260,13 +254,13 @@ public class EssentialsSign {
|
||||
final User user = ess.getUser(player);
|
||||
try {
|
||||
return onBlockInteract(block, user, getUsername(user), ess);
|
||||
} catch (final ChargeException | SignException ex) {
|
||||
} catch (final SignException ex) {
|
||||
showError(ess, user.getSource(), ex, signName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected final boolean onBlockBreak(final Block block, final Player player, final IEssentials ess) throws MaxMoneyException {
|
||||
protected final boolean onBlockBreak(final Block block, final Player player, final IEssentials ess) {
|
||||
final User user = ess.getUser(player);
|
||||
try {
|
||||
return onBlockBreak(block, user, getUsername(user), ess);
|
||||
@@ -296,15 +290,15 @@ public class EssentialsSign {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean onBlockInteract(final Block block, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onBlockInteract(final Block block, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException, MaxMoneyException {
|
||||
protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -320,51 +314,6 @@ public class EssentialsSign {
|
||||
return sign.getLine(lineNumber).trim();
|
||||
}
|
||||
|
||||
protected final void validateTrade(final ISign sign, final int index, final IEssentials ess) throws SignException {
|
||||
final String line = getSignText(sign, index);
|
||||
if (line.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final Trade trade = getTrade(sign, index, 0, ess);
|
||||
final BigDecimal money = trade.getMoney();
|
||||
if (money != null) {
|
||||
sign.setLine(index, NumberUtil.shortCurrency(money, ess));
|
||||
}
|
||||
}
|
||||
|
||||
protected final void validateTrade(final ISign sign, final int amountIndex, final int itemIndex, final User player, final IEssentials ess) throws SignException {
|
||||
final String itemType = getSignText(sign, itemIndex);
|
||||
if (itemType.equalsIgnoreCase("exp") || itemType.equalsIgnoreCase("xp")) {
|
||||
final int amount = getIntegerPositive(getSignText(sign, amountIndex));
|
||||
sign.setLine(amountIndex, Integer.toString(amount));
|
||||
sign.setLine(itemIndex, "exp");
|
||||
return;
|
||||
}
|
||||
final Trade trade = getTrade(sign, amountIndex, itemIndex, player, ess);
|
||||
final ItemStack item = trade.getItemStack();
|
||||
sign.setLine(amountIndex, Integer.toString(item.getAmount()));
|
||||
sign.setLine(itemIndex, itemType);
|
||||
}
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int amountIndex, final int itemIndex, final User player, final IEssentials ess) throws SignException {
|
||||
return getTrade(sign, amountIndex, itemIndex, player, false, ess);
|
||||
}
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int amountIndex, final int itemIndex, final User player, final boolean allowId, final IEssentials ess) throws SignException {
|
||||
final String itemType = getSignText(sign, itemIndex);
|
||||
if (itemType.equalsIgnoreCase("exp") || itemType.equalsIgnoreCase("xp")) {
|
||||
final int amount = getIntegerPositive(getSignText(sign, amountIndex));
|
||||
return new Trade(amount, ess);
|
||||
}
|
||||
final ItemStack item = getItemStack(itemType, 1, allowId, ess);
|
||||
final int amount = Math.min(getIntegerPositive(getSignText(sign, amountIndex)), item.getType().getMaxStackSize() * player.getBase().getInventory().getSize());
|
||||
if (item.getType() == Material.AIR || amount < 1) {
|
||||
throw new SignException(tl("moreThanZero"));
|
||||
}
|
||||
item.setAmount(amount);
|
||||
return new Trade(item, ess);
|
||||
}
|
||||
|
||||
protected final void validateInteger(final ISign sign, final int index) throws SignException {
|
||||
final String line = getSignText(sign, index);
|
||||
if (line.isEmpty()) {
|
||||
@@ -430,67 +379,6 @@ public class EssentialsSign {
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected final BigDecimal getMoney(final String line, final IEssentials ess) throws SignException {
|
||||
final boolean isMoney = line.matches("^[^0-9-.]?[.0-9]+[^0-9-.]?$");
|
||||
return isMoney ? getBigDecimalPositive(line, ess) : null;
|
||||
}
|
||||
|
||||
protected final BigDecimal getBigDecimalPositive(final String line, final IEssentials ess) throws SignException {
|
||||
final BigDecimal quantity = getBigDecimal(line, ess);
|
||||
if (quantity.compareTo(MINTRANSACTION) < 0) {
|
||||
throw new SignException(tl("moreThanZero"));
|
||||
}
|
||||
return quantity;
|
||||
}
|
||||
|
||||
protected final BigDecimal getBigDecimal(final String line, final IEssentials ess) throws SignException {
|
||||
try {
|
||||
return new BigDecimal(NumberUtil.sanitizeCurrencyString(line, ess));
|
||||
} catch (final ArithmeticException | NumberFormatException ex) {
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int index, final IEssentials ess) throws SignException {
|
||||
return getTrade(sign, index, 1, ess);
|
||||
}
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int index, final int decrement, final IEssentials ess) throws SignException {
|
||||
return getTrade(sign, index, decrement, false, ess);
|
||||
}
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int index, final int decrement, final boolean allowId, final IEssentials ess) throws SignException {
|
||||
final String line = getSignText(sign, index);
|
||||
if (line.isEmpty()) {
|
||||
return new Trade(signName.toLowerCase(Locale.ENGLISH) + "sign", ess);
|
||||
}
|
||||
|
||||
final BigDecimal money = getMoney(line, ess);
|
||||
if (money == null) {
|
||||
final String[] split = line.split("[ :]+", 2);
|
||||
if (split.length != 2) {
|
||||
throw new SignException(tl("invalidCharge"));
|
||||
}
|
||||
final int quantity = getIntegerPositive(split[0]);
|
||||
|
||||
final String item = split[1].toLowerCase(Locale.ENGLISH);
|
||||
if (item.equalsIgnoreCase("times")) {
|
||||
sign.setLine(index, (quantity - decrement) + " times");
|
||||
sign.updateSign();
|
||||
return new Trade(signName.toLowerCase(Locale.ENGLISH) + "sign", ess);
|
||||
} else if (item.equalsIgnoreCase("exp") || item.equalsIgnoreCase("xp")) {
|
||||
sign.setLine(index, quantity + " exp");
|
||||
return new Trade(quantity, ess);
|
||||
} else {
|
||||
final ItemStack stack = getItemStack(item, quantity, allowId, ess);
|
||||
sign.setLine(index, quantity + " " + item);
|
||||
return new Trade(stack, ess);
|
||||
}
|
||||
} else {
|
||||
return new Trade(money, ess);
|
||||
}
|
||||
}
|
||||
|
||||
private void showError(final IEssentials ess, final CommandSource sender, final Throwable exception, final String signName) {
|
||||
ess.showError(sender, exception, "\\ sign: " + signName);
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class SignBalance extends EssentialsSign {
|
||||
public SignBalance() {
|
||||
super("Balance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
player.sendMessage(tl("balance", NumberUtil.displayCurrency(player.getMoney(), ess)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -37,16 +36,12 @@ public class SignBlockListener implements Listener {
|
||||
event.getHandlers().unregister(this);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (protectSignsAndBlocks(event.getBlock(), event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} catch (final MaxMoneyException ex) {
|
||||
if (protectSignsAndBlocks(event.getBlock(), event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean protectSignsAndBlocks(final Block block, final Player player) throws MaxMoneyException {
|
||||
public boolean protectSignsAndBlocks(final Block block, final Player player) {
|
||||
// prevent any signs be broken by destroying the block they are attached to
|
||||
if (EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class SignBuy extends EssentialsSign {
|
||||
public SignBuy() {
|
||||
super("Buy");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
validateTrade(sign, 1, 2, player, ess);
|
||||
validateTrade(sign, 3, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException {
|
||||
Trade items = getTrade(sign, 1, 2, player, ess);
|
||||
Trade charge = getTrade(sign, 3, ess);
|
||||
|
||||
// Check if the player is trying to buy in bulk.
|
||||
if (ess.getSettings().isAllowBulkBuySell() && player.getBase().isSneaking()) {
|
||||
final ItemStack heldItem = player.getItemInHand();
|
||||
if (items.getItemStack().isSimilar(heldItem)) {
|
||||
final int initialItemAmount = items.getItemStack().getAmount();
|
||||
final int newItemAmount = heldItem.getAmount();
|
||||
final ItemStack item = items.getItemStack();
|
||||
item.setAmount(newItemAmount);
|
||||
items = new Trade(item, ess);
|
||||
|
||||
final BigDecimal chargeAmount = charge.getMoney();
|
||||
//noinspection BigDecimalMethodWithoutRoundingCalled
|
||||
BigDecimal pricePerSingleItem = chargeAmount.divide(new BigDecimal(initialItemAmount));
|
||||
pricePerSingleItem = pricePerSingleItem.multiply(new BigDecimal(newItemAmount));
|
||||
charge = new Trade(pricePerSingleItem, ess);
|
||||
}
|
||||
}
|
||||
|
||||
charge.isAffordableFor(player);
|
||||
if (!items.pay(player)) {
|
||||
throw new ChargeException("Inventory full"); //TODO: TL
|
||||
}
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Buy", "Interact", username, charge, username, items, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
@@ -12,7 +11,7 @@ public class SignDisposal extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
if (!player.isAuthorized("essentials.signs.disposal.name")) {
|
||||
sign.setLine(1, "");
|
||||
sign.setLine(2, "");
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Enchantments;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import net.ess3.api.IEssentials;
|
||||
@@ -20,7 +18,7 @@ public class SignEnchant extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
final ItemStack stack;
|
||||
final String itemName = sign.getLine(1);
|
||||
final MaterialTagProvider tagProvider = ess.getMaterialTagProvider();
|
||||
@@ -61,18 +59,15 @@ public class SignEnchant extends EssentialsSign {
|
||||
} catch (final Throwable ex) {
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
getTrade(sign, 3, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
final ItemStack playerHand = Inventories.getItemInHand(player.getBase());
|
||||
final MaterialTagProvider tagProvider = ess.getMaterialTagProvider();
|
||||
final String itemName = sign.getLine(1);
|
||||
final ItemStack search = itemName.equals("*") || itemName.equalsIgnoreCase("any") || (tagProvider != null && tagProvider.tagExists(itemName) && tagProvider.isTagged(itemName, playerHand.getType())) ? null : getItemStack(itemName, 1, ess);
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
final String[] enchantLevel = sign.getLine(2).split(":");
|
||||
final Enchantment enchantment = Enchantments.getByName(enchantLevel[0]);
|
||||
if (enchantment == null) {
|
||||
@@ -115,8 +110,6 @@ public class SignEnchant extends EssentialsSign {
|
||||
player.sendMessage(tl("enchantmentApplied", enchantmentName.replace('_', ' ')));
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Enchant", "Interact", username, charge, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
player.getBase().updateInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Material;
|
||||
@@ -49,7 +48,6 @@ public class SignFree extends EssentialsSign {
|
||||
invent.addItem(item);
|
||||
}
|
||||
player.getBase().openInventory(invent);
|
||||
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -22,27 +20,19 @@ public class SignGameMode extends EssentialsSign {
|
||||
if (gamemode.isEmpty()) {
|
||||
sign.setLine(1, "Survival");
|
||||
}
|
||||
|
||||
validateTrade(sign, 2, ess);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
final String mode = sign.getLine(1).trim();
|
||||
|
||||
if (mode.isEmpty()) {
|
||||
throw new SignException(tl("invalidSignLine", 2));
|
||||
}
|
||||
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
performSetMode(mode.toLowerCase(Locale.ENGLISH), player.getBase());
|
||||
player.sendMessage(tl("gameMode", tl(player.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||
Trade.log("Sign", "gameMode", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
@@ -14,23 +12,18 @@ public class SignHeal extends EssentialsSign {
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
validateTrade(sign, 1, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
if (player.getBase().getHealth() == 0) {
|
||||
throw new SignException(tl("healDead"));
|
||||
}
|
||||
final Trade charge = getTrade(sign, 1, ess);
|
||||
charge.isAffordableFor(player);
|
||||
player.getBase().setHealth(20);
|
||||
player.getBase().setFoodLevel(20);
|
||||
player.getBase().setFireTicks(0);
|
||||
player.sendMessage(tl("youAreHealed"));
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Heal", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
@@ -18,15 +16,11 @@ public class SignInfo extends EssentialsSign {
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
validateTrade(sign, 3, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
final String chapter = sign.getLine(1);
|
||||
final String page = sign.getLine(2);
|
||||
|
||||
@@ -42,8 +36,6 @@ public class SignInfo extends EssentialsSign {
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Info", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Kit;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import net.ess3.api.IEssentials;
|
||||
@@ -18,8 +16,6 @@ public class SignKit extends EssentialsSign {
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
validateTrade(sign, 3, ess);
|
||||
|
||||
final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH).trim();
|
||||
|
||||
if (kitName.isEmpty()) {
|
||||
@@ -40,20 +36,15 @@ public class SignKit extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH).trim();
|
||||
final String group = sign.getLine(2).trim();
|
||||
if ((!group.isEmpty() && ("§2Everyone".equals(group) || player.inGroup(group))) || (group.isEmpty() && player.isAuthorized("essentials.kits." + kitName))) {
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
try {
|
||||
final Kit kit = new Kit(kitName, ess);
|
||||
kit.checkDelay(player);
|
||||
kit.setTime(player);
|
||||
kit.expandItems(player);
|
||||
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Kit", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
} catch (final NoChargeException ex) {
|
||||
return false;
|
||||
} catch (final Exception ex) {
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.Trade.OverflowType;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
@@ -35,7 +30,7 @@ public class SignProtection extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
sign.setLine(3, "§4" + username);
|
||||
if (hasAdjacentBlock(sign.getBlock())) {
|
||||
final SignProtectionState state = isBlockProtected(sign.getBlock(), player, username, true);
|
||||
@@ -69,15 +64,14 @@ public class SignProtection extends EssentialsSign {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void checkIfSignsAreBroken(final Block block, final User player, final String username, final IEssentials ess) throws MaxMoneyException {
|
||||
private void checkIfSignsAreBroken(final Block block, final User player, final String username, final IEssentials ess) {
|
||||
final Map<Location, SignProtectionState> signs = getConnectedSigns(block, player, username, false);
|
||||
for (final Map.Entry<Location, SignProtectionState> entry : signs.entrySet()) {
|
||||
if (entry.getValue() != SignProtectionState.NOSIGN) {
|
||||
final Block sign = entry.getKey().getBlock();
|
||||
if (!hasAdjacentBlock(sign, block)) {
|
||||
block.setType(Material.AIR);
|
||||
final Trade trade = new Trade(new ItemStack(sign.getType(), 1), ess);
|
||||
trade.pay(player, OverflowType.DROP);
|
||||
player.getWorld().dropItemNaturally(player.getLocation(), new org.bukkit.inventory.ItemStack(sign.getType(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,7 +220,7 @@ public class SignProtection extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException, MaxMoneyException {
|
||||
protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
final SignProtectionState state = isBlockProtected(block, player, username, false);
|
||||
|
||||
if (state == SignProtectionState.OWNER || state == SignProtectionState.NOSIGN) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.commands.Commandrepair;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
@@ -23,15 +21,11 @@ public class SignRepair extends EssentialsSign {
|
||||
sign.setLine(1, "§c<hand|all>");
|
||||
throw new SignException(tl("invalidSignLine", 2));
|
||||
}
|
||||
validateTrade(sign, 2, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
final Commandrepair command = new Commandrepair();
|
||||
command.setEssentials(ess);
|
||||
|
||||
@@ -48,8 +42,6 @@ public class SignRepair extends EssentialsSign {
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Repair", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.Trade.OverflowType;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class SignSell extends EssentialsSign {
|
||||
public SignSell() {
|
||||
super("Sell");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
validateTrade(sign, 1, 2, player, ess);
|
||||
validateTrade(sign, 3, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException {
|
||||
Trade charge = getTrade(sign, 1, 2, player, ess);
|
||||
Trade money = getTrade(sign, 3, ess);
|
||||
|
||||
// Check if the player is trying to sell in bulk.
|
||||
if (ess.getSettings().isAllowBulkBuySell() && player.getBase().isSneaking()) {
|
||||
final ItemStack heldItem = player.getItemInHand();
|
||||
if (charge.getItemStack().isSimilar(heldItem)) {
|
||||
final int initialItemAmount = charge.getItemStack().getAmount();
|
||||
final int newItemAmount = heldItem.getAmount();
|
||||
final ItemStack item = charge.getItemStack();
|
||||
item.setAmount(newItemAmount);
|
||||
charge = new Trade(item, ess);
|
||||
|
||||
final BigDecimal chargeAmount = money.getMoney();
|
||||
//noinspection BigDecimalMethodWithoutRoundingCalled
|
||||
BigDecimal pricePerSingleItem = chargeAmount.divide(new BigDecimal(initialItemAmount));
|
||||
pricePerSingleItem = pricePerSingleItem.multiply(new BigDecimal(newItemAmount));
|
||||
money = new Trade(pricePerSingleItem, ess);
|
||||
}
|
||||
}
|
||||
|
||||
charge.isAffordableFor(player);
|
||||
money.pay(player, OverflowType.DROP);
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Sell", "Interact", username, charge, username, money, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.SpawnMob;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
@@ -14,17 +12,13 @@ public class SignSpawnmob extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
validateInteger(sign, 1);
|
||||
validateTrade(sign, 3, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
try {
|
||||
final List<String> mobParts = SpawnMob.mobParts(sign.getLine(2));
|
||||
final List<String> mobData = SpawnMob.mobData(sign.getLine(2));
|
||||
@@ -32,9 +26,6 @@ public class SignSpawnmob extends EssentialsSign {
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Spawnmob", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.DescParseTickFormat;
|
||||
import net.ess3.api.IEssentials;
|
||||
@@ -19,7 +17,6 @@ public class SignTime extends EssentialsSign {
|
||||
return true;
|
||||
}
|
||||
|
||||
validateTrade(sign, 2, ess);
|
||||
final String timeString = sign.getLine(1);
|
||||
if ("Day".equalsIgnoreCase(timeString)) {
|
||||
sign.setLine(1, "§2Day");
|
||||
@@ -33,27 +30,21 @@ public class SignTime extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
if (sign.getLine(1).isEmpty() && sign.getLine(2).isEmpty() && sign.getLine(3).isEmpty()) {
|
||||
player.sendMessage(tl("timeWorldCurrentSign", DescParseTickFormat.format(player.getWorld().getTime())));
|
||||
return true;
|
||||
}
|
||||
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
charge.isAffordableFor(player);
|
||||
final String timeString = sign.getLine(1);
|
||||
long time = player.getWorld().getTime();
|
||||
time -= time % 24000;
|
||||
if ("§2Day".equalsIgnoreCase(timeString)) {
|
||||
player.getWorld().setTime(time + 24000);
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "TimeDay", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
if ("§2Night".equalsIgnoreCase(timeString)) {
|
||||
player.getWorld().setTime(time + 37700);
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "TimeNight", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
throw new SignException(tl("onlyDayNight"));
|
||||
|
||||
@@ -1,365 +0,0 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.Trade.OverflowType;
|
||||
import com.earth2me.essentials.Trade.TradeType;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
//TODO: TL exceptions
|
||||
public class SignTrade extends EssentialsSign {
|
||||
private static final int MAX_STOCK_LINE_LENGTH = 15;
|
||||
|
||||
public SignTrade() {
|
||||
super("Trade");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
validateTrade(sign, 1, false, ess);
|
||||
validateTrade(sign, 2, true, ess);
|
||||
final Trade trade = getTrade(sign, 2, AmountType.ROUNDED, true, true, ess);
|
||||
final Trade charge = getTrade(sign, 1, AmountType.ROUNDED, false, true, ess);
|
||||
if (trade.getType() == charge.getType() && (trade.getType() != TradeType.ITEM || trade.getItemStack().isSimilar(charge.getItemStack()))) {
|
||||
throw new SignException("You cannot trade for the same item type.");
|
||||
}
|
||||
trade.isAffordableFor(player);
|
||||
setOwner(ess, player, sign, 3, "§8");
|
||||
trade.charge(player);
|
||||
Trade.log("Sign", "Trade", "Create", username, trade, username, null, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException {
|
||||
if (isOwner(ess, player, sign, 3, "§8")) {
|
||||
final Trade store = rechargeSign(sign, ess, player);
|
||||
final Trade stored;
|
||||
try {
|
||||
stored = getTrade(sign, 1, AmountType.TOTAL, true, true, ess);
|
||||
subtractAmount(sign, 1, stored, ess);
|
||||
|
||||
final Map<Integer, ItemStack> withdraw = stored.pay(player, OverflowType.RETURN);
|
||||
|
||||
if (withdraw == null) {
|
||||
Trade.log("Sign", "Trade", "Withdraw", username, store, username, null, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
} else {
|
||||
setAmount(sign, 1, BigDecimal.valueOf(withdraw.get(0).getAmount()), ess);
|
||||
Trade.log("Sign", "Trade", "Withdraw", username, stored, username, new Trade(withdraw.get(0), ess), sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
}
|
||||
} catch (final SignException e) {
|
||||
if (store == null) {
|
||||
throw new SignException(tl("tradeSignEmptyOwner"), e);
|
||||
}
|
||||
}
|
||||
Trade.log("Sign", "Trade", "Deposit", username, store, username, null, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
} else {
|
||||
final Trade charge = getTrade(sign, 1, AmountType.COST, false, true, ess);
|
||||
final Trade trade = getTrade(sign, 2, AmountType.COST, true, true, ess);
|
||||
charge.isAffordableFor(player);
|
||||
addAmount(sign, 1, charge, ess);
|
||||
subtractAmount(sign, 2, trade, ess);
|
||||
if (!trade.pay(player)) {
|
||||
subtractAmount(sign, 1, charge, ess);
|
||||
addAmount(sign, 2, trade, ess);
|
||||
throw new ChargeException("Full inventory");
|
||||
}
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Trade", "Interact", sign.getLine(3).substring(2), charge, username, trade, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
}
|
||||
sign.updateSign();
|
||||
return true;
|
||||
}
|
||||
|
||||
private Trade rechargeSign(final ISign sign, final IEssentials ess, final User player) throws SignException, ChargeException {
|
||||
final Trade trade = getTrade(sign, 2, AmountType.COST, false, true, ess);
|
||||
ItemStack stack = Inventories.getItemInHand(player.getBase());
|
||||
if (trade.getItemStack() != null && stack != null && !MaterialUtil.isAir(stack.getType()) && trade.getItemStack().getType() == stack.getType() && MaterialUtil.getDamage(trade.getItemStack()) == MaterialUtil.getDamage(stack) && trade.getItemStack().getEnchantments().equals(stack.getEnchantments())) {
|
||||
if (MaterialUtil.isPotion(trade.getItemStack().getType()) && !trade.getItemStack().isSimilar(stack)) {
|
||||
return null;
|
||||
}
|
||||
final int amount = trade.getItemStack().getAmount();
|
||||
if (Inventories.containsAtLeast(player.getBase(), trade.getItemStack(), amount)) {
|
||||
stack = stack.clone();
|
||||
stack.setAmount(amount);
|
||||
final Trade store = new Trade(stack, ess);
|
||||
addAmount(sign, 2, store, ess);
|
||||
store.charge(player);
|
||||
return store;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, MaxMoneyException {
|
||||
final String signOwner = sign.getLine(3);
|
||||
|
||||
final boolean isOwner = isOwner(ess, player, sign, 3, "§8");
|
||||
final boolean canBreak = isOwner || player.isAuthorized("essentials.signs.trade.override");
|
||||
final boolean canCollect = isOwner || player.isAuthorized("essentials.signs.trade.override.collect");
|
||||
|
||||
if (canBreak) {
|
||||
try {
|
||||
final Trade stored1 = getTrade(sign, 1, AmountType.TOTAL, false, true, ess);
|
||||
final Trade stored2 = getTrade(sign, 2, AmountType.TOTAL, false, true, ess);
|
||||
|
||||
if (!canCollect) {
|
||||
Trade.log("Sign", "Trade", "Destroy", signOwner.substring(2), stored2, username, stored1, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
final Map<Integer, ItemStack> withdraw1 = stored1.pay(player, OverflowType.DROP);
|
||||
final Map<Integer, ItemStack> withdraw2 = stored2.pay(player, OverflowType.DROP);
|
||||
|
||||
if (withdraw1 == null && withdraw2 == null) {
|
||||
Trade.log("Sign", "Trade", "Break", signOwner.substring(2), stored2, username, stored1, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
setAmount(sign, 1, BigDecimal.valueOf(withdraw1 == null ? 0L : withdraw1.get(0).getAmount()), ess);
|
||||
Trade.log("Sign", "Trade", "Withdraw", signOwner.substring(2), stored1, username, withdraw1 == null ? null : new Trade(withdraw1.get(0), ess), sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
|
||||
setAmount(sign, 2, BigDecimal.valueOf(withdraw2 == null ? 0L : withdraw2.get(0).getAmount()), ess);
|
||||
Trade.log("Sign", "Trade", "Withdraw", signOwner.substring(2), stored2, username, withdraw2 == null ? null : new Trade(withdraw2.get(0), ess), sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
|
||||
sign.updateSign();
|
||||
} catch (final SignException e) {
|
||||
if (player.isAuthorized("essentials.signs.trade.override")) {
|
||||
return true;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void validateSignLength(final String newLine) throws SignException {
|
||||
if (newLine.length() > MAX_STOCK_LINE_LENGTH) {
|
||||
throw new SignException("This sign is full!");
|
||||
}
|
||||
}
|
||||
|
||||
protected final void validateTrade(final ISign sign, final int index, final boolean amountNeeded, final IEssentials ess) throws SignException {
|
||||
final String line = sign.getLine(index).trim();
|
||||
if (line.isEmpty()) {
|
||||
throw new SignException("Empty line");
|
||||
}
|
||||
final String[] split = line.split("[ :]+");
|
||||
|
||||
if (split.length == 1 && !amountNeeded) {
|
||||
final BigDecimal money = getMoney(split[0], ess);
|
||||
if (money != null) {
|
||||
final String newLine = NumberUtil.shortCurrency(money, ess) + ":0";
|
||||
validateSignLength(newLine);
|
||||
sign.setLine(index, newLine);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (split.length == 2 && amountNeeded) {
|
||||
final BigDecimal money = getMoney(split[0], ess);
|
||||
BigDecimal amount = getBigDecimalPositive(split[1], ess);
|
||||
if (money != null && amount != null) {
|
||||
amount = amount.subtract(amount.remainder(money));
|
||||
if (amount.compareTo(MINTRANSACTION) < 0 || money.compareTo(MINTRANSACTION) < 0) {
|
||||
throw new SignException(tl("moreThanZero"));
|
||||
}
|
||||
final String newLine = NumberUtil.shortCurrency(money, ess) + ":" + NumberUtil.formatAsCurrency(amount);
|
||||
validateSignLength(newLine);
|
||||
sign.setLine(index, newLine);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (split.length == 2 && !amountNeeded) {
|
||||
final int amount = getIntegerPositive(split[0]);
|
||||
|
||||
if (amount < 1) {
|
||||
throw new SignException(tl("moreThanZero"));
|
||||
}
|
||||
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp")) && getItemStack(split[1], amount, ess).getType() == Material.AIR) {
|
||||
throw new SignException(tl("moreThanZero"));
|
||||
}
|
||||
final String newline = amount + " " + split[1] + ":0";
|
||||
validateSignLength(newline);
|
||||
sign.setLine(index, newline);
|
||||
return;
|
||||
}
|
||||
|
||||
if (split.length == 3 && amountNeeded) {
|
||||
final int stackamount = getIntegerPositive(split[0]);
|
||||
int amount = getIntegerPositive(split[2]);
|
||||
amount -= amount % stackamount;
|
||||
if (amount < 1 || stackamount < 1) {
|
||||
throw new SignException(tl("moreThanZero"));
|
||||
}
|
||||
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp")) && getItemStack(split[1], stackamount, ess).getType() == Material.AIR) {
|
||||
throw new SignException(tl("moreThanZero"));
|
||||
}
|
||||
final String newline = stackamount + " " + split[1] + ":" + amount;
|
||||
validateSignLength(newline);
|
||||
sign.setLine(index, newline);
|
||||
return;
|
||||
}
|
||||
throw new SignException(tl("invalidSignLine", index + 1));
|
||||
}
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int index, final AmountType amountType, final boolean notEmpty, final IEssentials ess) throws SignException {
|
||||
return getTrade(sign, index, amountType, notEmpty, false, ess);
|
||||
}
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int index, final AmountType amountType, final boolean notEmpty, final boolean allowId, final IEssentials ess) throws SignException {
|
||||
final String line = sign.getLine(index).trim();
|
||||
if (line.isEmpty()) {
|
||||
throw new SignException("Empty line");
|
||||
}
|
||||
final String[] split = line.split("[ :]+");
|
||||
|
||||
if (split.length == 2) {
|
||||
try {
|
||||
final BigDecimal money = getMoney(split[0], ess);
|
||||
final BigDecimal amount = notEmpty ? getBigDecimalPositive(split[1], ess) : getBigDecimal(split[1], ess);
|
||||
if (money != null && amount != null) {
|
||||
return new Trade(amountType == AmountType.COST ? money : amount, ess);
|
||||
}
|
||||
} catch (final SignException e) {
|
||||
throw new SignException(tl("tradeSignEmpty"), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (split.length == 3) {
|
||||
final int stackAmount = getIntegerPositive(split[0]);
|
||||
if (split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp")) {
|
||||
int amount = getInteger(split[2]);
|
||||
if (amountType == AmountType.ROUNDED) {
|
||||
amount -= amount % stackAmount;
|
||||
}
|
||||
if (notEmpty && (amount < 1 || stackAmount < 1)) {
|
||||
throw new SignException(tl("tradeSignEmpty"));
|
||||
}
|
||||
return new Trade(amountType == AmountType.COST ? stackAmount : amount, ess);
|
||||
} else {
|
||||
final ItemStack item = getItemStack(split[1], stackAmount, allowId, ess);
|
||||
int amount = getInteger(split[2]);
|
||||
if (amountType == AmountType.ROUNDED) {
|
||||
amount -= amount % stackAmount;
|
||||
}
|
||||
if (notEmpty && (amount < 1 || stackAmount < 1 || item.getType() == Material.AIR || amount < stackAmount)) {
|
||||
throw new SignException(tl("tradeSignEmpty"));
|
||||
}
|
||||
item.setAmount(amountType == AmountType.COST ? stackAmount : amount);
|
||||
return new Trade(item, ess);
|
||||
}
|
||||
}
|
||||
throw new SignException(tl("invalidSignLine", index + 1));
|
||||
}
|
||||
|
||||
protected final void subtractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException {
|
||||
final BigDecimal money = trade.getMoney();
|
||||
if (money != null) {
|
||||
changeAmount(sign, index, money.negate(), ess);
|
||||
}
|
||||
final ItemStack item = trade.getItemStack();
|
||||
if (item != null) {
|
||||
changeAmount(sign, index, BigDecimal.valueOf(-item.getAmount()), ess);
|
||||
}
|
||||
final Integer exp = trade.getExperience();
|
||||
if (exp != null) {
|
||||
changeAmount(sign, index, BigDecimal.valueOf(-exp), ess);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void addAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException {
|
||||
final BigDecimal money = trade.getMoney();
|
||||
if (money != null) {
|
||||
changeAmount(sign, index, money, ess);
|
||||
}
|
||||
final ItemStack item = trade.getItemStack();
|
||||
if (item != null) {
|
||||
changeAmount(sign, index, BigDecimal.valueOf(item.getAmount()), ess);
|
||||
}
|
||||
final Integer exp = trade.getExperience();
|
||||
if (exp != null) {
|
||||
changeAmount(sign, index, BigDecimal.valueOf(exp), ess);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Translate these exceptions.
|
||||
private void changeAmount(final ISign sign, final int index, final BigDecimal value, final IEssentials ess) throws SignException {
|
||||
final String line = sign.getLine(index).trim();
|
||||
if (line.isEmpty()) {
|
||||
throw new SignException("Empty line");
|
||||
}
|
||||
final String[] split = line.split("[ :]+");
|
||||
|
||||
if (split.length == 2) {
|
||||
final BigDecimal amount = getBigDecimal(split[1], ess).add(value);
|
||||
setAmount(sign, index, amount, ess);
|
||||
return;
|
||||
}
|
||||
if (split.length == 3) {
|
||||
final BigDecimal amount = getBigDecimal(split[2], ess).add(value);
|
||||
setAmount(sign, index, amount, ess);
|
||||
return;
|
||||
}
|
||||
throw new SignException(tl("invalidSignLine", index + 1));
|
||||
}
|
||||
|
||||
//TODO: Translate these exceptions.
|
||||
private void setAmount(final ISign sign, final int index, final BigDecimal value, final IEssentials ess) throws SignException {
|
||||
|
||||
final String line = sign.getLine(index).trim();
|
||||
if (line.isEmpty()) {
|
||||
throw new SignException("Empty line");
|
||||
}
|
||||
final String[] split = line.split("[ :]+");
|
||||
|
||||
if (split.length == 2) {
|
||||
final BigDecimal money = getMoney(split[0], ess);
|
||||
final BigDecimal amount = getBigDecimal(split[1], ess);
|
||||
if (money != null && amount != null) {
|
||||
final String newline = NumberUtil.shortCurrency(money, ess) + ":" + NumberUtil.formatAsCurrency(value);
|
||||
validateSignLength(newline);
|
||||
sign.setLine(index, newline);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (split.length == 3) {
|
||||
final int stackAmount = getIntegerPositive(split[0]);
|
||||
if (split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp")) {
|
||||
final String newline = stackAmount + " " + split[1] + ":" + value.intValueExact();
|
||||
validateSignLength(newline);
|
||||
sign.setLine(index, newline);
|
||||
} else {
|
||||
getItemStack(split[1], stackAmount, ess);
|
||||
final String newline = stackAmount + " " + split[1] + ":" + value.intValueExact();
|
||||
validateSignLength(newline);
|
||||
sign.setLine(index, newline);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new SignException(tl("invalidSignLine", index + 1));
|
||||
}
|
||||
|
||||
public enum AmountType {
|
||||
TOTAL,
|
||||
ROUNDED,
|
||||
COST
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
@@ -17,7 +15,6 @@ public class SignWarp extends EssentialsSign {
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
validateTrade(sign, 3, ess);
|
||||
final String warpName = sign.getLine(1);
|
||||
|
||||
if (warpName.isEmpty()) {
|
||||
@@ -38,7 +35,7 @@ public class SignWarp extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
final String warpName = sign.getLine(1);
|
||||
final String group = sign.getLine(2);
|
||||
|
||||
@@ -52,14 +49,8 @@ public class SignWarp extends EssentialsSign {
|
||||
}
|
||||
}
|
||||
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
player.getAsyncTeleport().warp(player, warpName, charge, TeleportCause.PLUGIN, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
Trade.log("Sign", "Warp", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
}
|
||||
});
|
||||
player.getAsyncTeleport().warp(player, warpName, TeleportCause.PLUGIN, future);
|
||||
future.exceptionally(e -> {
|
||||
ess.showError(player.getSource(), e, "\\ sign: " + signName);
|
||||
return false;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
@@ -18,7 +16,6 @@ public class SignWeather extends EssentialsSign {
|
||||
return true;
|
||||
}
|
||||
|
||||
validateTrade(sign, 2, ess);
|
||||
final String timeString = sign.getLine(1);
|
||||
if ("Sun".equalsIgnoreCase(timeString)) {
|
||||
sign.setLine(1, "§2Sun");
|
||||
@@ -33,7 +30,7 @@ public class SignWeather extends EssentialsSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
|
||||
if (sign.getLine(1).isEmpty() && sign.getLine(2).isEmpty() && sign.getLine(3).isEmpty()) {
|
||||
if (player.getWorld().hasStorm()) {
|
||||
player.sendMessage(tl("weatherSignStorm"));
|
||||
@@ -43,19 +40,13 @@ public class SignWeather extends EssentialsSign {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
charge.isAffordableFor(player);
|
||||
final String weatherString = sign.getLine(1);
|
||||
if ("§2Sun".equalsIgnoreCase(weatherString)) {
|
||||
player.getWorld().setStorm(false);
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "WeatherSun", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
if ("§2Storm".equalsIgnoreCase(weatherString)) {
|
||||
player.getWorld().setStorm(true);
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "WeatherStorm", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
return true;
|
||||
}
|
||||
throw new SignException(tl("onlySunStorm"));
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.earth2me.essentials.signs;
|
||||
//This enum is used when checking to see what signs are enabled
|
||||
public enum Signs {
|
||||
ANVIL(new SignAnvil()),
|
||||
BALANCE(new SignBalance()),
|
||||
BUY(new SignBuy()),
|
||||
CARTOGRAPHY(new SignCartography()),
|
||||
DISPOSAL(new SignDisposal()),
|
||||
ENCHANT(new SignEnchant()),
|
||||
@@ -18,11 +16,9 @@ public enum Signs {
|
||||
MAIL(new SignMail()),
|
||||
PROTECTION(new SignProtection()),
|
||||
REPAIR(new SignRepair()),
|
||||
SELL(new SignSell()),
|
||||
SMITHING(new SignSmithing()),
|
||||
SPAWNMOB(new SignSpawnmob()),
|
||||
TIME(new SignTime()),
|
||||
TRADE(new SignTrade()),
|
||||
WARP(new SignWarp()),
|
||||
WEATHER(new SignWeather()),
|
||||
WORKBENCH(new SignWorkbench());
|
||||
|
||||
@@ -41,7 +41,6 @@ enum KeywordType {
|
||||
PREFIX(KeywordCachable.CACHEABLE),
|
||||
SUFFIX(KeywordCachable.CACHEABLE),
|
||||
GROUP(KeywordCachable.CACHEABLE),
|
||||
BALANCE(KeywordCachable.CACHEABLE),
|
||||
MAILS(KeywordCachable.CACHEABLE),
|
||||
PLAYTIME(KeywordCachable.CACHEABLE),
|
||||
WORLD(KeywordCachable.CACHEABLE),
|
||||
@@ -227,11 +226,6 @@ public class KeywordReplacer implements IText {
|
||||
replacer = user.getGroup();
|
||||
}
|
||||
break;
|
||||
case BALANCE:
|
||||
if (user != null) {
|
||||
replacer = NumberUtil.displayCurrency(user.getMoney(), ess);
|
||||
}
|
||||
break;
|
||||
case MAILS:
|
||||
if (user != null) {
|
||||
replacer = Integer.toString(user.getMailAmount());
|
||||
|
||||
@@ -1,100 +1,31 @@
|
||||
package com.earth2me.essentials.utils;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public final class NumberUtil {
|
||||
|
||||
private static final DecimalFormat twoDPlaces = new DecimalFormat("#,###.##");
|
||||
private static final DecimalFormat currencyFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
// This field is likely to be modified in com.earth2me.essentials.Settings when loading currency format.
|
||||
// This ensures that we can supply a constant formatting.
|
||||
private static NumberFormat PRETTY_FORMAT = NumberFormat.getInstance(Locale.US);
|
||||
// Kept as a no-op setter for legacy compatibility.
|
||||
private static NumberFormat PRETTY_FORMAT = NumberFormat.getInstance();
|
||||
|
||||
static {
|
||||
twoDPlaces.setRoundingMode(RoundingMode.HALF_UP);
|
||||
currencyFormat.setRoundingMode(RoundingMode.FLOOR);
|
||||
|
||||
PRETTY_FORMAT.setRoundingMode(RoundingMode.FLOOR);
|
||||
PRETTY_FORMAT.setGroupingUsed(true);
|
||||
PRETTY_FORMAT.setMinimumFractionDigits(2);
|
||||
PRETTY_FORMAT.setMaximumFractionDigits(2);
|
||||
}
|
||||
|
||||
private NumberUtil() {
|
||||
}
|
||||
|
||||
// this method should only be called by Essentials
|
||||
public static void internalSetPrettyFormat(final NumberFormat prettyFormat) {
|
||||
PRETTY_FORMAT = prettyFormat;
|
||||
}
|
||||
|
||||
public static String shortCurrency(final BigDecimal value, final IEssentials ess) {
|
||||
if (ess.getSettings().isCurrencySymbolSuffixed()) {
|
||||
return formatAsCurrency(value) + ess.getSettings().getCurrencySymbol();
|
||||
}
|
||||
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
|
||||
}
|
||||
|
||||
public static String formatDouble(final double value) {
|
||||
return twoDPlaces.format(value);
|
||||
}
|
||||
|
||||
public static String formatAsCurrency(final BigDecimal value) {
|
||||
String str = currencyFormat.format(value);
|
||||
if (str.endsWith(".00")) {
|
||||
str = str.substring(0, str.length() - 3);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String formatAsPrettyCurrency(final BigDecimal value) {
|
||||
String str = PRETTY_FORMAT.format(value);
|
||||
if (str.endsWith(".00")) {
|
||||
str = str.substring(0, str.length() - 3);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String displayCurrency(final BigDecimal value, final IEssentials ess) {
|
||||
String currency = formatAsPrettyCurrency(value);
|
||||
String sign = "";
|
||||
if (value.signum() < 0) {
|
||||
currency = currency.substring(1);
|
||||
sign = "-";
|
||||
}
|
||||
if (ess.getSettings().isCurrencySymbolSuffixed()) {
|
||||
return sign + tl("currency", currency, ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
return sign + tl("currency", ess.getSettings().getCurrencySymbol(), currency);
|
||||
}
|
||||
|
||||
public static String displayCurrencyExactly(final BigDecimal value, final IEssentials ess) {
|
||||
String currency = value.toPlainString();
|
||||
String sign = "";
|
||||
if (value.signum() < 0) {
|
||||
currency = currency.substring(1);
|
||||
sign = "-";
|
||||
}
|
||||
if (ess.getSettings().isCurrencySymbolSuffixed()) {
|
||||
return sign + tl("currency", currency, ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
return sign + tl("currency", ess.getSettings().getCurrencySymbol(), currency);
|
||||
}
|
||||
|
||||
public static String sanitizeCurrencyString(final String input, final IEssentials ess) {
|
||||
return input.replace(ess.getSettings().getCurrencySymbol(), "");
|
||||
}
|
||||
|
||||
public static boolean isInt(final String sInt) {
|
||||
try {
|
||||
Integer.parseInt(sInt);
|
||||
@@ -129,9 +60,6 @@ public final class NumberUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backport from Guava.
|
||||
*/
|
||||
public static int constrainToRange(int value, int min, int max) {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package net.ess3.api;
|
||||
|
||||
/**
|
||||
* Do not use this class.
|
||||
* This class proxies {@link com.earth2me.essentials.api.Economy}.
|
||||
* <p>
|
||||
* If you want to interact with EssentialsX's economy, we recommend using Vault or {@link com.earth2me.essentials.api.Economy}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class Economy extends com.earth2me.essentials.api.Economy {
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package net.ess3.api;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
/**
|
||||
* Thrown when a transaction would put the player's balance above the maximum balance allowed.
|
||||
*/
|
||||
public class MaxMoneyException extends Exception {
|
||||
public MaxMoneyException() {
|
||||
super(tl("maxMoney"));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package net.ess3.api;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
/**
|
||||
* @deprecated You should use {@link com.earth2me.essentials.api.NoLoanPermittedException} instead of this class.
|
||||
*/
|
||||
@Deprecated
|
||||
public class NoLoanPermittedException extends Exception {
|
||||
public NoLoanPermittedException() {
|
||||
super(tl("negativeBalanceError"));
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package net.ess3.api.events;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Fired when a user's balance updates.
|
||||
*/
|
||||
public class UserBalanceUpdateEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Player player;
|
||||
private final BigDecimal originalBalance;
|
||||
private final Cause cause;
|
||||
private BigDecimal balance;
|
||||
|
||||
@Deprecated
|
||||
public UserBalanceUpdateEvent(final Player player, final BigDecimal originalBalance, final BigDecimal balance) {
|
||||
this(player, originalBalance, balance, Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
public UserBalanceUpdateEvent(final Player player, final BigDecimal originalBalance, final BigDecimal balance, final Cause cause) {
|
||||
super(!Bukkit.getServer().isPrimaryThread());
|
||||
this.player = player;
|
||||
this.originalBalance = originalBalance;
|
||||
this.balance = balance;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public BigDecimal getNewBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the value that the user's balance will be changed to.
|
||||
*
|
||||
* @param newBalance The user's new balance
|
||||
*/
|
||||
public void setNewBalance(final BigDecimal newBalance) {
|
||||
Preconditions.checkNotNull(newBalance, "newBalance cannot be null.");
|
||||
this.balance = newBalance;
|
||||
}
|
||||
|
||||
public BigDecimal getOldBalance() {
|
||||
return originalBalance;
|
||||
}
|
||||
|
||||
public Cause getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* The cause of the balance update.
|
||||
*/
|
||||
public enum Cause {
|
||||
COMMAND_ECO,
|
||||
COMMAND_PAY,
|
||||
COMMAND_SELL,
|
||||
API,
|
||||
SPECIAL, // Reserved for API usage
|
||||
UNKNOWN
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.ess3.api.events;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -14,15 +13,13 @@ public class UserWarpEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final IUser user;
|
||||
private final Trade trade;
|
||||
private String warp;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public UserWarpEvent(final IUser user, final String warp, final Trade trade) {
|
||||
public UserWarpEvent(final IUser user, final String warp) {
|
||||
super(!Bukkit.getServer().isPrimaryThread());
|
||||
this.user = user;
|
||||
this.warp = warp;
|
||||
this.trade = trade;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
@@ -41,15 +38,6 @@ public class UserWarpEvent extends Event implements Cancellable {
|
||||
this.warp = warp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting payment handling information
|
||||
*
|
||||
* @return The payment handling class
|
||||
*/
|
||||
public Trade getTrade() {
|
||||
return trade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
package net.essentialsx.api.v2.services;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* A class which provides numerous methods to interact with Essentials' balance top calculations.
|
||||
* <p>
|
||||
* Note: Implementations of this class should be thread-safe and thus do not need to be called from the server thread.
|
||||
*/
|
||||
public interface BalanceTop {
|
||||
/**
|
||||
* Re-calculates the balance top cache asynchronously.
|
||||
* <p>
|
||||
* This method will return a {@link CompletableFuture CompletableFuture<Void>} which
|
||||
* will be completed upon the recalculation of the balance top map.
|
||||
* After which you should run {@link BalanceTop#getBalanceTopCache()}
|
||||
* to get the newly updated cache
|
||||
*
|
||||
* @return A future which completes after the balance top cache has been calculated.
|
||||
*/
|
||||
CompletableFuture<Void> calculateBalanceTopMapAsync();
|
||||
|
||||
/**
|
||||
* Gets the balance top cache or an empty list if one has not been calculated yet. The balance top cache is a {@link Map}
|
||||
* which maps the UUID of the player to a {@link BalanceTop.Entry} object which stores the user's display name and balance.
|
||||
* The returned map is sorted by greatest to least wealth.
|
||||
* <p>
|
||||
* There is no guarantee the returned cache is up to date. The balancetop command is directly responsible for updating
|
||||
* this cache and does so every two minutes (if executed). See {@link BalanceTop#calculateBalanceTopMapAsync()} to
|
||||
* manually update this cache yourself.
|
||||
*
|
||||
* @return The balance top cache.
|
||||
* @see BalanceTop#calculateBalanceTopMapAsync()
|
||||
*/
|
||||
Map<UUID, Entry> getBalanceTopCache();
|
||||
|
||||
/**
|
||||
* Gets the epoch time (in mills.) that the baltop cache was last updated at. A value of zero indicates the cache
|
||||
* has not been calculated yet at all.
|
||||
*
|
||||
* @return The epoch time (in mills.) since last cache update or zero.
|
||||
*/
|
||||
long getCacheAge();
|
||||
|
||||
/**
|
||||
* Gets the total amount of money in the economy at the point of the last balance top cache calculation or returns zero
|
||||
* if no baltop calculation has been made as of yet.
|
||||
*
|
||||
* @return The total amount of money in the economy or zero.
|
||||
* @see BalanceTop#getCacheAge() to find last baltop cache calculation
|
||||
*/
|
||||
BigDecimal getBalanceTopTotal();
|
||||
|
||||
/**
|
||||
* Checks to see if {@link BalanceTop#calculateBalanceTopMapAsync()} is still in the process of calculating the map.
|
||||
*
|
||||
* @return true if the balance top cache is still in the process of being calculated, otherwise false.
|
||||
*/
|
||||
boolean isCacheLocked();
|
||||
|
||||
/**
|
||||
* This class represents a user's name/balance in the balancetop cache.
|
||||
*/
|
||||
class Entry {
|
||||
private final UUID uuid;
|
||||
private final String displayName;
|
||||
private final BigDecimal balance;
|
||||
|
||||
public Entry(UUID uuid, String displayName, BigDecimal balance) {
|
||||
this.uuid = uuid;
|
||||
this.displayName = displayName;
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UUID of the user.
|
||||
* @return The uuid of this user.
|
||||
*/
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name of the user at the time of cache population.
|
||||
* @return The display name of this user.
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the balance of the user at the time of cache population.
|
||||
* @return The balance of this user.
|
||||
*/
|
||||
public BigDecimal getBalance() {
|
||||
return balance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,34 +171,22 @@ overridden-commands:
|
||||
# You should not have to disable commands used in other plugins, they will automatically get priority.
|
||||
# See https://bukkit.fandom.com/wiki/Commands.yml#aliases to map commands to other plugins.
|
||||
disabled-commands:
|
||||
- bal
|
||||
- balance
|
||||
- balancetop
|
||||
- baltop
|
||||
- buy
|
||||
- clear
|
||||
- ebal
|
||||
- ebalance
|
||||
- ebalancetop
|
||||
- ebaltop
|
||||
- emsg
|
||||
- epm
|
||||
- er
|
||||
- ereply
|
||||
- ewhisper
|
||||
- eco
|
||||
- give
|
||||
- kill
|
||||
- locate
|
||||
- m
|
||||
- message
|
||||
- money
|
||||
- msg
|
||||
- pay
|
||||
- pm
|
||||
- r
|
||||
- reply
|
||||
- sell
|
||||
- shop
|
||||
- t
|
||||
- tell
|
||||
@@ -278,9 +266,6 @@ player-commands:
|
||||
- afk.auto
|
||||
- back
|
||||
- back.ondeath
|
||||
- balance
|
||||
- balance.others
|
||||
- balancetop
|
||||
- build
|
||||
- chat.color
|
||||
- chat.format
|
||||
@@ -310,7 +295,6 @@ player-commands:
|
||||
- msg.color
|
||||
- nick
|
||||
- near
|
||||
- pay
|
||||
- ping
|
||||
- protect
|
||||
- r
|
||||
@@ -318,15 +302,10 @@ player-commands:
|
||||
- renamehome
|
||||
- realname
|
||||
- seen
|
||||
- sell
|
||||
- sethome
|
||||
- setxmpp
|
||||
- signs.create.protection
|
||||
- signs.create.trade
|
||||
- signs.break.protection
|
||||
- signs.break.trade
|
||||
- signs.use.balance
|
||||
- signs.use.buy
|
||||
- signs.use.disposal
|
||||
- signs.use.enchant
|
||||
- signs.use.free
|
||||
@@ -337,9 +316,7 @@ player-commands:
|
||||
- signs.use.mail
|
||||
- signs.use.protection
|
||||
- signs.use.repair
|
||||
- signs.use.sell
|
||||
- signs.use.time
|
||||
- signs.use.trade
|
||||
- signs.use.warp
|
||||
- signs.use.weather
|
||||
- spawn
|
||||
@@ -352,7 +329,6 @@ player-commands:
|
||||
- warp
|
||||
- warp.list
|
||||
- world
|
||||
- worth
|
||||
- xmpp
|
||||
|
||||
# Use this option to force superperms-based permissions handler regardless of detected installed perms plugin.
|
||||
@@ -391,10 +367,6 @@ use-nbt-serialization-in-createkit: true
|
||||
|
||||
enabledSigns:
|
||||
- color
|
||||
#- balance
|
||||
#- buy
|
||||
#- sell
|
||||
#- trade
|
||||
#- free
|
||||
#- warp
|
||||
#- kit
|
||||
@@ -689,17 +661,6 @@ command-cooldowns:
|
||||
# Whether command cooldowns should be persistent past server shutdowns
|
||||
command-cooldown-persistence: true
|
||||
|
||||
# Whether NPC balances should be listed in balance ranking features such as /balancetop.
|
||||
# NPC balances can include features like factions from FactionsUUID plugin.
|
||||
npcs-in-balance-ranking: false
|
||||
|
||||
# Allow bulk buying and selling signs when the player is sneaking.
|
||||
# This is useful when a sign sells or buys one item at a time and the player wants to sell a bunch at once.
|
||||
allow-bulk-buy-sell: true
|
||||
|
||||
# Allow selling of items with custom names with the /sell command.
|
||||
# This may be useful to prevent players accidentally selling named items.
|
||||
allow-selling-named-items: false
|
||||
|
||||
# Delay for the MOTD display for players on join, in milliseconds.
|
||||
# This has no effect if the MOTD command or permission are disabled.
|
||||
@@ -808,75 +769,6 @@ spawn-if-no-home: false
|
||||
# Should players be asked to provide confirmation for homes which they attempt to overwrite?
|
||||
confirm-home-overwrite: true
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Economy | #
|
||||
# +------------------------------------------------------+ #
|
||||
############################################################
|
||||
|
||||
# For more information, visit http://wiki.ess3.net/wiki/Essentials_Economy
|
||||
|
||||
# You can control the values of items that are sold to the server by using the /setworth command.
|
||||
|
||||
# Defines the balance with which new players begin. Defaults to 0.
|
||||
starting-balance: 0
|
||||
|
||||
# Defines the cost to use the given commands PER USE.
|
||||
# Some commands like /repair have sub-costs, check the wiki for more information.
|
||||
command-costs:
|
||||
# /example costs $1000 PER USE
|
||||
#example: 1000
|
||||
# /kit tools costs $1500 PER USE
|
||||
#kit-tools: 1500
|
||||
|
||||
# Set this to a currency symbol you want to use.
|
||||
# Remember, if you want to use special characters in this document,
|
||||
# such as accented letters, you MUST save the file as UTF-8, not ANSI.
|
||||
currency-symbol: 'Diamonds: '
|
||||
|
||||
# Enable this to make the currency symbol appear at the end of the amount rather than at the start.
|
||||
# For example, the euro symbol typically appears after the current amount.
|
||||
currency-symbol-suffix: false
|
||||
|
||||
# Set the maximum amount of money a player can have.
|
||||
# The amount is always limited to 10 trillion because of the limitations of a java double.
|
||||
max-money: 0
|
||||
|
||||
# Set the minimum amount of money a player can have (must be above the negative of max-money).
|
||||
# Setting this to 0, will disable overdrafts/loans completely. Users need 'essentials.eco.loan' perm to go below 0.
|
||||
min-money: 0
|
||||
|
||||
# Enable this to log all interactions with trade/buy/sell signs and sell command.
|
||||
economy-log-enabled: false
|
||||
|
||||
# Enable this to also log all transactions from other plugins through Vault.
|
||||
# This can cause the economy log to fill up quickly so should only be enabled for testing purposes!
|
||||
economy-log-update-enabled: false
|
||||
|
||||
# Minimum acceptable amount to be used in /pay.
|
||||
minimum-pay-amount: 0
|
||||
|
||||
# Enable this to block users who try to /pay another user which ignore them.
|
||||
pay-excludes-ignore-list: true
|
||||
|
||||
# Whether or not users with a balance less than or equal to $0 should be shown in balance-top.
|
||||
# Setting to false will not show people with balances <= 0 in balance-top.
|
||||
# NOTE: After reloading the config, you must also run '/baltop force' for this to appear
|
||||
show-zero-baltop: true
|
||||
|
||||
# The format of currency, excluding symbols. See currency-symbol-format-locale for symbol configuration.
|
||||
#
|
||||
# "#,##0.00" is how the majority of countries display currency.
|
||||
currency-format: "#,##0.00"
|
||||
|
||||
# Format currency symbols. Some locales use , and . interchangeably.
|
||||
# Some formats do not display properly in-game due to faulty Minecraft font rendering.
|
||||
#
|
||||
# For 1.234,50 use de-DE
|
||||
# For 1,234.50 use en-US
|
||||
# For 1'234,50 use fr-ch
|
||||
currency-symbol-format-locale: en-US
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Help | #
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
# Single quotes have to be doubled: ''
|
||||
# by:
|
||||
action=\u00a75* {0} \u00a75{1}
|
||||
addedToAccount=\u00a7a{0} has been added to your account.
|
||||
addedToOthersAccount=\u00a7a{0} added to {1}\u00a7a account. New balance\: {2}
|
||||
adventure=adventure
|
||||
afkCommandDescription=Marks you as away-from-keyboard.
|
||||
afkCommandUsage=/<command> [player/message...]
|
||||
@@ -47,20 +45,6 @@ backupFinished=\u00a76Backup finished.
|
||||
backupStarted=\u00a76Backup started.
|
||||
backupInProgress=\u00a76An external backup script is currently in progress! Halting plugin disable until finished.
|
||||
backUsageMsg=\u00a76Returning to previous location.
|
||||
balance=\u00a7aBalance\:\u00a7c {0}
|
||||
balanceCommandDescription=States the current balance of a player.
|
||||
balanceCommandUsage=/<command> [player]
|
||||
balanceCommandUsage1=/<command>
|
||||
balanceCommandUsage1Description=States your current balance
|
||||
balanceCommandUsage2=/<command> <player>
|
||||
balanceCommandUsage2Description=Displays the balance of the specified player
|
||||
balanceOther=\u00a7aBalance of {0}\u00a7a\:\u00a7c {1}
|
||||
balanceTop=\u00a76Top balances ({0})
|
||||
balanceTopLine={0}. {1}, {2}
|
||||
balancetopCommandDescription=Gets the top balance values.
|
||||
balancetopCommandUsage=/<command> [page]
|
||||
balancetopCommandUsage1=/<command> [page]
|
||||
balancetopCommandUsage1Description=Displays the first (or specified) page of the top balance values
|
||||
banCommandDescription=Bans a player.
|
||||
banCommandUsage=/<command> <player> [reason]
|
||||
banCommandUsage1=/<command> <player> [reason]
|
||||
@@ -161,16 +145,9 @@ consoleCannotUseCommand=This command cannot be used by Console.
|
||||
compassBearing=\u00a76Bearing\: {0} ({1} degrees).
|
||||
compassCommandDescription=Describes your current bearing.
|
||||
compassCommandUsage=/<command>
|
||||
condenseCommandDescription=Condenses items into a more compact blocks.
|
||||
condenseCommandUsage=/<command> [item]
|
||||
condenseCommandUsage1=/<command>
|
||||
condenseCommandUsage1Description=Condenses all items in your inventory
|
||||
condenseCommandUsage2=/<command> <item>
|
||||
condenseCommandUsage2Description=Condenses the specified item in your inventory
|
||||
configFileMoveError=Failed to move config.yml to backup location.
|
||||
configFileRenameError=Failed to rename temp file to config.yml.
|
||||
confirmClear=\u00a77To \u00a7lCONFIRM\u00a77 inventory clear, please repeat command: \u00a76{0}
|
||||
confirmPayment=\u00a77To \u00a7lCONFIRM\u00a77 payment of \u00a76{0}\u00a77, please repeat command: \u00a76{1}
|
||||
connectedPlayers=\u00a76Connected players\u00a7r
|
||||
connectionFailed=Failed to open connection.
|
||||
consoleName=Console
|
||||
@@ -189,7 +166,6 @@ createKitUnsupported=\u00a74NBT item serialization has been enabled, but this se
|
||||
creatingConfigFromTemplate=Creating config from template\: {0}
|
||||
creatingEmptyConfig=Creating empty config\: {0}
|
||||
creative=creative
|
||||
currency={0}{1}
|
||||
currentWorld=\u00a76Current World\:\u00a7c {0}
|
||||
customtextCommandDescription=Allows you to create custom text commands.
|
||||
customtextCommandUsage=/<alias> - Define in bukkit.yml
|
||||
@@ -313,16 +289,6 @@ dumpUrl=\u00a76Created server dump: \u00a7c{0}
|
||||
duplicatedUserdata=Duplicated userdata\: {0} and {1}.
|
||||
durability=\u00a76This tool has \u00a7c{0}\u00a76 uses left.
|
||||
east=E
|
||||
ecoCommandDescription=Manages the server economy.
|
||||
ecoCommandUsage=/<command> <give|take|set|reset> <player> <amount>
|
||||
ecoCommandUsage1=/<command> give <player> <amount>
|
||||
ecoCommandUsage1Description=Gives the specified player the specified amount of money
|
||||
ecoCommandUsage2=/<command> take <player> <amount>
|
||||
ecoCommandUsage2Description=Takes the specified amount of money from the specified player
|
||||
ecoCommandUsage3=/<command> set <player> <amount>
|
||||
ecoCommandUsage3Description=Sets the specified player's balance to the specified amount of money
|
||||
ecoCommandUsage4=/<command> reset <player> <amount>
|
||||
ecoCommandUsage4Description=Resets the specified player's balance to the server's starting balance
|
||||
editBookContents=\u00a7eYou may now edit the contents of this book.
|
||||
enabled=enabled
|
||||
enchantCommandDescription=Enchants the item the user is holding.
|
||||
@@ -541,9 +507,7 @@ infoCommandDescription=Shows information set by the server owner.
|
||||
infoCommandUsage=/<command> [chapter] [page]
|
||||
infoPages=\u00a7e ---- \u00a76{2} \u00a7e--\u00a76 Page \u00a7c{0}\u00a76/\u00a7c{1} \u00a7e----
|
||||
infoUnknownChapter=\u00a74Unknown chapter.
|
||||
insufficientFunds=\u00a74Insufficient funds available.
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
invalidCharge=\u00a74Invalid charge.
|
||||
invalidFireworkFormat=\u00a74The option \u00a7c{0} \u00a74is not a valid value for \u00a7c{1}\u00a74.
|
||||
invalidHome=\u00a74Home\u00a7c {0} \u00a74doesn''t exist\!
|
||||
invalidHomeName=\u00a74Invalid home name\!
|
||||
@@ -661,7 +625,6 @@ kitCommandUsage1Description=Lists all available kits
|
||||
kitCommandUsage2=/<command> <kit> [player]
|
||||
kitCommandUsage2Description=Gives the specified kit to you or another player if specified
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitCost=\ \u00a77\u00a7o({0})\u00a7r
|
||||
kitDelay=\u00a7m{0}\u00a7r
|
||||
kitError=\u00a74There are no valid kits.
|
||||
kitError2=\u00a74That kit is improperly defined. Contact an administrator.
|
||||
@@ -747,7 +710,6 @@ mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
|
||||
markMailAsRead=\u00a76To mark your mail as read, type\u00a7c /mail clear\u00a76.
|
||||
matchingIPAddress=\u00a76The following players previously logged in from that IP address\:
|
||||
maxHomes=\u00a74You cannot set more than\u00a7c {0} \u00a74homes.
|
||||
maxMoney=\u00a74This transaction would exceed the balance limit for this account.
|
||||
mayNotJail=\u00a74You may not jail that person\!
|
||||
mayNotJailOffline=\u00a74You may not jail offline players.
|
||||
meCommandDescription=Describes an action in the context of the player.
|
||||
@@ -756,7 +718,6 @@ meCommandUsage1=/<command> <description>
|
||||
meCommandUsage1Description=Describes an action
|
||||
meSender=me
|
||||
meRecipient=me
|
||||
minimumBalanceError=\u00a74The minimum balance a user can have is {0}.
|
||||
minimumPayAmount=\u00a7cThe minimum amount you can pay is {0}.
|
||||
minute=minute
|
||||
minutes=minutes
|
||||
@@ -766,8 +727,6 @@ mobsAvailable=\u00a76Mobs\:\u00a7r {0}
|
||||
mobSpawnError=\u00a74Error while changing mob spawner.
|
||||
mobSpawnLimit=Mob quantity limited to server limit.
|
||||
mobSpawnTarget=\u00a74Target block must be a mob spawner.
|
||||
moneyRecievedFrom=\u00a7a{0}\u00a76 has been received from\u00a7a {1}\u00a76.
|
||||
moneySentTo=\u00a7a{0} has been sent to {1}.
|
||||
month=month
|
||||
months=months
|
||||
moreCommandDescription=Fills the item stack in hand to specified amount, or to maximum size if none is specified.
|
||||
@@ -792,7 +751,6 @@ msgtoggleCommandDescription=Blocks receiving all private messages.
|
||||
msgtoggleCommandUsage=/<command> [player] [on|off]
|
||||
msgtoggleCommandUsage1=/<command> [player]
|
||||
msgtoggleCommandUsage1Description=Toggles fly for yourself or another player if specified
|
||||
multipleCharges=\u00a74You cannot apply more than one charge to this firework.
|
||||
multiplePotionEffects=\u00a74You cannot apply more than one effect to this potion.
|
||||
muteCommandDescription=Mutes or unmutes a player.
|
||||
muteCommandUsage=/<command> <player> [datediff] [reason]
|
||||
@@ -823,7 +781,6 @@ nearCommandUsage4=/<command> <player> <radius>
|
||||
nearCommandUsage4Description=Lists all players within the given radius of the specified player
|
||||
nearbyPlayers=\u00a76Players nearby\:\u00a7r {0}
|
||||
nearbyPlayersList={0}\u00a7f(\u00a7c{1}m\u00a7f)
|
||||
negativeBalanceError=\u00a74User is not allowed to have a negative balance.
|
||||
nickChanged=\u00a76Nickname changed.
|
||||
nickCommandDescription=Change your nickname or that of another player.
|
||||
nickCommandUsage=/<command> [player] <nickname|off>
|
||||
@@ -876,12 +833,10 @@ noPermToSpawnMob=\u00a74You don''t have permission to spawn this mob.
|
||||
noPlacePermission=\u00a74You do not have permission to place a block near that sign.
|
||||
noPotionEffectPerm=\u00a74You do not have permission to apply potion effect \u00a7c{0} \u00a74to this potion.
|
||||
noPowerTools=\u00a76You have no power tools assigned.
|
||||
notAcceptingPay=\u00a74{0} \u00a74is not accepting payment.
|
||||
notAllowedToLocal=\u00a74You don't have permission to speak in local chat.
|
||||
notAllowedToQuestion=\u00a74You don't have permission to use question.
|
||||
notAllowedToShout=\u00a74You don't have permission to shout.
|
||||
notEnoughExperience=\u00a74You do not have enough experience.
|
||||
notEnoughMoney=\u00a74You do not have sufficient funds.
|
||||
notFlying=not flying
|
||||
nothingInHand=\u00a74You have nothing in your hand.
|
||||
now=now
|
||||
@@ -897,28 +852,9 @@ onlyPlayers=\u00a74Only in-game players can use \u00a7c{0}\u00a74.
|
||||
onlyPlayerSkulls=\u00a74You can only set the owner of player skulls (\u00a7c397\:3\u00a74).
|
||||
onlySunStorm=\u00a74/weather only supports sun/storm.
|
||||
openingDisposal=\u00a76Opening disposal menu...
|
||||
orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait...
|
||||
oversizedMute=§4You may not mute a player for this period of time.
|
||||
oversizedTempban=\u00a74You may not ban a player for this period of time.
|
||||
passengerTeleportFail=\u00a74You cannot be teleported while carrying passengers.
|
||||
payCommandDescription=Pays another player from your balance.
|
||||
payCommandUsage=/<command> <player> <amount>
|
||||
payCommandUsage1=/<command> <player> <amount>
|
||||
payCommandUsage1Description=Pays the specified player the given amount of money
|
||||
payConfirmToggleOff=\u00a76You will no longer be prompted to confirm payments.
|
||||
payConfirmToggleOn=\u00a76You will now be prompted to confirm payments.
|
||||
payDisabledFor=\u00a76Disabled accepting payments for \u00a7c{0}\u00a76.
|
||||
payEnabledFor=\u00a76Enabled accepting payments for \u00a7c{0}\u00a76.
|
||||
payMustBePositive=\u00a74Amount to pay must be positive.
|
||||
payOffline=\u00a74You cannot pay offline users.
|
||||
payToggleOff=\u00a76You are no longer accepting payments.
|
||||
payToggleOn=\u00a76You are now accepting payments.
|
||||
payconfirmtoggleCommandDescription=Toggles whether you are prompted to confirm payments.
|
||||
payconfirmtoggleCommandUsage=/<command>
|
||||
paytoggleCommandDescription=Toggles whether you are accepting payments.
|
||||
paytoggleCommandUsage=/<command> [player]
|
||||
paytoggleCommandUsage1=/<command> [player]
|
||||
paytoggleCommandUsage1Description=Toggles if you, or another player if specified, are accepting payments
|
||||
pendingTeleportCancelled=\u00a74Pending teleportation request cancelled.
|
||||
pingCommandDescription=Pong!
|
||||
pingCommandUsage=/<command>
|
||||
@@ -1086,8 +1022,6 @@ requestSent=\u00a76Request sent to\u00a7c {0}\u00a76.
|
||||
requestSentAlready=\u00a74You have already sent {0}\u00a74 a teleport request.
|
||||
requestTimedOut=\u00a74Teleport request has timed out.
|
||||
requestTimedOutFrom=\u00a74Teleport request from \u00a7c{0} \u00a74has timed out.
|
||||
resetBal=\u00a76Balance has been reset to \u00a7c{0} \u00a76for all online players.
|
||||
resetBalAll=\u00a76Balance has been reset to \u00a7c{0} \u00a76for all players.
|
||||
rest=\u00a76You feel well rested.
|
||||
restCommandDescription=Rests you or the given player.
|
||||
restCommandUsage=/<command> [player]
|
||||
@@ -1109,18 +1043,6 @@ seenCommandUsage1=/<command> <playername>
|
||||
seenCommandUsage1Description=Shows the logout time, ban, mute, and UUID information of the specified player
|
||||
seenOffline=\u00a76Player\u00a7c {0} \u00a76has been \u00a74offline\u00a76 since \u00a7c{1}\u00a76.
|
||||
seenOnline=\u00a76Player\u00a7c {0} \u00a76has been \u00a7aonline\u00a76 since \u00a7c{1}\u00a76.
|
||||
sellBulkPermission=\u00a76You do not have permission to bulk sell.
|
||||
sellCommandDescription=Sells the item currently in your hand.
|
||||
sellCommandUsage=/<command> <<itemname>|<id>|hand|inventory|blocks> [amount]
|
||||
sellCommandUsage1=/<command> <itemname> [amount]
|
||||
sellCommandUsage1Description=Sells all (or the given amount, if specified) of the given item in your inventory
|
||||
sellCommandUsage2=/<command> hand [amount]
|
||||
sellCommandUsage2Description=Sells all (or the given amount, if specified) of the held item
|
||||
sellCommandUsage3=/<command> all
|
||||
sellCommandUsage3Description=Sells all possible items in your inventory
|
||||
sellCommandUsage4=/<command> blocks [amount]
|
||||
sellCommandUsage4Description=Sells all (or the given amount, if specified) of blocks in your inventory
|
||||
sellHandPermission=\u00a76You do not have permission to hand sell.
|
||||
serverFull=Server is full\!
|
||||
serverReloading=There's a good chance you're reloading your server right now. If that's the case, why do you hate yourself? Expect no support from the EssentialsX team when using /reload.
|
||||
serverTotal=\u00a76Server Total\:\u00a7c {0}
|
||||
@@ -1131,8 +1053,6 @@ serverUnsupportedDangerous=You are running a server fork that is known to be ext
|
||||
serverUnsupportedLimitedApi=You are running a server with limited API functionality. EssentialsX will still work, but certain features may be disabled.
|
||||
serverUnsupportedDumbPlugins=You are using plugins known to cause severe issues with EssentialsX and other plugins.
|
||||
serverUnsupportedMods=You are running a server that does not properly support Bukkit plugins. Bukkit plugins should not be used with Forge/Fabric mods! For Forge: Consider using ForgeEssentials, or SpongeForge + Nucleus.
|
||||
setBal=\u00a7aYour balance was set to {0}.
|
||||
setBalOthers=\u00a7aYou set {0}\u00a7a''s balance to {1}.
|
||||
setSpawner=\u00a76Changed spawner type to\u00a7c {0}\u00a76.
|
||||
sethomeCommandDescription=Set your home to your current location.
|
||||
sethomeCommandUsage=/<command> [[player:]name]
|
||||
@@ -1158,12 +1078,6 @@ setwarpCommandDescription=Creates a new warp.
|
||||
setwarpCommandUsage=/<command> <warp>
|
||||
setwarpCommandUsage1=/<command> <warp>
|
||||
setwarpCommandUsage1Description=Sets the warp with the specified name to your location
|
||||
setworthCommandDescription=Set the sell value of an item.
|
||||
setworthCommandUsage=/<command> [itemname|id] <price>
|
||||
setworthCommandUsage1=/<command> <price>
|
||||
setworthCommandUsage1Description=Sets the worth of your held item to the given price
|
||||
setworthCommandUsage2=/<command> <itemname> <price>
|
||||
setworthCommandUsage2Description=Sets the worth of the specified item to the given price
|
||||
sheepMalformedColor=\u00a74Malformed color.
|
||||
shoutDisabled=\u00a76Shout mode \u00a7cdisabled\u00a76.
|
||||
shoutDisabledFor=\u00a76Shout mode \u00a7cdisabled \u00a76for \u00a7c{0}\u00a76.
|
||||
@@ -1256,8 +1170,6 @@ suicideCommandUsage=/<command>
|
||||
suicideMessage=\u00a76Goodbye cruel world...
|
||||
suicideSuccess=\u00a76Player \u00a7c{0} \u00a76took their own life.
|
||||
survival=survival
|
||||
takenFromAccount=\u00a7e{0}\u00a7a has been taken from your account.
|
||||
takenFromOthersAccount=\u00a7e{0}\u00a7a taken from\u00a7e {1}\u00a7a account. New balance\:\u00a7e {2}
|
||||
teleportAAll=\u00a76Teleport request sent to all players...
|
||||
teleportAll=\u00a76Teleporting all players...
|
||||
teleportationCommencing=\u00a76Teleportation commencing...
|
||||
@@ -1411,8 +1323,6 @@ tptoggleCommandDescription=Blocks all forms of teleportation.
|
||||
tptoggleCommandUsage=/<command> [player] [on|off]
|
||||
tptoggleCommandUsage1=/<command> [player]
|
||||
tptoggleCommandUsageDescription=Toggles if teleports are enabled for yourself or another player if specified
|
||||
tradeSignEmpty=\u00a74The trade sign has nothing available for you.
|
||||
tradeSignEmptyOwner=\u00a74There is nothing to collect from this trade sign.
|
||||
treeCommandDescription=Spawn a tree where you are looking.
|
||||
treeCommandUsage=/<command> <tree|birch|redwood|redmushroom|brownmushroom|jungle|junglebush|swamp>
|
||||
treeCommandUsage1=/<command> <tree|birch|redwood|redmushroom|brownmushroom|jungle|junglebush|swamp>
|
||||
@@ -1494,12 +1404,11 @@ versionDevLatest=\u00a76You''re running the latest EssentialsX dev build!
|
||||
versionError=\u00a74Error while fetching EssentialsX version information! Build information: \u00a7c{0}\u00a76.
|
||||
versionErrorPlayer=\u00a76Error while checking EssentialsX version information!
|
||||
versionFetching=\u00a76Fetching version information...
|
||||
versionOutputVaultMissing=\u00a74Vault is not installed. Chat and permissions may not work.
|
||||
versionOutputLuckPermsMissing=\u00a74LuckPerms is not installed. Chat prefixes/suffixes and group features will not work.
|
||||
versionOutputFine=\u00a76{0} version: \u00a7a{1}
|
||||
versionOutputWarn=\u00a76{0} version: \u00a7c{1}
|
||||
versionOutputUnsupported=\u00a7d{0} \u00a76version: \u00a7d{1}
|
||||
versionOutputUnsupportedPlugins=\u00a76You are running \u00a7dunsupported plugins\u00a76!
|
||||
versionOutputEconLayer=\u00a76Economy Layer: \u00a7r{0}
|
||||
versionMismatch=\u00a74Version mismatch\! Please update {0} to the same version.
|
||||
versionMismatchAll=\u00a74Version mismatch\! Please update all Essentials jars to the same version.
|
||||
versionReleaseLatest=\u00a76You''re running the latest stable version of EssentialsX!
|
||||
@@ -1561,7 +1470,6 @@ whoisHunger=\u00a76 - Hunger\:\u00a7r {0}/20 (+{1} saturation)
|
||||
whoisIPAddress=\u00a76 - IP Address\:\u00a7r {0}
|
||||
whoisJail=\u00a76 - Jail\:\u00a7r {0}
|
||||
whoisLocation=\u00a76 - Location\:\u00a7r ({0}, {1}, {2}, {3})
|
||||
whoisMoney=\u00a76 - Money\:\u00a7r {0}
|
||||
whoisMuted=\u00a76 - Muted\:\u00a7r {0}
|
||||
whoisMutedReason=\u00a76 - Muted\:\u00a7r {0} \u00a76Reason\: \u00a7c{1}
|
||||
whoisNick=\u00a76 - Nick\:\u00a7r {0}
|
||||
@@ -1579,19 +1487,6 @@ worldCommandUsage1=/<command>
|
||||
worldCommandUsage1Description=Teleports to your corresponding location in the nether or overworld
|
||||
worldCommandUsage2=/<command> <world>
|
||||
worldCommandUsage2Description=Teleports to your location in the given world
|
||||
worth=\u00a7aStack of {0} worth \u00a7c{1}\u00a7a ({2} item(s) at {3} each)
|
||||
worthCommandDescription=Calculates the worth of items in hand or as specified.
|
||||
worthCommandUsage=/<command> <<itemname>|<id>|hand|inventory|blocks> [-][amount]
|
||||
worthCommandUsage1=/<command> <itemname> [amount]
|
||||
worthCommandUsage1Description=Checks the worth of all (or the given amount, if specified) of the given item in your inventory
|
||||
worthCommandUsage2=/<command> hand [amount]
|
||||
worthCommandUsage2Description=Checks the worth of all (or the given amount, if specified) of the held item
|
||||
worthCommandUsage3=/<command> all
|
||||
worthCommandUsage3Description=Checks the worth of all possible items in your inventory
|
||||
worthCommandUsage4=/<command> blocks [amount]
|
||||
worthCommandUsage4Description=Checks the worth of all (or the given amount, if specified) of blocks in your inventory
|
||||
worthMeta=\u00a7aStack of {0} with metadata of {1} worth \u00a7c{2}\u00a7a ({3} item(s) at {4} each)
|
||||
worthSet=\u00a76Worth value set
|
||||
year=year
|
||||
years=years
|
||||
youAreHealed=\u00a76You have been healed.
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
# Single quotes have to be doubled: ''
|
||||
# by:
|
||||
action=§5* {0} §5{1}
|
||||
addedToAccount=§a{0} бяха добавени към вашият акаунт.
|
||||
addedToOthersAccount=§a{0} бяха добавени към акаунта на {1}. Нов баланс\: {2}
|
||||
adventure=приключенски
|
||||
afkCommandDescription=Маркира ви като далеч-от-клавиятурата.
|
||||
afkCommandUsage=/<command> [player/message...]
|
||||
@@ -47,20 +45,6 @@ backupFinished=§6Архивирането е завършено.
|
||||
backupStarted=§6Създаване на архив.
|
||||
backupInProgress=§6В момента се изпълнява външен скрипт за резервно копие\! Спиране на плъгина до приключване.
|
||||
backUsageMsg=§6Връщане до предишната локация.
|
||||
balance=§aБаланс\:§c {0}
|
||||
balanceCommandDescription=Показва текущия баланс на играч.
|
||||
balanceCommandUsage=/<command> [player]
|
||||
balanceCommandUsage1=/<command>
|
||||
balanceCommandUsage1Description=Показва вашия текущ баланс
|
||||
balanceCommandUsage2=/<command> <player>
|
||||
balanceCommandUsage2Description=Показва баланса на специфичен играч
|
||||
balanceOther=§aБалансът на {0}§a\:§c {1}
|
||||
balanceTop=§6Топ богаташи ({0})
|
||||
balanceTopLine={0}. {1}, {2}
|
||||
balancetopCommandDescription=Показва топ играчите по баланс.
|
||||
balancetopCommandUsage=/<command> [page]
|
||||
balancetopCommandUsage1=/<command> [page]
|
||||
balancetopCommandUsage1Description=Показва първата (или специфична) страница на играчите с най-висок баланс
|
||||
banCommandDescription=Ограничава играч.
|
||||
banCommandUsage=/<command> <player> [reason]
|
||||
banCommandUsage1=/<command> <player> [reason]
|
||||
@@ -161,15 +145,9 @@ consoleCannotUseCommand=Тази команда не може да бъде из
|
||||
compassBearing=§6Посока\: {0} ({1} градуса).
|
||||
compassCommandDescription=Описва текущото ви държание.
|
||||
compassCommandUsage=/<command>
|
||||
condenseCommandDescription=Кондензира предметите в по-компактни блокове.
|
||||
condenseCommandUsage=/<command> [item]
|
||||
condenseCommandUsage1=/<command>
|
||||
condenseCommandUsage1Description=Кондензира всички предмети от вашия инвентар
|
||||
condenseCommandUsage2Description=Кондензира специфицирания предмет от вашия инвентар
|
||||
configFileMoveError=Грешка при прехвърлянето на config.yml в архива.
|
||||
configFileRenameError=Грешка при преименуването на временния файл към config.yml.
|
||||
confirmClear=§7За да §lпотвърдите§7 изчистването на инвентара, повторете командата\: §6{0}
|
||||
confirmPayment=§7За да §lПОТВЪРДИТЕ§7 заплащането на §6{0}§7, моля повторете командата\: §6{1}
|
||||
connectedPlayers=§6Свързани играчи§r
|
||||
connectionFailed=Неуспешно отваряне на връзка.
|
||||
consoleName=Конзола
|
||||
@@ -188,7 +166,6 @@ createKitUnsupported=§4Предметна NBT сериализация е вк
|
||||
creatingConfigFromTemplate=Създаване на конфигурация от шаблон\: {0}
|
||||
creatingEmptyConfig=Създаване на празна конфигурация\: {0}
|
||||
creative=творчески
|
||||
currency={0}{1}
|
||||
currentWorld=§6Текущ свят\:§c {0}
|
||||
customtextCommandDescription=Позволява ви създаването на персонализирани текстови команди.
|
||||
customtextCommandUsage=/<alias> - Определете в bukkit.yml
|
||||
@@ -290,8 +267,6 @@ downloadingGeoIp=Изтегля се GeoIP база данни... това мо
|
||||
duplicatedUserdata=Дублирани данни на играчи\: {0} и {1}.
|
||||
durability=§6Този инструмент има §c{0}§6 оставащи използвания.
|
||||
east=И
|
||||
ecoCommandDescription=Управлява икономиката на сървъра.
|
||||
ecoCommandUsage=/<command> <give|take|set|reset> <player> <amount>
|
||||
editBookContents=§eСега можете да редактирате съдържанието на тази книга.
|
||||
enabled=включен
|
||||
enchantCommandDescription=Омагьосва предмета, който държите.
|
||||
@@ -458,9 +433,7 @@ infoCommandDescription=Показва информация зададена от
|
||||
infoCommandUsage=/<command> [chapter] [page]
|
||||
infoPages=§e ---- §6{2} §e--§6 Страница §c{0}§6/§c{1} §e----
|
||||
infoUnknownChapter=§4Непозната глава.
|
||||
insufficientFunds=§4Нямате достатъчно средства.
|
||||
invalidBanner=§4Невалиден синтаксис на банер.
|
||||
invalidCharge=§4Неправилен заряд.
|
||||
invalidFireworkFormat=§4Опцията §c{0} §4е не е валидна стойност за §c{1}§4.
|
||||
invalidHome=§4Дом с име§c {0} §4не съществува\!
|
||||
invalidHomeName=§4Няма дом с такова име\!
|
||||
@@ -535,7 +508,6 @@ killCommandUsage1=/<command> <player>
|
||||
killExempt=§4Не можете да убиете §c{0}§4.
|
||||
kitCommandUsage1=/<command>
|
||||
kitContains=§6Кит §c{0} §6съдържа\:
|
||||
kitCost=\ §7§o({0})§r
|
||||
kitDelay=§m{0}§r
|
||||
kitError=§4Няма китове.
|
||||
kitError2=§4Този кит е неправилно дефиниран. Свържете се с администратор.
|
||||
@@ -574,7 +546,6 @@ mailTooLong=§4Писмото е твърде дълго. Максимумът
|
||||
markMailAsRead=§6За да маркирате всички писма като прочетени, напишете§c /mail clear§6.
|
||||
matchingIPAddress=§6Следните играчи са влизали от този IP адрес\:
|
||||
maxHomes=§4Не можете да имате повече от§c {0} §4домове.
|
||||
maxMoney=§4Тази транзакция ще надвиши лимитът на сметката за този акаунт.
|
||||
mayNotJail=§4Не можете да затворите този играч\!
|
||||
mayNotJailOffline=§4Не може да затворите играчи извън линия.
|
||||
meCommandUsage1Description=Описва действие
|
||||
@@ -589,8 +560,6 @@ mobsAvailable=§6Същества\:§r {0}
|
||||
mobSpawnError=§4Грешка при сменянето на вида на размножителя.
|
||||
mobSpawnLimit=Броят на съществата беше намален до лимита на сървъра.
|
||||
mobSpawnTarget=§4Целта трябва да е размножител.
|
||||
moneyRecievedFrom=§a{0} беше получено от {1}.
|
||||
moneySentTo=§a{0} бяха пратени на {1}.
|
||||
month=месец
|
||||
months=месеца
|
||||
moreThanZero=§4Сумата трябва да е повече от 0.
|
||||
@@ -604,7 +573,6 @@ msgFormat=§6[§c{0}§6 -> §c{1}§6] §r{2}
|
||||
msgIgnore=§cСъобщенията за {0} §4са изключени.
|
||||
msgtoggleCommandUsage=/<command> [player] [on|off]
|
||||
msgtoggleCommandUsage1=/<command> [player]
|
||||
multipleCharges=§4Не можете да зареждате фойерверка с повече от един заряд.
|
||||
multiplePotionEffects=§4Не можете да приложете повече от един ефект на тази отвара.
|
||||
muteCommandUsage1=/<command> <player>
|
||||
mutedPlayer=§6Играчът§c {0} §6бе перманентно заглушен.
|
||||
@@ -623,7 +591,6 @@ nearCommandUsage1=/<command>
|
||||
nearCommandUsage2Description=Показва всички играчи с даденият радиус от вас
|
||||
nearCommandUsage3=/<command> <player>
|
||||
nearbyPlayers=§6Играчи наблизо\:§r {0}
|
||||
negativeBalanceError=§4Играчът няма право да има негативен баланс.
|
||||
nickChanged=§6Прякорът ви беше променен.
|
||||
nickDisplayName=§4Трябва да активирате change-displayname в Essentials конфигурацията.
|
||||
nickInUse=§4Това име вече се използва.
|
||||
@@ -663,9 +630,7 @@ noPermToSpawnMob=§4Нямате право да разпространите т
|
||||
noPlacePermission=§4Нямате права да поставяте блокчета около тази табела.
|
||||
noPotionEffectPerm=§4Нямате право да прилагате ефект §c{0} §4на тази отвара.
|
||||
noPowerTools=§6Нямате предмети със зададени команди.
|
||||
notAcceptingPay=§4{0} §4не приема плащания.
|
||||
notEnoughExperience=§4Нямате достатъчно опит.
|
||||
notEnoughMoney=§4Нямате достатъчно средства.
|
||||
notFlying=не лети
|
||||
nothingInHand=§4Нямате нищо в ръката си.
|
||||
now=сега
|
||||
@@ -678,18 +643,9 @@ onlyPlayers=§4Командата §c{0} §4може да се изпълни е
|
||||
onlyPlayerSkulls=§4Можете да задавате единствено собственика на главите (§c397\:3§4).
|
||||
onlySunStorm=§4/weather приема единствено sun/storm.
|
||||
openingDisposal=§6Отваряне на кошчето за боклук...
|
||||
orderBalances=§6Подреждане на баланските на§c {0} §6играчи, моля изчакайте...
|
||||
oversizedMute=§4Не може да заглушите играч за този период от време.
|
||||
oversizedTempban=§4Не може да ограничите играч за този период от време.
|
||||
passengerTeleportFail=§4Не може да бъдете телепортиран докато носите пасажери.
|
||||
payConfirmToggleOff=§6Вече няма да бъдете питани за потвърждение на плащания.
|
||||
payConfirmToggleOn=§6Вече ще бъдете питани за потвърждение на плащания.
|
||||
payMustBePositive=§4Сумата трябва да е положителна.
|
||||
payToggleOff=§6Вече ще отхвърляте всички плащания.
|
||||
payToggleOn=§6Вече няма да отхвърляте всички плащания.
|
||||
payconfirmtoggleCommandUsage=/<command>
|
||||
paytoggleCommandUsage=/<command> [player]
|
||||
paytoggleCommandUsage1=/<command> [player]
|
||||
pendingTeleportCancelled=§4Заявката за телепортиране беше отказана.
|
||||
pingCommandDescription=Понг\!
|
||||
pingCommandUsage=/<command>
|
||||
@@ -785,8 +741,6 @@ requestDeniedFrom=§c{0} §6отказва вашата заявка за тел
|
||||
requestSent=§6Изпратихте заявка на§c {0}§6.
|
||||
requestSentAlready=§4Вече сте пратили заявка за телепортиране на {0}§4.
|
||||
requestTimedOut=§4Заявката за телепортиране изтече.
|
||||
resetBal=§6Балансът бе рестартиран на §c{0} §6за всички активни играчи.
|
||||
resetBalAll=§6Балансът бе рестартиран на §c{0} §6за всички играчи.
|
||||
restCommandUsage=/<command> [player]
|
||||
restCommandUsage1=/<command> [player]
|
||||
returnPlayerToJailError=§4Възникна грешка при опит да върнете играча§c {0} §4в затвора\: §c{1}§4\!
|
||||
@@ -798,14 +752,10 @@ seconds=секунди
|
||||
seenAccounts=§6Играчът е също познат като\:§c {0}
|
||||
seenOffline=§6Играчът§c {0} §6е §4неактивен/на§6 от §c{1}§6.
|
||||
seenOnline=§6Играчът§c {0} §6е §4активен/на§6 от §c{1}§6.
|
||||
sellBulkPermission=§6Нямате право да продавате на куп.
|
||||
sellHandPermission=§6Нямате право да продавате предмета в ръката си.
|
||||
serverFull=Сървърът е пълен\!
|
||||
serverTotal=§6Общо играчи\:§c {0}
|
||||
serverUnsupported=Имате неподдържана версия на сървъра\!
|
||||
serverUnsupportedDangerous=Използвате сървърен форк, за който се знае, че е изключително опасен и може да доведе до загуба на данни. Препоръчително е да преминете към по-стабилен сървърен софтуер като Paper.
|
||||
setBal=§aВашият баланс беше зададен на {0}.
|
||||
setBalOthers=§aЗададохте баланса на {0}§a на {1}.
|
||||
setSpawner=§6Променихте вида на размножителя на§c {0}§6.
|
||||
sethomeCommandUsage1=/<command> <name>
|
||||
sethomeCommandUsage2=/<command> <player>\:<name>
|
||||
@@ -846,8 +796,6 @@ suicideCommandUsage=/<command>
|
||||
suicideMessage=§6Сбогом, жесток свят...
|
||||
suicideSuccess=§6Играчът §c{0} §6се самоуби.
|
||||
survival=оцеляване
|
||||
takenFromAccount=§a{0} бяха взети от сметката ви.
|
||||
takenFromOthersAccount=§a{0} взети от сметката на {1}§a. Нова наличност\: {2}
|
||||
teleportAAll=§6Беше изпратена покана за телепорт до всички играчи...
|
||||
teleportAll=§6Телепортиране на всички играчи...
|
||||
teleportationCommencing=§6Телепортирането започва...
|
||||
@@ -923,8 +871,6 @@ tprCommandUsage1=/<command>
|
||||
tps=§6Текущ TPS \= {0}
|
||||
tptoggleCommandUsage=/<command> [player] [on|off]
|
||||
tptoggleCommandUsage1=/<command> [player]
|
||||
tradeSignEmpty=§4Тази търговска табела няма нищо налично за вас.
|
||||
tradeSignEmptyOwner=§4Няма нищо за събиране от тази търговска табела.
|
||||
treeFailure=§4Провал при създаване на дърво. Опитайте върху пръст или трева.
|
||||
treeSpawned=§6Създадено е дърво.
|
||||
true=§aда§r
|
||||
@@ -972,7 +918,6 @@ vanishCommandDescription=Скрий себе си от другите играч
|
||||
vanishCommandUsage=/<command> [player] [on|off]
|
||||
vanishCommandUsage1=/<command> [player]
|
||||
vanished=§6Сега сте напълно невидим за нормалните играчи и скрит от командите в сървъра.
|
||||
versionOutputVaultMissing=§4Vault не е инсталиран. Чатът и правата може да не работят.
|
||||
versionOutputFine=§6{0} версия\: §a{1}
|
||||
versionOutputWarn=§6{0} версия\: §a{1}
|
||||
versionOutputUnsupported=§d{0} §6версия\: §d{1}
|
||||
@@ -1024,7 +969,6 @@ whoisHunger=§6 - Глад\:§r {0}/20 (+{1} наситеност)
|
||||
whoisIPAddress=§6 - IP Адрес\:§r {0}
|
||||
whoisJail=§6 - Затворен/а\:§r {0}
|
||||
whoisLocation=§6 - Локация\:§r ({0}, {1}, {2}, {3})
|
||||
whoisMoney=§6 - Пари\:§r {0}
|
||||
whoisMuted=§6 - Заглушен/а\:§r {0}
|
||||
whoisMutedReason=§6 - Заглушен/а\:§r {0} §6Причина\: §c{1}
|
||||
whoisNick=§6 - Прякор\:§r {0}
|
||||
@@ -1039,9 +983,6 @@ worldCommandDescription=Превключвате между светове.
|
||||
worldCommandUsage=/<command> [world]
|
||||
worldCommandUsage1=/<command>
|
||||
worldCommandUsage2Description=Телепортира на твойта локация в даден свят
|
||||
worth=§aСтак от {0} струва §c{1}§a ({2} предмет(а) по {3} всеки)
|
||||
worthMeta=§aСтак от {0} с метаданни на {1} струва §c{2}§a ({3} предмет(а) по {4} всеки)
|
||||
worthSet=§6Цената е зададена
|
||||
year=година
|
||||
years=години
|
||||
youAreHealed=§6Вие бяхте излекувани.
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#version: ${full.version}
|
||||
# Single quotes have to be doubled: ''
|
||||
# by:
|
||||
addedToAccount=§a{0} je dodano na vas racun.
|
||||
addedToOthersAccount=dodan §a {0} {1} §a račun. Novo ravnotežu\: {2}
|
||||
adventure=pustolovina
|
||||
afkCommandDescription=Označava da ste trenutno odsutni.
|
||||
afkCommandUsage=/<command> [Igrač/poruka...]
|
||||
@@ -25,9 +23,6 @@ backupDisabled=§7Jedna vanjska sigurnosna kopija nije konfigurirana.
|
||||
backupFinished=§7Backup je zavrsen.
|
||||
backupStarted=§7Backup je zapoceo.
|
||||
backUsageMsg=§7Vracanje na prethodnu lokaciju.
|
||||
balance=§aStanje na racunu\:§c {0}
|
||||
balanceOther=§aStanje na racunu od {0}§a\:§c {1}
|
||||
balanceTop=§6Top stanje na racunu ({0})
|
||||
banExempt=§4Nemozes banati tog igraca.
|
||||
banFormat=§cBanovani ste sa servera\!\!\nNe poksuavajte praviti nove acconte, inace nikada necete dobiti unban\nRazlog\:\n§r{0}
|
||||
bed=§oKrevet§r
|
||||
@@ -125,7 +120,6 @@ missingItems=§4Ti nemas §c{0}x {1}§4.
|
||||
mobSpawnError=&7Greska u promjenjivanju spawnera.
|
||||
mobSpawnLimit=&7Mob kolicina je ogranicena na ovom serveru.
|
||||
mobSpawnTarget=&7Moras gledati u spawner da ga pretvoris u drugi spawner.
|
||||
moneySentTo=§a{0} je poslano do {1}.
|
||||
moreThanZero=&7Quantities mora biti veci od 0.
|
||||
multiplePotionEffects=&7Nije moguce primjeniti vise efekta ovaj napitak.
|
||||
mutedPlayer=&7Igrac &3{0} &7muted.
|
||||
@@ -133,7 +127,6 @@ mutedPlayerFor=&7Igrac&3 {0} &7je mutovan za &3{1}&7.
|
||||
muteExempt=&7Nemozes mute ovog igraca.
|
||||
muteNotify=&3{0} &7je mutovao igraca &3{1}&7.
|
||||
nearbyPlayers=&7Igraci u blizini\: &3{0}
|
||||
negativeBalanceError=&7Igrac nesmije imati negativne novce.
|
||||
nickChanged=&7Ime je promjenjeno.
|
||||
nickDisplayName=&7Moras promjeniti displayname u Essentials config.
|
||||
nickInUse=&7Ovo ime vec postoji.
|
||||
@@ -144,7 +137,6 @@ nuke=&7Bombe ce poceti padat.
|
||||
onlyDayNight=/Time samo podržava dan/noć.
|
||||
onlyPlayers=§4Samo igrači u igri mogu koristiti §c{0}§4.
|
||||
onlyPlayerSkulls=Možeš postaviti samo igračevu lubanju (§c397\:3§4).
|
||||
orderBalances=&7Ucitavamo stanja novaca &3{0} &figraca, molimo pricekajte...
|
||||
oversizedTempban=&7Nemozes banovati igraca na to vrijeme.
|
||||
pendingTeleportCancelled=&7Ponistio si teleport zahtijev.
|
||||
playerBanIpAddress=&7Igrac &3{0} &7je banovao IP Adresu &3{1} &7za\: &3{2}&7.
|
||||
@@ -173,8 +165,6 @@ pWeatherPlayers=&7Ovi igraci imaju svoje vrijeme\: &r
|
||||
pWeatherReset=&7Igracevo vrijeme je vraceno na\: &3{0}
|
||||
pWeatherSet=&7Igracevo vrijeme je stavljeno na &3{0}&7 za\: &3{1}&7.
|
||||
serverTotal=&7Server ukupno\: &3{0}
|
||||
setBal=&7Tvoj novac je postavljen na &3{0}.
|
||||
setBalOthers=&7Stavio si &3{0} &7novce za &3{1}&7.
|
||||
setSpawner=§6Promijenjen spawner tip to§c {0}§6.
|
||||
signProtectInvalidLocation=§4Nemas dozvolu da postavis sign ovdje.
|
||||
similarWarpExist=§4Warp sa slicnim imenom vec postoji.
|
||||
@@ -219,9 +209,6 @@ whoisGeoLocation=&7Lokacija\: &3 {0}
|
||||
whoisHealth=&7 - Zdravlje\: &3 {0}/20
|
||||
whoisHunger=&7 - glad\: &3 {0}/20 (+{1} Zasicenje)
|
||||
whoisIPAddress=&7 - IP Adresa\: &3 {0}
|
||||
whoisMoney=&7 - Novac\: &3 {0}
|
||||
whoisMuted=&7 - Mutovan\:&3 {0}
|
||||
worth=§aStack {0} vrijednosti §c{1}§a ({2} stavke u {3} svaki)
|
||||
worthSet=§6Vrijednost je stavljena
|
||||
youAreHealed=§6Izlječen si.
|
||||
youHaveNewMail=§6Imaš§c {0} §6poruka\! Kucaj §c/mail read§6 da vidiš poštu.
|
||||
@@ -3,8 +3,6 @@
|
||||
# Single quotes have to be doubled: ''
|
||||
# by:
|
||||
action=§5* {0} §5{1}
|
||||
addedToAccount=§a{0} bylo připsáno na tvůj účet.
|
||||
addedToOthersAccount=§aNa účet hráče {1}§a bylo připsáno {0}. Nový zůstatek\: {2}
|
||||
adventure=dobrodružná hra
|
||||
afkCommandDescription=Označuje tě jako mimo počítač.
|
||||
afkCommandUsage=/<command> [hráč/zpráva...]
|
||||
@@ -47,20 +45,6 @@ backupFinished=§6Záloha dokončena.
|
||||
backupStarted=§6Začalo zálohování.
|
||||
backupInProgress=§6Probíhá externí zálohovací skript\! Dokud nedoběhne, tak je zastavení zásuvného modulu znemožněno.
|
||||
backUsageMsg=§6Návrat na předchozí polohu.
|
||||
balance=§aZůstatek\:§c {0}
|
||||
balanceCommandDescription=Zobrazí aktuální zůstatek hráče.
|
||||
balanceCommandUsage=/<command> [hráč]
|
||||
balanceCommandUsage1=/<command>
|
||||
balanceCommandUsage1Description=Aktuální zůstatek tvého účtu
|
||||
balanceCommandUsage2=/<command> <hráč>
|
||||
balanceCommandUsage2Description=Zobrazí zůstatek zadaného hráče
|
||||
balanceOther=§aZůstatek hráče {0}§a\:§c {1}
|
||||
balanceTop=§6Nejvyšší zůstatky ({0})
|
||||
balanceTopLine={0}. {1}, {2}
|
||||
balancetopCommandDescription=Vypíše žebříček nejvyšších zůstatků.
|
||||
balancetopCommandUsage=/<command> [strana]
|
||||
balancetopCommandUsage1=/<command> [strana]
|
||||
balancetopCommandUsage1Description=Zobrazí první (nebo zadanou) stránku seznamu nejvyšších zůstatků
|
||||
banCommandDescription=Zablokuje hráče.
|
||||
banCommandUsage=/<command> <hráč> [důvod]
|
||||
banCommandUsage1=/<command> <hráč> [důvod]
|
||||
@@ -161,16 +145,9 @@ consoleCannotUseCommand=Tento příkaz nelze použít na konzoli.
|
||||
compassBearing=§6Kurs\: {0} ({1} stupňů).
|
||||
compassCommandDescription=Zobrazuje tvůj aktuální azimut.
|
||||
compassCommandUsage=/<command>
|
||||
condenseCommandDescription=Zhustí předměty do kompaktnějších bloků.
|
||||
condenseCommandUsage=/<command> [předmět]
|
||||
condenseCommandUsage1=/<command>
|
||||
condenseCommandUsage1Description=Zhustí všechny předměty ve tvém inventáři
|
||||
condenseCommandUsage2=/<command> <předmět>
|
||||
condenseCommandUsage2Description=Zhustí zadaný předmět ve tvém inventáři
|
||||
configFileMoveError=Nepodařilo se přesunout config.yml do zálohy.
|
||||
configFileRenameError=Dočasný soubor se nepodařilo přejmenovat na config.yml.
|
||||
confirmClear=§7Smazání inventáře je třeba §lPOTVRDIT§7, opakuj příkaz\: §6{0}
|
||||
confirmPayment=§7Platbu je třeba §lPOTVRDIT§7 §6{0}§7, opakuj příkaz\: §6{1}
|
||||
connectedPlayers=§6Připojení hráči§r
|
||||
connectionFailed=Pokus o otevření připojení selhal.
|
||||
consoleName=Konzole
|
||||
@@ -189,7 +166,6 @@ createKitUnsupported=§4NBT serializace předmětů byla povolena, avšak tento
|
||||
creatingConfigFromTemplate=Vytváří se konfigurace podle šablony\: {0}
|
||||
creatingEmptyConfig=Vytváří se prázdná konfigurace\: {0}
|
||||
creative=tvořivá hra
|
||||
currency={0}{1}
|
||||
currentWorld=§6Součaný svět\:§c {0}
|
||||
customtextCommandDescription=Umožňuje vytvářet vlastní textové příkazy.
|
||||
customtextCommandUsage=/<alias> - definuj v souboru bukkit.yml
|
||||
@@ -313,16 +289,6 @@ dumpUrl=§6Vytvořen výpis serveru\: §c{0}
|
||||
duplicatedUserdata=Duplicitní uživatelská data\: {0} a {1}.
|
||||
durability=§6U tohoto nástroje zbývá ještě §c{0}§6 použití.
|
||||
east=V
|
||||
ecoCommandDescription=Spravuje ekonomiku serveru.
|
||||
ecoCommandUsage=/<command> <give|take|set|reset> <hráč> <částka>
|
||||
ecoCommandUsage1=/<command> give <hráč> <množství>
|
||||
ecoCommandUsage1Description=Dá zadanému hráči uvedený počet peněz
|
||||
ecoCommandUsage2=/<command> take <hráč> <množství>
|
||||
ecoCommandUsage2Description=Vezme zadanému hráči uvedený počet peněz
|
||||
ecoCommandUsage3=/<command> set <hráč> <množství>
|
||||
ecoCommandUsage3Description=Nastaví zadanému hráči uvedený počet peněz
|
||||
ecoCommandUsage4=/<command> reset <hráč> <množství>
|
||||
ecoCommandUsage4Description=Nastaví zadanému hráči zůstatek na počáteční částku
|
||||
editBookContents=§eNyní můžeš upravovat obsah této knihy.
|
||||
enabled=povoleno
|
||||
enchantCommandDescription=Očaruje předmět, který uživatel drží.
|
||||
@@ -540,9 +506,7 @@ infoCommandDescription=Zobrazí informace nastavené vlastníkem serveru.
|
||||
infoCommandUsage=/<command> [kapitola] [strana]
|
||||
infoPages=§e ---- §6{2} §e--§6 Strana §c{0}§6/§c{1} §e----
|
||||
infoUnknownChapter=§4Neznámá kapitola.
|
||||
insufficientFunds=§4Nedostatek prostředků.
|
||||
invalidBanner=§4Neplatná definice praporu.
|
||||
invalidCharge=§4Neplatný poplatek.
|
||||
invalidFireworkFormat=§4Možnost §c{0} §4není platná hodnota pro §c{1}§4.
|
||||
invalidHome=§4Domov§c {0} §4neexistuje\!
|
||||
invalidHomeName=§4Neplatný název domova\!
|
||||
@@ -659,7 +623,6 @@ kitCommandUsage1Description=Zobrazí veškeré dostupné sady
|
||||
kitCommandUsage2=/<command> <sada> [hráč]
|
||||
kitCommandUsage2Description=Dá uvedenou sadu tobě nebo jinému hráč, byl-li zadán
|
||||
kitContains=§6Sada §c{0} §6obsahuje\:
|
||||
kitCost=\ §7§o({0})§r
|
||||
kitDelay=§m{0}§r
|
||||
kitError=§4Neexistují žádné platné sady.
|
||||
kitError2=§4Tato sada není správně definována. Kontaktuj správce.
|
||||
@@ -739,7 +702,6 @@ mailTooLong=§4Zpráva je příliš dlouhá, může obsahovat nejvýše 1000 zna
|
||||
markMailAsRead=§6Příkazem§c /mail clear§6 označíš poštu jako přečtenou.
|
||||
matchingIPAddress=§6Z této IP adresy se v minulosti připojili následující hráči\:
|
||||
maxHomes=§4Nemůžeš si nastavit více než§c {0} §4domovů.
|
||||
maxMoney=§4Tato transakce by překročila limit tohoto účtu.
|
||||
mayNotJail=§4Tohoto hráče nemůžeš uvrhnout do vězení\!
|
||||
mayNotJailOffline=§Nemůžeš uvěznit hráče, který není ve hře.
|
||||
meCommandDescription=Umožňuje napsat o sobě ve třetí osobě.
|
||||
@@ -748,7 +710,6 @@ meCommandUsage1=/<command> <popis>
|
||||
meCommandUsage1Description=Popisuje akci
|
||||
meSender=já
|
||||
meRecipient=já
|
||||
minimumBalanceError=§4Nejnižší možný zůstatek uživatele je {0}.
|
||||
minimumPayAmount=§cNejméně můžeš zaplatit {0}.
|
||||
minute=minuta
|
||||
minutes=minut
|
||||
@@ -758,8 +719,6 @@ mobsAvailable=§6Stvoření\:§r {0}
|
||||
mobSpawnError=§4Chyba při změně líhně.
|
||||
mobSpawnLimit=Počet stvoření je omezen limitem serveru.
|
||||
mobSpawnTarget=§4Musíš se dívat na líheň.
|
||||
moneyRecievedFrom=§6Obdržel jsi §a{0}§6 od hráče§a {1}§6.
|
||||
moneySentTo=§a{0} bylo odesláno hráči {1}.
|
||||
month=měsíc
|
||||
months=měsíců
|
||||
moreCommandDescription=Vyplní stack v ruce na stanovené množství nebo na maximum, není-li množství uvedeno.
|
||||
@@ -784,7 +743,6 @@ msgtoggleCommandDescription=Blokuje příjem všech soukromých zpráv.
|
||||
msgtoggleCommandUsage=/<command> [hráč] [on|off]
|
||||
msgtoggleCommandUsage1=/<command> [hráč]
|
||||
msgtoggleCommandUsage1Description=Přepíná létání pro sebe nebo jiného hráče, je-li zadán
|
||||
multipleCharges=§4Na tento ohňostroj nemůžeš použít více než jeden náboj.
|
||||
multiplePotionEffects=§4Na tento lektvar nelze použít více než jeden efekt.
|
||||
muteCommandDescription=Umlčí hráče nebo mu povolí mluvit.
|
||||
muteCommandUsage=/<command> <hráč> [trvání] [důvod]
|
||||
@@ -815,7 +773,6 @@ nearCommandUsage4=/<command> <hráč> <poloměr>
|
||||
nearCommandUsage4Description=Vypíše všechny hráče nebo specifického hráče kolem tebe v daném poloměru
|
||||
nearbyPlayers=§6Hráči v okolí\:§r {0}
|
||||
nearbyPlayersList={0}§f(§c{1} m§f)
|
||||
negativeBalanceError=§4Hráč nemůže mít záporný zůstatek.
|
||||
nickChanged=§6Přezdívka změněna.
|
||||
nickCommandDescription=Změní tvou přezdívku nebo přezdívku jiného hráče.
|
||||
nickCommandUsage=/<command> [hráč] <přezdívka|off>
|
||||
@@ -867,12 +824,10 @@ noPermToSpawnMob=§4Nemáš oprávnění vyvolat toto stvoření.
|
||||
noPlacePermission=§4Nemáš oprávnění pokládat bloky poblíž této cedule.
|
||||
noPotionEffectPerm=§4Nemáš oprávnění používat u tohoto lektvaru účinek §c{0}§4.
|
||||
noPowerTools=§6Nemáš přiřazen žádný výkonný nástroj.
|
||||
notAcceptingPay=§4{0} §4nepřijímá platby.
|
||||
notAllowedToLocal=§4Nemáš oprávnění mluvit v místním chatu.
|
||||
notAllowedToQuestion=§4Nemáš oprávnění položit dotaz.
|
||||
notAllowedToShout=§4Nemáš oprávnění k hlučnému módu.
|
||||
notEnoughExperience=§4Nemáš dostatek zkušeností.
|
||||
notEnoughMoney=§4Nemáš dost prostředků.
|
||||
notFlying=nelétá
|
||||
nothingInHand=§4Nic nedržíš v ruce.
|
||||
now=nyní
|
||||
@@ -888,28 +843,9 @@ onlyPlayers=§4Pouze hráči ve hře mohou použít §c{0}§4.
|
||||
onlyPlayerSkulls=§4Vlastníka můžeš nastavit pouze hlavám hráčů (§c397\:3§4).
|
||||
onlySunStorm=§4/weather podporuje pouze sun/storm.
|
||||
openingDisposal=§6Otevírá se odpadkový koš...
|
||||
orderBalances=§6Seřazuji zůstatky§c {0} §6hráčů, chvilku strpení...
|
||||
oversizedMute=§4Nemůžeš umlčet hráče na tak dlouhou dobu.
|
||||
oversizedTempban=§4Nemůžeš potrestat hráče na tak dlouhou dobu.
|
||||
passengerTeleportFail=§4Nemůžeš být teleportován během přepravy cestujících.
|
||||
payCommandDescription=Převede peníze jinému hráči z tvého zůstatku.
|
||||
payCommandUsage=/<command> <hráč> [částka]
|
||||
payCommandUsage1=/<command> <hráč> [částka]
|
||||
payCommandUsage1Description=Zaplatí zadanému hráči uvedený počet peněz
|
||||
payConfirmToggleOff=§6Od této chvíle se nebude požadovat potvrzení platby.
|
||||
payConfirmToggleOn=§6Od této chvíle se bude požadovat potvrzení platby.
|
||||
payDisabledFor=§6Přijímání plateb bylo pro §c{0}§6 vypnuto.
|
||||
payEnabledFor=§6Přijímání plateb bylo pro §c{0}§6 zapnuto.
|
||||
payMustBePositive=§4Převáděná částka musí být kladná.
|
||||
payOffline=§4Nemůžeš platit hráčům, kteří nejsou ve hře.
|
||||
payToggleOff=§6Od této chvíle nepřijímáš platby.
|
||||
payToggleOn=§6Od této chvíle přijímáš platby.
|
||||
payconfirmtoggleCommandDescription=Přepíná, zda je třeba potvrzovat platby.
|
||||
payconfirmtoggleCommandUsage=/<command>
|
||||
paytoggleCommandDescription=Přepíná, zda přijímáš platby.
|
||||
paytoggleCommandUsage=/<command> [hráč]
|
||||
paytoggleCommandUsage1=/<command> [hráč]
|
||||
paytoggleCommandUsage1Description=Přepíná, zda ty nebo případný zadaný hráč, přijímáte platby
|
||||
pendingTeleportCancelled=§4Nevyřízená žádost o teleportování byla zrušena.
|
||||
pingCommandDescription=Pong\!
|
||||
pingCommandUsage=/<command>
|
||||
@@ -1077,8 +1013,6 @@ requestSent=§6Žádost odeslána hráči §c{0}§6.
|
||||
requestSentAlready=§4Žádost o teleportování byla hráči §c{0}§4 už poslána.
|
||||
requestTimedOut=§4Žádost o teleportování vypršela.
|
||||
requestTimedOutFrom=§4Žádost o teleportování od §c{0} §4vypršela.
|
||||
resetBal=§6Stav účtu všech připojených hráčů byl obnoven na §c{0}§6.
|
||||
resetBalAll=§6Stav účtu všech hráčů byl obnoven na §c{0}§6.
|
||||
rest=§6Cítíš se dobře odpočatý.
|
||||
restCommandDescription=Poskytne odpočinek tobě nebo zadanému hráči.
|
||||
restCommandUsage=/<command> [hráč]
|
||||
@@ -1100,18 +1034,6 @@ seenCommandUsage1=/<command> <hráč>
|
||||
seenCommandUsage1Description=Ukáže informace o času odpojení, banu, umlčení a UUID specifikovaného hráče
|
||||
seenOffline=§6Hráč §c{0} §6je §4odpojen§6 od §c{1}§6.
|
||||
seenOnline=§6Hráč §c{0} §6je §apřipojen§6 od §c{1}§6.
|
||||
sellBulkPermission=§6Nemáš oprávnění prodávat ve velkém.
|
||||
sellCommandDescription=Prodá předmět, který je právě v ruce.
|
||||
sellCommandUsage=/<příkaz> <<jméno předmětu>|<id>|hand|inventory|blocks> [množství]
|
||||
sellCommandUsage1=/<command> <jméno předmětu> [množství]
|
||||
sellCommandUsage1Description=Prodá všechny (nebo daný počet, pokud je specifikován) dané předměty z tvého inventáře
|
||||
sellCommandUsage2=/<command> hand [počet]
|
||||
sellCommandUsage2Description=Prodá všechny (nebo daný počet, pokud je specifikován) předměty, které máš v ruce
|
||||
sellCommandUsage3=/<příkaz> all
|
||||
sellCommandUsage3Description=Prodá úplně všechny předměty ve tvém inventáři
|
||||
sellCommandUsage4=/<command> blocks [počet]
|
||||
sellCommandUsage4Description=Prodá všechny (nebo daný počet, pokud je specifikován) bloky z tvého inventáře
|
||||
sellHandPermission=§6Nemáš oprávnění prodávat z ruky.
|
||||
serverFull=Server je plný\!
|
||||
serverReloading=Je zde značná pravděpodobnost, že právě opětovně načítáte server. Pokud je tomu tak, tak proč se nenávidíte? Při používání /reload neočekávejte od týmu EssentialsX žádnou podporu.
|
||||
serverTotal=§6Server celkem\:§c {0}
|
||||
@@ -1122,8 +1044,6 @@ serverUnsupportedDangerous=Máte verzi serveru, o níž je známo, že je velmi
|
||||
serverUnsupportedLimitedApi=Používáte server s omezenou funkčností API. EssentialsX bude stále fungovat, ale některé funkce mohou být zakázány.
|
||||
serverUnsupportedDumbPlugins=Používáš zásuvné moduly, o nichž je známo, že způsobují vážné problémy s EssentialsX a dalšími zásuvnými moduly.
|
||||
serverUnsupportedMods=Používáte server, který nepodporuje Bukkit pluginy. Bukkit pluginy by se neměly používat s Forge/Fabric módy\! Pro Forge módy zvažte použití ForgeEssentials nebo SpongeForge + Nucleus.
|
||||
setBal=§aStav tvého účtu byl nastaven na {0}.
|
||||
setBalOthers=§aNastavil jsi stav účtu hráče {0}§a na {1}.
|
||||
setSpawner=§6Typ líhně změněn na§c {0}§6.
|
||||
sethomeCommandDescription=Nastaví tvůj domov na aktuální polohu.
|
||||
sethomeCommandUsage=/<command> [[hráč\:]název]
|
||||
@@ -1149,12 +1069,6 @@ setwarpCommandDescription=Vytvoří nový warp.
|
||||
setwarpCommandUsage=/<command> <warp>
|
||||
setwarpCommandUsage1=/<command> <warp>
|
||||
setwarpCommandUsage1Description=Vytvoří warp s určitým jménem tam, kde stojíš
|
||||
setworthCommandDescription=Nastaví prodejní cenu předmětu.
|
||||
setworthCommandUsage=/<command> [předmět|id] <cena>
|
||||
setworthCommandUsage1=/<command> <cena>
|
||||
setworthCommandUsage1Description=Nastaví hodnotu předmětu, který máš v ruce na danou cenu
|
||||
setworthCommandUsage2=/<command> <jméno předmětu> <cena>
|
||||
setworthCommandUsage2Description=Nastaví hodnotu určitého předmětu na danou cenu
|
||||
sheepMalformedColor=§4Neplatná barva.
|
||||
shoutDisabled=§6Hlučný mód §cvypnut§6.
|
||||
shoutDisabledFor=§6Hlučný mód §cvypnut §6 pro hráče §c{0}§6.
|
||||
@@ -1244,8 +1158,6 @@ suicideCommandUsage=/<command>
|
||||
suicideMessage=§6Sbohem, krutý světe...
|
||||
suicideSuccess=§6Hráč §c{0} §6si vzal život.
|
||||
survival=hra o přežití
|
||||
takenFromAccount=§e{0}§a bylo strženo ze tvého účtu.
|
||||
takenFromOthersAccount=§aZ účtu hráče§e {1}§a bylo strženo §e{0}§a. Nový zůstatek\:§e {2}
|
||||
teleportAAll=§6Žádost o teleportování zaslána všem hráčům...
|
||||
teleportAll=§6Teleportují se všichni hráči...
|
||||
teleportationCommencing=§6Teleportování zahájeno...
|
||||
@@ -1399,8 +1311,6 @@ tptoggleCommandDescription=Blokuje všechny druhy teleportace.
|
||||
tptoggleCommandUsage=/<command> [hráč] [on|off]
|
||||
tptoggleCommandUsage1=/<command> [hráč]
|
||||
tptoggleCommandUsageDescription=Přepne, jestli jsou pro tebe, nebo pro jiného hráče, pokud je uveden, povoleny teleporty
|
||||
tradeSignEmpty=§4Tato obchodní cedule již nemá pro tebe nic dostupného.
|
||||
tradeSignEmptyOwner=§4Z této obchodní cedule už není co brát.
|
||||
treeCommandDescription=Vytvoří strom na místě, kam se díváš.
|
||||
treeCommandUsage=/<command> <tree|birch|redwood|redmushroom|brownmushroom|jungle|junglebush|swamp>
|
||||
treeCommandUsage1=/<command> <tree|birch|redwood|redmushroom|brownmushroom|jungle|junglebush|swamp>
|
||||
@@ -1481,12 +1391,10 @@ versionDevLatest=§6Používáš nejnovější vývojové sestavení EssentialsX
|
||||
versionError=§4Chyba při načítání informací o verzi EssentialsX\! Informace o sestavení\: §c{0}§6.
|
||||
versionErrorPlayer=§6Chyba při zjišťování informací o verzi EssentialsX\!
|
||||
versionFetching=§6Získávání informací o verzi…
|
||||
versionOutputVaultMissing=§4Vault není nainstalován. Chat a oprávnění nemusejí fungovat.
|
||||
versionOutputFine=§6{0} verze\: §a{1}
|
||||
versionOutputWarn=§6{0} verze\: §c{1}
|
||||
versionOutputUnsupported=§d{0} §6verze\: §d{1}
|
||||
versionOutputUnsupportedPlugins=§6Používáte §dnepodporované zásuvné moduly§6\!
|
||||
versionOutputEconLayer=§6Ekonomická vrstva\: §r{0}
|
||||
versionMismatch=§4Nesprávná verze\! Aktualizuj§r {0} §4na stejnou verzi.
|
||||
versionMismatchAll=§4Nesprávná verze\! Aktualizuj všechny soubory Essentials .jar na stejnou verzi.
|
||||
versionReleaseLatest=§6Používáš nejnovější stabilní verzi EssentialsX\!
|
||||
@@ -1548,7 +1456,6 @@ whoisHunger=§6 - Hlad\:§r {0}/20 (+{1} sytost)
|
||||
whoisIPAddress=§6 - IP adresa\:§r {0}
|
||||
whoisJail=§6 - Vězení\:§r {0}
|
||||
whoisLocation=§6 - Poloha\:§r ({0}, {1}, {2}, {3})
|
||||
whoisMoney=§6 - Peníze\:§r {0}
|
||||
whoisMuted=§6 - Umlčen\:§r {0}
|
||||
whoisMutedReason=§6 - Umlčen\:§r {0} §6Důvod\: §c{1}
|
||||
whoisNick=§6 - Přezdívka\:§r {0}
|
||||
@@ -1565,19 +1472,6 @@ worldCommandUsage1=/<command>
|
||||
worldCommandUsage1Description=Teleportuje tě na odpovídající umístění v netheru nebo v overworldu
|
||||
worldCommandUsage2=/<command> <svět>
|
||||
worldCommandUsage2Description=Teleportuje tě na umístění v daném světě
|
||||
worth=§aStack {0} ceny §c{1}§a ({2} kus(u) za {3} kus)
|
||||
worthCommandDescription=Vypočte hodnotu předmětů v ruce nebo předmětů zadaných.
|
||||
worthCommandUsage=/<command> <<název_předmětu>|<id>|hand|inventory|blocks> [-][počet]
|
||||
worthCommandUsage1=/<command> <jméno předmětu> [množství]
|
||||
worthCommandUsage1Description=Spočítá hodnotu všech (nebo daného množství, pokud je uvedeno) daných předmětů ve tvém inventáři
|
||||
worthCommandUsage2=/<command> hand [počet]
|
||||
worthCommandUsage2Description=Spočítá hodnotu všech (nebo daného množství, pokud je uvedeno) držených předmětů
|
||||
worthCommandUsage3=/<příkaz> all
|
||||
worthCommandUsage3Description=Spočítá hodnotu úplně všech předmětů ve tvém inventáři
|
||||
worthCommandUsage4=/<command> blocks [počet]
|
||||
worthCommandUsage4Description=Spočítá hodnotu všech (nebo daného množství, pokud je uvedeno) bloků ve tvém inventáři
|
||||
worthMeta=§aStack {0} s metadaty {1} ceny §c{2}§a ({3} kus(u) za {4} kus)
|
||||
worthSet=§6Cena nastavena
|
||||
year=rok
|
||||
years=roky
|
||||
youAreHealed=§6Byl jsi uzdraven.
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
# Single quotes have to be doubled: ''
|
||||
# by:
|
||||
action=§5* {0} §5{1}
|
||||
addedToAccount=§a{0} er blevet tilføjet til din konto.
|
||||
addedToOthersAccount=§a{0} tilføjet til {1}§a konto. Ny saldo\: {2}
|
||||
adventure=eventyr
|
||||
afkCommandDescription=Markerer dig som værende inaktiv.
|
||||
afkCommandUsage=/<command> [spiller/besked...]
|
||||
@@ -46,19 +44,6 @@ backupFinished=§6Backup afsluttet.
|
||||
backupStarted=§6Backup startet.
|
||||
backupInProgress=§6Et eksternt backup-script er i gang\! Stop plugin deaktiveret indtil færdig.
|
||||
backUsageMsg=§6Retunerer til tidligere lokation.
|
||||
balance=§aSaldo\:§c {0}
|
||||
balanceCommandDescription=Angiver den aktuelle balance for en spiller.
|
||||
balanceCommandUsage=/<command> [player]
|
||||
balanceCommandUsage1=/<command>
|
||||
balanceCommandUsage1Description=Viser din nuværende saldo
|
||||
balanceCommandUsage2Description=Viser den specificerede spillers saldo
|
||||
balanceOther=§aSaldo for {0}§a\:§c {1}
|
||||
balanceTop=§6Top saldi ({0})
|
||||
balanceTopLine={0}. {1}, {2}
|
||||
balancetopCommandDescription=Henter listen over top balanceværdier.
|
||||
balancetopCommandUsage=/<command> [page]
|
||||
balancetopCommandUsage1=/<command> [page]
|
||||
balancetopCommandUsage1Description=Viser den første (eller specificerede) side af de øverste saldoværdier
|
||||
banCommandDescription=Udelukker en spiller.
|
||||
banCommandUsage=/<command> <player> [reason]
|
||||
banCommandUsage1=/<command> <player> [reason]
|
||||
@@ -135,12 +120,9 @@ commandNotLoaded=§4Kommandoen {0} er indlæst forkert.
|
||||
compassBearing=§6Pejling\: {0} ({1} degrees).
|
||||
compassCommandDescription=Beskriver din nuværende retning.
|
||||
compassCommandUsage=/<command>
|
||||
condenseCommandDescription=Kondenserer genstande i en mere kompakt block.
|
||||
condenseCommandUsage1=/<command>
|
||||
configFileMoveError=Kunne ikke flytte config.yml til backup-lokation.
|
||||
configFileRenameError=Kunne ikke omdøbe midlertidig fil til config.yml.
|
||||
confirmClear=§7To §lCONFIRM§7 inventory clear, please repeat command\: §6{0}
|
||||
confirmPayment=§7To §lCONFIRM§7 payment of §6{0}§7, please repeat command\: §6{1}
|
||||
connectedPlayers=§6Tilsluttede spillere§r
|
||||
connectionFailed=Kunne ikke åbne forbindelse.
|
||||
consoleName=Konsol
|
||||
@@ -155,7 +137,6 @@ createKitSuccess=§6Created Kit\: §f{0}\n§6Delay\: §f{1}\n§6Link\: §f{2}\n
|
||||
creatingConfigFromTemplate=Opretter konfig fra skabelon\: {0}
|
||||
creatingEmptyConfig=Opretter tom konfig\: {0}
|
||||
creative=kreativ
|
||||
currency={0}{1}
|
||||
currentWorld=§6Nuværende Verden\:§c {0}
|
||||
customtextCommandDescription=Tillader dig at oprette brugerdefinerede tekstkommandoer.
|
||||
day=dag
|
||||
@@ -290,9 +271,7 @@ infoChapter=§6Vælg kapitel\:
|
||||
infoChapterPages=§e ---- §6{0} §e--§6 Side §c{1}§6 af §c{2} §e----
|
||||
infoPages=§e ---- §6{2} §e--§6 Side §c{0}§6/§c{1} §e----
|
||||
infoUnknownChapter=§4Ukendt kapitel.
|
||||
insufficientFunds=§4Ikke tilstrækkelige midler.
|
||||
invalidBanner=§4Invalid banner syntax.
|
||||
invalidCharge=§4Ugyldig ladning.
|
||||
invalidFireworkFormat=§4Muligheden §c{0} §4er ikke en gyldig værdi til §c{1}§4.
|
||||
invalidHome=§4Hjemmet§c {0} §4eksisterer ikke\!
|
||||
invalidHomeName=§4Ugyldigt navn til dit hjem.
|
||||
@@ -352,7 +331,6 @@ kill=§6Dræbte§c {0}§6.
|
||||
killExempt=§4Du kan ikke dræbe §c{0}§4.
|
||||
kitCommandUsage1=/<command>
|
||||
kitContains=§6Kit §c{0} §6contains\:
|
||||
kitCost=\ §7§o({0})§r
|
||||
kitDelay=§m{0}§r
|
||||
kitError=§4Der er ingen gyldige kits.
|
||||
kitError2=§4Det kit er ikke defineret korrekt. Kontakt en administrator.
|
||||
@@ -390,7 +368,6 @@ mailTooLong=§4Mailbeskeden er for lang. Prøv at holde den under 1000 tegn.
|
||||
markMailAsRead=§6For at markere alt post som læst, skriv§c /mail clear§6.
|
||||
matchingIPAddress=§6De følgende spillere er tidligere logget ind fra den IP adresse\:
|
||||
maxHomes=§4Du kan ikke lave mere end§c {0} §4hjem.
|
||||
maxMoney=§4Denne transaktion vil overstige saldoen af denne konto.
|
||||
mayNotJail=§4Du kan ikke sætte den person i fængsel\!
|
||||
mayNotJailOffline=§4Du kan ikke sætte offline spillere i fængsel.
|
||||
meSender=mig
|
||||
@@ -404,8 +381,6 @@ mobsAvailable=§6Mobs\:§r {0}
|
||||
mobSpawnError=§4Fejl under ændring af mob spawner.
|
||||
mobSpawnLimit=Mob mængde begrænset til serverens grænse.
|
||||
mobSpawnTarget=§4Målblokken skal være en mob spawner.
|
||||
moneyRecievedFrom=§a{0}§6 blev modtaget fra§a {1}§6.
|
||||
moneySentTo=§a{0} er blevet sendt til {1}.
|
||||
month=måned
|
||||
months=måneder
|
||||
moreThanZero=§4Mængder skal være større end 0.
|
||||
@@ -417,7 +392,6 @@ msgEnabledFor=§6Receiving messages §cenabled §6for §c{0}§6.
|
||||
msgFormat=§6[§c{0}§6 -> §c{1}§6] §r{2}
|
||||
msgIgnore=§c{0} §4has messages disabled.
|
||||
msgtoggleCommandUsage1=/<command> [player]
|
||||
multipleCharges=§4Du kan ikke tilføje mere end én ladning til dette fyrværkeri.
|
||||
multiplePotionEffects=§4Du kan ikke tilføje mere end én effekt til denne eliksir.
|
||||
mutedPlayer=§6Spilleren§c {0} §6 er gjort tavs.
|
||||
mutedPlayerFor=§6Spilleren§c {0} §6blev gjort tavs i§c {1}§6.
|
||||
@@ -432,7 +406,6 @@ muteNotifyForReason=§c{0} §6har dæmpet spiller §c{1}§6 for§c {2}§6. Grund
|
||||
muteNotifyReason=§c{0} §6har dæmpet spiller §c{1}§6. Grund\: §c{2}
|
||||
nearCommandUsage1=/<command>
|
||||
nearbyPlayers=§6Spillere i nærheden\:§r {0}
|
||||
negativeBalanceError=§4Brugeren er ikke tilladt at have en negativ saldo.
|
||||
nickChanged=§6Kaldenavn ændret.
|
||||
nickDisplayName=§4Du skal aktivere change-displayname i Essentials-konfiggen.
|
||||
nickInUse=§4Det navn bruges allerede.
|
||||
@@ -472,9 +445,7 @@ noPermToSpawnMob=§4Du har ikke tilladelse til at spawne det mob.
|
||||
noPlacePermission=§4Du har ikke tilladelse til at placere en blok i nærheden af det skilt.
|
||||
noPotionEffectPerm=§4Du har ikke tilladelse til at tilføje effekten §c{0} §4til denne eliksir.
|
||||
noPowerTools=§6Du har ingen magtværktøjer tildelt.
|
||||
notAcceptingPay=§4{0} §4is not accepting payment.
|
||||
notEnoughExperience=§4Du har ikke nok experience.
|
||||
notEnoughMoney=§4Du har ikke tilstrækkelige midler.
|
||||
notFlying=flyver ikke
|
||||
nothingInHand=§4Du har intet i din hånd.
|
||||
now=nu
|
||||
@@ -487,18 +458,9 @@ onlyPlayers=§4Kun spillere på serveren kan bruge §c{0}§4.
|
||||
onlyPlayerSkulls=§4Du kan kun indstille ejeren af spillerkranier (§c397\:3§4).
|
||||
onlySunStorm=§4/weather understøtter kun sun/storm.
|
||||
openingDisposal=§6Opening disposal menu...
|
||||
orderBalances=§6Tjekker saldi af§c {0} §6brugere. Vent venligst...
|
||||
oversizedMute=§4Du må ikke mute en spiller i dette tidsrum.
|
||||
oversizedTempban=§4Du kan ikke bandlyse den spiller i det tidsrum.
|
||||
passengerTeleportFail=§4Du kan ikke teleporteres mens du har passagerer.
|
||||
payConfirmToggleOff=§6You will no longer be prompted to confirm payments.
|
||||
payConfirmToggleOn=§6You will now be prompted to confirm payments.
|
||||
payMustBePositive=§4Amount to pay must be positive.
|
||||
payToggleOff=§6You are no longer accepting payments.
|
||||
payToggleOn=§6You are now accepting payments.
|
||||
payconfirmtoggleCommandUsage=/<command>
|
||||
paytoggleCommandUsage=/<command> [player]
|
||||
paytoggleCommandUsage1=/<command> [player]
|
||||
pendingTeleportCancelled=§4Afventende teleporteringsanmodning afvist.
|
||||
pingCommandDescription=Pong\!
|
||||
pingCommandUsage=/<command>
|
||||
@@ -589,8 +551,6 @@ requestDeniedFrom=§c{0} §6afviste din teleporteringsanmodning.
|
||||
requestSent=§6Anmodning sendt til§c {0}§6.
|
||||
requestSentAlready=§4You have already sent {0}§4 a teleport request.
|
||||
requestTimedOut=§4Teleporteringsanmoding udløb.
|
||||
resetBal=§6Saldo er blevet nulstillet til §c{0} §6for alle online spillere.
|
||||
resetBalAll=§6Saldo er blevet nulstillet til §c{0} §6for alle spillere.
|
||||
restCommandUsage=/<command> [player]
|
||||
restCommandUsage1=/<command> [player]
|
||||
returnPlayerToJailError=§4Der opstod en fejl under forsøget på at returnere spilleren§c {0} §4til fængsel\: §c{1}§4\!
|
||||
@@ -600,13 +560,9 @@ seconds=sekunder
|
||||
seenAccounts=§6Spilleren er også kendt som\:§c {0}
|
||||
seenOffline=§6Spilleren§c {0} §6har været §4offline§6 siden §c{1}§6.
|
||||
seenOnline=§6Spilleren§c {0} §6har været §aonline§6 siden §c{1}§6.
|
||||
sellBulkPermission=§6You do not have permission to bulk sell.
|
||||
sellHandPermission=§6You do not have permission to hand sell.
|
||||
serverFull=Serveren er fyldt op\!
|
||||
serverTotal=§6Server Total\:§c {0}
|
||||
serverUnsupported=Du kører en ikke-understøttet serverversion\!
|
||||
setBal=§aDin saldo blev ændret til {0}.
|
||||
setBalOthers=§aDu ændrede {0}§a''s saldo til {1}.
|
||||
setSpawner=§6Ændrede spawner type til§c {0}§6.
|
||||
sheepMalformedColor=§4Forkert udformet farve.
|
||||
shoutFormat=§6[Råb]§r {0}
|
||||
@@ -638,8 +594,6 @@ suicideCommandUsage=/<command>
|
||||
suicideMessage=§6Farvel, grusomme verden...
|
||||
suicideSuccess=§6{0} §6tog sit eget liv.
|
||||
survival=overlevelse
|
||||
takenFromAccount=§e{0}§a er taget fra din konto.
|
||||
takenFromOthersAccount=§e{0}§a taget fra§e {1}§a konto. Ny saldo\:§e {2}
|
||||
teleportAAll=§6Teleporteringsanmodning sendt til alle spillere...
|
||||
teleportAll=§6Teleporterer alle spillere...
|
||||
teleportationCommencing=§6Teleportering begynder...
|
||||
@@ -696,8 +650,6 @@ tprCommandUsage=/<command>
|
||||
tprCommandUsage1=/<command>
|
||||
tps=§6Nuværende TPS \= {0}
|
||||
tptoggleCommandUsage1=/<command> [player]
|
||||
tradeSignEmpty=§4Handelsskiltet har ikke noget tilgængeligt til dig.
|
||||
tradeSignEmptyOwner=§4Der er ikke noget at hente fra dette handelsskilt.
|
||||
treeFailure=§4Fejl ved generering af træ. Prøv igen på græs eller jord.
|
||||
treeSpawned=§6Træ spawnet.
|
||||
true=§asandt§r
|
||||
@@ -739,7 +691,6 @@ usingTempFolderForTesting=Bruger temp mappe til testning\:
|
||||
vanish=§6Vanish for {0}§6\: {1}
|
||||
vanishCommandUsage1=/<command> [player]
|
||||
vanished=§6Du er nu helt usynlig over for normale spillere, og er skjult fra in-game kommandoer.
|
||||
versionOutputVaultMissing=§4Vault er ikke installeret. Chat og tilladelser virker måske ikke.
|
||||
versionOutputFine=§6{0} version\: §a{1}
|
||||
versionOutputWarn=§6{0} version\: §c{1}
|
||||
versionOutputUnsupported=§d{0} §6version\: §d{1}
|
||||
@@ -780,7 +731,6 @@ whoisHunger=§6 - Sult\:§r {0}/20 (+{1} mætning)
|
||||
whoisIPAddress=§6 - IP Adresse\:§r {0}
|
||||
whoisJail=§6 - Fængsel\:§r {0}
|
||||
whoisLocation=§6 - Lokation\:§r ({0}, {1}, {2}, {3})
|
||||
whoisMoney=§6 - Penge\:§r {0}
|
||||
whoisMuted=§6 - Gjort tavs\:§r {0}
|
||||
whoisMutedReason=§6 - Tavs\:§r {0} §6Grund\: §c{1}
|
||||
whoisNick=§6 - Nick\:§r {0}
|
||||
@@ -791,9 +741,6 @@ whoisTop=§6 \=\=\=\=\=\= WhoIs\:§c {0} §6\=\=\=\=\=\=
|
||||
whoisUuid=§6 - UUID\:§r {0}
|
||||
workbenchCommandUsage=/<command>
|
||||
worldCommandUsage1=/<command>
|
||||
worth=§aStak af {0} med en værdi af §c{1}§a ({2} ting á {3} hver)
|
||||
worthMeta=§aStak af {0} med metadata af {1} med en værdi af §c{2}§a ({3} element(er) á {4} hver)
|
||||
worthSet=§6Værdi ændret
|
||||
year=år
|
||||
years=år
|
||||
youAreHealed=§6Du er blevet helbredt.
|
||||
|
||||
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user