mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-12 03:13:40 +01:00
Updated for iConomy 3.0
This commit is contained in:
parent
2d06a40127
commit
e54b201aa5
BIN
lib/iConomy.jar
BIN
lib/iConomy.jar
Binary file not shown.
@ -34,9 +34,12 @@
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEvent;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import com.nijiko.iConomy.configuration.PropertyHandler;
|
||||
import com.nijikokun.bukkit.iConomy.iConomy;
|
||||
import com.sk89q.bukkit.migration.PermissionsResolverManager;
|
||||
import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
@ -79,7 +82,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
public Set<String> amphibiousPlayers = new HashSet<String>();
|
||||
public boolean fireSpreadDisableToggle;
|
||||
|
||||
public boolean isiConomyEnabled = false;
|
||||
public static iConomy iConomy;
|
||||
|
||||
// Configuration follows
|
||||
public boolean suppressTickSyncWarnings;
|
||||
@ -151,7 +154,6 @@ public void onEnable() {
|
||||
loadConfiguration();
|
||||
postReload();
|
||||
registerEvents();
|
||||
checkiConomy();
|
||||
|
||||
if (suppressTickSyncWarnings) {
|
||||
Logger.getLogger("Minecraft").setFilter(new TickSyncDelayLoggerFilter());
|
||||
@ -208,16 +210,11 @@ private void registerEvents() {
|
||||
/**
|
||||
* Check if iConomy is enabled on this server
|
||||
*/
|
||||
public boolean checkiConomy() {
|
||||
Plugin test = this.getServer().getPluginManager().getPlugin("iConomy");
|
||||
|
||||
if (test != null) {
|
||||
this.isiConomyEnabled = true;
|
||||
} else {
|
||||
this.isiConomyEnabled = false;
|
||||
public void onPluginEnabled(PluginEvent event) {
|
||||
if(event.getPlugin().getDescription().getName().equals("iConomy")) {
|
||||
this.iConomy = (iConomy)event.getPlugin();
|
||||
logger.info("WorldGuard: Attached to iConomy.");
|
||||
}
|
||||
|
||||
return isiConomyEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,10 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
sender.sendMessage("Only players may use this command");
|
||||
return true;
|
||||
}
|
||||
if (wg.iConomy == null) {
|
||||
sender.sendMessage("iConomy is not installed on this Server.");
|
||||
return true;
|
||||
}
|
||||
String id = args[0];
|
||||
Player player = (Player) sender;
|
||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
@ -57,9 +61,9 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (args[1] == "info") {
|
||||
player.sendMessage(ChatColor.YELLOW + "Region " + id + " costs " +
|
||||
iConomy.Misc.formatCurrency(flags.getIntFlag("iconomy", "price"), iConomy.currency));
|
||||
if (iConomy.db.has_balance(player.getName())) {
|
||||
if (iConomy.database.hasBalance(player.getName())) {
|
||||
player.sendMessage(ChatColor.YELLOW + "You have " +
|
||||
iConomy.Misc.formatCurrency(iConomy.db.get_balance(player.getName()), iConomy.currency));
|
||||
iConomy.Misc.formatCurrency((int)Math.round(iConomy.database.getBalance(player.getName())), iConomy.currency));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + "You have not enough money.");
|
||||
}
|
||||
@ -67,12 +71,12 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
player.sendMessage(ChatColor.RED + "Usage: /buyregion <region id> (info)");
|
||||
}
|
||||
} else {
|
||||
if (iConomy.db.has_balance(player.getName())) {
|
||||
int balance = iConomy.db.get_balance(player.getName());
|
||||
if (iConomy.database.hasBalance(player.getName())) {
|
||||
double balance = iConomy.database.getBalance(player.getName());
|
||||
int regionPrice = flags.getIntFlag("iconomy", "price");
|
||||
|
||||
if (balance >= regionPrice) {
|
||||
iConomy.db.set_balance(player.getName(), balance - regionPrice);
|
||||
iConomy.database.setBalance(player.getName(), balance - regionPrice);
|
||||
player.sendMessage(ChatColor.YELLOW + "You have bought the region " + id + " for " +
|
||||
iConomy.Misc.formatCurrency(regionPrice, iConomy.currency));
|
||||
}
|
||||
|
@ -105,19 +105,19 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
|
||||
region.getOwners().addPlayer(player.getName());
|
||||
|
||||
if (wg.useiConomy && wg.buyOnClaim) {
|
||||
if (iConomy.db.has_balance(player.getName())) {
|
||||
int balance = iConomy.db.get_balance(player.getName());
|
||||
if (wg.iConomy != null && wg.useiConomy && wg.buyOnClaim) {
|
||||
if (iConomy.database.hasBalance(player.getName())) {
|
||||
double balance = iConomy.database.getBalance(player.getName());
|
||||
int regionCosts = region.countBlocks() * wg.buyOnClaimPrice;
|
||||
if (balance >= regionCosts) {
|
||||
iConomy.db.set_balance(player.getName(), balance - regionCosts);
|
||||
iConomy.database.setBalance(player.getName(), balance - regionCosts);
|
||||
player.sendMessage(ChatColor.YELLOW + "You have bought that region for " +
|
||||
iConomy.Misc.formatCurrency(regionCosts, iConomy.currency));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "You have not enough money.");
|
||||
player.sendMessage(ChatColor.RED + "The region you want to claim costs " +
|
||||
iConomy.Misc.formatCurrency(regionCosts, iConomy.currency));
|
||||
player.sendMessage(ChatColor.RED + "You have " + iConomy.Misc.formatCurrency(balance, iConomy.currency));
|
||||
player.sendMessage(ChatColor.RED + "You have " + iConomy.Misc.formatCurrency((int)Math.round(balance), iConomy.currency));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user