Added Permissions support. Trying everything to get gates and teleports in player_move working again to no avail.

This commit is contained in:
taoneill 2011-01-22 02:05:04 -05:00
parent b45af8cad0
commit 06ba048797
8 changed files with 283 additions and 252 deletions

View File

@ -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.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/bukkit"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/Permissions.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.PluginManager;
@ -31,12 +32,15 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.nijikokun.bukkit.Permissions.Permissions;
/**
*
* @author tommytony
*
*/
public class War extends JavaPlugin {
public static Permissions Permissions = null;
public War(PluginLoader pluginLoader, Server instance,
PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
@ -45,7 +49,6 @@ public class War extends JavaPlugin {
this.desc = desc;
}
private WarPlayerListener playerListener = new WarPlayerListener(this);
private WarEntityListener entityListener = new WarEntityListener(this);
private WarBlockListener blockListener = new WarBlockListener(this);
@ -88,7 +91,7 @@ public class War extends JavaPlugin {
public void onEnable() {
this.log = Logger.getLogger("Minecraft");
this.setupPermissions();
// Register hooks
PluginManager pm = getServer().getPluginManager();
@ -185,7 +188,7 @@ public class War extends JavaPlugin {
}
// /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()))
|| (arguments.length > 0 && TeamMaterials.teamMaterialFromString(arguments[0]) == null)) {
player.sendMessage(this.str("Usage: /join <diamond/iron/gold/d/i/g>." +
@ -267,11 +270,11 @@ public class War extends JavaPlugin {
// /team <msg>
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>. " +
"Sends a message only to your teammates."));
} else {
Team playerTeam = this.getPlayerTeam(player.getName());
ChatColor color = null;
if(playerTeam.getMaterial() == TeamMaterials.TEAMDIAMOND) {
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.");
} else {
Team playerTeam = this.getPlayerTeam(player.getName());
Warzone playerWarzone = getPlayerWarzone(player.getName());
Warzone playerWarzone = getPlayerTeamWarzone(player.getName());
if(playerTeam != null) { // was in zone
playerTeam.removePlayer(player.getName());
}
@ -306,7 +309,7 @@ public class War extends JavaPlugin {
player.teleportTo(this.getWarHub().getLocation());
}
} else if(this.isZoneMaker(player.getName())) {
} else if(this.isZoneMaker(player)) {
// Mod commands : /nextbattle
// /nextbattle
@ -988,7 +991,7 @@ public class War extends JavaPlugin {
return null;
}
public Warzone getPlayerWarzone(String playerName) {
public Warzone getPlayerTeamWarzone(String playerName) {
for(Warzone warzone : warzones) {
Team team = warzone.getPlayerTeam(playerName);
if(team != null) return warzone;
@ -1093,9 +1096,23 @@ public class War extends JavaPlugin {
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) {
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;
}
@ -1184,4 +1201,16 @@ public class War extends JavaPlugin {
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."));
}
}
}
}

View File

@ -32,8 +32,8 @@ public class WarBlockListener extends BlockListener {
boolean captured = false;
if(player != null) {
Team team = war.getPlayerTeam(player.getName());
Warzone zone = war.getPlayerWarzone(player.getName());
boolean isZoneMaker = war.isZoneMaker(player.getName());
Warzone zone = war.getPlayerTeamWarzone(player.getName());
boolean isZoneMaker = war.isZoneMaker(player);
if(team != null && block != null && zone != null
&& zone.isMonumentCenterBlock(block)
&& block.getType() == team.getMaterial()) {
@ -75,7 +75,7 @@ public class WarBlockListener extends BlockListener {
if(player != null && block != null && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
Warzone warzone = war.warzone(player.getLocation());
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) {
// can't actually destroy blocks in a warzone if not part of a team

View File

@ -35,10 +35,9 @@ public class WarEntityListener extends EntityListener {
if(defender instanceof Player) {
Player d = (Player)defender;
synchronized(defender) {
if(event.getDamage() >= d.getHealth()) {
// Player died
Warzone defenderWarzone = war.getPlayerWarzone(d.getName());
Warzone defenderWarzone = war.getPlayerTeamWarzone(d.getName());
Team defenderTeam = war.getPlayerTeam(d.getName());
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) {
Entity attacker = event.getDamager();
Entity defender = event.getEntity();
@ -102,16 +57,16 @@ public class WarEntityListener extends EntityListener {
// only let adversaries (same warzone, different team) attack each other
Player a = (Player)attacker;
Player d = (Player)defender;
Warzone attackerWarzone = war.getPlayerWarzone(a.getName());
Warzone attackerWarzone = war.getPlayerTeamWarzone(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());
if(attackerTeam != null && defenderTeam != null
&& attackerTeam != defenderTeam
&& attackerWarzone == defenderWarzone) {
// A real attack: handle death scenario. ==> now handled in entity damage as well
synchronized(d) {
if(event.getDamage() >= d.getHealth()) {
//synchronized(d) {
if(d.getHealth() <= 0) {
// // Player died, loot him!
// PlayerInventory attackerInv = a.getInventory();
// PlayerInventory defenderInv = d.getInventory();
@ -132,7 +87,7 @@ public class WarEntityListener extends EntityListener {
handleDeath(d, defenderWarzone, defenderTeam);
event.setCancelled(true);
}
}
//}
} else if (attackerTeam != null && defenderTeam != null
&& attackerTeam == defenderTeam
&& attackerWarzone == defenderWarzone) {

View File

@ -39,7 +39,7 @@ public class WarPlayerListener extends PlayerListener {
Player player = event.getPlayer();
Team team = war.getPlayerTeam(player.getName());
if(team != null) {
Warzone zone = war.getPlayerWarzone(player.getName());
Warzone zone = war.getPlayerTeamWarzone(player.getName());
if(zone != null && zone.hasPlayerInventory(player.getName())) {
player.teleportTo(zone.getTeleport());
zone.restorePlayerInventory(player);
@ -59,11 +59,20 @@ public class WarPlayerListener extends PlayerListener {
public void onPlayerMove(PlayerMoveEvent event) {
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();
boolean canPlay = war.canPlayWar(player);
boolean isMaker = war.isZoneMaker(player);
// 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);
if(nearbyZone != null) {
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;
if(to != null) {
// Warzone lobby gates
for(Warzone zone : war.getWarzones()){
if(zone.getLobby() != null) {
if(locLobby != null && to != null) {
Warzone zone = locLobby.getZone();
Team oldTeam = war.getPlayerTeam(player.getName());
if(oldTeam == null) { // trying to counter spammy player move
if(zone.getLobby().isAutoAssignGate(to)) {
boolean isAutoAssignGate = false;
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;
dropFromOldTeamIfAny(player);
int noOfPlayers = 0;
@ -92,16 +106,20 @@ public class WarPlayerListener extends PlayerListener {
noOfPlayers += t.getPlayers().size();
}
if(noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
//zone.autoAssign(event, player);
zone.autoAssign(player);
event.setCancelled(true);
zone.autoAssign(event, player);
//zone.autoAssign(player);
//event.setCancelled(true);
} else {
//event.setTo(zone.getTeleport());
player.teleportTo(zone.getTeleport());
event.setCancelled(true);
event.setTo(zone.getTeleport());
//player.teleportTo(zone.getTeleport());
//event.setCancelled(true);
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;
dropFromOldTeamIfAny(player);
Team diamondTeam = zone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND);
@ -110,19 +128,23 @@ public class WarPlayerListener extends PlayerListener {
diamondTeam.resetSign();
zone.keepPlayerInventory(player);
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
//zone.respawnPlayer(event, diamondTeam, player);
zone.respawnPlayer(diamondTeam, player);
event.setCancelled(true);
zone.respawnPlayer(event, diamondTeam, player);
//zone.respawnPlayer(diamondTeam, player);
//event.setCancelled(true);
for(Team team : zone.getTeams()){
team.teamcast(war.str("" + player.getName() + " joined team diamond."));
}
} else {
//event.setTo(zone.getTeleport());
player.teleportTo(zone.getTeleport());
event.setCancelled(true);
event.setTo(zone.getTeleport());
//player.teleportTo(zone.getTeleport());
//event.setCancelled(true);
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;
dropFromOldTeamIfAny(player);
Team ironTeam = zone.getTeamByMaterial(TeamMaterials.TEAMIRON);
@ -131,19 +153,23 @@ public class WarPlayerListener extends PlayerListener {
ironTeam.resetSign();
zone.keepPlayerInventory(player);
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
//zone.respawnPlayer(event, ironTeam, player);
zone.respawnPlayer(ironTeam, player);
event.setCancelled(true);
zone.respawnPlayer(event, ironTeam, player);
// zone.respawnPlayer(ironTeam, player);
// event.setCancelled(true);
for(Team team : zone.getTeams()){
team.teamcast(war.str("" + player.getName() + " joined team iron."));
}
} else {
//event.setTo(zone.getTeleport());
player.teleportTo(zone.getTeleport());
event.setCancelled(true);
event.setTo(zone.getTeleport());
// player.teleportTo(zone.getTeleport());
// event.setCancelled(true);
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;
dropFromOldTeamIfAny(player);
Team goldTeam = zone.getTeamByMaterial(TeamMaterials.TEAMGOLD);
@ -152,52 +178,46 @@ public class WarPlayerListener extends PlayerListener {
goldTeam.resetSign();
zone.keepPlayerInventory(player);
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
//zone.respawnPlayer(event, goldTeam, player);
zone.respawnPlayer(goldTeam, player);
event.setCancelled(true);
zone.respawnPlayer(event, goldTeam, player);
//zone.respawnPlayer(goldTeam, player);
//event.setCancelled(true);
for(Team team : zone.getTeams()){
team.teamcast(war.str("" + player.getName() + " joined team gold."));
}
} else {
//event.setTo(zone.getTeleport());
player.teleportTo(zone.getTeleport());
event.setCancelled(true);
event.setTo(zone.getTeleport());
// player.teleportTo(zone.getTeleport());
// event.setCancelled(true);
player.sendMessage("Team gold is full.");
}
} else if (zone.getLobby().isInWarHubLinkGate(to)){
return;
}
if (zone.getLobby().isInWarHubLinkGate(to)){
enteredGate = true;
dropFromOldTeamIfAny(player);
//event.setTo(war.getWarHub().getLocation());
player.teleportTo(war.getWarHub().getLocation());
event.setCancelled(true);
event.setTo(war.getWarHub().getLocation());
// player.teleportTo(war.getWarHub().getLocation());
// event.setCancelled(true);
player.sendMessage(war.str("Welcome to the War hub."));
return;
}
} else if(zone.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());
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(zone);
}
}
} else if ((isAutoAssignGate || isDiamondGate || isGoldGate || isIronGate) &&
!canPlay) {
event.setTo(zone.getTeleport());
// player.teleportTo(zone.getTeleport());
// event.setCancelled(true);
player.sendMessage(war.str("You don't have permission to play War. Ask a mod, please."));
return;
}
}
// Warhub zone gates
WarHub hub = war.getWarHub();
if(hub != null) {
if(hub != null && from != null && to != null && hub.getVolume().contains(from)) {
Warzone zone = hub.getDestinationWarzoneForLocation(to);
synchronized(player) {
//synchronized(player) {
if(zone != null) {
enteredGate = true;
event.setTo(zone.getTeleport());
@ -205,7 +225,31 @@ public class WarPlayerListener extends PlayerListener {
//
// event.setCancelled(true);
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());
// 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."));
//event.setTo(team.getTeamSpawn());
playerWarzone.respawnPlayer(team, player);
event.setTo(team.getTeamSpawn());
//playerWarzone.respawnPlayer(team, player);
//player.teleportTo(team.getTeamSpawn());
event.setCancelled(true);
//event.setCancelled(true);
}
// Monuments
@ -229,17 +273,17 @@ public class WarPlayerListener extends PlayerListener {
player.setHealth(20);
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);
//event.setTo(zone.getTeleport());
player.teleportTo(zone.getTeleport());
event.setCancelled(true);
event.setTo(zone.getTeleport());
// player.teleportTo(zone.getTeleport());
// event.setCancelled(true);
//player.sendMessage(war.str("You can't be inside a warzone without a team."));
}
}
}
}
private void dropFromOldTeamIfAny(Player player) {
// drop from old team if any

View File

@ -40,8 +40,9 @@ public class VolumeMapper {
public static void load(Volume volume, String zoneName, War war, World world) {
BufferedReader in = null;
try {
if(zoneName.equals("")) in = new BufferedReader(new FileReader(new File("War/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
else in = new BufferedReader(new FileReader(new File("War/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
if(zoneName.equals("")) in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() +
"/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();
if(firstLine != null && !firstLine.equals("")) {
int x1 = Integer.parseInt(in.readLine());
@ -109,8 +110,9 @@ public class VolumeMapper {
if(volume.isSaved() && volume.getBlockTypes() != null) {
BufferedWriter out = null;
try {
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File("War/dat/volume-" + volume.getName() + ".dat")));
else out = new BufferedWriter(new FileWriter(new File("War/dat/warzone-" + zoneName + "/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.getDataFolder().getPath() +
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
out.write("corner1"); out.newLine();
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();

View File

@ -22,9 +22,9 @@ public class WarMapper {
public static void load(War war, World world) {
//war.getLogger().info("Loading war config...");
(new File("War")).mkdir();
(new File("War/dat")).mkdir();
PropertiesFile warConfig = new PropertiesFile(war.getName() + "/war.txt");
(war.getDataFolder()).mkdir();
(new File(war.getDataFolder().getPath() + "/dat")).mkdir();
PropertiesFile warConfig = new PropertiesFile(war.getDataFolder().getPath() + "/war.txt");
try {
warConfig.load();
} catch (IOException e) {
@ -138,7 +138,7 @@ public class WarMapper {
public static void save(War war) {
//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 = "";
// warzones

View File

@ -29,7 +29,7 @@ public class WarzoneMapper {
public static Warzone load(War war, String name, boolean loadBlocks) {
//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 {
warzoneConfig.load();
} catch (IOException e) {
@ -208,8 +208,8 @@ public class WarzoneMapper {
}
public static void save(War war, Warzone warzone, boolean saveAllBlocks) {
(new File(war.getName()+"/dat/warzone-"+warzone.getName())).mkdir();
PropertiesFile warzoneConfig = new PropertiesFile(war.getName() + "/warzone-" + warzone.getName() + ".txt");
(new File(war.getDataFolder().getPath() +"/dat/warzone-"+warzone.getName())).mkdir();
PropertiesFile warzoneConfig = new PropertiesFile(war.getDataFolder().getPath() + "/warzone-" + warzone.getName() + ".txt");
//war.getLogger().info("Saving warzone " + warzone.getName() + "...");
// name
@ -332,7 +332,7 @@ public class WarzoneMapper {
}
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();
for(File file : files) {
boolean deletedData = file.delete();
@ -344,7 +344,7 @@ public class WarzoneMapper {
if(!deletedData) {
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();
if(!deletedData) {
war.warn("Failed to delete file " + zoneFile.getName());