mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 21:48:43 +01:00
parent
dceadc399b
commit
60f2a497dd
@ -237,62 +237,61 @@ 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 */
|
||||||
if (wolf != null) {
|
if (wolf != null) {
|
||||||
wolf.remove();
|
wolf.remove();
|
||||||
wolf = null;
|
wolf = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dClass.hasDog()) {
|
if (dClass.hasDog()) {
|
||||||
wolf = (Wolf) getWorld().spawnEntity(getPlayer().getLocation(), EntityType.WOLF);
|
wolf = (Wolf) getWorld().spawnEntity(getPlayer().getLocation(), EntityType.WOLF);
|
||||||
wolf.setTamed(true);
|
wolf.setTamed(true);
|
||||||
wolf.setOwner(getPlayer());
|
wolf.setOwner(getPlayer());
|
||||||
|
|
||||||
double maxHealth = ((Damageable) wolf).getMaxHealth();
|
double maxHealth = ((Damageable) wolf).getMaxHealth();
|
||||||
wolf.setHealth(maxHealth);
|
wolf.setHealth(maxHealth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete Inventory */
|
/* Delete Inventory */
|
||||||
getPlayer().getInventory().clear();
|
getPlayer().getInventory().clear();
|
||||||
getPlayer().getInventory().setArmorContents(null);
|
getPlayer().getInventory().setArmorContents(null);
|
||||||
getPlayer().getInventory().setItemInHand(new ItemStack(Material.AIR));
|
getPlayer().getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||||
|
|
||||||
// Remove Potion Effects
|
// Remove Potion Effects
|
||||||
for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
|
for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
|
||||||
getPlayer().removePotionEffect(effect.getType());
|
getPlayer().removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset lvl
|
// Reset lvl
|
||||||
getPlayer().setTotalExperience(0);
|
getPlayer().setTotalExperience(0);
|
||||||
getPlayer().setLevel(0);
|
getPlayer().setLevel(0);
|
||||||
|
|
||||||
/* Set Inventory */
|
/* Set Inventory */
|
||||||
for (ItemStack istack : dClass.getItems()) {
|
for (ItemStack istack : dClass.getItems()) {
|
||||||
|
|
||||||
// Leggings
|
// Leggings
|
||||||
if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS
|
if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS
|
||||||
|| istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == LegacyUtil.GOLDEN_LEGGINGS) {
|
|| istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == LegacyUtil.GOLDEN_LEGGINGS) {
|
||||||
getPlayer().getInventory().setLeggings(istack);
|
getPlayer().getInventory().setLeggings(istack);
|
||||||
} // Helmet
|
} // Helmet
|
||||||
else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET
|
else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET
|
||||||
|| istack.getType() == Material.DIAMOND_HELMET || istack.getType() == LegacyUtil.GOLDEN_HELMET) {
|
|| istack.getType() == Material.DIAMOND_HELMET || istack.getType() == LegacyUtil.GOLDEN_HELMET) {
|
||||||
getPlayer().getInventory().setHelmet(istack);
|
getPlayer().getInventory().setHelmet(istack);
|
||||||
} // Chestplate
|
} // Chestplate
|
||||||
else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE
|
else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE
|
||||||
|| istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == LegacyUtil.GOLDEN_CESTPLATE) {
|
|| istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == LegacyUtil.GOLDEN_CESTPLATE) {
|
||||||
getPlayer().getInventory().setChestplate(istack);
|
getPlayer().getInventory().setChestplate(istack);
|
||||||
} // Boots
|
} // Boots
|
||||||
else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS
|
else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS
|
||||||
|| istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == LegacyUtil.GOLDEN_BOOTS) {
|
|| istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == LegacyUtil.GOLDEN_BOOTS) {
|
||||||
getPlayer().getInventory().setBoots(istack);
|
getPlayer().getInventory().setBoots(istack);
|
||||||
} else {
|
} else {
|
||||||
getPlayer().getInventory().addItem(istack);
|
getPlayer().getInventory().addItem(istack);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -487,10 +486,12 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
GameRuleProvider rules = game.getRules();
|
GameRuleProvider rules = game.getRules();
|
||||||
delete();
|
delete();
|
||||||
|
|
||||||
if (finished) {
|
if (player.isOnline()) {
|
||||||
reset(rules.getKeepInventoryOnFinish());
|
if (finished) {
|
||||||
} else {
|
reset(rules.getKeepInventoryOnFinish());
|
||||||
reset(rules.getKeepInventoryOnEscape());
|
} else {
|
||||||
|
reset(rules.getKeepInventoryOnEscape());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permission bridge
|
// Permission bridge
|
||||||
|
@ -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,19 +363,12 @@ 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()) {
|
dPlayer.startTutorial();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DGamePlayer.getByPlayer(player) != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dPlayer.startTutorial();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
Loading…
Reference in New Issue
Block a user