mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-01 07:03:26 +01:00
Added resets for island joining.
This commit is contained in:
parent
11d257c64a
commit
56d63dc9c8
@ -77,14 +77,14 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand {
|
||||
user.teleport(newHome);
|
||||
// Remove player as owner of the old island
|
||||
getIslands().removePlayer(getWorld(), playerUUID);
|
||||
// Remove money inventory etc.
|
||||
if (getIWM().isOnLeaveResetEnderChest(getWorld())) {
|
||||
// Remove money inventory etc. for leaving
|
||||
if (getIWM().isOnLeaveResetEnderChest(getWorld()) || getIWM().isOnJoinResetEnderChest(getWorld())) {
|
||||
user.getPlayer().getEnderChest().clear();
|
||||
}
|
||||
if (getIWM().isOnLeaveResetInventory(getWorld())) {
|
||||
if (getIWM().isOnLeaveResetInventory(getWorld()) || getIWM().isOnJoinResetInventory(getWorld())) {
|
||||
user.getPlayer().getInventory().clear();
|
||||
}
|
||||
if (getSettings().isUseEconomy() && getIWM().isOnLeaveResetMoney(getWorld())) {
|
||||
if (getSettings().isUseEconomy() && (getIWM().isOnLeaveResetMoney(getWorld()) || getIWM().isOnJoinResetMoney(getWorld()))) {
|
||||
// TODO: needs Vault
|
||||
}
|
||||
// Add the player as a team member of the new island
|
||||
|
@ -474,17 +474,44 @@ public class IslandsManager {
|
||||
* @param player - the player
|
||||
*/
|
||||
public void homeTeleport(World world, Player player) {
|
||||
homeTeleport(world, player, 1);
|
||||
homeTeleport(world, player, 1, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleport player to a home location. If one cannot be found a search is done to
|
||||
* find a safe place.
|
||||
*
|
||||
* @param world - world to check
|
||||
* @param player - the player
|
||||
* @param number - a number - home location to do to
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void homeTeleport(World world, Player player, int number) {
|
||||
homeTeleport(world, player, number, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This teleports player to their island. If not safe place can be found
|
||||
* then the player is sent to spawn via /spawn command
|
||||
*
|
||||
* @param world - world to check
|
||||
* @param player - the player
|
||||
* @param newIsland - true if this is a new island teleport
|
||||
*/
|
||||
public void homeTeleport(World world, Player player, boolean newIsland) {
|
||||
homeTeleport(world, player, 1, newIsland);
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleport player to a home location. If one cannot be found a search is done to
|
||||
* find a safe place.
|
||||
*
|
||||
* @param world - world to check
|
||||
* @param player - the player
|
||||
* @param number - a number - home location to do to
|
||||
* @param newIsland - true if this is a new island teleport
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void homeTeleport(World world, Player player, int number, boolean newIsland) {
|
||||
User user = User.getInstance(player);
|
||||
Location home = getSafeHomeLocation(world, user, number);
|
||||
// Stop any gliding
|
||||
@ -518,6 +545,21 @@ public class IslandsManager {
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
player.setGameMode(plugin.getIWM().getDefaultGameMode(world));
|
||||
}
|
||||
// If this is a new island, then run commands and do resets
|
||||
if (newIsland) {
|
||||
// TODO add command running
|
||||
|
||||
// Remove money inventory etc.
|
||||
if (plugin.getIWM().isOnJoinResetEnderChest(world)) {
|
||||
user.getPlayer().getEnderChest().clear();
|
||||
}
|
||||
if (plugin.getIWM().isOnJoinResetInventory(world)) {
|
||||
user.getPlayer().getInventory().clear();
|
||||
}
|
||||
if (plugin.getSettings().isUseEconomy() && plugin.getIWM().isOnJoinResetMoney(world)) {
|
||||
// TODO: needs Vault
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +132,7 @@ public class NewIsland {
|
||||
ib.setType(IslandType.END).build();
|
||||
}
|
||||
// Teleport player to their island
|
||||
plugin.getIslands().homeTeleport(world, user.getPlayer());
|
||||
plugin.getIslands().homeTeleport(world, user.getPlayer(), true);
|
||||
// Fire exit event
|
||||
Reason reasonDone = Reason.CREATED;
|
||||
switch (reason) {
|
||||
|
Loading…
Reference in New Issue
Block a user