mirror of
https://github.com/taoneill/war.git
synced 2024-11-24 03:05:54 +01:00
Playtesting v0.3. Bugs everywhere getting fixed. No more spamming anything. Weird crash occured twice. Scary. Otherwise monuments work great and its a lot of fun.
This commit is contained in:
parent
6cc5ee64bc
commit
6dfb261c05
@ -71,7 +71,7 @@ public class War extends JavaPlugin {
|
||||
if(warHub != null) {
|
||||
warHub.getVolume().resetBlocks();
|
||||
}
|
||||
Logger.getLogger("Minecraft").info("All warzone blocks reset. War v" + version + " disabled.");
|
||||
Logger.getLogger("Minecraft").info("All War blocks reset. War v" + version + " disabled.");
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
@ -82,9 +82,9 @@ public class War extends JavaPlugin {
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this);
|
||||
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this);
|
||||
//pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this);
|
||||
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
||||
@ -574,13 +574,14 @@ public class War extends JavaPlugin {
|
||||
Team newTeam = new Team(name, teamMaterial, player.getLocation(), this, warzone);
|
||||
newTeam.setRemainingTickets(warzone.getLifePool());
|
||||
warzone.getTeams().add(newTeam);
|
||||
newTeam.setTeamSpawn(player.getLocation());
|
||||
if(warzone.getLobby() != null) {
|
||||
warzone.getLobby().getVolume().resetBlocks();
|
||||
warzone.getVolume().resetWallBlocks(warzone.getLobby().getWall());
|
||||
warzone.addZoneOutline(warzone.getLobby().getWall());
|
||||
warzone.getLobby().initialize();
|
||||
}
|
||||
newTeam.setTeamSpawn(player.getLocation());
|
||||
|
||||
player.sendMessage(this.str("Team " + name + " created with spawn here."));
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ public class WarBlockListener extends BlockListener {
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
boolean captured = false;
|
||||
if(player != null) {
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
Warzone zone = war.getPlayerWarzone(player.getName());
|
||||
@ -43,12 +44,14 @@ public class WarBlockListener extends BlockListener {
|
||||
for(Team t : teams) {
|
||||
t.teamcast(war.str("Monument " + monument.getName() + " has been captured by team " + team.getName() + "."));
|
||||
}
|
||||
return; // important otherwise cancelled down a few line by isImportantblock
|
||||
|
||||
captured = true; // important otherwise cancelled down a few line by isImportantblock
|
||||
} else {
|
||||
player.sendMessage(war.str("You can't capture a monument without a block of your team's material. Get one from your team spawn."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if(!captured) {
|
||||
if(zone != null && zone.isImportantBlock(block) && !isZoneMaker){
|
||||
player.sendMessage(war.str("Can't build here."));
|
||||
event.setCancelled(true);
|
||||
@ -64,6 +67,7 @@ public class WarBlockListener extends BlockListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -77,7 +81,18 @@ public class WarBlockListener extends BlockListener {
|
||||
// can't actually destroy blocks in a warzone if not part of a team
|
||||
player.sendMessage(war.str("Can't destroy part of a warzone if you're not in a team."));
|
||||
event.setCancelled(true);
|
||||
} else if(warzone != null && warzone.isImportantBlock(block) && !isZoneMaker) {
|
||||
} else if(team != null && block != null && warzone != null
|
||||
&& warzone.isMonumentCenterBlock(block)){
|
||||
Monument monument = warzone.getMonumentFromCenterBlock(block);
|
||||
if(monument.hasOwner()) {
|
||||
|
||||
List<Team> teams = warzone.getTeams();
|
||||
for(Team t : teams) {
|
||||
t.teamcast(war.str("Team " + monument.getOwnerTeam().getName() + " loses control of monument " + monument.getName()));
|
||||
}
|
||||
monument.uncapture();
|
||||
}
|
||||
}else if(warzone != null && warzone.isImportantBlock(block) && !isZoneMaker) {
|
||||
if(team != null && team.getVolume().contains(block)) {
|
||||
if(player.getInventory().contains(team.getMaterial())) {
|
||||
player.sendMessage(war.str("You already have a " + team.getName() + " block."));
|
||||
@ -88,17 +103,6 @@ public class WarBlockListener extends BlockListener {
|
||||
player.sendMessage(war.str("Can't destroy this."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if(team != null && block != null && warzone != null
|
||||
&& warzone.isMonumentCenterBlock(block)
|
||||
){
|
||||
Monument monument = warzone.getMonumentFromCenterBlock(block);
|
||||
if(monument.hasOwner()) {
|
||||
monument.uncapture();
|
||||
List<Team> teams = warzone.getTeams();
|
||||
for(Team t : teams) {
|
||||
t.teamcast(war.str("Team " + team.getName() + " loses control of monument " + monument.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// protect warzone lobbies
|
||||
|
@ -24,7 +24,7 @@ public class WarEntityListener extends EntityListener {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
//public void onEntityDamage(EntityDamageEvent event) {
|
||||
// // BUKKIT !!
|
||||
// //Entity attacker = event.getDamager();
|
||||
// Entity defender = event.getEntity();
|
||||
@ -76,7 +76,7 @@ public class WarEntityListener extends EntityListener {
|
||||
// event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team
|
||||
// }
|
||||
// }
|
||||
}
|
||||
//}
|
||||
|
||||
// public void onEntityDamaged(EntityDamagedEvent event) {
|
||||
// Entity damaged = event.getEntity();
|
||||
|
@ -5,22 +5,16 @@ import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import com.tommytony.war.Monument;
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.TeamMaterials;
|
||||
import com.tommytony.war.WarHub;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.ZoneLobby;
|
||||
import com.tommytony.war.mappers.WarMapper;
|
||||
import com.tommytony.war.mappers.WarzoneMapper;
|
||||
|
||||
|
||||
/**
|
||||
@ -86,7 +80,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
List<Team> teams = playerWarzone.getTeams();
|
||||
for(Team t : teams) {
|
||||
t.teamcast(war.str("The battle is over. Team " + team.getName() + " lost: "
|
||||
+ player.getName() + " hit the bottom of their life pool." ));
|
||||
+ player.getName() + " died and there were no lives left in their life pool." ));
|
||||
|
||||
if(!t.getName().equals(team.getName())) {
|
||||
// all other teams get a point
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
@ -34,6 +35,8 @@ public class Monument {
|
||||
}
|
||||
|
||||
public void addMonumentBlocks() {
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
|
||||
this.ownerTeam = null;
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
@ -120,12 +123,12 @@ public class Monument {
|
||||
|
||||
public void capture(Team team) {
|
||||
ownerTeam = team;
|
||||
warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(team.getMaterial());
|
||||
//warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(team.getMaterial());
|
||||
}
|
||||
|
||||
public void uncapture() {
|
||||
ownerTeam = null;
|
||||
warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(Material.OBSIDIAN);
|
||||
//warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(Material.OBSIDIAN);
|
||||
|
||||
}
|
||||
|
||||
@ -159,4 +162,9 @@ public class Monument {
|
||||
this.volume = newVolume;
|
||||
|
||||
}
|
||||
|
||||
public Team getOwnerTeam() {
|
||||
|
||||
return ownerTeam;
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ public class Team {
|
||||
}
|
||||
|
||||
private void initializeTeamSpawn(Location teamSpawn) {
|
||||
// make air
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
|
||||
// Set the spawn
|
||||
int x = teamSpawn.getBlockX();
|
||||
int y = teamSpawn.getBlockY();
|
||||
@ -208,12 +211,14 @@ public class Team {
|
||||
block.setData((byte)6);
|
||||
|
||||
BlockState state = block.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "Team " + name);
|
||||
sign.setLine(1, remainingTickets + "/" + warzone.getLifePool() + " lives left");
|
||||
sign.setLine(2, points + "/" + warzone.getScoreCap() + " pts");
|
||||
sign.setLine(3, players.size() + "/" + warzone.getTeamCap() + " players");
|
||||
state.update(true);
|
||||
}
|
||||
|
||||
if(warzone.getLobby() != null) {
|
||||
warzone.getLobby().resetTeamGateSign(this);
|
||||
|
@ -98,6 +98,7 @@ public class WarHub {
|
||||
if(signBlock.getType() != Material.SIGN_POST) signBlock.setType(Material.SIGN_POST);
|
||||
signBlock.setData((byte)8);
|
||||
BlockState state = signBlock.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "War hub");
|
||||
sign.setLine(1, "");
|
||||
@ -105,6 +106,14 @@ public class WarHub {
|
||||
sign.setLine(3, "");
|
||||
state.update(true);
|
||||
}
|
||||
|
||||
// Warzone signs
|
||||
for(Warzone zone : war.getWarzones()) {
|
||||
if(zone.ready()) {
|
||||
war.getWarHub().resetZoneSign(zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetZoneSign(Warzone zone) {
|
||||
@ -126,6 +135,7 @@ public class WarHub {
|
||||
}
|
||||
|
||||
BlockState state = block.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "Warzone");
|
||||
sign.setLine(1, zone.getName());
|
||||
@ -133,6 +143,7 @@ public class WarHub {
|
||||
sign.setLine(3, zone.getTeams().size() + " teams");
|
||||
state.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVolume(Volume vol) {
|
||||
this.volume = vol;
|
||||
|
@ -145,6 +145,7 @@ public class ZoneLobby {
|
||||
|
||||
if(lobbyMiddleWallBlock != null && volume != null && volume.isSaved()) {
|
||||
// flatten the area (set all but floor to air, then replace any floor air blocks with glass)
|
||||
this.volume.clearBlocksThatDontFloat();
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS); // beautiful
|
||||
|
||||
@ -154,7 +155,7 @@ public class ZoneLobby {
|
||||
// add warhub sign
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "";
|
||||
lines[1] = "War hub";
|
||||
lines[1] = "To War hub";
|
||||
lines[2] = "";
|
||||
lines[3] = "";
|
||||
resetGateSign(warHubLinkGate, lines, false);
|
||||
@ -516,7 +517,9 @@ public class ZoneLobby {
|
||||
if(awayFromWall) block.setData((byte)0);
|
||||
else block.setData((byte)8);
|
||||
}
|
||||
|
||||
BlockState state = block.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, lines[0]);
|
||||
sign.setLine(1, lines[1]);
|
||||
@ -524,4 +527,5 @@ public class ZoneLobby {
|
||||
sign.setLine(3, lines[3]);
|
||||
state.update(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,9 +70,7 @@ public class Volume {
|
||||
|
||||
public int resetBlocks() {
|
||||
int noOfResetBlocks = 0;
|
||||
Material[] toAirMaterials = new Material[1];
|
||||
toAirMaterials[0] = Material.SIGN_POST;
|
||||
switchMaterials(toAirMaterials, Material.AIR);
|
||||
clearBlocksThatDontFloat();
|
||||
try {
|
||||
if(hasTwoCorners() && getBlockInfos() != null) {
|
||||
int x = getMinX();
|
||||
@ -295,7 +293,7 @@ public class Volume {
|
||||
for(int k = 0;k < getSizeZ(); k++) {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
for(Material oldType : oldTypes) {
|
||||
if(currentBlock.getType() == oldType) {
|
||||
if(currentBlock.getType().getId() == oldType.getId()) {
|
||||
currentBlock.setType(newType);
|
||||
}
|
||||
}
|
||||
@ -311,4 +309,31 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearBlocksThatDontFloat() {
|
||||
Material[] toAirMaterials = new Material[22];
|
||||
toAirMaterials[0] = Material.SIGN_POST;
|
||||
toAirMaterials[1] = Material.SIGN;
|
||||
toAirMaterials[2] = Material.IRON_DOOR_BLOCK;
|
||||
toAirMaterials[3] = Material.WOOD_DOOR;
|
||||
toAirMaterials[4] = Material.LADDER;
|
||||
toAirMaterials[5] = Material.YELLOW_FLOWER;
|
||||
toAirMaterials[6] = Material.RED_ROSE;
|
||||
toAirMaterials[7] = Material.RED_MUSHROOM;
|
||||
toAirMaterials[8] = Material.BROWN_MUSHROOM;
|
||||
toAirMaterials[9] = Material.SAPLING;
|
||||
toAirMaterials[10] = Material.TORCH;
|
||||
toAirMaterials[11] = Material.RAILS;
|
||||
toAirMaterials[12] = Material.STONE_BUTTON;
|
||||
toAirMaterials[13] = Material.STONE_PLATE;
|
||||
toAirMaterials[14] = Material.WOOD_PLATE;
|
||||
toAirMaterials[15] = Material.LEVER;
|
||||
toAirMaterials[16] = Material.REDSTONE;
|
||||
toAirMaterials[17] = Material.REDSTONE_TORCH_ON;
|
||||
toAirMaterials[18] = Material.REDSTONE_TORCH_OFF;
|
||||
toAirMaterials[19] = Material.CACTUS;
|
||||
toAirMaterials[20] = Material.SNOW;
|
||||
toAirMaterials[21] = Material.ICE;
|
||||
switchMaterials(toAirMaterials, Material.AIR);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user