mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Fix PVP rules; resolves #1009
This commit is contained in:
parent
738d472b43
commit
cb53d67293
@ -15,6 +15,7 @@
|
|||||||
package de.erethon.dungeonsxl.api.world;
|
package de.erethon.dungeonsxl.api.world;
|
||||||
|
|
||||||
import de.erethon.dungeonsxl.api.dungeon.Dungeon;
|
import de.erethon.dungeonsxl.api.dungeon.Dungeon;
|
||||||
|
import de.erethon.dungeonsxl.api.dungeon.Game;
|
||||||
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer;
|
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -120,22 +121,11 @@ public interface ResourceWorld {
|
|||||||
* Returns a new game instance of this resource.
|
* Returns a new game instance of this resource.
|
||||||
*
|
*
|
||||||
* @see de.erethon.dungeonsxl.api.dungeon.Game#ensureWorldIsLoaded(boolean)
|
* @see de.erethon.dungeonsxl.api.dungeon.Game#ensureWorldIsLoaded(boolean)
|
||||||
|
* @param game the game the instance belongs to
|
||||||
* @param ignoreLimit if the instance limit set in the main config shall be ignored
|
* @param ignoreLimit if the instance limit set in the main config shall be ignored
|
||||||
* @return a new game instance of this resource
|
* @return a new game instance of this resource
|
||||||
*/
|
*/
|
||||||
default GameWorld instantiateGameWorld(boolean ignoreLimit) {
|
GameWorld instantiateGameWorld(Game game, boolean ignoreLimit);
|
||||||
return instantiateGameWorld(getSingleFloorDungeon(), ignoreLimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new game instance of this resource.
|
|
||||||
*
|
|
||||||
* @see de.erethon.dungeonsxl.api.dungeon.Game#ensureWorldIsLoaded(boolean)
|
|
||||||
* @param dungeon the dungeon this game world will be part of
|
|
||||||
* @param ignoreLimit if the instance limit set in the main config shall be ignored
|
|
||||||
* @return a new game instance of this resource
|
|
||||||
*/
|
|
||||||
GameWorld instantiateGameWorld(Dungeon dungeon, boolean ignoreLimit);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the single floor dungeon of this resource.
|
* Returns the single floor dungeon of this resource.
|
||||||
|
@ -291,7 +291,7 @@ public class DGame implements Game {
|
|||||||
if (world != null) {
|
if (world != null) {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
world = dungeon.getMap().instantiateGameWorld(dungeon, ignoreLimit);
|
world = dungeon.getMap().instantiateGameWorld(this, ignoreLimit);
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,6 +305,7 @@ public class DGame implements Game {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!((DGroup) group).startGame(this, i++)) {
|
if (!((DGroup) group).startGame(this, i++)) {
|
||||||
|
plugin.log("Could not start game for group " + group);
|
||||||
return false; // TODO: State of groups that are OK has already been changed
|
return false; // TODO: State of groups that are OK has already been changed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,14 +510,7 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ready = true;
|
ready = true;
|
||||||
|
return ready;
|
||||||
boolean start = true;
|
|
||||||
if (!game.start()) {// TODO: Start for every player???
|
|
||||||
start = false;
|
|
||||||
} else {
|
|
||||||
respawn();
|
|
||||||
}
|
|
||||||
return start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -515,7 +515,7 @@ public class DGroup implements PlayerGroup {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameWorld gameWorld = newFloor.instantiateGameWorld(true);
|
GameWorld gameWorld = newFloor.instantiateGameWorld(getGame(), true);
|
||||||
gameWorld.setType(type);
|
gameWorld.setType(type);
|
||||||
game.setWorld(gameWorld);
|
game.setWorld(gameWorld);
|
||||||
|
|
||||||
@ -561,7 +561,6 @@ public class DGroup implements PlayerGroup {
|
|||||||
color = plugin.getMainConfig().getGroupColorPriority(index);
|
color = plugin.getMainConfig().getGroupColorPriority(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ready = true;
|
|
||||||
for (Player player : getMembers().getOnlinePlayers()) {
|
for (Player player : getMembers().getOnlinePlayers()) {
|
||||||
GamePlayer gamePlayer = plugin.getPlayerCache().getGamePlayer(player);
|
GamePlayer gamePlayer = plugin.getPlayerCache().getGamePlayer(player);
|
||||||
if (gamePlayer == null) {
|
if (gamePlayer == null) {
|
||||||
@ -569,13 +568,9 @@ public class DGroup implements PlayerGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gamePlayer.isReady()) {
|
if (!gamePlayer.isReady()) {
|
||||||
ready = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ready) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GroupStartFloorEvent event = new GroupStartFloorEvent(this, getGameWorld());
|
GroupStartFloorEvent event = new GroupStartFloorEvent(this, getGameWorld());
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
@ -170,10 +170,13 @@ public class ReadySign extends Button {
|
|||||||
boolean wasReady = player.isReady();
|
boolean wasReady = player.isReady();
|
||||||
|
|
||||||
if (!getGameWorld().areClassesEnabled() || player.getPlayerClass() != null) {
|
if (!getGameWorld().areClassesEnabled() || player.getPlayerClass() != null) {
|
||||||
if (player.ready() && bar != null) {
|
if (player.ready()) {
|
||||||
|
getGame().start();
|
||||||
|
if (bar != null) {
|
||||||
bar.cancel();
|
bar.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!wasReady) {
|
if (!wasReady) {
|
||||||
if (player.isReady()) {
|
if (player.isReady()) {
|
||||||
|
@ -233,14 +233,14 @@ public class DResourceWorld implements ResourceWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameWorld instantiateGameWorld(Dungeon dungeon, boolean ignoreLimit) {
|
public GameWorld instantiateGameWorld(Game game, boolean ignoreLimit) {
|
||||||
if (plugin.isLoadingWorld()) {
|
if (plugin.isLoadingWorld()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!ignoreLimit && plugin.getMainConfig().getMaxInstances() <= plugin.getInstanceCache().size()) {
|
if (!ignoreLimit && plugin.getMainConfig().getMaxInstances() <= plugin.getInstanceCache().size()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (DGameWorld) instantiate(new DGame(plugin, dungeon));
|
return (DGameWorld) instantiate(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user