Added 'stargate.free' permission
Added iConomy cost into .gate files
This commit is contained in:
parent
8bdbb4a613
commit
b17d00e4e8
3
README
3
README
@ -88,6 +88,9 @@ not-enough-money-message - The message displayed if a player lacks money to do s
|
||||
=============
|
||||
Changes
|
||||
=============
|
||||
[Version 0.3.4]
|
||||
- Added 'stargate.free' permission
|
||||
- Added iConomy cost into .gate files
|
||||
[Version 0.3.3]
|
||||
- Moved sign update into a schedule event, should fix signs
|
||||
[Version 0.3.2]
|
||||
|
@ -36,6 +36,11 @@ public class Gate {
|
||||
private HashMap<RelativeBlockVector, Integer> exits = new HashMap<RelativeBlockVector, Integer>();
|
||||
private int portalBlockOpen = Material.PORTAL.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) {
|
||||
this.filename = filename;
|
||||
@ -99,6 +104,12 @@ public class Gate {
|
||||
|
||||
writeConfig(bw, "portal-open", portalBlockOpen);
|
||||
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()) {
|
||||
Integer value = types.get(type);
|
||||
@ -188,6 +199,18 @@ public class Gate {
|
||||
public int getPortalBlockClosed() {
|
||||
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) {
|
||||
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.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) {
|
||||
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points.");
|
||||
|
@ -638,7 +638,7 @@ public class Portal {
|
||||
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()) {
|
||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||
}
|
||||
|
@ -232,7 +232,8 @@ public class Stargate extends JavaPlugin {
|
||||
Portal destination = gate.getDestination();
|
||||
|
||||
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);
|
||||
} else if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
|
||||
gate.deactivate();
|
||||
@ -304,9 +305,10 @@ public class Stargate extends JavaPlugin {
|
||||
Portal dest = portal.getDestination();
|
||||
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()) {
|
||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.useCost));
|
||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getUseCost()));
|
||||
}
|
||||
if (!teleMsg.isEmpty()) {
|
||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
||||
@ -333,9 +335,10 @@ public class Stargate extends JavaPlugin {
|
||||
Portal destination = portal.getDestination();
|
||||
|
||||
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()) {
|
||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.useCost));
|
||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getUseCost()));
|
||||
}
|
||||
if (!teleMsg.isEmpty()) {
|
||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
||||
@ -436,7 +439,7 @@ public class Stargate extends JavaPlugin {
|
||||
if (portal == null) return;
|
||||
|
||||
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()) {
|
||||
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()) ||
|
||||
( portal.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) {
|
||||
// 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()) {
|
||||
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) {
|
||||
player.sendMessage(ChatColor.GREEN + "Refunded " + iConomy.getBank().format(-iConomyHandler.destroyCost));
|
||||
if(iConomyHandler.getBalance(player.getName()) < portal.getGate().getDestroyCost()) {
|
||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||
event.setCancelled(true);
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: Stargate
|
||||
main: net.TheDgtl.Stargate.Stargate
|
||||
version: 0.3.3
|
||||
version: 0.3.4
|
||||
description: Stargate mod for Bukkit
|
||||
author: Drakia
|
||||
website: http://www.thedgtl.net
|
Loading…
Reference in New Issue
Block a user