Changes EconomyHandler method names to be more consistent
This commit is contained in:
parent
d45af537cd
commit
e2c91c1feb
@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class StargateEntityPortalEvent extends StargateEvent {
|
public class StargateEntityPortalEvent extends StargateEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
Entity travellingEntity;
|
final Entity travellingEntity;
|
||||||
private final Portal destination;
|
private final Portal destination;
|
||||||
private Location exit;
|
private Location exit;
|
||||||
|
|
||||||
|
@ -102,9 +102,9 @@ public class VehicleEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Transfer payment if necessary
|
//Transfer payment if necessary
|
||||||
int cost = EconomyHandler.getUseCost(player, entrancePortal, destinationPortal);
|
int cost = EconomyHandler.getDefaultUseCost(player, entrancePortal, destinationPortal);
|
||||||
if (cost > 0) {
|
if (cost > 0) {
|
||||||
if (!EconomyHelper.payTeleportFee(entrancePortal, player, cost)) {
|
if (EconomyHelper.cannotPayTeleportFee(entrancePortal, player, cost)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public final class EconomyHandler {
|
|||||||
*
|
*
|
||||||
* @return <p>The gate use cost</p>
|
* @return <p>The gate use cost</p>
|
||||||
*/
|
*/
|
||||||
public static int getUseCost() {
|
public static int getDefaultUseCost() {
|
||||||
return useCost;
|
return useCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public final class EconomyHandler {
|
|||||||
*
|
*
|
||||||
* @param useCost <p>The gate use cost</p>
|
* @param useCost <p>The gate use cost</p>
|
||||||
*/
|
*/
|
||||||
public static void setUseCost(int useCost) {
|
public static void setDefaultUseCost(int useCost) {
|
||||||
if (useCost < 0) {
|
if (useCost < 0) {
|
||||||
throw new IllegalArgumentException("Using a gate cannot cost a negative amount");
|
throw new IllegalArgumentException("Using a gate cannot cost a negative amount");
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ public final class EconomyHandler {
|
|||||||
*
|
*
|
||||||
* @param createCost <p>The gate creation cost</p>
|
* @param createCost <p>The gate creation cost</p>
|
||||||
*/
|
*/
|
||||||
public static void setCreateCost(int createCost) {
|
public static void setDefaultCreateCost(int createCost) {
|
||||||
EconomyHandler.createCost = createCost;
|
EconomyHandler.createCost = createCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public final class EconomyHandler {
|
|||||||
*
|
*
|
||||||
* @param destroyCost <p>The gate destruction cost</p>
|
* @param destroyCost <p>The gate destruction cost</p>
|
||||||
*/
|
*/
|
||||||
public static void setDestroyCost(int destroyCost) {
|
public static void setDefaultDestroyCost(int destroyCost) {
|
||||||
EconomyHandler.destroyCost = destroyCost;
|
EconomyHandler.destroyCost = destroyCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public final class EconomyHandler {
|
|||||||
if (skipPayment(cost)) {
|
if (skipPayment(cost)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Charge player
|
//Charge player
|
||||||
return EconomyHandler.chargePlayer(player, cost);
|
return EconomyHandler.chargePlayer(player, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ public final class EconomyHandler {
|
|||||||
if (skipPayment(cost)) {
|
if (skipPayment(cost)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Charge player
|
//Charge player
|
||||||
return EconomyHandler.chargePlayer(player, target, cost);
|
return EconomyHandler.chargePlayer(player, target, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public final class EconomyHandler {
|
|||||||
if (!economyEnabled) {
|
if (!economyEnabled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check for Vault
|
//Check if vault is loaded
|
||||||
Plugin vault = pluginManager.getPlugin("Vault");
|
Plugin vault = pluginManager.getPlugin("Vault");
|
||||||
if (vault != null && vault.isEnabled()) {
|
if (vault != null && vault.isEnabled()) {
|
||||||
RegisteredServiceProvider<Economy> economyProvider = Stargate.server.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
RegisteredServiceProvider<Economy> economyProvider = Stargate.server.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
@ -188,7 +188,7 @@ public final class EconomyHandler {
|
|||||||
* @param destination <p>The destination portal</p>
|
* @param destination <p>The destination portal</p>
|
||||||
* @return <p>The cost of using the portal</p>
|
* @return <p>The cost of using the portal</p>
|
||||||
*/
|
*/
|
||||||
public static int getUseCost(Player player, Portal source, Portal destination) {
|
public static int getDefaultUseCost(Player player, Portal source, Portal destination) {
|
||||||
//No payment required
|
//No payment required
|
||||||
if (!EconomyHandler.useEconomy() || source.getOptions().isFree()) {
|
if (!EconomyHandler.useEconomy() || source.getOptions().isFree()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -19,9 +19,9 @@ public final class EconomyHelper {
|
|||||||
* @param entrancePortal <p>The portal the player is entering</p>
|
* @param entrancePortal <p>The portal the player is entering</p>
|
||||||
* @param player <p>The player wishing to teleport</p>
|
* @param player <p>The player wishing to teleport</p>
|
||||||
* @param cost <p>The cost of teleportation</p>
|
* @param cost <p>The cost of teleportation</p>
|
||||||
* @return <p>True if payment was successful</p>
|
* @return <p>False if payment was successful. True if the payment was unsuccessful</p>
|
||||||
*/
|
*/
|
||||||
public static boolean payTeleportFee(Portal entrancePortal, Player player, int cost) {
|
public static boolean cannotPayTeleportFee(Portal entrancePortal, Player player, int cost) {
|
||||||
boolean success;
|
boolean success;
|
||||||
|
|
||||||
//Try to charge the player
|
//Try to charge the player
|
||||||
@ -36,7 +36,7 @@ public final class EconomyHelper {
|
|||||||
if (!success) {
|
if (!success) {
|
||||||
sendInsufficientFundsMessage(entrancePortal.getName(), player, cost);
|
sendInsufficientFundsMessage(entrancePortal.getName(), player, cost);
|
||||||
entrancePortal.close(false);
|
entrancePortal.close(false);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send the deduct-message to the player
|
//Send the deduct-message to the player
|
||||||
@ -55,7 +55,7 @@ public final class EconomyHelper {
|
|||||||
sendObtainMessage(entrancePortal.getName(), gateOwner, cost);
|
sendObtainMessage(entrancePortal.getName(), gateOwner, cost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -405,9 +405,9 @@ public final class PermissionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Player cannot pay for teleportation
|
//Player cannot pay for teleportation
|
||||||
int cost = EconomyHandler.getUseCost(player, entrancePortal, destination);
|
int cost = EconomyHandler.getDefaultUseCost(player, entrancePortal, destination);
|
||||||
if (cost > 0) {
|
if (cost > 0) {
|
||||||
return !EconomyHelper.payTeleportFee(entrancePortal, player, cost);
|
return EconomyHelper.cannotPayTeleportFee(entrancePortal, player, cost);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user