Save armour and location only in Bridges
This commit is contained in:
parent
ec1038bce6
commit
9a2ebdfb33
@ -272,7 +272,9 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
.setGiveCompassToAlive(true)
|
.setGiveCompassToAlive(true)
|
||||||
.register(this);
|
.register(this);
|
||||||
|
|
||||||
_rejoinModule = new RejoinModule(manager);
|
_rejoinModule = new RejoinModule(manager)
|
||||||
|
.setSaveInventory(true)
|
||||||
|
.setSaveLocation(true);
|
||||||
_rejoinModule.register(this);
|
_rejoinModule.register(this);
|
||||||
|
|
||||||
// So that we can be 110% sure
|
// So that we can be 110% sure
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.game.region.GameRejoinManager;
|
import mineplex.core.game.region.GameRejoinManager;
|
||||||
@ -26,6 +27,8 @@ public class RejoinModule extends Module
|
|||||||
private final GameRejoinManager _manager;
|
private final GameRejoinManager _manager;
|
||||||
private final Map<UUID, PlayerGameInfo> _rejoinData;
|
private final Map<UUID, PlayerGameInfo> _rejoinData;
|
||||||
|
|
||||||
|
private boolean _saveInventory, _saveLocation;
|
||||||
|
|
||||||
public RejoinModule(ArcadeManager manager)
|
public RejoinModule(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
_manager = new GameRejoinManager(manager);
|
_manager = new GameRejoinManager(manager);
|
||||||
@ -47,6 +50,18 @@ public class RejoinModule extends Module
|
|||||||
UtilServer.Unregister(_manager);
|
UtilServer.Unregister(_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RejoinModule setSaveInventory(boolean saveInventory)
|
||||||
|
{
|
||||||
|
_saveInventory = saveInventory;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RejoinModule setSaveLocation(boolean saveLocation)
|
||||||
|
{
|
||||||
|
_saveLocation = saveLocation;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void disableRejoining()
|
public void disableRejoining()
|
||||||
{
|
{
|
||||||
getGame().QuitOut = true;
|
getGame().QuitOut = true;
|
||||||
@ -69,8 +84,23 @@ public class RejoinModule extends Module
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_rejoinData.put(player.getUniqueId(), new PlayerGameInfo(player.getHealth(), getGame().GetKit(player), team));
|
PlayerGameInfo data;
|
||||||
|
|
||||||
|
if (_saveInventory)
|
||||||
|
{
|
||||||
|
data = new PlayerGameInfo(player.getHealth(), player.getInventory().getContents(), player.getInventory().getArmorContents(), getGame().GetKit(player), team);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = new PlayerGameInfo(player.getHealth(), getGame().GetKit(player), team);
|
||||||
|
}
|
||||||
|
|
||||||
|
_rejoinData.put(player.getUniqueId(), data);
|
||||||
|
|
||||||
|
if (_saveLocation)
|
||||||
|
{
|
||||||
getGame().GetLocationStore().putIfAbsent(player.getName(), player.getLocation());
|
getGame().GetLocationStore().putIfAbsent(player.getName(), player.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
team.RemovePlayer(player);
|
team.RemovePlayer(player);
|
||||||
|
|
||||||
@ -130,6 +160,12 @@ public class RejoinModule extends Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.setHealth(Math.min(info.getHealth(), player.getHealth()));
|
player.setHealth(Math.min(info.getHealth(), player.getHealth()));
|
||||||
|
|
||||||
|
if (_saveInventory)
|
||||||
|
{
|
||||||
|
player.getInventory().setArmorContents(info.getInventoryArmour());
|
||||||
|
player.getInventory().setContents(info.getInventoryContents());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEnabled()
|
private boolean isEnabled()
|
||||||
@ -140,13 +176,21 @@ public class RejoinModule extends Module
|
|||||||
public class PlayerGameInfo
|
public class PlayerGameInfo
|
||||||
{
|
{
|
||||||
private final double _health;
|
private final double _health;
|
||||||
|
private final ItemStack[] _inventoryContents, _inventoryArmour;
|
||||||
private final Kit _kit;
|
private final Kit _kit;
|
||||||
private GameTeam _team;
|
private GameTeam _team;
|
||||||
private boolean _cancelled;
|
private boolean _cancelled;
|
||||||
|
|
||||||
PlayerGameInfo(double health, Kit kit, GameTeam team)
|
PlayerGameInfo(double health, Kit kit, GameTeam team)
|
||||||
|
{
|
||||||
|
this(health, null, null, kit, team);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerGameInfo(double health, ItemStack[] inventoryContents, ItemStack[] inventoryArmour, Kit kit, GameTeam team)
|
||||||
{
|
{
|
||||||
_health = health;
|
_health = health;
|
||||||
|
_inventoryContents = inventoryContents;
|
||||||
|
_inventoryArmour = inventoryArmour;
|
||||||
_kit = kit;
|
_kit = kit;
|
||||||
_team = team;
|
_team = team;
|
||||||
}
|
}
|
||||||
@ -156,6 +200,16 @@ public class RejoinModule extends Module
|
|||||||
return _health;
|
return _health;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getInventoryContents()
|
||||||
|
{
|
||||||
|
return _inventoryContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getInventoryArmour()
|
||||||
|
{
|
||||||
|
return _inventoryArmour;
|
||||||
|
}
|
||||||
|
|
||||||
public Kit getKit()
|
public Kit getKit()
|
||||||
{
|
{
|
||||||
return _kit;
|
return _kit;
|
||||||
|
Loading…
Reference in New Issue
Block a user