Changes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,6 +5,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -76,7 +77,7 @@ public class Arena
|
|||||||
|
|
||||||
// Arena sets/maps
|
// Arena sets/maps
|
||||||
protected Set<Player> hasPaid, rewardedPlayers, notifyPlayers, randoms;
|
protected Set<Player> hasPaid, rewardedPlayers, notifyPlayers, randoms;
|
||||||
protected Set<LivingEntity> monsters;
|
protected Set<LivingEntity> monsters, explodingSheep, plaguedPigs, madCows;
|
||||||
protected Set<Block> blocks;
|
protected Set<Block> blocks;
|
||||||
protected Set<Wolf> pets;
|
protected Set<Wolf> pets;
|
||||||
protected Map<Player,Integer> petMap;
|
protected Map<Player,Integer> petMap;
|
||||||
@@ -117,6 +118,9 @@ public class Arena
|
|||||||
rewardedPlayers = new HashSet<Player>();
|
rewardedPlayers = new HashSet<Player>();
|
||||||
hasPaid = new HashSet<Player>();
|
hasPaid = new HashSet<Player>();
|
||||||
monsters = new HashSet<LivingEntity>();
|
monsters = new HashSet<LivingEntity>();
|
||||||
|
explodingSheep = new HashSet<LivingEntity>();
|
||||||
|
plaguedPigs = new HashSet<LivingEntity>();
|
||||||
|
madCows = new HashSet<LivingEntity>();
|
||||||
blocks = new HashSet<Block>();
|
blocks = new HashSet<Block>();
|
||||||
pets = new HashSet<Wolf>();
|
pets = new HashSet<Wolf>();
|
||||||
petMap = new HashMap<Player,Integer>();
|
petMap = new HashMap<Player,Integer>();
|
||||||
@@ -259,7 +263,6 @@ public class Arena
|
|||||||
lobbyPlayers.clear();
|
lobbyPlayers.clear();
|
||||||
readyPlayers.clear();
|
readyPlayers.clear();
|
||||||
|
|
||||||
//rewardMap.clear();
|
|
||||||
monsters.clear();
|
monsters.clear();
|
||||||
|
|
||||||
spawnTaskId = -1;
|
spawnTaskId = -1;
|
||||||
@@ -292,7 +295,7 @@ public class Arena
|
|||||||
MAUtils.clearInventory(p);
|
MAUtils.clearInventory(p);
|
||||||
|
|
||||||
restoreInvAndGiveRewards(p);
|
restoreInvAndGiveRewards(p);
|
||||||
if (log.players.get(p) != null) log.players.get(p).lastWave = spawnThread.wave - 1;
|
if (log.players.get(p) != null) log.players.get(p).lastWave = spawnThread.getWave() - 1;
|
||||||
movePlayerToEntry(p);
|
movePlayerToEntry(p);
|
||||||
finishWithPlayer(p);
|
finishWithPlayer(p);
|
||||||
endArena();
|
endArena();
|
||||||
@@ -302,7 +305,7 @@ public class Arena
|
|||||||
{
|
{
|
||||||
MAUtils.clearInventory(p);
|
MAUtils.clearInventory(p);
|
||||||
restoreInvAndGiveRewards(p);
|
restoreInvAndGiveRewards(p);
|
||||||
log.players.get(p).lastWave = spawnThread.wave - 1;
|
log.players.get(p).lastWave = spawnThread.getWave() - 1;
|
||||||
|
|
||||||
if (specOnDeath)
|
if (specOnDeath)
|
||||||
{
|
{
|
||||||
@@ -368,7 +371,7 @@ public class Arena
|
|||||||
// Stop the spawn thread.
|
// Stop the spawn thread.
|
||||||
if (spawnThread != null)
|
if (spawnThread != null)
|
||||||
{
|
{
|
||||||
Bukkit.getServer().getScheduler().cancelTask(spawnThread.taskId);
|
Bukkit.getServer().getScheduler().cancelTask(spawnThread.getTaskId());
|
||||||
Bukkit.getServer().getScheduler().cancelTask(spawnTaskId);
|
Bukkit.getServer().getScheduler().cancelTask(spawnTaskId);
|
||||||
spawnTaskId = -1;
|
spawnTaskId = -1;
|
||||||
spawnThread = null;
|
spawnThread = null;
|
||||||
@@ -544,6 +547,9 @@ public class Arena
|
|||||||
removePets();
|
removePets();
|
||||||
removeEntities();
|
removeEntities();
|
||||||
monsters.clear();
|
monsters.clear();
|
||||||
|
explodingSheep.clear();
|
||||||
|
plaguedPigs.clear();
|
||||||
|
madCows.clear();
|
||||||
blocks.clear();
|
blocks.clear();
|
||||||
pets.clear();
|
pets.clear();
|
||||||
}
|
}
|
||||||
@@ -552,6 +558,12 @@ public class Arena
|
|||||||
{
|
{
|
||||||
for (LivingEntity e : monsters)
|
for (LivingEntity e : monsters)
|
||||||
e.remove();
|
e.remove();
|
||||||
|
for (LivingEntity e : explodingSheep)
|
||||||
|
e.remove();
|
||||||
|
for (LivingEntity e : plaguedPigs)
|
||||||
|
e.remove();
|
||||||
|
for (LivingEntity e : madCows)
|
||||||
|
e.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeBlocks()
|
private void removeBlocks()
|
||||||
@@ -653,16 +665,15 @@ public class Arena
|
|||||||
spawnpoints = MAUtils.getArenaSpawnpoints(config, world, configName);
|
spawnpoints = MAUtils.getArenaSpawnpoints(config, world, configName);
|
||||||
|
|
||||||
// NEW WAVES
|
// NEW WAVES
|
||||||
singleWaves = WaveUtils.getWaves(config, configName, WaveBranch.SINGLE);
|
singleWaves = WaveUtils.getWaves(this, config, WaveBranch.SINGLE);
|
||||||
recurrentWaves = WaveUtils.getWaves(config, configName, WaveBranch.RECURRENT);
|
recurrentWaves = WaveUtils.getWaves(this, config, WaveBranch.RECURRENT);
|
||||||
|
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("ARENA: " + configName);
|
System.out.println("ARENA: " + configName);
|
||||||
System.out.println("Single waves");
|
System.out.println("Single waves");
|
||||||
int si = singleWaves.size();
|
for (Wave w : singleWaves)
|
||||||
for (int i = 0; i < si; i++)
|
System.out.println("- " + w);
|
||||||
System.out.println("- " + singleWaves.pollFirst());
|
|
||||||
System.out.println("Reccurent waves");
|
System.out.println("Reccurent waves");
|
||||||
for (Wave w : recurrentWaves)
|
for (Wave w : recurrentWaves)
|
||||||
System.out.println("- " + w);
|
System.out.println("- " + w);
|
||||||
@@ -854,6 +865,31 @@ public class Arena
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public World getWorld()
|
||||||
|
{
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getClasses()
|
||||||
|
{
|
||||||
|
return classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Location> getSpawnpoints()
|
||||||
|
{
|
||||||
|
return spawnpoints.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerCount()
|
||||||
|
{
|
||||||
|
return spawnThread.getPlayerCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMonster(LivingEntity e)
|
||||||
|
{
|
||||||
|
monsters.add(e);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Player> getAllPlayers()
|
public List<Player> getAllPlayers()
|
||||||
{
|
{
|
||||||
List<Player> result = new LinkedList<Player>();
|
List<Player> result = new LinkedList<Player>();
|
||||||
@@ -884,9 +920,9 @@ public class Arena
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Reset the previousSize, cancel the previous timer, and start the new timer.
|
// Reset the previousSize, cancel the previous timer, and start the new timer.
|
||||||
spawnThread.previousSize = monsters.size();
|
spawnThread.setPreviousSize(monsters.size());
|
||||||
Bukkit.getServer().getScheduler().cancelTask(spawnThread.taskId);
|
Bukkit.getServer().getScheduler().cancelTask(spawnThread.getTaskId());
|
||||||
spawnThread.taskId = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
int id = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||||
new Runnable()
|
new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@@ -898,7 +934,7 @@ public class Arena
|
|||||||
monsters.remove(e);
|
monsters.remove(e);
|
||||||
|
|
||||||
// Compare the current size with the previous size.
|
// Compare the current size with the previous size.
|
||||||
if (monsters.size() < spawnThread.previousSize || spawnThread.previousSize == 0)
|
if (monsters.size() < spawnThread.getPreviousSize() || spawnThread.getPreviousSize() == 0)
|
||||||
{
|
{
|
||||||
resetIdleTimer();
|
resetIdleTimer();
|
||||||
return;
|
return;
|
||||||
@@ -914,6 +950,7 @@ public class Arena
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, maxIdleTime);
|
}, maxIdleTime);
|
||||||
|
spawnThread.setTaskId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTrunkAndLeaves(Block b)
|
public void addTrunkAndLeaves(Block b)
|
||||||
@@ -1018,11 +1055,6 @@ public class Arena
|
|||||||
hasPaid.remove(p);
|
hasPaid.remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getClasses()
|
|
||||||
{
|
|
||||||
return classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "perfect equals method" cf. "Object-Oriented Design and Patterns"
|
* The "perfect equals method" cf. "Object-Oriented Design and Patterns"
|
||||||
* by Cay S. Horstmann.
|
* by Cay S. Horstmann.
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ArenaLog
|
|||||||
|
|
||||||
public void end()
|
public void end()
|
||||||
{
|
{
|
||||||
lastWave = arena.spawnThread.wave - 1;
|
lastWave = arena.spawnThread.getWave() - 1;
|
||||||
endTime = new Timestamp((new Date()).getTime());
|
endTime = new Timestamp((new Date()).getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,27 +5,19 @@ import java.util.HashSet;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Wolf;
|
|
||||||
import org.bukkit.entity.Ghast;
|
|
||||||
import org.bukkit.entity.Slime;
|
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.CreatureType;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.MAMessages.Msg;
|
import com.garbagemule.MobArena.MAMessages.Msg;
|
||||||
import com.garbagemule.MobArena.util.WaveUtils;
|
import com.garbagemule.MobArena.util.WaveUtils;
|
||||||
import com.garbagemule.MobArena.waves.RecurrentWave;
|
|
||||||
import com.garbagemule.MobArena.waves.SingleWave;
|
|
||||||
import com.garbagemule.MobArena.waves.Wave;
|
import com.garbagemule.MobArena.waves.Wave;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,26 +30,28 @@ import com.garbagemule.MobArena.waves.Wave;
|
|||||||
*/
|
*/
|
||||||
public class MASpawnThread implements Runnable
|
public class MASpawnThread implements Runnable
|
||||||
{
|
{
|
||||||
protected int wave, previousSize, taskId;
|
|
||||||
private int ran, noOfPlayers, modulo;
|
|
||||||
private int dZombies, dSkeletons, dSpiders, dCreepers, dWolves;
|
|
||||||
private int dPoweredCreepers, dPigZombies, dSlimes, dMonsters, dAngryWolves, dGiants, dGhasts;
|
|
||||||
private Random random;
|
|
||||||
private MobArena plugin;
|
private MobArena plugin;
|
||||||
private Arena arena;
|
private Arena arena;
|
||||||
|
private int wave, taskId, previousSize, playerCount;
|
||||||
|
|
||||||
// NEW WAVES
|
// NEW WAVES
|
||||||
/* Single waves are waves with a frequency of 0, and they only
|
|
||||||
* spawn once. Their priority is infinity, meaning they will always
|
|
||||||
* spawn instead of recurrent waves, if the wave numbers clash. */
|
|
||||||
private Wave defaultWave;
|
private Wave defaultWave;
|
||||||
private TreeSet<SingleWave> singleWaves;
|
private TreeSet<Wave> recurrentWaves;
|
||||||
private TreeSet<RecurrentWave> recurrentWaves;
|
private TreeSet<Wave> singleWaves;
|
||||||
|
|
||||||
public MASpawnThread(MobArena plugin, Arena arena)
|
public MASpawnThread(MobArena plugin, Arena arena)
|
||||||
{
|
{
|
||||||
|
// WAVES
|
||||||
|
defaultWave = arena.recurrentWaves.first();
|
||||||
|
recurrentWaves = arena.recurrentWaves;
|
||||||
|
singleWaves = arena.singleWaves;
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.arena = arena;
|
this.arena = arena;
|
||||||
|
wave = 1;
|
||||||
|
playerCount = arena.arenaPlayers.size();
|
||||||
|
|
||||||
|
/*
|
||||||
modulo = arena.specialModulo;
|
modulo = arena.specialModulo;
|
||||||
if (modulo <= 0) modulo = -32768;
|
if (modulo <= 0) modulo = -32768;
|
||||||
|
|
||||||
@@ -84,9 +78,10 @@ public class MASpawnThread implements Runnable
|
|||||||
dGiants = dAngryWolves + arena.distSpecial.get("giants");
|
dGiants = dAngryWolves + arena.distSpecial.get("giants");
|
||||||
dGhasts = dGiants + arena.distSpecial.get("ghasts");
|
dGhasts = dGiants + arena.distSpecial.get("ghasts");
|
||||||
if (dGhasts < 1) { dPoweredCreepers = 1; dPigZombies = 2; dSlimes = 3; dMonsters = 4; dAngryWolves = 5; dGiants = 5; dGhasts = 5; }
|
if (dGhasts < 1) { dPoweredCreepers = 1; dPigZombies = 2; dSlimes = 3; dMonsters = 4; dAngryWolves = 5; dGiants = 5; dGhasts = 5; }
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run2()
|
public void run()
|
||||||
{
|
{
|
||||||
// Clear out all dead monsters in the monster set.
|
// Clear out all dead monsters in the monster set.
|
||||||
removeDeadMonsters();
|
removeDeadMonsters();
|
||||||
@@ -145,23 +140,10 @@ public class MASpawnThread implements Runnable
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SortedSet<Wave> matches = getMatchingRecurrentWaves(wave);
|
SortedSet<Wave> matches = getMatchingRecurrentWaves(wave);
|
||||||
|
w = matches.isEmpty() ? defaultWave : matches.last();
|
||||||
if (matches.isEmpty())
|
|
||||||
w = defaultWave;
|
|
||||||
else
|
|
||||||
w = matches.last();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w.spawn(wave, arena.spawnpoints.values());
|
w.spawn(wave);
|
||||||
/*
|
|
||||||
// Otherwise, check the recurrent waves.
|
|
||||||
SortedSet<Wave> matches = getMatchingRecurrentWaves(wave);
|
|
||||||
|
|
||||||
if (matches.isEmpty())
|
|
||||||
defaultWave.spawn(wave, arena.spawnpoints.values());
|
|
||||||
else
|
|
||||||
matches.last().spawn(wave, arena.spawnpoints.values());
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortedSet<Wave> getMatchingRecurrentWaves(int wave)
|
private SortedSet<Wave> getMatchingRecurrentWaves(int wave)
|
||||||
@@ -177,7 +159,46 @@ public class MASpawnThread implements Runnable
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
|
||||||
|
|
||||||
|
/*////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Getters/setters
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
public int getWave()
|
||||||
|
{
|
||||||
|
return wave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTaskId()
|
||||||
|
{
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPreviousSize()
|
||||||
|
{
|
||||||
|
return previousSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerCount()
|
||||||
|
{
|
||||||
|
return playerCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskId(int taskId)
|
||||||
|
{
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreviousSize(int previousSize)
|
||||||
|
{
|
||||||
|
this.previousSize = previousSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public void run1()
|
||||||
{
|
{
|
||||||
if (arena.arenaPlayers.isEmpty())
|
if (arena.arenaPlayers.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -228,6 +249,7 @@ public class MASpawnThread implements Runnable
|
|||||||
wave++;
|
wave++;
|
||||||
if (arena.maxIdleTime > 0 && arena.monsters.isEmpty()) arena.resetIdleTimer();
|
if (arena.maxIdleTime > 0 && arena.monsters.isEmpty()) arena.resetIdleTimer();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewards all players with an item from the input String.
|
* Rewards all players with an item from the input String.
|
||||||
@@ -238,12 +260,9 @@ public class MASpawnThread implements Runnable
|
|||||||
{
|
{
|
||||||
if (arena.log.players.get(p) == null)
|
if (arena.log.players.get(p) == null)
|
||||||
continue;
|
continue;
|
||||||
/*if (arena.rewardMap.get(p) == null)
|
|
||||||
continue;*/
|
|
||||||
|
|
||||||
ItemStack reward = MAUtils.getRandomReward(rewards);
|
ItemStack reward = MAUtils.getRandomReward(rewards);
|
||||||
arena.log.players.get(p).rewards.add(reward);
|
arena.log.players.get(p).rewards.add(reward);
|
||||||
//arena.rewardMap.get(p).add(reward);
|
|
||||||
|
|
||||||
if (reward == null)
|
if (reward == null)
|
||||||
{
|
{
|
||||||
@@ -266,7 +285,7 @@ public class MASpawnThread implements Runnable
|
|||||||
/**
|
/**
|
||||||
* Spawns a default wave of monsters.
|
* Spawns a default wave of monsters.
|
||||||
*/
|
*/
|
||||||
private void defaultWave()
|
/*private void defaultWave()
|
||||||
{
|
{
|
||||||
Location loc;
|
Location loc;
|
||||||
List<Location> spawnpoints = getValidSpawnpoints();
|
List<Location> spawnpoints = getValidSpawnpoints();
|
||||||
@@ -283,7 +302,7 @@ public class MASpawnThread implements Runnable
|
|||||||
* we're able to evaluate the random number in this way.
|
* we're able to evaluate the random number in this way.
|
||||||
* If dSpiders = 0, then dSpiders = dSkeletons, which
|
* If dSpiders = 0, then dSpiders = dSkeletons, which
|
||||||
* means if the random number is below that value, we will
|
* means if the random number is below that value, we will
|
||||||
* spawn a skeleton and break out of the statement. */
|
* spawn a skeleton and break out of the statement. */ /*
|
||||||
if (ran < dZombies) mob = CreatureType.ZOMBIE;
|
if (ran < dZombies) mob = CreatureType.ZOMBIE;
|
||||||
else if (ran < dSkeletons) mob = CreatureType.SKELETON;
|
else if (ran < dSkeletons) mob = CreatureType.SKELETON;
|
||||||
else if (ran < dSpiders) mob = CreatureType.SPIDER;
|
else if (ran < dSpiders) mob = CreatureType.SPIDER;
|
||||||
@@ -301,12 +320,12 @@ public class MASpawnThread implements Runnable
|
|||||||
Creature c = (Creature) e;
|
Creature c = (Creature) e;
|
||||||
c.setTarget(getClosestPlayer(e));
|
c.setTarget(getClosestPlayer(e));
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawns a special wave of monsters.
|
* Spawns a special wave of monsters.
|
||||||
*/
|
*/
|
||||||
private void specialWave()
|
/*private void specialWave()
|
||||||
{
|
{
|
||||||
Location loc;
|
Location loc;
|
||||||
List<Location> spawnpoints = getValidSpawnpoints();
|
List<Location> spawnpoints = getValidSpawnpoints();
|
||||||
@@ -389,7 +408,7 @@ public class MASpawnThread implements Runnable
|
|||||||
// Lightning, just for effect ;)
|
// Lightning, just for effect ;)
|
||||||
for (Location spawn : arena.spawnpoints.values())
|
for (Location spawn : arena.spawnpoints.values())
|
||||||
arena.world.strikeLightningEffect(spawn);
|
arena.world.strikeLightningEffect(spawn);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Detonates" all the Creepers in the monsterSet.
|
* "Detonates" all the Creepers in the monsterSet.
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ public class MobArena extends JavaPlugin
|
|||||||
|
|
||||||
config = new Configuration(file);
|
config = new Configuration(file);
|
||||||
config.load();
|
config.load();
|
||||||
|
config.setHeader(header());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners()
|
private void registerListeners()
|
||||||
@@ -178,4 +179,12 @@ public class MobArena extends JavaPlugin
|
|||||||
public Configuration getConfig() { return config; }
|
public Configuration getConfig() { return config; }
|
||||||
public ArenaMaster getAM() { return am; } // More convenient.
|
public ArenaMaster getAM() { return am; } // More convenient.
|
||||||
public ArenaMaster getArenaMaster() { return am; }
|
public ArenaMaster getArenaMaster() { return am; }
|
||||||
|
|
||||||
|
private String header()
|
||||||
|
{
|
||||||
|
String sep = System.getProperty("line.separator");
|
||||||
|
return "# MobArena v" + desc.getVersion() + " - Config-file" + sep +
|
||||||
|
"# Read the Wiki for details on how to set up this file: http://goo.gl/F5TTc" + sep +
|
||||||
|
"# Note: You -must- use spaces instead of tabs!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,20 +8,15 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.CreatureType;
|
import org.bukkit.entity.CreatureType;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.Arena;
|
||||||
import com.garbagemule.MobArena.MAUtils;
|
import com.garbagemule.MobArena.MAUtils;
|
||||||
import com.garbagemule.MobArena.MobArena;
|
import com.garbagemule.MobArena.MobArena;
|
||||||
import com.garbagemule.MobArena.waves.RecurrentWave;
|
import com.garbagemule.MobArena.waves.*;
|
||||||
import com.garbagemule.MobArena.waves.SingleWave;
|
import com.garbagemule.MobArena.waves.Wave.*;
|
||||||
import com.garbagemule.MobArena.waves.Wave;
|
|
||||||
import com.garbagemule.MobArena.waves.Wave.BossAbility;
|
|
||||||
import com.garbagemule.MobArena.waves.Wave.BossHealth;
|
|
||||||
import com.garbagemule.MobArena.waves.Wave.SwarmAmount;
|
|
||||||
import com.garbagemule.MobArena.waves.Wave.WaveBranch;
|
|
||||||
import com.garbagemule.MobArena.waves.Wave.WaveGrowth;
|
|
||||||
import com.garbagemule.MobArena.waves.Wave.WaveType;
|
|
||||||
|
|
||||||
public class WaveUtils
|
public class WaveUtils
|
||||||
{
|
{
|
||||||
@@ -60,17 +55,48 @@ public class WaveUtils
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Player getClosestPlayer(Arena arena, Entity e)
|
||||||
|
{
|
||||||
|
// Set up the comparison variable and the result.
|
||||||
|
double dist = 0;
|
||||||
|
double current = Double.POSITIVE_INFINITY;
|
||||||
|
Player result = null;
|
||||||
|
|
||||||
|
/* Iterate through the ArrayList, and update current and result every
|
||||||
|
* time a squared distance smaller than current is found. */
|
||||||
|
//for (Player p : arena.livePlayers)
|
||||||
|
for (Player p : arena.getLivingPlayers())
|
||||||
|
{
|
||||||
|
if (!arena.getWorld().equals(p.getWorld()))
|
||||||
|
{
|
||||||
|
System.out.println("[MobArena] Player '" + p.getName() + "' is not in the right world. Force leaving...");
|
||||||
|
arena.playerLeave(p);
|
||||||
|
MAUtils.tellPlayer(p, "You warped out of the arena world.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
dist = p.getLocation().distanceSquared(e.getLocation());
|
||||||
|
if (dist < current && dist < MobArena.MIN_PLAYER_DISTANCE)
|
||||||
|
{
|
||||||
|
current = dist;
|
||||||
|
result = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab and process all the waves in the config-file for the arena.
|
* Grab and process all the waves in the config-file for the arena.
|
||||||
*/
|
*/
|
||||||
public static TreeSet<Wave> getWaves(Configuration config, String arena, WaveBranch branch)
|
public static TreeSet<Wave> getWaves(Arena arena, Configuration config, WaveBranch branch)
|
||||||
{
|
{
|
||||||
// Determine the branch type of the wave, and grab the appropriate comparator
|
// Determine the branch type of the wave, and grab the appropriate comparator
|
||||||
String b = branch.toString().toLowerCase();
|
String b = branch.toString().toLowerCase();
|
||||||
TreeSet<Wave> result = new TreeSet<Wave>(getComparator(branch));
|
TreeSet<Wave> result = new TreeSet<Wave>(getComparator(branch));
|
||||||
|
|
||||||
// Grab the waves from the config-file
|
// Grab the waves from the config-file
|
||||||
String path = "arenas." + arena + ".waves." + b;
|
String path = "arenas." + arena.configName() + ".waves." + b; // waves.yml, change to either "waves." + b, or simply b
|
||||||
List<String> waves = config.getKeys(path);
|
List<String> waves = config.getKeys(path);
|
||||||
|
|
||||||
// If there are any waves, process them
|
// If there are any waves, process them
|
||||||
@@ -80,7 +106,7 @@ public class WaveUtils
|
|||||||
for (String w : waves)
|
for (String w : waves)
|
||||||
{
|
{
|
||||||
// path argument becomes: "arenas.<arena>.waves.<branch>.<wave>."
|
// path argument becomes: "arenas.<arena>.waves.<branch>.<wave>."
|
||||||
wave = getWave(config, path + "." + w + ".", w, branch);
|
wave = getWave(arena, config, path + "." + w + ".", w, branch);
|
||||||
if (wave != null) result.add(wave);
|
if (wave != null) result.add(wave);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,12 +114,12 @@ public class WaveUtils
|
|||||||
// If there are no waves and the type is 'recurrent', add a default wave.
|
// If there are no waves and the type is 'recurrent', add a default wave.
|
||||||
if (branch == WaveBranch.RECURRENT && (result.isEmpty() || waves == null))
|
if (branch == WaveBranch.RECURRENT && (result.isEmpty() || waves == null))
|
||||||
{
|
{
|
||||||
RecurrentWave def = new RecurrentWave("DEF_WAVE_AUTO", 1, 1, 1);
|
/*
|
||||||
|
DefaultWave def = new DefaultWave(arena, "DEF_WAVE_AUTO", 1, 1, 1, null, null);
|
||||||
def.setType(WaveType.DEFAULT);
|
def.setType(WaveType.DEFAULT);
|
||||||
def.setGrowth(WaveGrowth.MEDIUM);
|
def.setGrowth(WaveGrowth.MEDIUM);
|
||||||
def.setDefault(true);
|
|
||||||
|
|
||||||
result.add(def);
|
result.add(def);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -103,9 +129,9 @@ public class WaveUtils
|
|||||||
* Get a single wave based on the config-file, the path, and branch
|
* Get a single wave based on the config-file, the path, and branch
|
||||||
* @return A Wave object if it is well defined, null otherwise.
|
* @return A Wave object if it is well defined, null otherwise.
|
||||||
*/
|
*/
|
||||||
private static Wave getWave(Configuration config, String path, String name, WaveBranch branch)
|
private static Wave getWave(Arena arena, Configuration config, String path, String name, WaveBranch branch)
|
||||||
{
|
{
|
||||||
// Grab the wave type, if null, return null
|
// Grab the wave type, if null or not well defined, return null
|
||||||
WaveType type = WaveType.fromString(config.getString(path + "type"));
|
WaveType type = WaveType.fromString(config.getString(path + "type"));
|
||||||
if (type == null || !isWaveWellDefined(config, path, branch, type))
|
if (type == null || !isWaveWellDefined(config, path, branch, type))
|
||||||
return null;
|
return null;
|
||||||
@@ -117,209 +143,25 @@ public class WaveUtils
|
|||||||
int frequency = config.getInt(path + "frequency", 0);
|
int frequency = config.getInt(path + "frequency", 0);
|
||||||
int priority = config.getInt(path + "priority", 0);
|
int priority = config.getInt(path + "priority", 0);
|
||||||
int wave = config.getInt(path + "wave", frequency);
|
int wave = config.getInt(path + "wave", frequency);
|
||||||
result = new RecurrentWave(name, wave, frequency, priority);
|
|
||||||
|
//if (type == WaveType.DEFAULT)
|
||||||
|
result = new DefaultWave(arena, name, wave, frequency, priority, config, path);
|
||||||
|
result.setGrowth(WaveGrowth.OLD);
|
||||||
|
//else
|
||||||
|
// result = new SpecialWave(arena, name, wave, frequency, priority, config, path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int wave = config.getInt(path + "wave", 0);
|
int wave = config.getInt(path + "wave", 0);
|
||||||
result = new SingleWave(name, wave);
|
|
||||||
|
//if (type == WaveType.DEFAULT)
|
||||||
|
result = new DefaultWave(arena, name, wave, config, path);
|
||||||
|
result.setGrowth(WaveGrowth.OLD);
|
||||||
|
//else
|
||||||
|
// result = new SpecialWave(arena, name, wave, config, path);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public static RecurrentWave getRecurrentWave(Configuration config, String arena, String w)
|
|
||||||
{
|
|
||||||
// Grab the path
|
|
||||||
String path = "arenas." + arena + ".waves.recurrent." + w + ".";
|
|
||||||
|
|
||||||
// Ensure that frequency and priority exist, otherwise return null
|
|
||||||
int frequency = config.getInt(path + "frequency", 0);
|
|
||||||
int priority = config.getInt(path + "priority", 0);
|
|
||||||
if (frequency == 0 || priority == 0) return null;
|
|
||||||
|
|
||||||
// Grab other variables
|
|
||||||
int wave = config.getInt(path + "wave", frequency);
|
|
||||||
WaveType type = WaveType.fromString(config.getString(path + "type", "default"));
|
|
||||||
WaveGrowth growth = WaveGrowth.fromString(config.getString(path + "growth", "medium"));
|
|
||||||
|
|
||||||
// Grab monster distribution
|
|
||||||
//Map<CreatureType,Integer> monsters = getWaveMonsters(config, arena, path, type);
|
|
||||||
|
|
||||||
// Create the wave
|
|
||||||
RecurrentWave result = new RecurrentWave(w, wave, frequency, priority, type, growth);
|
|
||||||
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SingleWave getSingleWave(Configuration config, String arena, String w)
|
|
||||||
{
|
|
||||||
// Grab the path
|
|
||||||
String path = "arenas." + arena + ".waves.single." + w + ".";
|
|
||||||
|
|
||||||
// Ensure that the wave number exists, otherwise return null
|
|
||||||
int wave = config.getInt(path + "wave", 0);
|
|
||||||
if (wave == 0) return null;
|
|
||||||
|
|
||||||
// Grab other variables
|
|
||||||
|
|
||||||
SingleWave result = new SingleWave(w, wave);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<CreatureType,Integer> getWaveMonsters(Configuration config, String arena, String path, String type)
|
|
||||||
{
|
|
||||||
Map<CreatureType,Integer> result = new HashMap<CreatureType,Integer>();
|
|
||||||
|
|
||||||
List<String> monsters = config.getKeys(path + "monsters");
|
|
||||||
|
|
||||||
// If no monsters specified, make sure to add some
|
|
||||||
if (monsters == null)
|
|
||||||
{
|
|
||||||
if (type.equals("default"))
|
|
||||||
{
|
|
||||||
result.put(CreatureType.ZOMBIE, 10);
|
|
||||||
result.put(CreatureType.SKELETON, 10);
|
|
||||||
result.put(CreatureType.SPIDER, 10);
|
|
||||||
result.put(CreatureType.CREEPER, 10);
|
|
||||||
result.put(CreatureType.WOLF, 10);
|
|
||||||
}
|
|
||||||
else if (type.equals("default"))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Comparators
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a comparator based on the WaveBranch parameter.
|
|
||||||
*/
|
|
||||||
public static Comparator<Wave> getComparator(WaveBranch branch)
|
|
||||||
{
|
|
||||||
if (branch == WaveBranch.SINGLE)
|
|
||||||
return getSingleComparator();
|
|
||||||
else if (branch == WaveBranch.RECURRENT)
|
|
||||||
return getRecurrentComparator();
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a Comparator that compares Wave objects by wave number.
|
|
||||||
* If the wave numbers are equal, the waves are equal. This is to
|
|
||||||
* DISALLOW "duplicates" in the SINGLE WAVES collection.
|
|
||||||
* @return Comparator whose compare()-method compares wave numbers.
|
|
||||||
*/
|
|
||||||
public static Comparator<Wave> getSingleComparator()
|
|
||||||
{
|
|
||||||
return new Comparator<Wave>()
|
|
||||||
{
|
|
||||||
public int compare(Wave w1, Wave w2)
|
|
||||||
{
|
|
||||||
if (w1.getWave() < w2.getWave())
|
|
||||||
return -1;
|
|
||||||
else if (w1.getWave() > w2.getWave())
|
|
||||||
return 1;
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a Comparator that compares Wave objects by priority.
|
|
||||||
* If the priorities are equal, the names are compared. This is to
|
|
||||||
* ALLOW "duplicates" in the RECURRENT WAVES collection.
|
|
||||||
* @return Comparator whose compare()-method compares wave priorities.
|
|
||||||
*/
|
|
||||||
public static Comparator<Wave> getRecurrentComparator()
|
|
||||||
{
|
|
||||||
return new Comparator<Wave>()
|
|
||||||
{
|
|
||||||
public int compare(Wave w1, Wave w2)
|
|
||||||
{
|
|
||||||
if (w1.getPriority() < w2.getPriority())
|
|
||||||
return -1;
|
|
||||||
else if (w1.getPriority() > w2.getPriority())
|
|
||||||
return 1;
|
|
||||||
else return w1.getName().compareTo(w2.getName());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all the single waves for the given arena.
|
|
||||||
*/
|
|
||||||
/*public static TreeSet<SingleWave> getSingleWaves(Configuration config, String arena)
|
|
||||||
{
|
|
||||||
TreeSet<SingleWave> result = new TreeSet<SingleWave>();
|
|
||||||
|
|
||||||
List<String> waves = config.getKeys("arenas." + arena + ".waves.single");
|
|
||||||
if (waves != null)
|
|
||||||
{
|
|
||||||
int wave;
|
|
||||||
|
|
||||||
for (String w : waves)
|
|
||||||
{
|
|
||||||
wave = config.getInt("arenas." + arena + ".waves.single." + w + ".wave", 0);
|
|
||||||
if (wave == 0) continue;
|
|
||||||
result.add(new SingleWave(w, wave));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all the recurrent waves for the given arena.
|
|
||||||
* If no waves are found, a default wave is added. This ensures that
|
|
||||||
* the arena always has monsters spawning, regardless of how badly the
|
|
||||||
* user messes up the config-file.
|
|
||||||
*/
|
|
||||||
/*public static TreeSet<RecurrentWave> getRecurrentWaves(Configuration config, String arena)
|
|
||||||
{
|
|
||||||
TreeSet<RecurrentWave> result = new TreeSet<RecurrentWave>();
|
|
||||||
|
|
||||||
List<String> waves = config.getKeys("arenas." + arena + ".waves.recurrent");
|
|
||||||
if (waves != null)
|
|
||||||
{
|
|
||||||
int wave, frequency, priority;
|
|
||||||
|
|
||||||
for (String w : waves)
|
|
||||||
{
|
|
||||||
frequency = config.getInt("arenas." + arena + ".waves.recurrent." + w + ".frequency", 0);
|
|
||||||
priority = config.getInt("arenas." + arena + ".waves.recurrent." + w + ".priority", 0);
|
|
||||||
if (frequency == 0 || priority == 0) continue;
|
|
||||||
|
|
||||||
wave = config.getInt("arenas." + arena + ".waves.single." + w + ".wave", frequency);
|
|
||||||
result.add(new RecurrentWave(w, wave, frequency, priority));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RecurrentWave def = new RecurrentWave("DEF_WAVE_AUTO", 1, 1, 1);
|
|
||||||
def.setType(WaveType.DEFAULT);
|
|
||||||
def.setGrowth(WaveGrowth.MEDIUM);
|
|
||||||
|
|
||||||
RecurrentWave spec = new RecurrentWave("SPEC_WAVE_AUTO", 4, 4, 4);
|
|
||||||
spec.setType(WaveType.SPECIAL);
|
|
||||||
|
|
||||||
result.add(def);
|
|
||||||
result.add(spec);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -407,7 +249,8 @@ public class WaveUtils
|
|||||||
|
|
||||||
for (String monster : monsters)
|
for (String monster : monsters)
|
||||||
{
|
{
|
||||||
if (getEnumFromString(CreatureType.class, monster) != null)
|
//if (getEnumFromString(CreatureType.class, monster) != null)
|
||||||
|
if (getEnumFromString(MACreature.class, monster) != null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MAUtils.error("Invalid monster type '" + monster + "' in " + path);
|
MAUtils.error("Invalid monster type '" + monster + "' in " + path);
|
||||||
@@ -494,6 +337,69 @@ public class WaveUtils
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Comparators
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a comparator based on the WaveBranch parameter.
|
||||||
|
*/
|
||||||
|
public static Comparator<Wave> getComparator(WaveBranch branch)
|
||||||
|
{
|
||||||
|
if (branch == WaveBranch.SINGLE)
|
||||||
|
return getSingleComparator();
|
||||||
|
else if (branch == WaveBranch.RECURRENT)
|
||||||
|
return getRecurrentComparator();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a Comparator that compares Wave objects by wave number.
|
||||||
|
* If the wave numbers are equal, the waves are equal. This is to
|
||||||
|
* DISALLOW "duplicates" in the SINGLE WAVES collection.
|
||||||
|
* @return Comparator whose compare()-method compares wave numbers.
|
||||||
|
*/
|
||||||
|
public static Comparator<Wave> getSingleComparator()
|
||||||
|
{
|
||||||
|
return new Comparator<Wave>()
|
||||||
|
{
|
||||||
|
public int compare(Wave w1, Wave w2)
|
||||||
|
{
|
||||||
|
if (w1.getWave() < w2.getWave())
|
||||||
|
return -1;
|
||||||
|
else if (w1.getWave() > w2.getWave())
|
||||||
|
return 1;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a Comparator that compares Wave objects by priority.
|
||||||
|
* If the priorities are equal, the names are compared. This is to
|
||||||
|
* ALLOW "duplicates" in the RECURRENT WAVES collection.
|
||||||
|
* @return Comparator whose compare()-method compares wave priorities.
|
||||||
|
*/
|
||||||
|
public static Comparator<Wave> getRecurrentComparator()
|
||||||
|
{
|
||||||
|
return new Comparator<Wave>()
|
||||||
|
{
|
||||||
|
public int compare(Wave w1, Wave w2)
|
||||||
|
{
|
||||||
|
if (w1.getPriority() < w2.getPriority())
|
||||||
|
return -1;
|
||||||
|
else if (w1.getPriority() > w2.getPriority())
|
||||||
|
return 1;
|
||||||
|
else return w1.getName().compareTo(w2.getName());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*////////////////////////////////////////////////////////////////////
|
/*////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Misc - Perhaps move into MAUtils?
|
// Misc - Perhaps move into MAUtils?
|
||||||
|
|||||||
@@ -1,43 +1,85 @@
|
|||||||
package com.garbagemule.MobArena.waves;
|
package com.garbagemule.MobArena.waves;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.Arena;
|
||||||
|
|
||||||
public abstract class AbstractWave implements Wave
|
public abstract class AbstractWave implements Wave
|
||||||
{
|
{
|
||||||
private String name;
|
private Arena arena;
|
||||||
|
private World world;
|
||||||
|
private String waveName;
|
||||||
private int wave, frequency, priority;
|
private int wave, frequency, priority;
|
||||||
|
private WaveBranch branch;
|
||||||
private WaveType type;
|
private WaveType type;
|
||||||
private WaveGrowth growth;
|
private WaveGrowth growth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic wave constructor.
|
* Basic wave constructor.
|
||||||
* Constructs a wave with an initial wave number, a wave frequency, and
|
* @param name The config-file identifier
|
||||||
* a wave priority.
|
|
||||||
* @param wave Initial wave number. This is the first wave number this wave can spawn at.
|
* @param wave Initial wave number. This is the first wave number this wave can spawn at.
|
||||||
* @param frequency How often the wave can spawn.
|
* @param frequency How often the wave can spawn.
|
||||||
* @param priority The priority of the wave.
|
* @param priority The priority of the wave.
|
||||||
|
* @param branch The branch type (single, recurrent)
|
||||||
*/
|
*/
|
||||||
public AbstractWave(String name, int wave, int frequency, int priority)
|
public AbstractWave(Arena arena, String waveName, int wave, int frequency, int priority, WaveBranch branch)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.arena = arena;
|
||||||
|
this.world = arena.getWorld();
|
||||||
|
this.waveName = waveName;
|
||||||
this.wave = wave;
|
this.wave = wave;
|
||||||
this.frequency = frequency;
|
this.frequency = frequency;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
|
this.branch = branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default recurrent wave constructor
|
||||||
|
public AbstractWave(Arena arena, String name, int wave, int frequency, int priority)
|
||||||
|
{
|
||||||
|
this(arena, name, wave, frequency, priority, WaveBranch.RECURRENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default single wave constructor
|
||||||
|
public AbstractWave(Arena arena, String name, int wave)
|
||||||
|
{
|
||||||
|
this(arena, name, wave, 0, 0, WaveBranch.SINGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default wave constructor.
|
* Check if a wave matches a wave number.
|
||||||
* Constructs a basic wave with additional information in the type of
|
* SINGLE WAVES match, if their wave number is the same as the
|
||||||
* wave and the wave growth.
|
* parameter.
|
||||||
* @param wave Initial wave number. This is the first wave number this wave can spawn at.
|
* RECURRENT WAVES match, if their wave number subtracted from
|
||||||
* @param frequency How often the wave can spawn.
|
* the parameter divides the frequency. The wave number must be
|
||||||
* @param priority The priority of the wave.
|
* greater than or equal to the parameter.
|
||||||
* @param type The type of wave.
|
* @param wave The wave number to compare
|
||||||
* @param growth The growth rate of the wave.
|
* @return true, if the wave matches the wave number
|
||||||
*/
|
*/
|
||||||
public AbstractWave(String name, int wave, int frequency, int priority, WaveType type, WaveGrowth growth)
|
public boolean matches(int wave)
|
||||||
{
|
{
|
||||||
this(name, wave, frequency, priority);
|
if (branch == WaveBranch.SINGLE)
|
||||||
this.type = type;
|
return this.wave == wave;
|
||||||
this.growth = growth;
|
|
||||||
|
if (branch == WaveBranch.RECURRENT && wave >= this.wave)
|
||||||
|
return ((wave - this.wave) % frequency == 0);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GETTERS
|
||||||
|
public Arena getArena()
|
||||||
|
{
|
||||||
|
return arena;
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getWorld()
|
||||||
|
{
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WaveBranch getBranch()
|
||||||
|
{
|
||||||
|
return branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaveType getType()
|
public WaveType getType()
|
||||||
@@ -45,21 +87,11 @@ public abstract class AbstractWave implements Wave
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(WaveType type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WaveGrowth getGrowth()
|
public WaveGrowth getGrowth()
|
||||||
{
|
{
|
||||||
return growth;
|
return growth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGrowth(WaveGrowth growth)
|
|
||||||
{
|
|
||||||
this.growth = growth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWave()
|
public int getWave()
|
||||||
{
|
{
|
||||||
return wave;
|
return wave;
|
||||||
@@ -77,12 +109,29 @@ public abstract class AbstractWave implements Wave
|
|||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return waveName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SETTERS
|
||||||
|
public void setBranch(WaveBranch branch)
|
||||||
|
{
|
||||||
|
this.branch = branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(WaveType type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGrowth(WaveGrowth growth)
|
||||||
|
{
|
||||||
|
this.growth = growth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MISC
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "[name=" + name +
|
return "[name=" + waveName +
|
||||||
", wave=" + wave +
|
", wave=" + wave +
|
||||||
", frequency=" + frequency +
|
", frequency=" + frequency +
|
||||||
", priority=" + priority + "]";
|
", priority=" + priority + "]";
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package com.garbagemule.MobArena.waves;
|
package com.garbagemule.MobArena.waves;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.waves.Wave.BossAbility;
|
import com.garbagemule.MobArena.waves.Wave.BossAbility;
|
||||||
|
|
||||||
public class BossWave
|
public class BossWave // TODO: implement/extend something?
|
||||||
{
|
{
|
||||||
private Creature boss;
|
private Creature boss;
|
||||||
private Set<BossAbility> abilities;
|
private Set<BossAbility> abilities;
|
||||||
@@ -32,4 +34,17 @@ public class BossWave
|
|||||||
{
|
{
|
||||||
this.health = health;
|
this.health = health;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void spawn(int wave, Collection<Location> spawnpoints)
|
||||||
|
{
|
||||||
|
// Spawn boss and adds
|
||||||
|
// Something like this, perhaps? Pseudo-code
|
||||||
|
// LivingEntity b = spawnCreature(bossType, random location)
|
||||||
|
// boss = (Creature) b;
|
||||||
|
// boss.setHealth(health);
|
||||||
|
// for (String a : ablts)
|
||||||
|
// abilities.add(BossAbility.fromString(a));
|
||||||
|
// for (int i = 0; i < addCount; i++)
|
||||||
|
// adds.add(spawnCreature(addType, bossLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package com.garbagemule.MobArena.waves;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.Arena;
|
||||||
|
import com.garbagemule.MobArena.util.WaveUtils;
|
||||||
|
|
||||||
|
public class DefaultWave extends AbstractWave
|
||||||
|
{
|
||||||
|
private int totalProbability = 0;
|
||||||
|
private Map<Integer,MACreature> probabilities = new TreeMap<Integer,MACreature>();
|
||||||
|
|
||||||
|
// Recurrent
|
||||||
|
public DefaultWave(Arena arena, String name, int wave, int frequency, int priority, Configuration config, String path)
|
||||||
|
{
|
||||||
|
super(arena, name, wave, frequency, priority);
|
||||||
|
load(config, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Single
|
||||||
|
public DefaultWave(Arena arena, String name, int wave, Configuration config, String path)
|
||||||
|
{
|
||||||
|
super(arena, name, wave);
|
||||||
|
load(config, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the wave for spawning by initializing the variables and
|
||||||
|
* populating the collections needed.
|
||||||
|
* @param config The config-file
|
||||||
|
* @param path The absolute path of the wave
|
||||||
|
*/
|
||||||
|
public void load(Configuration config, String path)
|
||||||
|
{
|
||||||
|
// Extract the monster probabilities and calculate the sum
|
||||||
|
totalProbability = 0;
|
||||||
|
int prob;
|
||||||
|
for (String m : config.getKeys(path + "monsters"))
|
||||||
|
{
|
||||||
|
prob = config.getInt(path + "monsters." + m, 1);
|
||||||
|
totalProbability += prob;
|
||||||
|
probabilities.put(totalProbability, MACreature.fromString(m));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void spawn(int wave)
|
||||||
|
{
|
||||||
|
// Get the valid spawnpoints, and initialize counter
|
||||||
|
List<Location> validSpawnpoints = WaveUtils.getValidSpawnpoints(getArena().getSpawnpoints(), getArena().getLivingPlayers());
|
||||||
|
int noOfSpawnpoints = validSpawnpoints.size();
|
||||||
|
|
||||||
|
// Initialize the total amount of mobs to spawn
|
||||||
|
int totalToSpawn = getGrowth().getAmount(wave, getArena().getPlayerCount());
|
||||||
|
|
||||||
|
// Allocate some variables
|
||||||
|
Random random = new Random();
|
||||||
|
int randomNumber;
|
||||||
|
Location loc;
|
||||||
|
|
||||||
|
// Spawn <totalToSpawn> monsters
|
||||||
|
for (int i = 0; i < totalToSpawn; i++)
|
||||||
|
{
|
||||||
|
// Grab the next location.
|
||||||
|
loc = validSpawnpoints.get(i % noOfSpawnpoints);
|
||||||
|
|
||||||
|
// Grab a random number.
|
||||||
|
randomNumber = random.nextInt(totalProbability);
|
||||||
|
|
||||||
|
// Find the monster that corresponds to the random number, and spawn it
|
||||||
|
for (Map.Entry<Integer,MACreature> entry : probabilities.entrySet())
|
||||||
|
{
|
||||||
|
if (randomNumber > entry.getKey()) continue;
|
||||||
|
|
||||||
|
// Spawn and add to collection
|
||||||
|
LivingEntity e = entry.getValue().spawn(getWorld(), loc);
|
||||||
|
getArena().addMonster(e);
|
||||||
|
|
||||||
|
// Grab a random target.
|
||||||
|
if (e instanceof Creature)
|
||||||
|
{
|
||||||
|
Creature c = (Creature) e;
|
||||||
|
c.setTarget(WaveUtils.getClosestPlayer(getArena(), e));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("WAVE SPAWN! Wave: " + wave + ", name: " + getName() + ", type: " + getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package com.garbagemule.MobArena.waves;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
|
import org.bukkit.entity.Creeper;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.util.WaveUtils;
|
||||||
|
|
||||||
|
public enum MACreature
|
||||||
|
{
|
||||||
|
// Default creatures
|
||||||
|
ZOMBIES(CreatureType.ZOMBIE),
|
||||||
|
SKELETONS(CreatureType.SKELETON),
|
||||||
|
SPIDERS(CreatureType.SPIDER),
|
||||||
|
CREEPERS(CreatureType.CREEPER),
|
||||||
|
WOLVES(CreatureType.WOLF),
|
||||||
|
|
||||||
|
// Special creatures
|
||||||
|
ZOMBIE_PIGMEN(CreatureType.PIG_ZOMBIE),
|
||||||
|
POWERED_CREEPERS(CreatureType.CREEPER),
|
||||||
|
ANGRY_WOLVES(CreatureType.WOLF),
|
||||||
|
HUMANS(CreatureType.MONSTER),
|
||||||
|
SLIMES(CreatureType.SLIME),
|
||||||
|
GIANTS(CreatureType.GIANT),
|
||||||
|
GHASTS(CreatureType.GHAST);
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
// EXPLODING_SHEEP(CreatureType.SHEEP), // Explode (power: 1) when close enough to players
|
||||||
|
// PLAGUED_PIGS(CreatureType.PIG), // Damage "aura" (getNearbyEntities)
|
||||||
|
// MAD_COWS(CreatureType.COW); // Ram/throw players
|
||||||
|
//
|
||||||
|
|
||||||
|
private CreatureType type;
|
||||||
|
|
||||||
|
private MACreature(CreatureType type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreatureType getType()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MACreature fromString(String string)
|
||||||
|
{
|
||||||
|
return WaveUtils.getEnumFromString(MACreature.class, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LivingEntity spawn(World world, Location loc)
|
||||||
|
{
|
||||||
|
LivingEntity e = world.spawnCreature(loc, type);
|
||||||
|
|
||||||
|
switch (this)
|
||||||
|
{
|
||||||
|
case POWERED_CREEPERS:
|
||||||
|
((Creeper) e).setPowered(true);
|
||||||
|
break;
|
||||||
|
case ANGRY_WOLVES:
|
||||||
|
((Wolf) e).setAngry(true);
|
||||||
|
break;
|
||||||
|
case SLIMES:
|
||||||
|
((Slime) e).setSize(2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LivingEntity spawn(MACreature creature, World world, Location loc)
|
||||||
|
{
|
||||||
|
LivingEntity e = world.spawnCreature(loc, creature.type);
|
||||||
|
|
||||||
|
switch (creature)
|
||||||
|
{
|
||||||
|
case POWERED_CREEPERS:
|
||||||
|
((Creeper) e).setPowered(true);
|
||||||
|
break;
|
||||||
|
case ANGRY_WOLVES:
|
||||||
|
((Wolf) e).setAngry(true);
|
||||||
|
break;
|
||||||
|
case SLIMES:
|
||||||
|
((Slime) e).setSize(2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ public class RecurrentWave extends AbstractWave
|
|||||||
|
|
||||||
public RecurrentWave(String name, int wave, int frequency, int priority, WaveType type, WaveGrowth growth)
|
public RecurrentWave(String name, int wave, int frequency, int priority, WaveType type, WaveGrowth growth)
|
||||||
{
|
{
|
||||||
super(name, wave, frequency, priority, type, growth);
|
super(name, wave, frequency, priority, WaveBranch.RECURRENT, type, growth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawn(int wave, Collection<Location> spawnpoints)
|
public void spawn(int wave, Collection<Location> spawnpoints)
|
||||||
@@ -28,7 +28,10 @@ public class RecurrentWave extends AbstractWave
|
|||||||
|
|
||||||
public boolean matches(int wave)
|
public boolean matches(int wave)
|
||||||
{
|
{
|
||||||
return wave % getWave() + getFrequency() == 0;
|
if (wave < getWave())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (wave - getWave()) % getFrequency() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +39,7 @@ public class RecurrentWave extends AbstractWave
|
|||||||
* If the priorities are equal, the names are compared. This is to
|
* If the priorities are equal, the names are compared. This is to
|
||||||
* ALLOW "duplicates" in the RECURRENT WAVES collection.
|
* ALLOW "duplicates" in the RECURRENT WAVES collection.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public int compareTo(Wave w)
|
public int compareTo(Wave w)
|
||||||
{
|
{
|
||||||
if (getPriority() < w.getPriority())
|
if (getPriority() < w.getPriority())
|
||||||
@@ -44,4 +48,5 @@ public class RecurrentWave extends AbstractWave
|
|||||||
return 1;
|
return 1;
|
||||||
else return getName().compareTo(w.getName());
|
else return getName().compareTo(w.getName());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class SingleWave extends AbstractWave
|
|||||||
public SingleWave(String name, int wave)
|
public SingleWave(String name, int wave)
|
||||||
{
|
{
|
||||||
super(name, wave, 0, 0);
|
super(name, wave, 0, 0);
|
||||||
|
setBranch(WaveBranch.SINGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawn(int wave, Collection<Location> spawnpoints)
|
public void spawn(int wave, Collection<Location> spawnpoints)
|
||||||
@@ -26,6 +27,7 @@ public class SingleWave extends AbstractWave
|
|||||||
* If the wave numbers are equal, the waves are equal. This is to
|
* If the wave numbers are equal, the waves are equal. This is to
|
||||||
* DISALLOW "duplicates" in the SINGLE WAVES collection.
|
* DISALLOW "duplicates" in the SINGLE WAVES collection.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public int compareTo(Wave w)
|
public int compareTo(Wave w)
|
||||||
{
|
{
|
||||||
if (this.getWave() < w.getWave())
|
if (this.getWave() < w.getWave())
|
||||||
@@ -34,4 +36,5 @@ public class SingleWave extends AbstractWave
|
|||||||
return 1;
|
return 1;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.garbagemule.MobArena.waves;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.Arena;
|
||||||
|
|
||||||
|
public class SpecialWave extends AbstractWave
|
||||||
|
{
|
||||||
|
// Recurrent
|
||||||
|
public SpecialWave(Arena arena, String name, int wave, int frequency, int priority)
|
||||||
|
{
|
||||||
|
super(arena, name, wave, frequency, priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Single
|
||||||
|
public SpecialWave(Arena arena, String name, int wave)
|
||||||
|
{
|
||||||
|
super(arena, name, wave);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void spawn(int wave)
|
||||||
|
{
|
||||||
|
System.out.println("WAVE SPAWN! Wave: " + wave + ", name: " + getName() + ", type: " + getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
package com.garbagemule.MobArena.waves;
|
package com.garbagemule.MobArena.waves;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
|
|
||||||
import com.garbagemule.MobArena.util.WaveUtils;
|
import com.garbagemule.MobArena.util.WaveUtils;
|
||||||
|
|
||||||
public interface Wave extends Comparable<Wave>
|
public interface Wave
|
||||||
{
|
{
|
||||||
public enum WaveBranch
|
public enum WaveBranch
|
||||||
{
|
{
|
||||||
@@ -25,11 +21,28 @@ public interface Wave extends Comparable<Wave>
|
|||||||
|
|
||||||
public enum WaveGrowth
|
public enum WaveGrowth
|
||||||
{
|
{
|
||||||
SLOW, MEDIUM, FAST;
|
OLD(0), SLOW(0.5), MEDIUM(0.65), FAST(0.8), PSYCHO(1.1);
|
||||||
|
private double exp;
|
||||||
|
|
||||||
|
private WaveGrowth(double exp)
|
||||||
|
{
|
||||||
|
this.exp = exp;
|
||||||
|
}
|
||||||
|
|
||||||
public static WaveGrowth fromString(String string)
|
public static WaveGrowth fromString(String string)
|
||||||
{
|
{
|
||||||
return WaveUtils.getEnumFromString(WaveGrowth.class, string, MEDIUM);
|
return WaveUtils.getEnumFromString(WaveGrowth.class, string, OLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount(int wave, int playerCount)
|
||||||
|
{
|
||||||
|
if (this == OLD) return wave + playerCount;
|
||||||
|
|
||||||
|
double pc = (double) playerCount;
|
||||||
|
double w = (double) wave;
|
||||||
|
|
||||||
|
double base = Math.min(Math.ceil(pc/2) + 1, 13);
|
||||||
|
return (int) ( base * Math.pow(w, exp) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +82,7 @@ public interface Wave extends Comparable<Wave>
|
|||||||
* be modified by the wave parameter.
|
* be modified by the wave parameter.
|
||||||
* @param wave Wave number
|
* @param wave Wave number
|
||||||
*/
|
*/
|
||||||
public void spawn(int wave, Collection<Location> spawnpoints);
|
public void spawn(int wave);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of wave.
|
* Get the type of wave.
|
||||||
@@ -107,6 +120,12 @@ public interface Wave extends Comparable<Wave>
|
|||||||
*/
|
*/
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the wave's growth
|
||||||
|
* @param growth How fast the wave will grow
|
||||||
|
*/
|
||||||
|
public void setGrowth(WaveGrowth growth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this wave matches the wave number.
|
* Check if this wave matches the wave number.
|
||||||
* The SingleWave class does a simple check if its wave == the parameter.
|
* The SingleWave class does a simple check if its wave == the parameter.
|
||||||
|
|||||||
@@ -3,27 +3,121 @@ package com.garbagemule.register.payment;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method.java
|
* Interface to be implemented by a payment method.
|
||||||
* Interface for all sub-methods for payment.
|
|
||||||
*
|
*
|
||||||
* @author: Nijikokun<nijikokun@gmail.com> (@nijikokun)
|
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||||
* @copyright: Copyright (C) 2011
|
* @copyright Copyright (C) 2011
|
||||||
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
|
* @license AOL license <http://aol.nexua.org>
|
||||||
*/
|
*/
|
||||||
public interface Method {
|
public interface Method {
|
||||||
|
/**
|
||||||
|
* Encodes the Plugin into an Object disguised as the Plugin.
|
||||||
|
* If you want the original Plugin Class you must cast it to the correct
|
||||||
|
* Plugin, to do so you have to verify the name and or version then cast.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* if(method.getName().equalsIgnoreCase("iConomy"))
|
||||||
|
* iConomy plugin = ((iConomy)method.getPlugin());</pre>
|
||||||
|
*
|
||||||
|
* @return <code>Object</code>
|
||||||
|
* @see #getName()
|
||||||
|
* @see #getVersion()
|
||||||
|
*/
|
||||||
public Object getPlugin();
|
public Object getPlugin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the actual name of this method.
|
||||||
|
*
|
||||||
|
* @return <code>String</code> Plugin name.
|
||||||
|
*/
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the actual version of this method.
|
||||||
|
*
|
||||||
|
* @return <code>String</code> Plugin version.
|
||||||
|
*/
|
||||||
public String getVersion();
|
public String getVersion();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats amounts into this payment methods style of currency display.
|
||||||
|
*
|
||||||
|
* @param amount Double
|
||||||
|
* @return <code>String</code> - Formatted Currency Display.
|
||||||
|
*/
|
||||||
public String format(double amount);
|
public String format(double amount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the verification of bank API existence in this payment method.
|
||||||
|
*
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
*/
|
||||||
public boolean hasBanks();
|
public boolean hasBanks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the existence of a bank via name.
|
||||||
|
*
|
||||||
|
* @param bank Bank name
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
* @see #hasBanks
|
||||||
|
*/
|
||||||
public boolean hasBank(String bank);
|
public boolean hasBank(String bank);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the existence of an account via name.
|
||||||
|
*
|
||||||
|
* @param name Account name
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
*/
|
||||||
public boolean hasAccount(String name);
|
public boolean hasAccount(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if an account <code>name</code> is tied to a <code>bank</code>.
|
||||||
|
*
|
||||||
|
* @param bank Bank name
|
||||||
|
* @param name Account name
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
*/
|
||||||
public boolean hasBankAccount(String bank, String name);
|
public boolean hasBankAccount(String bank, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
|
||||||
|
*
|
||||||
|
* @param name Account name
|
||||||
|
* @return <code>MethodAccount</code> <em>or</em> <code>Null</code>
|
||||||
|
*/
|
||||||
public MethodAccount getAccount(String name);
|
public MethodAccount getAccount(String name);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>MethodBankAccount</code> class for an account <code>name</code>.
|
||||||
|
*
|
||||||
|
* @param bank Bank name
|
||||||
|
* @param name Account name
|
||||||
|
* @return <code>MethodBankAccount</code> <em>or</em> <code>Null</code>
|
||||||
|
*/
|
||||||
public MethodBankAccount getBankAccount(String bank, String name);
|
public MethodBankAccount getBankAccount(String bank, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to verify the compatibility between this Method and a plugin.
|
||||||
|
* Internal usage only, for the most part.
|
||||||
|
*
|
||||||
|
* @param plugin Plugin
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
*/
|
||||||
public boolean isCompatible(Plugin plugin);
|
public boolean isCompatible(Plugin plugin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Plugin data.
|
||||||
|
*
|
||||||
|
* @param plugin Plugin
|
||||||
|
*/
|
||||||
public void setPlugin(Plugin plugin);
|
public void setPlugin(Plugin plugin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains Calculator and Balance functions for Accounts.
|
||||||
|
*/
|
||||||
public interface MethodAccount {
|
public interface MethodAccount {
|
||||||
public double balance();
|
public double balance();
|
||||||
public boolean set(double amount);
|
public boolean set(double amount);
|
||||||
@@ -41,6 +135,9 @@ public interface Method {
|
|||||||
public String toString();
|
public String toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains Calculator and Balance functions for Bank Accounts.
|
||||||
|
*/
|
||||||
public interface MethodBankAccount {
|
public interface MethodBankAccount {
|
||||||
public double balance();
|
public double balance();
|
||||||
public String getBankName();
|
public String getBankName();
|
||||||
|
|||||||
@@ -1,21 +1,31 @@
|
|||||||
package com.garbagemule.register.payment;
|
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.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods.java
|
* The <code>Methods</code> initializes Methods that utilize the Method interface
|
||||||
* Controls the getting / setting of methods & the method of payment used.
|
* based on a "first come, first served" basis.
|
||||||
*
|
*
|
||||||
* @author: Nijikokun<[email protected]> (@nijikokun)
|
* Allowing you to check whether a payment method exists or not.
|
||||||
|
*
|
||||||
|
* <blockquote><pre>
|
||||||
|
* Methods methods = new Methods();
|
||||||
|
* </pre></blockquote>
|
||||||
|
*
|
||||||
|
* Methods also allows you to set a preferred method of payment before it captures
|
||||||
|
* payment plugins in the initialization process.
|
||||||
|
*
|
||||||
|
* <blockquote><pre>
|
||||||
|
* Methods methods = new Methods("iConomy");
|
||||||
|
* </pre></blockquote>
|
||||||
|
*
|
||||||
|
* @author: Nijikokun <[email protected]> (@nijikokun)
|
||||||
* @copyright: Copyright (C) 2011
|
* @copyright: Copyright (C) 2011
|
||||||
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
|
* @license: AOL license <http://aol.nexua.org>
|
||||||
*/
|
*/
|
||||||
public class Methods {
|
public class Methods {
|
||||||
private boolean self = false;
|
private boolean self = false;
|
||||||
@@ -25,14 +35,18 @@ public class Methods {
|
|||||||
private Set<String> Dependencies = new HashSet<String>();
|
private Set<String> Dependencies = new HashSet<String>();
|
||||||
private Set<Method> Attachables = new HashSet<Method>();
|
private Set<Method> Attachables = new HashSet<Method>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Method class
|
||||||
|
*/
|
||||||
public Methods() {
|
public Methods() {
|
||||||
this._init();
|
this._init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to set which economy plugin is most preferred.
|
* Initializes <code>Methods</code> class utilizing a "preferred" payment method check before
|
||||||
|
* returning the first method that was initialized.
|
||||||
*
|
*
|
||||||
* @param preferred - preferred economy plugin
|
* @param preferred Payment method that is most preferred for this setup.
|
||||||
*/
|
*/
|
||||||
public Methods(String preferred) {
|
public Methods(String preferred) {
|
||||||
this._init();
|
this._init();
|
||||||
@@ -42,18 +56,40 @@ public class Methods {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement all methods along with their respective name & class.
|
||||||
|
*
|
||||||
|
* @see #Methods()
|
||||||
|
* @see #Methods(java.lang.String)
|
||||||
|
*/
|
||||||
private void _init() {
|
private void _init() {
|
||||||
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo4());
|
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo6());
|
||||||
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo5());
|
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo5());
|
||||||
this.addMethod("BOSEconomy", new BOSE6());
|
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo4());
|
||||||
this.addMethod("BOSEconomy", new BOSE7());
|
this.addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE6());
|
||||||
|
this.addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE7());
|
||||||
this.addMethod("Essentials", new com.garbagemule.register.payment.methods.EE17());
|
this.addMethod("Essentials", new com.garbagemule.register.payment.methods.EE17());
|
||||||
|
this.addMethod("MultiCurrency", new com.garbagemule.register.payment.methods.MCUR());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of payment method names that have been loaded
|
||||||
|
* through the <code>_init</code> method.
|
||||||
|
*
|
||||||
|
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
||||||
|
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||||
|
*/
|
||||||
public Set<String> getDependencies() {
|
public Set<String> getDependencies() {
|
||||||
return Dependencies;
|
return Dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interprets Plugin class data to verify whether it is compatible with an existing payment
|
||||||
|
* method to use for payments and other various economic activity.
|
||||||
|
*
|
||||||
|
* @param plugin Plugin data from bukkit, Internal Class file.
|
||||||
|
* @return Method <em>or</em> Null
|
||||||
|
*/
|
||||||
public Method createMethod(Plugin plugin) {
|
public Method createMethod(Plugin plugin) {
|
||||||
for (Method method: Methods) {
|
for (Method method: Methods) {
|
||||||
if (method.isCompatible(plugin)) {
|
if (method.isCompatible(plugin)) {
|
||||||
@@ -70,17 +106,31 @@ public class Methods {
|
|||||||
Methods.add(method);
|
Methods.add(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies if Register has set a payment method for usage yet.
|
||||||
|
*
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||||
|
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
||||||
|
*/
|
||||||
public boolean hasMethod() {
|
public boolean hasMethod() {
|
||||||
return (Method != null);
|
return (Method != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks Plugin Class against a multitude of checks to verify it's usability
|
||||||
|
* as a payment method.
|
||||||
|
*
|
||||||
|
* @param method Plugin data from bukkit, Internal Class file.
|
||||||
|
* @return <code>boolean</code> True on success, False on failure.
|
||||||
|
*/
|
||||||
public boolean setMethod(Plugin method) {
|
public boolean setMethod(Plugin method) {
|
||||||
if(hasMethod()) return true;
|
if(hasMethod()) return true;
|
||||||
if(self) { self = false; return false; }
|
if(self) { self = false; return false; }
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
Plugin plugin;
|
Plugin plugin = null;
|
||||||
PluginManager manager = method.getServer().getPluginManager();
|
PluginManager manager = method.getServer().getPluginManager();
|
||||||
|
|
||||||
for(String name: this.getDependencies()) {
|
for(String name: this.getDependencies()) {
|
||||||
@@ -129,10 +179,22 @@ public class Methods {
|
|||||||
return hasMethod();
|
return hasMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grab the existing and initialized (hopefully) Method Class.
|
||||||
|
*
|
||||||
|
* @return <code>Method</code> <em>or</em> <code>Null</code>
|
||||||
|
*/
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return Method;
|
return Method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify is a plugin is disabled, only does this if we there is an existing payment
|
||||||
|
* method initialized in Register.
|
||||||
|
*
|
||||||
|
* @param method Plugin data from bukkit, Internal Class file.
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
*/
|
||||||
public boolean checkDisabled(Plugin method) {
|
public boolean checkDisabled(Plugin method) {
|
||||||
if(!hasMethod()) return true;
|
if(!hasMethod()) return true;
|
||||||
if (Method.isCompatible(method)) Method = null;
|
if (Method.isCompatible(method)) Method = null;
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
import cosine.boseconomy.BOSEconomy;
|
import cosine.boseconomy.BOSEconomy;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BOSEconomy 6 Implementation of Method
|
||||||
|
*
|
||||||
|
* @author Nijikokun <[email protected]> (@nijikokun)
|
||||||
|
* @copyright (c) 2011
|
||||||
|
* @license AOL license <http://aol.nexua.org>
|
||||||
|
*/
|
||||||
public class BOSE6 implements Method {
|
public class BOSE6 implements Method {
|
||||||
private BOSEconomy BOSEconomy;
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
@@ -61,8 +67,8 @@ public class BOSE6 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class BOSEAccount implements MethodAccount {
|
public class BOSEAccount implements MethodAccount {
|
||||||
private String name;
|
private final String name;
|
||||||
private BOSEconomy BOSEconomy;
|
private final BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -70,7 +76,7 @@ public class BOSE6 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double balance() {
|
public double balance() {
|
||||||
return Double.valueOf(this.BOSEconomy.getPlayerMoney(this.name));
|
return (double) this.BOSEconomy.getPlayerMoney(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
@@ -123,8 +129,8 @@ public class BOSE6 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class BOSEBankAccount implements MethodBankAccount {
|
public class BOSEBankAccount implements MethodBankAccount {
|
||||||
private String bank;
|
private final String bank;
|
||||||
private BOSEconomy BOSEconomy;
|
private final BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||||
this.bank = bank;
|
this.bank = bank;
|
||||||
@@ -140,7 +146,7 @@ public class BOSE6 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double balance() {
|
public double balance() {
|
||||||
return Double.valueOf(this.BOSEconomy.getBankMoney(bank));
|
return (double) this.BOSEconomy.getBankMoney(bank);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
import cosine.boseconomy.BOSEconomy;
|
import cosine.boseconomy.BOSEconomy;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* BOSEconomy 7 Implementation of Method
|
||||||
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
* @author Nijikokun <[email protected]> (@nijikokun)
|
||||||
|
* @copyright (c) 2011
|
||||||
|
* @license AOL license <http://aol.nexua.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BOSE7 implements Method {
|
public class BOSE7 implements Method {
|
||||||
private BOSEconomy BOSEconomy;
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,21 @@ import com.earth2me.essentials.Essentials;
|
|||||||
import com.earth2me.essentials.api.Economy;
|
import com.earth2me.essentials.api.Economy;
|
||||||
import com.earth2me.essentials.api.NoLoanPermittedException;
|
import com.earth2me.essentials.api.NoLoanPermittedException;
|
||||||
import com.earth2me.essentials.api.UserDoesNotExistException;
|
import com.earth2me.essentials.api.UserDoesNotExistException;
|
||||||
import com.garbagemule.register.payment.Method;
|
|
||||||
|
|
||||||
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Essentials 17 Implementation of Method
|
||||||
|
*
|
||||||
|
* @author Nijikokun <[email protected]> (@nijikokun)
|
||||||
|
* @author Snowleo
|
||||||
|
* @author Acrobot
|
||||||
|
* @author KHobbits
|
||||||
|
* @copyright (c) 2011
|
||||||
|
* @license AOL license <http://aol.nexua.org>
|
||||||
|
*/
|
||||||
public class EE17 implements Method {
|
public class EE17 implements Method {
|
||||||
private Essentials Essentials;
|
private Essentials Essentials;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
|
import me.ashtheking.currency.Currency;
|
||||||
|
import me.ashtheking.currency.CurrencyList;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MultiCurrency Method implementation.
|
||||||
|
*
|
||||||
|
* @author Acrobot
|
||||||
|
* @copyright (c) 2011
|
||||||
|
* @license AOL license <http://aol.nexua.org>
|
||||||
|
*/
|
||||||
|
public class MCUR implements Method {
|
||||||
|
private Currency currencyList;
|
||||||
|
|
||||||
|
public Object getPlugin() {
|
||||||
|
return this.currencyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "MultiCurrency";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return "0.09";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String format(double amount) {
|
||||||
|
return amount + " Currency";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBanks() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBank(String bank) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasAccount(String name) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodAccount getAccount(String name) {
|
||||||
|
return new MCurrencyAccount(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCompatible(Plugin plugin) {
|
||||||
|
return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlugin(Plugin plugin) {
|
||||||
|
currencyList = (Currency) plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MCurrencyAccount implements MethodAccount{
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public MCurrencyAccount(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double balance() {
|
||||||
|
return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean set(double amount) {
|
||||||
|
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean add(double amount) {
|
||||||
|
return CurrencyList.add(name, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean subtract(double amount) {
|
||||||
|
return CurrencyList.subtract(name, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean multiply(double amount) {
|
||||||
|
return CurrencyList.multiply(name, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean divide(double amount) {
|
||||||
|
return CurrencyList.divide(name, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEnough(double amount) {
|
||||||
|
return CurrencyList.hasEnough(name, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasOver(double amount) {
|
||||||
|
return CurrencyList.hasOver(name, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUnder(double amount) {
|
||||||
|
return CurrencyList.hasUnder(name, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNegative() {
|
||||||
|
return CurrencyList.isNegative(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean remove() {
|
||||||
|
return CurrencyList.remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,19 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
|
||||||
import com.nijiko.coelho.iConomy.iConomy;
|
import com.nijiko.coelho.iConomy.iConomy;
|
||||||
import com.nijiko.coelho.iConomy.system.Account;
|
import com.nijiko.coelho.iConomy.system.Account;
|
||||||
|
|
||||||
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* iConomy 4 Implementation of Method
|
||||||
|
*
|
||||||
|
* @author Nijikokun <[email protected]> (@nijikokun)
|
||||||
|
* @copyright (c) 2011
|
||||||
|
* @license AOL license <http://aol.nexua.org>
|
||||||
|
*/
|
||||||
public class iCo4 implements Method {
|
public class iCo4 implements Method {
|
||||||
private iConomy iConomy;
|
private iConomy iConomy;
|
||||||
|
|
||||||
@@ -51,7 +58,7 @@ public class iCo4 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && !plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
|
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") && plugin instanceof iConomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
|
||||||
import com.iConomy.iConomy;
|
import com.iConomy.iConomy;
|
||||||
import com.iConomy.system.Account;
|
import com.iConomy.system.Account;
|
||||||
import com.iConomy.system.BankAccount;
|
import com.iConomy.system.BankAccount;
|
||||||
import com.iConomy.system.Holdings;
|
import com.iConomy.system.Holdings;
|
||||||
import com.iConomy.util.Constants;
|
import com.iConomy.util.Constants;
|
||||||
|
|
||||||
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* iConomy 5 Implementation of Method
|
||||||
|
*
|
||||||
|
* @author Nijikokun <[email protected]> (@nijikokun)
|
||||||
|
* @copyright (c) 2011
|
||||||
|
* @license AOL license <http://aol.nexua.org>
|
||||||
|
*/
|
||||||
public class iCo5 implements Method {
|
public class iCo5 implements Method {
|
||||||
private iConomy iConomy;
|
private iConomy iConomy;
|
||||||
|
|
||||||
@@ -34,7 +41,7 @@ public class iCo5 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBank(String bank) {
|
public boolean hasBank(String bank) {
|
||||||
return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank);
|
return (hasBanks()) && this.iConomy.Banks.exists(bank);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAccount(String name) {
|
public boolean hasAccount(String name) {
|
||||||
@@ -42,7 +49,7 @@ public class iCo5 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBankAccount(String bank, String name) {
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
return (!hasBank(bank)) ? false : this.iConomy.getBank(bank).hasAccount(name);
|
return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodAccount getAccount(String name) {
|
public MethodAccount getAccount(String name) {
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
|
import com.iCo6.iConomy;
|
||||||
|
import com.iCo6.system.Account;
|
||||||
|
import com.iCo6.system.Accounts;
|
||||||
|
import com.iCo6.system.Holdings;
|
||||||
|
|
||||||
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* iConomy 6 Implementation of Method
|
||||||
|
*
|
||||||
|
* @author Nijikokun <[email protected]> (@nijikokun)
|
||||||
|
* @copyright (c) 2011
|
||||||
|
* @license AOL license <http://aol.nexua.org>
|
||||||
|
*/
|
||||||
|
public class iCo6 implements Method {
|
||||||
|
private iConomy iConomy;
|
||||||
|
|
||||||
|
public iConomy getPlugin() {
|
||||||
|
return this.iConomy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "iConomy";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return "6";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String format(double amount) {
|
||||||
|
return this.iConomy.format(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBanks() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBank(String bank) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasAccount(String name) {
|
||||||
|
return (new Accounts()).exists(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodAccount getAccount(String name) {
|
||||||
|
return new iCoAccount((new Accounts()).get(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCompatible(Plugin plugin) {
|
||||||
|
try { Class.forName("com.iCo6.IO"); }
|
||||||
|
catch(Exception e) { return false; }
|
||||||
|
|
||||||
|
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iCo6.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.getBalance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean set(double amount) {
|
||||||
|
if(this.holdings == null) return false;
|
||||||
|
this.holdings.setBalance(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user