Merge branch 'dev' of github.com:garbagemule/MobArena into dev

This commit is contained in:
Andreas Troelsen 2011-07-17 13:48:59 +02:00
commit a118a5056f
30 changed files with 7864 additions and 0 deletions

BIN
MobArena.jar Normal file

Binary file not shown.

26
bin/plugin.yml Normal file
View File

@ -0,0 +1,26 @@
name: MobArena
main: com.garbagemule.MobArena.MobArena
version: 0.92
softdepend: [MultiVerse]
commands:
ma:
description: Base command for MobArena
usage: |
/ma join - Join the arena.
/ma leave - Leave the arena.
/ma notready - List of players who aren't ready.
/ma spectate - Warp to the spectator area.
marena:
description: Base command for MobArena
usage: |
/marena join - Join the arena.
/marena leave - Leave the arena.
/marena notready - List of players who aren't ready.
/marena spectate - Warp to the spectator area.
mobarena:
description: Base command for MobArena
usage: |
/mobarena join - Join the arena.
/mobarena leave - Leave the arena.
/mobarena notready - List of players who aren't ready.
/mobarena spectate - Warp to the spectator area.

View File

@ -0,0 +1,51 @@
ARENA_START=Lad massakren begynde!
ARENA_END=Arena slut.
ARENA_DOES_NOT_EXIST=Arenaen findes ikke. Skriv /ma arenas for en liste.
JOIN_PLAYER_JOINED=Du joinede arenaen!
JOIN_NOT_ENABLED=MobArena er ikke aktiveret.
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.
JOIN_TOO_FAR=Du er for langt fra denne arena til at kunne joine.
JOIN_EMPTY_INV=Du skal tømme dit inventory før du kan joine arenaen.
JOIN_PLAYER_LIMIT_REACHED=Der kan ikke være flere spillere i arenaen.
JOIN_STORE_INV_FAIL=Kunne ikke gemme dit inventory. Prøv igen.
LEAVE_PLAYER_LEFT=Du forlod arenaen.
LEAVE_NOT_PLAYING=Du er ikke i en arena.
PLAYER_DIED=% døde!
SPEC_PLAYER_SPECTATE=Nyd forestillingen!
SPEC_NOT_RUNNING=Arenaen er ikke startet.
SPEC_ARG_NEEDED=Arenanavn påkrævet. Skriv /ma arenas for en liste.
SPEC_EMPTY_INV=Du skal tømme dit inventory først.
SPEC_ALREADY_PLAYING=Du spiller allerede!
NOT_READY_PLAYERS=Ikke klar: %
FORCE_START_STARTED=Arena tvunget til at starte.
FORCE_START_RUNNING=Arenaen er allerede startet.
FORCE_START_NOT_READY=Ingen spillere er klar.
FORCE_END_ENDED=Arena tvunget til at slutte.
FORCE_END_EMPTY=Der er ingen i arenaen.
FORCE_END_IDLE=Du var ikke hurtig nok!
REWARDS_GIVE=Her er alle dine præmier!
LOBBY_CLASS_PICKED=Du har valgt % som din klasse!
LOBBY_CLASS_RANDOM=Du får tildelt en klasse ved arena start.
LOBBY_CLASS_PERMISSION=Du har ikke rettigheder til den klasse!
LOBBY_PLAYER_READY=Du er markeret som klar!
LOBBY_DROP_ITEM=Du kan ikke dele items i lobbyen!
LOBBY_PICK_CLASS=Du skal først vælge en klasse!
LOBBY_RIGHT_CLICK=Slå skiltene; ikke højre-klik.
WARP_TO_ARENA=Du kan ikke warpe til arenaen efter, den er startet.
WARP_FROM_ARENA=Du kan ikke warpe fra arenaen.
WAVE_DEFAULT=Bølge #%!
WAVE_SPECIAL=Bølge #%! [SPECIEL]
WAVE_REWARD=Du har lige vundet en præmie: %
MISC_LIST_ARENAS=Tilgængelige arenaer: %
MISC_LIST_PLAYERS=Levende spillere: %
MISC_COMMAND_NOT_ALLOWED=Du kan ikke bruge den kommando i arenaen.
MISC_NO_ACCESS=Du har ikke adgang til den kommando.
MISC_NONE=<ingen>

View File

@ -0,0 +1,51 @@
ARENA_START=Que le massacre commence !
ARENA_END=L'arène est terminée.
ARENA_DOES_NOT_EXIST=Cette arène n'existe pas. Entrez "/ma arenas" pour la liste.
JOIN_PLAYER_JOINED=Vous avez rejoint l'arène. Prennez plaisir !
JOIN_NOT_ENABLED=MobArena n'est pas actif.
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.
JOIN_TOO_FAR=Vous êtes trop loins de l'arène pour pouvoir joindre en tant que joueur ou specateur.
JOIN_EMPTY_INV=Vous devez vider votre inventaire afin de joindre l'arène.
JOIN_PLAYER_LIMIT_REACHED=La limite de joueur pour cette arène a été atteinte.
JOIN_STORE_INV_FAIL=La sauvegarde de l'inventaire a échouée. Essayez encore.
LEAVE_PLAYER_LEFT=Vous avez quitté l'arène. Merci d'avoir joué !
LEAVE_NOT_PLAYING=Vous n'êtes pas dans l'arène.
PLAYER_DIED=% est mort !
SPEC_PLAYER_SPECTATE=Profitez bien du spectacle !
SPEC_NOT_RUNNING=Cette arène n'est pas en cours.
SPEC_ARG_NEEDED=Vous devez spécifier une arène. Entrez "/ma arenas" pour la liste.
SPEC_EMPTY_INV=Vous devez vider votre inventaire.
SPEC_ALREADY_PLAYING=Vous ne pouvez pas être spectateur en tant que joueur de l'arène !
NOT_READY_PLAYERS=Non prêt: %
FORCE_START_STARTED=Début forcé de l'arène.
FORCE_START_RUNNING=L'arène a commencée.
FORCE_START_NOT_READY=Ne peut pas forcer le début, il n'y a pas de joueurs prêts.
FORCE_END_ENDED=Fin forcée de l'arène.
FORCE_END_EMPTY=Il n'y a personne dans l'arène.
FORCE_END_IDLE=Vous n'avez pas été assez rapide !
REWARDS_GIVE=Voici vos récompenses !
LOBBY_CLASS_PICKED=Vous avez choisi % comme classe !
LOBBY_CLASS_RANDOM=Une classe aléatoire va vous être attribuée.
LOBBY_CLASS_PERMISSION=Vous n'avez pas les permissions pour utiliser cette classe !
LOBBY_PLAYER_READY=Vous avez été marqué comme prêt !
LOBBY_DROP_ITEM=Pas de partage avant le début de l'arène !
LOBBY_PICK_CLASS=Vous devez d'abord choisir une classe !
LOBBY_RIGHT_CLICK=Vous devez frapper le panneau, pas cliquer du droit dessus.
WARP_TO_ARENA=Vous ne pouvez pas vous téléporter à l'arène pendant la bataille !
WARP_FROM_ARENA=La téléportation est interdite dans l'arène !
WAVE_DEFAULT=Soyez prêt pour la vague #% !
WAVE_SPECIAL=Soyez prêt pour la vague #% ! [SPECIALE]
WAVE_REWARD=Vous avez gagné une récompense: %
MISC_LIST_ARENAS=Les arènes disponibles: %
MISC_LIST_PLAYERS=Les joueurs en live: %
MISC_COMMAND_NOT_ALLOWED=Vous ne pouvez pas utiliser cette commande dans l'arène !
MISC_NO_ACCESS=Vous n'avez pas accès à cette commande.
MISC_NONE=<rien>

View File

@ -0,0 +1,51 @@
ARENA_START=Hearts alive, men!
ARENA_END=Land ho!
ARENA_DOES_NOT_EXIST=Thar be no ship by that name!
JOIN_PLAYER_JOINED=Ahoy, matey!
JOIN_NOT_ENABLED=We be swabbing down the decks on all ships, matey.
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!
JOIN_TOO_FAR=Ye be too far from the docks, landlubber!
JOIN_EMPTY_INV=Throw ye belongings overboard, scallywag!
JOIN_PLAYER_LIMIT_REACHED=Thar be too many men aboard this ship already, landlubber!
JOIN_STORE_INV_FAIL=Ye belongings didn't fit in the storage deck, arrgh!
LEAVE_PLAYER_LEFT=Ye abandonned the ship! Arrrgh!
LEAVE_NOT_PLAYING=Ye're already on land, matey!
PLAYER_DIED=% walked the plank!
SPEC_PLAYER_SPECTATE=Welcome to the Crow's Nest! Grab ye spyglass!
SPEC_NOT_RUNNING=Thar be no one aboard that ship!
SPEC_ARG_NEEDED=Which ship are ye boarding? Type /ma arenas for a list, arrgh!
SPEC_EMPTY_INV=Throw ye belongings overboard, scallywag!
SPEC_ALREADY_PLAYING=Ye don't need ye spyglass aboard this ship, harr!
NOT_READY_PLAYERS=Landlubbers: %
FORCE_START_STARTED=Set sail!
FORCE_START_RUNNING=The ship has already set sail!
FORCE_START_NOT_READY=Thar be no scurvy dogs ready to set sail!
FORCE_END_ENDED=Forced the men to walk the plank!
FORCE_END_EMPTY=Thar be no one aboard the ship!
FORCE_END_IDLE=Arrrgh! Too slow, matey!
REWARDS_GIVE=Here's ye booty, seadog!
LOBBY_CLASS_PICKED=Ye be the %!
LOBBY_CLASS_RANDOM=
LOBBY_CLASS_PERMISSION=Ye can't use that cutlass, scurvy dog!
LOBBY_PLAYER_READY=Ready to sail! Arrrgh!
LOBBY_DROP_ITEM=Don't be sharing ye rum yet, scallywag!
LOBBY_PICK_CLASS=Grab ye cutlass first, matey!
LOBBY_RIGHT_CLICK=Ye can't be right-clickin', landlubber.
WARP_TO_ARENA=Ye can't board this ship, wench!
WARP_FROM_ARENA=Walk the plank if ye want to leave, arrrgh!
WAVE_DEFAULT=Wave %: Blow them all down!
WAVE_SPECIAL=Wave %: Thar she blows!
WAVE_REWARD=Ye earned yerself some booty: %
MISC_LIST_ARENAS=Ships: %
MISC_LIST_PLAYERS=Buccaneers: %
MISC_COMMAND_NOT_ALLOWED=Ye can't be usin' that command on the ship, landlubber!
MISC_NO_ACCESS=Only the captain uses these commands, wench!
MISC_NONE=<none>

View File

@ -0,0 +1,40 @@
package com.garbagemule.MobArena;
import org.bukkit.entity.Player;
public abstract class AbstractArena
{
/**
* Start the arena session.
* This method should warp all players to their respective warp points, start all
* needed timers, clear/populate all sets and lists, and flag all booleans.
*/
public abstract void startArena();
/**
* Stop the arena session.
* Distribute rewards, clean up arena floor and reset everything to how it was before
* the arena session was started.
*/
public abstract void endArena();
/**
* Player joins the arena/lobby.
*/
public abstract void playerJoin(Player p);
/**
* Player leaves the arena/lobby.
*/
public abstract void playerLeave(Player p);
/**
* Player dies in the arena.
*/
public abstract void playerDeath(Player p);
/**
* Player signals that they are ready.
*/
public abstract void playerReady(Player p);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,137 @@
package com.garbagemule.MobArena;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.sql.Timestamp;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.entity.Player;
public class ArenaLog
{
protected MobArena plugin;
protected Arena arena;
protected List<String> log, classDistribution;
protected Timestamp startTime, endTime;
public ArenaLog(MobArena plugin, Arena arena)
{
this.plugin = plugin;
this.arena = arena;
log = new LinkedList<String>();
classDistribution = new LinkedList<String>();
}
public void start()
{
startTime = new Timestamp((new Date()).getTime());
// Class distribution
int length = 0;
for (String c : plugin.getAM().classes)
if (c.length() > length)
length = c.length();
List<String> classList = new LinkedList<String>(arena.classMap.values());
for (String c : plugin.getAM().classes)
{
int count = 0;
int id = classList.indexOf(c);
while (id != -1)
{
classList.remove(id);
count++;
id = classList.indexOf(c);
}
//int percentage = (int) (((double) count) / ((double) arena.livePlayers.size())) * 100;
int percentage = (int) (((double) count) / ((double) arena.arenaPlayers.size())) * 100;
classDistribution.add(MAUtils.padRight(c + ": ", length + 2) + MAUtils.padLeft("" + count, 2) + " (" + percentage + "%)");
}
}
public void end()
{
endTime = new Timestamp((new Date()).getTime());
// General stuff
log.add("--------------------------------------------------- ENTRY ---");
log.add("Start: " + startTime);
log.add("End: " + endTime);
log.add("Duration: " + MAUtils.getDuration(endTime.getTime() - startTime.getTime()));
log.add("Last wave: " + (arena.spawnThread.wave - 1));
log.add(" ");
// Class distribution
log.add("Class Distribution: " + plugin.getAM().classes.size() + " classes");
for (String c : classDistribution)
log.add("- " + c);
classDistribution.clear();
log.add(" ");
// Player data
int NAME = 12;
int CLASS = 0;
int WAVE = 4;
int KILLS = 5;
for (String c : plugin.getAM().classes)
if (c.length() > CLASS)
CLASS = c.length();
log.add("Player Data: " + arena.classMap.keySet().size() + " players");
log.add("- " + MAUtils.padRight("Name", NAME + 2, ' ') + MAUtils.padRight("Class", CLASS + 2, ' ') + MAUtils.padRight("Wave", WAVE + 2, ' ') + MAUtils.padRight("Kills", KILLS + 2, ' ') + "Rewards");
for (Map.Entry<Player,String> entry : arena.classMap.entrySet())
{
Player p = entry.getKey();
StringBuffer buffy = new StringBuffer();
buffy.append(" ");
// Name
String name = (p.getName().length() <= NAME) ? p.getName() : p.getName().substring(0, NAME+1);
buffy.append(MAUtils.padRight(name, NAME + 2, ' '));
// Class
buffy.append(MAUtils.padRight(entry.getValue(), CLASS + 2, ' '));
// Wave
buffy.append(MAUtils.padLeft(arena.waveMap.remove(p).toString(), WAVE, ' ') + " ");
// Kills
buffy.append(MAUtils.padLeft(arena.killMap.remove(p).toString(), KILLS, ' ') + " ");
// Rewards
buffy.append(MAUtils.listToString(arena.rewardMap.get(p), plugin));
log.add(buffy.toString());
}
log.add(" ");
}
public void serialize()
{
try
{
new File(plugin.getDataFolder() + File.separator + "logs").mkdir();
File logFile = new File(plugin.getDataFolder() + File.separator + "logs" + File.separator + arena.configName() + ".log");
if (logFile.exists())
logFile.createNewFile();
FileWriter fw = new FileWriter(logFile, true);
BufferedWriter bw = new BufferedWriter(fw);
for (String l : log)
{
bw.write(l);
bw.write(System.getProperty("line.separator"));
}
bw.close();
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("[MobArena] ERROR! Could not create log file!");
return;
}
}
public void add(String s) { log.add(s); }
public void clear() { log.clear(); }
}

View File

@ -0,0 +1,386 @@
package com.garbagemule.MobArena;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.config.Configuration;
public class ArenaMaster
{
private MobArena plugin;
private Configuration config;
protected Arena selectedArena;
//protected Lobby masterLobby;
// Settings
protected boolean enabled, updateNotify;
// Classes
protected List<String> classes;
protected Map<String,List<ItemStack>> classItems, classArmor;
protected Map<Integer,Map<Player,List<ItemStack>>> classBonuses;
protected Map<Player,Arena> arenaMap;
// Location map
protected Map<Player,Location> locations = new HashMap<Player,Location>();
// Arena list
protected List<Arena> arenas;
// Listeners
protected Set<MobArenaListener> listeners = new HashSet<MobArenaListener>();
/**
* Default constructor.
*/
public ArenaMaster(MobArena instance)
{
plugin = instance;
config = plugin.getConfig();
}
/*/////////////////////////////////////////////////////////////////////////
//
// Arena getters
//
/////////////////////////////////////////////////////////////////////////*/
public List<Arena> getEnabledArenas()
{
List<Arena> result = new LinkedList<Arena>();
for (Arena arena : arenas)
if (arena.enabled)
result.add(arena);
return result;
}
public Arena getArenaAtLocation(Location loc)
{
for (Arena arena : arenas)
if (arena.inRegion(loc))
return arena;
return null;
}
public List<Arena> getArenasInWorld(World world)
{
List<Arena> result = new LinkedList<Arena>();
for (Arena arena : arenas)
if (arena.world.equals(world))
result.add(arena);
return result;
}
public List<Player> getAllPlayers()
{
List<Player> result = new LinkedList<Player>();
for (Arena arena : arenas)
result.addAll(arena.getAllPlayers());
return result;
}
public List<Player> getAllPlayersInArena(String arenaName)
{
Arena arena = getArenaWithName(arenaName);
return (arena != null) ? arena.getLivingPlayers() : new LinkedList<Player>();
}
public List<Player> getAllLivingPlayers()
{
List<Player> result = new LinkedList<Player>();
for (Arena arena : arenas)
result.addAll(arena.getLivingPlayers());
return result;
}
public List<Player> getLivingPlayersInArena(String arenaName)
{
Arena arena = getArenaWithName(arenaName);
return (arena != null) ? arena.getLivingPlayers() : new LinkedList<Player>();
}
public Arena getArenaWithPlayer(Player p)
{
return arenaMap.get(p);
}
public Arena getArenaWithPlayer(String playerName)
{
return arenaMap.get(Bukkit.getServer().getPlayer(playerName));
}
public Arena getArenaWithSpectator(Player p)
{
for (Arena arena : arenas)
{
if (arena.specPlayers.contains(p))
return arena;
}
return null;
}
public Arena getArenaWithMonster(Entity e)
{
for (Arena arena : arenas)
if (arena.monsters.contains(e))
return arena;
return null;
}
public Arena getArenaWithPet(Entity e)
{
for (Arena arena : arenas)
if (arena.pets.contains(e))
return arena;
return null;
}
public Arena getArenaWithName(String configName)
{
for (Arena arena : arenas)
if (arena.configName().equals(configName))
return arena;
return null;
}
/*/////////////////////////////////////////////////////////////////////////
//
// Initialization
//
/////////////////////////////////////////////////////////////////////////*/
public void initialize()
{
config.load();
loadSettings();
loadClasses();
loadArenas();
config.save();
}
/**
* Load the global settings.
*/
public void loadSettings()
{
if (config.getKeys("global-settings") == null)
{
config.setProperty("global-settings.enabled", true);
config.setProperty("global-settings.update-notification", true);
}
enabled = config.getBoolean("global-settings.enabled", true);
updateNotify = config.getBoolean("global-settings.update-notification", true);
}
/**
* Load all class-related stuff.
*/
public void loadClasses()
{
if (config.getKeys("classes") == null)
{
config.setProperty("classes.Archer.items", "wood_sword, bow, arrow:128, grilled_pork");
config.setProperty("classes.Archer.armor", "298,299,300,301");
config.setProperty("classes.Knight.items", "diamond_sword, grilled_pork:2");
config.setProperty("classes.Knight.armor", "306,307,308,309");
config.setProperty("classes.Tank.items", "iron_sword, grilled_pork:3, apple");
config.setProperty("classes.Tank.armor", "310,311,312,313");
config.setProperty("classes.Oddjob.items", "stone_sword, flint_and_steel, netherrack:2, wood_pickaxe, tnt:4, fishing_rod, apple, grilled_pork:3");
config.setProperty("classes.Oddjob.armor", "298,299,300,301");
config.setProperty("classes.Chef.items", "stone_sword, bread:6, grilled_pork:4, mushroom_soup, cake:3, cookie:12");
config.setProperty("classes.Chef.armor", "314,315,316,317");
}
classes = config.getKeys("classes");
classItems = MAUtils.getClassItems(config, "items");
classArmor = MAUtils.getClassItems(config, "armor");
}
/**
* Load all arena-related stuff.
*/
public void loadArenas()
{
arenas = new LinkedList<Arena>();
if (config.getKeys("arenas") == null)
createArenaNode("default", Bukkit.getServer().getWorlds().get(0));
for (String configName : config.getKeys("arenas"))
{
String arenaPath = "arenas." + configName + ".";
String worldName = config.getString(arenaPath + "settings.world");
World world;
if (worldName == null)
{
System.out.println("[MobArena] ERROR! Could not find the world for arena '" + configName + "'. Using default world! Check the config-file!");
world = Bukkit.getServer().getWorlds().get(0);
}
else
{
world = Bukkit.getServer().getWorld(worldName);
}
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
arena.load(config);
arenas.add(arena);
}
arenaMap = new HashMap<Player,Arena>();
selectedArena = arenas.get(0);
}
public Arena createArenaNode(String configName, World world)
{
config.setProperty("arenas." + configName + ".settings.world", world.getName());
config.save();
config.load();
config.setProperty("arenas." + configName + ".settings.enabled", true);
config.save();
config.load();
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);
config.setProperty("arenas." + configName + ".settings.detonate-damage", false);
config.setProperty("arenas." + configName + ".settings.lightning", true);
config.setProperty("arenas." + configName + ".settings.auto-equip-armor", true);
config.setProperty("arenas." + configName + ".settings.force-restore", false);
config.setProperty("arenas." + configName + ".settings.soft-restore", false);
config.setProperty("arenas." + configName + ".settings.soft-restore-drops", false);
config.setProperty("arenas." + configName + ".settings.require-empty-inv-join", true);
config.setProperty("arenas." + configName + ".settings.require-empty-inv-spec", true);
config.setProperty("arenas." + configName + ".settings.hellhounds", false);
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);
config.setProperty("arenas." + configName + ".settings.max-join-distance", 0);
config.save();
config.load();
config.setProperty("arenas." + configName + ".settings.repair-delay", 5);
config.setProperty("arenas." + configName + ".settings.first-wave-delay", 5);
config.setProperty("arenas." + configName + ".settings.wave-interval", 20);
config.setProperty("arenas." + configName + ".settings.special-modulo", 4);
config.setProperty("arenas." + configName + ".settings.max-idle-time", 0);
config.save();
config.load();
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
arena.load(config);
return arena;
}
public void removeArenaNode(String configName)
{
config.removeProperty("arenas." + configName);
config.save();
}
/*/////////////////////////////////////////////////////////////////////////
//
// Update and serialization methods
//
/////////////////////////////////////////////////////////////////////////*/
/**
* Update one, two or all three of global settings, classes
* and arenas (arenas with deserialization).
*/
public void update(boolean settings, boolean classes, boolean arenalist)
{
boolean tmp = enabled;
enabled = false;
for (Arena arena : arenas)
arena.forceEnd();
config.load();
if (settings) loadSettings();
if (classes) loadClasses();
if (arenalist) deserializeArenas();
config.save();
enabled = tmp;
}
/**
* Serialize the global settings.
*/
public void serializeSettings()
{
String settings = "global-settings.";
config.setProperty(settings + "enabled", enabled);
config.save();
}
/**
* Serialize all arena configs.
*/
public void serializeArenas()
{
for (Arena arena : arenas)
arena.serializeConfig();
}
/**
* Deserialize all arena configs. Updates the arena list to
* include only the current arenas (not ones added in the
* actual file) that are also in the config-file.
*/
public void deserializeArenas()
{
// Get only the arenas in the config.
List<String> strings = config.getKeys("arenas");
if (strings == null)
return;
// Get their Arena objects.
List<Arena> configArenas = new LinkedList<Arena>();
for (String s : strings)
if (getArenaWithName(s) != null)
configArenas.add(getArenaWithName(s));
// Remove all Arenas no longer in the config.
arenas.retainAll(configArenas);
for (Arena arena : arenas)
arena.deserializeConfig();
// Make sure to update the selected arena to a valid one.
if (!arenas.contains(selectedArena) && arenas.size() >= 1)
selectedArena = arenas.get(0);
}
public void updateSettings() { update(true, false, false); }
public void updateClasses() { update(false, true, false); }
public void updateArenas() { update(false, false, true); }
public void updateAll() { update(true, true, true); }
}

View File

@ -0,0 +1,89 @@
package com.garbagemule.MobArena;
import java.io.Serializable;
import org.bukkit.Location;
import org.bukkit.World;
/**
* NOTE: I (garbagemule) DID NOT WRITE THIS CLASS (notice the author below)
* @author creadri
*/
@SuppressWarnings("serial")
public class EntityPosition implements Serializable{
private double x;
private double y;
private double z;
private String world;
private float yaw;
private float pitch;
public EntityPosition(double x, double y, double z, String world, float yaw, float pitch) {
this.x = x;
this.y = y;
this.z = z;
this.world = world;
this.yaw = yaw;
this.pitch = pitch;
}
public EntityPosition(Location location) {
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.world = location.getWorld().getName();
this.yaw = location.getYaw();
this.pitch = location.getPitch();
}
public Location getLocation(World world) {
return new Location(world, x, y, z, yaw, pitch);
}
public float getPitch() {
return pitch;
}
public void setPitch(float pitch) {
this.pitch = pitch;
}
public String getWorld() {
return world;
}
public void setWorld(String world) {
this.world = world;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public float getYaw() {
return yaw;
}
public void setYaw(float yaw) {
this.yaw = yaw;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
}

View File

@ -0,0 +1,26 @@
package com.garbagemule.MobArena;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class Lobby
{
protected Arena arena;
protected ArenaMaster am;
protected Location warp, l1, l2;
public Lobby(Arena arena)
{
this.arena = arena;
}
public Lobby()
{
this(null);
}
public void playerJoin(Player p)
{
p.teleport(warp);
}
}

View File

@ -0,0 +1,27 @@
package com.garbagemule.MobArena;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
public class MABlockListener extends BlockListener
{
private ArenaMaster am;
public MABlockListener(ArenaMaster am)
{
this.am = am;
}
public void onBlockBreak(BlockBreakEvent event)
{
for (Arena arena : am.arenas)
arena.onBlockBreak(event);
}
public void onBlockPlace(BlockPlaceEvent event)
{
for (Arena arena : am.arenas)
arena.onBlockPlace(event);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,65 @@
package com.garbagemule.MobArena;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import com.garbagemule.MobArena.Arena;
import com.garbagemule.MobArena.ArenaMaster;
public class MAEntityListener extends EntityListener
{
private ArenaMaster am;
public MAEntityListener(ArenaMaster am)
{
this.am = am;
}
public void onEntityRegainHealth(EntityRegainHealthEvent event)
{
for (Arena arena : am.arenas)
arena.onEntityRegainHealth(event);
}
public void onEntityDeath(EntityDeathEvent event)
{
for (Arena arena : am.arenas)
arena.onEntityDeath(event);
}
public void onEntityDamage(EntityDamageEvent event)
{
for (Arena arena : am.arenas)
arena.onEntityDamage(event);
}
public void onCreatureSpawn(CreatureSpawnEvent event)
{
for (Arena arena : am.arenas)
arena.onCreatureSpawn(event);
}
public void onEntityExplode(EntityExplodeEvent event)
{
for (Arena arena : am.arenas)
arena.onEntityExplode(event);
}
public void onEntityCombust(EntityCombustEvent event)
{
for (Arena arena : am.arenas)
arena.onEntityCombust(event);
}
public void onEntityTarget(EntityTargetEvent event)
{
for (Arena arena : am.arenas)
arena.onEntityTarget(event);
}
}

View File

@ -0,0 +1,22 @@
package com.garbagemule.MobArena;
import java.io.Serializable;
public class MAInventoryItem implements Serializable
{
private static final long serialVersionUID = 739709220350581510L;
private int typeId;
private int amount;
private short durability;
public MAInventoryItem(int typeId, int amount, short durability)
{
this.typeId = typeId;
this.amount = amount;
this.durability = durability;
}
public int getTypeId() { return typeId; }
public int getAmount() { return amount; }
public short getDurability() { return durability; }
}

View File

@ -0,0 +1,244 @@
package com.garbagemule.MobArena;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class MAMessages
{
protected static Map<Msg,String> msgMap;
private static Map<Msg,String> defaults = new HashMap<Msg,String>();
protected static enum Msg
{
ARENA_START,
ARENA_END,
ARENA_DOES_NOT_EXIST,
JOIN_PLAYER_JOINED,
JOIN_NOT_ENABLED,
JOIN_IN_OTHER_ARENA,
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,
JOIN_TOO_FAR,
JOIN_EMPTY_INV,
JOIN_PLAYER_LIMIT_REACHED,
JOIN_STORE_INV_FAIL,
LEAVE_PLAYER_LEFT,
LEAVE_NOT_PLAYING,
PLAYER_DIED,
SPEC_PLAYER_SPECTATE,
SPEC_NOT_RUNNING,
SPEC_ARG_NEEDED,
SPEC_EMPTY_INV,
SPEC_ALREADY_PLAYING,
NOT_READY_PLAYERS,
FORCE_START_STARTED,
FORCE_START_RUNNING,
FORCE_START_NOT_READY,
FORCE_END_ENDED,
FORCE_END_EMPTY,
FORCE_END_IDLE,
REWARDS_GIVE,
LOBBY_CLASS_PICKED,
LOBBY_CLASS_RANDOM,
LOBBY_CLASS_PERMISSION,
LOBBY_PLAYER_READY,
LOBBY_DROP_ITEM,
LOBBY_PICK_CLASS,
LOBBY_RIGHT_CLICK,
WARP_TO_ARENA,
WARP_FROM_ARENA,
WAVE_DEFAULT,
WAVE_SPECIAL,
WAVE_REWARD,
MISC_LIST_ARENAS,
MISC_LIST_PLAYERS,
MISC_COMMAND_NOT_ALLOWED,
MISC_NO_ACCESS,
MISC_NONE
}
// Populate the defaults map.
static
{
defaults.put(Msg.ARENA_START, "Let the slaughter begin!");
defaults.put(Msg.ARENA_END, "Arena finished.");
defaults.put(Msg.ARENA_DOES_NOT_EXIST, "That arena does not exist. Type /ma arenas for a list.");
defaults.put(Msg.JOIN_NOT_ENABLED, "MobArena is not enabled.");
defaults.put(Msg.JOIN_IN_OTHER_ARENA, "You are already in an arena! Leave that one first.");
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.");
defaults.put(Msg.JOIN_TOO_FAR, "You are too far away from the arena to join/spectate.");
defaults.put(Msg.JOIN_EMPTY_INV, "You must empty your inventory to join the arena.");
defaults.put(Msg.JOIN_PLAYER_LIMIT_REACHED, "The player limit of this arena has been reached.");
defaults.put(Msg.JOIN_STORE_INV_FAIL, "Failed to store inventory. Try again.");
defaults.put(Msg.JOIN_PLAYER_JOINED, "You joined the arena. Have fun!");
defaults.put(Msg.LEAVE_NOT_PLAYING, "You are not in the arena.");
defaults.put(Msg.LEAVE_PLAYER_LEFT, "You left the arena. Thanks for playing!");
defaults.put(Msg.PLAYER_DIED, "% died!");
defaults.put(Msg.SPEC_PLAYER_SPECTATE, "Enjoy the show!");
defaults.put(Msg.SPEC_NOT_RUNNING, "This arena isn't running.");
defaults.put(Msg.SPEC_ARG_NEEDED, "You must specify an arena. Type /ma arenas for a list.");
defaults.put(Msg.SPEC_EMPTY_INV, "Empty your inventory first!");
defaults.put(Msg.SPEC_ALREADY_PLAYING, "Can't spectate when in the arena!");
defaults.put(Msg.NOT_READY_PLAYERS, "Not ready: %");
defaults.put(Msg.FORCE_START_RUNNING, "Arena has already started.");
defaults.put(Msg.FORCE_START_NOT_READY, "Can't force start, no players are ready.");
defaults.put(Msg.FORCE_START_STARTED, "Forced arena start.");
defaults.put(Msg.FORCE_END_EMPTY, "No one is in the arena.");
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 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.");
defaults.put(Msg.LOBBY_CLASS_PICKED, "You have chosen % as your class!");
defaults.put(Msg.LOBBY_CLASS_RANDOM, "You will get a random class on arena start.");
defaults.put(Msg.LOBBY_CLASS_PERMISSION, "You don't have permission to use this class!");
defaults.put(Msg.WARP_TO_ARENA, "Can't warp to the arena during battle!");
defaults.put(Msg.WARP_FROM_ARENA, "Warping not allowed in the arena!");
defaults.put(Msg.WAVE_DEFAULT, "Get ready for wave #%!");
defaults.put(Msg.WAVE_SPECIAL, "Get ready for wave #%! [SPECIAL]");
defaults.put(Msg.WAVE_REWARD, "You just earned a reward: %");
defaults.put(Msg.MISC_LIST_PLAYERS, "Live players: %");
defaults.put(Msg.MISC_LIST_ARENAS, "Available arenas: %");
defaults.put(Msg.MISC_COMMAND_NOT_ALLOWED, "You can't use that command in the arena!");
defaults.put(Msg.MISC_NO_ACCESS, "You don't have access to this command.");
defaults.put(Msg.MISC_NONE, "<none>");
}
/**
* Initializes the msgMap by reading from the announcements-file.
*/
public static void init(MobArena plugin, boolean update)
{
// Use defaults in case of any errors.
msgMap = defaults;
// Grab the announcements-file.
File msgFile;
try
{
msgFile = new File(plugin.getDataFolder(), "announcements.properties");
// If it doesn't exist, create it.
if (!msgFile.exists())
{
System.out.println("[MobArena] Announcements-file not found. Creating one...");
msgFile.createNewFile();
BufferedWriter bw = new BufferedWriter(new FileWriter(msgFile));
for (Msg m : Msg.values())
{
bw.write(m.toString() + "=" + defaults.get(m));
bw.newLine();
}
bw.close();
return;
}
}
catch (Exception e)
{
System.out.println("[MobArena] ERROR! Couldn't initialize announcements-file. Using defaults.");
return;
}
// If the file was found, populate the msgMap.
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(msgFile), "UTF-8"));
// Check for BOM character.
br.mark(1); int bom = br.read();
if (bom != 65279) br.reset();
String s;
while ((s = br.readLine()) != null)
process(s);
br.close();
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("[MobArena] ERROR! Problem with announcements-file. Using defaults.");
return;
}
}
public static void init(MobArena plugin)
{
init(plugin, false);
}
/**
* Grabs the announcement from the msgMap, and in case of
* s not being null, replaces the % with s.
*/
public static String get(Msg msg, String s)
{
// If p is null, just return the announcement as is.
if (s == null)
return msgMap.get(msg);
// Otherwise, replace the % with the input string.
return msgMap.get(msg).replace("%", s);
}
/**
* Grabs the announcement from the msgMap.
*/
public static String get(Msg msg)
{
return get(msg, null);
}
/**
* Helper-method for parsing the strings from the
* announcements-file.
*/
private static void process(String s)
{
// Split the string by the equals-sign.
String[] split = s.split("=");
if (split.length != 2)
{
System.out.println("[MobArena] ERROR! Couldn't parse \"" + s + "\". Check announcements-file.");
return;
}
// For simplicity...
String key = split[0];
String val = split[1];
Msg msg;
try
{
msg = Msg.valueOf(key);
msgMap.put(msg, val);
}
catch (Exception e)
{
System.out.println("[MobArena] ERROR! " + key + " is not a valid key. Check announcements-file.");
return;
}
}
}

View File

@ -0,0 +1,87 @@
package com.garbagemule.MobArena;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
public class MAPlayerListener extends PlayerListener
{
private MobArena plugin;
private ArenaMaster am;
public MAPlayerListener(MobArena plugin, ArenaMaster am)
{
this.plugin = plugin;
this.am = am;
}
public void onPlayerInteract(PlayerInteractEvent event)
{
if (!am.enabled) return;
for (Arena arena : am.arenas)
arena.onPlayerInteract(event);
}
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!am.enabled) return;
for (Arena arena : am.arenas)
arena.onPlayerDropItem(event);
}
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
{
if (!am.enabled) return;
for (Arena arena : am.arenas)
arena.onPlayerBucketEmpty(event);
}
public void onPlayerTeleport(PlayerTeleportEvent event)
{
if (!am.enabled) return;
for (Arena arena : am.arenas)
arena.onPlayerTeleport(event);
}
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
if (!am.enabled) return;
for (Arena arena : am.arenas)
arena.onPlayerCommandPreprocess(event);
}
public void onPlayerQuit(PlayerQuitEvent event)
{
for (Arena arena : am.arenas)
arena.onPlayerQuit(event);
}
public void onPlayerKick(PlayerKickEvent event)
{
for (Arena arena : am.arenas)
arena.onPlayerKick(event);
}
public void onPlayerJoin(PlayerJoinEvent event)
{
if (!am.updateNotify || !event.getPlayer().isOp()) return;
final Player p = event.getPlayer();
Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask(plugin,
new Runnable()
{
public void run()
{
MAUtils.checkForUpdates(plugin, p, false);
}
}, 100);
}
}

View File

@ -0,0 +1,402 @@
package com.garbagemule.MobArena;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Player;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.CreatureType;
import org.bukkit.inventory.ItemStack;
import com.garbagemule.MobArena.MAMessages.Msg;
/**
* Core class for handling wave spawning.
* Currently, every 4th wave is a special wave, and all other waves
* are default waves. The distribution coefficients are used to spread
* out the distribution of each default monster however the server
* host chooses. It is possible to create default waves that consist of
* only one type of monster, or ones that have no creepers, for example.
*/
// TODO: Allow custom special wave monsters.
// TODO: Allow additional "default" waves.
public class MASpawnThread implements Runnable
{
protected int wave, previousSize, taskId;
private int ran, noOfPlayers, modulo;
private int dZombies, dSkeletons, dSpiders, dCreepers, dWolves;
private int dPoweredCreepers, dPigZombies, dSlimes, dMonsters, dAngryWolves, dGiants, dGhasts;
private Random random;
private MobArena plugin;
private Arena arena;
public MASpawnThread(MobArena plugin, Arena arena)
{
this.plugin = plugin;
this.arena = arena;
modulo = arena.specialModulo;
if (modulo <= 0) modulo = -32768;
taskId = -32768;
//noOfPlayers = arena.livePlayers.size();
noOfPlayers = arena.arenaPlayers.size();
wave = 1;
random = new Random();
// Set up the distribution variables for the random spawner.
// Note: Updating these means MAUtils.getArenaDistributions() must also be updated!
dZombies = arena.distDefault.get("zombies");
dSkeletons = dZombies + arena.distDefault.get("skeletons");
dSpiders = dSkeletons + arena.distDefault.get("spiders");
dCreepers = dSpiders + arena.distDefault.get("creepers");
dWolves = dCreepers + arena.distDefault.get("wolves");
dPoweredCreepers = arena.distSpecial.get("powered-creepers");
dPigZombies = dPoweredCreepers + arena.distSpecial.get("zombie-pigmen");
dSlimes = dPigZombies + arena.distSpecial.get("slimes");
dMonsters = dSlimes + arena.distSpecial.get("humans");
dAngryWolves = dMonsters + arena.distSpecial.get("angry-wolves");
dGiants = dAngryWolves + arena.distSpecial.get("giants");
dGhasts = dGiants + arena.distSpecial.get("ghasts");
}
public void run()
{
List<Entity> tmp = new LinkedList<Entity>(arena.monsters);
for (Entity e : tmp)
if (e.isDead())
arena.monsters.remove(e);
// Check if wave needs to be cleared first. If so, return!
if (arena.waveClear && wave > 1)
{
if (!arena.monsters.isEmpty())
return;
}
// Check if we need to grant more rewards with the recurrent waves.
for (Map.Entry<Integer,List<ItemStack>> entry : arena.everyWaveMap.entrySet())
if (wave % entry.getKey() == 0)
addReward(entry.getValue());
// Same deal, this time with the one-time waves.
if (arena.afterWaveMap.containsKey(wave))
addReward(arena.afterWaveMap.get(wave));
// Check if this is a special wave.
if (wave % modulo == 0)
{
MAUtils.tellAll(arena, MAMessages.get(Msg.WAVE_SPECIAL, ""+wave));
detonateCreepers(arena.detCreepers);
specialWave();
// Notify listeners.
for (MobArenaListener listener : plugin.getAM().listeners)
listener.onSpecialWave(wave, wave/modulo);
}
else
{
MAUtils.tellAll(arena, MAMessages.get(Msg.WAVE_DEFAULT, ""+wave));
detonateCreepers(arena.detCreepers);
defaultWave();
// Notify listeners.
for (MobArenaListener listener : plugin.getAM().listeners)
listener.onDefaultWave(wave);
}
wave++;
if (arena.maxIdleTime > 0 && arena.monsters.isEmpty()) arena.resetIdleTimer();
}
/**
* Rewards all players with an item from the input String.
*/
private void addReward(List<ItemStack> rewards)
{
//for (Player p : arena.livePlayers)
for (Player p : arena.arenaPlayers)
{
if (arena.rewardMap.get(p) == null)
continue;
ItemStack reward = MAUtils.getRandomReward(rewards);
arena.rewardMap.get(p).add(reward);
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()));
}
}
}
/**
* Spawns a default wave of monsters.
*/
private void defaultWave()
{
Location loc;
List<Location> spawnpoints = getValidSpawnpoints();
int noOfSpawnpoints = spawnpoints.size();
int count = wave + noOfPlayers;
CreatureType mob;
for (int i = 0; i < count; i++)
{
loc = spawnpoints.get(i % noOfSpawnpoints);
ran = random.nextInt(dWolves);
/* Because of the nature of the if-elseif-else statement,
* we're able to evaluate the random number in this way.
* If dSpiders = 0, then dSpiders = dSkeletons, which
* means if the random number is below that value, we will
* spawn a skeleton and break out of the statement. */
if (ran < dZombies) mob = CreatureType.ZOMBIE;
else if (ran < dSkeletons) mob = CreatureType.SKELETON;
else if (ran < dSpiders) mob = CreatureType.SPIDER;
else if (ran < dCreepers) mob = CreatureType.CREEPER;
else if (ran < dWolves) mob = CreatureType.WOLF;
else continue;
LivingEntity e = arena.world.spawnCreature(loc,mob);
arena.monsters.add(e);
if (mob == CreatureType.WOLF)
((Wolf)e).setOwner(null);
// Grab a random target.
Creature c = (Creature) e;
c.setTarget(getClosestPlayer(e));
}
}
/**
* Spawns a special wave of monsters.
*/
private void specialWave()
{
Location loc;
List<Location> spawnpoints = getValidSpawnpoints();
int noOfSpawnpoints = spawnpoints.size();
CreatureType mob;
ran = random.nextInt(dGhasts);
int count;
boolean slime = false;
boolean wolf = false;
boolean ghast = false;
boolean creeper = false;
if (ran < dPoweredCreepers) mob = CreatureType.CREEPER;
else if (ran < dPigZombies) mob = CreatureType.PIG_ZOMBIE;
else if (ran < dSlimes) mob = CreatureType.SLIME;
else if (ran < dMonsters) mob = CreatureType.MONSTER;
else if (ran < dAngryWolves) mob = CreatureType.WOLF;
else if (ran < dGiants) mob = CreatureType.GIANT;
else if (ran < dGhasts) mob = CreatureType.GHAST;
else return;
switch(mob)
{
case CREEPER:
count = noOfPlayers * 3;
creeper = true;
break;
case PIG_ZOMBIE:
count = noOfPlayers * 2;
break;
case SLIME:
count = noOfPlayers * 4;
slime = true;
break;
case MONSTER:
count = noOfPlayers + 1;
break;
case WOLF:
count = noOfPlayers * 3;
wolf = true;
break;
case GIANT:
count = 1;
break;
case GHAST:
count = 2;
ghast = true;
break;
default:
count = 50;
break;
}
// Spawn the hippie monsters.
for (int i = 0; i < count; i++)
{
loc = spawnpoints.get(i % noOfSpawnpoints);
LivingEntity e = arena.world.spawnCreature(loc,mob);
arena.monsters.add(e);
if (slime) ((Slime)e).setSize(2);
if (wolf) { ((Wolf)e).setAngry(true); ((Wolf)e).setOwner(null); }
if (ghast) ((Ghast)e).setHealth(Math.min(noOfPlayers*25, 200));
if (creeper) ((Creeper)e).setPowered(true);
// Slimes can't have targets, apparently.
if (!(e instanceof Creature))
continue;
// Grab a random target.
Creature c = (Creature) e;
c.setTarget(getClosestPlayer(e));
}
if (!arena.lightning)
return;
// Lightning, just for effect ;)
for (Location spawn : arena.spawnpoints.values())
arena.world.strikeLightningEffect(spawn);
}
/**
* "Detonates" all the Creepers in the monsterSet.
*/
public void detonateCreepers(boolean really)
{
if (!really)
return;
Set<Entity> tmp = new HashSet<Entity>();
for (Entity e : arena.monsters)
{
if (!(e instanceof Creeper) || e.isDead())
continue;
tmp.add(e);
}
Location loc;
for (Entity e : tmp)
{
arena.monsters.remove(e);
loc = e.getLocation().getBlock().getRelative(0,2,0).getLocation();
arena.world.createExplosion(loc, 2);
e.remove();
}
}
/**
* Get all the spawnpoints that have players nearby.
*/
public List<Location> getValidSpawnpoints()
{
List<Location> result = new ArrayList<Location>();
for (Location s : arena.spawnpoints.values())
{
//for (Player p : arena.livePlayers)
for (Player p : arena.arenaPlayers)
{
if (!arena.world.equals(p.getWorld()))
{
System.out.println("[MobArena] MASpawnThread:291: 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;
}
if (s.distanceSquared(p.getLocation()) > MobArena.MIN_PLAYER_DISTANCE)
continue;
result.add(s);
break;
}
}
// If no players are in range, just use all the spawnpoints.
if (result.isEmpty())
result.addAll(arena.spawnpoints.values());
return result;
}
/**
* Get the player closest to the input entity.
*/
// TODO: Move this into MAUtils
public Player getClosestPlayer(Entity e)
{
// Set up the comparison variable and the result.
double dist = 0;
double current = Double.POSITIVE_INFINITY;
Player result = null;
/* Iterate through the ArrayList, and update current and result every
* time a squared distance smaller than current is found. */
//for (Player p : arena.livePlayers)
for (Player p : arena.arenaPlayers)
{
if (!arena.world.equals(p.getWorld()))
{
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());
if (dist < current && dist < MobArena.MIN_PLAYER_DISTANCE)
{
current = dist;
result = p;
}
}
return result;
}
/**
* Update the targets of all monsters, if their targets aren't alive.
*/
public void updateTargets()
{
Creature c;
Entity target;
for (Entity e : arena.monsters)
{
if (!(e instanceof Creature))
continue;
c = (Creature) e;
target = c.getTarget();
//if (target instanceof Player && arena.livePlayers.contains(target))
if (target instanceof Player && arena.arenaPlayers.contains(target))
continue;
c.setTarget(getClosestPlayer(e));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,276 @@
package com.garbagemule.MobArena;
import java.io.File;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
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
* @author garbagemule
*/
public class MobArena extends JavaPlugin
{
private Configuration config;
private ArenaMaster am;
// Permissions stuff
private PermissionHandler permissionHandler;
// 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()
{
PluginDescriptionFile pdfFile = this.getDescription();
// Config, messages and ArenaMaster initialization
loadConfig();
MAMessages.init(this);
am = new ArenaMaster(this);
am.initialize();
// 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);
getCommand("marena").setExecutor(commandExecutor);
getCommand("mobarena").setExecutor(commandExecutor);
// Create event listeners.
PluginManager pm = getServer().getPluginManager();
PlayerListener playerListener = new MAPlayerListener(this, am);
EntityListener entityListener = new MAEntityListener(am);
BlockListener blockListener = new MABlockListener(am);
// Register events.
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.Normal, this);
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.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);
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Monitor, this);
System.out.println("[MobArena] v" + pdfFile.getVersion() + " enabled." );
}
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.");
}
/**
* Load the config-file and initialize the Configuration object.
*/
private void loadConfig()
{
File file = new File(this.getDataFolder(), "config.yml");
if (!file.exists())
{
try
{
this.getDataFolder().mkdir();
file.createNewFile();
}
catch (Exception e)
{
e.printStackTrace();
return;
}
}
// TODO: Remove in v1.0
else
{
Configuration tmp = new Configuration(file);
tmp.load();
if (tmp.getKeys("global-settings") == null)
{
file.renameTo(new File(this.getDataFolder(), "config_OLD.yml"));
file = new File(this.getDataFolder(), "config.yml");
try
{
this.getDataFolder().mkdir();
file.createNewFile();
}
catch (Exception e)
{
e.printStackTrace();
return;
}
config = new Configuration(file);
config.load();
fixConfig();
config.setHeader("# MobArena Configuration-file\r\n# Please go to https://github.com/garbagemule/MobArena/wiki/Installing-MobArena for more details.");
config.save();
}
}
config = new Configuration(file);
config.load();
config.setHeader("# MobArena Configuration-file\r\n# Please go to https://github.com/garbagemule/MobArena/wiki/Installing-MobArena for more details.");
config.save();
}
// Permissions stuff
public boolean has(Player p, String s)
{
//return (permissionHandler != null && permissionHandler.has(p, s));
return (permissionHandler == null || permissionHandler.has(p, s));
}
public boolean hasDefTrue(Player p, String s)
{
return (permissionHandler == null || permissionHandler.has(p, s));
}
private void setupPermissions()
{
if (permissionHandler != null)
return;
Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
if (permissionsPlugin == null) return;
permissionHandler = ((Permissions) permissionsPlugin).getHandler();
}
public Configuration getConfig() { return config; }
public ArenaMaster getAM() { return am; } // More convenient.
public ArenaMaster getArenaMaster() { return am; }
// TODO: Remove in v1.0
private void fixConfig()
{
// If global-settings is sorted, don't do anything.
if (config.getKeys("global-settings") != null)
return;
File oldFile = new File(this.getDataFolder(), "config_OLD.yml");
if (!oldFile.exists())
return;
System.out.println("[MobArena] Config-file appears to be old. Trying to fix it...");
Configuration oldConfig = new Configuration(oldFile);
oldConfig.load();
config.setProperty("global-settings.enabled", true);
config.save();
config.load();
config.setProperty("global-settings.update-notification", true);
config.save();
config.load();
// Copy classes
for (String s : oldConfig.getKeys("classes"))
{
config.setProperty("classes." + s + ".items", oldConfig.getString("classes." + s + ".items"));
config.setProperty("classes." + s + ".armor", oldConfig.getString("classes." + s + ".armor"));
}
config.save();
// Make the default arena node.
config.setProperty("arenas.default.settings.enabled", true);
config.save();
config.load();
config.setProperty("arenas.default.settings.world", oldConfig.getString("settings.world"));
config.save();
config.load();
// Copy the coords.
for (String s : oldConfig.getKeys("coords"))
{
if (s.equals("spawnpoints"))
continue;
StringBuffer buffy = new StringBuffer();
buffy.append(oldConfig.getString("coords." + s + ".x"));
buffy.append(",");
buffy.append(oldConfig.getString("coords." + s + ".y"));
buffy.append(",");
buffy.append(oldConfig.getString("coords." + s + ".z"));
buffy.append(",");
buffy.append(oldConfig.getString("coords." + s + ".yaw"));
buffy.append(",");
buffy.append(oldConfig.getString("coords." + s + ".pitch"));
config.setProperty("arenas.default.coords." + s, buffy.toString());
}
config.save();
config.load();
for (String s : oldConfig.getKeys("coords.spawnpoints"))
{
StringBuffer buffy = new StringBuffer();
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".x"));
buffy.append(",");
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".y"));
buffy.append(",");
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".z"));
buffy.append(",");
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".yaw"));
buffy.append(",");
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".pitch"));
config.setProperty("arenas.default.coords.spawnpoints." + s, buffy.toString());
}
config.save();
config.load();
System.out.println("[MobArena] Updated the config-file!");
}
}

View File

@ -0,0 +1,126 @@
package com.garbagemule.MobArena;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class MobArenaHandler
{
MobArena plugin;
boolean ma = false;
/**
* Primary constructor.
* The boolean 'ma' is flagged true, and the field 'plugin' is initalized, if the server is running MobArena.
*/
public MobArenaHandler()
{
Plugin maPlugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
if (maPlugin == null)
return;
ma = true;
plugin = (MobArena) maPlugin;
}
/**
* Check if a Location is inside of an arena region.
* @param loc A location.
* @return true, if the Location is inside of any arena region.
*/
public boolean inRegion(Location loc)
{
// If the plugin doesn't exist, always return false.
if (!ma || plugin.getAM() == null) return false;
// Return true if location is within just one arena's region.
for (Arena arena : plugin.getAM().arenas)
if (arena.inRegion(loc))
return true;
return false;
}
/**
* Check if a Location is inside of a specific arena region.
* @param arena An Arena object
* @param loc A location
* @return true, if the Location is inside of the arena region.
*/
public boolean inRegion(Arena arena, Location loc) { return (ma && arena != null && arena.inRegion(loc)); }
/**
* Check if a Location is inside of the region of an arena that is currently running.
* @param loc A location.
* @return true, if the Location is inside of the region of an arena that is currently running.
*/
public boolean inRunningRegion(Location loc) { return inRegion(loc, false, true); }
/**
* Check if a Location is inside of the region of an arena that is currently enabled.
* @param loc A location.
* @return true, if the Location is inside of the region of an arena that is currently enabled.
*/
public boolean inEnabledRegion(Location loc) { return inRegion(loc, true, false); }
/**
* Private helper method for inRunningRegion and inEnabledRegion
* @param loc A location
* @param enabled if true, the method will check if the arena is enabled
* @param running if true, the method will check if the arena is running, overrides enabled
* @return true, if the location is inside of the region of an arena that is currently enabled/running, depending on the parameters.
*/
private boolean inRegion(Location loc, boolean enabled, boolean running)
{
// If the plugin doesn't exist, always return false.
if (!ma || plugin.getAM() == null) return false;
// Return true if location is within just one arena's region.
for (Arena arena : plugin.getAM().arenas)
if (arena.inRegion(loc))
if ((running && arena.running) || (enabled && arena.enabled))
return true;
return false;
}
/**
* Get an Arena object at the given location.
* @param loc A location
* @return an Arena object, or null
*/
public Arena getArenaAtLocation(Location loc) { return (ma) ? plugin.getAM().getArenaAtLocation(loc) : null; }
/**
* Get the Arena object that the given player is currently in.
* @param p A player
* @return an Arena object, or null
*/
public Arena getArenaWithPlayer(Player p) { return (ma) ? plugin.getAM().getArenaWithPlayer(p) : null; }
/**
* Get the Arena object that the given pet is currently in.
* @param wolf A pet wolf
* @return an Arena object, or null
*/
public Arena getArenaWithPet(Entity wolf) { return (ma) ? plugin.getAM().getArenaWithPet(wolf) : null; }
/**
* Get the Arena object that the given monster is currently in.
* @param monster A monster
* @return an Arena object, or null
*/
public Arena getArenaWithMonster(Entity monster) { return (ma) ? plugin.getAM().getArenaWithMonster(monster) : null; }
/**
* Check if the server is running MobArena.
* @return true, if MobArena exists on the server.
*/
public boolean hasMA()
{
return ma;
}
}

View File

@ -0,0 +1,23 @@
package com.garbagemule.MobArena;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class MobArenaListener
{
protected MobArena plugin;
public MobArenaListener()
{
plugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
plugin.getAM().listeners.add(this);
}
public void onArenaStart() {}
public void onArenaEnd() {}
public void onDefaultWave(int waveNumber) {}
public void onSpecialWave(int waveNumber, int specialwaveNumber) {}
public void onPlayerJoin(Player p) {}
public void onPlayerLeave(Player p) {}
public void onPlayerDeath(Player p) {}
}

View 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();
}
}

View 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);
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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;
}
}
}

View 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;
}
}
}

View 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;
}
}
}