mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-01 13:01:33 +01:00
Add flight game rule
This commit is contained in:
parent
d7736831f9
commit
6845fa7711
@ -50,6 +50,7 @@ public class GameRuleProvider {
|
||||
|
||||
/* World */
|
||||
DEFAULT_VALUES.gameMode = GameMode.SURVIVAL;
|
||||
DEFAULT_VALUES.fly = false;
|
||||
DEFAULT_VALUES.breakBlocks = false;
|
||||
DEFAULT_VALUES.breakPlacedBlocks = false;
|
||||
DEFAULT_VALUES.breakWhitelist = null;
|
||||
@ -115,6 +116,7 @@ public class GameRuleProvider {
|
||||
|
||||
/* World */
|
||||
protected GameMode gameMode;
|
||||
protected Boolean fly;
|
||||
protected Boolean breakBlocks;
|
||||
protected Boolean breakPlacedBlocks;
|
||||
protected Map<ExItem, HashSet<ExItem>> breakWhitelist;
|
||||
@ -212,6 +214,10 @@ public class GameRuleProvider {
|
||||
return gameMode;
|
||||
}
|
||||
|
||||
public boolean canFly() {
|
||||
return fly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if all blocks may be destroyed
|
||||
*/
|
||||
@ -684,6 +690,10 @@ public class GameRuleProvider {
|
||||
gameMode = defaultValues.gameMode;
|
||||
}
|
||||
|
||||
if (fly == null) {
|
||||
fly = defaultValues.fly;
|
||||
}
|
||||
|
||||
if (breakBlocks == null) {
|
||||
breakBlocks = defaultValues.breakBlocks;
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
if (!rules.getKeepInventoryOnEnter()) {
|
||||
clearPlayerData();
|
||||
}
|
||||
player.setAllowFlight(rules.canFly());
|
||||
|
||||
if (rules.isLobbyDisabled()) {
|
||||
ready();
|
||||
|
@ -69,6 +69,8 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||
/* Actions */
|
||||
/**
|
||||
* Clear the player's inventory, potion effects etc.
|
||||
* <p>
|
||||
* Does NOT handle flight.
|
||||
*/
|
||||
public void clearPlayerData() {
|
||||
player.getInventory().clear();
|
||||
@ -85,7 +87,6 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||
player.setCollidable(true);
|
||||
player.setInvulnerable(false);
|
||||
}
|
||||
player.setAllowFlight(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,6 +143,10 @@ public class WorldConfig extends GameRuleProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if (configFile.contains("fly")) {
|
||||
fly = configFile.getBoolean("fly");
|
||||
}
|
||||
|
||||
if (configFile.contains("breakBlocks")) {
|
||||
breakBlocks = configFile.getBoolean("breakBlocks");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user