Clear EnderChests on match join
arahpthos opened this issue ยท 1 comments
Ender Chests remain persistent on the server through the player data. This means that you can pack your Ender Chest full of objective blocks and never have to actually run any dungeons.
I think that Ender Chests should be cleared for a player whenever he/she joins a team
A way that I think can solve this is by adding this to AutoReferee / src / main / java / org / mctourney / autoreferee / util / PlayerUtil.java:
/**
* Clears the player's Ender Chest.
*/
public static void clearEnderChest(Player player)
{
// clear the player's ender inventory
Inventory endChest = player.getEnderChest();
endChest.clear();
}
and just call that function wherever necessary. Such as starting at line 95 in AutoReferee / src / main / java / org / mctourney / autoreferee / listeners / WorldListener.java :
// only clear inventories and give books if before match or not a player
if (match.getCurrentState().isBeforeMatch() || !match.isPlayer(player))
{
// give them a book with info about the match
PlayerUtil.clearInventory(player);
match.giveMatchInfoBook(player);
}
becoming:
// only clear inventories and give books if before match or not a player
if (match.getCurrentState().isBeforeMatch() || !match.isPlayer(player))
{
// give them a book with info about the match
PlayerUtil.clearInventory(player);
PlayerUtil.clearEnderChest(player);
match.giveMatchInfoBook(player);
}
and line 136 of the same file from:
if (matchTo != null)
{
matchTo.checkTeamsReady();
matchTo.sendMatchInfo(player);
matchTo.setupSpectators(player);
if (matchTo.isReferee(player))
matchTo.updateReferee(player);
// give them a book with info about the match
PlayerUtil.clearInventory(player);
matchTo.giveMatchInfoBook(player);
}
to:
if (matchTo != null)
{
matchTo.checkTeamsReady();
matchTo.sendMatchInfo(player);
matchTo.setupSpectators(player);
if (matchTo.isReferee(player))
matchTo.updateReferee(player);
// give them a book with info about the match
PlayerUtil.clearInventory(player);
PlayerUtil.clearEnderChest(player);
matchTo.giveMatchInfoBook(player);
}
Added in #205.