mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
parent
dceadc399b
commit
60f2a497dd
@ -237,8 +237,9 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
|
||||
DClass dClass = plugin.getDClasses().getByName(className);
|
||||
if (dClass != null) {
|
||||
if (this.dClass != dClass) {
|
||||
if (dClass == null || this.dClass == dClass) {
|
||||
return;
|
||||
}
|
||||
this.dClass = dClass;
|
||||
|
||||
/* Set Dog */
|
||||
@ -294,8 +295,6 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the checkpoint
|
||||
@ -487,11 +486,13 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
GameRuleProvider rules = game.getRules();
|
||||
delete();
|
||||
|
||||
if (player.isOnline()) {
|
||||
if (finished) {
|
||||
reset(rules.getKeepInventoryOnFinish());
|
||||
} else {
|
||||
reset(rules.getKeepInventoryOnEscape());
|
||||
}
|
||||
}
|
||||
|
||||
// Permission bridge
|
||||
if (plugin.getPermissionProvider() != null) {
|
||||
|
@ -47,6 +47,8 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
|
||||
|
||||
protected Player player;
|
||||
|
||||
private DPlayerData data;
|
||||
@ -328,12 +330,12 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
}
|
||||
player.getInventory().setContents(data.getOldInventory().toArray(new ItemStack[36]));
|
||||
player.getInventory().setArmorContents(data.getOldArmor().toArray(new ItemStack[4]));
|
||||
if (Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
||||
if (is1_9) {
|
||||
player.getInventory().setItemInOffHand(data.getOldOffHand());
|
||||
}
|
||||
player.setLevel(data.getOldLevel());
|
||||
player.setExp(data.getOldExp());
|
||||
if (Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals())) {
|
||||
if (is1_9) {
|
||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(data.getOldMaxHealth());
|
||||
}
|
||||
player.setHealth(data.getOldHealth() <= data.getOldMaxHealth() ? data.getOldHealth() : data.getOldMaxHealth());
|
||||
|
@ -60,7 +60,7 @@ public class DGroup {
|
||||
DPlayerCache dPlayers = plugin.getDPlayers();
|
||||
|
||||
private String name;
|
||||
private UUID captain;
|
||||
private Player captain;
|
||||
private PlayerCollection players = new PlayerCollection();
|
||||
private PlayerCollection invitedPlayers = new PlayerCollection();
|
||||
private Dungeon dungeon;
|
||||
@ -114,8 +114,8 @@ public class DGroup {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
this.captain = captain.getUniqueId();
|
||||
this.players.add(captain.getUniqueId());
|
||||
this.captain = captain;
|
||||
this.players.add(captain);
|
||||
}
|
||||
|
||||
for (Player player : players) {
|
||||
@ -155,12 +155,12 @@ public class DGroup {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
this.captain = captain.getUniqueId();
|
||||
this.players.add(captain.getUniqueId());
|
||||
this.captain = captain;
|
||||
this.players.add(captain);
|
||||
}
|
||||
|
||||
for (Player player : players) {
|
||||
if (!this.players.contains(player.getUniqueId())) {
|
||||
if (!this.players.contains(player)) {
|
||||
addPlayer(player);
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ public class DGroup {
|
||||
* @return the captain
|
||||
*/
|
||||
public Player getCaptain() {
|
||||
return Bukkit.getPlayer(captain);
|
||||
return captain;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,7 +213,7 @@ public class DGroup {
|
||||
* the captain to set
|
||||
*/
|
||||
public void setCaptain(Player captain) {
|
||||
this.captain = captain.getUniqueId();
|
||||
this.captain = captain;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -818,6 +818,7 @@ public class DGroup {
|
||||
continue;
|
||||
}
|
||||
dPlayer.getData().logTimeLastStarted(getDungeonName());
|
||||
dPlayer.getData().setKeepInventoryAfterLogout(rules.getKeepInventoryOnEscape());
|
||||
|
||||
dPlayer.respawn();
|
||||
|
||||
|
@ -166,11 +166,6 @@ public class DPlayerCache {
|
||||
return false;
|
||||
}
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer());
|
||||
if (dGroup != null) {
|
||||
dGroup.removePlayer(dPlayer.getPlayer());
|
||||
dGroup.addPlayer(player);
|
||||
}
|
||||
dPlayer.setPlayer(player);
|
||||
dPlayer.setOfflineTime(0);
|
||||
return true;
|
||||
|
@ -48,12 +48,13 @@ public class DPlayerData extends DREConfig {
|
||||
|
||||
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
|
||||
|
||||
public static final int CONFIG_VERSION = 3;
|
||||
public static final int CONFIG_VERSION = 4;
|
||||
|
||||
public static final String PREFIX_STATE_PERSISTENCE = "savePlayer.";
|
||||
public static final String PREFIX_STATS = "stats.";
|
||||
|
||||
// State persistence
|
||||
private boolean keepInventoryAfterLogout = true;
|
||||
private Location oldLocation;
|
||||
private List<ItemStack> oldInventory;
|
||||
private List<ItemStack> oldArmor;
|
||||
@ -88,6 +89,23 @@ public class DPlayerData extends DREConfig {
|
||||
return config.contains(PREFIX_STATE_PERSISTENCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the inventory shall be reset after a logout
|
||||
*/
|
||||
public boolean getKeepInventoryAfterLogout() {
|
||||
return keepInventoryAfterLogout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keepInventoryOnEscape
|
||||
* set if the inventory shall be reset after a logout
|
||||
*/
|
||||
public void setKeepInventoryAfterLogout(boolean keepInventoryAfterLogout) {
|
||||
this.keepInventoryAfterLogout = keepInventoryAfterLogout;
|
||||
config.set(PREFIX_STATE_PERSISTENCE + "keepInventoryAfterLogout", keepInventoryAfterLogout);
|
||||
super.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the old location
|
||||
*/
|
||||
@ -390,6 +408,7 @@ public class DPlayerData extends DREConfig {
|
||||
return;
|
||||
}
|
||||
|
||||
keepInventoryAfterLogout = config.getBoolean(PREFIX_STATE_PERSISTENCE + "keepInventoryAfterLogout");
|
||||
oldInventory = (List<ItemStack>) config.get(PREFIX_STATE_PERSISTENCE + "oldInventory");
|
||||
oldArmor = (List<ItemStack>) config.get(PREFIX_STATE_PERSISTENCE + "oldArmor");
|
||||
oldOffHand = (ItemStack) config.get(PREFIX_STATE_PERSISTENCE + "oldOffHand");
|
||||
|
@ -363,20 +363,13 @@ public class DPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
DGlobalPlayer dPlayer = new DGlobalPlayer(player);
|
||||
if (player.hasPlayedBefore()) {
|
||||
return;
|
||||
if (dPlayer.getData().wasInGame()) {
|
||||
dPlayer.reset(dPlayer.getData().getKeepInventoryAfterLogout());
|
||||
}
|
||||
|
||||
if (!config.isTutorialActivated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DGamePlayer.getByPlayer(player) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.hasPlayedBefore() && config.isTutorialActivated()) {
|
||||
dPlayer.startTutorial();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
|
Loading…
Reference in New Issue
Block a user