mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-13 06:07:36 +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;
|
||||
|
||||
import de.erethon.dungeonsxl.api.dungeon.Dungeon;
|
||||
import de.erethon.dungeonsxl.api.dungeon.Game;
|
||||
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer;
|
||||
import java.io.File;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -120,22 +121,11 @@ public interface ResourceWorld {
|
||||
* Returns a new game instance of this resource.
|
||||
*
|
||||
* @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
|
||||
* @return a new game instance of this resource
|
||||
*/
|
||||
default GameWorld instantiateGameWorld(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);
|
||||
GameWorld instantiateGameWorld(Game game, boolean ignoreLimit);
|
||||
|
||||
/**
|
||||
* Returns the single floor dungeon of this resource.
|
||||
|
@ -291,7 +291,7 @@ public class DGame implements Game {
|
||||
if (world != null) {
|
||||
return world;
|
||||
}
|
||||
world = dungeon.getMap().instantiateGameWorld(dungeon, ignoreLimit);
|
||||
world = dungeon.getMap().instantiateGameWorld(this, ignoreLimit);
|
||||
return world;
|
||||
}
|
||||
|
||||
@ -305,6 +305,7 @@ public class DGame implements Game {
|
||||
continue;
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -510,14 +510,7 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
|
||||
}
|
||||
|
||||
ready = true;
|
||||
|
||||
boolean start = true;
|
||||
if (!game.start()) {// TODO: Start for every player???
|
||||
start = false;
|
||||
} else {
|
||||
respawn();
|
||||
}
|
||||
return start;
|
||||
return ready;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -515,7 +515,7 @@ public class DGroup implements PlayerGroup {
|
||||
return;
|
||||
}
|
||||
|
||||
GameWorld gameWorld = newFloor.instantiateGameWorld(true);
|
||||
GameWorld gameWorld = newFloor.instantiateGameWorld(getGame(), true);
|
||||
gameWorld.setType(type);
|
||||
game.setWorld(gameWorld);
|
||||
|
||||
@ -561,7 +561,6 @@ public class DGroup implements PlayerGroup {
|
||||
color = plugin.getMainConfig().getGroupColorPriority(index);
|
||||
}
|
||||
|
||||
boolean ready = true;
|
||||
for (Player player : getMembers().getOnlinePlayers()) {
|
||||
GamePlayer gamePlayer = plugin.getPlayerCache().getGamePlayer(player);
|
||||
if (gamePlayer == null) {
|
||||
@ -569,14 +568,10 @@ public class DGroup implements PlayerGroup {
|
||||
}
|
||||
|
||||
if (!gamePlayer.isReady()) {
|
||||
ready = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ready) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GroupStartFloorEvent event = new GroupStartFloorEvent(this, getGameWorld());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
|
@ -170,8 +170,11 @@ public class ReadySign extends Button {
|
||||
boolean wasReady = player.isReady();
|
||||
|
||||
if (!getGameWorld().areClassesEnabled() || player.getPlayerClass() != null) {
|
||||
if (player.ready() && bar != null) {
|
||||
bar.cancel();
|
||||
if (player.ready()) {
|
||||
getGame().start();
|
||||
if (bar != null) {
|
||||
bar.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,14 +233,14 @@ public class DResourceWorld implements ResourceWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameWorld instantiateGameWorld(Dungeon dungeon, boolean ignoreLimit) {
|
||||
public GameWorld instantiateGameWorld(Game game, boolean ignoreLimit) {
|
||||
if (plugin.isLoadingWorld()) {
|
||||
return null;
|
||||
}
|
||||
if (!ignoreLimit && plugin.getMainConfig().getMaxInstances() <= plugin.getInstanceCache().size()) {
|
||||
return null;
|
||||
}
|
||||
return (DGameWorld) instantiate(new DGame(plugin, dungeon));
|
||||
return (DGameWorld) instantiate(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user