Carts with no player can now go through gates.

You can set gates to send their cost to their owner.
Cleaned up the iConomy code a bit, messages should only be shown on
actual deduction now.
Created separate 'stargate.free.{use/create/destroy}' permissions.
This commit is contained in:
Drakia 2011-04-08 00:42:34 -07:00
parent 91bf4e25ef
commit 2d97b497d8
5 changed files with 133 additions and 106 deletions

14
README
View File

@ -9,7 +9,7 @@ iConomy support added back in, only costs are create, destroy and use.
============= =============
Known Issues Known Issues
============= =============
- There are many bugs with portal material not showing properly. This is a bug I can not track down, and have no fix for at the moment. Hmm.. None?
============= =============
Permissions Permissions
@ -17,12 +17,13 @@ Known Issues
- stargate.use - Allow this player/group to use stargates. - stargate.use - Allow this player/group to use stargates.
- stargate.create - Allow this player/group to create new stargates. - stargate.create - Allow this player/group to create new stargates.
- stargate.create.personal - Allow this player/group to create new stargates on a network defined as their name. - stargate.create.personal - Allow this player/group to create new stargates on a network defined as their name.
- stargate.destroy - Allow this player/group to destroy existing stargates. (Deprecated)
- stargate.destroy.all - Allow this player/group to destroy any existing stargate (Replaces stargate.destroy) - stargate.destroy.all - Allow this player/group to destroy any existing stargate (Replaces stargate.destroy)
- stargate.destroy.owner - Allow this player/group to destroy any stargate that they are the owner of. - stargate.destroy.owner - Allow this player/group to destroy any stargate that they are the owner of.
- stargate.hidden - Allow this player/group to see all hidden stargates. - stargate.hidden - Allow this player/group to see all hidden stargates.
- stargate.private - Allow this player/group to use all private stargates. - stargate.private - Allow this player/group to use all private stargates.
- stargate.free - This player/group is not charged to use gates even if the gate has a cost. - stargate.free.use - This player/group is not charged to use gates even if the gate has a cost.
- stargate.free.create - This player/group is not charged to create gates even if the gate has a cost.
- stargate.free.destroy - This player/group is not charged to destroy gates even if the gate has a cost.
- stargate.world.{worldname} - Allow this user/group access to gates on the world {worldname} - stargate.world.{worldname} - Allow this user/group access to gates on the world {worldname}
- stargate.network.{networkname} - Allow this user/group access to the network {networkname} - stargate.network.{networkname} - Allow this user/group access to the network {networkname}
@ -115,10 +116,17 @@ usecost - The cost to use a stargate
not-enough-money-message - The message displayed if a player lacks money to do something 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. 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. worldfilter - Whether or not to disallow users access to a network if they don't have the 'stargate.world.{worldname}' permission.
toowner - Whether the money from gate-use goes to the owner or nobody
============= =============
Changes Changes
============= =============
[Version 0.4.0]
- Carts with no player can now go through gates.
- You can set gates to send their cost to their owner.
- Per-gate layout option for "toOwner".
- Cleaned up the iConomy code a bit, messages should only be shown on actual deduction now.
- Created separate 'stargate.free.{use/create/destroy}' permissions.
[Version 0.3.5] [Version 0.3.5]
- Added 'stargate.world.*' permissions - Added 'stargate.world.*' permissions
- Added 'stargate.network.*' permissions - Added 'stargate.network.*' permissions

View File

@ -24,6 +24,8 @@ import org.bukkit.material.Button;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.nijiko.coelho.iConomy.iConomy;
/** /**
* Portal.java - Plug-in for hey0's minecraft mod. * Portal.java - Plug-in for hey0's minecraft mod.
* @author Shaun (sturmeh) * @author Shaun (sturmeh)
@ -244,10 +246,10 @@ public class Portal {
newVelocity.multiply(velocity); newVelocity.multiply(velocity);
final Entity passenger = vehicle.getPassenger(); final Entity passenger = vehicle.getPassenger();
if (passenger != null) {
vehicle.eject(); vehicle.eject();
vehicle.remove(); vehicle.remove();
final Minecart mc = exit.getWorld().spawnMinecart(exit); final Minecart mc = exit.getWorld().spawnMinecart(exit);
if (passenger != null) {
passenger.teleport(exit); passenger.teleport(exit);
Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() { Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
public void run() { public void run() {
@ -256,7 +258,8 @@ public class Portal {
} }
}, 1); }, 1);
} else { } else {
mc.setVelocity(newVelocity); vehicle.teleport(exit);
vehicle.setVelocity(newVelocity);
} }
} }
@ -641,12 +644,16 @@ public class Portal {
return null; return null;
} }
if (iConomyHandler.useiConomy() && !Stargate.hasPerm(player, "stargate.free", player.isOp()) && !iConomyHandler.chargePlayer(player.getName(), null, gate.getCreateCost())) { if (iConomyHandler.useiConomy() && !Stargate.hasPerm(player, "stargate.free.create", player.isOp())) {
if (!iConomyHandler.chargePlayer(player.getName(), null, gate.getCreateCost())) {
if (!iConomyHandler.inFundMsg.isEmpty()) { if (!iConomyHandler.inFundMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg); player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
} }
return null; return null;
} }
if (gate.getCreateCost() > 0)
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(gate.getCreateCost()));
}
Portal portal = null; Portal portal = null;

View File

@ -119,9 +119,6 @@ public class Stargate extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
//pm.registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Normal, this);
//pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
//pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.VEHICLE_MOVE, vehicleListener, Priority.Normal, this); pm.registerEvent(Event.Type.VEHICLE_MOVE, vehicleListener, Priority.Normal, this);
@ -131,7 +128,7 @@ public class Stargate extends JavaPlugin {
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
// iConomy Loading // Dependency Loading
pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this); pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
pm.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Priority.Monitor, this); pm.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Priority.Monitor, this);
@ -158,6 +155,7 @@ public class Stargate extends JavaPlugin {
iConomyHandler.destroyCost = config.getInt("destroycost", iConomyHandler.destroyCost); iConomyHandler.destroyCost = config.getInt("destroycost", iConomyHandler.destroyCost);
iConomyHandler.useCost = config.getInt("usecost", iConomyHandler.useCost); iConomyHandler.useCost = config.getInt("usecost", iConomyHandler.useCost);
iConomyHandler.inFundMsg = config.getString("not-enough-money-message", iConomyHandler.inFundMsg); iConomyHandler.inFundMsg = config.getString("not-enough-money-message", iConomyHandler.inFundMsg);
iConomyHandler.toOwner = config.getBoolean("toowner", iConomyHandler.toOwner);
saveConfig(); saveConfig();
} }
@ -181,6 +179,7 @@ public class Stargate extends JavaPlugin {
config.setProperty("destroycost", iConomyHandler.destroyCost); config.setProperty("destroycost", iConomyHandler.destroyCost);
config.setProperty("usecost", iConomyHandler.useCost); config.setProperty("usecost", iConomyHandler.useCost);
config.setProperty("not-enough-money-message", iConomyHandler.inFundMsg); config.setProperty("not-enough-money-message", iConomyHandler.inFundMsg);
config.setProperty("toowner", iConomyHandler.toOwner);
config.save(); config.save();
} }
@ -238,7 +237,7 @@ public class Stargate extends JavaPlugin {
Portal destination = gate.getDestination(); Portal destination = gate.getDestination();
if (!gate.isOpen()) { if (!gate.isOpen()) {
if (!gate.isFree() && !hasPerm(player, "stargate.free", player.isOp()) && if (!gate.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()) &&
iConomyHandler.useiConomy() && iConomyHandler.getBalance(player.getName()) < gate.getGate().getUseCost()) { iConomyHandler.useiConomy() && iConomyHandler.getBalance(player.getName()) < gate.getGate().getUseCost()) {
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg); player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
} else if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) { } else if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
@ -311,10 +310,15 @@ public class Stargate extends JavaPlugin {
Portal dest = portal.getDestination(); Portal dest = portal.getDestination();
if (dest == null) return; if (dest == null) return;
if (portal.isFree() || !iConomyHandler.useiConomy() || hasPerm(player, "stargate.free", player.isOp()) || boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
iConomyHandler.chargePlayer(player.getName(), null, portal.getGate().getUseCost())) {
if (!portal.isFree() && iConomyHandler.useiConomy()) { if (!iConCharge || iConomyHandler.chargePlayer(player.getName(), portal.getOwner(), portal.getGate().getUseCost())) {
if (iConCharge && portal.getGate().getUseCost() > 0) {
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getUseCost())); player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getUseCost()));
Player p = server.getPlayer(portal.getOwner());
if (iConomyHandler.toOwner && p != null && !portal.getOwner().equals(player.getName()))
p.sendMessage(ChatColor.GREEN + "Obtained " + iConomy.getBank().format(portal.getGate().getUseCost()) + " from Stargate " + portal.getName());
} }
if (!teleMsg.isEmpty()) { if (!teleMsg.isEmpty()) {
player.sendMessage(ChatColor.BLUE + teleMsg); player.sendMessage(ChatColor.BLUE + teleMsg);
@ -326,6 +330,10 @@ public class Stargate extends JavaPlugin {
} }
} }
portal.close(false); portal.close(false);
} else {
Portal dest = portal.getDestination();
if (dest == null) return;
dest.teleport(vehicle, portal);
} }
} }
} }
@ -337,14 +345,26 @@ public class Stargate extends JavaPlugin {
Portal portal = Portal.getByEntrance(event.getTo()); Portal portal = Portal.getByEntrance(event.getTo());
if ((portal != null) && (portal.isOpen())) { if ((portal != null) && (portal.isOpen())) {
if (portal.isOpenFor(player)) { if (!portal.isOpenFor(player)) {
Portal destination = portal.getDestination(); if (!denyMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + denyMsg);
}
return;
}
if (destination != null) { Portal destination = portal.getDestination();
if (portal.isFree() || !iConomyHandler.useiConomy() || hasPerm(player, "stargate.free", player.isOp()) || if (destination == null) return;
iConomyHandler.chargePlayer(player.getName(), null, portal.getGate().getUseCost())) {
if (!portal.isFree() && iConomyHandler.useiConomy()) { boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
if (!iConCharge || iConomyHandler.chargePlayer(player.getName(), portal.getOwner(), portal.getGate().getUseCost())) {
if (iConCharge && portal.getGate().getUseCost() > 0) {
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getUseCost())); player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getUseCost()));
Player p = server.getPlayer(portal.getOwner());
if (iConomyHandler.toOwner && p != null && !portal.getOwner().equals(player.getName())) {
p.sendMessage(ChatColor.GREEN + "Obtained " + iConomy.getBank().format(portal.getGate().getUseCost()) + " from Stargate " + portal.getName());
}
} }
if (!teleMsg.isEmpty()) { if (!teleMsg.isEmpty()) {
player.sendMessage(ChatColor.BLUE + teleMsg); player.sendMessage(ChatColor.BLUE + teleMsg);
@ -358,12 +378,6 @@ public class Stargate extends JavaPlugin {
} }
portal.close(false); portal.close(false);
} }
} else {
if (!denyMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + denyMsg);
}
}
}
} }
@Override @Override
@ -446,9 +460,6 @@ public class Stargate extends JavaPlugin {
Portal portal = Portal.createPortal(sign, player); Portal portal = Portal.createPortal(sign, player);
if (portal == null) return; if (portal == null) return;
if (iConomyHandler.useiConomy()) {
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getCreateCost()));
}
if (!regMsg.isEmpty()) { if (!regMsg.isEmpty()) {
player.sendMessage(ChatColor.GREEN + regMsg); player.sendMessage(ChatColor.GREEN + regMsg);
} }
@ -476,15 +487,15 @@ public class Stargate extends JavaPlugin {
if (hasPerm(player, "stargate.destroy", player.isOp()) || hasPerm(player, "stargate.destroy.all", player.isOp()) || 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) )) { ( portal.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) {
// Can't afford // Can't afford
if (iConomyHandler.useiConomy()) { if (iConomyHandler.useiConomy() && !hasPerm(player, "stargate.free.destroy", player.isOp())) {
if(iConomyHandler.getBalance(player.getName()) < portal.getGate().getDestroyCost()) { if (!iConomyHandler.chargePlayer(player.getName(), null, portal.getGate().getDestroyCost())) {
if (!iConomyHandler.inFundMsg.isEmpty()) { if (!iConomyHandler.inFundMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg); player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
}
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
}
iConomyHandler.chargePlayer(player.getName(), null, portal.getGate().getDestroyCost());
if (portal.getGate().getDestroyCost() > 0) { if (portal.getGate().getDestroyCost() > 0) {
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getDestroyCost())); player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(portal.getGate().getDestroyCost()));
} else if (portal.getGate().getDestroyCost() < 0) { } else if (portal.getGate().getDestroyCost() < 0) {

View File

@ -11,6 +11,7 @@ public class iConomyHandler {
public static int createCost = 0; public static int createCost = 0;
public static int destroyCost = 0; public static int destroyCost = 0;
public static String inFundMsg = "Insufficient Funds."; public static String inFundMsg = "Insufficient Funds.";
public static boolean toOwner = false;
public static double getBalance(String player) { public static double getBalance(String player) {
if (useiConomy && iconomy != null) { if (useiConomy && iconomy != null) {
@ -36,7 +37,7 @@ public class iConomyHandler {
if (balance < amount) return false; if (balance < amount) return false;
acc.setBalance(balance - amount); acc.setBalance(balance - amount);
if (target != null) { if (toOwner && target != null && !player.equals(target)) {
Account tAcc = iConomy.getBank().getAccount(target); Account tAcc = iConomy.getBank().getAccount(target);
if (tAcc != null) { if (tAcc != null) {
balance = tAcc.getBalance(); balance = tAcc.getBalance();

View File

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