Lava and water gates no longer destroy on reload
"sg reload" now closes gates before reloading Added Vault support Added missing "useiConomy" option in default config
This commit is contained in:
parent
d73f90c6e8
commit
cd69ac7c8a
5
README
5
README
@ -197,6 +197,11 @@ createConflict=Gate conflicts with existing gate
|
||||
=============
|
||||
Changes
|
||||
=============
|
||||
[Version 0.7.3]
|
||||
- Lava and water gates no longer destroy on reload
|
||||
- "sg reload" now closes gates before reloading
|
||||
- Added Vault support
|
||||
- Added missing "useiConomy" option in config
|
||||
[Version 0.7.2.1]
|
||||
- Quick fix for an NPE
|
||||
[Version 0.7.2]
|
||||
|
@ -19,7 +19,7 @@ destMemory: false
|
||||
# Stargate economy options
|
||||
|
||||
# Whether to use an economy plugin (Uses Register to interact with all economy plugins)
|
||||
useiconomy:
|
||||
useiconomy: false
|
||||
# The cost to create a gate
|
||||
createcost: 0
|
||||
# The cost to destroy a gate
|
||||
|
@ -229,6 +229,18 @@ public class Gate {
|
||||
if (id == ENTRANCE || id == EXIT) {
|
||||
int type = topleft.modRelative(x, y, 0, modX, 1, modZ).getType();
|
||||
if (type != portalBlockClosed && type != portalBlockOpen) {
|
||||
// Special case for water gates
|
||||
if (portalBlockOpen == Material.WATER.getId() || portalBlockOpen == Material.STATIONARY_WATER.getId()) {
|
||||
if (type == Material.WATER.getId() || type == Material.STATIONARY_WATER.getId()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Special case for lava gates
|
||||
if (portalBlockOpen == Material.LAVA.getId() || portalBlockOpen == Material.STATIONARY_LAVA.getId()) {
|
||||
if (type == Material.LAVA.getId() || type == Material.STATIONARY_LAVA.getId()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Stargate.debug("Gate::Matches", "Entrance/Exit Material Mismatch: " + type);
|
||||
return false;
|
||||
}
|
||||
|
@ -121,8 +121,11 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Check to see if iConomy/Permissions is loaded yet.
|
||||
permissions = (Permissions)checkPlugin("Permissions");
|
||||
if (iConomyHandler.setupiConomy(pm)) {
|
||||
if (iConomyHandler.setupeConomy(pm)) {
|
||||
if (iConomyHandler.register != null)
|
||||
log.info("[Stargate] Register v" + iConomyHandler.register.getDescription().getVersion() + " found");
|
||||
if (iConomyHandler.economy != null)
|
||||
log.info("[Stargate] Vault v" + iConomyHandler.vault.getDescription().getVersion() + " found");
|
||||
}
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||
@ -179,6 +182,11 @@ public class Stargate extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void reloadGates() {
|
||||
// Close all gates prior to reloading
|
||||
for (Portal p : openList) {
|
||||
p.close(true);
|
||||
}
|
||||
|
||||
Gate.loadGates(gateFolder);
|
||||
// Replace nethergate.gate if it doesn't have an exit point.
|
||||
if (Gate.getGateByName("nethergate.gate") == null || Gate.getGateByName("nethergate.gate").getExit() == null) {
|
||||
@ -1003,9 +1011,12 @@ public class Stargate extends JavaPlugin {
|
||||
private class sListener extends ServerListener {
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (iConomyHandler.setupiConomy(event.getPlugin())) {
|
||||
if (iConomyHandler.setupRegister(event.getPlugin())) {
|
||||
log.info("[Stargate] Register v" + iConomyHandler.register.getDescription().getVersion() + " found");
|
||||
}
|
||||
if (iConomyHandler.setupVault(event.getPlugin())) {
|
||||
log.info("[Stargate] Vault v" + iConomyHandler.vault.getDescription().getVersion() + " found");
|
||||
}
|
||||
if (permissions == null) {
|
||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) {
|
||||
permissions = (Permissions)checkPlugin(event.getPlugin());
|
||||
@ -1016,7 +1027,7 @@ public class Stargate extends JavaPlugin {
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (iConomyHandler.checkLost(event.getPlugin())) {
|
||||
log.info("[Stargate] Register plugin lost.");
|
||||
log.info("[Stargate] Register/Vault plugin lost.");
|
||||
}
|
||||
if (event.getPlugin() == permissions) {
|
||||
log.info("[Stargate] Permissions plugin lost.");
|
||||
@ -1061,6 +1072,14 @@ public class Stargate extends JavaPlugin {
|
||||
if (cmd.equalsIgnoreCase("sg")) {
|
||||
if (args.length != 1) return false;
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
// Deactivate portals
|
||||
for (Portal p : activeList) {
|
||||
p.deactivate();
|
||||
}
|
||||
// Close portals
|
||||
for (Portal p : openList) {
|
||||
p.close(true);
|
||||
}
|
||||
// Clear all lists
|
||||
activeList.clear();
|
||||
openList.clear();
|
||||
|
@ -1,7 +1,11 @@
|
||||
package net.TheDgtl.Stargate;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import com.nijikokun.register.Register;
|
||||
import com.nijikokun.register.payment.Method;
|
||||
@ -17,6 +21,8 @@ public class iConomyHandler {
|
||||
public static String pName = "Stargate";
|
||||
public static boolean useiConomy = false;
|
||||
public static Register register = null;
|
||||
public static Vault vault = null;
|
||||
public static Economy economy = null;
|
||||
|
||||
public static int useCost = 0;
|
||||
public static int createCost = 0;
|
||||
@ -26,7 +32,11 @@ public class iConomyHandler {
|
||||
public static boolean freeGatesGreen = false;
|
||||
|
||||
public static double getBalance(String player) {
|
||||
if (useiConomy && register != null) {
|
||||
if (!useiConomy) return 0;
|
||||
if (economy != null) {
|
||||
return economy.getBalance(player);
|
||||
}
|
||||
if (register != null) {
|
||||
Method method = Methods.getMethod();
|
||||
if (method == null) {
|
||||
return 0;
|
||||
@ -43,7 +53,20 @@ public class iConomyHandler {
|
||||
}
|
||||
|
||||
public static boolean chargePlayer(String player, String target, double amount) {
|
||||
if (useiConomy && register != null) {
|
||||
if (!useiConomy) return true;
|
||||
if (economy != null) {
|
||||
if (player.equals(target)) return true;
|
||||
|
||||
if (!economy.has(player, amount)) return false;
|
||||
economy.withdrawPlayer(player, amount);
|
||||
|
||||
if (target != null) {
|
||||
economy.depositPlayer(target, amount);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (register != null) {
|
||||
// Check for a payment method
|
||||
Method method = Methods.getMethod();
|
||||
if (method == null) {
|
||||
@ -73,25 +96,58 @@ public class iConomyHandler {
|
||||
}
|
||||
|
||||
public static boolean useiConomy() {
|
||||
return (useiConomy && register != null && Methods.getMethod() != null);
|
||||
if (!useiConomy) return false;
|
||||
if (economy != null) return true;
|
||||
if (register != null && Methods.getMethod() != null) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String format(int amt) {
|
||||
if (economy != null) {
|
||||
return economy.format(amt);
|
||||
}
|
||||
if (register != null) {
|
||||
Method method = Methods.getMethod();
|
||||
if (method == null) {
|
||||
return Integer.toString(amt);
|
||||
}
|
||||
return method.format(amt);
|
||||
}
|
||||
|
||||
public static boolean setupiConomy(PluginManager pm) {
|
||||
if (!useiConomy) return false;
|
||||
Plugin p = pm.getPlugin("Register");
|
||||
return setupiConomy(p);
|
||||
return "";
|
||||
}
|
||||
|
||||
public static boolean setupiConomy(Plugin p) {
|
||||
public static boolean setupeConomy(PluginManager pm) {
|
||||
if (!useiConomy) return false;
|
||||
// Check for Vault
|
||||
Plugin p = pm.getPlugin("Vault");
|
||||
if (p != null)
|
||||
return setupVault(p);
|
||||
// Check for Register
|
||||
p = pm.getPlugin("Register");
|
||||
if (p != null)
|
||||
return setupRegister(p);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean setupVault(Plugin p) {
|
||||
if (!useiConomy) return false;
|
||||
if (register != null) return false;
|
||||
if (p == null || !p.isEnabled()) return false;
|
||||
if (!p.getDescription().getName().equals("Vault")) return false;
|
||||
|
||||
RegisteredServiceProvider<Economy> economyProvider = Stargate.server.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
vault = (Vault)p;
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
|
||||
return (economy != null);
|
||||
}
|
||||
|
||||
public static boolean setupRegister(Plugin p) {
|
||||
if (!useiConomy) return false;
|
||||
if (vault != null) return false;
|
||||
if (p == null || !p.isEnabled()) return false;
|
||||
if (!p.getDescription().getName().equals("Register")) return false;
|
||||
register = (Register)p;
|
||||
@ -103,6 +159,11 @@ public class iConomyHandler {
|
||||
register = null;
|
||||
return true;
|
||||
}
|
||||
if (p.equals(vault)) {
|
||||
economy = null;
|
||||
vault = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: Stargate
|
||||
main: net.TheDgtl.Stargate.Stargate
|
||||
version: 0.7.2.1
|
||||
version: 0.7.3
|
||||
description: Stargate mod for Bukkit
|
||||
author: Drakia
|
||||
website: http://www.thedgtl.net
|
||||
|
Loading…
Reference in New Issue
Block a user