Added chargefreedestination option
Added freegatesgreen option Thanks @jtojnar
This commit is contained in:
@ -122,6 +122,13 @@ public class Portal {
|
||||
public boolean isFree() {
|
||||
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,19 +431,49 @@ public class Portal {
|
||||
int index = destinations.indexOf(destination);
|
||||
|
||||
if ((index == max) && (max > 1) && (++done <= 3)) {
|
||||
id.setText(done, destinations.get(index - 2));
|
||||
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)) {
|
||||
id.setText(done, destinations.get(index - 1));
|
||||
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) {
|
||||
id.setText(done, " >" + destination + "< ");
|
||||
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)) {
|
||||
id.setText(done, destinations.get(index + 1));
|
||||
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)) {
|
||||
id.setText(done, destinations.get(index + 2));
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user