mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-02 23:43:38 +01:00
Continue new game type feature
This commit is contained in:
parent
d519578dae
commit
f58063a3b2
@ -17,6 +17,7 @@ public class MessageConfig {
|
|||||||
GROUP_UNINVITED_PLAYER("Group_UninvitedPlayer", "&4&v1&6 took back the invitation for &4&v2&6 to the group &4&v3&6."),
|
GROUP_UNINVITED_PLAYER("Group_UninvitedPlayer", "&4&v1&6 took back the invitation for &4&v2&6 to the group &4&v3&6."),
|
||||||
GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."),
|
GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."),
|
||||||
GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"),
|
GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"),
|
||||||
|
GROUP_WAVE_FINISHED("Group_WaveFinished", "&6Your group finished wave no. &4&v1&6. The next one is going to start in &4&v2&6 seconds."),
|
||||||
|
|
||||||
LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!"),
|
LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!"),
|
||||||
LOG_ERROR_MOBTYPE("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!"),
|
LOG_ERROR_MOBTYPE("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!"),
|
||||||
|
@ -169,6 +169,10 @@ public class GameChest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Statics
|
// Statics
|
||||||
|
/**
|
||||||
|
* @param event
|
||||||
|
* event.getPlayer() has to be a Player
|
||||||
|
*/
|
||||||
public static void onOpenInventory(InventoryOpenEvent event) {
|
public static void onOpenInventory(InventoryOpenEvent event) {
|
||||||
InventoryView inventory = event.getView();
|
InventoryView inventory = event.getView();
|
||||||
|
|
||||||
@ -196,7 +200,7 @@ public class GameChest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) {
|
if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) {
|
||||||
gameChest.addTreasure(DGroup.getByGameWorld(gameWorld));
|
gameChest.addTreasure(DGroup.getByPlayer((Player) event.getPlayer()));
|
||||||
gameChest.used = true;
|
gameChest.used = true;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -18,28 +18,23 @@ public enum GameTypeDefault implements GameType {
|
|||||||
QUEST_TIME_IS_RUNNING("Quest - Time is Running", "Quest TiR", false, false, false, true, true, false, GameMode.SURVIVAL),
|
QUEST_TIME_IS_RUNNING("Quest - Time is Running", "Quest TiR", false, false, false, true, true, false, GameMode.SURVIVAL),
|
||||||
TEST("Test", "Test", false, false, false, false, true, true, GameMode.SURVIVAL),
|
TEST("Test", "Test", false, false, false, false, true, true, GameMode.SURVIVAL),
|
||||||
TUTORIAL("Tutorial", "Tutorial", false, false, false, true, false, false, GameMode.SURVIVAL),
|
TUTORIAL("Tutorial", "Tutorial", false, false, false, true, false, false, GameMode.SURVIVAL),
|
||||||
DEFAULT("Default", "Default");
|
DEFAULT("Default", "Default", false, false, false, true, false, false, GameMode.SURVIVAL);
|
||||||
|
|
||||||
private String displayName;
|
private String displayName;
|
||||||
private String signName;
|
private String signName;
|
||||||
private boolean playerVersusPlayer;
|
private boolean playerVersusPlayer;// TODO: Testing
|
||||||
private boolean friendlyFire;
|
private boolean friendlyFire;// TODO: Testing
|
||||||
private boolean mobWaves;
|
private boolean mobWaves;// TODO: Implementing
|
||||||
private boolean rewards;
|
private boolean rewards;// TODO: Testing
|
||||||
private boolean showTime;
|
private boolean showTime;// TODO: Implementing
|
||||||
private boolean build;
|
private boolean build;// TODO: Testing
|
||||||
private GameMode gameMode;
|
private GameMode gameMode;// TODO: Testing
|
||||||
|
|
||||||
GameTypeDefault(String displayName, String signName) {
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.signName = signName;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameTypeDefault(String displayName, String signName, boolean playerVersusPlayer, boolean friendlyFire, boolean mobWaves, boolean rewards, boolean showTime, boolean build, GameMode gameMode) {
|
GameTypeDefault(String displayName, String signName, boolean playerVersusPlayer, boolean friendlyFire, boolean mobWaves, boolean rewards, boolean showTime, boolean build, GameMode gameMode) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
this.signName = signName;
|
this.signName = signName;
|
||||||
this.playerVersusPlayer = playerVersusPlayer;
|
this.playerVersusPlayer = playerVersusPlayer;
|
||||||
this.setFriendlyFire(friendlyFire);
|
this.friendlyFire = friendlyFire;
|
||||||
this.mobWaves = mobWaves;
|
this.mobWaves = mobWaves;
|
||||||
this.rewards = rewards;
|
this.rewards = rewards;
|
||||||
this.showTime = showTime;
|
this.showTime = showTime;
|
||||||
|
@ -60,6 +60,7 @@ public class GameWorld {
|
|||||||
|
|
||||||
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
|
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
|
||||||
private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
|
private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
|
||||||
|
//TODO: Killed mobs
|
||||||
private CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
|
private CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
|
||||||
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
|
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
|
||||||
private WorldConfig worldConfig;
|
private WorldConfig worldConfig;
|
||||||
@ -273,11 +274,19 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dMobs
|
* @param dMob
|
||||||
* the dMobs to set
|
* the dMob to add
|
||||||
*/
|
*/
|
||||||
public void setDMobs(CopyOnWriteArrayList<DMob> dMobs) {
|
public void addDMob(DMob dMob) {
|
||||||
this.dMobs = dMobs;
|
dMobs.add(dMob);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dMob
|
||||||
|
* the dMob to remove
|
||||||
|
*/
|
||||||
|
public void removeDMob(DMob dMob) {
|
||||||
|
dMobs.remove(dMob);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,8 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|||||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
|
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
@ -119,8 +121,17 @@ public class BlockListener implements Listener {
|
|||||||
// Deny GameWorld Blocks
|
// Deny GameWorld Blocks
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
|
GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
|
||||||
if (gameWorld != null) {
|
if (gameWorld != null) {
|
||||||
if (gameWorld.getDSigns().contains(block) || !gameWorld.getConfig().canBuild()) {
|
if (gameWorld.getDSigns().contains(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
} else if (gameWorld.getGame() != null) {
|
||||||
|
GameType gameType = gameWorld.getGame().getType();
|
||||||
|
if (gameType == GameTypeDefault.DEFAULT && gameWorld.getConfig() != null) {
|
||||||
|
event.setCancelled( !gameWorld.getConfig().canBuild());
|
||||||
|
|
||||||
|
} else if ( !gameType.canBuild()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,16 +92,19 @@ public class PlayerListener implements Listener {
|
|||||||
}.runTaskLater(plugin, 1L);
|
}.runTaskLater(plugin, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ( !(dPlayer.getLives() == -1)) {
|
}
|
||||||
|
|
||||||
|
if (dPlayer.getLives() != -1) {
|
||||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_DEATH, String.valueOf(dPlayer.getLives())));
|
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_DEATH, String.valueOf(dPlayer.getLives())));
|
||||||
|
|
||||||
} else if (dConfig != null) {
|
if (dConfig != null) {
|
||||||
if (dConfig.getKeepInventoryOnDeath()) {
|
if (dConfig.getKeepInventoryOnDeath()) {
|
||||||
dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
|
dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
|
||||||
dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
||||||
// Delete all drops
|
// Delete all drops
|
||||||
for (ItemStack istack : event.getDrops()) {
|
for (ItemStack istack : event.getDrops()) {
|
||||||
istack.setType(Material.AIR);
|
istack.setType(Material.AIR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,7 +558,9 @@ public class PlayerListener implements Listener {
|
|||||||
// Inventory Events
|
// Inventory Events
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||||
GameChest.onOpenInventory(event);
|
if (event.getPlayer() instanceof Player) {
|
||||||
|
GameChest.onOpenInventory(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -19,7 +19,7 @@ public class DMob {
|
|||||||
private String trigger;
|
private String trigger;
|
||||||
|
|
||||||
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type) {
|
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type) {
|
||||||
gameWorld.getDMobs().add(this);
|
gameWorld.addDMob(this);
|
||||||
|
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -33,7 +33,7 @@ public class DMob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) {
|
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) {
|
||||||
gameWorld.getDMobs().add(this);
|
gameWorld.addDMob(this);
|
||||||
|
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -63,40 +63,41 @@ public class DMob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (DMob dMob : gameWorld.getDMobs()) {
|
for (DMob dMob : gameWorld.getDMobs()) {
|
||||||
if (dMob.entity == victim) {
|
if (dMob.entity != victim) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
DMobDeathEvent dMobDeathEvent = new DMobDeathEvent(dMob, event);
|
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.getDMobs().remove(dMob);
|
|
||||||
return;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
package io.github.dre2n.dungeonsxl.player;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
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.Messages;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||||
|
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.event.dgroup.DGroupStartFloorEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupStartFloorEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.requirement.RequirementDemandEvent;
|
import io.github.dre2n.dungeonsxl.event.requirement.RequirementDemandEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.reward.RewardAdditionEvent;
|
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.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||||
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.util.messageutil.MessageUtil;
|
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.playerutil.PlayerUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,6 +28,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class DGroup {
|
public class DGroup {
|
||||||
|
|
||||||
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
static MessageConfig messageConfig = plugin.getMessageConfig();
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private Player captain;
|
private Player captain;
|
||||||
@ -34,6 +40,7 @@ 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<Reward>();
|
private List<Reward> rewards = new ArrayList<Reward>();
|
||||||
|
|
||||||
public DGroup(String name, Player player) {
|
public DGroup(String name, Player player) {
|
||||||
@ -375,6 +382,21 @@ 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
|
||||||
*/
|
*/
|
||||||
@ -460,21 +482,41 @@ public class DGroup {
|
|||||||
MessageUtil.sendScreenMessage(player, "&4&l" + mapName.replaceAll("_", " "));
|
MessageUtil.sendScreenMessage(player, "&4&l" + mapName.replaceAll("_", " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Requirement requirement : gameWorld.getConfig().getRequirements()) {
|
WorldConfig config = gameWorld.getConfig();
|
||||||
RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player);
|
if (config != null) {
|
||||||
|
for (Requirement requirement : config.getRequirements()) {
|
||||||
|
RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player);
|
||||||
|
|
||||||
if (requirementDemandEvent.isCancelled()) {
|
if (requirementDemandEvent.isCancelled()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
requirement.demand(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
requirement.demand(player);
|
GameType gameType = game.getType();
|
||||||
}
|
if (gameType == GameTypeDefault.DEFAULT) {
|
||||||
|
player.setGameMode(config.getGameMode());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
player.setGameMode(gameType.getGameMode());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
*/
|
*/
|
||||||
@ -522,16 +564,6 @@ public class DGroup {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DGroup getByGameWorld(GameWorld gameWorld) {
|
|
||||||
for (DGroup dGroup : plugin.getDGroups()) {
|
|
||||||
if (dGroup.getGameWorld() == gameWorld) {
|
|
||||||
return dGroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void leaveGroup(Player player) {
|
public static void leaveGroup(Player player) {
|
||||||
for (DGroup dGroup : plugin.getDGroups()) {
|
for (DGroup dGroup : plugin.getDGroups()) {
|
||||||
if (dGroup.getPlayers().contains(player)) {
|
if (dGroup.getPlayers().contains(player)) {
|
||||||
@ -540,4 +572,20 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gameWorld
|
||||||
|
* the GameWorld to check
|
||||||
|
* @return a List of DGroups in this GameWorld
|
||||||
|
*/
|
||||||
|
public static List<DGroup> getByGameWorld(GameWorld gameWorld) {
|
||||||
|
List<DGroup> dGroups = new ArrayList<DGroup>();
|
||||||
|
for (DGroup dGroup : plugin.getDGroups()) {
|
||||||
|
if (dGroup.getGameWorld().equals(gameWorld)) {
|
||||||
|
dGroups.add(dGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dGroups;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class DPlayer {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
WorldConfig worldConfig = GameWorld.getByWorld(world).getConfig();
|
WorldConfig worldConfig = GameWorld.getByWorld(world).getConfig();
|
||||||
this.getPlayer().setGameMode(worldConfig.getGameMode());
|
this.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||||
if ( !worldConfig.getKeepInventoryOnEnter()) {
|
if ( !worldConfig.getKeepInventoryOnEnter()) {
|
||||||
clearPlayerData();
|
clearPlayerData();
|
||||||
}
|
}
|
||||||
@ -523,8 +523,12 @@ public class DPlayer {
|
|||||||
// Belohnung
|
// Belohnung
|
||||||
if ( !isInTestMode()) {// Nur wenn man nicht am Testen ist
|
if ( !isInTestMode()) {// Nur wenn man nicht am Testen ist
|
||||||
if (finished) {
|
if (finished) {
|
||||||
for (Reward reward : gameWorld.getConfig().getRewards()) {
|
if (gameWorld.getGame() != null) {
|
||||||
reward.giveTo(player);
|
if (gameWorld.getGame().getType().hasRewards()) {
|
||||||
|
for (Reward reward : gameWorld.getConfig().getRewards()) {
|
||||||
|
reward.giveTo(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addTreasure();
|
addTreasure();
|
||||||
|
@ -21,7 +21,8 @@ public enum DSignTypeDefault implements DSignType {
|
|||||||
REDSTONE("Redstone", "dxl.sign.redstone", false, RedstoneSign.class),
|
REDSTONE("Redstone", "dxl.sign.redstone", false, RedstoneSign.class),
|
||||||
SOUND_MESSAGE("SoundMSG", "dxl.sign.soundmsg", false, SoundMessageSign.class),
|
SOUND_MESSAGE("SoundMSG", "dxl.sign.soundmsg", false, SoundMessageSign.class),
|
||||||
START("Start", "dxl.sign.start", true, StartSign.class),
|
START("Start", "dxl.sign.start", true, StartSign.class),
|
||||||
TRIGGER("Trigger", "dxl.sign.trigger", true, TriggerSign.class);
|
TRIGGER("Trigger", "dxl.sign.trigger", true, TriggerSign.class),
|
||||||
|
WAVE("Wave", "dxl.sign.wave", false, WaveSign.class);
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String buildPermission;
|
private String buildPermission;
|
||||||
|
@ -45,11 +45,15 @@ public class EndSign extends DSign {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
DPlayer dPlayer = DPlayer.getByPlayer(player);
|
DPlayer dPlayer = DPlayer.getByPlayer(player);
|
||||||
if (dPlayer != null) {
|
if (dPlayer == null) {
|
||||||
if ( !dPlayer.isFinished()) {
|
return true;
|
||||||
dPlayer.finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dPlayer.isFinished()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dPlayer.finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
95
src/io/github/dre2n/dungeonsxl/sign/WaveSign.java
Normal file
95
src/io/github/dre2n/dungeonsxl/sign/WaveSign.java
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.NumberUtil;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class WaveSign extends DSign {
|
||||||
|
|
||||||
|
private DSignType type = DSignTypeDefault.WAVE;
|
||||||
|
|
||||||
|
private double mobCountIncreaseRate;
|
||||||
|
|
||||||
|
public WaveSign(Sign sign, GameWorld gameWorld) {
|
||||||
|
super(sign, gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mobCountIncreaseRate
|
||||||
|
*/
|
||||||
|
public double getMobCountIncreaseRate() {
|
||||||
|
return mobCountIncreaseRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobCountIncreaseRate
|
||||||
|
* the mobCountIncreaseRate to set
|
||||||
|
*/
|
||||||
|
public void setMobCountIncreaseRate(double mobCountIncreaseRate) {
|
||||||
|
this.mobCountIncreaseRate = mobCountIncreaseRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
String[] lines = getSign().getLines();
|
||||||
|
if ( !lines[1].equals("")) {
|
||||||
|
mobCountIncreaseRate = NumberUtil.parseDouble(lines[1], 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !getTriggers().isEmpty()) {
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.addListener(this);
|
||||||
|
addTrigger(trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().setLine(1, ChatColor.DARK_GREEN + "START");
|
||||||
|
getSign().setLine(2, ChatColor.DARK_GREEN + "NEXT WAVE");
|
||||||
|
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPlayerTrigger(Player player) {
|
||||||
|
DGroup dGroup = DGroup.getByPlayer(player);
|
||||||
|
if (dGroup == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getGameWorld() == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dGroup.finishWave(mobCountIncreaseRate);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrigger() {
|
||||||
|
for (DGroup dGroup : plugin.getDGroups()) {
|
||||||
|
dGroup.finishWave(mobCountIncreaseRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DSignType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -135,6 +135,12 @@ public abstract class Trigger {
|
|||||||
return UseItemTrigger.getOrCreate(value, dSign.getGameWorld());
|
return UseItemTrigger.getOrCreate(value, dSign.getGameWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (type == TriggerTypeDefault.WAVE) {
|
||||||
|
|
||||||
|
if (value != null) {
|
||||||
|
return WaveTrigger.getOrCreate(NumberUtil.parseInt(value, 1), dSign.getGameWorld());
|
||||||
|
}
|
||||||
|
|
||||||
} else if (type != null) {
|
} else if (type != null) {
|
||||||
Trigger trigger = null;
|
Trigger trigger = null;
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ public enum TriggerTypeDefault implements TriggerType {
|
|||||||
MOB("M", MobTrigger.class),
|
MOB("M", MobTrigger.class),
|
||||||
REDSTONE("R", RedstoneTrigger.class),
|
REDSTONE("R", RedstoneTrigger.class),
|
||||||
SIGN("T", SignTrigger.class),
|
SIGN("T", SignTrigger.class),
|
||||||
USE_ITEM("U", UseItemTrigger.class);
|
USE_ITEM("U", UseItemTrigger.class),
|
||||||
|
WAVE("W", WaveTrigger.class);
|
||||||
|
|
||||||
private String identifier;
|
private String identifier;
|
||||||
private Class<? extends Trigger> handler;
|
private Class<? extends Trigger> handler;
|
||||||
|
93
src/io/github/dre2n/dungeonsxl/trigger/WaveTrigger.java
Normal file
93
src/io/github/dre2n/dungeonsxl/trigger/WaveTrigger.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.trigger;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class WaveTrigger extends Trigger {
|
||||||
|
|
||||||
|
private static Map<GameWorld, ArrayList<WaveTrigger>> triggers = new HashMap<GameWorld, ArrayList<WaveTrigger>>();
|
||||||
|
|
||||||
|
private TriggerType type = TriggerTypeDefault.WAVE;
|
||||||
|
|
||||||
|
private int mustKillAmount;
|
||||||
|
|
||||||
|
public WaveTrigger(int mustKillAmount) {
|
||||||
|
this.mustKillAmount = mustKillAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTrigger() {
|
||||||
|
TriggerActionEvent event = new TriggerActionEvent(this);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTriggered(true);
|
||||||
|
updateDSigns();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(GameWorld gameWorld) {
|
||||||
|
if ( !hasTriggers(gameWorld)) {
|
||||||
|
ArrayList<WaveTrigger> list = new ArrayList<WaveTrigger>();
|
||||||
|
list.add(this);
|
||||||
|
triggers.put(gameWorld, list);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
triggers.get(gameWorld).add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregister(GameWorld gameWorld) {
|
||||||
|
if (hasTriggers(gameWorld)) {
|
||||||
|
triggers.get(gameWorld).remove(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TriggerType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WaveTrigger getOrCreate(int mustKillAmount, GameWorld gameWorld) {
|
||||||
|
WaveTrigger trigger = get(gameWorld);
|
||||||
|
if (trigger != null) {
|
||||||
|
return trigger;
|
||||||
|
}
|
||||||
|
return new WaveTrigger(mustKillAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WaveTrigger get(GameWorld gameWorld) {
|
||||||
|
if (hasTriggers(gameWorld)) {
|
||||||
|
for (WaveTrigger trigger : triggers.get(gameWorld)) {
|
||||||
|
return trigger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasTriggers(GameWorld 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,6 +22,8 @@ permissions:
|
|||||||
default: op
|
default: op
|
||||||
dxl.escape:
|
dxl.escape:
|
||||||
default: true
|
default: true
|
||||||
|
dxl.game:
|
||||||
|
default: true
|
||||||
dxl.group:
|
dxl.group:
|
||||||
default: op
|
default: op
|
||||||
dxl.group.admin:
|
dxl.group.admin:
|
||||||
|
Loading…
Reference in New Issue
Block a user