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:
Steven Scott 2011-12-03 19:56:50 -08:00
parent d73f90c6e8
commit cd69ac7c8a
6 changed files with 114 additions and 17 deletions

5
README
View File

@ -197,6 +197,11 @@ createConflict=Gate conflicts with existing gate
============= =============
Changes 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] [Version 0.7.2.1]
- Quick fix for an NPE - Quick fix for an NPE
[Version 0.7.2] [Version 0.7.2]

View File

@ -19,7 +19,7 @@ destMemory: false
# Stargate economy options # Stargate economy options
# Whether to use an economy plugin (Uses Register to interact with all economy plugins) # Whether to use an economy plugin (Uses Register to interact with all economy plugins)
useiconomy: useiconomy: false
# The cost to create a gate # The cost to create a gate
createcost: 0 createcost: 0
# The cost to destroy a gate # The cost to destroy a gate

View File

@ -229,6 +229,18 @@ public class Gate {
if (id == ENTRANCE || id == EXIT) { if (id == ENTRANCE || id == EXIT) {
int type = topleft.modRelative(x, y, 0, modX, 1, modZ).getType(); int type = topleft.modRelative(x, y, 0, modX, 1, modZ).getType();
if (type != portalBlockClosed && type != portalBlockOpen) { 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); Stargate.debug("Gate::Matches", "Entrance/Exit Material Mismatch: " + type);
return false; return false;
} }

View File

@ -121,8 +121,11 @@ public class Stargate extends JavaPlugin {
// Check to see if iConomy/Permissions is loaded yet. // Check to see if iConomy/Permissions is loaded yet.
permissions = (Permissions)checkPlugin("Permissions"); permissions = (Permissions)checkPlugin("Permissions");
if (iConomyHandler.setupiConomy(pm)) { if (iConomyHandler.setupeConomy(pm)) {
log.info("[Stargate] Register v" + iConomyHandler.register.getDescription().getVersion() + " found"); 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); pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
@ -179,6 +182,11 @@ public class Stargate extends JavaPlugin {
} }
public void reloadGates() { public void reloadGates() {
// Close all gates prior to reloading
for (Portal p : openList) {
p.close(true);
}
Gate.loadGates(gateFolder); Gate.loadGates(gateFolder);
// Replace nethergate.gate if it doesn't have an exit point. // Replace nethergate.gate if it doesn't have an exit point.
if (Gate.getGateByName("nethergate.gate") == null || Gate.getGateByName("nethergate.gate").getExit() == null) { 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 { private class sListener extends ServerListener {
@Override @Override
public void onPluginEnable(PluginEnableEvent event) { 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"); 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 (permissions == null) {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) { if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) {
permissions = (Permissions)checkPlugin(event.getPlugin()); permissions = (Permissions)checkPlugin(event.getPlugin());
@ -1016,7 +1027,7 @@ public class Stargate extends JavaPlugin {
@Override @Override
public void onPluginDisable(PluginDisableEvent event) { public void onPluginDisable(PluginDisableEvent event) {
if (iConomyHandler.checkLost(event.getPlugin())) { if (iConomyHandler.checkLost(event.getPlugin())) {
log.info("[Stargate] Register plugin lost."); log.info("[Stargate] Register/Vault plugin lost.");
} }
if (event.getPlugin() == permissions) { if (event.getPlugin() == permissions) {
log.info("[Stargate] Permissions plugin lost."); log.info("[Stargate] Permissions plugin lost.");
@ -1061,6 +1072,14 @@ public class Stargate extends JavaPlugin {
if (cmd.equalsIgnoreCase("sg")) { if (cmd.equalsIgnoreCase("sg")) {
if (args.length != 1) return false; if (args.length != 1) return false;
if (args[0].equalsIgnoreCase("reload")) { 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 // Clear all lists
activeList.clear(); activeList.clear();
openList.clear(); openList.clear();

View File

@ -1,7 +1,11 @@
package net.TheDgtl.Stargate; package net.TheDgtl.Stargate;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
import com.nijikokun.register.Register; import com.nijikokun.register.Register;
import com.nijikokun.register.payment.Method; import com.nijikokun.register.payment.Method;
@ -17,6 +21,8 @@ public class iConomyHandler {
public static String pName = "Stargate"; public static String pName = "Stargate";
public static boolean useiConomy = false; public static boolean useiConomy = false;
public static Register register = null; public static Register register = null;
public static Vault vault = null;
public static Economy economy = null;
public static int useCost = 0; public static int useCost = 0;
public static int createCost = 0; public static int createCost = 0;
@ -26,7 +32,11 @@ public class iConomyHandler {
public static boolean freeGatesGreen = false; public static boolean freeGatesGreen = false;
public static double getBalance(String player) { 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(); Method method = Methods.getMethod();
if (method == null) { if (method == null) {
return 0; return 0;
@ -43,7 +53,20 @@ public class iConomyHandler {
} }
public static boolean chargePlayer(String player, String target, double amount) { 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 // Check for a payment method
Method method = Methods.getMethod(); Method method = Methods.getMethod();
if (method == null) { if (method == null) {
@ -73,25 +96,58 @@ public class iConomyHandler {
} }
public static boolean useiConomy() { 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) { public static String format(int amt) {
Method method = Methods.getMethod(); if (economy != null) {
if (method == null) { return economy.format(amt);
return Integer.toString(amt);
} }
return method.format(amt); if (register != null) {
Method method = Methods.getMethod();
if (method == null) {
return Integer.toString(amt);
}
return method.format(amt);
}
return "";
} }
public static boolean setupiConomy(PluginManager pm) { public static boolean setupeConomy(PluginManager pm) {
if (!useiConomy) return false; if (!useiConomy) return false;
Plugin p = pm.getPlugin("Register"); // Check for Vault
return setupiConomy(p); 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 setupiConomy(Plugin p) { public static boolean setupVault(Plugin p) {
if (!useiConomy) return false; 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 == null || !p.isEnabled()) return false;
if (!p.getDescription().getName().equals("Register")) return false; if (!p.getDescription().getName().equals("Register")) return false;
register = (Register)p; register = (Register)p;
@ -103,6 +159,11 @@ public class iConomyHandler {
register = null; register = null;
return true; return true;
} }
if (p.equals(vault)) {
economy = null;
vault = null;
return true;
}
return false; return false;
} }
} }

View File

@ -1,6 +1,6 @@
name: Stargate name: Stargate
main: net.TheDgtl.Stargate.Stargate main: net.TheDgtl.Stargate.Stargate
version: 0.7.2.1 version: 0.7.3
description: Stargate mod for Bukkit description: Stargate mod for Bukkit
author: Drakia author: Drakia
website: http://www.thedgtl.net website: http://www.thedgtl.net