mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
Added mob waves and the wave trigger
Still needs a trigger to trigger other signs
This commit is contained in:
parent
bac30d3dbb
commit
53ef4f2280
@ -22,8 +22,8 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|||||||
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -74,6 +74,8 @@ public class GameCommand extends BRCommand {
|
|||||||
MessageUtil.sendMessage(sender, "&bGame type: &e" + (game.getType() == null ? "Not started yet" : game.getType()));
|
MessageUtil.sendMessage(sender, "&bGame type: &e" + (game.getType() == null ? "Not started yet" : game.getType()));
|
||||||
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeonName() == null ? "N/A" : dGroup.getDungeonName()));
|
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeonName() == null ? "N/A" : dGroup.getDungeonName()));
|
||||||
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getMapName() == null ? "N/A" : dGroup.getMapName()));
|
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getMapName() == null ? "N/A" : dGroup.getMapName()));
|
||||||
|
MessageUtil.sendMessage(sender, "&bWaves finished: &e" + game.getWaveCount());
|
||||||
|
MessageUtil.sendMessage(sender, "&bKills: &e" + game.getGameKills() + " / Game; " + game.getWaveKills() + " / Wave");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ public class WorldConfig {
|
|||||||
private boolean isLobbyDisabled = false;
|
private boolean isLobbyDisabled = false;
|
||||||
private int timeToNextPlay = 0;
|
private int timeToNextPlay = 0;
|
||||||
private int timeToNextLoot = 0;
|
private int timeToNextLoot = 0;
|
||||||
|
private int timeToNextWave = 10;
|
||||||
|
|
||||||
private int timeUntilKickOfflinePlayer = -1;
|
private int timeUntilKickOfflinePlayer = -1;
|
||||||
private int timeToFinish = -1;
|
private int timeToFinish = -1;
|
||||||
@ -295,6 +296,12 @@ public class WorldConfig {
|
|||||||
timeToNextLoot = plugin.getDefaultConfig().timeToNextLoot;
|
timeToNextLoot = plugin.getDefaultConfig().timeToNextLoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("timeToNextWave")) {
|
||||||
|
timeToNextWave = configFile.getInt("timeToNextWave");
|
||||||
|
} else {
|
||||||
|
timeToNextWave = plugin.getDefaultConfig().timeToNextWave;
|
||||||
|
}
|
||||||
|
|
||||||
if (configFile.contains("timeUntilKickOfflinePlayer")) {
|
if (configFile.contains("timeUntilKickOfflinePlayer")) {
|
||||||
timeUntilKickOfflinePlayer = configFile.getInt("timeUntilKickOfflinePlayer");
|
timeUntilKickOfflinePlayer = configFile.getInt("timeUntilKickOfflinePlayer");
|
||||||
} else {
|
} else {
|
||||||
@ -579,6 +586,13 @@ public class WorldConfig {
|
|||||||
return timeToNextLoot;
|
return timeToNextLoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the break between two waves
|
||||||
|
*/
|
||||||
|
public int getTimeToNextWave() {
|
||||||
|
return timeToNextWave;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the time until a player gets kicked from his group if he is offline
|
* @return the time until a player gets kicked from his group if he is offline
|
||||||
*/
|
*/
|
||||||
|
@ -16,13 +16,22 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.game;
|
package io.github.dre2n.dungeonsxl.game;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
@ -35,6 +44,9 @@ public class Game {
|
|||||||
private boolean started;
|
private boolean started;
|
||||||
private GameType type;
|
private GameType type;
|
||||||
private GameWorld world;
|
private GameWorld world;
|
||||||
|
private int waveCount;
|
||||||
|
private Map<String, Integer> gameKills = new HashMap<>();
|
||||||
|
private Map<String, Integer> waveKills = new HashMap<>();
|
||||||
|
|
||||||
public Game(DGroup dGroup) {
|
public Game(DGroup dGroup) {
|
||||||
dGroups.add(dGroup);
|
dGroups.add(dGroup);
|
||||||
@ -124,6 +136,73 @@ public class Game {
|
|||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the waveCount
|
||||||
|
*/
|
||||||
|
public int getWaveCount() {
|
||||||
|
return waveCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param waveCount
|
||||||
|
* the waveCount to set
|
||||||
|
*/
|
||||||
|
public void setWaveCount(int waveCount) {
|
||||||
|
this.waveCount = waveCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return how many mobs have been killed in the game
|
||||||
|
*/
|
||||||
|
public int getGameKills() {
|
||||||
|
int count = 0;
|
||||||
|
for (String killer : gameKills.keySet()) {
|
||||||
|
count += gameKills.get(killer);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return how many mobs have been killed in the last game
|
||||||
|
*/
|
||||||
|
public int getWaveKills() {
|
||||||
|
int count = 0;
|
||||||
|
for (String killer : waveKills.keySet()) {
|
||||||
|
count += waveKills.get(killer);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param killer
|
||||||
|
* the killer; null if the killer is not a player
|
||||||
|
*/
|
||||||
|
public void addKill(String killer) {
|
||||||
|
if (killer == null) {
|
||||||
|
killer = "N/A";
|
||||||
|
}
|
||||||
|
waveKills.put(killer, waveKills.get(killer) == null ? 1 : waveKills.get(killer) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the values of the wave kills map to the game kills map and resets the wave kills.
|
||||||
|
*/
|
||||||
|
public void resetWaveKills() {
|
||||||
|
gameKills.putAll(waveKills);
|
||||||
|
waveKills.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the players in all dGroups
|
||||||
|
*/
|
||||||
|
public Set<Player> getPlayers() {
|
||||||
|
Set<Player> toReturn = new HashSet<>();
|
||||||
|
for (DGroup dGroup : dGroups) {
|
||||||
|
toReturn.addAll(dGroup.getPlayers());
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if the DGroup list is empty
|
* @return if the DGroup list is empty
|
||||||
*/
|
*/
|
||||||
@ -131,7 +210,55 @@ public class Game {
|
|||||||
return dGroups.isEmpty();
|
return dGroups.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
/* Actions */
|
||||||
|
/**
|
||||||
|
* @param mobCountIncreaseRate
|
||||||
|
* the new mob count will be increased by this rate
|
||||||
|
* @param teleport
|
||||||
|
* whether or not to teleport the players to the start location
|
||||||
|
*/
|
||||||
|
public void finishWave(final double mobCountIncreaseRate, final boolean teleport) {
|
||||||
|
waveCount++;
|
||||||
|
resetWaveKills();
|
||||||
|
|
||||||
|
int delay = world.getConfig().getTimeToNextWave();
|
||||||
|
sendMessage(plugin.getMessageConfig().getMessage(MessageConfig.Messages.GROUP_WAVE_FINISHED, String.valueOf(waveCount), String.valueOf(delay)));
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (teleport) {
|
||||||
|
for (Player player : getPlayers()) {
|
||||||
|
PlayerUtil.secureTeleport(player, world.getLocStart());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DSign dSign : world.getDSigns()) {
|
||||||
|
if (!(dSign instanceof MobSign)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobSign mobSign = (MobSign) dSign;
|
||||||
|
int newAmount = (int) Math.ceil(mobSign.getInitialAmount() * mobCountIncreaseRate);
|
||||||
|
|
||||||
|
mobSign.setAmount(newAmount);
|
||||||
|
mobSign.setInitialAmount(newAmount);
|
||||||
|
mobSign.initializeTask();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, delay * 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message the message to send
|
||||||
|
*/
|
||||||
|
public void sendMessage(String message) {
|
||||||
|
for (DGroup dGroup : dGroups) {
|
||||||
|
dGroup.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Statics */
|
||||||
public static Game getByDGroup(DGroup dGroup) {
|
public static Game getByDGroup(DGroup dGroup) {
|
||||||
for (Game game : plugin.getGames()) {
|
for (Game game : plugin.getGames()) {
|
||||||
if (game.getDGroups().contains(dGroup)) {
|
if (game.getDGroups().contains(dGroup)) {
|
||||||
|
@ -43,7 +43,7 @@ public enum GameTypeDefault implements GameType {
|
|||||||
private String signName;
|
private String signName;
|
||||||
private boolean playerVersusPlayer;
|
private boolean playerVersusPlayer;
|
||||||
private boolean friendlyFire;
|
private boolean friendlyFire;
|
||||||
private boolean mobWaves;// TODO: Implementing
|
private boolean mobWaves;
|
||||||
private boolean rewards;
|
private boolean rewards;
|
||||||
private boolean showTime;
|
private boolean showTime;
|
||||||
private boolean build;
|
private boolean build;
|
||||||
|
@ -18,14 +18,14 @@ package io.github.dre2n.dungeonsxl.listener;
|
|||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -90,7 +90,11 @@ public class EntityListener implements Listener {
|
|||||||
if (gameWorld.isPlaying()) {
|
if (gameWorld.isPlaying()) {
|
||||||
if (entity.getType() != EntityType.PLAYER) {
|
if (entity.getType() != EntityType.PLAYER) {
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
DMob.onDeath(event);
|
|
||||||
|
DMob dMob = DMob.getByEntity(entity);
|
||||||
|
if (dMob != null) {
|
||||||
|
dMob.onDeath(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,6 +114,31 @@ public class EntityListener implements Listener {
|
|||||||
if (!gameWorld.isPlaying()) {
|
if (!gameWorld.isPlaying()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean dead = ((LivingEntity) event.getEntity()).getHealth() - event.getFinalDamage() <= 0;
|
||||||
|
if (dead && DMob.getByEntity(event.getEntity()) != null) {
|
||||||
|
String killer = null;
|
||||||
|
|
||||||
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
|
Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
|
||||||
|
|
||||||
|
if (damager instanceof Projectile) {
|
||||||
|
if (((Projectile) damager).getShooter() instanceof Player) {
|
||||||
|
damager = (Player) ((Projectile) damager).getShooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (damager instanceof Player) {
|
||||||
|
killer = damager.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameWorld.getGame().addKill(killer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
@ -155,27 +184,23 @@ public class EntityListener implements Listener {
|
|||||||
DGroup attackerDGroup = null;
|
DGroup attackerDGroup = null;
|
||||||
DGroup attackedDGroup = null;
|
DGroup attackedDGroup = null;
|
||||||
|
|
||||||
if (attackerEntity instanceof Player && attackedEntity instanceof Player) {
|
if (attackerEntity instanceof LivingEntity && attackedEntity instanceof LivingEntity) {
|
||||||
attackerPlayer = (Player) attackerEntity;
|
if (attackerEntity instanceof Player && attackedEntity instanceof Player) {
|
||||||
attackedPlayer = (Player) attackedEntity;
|
attackerPlayer = (Player) attackerEntity;
|
||||||
|
attackedPlayer = (Player) attackedEntity;
|
||||||
|
|
||||||
attackerDGroup = DGroup.getByPlayer(attackerPlayer);
|
attackerDGroup = DGroup.getByPlayer(attackerPlayer);
|
||||||
attackedDGroup = DGroup.getByPlayer(attackedPlayer);
|
attackedDGroup = DGroup.getByPlayer(attackedPlayer);
|
||||||
|
|
||||||
if (!pvp) {
|
if (!pvp) {
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attackerDGroup != null && attackedDGroup != null) {
|
|
||||||
if (!friendlyFire && attackerDGroup.equals(attackedDGroup)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attackerEntity instanceof LivingEntity && attackedEntity instanceof LivingEntity) {
|
if (attackerDGroup != null && attackedDGroup != null) {
|
||||||
if (!(attackerEntity instanceof Player) && !(attackedEntity instanceof Player)) {
|
if (!friendlyFire && attackerDGroup.equals(attackedDGroup)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Dogs
|
// Check Dogs
|
||||||
|
@ -17,9 +17,13 @@
|
|||||||
package io.github.dre2n.dungeonsxl.mob;
|
package io.github.dre2n.dungeonsxl.mob;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dmob.DMobDeathEvent;
|
import io.github.dre2n.dungeonsxl.event.dmob.DMobDeathEvent;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.MobTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.MobTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.WaveTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -50,22 +54,11 @@ public class DMob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) {
|
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) {
|
||||||
gameWorld.addDMob(this);
|
this(entity, gameWorld, type);
|
||||||
|
|
||||||
this.entity = entity;
|
|
||||||
this.type = type;
|
|
||||||
this.trigger = trigger;
|
this.trigger = trigger;
|
||||||
|
|
||||||
/* Remove DropChance of equipment */
|
|
||||||
this.entity.getEquipment().setHelmetDropChance(0);
|
|
||||||
this.entity.getEquipment().setChestplateDropChance(0);
|
|
||||||
this.entity.getEquipment().setLeggingsDropChance(0);
|
|
||||||
this.entity.getEquipment().setBootsDropChance(0);
|
|
||||||
this.entity.getEquipment().setItemInHandDropChance(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Statics */
|
public void onDeath(EntityDeathEvent event) {
|
||||||
public static void onDeath(EntityDeathEvent event) {
|
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -78,43 +71,56 @@ public class DMob {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DMob dMob : gameWorld.getDMobs()) {
|
DMobDeathEvent dMobDeathEvent = new DMobDeathEvent(this, event);
|
||||||
if (dMob.entity != victim) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DMobDeathEvent dMobDeathEvent = new DMobDeathEvent(dMob, event);
|
if (dMobDeathEvent.isCancelled()) {
|
||||||
|
|
||||||
if (dMobDeathEvent.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dMob.type != null) {
|
|
||||||
for (ItemStack itemStack : dMob.type.getDrops().keySet()) {
|
|
||||||
Random randomGenerator = new Random();
|
|
||||||
int random = randomGenerator.nextInt(100);
|
|
||||||
|
|
||||||
if (dMob.type.getDrops().get(itemStack) > random) {
|
|
||||||
event.getDrops().add(itemStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name = dMob.type.getName();
|
|
||||||
|
|
||||||
} else if (dMob.type == null && dMob.trigger != null) {// <=MythicMobs mob
|
|
||||||
name = dMob.trigger;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
name = victim.getType().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
MobTrigger trigger = MobTrigger.get(name, gameWorld);
|
|
||||||
if (trigger != null) {
|
|
||||||
trigger.onTrigger();
|
|
||||||
}
|
|
||||||
|
|
||||||
gameWorld.removeDMob(dMob);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type != null) {
|
||||||
|
for (ItemStack itemStack : type.getDrops().keySet()) {
|
||||||
|
Random randomGenerator = new Random();
|
||||||
|
int random = randomGenerator.nextInt(100);
|
||||||
|
|
||||||
|
if (type.getDrops().get(itemStack) > random) {
|
||||||
|
event.getDrops().add(itemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name = type.getName();
|
||||||
|
|
||||||
|
} else if (type == null && trigger != null) {// <=MythicMobs mob
|
||||||
|
name = trigger;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
name = victim.getType().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
MobTrigger mobTriger = MobTrigger.get(name, gameWorld);
|
||||||
|
if (mobTriger != null) {
|
||||||
|
mobTriger.onTrigger();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<WaveTrigger> waveTriggers = WaveTrigger.getByGameWorld(gameWorld);
|
||||||
|
for (WaveTrigger waveTrigger : waveTriggers) {
|
||||||
|
if (Game.getByGameWorld(gameWorld).getWaveKills() >= Math.ceil(gameWorld.getMobCount() * waveTrigger.getMustKillRate())) {
|
||||||
|
waveTrigger.onTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameWorld.removeDMob(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Statics */
|
||||||
|
public static DMob getByEntity(Entity entity) {
|
||||||
|
GameWorld gameWorld = GameWorld.getByWorld(entity.getWorld());
|
||||||
|
|
||||||
|
for (DMob dMob : gameWorld.getDMobs()) {
|
||||||
|
if (dMob.entity == entity) {
|
||||||
|
return dMob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package io.github.dre2n.dungeonsxl.player;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||||
@ -30,12 +29,12 @@ import io.github.dre2n.dungeonsxl.event.reward.RewardAdditionEvent;
|
|||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||||
import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask;
|
import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -63,7 +62,6 @@ public class DGroup {
|
|||||||
private GameWorld gameWorld;
|
private GameWorld gameWorld;
|
||||||
private boolean playing;
|
private boolean playing;
|
||||||
private int floorCount;
|
private int floorCount;
|
||||||
private int waveCount;
|
|
||||||
private List<Reward> rewards = new ArrayList<>();
|
private List<Reward> rewards = new ArrayList<>();
|
||||||
private BukkitTask timeIsRunningTask;
|
private BukkitTask timeIsRunningTask;
|
||||||
|
|
||||||
@ -377,21 +375,6 @@ public class DGroup {
|
|||||||
this.floorCount = floorCount;
|
this.floorCount = floorCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the waveCount
|
|
||||||
*/
|
|
||||||
public int getWaveCount() {
|
|
||||||
return waveCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param waveCount
|
|
||||||
* the waveCount to set
|
|
||||||
*/
|
|
||||||
public void setWaveCount(int waveCount) {
|
|
||||||
this.waveCount = waveCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the rewards
|
* @return the rewards
|
||||||
*/
|
*/
|
||||||
@ -442,7 +425,8 @@ public class DGroup {
|
|||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return players.isEmpty();
|
return players.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
/**
|
/**
|
||||||
* Remove the group from the List
|
* Remove the group from the List
|
||||||
*/
|
*/
|
||||||
@ -547,16 +531,6 @@ public class DGroup {
|
|||||||
GroupSign.updatePerGroup(this);
|
GroupSign.updatePerGroup(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishWave(double mobCountIncreaseRate) {
|
|
||||||
for (DGroup dGroup : DGroup.getByGameWorld(gameWorld)) {
|
|
||||||
dGroup.sendMessage(messageConfig.getMessage(Messages.GROUP_WAVE_FINISHED, String.valueOf(dGroup.getWaveCount()) + "TIME"));// TODO
|
|
||||||
|
|
||||||
for (Player player : dGroup.getPlayers()) {
|
|
||||||
PlayerUtil.secureTeleport(player, gameWorld.getLocStart());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to all players in the group
|
* Send a message to all players in the group
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,6 @@ import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
|||||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
|
import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
|
||||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishFloorEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishFloorEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerFinishEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerFinishEvent;
|
||||||
@ -36,9 +35,10 @@ import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerUpdateEvent;
|
|||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
@ -473,7 +473,7 @@ public class DPlayer extends DGlobalPlayer {
|
|||||||
this.lives = lives;
|
this.lives = lives;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
/* Actions */
|
||||||
public void escape() {
|
public void escape() {
|
||||||
delete();
|
delete();
|
||||||
savePlayer.reset(false);
|
savePlayer.reset(false);
|
||||||
@ -761,6 +761,8 @@ public class DPlayer extends DGlobalPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Game.getByDGroup(dGroup).resetWaveKills();
|
||||||
|
|
||||||
for (Player player : dGroup.getPlayers()) {
|
for (Player player : dGroup.getPlayers()) {
|
||||||
DPlayer dPlayer = getByPlayer(player);
|
DPlayer dPlayer = getByPlayer(player);
|
||||||
dPlayer.leave();
|
dPlayer.leave();
|
||||||
|
210
src/main/java/io/github/dre2n/dungeonsxl/sign/DMobSign.java
Normal file
210
src/main/java/io/github/dre2n/dungeonsxl/sign/DMobSign.java
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2016 Frank Baumann
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.task.MobSpawnTask;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class DMobSign extends DSign implements MobSign {
|
||||||
|
|
||||||
|
private DSignType type = DSignTypeDefault.MOB;
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
private String mob;
|
||||||
|
private int maxInterval = 1;
|
||||||
|
private int interval = 0;
|
||||||
|
private int amount = 1;
|
||||||
|
private int initialAmount = 1;
|
||||||
|
private boolean initialized;
|
||||||
|
private boolean active;
|
||||||
|
private BukkitTask task;
|
||||||
|
|
||||||
|
public DMobSign(Sign sign, GameWorld gameWorld) {
|
||||||
|
super(sign, gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMob() {
|
||||||
|
return mob;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMob(String mob) {
|
||||||
|
this.mob = mob;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxInterval() {
|
||||||
|
return maxInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMaxInterval(int maxInterval) {
|
||||||
|
this.maxInterval = maxInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInterval() {
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInterval(int interval) {
|
||||||
|
this.interval = interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInitialAmount() {
|
||||||
|
return initialAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialAmount(int initialAmount) {
|
||||||
|
this.initialAmount = initialAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInitialized() {
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialized(boolean initialized) {
|
||||||
|
this.initialized = initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setActive(boolean active) {
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BukkitTask getTask() {
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTask(BukkitTask task) {
|
||||||
|
this.task = task;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initializeTask() {
|
||||||
|
task = new MobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
String lines[] = getSign().getLines();
|
||||||
|
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lines[1] == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] attributes = lines[2].split(",");
|
||||||
|
if (attributes.length == 2) {
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
String lines[] = getSign().getLines();
|
||||||
|
if (!lines[1].isEmpty() && !lines[2].isEmpty()) {
|
||||||
|
String mob = lines[1];
|
||||||
|
if (mob != null) {
|
||||||
|
String[] attributes = lines[2].split(",");
|
||||||
|
if (attributes.length == 2) {
|
||||||
|
this.mob = mob;
|
||||||
|
maxInterval = NumberUtil.parseInt(attributes[0]);
|
||||||
|
amount = NumberUtil.parseInt(attributes[1]);
|
||||||
|
initialAmount = amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrigger() {
|
||||||
|
if (!initialized || active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeTask();
|
||||||
|
|
||||||
|
active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
if (!initialized || !active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
killTask();
|
||||||
|
interval = 0;
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void killTask() {
|
||||||
|
if (!initialized || !active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (task != null) {
|
||||||
|
task.cancel();
|
||||||
|
task = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DSignType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,8 +18,9 @@ package io.github.dre2n.dungeonsxl.sign;
|
|||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.event.dsign.DSignRegistrationEvent;
|
import io.github.dre2n.dungeonsxl.event.dsign.DSignRegistrationEvent;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.Trigger;
|
import io.github.dre2n.dungeonsxl.trigger.Trigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -93,6 +94,13 @@ public abstract class DSign {
|
|||||||
return gameWorld;
|
return gameWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the game
|
||||||
|
*/
|
||||||
|
public Game getGame() {
|
||||||
|
return Game.getByGameWorld(gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the triggers
|
* @return the triggers
|
||||||
*/
|
*/
|
||||||
@ -136,10 +144,6 @@ public abstract class DSign {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (triggers.size() != 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trigger.getPlayer() == null) {
|
if (trigger.getPlayer() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public enum DSignTypeDefault implements DSignType {
|
|||||||
INTERACT("Interact", "dxl.sign.interact", true, InteractSign.class),
|
INTERACT("Interact", "dxl.sign.interact", true, InteractSign.class),
|
||||||
LEAVE("Leave", "dxl.sign.leave", true, LeaveSign.class),
|
LEAVE("Leave", "dxl.sign.leave", true, LeaveSign.class),
|
||||||
LOBBY("Lobby", "dxl.sign.lobby", true, LobbySign.class),
|
LOBBY("Lobby", "dxl.sign.lobby", true, LobbySign.class),
|
||||||
MOB("Mob", "dxl.sign.mob", false, MobSign.class),
|
MOB("Mob", "dxl.sign.mob", false, DMobSign.class),
|
||||||
MESSAGE("MSG", "dxl.sign.msg", false, MessageSign.class),
|
MESSAGE("MSG", "dxl.sign.msg", false, MessageSign.class),
|
||||||
MYTHIC_MOBS("MythicMobs", "dxl.sign.mob", false, MythicMobsSign.class),
|
MYTHIC_MOBS("MythicMobs", "dxl.sign.mob", false, MythicMobsSign.class),
|
||||||
PLACE("Place", "dxl.sign.place", false, PlaceSign.class),
|
PLACE("Place", "dxl.sign.place", false, PlaceSign.class),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2016 Frank Baumann
|
* Copyright (C) 2016 Daniel Saukel
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,213 +16,104 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.task.MobSpawnTask;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class MobSign extends DSign {
|
public interface MobSign {
|
||||||
|
|
||||||
private DSignType type = DSignTypeDefault.MOB;
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
private String mob;
|
|
||||||
private int maxinterval = 1;
|
|
||||||
private int interval = 0;
|
|
||||||
private int amount = 1;
|
|
||||||
private boolean initialized;
|
|
||||||
private boolean active;
|
|
||||||
private BukkitTask task;
|
|
||||||
|
|
||||||
public MobSign(Sign sign, GameWorld gameWorld) {
|
|
||||||
super(sign, gameWorld);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the mob
|
* @return the mob
|
||||||
*/
|
*/
|
||||||
public String getMob() {
|
public String getMob();
|
||||||
return mob;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mob
|
* @param mob
|
||||||
* the mob to set
|
* the mob to set
|
||||||
*/
|
*/
|
||||||
public void setMob(String mob) {
|
public void setMob(String mob);
|
||||||
this.mob = mob;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the maxinterval
|
* @return the the maximum interval between mob spawns
|
||||||
*/
|
*/
|
||||||
public int getMaxinterval() {
|
public int getMaxInterval();
|
||||||
return maxinterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param maxinterval
|
* @param maxInterval
|
||||||
* the maxinterval to set
|
* the maximum interval between mob spawns
|
||||||
*/
|
*/
|
||||||
public void setMaxinterval(int maxinterval) {
|
public void setMaxInterval(int maxInterval);
|
||||||
this.maxinterval = maxinterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the interval
|
* @return the spawn interval
|
||||||
*/
|
*/
|
||||||
public int getInterval() {
|
public int getInterval();
|
||||||
return interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param interval
|
* @param interval
|
||||||
* the interval to set
|
* the spawn interval
|
||||||
*/
|
*/
|
||||||
public void setInterval(int interval) {
|
public void setInterval(int interval);
|
||||||
this.interval = interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the amount
|
* @return the amount of mobs
|
||||||
*/
|
*/
|
||||||
public int getAmount() {
|
public int getAmount();
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param amount
|
* @param amount
|
||||||
* the amount to set
|
* the amount of mobs to set
|
||||||
*/
|
*/
|
||||||
public void setAmount(int amount) {
|
public void setAmount(int amount);
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the initialized
|
* @return the initial amount of mobs
|
||||||
*/
|
*/
|
||||||
public boolean isInitialized() {
|
public int getInitialAmount();
|
||||||
return initialized;
|
|
||||||
}
|
/**
|
||||||
|
* @param amount
|
||||||
|
* the amount of mobs to set
|
||||||
|
*/
|
||||||
|
public void setInitialAmount(int initialAmount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the sign is initialized
|
||||||
|
*/
|
||||||
|
public boolean isInitialized();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param initialized
|
* @param initialized
|
||||||
* the initialized to set
|
* set the sign initialized
|
||||||
*/
|
*/
|
||||||
public void setInitialized(boolean initialized) {
|
public void setInitialized(boolean initialized);
|
||||||
this.initialized = initialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the active
|
* @return if the sign is active
|
||||||
*/
|
*/
|
||||||
public boolean isActive() {
|
public boolean isActive();
|
||||||
return active;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param active
|
* @param active
|
||||||
* the active to set
|
* set the sign active
|
||||||
*/
|
*/
|
||||||
public void setActive(boolean active) {
|
public void setActive(boolean active);
|
||||||
this.active = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the task
|
* @return the spawn task
|
||||||
*/
|
*/
|
||||||
public BukkitTask getTask() {
|
public BukkitTask getTask();
|
||||||
return task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param task
|
* @param task
|
||||||
* the task to set
|
* the task to set
|
||||||
*/
|
*/
|
||||||
public void setTask(BukkitTask task) {
|
public void setTask(BukkitTask task);
|
||||||
this.task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean check() {
|
* Start a new spawn task.
|
||||||
String lines[] = getSign().getLines();
|
*/
|
||||||
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
public void initializeTask();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lines[1] == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] attributes = lines[2].split(",");
|
|
||||||
if (attributes.length == 2) {
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInit() {
|
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
if (!lines[1].isEmpty() && !lines[2].isEmpty()) {
|
|
||||||
String mob = lines[1];
|
|
||||||
if (mob != null) {
|
|
||||||
String[] attributes = lines[2].split(",");
|
|
||||||
if (attributes.length == 2) {
|
|
||||||
this.mob = mob;
|
|
||||||
maxinterval = NumberUtil.parseInt(attributes[0]);
|
|
||||||
amount = NumberUtil.parseInt(attributes[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getSign().getBlock().setType(Material.AIR);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTrigger() {
|
|
||||||
if (!initialized || active) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
task = new MobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
|
|
||||||
|
|
||||||
active = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
if (!initialized || !active) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
killTask();
|
|
||||||
interval = 0;
|
|
||||||
active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void killTask() {
|
|
||||||
if (!initialized || !active) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (task != null) {
|
|
||||||
task.cancel();
|
|
||||||
task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DSignType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.task.MythicMobSpawnTask;
|
import io.github.dre2n.dungeonsxl.task.MythicMobSpawnTask;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -31,15 +31,16 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class MythicMobsSign extends DSign {
|
public class MythicMobsSign extends DSign implements MobSign {
|
||||||
|
|
||||||
private DSignType type = DSignTypeDefault.MYTHIC_MOBS;
|
private DSignType type = DSignTypeDefault.MYTHIC_MOBS;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private String mob;
|
private String mob;
|
||||||
private int maxinterval = 1;
|
private int maxInterval = 1;
|
||||||
private int interval = 0;
|
private int interval = 0;
|
||||||
private int amount = 1;
|
private int amount = 1;
|
||||||
|
private int initialAmount = 1;
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private BukkitTask task;
|
private BukkitTask task;
|
||||||
@ -51,96 +52,91 @@ public class MythicMobsSign extends DSign {
|
|||||||
super(sign, gameWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the mob
|
|
||||||
*/
|
|
||||||
public String getMob() {
|
public String getMob() {
|
||||||
return mob;
|
return mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @param mob
|
|
||||||
* the mob to set
|
|
||||||
*/
|
|
||||||
public void setMob(String mob) {
|
public void setMob(String mob) {
|
||||||
this.mob = mob;
|
this.mob = mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the maxinterval
|
public int getMaxInterval() {
|
||||||
*/
|
return maxInterval;
|
||||||
public int getMaxinterval() {
|
|
||||||
return maxinterval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @param maxinterval
|
public void setMaxInterval(int maxInterval) {
|
||||||
* the maxinterval to set
|
this.maxInterval = maxInterval;
|
||||||
*/
|
|
||||||
public void setMaxinterval(int maxinterval) {
|
|
||||||
this.maxinterval = maxinterval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the interval
|
|
||||||
*/
|
|
||||||
public int getInterval() {
|
public int getInterval() {
|
||||||
return interval;
|
return interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @param interval
|
|
||||||
* the interval to set
|
|
||||||
*/
|
|
||||||
public void setInterval(int interval) {
|
public void setInterval(int interval) {
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the amount
|
|
||||||
*/
|
|
||||||
public int getAmount() {
|
public int getAmount() {
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @param amount
|
|
||||||
* the amount to set
|
|
||||||
*/
|
|
||||||
public void setAmount(int amount) {
|
public void setAmount(int amount) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the initialized
|
public int getInitialAmount() {
|
||||||
*/
|
return initialAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialAmount(int initialAmount) {
|
||||||
|
this.initialAmount = initialAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isInitialized() {
|
public boolean isInitialized() {
|
||||||
return initialized;
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @param initialized
|
|
||||||
* the initialized to set
|
|
||||||
*/
|
|
||||||
public void setInitialized(boolean initialized) {
|
public void setInitialized(boolean initialized) {
|
||||||
this.initialized = initialized;
|
this.initialized = initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the active
|
|
||||||
*/
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @param active
|
|
||||||
* the active to set
|
|
||||||
*/
|
|
||||||
public void setActive(boolean active) {
|
public void setActive(boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BukkitTask getTask() {
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTask(BukkitTask task) {
|
||||||
|
this.task = task;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initializeTask() {
|
||||||
|
task = new MythicMobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the spawnLocation
|
* @return the spawnLocation
|
||||||
*/
|
*/
|
||||||
@ -186,21 +182,6 @@ public class MythicMobsSign extends DSign {
|
|||||||
this.mythicMobs = mythicMobs;
|
this.mythicMobs = mythicMobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public BukkitTask getTask() {
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param task
|
|
||||||
* the task to set
|
|
||||||
*/
|
|
||||||
public void setTask(BukkitTask task) {
|
|
||||||
this.task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
@ -224,15 +205,16 @@ public class MythicMobsSign extends DSign {
|
|||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
if (lines[1].isEmpty() || lines[2].equals("")) {
|
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
||||||
} else {
|
} else {
|
||||||
String mob = lines[1];
|
String mob = lines[1];
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
String[] attributes = lines[2].split(",");
|
String[] attributes = lines[2].split(",");
|
||||||
if (attributes.length == 2) {
|
if (attributes.length == 2) {
|
||||||
this.setMob(mob);
|
this.setMob(mob);
|
||||||
setMaxinterval(NumberUtil.parseInt(attributes[0]));
|
setMaxInterval(NumberUtil.parseInt(attributes[0]));
|
||||||
setAmount(NumberUtil.parseInt(attributes[1]));
|
setAmount(NumberUtil.parseInt(attributes[1]));
|
||||||
|
initialAmount = amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,7 +229,7 @@ public class MythicMobsSign extends DSign {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
task = new MythicMobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
|
initializeTask();
|
||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -33,6 +32,7 @@ public class WaveSign extends DSign {
|
|||||||
private DSignType type = DSignTypeDefault.WAVE;
|
private DSignType type = DSignTypeDefault.WAVE;
|
||||||
|
|
||||||
private double mobCountIncreaseRate;
|
private double mobCountIncreaseRate;
|
||||||
|
private boolean teleport;
|
||||||
|
|
||||||
public WaveSign(Sign sign, GameWorld gameWorld) {
|
public WaveSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gameWorld);
|
super(sign, gameWorld);
|
||||||
@ -53,6 +53,21 @@ public class WaveSign extends DSign {
|
|||||||
this.mobCountIncreaseRate = mobCountIncreaseRate;
|
this.mobCountIncreaseRate = mobCountIncreaseRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the group members will be teleported to the start location
|
||||||
|
*/
|
||||||
|
public boolean getTeleport() {
|
||||||
|
return teleport;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param teleport
|
||||||
|
* Set if the players shall get teleported to the start location
|
||||||
|
*/
|
||||||
|
public void setTeleport(boolean teleport) {
|
||||||
|
this.teleport = teleport;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
return true;
|
return true;
|
||||||
@ -65,6 +80,10 @@ public class WaveSign extends DSign {
|
|||||||
mobCountIncreaseRate = NumberUtil.parseDouble(lines[1], 2);
|
mobCountIncreaseRate = NumberUtil.parseDouble(lines[1], 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!lines[2].isEmpty()) {
|
||||||
|
teleport = lines[2].equals("+") || lines[2].equals("true");
|
||||||
|
}
|
||||||
|
|
||||||
if (!getTriggers().isEmpty()) {
|
if (!getTriggers().isEmpty()) {
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
return;
|
return;
|
||||||
@ -85,24 +104,13 @@ public class WaveSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
DGroup dGroup = DGroup.getByPlayer(player);
|
getGame().finishWave(mobCountIncreaseRate, teleport);
|
||||||
if (dGroup == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getGameWorld() == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dGroup.finishWave(mobCountIncreaseRate);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
for (DGroup dGroup : plugin.getDGroups()) {
|
getGame().finishWave(mobCountIncreaseRate, teleport);
|
||||||
dGroup.finishWave(mobCountIncreaseRate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.task;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMobType;
|
import io.github.dre2n.dungeonsxl.mob.DMobType;
|
||||||
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
import io.github.dre2n.dungeonsxl.sign.DMobSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -35,9 +35,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
*/
|
*/
|
||||||
public class MobSpawnTask extends BukkitRunnable {
|
public class MobSpawnTask extends BukkitRunnable {
|
||||||
|
|
||||||
private MobSign sign;
|
private DMobSign sign;
|
||||||
|
|
||||||
public MobSpawnTask(MobSign sign) {
|
public MobSpawnTask(DMobSign sign) {
|
||||||
this.sign = sign;
|
this.sign = sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,11 +84,10 @@ public class MobSpawnTask extends BukkitRunnable {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
sign.killTask();
|
sign.killTask();
|
||||||
sign.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sign.setInterval(sign.getMaxinterval());
|
sign.setInterval(sign.getMaxInterval());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sign.killTask();
|
sign.killTask();
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.task;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.sign.MythicMobsSign;
|
import io.github.dre2n.dungeonsxl.sign.MythicMobsSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -60,11 +60,10 @@ public class MythicMobSpawnTask extends BukkitRunnable {
|
|||||||
sign.setAmount(sign.getAmount() - 1);
|
sign.setAmount(sign.getAmount() - 1);
|
||||||
} else {
|
} else {
|
||||||
sign.killTask();
|
sign.killTask();
|
||||||
sign.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sign.setInterval(sign.getMaxinterval());
|
sign.setInterval(sign.getMaxInterval());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sign.killTask();
|
sign.killTask();
|
||||||
|
@ -51,7 +51,7 @@ public class MobTrigger extends Trigger {
|
|||||||
@Override
|
@Override
|
||||||
public void register(GameWorld gameWorld) {
|
public void register(GameWorld gameWorld) {
|
||||||
if (!hasTriggers(gameWorld)) {
|
if (!hasTriggers(gameWorld)) {
|
||||||
ArrayList<MobTrigger> list = new ArrayList<MobTrigger>();
|
ArrayList<MobTrigger> list = new ArrayList<>();
|
||||||
list.add(this);
|
list.add(this);
|
||||||
triggers.put(gameWorld, list);
|
triggers.put(gameWorld, list);
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ package io.github.dre2n.dungeonsxl.trigger;
|
|||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.event.trigger.TriggerRegistrationEvent;
|
import io.github.dre2n.dungeonsxl.event.trigger.TriggerRegistrationEvent;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -107,7 +107,7 @@ public abstract class Trigger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateDSigns() {
|
public void updateDSigns() {
|
||||||
for (DSign dSign : dSigns.toArray(new DSign[dSigns.size()])) {
|
for (DSign dSign : dSigns) {
|
||||||
dSign.onUpdate();
|
dSign.onUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ public abstract class Trigger {
|
|||||||
} else if (type == TriggerTypeDefault.WAVE) {
|
} else if (type == TriggerTypeDefault.WAVE) {
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return WaveTrigger.getOrCreate(NumberUtil.parseInt(value, 1), dSign.getGameWorld());
|
return WaveTrigger.getOrCreate(NumberUtil.parseDouble(value, 1), dSign.getGameWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type != null) {
|
} else if (type != null) {
|
||||||
|
@ -20,7 +20,9 @@ import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
|
|||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Daniel Saukel
|
* @author Frank Baumann, Daniel Saukel
|
||||||
@ -31,10 +33,25 @@ public class WaveTrigger extends Trigger {
|
|||||||
|
|
||||||
private TriggerType type = TriggerTypeDefault.WAVE;
|
private TriggerType type = TriggerTypeDefault.WAVE;
|
||||||
|
|
||||||
private int mustKillAmount;
|
private double mustKillRate = 1;
|
||||||
|
|
||||||
public WaveTrigger(int mustKillAmount) {
|
public WaveTrigger(double mustKillRate) {
|
||||||
this.mustKillAmount = mustKillAmount;
|
this.mustKillRate = mustKillRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the minimal mob kill rate to trigger the wave
|
||||||
|
*/
|
||||||
|
public double getMustKillRate() {
|
||||||
|
return mustKillRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mustKillRate
|
||||||
|
* the minimal mob kill rate to trigger the wave to set
|
||||||
|
*/
|
||||||
|
public void setMustKillRate(double mustKillRate) {
|
||||||
|
this.mustKillRate = mustKillRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
@ -46,12 +63,13 @@ public class WaveTrigger extends Trigger {
|
|||||||
|
|
||||||
setTriggered(true);
|
setTriggered(true);
|
||||||
updateDSigns();
|
updateDSigns();
|
||||||
|
setTriggered(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(GameWorld gameWorld) {
|
public void register(GameWorld gameWorld) {
|
||||||
if (!hasTriggers(gameWorld)) {
|
if (!hasTriggers(gameWorld)) {
|
||||||
ArrayList<WaveTrigger> list = new ArrayList<WaveTrigger>();
|
ArrayList<WaveTrigger> list = new ArrayList<>();
|
||||||
list.add(this);
|
list.add(this);
|
||||||
triggers.put(gameWorld, list);
|
triggers.put(gameWorld, list);
|
||||||
|
|
||||||
@ -72,40 +90,24 @@ public class WaveTrigger extends Trigger {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WaveTrigger getOrCreate(int mustKillAmount, GameWorld gameWorld) {
|
/* Statics */
|
||||||
WaveTrigger trigger = get(gameWorld);
|
public static WaveTrigger getOrCreate(double mustKillRate, GameWorld gameWorld) {
|
||||||
if (trigger != null) {
|
return new WaveTrigger(mustKillRate);
|
||||||
return trigger;
|
|
||||||
}
|
|
||||||
return new WaveTrigger(mustKillAmount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WaveTrigger get(GameWorld gameWorld) {
|
/**
|
||||||
if (hasTriggers(gameWorld)) {
|
* @return the WaveTriggers in the GameWorld
|
||||||
for (WaveTrigger trigger : triggers.get(gameWorld)) {
|
*/
|
||||||
return trigger;
|
public static Set<WaveTrigger> getByGameWorld(GameWorld gameWorld) {
|
||||||
}
|
Set<WaveTrigger> toReturn = new HashSet<>();
|
||||||
|
for (WaveTrigger trigger : triggers.get(gameWorld)) {
|
||||||
|
toReturn.add(trigger);
|
||||||
}
|
}
|
||||||
return null;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasTriggers(GameWorld gameWorld) {
|
public static boolean hasTriggers(GameWorld gameWorld) {
|
||||||
return !triggers.isEmpty() && triggers.containsKey(gameWorld);
|
return !triggers.isEmpty() && triggers.containsKey(gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the mustKillAmount
|
|
||||||
*/
|
|
||||||
public int getMustKillAmount() {
|
|
||||||
return mustKillAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mustKillAmount
|
|
||||||
* the mustKillAmount to set
|
|
||||||
*/
|
|
||||||
public void setMustKillAmount(int mustKillAmount) {
|
|
||||||
this.mustKillAmount = mustKillAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldLoadEvent;
|
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldLoadEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldStartGameEvent;
|
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldStartGameEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
|
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
|
||||||
@ -35,6 +34,7 @@ import io.github.dre2n.dungeonsxl.player.DGroup;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -338,6 +338,23 @@ public class GameWorld {
|
|||||||
this.dSigns = dSigns;
|
this.dSigns = dSigns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the potential amount of mobs in the world
|
||||||
|
*/
|
||||||
|
public int getMobCount() {
|
||||||
|
int mobCount = 0;
|
||||||
|
|
||||||
|
for (DSign dSign : dSigns) {
|
||||||
|
if (!(dSign instanceof MobSign)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
mobCount += ((MobSign) dSign).getInitialAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mobCount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the worldConfig
|
* @return the worldConfig
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user