Removed Permissions from dependencies since everything works just fine with SuperPerms API. Restoring Spout player title color upon leaving warzone.

This commit is contained in:
taoneill 2012-01-14 12:52:26 -05:00
parent 4d04f39e3b
commit e53eb7965e
5 changed files with 29 additions and 94 deletions

View File

@ -8,7 +8,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/craftbukkit"/> <classpathentry combineaccessrules="false" kind="src" path="/craftbukkit"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/mockito-all-1.8.5.jar"/> <classpathentry kind="lib" path="C:/dev/war/war/lib/mockito-all-1.8.5.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Permissions"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/SpoutPluginAPI.jar"/> <classpathentry kind="lib" path="C:/dev/war/war/lib/SpoutPluginAPI.jar"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -13,6 +13,10 @@
<id>spout-repo</id> <id>spout-repo</id>
<url>http://nexus.getspout.org/content/groups/public/</url> <url>http://nexus.getspout.org/content/groups/public/</url>
</repository> </repository>
<repository>
<id>sk89q-mvn2</id>
<url>http://mvn2.sk89q.com/repo</url>
</repository>
</repositories> </repositories>
<build> <build>
<plugins> <plugins>
@ -68,12 +72,6 @@
<version>1.8.5</version> <version>1.8.5</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.nijikokun.bukkit</groupId>
<artifactId>Permissions</artifactId>
<version>2.7.4</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -18,13 +18,10 @@ 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.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.tommytony.war.FlagReturn; import com.tommytony.war.FlagReturn;
import com.tommytony.war.Team; import com.tommytony.war.Team;
import com.tommytony.war.TeamKind; import com.tommytony.war.TeamKind;
@ -54,7 +51,6 @@ import com.tommytony.war.utils.PlayerState;
* @package bukkit.tommytony.war * @package bukkit.tommytony.war
*/ */
public class War extends JavaPlugin { public class War extends JavaPlugin {
public static PermissionHandler permissionHandler;
public static War war; public static War war;
private static boolean loadedOnce = false; private static boolean loadedOnce = false;
@ -121,9 +117,6 @@ public class War extends JavaPlugin {
this.desc = this.getDescription(); this.desc = this.getDescription();
this.logger = this.getServer().getLogger(); this.logger = this.getServer().getLogger();
// Permissions
this.setupPermissions();
// Spout server detection // Spout server detection
try { try {
Class.forName("org.getspout.spoutapi.player.SpoutPlayer"); Class.forName("org.getspout.spoutapi.player.SpoutPlayer");
@ -293,20 +286,6 @@ public class War extends JavaPlugin {
this.setLoaded(false); this.setLoaded(false);
} }
/**
* Initializes Permissions
*/
public void setupPermissions() {
Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
if (War.permissionHandler == null) {
if (permissionsPlugin != null) {
War.permissionHandler = ((Permissions) permissionsPlugin).getHandler();
} else {
this.log("Permissions system not enabled. Defaulting to regular War config.", Level.INFO);
}
}
}
/** /**
* @see JavaPlugin.onCommand() * @see JavaPlugin.onCommand()
*/ */
@ -750,16 +729,7 @@ public class War extends JavaPlugin {
* @return true if the player may play war * @return true if the player may play war
*/ */
public boolean canPlayWar(Player player) { public boolean canPlayWar(Player player) {
if (War.permissionHandler != null) { return player.hasPermission("war.player");
if (War.permissionHandler.has(player, "war.player")) {
return true;
} else {
return false;
}
} else {
// w/o Permissions, everyone can play
return player.hasPermission("war.player");
}
} }
/** /**
@ -769,17 +739,7 @@ public class War extends JavaPlugin {
* @return true if the player may warp * @return true if the player may warp
*/ */
public boolean canWarp(Player player) { public boolean canWarp(Player player) {
if (War.permissionHandler != null) { return player.hasPermission("war.warp");
if (War.permissionHandler.has(player, "war.warp")) {
return true;
} else {
return false;
}
} else {
// w/o Permissions, everyone can warp
return player.hasPermission("war.warp");
}
} }
/** /**
@ -790,16 +750,7 @@ public class War extends JavaPlugin {
*/ */
public boolean canBuildOutsideZone(Player player) { public boolean canBuildOutsideZone(Player player) {
if (this.getWarConfig().getBoolean(WarConfig.BUILDINZONESONLY)) { if (this.getWarConfig().getBoolean(WarConfig.BUILDINZONESONLY)) {
if (War.permissionHandler != null) { return player.hasPermission("war.build");
if (War.permissionHandler.has(player, "war.build")) {
return true;
} else {
return false;
}
} else {
// w/o Permissions, if buildInZonesOnly, no one can build outside the zone except Zonemakers
return player.hasPermission("war.build");
}
} else { } else {
return true; return true;
} }
@ -813,16 +764,7 @@ public class War extends JavaPlugin {
*/ */
public boolean canPvpOutsideZones(Player player) { public boolean canPvpOutsideZones(Player player) {
if (this.getWarConfig().getBoolean(WarConfig.PVPINZONESONLY)) { if (this.getWarConfig().getBoolean(WarConfig.PVPINZONESONLY)) {
if (War.permissionHandler != null) { return player.hasPermission("war.pvp");
if (War.permissionHandler.has(player, "war.pvp")) {
return true;
} else {
return false;
}
} else {
// w/o Permissions, if pvpInZoneOnly, no one can pvp outside the zone
return player.hasPermission("war.pvp");
}
} else { } else {
return true; return true;
} }
@ -848,17 +790,7 @@ public class War extends JavaPlugin {
} }
} }
if (War.permissionHandler != null) { return player.hasPermission("war.zonemaker");
if (War.permissionHandler.has(player, "war.zonemaker")) {
// War admins are zonemakers
return true;
} else {
return false;
}
} else {
// default to op, if no permissions are found
return player.hasPermission("war.zonemaker");
}
} }
/** /**
@ -868,16 +800,7 @@ public class War extends JavaPlugin {
* @return true if the player is a War admin * @return true if the player is a War admin
*/ */
public boolean isWarAdmin(Player player) { public boolean isWarAdmin(Player player) {
if (War.permissionHandler != null) { return player.hasPermission("war.admin");
if (War.permissionHandler.has(player, "war.*") || War.permissionHandler.has(player, "war.admin")) {
return true;
} else {
return false;
}
} else {
// default to op, if no permissions are found
return player.hasPermission("war.admin");
}
} }
public void addWandBearer(Player player, String zoneName) { public void addWandBearer(Player player, String zoneName) {

View File

@ -427,9 +427,17 @@ public class Warzone {
ItemStack[] contents = inventory.getContents(); ItemStack[] contents = inventory.getContents();
List<PotionEffect> potionEffects = PotionEffect.getCurrentPotionEffects(player); List<PotionEffect> potionEffects = PotionEffect.getCurrentPotionEffects(player);
this.playerStates.put(player.getName(), new PlayerState(player.getGameMode(), this.playerStates.put(player.getName(), new PlayerState(player.getGameMode(),
contents, inventory.getHelmet(), inventory.getChestplate(), inventory.getLeggings(), inventory.getBoots(), contents,
player.getHealth(), player.getExhaustion(), player.getSaturation(), inventory.getHelmet(),
player.getFoodLevel(), potionEffects)); inventory.getChestplate(),
inventory.getLeggings(),
inventory.getBoots(),
player.getHealth(),
player.getExhaustion(),
player.getSaturation(),
player.getFoodLevel(),
potionEffects,
SpoutManager.getPlayer(player).getTitle()));
} }
public void restorePlayerState(Player player) { public void restorePlayerState(Player player) {
@ -443,6 +451,7 @@ public class Warzone {
player.setSaturation(originalContents.getSaturation()); player.setSaturation(originalContents.getSaturation());
player.setFoodLevel(originalContents.getFoodLevel()); player.setFoodLevel(originalContents.getFoodLevel());
PotionEffect.restorePotionEffects(player, originalContents.getPotionEffects()); PotionEffect.restorePotionEffects(player, originalContents.getPotionEffects());
SpoutManager.getPlayer(player).setTitle(originalContents.getPlayerTitle());
} }
} }

View File

@ -19,14 +19,16 @@ public class PlayerState {
private final int health; private final int health;
private final GameMode gamemode; private final GameMode gamemode;
private final List<PotionEffect> potionEffects; private final List<PotionEffect> potionEffects;
private final String playerTitle;
public PlayerState(GameMode gamemode, ItemStack[] contents, ItemStack helmet, ItemStack chest, ItemStack legs, ItemStack feet, int health, float exhaustion, float saturation, int foodLevel, List<PotionEffect> potionEffects) { public PlayerState(GameMode gamemode, ItemStack[] contents, ItemStack helmet, ItemStack chest, ItemStack legs, ItemStack feet, int health, float exhaustion, float saturation, int foodLevel, List<PotionEffect> potionEffects, String playerTitle) {
this.gamemode = gamemode; this.gamemode = gamemode;
this.health = health; this.health = health;
this.exhaustion = exhaustion; this.exhaustion = exhaustion;
this.saturation = saturation; this.saturation = saturation;
this.foodLevel = foodLevel; this.foodLevel = foodLevel;
this.potionEffects = potionEffects; this.potionEffects = potionEffects;
this.playerTitle = playerTitle;
this.setContents(contents); this.setContents(contents);
this.setHelmet(helmet); this.setHelmet(helmet);
this.setChest(chest); this.setChest(chest);
@ -98,4 +100,8 @@ public class PlayerState {
return potionEffects; return potionEffects;
} }
public String getPlayerTitle() {
return playerTitle;
}
} }