Fixed the Blox hashcode
Added 'F'ree option to gates Added vehicle handling code, including iConomy while in a vehicle Framework for changing where iConomy sends money
This commit is contained in:
parent
77ed32c7fa
commit
8bdbb4a613
7
README
7
README
@ -11,8 +11,6 @@ This version of Stargate is still heavily under development. There are going to
|
||||
=============
|
||||
Known Issues
|
||||
=============
|
||||
- Vehicle implementation is nowhere near done.
|
||||
- Signs aren't always updating, I don't know what's causing this, I think it's a Bukkit thing.
|
||||
- There are many bugs with portal material not showing properly. This is a bug I can not track down, and have no fix for at the moment.
|
||||
|
||||
=============
|
||||
@ -90,8 +88,13 @@ not-enough-money-message - The message displayed if a player lacks money to do s
|
||||
=============
|
||||
Changes
|
||||
=============
|
||||
[Version 0.3.3]
|
||||
- Moved sign update into a schedule event, should fix signs
|
||||
[Version 0.3.2]
|
||||
- Updated to latest RB
|
||||
- Implemented proper vehicle handling
|
||||
- Added iConomy to vehicle handling
|
||||
- Can now set cost to go to creator on use
|
||||
[Version 0.3.1]
|
||||
- Changed version numbering.
|
||||
- Changed how plugins are hooked into.
|
||||
|
@ -110,7 +110,7 @@ public class Blox {
|
||||
result = result * 27 + x;
|
||||
result = result * 27 + y;
|
||||
result = result * 27 + z;
|
||||
result = result * 27 + world.hashCode();
|
||||
result = result * 27 + world.getName().hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -397,6 +397,10 @@ public class Gate {
|
||||
return gates.get(name);
|
||||
}
|
||||
|
||||
public static int getGateCount() {
|
||||
return gates.size();
|
||||
}
|
||||
|
||||
static class StargateFilenameFilter implements FilenameFilter {
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".gate");
|
||||
|
@ -56,6 +56,7 @@ public class Portal {
|
||||
private boolean hidden = false;
|
||||
private boolean alwaysOn = false;
|
||||
private boolean priv = false;
|
||||
private boolean free = false;
|
||||
private World world;
|
||||
// Gate options
|
||||
private boolean verified;
|
||||
@ -71,7 +72,7 @@ public class Portal {
|
||||
float rotX, SignPost id, Blox button,
|
||||
String dest, String name,
|
||||
boolean verified, String network, Gate gate,
|
||||
String owner, boolean hidden, boolean alwaysOn, boolean priv) {
|
||||
String owner, boolean hidden, boolean alwaysOn, boolean priv, boolean free) {
|
||||
this.topLeft = topLeft;
|
||||
this.modX = modX;
|
||||
this.modZ = modZ;
|
||||
@ -88,6 +89,7 @@ public class Portal {
|
||||
this.hidden = hidden;
|
||||
this.alwaysOn = alwaysOn;
|
||||
this.priv = priv;
|
||||
this.free = free;
|
||||
this.world = topLeft.getWorld();
|
||||
|
||||
if (this.alwaysOn && !this.fixed) {
|
||||
@ -117,6 +119,10 @@ public class Portal {
|
||||
return priv;
|
||||
}
|
||||
|
||||
public boolean isFree() {
|
||||
return free;
|
||||
}
|
||||
|
||||
public boolean open(boolean force) {
|
||||
return open(null, force);
|
||||
}
|
||||
@ -554,6 +560,7 @@ public class Portal {
|
||||
boolean hidden = (options.indexOf('h') != -1 || options.indexOf('H') != -1);
|
||||
boolean alwaysOn = (options.indexOf('a') != -1 || options.indexOf('A') != -1);
|
||||
boolean priv = (options.indexOf('p') != -1 || options.indexOf('P') != -1);
|
||||
boolean free = (options.indexOf('f') != - 1|| options.indexOf('F') != -1);
|
||||
|
||||
// Check if the user can only create personal gates, set network if so
|
||||
if (Stargate.hasPerm(player, "stargate.create.personal", false) &&
|
||||
@ -631,7 +638,7 @@ public class Portal {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (iConomyHandler.useiConomy() && !iConomyHandler.chargePlayer(player.getName(), iConomyHandler.createCost)) {
|
||||
if (iConomyHandler.useiConomy() && !iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.createCost)) {
|
||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||
}
|
||||
@ -647,7 +654,7 @@ public class Portal {
|
||||
button.setType(Material.STONE_BUTTON.getId());
|
||||
button.setData(facing);
|
||||
}
|
||||
portal = new Portal(topleft, modX, modZ, rotX, id, button, destName, name, true, network, gate, player.getName(), hidden, alwaysOn, priv);
|
||||
portal = new Portal(topleft, modX, modZ, rotX, id, button, destName, name, true, network, gate, player.getName(), hidden, alwaysOn, priv, free);
|
||||
|
||||
// Open always on gate
|
||||
if (portal.isAlwaysOn()) {
|
||||
@ -728,6 +735,8 @@ public class Portal {
|
||||
builder.append(portal.isPrivate());
|
||||
builder.append(':');
|
||||
builder.append(portal.world.getName());
|
||||
builder.append(':');
|
||||
builder.append(portal.isFree());
|
||||
|
||||
bw.append(builder.toString());
|
||||
bw.newLine();
|
||||
@ -793,8 +802,9 @@ public class Portal {
|
||||
boolean hidden = (split.length > 11) ? split[11].equalsIgnoreCase("true") : false;
|
||||
boolean alwaysOn = (split.length > 12) ? split[12].equalsIgnoreCase("true") : false;
|
||||
boolean priv = (split.length > 13) ? split[13].equalsIgnoreCase("true") : false;
|
||||
boolean free = (split.length > 15) ? split[15].equalsIgnoreCase("true") : false;
|
||||
|
||||
Portal portal = new Portal(topLeft, modX, modZ, rotX, sign, button, dest, name, false, network, gate, owner, hidden, alwaysOn, priv);
|
||||
Portal portal = new Portal(topLeft, modX, modZ, rotX, sign, button, dest, name, false, network, gate, owner, hidden, alwaysOn, priv, free);
|
||||
portal.close(true);
|
||||
}
|
||||
scanner.close();
|
||||
|
@ -61,12 +61,17 @@ public class SignPost {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
Sign sign = findSign();
|
||||
final Sign sign = findSign();
|
||||
if (sign == null) {
|
||||
Stargate.log.info("[Stargate::SignPost::update] Sign null");
|
||||
return;
|
||||
}
|
||||
sign.update(true);
|
||||
|
||||
Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
|
||||
public void run() {
|
||||
sign.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void findParent() {
|
||||
|
@ -113,7 +113,7 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Check to see if iConomy/Permissions is loaded yet.
|
||||
permissions = (Permissions)checkPlugin("Permissions");
|
||||
iConomyHandler.iConomy = (iConomy)checkPlugin("iConomy");
|
||||
iConomyHandler.iconomy = (iConomy)checkPlugin("iConomy");
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||
|
||||
@ -185,7 +185,7 @@ public class Stargate extends JavaPlugin {
|
||||
if (Gate.getGateByName("nethergate.gate") == null || Gate.getGateByName("nethergate.gate").getExit() == null) {
|
||||
Gate.populateDefaults(gateFolder);
|
||||
}
|
||||
|
||||
log.info("[Stargate] Loaded " + Gate.getGateCount() + " gate layouts");
|
||||
for (World world : getServer().getWorlds()) {
|
||||
Portal.loadAllGates(world);
|
||||
}
|
||||
@ -232,7 +232,7 @@ public class Stargate extends JavaPlugin {
|
||||
Portal destination = gate.getDestination();
|
||||
|
||||
if (!gate.isOpen()) {
|
||||
if (iConomyHandler.useiConomy() && iConomyHandler.getBalance(player.getName()) < iConomyHandler.useCost) {
|
||||
if (!gate.isFree() && iConomyHandler.useiConomy() && iConomyHandler.getBalance(player.getName()) < iConomyHandler.useCost) {
|
||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||
} else if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
|
||||
gate.deactivate();
|
||||
@ -293,7 +293,8 @@ public class Stargate extends JavaPlugin {
|
||||
Vehicle vehicle = event.getVehicle();
|
||||
|
||||
Portal portal = Portal.getByEntrance(event.getTo());
|
||||
if (portal != null && portal.isOpen()) {
|
||||
if (portal == null || !portal.isOpen()) return;
|
||||
|
||||
if (passenger instanceof Player) {
|
||||
Player player = (Player)passenger;
|
||||
if (!portal.isOpenFor(player)) {
|
||||
@ -302,14 +303,21 @@ public class Stargate extends JavaPlugin {
|
||||
}
|
||||
Portal dest = portal.getDestination();
|
||||
if (dest == null) return;
|
||||
dest.teleport(vehicle, portal);
|
||||
|
||||
if (!teleMsg.isEmpty())
|
||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
||||
portal.close(false);
|
||||
} else {
|
||||
|
||||
if (portal.isFree() || !iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.useCost)) {
|
||||
if (!portal.isFree() && iConomyHandler.useiConomy()) {
|
||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.useCost));
|
||||
}
|
||||
if (!teleMsg.isEmpty()) {
|
||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
||||
}
|
||||
dest.teleport(vehicle, portal);
|
||||
} else {
|
||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||
}
|
||||
}
|
||||
portal.close(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -325,8 +333,8 @@ public class Stargate extends JavaPlugin {
|
||||
Portal destination = portal.getDestination();
|
||||
|
||||
if (destination != null) {
|
||||
if (!iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), iConomyHandler.useCost)) {
|
||||
if (iConomyHandler.useiConomy()) {
|
||||
if (portal.isFree() || !iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.useCost)) {
|
||||
if (!portal.isFree() && iConomyHandler.useiConomy()) {
|
||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.useCost));
|
||||
}
|
||||
if (!teleMsg.isEmpty()) {
|
||||
@ -465,7 +473,7 @@ public class Stargate extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
if (iConomyHandler.useiConomy()) {
|
||||
iConomyHandler.chargePlayer(player.getName(), iConomyHandler.destroyCost);
|
||||
iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.destroyCost);
|
||||
if (iConomyHandler.destroyCost > 0) {
|
||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.destroyCost));
|
||||
} else if (iConomyHandler.destroyCost < 0) {
|
||||
@ -533,9 +541,9 @@ public class Stargate extends JavaPlugin {
|
||||
private class sListener extends ServerListener {
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (iConomyHandler.iConomy == null) {
|
||||
if (iConomyHandler.iconomy == null) {
|
||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
|
||||
iConomyHandler.iConomy = (iConomy)checkPlugin(event.getPlugin());
|
||||
iConomyHandler.iconomy = (iConomy)checkPlugin(event.getPlugin());
|
||||
}
|
||||
}
|
||||
if (permissions == null) {
|
||||
@ -547,9 +555,9 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (event.getPlugin() == iConomyHandler.iConomy) {
|
||||
if (event.getPlugin() == iConomyHandler.iconomy) {
|
||||
log.info("[Stargate] iConomy plugin lost.");
|
||||
iConomyHandler.iConomy = null;
|
||||
iConomyHandler.iconomy = null;
|
||||
}
|
||||
if (event.getPlugin() == permissions) {
|
||||
log.info("[Stargate] Permissions plugin lost.");
|
||||
|
@ -5,7 +5,7 @@ import com.nijiko.coelho.iConomy.system.Account;
|
||||
|
||||
public class iConomyHandler {
|
||||
public static boolean useiConomy = false;
|
||||
public static iConomy iConomy = null;
|
||||
public static iConomy iconomy = null;
|
||||
|
||||
public static int useCost = 0;
|
||||
public static int createCost = 0;
|
||||
@ -13,8 +13,8 @@ public class iConomyHandler {
|
||||
public static String inFundMsg = "Insufficient Funds.";
|
||||
|
||||
public static double getBalance(String player) {
|
||||
if (useiConomy && iConomy != null) {
|
||||
Account acc = com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(player);
|
||||
if (useiConomy && iconomy != null) {
|
||||
Account acc = iConomy.getBank().getAccount(player);
|
||||
if (acc == null) {
|
||||
Stargate.log.info("[Stargate::ich::getBalance] Error fetching iConomy account for " + player);
|
||||
return 0;
|
||||
@ -24,9 +24,9 @@ public class iConomyHandler {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean chargePlayer(String player, double amount) {
|
||||
if (useiConomy && iConomy != null) {
|
||||
Account acc = com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(player);
|
||||
public static boolean chargePlayer(String player, String target, double amount) {
|
||||
if (useiConomy && iconomy != null) {
|
||||
Account acc = iConomy.getBank().getAccount(player);
|
||||
if (acc == null) {
|
||||
Stargate.log.info("[Stargate::ich::chargePlayer] Error fetching iConomy account for " + player);
|
||||
return false;
|
||||
@ -35,12 +35,20 @@ public class iConomyHandler {
|
||||
|
||||
if (balance < amount) return false;
|
||||
acc.setBalance(balance - amount);
|
||||
|
||||
if (target != null) {
|
||||
Account tAcc = iConomy.getBank().getAccount(target);
|
||||
if (tAcc != null) {
|
||||
balance = tAcc.getBalance();
|
||||
tAcc.setBalance(balance + amount);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean useiConomy() {
|
||||
return (useiConomy && iConomy != null);
|
||||
return (useiConomy && iconomy != null);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: Stargate
|
||||
main: net.TheDgtl.Stargate.Stargate
|
||||
version: 0.3.2
|
||||
version: 0.3.3
|
||||
description: Stargate mod for Bukkit
|
||||
author: Drakia
|
||||
website: http://www.thedgtl.net
|
Loading…
Reference in New Issue
Block a user