mirror of
https://github.com/taoneill/war.git
synced 2024-11-30 14:13:23 +01:00
Added Permissions support. Trying everything to get gates and teleports in player_move working again to no avail.
This commit is contained in:
parent
b45af8cad0
commit
06ba048797
@ -4,5 +4,6 @@
|
|||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||||
<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="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginLoader;
|
import org.bukkit.plugin.PluginLoader;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -31,12 +32,15 @@ import java.util.Map;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class War extends JavaPlugin {
|
public class War extends JavaPlugin {
|
||||||
|
public static Permissions Permissions = null;
|
||||||
|
|
||||||
public War(PluginLoader pluginLoader, Server instance,
|
public War(PluginLoader pluginLoader, Server instance,
|
||||||
PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
|
PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
|
||||||
@ -45,7 +49,6 @@ public class War extends JavaPlugin {
|
|||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private WarPlayerListener playerListener = new WarPlayerListener(this);
|
private WarPlayerListener playerListener = new WarPlayerListener(this);
|
||||||
private WarEntityListener entityListener = new WarEntityListener(this);
|
private WarEntityListener entityListener = new WarEntityListener(this);
|
||||||
private WarBlockListener blockListener = new WarBlockListener(this);
|
private WarBlockListener blockListener = new WarBlockListener(this);
|
||||||
@ -88,7 +91,7 @@ public class War extends JavaPlugin {
|
|||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.log = Logger.getLogger("Minecraft");
|
this.log = Logger.getLogger("Minecraft");
|
||||||
|
this.setupPermissions();
|
||||||
|
|
||||||
// Register hooks
|
// Register hooks
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
@ -185,7 +188,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// /join <teamname>
|
// /join <teamname>
|
||||||
else if(command.equals("join")) {
|
else if(command.equals("join") && canPlayWar(player)) {
|
||||||
if(arguments.length < 1 || (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation()))
|
if(arguments.length < 1 || (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation()))
|
||||||
|| (arguments.length > 0 && TeamMaterials.teamMaterialFromString(arguments[0]) == null)) {
|
|| (arguments.length > 0 && TeamMaterials.teamMaterialFromString(arguments[0]) == null)) {
|
||||||
player.sendMessage(this.str("Usage: /join <diamond/iron/gold/d/i/g>." +
|
player.sendMessage(this.str("Usage: /join <diamond/iron/gold/d/i/g>." +
|
||||||
@ -267,11 +270,11 @@ public class War extends JavaPlugin {
|
|||||||
|
|
||||||
// /team <msg>
|
// /team <msg>
|
||||||
else if(command.equals("team")) {
|
else if(command.equals("team")) {
|
||||||
if(!this.inAnyWarzone(player.getLocation())) {
|
Team playerTeam = this.getPlayerTeam(player.getName());
|
||||||
|
if(!this.inAnyWarzone(player.getLocation()) && playerTeam != null) {
|
||||||
player.sendMessage(this.str("Usage: /team <message>. " +
|
player.sendMessage(this.str("Usage: /team <message>. " +
|
||||||
"Sends a message only to your teammates."));
|
"Sends a message only to your teammates."));
|
||||||
} else {
|
} else {
|
||||||
Team playerTeam = this.getPlayerTeam(player.getName());
|
|
||||||
ChatColor color = null;
|
ChatColor color = null;
|
||||||
if(playerTeam.getMaterial() == TeamMaterials.TEAMDIAMOND) {
|
if(playerTeam.getMaterial() == TeamMaterials.TEAMDIAMOND) {
|
||||||
color = ChatColor.DARK_AQUA;
|
color = ChatColor.DARK_AQUA;
|
||||||
@ -295,7 +298,7 @@ public class War extends JavaPlugin {
|
|||||||
player.sendMessage("No warhub on this War server. Try /zones and /zone.");
|
player.sendMessage("No warhub on this War server. Try /zones and /zone.");
|
||||||
} else {
|
} else {
|
||||||
Team playerTeam = this.getPlayerTeam(player.getName());
|
Team playerTeam = this.getPlayerTeam(player.getName());
|
||||||
Warzone playerWarzone = getPlayerWarzone(player.getName());
|
Warzone playerWarzone = getPlayerTeamWarzone(player.getName());
|
||||||
if(playerTeam != null) { // was in zone
|
if(playerTeam != null) { // was in zone
|
||||||
playerTeam.removePlayer(player.getName());
|
playerTeam.removePlayer(player.getName());
|
||||||
}
|
}
|
||||||
@ -306,7 +309,7 @@ public class War extends JavaPlugin {
|
|||||||
player.teleportTo(this.getWarHub().getLocation());
|
player.teleportTo(this.getWarHub().getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(this.isZoneMaker(player.getName())) {
|
} else if(this.isZoneMaker(player)) {
|
||||||
// Mod commands : /nextbattle
|
// Mod commands : /nextbattle
|
||||||
|
|
||||||
// /nextbattle
|
// /nextbattle
|
||||||
@ -988,7 +991,7 @@ public class War extends JavaPlugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Warzone getPlayerWarzone(String playerName) {
|
public Warzone getPlayerTeamWarzone(String playerName) {
|
||||||
for(Warzone warzone : warzones) {
|
for(Warzone warzone : warzones) {
|
||||||
Team team = warzone.getPlayerTeam(playerName);
|
Team team = warzone.getPlayerTeam(playerName);
|
||||||
if(team != null) return warzone;
|
if(team != null) return warzone;
|
||||||
@ -1093,9 +1096,23 @@ public class War extends JavaPlugin {
|
|||||||
return zoneMakerNames;
|
return zoneMakerNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isZoneMaker(String playerName) {
|
public boolean canPlayWar(Player player) {
|
||||||
|
if(Permissions != null && Permissions.Security.permission(player, "war.player")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(Permissions == null) {
|
||||||
|
// w/o Permissions, everyone can play
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isZoneMaker(Player player) {
|
||||||
for(String zoneMaker : zoneMakerNames) {
|
for(String zoneMaker : zoneMakerNames) {
|
||||||
if(zoneMaker.equals(playerName)) return true;
|
if(zoneMaker.equals(player.getName())) return true;
|
||||||
|
}
|
||||||
|
if(Permissions != null && Permissions.Security.permission(player, "war.*")) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1184,4 +1201,16 @@ public class War extends JavaPlugin {
|
|||||||
return zoneMakersImpersonatingPlayers;
|
return zoneMakersImpersonatingPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setupPermissions() {
|
||||||
|
Plugin test = this.getServer().getPluginManager().getPlugin("Permissions");
|
||||||
|
|
||||||
|
if(this.Permissions == null) {
|
||||||
|
if(test != null) {
|
||||||
|
this.Permissions = (Permissions)test;
|
||||||
|
} else {
|
||||||
|
info(str("Permission system not enabled. Defaulting to regular War config."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ public class WarBlockListener extends BlockListener {
|
|||||||
boolean captured = false;
|
boolean captured = false;
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
Team team = war.getPlayerTeam(player.getName());
|
Team team = war.getPlayerTeam(player.getName());
|
||||||
Warzone zone = war.getPlayerWarzone(player.getName());
|
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||||
boolean isZoneMaker = war.isZoneMaker(player.getName());
|
boolean isZoneMaker = war.isZoneMaker(player);
|
||||||
if(team != null && block != null && zone != null
|
if(team != null && block != null && zone != null
|
||||||
&& zone.isMonumentCenterBlock(block)
|
&& zone.isMonumentCenterBlock(block)
|
||||||
&& block.getType() == team.getMaterial()) {
|
&& block.getType() == team.getMaterial()) {
|
||||||
@ -75,7 +75,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
if(player != null && block != null && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
|
if(player != null && block != null && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
|
||||||
Warzone warzone = war.warzone(player.getLocation());
|
Warzone warzone = war.warzone(player.getLocation());
|
||||||
Team team = war.getPlayerTeam(player.getName());
|
Team team = war.getPlayerTeam(player.getName());
|
||||||
boolean isZoneMaker = war.isZoneMaker(player.getName());
|
boolean isZoneMaker = war.isZoneMaker(player);
|
||||||
|
|
||||||
if(warzone != null && war.getPlayerTeam(player.getName()) == null && !isZoneMaker) {
|
if(warzone != null && war.getPlayerTeam(player.getName()) == null && !isZoneMaker) {
|
||||||
// can't actually destroy blocks in a warzone if not part of a team
|
// can't actually destroy blocks in a warzone if not part of a team
|
||||||
|
@ -35,10 +35,9 @@ public class WarEntityListener extends EntityListener {
|
|||||||
|
|
||||||
if(defender instanceof Player) {
|
if(defender instanceof Player) {
|
||||||
Player d = (Player)defender;
|
Player d = (Player)defender;
|
||||||
synchronized(defender) {
|
|
||||||
if(event.getDamage() >= d.getHealth()) {
|
if(event.getDamage() >= d.getHealth()) {
|
||||||
// Player died
|
// Player died
|
||||||
Warzone defenderWarzone = war.getPlayerWarzone(d.getName());
|
Warzone defenderWarzone = war.getPlayerTeamWarzone(d.getName());
|
||||||
Team defenderTeam = war.getPlayerTeam(d.getName());
|
Team defenderTeam = war.getPlayerTeam(d.getName());
|
||||||
if(defenderTeam != null) {
|
if(defenderTeam != null) {
|
||||||
|
|
||||||
@ -47,53 +46,9 @@ public class WarEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void onEntityDamaged(EntityDamagedEvent event) {
|
|
||||||
// Entity damaged = event.getEntity();
|
|
||||||
// DamageCause cause = event.getCause();
|
|
||||||
// if(damaged != null && damaged instanceof Player){
|
|
||||||
// Player player = (Player)damaged;
|
|
||||||
// int damage = event.getDamage();
|
|
||||||
// int currentPlayerHp = player.getHealth();
|
|
||||||
// if(damage >= currentPlayerHp) {
|
|
||||||
// Warzone zone = war.warzone(player.getLocation());
|
|
||||||
// if(war.getPlayerTeam(player.getName()) != null) {
|
|
||||||
// // player on a team killed himself
|
|
||||||
// handleDeath(((Player)damaged));
|
|
||||||
//
|
|
||||||
// } else if (zone != null ) {
|
|
||||||
// player.teleportTo(zone.getTeleport());
|
|
||||||
// }
|
|
||||||
// event.setCancelled(true); // Don't totally kill the player
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void onEntityDamagedByBlock(EntityDamagedByBlockEvent event) {
|
|
||||||
// Entity damaged = event.getEntity();
|
|
||||||
//
|
|
||||||
// if(damaged != null && damaged instanceof Player){
|
|
||||||
// Player player = (Player)damaged;
|
|
||||||
// int damage = event.getDamage();
|
|
||||||
// int currentPlayerHp = player.getHealth();
|
|
||||||
// if(damage >= currentPlayerHp) {
|
|
||||||
// Warzone zone = war.warzone(player.getLocation());
|
|
||||||
// if(war.getPlayerTeam(player.getName()) != null) {
|
|
||||||
// // player on a team killed himself
|
|
||||||
// handleDeath(((Player)damaged));
|
|
||||||
//
|
|
||||||
// } else if (zone != null ) {
|
|
||||||
// player.teleportTo(zone.getTeleport());
|
|
||||||
// }
|
|
||||||
// event.setCancelled(true); // Don't let the block totally kill the player
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
Entity attacker = event.getDamager();
|
Entity attacker = event.getDamager();
|
||||||
Entity defender = event.getEntity();
|
Entity defender = event.getEntity();
|
||||||
@ -102,16 +57,16 @@ public class WarEntityListener extends EntityListener {
|
|||||||
// only let adversaries (same warzone, different team) attack each other
|
// only let adversaries (same warzone, different team) attack each other
|
||||||
Player a = (Player)attacker;
|
Player a = (Player)attacker;
|
||||||
Player d = (Player)defender;
|
Player d = (Player)defender;
|
||||||
Warzone attackerWarzone = war.getPlayerWarzone(a.getName());
|
Warzone attackerWarzone = war.getPlayerTeamWarzone(a.getName());
|
||||||
Team attackerTeam = war.getPlayerTeam(a.getName());
|
Team attackerTeam = war.getPlayerTeam(a.getName());
|
||||||
Warzone defenderWarzone = war.getPlayerWarzone(d.getName());
|
Warzone defenderWarzone = war.getPlayerTeamWarzone(d.getName());
|
||||||
Team defenderTeam = war.getPlayerTeam(d.getName());
|
Team defenderTeam = war.getPlayerTeam(d.getName());
|
||||||
if(attackerTeam != null && defenderTeam != null
|
if(attackerTeam != null && defenderTeam != null
|
||||||
&& attackerTeam != defenderTeam
|
&& attackerTeam != defenderTeam
|
||||||
&& attackerWarzone == defenderWarzone) {
|
&& attackerWarzone == defenderWarzone) {
|
||||||
// A real attack: handle death scenario. ==> now handled in entity damage as well
|
// A real attack: handle death scenario. ==> now handled in entity damage as well
|
||||||
synchronized(d) {
|
//synchronized(d) {
|
||||||
if(event.getDamage() >= d.getHealth()) {
|
if(d.getHealth() <= 0) {
|
||||||
// // Player died, loot him!
|
// // Player died, loot him!
|
||||||
// PlayerInventory attackerInv = a.getInventory();
|
// PlayerInventory attackerInv = a.getInventory();
|
||||||
// PlayerInventory defenderInv = d.getInventory();
|
// PlayerInventory defenderInv = d.getInventory();
|
||||||
@ -132,7 +87,7 @@ public class WarEntityListener extends EntityListener {
|
|||||||
handleDeath(d, defenderWarzone, defenderTeam);
|
handleDeath(d, defenderWarzone, defenderTeam);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
} else if (attackerTeam != null && defenderTeam != null
|
} else if (attackerTeam != null && defenderTeam != null
|
||||||
&& attackerTeam == defenderTeam
|
&& attackerTeam == defenderTeam
|
||||||
&& attackerWarzone == defenderWarzone) {
|
&& attackerWarzone == defenderWarzone) {
|
||||||
|
@ -39,7 +39,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Team team = war.getPlayerTeam(player.getName());
|
Team team = war.getPlayerTeam(player.getName());
|
||||||
if(team != null) {
|
if(team != null) {
|
||||||
Warzone zone = war.getPlayerWarzone(player.getName());
|
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||||
if(zone != null && zone.hasPlayerInventory(player.getName())) {
|
if(zone != null && zone.hasPlayerInventory(player.getName())) {
|
||||||
player.teleportTo(zone.getTeleport());
|
player.teleportTo(zone.getTeleport());
|
||||||
zone.restorePlayerInventory(player);
|
zone.restorePlayerInventory(player);
|
||||||
@ -59,11 +59,20 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
synchronized(player) {
|
Location from = event.getFrom();
|
||||||
|
Warzone locZone = null;
|
||||||
|
ZoneLobby locLobby = null;
|
||||||
|
if(from != null) {
|
||||||
|
locZone = war.warzone(from);
|
||||||
|
locLobby = war.lobby(from);
|
||||||
|
}
|
||||||
|
// synchronized(player) {
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
|
boolean canPlay = war.canPlayWar(player);
|
||||||
|
boolean isMaker = war.isZoneMaker(player);
|
||||||
|
|
||||||
// Zone walls
|
// Zone walls
|
||||||
if(to != null && !war.isZoneMaker(player.getName())) { // zone makers don't get bothered with guard walls
|
if(!isMaker && to != null) { // zone makers don't get bothered with guard walls
|
||||||
Warzone nearbyZone = war.zoneOfZoneWallAtProximity(to);
|
Warzone nearbyZone = war.zoneOfZoneWallAtProximity(to);
|
||||||
if(nearbyZone != null) {
|
if(nearbyZone != null) {
|
||||||
nearbyZone.protectZoneWallAgainstPlayer(player);
|
nearbyZone.protectZoneWallAgainstPlayer(player);
|
||||||
@ -75,16 +84,21 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Warzone playerWarzone = war.getPlayerWarzone(player.getName()); // this uses the teams, so it asks: get the player's team's warzone, to be clearer
|
Warzone playerWarzone = war.getPlayerTeamWarzone(player.getName());
|
||||||
|
// this uses the teams, so it asks: get the player's team's warzone, to be clearer
|
||||||
|
|
||||||
boolean enteredGate = false;
|
boolean enteredGate = false;
|
||||||
if(to != null) {
|
|
||||||
// Warzone lobby gates
|
// Warzone lobby gates
|
||||||
for(Warzone zone : war.getWarzones()){
|
if(locLobby != null && to != null) {
|
||||||
if(zone.getLobby() != null) {
|
Warzone zone = locLobby.getZone();
|
||||||
Team oldTeam = war.getPlayerTeam(player.getName());
|
Team oldTeam = war.getPlayerTeam(player.getName());
|
||||||
if(oldTeam == null) { // trying to counter spammy player move
|
boolean isAutoAssignGate = false;
|
||||||
if(zone.getLobby().isAutoAssignGate(to)) {
|
boolean isDiamondGate = false;
|
||||||
|
boolean isIronGate = false;
|
||||||
|
boolean isGoldGate = false;
|
||||||
|
if(oldTeam == null && canPlay) { // trying to counter spammy player move
|
||||||
|
isAutoAssignGate = zone.getLobby().isAutoAssignGate(to);
|
||||||
|
if(isAutoAssignGate) {
|
||||||
enteredGate = true;
|
enteredGate = true;
|
||||||
dropFromOldTeamIfAny(player);
|
dropFromOldTeamIfAny(player);
|
||||||
int noOfPlayers = 0;
|
int noOfPlayers = 0;
|
||||||
@ -92,16 +106,20 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
noOfPlayers += t.getPlayers().size();
|
noOfPlayers += t.getPlayers().size();
|
||||||
}
|
}
|
||||||
if(noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
|
if(noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
|
||||||
//zone.autoAssign(event, player);
|
zone.autoAssign(event, player);
|
||||||
zone.autoAssign(player);
|
//zone.autoAssign(player);
|
||||||
event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
//event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
player.teleportTo(zone.getTeleport());
|
//player.teleportTo(zone.getTeleport());
|
||||||
event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
player.sendMessage("All teams are full.");
|
player.sendMessage("All teams are full.");
|
||||||
}
|
}
|
||||||
} else if (zone.getLobby().isInTeamGate(TeamMaterials.TEAMDIAMOND, to)){
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isDiamondGate = zone.getLobby().isInTeamGate(TeamMaterials.TEAMDIAMOND, to);
|
||||||
|
if (isDiamondGate){
|
||||||
enteredGate = true;
|
enteredGate = true;
|
||||||
dropFromOldTeamIfAny(player);
|
dropFromOldTeamIfAny(player);
|
||||||
Team diamondTeam = zone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND);
|
Team diamondTeam = zone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND);
|
||||||
@ -110,19 +128,23 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
diamondTeam.resetSign();
|
diamondTeam.resetSign();
|
||||||
zone.keepPlayerInventory(player);
|
zone.keepPlayerInventory(player);
|
||||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||||
//zone.respawnPlayer(event, diamondTeam, player);
|
zone.respawnPlayer(event, diamondTeam, player);
|
||||||
zone.respawnPlayer(diamondTeam, player);
|
//zone.respawnPlayer(diamondTeam, player);
|
||||||
event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
for(Team team : zone.getTeams()){
|
for(Team team : zone.getTeams()){
|
||||||
team.teamcast(war.str("" + player.getName() + " joined team diamond."));
|
team.teamcast(war.str("" + player.getName() + " joined team diamond."));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
player.teleportTo(zone.getTeleport());
|
//player.teleportTo(zone.getTeleport());
|
||||||
event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
player.sendMessage("Team diamond is full.");
|
player.sendMessage("Team diamond is full.");
|
||||||
}
|
}
|
||||||
} else if (zone.getLobby().isInTeamGate(TeamMaterials.TEAMIRON, to)){
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isIronGate = zone.getLobby().isInTeamGate(TeamMaterials.TEAMIRON, to);
|
||||||
|
if (isIronGate){
|
||||||
enteredGate = true;
|
enteredGate = true;
|
||||||
dropFromOldTeamIfAny(player);
|
dropFromOldTeamIfAny(player);
|
||||||
Team ironTeam = zone.getTeamByMaterial(TeamMaterials.TEAMIRON);
|
Team ironTeam = zone.getTeamByMaterial(TeamMaterials.TEAMIRON);
|
||||||
@ -131,19 +153,23 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
ironTeam.resetSign();
|
ironTeam.resetSign();
|
||||||
zone.keepPlayerInventory(player);
|
zone.keepPlayerInventory(player);
|
||||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||||
//zone.respawnPlayer(event, ironTeam, player);
|
zone.respawnPlayer(event, ironTeam, player);
|
||||||
zone.respawnPlayer(ironTeam, player);
|
// zone.respawnPlayer(ironTeam, player);
|
||||||
event.setCancelled(true);
|
// event.setCancelled(true);
|
||||||
for(Team team : zone.getTeams()){
|
for(Team team : zone.getTeams()){
|
||||||
team.teamcast(war.str("" + player.getName() + " joined team iron."));
|
team.teamcast(war.str("" + player.getName() + " joined team iron."));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
player.teleportTo(zone.getTeleport());
|
// player.teleportTo(zone.getTeleport());
|
||||||
event.setCancelled(true);
|
// event.setCancelled(true);
|
||||||
player.sendMessage("Team iron is full.");
|
player.sendMessage("Team iron is full.");
|
||||||
}
|
}
|
||||||
} else if (zone.getLobby().isInTeamGate(TeamMaterials.TEAMGOLD, to)){
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isGoldGate = zone.getLobby().isInTeamGate(TeamMaterials.TEAMGOLD, to);
|
||||||
|
if (isGoldGate){
|
||||||
enteredGate = true;
|
enteredGate = true;
|
||||||
dropFromOldTeamIfAny(player);
|
dropFromOldTeamIfAny(player);
|
||||||
Team goldTeam = zone.getTeamByMaterial(TeamMaterials.TEAMGOLD);
|
Team goldTeam = zone.getTeamByMaterial(TeamMaterials.TEAMGOLD);
|
||||||
@ -152,52 +178,46 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
goldTeam.resetSign();
|
goldTeam.resetSign();
|
||||||
zone.keepPlayerInventory(player);
|
zone.keepPlayerInventory(player);
|
||||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||||
//zone.respawnPlayer(event, goldTeam, player);
|
zone.respawnPlayer(event, goldTeam, player);
|
||||||
zone.respawnPlayer(goldTeam, player);
|
//zone.respawnPlayer(goldTeam, player);
|
||||||
event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
for(Team team : zone.getTeams()){
|
for(Team team : zone.getTeams()){
|
||||||
team.teamcast(war.str("" + player.getName() + " joined team gold."));
|
team.teamcast(war.str("" + player.getName() + " joined team gold."));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
player.teleportTo(zone.getTeleport());
|
// player.teleportTo(zone.getTeleport());
|
||||||
event.setCancelled(true);
|
// event.setCancelled(true);
|
||||||
player.sendMessage("Team gold is full.");
|
player.sendMessage("Team gold is full.");
|
||||||
}
|
}
|
||||||
} else if (zone.getLobby().isInWarHubLinkGate(to)){
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zone.getLobby().isInWarHubLinkGate(to)){
|
||||||
enteredGate = true;
|
enteredGate = true;
|
||||||
dropFromOldTeamIfAny(player);
|
dropFromOldTeamIfAny(player);
|
||||||
//event.setTo(war.getWarHub().getLocation());
|
event.setTo(war.getWarHub().getLocation());
|
||||||
player.teleportTo(war.getWarHub().getLocation());
|
// player.teleportTo(war.getWarHub().getLocation());
|
||||||
event.setCancelled(true);
|
// event.setCancelled(true);
|
||||||
player.sendMessage(war.str("Welcome to the War hub."));
|
player.sendMessage(war.str("Welcome to the War hub."));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if(zone.getLobby().isLeavingZone(to)) { // already in a team and in warzone, leaving
|
} else if ((isAutoAssignGate || isDiamondGate || isGoldGate || isIronGate) &&
|
||||||
enteredGate = true;
|
!canPlay) {
|
||||||
// same as leave, except event.setTo
|
event.setTo(zone.getTeleport());
|
||||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
// player.teleportTo(zone.getTeleport());
|
||||||
playerTeam.removePlayer(player.getName());
|
// event.setCancelled(true);
|
||||||
playerTeam.resetSign();
|
player.sendMessage(war.str("You don't have permission to play War. Ask a mod, please."));
|
||||||
//event.setTo(playerWarzone.getTeleport());
|
return;
|
||||||
player.teleportTo(zone.getTeleport());
|
|
||||||
event.setCancelled(true);
|
|
||||||
playerWarzone.restorePlayerInventory(player);
|
|
||||||
if(playerWarzone.getLobby() != null) {
|
|
||||||
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
|
|
||||||
}
|
|
||||||
player.sendMessage(war.str("Left the zone. Your inventory has (hopefully) been restored."));
|
|
||||||
if(war.getWarHub() != null) {
|
|
||||||
war.getWarHub().resetZoneSign(zone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warhub zone gates
|
// Warhub zone gates
|
||||||
WarHub hub = war.getWarHub();
|
WarHub hub = war.getWarHub();
|
||||||
if(hub != null) {
|
if(hub != null && from != null && to != null && hub.getVolume().contains(from)) {
|
||||||
Warzone zone = hub.getDestinationWarzoneForLocation(to);
|
Warzone zone = hub.getDestinationWarzoneForLocation(to);
|
||||||
synchronized(player) {
|
//synchronized(player) {
|
||||||
if(zone != null) {
|
if(zone != null) {
|
||||||
enteredGate = true;
|
enteredGate = true;
|
||||||
event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
@ -205,7 +225,31 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
//
|
//
|
||||||
// event.setCancelled(true);
|
// event.setCancelled(true);
|
||||||
player.sendMessage(war.str("Welcome to warzone " + zone.getName() + "."));
|
player.sendMessage(war.str("Welcome to warzone " + zone.getName() + "."));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(locZone != null && to != null && locZone.getLobby() != null
|
||||||
|
&& locZone.getLobby().isLeavingZone(to)) { // already in a team and in warzone, leaving
|
||||||
|
enteredGate = true;
|
||||||
|
// same as leave, except event.setTo
|
||||||
|
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||||
|
if(playerTeam != null) {
|
||||||
|
playerTeam.removePlayer(player.getName());
|
||||||
|
playerTeam.resetSign();
|
||||||
|
event.setTo(playerWarzone.getTeleport());
|
||||||
|
// player.teleportTo(zone.getTeleport());
|
||||||
|
// event.setCancelled(true);
|
||||||
|
playerWarzone.restorePlayerInventory(player);
|
||||||
|
if(playerWarzone.getLobby() != null) {
|
||||||
|
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
|
||||||
|
}
|
||||||
|
player.sendMessage(war.str("Left the zone. Your inventory has (hopefully) been restored."));
|
||||||
|
if(war.getWarHub() != null) {
|
||||||
|
war.getWarHub().resetZoneSign(locZone);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,12 +257,12 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
Team team = war.getPlayerTeam(player.getName());
|
Team team = war.getPlayerTeam(player.getName());
|
||||||
|
|
||||||
// Player belongs to a warzone team but is outside: he snuck out!.
|
// Player belongs to a warzone team but is outside: he snuck out!.
|
||||||
if(war.warzone(to) == null && team != null) {
|
if(locZone == null && team != null) {
|
||||||
//player.sendMessage(war.str("Teleporting you back to spawn. Please /leave your team if you want to exit the zone."));
|
//player.sendMessage(war.str("Teleporting you back to spawn. Please /leave your team if you want to exit the zone."));
|
||||||
//event.setTo(team.getTeamSpawn());
|
event.setTo(team.getTeamSpawn());
|
||||||
playerWarzone.respawnPlayer(team, player);
|
//playerWarzone.respawnPlayer(team, player);
|
||||||
//player.teleportTo(team.getTeamSpawn());
|
//player.teleportTo(team.getTeamSpawn());
|
||||||
event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monuments
|
// Monuments
|
||||||
@ -229,17 +273,17 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain full health!"));
|
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain full health!"));
|
||||||
}
|
}
|
||||||
} else if (!enteredGate && war.inAnyWarzone(to) && !war.warzone(to).getLobby().isLeavingZone(to) && !war.isZoneMaker(player.getName())) { // player is not in any team, but inside warzone boundaries, get him out
|
} else if (locZone != null && locZone.getLobby() != null
|
||||||
|
&& locZone.getLobby().isLeavingZone(to) && !isMaker) {
|
||||||
|
// player is not in any team, but inside warzone boundaries, get him out
|
||||||
Warzone zone = war.warzone(to);
|
Warzone zone = war.warzone(to);
|
||||||
//event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
player.teleportTo(zone.getTeleport());
|
// player.teleportTo(zone.getTeleport());
|
||||||
event.setCancelled(true);
|
// event.setCancelled(true);
|
||||||
//player.sendMessage(war.str("You can't be inside a warzone without a team."));
|
//player.sendMessage(war.str("You can't be inside a warzone without a team."));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dropFromOldTeamIfAny(Player player) {
|
private void dropFromOldTeamIfAny(Player player) {
|
||||||
// drop from old team if any
|
// drop from old team if any
|
||||||
|
@ -40,8 +40,9 @@ public class VolumeMapper {
|
|||||||
public static void load(Volume volume, String zoneName, War war, World world) {
|
public static void load(Volume volume, String zoneName, War war, World world) {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try {
|
try {
|
||||||
if(zoneName.equals("")) in = new BufferedReader(new FileReader(new File("War/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
if(zoneName.equals("")) in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() +
|
||||||
else in = new BufferedReader(new FileReader(new File("War/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
"/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
||||||
|
else in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
String firstLine = in.readLine();
|
String firstLine = in.readLine();
|
||||||
if(firstLine != null && !firstLine.equals("")) {
|
if(firstLine != null && !firstLine.equals("")) {
|
||||||
int x1 = Integer.parseInt(in.readLine());
|
int x1 = Integer.parseInt(in.readLine());
|
||||||
@ -109,8 +110,9 @@ public class VolumeMapper {
|
|||||||
if(volume.isSaved() && volume.getBlockTypes() != null) {
|
if(volume.isSaved() && volume.getBlockTypes() != null) {
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
try {
|
try {
|
||||||
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File("War/dat/volume-" + volume.getName() + ".dat")));
|
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||||
else out = new BufferedWriter(new FileWriter(new File("War/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
else out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||||
|
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
|
|
||||||
out.write("corner1"); out.newLine();
|
out.write("corner1"); out.newLine();
|
||||||
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
||||||
|
@ -22,9 +22,9 @@ public class WarMapper {
|
|||||||
|
|
||||||
public static void load(War war, World world) {
|
public static void load(War war, World world) {
|
||||||
//war.getLogger().info("Loading war config...");
|
//war.getLogger().info("Loading war config...");
|
||||||
(new File("War")).mkdir();
|
(war.getDataFolder()).mkdir();
|
||||||
(new File("War/dat")).mkdir();
|
(new File(war.getDataFolder().getPath() + "/dat")).mkdir();
|
||||||
PropertiesFile warConfig = new PropertiesFile(war.getName() + "/war.txt");
|
PropertiesFile warConfig = new PropertiesFile(war.getDataFolder().getPath() + "/war.txt");
|
||||||
try {
|
try {
|
||||||
warConfig.load();
|
warConfig.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -138,7 +138,7 @@ public class WarMapper {
|
|||||||
|
|
||||||
public static void save(War war) {
|
public static void save(War war) {
|
||||||
//war.getLogger().info("Saving war config...");
|
//war.getLogger().info("Saving war config...");
|
||||||
PropertiesFile warConfig = new PropertiesFile(war.getName() + "/war.txt");
|
PropertiesFile warConfig = new PropertiesFile(war.getDataFolder().getPath() + "/war.txt");
|
||||||
String warzonesStr = "";
|
String warzonesStr = "";
|
||||||
|
|
||||||
// warzones
|
// warzones
|
||||||
|
@ -29,7 +29,7 @@ public class WarzoneMapper {
|
|||||||
|
|
||||||
public static Warzone load(War war, String name, boolean loadBlocks) {
|
public static Warzone load(War war, String name, boolean loadBlocks) {
|
||||||
//war.getLogger().info("Loading warzone " + name + " config and blocks...");
|
//war.getLogger().info("Loading warzone " + name + " config and blocks...");
|
||||||
PropertiesFile warzoneConfig = new PropertiesFile(war.getName() + "/warzone-" + name + ".txt");
|
PropertiesFile warzoneConfig = new PropertiesFile(war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
|
||||||
try {
|
try {
|
||||||
warzoneConfig.load();
|
warzoneConfig.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -208,8 +208,8 @@ public class WarzoneMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void save(War war, Warzone warzone, boolean saveAllBlocks) {
|
public static void save(War war, Warzone warzone, boolean saveAllBlocks) {
|
||||||
(new File(war.getName()+"/dat/warzone-"+warzone.getName())).mkdir();
|
(new File(war.getDataFolder().getPath() +"/dat/warzone-"+warzone.getName())).mkdir();
|
||||||
PropertiesFile warzoneConfig = new PropertiesFile(war.getName() + "/warzone-" + warzone.getName() + ".txt");
|
PropertiesFile warzoneConfig = new PropertiesFile(war.getDataFolder().getPath() + "/warzone-" + warzone.getName() + ".txt");
|
||||||
//war.getLogger().info("Saving warzone " + warzone.getName() + "...");
|
//war.getLogger().info("Saving warzone " + warzone.getName() + "...");
|
||||||
|
|
||||||
// name
|
// name
|
||||||
@ -332,7 +332,7 @@ public class WarzoneMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void delete(War war, String name) {
|
public static void delete(War war, String name) {
|
||||||
File zoneFolder = new File(war.getName() + "/dat/warzone-" + name);
|
File zoneFolder = new File(war.getDataFolder().getPath() + "/dat/warzone-" + name);
|
||||||
File[] files = zoneFolder.listFiles();
|
File[] files = zoneFolder.listFiles();
|
||||||
for(File file : files) {
|
for(File file : files) {
|
||||||
boolean deletedData = file.delete();
|
boolean deletedData = file.delete();
|
||||||
@ -344,7 +344,7 @@ public class WarzoneMapper {
|
|||||||
if(!deletedData) {
|
if(!deletedData) {
|
||||||
war.warn("Failed to delete folder " + zoneFolder.getName());
|
war.warn("Failed to delete folder " + zoneFolder.getName());
|
||||||
}
|
}
|
||||||
File zoneFile = new File(war.getName() + "/warzone-" + name + ".txt");
|
File zoneFile = new File(war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
|
||||||
deletedData = zoneFile.delete();
|
deletedData = zoneFile.delete();
|
||||||
if(!deletedData) {
|
if(!deletedData) {
|
||||||
war.warn("Failed to delete file " + zoneFile.getName());
|
war.warn("Failed to delete file " + zoneFile.getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user