mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 02:35:24 +01:00
Closes gh-81. Closes gh-77. Closes gh-87. Temporarily closing these issue because volume resets and some player respawns are now delayed tasks handed off to the scheduler, which makes everything faster for the person who just died. There's a short delay to the zone reset now, though. Sign spam should be fixed in the same swoop.
This commit is contained in:
parent
07ad330083
commit
08ca02cbad
@ -1,9 +1,9 @@
|
||||
War add team deathmatch and capture-the-flag to Minecraft SMP.
|
||||
War adds team deathmatch and capture-the-flag to Minecraft SMP.
|
||||
|
||||
The plugin started on hMod but was ported to bukkit from v0.3 on.
|
||||
The plugin started on hMod but was ported to Bukkit from v0.3 on.
|
||||
|
||||
Grab your copy in the Downloads section.
|
||||
|
||||
Go to http://war.tommytony.com for more.
|
||||
|
||||
All credit goes to Mojang, hey0 and the bukkit team for being so awesome.
|
||||
All credit goes to Mojang, hey0 and the Bukkit team for being so awesome.
|
@ -102,7 +102,6 @@ public class War extends JavaPlugin {
|
||||
|
||||
public void onEnable() {
|
||||
desc = this.getDescription();
|
||||
//this.log = Logger.getLogger("Minecraft");
|
||||
this.log = this.getServer().getLogger();
|
||||
this.setupPermissions();
|
||||
|
||||
@ -193,7 +192,7 @@ public class War extends JavaPlugin {
|
||||
performSetZoneLobby(player, arguments);
|
||||
} else if(command.equals("savezone")) {
|
||||
performSaveZone(player, arguments);
|
||||
} else if(command.equals("setzoneconfig")) {
|
||||
} else if(command.equals("setzoneconfig") || command.equals("zonecfg")) {
|
||||
performSetZoneConfig(player, arguments);
|
||||
} else if(command.equals("resetzone")) {
|
||||
performResetZone(player, arguments);
|
||||
@ -213,7 +212,7 @@ public class War extends JavaPlugin {
|
||||
performSetWarhub(player);
|
||||
} else if(command.equals("deletewarhub")) {
|
||||
performDeleteWarhub(player);
|
||||
} else if(command.equals("setwarconfig")) {
|
||||
} else if(command.equals("setwarconfig") || command.equals("warcfg")) {
|
||||
performSetWarConfig(player, arguments);
|
||||
} else if(command.equals("zonemaker")) {
|
||||
performZonemakerAsZonemaker(player, arguments);
|
||||
@ -588,22 +587,22 @@ public class War extends JavaPlugin {
|
||||
this.getWarzones().remove(warzone);
|
||||
resetWarzone = WarzoneMapper.load(this, warzone.getName(), true);
|
||||
this.getWarzones().add(resetWarzone);
|
||||
resetBlocks = warzone.getVolume().resetBlocks();
|
||||
warzone.getVolume().resetBlocksAsJob();
|
||||
if(lobby!=null) {
|
||||
lobby.getVolume().resetBlocks();
|
||||
lobby.getVolume().resetBlocksAsJob();
|
||||
}
|
||||
resetWarzone.initializeZone();
|
||||
resetWarzone.initializeZoneAsJob();
|
||||
} else {
|
||||
resetBlocks = warzone.getVolume().resetBlocks();
|
||||
warzone.getVolume().resetBlocksAsJob();
|
||||
if(lobby!=null) {
|
||||
lobby.getVolume().resetBlocks();
|
||||
lobby.getVolume().resetBlocksAsJob();
|
||||
}
|
||||
warzone.initializeZone();
|
||||
warzone.initializeZoneAsJob();
|
||||
|
||||
}
|
||||
|
||||
this.msg(player, "Warzone and teams reset. " + resetBlocks + " blocks reset.");
|
||||
logInfo(resetBlocks + " blocks reset in warzone " + warzone.getName() + ".");
|
||||
// this.msg(player, "Warzone and teams reset. " + resetBlocks + " blocks reset.");
|
||||
// logInfo(resetBlocks + " blocks reset in warzone " + warzone.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -864,10 +863,10 @@ public class War extends JavaPlugin {
|
||||
for(Team team: warzone.getTeams()) {
|
||||
team.teamcast("The battle was interrupted. " + playerListener.getAllTeamsMsg(player) + " Resetting warzone " + warzone.getName() + " and life pools...");
|
||||
}
|
||||
int resetBlocks = warzone.getVolume().resetBlocks();
|
||||
warzone.initializeZone();
|
||||
this.msg(player, "Warzone reset. " + resetBlocks + " blocks reset.");
|
||||
logInfo(resetBlocks + " blocks reset in warzone " + warzone.getName() + ".");
|
||||
warzone.getVolume().resetBlocksAsJob();
|
||||
warzone.initializeZoneAsJob();
|
||||
// this.msg(player, "Warzone reset. " + resetBlocks + " blocks reset.");
|
||||
// logInfo(resetBlocks + " blocks reset in warzone " + warzone.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,31 +70,6 @@ public class WarEntityListener extends EntityListener {
|
||||
&& attackerTeam != defenderTeam
|
||||
&& attackerWarzone == defenderWarzone) {
|
||||
// Make sure one of the players isn't in the spawn
|
||||
// if(!){
|
||||
// // A real attack: handle death scenario. ==> now handled in entity damage as well
|
||||
// //synchronized(d) {
|
||||
//// if(d.getHealth() <= 0) {
|
||||
////// // Player died, loot him!
|
||||
////// PlayerInventory attackerInv = a.getInventory();
|
||||
////// PlayerInventory defenderInv = d.getInventory();
|
||||
////// HashMap<Integer, ItemStack> noMorePlace = new HashMap<Integer, ItemStack>();
|
||||
////// for(ItemStack stack : defenderInv.getContents()) {
|
||||
////// HashMap<Integer, ItemStack> newNoMorePlace = attackerInv.addItem(stack);
|
||||
////// noMorePlace.putAll(newNoMorePlace);
|
||||
////// }
|
||||
//////
|
||||
////// // attacker inventory is full, drop the rest.
|
||||
////// if(!noMorePlace.isEmpty()) {
|
||||
////// for(Integer key : noMorePlace.keySet()) {
|
||||
////// ItemStack toDrop = noMorePlace.get(key);
|
||||
////// defender.getWorld().dropItem(defender.getLocation(), toDrop);
|
||||
////// }
|
||||
////// }
|
||||
////
|
||||
//// handleDeath(d, defenderWarzone, defenderTeam);
|
||||
//// event.setCancelled(true);
|
||||
// //}
|
||||
// }
|
||||
if(defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn
|
||||
war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
|
||||
event.setCancelled(true);
|
||||
|
@ -400,16 +400,17 @@ public class WarPlayerListener extends PlayerListener {
|
||||
return;
|
||||
}
|
||||
|
||||
// DEADMAN
|
||||
// The guy whose death caused the game to end
|
||||
// He dies for real (no quick respawn) becasue his ENTITY_DEATH takes too long (everyones warping)
|
||||
if(locZone == null && locLobby == null) {
|
||||
for(Warzone zone : war.getWarzones()) {
|
||||
if(zone.isDeadMan(player.getName())) {
|
||||
RestoreDeadmanInventoryJob job = new RestoreDeadmanInventoryJob(player, zone);
|
||||
war.getServer().getScheduler().scheduleAsyncDelayedTask(war, job, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(locZone == null && locLobby == null) {
|
||||
// for(Warzone zone : war.getWarzones()) {
|
||||
// if(zone.isDeadMan(player.getName())) {
|
||||
// RestoreDeadmanInventoryJob job = new RestoreDeadmanInventoryJob(player, zone);
|
||||
// war.getServer().getScheduler().scheduleAsyncDelayedTask(war, job, 3);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,15 +3,12 @@ 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.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -19,7 +16,9 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
import com.tommytony.war.jobs.InitZoneJob;
|
||||
import com.tommytony.war.jobs.ResetCursorJob;
|
||||
import com.tommytony.war.jobs.ScoreCapReachedJob;
|
||||
import com.tommytony.war.utils.InventoryStash;
|
||||
import com.tommytony.war.volumes.VerticalVolume;
|
||||
|
||||
@ -132,7 +131,7 @@ public class Warzone {
|
||||
topNWBlock.setType(Material.GLASS);
|
||||
topNWBlock.getFace(BlockFace.EAST).setType(Material.GLASS);
|
||||
topNWBlock.getFace(BlockFace.SOUTH).setType(Material.GLASS);
|
||||
this.war.getServer().getScheduler().scheduleAsyncDelayedTask(this.war, new ResetCursorJob(topNWBlock, originalNorthwestBlocks, false), 85);
|
||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, new ResetCursorJob(topNWBlock, originalNorthwestBlocks, false), 40);
|
||||
}
|
||||
|
||||
public Location getNorthwest() {
|
||||
@ -154,7 +153,7 @@ public class Warzone {
|
||||
topSEBlock.setType(Material.GLASS);
|
||||
topSEBlock.getFace(BlockFace.WEST).setType(Material.GLASS);
|
||||
topSEBlock.getFace(BlockFace.NORTH).setType(Material.GLASS);
|
||||
this.war.getServer().getScheduler().scheduleAsyncDelayedTask(this.war, new ResetCursorJob(topSEBlock, originalSoutheastBlocks, true), 85);
|
||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, new ResetCursorJob(topSEBlock, originalSoutheastBlocks, true), 40);
|
||||
}
|
||||
|
||||
|
||||
@ -208,11 +207,15 @@ public class Warzone {
|
||||
* @return
|
||||
*/
|
||||
public void initializeZone() {
|
||||
initializeZone(null);
|
||||
}
|
||||
|
||||
public void initializeZone(Player respawnExempted) {
|
||||
if(ready() && volume.isSaved()){
|
||||
// everyone back to team spawn with full health
|
||||
for(Team team : teams) {
|
||||
for(Player player : team.getPlayers()) {
|
||||
respawnPlayer(team, player);
|
||||
if(player != respawnExempted) respawnPlayer(team, player);
|
||||
}
|
||||
team.setRemainingLives(lifePool);
|
||||
team.initializeTeamSpawn();
|
||||
@ -230,14 +233,23 @@ public class Warzone {
|
||||
for(Team team : teams) {
|
||||
if(team.getPlayers().size() > 0) {
|
||||
craftWorld.refreshChunk(team.getTeamSpawn().getBlockX(), team.getTeamSpawn().getBlockZ());
|
||||
craftWorld.refreshChunk(team.getSpawnVolume().getCornerOne().getX(), team.getSpawnVolume().getCornerOne().getZ());
|
||||
craftWorld.refreshChunk(team.getSpawnVolume().getCornerTwo().getX(), team.getSpawnVolume().getCornerTwo().getZ());
|
||||
}
|
||||
}
|
||||
// dont do all the zone chunks for now
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initializeZoneAsJob(Player respawnExempted) {
|
||||
InitZoneJob job = new InitZoneJob(this, respawnExempted);
|
||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
|
||||
}
|
||||
|
||||
public void initializeZoneAsJob() {
|
||||
InitZoneJob job = new InitZoneJob(this);
|
||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
|
||||
}
|
||||
|
||||
private void initZone() {
|
||||
// add wall outlines
|
||||
@ -388,20 +400,20 @@ public class Warzone {
|
||||
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 {
|
||||
// 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) {
|
||||
@ -895,10 +907,10 @@ public class Warzone {
|
||||
} else {
|
||||
// A new battle starts. Reset the zone but not the teams.
|
||||
for(Team t : teams) {
|
||||
t.teamcast("A new battle begins. Warzone reset.");
|
||||
t.teamcast("A new battle begins. Resetting warzone...");
|
||||
}
|
||||
playerWarzone.getVolume().resetBlocks();
|
||||
playerWarzone.initializeZone();
|
||||
playerWarzone.getVolume().resetBlocksAsJob();
|
||||
playerWarzone.initializeZoneAsJob(player);
|
||||
newBattle = true;
|
||||
}
|
||||
} else {
|
||||
@ -920,18 +932,10 @@ public class Warzone {
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
//}
|
||||
//synchronized(player) {
|
||||
if(!newBattle && !scoreCapReached) {
|
||||
//if(!newBattle /*&& !scoreCapReached*/) {
|
||||
playerTeam.resetSign();
|
||||
playerWarzone.respawnPlayer(playerTeam, player);
|
||||
}
|
||||
// war.info(player.getName() + " died and enemy team reached score cap");
|
||||
// } else if (newBattle){
|
||||
// war.info(player.getName() + " died and battle ended in team " + playerTeam.getName() + "'s disfavor");
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -973,13 +977,13 @@ public class Warzone {
|
||||
}
|
||||
if(zoneEmpty) {
|
||||
// reset the zone for a new game when the last player leaves
|
||||
int resetBlocks = this.getVolume().resetBlocks();
|
||||
this.initializeZone();
|
||||
for(Team team : this.getTeams()) {
|
||||
team.setPoints(0);
|
||||
team.setRemainingLives(this.getLifePool());
|
||||
}
|
||||
war.logInfo("Last player left warzone " + this.getName() + ". " + resetBlocks + " blocks reset automatically.");
|
||||
this.getVolume().resetBlocksAsJob();
|
||||
this.initializeZoneAsJob();
|
||||
war.logInfo("Last player left warzone " + this.getName() + ". Warzone blocks resetting automatically...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1035,46 +1039,50 @@ public class Warzone {
|
||||
|
||||
public void handleScoreCapReached(Player player, String winnersStr) {
|
||||
winnersStr = "Score cap reached! Winning team(s): " + winnersStr;
|
||||
winnersStr += ". Your inventory has (hopefully) been reset. The warzone is being reset... Please choose a new team.";
|
||||
if(this.hasPlayerInventory(player.getName())){
|
||||
InventoryStash stash = inventories.remove(player.getName());
|
||||
deadMenInventories.put(player.getName(), stash);
|
||||
}
|
||||
winnersStr += ". The warzone and your inventory are being reset....";
|
||||
// DEADMAN
|
||||
// if(this.hasPlayerInventory(player.getName())){
|
||||
// InventoryStash stash = inventories.remove(player.getName());
|
||||
// deadMenInventories.put(player.getName(), stash);
|
||||
// }
|
||||
// Score cap reached. Reset everything.
|
||||
for(Team t : this.getTeams()) {
|
||||
t.teamcast(winnersStr);
|
||||
for(Player tp : t.getPlayers()) {
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
||||
if(!tp.getName().equals(player.getName())) {
|
||||
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
|
||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
|
||||
// for(Team t : this.getTeams()) {
|
||||
// t.teamcast(winnersStr);
|
||||
// for(Player tp : t.getPlayers()) {
|
||||
// PlayerInventory inv = player.getInventory();
|
||||
//
|
||||
// if(!tp.getName().equals(player.getName())) {
|
||||
// ScoreCapReachedJob job = new ScoreCapReachedJob(tp, this);
|
||||
// if(winnersStr.contains(t.getName())) {
|
||||
// job.giveReward(true);
|
||||
// }
|
||||
// war.getServer().getScheduler().scheduleAsyncDelayedTask(war, job, 1);
|
||||
// fail
|
||||
tp.teleportTo(this.getTeleport());
|
||||
// don't reset inv of dead guy who caused this, he's gonna die becasue this takes too long so we'll restore inv at PLAYER_MOVE
|
||||
if(this.hasPlayerInventory(tp.getName())){
|
||||
this.restorePlayerInventory(tp);
|
||||
}
|
||||
}
|
||||
if(winnersStr.contains(t.getName())) {
|
||||
// give reward
|
||||
for(Integer slot : getReward().keySet()){
|
||||
tp.getInventory().addItem(getReward().get(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
t.setPoints(0);
|
||||
t.getPlayers().clear(); // empty the team
|
||||
}
|
||||
//
|
||||
// tp.teleportTo(this.getTeleport());
|
||||
// // don't reset inv of dead guy who caused this, he's gonna die becasue this takes too long so we'll restore inv at PLAYER_MOVE
|
||||
// if(this.hasPlayerInventory(tp.getName())){
|
||||
// this.restorePlayerInventory(tp);
|
||||
// }
|
||||
// }
|
||||
// if(winnersStr.contains(t.getName())) {
|
||||
// // give reward
|
||||
// for(Integer slot : getReward().keySet()){
|
||||
// tp.getInventory().addItem(getReward().get(slot));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// t.setPoints(0);
|
||||
// t.getPlayers().clear(); // empty the team
|
||||
// }
|
||||
if(this.getLobby() != null) {
|
||||
this.getLobby().getVolume().resetBlocks();
|
||||
this.getLobby().getVolume().resetBlocksAsJob();
|
||||
}
|
||||
this.getVolume().resetBlocks();
|
||||
this.initializeZone();
|
||||
this.getVolume().resetBlocksAsJob();
|
||||
this.initializeZoneAsJob(player);
|
||||
if(war.getWarHub() != null) {
|
||||
// TODO: test if warhub sign give the correct info despite the jobs
|
||||
war.getWarHub().resetZoneSign(this);
|
||||
}
|
||||
}
|
||||
@ -1150,6 +1158,7 @@ public class Warzone {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public Team getTeamByName(String name) {
|
||||
// for(Team team : getTeams()) {
|
||||
// if(team.getName().startsWith(name)) {
|
||||
|
@ -1,15 +1,5 @@
|
||||
package com.tommytony.war.jobs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.Dispenser;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.tommytony.war.volumes.Volume;
|
||||
|
||||
public class BlockResetJob implements Runnable {
|
||||
@ -21,123 +11,7 @@ public class BlockResetJob implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
int visitedBlocks = 0, noOfResetBlocks = 0, x = 0, y = 0, z = 0;
|
||||
int currentBlockId = 0;
|
||||
int oldBlockType = 0;
|
||||
volume.clearBlocksThatDontFloat();
|
||||
try {
|
||||
if(volume.hasTwoCorners() && volume.getBlockTypes() != null) {
|
||||
x = volume.getMinX();
|
||||
for(int i = 0; i < volume.getSizeX(); i++){
|
||||
y = volume.getMinY();
|
||||
for(int j = 0; j < volume.getSizeY(); j++){
|
||||
z = volume.getMinZ();
|
||||
for(int k = 0;k < volume.getSizeZ(); k++) {
|
||||
try {
|
||||
oldBlockType = volume.getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = volume.getBlockDatas()[i][j][k];
|
||||
Block currentBlock = volume.getWorld().getBlockAt(x, y, z);
|
||||
currentBlockId = currentBlock.getTypeId();
|
||||
if(currentBlockId != oldBlockType ||
|
||||
(currentBlockId == oldBlockType && currentBlock.getData() != oldBlockData ) ||
|
||||
(currentBlockId == oldBlockType && currentBlock.getData() == oldBlockData &&
|
||||
(oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()
|
||||
|| oldBlockType == Material.CHEST.getId() || oldBlockType == Material.DISPENSER.getId())
|
||||
)
|
||||
) {
|
||||
if(oldBlockType == Material.WALL_SIGN.getId()
|
||||
|| oldBlockType == Material.SIGN_POST.getId()) {
|
||||
// Signs
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
BlockState state = currentBlock.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign)state;
|
||||
String[] lines = volume.getSignLines().get("sign-" + i + "-" + j + "-" + k);
|
||||
if(lines != null && sign.getLines() != null) {
|
||||
if(lines.length>0)sign.setLine(0, lines[0]);
|
||||
if(lines.length>1)sign.setLine(1, lines[1]);
|
||||
if(lines.length>2)sign.setLine(2, lines[2]);
|
||||
if(lines.length>3)sign.setLine(3, lines[3]);
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
} else if(oldBlockType == Material.CHEST.getId()) {
|
||||
// Chests
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
BlockState state = currentBlock.getState();
|
||||
if(state instanceof Chest) {
|
||||
Chest chest = (Chest)state;
|
||||
List<ItemStack> contents = volume.getInvBlockContents().get("chest-" + i + "-" + j + "-" + k);
|
||||
if(contents != null) {
|
||||
int ii = 0;
|
||||
chest.getInventory().clear();
|
||||
for(ItemStack item : contents) {
|
||||
chest.getInventory().setItem(ii, item);
|
||||
ii++;
|
||||
}
|
||||
chest.update(true);
|
||||
}
|
||||
}
|
||||
} else if(oldBlockType == Material.DISPENSER.getId()) {
|
||||
// Dispensers
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
BlockState state = currentBlock.getState();
|
||||
if(state instanceof Dispenser) {
|
||||
Dispenser dispenser = (Dispenser)state;
|
||||
List<ItemStack> contents = volume.getInvBlockContents().get("dispenser-" + i + "-" + j + "-" + k);
|
||||
if(contents != null) {
|
||||
int ii = 0;
|
||||
dispenser.getInventory().clear();
|
||||
for(ItemStack item : contents) {
|
||||
dispenser.getInventory().setItem(ii, item);
|
||||
ii++;
|
||||
}
|
||||
dispenser.update(true);
|
||||
}
|
||||
}
|
||||
} else if(oldBlockType == Material.WOODEN_DOOR.getId() || oldBlockType == Material.IRON_DOOR_BLOCK.getId()){
|
||||
// Door blocks
|
||||
|
||||
// Check if is bottom door block
|
||||
if(j+1 < volume.getSizeY() && volume.getBlockTypes()[i][j+1][k] == oldBlockType) {
|
||||
// set both door blocks right away
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
Block blockAbove = volume.getWorld().getBlockAt(x, y+1, z);
|
||||
blockAbove.setType(Material.getMaterial(oldBlockType));
|
||||
blockAbove.setData(volume.getBlockDatas()[i][j+1][k]);
|
||||
}
|
||||
} else {
|
||||
// regular block
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
}
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
visitedBlocks++;
|
||||
} catch (Exception e) {
|
||||
volume.getWar().getLogger().warning("Failed to reset block in volume " + volume.getName() + ". Visited blocks so far:" + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||
". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
z++;
|
||||
}
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
volume.getWar().logWarn("Failed to reset volume " + volume.getName() + " blocks. Blocks visited: " + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z
|
||||
+ ". Current block: " + currentBlockId + ". Old block: " + oldBlockType + ". Exception: " + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
volume.resetBlocks();
|
||||
}
|
||||
|
||||
}
|
||||
|
27
war/src/main/java/com/tommytony/war/jobs/InitZoneJob.java
Normal file
27
war/src/main/java/com/tommytony/war/jobs/InitZoneJob.java
Normal file
@ -0,0 +1,27 @@
|
||||
package com.tommytony.war.jobs;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
public class InitZoneJob implements Runnable {
|
||||
|
||||
private final Warzone zone;
|
||||
private final Player respawnExempted;
|
||||
|
||||
public InitZoneJob(Warzone zone) {
|
||||
this.zone = zone;
|
||||
respawnExempted = null;
|
||||
}
|
||||
|
||||
public InitZoneJob(Warzone warzone, Player respawnExempted) {
|
||||
zone = warzone;
|
||||
this.respawnExempted = respawnExempted;
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void run() {
|
||||
zone.initializeZone(respawnExempted);
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +1,39 @@
|
||||
package com.tommytony.war.jobs;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
public class ScoreCapReachedJob implements Runnable {
|
||||
|
||||
private final Player player;
|
||||
private final Warzone zone;
|
||||
private boolean giveReward;
|
||||
private final String winnersStr;
|
||||
|
||||
public ScoreCapReachedJob(Player player, Warzone zone) {
|
||||
this.player = player;
|
||||
public ScoreCapReachedJob(Warzone zone, String winnersStr) {
|
||||
this.zone = zone;
|
||||
this.winnersStr = winnersStr;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
player.teleportTo(zone.getTeleport());
|
||||
// don't reset inv of dead guy who caused this, he's gonna die becasue this takes too long so we'll restore inv at PLAYER_MOVE
|
||||
if(zone.hasPlayerInventory(player.getName())){
|
||||
zone.restorePlayerInventory(player);
|
||||
}
|
||||
if(giveReward) {
|
||||
// give reward
|
||||
for(Integer slot : zone.getReward().keySet()){
|
||||
player.getInventory().addItem(zone.getReward().get(slot));
|
||||
for(Team t : zone.getTeams()) {
|
||||
t.teamcast(winnersStr);
|
||||
for(Player tp : t.getPlayers()) {
|
||||
tp.teleportTo(zone.getTeleport()); // TODO: change this to a more general rally point (which will enable linking zones together)
|
||||
if(zone.hasPlayerInventory(tp.getName())){
|
||||
zone.restorePlayerInventory(tp);
|
||||
}
|
||||
if(winnersStr.contains(t.getName())) {
|
||||
// give reward
|
||||
for(Integer slot : zone.getReward().keySet()){
|
||||
tp.getInventory().addItem(zone.getReward().get(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
t.setPoints(0);
|
||||
t.getPlayers().clear(); // empty the team
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,10 +139,12 @@ public class Volume {
|
||||
return noOfSavedBlocks;
|
||||
}
|
||||
|
||||
public void resetBlocksAsJob() {
|
||||
BlockResetJob job = new BlockResetJob(this);
|
||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
|
||||
}
|
||||
|
||||
public int resetBlocks() {
|
||||
// BlockResetJob job = new BlockResetJob(this);
|
||||
// war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
|
||||
// return 0;
|
||||
int visitedBlocks = 0, noOfResetBlocks = 0, x = 0, y = 0, z = 0;
|
||||
int currentBlockId = 0;
|
||||
int oldBlockType = 0;
|
||||
@ -478,8 +480,6 @@ public class Volume {
|
||||
Material[] toAirMaterials = new Material[22];
|
||||
toAirMaterials[0] = Material.SIGN_POST;
|
||||
toAirMaterials[1] = Material.WALL_SIGN;
|
||||
//toAirMaterials[2] = Material.IRON_DOOR_BLOCK;
|
||||
//toAirMaterials[3] = Material.WOODEN_DOOR;
|
||||
toAirMaterials[2] = Material.IRON_DOOR;
|
||||
toAirMaterials[3] = Material.WOOD_DOOR;
|
||||
toAirMaterials[4] = Material.LADDER;
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: War
|
||||
version: 1.2.1 (Bradley)
|
||||
version: 1.3 (Rokossovsky)
|
||||
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
|
||||
author: tommytony
|
||||
website: war.tommytony.com
|
||||
@ -108,6 +108,9 @@ commands:
|
||||
- /setzoneconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on
|
||||
- /setzoneconfig loadout:default => sets the respawn inventory to your current items
|
||||
- /setzoneconfig reward:default => sets the winner's reward to your current items
|
||||
zonecfg:
|
||||
description: (War) Alias for /setzoneconfig
|
||||
usage:
|
||||
zonemaker:
|
||||
description: (War) Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
|
||||
usage:
|
||||
@ -120,7 +123,7 @@ commands:
|
||||
deletewarhub:
|
||||
description: (War) Deletes the warhub if it exists. Resets all warzone lobbies.
|
||||
usage: /deletewarhub
|
||||
# 4- Defaults
|
||||
# 4- Defaults and server configuration
|
||||
setwarconfig:
|
||||
description: (War) Change gobal settings and the default warzone configuration values.
|
||||
usage:
|
||||
@ -128,6 +131,9 @@ commands:
|
||||
- /setwarconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on => Warzone defaults
|
||||
- /setwarconfig loadout:default => sets the respawn inventory to your current items
|
||||
- /setwarconfig reward:default => sets the winner's reward to your current items
|
||||
warcfg:
|
||||
description: (War) Alias for /setwarconfig
|
||||
usage:
|
||||
# Fallback
|
||||
war:
|
||||
description: (War) Short War help. Can also be used as a prefix for all War commands as a fallback if they conflict with other plugins.
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: War
|
||||
version: 1.2.1 (Bradley)
|
||||
version: 1.3 (Rokossovsky)
|
||||
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
|
||||
author: tommytony
|
||||
website: war.tommytony.com
|
||||
@ -108,6 +108,9 @@ commands:
|
||||
- /setzoneconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on
|
||||
- /setzoneconfig loadout:default => sets the respawn inventory to your current items
|
||||
- /setzoneconfig reward:default => sets the winner's reward to your current items
|
||||
zonecfg:
|
||||
description: (War) Alias for /setzoneconfig
|
||||
usage:
|
||||
zonemaker:
|
||||
description: (War) Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
|
||||
usage:
|
||||
@ -120,7 +123,7 @@ commands:
|
||||
deletewarhub:
|
||||
description: (War) Deletes the warhub if it exists. Resets all warzone lobbies.
|
||||
usage: /deletewarhub
|
||||
# 4- Defaults
|
||||
# 4- Defaults and server configuration
|
||||
setwarconfig:
|
||||
description: (War) Change gobal settings and the default warzone configuration values.
|
||||
usage:
|
||||
@ -128,6 +131,9 @@ commands:
|
||||
- /setwarconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on => Warzone defaults
|
||||
- /setwarconfig loadout:default => sets the respawn inventory to your current items
|
||||
- /setwarconfig reward:default => sets the winner's reward to your current items
|
||||
warcfg:
|
||||
description: (War) Alias for /setwarconfig
|
||||
usage:
|
||||
# Fallback
|
||||
war:
|
||||
description: (War) Short War help. Can also be used as a prefix for all War commands as a fallback if they conflict with other plugins.
|
||||
|
Loading…
Reference in New Issue
Block a user