Added 'stargate.free' permission

Added iConomy cost into .gate files
This commit is contained in:
Drakia 2011-04-04 21:55:33 -07:00
parent 8bdbb4a613
commit b17d00e4e8
5 changed files with 52 additions and 20 deletions

3
README
View File

@ -88,6 +88,9 @@ not-enough-money-message - The message displayed if a player lacks money to do s
============= =============
Changes Changes
============= =============
[Version 0.3.4]
- Added 'stargate.free' permission
- Added iConomy cost into .gate files
[Version 0.3.3] [Version 0.3.3]
- Moved sign update into a schedule event, should fix signs - Moved sign update into a schedule event, should fix signs
[Version 0.3.2] [Version 0.3.2]

View File

@ -36,6 +36,11 @@ public class Gate {
private HashMap<RelativeBlockVector, Integer> exits = new HashMap<RelativeBlockVector, Integer>(); private HashMap<RelativeBlockVector, Integer> exits = new HashMap<RelativeBlockVector, Integer>();
private int portalBlockOpen = Material.PORTAL.getId(); private int portalBlockOpen = Material.PORTAL.getId();
private int portalBlockClosed = Material.AIR.getId(); private int portalBlockClosed = Material.AIR.getId();
// iConomy information
private int useCost = 0;
private int createCost = 0;
private int destroyCost = 0;
private Gate(String filename, Integer[][] layout, HashMap<Character, Integer> types) { private Gate(String filename, Integer[][] layout, HashMap<Character, Integer> types) {
this.filename = filename; this.filename = filename;
@ -99,6 +104,12 @@ public class Gate {
writeConfig(bw, "portal-open", portalBlockOpen); writeConfig(bw, "portal-open", portalBlockOpen);
writeConfig(bw, "portal-closed", portalBlockClosed); writeConfig(bw, "portal-closed", portalBlockClosed);
if (useCost != iConomyHandler.useCost)
writeConfig(bw, "usecost", useCost);
if (createCost != iConomyHandler.createCost)
writeConfig(bw, "createcost", createCost);
if (destroyCost != iConomyHandler.destroyCost)
writeConfig(bw, "destroycost", destroyCost);
for (Character type : types.keySet()) { for (Character type : types.keySet()) {
Integer value = types.get(type); Integer value = types.get(type);
@ -188,6 +199,18 @@ public class Gate {
public int getPortalBlockClosed() { public int getPortalBlockClosed() {
return portalBlockClosed; return portalBlockClosed;
} }
public int getUseCost() {
return useCost;
}
public Integer getCreateCost() {
return createCost;
}
public Integer getDestroyCost() {
return destroyCost;
}
public boolean matches(Block topleft, int modX, int modZ) { public boolean matches(Block topleft, int modX, int modZ) {
return matches(new Blox(topleft), modX, modZ); return matches(new Blox(topleft), modX, modZ);
@ -319,6 +342,9 @@ public class Gate {
gate.portalBlockOpen = readConfig(config, gate, file, "portal-open", gate.portalBlockOpen); gate.portalBlockOpen = readConfig(config, gate, file, "portal-open", gate.portalBlockOpen);
gate.portalBlockClosed = readConfig(config, gate, file, "portal-closed", gate.portalBlockClosed); gate.portalBlockClosed = readConfig(config, gate, file, "portal-closed", gate.portalBlockClosed);
gate.useCost = readConfig(config, gate, file, "usecost", iConomyHandler.useCost);
gate.destroyCost = readConfig(config, gate, file, "destroycost", iConomyHandler.destroyCost);
gate.createCost = readConfig(config, gate, file, "createcost", iConomyHandler.createCost);
if (gate.getControls().length != 2) { if (gate.getControls().length != 2) {
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points."); Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points.");

View File

@ -638,7 +638,7 @@ public class Portal {
return null; return null;
} }
if (iConomyHandler.useiConomy() && !iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.createCost)) { if (iConomyHandler.useiConomy() && !Stargate.hasPerm(player, "stargate.free", player.isOp()) && !iConomyHandler.chargePlayer(player.getName(), null, gate.getCreateCost())) {
if (!iConomyHandler.inFundMsg.isEmpty()) { if (!iConomyHandler.inFundMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg); player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
} }

View File

@ -232,7 +232,8 @@ public class Stargate extends JavaPlugin {
Portal destination = gate.getDestination(); Portal destination = gate.getDestination();
if (!gate.isOpen()) { if (!gate.isOpen()) {
if (!gate.isFree() && iConomyHandler.useiConomy() && iConomyHandler.getBalance(player.getName()) < iConomyHandler.useCost) { if (!gate.isFree() && !hasPerm(player, "stargate.free", player.isOp()) &&
iConomyHandler.useiConomy() && iConomyHandler.getBalance(player.getName()) < gate.getGate().getUseCost()) {
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();
@ -304,9 +305,10 @@ public class Stargate extends JavaPlugin {
Portal dest = portal.getDestination(); Portal dest = portal.getDestination();
if (dest == null) return; if (dest == null) return;
if (portal.isFree() || !iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.useCost)) { if (portal.isFree() || !iConomyHandler.useiConomy() || hasPerm(player, "stargate.free", player.isOp()) ||
iConomyHandler.chargePlayer(player.getName(), null, portal.getGate().getUseCost())) {
if (!portal.isFree() && 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(portal.getGate().getUseCost()));
} }
if (!teleMsg.isEmpty()) { if (!teleMsg.isEmpty()) {
player.sendMessage(ChatColor.BLUE + teleMsg); player.sendMessage(ChatColor.BLUE + teleMsg);
@ -333,9 +335,10 @@ public class Stargate extends JavaPlugin {
Portal destination = portal.getDestination(); Portal destination = portal.getDestination();
if (destination != null) { if (destination != null) {
if (portal.isFree() || !iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.useCost)) { if (portal.isFree() || !iConomyHandler.useiConomy() || hasPerm(player, "stargate.free", player.isOp()) ||
iConomyHandler.chargePlayer(player.getName(), null, portal.getGate().getUseCost())) {
if (!portal.isFree() && 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(portal.getGate().getUseCost()));
} }
if (!teleMsg.isEmpty()) { if (!teleMsg.isEmpty()) {
player.sendMessage(ChatColor.BLUE + teleMsg); player.sendMessage(ChatColor.BLUE + teleMsg);
@ -436,7 +439,7 @@ public class Stargate extends JavaPlugin {
if (portal == null) return; if (portal == null) return;
if (iConomyHandler.useiConomy()) { if (iConomyHandler.useiConomy()) {
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.createCost)); player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getCreateCost()));
} }
if (!regMsg.isEmpty()) { if (!regMsg.isEmpty()) {
player.sendMessage(ChatColor.GREEN + regMsg); player.sendMessage(ChatColor.GREEN + regMsg);
@ -465,19 +468,19 @@ public class Stargate extends JavaPlugin {
if (hasPerm(player, "stargate.destroy", player.isOp()) || hasPerm(player, "stargate.destroy.all", player.isOp()) || if (hasPerm(player, "stargate.destroy", player.isOp()) || hasPerm(player, "stargate.destroy.all", player.isOp()) ||
( portal.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) { ( portal.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) {
// Can't afford // Can't afford
if (iConomyHandler.useiConomy() && (iConomyHandler.destroyCost > 0 && iConomyHandler.getBalance(player.getName()) < iConomyHandler.destroyCost)) {
if (!iConomyHandler.inFundMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
event.setCancelled(true);
return;
}
}
if (iConomyHandler.useiConomy()) { if (iConomyHandler.useiConomy()) {
iConomyHandler.chargePlayer(player.getName(), null, iConomyHandler.destroyCost); if(iConomyHandler.getBalance(player.getName()) < portal.getGate().getDestroyCost()) {
if (iConomyHandler.destroyCost > 0) { if (!iConomyHandler.inFundMsg.isEmpty()) {
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.destroyCost)); player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
} else if (iConomyHandler.destroyCost < 0) { event.setCancelled(true);
player.sendMessage(ChatColor.GREEN + "Refunded " + iConomy.getBank().format(-iConomyHandler.destroyCost)); return;
}
}
iConomyHandler.chargePlayer(player.getName(), null, portal.getGate().getDestroyCost());
if (portal.getGate().getDestroyCost() > 0) {
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getDestroyCost()));
} else if (portal.getGate().getDestroyCost() < 0) {
player.sendMessage(ChatColor.GREEN + "Refunded " + iConomy.getBank().format(-portal.getGate().getDestroyCost()));
} }
} }

View File

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