[Version 0.6.6]

- Added %cost% and %portal% to all eco* messages
 - Fixed an issue when creating a gate on a network you don't have
access to
 - I can't spell
This commit is contained in:
Steven Scott
2011-08-28 21:35:33 -07:00
parent 394421dff8
commit ab21354c7a
6 changed files with 37 additions and 31 deletions

@ -779,19 +779,15 @@ public class Portal {
// Check if the player can create gates on this network
if (!Stargate.canCreate(player, network)) {
Stargate.debug("createPortal", "Player doesn't have create permissions on network. Trying personal");
network = player.getName();
if (network.length() > 11) {
network = network.substring(0, 11);
}
// Check if we can create a gate on our own network
if (!Stargate.canCreate(player, network)) {
if (Stargate.canCreatePersonal(player)) {
network = player.getName();
if (network.length() > 11) network = network.substring(0, 11);
Stargate.debug("createPortal", "Creating personal portal");
Stargate.sendMessage(player, Stargate.getString("createPersonal"));
} else {
Stargate.debug("createPortal", "Player does not have access to network");
Stargate.sendMessage(player, Stargate.getString("createNetDeny"));
return null;
} else {
Stargate.debug("createPortal", "Creating personal portal");
Stargate.sendMessage(player, Stargate.getString("createPersonal"));
}
}
@ -849,12 +845,14 @@ public class Portal {
int cost = Stargate.getCreateCost(player, gate);
if (cost > 0) {
if (!Stargate.chargePlayer(player, null, gate.getCreateCost())) {
Stargate.sendMessage(player, Stargate.getString("ecoInFunds"));
String inFundMsg = Stargate.getString("ecoInFunds");
inFundMsg = Stargate.replaceVars(inFundMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), name});
Stargate.sendMessage(player, inFundMsg);
Stargate.debug("createPortal", "Insufficient Funds");
return null;
}
String deductMsg = Stargate.getString("ecoDeduct");
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(cost)});
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), name});
Stargate.sendMessage(player, deductMsg, false);
}

@ -185,7 +185,6 @@ public class Stargate extends JavaPlugin {
config.setProperty("createcost", iConomyHandler.createCost);
config.setProperty("destroycost", iConomyHandler.destroyCost);
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);
@ -447,10 +446,17 @@ public class Stargate extends JavaPlugin {
// Check for this specific network
if (hasPerm(player, "stargate.create.network." + network)) return true;
// Check if this is a personal gate, and if the player has create.personal
String pNet = player.getName();
if (pNet.length() > 11) pNet = pNet.substring(0, 11);
if (pNet.equalsIgnoreCase(network) && hasPerm(player, "stargate.create.personal")) return true;
return false;
}
/*
* Check if the player can create a personal gate
*/
public static boolean canCreatePersonal(Player player) {
// Check for general create
if (hasPerm(player, "stargate.create")) return true;
// Check for personal
if (hasPerm(player, "stargate.create.personal")) return true;
return false;
}
@ -615,7 +621,7 @@ public class Stargate extends JavaPlugin {
return;
}
String deductMsg = Stargate.getString("ecoDeduct");
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(cost)});
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), portal.getName()});
sendMessage(player, deductMsg, false);
if (target != null) {
Player p = server.getPlayer(target);
@ -707,7 +713,7 @@ public class Stargate extends JavaPlugin {
return;
}
String deductMsg = Stargate.getString("ecoDeduct");
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(cost)});
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), portal.getName()});
sendMessage(player, deductMsg, false);
if (target != null) {
Player p = server.getPlayer(target);
@ -838,18 +844,18 @@ public class Stargate extends JavaPlugin {
if (cost != 0) {
if (!Stargate.chargePlayer(player, null, cost)) {
Stargate.debug("onBlockBreak", "Insufficient Funds");
Stargate.sendMessage(player, iConomyHandler.inFundMsg);
Stargate.sendMessage(player, Stargate.getString("inFunds"));
event.setCancelled(true);
return;
}
if (cost > 0) {
String deductMsg = Stargate.getString("ecoDeduct");
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(cost)});
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), portal.getName()});
sendMessage(player, deductMsg, false);
} else if (cost < 0) {
String refundMsg = Stargate.getString("ecoRefund");
refundMsg = Stargate.replaceVars(refundMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(-cost)});
refundMsg = Stargate.replaceVars(refundMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(-cost), portal.getName()});
sendMessage(player, refundMsg, false);
}
}

@ -17,7 +17,6 @@ public class iConomyHandler {
public static int useCost = 0;
public static int createCost = 0;
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;

@ -7,8 +7,8 @@ destEmpty=Destination List Empty
denyMsg=Access Denied
ecoDeduct=Deducted %cost%
ecoRefund=Redunded %cost%
ecoObtain=Obtained %cost$ from Stargate %portal%
ecoRefund=Refunded %cost%
ecoObtain=Obtained %cost% from Stargate %portal%
ecoInFunds=Insufficient Funds
createMsg=Gate Created

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