Closes 23. Closes 24. Closes 30. Death by lava seems to work ok on my side. Inventories get reset and signs as well. Fixed tp error with drowning deaths - weird workaround. Fire is extinguished back at the player spawn.

This commit is contained in:
taoneill 2011-02-06 12:49:22 -05:00
parent 7251ed06e3
commit 18c1b498fb
5 changed files with 111 additions and 16 deletions

View File

@ -5,5 +5,7 @@
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/bukkit"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/Permissions.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/craftbukkit"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/minecraft_server.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,25 +1,39 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tommytony</groupId>
<artifactId>war</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.8</version>
<packaging>jar</packaging>
<name>war</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<name>War</name>
<url>http://war.tommytony.com</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -105,6 +105,8 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_PROJECTILE, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);

View File

@ -4,13 +4,17 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerMoveEvent;
import com.tommytony.war.Team;
@ -260,6 +264,58 @@ public class WarEntityListener extends EntityListener {
// }
//}
}
public void onEntityDamage(EntityDamageEvent event) {
if(event.getCause() == DamageCause.FIRE_TICK) {
Entity entity = event.getEntity();
if(entity instanceof Player) {
Player player = (Player) entity;
Team team = war.getPlayerTeam(player.getName());
if(team != null && team.getSpawnVolume().contains(player.getLocation())) {
// smother out the fire that didn't burn out when you respawned
// Stop fire (upcast, watch out!)
if(player instanceof CraftPlayer) {
net.minecraft.server.Entity playerEntity = ((CraftPlayer)player).getHandle();
playerEntity.fireTicks = 0;
// playerEntity.r(); // force refresh (?)
}
event.setCancelled(true);
}
}
} else if (event.getCause() == DamageCause.DROWNING) {
Entity entity = event.getEntity();
if(entity instanceof Player) {
Player player = (Player) entity;
Team team = war.getPlayerTeam(player.getName());
if(team != null && player.getHealth() <= 0) {
// don't keep killing drowing player: trying to stop "Player moved wrongly!" error at respawn.
event.setCancelled(true);
}
}
}
}
public void onEntityCombust(EntityCombustEvent event) {
Entity entity = event.getEntity();
if(entity instanceof Player) {
Player player = (Player) entity;
Team team = war.getPlayerTeam(player.getName());
if(team != null && team.getSpawnVolume().contains(player.getLocation())) {
// smother out the fire that didn't burn out when you respawned
//Stop fire (upcast, watch out!)
if(player instanceof CraftPlayer) {
net.minecraft.server.Entity playerEntity = ((CraftPlayer)player).getHandle();
playerEntity.fireTicks = 0;
// playerEntity.r(); // force refresh (?)
}
event.setCancelled(true);
}
}
}
// private void handleDeath(Player player, Warzone playerWarzone, Team playerTeam) {

View File

@ -3,11 +3,14 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.server.Entity;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
@ -358,13 +361,13 @@ public class Warzone {
public void respawnPlayer(Team team, Player player) {
handleRespawn(team, player);
player.teleportTo(team.getTeamSpawn());
}
public void respawnPlayer(PlayerMoveEvent event, Team team, Player player) {
event.setFrom(team.getTeamSpawn());
handleRespawn(team, player);
player.teleportTo(team.getTeamSpawn());
event.setCancelled(true);
}
@ -400,7 +403,25 @@ public class Warzone {
playerInv.setHelmet(new ItemStack(Material.IRON_HELMET));
}
}
// Fill hp
player.setHealth(20);
// Teleport the player back to spawn
Location playerLoc = player.getLocation();
int x = playerLoc.getBlockX();
int y = playerLoc.getBlockY();
int z = playerLoc.getBlockZ();
Block playerBlock = world.getBlockAt(x, y, z).getFace(BlockFace.UP);
Material playerBlockType = playerBlock.getType();
if(playerBlockType.getId() == Material.WATER.getId()
|| playerBlockType.getId() == Material.STATIONARY_WATER.getId()) {
// If in water, make arbitrary adjustments to fix drowning deaths causing "Player moved wrongly!" error
player.teleportTo(new Location(playerLoc.getWorld(),
team.getTeamSpawn().getX(), team.getTeamSpawn().getY() + 3, team.getTeamSpawn().getZ()));
} else {
player.teleportTo(team.getTeamSpawn());
}
}
public boolean isMonumentCenterBlock(Block block) {