Added chargefreedestination option

Added freegatesgreen option
Thanks @jtojnar
This commit is contained in:
Drakia 2011-05-07 13:13:21 -07:00
parent 858a40e0cf
commit d22a4b0871
5 changed files with 62 additions and 10 deletions

6
README
View File

@ -118,6 +118,8 @@ useiconomy - Whether or not to use iConomy
createcost - The cost to create a stargate
destroycost - The cost to destroy a stargate (Can be negative for a "refund"
usecost - The cost to use a stargate
chargefreedestination - Enable to allow free travel from any gate to a free gate
freegatesgreen - Enable to make gates that won't cost the player money show up as green
not-enough-money-message - The message displayed if a player lacks money to do something
networkfilter - Whether or not to disallow users access to a network if they don't have the 'stargate.network.{networkname}' permission.
worldfilter - Whether or not to disallow users access to a network if they don't have the 'stargate.world.{worldname}' permission.
@ -127,9 +129,13 @@ debug - Whether to show massive debug output for gate creation
=============
Changes
=============
[Version 0.4.8]
- Added chargefreedestination option
- Added freegatesgreen option
[Version 0.4.7]
- Added debug option
- Fixed gates will now show in the list of gates they link to.
- iConomy no longer touched if not enabled in config
[Version 0.4.6]
- Fixed a bug in iConomy handling.
[Version 0.4.5]

View File

@ -123,6 +123,13 @@ public class Portal {
return free;
}
public boolean isFree(Player player, Portal dest) {
// This gate is free, the player gets all gates free, or we don't charge for free dest and dest is free
boolean isFree = isFree() || Stargate.hasPerm(player, "stargate.free.use", player.isOp()) ||
(!iConomyHandler.chargeFreeDestination && dest.isFree());
return isFree;
}
public boolean open(boolean force) {
return open(null, force);
}
@ -424,22 +431,52 @@ public class Portal {
int index = destinations.indexOf(destination);
if ((index == max) && (max > 1) && (++done <= 3)) {
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
Portal dest = Portal.getByName(destinations.get(index - 2), network);
boolean green = isFree(activePlayer, dest);
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 2));
} else {
id.setText(done, destinations.get(index - 2));
}
}
if ((index > 0) && (++done <= 3)) {
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
Portal dest = Portal.getByName(destinations.get(index - 1), network);
boolean green = isFree(activePlayer, dest);
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 1));
} else {
id.setText(done, destinations.get(index - 1));
}
}
if (++done <= 3) {
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
Portal dest = Portal.getByName(destination, network);
boolean green = isFree(activePlayer, dest);
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + " >" + destination + "< ");
} else {
id.setText(done, " >" + destination + "< ");
}
}
if ((max >= index + 1) && (++done <= 3)) {
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
Portal dest = Portal.getByName(destinations.get(index + 1), network);
boolean green = isFree(activePlayer, dest);
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 1));
} else {
id.setText(done, destinations.get(index + 1));
}
}
if ((max >= index + 2) && (++done <= 3)) {
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
Portal dest = Portal.getByName(destinations.get(index + 2), network);
boolean green = isFree(activePlayer, dest);
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 2));
} else {
id.setText(done, destinations.get(index + 2));
}
}
}
}
for (done++; done <= 3; done++) {
id.setText(done, "");

View File

@ -164,6 +164,8 @@ public class Stargate extends JavaPlugin {
iConomyHandler.useCost = config.getInt("usecost", iConomyHandler.useCost);
iConomyHandler.inFundMsg = config.getString("not-enough-money-message", iConomyHandler.inFundMsg);
iConomyHandler.toOwner = config.getBoolean("toowner", iConomyHandler.toOwner);
iConomyHandler.chargeFreeDestination = config.getBoolean("chargefreedestination", iConomyHandler.chargeFreeDestination);
iConomyHandler.freeGatesGreen = config.getBoolean("freegatesgreen", iConomyHandler.freeGatesGreen);
saveConfig();
}
@ -188,6 +190,8 @@ public class Stargate extends JavaPlugin {
config.setProperty("usecost", iConomyHandler.useCost);
config.setProperty("not-enough-money-message", iConomyHandler.inFundMsg);
config.setProperty("toowner", iConomyHandler.toOwner);
config.setProperty("chargefreedestination", iConomyHandler.chargeFreeDestination);
config.setProperty("freegatesgreen", iConomyHandler.freeGatesGreen);
config.save();
}
@ -253,10 +257,7 @@ public class Stargate extends JavaPlugin {
Portal destination = gate.getDestination();
if (!gate.isOpen()) {
if (!gate.isFree() && !hasPerm(player, "stargate.free.use", 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)) {
if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
gate.deactivate();
if (!denyMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + denyMsg);
@ -327,6 +328,9 @@ public class Stargate extends JavaPlugin {
if (dest == null) return;
boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
if (!iConomyHandler.chargeFreeDestination)
iConCharge = iConCharge && !dest.isFree();
String target = (portal.getGate().getToOwner() ? portal.getOwner() : null);
if (target != null)
iConCharge = iConCharge && !target.equals(player.getName());
@ -388,6 +392,9 @@ public class Stargate extends JavaPlugin {
}
boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
if (!iConomyHandler.chargeFreeDestination)
iConCharge = iConCharge && !destination.isFree();
String target = (portal.getGate().getToOwner() ? portal.getOwner() : null);
if (target != null)
iConCharge = iConCharge && !target.equals(player.getName());

View File

@ -14,6 +14,8 @@ public class iConomyHandler {
public static int destroyCost = 0;
public static String inFundMsg = "Insufficient Funds.";
public static boolean toOwner = false;
public static boolean chargeFreeDestination = true;
public static boolean freeGatesGreen = false;
public static double getBalance(String player) {
if (useiConomy && iconomy != null) {

View File

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