Moves some config values from StarGate and into the StarGateConfig class
Renames EconomyHandler to EconomyConfig and puts it in the new config package Moves the LanguageLoader to the config package Fixes the explanation of chargeFreeDestination in the README
This commit is contained in:
@ -3,7 +3,6 @@ package net.knarcraft.stargate.portal;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.container.BlockLocation;
|
||||
import net.knarcraft.stargate.container.RelativeBlockVector;
|
||||
import net.knarcraft.stargate.utility.EconomyHandler;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
@ -122,7 +121,7 @@ public class Gate {
|
||||
* @return <p>The cost of using a portal with this gate</p>
|
||||
*/
|
||||
public int getUseCost() {
|
||||
return useCost < 0 ? EconomyHandler.getDefaultUseCost() : useCost;
|
||||
return useCost < 0 ? Stargate.getEconomyConfig().getDefaultUseCost() : useCost;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,7 +130,7 @@ public class Gate {
|
||||
* @return <p>The cost of creating a portal with this gate</p>
|
||||
*/
|
||||
public Integer getCreateCost() {
|
||||
return createCost < 0 ? EconomyHandler.getDefaultCreateCost() : createCost;
|
||||
return createCost < 0 ? Stargate.getEconomyConfig().getDefaultCreateCost() : createCost;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,7 +139,7 @@ public class Gate {
|
||||
* @return <p>The cost of destroying a portal with this gate</p>
|
||||
*/
|
||||
public Integer getDestroyCost() {
|
||||
return destroyCost < 0 ? EconomyHandler.getDefaultDestroyCost() : destroyCost;
|
||||
return destroyCost < 0 ? Stargate.getEconomyConfig().getDefaultDestroyCost() : destroyCost;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.knarcraft.stargate.portal;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.utility.EconomyHandler;
|
||||
import net.knarcraft.stargate.utility.GateReader;
|
||||
import net.knarcraft.stargate.utility.MaterialHelper;
|
||||
import org.bukkit.Material;
|
||||
@ -170,7 +169,7 @@ public class GateHandler {
|
||||
int createCost = GateReader.readGateConfig(config, fileName, "createcost");
|
||||
int destroyCost = GateReader.readGateConfig(config, fileName, "destroycost");
|
||||
boolean toOwner = (config.containsKey("toowner") ? Boolean.parseBoolean(config.get("toowner")) :
|
||||
EconomyHandler.toOwner);
|
||||
Stargate.getEconomyConfig().sendPaymentToOwner());
|
||||
|
||||
//Create the new gate
|
||||
Gate gate = new Gate(fileName, new GateLayout(layout), characterMaterialMap, portalOpenBlock, portalClosedBlock,
|
||||
|
@ -140,12 +140,13 @@ public class PortalActivator {
|
||||
destinations = PortalHandler.getDestinations(portal, player, network);
|
||||
|
||||
//Sort destinations if enabled
|
||||
if (Stargate.sortNetworkDestinations) {
|
||||
if (Stargate.getGateConfig().sortNetworkDestinations()) {
|
||||
Collections.sort(destinations);
|
||||
}
|
||||
|
||||
//Select last used destination if remember destination is enabled
|
||||
if (Stargate.rememberDestination && !lastDestination.isEmpty() && destinations.contains(lastDestination)) {
|
||||
if (Stargate.getGateConfig().rememberDestination() && !lastDestination.isEmpty() &&
|
||||
destinations.contains(lastDestination)) {
|
||||
destination = lastDestination;
|
||||
}
|
||||
|
||||
@ -254,7 +255,7 @@ public class PortalActivator {
|
||||
}
|
||||
|
||||
//Cycle if destination remembering is disabled, if the portal was already active, or it has no last destination
|
||||
if (!Stargate.rememberDestination || !activate || lastDestination.isEmpty()) {
|
||||
if (!Stargate.getGateConfig().rememberDestination() || !activate || lastDestination.isEmpty()) {
|
||||
cycleDestination(direction);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import net.knarcraft.stargate.container.BlockLocation;
|
||||
import net.knarcraft.stargate.container.RelativeBlockVector;
|
||||
import net.knarcraft.stargate.event.StargateCreateEvent;
|
||||
import net.knarcraft.stargate.utility.DirectionHelper;
|
||||
import net.knarcraft.stargate.utility.EconomyHandler;
|
||||
import net.knarcraft.stargate.utility.EconomyHelper;
|
||||
import net.knarcraft.stargate.utility.PermissionHelper;
|
||||
import net.knarcraft.stargate.utility.PortalFileHelper;
|
||||
@ -173,7 +172,7 @@ public class PortalCreator {
|
||||
String portalName = portal.getName();
|
||||
String destinationName = portal.getDestinationName();
|
||||
|
||||
int createCost = EconomyHandler.getCreateCost(player, gate);
|
||||
int createCost = Stargate.getEconomyConfig().getCreateCost(player, gate);
|
||||
|
||||
//Call StargateCreateEvent to let other plugins cancel or overwrite denial
|
||||
StargateCreateEvent stargateCreateEvent = new StargateCreateEvent(player, portal, lines, deny,
|
||||
@ -247,14 +246,15 @@ public class PortalCreator {
|
||||
|
||||
//Check if there are too many gates in this network
|
||||
List<String> networkList = PortalHandler.getAllPortalNetworks().get(portal.getNetwork().toLowerCase());
|
||||
if (Stargate.maxGatesEachNetwork > 0 && networkList != null && networkList.size() >= Stargate.maxGatesEachNetwork) {
|
||||
int maxGates = Stargate.getGateConfig().maxGatesEachNetwork();
|
||||
if (maxGates > 0 && networkList != null && networkList.size() >= maxGates) {
|
||||
Stargate.sendErrorMessage(player, Stargate.getString("createFull"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (cost > 0) {
|
||||
if (!EconomyHandler.chargePlayerIfNecessary(player, cost)) {
|
||||
if (!Stargate.getEconomyConfig().chargePlayerIfNecessary(player, cost)) {
|
||||
EconomyHelper.sendInsufficientFundsMessage(portalName, player, cost);
|
||||
Stargate.debug("createPortal", "Insufficient Funds");
|
||||
return false;
|
||||
|
@ -123,7 +123,7 @@ public class PortalHandler {
|
||||
if (!PermissionHelper.hasPermission(player, "stargate.admin.bungee")) {
|
||||
Stargate.sendErrorMessage(player, Stargate.getString("bungeeDeny"));
|
||||
return false;
|
||||
} else if (!Stargate.enableBungee) {
|
||||
} else if (!Stargate.getGateConfig().enableBungee()) {
|
||||
Stargate.sendErrorMessage(player, Stargate.getString("bungeeDisabled"));
|
||||
return false;
|
||||
} else if (destinationName.isEmpty() || network.isEmpty()) {
|
||||
@ -394,8 +394,9 @@ public class PortalHandler {
|
||||
|
||||
for (Portal portal : PortalRegistry.getAllPortals()) {
|
||||
//Open the gate if it's set as always open or if it's a bungee gate
|
||||
if (portal.getOptions().isFixed() && (Stargate.enableBungee && portal.getOptions().isBungee() ||
|
||||
portal.getPortalActivator().getDestination() != null && portal.getOptions().isAlwaysOn())) {
|
||||
if (portal.getOptions().isFixed() && (Stargate.getGateConfig().enableBungee() &&
|
||||
portal.getOptions().isBungee() || portal.getPortalActivator().getDestination() != null &&
|
||||
portal.getOptions().isAlwaysOn())) {
|
||||
portal.getPortalOpener().openPortal(true);
|
||||
alwaysOpenCount++;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.knarcraft.stargate.portal;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.utility.EconomyHandler;
|
||||
import net.knarcraft.stargate.utility.PermissionHelper;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
@ -50,8 +49,8 @@ public class PortalSignDrawer {
|
||||
for (int index = 0; index <= 3; index++) {
|
||||
sign.setLine(index, "");
|
||||
}
|
||||
Stargate.setLine(sign, 0, ChatColor.WHITE + "-" + Stargate.signColor + portal.getName() +
|
||||
ChatColor.WHITE + "-");
|
||||
Stargate.setLine(sign, 0, ChatColor.WHITE + "-" + Stargate.getGateConfig().getSignColor() +
|
||||
portal.getName() + ChatColor.WHITE + "-");
|
||||
|
||||
if (!portal.getPortalActivator().isActive()) {
|
||||
//Default sign text
|
||||
@ -82,7 +81,8 @@ public class PortalSignDrawer {
|
||||
int maxIndex = destinations.getDestinations().size() - 1;
|
||||
int signLineIndex = 0;
|
||||
int destinationIndex = destinations.getDestinations().indexOf(portal.getDestinationName());
|
||||
boolean freeGatesGreen = EconomyHandler.useEconomy() && EconomyHandler.freeGatesGreen;
|
||||
boolean freeGatesGreen = Stargate.getEconomyConfig().useEconomy() &&
|
||||
Stargate.getEconomyConfig().drawFreePortalsGreen();
|
||||
|
||||
//Last, and not only entry. Draw the entry two back
|
||||
if ((destinationIndex == maxIndex) && (maxIndex > 1)) {
|
||||
@ -118,8 +118,8 @@ public class PortalSignDrawer {
|
||||
Stargate.setLine(sign, signLineIndex, (green ? ChatColor.DARK_GREEN : "") + ">" +
|
||||
portal.getDestinationName() + (green ? ChatColor.DARK_GREEN : "") + "<");
|
||||
} else {
|
||||
Stargate.setLine(sign, signLineIndex, Stargate.signColor + " >" + portal.getDestinationName() +
|
||||
Stargate.signColor + "< ");
|
||||
Stargate.setLine(sign, signLineIndex, Stargate.getGateConfig().getSignColor() + " >" +
|
||||
portal.getDestinationName() + Stargate.getGateConfig().getSignColor() + "< ");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class PortalStructure {
|
||||
*/
|
||||
public boolean isVerified() {
|
||||
boolean verified = true;
|
||||
if (!Stargate.verifyPortals) {
|
||||
if (!Stargate.getGateConfig().verifyPortals()) {
|
||||
return true;
|
||||
}
|
||||
for (RelativeBlockVector control : gate.getLayout().getControls()) {
|
||||
@ -83,7 +83,7 @@ public class PortalStructure {
|
||||
* @return <p>True if this portal was verified</p>
|
||||
*/
|
||||
public boolean wasVerified() {
|
||||
if (!Stargate.verifyPortals) {
|
||||
if (!Stargate.getGateConfig().verifyPortals()) {
|
||||
return true;
|
||||
}
|
||||
return verified;
|
||||
@ -95,10 +95,11 @@ public class PortalStructure {
|
||||
* @return <p>True if all blocks match the gate template</p>
|
||||
*/
|
||||
public boolean checkIntegrity() {
|
||||
if (!Stargate.verifyPortals) {
|
||||
if (Stargate.getGateConfig().verifyPortals()) {
|
||||
return gate.matches(portal.getTopLeft(), portal.getYaw());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return gate.matches(portal.getTopLeft(), portal.getYaw());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user