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