Skip to content

Commit

Permalink
Add some function to the API
Browse files Browse the repository at this point in the history
Add World : getDMWorld(Player, player)
Add String : getDMWorldName(Player, player)
Add boolean : isADMWorld(World w)
Add boolean : canBuildInDMWorld (World world, Player player)
Add boolean : isPlayerAllowOnWorldSurface(World world, Player player)
  • Loading branch information
Xephi committed Oct 26, 2012
1 parent 87e4ff2 commit 3a2c22e
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion src/com/timvisee/DungeonMaze/DungeonMazeAPI.java
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;

public class DungeonMazeAPI {
Expand All @@ -23,6 +23,57 @@ public static boolean isInDMWorld(Player player) {
public static List<String> getDMWorlds() {
return plugin.getDungeonMazeWorlds();
}

public static World getDMWorld(Player player) {
World worldNameByPlayer = null;
if (isInDMWorld(player)) {
worldNameByPlayer = player.getWorld();
}
return worldNameByPlayer;
}

public static String getDMWorldName(Player player) {
String worldNameByPlayer = null;
if (isInDMWorld(player)) {
worldNameByPlayer = player.getWorld().getName();
}
return worldNameByPlayer;
}

public static boolean isADMWorld (World w) {
List<String> worlds = plugin.getDungeonMazeWorlds();
boolean result = false;
for (String world : worlds) {
if (w.getName() == world) {
result = true;
}
}
return result;
}

public static boolean canBuildInDMWorld (World world, Player player) {
boolean result = true;
if (isADMWorld(world.getName())) {
if (plugin.getConfig().getBoolean("worldProtection", false)) {
if (plugin.hasPermission(player, "dungeonmaze.bypass.build", player.isOp()) == false) {
result = false;
}
}
}
return result;
}

public static boolean isPlayerAllowOnWorldSurface (World world, Player player) {
boolean result = true;
if (isADMWorld(world.getName())) {
if ((plugin.getConfig().getBoolean("allowSurface", false) == false)) {
if (plugin.hasPermission(player, "dungeonmaze.bypass.surface", player.isOp()) == false) {
result = false;
}
}
}
return result;
}

public static void setPlugin(DungeonMaze plugin) {
DungeonMazeAPI.plugin = plugin;
Expand Down

0 comments on commit 3a2c22e

Please sign in to comment.