mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-22 18:46:45 +01:00
v0.93 - Economy support, entry fees, spectate-on-death, bugfixes
This commit is contained in:
parent
d1f2cb68dd
commit
753088bdc4
BIN
MobArena.jar
BIN
MobArena.jar
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: MobArena
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.92.4
|
||||
version: 0.93
|
||||
softdepend: [MultiVerse,XcraftGate]
|
||||
commands:
|
||||
ma:
|
||||
|
@ -7,6 +7,8 @@ JOIN_IN_OTHER_ARENA=Du er allerede i en arena. Forlad den først.
|
||||
JOIN_ARENA_NOT_ENABLED=Arenaen er deaktiveret.
|
||||
JOIN_ARENA_NOT_SETUP=Arenaen er ikke blevet sat op endnu.
|
||||
JOIN_ARENA_PERMISSION=Du har ikke rettigheder til den arena!
|
||||
JOIN_FEE_REQUIRED=Du er for fattig. Pris: %
|
||||
JOIN_FEE_PAID=Prisen for at joine var: %
|
||||
JOIN_ARENA_IS_RUNNING=Arenaen er allerede startet.
|
||||
JOIN_ALREADY_PLAYING=Du spiller allerede!
|
||||
JOIN_ARG_NEEDED=Arenanavn påkrævet. Skriv /ma arenas for en liste.
|
||||
|
@ -7,6 +7,8 @@ JOIN_IN_OTHER_ARENA=Vous êtes déjà dans l'arène! Quittez-la avant.
|
||||
JOIN_ARENA_NOT_ENABLED=Cetta arène n'est pas active.
|
||||
JOIN_ARENA_NOT_SETUP=Cette arène n'a pas encore été configurée.
|
||||
JOIN_ARENA_PERMISSION=Vous n'avez pas la permission pour rejoindre cette arène.
|
||||
JOIN_FEE_REQUIRED=Pas assez d'argent. Prix: %
|
||||
JOIN_FEE_PAID=Le prix pour rejoindre était de: %
|
||||
JOIN_ARENA_IS_RUNNING=L'arène est déjà occupée.
|
||||
JOIN_ALREADY_PLAYING=Vous êtes déjà en train de jouer.
|
||||
JOIN_ARG_NEEDED=Vous devez spécifier une arène. Entrez "/ma arenas" pour la liste.
|
||||
|
@ -7,6 +7,8 @@ JOIN_IN_OTHER_ARENA=Ye're already at sea, scallywag!
|
||||
JOIN_ARENA_NOT_ENABLED=We be swabbing down the decks on this ship, matey.
|
||||
JOIN_ARENA_NOT_SETUP=Arrrgh! We be missing the top sail!
|
||||
JOIN_ARENA_PERMISSION=Arrgh! Ye can't board this ship, scurvy dog!
|
||||
JOIN_FEE_REQUIRED=Ye don't own enough doubloons, matey! Price: %
|
||||
JOIN_FEE_PAID=Booty ye gave up to join: %
|
||||
JOIN_ARENA_IS_RUNNING=That ship has sailed, landlubber!
|
||||
JOIN_ALREADY_PLAYING=Ye be aboard already, ye scurvy dog!
|
||||
JOIN_ARG_NEEDED=Which ship are ye boarding? Type /ma arenas for a list, arrgh!
|
||||
|
@ -53,6 +53,7 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.garbagemule.MobArena.MAMessages.Msg;
|
||||
@ -65,11 +66,11 @@ public class Arena
|
||||
protected String name;
|
||||
protected World world;
|
||||
protected boolean enabled, protect, logging, running, setup, lobbySetup, autoEquip, forceRestore, softRestore, softRestoreDrops, emptyInvJoin, emptyInvSpec, pvp, monsterInfight, allowWarp;
|
||||
protected boolean edit, waveClear, detCreepers, detDamage, lightning, hellhounds;
|
||||
protected boolean edit, waveClear, detCreepers, detDamage, lightning, hellhounds, specOnDeath, shareInArena;
|
||||
protected Location p1, p2, l1, l2, arenaLoc, lobbyLoc, spectatorLoc;
|
||||
protected Map<String,Location> spawnpoints;
|
||||
|
||||
// Wave/reward fields
|
||||
// Wave/reward/entryfee fields
|
||||
protected int spawnTaskId, waveDelay, waveInterval, specialModulo, spawnMonstersInt, maxIdleTime;
|
||||
protected MASpawnThread spawnThread;
|
||||
protected Map<Integer,List<ItemStack>> everyWaveMap, afterWaveMap;
|
||||
@ -79,9 +80,10 @@ public class Arena
|
||||
protected Map<String,List<ItemStack>> classItems, classArmor;
|
||||
protected Map<Integer,Map<Player,List<ItemStack>>> classBonuses;
|
||||
protected Map<Player,List<ItemStack>> rewardMap;
|
||||
protected List<ItemStack> entryFee;
|
||||
|
||||
// Arena sets/maps
|
||||
protected Set<Player> livePlayers, deadPlayers, readyPlayers, specPlayers;
|
||||
protected Set<Player> livePlayers, deadPlayers, readyPlayers, specPlayers, waitPlayers, hasPaid;
|
||||
protected Set<LivingEntity> monsters;
|
||||
protected Set<Block> blocks;
|
||||
protected Set<Wolf> pets;
|
||||
@ -99,7 +101,6 @@ public class Arena
|
||||
|
||||
// Logging
|
||||
protected ArenaLog log;
|
||||
//protected List<String> log = new LinkedList<String>();
|
||||
protected List<String> classDistribution = new LinkedList<String>();
|
||||
protected Map<Player,Integer> waveMap = new HashMap<Player,Integer>();
|
||||
protected Map<Player,Integer> killMap = new HashMap<Player,Integer>();
|
||||
@ -123,6 +124,8 @@ public class Arena
|
||||
deadPlayers = new HashSet<Player>();
|
||||
readyPlayers = new HashSet<Player>();
|
||||
specPlayers = new HashSet<Player>();
|
||||
waitPlayers = new HashSet<Player>();
|
||||
hasPaid = new HashSet<Player>();
|
||||
monsters = new HashSet<LivingEntity>();
|
||||
blocks = new HashSet<Block>();
|
||||
pets = new HashSet<Wolf>();
|
||||
@ -151,10 +154,10 @@ public class Arena
|
||||
// Assign random classes, and if all get kicked, return.
|
||||
for (Player p : randoms)
|
||||
assignRandomClass(p);
|
||||
if (livePlayers.isEmpty()) return;
|
||||
if (livePlayers.isEmpty())
|
||||
return;
|
||||
|
||||
// Set the spawn flags to enable monster spawning.
|
||||
//MAUtils.setSpawnFlags(plugin, world, 1, true, true);
|
||||
MAUtils.setSpawnFlags(plugin, world, 1, allowMonsters, allowAnimals);
|
||||
|
||||
// Teleport players.
|
||||
@ -212,6 +215,8 @@ public class Arena
|
||||
{
|
||||
running = false;
|
||||
|
||||
MAUtils.tellAll(this, MAMessages.get(Msg.ARENA_END), true);
|
||||
|
||||
// Logging stuff
|
||||
if (logging)
|
||||
{
|
||||
@ -238,6 +243,7 @@ public class Arena
|
||||
// Clear all the sets and maps.
|
||||
livePlayers.clear();
|
||||
deadPlayers.clear();
|
||||
waitPlayers.clear();
|
||||
pets.clear();
|
||||
classMap.clear();
|
||||
rewardMap.clear();
|
||||
@ -250,7 +256,6 @@ public class Arena
|
||||
|
||||
// Set the spawn flags to restore monster spawning.
|
||||
MAUtils.setSpawnFlags(plugin, world, spawnMonsters, allowMonsters, allowAnimals);
|
||||
MAUtils.tellAll(this, MAMessages.get(Msg.ARENA_END));
|
||||
|
||||
// Notify listeners.
|
||||
for (MobArenaListener listener : plugin.getAM().listeners)
|
||||
@ -338,13 +343,16 @@ public class Arena
|
||||
boolean clear = false;
|
||||
|
||||
Location old = locations.get(p);
|
||||
Chunk chunk = old.getWorld().getChunkAt(old);
|
||||
if (!old.getWorld().isChunkLoaded(chunk))
|
||||
old.getWorld().loadChunk(chunk);
|
||||
else
|
||||
old.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
|
||||
p.teleport(old);
|
||||
if (old != null)
|
||||
{
|
||||
Chunk chunk = old.getWorld().getChunkAt(old);
|
||||
if (!old.getWorld().isChunkLoaded(chunk))
|
||||
old.getWorld().loadChunk(chunk);
|
||||
else
|
||||
old.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
|
||||
p.teleport(old);
|
||||
}
|
||||
locations.remove(p); // get, then remove, because of Teleport Event
|
||||
|
||||
// Only clear the inventory if the player has class items.
|
||||
@ -352,8 +360,13 @@ public class Arena
|
||||
if (livePlayers.remove(p)) clear = true;
|
||||
deadPlayers.remove(p);
|
||||
specPlayers.remove(p);
|
||||
hasPaid.remove(p);
|
||||
removePets(p);
|
||||
|
||||
// Update the monster targets.
|
||||
if (running && spawnThread != null)
|
||||
spawnThread.updateTargets();
|
||||
|
||||
// Clear inventory and record current wave
|
||||
if (clear)
|
||||
{
|
||||
@ -365,6 +378,9 @@ public class Arena
|
||||
if (!emptyInvJoin)
|
||||
MAUtils.restoreInventory(p);
|
||||
|
||||
// Grant rewards.
|
||||
MAUtils.giveRewards(p, rewardMap.remove(p), plugin);
|
||||
|
||||
if (running && livePlayers.isEmpty())
|
||||
endArena();
|
||||
else if (!readyPlayers.isEmpty() && readyPlayers.equals(livePlayers))
|
||||
@ -377,7 +393,7 @@ public class Arena
|
||||
|
||||
public void playerDeath(final Player p)
|
||||
{
|
||||
p.teleport(arenaLoc); // This will sometimes force players to drop any items held (not confirmed)
|
||||
p.teleport(arenaLoc); // This will sometimes force players to drop any items held (not confirmed)
|
||||
p.teleport(spectatorLoc);
|
||||
p.setFireTicks(0);
|
||||
p.setHealth(20);
|
||||
@ -386,18 +402,28 @@ public class Arena
|
||||
livePlayers.remove(p);
|
||||
deadPlayers.add(p);
|
||||
removePets(p);
|
||||
|
||||
// Update the monster targets.
|
||||
if (running && spawnThread != null)
|
||||
spawnThread.updateTargets();
|
||||
|
||||
// Has to be delayed for TombStone not to fuck shit up.
|
||||
if (running && livePlayers.isEmpty())
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable()
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
public void run()
|
||||
if (!specOnDeath)
|
||||
{
|
||||
MAUtils.restoreInventory(p);
|
||||
endArena();
|
||||
plugin.getAM().arenaMap.remove(p);
|
||||
playerLeave(p);
|
||||
}
|
||||
}, 10);
|
||||
else MAUtils.restoreInventory(p);
|
||||
|
||||
if (livePlayers.isEmpty())
|
||||
endArena();
|
||||
}
|
||||
}, 8);
|
||||
|
||||
MAUtils.tellAll(this, MAMessages.get(Msg.PLAYER_DIED, p.getName()));
|
||||
|
||||
@ -443,8 +469,8 @@ public class Arena
|
||||
return;
|
||||
}
|
||||
|
||||
MAUtils.giveItems(p, classItems.get(className), autoEquip);
|
||||
MAUtils.giveItems(p, classArmor.get(className), autoEquip);
|
||||
MAUtils.giveItems(p, classItems.get(className), autoEquip, plugin);
|
||||
MAUtils.giveItems(p, classArmor.get(className), autoEquip, plugin);
|
||||
|
||||
int pets = MAUtils.getPetAmount(p);
|
||||
if (pets > 0) petMap.put(p, pets);
|
||||
@ -456,7 +482,7 @@ public class Arena
|
||||
List<String> classes = new LinkedList<String>(plugin.getAM().classes);
|
||||
|
||||
String className = classes.remove(r.nextInt(classes.size()));
|
||||
while (!MobArena.has(p, "mobarena.classes." + className))
|
||||
while (!plugin.has(p, "mobarena.classes." + className))
|
||||
{
|
||||
if (classes.isEmpty())
|
||||
{
|
||||
@ -476,7 +502,7 @@ public class Arena
|
||||
for (Map.Entry<Player,List<ItemStack>> entry : rewardMap.entrySet())
|
||||
{
|
||||
MAUtils.tellPlayer(entry.getKey(), MAMessages.get(Msg.REWARDS_GIVE));
|
||||
MAUtils.giveRewards(entry.getKey(), entry.getValue());
|
||||
MAUtils.giveRewards(entry.getKey(), entry.getValue(), plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -506,14 +532,22 @@ public class Arena
|
||||
private void removePets()
|
||||
{
|
||||
for (Wolf w : pets)
|
||||
{
|
||||
w.setOwner(null);
|
||||
w.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void removePets(Player p)
|
||||
{
|
||||
for (Wolf w : pets)
|
||||
if (((Player) w.getOwner()).getName().equals(p.getName()))
|
||||
w.remove();
|
||||
{
|
||||
if (!((Player) w.getOwner()).getName().equals(p.getName()))
|
||||
continue;
|
||||
|
||||
w.setOwner(null);
|
||||
w.remove();
|
||||
}
|
||||
petMap.remove(p);
|
||||
}
|
||||
|
||||
@ -561,6 +595,8 @@ public class Arena
|
||||
pvp = config.getBoolean(arenaPath + "pvp-enabled", false);
|
||||
monsterInfight = config.getBoolean(arenaPath + "monster-infight", false);
|
||||
allowWarp = config.getBoolean(arenaPath + "allow-teleporting", false);
|
||||
specOnDeath = config.getBoolean(arenaPath + "spectate-on-death", true);
|
||||
shareInArena = config.getBoolean(arenaPath + "share-items-in-arena", true);
|
||||
joinDistance = config.getInt(arenaPath + "max-join-distance", 0);
|
||||
playerLimit = config.getInt(arenaPath + "player-limit", 0);
|
||||
repairDelay = config.getInt(arenaPath + "repair-delay", 5);
|
||||
@ -573,6 +609,7 @@ public class Arena
|
||||
distSpecial = MAUtils.getArenaDistributions(config, configName, "special");
|
||||
everyWaveMap = MAUtils.getArenaRewardMap(config, configName, "every");
|
||||
afterWaveMap = MAUtils.getArenaRewardMap(config, configName, "after");
|
||||
entryFee = MAUtils.getEntryFee(config, configName);
|
||||
|
||||
p1 = MAUtils.getArenaCoord(config, world, configName, "p1");
|
||||
p2 = MAUtils.getArenaCoord(config, world, configName, "p2");
|
||||
@ -833,9 +870,7 @@ public class Arena
|
||||
for (Block b : event.blockList())
|
||||
{
|
||||
if (!(b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -966,7 +1001,7 @@ public class Arena
|
||||
event.getDrops().clear();
|
||||
waveMap.put(p, spawnThread.wave - 1);
|
||||
playerDeath(p);
|
||||
p.getInventory().clear(); // For TombStone
|
||||
//p.getInventory().clear(); // For TombStone
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1049,7 +1084,7 @@ public class Arena
|
||||
// Lobby Listener
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (running) return;
|
||||
if (running && shareInArena) return;
|
||||
|
||||
Player p = event.getPlayer();
|
||||
if (!livePlayers.contains(p))
|
||||
@ -1134,7 +1169,7 @@ public class Arena
|
||||
if (!classes.contains(className) && !className.equalsIgnoreCase("random"))
|
||||
return;
|
||||
|
||||
if (!MobArena.hasDefTrue(p, "mobarena.classes." + className) && !className.equalsIgnoreCase("random"))
|
||||
if (!plugin.hasDefTrue(p, "mobarena.classes." + className) && !className.equalsIgnoreCase("random"))
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_CLASS_PERMISSION));
|
||||
return;
|
||||
@ -1188,7 +1223,7 @@ public class Arena
|
||||
Location to = event.getTo();
|
||||
Location from = event.getFrom();
|
||||
|
||||
if (livePlayers.contains(p))
|
||||
if (livePlayers.contains(p) || specPlayers.contains(p))
|
||||
{
|
||||
if (inRegion(from))
|
||||
{
|
||||
@ -1325,6 +1360,99 @@ public class Arena
|
||||
}, maxIdleTime);
|
||||
}
|
||||
|
||||
public void delayRestoreInventory(final Player p, final String method)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (method.equals("restoreInventory"))
|
||||
MAUtils.restoreInventory(p);
|
||||
else if (method.equals("giveRewards"))
|
||||
MAUtils.giveRewards(p, rewardMap.get(p), plugin);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
public boolean canAfford(Player p)
|
||||
{
|
||||
if (entryFee.isEmpty())
|
||||
return true;
|
||||
|
||||
PlayerInventory inv = p.getInventory();
|
||||
for (ItemStack stack : entryFee)
|
||||
{
|
||||
// Economy money
|
||||
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||
{
|
||||
if (plugin.Methods.hasMethod() && !plugin.Method.getAccount(p.getName()).hasEnough(stack.getAmount()))
|
||||
return false;
|
||||
}
|
||||
// Normal stack
|
||||
else
|
||||
{
|
||||
if (!inv.contains(stack.getTypeId(), stack.getAmount()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean takeFee(Player p)
|
||||
{
|
||||
if (entryFee.isEmpty())
|
||||
return true;
|
||||
|
||||
PlayerInventory inv = p.getInventory();
|
||||
for (ItemStack stack : entryFee)
|
||||
{
|
||||
// Economy money
|
||||
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||
{
|
||||
if (plugin.Methods.hasMethod() && !plugin.Method.getAccount(p.getName()).subtract(stack.getAmount()))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Normal stack
|
||||
else
|
||||
{
|
||||
int id = stack.getTypeId();
|
||||
int amount = stack.getAmount();
|
||||
|
||||
while (amount > 0)
|
||||
{
|
||||
int pos = inv.first(id);
|
||||
if (pos == -1) return false;
|
||||
|
||||
ItemStack is = inv.getItem(pos);
|
||||
if (is.getAmount() > amount)
|
||||
{
|
||||
is.setAmount(is.getAmount() - amount);
|
||||
amount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
amount -= is.getAmount();
|
||||
inv.setItem(pos, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasPaid.add(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void refund(Player p)
|
||||
{
|
||||
if (!hasPaid.contains(p))
|
||||
return;
|
||||
|
||||
MAUtils.giveItems(p, entryFee, false, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* The "perfect equals method" cf. "Object-Oriented Design and Patterns"
|
||||
* by Cay S. Horstmann.
|
||||
|
@ -97,7 +97,7 @@ public class ArenaLog
|
||||
// Kills
|
||||
buffy.append(MAUtils.padLeft(arena.killMap.remove(p).toString(), KILLS, ' ') + " ");
|
||||
// Rewards
|
||||
buffy.append(MAUtils.listToString(arena.rewardMap.get(p)));
|
||||
buffy.append(MAUtils.listToString(arena.rewardMap.get(p), plugin));
|
||||
log.add(buffy.toString());
|
||||
}
|
||||
|
||||
|
@ -257,6 +257,9 @@ public class ArenaMaster
|
||||
config.setProperty("arenas." + configName + ".settings.protect", true);
|
||||
config.save();
|
||||
config.load();
|
||||
config.setProperty("arenas." + configName + ".settings.entry-fee", "");
|
||||
config.save();
|
||||
config.load();
|
||||
config.setProperty("arenas." + configName + ".settings.logging", false);
|
||||
config.setProperty("arenas." + configName + ".settings.clear-wave-before-next", false);
|
||||
config.setProperty("arenas." + configName + ".settings.detonate-creepers", false);
|
||||
@ -272,6 +275,8 @@ public class ArenaMaster
|
||||
config.setProperty("arenas." + configName + ".settings.pvp-enabled", false);
|
||||
config.setProperty("arenas." + configName + ".settings.monster-infight", false);
|
||||
config.setProperty("arenas." + configName + ".settings.allow-teleporting", false);
|
||||
config.setProperty("arenas." + configName + ".settings.spectate-on-death", true);
|
||||
config.setProperty("arenas." + configName + ".settings.share-items-in-arena", true);
|
||||
config.save();
|
||||
config.load();
|
||||
config.setProperty("arenas." + configName + ".settings.player-limit", 0);
|
||||
|
@ -118,7 +118,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("join") || base.equals("j"))
|
||||
{
|
||||
if (!player || !MobArena.has(p, "mobarena.use.join"))
|
||||
if (!player || !plugin.has(p, "mobarena.use.join"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -150,12 +150,14 @@ public class MACommands implements CommandExecutor
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_ENABLED));
|
||||
else if (!arena.setup || arena.edit)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_SETUP));
|
||||
else if (arena.running)
|
||||
else if (arena.running && arena.waitPlayers.add(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
|
||||
else if (arena.livePlayers.contains(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
|
||||
else if (!MobArena.has(p, "mobarena.arenas." + arena.configName()))
|
||||
else if (!plugin.has(p, "mobarena.arenas." + arena.configName()))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_PERMISSION));
|
||||
else if (!arena.canAfford(p) || !arena.takeFee(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_FEE_REQUIRED, MAUtils.listToString(arena.entryFee, plugin)));
|
||||
else if (arena.playerLimit > 0 && arena.livePlayers.size() >= arena.playerLimit)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_LIMIT_REACHED));
|
||||
else if (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
||||
@ -168,12 +170,22 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
// If there was an error, don't join.
|
||||
if (error)
|
||||
{
|
||||
arena.refund(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If player is in a boat/minecart, eject!
|
||||
if (p.isInsideVehicle())
|
||||
p.leaveVehicle();
|
||||
|
||||
am.arenaMap.put(p,arena);
|
||||
arena.playerJoin(p, p.getLocation());
|
||||
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_JOINED));
|
||||
if (!arena.entryFee.isEmpty())
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_FEE_PAID, MAUtils.listToString(arena.entryFee, plugin)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -182,7 +194,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("leave") || base.equals("l"))
|
||||
{
|
||||
if (!player || !MobArena.has(p, "mobarena.use.leave"))
|
||||
if (!player || !plugin.has(p, "mobarena.use.leave"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -213,7 +225,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("spectate") || base.equals("spec"))
|
||||
{
|
||||
if (!player || !MobArena.has(p, "mobarena.use.spectate"))
|
||||
if (!player || !plugin.has(p, "mobarena.use.spectate"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -257,6 +269,10 @@ public class MACommands implements CommandExecutor
|
||||
if (error)
|
||||
return true;
|
||||
|
||||
// If player is in a boat/minecart, eject!
|
||||
if (p.isInsideVehicle())
|
||||
p.leaveVehicle();
|
||||
|
||||
am.arenaMap.put(p,arena);
|
||||
arena.playerSpec(p, p.getLocation());
|
||||
|
||||
@ -269,7 +285,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("arenas"))
|
||||
{
|
||||
String list = MAUtils.listToString(am.arenas);
|
||||
String list = MAUtils.listToString(am.arenas, plugin);
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_ARENAS, list));
|
||||
return true;
|
||||
}
|
||||
@ -288,7 +304,7 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
String list = MAUtils.listToString(arena.getLivingPlayers());
|
||||
String list = MAUtils.listToString(arena.getLivingPlayers(), plugin);
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, list));
|
||||
}
|
||||
else
|
||||
@ -297,7 +313,7 @@ public class MACommands implements CommandExecutor
|
||||
List<Player> players = new LinkedList<Player>();
|
||||
for (Arena arena : am.arenas)
|
||||
players.addAll(arena.getLivingPlayers());
|
||||
buffy.append(MAUtils.listToString(players));
|
||||
buffy.append(MAUtils.listToString(players, plugin));
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, buffy.toString()));
|
||||
}
|
||||
return true;
|
||||
@ -333,7 +349,7 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
String list = MAUtils.listToString(arena.getNonreadyPlayers());
|
||||
String list = MAUtils.listToString(arena.getNonreadyPlayers(), plugin);
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, list));
|
||||
return true;
|
||||
}
|
||||
@ -351,7 +367,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if ((base.equals("enable") || base.equals("disable")))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.enable")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.admin.enable")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -385,7 +401,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("restore"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.restore")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.admin.restore")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -412,7 +428,7 @@ public class MACommands implements CommandExecutor
|
||||
{
|
||||
if (arg1.equals("end"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.force.end")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.admin.force.end")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -446,7 +462,7 @@ public class MACommands implements CommandExecutor
|
||||
}
|
||||
else if (arg1.equals("start"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.force.start")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.admin.force.start")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -492,7 +508,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("config"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.config.reload")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.admin.config.reload")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -514,7 +530,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("arena"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.arena")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.arena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -540,7 +556,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("setarena"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.setarena")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.setarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -569,7 +585,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("addarena"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.addarena")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.addarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -597,7 +613,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("delarena"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.delarena")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.delarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -633,7 +649,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("protect"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.protect")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.protect")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -699,7 +715,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("editarena"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.editarena")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.editarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -768,7 +784,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("setregion"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.setregion")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.setregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -790,7 +806,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("expandregion"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.expandregion")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.expandregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -835,7 +851,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("showregion"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.showregion")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.showregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -887,7 +903,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("setlobbyregion"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.setlobbyregion")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.setlobbyregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -906,7 +922,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("expandlobbyregion"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.expandlobbyregion")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.expandlobbyregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -954,7 +970,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("setwarp"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.setwarp")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.setwarp")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -975,7 +991,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("spawnpoints"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.spawnpoints")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.spawnpoints")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -1006,7 +1022,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("addspawn"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.addspawn")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.addspawn")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -1027,7 +1043,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("delspawn"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.delspawn")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.delspawn")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -1047,7 +1063,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("auto-generate"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.autogenerate")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.autogenerate")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -1072,7 +1088,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("auto-degenerate"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.autodegenerate")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.autodegenerate")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -1102,7 +1118,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("dooooo") && arg1.equals("it") && arg2.equals("hippie") && arg3.equals("monster"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.autogenerate")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.autogenerate")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -1121,7 +1137,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("undo") && arg1.equals("it") && arg2.equals("hippie") && arg3.equals("monster"))
|
||||
{
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.autodegenerate")) && !op)
|
||||
if (!(player && plugin.has(p, "mobarena.setup.autodegenerate")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
|
@ -24,6 +24,8 @@ public class MAMessages
|
||||
JOIN_ARENA_NOT_ENABLED,
|
||||
JOIN_ARENA_NOT_SETUP,
|
||||
JOIN_ARENA_PERMISSION,
|
||||
JOIN_FEE_REQUIRED,
|
||||
JOIN_FEE_PAID,
|
||||
JOIN_ARENA_IS_RUNNING,
|
||||
JOIN_ALREADY_PLAYING,
|
||||
JOIN_ARG_NEEDED,
|
||||
@ -77,6 +79,8 @@ public class MAMessages
|
||||
defaults.put(Msg.JOIN_ARENA_NOT_ENABLED, "This arena is not enabled.");
|
||||
defaults.put(Msg.JOIN_ARENA_NOT_SETUP, "This arena has not been set up yet.");
|
||||
defaults.put(Msg.JOIN_ARENA_PERMISSION, "You don't have permission to join this arena.");
|
||||
defaults.put(Msg.JOIN_FEE_REQUIRED, "Insufficient funds. Price: %");
|
||||
defaults.put(Msg.JOIN_FEE_PAID, "Price to join was: %");
|
||||
defaults.put(Msg.JOIN_ARENA_IS_RUNNING, "This arena is in already progress.");
|
||||
defaults.put(Msg.JOIN_ALREADY_PLAYING, "You are already playing!");
|
||||
defaults.put(Msg.JOIN_ARG_NEEDED, "You must specify an arena. Type /ma arenas for a list.");
|
||||
@ -101,7 +105,7 @@ public class MAMessages
|
||||
defaults.put(Msg.FORCE_END_ENDED, "Forced arena end.");
|
||||
defaults.put(Msg.FORCE_END_IDLE, "You weren't quick enough!");
|
||||
defaults.put(Msg.REWARDS_GIVE, "Here are all of your rewards!");
|
||||
defaults.put(Msg.LOBBY_DROP_ITEM, "No sharing before the arena starts!");
|
||||
defaults.put(Msg.LOBBY_DROP_ITEM, "No sharing allowed at this time!");
|
||||
defaults.put(Msg.LOBBY_PLAYER_READY, "You have been flagged as ready!");
|
||||
defaults.put(Msg.LOBBY_PICK_CLASS, "You must first pick a class!");
|
||||
defaults.put(Msg.LOBBY_RIGHT_CLICK, "Punch the sign. Don't right-click.");
|
||||
|
@ -24,7 +24,7 @@ public class MAPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
{
|
||||
if (!am.enabled) return;
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onPlayerInteract(event);
|
||||
|
@ -41,7 +41,6 @@ public class MASpawnThread implements Runnable
|
||||
private Random random;
|
||||
private MobArena plugin;
|
||||
private Arena arena;
|
||||
private final double MIN_DISTANCE = 256;
|
||||
|
||||
public MASpawnThread(MobArena plugin, Arena arena)
|
||||
{
|
||||
@ -132,7 +131,21 @@ public class MASpawnThread implements Runnable
|
||||
ItemStack reward = MAUtils.getRandomReward(rewards);
|
||||
arena.rewardMap.get(p).add(reward);
|
||||
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WAVE_REWARD, MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount()));
|
||||
if (reward == null)
|
||||
{
|
||||
MAUtils.tellPlayer(p, "ERROR! Problem with economy rewards. Notify server host!");
|
||||
System.out.println("[MobArena] ERROR! Could not add null reward. Please check the config-file!");
|
||||
}
|
||||
else if (reward.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||
{
|
||||
if (plugin.Methods.hasMethod())
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WAVE_REWARD, plugin.Method.format(reward.getAmount())));
|
||||
else System.out.println("[MobArena] ERROR! No economy plugin detected!");
|
||||
}
|
||||
else
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WAVE_REWARD, MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,7 +212,6 @@ public class MASpawnThread implements Runnable
|
||||
else if (ran < dGhasts) mob = CreatureType.GHAST;
|
||||
else return;
|
||||
|
||||
// 5 on purpose - Ghasts act weird in Overworld.
|
||||
switch(mob)
|
||||
{
|
||||
case CREEPER:
|
||||
@ -308,7 +320,7 @@ public class MASpawnThread implements Runnable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (s.distanceSquared(p.getLocation()) > MIN_DISTANCE)
|
||||
if (s.distanceSquared(p.getLocation()) > MobArena.MIN_PLAYER_DISTANCE)
|
||||
continue;
|
||||
|
||||
result.add(s);
|
||||
@ -340,14 +352,14 @@ public class MASpawnThread implements Runnable
|
||||
{
|
||||
if (!arena.world.equals(p.getWorld()))
|
||||
{
|
||||
System.out.println("[MobArena] MASpawnThread:326: Player '" + p.getName() + "' is not in the right world. Force leaving...");
|
||||
System.out.println("[MobArena] MASpawnThread:329: Player '" + p.getName() + "' is not in the right world. Force leaving...");
|
||||
arena.playerLeave(p);
|
||||
MAUtils.tellPlayer(p, "You warped out of the arena world.");
|
||||
continue;
|
||||
}
|
||||
dist = p.getLocation().distanceSquared(e.getLocation());
|
||||
//double dist = MAUtils.distance(p.getLocation(), e.getLocation());
|
||||
if (dist < current && dist < MIN_DISTANCE)
|
||||
if (dist < current && dist < MobArena.MIN_PLAYER_DISTANCE)
|
||||
{
|
||||
current = dist;
|
||||
result = p;
|
||||
@ -355,4 +367,18 @@ public class MASpawnThread implements Runnable
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the targets of all monsters, if their targets aren't alive.
|
||||
*/
|
||||
public void updateTargets()
|
||||
{
|
||||
for (Entity e : arena.monsters)
|
||||
{
|
||||
if (arena.livePlayers.contains(((Creature) e).getTarget()))
|
||||
continue;
|
||||
|
||||
((Creature) e).setTarget(getClosestPlayer(e));
|
||||
}
|
||||
}
|
||||
}
|
@ -161,6 +161,11 @@ public class MAUtils
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getEntryFee(Configuration config, String arena)
|
||||
{
|
||||
return makeItemStackList(config.getString("arenas." + arena + ".settings.entry-fee", null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a comma-separated list of items in the <type>:<amount> format and
|
||||
* returns a list of ItemStacks created from that data.
|
||||
@ -176,7 +181,6 @@ public class MAUtils
|
||||
string = string.substring(0, string.length()-1);
|
||||
String[] items = string.split(",");
|
||||
|
||||
|
||||
for (String item : items)
|
||||
{
|
||||
// Trim whitespace and split by colons.
|
||||
@ -185,17 +189,21 @@ public class MAUtils
|
||||
|
||||
// Grab the amount.
|
||||
int amount = 1;
|
||||
if (parts.length == 2 && parts[1].matches("(-)?[0-9]+"))
|
||||
if (parts.length == 1 && parts[0].matches("\\$[0-9]+"))
|
||||
amount = Integer.parseInt(parts[0].substring(1, parts[0].length()));
|
||||
else if (parts.length == 2 && parts[1].matches("(-)?[0-9]+"))
|
||||
amount = Integer.parseInt(parts[1]);
|
||||
else if (parts.length == 3 && parts[2].matches("(-)?[0-9]+"))
|
||||
amount = Integer.parseInt(parts[2]);
|
||||
|
||||
|
||||
// Make the ItemStack.
|
||||
ItemStack stack = (parts.length == 3) ?
|
||||
makeItemStack(parts[0], amount, parts[1]) :
|
||||
makeItemStack(parts[0], amount);
|
||||
|
||||
result.add(stack);
|
||||
if (stack != null)
|
||||
result.add(stack);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -443,15 +451,26 @@ public class MAUtils
|
||||
/**
|
||||
* Gives the player all of the items in the list of ItemStacks.
|
||||
*/
|
||||
public static void giveItems(Player p, List<ItemStack> stacks, boolean autoEquip, boolean rewards)
|
||||
public static void giveItems(Player p, List<ItemStack> stacks, boolean autoEquip, boolean rewards, MobArena plugin)
|
||||
{
|
||||
PlayerInventory inv = p.getInventory();
|
||||
if (stacks == null)
|
||||
return;
|
||||
|
||||
PlayerInventory inv = p.getInventory();
|
||||
for (ItemStack stack : stacks)
|
||||
{
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
// If this is money, don't add to inventory.
|
||||
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||
{
|
||||
if (plugin != null && plugin.Methods.hasMethod())
|
||||
plugin.Method.getAccount(p.getName()).add(stack.getAmount());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// If these are rewards, don't tamper with them.
|
||||
if (rewards)
|
||||
{
|
||||
@ -459,36 +478,28 @@ public class MAUtils
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this is an armor piece, equip it and continue.
|
||||
// If this is an armor piece, equip it.
|
||||
if (autoEquip && ARMORS_TYPE.contains(stack.getType()))
|
||||
{
|
||||
equipArmorPiece(stack, inv);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this is a sword, set its durability to "unlimited".
|
||||
//if (SWORDS_TYPE.contains(stack.getType()))
|
||||
// If this is a weapon, set its durability to "unlimited".
|
||||
if (WEAPONS_TYPE.contains(stack.getType()))
|
||||
stack.setDurability((short) -32768);
|
||||
|
||||
/*if (stack.getAmount() < 0)
|
||||
{
|
||||
stack = new ItemStack(stack.getType(), 32768);
|
||||
inv.setItem(inv.firstEmpty(), stack);
|
||||
continue;
|
||||
}*/
|
||||
inv.addItem(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void giveItems(Player p, List<ItemStack> stacks, boolean autoEquip)
|
||||
public static void giveRewards(Player p, List<ItemStack> stacks, MobArena plugin)
|
||||
{
|
||||
giveItems(p, stacks, autoEquip, false);
|
||||
giveItems(p, stacks, false, true, plugin);
|
||||
}
|
||||
|
||||
public static void giveRewards(Player p, List<ItemStack> stacks)
|
||||
public static void giveItems(Player p, List<ItemStack> stacks, boolean autoEquip, MobArena plugin)
|
||||
{
|
||||
giveItems(p, stacks, false, true);
|
||||
giveItems(p, stacks, autoEquip, false, plugin);
|
||||
}
|
||||
|
||||
public static int getPetAmount(Player p)
|
||||
@ -522,8 +533,12 @@ public class MAUtils
|
||||
}
|
||||
|
||||
/* Helper methods for making ItemStacks out of strings and ints */
|
||||
private static ItemStack makeItemStack(String name, int amount, String data)
|
||||
public static ItemStack makeItemStack(String name, int amount, String data)
|
||||
{
|
||||
// If this is economy money, create a dummy ItemStack.
|
||||
if (name.matches("\\$[0-9]+"))
|
||||
return new ItemStack(MobArena.ECONOMY_MONEY_ID, amount);
|
||||
|
||||
try
|
||||
{
|
||||
byte offset = 0;
|
||||
@ -548,7 +563,10 @@ public class MAUtils
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private static ItemStack makeItemStack(String name, int amount) { return makeItemStack(name, amount, "0"); }
|
||||
public static ItemStack makeItemStack(String name, int amount)
|
||||
{
|
||||
return makeItemStack(name, amount, "0");
|
||||
}
|
||||
|
||||
/* Helper method for grabbing a random reward */
|
||||
public static ItemStack getRandomReward(List<ItemStack> rewards)
|
||||
@ -879,13 +897,15 @@ public class MAUtils
|
||||
/**
|
||||
* Sends a message to all players in and around the arena.
|
||||
*/
|
||||
public static void tellAll(Arena arena, String msg)
|
||||
public static void tellAll(Arena arena, String msg) { tellAll(arena, msg, false); }
|
||||
public static void tellAll(Arena arena, String msg, boolean waitPlayers)
|
||||
{
|
||||
Set<Player> tmp = new HashSet<Player>();
|
||||
tmp.addAll(arena.livePlayers);
|
||||
tmp.addAll(arena.deadPlayers);
|
||||
tmp.addAll(arena.specPlayers);
|
||||
tmp.addAll(arena.readyPlayers);
|
||||
if (waitPlayers) tmp.addAll(arena.waitPlayers);
|
||||
for (Player p : tmp)
|
||||
tellPlayer(p, msg);
|
||||
}
|
||||
@ -964,7 +984,7 @@ public class MAUtils
|
||||
/**
|
||||
* Turn a list into a space-separated string-representation of the list.
|
||||
*/
|
||||
public static <E> String listToString(List<E> list, boolean none)
|
||||
public static <E> String listToString(List<E> list, boolean none, MobArena plugin)
|
||||
{
|
||||
if (list.isEmpty())
|
||||
{
|
||||
@ -975,6 +995,7 @@ public class MAUtils
|
||||
}
|
||||
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
int trimLength = 0;
|
||||
|
||||
E type = list.get(0);
|
||||
if (type instanceof Player)
|
||||
@ -987,10 +1008,21 @@ public class MAUtils
|
||||
}
|
||||
else if (type instanceof ItemStack)
|
||||
{
|
||||
trimLength = 2;
|
||||
ItemStack stack;
|
||||
for (E e : list)
|
||||
{
|
||||
stack = (ItemStack) e;
|
||||
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||
{
|
||||
if (plugin.Methods.hasMethod())
|
||||
{
|
||||
buffy.append(plugin.Method.format(stack.getAmount()));
|
||||
buffy.append(", ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
buffy.append(stack.getType().toString().toLowerCase());
|
||||
buffy.append(":");
|
||||
buffy.append(stack.getAmount());
|
||||
@ -1005,9 +1037,9 @@ public class MAUtils
|
||||
buffy.append(" ");
|
||||
}
|
||||
}
|
||||
return buffy.toString();
|
||||
return buffy.toString().substring(0, buffy.length() - trimLength);
|
||||
}
|
||||
public static <E> String listToString(List<E> list) { return listToString(list, true); }
|
||||
public static <E> String listToString(List<E> list, MobArena plugin) { return listToString(list, true, plugin); }
|
||||
|
||||
/**
|
||||
* Returns a String-list version of a comma-separated list.
|
||||
|
@ -16,6 +16,8 @@ import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.garbagemule.register.payment.Method;
|
||||
import com.garbagemule.register.payment.Methods;
|
||||
|
||||
/**
|
||||
* MobArena
|
||||
@ -27,11 +29,15 @@ public class MobArena extends JavaPlugin
|
||||
private ArenaMaster am;
|
||||
|
||||
// Permissions stuff
|
||||
protected static PermissionHandler permissionHandler;
|
||||
private PermissionHandler permissionHandler;
|
||||
|
||||
public MobArena()
|
||||
{
|
||||
}
|
||||
// Economy stuff
|
||||
protected Methods Methods;
|
||||
protected Method Method;
|
||||
|
||||
// Global variables
|
||||
protected static final double MIN_PLAYER_DISTANCE = 256.0;
|
||||
protected static final int ECONOMY_MONEY_ID = -29;
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
@ -46,6 +52,14 @@ public class MobArena extends JavaPlugin
|
||||
// Permissions
|
||||
setupPermissions();
|
||||
|
||||
// Economy
|
||||
Methods = new Methods();
|
||||
if (!Methods.hasMethod() && Methods.setMethod(this))
|
||||
{
|
||||
Method = Methods.getMethod();
|
||||
System.out.println("[MobArena] Payment method found (" + Method.getName() + " version: " + Method.getVersion() + ")");
|
||||
}
|
||||
|
||||
// Bind the /ma, /marena, and /mobarena commands to MACommands.
|
||||
MACommands commandExecutor = new MACommands(this, am);
|
||||
getCommand("ma").setExecutor(commandExecutor);
|
||||
@ -68,7 +82,7 @@ public class MobArena extends JavaPlugin
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Highest, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.High, this); // mcMMO is "Highest"
|
||||
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Lowest, this); // Lowest because of Tombstone
|
||||
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Highest, this);
|
||||
@ -81,11 +95,20 @@ public class MobArena extends JavaPlugin
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
{
|
||||
// Force all arenas to end.
|
||||
for (Arena arena : am.arenas)
|
||||
arena.forceEnd();
|
||||
am.arenaMap.clear();
|
||||
|
||||
// Permissions & Economy
|
||||
permissionHandler = null;
|
||||
if (Methods != null && Methods.hasMethod())
|
||||
{
|
||||
Methods = null;
|
||||
System.out.println("[MobArena] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
|
||||
System.out.println("[MobArena] disabled.");
|
||||
}
|
||||
|
||||
@ -143,13 +166,13 @@ public class MobArena extends JavaPlugin
|
||||
}
|
||||
|
||||
// Permissions stuff
|
||||
public static boolean has(Player p, String s)
|
||||
public boolean has(Player p, String s)
|
||||
{
|
||||
//return (permissionHandler != null && permissionHandler.has(p, s));
|
||||
return (permissionHandler == null || permissionHandler.has(p, s));
|
||||
}
|
||||
|
||||
public static boolean hasDefTrue(Player p, String s)
|
||||
public boolean hasDefTrue(Player p, String s)
|
||||
{
|
||||
return (permissionHandler == null || permissionHandler.has(p, s));
|
||||
}
|
||||
|
62
src/com/garbagemule/register/payment/Method.java
Normal file
62
src/com/garbagemule/register/payment/Method.java
Normal file
@ -0,0 +1,62 @@
|
||||
package com.garbagemule.register.payment;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Method.java
|
||||
* Interface for all sub-methods for payment.
|
||||
*
|
||||
* @author: Nijikokun<nijikokun@gmail.com> (@nijikokun)
|
||||
* @copyright: Copyright (C) 2011
|
||||
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
|
||||
*/
|
||||
public interface Method {
|
||||
public Object getPlugin();
|
||||
public String getName();
|
||||
public String getVersion();
|
||||
public String format(double amount);
|
||||
public boolean hasBanks();
|
||||
public boolean hasBank(String bank);
|
||||
public boolean hasAccount(String name);
|
||||
public boolean hasBankAccount(String bank, String name);
|
||||
public MethodAccount getAccount(String name);
|
||||
public MethodBankAccount getBankAccount(String bank, String name);
|
||||
public boolean isCompatible(Plugin plugin);
|
||||
public void setPlugin(Plugin plugin);
|
||||
|
||||
public interface MethodAccount {
|
||||
public double balance();
|
||||
public boolean set(double amount);
|
||||
public boolean add(double amount);
|
||||
public boolean subtract(double amount);
|
||||
public boolean multiply(double amount);
|
||||
public boolean divide(double amount);
|
||||
public boolean hasEnough(double amount);
|
||||
public boolean hasOver(double amount);
|
||||
public boolean hasUnder(double amount);
|
||||
public boolean isNegative();
|
||||
public boolean remove();
|
||||
|
||||
@Override
|
||||
public String toString();
|
||||
}
|
||||
|
||||
public interface MethodBankAccount {
|
||||
public double balance();
|
||||
public String getBankName();
|
||||
public int getBankId();
|
||||
public boolean set(double amount);
|
||||
public boolean add(double amount);
|
||||
public boolean subtract(double amount);
|
||||
public boolean multiply(double amount);
|
||||
public boolean divide(double amount);
|
||||
public boolean hasEnough(double amount);
|
||||
public boolean hasOver(double amount);
|
||||
public boolean hasUnder(double amount);
|
||||
public boolean isNegative();
|
||||
public boolean remove();
|
||||
|
||||
@Override
|
||||
public String toString();
|
||||
}
|
||||
}
|
141
src/com/garbagemule/register/payment/Methods.java
Normal file
141
src/com/garbagemule/register/payment/Methods.java
Normal file
@ -0,0 +1,141 @@
|
||||
package com.garbagemule.register.payment;
|
||||
|
||||
import com.garbagemule.register.payment.methods.BOSE6;
|
||||
import com.garbagemule.register.payment.methods.BOSE7;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Methods.java
|
||||
* Controls the getting / setting of methods & the method of payment used.
|
||||
*
|
||||
* @author: Nijikokun<nijikokun@gmail.com> (@nijikokun)
|
||||
* @copyright: Copyright (C) 2011
|
||||
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
|
||||
*/
|
||||
public class Methods {
|
||||
private boolean self = false;
|
||||
private Method Method = null;
|
||||
private String preferred = "";
|
||||
private Set<Method> Methods = new HashSet<Method>();
|
||||
private Set<String> Dependencies = new HashSet<String>();
|
||||
private Set<Method> Attachables = new HashSet<Method>();
|
||||
|
||||
public Methods() {
|
||||
this._init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to set which economy plugin is most preferred.
|
||||
*
|
||||
* @param preferred - preferred economy plugin
|
||||
*/
|
||||
public Methods(String preferred) {
|
||||
this._init();
|
||||
|
||||
if(this.Dependencies.contains(preferred)) {
|
||||
this.preferred = preferred;
|
||||
}
|
||||
}
|
||||
|
||||
private void _init() {
|
||||
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo4());
|
||||
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo5());
|
||||
this.addMethod("BOSEconomy", new BOSE6());
|
||||
this.addMethod("BOSEconomy", new BOSE7());
|
||||
this.addMethod("Essentials", new com.garbagemule.register.payment.methods.EE17());
|
||||
}
|
||||
|
||||
public Set<String> getDependencies() {
|
||||
return Dependencies;
|
||||
}
|
||||
|
||||
public Method createMethod(Plugin plugin) {
|
||||
for (Method method: Methods) {
|
||||
if (method.isCompatible(plugin)) {
|
||||
method.setPlugin(plugin);
|
||||
return method;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addMethod(String name, Method method) {
|
||||
Dependencies.add(name);
|
||||
Methods.add(method);
|
||||
}
|
||||
|
||||
public boolean hasMethod() {
|
||||
return (Method != null);
|
||||
}
|
||||
|
||||
public boolean setMethod(Plugin method) {
|
||||
if(hasMethod()) return true;
|
||||
if(self) { self = false; return false; }
|
||||
|
||||
int count = 0;
|
||||
boolean match = false;
|
||||
Plugin plugin;
|
||||
PluginManager manager = method.getServer().getPluginManager();
|
||||
|
||||
for(String name: this.getDependencies()) {
|
||||
if(hasMethod()) break;
|
||||
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
|
||||
if(plugin == null) continue;
|
||||
|
||||
Method current = this.createMethod(plugin);
|
||||
if(current == null) continue;
|
||||
|
||||
if(this.preferred.isEmpty())
|
||||
this.Method = current;
|
||||
else {
|
||||
this.Attachables.add(current);
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.preferred.isEmpty()) {
|
||||
do {
|
||||
if(hasMethod()) {
|
||||
match = true;
|
||||
} else {
|
||||
for(Method attached: this.Attachables) {
|
||||
if(attached == null) continue;
|
||||
|
||||
if(hasMethod()) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(this.preferred.isEmpty()) this.Method = attached;
|
||||
|
||||
if(count == 0) {
|
||||
if(this.preferred.equalsIgnoreCase(attached.getName()))
|
||||
this.Method = attached;
|
||||
} else {
|
||||
this.Method = attached;
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
} while(!match);
|
||||
}
|
||||
|
||||
return hasMethod();
|
||||
}
|
||||
|
||||
public Method getMethod() {
|
||||
return Method;
|
||||
}
|
||||
|
||||
public boolean checkDisabled(Plugin method) {
|
||||
if(!hasMethod()) return true;
|
||||
if (Method.isCompatible(method)) Method = null;
|
||||
return (Method == null);
|
||||
}
|
||||
}
|
196
src/com/garbagemule/register/payment/methods/BOSE.java
Normal file
196
src/com/garbagemule/register/payment/methods/BOSE.java
Normal file
@ -0,0 +1,196 @@
|
||||
package com.garbagemule.register.payment.methods;
|
||||
|
||||
import com.garbagemule.register.payment.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BOSE implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.6.2";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.BOSEconomy.isBankOwner(bank, name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return new BOSEBankAccount(bank, name, BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
|
||||
public class BOSEAccount implements MethodAccount {
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return Double.valueOf(this.BOSEconomy.getPlayerMoney(this.name));
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class BOSEBankAccount implements MethodBankAccount {
|
||||
private String bank;
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEBankAccount(String bank, String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return Double.valueOf(this.BOSEconomy.getBankMoney(name));
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setBankMoney(name, IntAmount, true);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(this.name, (balance + IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(this.name, (balance / IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
}
|
195
src/com/garbagemule/register/payment/methods/BOSE6.java
Normal file
195
src/com/garbagemule/register/payment/methods/BOSE6.java
Normal file
@ -0,0 +1,195 @@
|
||||
package com.garbagemule.register.payment.methods;
|
||||
|
||||
import com.garbagemule.register.payment.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BOSE6 implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.6.2";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
if(!hasBankAccount(bank, name)) return null;
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
|
||||
public class BOSEAccount implements MethodAccount {
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return Double.valueOf(this.BOSEconomy.getPlayerMoney(this.name));
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class BOSEBankAccount implements MethodBankAccount {
|
||||
private String bank;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return Double.valueOf(this.BOSEconomy.getBankMoney(bank));
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
}
|
189
src/com/garbagemule/register/payment/methods/BOSE7.java
Normal file
189
src/com/garbagemule/register/payment/methods/BOSE7.java
Normal file
@ -0,0 +1,189 @@
|
||||
package com.garbagemule.register.payment.methods;
|
||||
|
||||
import com.garbagemule.register.payment.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
|
||||
public class BOSE7 implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.7.0";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
if(!hasBankAccount(bank, name)) return null;
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
|
||||
public class BOSEAccount implements MethodAccount {
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class BOSEBankAccount implements MethodBankAccount {
|
||||
private String bank;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.BOSEconomy.getBankMoneyDouble(bank);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
return this.BOSEconomy.setBankMoney(bank, amount, true);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
}
|
200
src/com/garbagemule/register/payment/methods/EE17.java
Normal file
200
src/com/garbagemule/register/payment/methods/EE17.java
Normal file
@ -0,0 +1,200 @@
|
||||
package com.garbagemule.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.earth2me.essentials.api.NoLoanPermittedException;
|
||||
import com.earth2me.essentials.api.UserDoesNotExistException;
|
||||
import com.garbagemule.register.payment.Method;
|
||||
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class EE17 implements Method {
|
||||
private Essentials Essentials;
|
||||
|
||||
public Essentials getPlugin() {
|
||||
return this.Essentials;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "Essentials";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "2.2";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return Economy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return Economy.playerExists(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new EEcoAccount(name);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
try { Class.forName("com.earth2me.essentials.api.Economy"); }
|
||||
catch(Exception e) { return false; }
|
||||
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("essentials") && plugin instanceof Essentials;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
Essentials = (Essentials)plugin;
|
||||
}
|
||||
|
||||
public class EEcoAccount implements MethodAccount {
|
||||
private String name;
|
||||
|
||||
public EEcoAccount(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
Double balance = 0.0;
|
||||
|
||||
try {
|
||||
balance = Economy.getMoney(this.name);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] Failed to grab balance in Essentials Economy: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return balance;
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
try {
|
||||
Economy.setMoney(name, amount);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
} catch (NoLoanPermittedException ex) {
|
||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
try {
|
||||
Economy.add(name, amount);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
} catch (NoLoanPermittedException ex) {
|
||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
try {
|
||||
Economy.subtract(name, amount);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
} catch (NoLoanPermittedException ex) {
|
||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
try {
|
||||
Economy.multiply(name, amount);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
} catch (NoLoanPermittedException ex) {
|
||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
try {
|
||||
Economy.divide(name, amount);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
} catch (NoLoanPermittedException ex) {
|
||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
try {
|
||||
return Economy.hasEnough(name, amount);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
try {
|
||||
return Economy.hasMore(name, amount);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
try {
|
||||
return Economy.hasLess(name, amount);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
try {
|
||||
return Economy.isNegative(name);
|
||||
} catch (UserDoesNotExistException ex) {
|
||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
128
src/com/garbagemule/register/payment/methods/iCo4.java
Normal file
128
src/com/garbagemule/register/payment/methods/iCo4.java
Normal file
@ -0,0 +1,128 @@
|
||||
package com.garbagemule.register.payment.methods;
|
||||
|
||||
import com.garbagemule.register.payment.Method;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.coelho.iConomy.system.Account;
|
||||
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class iCo4 implements Method {
|
||||
private iConomy iConomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "4";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.iConomy.getBank().format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.iConomy.getBank().hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount(this.iConomy.getBank().getAccount(name));
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && !plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Account getiCoAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.account.getBalance();
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.account.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.account.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.account.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
211
src/com/garbagemule/register/payment/methods/iCo5.java
Normal file
211
src/com/garbagemule/register/payment/methods/iCo5.java
Normal file
@ -0,0 +1,211 @@
|
||||
package com.garbagemule.register.payment.methods;
|
||||
|
||||
import com.garbagemule.register.payment.Method;
|
||||
import com.iConomy.iConomy;
|
||||
import com.iConomy.system.Account;
|
||||
import com.iConomy.system.BankAccount;
|
||||
import com.iConomy.system.Holdings;
|
||||
import com.iConomy.util.Constants;
|
||||
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class iCo5 implements Method {
|
||||
private iConomy iConomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "5";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.iConomy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return Constants.Banking;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.iConomy.hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return (!hasBank(bank)) ? false : this.iConomy.getBank(bank).hasAccount(name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount(this.iConomy.getAccount(name));
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
private Holdings holdings;
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
|
||||
public Account getiCoAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.holdings.balance();
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.set(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class iCoBankAccount implements MethodBankAccount {
|
||||
private BankAccount account;
|
||||
private Holdings holdings;
|
||||
|
||||
public iCoBankAccount(BankAccount account) {
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
|
||||
public BankAccount getiCoBankAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.account.getBankName();
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return this.account.getBankId();
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.holdings.balance();
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.set(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user