Closes #739. Respawning doesn't wipe your chat anymore.

- We just take care of wiping top inventory slots in CRAFTING-type inventory views (container inventories weren't causing the same issue)
- End-of-game teleport and state restoration shouldn't wipe your chat anymore either
This commit is contained in:
taoneill 2014-01-12 18:32:19 -05:00
parent 2ef0f3e324
commit 95ee0c1972
3 changed files with 48 additions and 9 deletions

View File

@ -1,11 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -16,12 +16,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>

View File

@ -30,7 +30,9 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.permissions.Permissible;
@ -423,8 +425,9 @@ public class Warzone {
player.setSaturation(team.getTeamConfig().resolveInt(TeamConfig.SATURATION));
player.setExhaustion(0);
player.setFireTicks(0); //this works fine here, why put it in LoudoutResetJob...? I'll keep it over there though
this.preventItemHackingThroughOpenedInventory(player);
player.getOpenInventory().close();
player.setLevel(0);
player.setExp(0);
player.setAllowFlight(false);
@ -571,7 +574,9 @@ public class Warzone {
PlayerState originalState = this.playerStates.remove(player.getName());
PlayerInventory playerInv = player.getInventory();
if (originalState != null) {
player.getOpenInventory().close();
// prevent item hacking thru CRAFTING personal inventory slots
this.preventItemHackingThroughOpenedInventory(player);
this.playerInvFromInventoryStash(playerInv, originalState);
player.setGameMode(originalState.getGamemode());
player.setHealth(Math.max(Math.min(originalState.getHealth(), 20.0D), 0.0D));
@ -590,6 +595,18 @@ public class Warzone {
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
}
private void preventItemHackingThroughOpenedInventory(Player player) {
InventoryView openedInv = player.getOpenInventory();
if (openedInv.getType() == InventoryType.CRAFTING) {
// prevent abuse of personal crafting slots (this behavior doesn't seem to happen
// for containers like workbench and furnace - those get closed properly)
openedInv.getTopInventory().clear();
}
// Prevent player from keeping items he was transferring in his inventory
openedInv.setCursor(null);
}
private void playerInvFromInventoryStash(PlayerInventory playerInv, PlayerState originalContents) {
playerInv.clear();