mirror of
https://github.com/taoneill/war.git
synced 2024-11-30 22:23:27 +01:00
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:
parent
7251ed06e3
commit
18c1b498fb
@ -5,5 +5,7 @@
|
|||||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/bukkit"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/bukkit"/>
|
||||||
<classpathentry kind="lib" path="C:/dev/war/war/lib/Permissions.jar"/>
|
<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"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
42
war/pom.xml
42
war/pom.xml
@ -1,25 +1,39 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.tommytony</groupId>
|
<groupId>com.tommytony</groupId>
|
||||||
<artifactId>war</artifactId>
|
<artifactId>war</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.8</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>war</name>
|
<name>War</name>
|
||||||
<url>http://maven.apache.org</url>
|
<url>http://war.tommytony.com</url>
|
||||||
|
<build>
|
||||||
<properties>
|
<plugins>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<plugin>
|
||||||
</properties>
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<scope>test</scope>
|
<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>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -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_DAMAGEDBY_PROJECTILE, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, 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_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_PLACED, blockListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
||||||
|
@ -4,13 +4,17 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityListener;
|
import org.bukkit.event.entity.EntityListener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
import com.tommytony.war.Team;
|
import com.tommytony.war.Team;
|
||||||
@ -261,6 +265,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) {
|
// private void handleDeath(Player player, Warzone playerWarzone, Team playerTeam) {
|
||||||
// // teleport to team spawn upon death
|
// // teleport to team spawn upon death
|
||||||
|
@ -3,11 +3,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.server.Entity;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -358,13 +361,13 @@ public class Warzone {
|
|||||||
|
|
||||||
public void respawnPlayer(Team team, Player player) {
|
public void respawnPlayer(Team team, Player player) {
|
||||||
handleRespawn(team, player);
|
handleRespawn(team, player);
|
||||||
player.teleportTo(team.getTeamSpawn());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void respawnPlayer(PlayerMoveEvent event, Team team, Player player) {
|
public void respawnPlayer(PlayerMoveEvent event, Team team, Player player) {
|
||||||
event.setFrom(team.getTeamSpawn());
|
event.setFrom(team.getTeamSpawn());
|
||||||
handleRespawn(team, player);
|
handleRespawn(team, player);
|
||||||
player.teleportTo(team.getTeamSpawn());
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +403,25 @@ public class Warzone {
|
|||||||
playerInv.setHelmet(new ItemStack(Material.IRON_HELMET));
|
playerInv.setHelmet(new ItemStack(Material.IRON_HELMET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill hp
|
||||||
player.setHealth(20);
|
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) {
|
public boolean isMonumentCenterBlock(Block block) {
|
||||||
|
Loading…
Reference in New Issue
Block a user