mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-16 20:41:56 +01:00
Bla
This commit is contained in:
parent
1498359add
commit
3d398a1899
51
language files/announcements_da.properties
Normal file
51
language files/announcements_da.properties
Normal 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>
|
51
language files/announcements_fr.properties
Normal file
51
language files/announcements_fr.properties
Normal 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>
|
51
language files/announcements_pirate.properties
Normal file
51
language files/announcements_pirate.properties
Normal 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>
|
40
src/com/garbagemule/MobArena/AbstractArena.java
Normal file
40
src/com/garbagemule/MobArena/AbstractArena.java
Normal 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
137
src/com/garbagemule/MobArena/ArenaLog.java
Normal file
137
src/com/garbagemule/MobArena/ArenaLog.java
Normal 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(); }
|
||||
}
|
@ -20,14 +20,15 @@ public class ArenaMaster
|
||||
private MobArena plugin;
|
||||
private Configuration config;
|
||||
protected Arena selectedArena;
|
||||
protected Lobby masterLobby;
|
||||
//protected Lobby masterLobby;
|
||||
|
||||
// Settings
|
||||
protected boolean enabled, updateNotify, autoEquip, emptyInvs, hellhounds;
|
||||
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
|
||||
@ -58,7 +59,16 @@ public class ArenaMaster
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
public Arena getArenaInLocation(Location loc)
|
||||
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))
|
||||
@ -197,9 +207,9 @@ public class ArenaMaster
|
||||
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");
|
||||
classes = config.getKeys("classes");
|
||||
classItems = MAUtils.getClassItems(config, "items");
|
||||
classArmor = MAUtils.getClassItems(config, "armor");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +237,7 @@ public class ArenaMaster
|
||||
world = Bukkit.getServer().getWorld(worldName);
|
||||
}
|
||||
|
||||
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world, this);
|
||||
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
|
||||
arena.load(config);
|
||||
arenas.add(arena);
|
||||
}
|
||||
@ -247,6 +257,10 @@ 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);
|
||||
config.setProperty("arenas." + configName + ".settings.detonate-damage", false);
|
||||
@ -255,12 +269,18 @@ public class ArenaMaster
|
||||
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", false);
|
||||
config.setProperty("arenas." + configName + ".settings.require-empty-inv-spec", 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);
|
||||
@ -271,7 +291,7 @@ public class ArenaMaster
|
||||
config.save();
|
||||
config.load();
|
||||
|
||||
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world, this);
|
||||
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
|
||||
arena.load(config);
|
||||
return arena;
|
||||
}
|
||||
|
@ -2,10 +2,14 @@ package com.garbagemule.MobArena;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -20,38 +24,43 @@ public class MACommands implements CommandExecutor
|
||||
public static final List<String> COMMANDS = new LinkedList<String>();
|
||||
static
|
||||
{
|
||||
COMMANDS.add("j"); // Join
|
||||
COMMANDS.add("join"); // Join
|
||||
COMMANDS.add("l"); // Leave
|
||||
COMMANDS.add("leave"); // Leave
|
||||
COMMANDS.add("notready"); // List of players who aren't ready
|
||||
COMMANDS.add("spec"); // Watch arena
|
||||
COMMANDS.add("spectate"); // Watch arena
|
||||
COMMANDS.add("arenas"); // List of arenas
|
||||
COMMANDS.add("list"); // List of players
|
||||
COMMANDS.add("players"); // List of players
|
||||
COMMANDS.add("restore"); // Restore inventory
|
||||
COMMANDS.add("enable"); // Enabling
|
||||
COMMANDS.add("disable"); // Disabling
|
||||
COMMANDS.add("protect"); // Protection on/off
|
||||
COMMANDS.add("force"); // Force start/end
|
||||
COMMANDS.add("config"); // Reload config
|
||||
COMMANDS.add("arena"); // Current arena
|
||||
COMMANDS.add("setarena"); // Set current arena
|
||||
COMMANDS.add("addarena"); // Add a new arena
|
||||
COMMANDS.add("delarena"); // Delete current aren
|
||||
COMMANDS.add("editarena"); // Editing
|
||||
COMMANDS.add("setregion"); // Set a region point
|
||||
COMMANDS.add("setwarp"); // Set arena/lobby/spec
|
||||
COMMANDS.add("spawnpoints"); // List spawnpoints
|
||||
COMMANDS.add("addspawn"); // Add a spawnpoint
|
||||
COMMANDS.add("delspawn"); // Delete a spawnpoint
|
||||
COMMANDS.add("expandregion"); // Expand the region
|
||||
COMMANDS.add("reset"); // Reset arena coordinates
|
||||
COMMANDS.add("auto-generate"); // Auto-generate arena
|
||||
COMMANDS.add("auto-degenerate"); // Restore cuboid
|
||||
COMMANDS.add("j"); // Join
|
||||
COMMANDS.add("join"); // Join
|
||||
COMMANDS.add("l"); // Leave
|
||||
COMMANDS.add("leave"); // Leave
|
||||
COMMANDS.add("notready"); // List of players who aren't ready
|
||||
COMMANDS.add("spec"); // Watch arena
|
||||
COMMANDS.add("spectate"); // Watch arena
|
||||
COMMANDS.add("arenas"); // List of arenas
|
||||
COMMANDS.add("list"); // List of players
|
||||
COMMANDS.add("players"); // List of players
|
||||
COMMANDS.add("info"); // Info/help
|
||||
COMMANDS.add("help"); // Info/help
|
||||
COMMANDS.add("restore"); // Restore inventory
|
||||
COMMANDS.add("enable"); // Enabling
|
||||
COMMANDS.add("disable"); // Disabling
|
||||
COMMANDS.add("protect"); // Protection on/off
|
||||
COMMANDS.add("force"); // Force start/end
|
||||
COMMANDS.add("config"); // Reload config
|
||||
COMMANDS.add("arena"); // Current arena
|
||||
COMMANDS.add("setarena"); // Set current arena
|
||||
COMMANDS.add("addarena"); // Add a new arena
|
||||
COMMANDS.add("delarena"); // Delete current aren
|
||||
COMMANDS.add("editarena"); // Editing
|
||||
COMMANDS.add("setregion"); // Set a region point
|
||||
COMMANDS.add("expandregion"); // Expand the region
|
||||
COMMANDS.add("showregion"); // Show the region
|
||||
COMMANDS.add("setlobbyregion"); // Set a region point
|
||||
COMMANDS.add("expandlobbyregion"); // Expand the region
|
||||
COMMANDS.add("setwarp"); // Set arena/lobby/spec
|
||||
COMMANDS.add("spawnpoints"); // List spawnpoints
|
||||
COMMANDS.add("addspawn"); // Add a spawnpoint
|
||||
COMMANDS.add("delspawn"); // Delete a spawnpoint
|
||||
COMMANDS.add("reset"); // Reset arena coordinates
|
||||
COMMANDS.add("auto-generate"); // Auto-generate arena
|
||||
COMMANDS.add("auto-degenerate"); // Restore cuboid
|
||||
}
|
||||
private boolean player, op, console, meanAdmins;
|
||||
private boolean meanAdmins, showingRegion;
|
||||
private Server server;
|
||||
private MobArena plugin;
|
||||
private ArenaMaster am;
|
||||
@ -80,9 +89,9 @@ public class MACommands implements CommandExecutor
|
||||
}
|
||||
|
||||
// Determine if the sender is a player (and an op), or the console.
|
||||
player = (sender instanceof Player);
|
||||
op = player && ((Player) sender).isOp();
|
||||
console = (sender instanceof ConsoleCommandSender);
|
||||
boolean player = (sender instanceof Player);
|
||||
boolean op = player && ((Player) sender).isOp();
|
||||
boolean console = (sender instanceof ConsoleCommandSender);
|
||||
|
||||
// Cast the sender to Player if possible.
|
||||
Player p = (player) ? (Player)sender : null;
|
||||
@ -94,6 +103,7 @@ public class MACommands implements CommandExecutor
|
||||
String base = args[0].toLowerCase();
|
||||
String arg1 = (args.length > 1) ? args[1].toLowerCase() : "";
|
||||
String arg2 = (args.length > 2) ? args[2].toLowerCase() : "";
|
||||
String arg3 = (args.length > 3) ? args[3].toLowerCase() : "";
|
||||
|
||||
|
||||
|
||||
@ -108,91 +118,79 @@ 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;
|
||||
}
|
||||
List<Arena> arenas = am.getEnabledArenas();
|
||||
if (!am.enabled || arenas.size() < 1)
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_NOT_ENABLED));
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean error;
|
||||
Arena arena;
|
||||
|
||||
if (!arg1.isEmpty())
|
||||
{
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
|
||||
// Crap-load of sanity-checks.
|
||||
if (!am.enabled)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_NOT_ENABLED));
|
||||
else if (arena == null)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
else if (am.arenaMap.containsKey(p) && am.arenaMap.get(p).livePlayers.contains(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_IN_OTHER_ARENA));
|
||||
else if (!arena.enabled)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_ENABLED));
|
||||
else if (!arena.setup)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_SETUP));
|
||||
else if (arena.running)
|
||||
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 (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
||||
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_STORE_INV_FAIL));
|
||||
else error = false;
|
||||
|
||||
// If there was an error, don't join.
|
||||
if (error)
|
||||
return true;
|
||||
|
||||
am.arenaMap.put(p,arena);
|
||||
arena.playerJoin(p, p.getLocation());
|
||||
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_JOINED));
|
||||
return true;
|
||||
}
|
||||
arena = am.getArenaWithName(arg1);
|
||||
else if (arenas.size() == 1)
|
||||
arena = arenas.get(0);
|
||||
else
|
||||
arena = null;
|
||||
|
||||
if (arenas.size() > 1 && arg1.isEmpty())
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARG_NEEDED));
|
||||
else if (arena == null)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
//else if (am.arenaMap.containsKey(p) && am.arenaMap.get(p).livePlayers.contains(p))
|
||||
else if (am.arenaMap.containsKey(p) && (am.arenaMap.get(p).arenaPlayers.contains(p) || am.arenaMap.get(p).lobbyPlayers.contains(p)))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_IN_OTHER_ARENA));
|
||||
else if (!arena.enabled)
|
||||
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 && arena.waitPlayers.add(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
|
||||
//else if (arena.livePlayers.contains(p))
|
||||
else if (arena.arenaPlayers.contains(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
|
||||
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)
|
||||
else if (arena.playerLimit > 0 && arena.lobbyPlayers.size() >= arena.playerLimit)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_LIMIT_REACHED));
|
||||
else if (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
||||
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_STORE_INV_FAIL));
|
||||
else if (arena.joinDistance > 0 && !arena.inRegionRadius(p.getLocation(), arena.joinDistance))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_TOO_FAR));
|
||||
else error = false;
|
||||
|
||||
// If there was an error, don't join.
|
||||
if (error)
|
||||
{
|
||||
if (am.arenas.size() < 1)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "There are no arenas loaded. Check your config-file.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Arena arena = am.arenas.get(0);
|
||||
|
||||
if (!am.enabled)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_NOT_ENABLED));
|
||||
else if (am.arenas.size() > 1)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARG_NEEDED));
|
||||
else if (arena == null)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
else if (am.arenaMap.containsKey(p) && am.arenaMap.get(p).livePlayers.contains(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_IN_OTHER_ARENA));
|
||||
else if (!arena.enabled)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_ENABLED));
|
||||
else if (!arena.setup)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_SETUP));
|
||||
else if (arena.running)
|
||||
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 (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
||||
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_STORE_INV_FAIL));
|
||||
else error = false;
|
||||
|
||||
// If there was an error, don't join.
|
||||
if (error)
|
||||
return true;
|
||||
|
||||
am.arenaMap.put(p,arena);
|
||||
arena.playerJoin(p, p.getLocation());
|
||||
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_JOINED));
|
||||
if (arena != null)
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -200,7 +198,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;
|
||||
@ -230,54 +228,60 @@ public class MACommands implements CommandExecutor
|
||||
* Player spectate
|
||||
*/
|
||||
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;
|
||||
}
|
||||
List<Arena> arenas = am.getEnabledArenas();
|
||||
if (!am.enabled || arenas.size() < 1)
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_NOT_ENABLED));
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean error;
|
||||
Arena arena = null;
|
||||
Arena arena;
|
||||
|
||||
if (!arg1.isEmpty())
|
||||
{
|
||||
arena = am.getArenaWithName(arg1);
|
||||
|
||||
if (!am.enabled)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_NOT_ENABLED));
|
||||
else if (am.arenaMap.containsKey(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_ALREADY_PLAYING));
|
||||
else if (arena == null)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
else if (arena.emptyInvSpec && !MAUtils.hasEmptyInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_EMPTY_INV));
|
||||
else error = false;
|
||||
|
||||
if (error)
|
||||
return true;
|
||||
}
|
||||
else if (arenas.size() == 1)
|
||||
arena = arenas.get(0);
|
||||
else
|
||||
{
|
||||
arena = am.arenas.get(0);
|
||||
|
||||
if (!am.enabled)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_NOT_ENABLED));
|
||||
else if (am.arenaMap.containsKey(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_ALREADY_PLAYING));
|
||||
else if (am.arenas.size() > 1)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARG_NEEDED));
|
||||
else if (arena == null)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
else if (arena.emptyInvSpec && !MAUtils.hasEmptyInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_EMPTY_INV));
|
||||
else error = false;
|
||||
|
||||
if (error)
|
||||
return true;
|
||||
}
|
||||
|
||||
arena = null;
|
||||
|
||||
if (arenas.size() > 1 && arg1.isEmpty())
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARG_NEEDED));
|
||||
else if (arena == null)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
//else if (am.arenaMap.containsKey(p) && am.arenaMap.get(p).livePlayers.contains(p))
|
||||
else if (am.arenaMap.containsKey(p) && (am.arenaMap.get(p).arenaPlayers.contains(p) || am.arenaMap.get(p).lobbyPlayers.contains(p)))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_IN_OTHER_ARENA));
|
||||
else if (!arena.enabled)
|
||||
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.livePlayers.contains(p))
|
||||
else if (arena.arenaPlayers.contains(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_ALREADY_PLAYING));
|
||||
else if (arena.emptyInvSpec && !MAUtils.hasEmptyInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_EMPTY_INV));
|
||||
else if (arena.joinDistance > 0 && !arena.inRegionRadius(p.getLocation(), arena.joinDistance))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_TOO_FAR));
|
||||
else error = false;
|
||||
|
||||
// If there was an error, don't spec.
|
||||
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());
|
||||
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_PLAYER_SPECTATE));
|
||||
return true;
|
||||
}
|
||||
@ -287,7 +291,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;
|
||||
}
|
||||
@ -306,14 +310,16 @@ 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
|
||||
{
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
List<Player> players = new LinkedList<Player>();
|
||||
for (Arena arena : am.arenas)
|
||||
buffy.append(MAUtils.listToString(arena.getLivingPlayers(), false));
|
||||
players.addAll(arena.getLivingPlayers());
|
||||
buffy.append(MAUtils.listToString(players, plugin));
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, buffy.toString()));
|
||||
}
|
||||
return true;
|
||||
@ -349,7 +355,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;
|
||||
}
|
||||
@ -367,7 +373,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;
|
||||
@ -397,33 +403,37 @@ public class MACommands implements CommandExecutor
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable or disable protection
|
||||
* Kick player from whichever arena they are in.
|
||||
*/
|
||||
if (base.equals("protect"))
|
||||
if (base.equals("kick"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.protect")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.admin.kick")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1.isEmpty() || !arg1.matches("^[a-zA-Z][a-zA-Z0-9_]*$") || !(arg2.equals("true") || arg2.equals("false")))
|
||||
|
||||
if (arg1.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma protect <arena name> [true|false]");
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma kick <player>");
|
||||
return true;
|
||||
}
|
||||
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
Arena arena = am.getArenaWithPlayer(arg1);
|
||||
if (arena == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
MAUtils.tellPlayer(sender, "That player is not in an arena.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player pl = server.getPlayer(arg1);
|
||||
am.arenaMap.remove(pl);
|
||||
arena.playerLeave(pl);
|
||||
MAUtils.tellPlayer(sender, "Player '" + arg1 + "' was kicked from arena '" + arena.configName() + "'.");
|
||||
MAUtils.tellPlayer(pl, "You were kicked by " + ((player) ? p.getName() : "the server."));
|
||||
return true;
|
||||
}
|
||||
|
||||
arena.protect = arg2.equals("true");
|
||||
arena.serializeConfig();
|
||||
arena.load(plugin.getConfig());
|
||||
MAUtils.tellPlayer(sender, "Protection for arena '" + arg1 + "' set to " + arg2);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -431,7 +441,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;
|
||||
@ -454,11 +464,11 @@ public class MACommands implements CommandExecutor
|
||||
/*
|
||||
* Force start/end arenas.
|
||||
*/
|
||||
if (base.equals("force") && arg1.equals("end"))
|
||||
if (base.equals("force"))
|
||||
{
|
||||
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;
|
||||
@ -480,7 +490,8 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arena.livePlayers.isEmpty())
|
||||
//if (arena.livePlayers.isEmpty())
|
||||
if (arena.arenaPlayers.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_END_EMPTY));
|
||||
return true;
|
||||
@ -492,7 +503,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;
|
||||
@ -538,7 +549,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;
|
||||
@ -560,7 +571,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;
|
||||
@ -586,7 +597,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;
|
||||
@ -615,7 +626,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;
|
||||
@ -643,7 +654,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;
|
||||
@ -674,28 +685,137 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
if (base.equals("editarena"))
|
||||
/*
|
||||
* Enable or disable protection
|
||||
*/
|
||||
if (base.equals("protect"))
|
||||
{
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.editarena")) && !op)
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.protect")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1.isEmpty() || !(arg2.equals("true") || arg2.equals("false")))
|
||||
|
||||
Arena arena;
|
||||
|
||||
// No arguments
|
||||
if (arg1.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma editarena <arena name> [true|false]");
|
||||
arena = am.selectedArena;
|
||||
arena.protect = !arena.protect;
|
||||
}
|
||||
|
||||
// One argument
|
||||
else if (arg2.isEmpty())
|
||||
{
|
||||
// true/false
|
||||
if (arg1.equals("true") || arg1.equals("false"))
|
||||
{
|
||||
arena = am.selectedArena;
|
||||
arena.protect = arg1.equals("true");
|
||||
}
|
||||
// Arena name
|
||||
else
|
||||
{
|
||||
arena = am.getArenaWithName(arg1);
|
||||
if (arena == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "There is no arena with that name.");
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma protect ([true|false])");
|
||||
MAUtils.tellPlayer(sender, " or /ma protect <arena name> ([true|false])");
|
||||
return true;
|
||||
}
|
||||
arena.protect = !arena.protect;
|
||||
}
|
||||
}
|
||||
|
||||
// Two arguments
|
||||
else
|
||||
{
|
||||
if (!(arg2.equals("true") || arg2.equals("false")))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma protect ([true|false])");
|
||||
MAUtils.tellPlayer(sender, " or /ma protect <arena name> ([true|false])");
|
||||
return true;
|
||||
}
|
||||
arena = am.getArenaWithName(arg1);
|
||||
if (arena == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "There is no arena with that name.");
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma protect ([true|false])");
|
||||
MAUtils.tellPlayer(sender, " or /ma protect <arena name> ([true|false])");
|
||||
return true;
|
||||
}
|
||||
arena.protect = arg2.equals("true");
|
||||
}
|
||||
|
||||
arena.serializeConfig();
|
||||
MAUtils.tellPlayer(sender, "Protection for arena '" + arena.configName() + "': " + ((arena.protect) ? ChatColor.GREEN + "on" : ChatColor.RED + "off"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (base.equals("editarena"))
|
||||
{
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.editarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
if (arena == null)
|
||||
Arena arena;
|
||||
|
||||
// No arguments.
|
||||
if (arg1.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "There is no arena with that name.");
|
||||
return true;
|
||||
arena = am.selectedArena;
|
||||
arena.edit = !arena.edit;
|
||||
}
|
||||
|
||||
arena.edit = arg2.equals("true");
|
||||
MAUtils.tellPlayer(sender, "Edit mode for arena '" + arg1 + "': " + ((arena.edit) ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
||||
// One argument.
|
||||
else if (arg2.isEmpty())
|
||||
{
|
||||
// Argument is [true|false]
|
||||
if (arg1.equals("true") || arg1.equals("false"))
|
||||
{
|
||||
arena = am.selectedArena;
|
||||
arena.edit = arg1.equals("true");
|
||||
}
|
||||
// Argument is <arena name>
|
||||
else
|
||||
{
|
||||
arena = am.getArenaWithName(arg1);
|
||||
if (arena == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "There is no arena with that name.");
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma editarena ([true|false])");
|
||||
MAUtils.tellPlayer(sender, " or /ma editarena <arena name> ([true|false])");
|
||||
return true;
|
||||
}
|
||||
arena.edit = !arena.edit;
|
||||
}
|
||||
}
|
||||
|
||||
// Two arguments
|
||||
else
|
||||
{
|
||||
if (!(arg2.equals("true") || arg2.equals("false")))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma editarena ([true|false])");
|
||||
MAUtils.tellPlayer(sender, " or /ma editarena <arena name> ([true|false])");
|
||||
return true;
|
||||
}
|
||||
arena = am.getArenaWithName(arg1);
|
||||
if (arena == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "There is no arena with that name.");
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma editarena ([true|false])");
|
||||
MAUtils.tellPlayer(sender, " or /ma editarena <arena name> ([true|false])");
|
||||
return true;
|
||||
}
|
||||
arena.edit = arg2.equals("true");
|
||||
}
|
||||
|
||||
MAUtils.tellPlayer(sender, "Edit mode for arena '" + arena.configName() + "': " + ((arena.edit) ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
||||
if (arena.edit) MAUtils.tellPlayer(sender, "Remember to turn it back off after editing!");
|
||||
return true;
|
||||
}
|
||||
@ -705,7 +825,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;
|
||||
@ -727,7 +847,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;
|
||||
@ -737,6 +857,11 @@ public class MACommands implements CommandExecutor
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma expandregion <amount> [up|down|out]");
|
||||
return true;
|
||||
}
|
||||
if (am.selectedArena.p1 == null || am.selectedArena.p2 == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "You must first define p1 and p2");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg2.equals("up"))
|
||||
{
|
||||
@ -765,12 +890,128 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
if (base.equals("showregion"))
|
||||
{
|
||||
if (!(player && plugin.has(p, "mobarena.setup.showregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (am.selectedArena.p1 == null || am.selectedArena.p2 == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "The region is not defined for the selected arena.");
|
||||
return true;
|
||||
}
|
||||
if (showingRegion || !am.selectedArena.edit)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Must be in edit mode.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Material mat = Material.WOOL;
|
||||
byte color = (byte)0;
|
||||
|
||||
if (arg1.equals("glowstone"))
|
||||
mat = Material.GLOWSTONE;
|
||||
else if (arg1.equals("white") || arg1.equals("red") || arg1.equals("blue"))
|
||||
color = DyeColor.valueOf(arg1.toUpperCase()).getData();
|
||||
else if (arg1.equals("green")) // Dark green sucks
|
||||
color = 0x5;
|
||||
else
|
||||
mat = Material.GLASS;
|
||||
|
||||
// Set the variable so we don't overwrite the region.
|
||||
showingRegion = true;
|
||||
|
||||
// Show the frame.
|
||||
final World world = am.selectedArena.world;
|
||||
final Set<int[]> blocks = MAUtils.showRegion(world, am.selectedArena.p1, am.selectedArena.p2, mat.getId(), color);
|
||||
|
||||
// And hide the frame.
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (int[] buffer : blocks)
|
||||
world.getBlockAt(buffer[0], buffer[1], buffer[2]).setTypeIdAndData(buffer[3], (byte) 0, false);
|
||||
showingRegion = false;
|
||||
}
|
||||
}, 2*20);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (base.equals("setlobbyregion"))
|
||||
{
|
||||
if (!(player && plugin.has(p, "mobarena.setup.setlobbyregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(arg1.equals("l1") || arg1.equals("l2")))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma setlobbyregion [l1|l2]");
|
||||
return true;
|
||||
}
|
||||
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), am.selectedArena, arg1, p.getLocation());
|
||||
MAUtils.tellPlayer(sender, "Set lobby point " + arg1 + " for arena '" + am.selectedArena.configName() + "'");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (base.equals("expandlobbyregion"))
|
||||
{
|
||||
if (!console && !(player && plugin.has(p, "mobarena.setup.expandlobbyregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (args.length != 3 || !arg1.matches("[0-9]+"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma expandlobbyregion <amount> [up|down|out]");
|
||||
return true;
|
||||
}
|
||||
if (am.selectedArena.l1 == null || am.selectedArena.l2 == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "You must first define l1 and l2");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg2.equals("up"))
|
||||
{
|
||||
am.selectedArena.l2.setY(Math.min(127, am.selectedArena.l2.getY() + Integer.parseInt(arg1)));
|
||||
}
|
||||
else if (arg2.equals("down"))
|
||||
{
|
||||
am.selectedArena.l1.setY(Math.max(0, am.selectedArena.l1.getY() - Integer.parseInt(arg1)));
|
||||
}
|
||||
else if (arg2.equals("out"))
|
||||
{
|
||||
am.selectedArena.l1.setX(am.selectedArena.l1.getX() - Integer.parseInt(arg1));
|
||||
am.selectedArena.l1.setZ(am.selectedArena.l1.getZ() - Integer.parseInt(arg1));
|
||||
am.selectedArena.l2.setX(am.selectedArena.l2.getX() + Integer.parseInt(arg1));
|
||||
am.selectedArena.l2.setZ(am.selectedArena.l2.getZ() + Integer.parseInt(arg1));
|
||||
}
|
||||
else
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma expandlobbyregion <amount> [up|down|out]");
|
||||
return true;
|
||||
}
|
||||
|
||||
MAUtils.tellPlayer(sender, "Lobby region for '" + am.selectedArena.configName() + "' expanded " + arg2 + " by " + arg1 + " blocks.");
|
||||
am.selectedArena.serializeConfig();
|
||||
am.selectedArena.load(plugin.getConfig());
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set warp points [arena|lobby|spectator] for the current arena.
|
||||
*/
|
||||
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;
|
||||
@ -780,8 +1021,8 @@ public class MACommands implements CommandExecutor
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma setwarp [arena|lobby|spectator]");
|
||||
return true;
|
||||
}
|
||||
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), am.selectedArena, arg1, p.getLocation().getBlock().getRelative(0,1,0).getLocation());
|
||||
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), am.selectedArena, arg1, p.getLocation());
|
||||
MAUtils.tellPlayer(sender, "Set warp point " + arg1 + " for arena '" + am.selectedArena.configName() + "'");
|
||||
return true;
|
||||
}
|
||||
@ -791,7 +1032,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;
|
||||
@ -822,7 +1063,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;
|
||||
@ -843,7 +1084,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;
|
||||
@ -863,7 +1104,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;
|
||||
@ -888,7 +1129,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;
|
||||
@ -916,6 +1157,55 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
if (base.equals("dooooo") && arg1.equals("it") && arg2.equals("hippie") && arg3.equals("monster"))
|
||||
{
|
||||
if (!(player && plugin.has(p, "mobarena.setup.autogenerate")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = "a0";
|
||||
do name = name.substring(0,1) + (Integer.parseInt(name.substring(1,2)) + 1);
|
||||
while (am.getArenaWithName(name) != null);
|
||||
|
||||
if (MAUtils.doooooItHippieMonster(p.getLocation(), 13, name, plugin))
|
||||
MAUtils.tellPlayer(sender, "Arena with name '" + name + "' generated.");
|
||||
else
|
||||
MAUtils.tellPlayer(sender, "Could not auto-generate arena.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (base.equals("undo") && arg1.equals("it") && arg2.equals("hippie") && arg3.equals("monster"))
|
||||
{
|
||||
if (!(player && plugin.has(p, "mobarena.setup.autodegenerate")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (am.arenas.size() < 2)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "At least one arena must exist!");
|
||||
return true;
|
||||
}
|
||||
if (am.getArenaWithName("a1") == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = "a1";
|
||||
while (am.getArenaWithName(name) != null)
|
||||
name = name.substring(0,1) + (Integer.parseInt(name.substring(1,2)) + 1);
|
||||
name = name.substring(0,1) + (Integer.parseInt(name.substring(1,2)) - 1);
|
||||
|
||||
if (MAUtils.undoItHippieMonster(name, plugin, true))
|
||||
MAUtils.tellPlayer(sender, "Arena with name '" + name + "' degenerated.");
|
||||
else
|
||||
MAUtils.tellPlayer(sender, "Could not degenerate arena.");
|
||||
return true;
|
||||
}
|
||||
|
||||
MAUtils.tellPlayer(sender, "Command not found.");
|
||||
return true;
|
||||
}
|
||||
|
@ -3,8 +3,9 @@ package com.garbagemule.MobArena;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -22,10 +23,15 @@ public class MAMessages
|
||||
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,
|
||||
@ -44,6 +50,7 @@ public class MAMessages
|
||||
FORCE_END_IDLE,
|
||||
REWARDS_GIVE,
|
||||
LOBBY_CLASS_PICKED,
|
||||
LOBBY_CLASS_RANDOM,
|
||||
LOBBY_CLASS_PERMISSION,
|
||||
LOBBY_PLAYER_READY,
|
||||
LOBBY_DROP_ITEM,
|
||||
@ -54,7 +61,6 @@ public class MAMessages
|
||||
WAVE_DEFAULT,
|
||||
WAVE_SPECIAL,
|
||||
WAVE_REWARD,
|
||||
// Misc
|
||||
MISC_LIST_ARENAS,
|
||||
MISC_LIST_PLAYERS,
|
||||
MISC_COMMAND_NOT_ALLOWED,
|
||||
@ -72,10 +78,15 @@ public class MAMessages
|
||||
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.");
|
||||
@ -94,11 +105,12 @@ 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.");
|
||||
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!");
|
||||
@ -108,7 +120,7 @@ public class MAMessages
|
||||
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 comand.");
|
||||
defaults.put(Msg.MISC_NO_ACCESS, "You don't have access to this command.");
|
||||
defaults.put(Msg.MISC_NONE, "<none>");
|
||||
}
|
||||
|
||||
@ -132,10 +144,7 @@ public class MAMessages
|
||||
System.out.println("[MobArena] Announcements-file not found. Creating one...");
|
||||
msgFile.createNewFile();
|
||||
|
||||
FileWriter fw = new FileWriter(msgFile);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
|
||||
// Write default announcements to the file.
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(msgFile));
|
||||
for (Msg m : Msg.values())
|
||||
{
|
||||
bw.write(m.toString() + "=" + defaults.get(m));
|
||||
@ -148,26 +157,29 @@ public class MAMessages
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("[MobArena] ERROR: Couldn't initialize announcements-file. Using defaults.");
|
||||
System.out.println("[MobArena] ERROR! Couldn't initialize announcements-file. Using defaults.");
|
||||
return;
|
||||
}
|
||||
|
||||
// If the file was found, populate the msgMap.
|
||||
try
|
||||
{
|
||||
FileReader fr = new FileReader(msgFile);
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
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)
|
||||
{
|
||||
System.out.println("[MobArena] ERROR: Problem with announcements-file. Using defaults.");
|
||||
e.printStackTrace();
|
||||
System.out.println("[MobArena] ERROR! Problem with announcements-file. Using defaults.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -209,7 +221,7 @@ public class MAMessages
|
||||
String[] split = s.split("=");
|
||||
if (split.length != 2)
|
||||
{
|
||||
System.out.println("[MobArena] ERROR: Couldn't parse \"" + s + "\". Check announcements-file.");
|
||||
System.out.println("[MobArena] ERROR! Couldn't parse \"" + s + "\". Check announcements-file.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -225,7 +237,7 @@ public class MAMessages
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("[MobArena] ERROR: " + key + " is not a valid key. Check announcements-file.");
|
||||
System.out.println("[MobArena] ERROR! " + key + " is not a valid key. Check announcements-file.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
@ -75,7 +75,7 @@ public class MAPlayerListener extends PlayerListener
|
||||
if (!am.updateNotify || !event.getPlayer().isOp()) return;
|
||||
|
||||
final Player p = event.getPlayer();
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask(plugin,
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -40,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)
|
||||
{
|
||||
@ -51,11 +51,13 @@ public class MASpawnThread implements Runnable
|
||||
|
||||
taskId = -32768;
|
||||
|
||||
noOfPlayers = arena.livePlayers.size();
|
||||
//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");
|
||||
@ -72,16 +74,18 @@ public class MASpawnThread implements Runnable
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// If maxIdleTime is defined, reset the timer.
|
||||
//if (arena.maxIdleTime > 0) arena.resetIdleTimer();
|
||||
|
||||
// Check if we need to grant more rewards with the recurrent waves.
|
||||
for (Map.Entry<Integer,List<ItemStack>> entry : arena.everyWaveMap.entrySet())
|
||||
@ -115,7 +119,7 @@ public class MASpawnThread implements Runnable
|
||||
}
|
||||
|
||||
wave++;
|
||||
if (arena.maxIdleTime > 0) arena.resetIdleTimer();
|
||||
if (arena.maxIdleTime > 0 && arena.monsters.isEmpty()) arena.resetIdleTimer();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,12 +127,30 @@ public class MASpawnThread implements Runnable
|
||||
*/
|
||||
private void addReward(List<ItemStack> rewards)
|
||||
{
|
||||
for (Player p : arena.livePlayers)
|
||||
//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);
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,6 +185,9 @@ public class MASpawnThread implements Runnable
|
||||
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));
|
||||
@ -195,7 +220,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:
|
||||
@ -237,7 +261,7 @@ public class MASpawnThread implements Runnable
|
||||
arena.monsters.add(e);
|
||||
|
||||
if (slime) ((Slime)e).setSize(2);
|
||||
if (wolf) ((Wolf)e).setAngry(true);
|
||||
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);
|
||||
|
||||
@ -294,9 +318,18 @@ public class MASpawnThread implements Runnable
|
||||
|
||||
for (Location s : arena.spawnpoints.values())
|
||||
{
|
||||
for (Player p : arena.livePlayers)
|
||||
//for (Player p : arena.livePlayers)
|
||||
for (Player p : arena.arenaPlayers)
|
||||
{
|
||||
if (s.distanceSquared(p.getLocation()) > MIN_DISTANCE)
|
||||
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);
|
||||
@ -324,11 +357,18 @@ public class MASpawnThread implements Runnable
|
||||
|
||||
/* 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.livePlayers)
|
||||
for (Player p : arena.arenaPlayers)
|
||||
{
|
||||
dist = p.getLocation().distance(e.getLocation());
|
||||
//double dist = MAUtils.distance(p.getLocation(), e.getLocation());
|
||||
if (dist < current && dist < 256)
|
||||
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;
|
||||
@ -336,4 +376,27 @@ public class MASpawnThread implements Runnable
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Location;
|
||||
@ -96,6 +97,7 @@ public class MAUtils
|
||||
HELMETS_TYPE.add(Material.CHAINMAIL_HELMET);
|
||||
HELMETS_TYPE.add(Material.IRON_HELMET);
|
||||
HELMETS_TYPE.add(Material.DIAMOND_HELMET);
|
||||
HELMETS_TYPE.add(Material.PUMPKIN);
|
||||
|
||||
CHESTPLATES_TYPE.add(Material.LEATHER_CHESTPLATE);
|
||||
CHESTPLATES_TYPE.add(Material.GOLD_CHESTPLATE);
|
||||
@ -159,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.
|
||||
@ -166,8 +173,9 @@ public class MAUtils
|
||||
public static List<ItemStack> makeItemStackList(String string)
|
||||
{
|
||||
List<ItemStack> result = new LinkedList<ItemStack>();
|
||||
if (string == null) return result;
|
||||
if (string == null || string.isEmpty()) return result;
|
||||
|
||||
// Trim commas and whitespace, and split items by commas
|
||||
string = string.trim();
|
||||
if (string.endsWith(","))
|
||||
string = string.substring(0, string.length()-1);
|
||||
@ -175,20 +183,27 @@ public class MAUtils
|
||||
|
||||
for (String item : items)
|
||||
{
|
||||
// Trim whitespace and split by colons.
|
||||
item = item.trim();
|
||||
String[] parts = item.split(":");
|
||||
|
||||
// Grab the amount.
|
||||
int amount = (parts.length == 2 && parts[1].matches("[0-9]+")) ?
|
||||
Integer.parseInt(parts[1]) :
|
||||
1;
|
||||
int amount = 1;
|
||||
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[0].matches("[0-9]+")) ?
|
||||
makeItemStack(Integer.parseInt(parts[0]), amount) :
|
||||
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;
|
||||
}
|
||||
@ -241,33 +256,26 @@ public class MAUtils
|
||||
*/
|
||||
public static Map<String,Integer> getArenaDistributions(Configuration config, String arena, String wave)
|
||||
{
|
||||
//config.load();
|
||||
String arenaPath = "arenas." + arena + ".waves." + wave;
|
||||
Map<String,Integer> result = new HashMap<String,Integer>();
|
||||
List<String> dists = config.getKeys(arenaPath);
|
||||
List<String> dists = (config.getKeys(arenaPath) != null) ? config.getKeys(arenaPath) : new LinkedList<String>();
|
||||
|
||||
// If there are no distributions yet, add them.
|
||||
if (dists == null)
|
||||
String[] monsters = (wave.equals("default")) ? new String[]{"zombies", "skeletons", "spiders", "creepers", "wolves"}
|
||||
: new String[]{"powered-creepers", "zombie-pigmen", "slimes", "humans", "angry-wolves", "giants", "ghasts"};
|
||||
boolean update = false;
|
||||
for (String monster : monsters)
|
||||
{
|
||||
if (wave.equals("default"))
|
||||
{
|
||||
config.setProperty(arenaPath + ".zombies", 10);
|
||||
config.setProperty(arenaPath + ".skeletons", 10);
|
||||
config.setProperty(arenaPath + ".spiders", 10);
|
||||
config.setProperty(arenaPath + ".creepers", 10);
|
||||
config.setProperty(arenaPath + ".wolves", 10);
|
||||
}
|
||||
else if (wave.equals("special"))
|
||||
{
|
||||
config.setProperty(arenaPath + ".powered-creepers", 10);
|
||||
config.setProperty(arenaPath + ".zombie-pigmen", 10);
|
||||
config.setProperty(arenaPath + ".slimes", 10);
|
||||
config.setProperty(arenaPath + ".humans", 10);
|
||||
config.setProperty(arenaPath + ".angry-wolves", 10);
|
||||
config.setProperty(arenaPath + ".giants", 0);
|
||||
config.setProperty(arenaPath + ".ghasts", 0);
|
||||
}
|
||||
//config.save();
|
||||
if (dists.contains(monster))
|
||||
continue;
|
||||
|
||||
//if (config.getInt(arenaPath + "." + m, -1) == -1)
|
||||
config.setProperty(arenaPath + "." + monster, (monster.equals("giants") || monster.equals("ghasts")) ? 0 : 10);
|
||||
update = true;
|
||||
}
|
||||
|
||||
if (update)
|
||||
{
|
||||
config.save();
|
||||
dists = config.getKeys(arenaPath);
|
||||
}
|
||||
|
||||
@ -283,8 +291,8 @@ public class MAUtils
|
||||
value = 0;
|
||||
|
||||
config.setProperty(arenaPath + "." + monster, value);
|
||||
//config.save();
|
||||
}
|
||||
config.save();
|
||||
|
||||
result.put(monster, value);
|
||||
}
|
||||
@ -329,14 +337,14 @@ public class MAUtils
|
||||
// Grab the contents.
|
||||
ItemStack[] armor = p.getInventory().getArmorContents();
|
||||
ItemStack[] items = p.getInventory().getContents();
|
||||
|
||||
|
||||
String invPath = "plugins" + sep + "MobArena" + sep + "inventories";
|
||||
new File(invPath).mkdir();
|
||||
File backupFile = new File(invPath + sep + p.getName() + ".inv");
|
||||
|
||||
try
|
||||
{
|
||||
if (backupFile.exists())
|
||||
if (backupFile.exists() && !restoreInventory(p))
|
||||
return false;
|
||||
|
||||
backupFile.createNewFile();
|
||||
@ -443,12 +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)
|
||||
{
|
||||
@ -456,30 +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);
|
||||
|
||||
|
||||
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)
|
||||
@ -513,12 +533,29 @@ public class MAUtils
|
||||
}
|
||||
|
||||
/* Helper methods for making ItemStacks out of strings and ints */
|
||||
private static ItemStack makeItemStack(String name, int amount)
|
||||
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
|
||||
{
|
||||
Material material = Material.valueOf(name.toUpperCase());
|
||||
return new ItemStack(material, amount);
|
||||
byte offset = 0;
|
||||
|
||||
Material material = (name.matches("[0-9]+")) ?
|
||||
Material.getMaterial(Integer.parseInt(name)) :
|
||||
Material.valueOf(name.toUpperCase());
|
||||
|
||||
if (material == Material.INK_SACK)
|
||||
offset = 15;
|
||||
|
||||
DyeColor dye = (data.matches("[0-9]+")) ?
|
||||
DyeColor.getByData((byte) Math.abs(offset - Integer.parseInt(data))) :
|
||||
DyeColor.valueOf(data.toUpperCase());
|
||||
|
||||
//return new ItemStack(material, amount, (byte) Math.abs((offset - dye.getData())));
|
||||
return new ItemStack(material, amount, (byte) Math.abs(offset - dye.getData()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -526,24 +563,17 @@ public class MAUtils
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack makeItemStack(int id, int amount)
|
||||
public static ItemStack makeItemStack(String name, int amount)
|
||||
{
|
||||
try
|
||||
{
|
||||
Material material = Material.getMaterial(id);
|
||||
return new ItemStack(material, amount);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("[MobArena] ERROR! Could not create item with id " + id + ". Check config.yml");
|
||||
return null;
|
||||
}
|
||||
return makeItemStack(name, amount, "0");
|
||||
}
|
||||
|
||||
/* Helper method for grabbing a random reward */
|
||||
public static ItemStack getRandomReward(List<ItemStack> rewards)
|
||||
{
|
||||
if (rewards.isEmpty())
|
||||
return null;
|
||||
|
||||
Random ran = new Random();
|
||||
return rewards.get(ran.nextInt(rewards.size()));
|
||||
}
|
||||
@ -561,21 +591,27 @@ public class MAUtils
|
||||
*/
|
||||
public static void sitPets(Player p)
|
||||
{
|
||||
if (p == null)
|
||||
{
|
||||
System.out.println("Player is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Entity> entities = p.getNearbyEntities(80, 40, 80);
|
||||
for (Entity e : entities)
|
||||
{
|
||||
if (!(e instanceof Wolf))
|
||||
continue;
|
||||
|
||||
Wolf w = (Wolf) e;
|
||||
if (w.getOwner().equals(p))
|
||||
Wolf w = (Wolf) e;
|
||||
if (w.isTamed() && w.getOwner() != null && w.getOwner().equals(p))
|
||||
w.setSitting(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all the pets belonging to this player.
|
||||
*/
|
||||
*//*
|
||||
public static void clearPets(Arena arena, Player p)
|
||||
{
|
||||
for (Wolf w : arena.pets)
|
||||
@ -583,7 +619,7 @@ public class MAUtils
|
||||
if (w.getOwner().equals(p))
|
||||
w.remove();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
@ -593,6 +629,91 @@ public class MAUtils
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////// */
|
||||
|
||||
/**
|
||||
* Create a frame spanned by the two input coordinates.
|
||||
* @return An int arry holding x,y,z and the original type IDs of each block.
|
||||
*/
|
||||
public static Set<int[]> showRegion(World world, Location p1, Location p2, int id, byte color)
|
||||
{
|
||||
Set<int[]> result = new HashSet<int[]>();
|
||||
|
||||
int x1 = p1.getBlockX(); int y1 = p1.getBlockY(); int z1 = p1.getBlockZ();
|
||||
int x2 = p2.getBlockX(); int y2 = p2.getBlockY(); int z2 = p2.getBlockZ();
|
||||
|
||||
int[] buffer;
|
||||
|
||||
for (int i = x1; i <= x2; i++)
|
||||
{
|
||||
buffer = new int[] {i, y1, z1, world.getBlockTypeIdAt(i, y1, z1)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(i, y1, z1).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {i, y2, z1, world.getBlockTypeIdAt(i, y2, z1)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(i, y2, z1).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {i, y1, z2, world.getBlockTypeIdAt(i, y1, z2)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(i, y1, z2).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {i, y2, z2, world.getBlockTypeIdAt(i, y2, z2)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(i, y2, z2).setTypeIdAndData(id, color, false);
|
||||
}
|
||||
for (int j = y1+1; j <= y2-1; j++)
|
||||
{
|
||||
buffer = new int[] {x1, j, z1, world.getBlockTypeIdAt(x1, j, z1)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(x1, j, z1).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {x2, j, z1, world.getBlockTypeIdAt(x2, j, z1)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(x2, j, z1).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {x1, j, z2, world.getBlockTypeIdAt(x1, j, z2)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(x1, j, z2).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {x2, j, z2, world.getBlockTypeIdAt(x2, j, z2)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(x2, j, z2).setTypeIdAndData(id, color, false);
|
||||
}
|
||||
for (int k = z1+1; k <= z2-1; k++)
|
||||
{
|
||||
buffer = new int[] {x1, y1, k, world.getBlockTypeIdAt(x1, y1, k)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(x1, y1, k).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {x2, y1, k, world.getBlockTypeIdAt(x2, y1, k)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(x2, y1, k).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {x1, y2, k, world.getBlockTypeIdAt(x1, y2, k)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(x1, y2, k).setTypeIdAndData(id, color, false);
|
||||
|
||||
buffer = new int[] {x2, y2, k, world.getBlockTypeIdAt(x2, y2, k)};
|
||||
result.add(buffer);
|
||||
world.getBlockAt(x2, y2, k).setTypeIdAndData(id, color, false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Set<int[]> showRegion(World world, Location p1, Location p2, int id)
|
||||
{
|
||||
return showRegion(world, p1, p2, id, (byte) 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take all the blocks with coordinates (buffer[0], buffer[1], buffer[2]) and set
|
||||
* their type ID to buffer[3]. Used to hide regions shown by showRegion.
|
||||
*/
|
||||
public static void hideRegion(int[] buffer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Location object from the config-file.
|
||||
*/
|
||||
@ -610,12 +731,17 @@ public class MAUtils
|
||||
*/
|
||||
public static void setArenaCoord(Configuration config, Arena arena, String coord, Location loc)
|
||||
{
|
||||
if (coord.equals("arena") || coord.equals("lobby") || coord.equals("spectator"))
|
||||
loc.setY(loc.getY() + 1);
|
||||
|
||||
config.setProperty("arenas." + arena.configName() + ".coords." + coord, makeCoord(loc));
|
||||
config.save();
|
||||
arena.load(config);
|
||||
|
||||
if (coord.equals("p1") || coord.equals("p2"))
|
||||
fixRegion(config, loc.getWorld(), arena);
|
||||
if (coord.equals("l1") || coord.equals("l2"))
|
||||
fixLobby(config, loc.getWorld(), arena);
|
||||
}
|
||||
|
||||
public static boolean delArenaCoord(Configuration config, Arena arena, String coord)
|
||||
@ -658,6 +784,35 @@ public class MAUtils
|
||||
arena.load(config);
|
||||
}
|
||||
|
||||
private static void fixLobby(Configuration config, World world, Arena arena)
|
||||
{
|
||||
if (arena.l1 == null || arena.l2 == null)
|
||||
return;
|
||||
|
||||
if (arena.l1.getX() > arena.l2.getX())
|
||||
{
|
||||
double tmp = arena.l1.getX();
|
||||
arena.l1.setX(arena.l2.getX());
|
||||
arena.l2.setX(tmp);
|
||||
}
|
||||
|
||||
if (arena.l1.getZ() > arena.l2.getZ())
|
||||
{
|
||||
double tmp = arena.l1.getZ();
|
||||
arena.l1.setZ(arena.l2.getZ());
|
||||
arena.l2.setZ(tmp);
|
||||
}
|
||||
|
||||
if (arena.l1.getY() > arena.l2.getY())
|
||||
{
|
||||
double tmp = arena.l1.getY();
|
||||
arena.l1.setY(arena.l2.getY());
|
||||
arena.l2.setY(tmp);
|
||||
}
|
||||
arena.serializeConfig();
|
||||
arena.load(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Location from the input String in the input World.
|
||||
*/
|
||||
@ -665,14 +820,14 @@ public class MAUtils
|
||||
{
|
||||
String[] parts = str.split(",");
|
||||
|
||||
double x = Double.parseDouble(parts[0]);
|
||||
double y = Double.parseDouble(parts[1]);
|
||||
double z = Double.parseDouble(parts[2]);
|
||||
double x = Double.parseDouble(parts[0].trim());
|
||||
double y = Double.parseDouble(parts[1].trim());
|
||||
double z = Double.parseDouble(parts[2].trim());
|
||||
|
||||
if (extras && parts.length == 5)
|
||||
if (extras && parts.length > 3)
|
||||
{
|
||||
float yaw = Float.parseFloat(parts[3]);
|
||||
float pitch = Float.parseFloat(parts[4]);
|
||||
float yaw = Float.parseFloat(parts[3].trim());
|
||||
float pitch = Float.parseFloat(parts[4].trim());
|
||||
return new Location(world, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@ -745,13 +900,17 @@ 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.livePlayers);
|
||||
tmp.addAll(arena.arenaPlayers);
|
||||
tmp.addAll(arena.lobbyPlayers);
|
||||
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);
|
||||
}
|
||||
@ -764,9 +923,18 @@ public class MAUtils
|
||||
|
||||
/* 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.livePlayers)
|
||||
for (Player p : arena.arenaPlayers)
|
||||
{
|
||||
double dist = p.getLocation().distanceSquared(e.getLocation()); //distance(p.getLocation(), e.getLocation());
|
||||
if (!arena.world.equals(p.getWorld()))
|
||||
{
|
||||
System.out.println("[MobArena] MAUtils:908: Player '" + p.getName() + "' is not in the right world. Force leaving...");
|
||||
arena.playerLeave(p);
|
||||
tellPlayer(p, "You warped out of the arena world.");
|
||||
continue;
|
||||
}
|
||||
|
||||
double dist = p.getLocation().distanceSquared(e.getLocation());
|
||||
if (dist < current && dist < 256)
|
||||
{
|
||||
current = dist;
|
||||
@ -776,15 +944,6 @@ public class MAUtils
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double distance(Location loc1, Location loc2)
|
||||
{
|
||||
double x = loc1.getX() - loc2.getX();
|
||||
double y = loc1.getY() - loc2.getY();
|
||||
double z = loc1.getZ() - loc2.getZ();
|
||||
|
||||
return x*x + y*y + z*z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a proper arena name to a config-file name.
|
||||
* All spaces are replaced by underscores, and the whole String is
|
||||
@ -830,25 +989,63 @@ public class MAUtils
|
||||
|
||||
/**
|
||||
* Turn a list into a space-separated string-representation of the list.
|
||||
*/
|
||||
public static <E> String listToString(List<E> list)
|
||||
{
|
||||
return listToString(list, true);
|
||||
}
|
||||
|
||||
public static <E> String listToString(List<E> list, boolean none)
|
||||
*/
|
||||
public static <E> String listToString(List<E> list, boolean none, MobArena plugin)
|
||||
{
|
||||
if (none && list.isEmpty())
|
||||
return MAMessages.get(Msg.MISC_NONE);
|
||||
if (list == null || list.isEmpty())
|
||||
{
|
||||
if (none)
|
||||
return MAMessages.get(Msg.MISC_NONE);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
for (E e : list)
|
||||
int trimLength = 0;
|
||||
|
||||
E type = list.get(0);
|
||||
if (type instanceof Player)
|
||||
{
|
||||
buffy.append(e.toString());
|
||||
buffy.append(" ");
|
||||
for (E e : list)
|
||||
{
|
||||
buffy.append(((Player) e).getName());
|
||||
buffy.append(" ");
|
||||
}
|
||||
}
|
||||
return buffy.toString();
|
||||
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());
|
||||
buffy.append(", ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (E e : list)
|
||||
{
|
||||
buffy.append(e.toString());
|
||||
buffy.append(" ");
|
||||
}
|
||||
}
|
||||
return buffy.toString().substring(0, buffy.length() - trimLength);
|
||||
}
|
||||
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.
|
||||
@ -873,7 +1070,8 @@ public class MAUtils
|
||||
public static Player getRandomPlayer(Arena arena)
|
||||
{
|
||||
Random random = new Random();
|
||||
Player[] array = (Player[]) arena.livePlayers.toArray();
|
||||
//Player[] array = (Player[]) arena.livePlayers.toArray();
|
||||
Player[] array = (Player[]) arena.arenaPlayers.toArray();
|
||||
return array[random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
@ -891,6 +1089,12 @@ public class MAUtils
|
||||
(arena.p2 != null) &&
|
||||
(arena.spawnpoints.size() > 0));
|
||||
}
|
||||
|
||||
public static boolean verifyLobby(Arena arena)
|
||||
{
|
||||
return ((arena.l1 != null) &&
|
||||
(arena.l2 != null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is a new update of MobArena and notifies the
|
||||
@ -898,7 +1102,7 @@ public class MAUtils
|
||||
*/
|
||||
public static void checkForUpdates(MobArena plugin, final Player p, boolean response)
|
||||
{
|
||||
String site = "http://forums.bukkit.org/threads/818.19144/";
|
||||
String site = "http://forums.bukkit.org/threads/19144/";
|
||||
try
|
||||
{
|
||||
// Make a URI of the site address
|
||||
@ -951,6 +1155,36 @@ public class MAUtils
|
||||
ws.allowAnimals = allowAnimals;
|
||||
}
|
||||
|
||||
public static String getDuration(long duration)
|
||||
{
|
||||
long seconds = duration / 1000;
|
||||
long secs = seconds % 60;
|
||||
long mins = (seconds - secs) / 60 % 60;
|
||||
long hrs = ((seconds - secs) - (mins * 60)) / 60 / 60;
|
||||
return hrs + ":" + ((mins < 10) ? "0" + mins : mins) + ":" + ((secs < 10) ? "0" + secs : secs);
|
||||
}
|
||||
|
||||
public static String padRight(String s, int length) { return padRight(s, length, ' '); }
|
||||
public static String padRight(String s, int length, char pad)
|
||||
{
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
buffy.append(s);
|
||||
for (int i = s.length(); i < length; i++)
|
||||
buffy.append(pad);
|
||||
return buffy.toString();
|
||||
}
|
||||
|
||||
public static String padLeft(String s, int length) { return padLeft(s, length, ' '); }
|
||||
public static String padLeft(String s, int length, char pad)
|
||||
{
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
for (int i = 0; i < length - s.length(); i++)
|
||||
buffy.append(pad);
|
||||
buffy.append(s);
|
||||
return buffy.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stand back, I'm going to try science!
|
||||
*/
|
||||
@ -1010,7 +1244,7 @@ public class MAUtils
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.out.println("Couldn't create backup file. Aborting auto-generate...");
|
||||
System.out.println("[MobArena] ERROR! Couldn't create backup file. Aborting auto-generate...");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1115,7 +1349,7 @@ public class MAUtils
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), arena, "p1", new Location(world, x1, ly1, z1));
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), arena, "p2", new Location(world, x2, y2+1, z2));
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), arena, "arena", new Location(world, loc.getX(), y1+1, loc.getZ()));
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), arena, "lobby", new Location(world, x1+2, y1-3, z1+2));
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), arena, "lobby", new Location(world, x1+2, ly1+1, z1+2));
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), arena, "spectator", new Location(world, loc.getX(), y2+1, loc.getZ()));
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), arena, "spawnpoints.s1", new Location(world, x1+3, y1+2, z1+3));
|
||||
MAUtils.setArenaCoord(plugin.getConfig(), arena, "spawnpoints.s2", new Location(world, x1+3, y1+2, z2-3));
|
||||
@ -1143,7 +1377,7 @@ public class MAUtils
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (error) System.out.println("Couldn't find backup file for arena '" + name + "'");
|
||||
if (error) System.out.println("[MobArena] ERROR! Couldn't find backup file for arena '" + name + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -1,105 +1,126 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
|
||||
}
|
||||
Plugin maPlugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
|
||||
|
||||
if (maPlugin == null)
|
||||
return;
|
||||
|
||||
// Check if there is an active arena session running.
|
||||
public boolean isRunning(String arenaName)
|
||||
{
|
||||
Arena arena = plugin.getAM().getArenaWithName(arenaName);
|
||||
if (arena == null)
|
||||
throw new NullPointerException("Arena with name '" + arenaName + "' does not exist!");
|
||||
|
||||
return arena.running;
|
||||
ma = true;
|
||||
plugin = (MobArena) maPlugin;
|
||||
}
|
||||
|
||||
// Check if the specified player is in an arena.
|
||||
public boolean isPlaying(Player p) { return (plugin.getAM().getArenaWithPlayer(p) != null); }
|
||||
|
||||
// Arena getters
|
||||
public Arena getArenaWithName(String arenaName) { return plugin.getAM().getArenaWithName(arenaName); }
|
||||
public Arena getArenaWithPlayer(Player p) { return plugin.getAM().getArenaWithPlayer(p); }
|
||||
public Arena getArenaWithPet(Entity wolf) { return plugin.getAM().getArenaWithPet(wolf); }
|
||||
public Arena getArenaWithMonster(Entity monster) { return plugin.getAM().getArenaWithMonster(monster); }
|
||||
public Arena getArenaInLocation(Location l) { return plugin.getAM().getArenaInLocation(l); }
|
||||
|
||||
// Player lists
|
||||
public List<Player> getAllPlayers() { return plugin.getAM().getAllPlayers(); }
|
||||
public List<Player> getAllLivingPlayers() { return plugin.getAM().getAllLivingPlayers(); }
|
||||
public List<Player> getAllPlayersInArena(String arenaName) { return plugin.getAM().getAllPlayersInArena(arenaName); }
|
||||
public List<Player> getLivingPlayersInArena(String arenaName) { return plugin.getAM().getLivingPlayersInArena(arenaName); }
|
||||
|
||||
// Warp locations.
|
||||
public Location getArenaLocation(String arenaName)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
Arena arena = plugin.getAM().getArenaWithName(arenaName);
|
||||
if (arena == null)
|
||||
throw new NullPointerException("Arena with name '" + arenaName + "' does not exist!");
|
||||
// If the plugin doesn't exist, always return false.
|
||||
if (!ma || plugin.getAM() == null) return false;
|
||||
|
||||
return arena.arenaLoc;
|
||||
}
|
||||
public Location getLobbyLocation(String arenaName)
|
||||
{
|
||||
Arena arena = plugin.getAM().getArenaWithName(arenaName);
|
||||
if (arena == null)
|
||||
throw new NullPointerException("Arena with name '" + arenaName + "' does not exist!");
|
||||
|
||||
return arena.lobbyLoc;
|
||||
}
|
||||
public Location getSpectatorLocation(String arenaName)
|
||||
{
|
||||
Arena arena = plugin.getAM().getArenaWithName(arenaName);
|
||||
if (arena == null)
|
||||
throw new NullPointerException("Arena with name '" + arenaName + "' does not exist!");
|
||||
|
||||
return arena.spectatorLoc;
|
||||
}
|
||||
|
||||
// Get the current wave number.
|
||||
public int getWave(Arena arena) { return arena.spawnThread.wave; }
|
||||
|
||||
public int getWave(String arenaName)
|
||||
{
|
||||
Arena arena = plugin.getAM().getArenaWithName(arenaName);
|
||||
if (arena == null)
|
||||
throw new NullPointerException("Arena with name '" + arenaName + "' does not exist!");
|
||||
|
||||
if (arena.spawnThread == null)
|
||||
throw new NullPointerException("Arena with name '" + arenaName + "' has not started!");
|
||||
|
||||
return arena.spawnThread.wave;
|
||||
}
|
||||
|
||||
// Check if a location is within any arena regions.
|
||||
|
||||
public boolean inRegion(Location l, Arena arena) { return arena.inRegion(l); }
|
||||
|
||||
public boolean inRegion(Location l, String arenaName)
|
||||
{
|
||||
Arena arena = plugin.getAM().getArenaWithName(arenaName);
|
||||
if (arena == null)
|
||||
throw new NullPointerException("Arena with name '" + arenaName + "' does not exist!");
|
||||
|
||||
return arena.inRegion(l);
|
||||
}
|
||||
public boolean inRegion(Location l)
|
||||
{
|
||||
// Return true if location is within just one arena's region.
|
||||
for (Arena arena : plugin.getAM().arenas)
|
||||
if (arena.inRegion(l))
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
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