Closes gh-130. The /war prefixed commands should work inside and outside warzones now. Updated to CB617/MC1.4. THis is War 1.4.

This commit is contained in:
taoneill 2011-04-02 16:50:39 -04:00
parent 498eb1e80a
commit 4f6f67bd92
8 changed files with 34 additions and 36 deletions

View File

@ -116,14 +116,13 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, 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_DAMAGE, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
//pm.registerEvent(Event.Type.CHUNK_UNLOADED, blockListener, Priority.Normal, this); //pm.registerEvent(Event.Type.CHUNK_UNLOADED, blockListener, Priority.Normal, this);
@ -150,10 +149,10 @@ public class War extends JavaPlugin {
// Handle both /war <command> and /<war command>. I.e. "/war zone temple" == "/zone temple" // Handle both /war <command> and /<war command>. I.e. "/war zone temple" == "/zone temple"
String helpMessage = "War is on. Please pick your battle. " + String helpMessage = "War is on. Please pick your battle. " +
"Try /warhub, /zones and /zone. Further instructions at war.tommytony.com/instructions."; "Try /warhub, /zones and /zone. Further instructions at war.tommytony.com/instructions.";
if((command.equals("war") || command.equals("War")) && args.length > 1) { if((command.equals("war") || command.equals("War")) && args.length > 0) {
command = args[1]; command = args[0];
arguments = new String[args.length - 1]; arguments = new String[args.length - 1];
for(int i = 2; i <= arguments.length; i++) { for(int i = 1; i <= arguments.length; i++) {
arguments[i-1] = args[i]; arguments[i-1] = args[i];
} }
if(arguments.length == 1 && (arguments[0].equals("help") || arguments[0].equals("h"))) { if(arguments.length == 1 && (arguments[0].equals("help") || arguments[0].equals("h"))) {
@ -475,7 +474,7 @@ public class War extends JavaPlugin {
// new team flag // new team flag
team.setTeamFlag(player.getLocation()); team.setTeamFlag(player.getLocation());
Location playerLoc = player.getLocation(); Location playerLoc = player.getLocation();
player.teleportTo(new Location(playerLoc.getWorld(), player.teleport(new Location(playerLoc.getWorld(),
playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ())); playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
this.msg(player, "Team " + team.getName() + " flag added here."); this.msg(player, "Team " + team.getName() + " flag added here.");
WarzoneMapper.save(this, warzone, false); WarzoneMapper.save(this, warzone, false);
@ -484,7 +483,7 @@ public class War extends JavaPlugin {
team.getFlagVolume().resetBlocks(); team.getFlagVolume().resetBlocks();
team.setTeamFlag(player.getLocation()); team.setTeamFlag(player.getLocation());
Location playerLoc = player.getLocation(); Location playerLoc = player.getLocation();
player.teleportTo(new Location(playerLoc.getWorld(), player.teleport(new Location(playerLoc.getWorld(),
playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()+1)); playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()+1));
this.msg(player, "Team " + team.getName() + " flag moved."); this.msg(player, "Team " + team.getName() + " flag moved.");
WarzoneMapper.save(this, warzone, false); WarzoneMapper.save(this, warzone, false);
@ -577,7 +576,7 @@ public class War extends JavaPlugin {
team.teamcast("The war has ended. " + playerListener.getAllTeamsMsg(player) + " Resetting warzone " + warzone.getName() + " and teams..."); team.teamcast("The war has ended. " + playerListener.getAllTeamsMsg(player) + " Resetting warzone " + warzone.getName() + " and teams...");
for(Player p : team.getPlayers()) { for(Player p : team.getPlayers()) {
warzone.restorePlayerInventory(p); warzone.restorePlayerInventory(p);
p.teleportTo(warzone.getTeleport()); p.teleport(warzone.getTeleport());
this.msg(player, "You have left the warzone. Your inventory has (hopefully) been restored."); this.msg(player, "You have left the warzone. Your inventory has (hopefully) been restored.");
} }
team.setPoints(0); team.setPoints(0);
@ -885,7 +884,7 @@ public class War extends JavaPlugin {
if(playerTeam != null) { // was in zone if(playerTeam != null) { // was in zone
playerWarzone.handlePlayerLeave(player, this.getWarHub().getLocation(), true); playerWarzone.handlePlayerLeave(player, this.getWarHub().getLocation(), true);
} }
player.teleportTo(this.getWarHub().getLocation()); player.teleport(this.getWarHub().getLocation());
} }
} }
@ -1011,7 +1010,7 @@ public class War extends JavaPlugin {
Warzone playerWarzone = getPlayerTeamWarzone(player.getName()); Warzone playerWarzone = getPlayerTeamWarzone(player.getName());
playerWarzone.handlePlayerLeave(player, warzone.getTeleport(), true); playerWarzone.handlePlayerLeave(player, warzone.getTeleport(), true);
} else { } else {
player.teleportTo(warzone.getTeleport()); player.teleport(warzone.getTeleport());
} }
warped = true; warped = true;
break; break;

View File

@ -5,12 +5,9 @@ import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockDamageLevel;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -8,9 +8,11 @@ import org.bukkit.craftbukkit.entity.CraftItem;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInventoryEvent; import org.bukkit.event.player.PlayerInventoryEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
@ -43,7 +45,7 @@ public class WarPlayerListener extends PlayerListener {
random = new Random(); random = new Random();
} }
public void onPlayerJoin(PlayerEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
// Disconnected // Disconnected
if(disconnected.containsKey(player.getName())) { if(disconnected.containsKey(player.getName())) {
@ -77,7 +79,7 @@ public class WarPlayerListener extends PlayerListener {
} }
} }
war.msg(player, "You were disconnected. Here's your inventory from last time."); war.msg(player, "You were disconnected while playing War. Here's your inventory from last time.");
} }
} }
@ -171,7 +173,7 @@ public class WarPlayerListener extends PlayerListener {
} }
} }
public void onPlayerCommandPreprocess(PlayerChatEvent event) { public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Team talkingPlayerTeam = war.getPlayerTeam(player.getName()); Team talkingPlayerTeam = war.getPlayerTeam(player.getName());
if(talkingPlayerTeam != null) { if(talkingPlayerTeam != null) {
@ -179,7 +181,7 @@ public class WarPlayerListener extends PlayerListener {
String[] split = msg.split(" "); String[] split = msg.split(" ");
if(!war.isZoneMaker(player) && split.length > 0 && split[0].startsWith("/")) { if(!war.isZoneMaker(player) && split.length > 0 && split[0].startsWith("/")) {
String command = split[0].substring(1); String command = split[0].substring(1);
if(!command.equals("zones") && !command.equals("warzones") if(!command.equals("war") && !command.equals("zones") && !command.equals("warzones")
&& !command.equals("zone") && !command.equals("warzone") && !command.equals("zone") && !command.equals("warzone")
&& !command.equals("teams") && !command.equals("teams")
&& !command.equals("join") && !command.equals("join")
@ -247,7 +249,7 @@ public class WarPlayerListener extends PlayerListener {
} }
} else { } else {
event.setFrom(zone.getTeleport()); event.setFrom(zone.getTeleport());
player.teleportTo(zone.getTeleport()); player.teleport(zone.getTeleport());
event.setCancelled(true); event.setCancelled(true);
war.badMsg(player, "All teams are full."); war.badMsg(player, "All teams are full.");
} }
@ -276,7 +278,7 @@ public class WarPlayerListener extends PlayerListener {
} }
} else { } else {
event.setFrom(zone.getTeleport()); event.setFrom(zone.getTeleport());
player.teleportTo(zone.getTeleport()); player.teleport(zone.getTeleport());
event.setCancelled(true); event.setCancelled(true);
war.badMsg(player, "Team " + team.getName() + " is full."); war.badMsg(player, "Team " + team.getName() + " is full.");
} }
@ -289,7 +291,7 @@ public class WarPlayerListener extends PlayerListener {
enteredGate = true; enteredGate = true;
dropFromOldTeamIfAny(player); dropFromOldTeamIfAny(player);
event.setFrom(war.getWarHub().getLocation()); event.setFrom(war.getWarHub().getLocation());
player.teleportTo(war.getWarHub().getLocation()); player.teleport(war.getWarHub().getLocation());
event.setCancelled(true); event.setCancelled(true);
war.msg(player, "Welcome to the War hub."); war.msg(player, "Welcome to the War hub.");
return; return;
@ -305,7 +307,7 @@ public class WarPlayerListener extends PlayerListener {
if(zone != null && zone.getTeleport() != null) { if(zone != null && zone.getTeleport() != null) {
enteredGate = true; enteredGate = true;
event.setFrom(zone.getTeleport()); event.setFrom(zone.getTeleport());
player.teleportTo(zone.getTeleport()); player.teleport(zone.getTeleport());
event.setCancelled(true); event.setCancelled(true);
war.msg(player, "Welcome to warzone " + zone.getName() + "."); war.msg(player, "Welcome to warzone " + zone.getName() + ".");
return; return;
@ -332,7 +334,7 @@ public class WarPlayerListener extends PlayerListener {
if(locZone == null && team != null) {; if(locZone == null && team != null) {;
war.badMsg(player, "You can't sneak out of a zone while in a team. Use /leave or walk out the lobby to exit the zone, please."); war.badMsg(player, "You can't sneak out of a zone while in a team. Use /leave or walk out the lobby to exit the zone, please.");
event.setFrom(team.getTeamSpawn()); event.setFrom(team.getTeamSpawn());
player.teleportTo(team.getTeamSpawn()); player.teleport(team.getTeamSpawn());
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -367,7 +369,7 @@ public class WarPlayerListener extends PlayerListener {
} }
playerWarzone.handleScoreCapReached(player, team.getName()); playerWarzone.handleScoreCapReached(player, team.getName());
event.setFrom(playerWarzone.getTeleport()); event.setFrom(playerWarzone.getTeleport());
player.teleportTo(playerWarzone.getTeleport()); player.teleport(playerWarzone.getTeleport());
event.setCancelled(true); event.setCancelled(true);
} else { } else {
// added a point // added a point
@ -392,7 +394,7 @@ public class WarPlayerListener extends PlayerListener {
// player is not in any team, but inside warzone boundaries, get him out // player is not in any team, but inside warzone boundaries, get him out
Warzone zone = war.warzone(playerLoc); Warzone zone = war.warzone(playerLoc);
event.setFrom(zone.getTeleport()); event.setFrom(zone.getTeleport());
player.teleportTo(zone.getTeleport()); player.teleport(zone.getTeleport());
event.setCancelled(true); event.setCancelled(true);
war.badMsg(player, "You can't be inside a warzone without a team."); war.badMsg(player, "You can't be inside a warzone without a team.");
return; return;
@ -416,7 +418,7 @@ public class WarPlayerListener extends PlayerListener {
if(zone.getLobby() != null) { if(zone.getLobby() != null) {
war.badMsg(player, "This warzone is disabled."); war.badMsg(player, "This warzone is disabled.");
event.setFrom(zone.getTeleport()); event.setFrom(zone.getTeleport());
player.teleportTo(zone.getTeleport()); player.teleport(zone.getTeleport());
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -372,7 +372,7 @@ public class Warzone {
player.setHealth(20); player.setHealth(20);
// Teleport the player back to spawn // Teleport the player back to spawn
player.teleportTo(team.getTeamSpawn()); player.teleport(team.getTeamSpawn());
LoadoutResetJob job = new LoadoutResetJob(this, team, player); LoadoutResetJob job = new LoadoutResetJob(this, team, player);
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job); war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
@ -891,7 +891,7 @@ public class Warzone {
} }
playerWarzone.handleScoreCapReached(player, winnersStr); playerWarzone.handleScoreCapReached(player, winnersStr);
//player.teleportTo(playerWarzone.getTeleport()); //player.teleport(playerWarzone.getTeleport());
// player will die because it took too long :( // player will die because it took too long :(
// we dont restore his inventory in handleScoreCapReached // we dont restore his inventory in handleScoreCapReached
// check out PLAYER_MOVE for the rest of the fix // check out PLAYER_MOVE for the rest of the fix
@ -956,7 +956,7 @@ public class Warzone {
player.setHealth(20); player.setHealth(20);
player.setFireTicks(0); player.setFireTicks(0);
player.setRemainingAir(300); player.setRemainingAir(300);
player.teleportTo(destination); player.teleport(destination);
war.msg(player, "Left the zone. Your inventory has (hopefully) been restored."); war.msg(player, "Left the zone. Your inventory has (hopefully) been restored.");
if(war.getWarHub() != null) { if(war.getWarHub() != null) {
war.getWarHub().resetZoneSign(this); war.getWarHub().resetZoneSign(this);

View File

@ -17,6 +17,6 @@ public class RestoreDeadmanInventoryJob implements Runnable {
public void run() { public void run() {
zone.restoreDeadmanInventory(player); zone.restoreDeadmanInventory(player);
player.teleportTo(zone.getTeleport()); player.teleport(zone.getTeleport());
} }
} }

View File

@ -20,8 +20,8 @@ public class ScoreCapReachedJob implements Runnable {
t.teamcast(winnersStr); t.teamcast(winnersStr);
for(Player tp : t.getPlayers()) { for(Player tp : t.getPlayers()) {
// Send everyone to rally point (or zone lobby if not rally point) // Send everyone to rally point (or zone lobby if not rally point)
if(zone.getRallyPoint() != null) tp.teleportTo(zone.getRallyPoint()); if(zone.getRallyPoint() != null) tp.teleport(zone.getRallyPoint());
else tp.teleportTo(zone.getTeleport()); else tp.teleport(zone.getTeleport());
tp.setFireTicks(0); tp.setFireTicks(0);
tp.setRemainingAir(300); tp.setRemainingAir(300);
if(zone.hasPlayerInventory(tp.getName())){ if(zone.hasPlayerInventory(tp.getName())){

View File

@ -1,5 +1,5 @@
name: War name: War
version: 1.3.2 (Rokossovsky) version: 1.4 (Slim)
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience. description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
author: tommytony author: tommytony
website: war.tommytony.com website: war.tommytony.com
@ -147,5 +147,5 @@ commands:
War: War:
description: (War) Same as /war. Used as fallback. description: (War) Same as /war. Used as fallback.
usage: See /war. usage: See /war.
#Note: When you /disable War with General, all warzone blocks will be reset and artifacts will disappear. #Note: When you /disable War with Essentials, or at shutdown, all warzone blocks will be reset and artifacts will disappear.
# When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear. # When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear.

View File

@ -1,5 +1,5 @@
name: War name: War
version: 1.3.2 (Rokossovsky) version: 1.4 (Slim)
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience. description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
author: tommytony author: tommytony
website: war.tommytony.com website: war.tommytony.com
@ -147,5 +147,5 @@ commands:
War: War:
description: (War) Same as /war. Used as fallback. description: (War) Same as /war. Used as fallback.
usage: See /war. usage: See /war.
#Note: When you /disable War with General, all warzone blocks will be reset and artifacts will disappear. #Note: When you /disable War with Essentials, or at shutdown, all warzone blocks will be reset and artifacts will disappear.
# When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear. # When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear.