mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-09 20:31:28 +01:00
keepInventory split
This commit is contained in:
parent
0dc20b271b
commit
b4599e74f3
@ -155,11 +155,21 @@ public class DConfig {
|
||||
|
||||
/* Keep Inventory */
|
||||
if (configFile.contains("keepInventory")) {
|
||||
keepInventoryOnEnter = configFile.getBoolean("keepInventory");
|
||||
keepInventoryOnEscape = configFile.getBoolean("keepInventory");
|
||||
keepInventoryOnFinish = configFile.getBoolean("keepInventory");
|
||||
if (!configFile.contains("keepInventoryOnEnter")) {
|
||||
keepInventoryOnEnter = configFile.getBoolean("keepInventory");
|
||||
}
|
||||
if (!configFile.contains("keepInventoryOnEscape")) {
|
||||
keepInventoryOnEscape = configFile.getBoolean("keepInventory");
|
||||
}
|
||||
if (!configFile.contains("keepInventoryOnFinish")) {
|
||||
keepInventoryOnFinish = configFile.getBoolean("keepInventory");
|
||||
}
|
||||
} else {
|
||||
keepInventory = mainConfig.keepInventory;
|
||||
if (mainConfig.keepInventory) {
|
||||
keepInventoryOnEnter = mainConfig.keepInventory;
|
||||
keepInventoryOnEscape = mainConfig.keepInventory;
|
||||
keepInventoryOnFinish = mainConfig.keepInventory;
|
||||
}
|
||||
}
|
||||
|
||||
if (configFile.contains("keepInventoryOnEnter")) {
|
||||
@ -342,10 +352,6 @@ public class DConfig {
|
||||
return tmpSecureObjects;
|
||||
}
|
||||
|
||||
public boolean getKeepInventory() {
|
||||
return keepInventory;
|
||||
}
|
||||
|
||||
public boolean getKeepInventoryOnEnter() {
|
||||
return keepInventoryOnEnter;
|
||||
}
|
||||
|
@ -76,10 +76,11 @@ public class DPlayer {
|
||||
this.clearPlayerData();
|
||||
} else {
|
||||
this.player.setGameMode(GameMode.SURVIVAL);
|
||||
if (!(GameWorld.get(world).config.getKeepInventoryOnEnter())) {
|
||||
DConfig dConfig = GameWorld.get(world).config;
|
||||
if (!(dConfig.getKeepInventoryOnEnter())) {
|
||||
this.clearPlayerData();
|
||||
}
|
||||
if (GameWorld.get(world).config.isLobbyDisabled()) {
|
||||
if (dConfig.isLobbyDisabled()) {
|
||||
this.ready();
|
||||
}
|
||||
initialLives = GameWorld.get(world).config.getInitialLives();
|
||||
@ -105,7 +106,7 @@ public class DPlayer {
|
||||
|
||||
public void escape() {
|
||||
remove(this);
|
||||
this.savePlayer.reset();
|
||||
this.savePlayer.reset(false);
|
||||
}
|
||||
|
||||
public void leave() {
|
||||
@ -114,7 +115,13 @@ public class DPlayer {
|
||||
// Lives
|
||||
p.lives.remove(player);
|
||||
|
||||
this.savePlayer.reset();
|
||||
DConfig dConfig = GameWorld.get(world).config;
|
||||
if (this.isFinished) {
|
||||
this.savePlayer.reset(dConfig.getKeepInventoryOnFinish());
|
||||
}
|
||||
else {
|
||||
this.savePlayer.reset(dConfig.getKeepInventoryOnEscape());
|
||||
}
|
||||
|
||||
if (this.isEditing) {
|
||||
EditWorld eworld = EditWorld.get(this.world);
|
||||
@ -218,7 +225,7 @@ public class DPlayer {
|
||||
}
|
||||
|
||||
// Respawn Items
|
||||
if (!(GameWorld.get(world).config.getKeepInventoryOnDeath())) {
|
||||
if (GameWorld.get(world).config.getKeepInventoryOnDeath()) {
|
||||
if (this.respawnInventory != null || this.respawnArmor != null) {
|
||||
this.player.getInventory().setContents(this.respawnInventory);
|
||||
this.player.getInventory().setArmorContents(this.respawnArmor);
|
||||
|
@ -59,30 +59,31 @@ public class DSavePlayer {
|
||||
save();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
public void reset(boolean keepInventory) {
|
||||
Player onlinePlayer = p.getServer().getPlayer(this.playerName);
|
||||
|
||||
try{
|
||||
if (onlinePlayer != null) {
|
||||
/* Player is online */
|
||||
onlinePlayer.getInventory().setContents(this.oldInventory);
|
||||
onlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
||||
onlinePlayer.setTotalExperience(this.oldExp);
|
||||
onlinePlayer.setLevel(this.oldLvl);
|
||||
onlinePlayer.setHealth(this.oldHealth);
|
||||
onlinePlayer.setFoodLevel(this.oldFoodLevel);
|
||||
onlinePlayer.setGameMode(this.oldGamemode);
|
||||
onlinePlayer.setFireTicks(this.oldFireTicks);
|
||||
for (PotionEffect effect : onlinePlayer.getActivePotionEffects()) {
|
||||
onlinePlayer.removePotionEffect(effect.getType());
|
||||
if (!keepInventory) {
|
||||
onlinePlayer.getInventory().setContents(this.oldInventory);
|
||||
onlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
||||
onlinePlayer.setTotalExperience(this.oldExp);
|
||||
onlinePlayer.setLevel(this.oldLvl);
|
||||
onlinePlayer.setHealth(this.oldHealth);
|
||||
onlinePlayer.setFoodLevel(this.oldFoodLevel);
|
||||
onlinePlayer.setGameMode(this.oldGamemode);
|
||||
onlinePlayer.setFireTicks(this.oldFireTicks);
|
||||
for (PotionEffect effect : onlinePlayer.getActivePotionEffects()) {
|
||||
onlinePlayer.removePotionEffect(effect.getType());
|
||||
}
|
||||
onlinePlayer.addPotionEffects(this.oldPotionEffects);
|
||||
}
|
||||
onlinePlayer.addPotionEffects(this.oldPotionEffects);
|
||||
|
||||
DUtility.secureTeleport(onlinePlayer, this.oldLocation);
|
||||
} else {
|
||||
/* Player is offline */
|
||||
Player offlinePlayer = p.getOfflinePlayer(this.playerName, UUID.fromString(uuid), this.oldLocation);
|
||||
if (offlinePlayer != null) {
|
||||
if (offlinePlayer != null && !keepInventory) {
|
||||
offlinePlayer.getInventory().setContents(this.oldInventory);
|
||||
offlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
||||
offlinePlayer.setTotalExperience(this.oldExp);
|
||||
@ -174,7 +175,7 @@ public class DSavePlayer {
|
||||
|
||||
// Create Player
|
||||
DSavePlayer savePlayer = new DSavePlayer(playerName, uuid, oldLocation, oldInventory, oldArmor, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGamemode, oldPotionEffects);
|
||||
savePlayer.reset();
|
||||
savePlayer.reset(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user