[Version 0.6.5]
- Moved printed message config to a seperate file - Added permdebug option - Hopefully fix path issues some people were having - Fixed iConomy creation cost
This commit is contained in:
parent
f1cb266a0a
commit
af37bac990
51
README
51
README
@ -133,12 +133,6 @@ Which would only allow black wool. If no data is supplied any version of a block
|
||||
Configuration
|
||||
==============
|
||||
default-gate-network - The default gate network
|
||||
not-selected-message - The message when no destination is selected
|
||||
portal-destroy-message - The message when a gate is destroyed
|
||||
portal-create-message - The message when a gate is created
|
||||
not-owner-message - The message when you aren't allowed to push the gate button
|
||||
other-side-blocked-message - The message when the gate you're dialing is open
|
||||
teleport-message - The message when you are teleported
|
||||
portal-folder - The folder your portal databases are saved in
|
||||
gate-folder - The folder containing your .gate files
|
||||
destroyexplosion - Whether to destroy a stargate with explosions, or stop an explosion if it contains a gates controls.
|
||||
@ -148,14 +142,55 @@ 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
|
||||
toowner - Whether the money from gate-use goes to the owner or nobody
|
||||
debug - Whether to show massive debug output
|
||||
maxgates - If non-zero, will define the maximum amount of gates allowed on any network.
|
||||
|
||||
debug - Whether to show massive debug output
|
||||
permdebug - Whether to show massive permission debug output
|
||||
|
||||
=======================
|
||||
Message Customization
|
||||
=======================
|
||||
As of 0.6.5 it is possible to customize all of the messages Stargate displays, including the [Stargate] prefix. You can find the strings in plugins/Stargate/lang/en.txt.
|
||||
If a string is removed, or left blank, it will not be shown when the user does the action associated with it.
|
||||
There are three special cases when it comes to messages, these are:
|
||||
ecoDeduct=Spent %cost%
|
||||
ecoRefund=Redunded %cost%
|
||||
ecoObtain=Obtained %cost$ from Stargate %portal%
|
||||
|
||||
As you can see, these three strings have variables in them. These variables are fairly self-explanatory.
|
||||
The full list of strings is as follows:
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Teleported
|
||||
destroyMsg=Gate Destroyed
|
||||
invalidMsg=Invalid Destination
|
||||
blockMsg=Destination Blocked
|
||||
denyMsg=Access Denied
|
||||
destEmpty=Destination List Empty
|
||||
|
||||
ecoDeduct=Deducted %cost%
|
||||
ecoRefund=Redunded %cost%
|
||||
ecoObtain=Obtained %cost$ from Stargate %portal%
|
||||
ecoInFunds=Insufficient Funds
|
||||
|
||||
createMsg=Gate Created
|
||||
createNetDeny=You do not have access to that network
|
||||
createPersonal=Creating gate on personal network
|
||||
createNameLength=Name too short or too long.
|
||||
createExists=A gate by that name already exists
|
||||
createFull=This network is full
|
||||
createWorldDeny=You do not have access to that world
|
||||
createConflict=Gate conflicts with existing gate
|
||||
|
||||
|
||||
=============
|
||||
Changes
|
||||
=============
|
||||
[Version 0.6.5]
|
||||
- Moved printed message config to a seperate file
|
||||
- Added permdebug option
|
||||
- Hopefully fix path issues some people were having
|
||||
- Fixed iConomy creation cost
|
||||
[Version 0.6.4]
|
||||
- Fixed iConomy handling
|
||||
[Version 0.6.3]
|
||||
|
@ -229,14 +229,17 @@ public class Gate {
|
||||
if (id == ENTRANCE || id == EXIT) {
|
||||
int type = topleft.modRelative(x, y, 0, modX, 1, modZ).getType();
|
||||
if (type != portalBlockClosed && type != portalBlockOpen) {
|
||||
Stargate.debug("Gate::Matches", "Entrance/Exit Material Mismatch: " + type);
|
||||
return false;
|
||||
}
|
||||
} else if (id != ANYTHING) {
|
||||
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != id) {
|
||||
Stargate.debug("Gate::Matches", "Block Type Mismatch: " + topleft.modRelative(x, y, 0, modX, 1, modZ).getType() + " != " + id);
|
||||
return false;
|
||||
}
|
||||
Integer mData = metadata.get(layout[y][x]);
|
||||
if (mData != null && topleft.modRelative(x, y, 0, modX, 1, modZ).getData() != mData) {
|
||||
Stargate.debug("Gate::Matches", "Block Data Mismatch: " + topleft.modRelative(x, y, 0, modX, 1, modZ).getData() + " != " + mData);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
114
src/net/TheDgtl/Stargate/LangLoader.java
Normal file
114
src/net/TheDgtl/Stargate/LangLoader.java
Normal file
@ -0,0 +1,114 @@
|
||||
package net.TheDgtl.Stargate;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public class LangLoader {
|
||||
// Variables
|
||||
private String datFolder;
|
||||
private String lang;
|
||||
private HashMap<String, String> strList;
|
||||
|
||||
public LangLoader(String datFolder, String lang) {
|
||||
this.lang = lang;
|
||||
this.datFolder = datFolder;
|
||||
strList = new HashMap<String, String>();
|
||||
|
||||
File tmp = new File(datFolder, lang + ".txt");
|
||||
if (!tmp.exists()) {
|
||||
tmp.getParentFile().mkdirs();
|
||||
loadDefaults();
|
||||
}
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
public boolean reload() {
|
||||
strList = new HashMap<String, String>();
|
||||
load();
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getString(String name) {
|
||||
String val = strList.get(name);
|
||||
if (val == null) return "";
|
||||
return val;
|
||||
}
|
||||
|
||||
private void loadDefaults() {
|
||||
InputStream is = Stargate.class.getResourceAsStream("resources/en.txt");
|
||||
if (is == null) return;
|
||||
Stargate.log.info("[Stargate] Extracting initial language file");
|
||||
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
// Input stuff
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
|
||||
// Save file
|
||||
fos = new FileOutputStream(datFolder + lang + ".txt");
|
||||
OutputStreamWriter out = new OutputStreamWriter(fos);
|
||||
BufferedWriter bw = new BufferedWriter(out);
|
||||
|
||||
String line = br.readLine();
|
||||
while (line != null) {
|
||||
bw.write(line);
|
||||
bw.newLine();
|
||||
line = br.readLine();
|
||||
}
|
||||
bw.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (fos != null) {
|
||||
try {fos.close();} catch (Exception ex) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean load() {
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(datFolder + lang + ".txt");
|
||||
InputStreamReader isr = new InputStreamReader(fis);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
String line = br.readLine();
|
||||
while (line != null) {
|
||||
// Split at first "="
|
||||
int eq = line.indexOf('=');
|
||||
if (eq == -1) {
|
||||
line = br.readLine();
|
||||
continue;
|
||||
}
|
||||
String key = line.substring(0, eq);
|
||||
String val = line.substring(eq + 1);
|
||||
strList.put(key, val);
|
||||
line = br.readLine();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {fis.close();}
|
||||
catch (Exception ex) {}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void debug() {
|
||||
Set<String> keys = strList.keySet();
|
||||
for (String key : keys) {
|
||||
Stargate.debug("LangLoader::Debug", key + " => " + strList.get(key));
|
||||
}
|
||||
}
|
||||
}
|
@ -484,6 +484,13 @@ public class Portal {
|
||||
public void cycleDestination(Player player, int dir) {
|
||||
if (!isActive() || getActivePlayer() != player) {
|
||||
activate(player);
|
||||
Stargate.debug("cycleDestination", "Network Size: " + allPortalsNet.get(network.toLowerCase()).size());
|
||||
Stargate.debug("cycleDestination", "Player has access to: " + destinations.size());
|
||||
}
|
||||
|
||||
if (destinations.size() == 0) {
|
||||
Stargate.sendMessage(player, Stargate.getString("destEmpty"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (destinations.size() > 0) {
|
||||
@ -767,30 +774,30 @@ public class Portal {
|
||||
// Check if we can create a gate on our own network
|
||||
if (!Stargate.canCreate(player, network)) {
|
||||
Stargate.debug("createPortal", "Player does not have access to network");
|
||||
Stargate.sendMessage(player, "You do not have access to that network");
|
||||
Stargate.sendMessage(player, Stargate.getString("createNetDeny"));
|
||||
return null;
|
||||
} else {
|
||||
Stargate.debug("createPortal", "Creating personal portal");
|
||||
Stargate.sendMessage(player, "Creating gate on personal network");
|
||||
Stargate.sendMessage(player, Stargate.getString("createPersonal"));
|
||||
}
|
||||
}
|
||||
|
||||
if (name.length() < 1 || name.length() > 11) {
|
||||
Stargate.debug("createPortal", "Name length error");
|
||||
Stargate.sendMessage(player, "Name too short or too long.");
|
||||
Stargate.sendMessage(player, Stargate.getString("createNameLength"));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (getByName(name, network) != null) {
|
||||
Stargate.debug("createPortal", "Name Error");
|
||||
Stargate.sendMessage(player, "A gate by that name already exists!");
|
||||
Stargate.sendMessage(player, Stargate.getString("createExists"));
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if there are too many gates in this network
|
||||
ArrayList<String> netList = allPortalsNet.get(network.toLowerCase());
|
||||
if (Stargate.maxGates > 0 && netList != null && netList.size() >= Stargate.maxGates) {
|
||||
Stargate.sendMessage(player, "This network is full.");
|
||||
Stargate.sendMessage(player, Stargate.getString("createFull"));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -801,7 +808,7 @@ public class Portal {
|
||||
String world = p.getWorld().getName();
|
||||
if (!Stargate.canAccessWorld(player, world)) {
|
||||
Stargate.debug("canCreate", "Player does not have access to destination world");
|
||||
Stargate.sendMessage(player, "You do not have access to that world.");
|
||||
Stargate.sendMessage(player, Stargate.getString("createWorldDeny"));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -812,17 +819,21 @@ public class Portal {
|
||||
Blox b = topleft.modRelative(v.getRight(), v.getDepth(), v.getDistance(), modX, 1, modZ);
|
||||
if (Portal.getByBlock(b.getBlock()) != null) {
|
||||
Stargate.debug("createPortal", "Gate conflicts with existing gate");
|
||||
Stargate.sendMessage(player, Stargate.getString("createConflict"));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
int cost = Stargate.getCreateCost(player, gate);
|
||||
int cost = Stargate.getCreateCost(player, gate);
|
||||
if (cost > 0) {
|
||||
if (!Stargate.chargePlayer(player, null, gate.getCreateCost())) {
|
||||
Stargate.sendMessage(player, "Insufficient Funds");
|
||||
Stargate.sendMessage(player, Stargate.getString("ecoInFunds"));
|
||||
Stargate.debug("createPortal", "Insufficient Funds");
|
||||
return null;
|
||||
}
|
||||
String deductMsg = Stargate.getString("ecoDeduct");
|
||||
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(cost)});
|
||||
Stargate.sendMessage(player, deductMsg, false);
|
||||
}
|
||||
|
||||
Portal portal = null;
|
||||
@ -1006,6 +1017,12 @@ public class Portal {
|
||||
// Verify portal integrity/register portal
|
||||
if (!portal.wasVerified()) {
|
||||
if (!portal.isVerified() || !portal.checkIntegrity()) {
|
||||
// DEBUG
|
||||
for (RelativeBlockVector control : portal.getGate().getControls()) {
|
||||
if (portal.getBlockAt(control).getBlock().getTypeId() != portal.getGate().getControlBlock()) {
|
||||
Stargate.debug("loadAllGates", "Control Block Type == " + portal.getBlockAt(control).getBlock().getTypeId());
|
||||
}
|
||||
}
|
||||
portal.unregister(false);
|
||||
iter.remove();
|
||||
Stargate.log.info("[Stargate] Destroying stargate at " + portal.toString());
|
||||
|
@ -72,15 +72,11 @@ public class Stargate extends JavaPlugin {
|
||||
private PluginManager pm;
|
||||
public static Server server;
|
||||
public static Stargate stargate;
|
||||
private static LangLoader lang;
|
||||
|
||||
private static String portalFolder;
|
||||
private static String gateFolder;
|
||||
private static String teleMsg = "Teleported";
|
||||
private static String regMsg = "Gate Created";
|
||||
private static String dmgMsg = "Gate Destroyed";
|
||||
private static String denyMsg = "Access Denied";
|
||||
private static String invMsg = "Invalid Destination";
|
||||
private static String blockMsg = "Destination Blocked";
|
||||
private static String langFolder;
|
||||
private static String defNetwork = "central";
|
||||
private static boolean destroyExplosion = false;
|
||||
public static int maxGates = 0;
|
||||
@ -88,7 +84,8 @@ public class Stargate extends JavaPlugin {
|
||||
private static int openTime = 10;
|
||||
|
||||
// Used for debug
|
||||
private static boolean debug = false;
|
||||
public static boolean debug = false;
|
||||
public static boolean permDebug = false;
|
||||
|
||||
public static ConcurrentLinkedQueue<Portal> openList = new ConcurrentLinkedQueue<Portal>();
|
||||
public static ConcurrentLinkedQueue<Portal> activeList = new ConcurrentLinkedQueue<Portal>();
|
||||
@ -107,8 +104,9 @@ public class Stargate extends JavaPlugin {
|
||||
Stargate.stargate = this;
|
||||
|
||||
// Set portalFile and gateFolder to the plugin folder as defaults.
|
||||
portalFolder = getDataFolder() + "/portals";
|
||||
gateFolder = getDataFolder() + "/gates/";
|
||||
portalFolder = getDataFolder().getPath().replaceAll("\\\\", "/") + "/portals/";
|
||||
gateFolder = getDataFolder().getPath().replaceAll("\\\\", "/") + "/gates/";
|
||||
langFolder = getDataFolder().getPath().replaceAll("\\\\", "/") + "/lang/";
|
||||
|
||||
log.info(pdfFile.getName() + " v." + pdfFile.getVersion() + " is enabled.");
|
||||
|
||||
@ -118,6 +116,8 @@ public class Stargate extends JavaPlugin {
|
||||
this.reloadConfig();
|
||||
this.migrate();
|
||||
this.reloadGates();
|
||||
lang = new LangLoader(langFolder, "en");
|
||||
lang.debug();
|
||||
|
||||
// Check to see if iConomy/Permissions is loaded yet.
|
||||
permissions = (Permissions)checkPlugin("Permissions");
|
||||
@ -152,17 +152,12 @@ public class Stargate extends JavaPlugin {
|
||||
config.load();
|
||||
portalFolder = config.getString("portal-folder", portalFolder);
|
||||
gateFolder = config.getString("gate-folder", gateFolder);
|
||||
teleMsg = config.getString("teleport-message", teleMsg);
|
||||
regMsg = config.getString("portal-create-message", regMsg);
|
||||
dmgMsg = config.getString("portal-destroy-message", dmgMsg);
|
||||
denyMsg = config.getString("not-owner-message", denyMsg);
|
||||
invMsg = config.getString("not-selected-message", invMsg);
|
||||
blockMsg = config.getString("other-side-blocked-message", blockMsg);
|
||||
defNetwork = config.getString("default-gate-network", defNetwork).trim();
|
||||
destroyExplosion = config.getBoolean("destroyexplosion", destroyExplosion);
|
||||
maxGates = config.getInt("maxgates", maxGates);
|
||||
// Debug
|
||||
debug = config.getBoolean("debug", debug);
|
||||
permDebug = config.getBoolean("permdebug", permDebug);
|
||||
// iConomy
|
||||
iConomyHandler.useiConomy = config.getBoolean("useiconomy", iConomyHandler.useiConomy);
|
||||
iConomyHandler.createCost = config.getInt("createcost", iConomyHandler.createCost);
|
||||
@ -177,14 +172,12 @@ public class Stargate extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
if (!debug)
|
||||
config.removeProperty("debug");
|
||||
if (!permDebug)
|
||||
config.removeProperty("permdebug");
|
||||
config.setProperty("portal-folder", portalFolder);
|
||||
config.setProperty("gate-folder", gateFolder);
|
||||
config.setProperty("teleport-message", teleMsg);
|
||||
config.setProperty("portal-create-message", regMsg);
|
||||
config.setProperty("portal-destroy-message", dmgMsg);
|
||||
config.setProperty("not-owner-message", denyMsg);
|
||||
config.setProperty("not-selected-message", invMsg);
|
||||
config.setProperty("other-side-blocked-message", blockMsg);
|
||||
config.setProperty("default-gate-network", defNetwork);
|
||||
config.setProperty("destroyexplosion", destroyExplosion);
|
||||
config.setProperty("maxgates", maxGates);
|
||||
@ -256,10 +249,11 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
public static void sendMessage(Player player, String message, boolean error) {
|
||||
if (message.isEmpty()) return;
|
||||
message = message.replaceAll("(&([a-f0-9]))", "\u00A7$2");
|
||||
if (error)
|
||||
player.sendMessage(ChatColor.RED + "[Stargate] " + ChatColor.WHITE + message);
|
||||
player.sendMessage(ChatColor.RED + Stargate.getString("prefix") + ChatColor.WHITE + message);
|
||||
else
|
||||
player.sendMessage(ChatColor.GREEN + "[Stargate] " + ChatColor.WHITE + message);
|
||||
player.sendMessage(ChatColor.GREEN + Stargate.getString("prefix") + ChatColor.WHITE + message);
|
||||
}
|
||||
|
||||
public static String getSaveLocation() {
|
||||
@ -270,23 +264,8 @@ public class Stargate extends JavaPlugin {
|
||||
return defNetwork;
|
||||
}
|
||||
|
||||
public static String getTeleMsg() {
|
||||
return teleMsg;
|
||||
}
|
||||
public static String getRegMsg() {
|
||||
return regMsg;
|
||||
}
|
||||
public static String getDmgMsg() {
|
||||
return dmgMsg;
|
||||
}
|
||||
public static String getDenyMsg() {
|
||||
return denyMsg;
|
||||
}
|
||||
public static String getInvMsg() {
|
||||
return invMsg;
|
||||
}
|
||||
public static String getBlockMsg() {
|
||||
return blockMsg;
|
||||
public static String getString(String name) {
|
||||
return lang.getString(name);
|
||||
}
|
||||
|
||||
private void onButtonPressed(Player player, Portal portal) {
|
||||
@ -299,7 +278,7 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Invalid destination
|
||||
if ((destination == null) || (destination == portal)) {
|
||||
Stargate.sendMessage(player, invMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("invalidMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -314,19 +293,19 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Gate that someone else is using -- Deny access
|
||||
if ((!portal.isFixed()) && portal.isActive() && (portal.getActivePlayer() != player)) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the player can use the private gate
|
||||
if (portal.isPrivate() && !Stargate.canPrivate(player, portal)) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Destination blocked
|
||||
if ((destination.isOpen()) && (!destination.isAlwaysOn())) {
|
||||
Stargate.sendMessage(player, blockMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("blockMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -339,8 +318,12 @@ public class Stargate extends JavaPlugin {
|
||||
*/
|
||||
public static boolean hasPerm(Player player, String perm) {
|
||||
if (permissions != null) {
|
||||
if (permDebug)
|
||||
Stargate.debug("hasPerm::Permissions", perm + " => " + permissions.getHandler().has(player, perm));
|
||||
return permissions.getHandler().has(player, perm);
|
||||
} else {
|
||||
if (permDebug)
|
||||
Stargate.debug("hasPerm::SuperPerm", perm + " => " + player.hasPermission(perm));
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
}
|
||||
@ -353,9 +336,17 @@ public class Stargate extends JavaPlugin {
|
||||
*/
|
||||
public static boolean hasPermDeep(Player player, String perm) {
|
||||
if (permissions != null) {
|
||||
if (permDebug)
|
||||
Stargate.debug("hasPermDeep::Permissions", perm + " => " + permissions.getHandler().has(player, perm));
|
||||
return permissions.getHandler().has(player, perm);
|
||||
} else {
|
||||
if (!player.isPermissionSet(perm)) return true;
|
||||
if (!player.isPermissionSet(perm)) {
|
||||
if (permDebug)
|
||||
Stargate.debug("hasPermDeep::SuperPerm", perm + " => true");
|
||||
return true;
|
||||
}
|
||||
if (permDebug)
|
||||
Stargate.debug("hasPermDeep::Permissions", perm + " => " + permissions.getHandler().has(player, perm));
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
}
|
||||
@ -468,16 +459,17 @@ public class Stargate extends JavaPlugin {
|
||||
* Check if the player can destroy this gate
|
||||
*/
|
||||
public static boolean canDestroy(Player player, Portal portal) {
|
||||
String network = portal.getNetwork();
|
||||
// Check for general destroy
|
||||
if (hasPerm(player, "stargate.destroy")) return true;
|
||||
// Check for all network destroy permission
|
||||
if (hasPerm(player, "stargate.destroy.network")) {
|
||||
// Do a deep check to see if the player lacks permission for this network node
|
||||
if (!hasPermDeep(player, "stargate.destroy.network." + portal.getNetwork())) return false;
|
||||
if (!hasPermDeep(player, "stargate.destroy.network." + network)) return false;
|
||||
return true;
|
||||
}
|
||||
// Check for this specific network
|
||||
if (hasPerm(player, "stargate.destroy.network." + portal.getNetwork())) return true;
|
||||
if (hasPerm(player, "stargate.destroy.network." + network)) return true;
|
||||
// Check for personal gate
|
||||
if (player.getName().equalsIgnoreCase(portal.getOwner()) && hasPerm(player, "stargate.destroy.personal")) return true;
|
||||
return false;
|
||||
@ -522,7 +514,7 @@ public class Stargate extends JavaPlugin {
|
||||
// Player gets free gate destruction
|
||||
if (hasPerm(player, "stargate.free") || hasPerm(player, "stargate.free.create")) return 0;
|
||||
|
||||
return gate.getDestroyCost();
|
||||
return gate.getCreateCost();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -553,6 +545,17 @@ public class Stargate extends JavaPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a given text string and replace the variables
|
||||
*/
|
||||
public static String replaceVars(String format, String[] search, String[] replace) {
|
||||
if (search.length != replace.length) return "";
|
||||
for (int i = 0; i < search.length; i++) {
|
||||
format = format.replaceAll(search[i], replace[i]);
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
private class vListener extends VehicleListener {
|
||||
@Override
|
||||
public void onVehicleMove(VehicleMoveEvent event) {
|
||||
@ -565,7 +568,7 @@ public class Stargate extends JavaPlugin {
|
||||
if (passenger instanceof Player) {
|
||||
Player player = (Player)passenger;
|
||||
if (!portal.isOpenFor(player)) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -573,14 +576,14 @@ public class Stargate extends JavaPlugin {
|
||||
if (dest == null) return;
|
||||
// Check if player has access to this network
|
||||
if (!canAccessNetwork(player, portal.getNetwork())) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
portal.close(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if player has access to destination world
|
||||
if (!canAccessWorld(player, dest.getWorld().getName())) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
portal.close(false);
|
||||
return;
|
||||
}
|
||||
@ -590,20 +593,24 @@ public class Stargate extends JavaPlugin {
|
||||
String target = portal.getGate().getToOwner() ? portal.getOwner() : null;
|
||||
if (!Stargate.chargePlayer(player, target, cost)) {
|
||||
// Insufficient Funds
|
||||
Stargate.sendMessage(player, "Insufficient Funds");
|
||||
Stargate.sendMessage(player, Stargate.getString("inFunds"));
|
||||
portal.close(false);
|
||||
return;
|
||||
}
|
||||
sendMessage(player, "Deducted " + iConomyHandler.format(cost), false);
|
||||
String deductMsg = Stargate.getString("ecoDeduct");
|
||||
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(cost)});
|
||||
sendMessage(player, deductMsg, false);
|
||||
if (target != null) {
|
||||
Player p = server.getPlayer(target);
|
||||
if (p != null) {
|
||||
Stargate.sendMessage(p, "Obtained " + iConomyHandler.format(cost) + " from Stargate " + portal.getName(), false);
|
||||
String obtainedMsg = Stargate.getString("ecoObtain");
|
||||
obtainedMsg = Stargate.replaceVars(obtainedMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), portal.getName()});
|
||||
Stargate.sendMessage(p, obtainedMsg, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Stargate.sendMessage(player, teleMsg, false);
|
||||
Stargate.sendMessage(player, Stargate.getString("teleportMsg"), false);
|
||||
dest.teleport(vehicle);
|
||||
portal.close(false);
|
||||
} else {
|
||||
@ -649,9 +656,7 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Not open for this player
|
||||
if (!portal.isOpenFor(player)) {
|
||||
if (!denyMsg.isEmpty()) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
}
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
portal.teleport(player, portal, event);
|
||||
return;
|
||||
}
|
||||
@ -661,7 +666,7 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Check if player has access to this network
|
||||
if (!canAccessNetwork(player, portal.getNetwork())) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
portal.teleport(player, portal, event);
|
||||
portal.close(false);
|
||||
return;
|
||||
@ -669,7 +674,7 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Check if player has access to destination world
|
||||
if (!canAccessWorld(player, destination.getWorld().getName())) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
portal.teleport(player, portal, event);
|
||||
portal.close(false);
|
||||
return;
|
||||
@ -684,16 +689,20 @@ public class Stargate extends JavaPlugin {
|
||||
portal.close(false);
|
||||
return;
|
||||
}
|
||||
sendMessage(player, "Deducted " + iConomyHandler.format(cost), false);
|
||||
String deductMsg = Stargate.getString("ecoDeduct");
|
||||
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(cost)});
|
||||
sendMessage(player, deductMsg, false);
|
||||
if (target != null) {
|
||||
Player p = server.getPlayer(target);
|
||||
if (p != null) {
|
||||
Stargate.sendMessage(p, "Obtained " + iConomyHandler.format(cost) + " from Stargate " + portal.getName(), false);
|
||||
String obtainedMsg = Stargate.getString("ecoObtain");
|
||||
obtainedMsg = Stargate.replaceVars(obtainedMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), portal.getName()});
|
||||
Stargate.sendMessage(p, obtainedMsg, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Stargate.sendMessage(player, teleMsg, false);
|
||||
Stargate.sendMessage(player, Stargate.getString("teleportMsg"), false);
|
||||
destination.teleport(player, portal, event);
|
||||
portal.close(false);
|
||||
}
|
||||
@ -713,7 +722,7 @@ public class Stargate extends JavaPlugin {
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
|
||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -728,7 +737,7 @@ public class Stargate extends JavaPlugin {
|
||||
Portal portal = Portal.getByBlock(block);
|
||||
if (portal == null) return;
|
||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
onButtonPressed(player, portal);
|
||||
@ -744,7 +753,7 @@ public class Stargate extends JavaPlugin {
|
||||
if (portal == null) return;
|
||||
|
||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -759,7 +768,7 @@ public class Stargate extends JavaPlugin {
|
||||
Portal portal = Portal.getByBlock(block);
|
||||
if (portal == null) return;
|
||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||
Stargate.sendMessage(player, denyMsg);
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
onButtonPressed(player, portal);
|
||||
@ -779,7 +788,7 @@ public class Stargate extends JavaPlugin {
|
||||
// Not creating a gate, just placing a sign
|
||||
if (portal == null) return;
|
||||
|
||||
Stargate.sendMessage(player, regMsg, false);
|
||||
Stargate.sendMessage(player, Stargate.getString("createMsg"), false);
|
||||
Stargate.debug("onSignChange", "Initialized stargate: " + portal.getName());
|
||||
Stargate.server.getScheduler().scheduleSyncDelayedTask(stargate, new Runnable() {
|
||||
public void run() {
|
||||
@ -818,14 +827,18 @@ public class Stargate extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (cost > 0) {
|
||||
Stargate.sendMessage(player, "Deducted " + iConomyHandler.format(cost), false);
|
||||
String deductMsg = Stargate.getString("ecoDeduct");
|
||||
deductMsg = Stargate.replaceVars(deductMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(cost)});
|
||||
sendMessage(player, deductMsg, false);
|
||||
} else if (cost < 0) {
|
||||
Stargate.sendMessage(player, "Refunded " + iConomyHandler.format(-cost), false);
|
||||
String refundMsg = Stargate.getString("ecoRefund");
|
||||
refundMsg = Stargate.replaceVars(refundMsg, new String[] {"%cost%"}, new String[] {iConomyHandler.format(-cost)});
|
||||
sendMessage(player, refundMsg, false);
|
||||
}
|
||||
}
|
||||
|
||||
portal.unregister(true);
|
||||
Stargate.sendMessage(player, dmgMsg, false);
|
||||
Stargate.sendMessage(player, Stargate.getString("destroyMsg"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1030,6 +1043,7 @@ public class Stargate extends JavaPlugin {
|
||||
// Reload data
|
||||
reloadConfig();
|
||||
reloadGates();
|
||||
lang.reload();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
21
src/net/TheDgtl/Stargate/resources/en.txt
Normal file
21
src/net/TheDgtl/Stargate/resources/en.txt
Normal file
@ -0,0 +1,21 @@
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Teleported
|
||||
destroyMsg=Gate Destroyed
|
||||
invalidMsg=Invalid Destination
|
||||
blockMsg=Destination Blocked
|
||||
destEmpty=Destination List Empty
|
||||
denyMsg=Access Denied
|
||||
|
||||
ecoDeduct=Deducted %cost%
|
||||
ecoRefund=Redunded %cost%
|
||||
ecoObtain=Obtained %cost$ from Stargate %portal%
|
||||
ecoInFunds=Insufficient Funds
|
||||
|
||||
createMsg=Gate Created
|
||||
createNetDeny=You do not have access to that network
|
||||
createPersonal=Creating gate on personal network
|
||||
createNameLength=Name too short or too long.
|
||||
createExists=A gate by that name already exists
|
||||
createFull=This network is full
|
||||
createWorldDeny=You do not have access to that world
|
||||
createConflict=Gate conflicts with existing gate
|
@ -1,6 +1,6 @@
|
||||
name: Stargate
|
||||
main: net.TheDgtl.Stargate.Stargate
|
||||
version: 0.6.4
|
||||
version: 0.6.5
|
||||
description: Stargate mod for Bukkit
|
||||
author: Drakia
|
||||
website: http://www.thedgtl.net
|
||||
|
Loading…
Reference in New Issue
Block a user