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
|
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.
|
- 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
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.3.3]
|
||||||
|
- Moved sign update into a schedule event, should fix signs
|
||||||
[Version 0.3.2]
|
[Version 0.3.2]
|
||||||
- Updated to latest RB
|
- 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]
|
[Version 0.3.1]
|
||||||
- Changed version numbering.
|
- Changed version numbering.
|
||||||
- Changed how plugins are hooked into.
|
- Changed how plugins are hooked into.
|
||||||
|
@ -110,7 +110,7 @@ public class Blox {
|
|||||||
result = result * 27 + x;
|
result = result * 27 + x;
|
||||||
result = result * 27 + y;
|
result = result * 27 + y;
|
||||||
result = result * 27 + z;
|
result = result * 27 + z;
|
||||||
result = result * 27 + world.hashCode();
|
result = result * 27 + world.getName().hashCode();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -397,6 +397,10 @@ public class Gate {
|
|||||||
return gates.get(name);
|
return gates.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getGateCount() {
|
||||||
|
return gates.size();
|
||||||
|
}
|
||||||
|
|
||||||
static class StargateFilenameFilter implements FilenameFilter {
|
static class StargateFilenameFilter implements FilenameFilter {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return name.endsWith(".gate");
|
return name.endsWith(".gate");
|
||||||
|
@ -56,6 +56,7 @@ public class Portal {
|
|||||||
private boolean hidden = false;
|
private boolean hidden = false;
|
||||||
private boolean alwaysOn = false;
|
private boolean alwaysOn = false;
|
||||||
private boolean priv = false;
|
private boolean priv = false;
|
||||||
|
private boolean free = false;
|
||||||
private World world;
|
private World world;
|
||||||
// Gate options
|
// Gate options
|
||||||
private boolean verified;
|
private boolean verified;
|
||||||
@ -71,7 +72,7 @@ public class Portal {
|
|||||||
float rotX, SignPost id, Blox button,
|
float rotX, SignPost id, Blox button,
|
||||||
String dest, String name,
|
String dest, String name,
|
||||||
boolean verified, String network, Gate gate,
|
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.topLeft = topLeft;
|
||||||
this.modX = modX;
|
this.modX = modX;
|
||||||
this.modZ = modZ;
|
this.modZ = modZ;
|
||||||
@ -88,6 +89,7 @@ public class Portal {
|
|||||||
this.hidden = hidden;
|
this.hidden = hidden;
|
||||||
this.alwaysOn = alwaysOn;
|
this.alwaysOn = alwaysOn;
|
||||||
this.priv = priv;
|
this.priv = priv;
|
||||||
|
this.free = free;
|
||||||
this.world = topLeft.getWorld();
|
this.world = topLeft.getWorld();
|
||||||
|
|
||||||
if (this.alwaysOn && !this.fixed) {
|
if (this.alwaysOn && !this.fixed) {
|
||||||
@ -117,6 +119,10 @@ public class Portal {
|
|||||||
return priv;
|
return priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFree() {
|
||||||
|
return free;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean open(boolean force) {
|
public boolean open(boolean force) {
|
||||||
return open(null, force);
|
return open(null, force);
|
||||||
}
|
}
|
||||||
@ -554,6 +560,7 @@ public class Portal {
|
|||||||
boolean hidden = (options.indexOf('h') != -1 || options.indexOf('H') != -1);
|
boolean hidden = (options.indexOf('h') != -1 || options.indexOf('H') != -1);
|
||||||
boolean alwaysOn = (options.indexOf('a') != -1 || options.indexOf('A') != -1);
|
boolean alwaysOn = (options.indexOf('a') != -1 || options.indexOf('A') != -1);
|
||||||
boolean priv = (options.indexOf('p') != -1 || options.indexOf('P') != -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
|
// Check if the user can only create personal gates, set network if so
|
||||||
if (Stargate.hasPerm(player, "stargate.create.personal", false) &&
|
if (Stargate.hasPerm(player, "stargate.create.personal", false) &&
|
||||||
@ -631,7 +638,7 @@ public class Portal {
|
|||||||
return null;
|
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()) {
|
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||||
}
|
}
|
||||||
@ -647,7 +654,7 @@ public class Portal {
|
|||||||
button.setType(Material.STONE_BUTTON.getId());
|
button.setType(Material.STONE_BUTTON.getId());
|
||||||
button.setData(facing);
|
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
|
// Open always on gate
|
||||||
if (portal.isAlwaysOn()) {
|
if (portal.isAlwaysOn()) {
|
||||||
@ -728,6 +735,8 @@ public class Portal {
|
|||||||
builder.append(portal.isPrivate());
|
builder.append(portal.isPrivate());
|
||||||
builder.append(':');
|
builder.append(':');
|
||||||
builder.append(portal.world.getName());
|
builder.append(portal.world.getName());
|
||||||
|
builder.append(':');
|
||||||
|
builder.append(portal.isFree());
|
||||||
|
|
||||||
bw.append(builder.toString());
|
bw.append(builder.toString());
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
@ -793,8 +802,9 @@ public class Portal {
|
|||||||
boolean hidden = (split.length > 11) ? split[11].equalsIgnoreCase("true") : false;
|
boolean hidden = (split.length > 11) ? split[11].equalsIgnoreCase("true") : false;
|
||||||
boolean alwaysOn = (split.length > 12) ? split[12].equalsIgnoreCase("true") : false;
|
boolean alwaysOn = (split.length > 12) ? split[12].equalsIgnoreCase("true") : false;
|
||||||
boolean priv = (split.length > 13) ? split[13].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);
|
portal.close(true);
|
||||||
}
|
}
|
||||||
scanner.close();
|
scanner.close();
|
||||||
|
@ -61,12 +61,17 @@ public class SignPost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
Sign sign = findSign();
|
final Sign sign = findSign();
|
||||||
if (sign == null) {
|
if (sign == null) {
|
||||||
Stargate.log.info("[Stargate::SignPost::update] Sign null");
|
Stargate.log.info("[Stargate::SignPost::update] Sign null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sign.update(true);
|
|
||||||
|
Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findParent() {
|
private void findParent() {
|
||||||
|
@ -113,7 +113,7 @@ 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");
|
||||||
iConomyHandler.iConomy = (iConomy)checkPlugin("iConomy");
|
iConomyHandler.iconomy = (iConomy)checkPlugin("iConomy");
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
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) {
|
if (Gate.getGateByName("nethergate.gate") == null || Gate.getGateByName("nethergate.gate").getExit() == null) {
|
||||||
Gate.populateDefaults(gateFolder);
|
Gate.populateDefaults(gateFolder);
|
||||||
}
|
}
|
||||||
|
log.info("[Stargate] Loaded " + Gate.getGateCount() + " gate layouts");
|
||||||
for (World world : getServer().getWorlds()) {
|
for (World world : getServer().getWorlds()) {
|
||||||
Portal.loadAllGates(world);
|
Portal.loadAllGates(world);
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
Portal destination = gate.getDestination();
|
Portal destination = gate.getDestination();
|
||||||
|
|
||||||
if (!gate.isOpen()) {
|
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);
|
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||||
} else if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
|
} else if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
|
||||||
gate.deactivate();
|
gate.deactivate();
|
||||||
@ -293,7 +293,8 @@ public class Stargate extends JavaPlugin {
|
|||||||
Vehicle vehicle = event.getVehicle();
|
Vehicle vehicle = event.getVehicle();
|
||||||
|
|
||||||
Portal portal = Portal.getByEntrance(event.getTo());
|
Portal portal = Portal.getByEntrance(event.getTo());
|
||||||
if (portal != null && portal.isOpen()) {
|
if (portal == null || !portal.isOpen()) return;
|
||||||
|
|
||||||
if (passenger instanceof Player) {
|
if (passenger instanceof Player) {
|
||||||
Player player = (Player)passenger;
|
Player player = (Player)passenger;
|
||||||
if (!portal.isOpenFor(player)) {
|
if (!portal.isOpenFor(player)) {
|
||||||
@ -302,14 +303,21 @@ public class Stargate extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
Portal dest = portal.getDestination();
|
Portal dest = portal.getDestination();
|
||||||
if (dest == null) return;
|
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();
|
Portal destination = portal.getDestination();
|
||||||
|
|
||||||
if (destination != null) {
|
if (destination != null) {
|
||||||
if (!iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), iConomyHandler.useCost)) {
|
if (portal.isFree() || !iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.useCost)) {
|
||||||
if (iConomyHandler.useiConomy()) {
|
if (!portal.isFree() && iConomyHandler.useiConomy()) {
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.useCost));
|
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.useCost));
|
||||||
}
|
}
|
||||||
if (!teleMsg.isEmpty()) {
|
if (!teleMsg.isEmpty()) {
|
||||||
@ -465,7 +473,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iConomyHandler.useiConomy()) {
|
if (iConomyHandler.useiConomy()) {
|
||||||
iConomyHandler.chargePlayer(player.getName(), iConomyHandler.destroyCost);
|
iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.destroyCost);
|
||||||
if (iConomyHandler.destroyCost > 0) {
|
if (iConomyHandler.destroyCost > 0) {
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.destroyCost));
|
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.destroyCost));
|
||||||
} else if (iConomyHandler.destroyCost < 0) {
|
} else if (iConomyHandler.destroyCost < 0) {
|
||||||
@ -533,9 +541,9 @@ 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.iConomy == null) {
|
if (iConomyHandler.iconomy == null) {
|
||||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
|
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
|
||||||
iConomyHandler.iConomy = (iConomy)checkPlugin(event.getPlugin());
|
iConomyHandler.iconomy = (iConomy)checkPlugin(event.getPlugin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (permissions == null) {
|
if (permissions == null) {
|
||||||
@ -547,9 +555,9 @@ public class Stargate extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginDisable(PluginDisableEvent event) {
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
if (event.getPlugin() == iConomyHandler.iConomy) {
|
if (event.getPlugin() == iConomyHandler.iconomy) {
|
||||||
log.info("[Stargate] iConomy plugin lost.");
|
log.info("[Stargate] iConomy plugin lost.");
|
||||||
iConomyHandler.iConomy = null;
|
iConomyHandler.iconomy = null;
|
||||||
}
|
}
|
||||||
if (event.getPlugin() == permissions) {
|
if (event.getPlugin() == permissions) {
|
||||||
log.info("[Stargate] Permissions plugin lost.");
|
log.info("[Stargate] Permissions plugin lost.");
|
||||||
|
@ -5,7 +5,7 @@ import com.nijiko.coelho.iConomy.system.Account;
|
|||||||
|
|
||||||
public class iConomyHandler {
|
public class iConomyHandler {
|
||||||
public static boolean useiConomy = false;
|
public static boolean useiConomy = false;
|
||||||
public static iConomy iConomy = null;
|
public static iConomy iconomy = null;
|
||||||
|
|
||||||
public static int useCost = 0;
|
public static int useCost = 0;
|
||||||
public static int createCost = 0;
|
public static int createCost = 0;
|
||||||
@ -13,8 +13,8 @@ public class iConomyHandler {
|
|||||||
public static String inFundMsg = "Insufficient Funds.";
|
public static String inFundMsg = "Insufficient Funds.";
|
||||||
|
|
||||||
public static double getBalance(String player) {
|
public static double getBalance(String player) {
|
||||||
if (useiConomy && iConomy != null) {
|
if (useiConomy && iconomy != null) {
|
||||||
Account acc = com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(player);
|
Account acc = iConomy.getBank().getAccount(player);
|
||||||
if (acc == null) {
|
if (acc == null) {
|
||||||
Stargate.log.info("[Stargate::ich::getBalance] Error fetching iConomy account for " + player);
|
Stargate.log.info("[Stargate::ich::getBalance] Error fetching iConomy account for " + player);
|
||||||
return 0;
|
return 0;
|
||||||
@ -24,9 +24,9 @@ public class iConomyHandler {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean chargePlayer(String player, double amount) {
|
public static boolean chargePlayer(String player, String target, double amount) {
|
||||||
if (useiConomy && iConomy != null) {
|
if (useiConomy && iconomy != null) {
|
||||||
Account acc = com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(player);
|
Account acc = iConomy.getBank().getAccount(player);
|
||||||
if (acc == null) {
|
if (acc == null) {
|
||||||
Stargate.log.info("[Stargate::ich::chargePlayer] Error fetching iConomy account for " + player);
|
Stargate.log.info("[Stargate::ich::chargePlayer] Error fetching iConomy account for " + player);
|
||||||
return false;
|
return false;
|
||||||
@ -35,12 +35,20 @@ public class iConomyHandler {
|
|||||||
|
|
||||||
if (balance < amount) return false;
|
if (balance < amount) return false;
|
||||||
acc.setBalance(balance - amount);
|
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;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean useiConomy() {
|
public static boolean useiConomy() {
|
||||||
return (useiConomy && iConomy != null);
|
return (useiConomy && iconomy != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.3.2
|
version: 0.3.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
|
Loading…
Reference in New Issue
Block a user