Updated for iConomy 4.0

This commit is contained in:
DarkLiKally 2011-02-27 09:54:43 +01:00
parent dc637d0f2b
commit 2092cc43b3
9 changed files with 18 additions and 76 deletions

Binary file not shown.

View File

@ -18,7 +18,7 @@
*/
package com.sk89q.worldguard.bukkit;
import com.nijikokun.bukkit.iConomy.iConomy;
import com.nijiko.coelho.iConomy.iConomy;
import com.sk89q.bukkit.migration.PermissionsResolverManager;
import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
import com.sk89q.worldedit.Vector;

View File

@ -18,7 +18,7 @@
*/
package com.sk89q.worldguard.bukkit;
import com.nijikokun.bukkit.iConomy.iConomy;
import com.nijiko.coelho.iConomy.iConomy;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import com.sk89q.worldguard.blacklist.events.ItemAcquireBlacklistEvent;

View File

@ -44,8 +44,6 @@ public class WorldGuardPlugin extends JavaPlugin {
new WorldGuardBlockListener(this);
private final WorldGuardEntityListener entityListener =
new WorldGuardEntityListener(this);
private final WorldGuardServerListener serverListener =
new WorldGuardServerListener(this);
private final CommandHandler commandHandler = new CommandHandler(this);
private final GlobalRegionManager globalRegionManager = new GlobalRegionManager(this);
@ -104,8 +102,6 @@ private void registerEvents() {
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.High, this);
pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
// 25 equals about 1s real time
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new TimedFlagsTimer(this), 25 * 5, 25 * 5);
}

View File

@ -1,53 +0,0 @@
// $Id$
/*
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.bukkit;
import org.bukkit.event.server.PluginEvent;
import org.bukkit.event.server.ServerListener;
import com.nijikokun.bukkit.iConomy.iConomy;
/**
*
* @author DarkLiKally
*/
public class WorldGuardServerListener extends ServerListener {
/**
* Plugin.
*/
private WorldGuardPlugin plugin;
/**
* Construct the object;
*
* @param plugin
*/
public WorldGuardServerListener(WorldGuardPlugin plugin) {
this.plugin = plugin;
}
@Override
public void onPluginEnabled(PluginEvent event) {
if(event.getPlugin().getDescription().getName().equals("iConomy")) {
plugin.getWgConfiguration().setiConomy((iConomy)event.getPlugin());
}
}
}

View File

@ -91,7 +91,7 @@ public class WorldGuardWorldConfiguration {
public String blockCreatureSpawn;
public boolean useiConomy;
public boolean buyOnClaim;
public int buyOnClaimPrice;
public double buyOnClaimPrice;
public int maxClaimVolume;
/* Configuration data end */
@ -205,7 +205,7 @@ private void loadConfiguration() {
useiConomy = config.getBoolean("iconomy.enable", false);
buyOnClaim = config.getBoolean("iconomy.buy-on-claim", false);
buyOnClaimPrice = config.getInt("iconomy.buy-on-claim-price", 1);
buyOnClaimPrice = config.getDouble("iconomy.buy-on-claim-price", 1.0);
blockCreatureSpawn = "";
for (String creature : config.getStringList("mobs.block-creature-spawn", null)) {

View File

@ -22,8 +22,8 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.nijikokun.bukkit.iConomy.Account;
import com.nijikokun.bukkit.iConomy.iConomy;
import com.nijiko.coelho.iConomy.iConomy;
import com.nijiko.coelho.iConomy.system.*;
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
@ -63,12 +63,11 @@ public boolean handle(CommandSender sender, String senderName, String command, S
if (args.length == 2) {
if (args[1] == "info") {
player.sendMessage(ChatColor.YELLOW + "Region " + id + " costs " +
iConomy.Misc.formatCurrency(flags.getIntFlag("iconomy", "price"), iConomy.currency));
iConomy.getBank().format(flags.getDoubleFlag("iconomy", "price")));
if (iConomy.getBank().hasAccount(player.getName())) {
player.sendMessage(ChatColor.YELLOW + "You have " +
iConomy.Misc.formatCurrency(
(int)Math.round(iConomy.getBank().getAccount(player.getName()).getBalance()),
iConomy.currency));
iConomy.getBank().format(
iConomy.getBank().getAccount(player.getName()).getBalance()));
} else {
player.sendMessage(ChatColor.YELLOW + "You have not enough money.");
}
@ -84,7 +83,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
if (balance >= regionPrice) {
account.subtract(regionPrice);
player.sendMessage(ChatColor.YELLOW + "You have bought the region " + id + " for " +
iConomy.Misc.formatCurrency(regionPrice, iConomy.currency));
iConomy.getBank().format(regionPrice));
DefaultDomain owners = region.getOwners();
owners.addPlayer(player.getName());
region.setOwners(owners);

View File

@ -34,8 +34,9 @@
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.nijikokun.bukkit.iConomy.Account;
import com.nijikokun.bukkit.iConomy.iConomy;
import com.nijiko.coelho.iConomy.*;
import com.nijiko.coelho.iConomy.system.*;
import java.io.IOException;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -116,18 +117,17 @@ public boolean handle(CommandSender sender, String senderName, String command, S
if (iConomy.getBank().hasAccount(player.getName())) {
Account account = iConomy.getBank().getAccount(player.getName());
double balance = account.getBalance();
int regionCosts = region.countBlocks() * wcfg.buyOnClaimPrice;
double regionCosts = region.countBlocks() * wcfg.buyOnClaimPrice;
if (balance >= regionCosts) {
account.subtract(regionCosts);
player.sendMessage(ChatColor.YELLOW + "You have bought that region for " +
iConomy.Misc.formatCurrency(regionCosts, iConomy.currency));
iConomy.getBank().format(regionCosts));
account.save();
} 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(
(int)Math.round(balance), iConomy.currency));
iConomy.getBank().format(regionCosts));
player.sendMessage(ChatColor.RED + "You have " + iConomy.getBank().format(balance));
return true;
}
} else {

View File

@ -57,7 +57,7 @@ public static enum FlagValueType { STRING, BOOLEAN, INT, FLOAT, DOUBLE, STATE, L
flagList.add(new FlagInfo("chest", null, FlagValueType.STATE, "states", "chest"));
flagList.add(new FlagInfo("waterflow", null, FlagValueType.STATE, "states", "waterflow"));
flagList.add(new FlagInfo("iconomy", "buyable", FlagValueType.BOOLEAN, "iconomy", "buyable"));
flagList.add(new FlagInfo("iconomy", "price", FlagValueType.INT, "iconomy", "price"));
flagList.add(new FlagInfo("iconomy", "price", FlagValueType.DOUBLE, "iconomy", "price"));
flagList.add(new FlagInfo("spawn", "set", FlagValueType.LOCATION, "spawn", ""));
flagList.add(new FlagInfo("spawn", "delete", FlagValueType.LOCATION, "spawn", ""));
flagList.add(new FlagInfo("spawn", "allow", FlagValueType.STRING, "spawn", "allow"));