Disabled worlds

This commit is contained in:
NuclearW 2012-02-05 16:29:56 -05:00
parent 43e3dd7977
commit 6e8ad54dc6
8 changed files with 200 additions and 300 deletions

View File

@ -23,7 +23,7 @@ public class AddxpCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!mcPermissions.permissionsEnabled) { if (!mcPermissions.isEnabled()) {
sender.sendMessage("This command requires permissions."); sender.sendMessage("This command requires permissions.");
return true; return true;
} }

View File

@ -24,7 +24,7 @@ public class MmoeditCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!mcPermissions.permissionsEnabled) { if (!mcPermissions.isEnabled()) {
sender.sendMessage("This command requires permissions."); sender.sendMessage("This command requires permissions.");
return true; return true;
} }

View File

@ -33,7 +33,7 @@ public class StatsCommand implements CommandExecutor {
player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats")); player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats"));
if (mcPermissions.getEnabled()) if (mcPermissions.isEnabled())
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote")); player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote"));
ChatColor header = ChatColor.GOLD; ChatColor header = ChatColor.GOLD;

View File

@ -14,7 +14,7 @@ import com.gmail.nossr50.locale.mcLocale;
public class McabilityCommand implements CommandExecutor { public class McabilityCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!mcPermissions.permissionsEnabled) { if (!mcPermissions.isEnabled()) {
sender.sendMessage("This command requires permissions."); sender.sendMessage("This command requires permissions.");
return true; return true;
} }

View File

@ -28,7 +28,7 @@ public class McgodCommand implements CommandExecutor {
Player player = (Player) sender; Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if (mcPermissions.permissionsEnabled) { if (mcPermissions.isEnabled()) {
if (!mcPermissions.getInstance().mcgod(player)) { if (!mcPermissions.getInstance().mcgod(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;

View File

@ -17,8 +17,10 @@
package com.gmail.nossr50.config; package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -86,6 +88,8 @@ public class LoadProperties {
excavationxpmodifier, archeryxpmodifier, swordsxpmodifier, excavationxpmodifier, archeryxpmodifier, swordsxpmodifier,
axesxpmodifier, acrobaticsxpmodifier; axesxpmodifier, acrobaticsxpmodifier;
public static ArrayList<String> disabledWorlds;
public static HUDType defaulthud; public static HUDType defaulthud;
protected static File configFile; protected static File configFile;
protected static File dataFolder; protected static File dataFolder;
@ -129,6 +133,12 @@ public class LoadProperties {
return result; return result;
} }
public static ArrayList<String> readList(String root, ArrayList<String> def) {
@SuppressWarnings({ "unchecked", "rawtypes" })
ArrayList<String> result = (ArrayList) config.getList(root, def);
return result;
}
private static void saveConfig() { private static void saveConfig() {
try { try {
config.save(configFile); config.save(configFile);
@ -297,6 +307,8 @@ public class LoadProperties {
enableMySpawn = readBoolean("General.MySpawn.Enabled", true); enableMySpawn = readBoolean("General.MySpawn.Enabled", true);
enableRegen = readBoolean("General.HP_Regeneration.Enabled", true); enableRegen = readBoolean("General.HP_Regeneration.Enabled", true);
disabledWorlds = readList("General.Disabled_Worlds", new ArrayList<String>());
enableCobbleToMossy = readBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); enableCobbleToMossy = readBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true);
xpGainMultiplier = readInteger("Experience.Gains.Multiplier.Global", 1); xpGainMultiplier = readInteger("Experience.Gains.Multiplier.Global", 1);
@ -431,5 +443,7 @@ public class LoadProperties {
aDisplayNames = readBoolean("Commands.a.Display_Names", true); aDisplayNames = readBoolean("Commands.a.Display_Names", true);
pDisplayNames = readBoolean("Commands.p.Display_Names", true); pDisplayNames = readBoolean("Commands.p.Display_Names", true);
} }
} }

View File

@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with mcMMO. If not, see <http://www.gnu.org/licenses/>. along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.gmail.nossr50; package com.gmail.nossr50;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -25,12 +25,12 @@ import org.bukkit.plugin.Plugin;
import ru.tehkode.permissions.PermissionManager; import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.bukkit.PermissionsEx; import ru.tehkode.permissions.bukkit.PermissionsEx;
import com.gmail.nossr50.config.LoadProperties;
import com.nijiko.permissions.PermissionHandler; import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions; import com.nijikokun.bukkit.Permissions.Permissions;
public class mcPermissions public class mcPermissions {
{ private static volatile mcPermissions instance;
private static volatile mcPermissions instance;
private enum PermissionType { private enum PermissionType {
PEX, PERMISSIONS, BUKKIT PEX, PERMISSIONS, BUKKIT
@ -38,42 +38,32 @@ public class mcPermissions
private static PermissionType permissionType; private static PermissionType permissionType;
private static Object PHandle; private static Object PHandle;
public static boolean permissionsEnabled = false;
public static void initialize(Server server) public static void initialize(Server server) {
{ Logger log = Logger.getLogger("Minecraft");
Logger log = Logger.getLogger("Minecraft");
if(permissionsEnabled && permissionType != PermissionType.PERMISSIONS) return; if (permissionType != null && permissionType != PermissionType.PERMISSIONS)
return;
Plugin PEXtest = server.getPluginManager().getPlugin("PermissionsEx"); Plugin PEXtest = server.getPluginManager().getPlugin("PermissionsEx");
Plugin test = server.getPluginManager().getPlugin("Permissions"); Plugin test = server.getPluginManager().getPlugin("Permissions");
if(PEXtest != null) { if (PEXtest != null) {
PHandle = (PermissionManager) PermissionsEx.getPermissionManager(); PHandle = (PermissionManager) PermissionsEx.getPermissionManager();
permissionType = PermissionType.PEX; permissionType = PermissionType.PEX;
permissionsEnabled = true;
log.info("[mcMMO] PermissionsEx found, using PermissionsEx."); log.info("[mcMMO] PermissionsEx found, using PermissionsEx.");
} else if(test != null) { } else if (test != null) {
PHandle = (PermissionHandler) ((Permissions) test).getHandler(); PHandle = (PermissionHandler) ((Permissions) test).getHandler();
permissionType = PermissionType.PERMISSIONS; permissionType = PermissionType.PERMISSIONS;
permissionsEnabled = true; log.info("[mcMMO] Permissions version " + test.getDescription().getVersion() + " found, using Permissions.");
log.info("[mcMMO] Permissions version "+test.getDescription().getVersion()+" found, using Permissions.");
} else { } else {
permissionType = PermissionType.BUKKIT; permissionType = PermissionType.BUKKIT;
permissionsEnabled = true;
log.info("[mcMMO] Using Bukkit Permissions."); log.info("[mcMMO] Using Bukkit Permissions.");
} }
} }
public static boolean getEnabled() public static boolean permission(Player player, String permission) {
{ if(LoadProperties.disabledWorlds.contains(player.getWorld().getName())) return false;
return permissionsEnabled; switch (permissionType) {
}
public static boolean permission(Player player, String permission)
{
if(!permissionsEnabled) return player.isOp();
switch(permissionType) {
case PEX: case PEX:
return ((PermissionManager) PHandle).has(player, permission); return ((PermissionManager) PHandle).has(player, permission);
case PERMISSIONS: case PERMISSIONS:
@ -84,269 +74,163 @@ public class mcPermissions
return true; return true;
} }
} }
public boolean admin(Player player){
if (permissionsEnabled) { public static mcPermissions getInstance() {
return permission(player, "mcmmo.admin"); if (instance == null) {
} else { instance = new mcPermissions();
return true; }
} return instance;
} }
public boolean mcrefresh(Player player) {
if (permissionsEnabled) { public static boolean isEnabled() {
return permission(player, "mcmmo.tools.mcrefresh"); return permissionType != null;
} else { }
return true;
} public boolean admin(Player player) {
} return permission(player, "mcmmo.admin");
public boolean mmoedit(Player player) { }
if (permissionsEnabled) {
return permission(player, "mcmmo.tools.mmoedit"); public boolean mcrefresh(Player player) {
} else { return permission(player, "mcmmo.tools.mcrefresh");
return true; }
}
} public boolean mmoedit(Player player) {
public boolean herbalismAbility(Player player){ return permission(player, "mcmmo.tools.mmoedit");
if (permissionsEnabled) { }
return permission(player, "mcmmo.ability.herbalism");
} else { public boolean herbalismAbility(Player player) {
return true; return permission(player, "mcmmo.ability.herbalism");
} }
}
public boolean excavationAbility(Player player){ public boolean excavationAbility(Player player) {
if (permissionsEnabled) { return permission(player, "mcmmo.ability.excavation");
return permission(player, "mcmmo.ability.excavation"); }
} else {
return true; public boolean unarmedAbility(Player player) {
} return permission(player, "mcmmo.ability.unarmed");
} }
public boolean unarmedAbility(Player player){
if (permissionsEnabled) { public boolean chimaeraWing(Player player) {
return permission(player, "mcmmo.ability.unarmed"); return permission(player, "mcmmo.item.chimaerawing");
} else { }
return true;
} public boolean miningAbility(Player player) {
} return permission(player, "mcmmo.ability.mining");
public boolean chimaeraWing(Player player){ }
if (permissionsEnabled) {
return permission(player, "mcmmo.item.chimaerawing"); public boolean axesAbility(Player player) {
} else { return permission(player, "mcmmo.ability.axes");
return true; }
}
} public boolean swordsAbility(Player player) {
public boolean miningAbility(Player player){ return permission(player, "mcmmo.ability.swords");
if (permissionsEnabled) { }
return permission(player, "mcmmo.ability.mining");
} else { public boolean woodCuttingAbility(Player player) {
return true; return permission(player, "mcmmo.ability.woodcutting");
} }
}
public boolean axesAbility(Player player){ public boolean mcgod(Player player) {
if (permissionsEnabled) { return permission(player, "mcmmo.tools.mcgod");
return permission(player, "mcmmo.ability.axes"); }
} else {
return true; public boolean regeneration(Player player) {
} return permission(player, "mcmmo.regeneration");
} }
public boolean swordsAbility(Player player){
if (permissionsEnabled) { public boolean motd(Player player) {
return permission(player, "mcmmo.ability.swords"); return permission(player, "mcmmo.motd");
} else { }
return true;
} public boolean mcAbility(Player player) {
} return permission(player, "mcmmo.commands.ability");
public boolean woodCuttingAbility(Player player) { }
if (permissionsEnabled) {
return permission(player, "mcmmo.ability.woodcutting"); public boolean mySpawn(Player player) {
} else { return permission(player, "mcmmo.commands.myspawn");
return true; }
}
} public boolean setMySpawn(Player player) {
public boolean mcgod(Player player) { return permission(player, "mcmmo.commands.setmyspawn");
if (permissionsEnabled) { }
return permission(player, "mcmmo.tools.mcgod");
} else { public boolean partyChat(Player player) {
return true; return permission(player, "mcmmo.chat.partychat");
} }
}
public boolean regeneration(Player player){ public boolean partyLock(Player player) {
if (permissionsEnabled) { return permission(player, "mcmmo.chat.partylock");
return permission(player, "mcmmo.regeneration"); }
} else {
return true; public boolean partyTeleport(Player player) {
} return permission(player, "mcmmo.commands.ptp");
} }
public boolean motd(Player player) {
if (permissionsEnabled) { public boolean whois(Player player) {
return permission(player, "mcmmo.motd"); return permission(player, "mcmmo.commands.whois");
} else { }
return true;
} public boolean party(Player player) {
} return permission(player, "mcmmo.commands.party");
public boolean mcAbility(Player player) { }
if (permissionsEnabled) {
return permission(player, "mcmmo.commands.ability"); public boolean adminChat(Player player) {
} else { return permission(player, "mcmmo.chat.adminchat");
return true; }
}
} public boolean taming(Player player) {
public boolean mySpawn(Player player) { return permission(player, "mcmmo.skills.taming");
if (permissionsEnabled) { }
return permission(player, "mcmmo.commands.myspawn");
} else { public boolean mining(Player player) {
return true; return permission(player, "mcmmo.skills.mining");
} }
}
public boolean setMySpawn(Player player) { public boolean fishing(Player player) {
if (permissionsEnabled) { return permission(player, "mcmmo.skills.fishing");
return permission(player, "mcmmo.commands.setmyspawn"); }
} else {
return true; public boolean alchemy(Player player) {
} return permission(player, "mcmmo.skills.alchemy");
} }
public boolean partyChat(Player player) {
if (permissionsEnabled) { public boolean enchanting(Player player) {
return permission(player, "mcmmo.chat.partychat"); return permission(player, "mcmmo.skills.enchanting");
} else { }
return true;
} public boolean woodcutting(Player player) {
} return permission(player, "mcmmo.skills.woodcutting");
public boolean partyLock(Player player) { }
if (permissionsEnabled) {
return permission(player, "mcmmo.chat.partylock"); public boolean repair(Player player) {
} else { return permission(player, "mcmmo.skills.repair");
return true; }
}
} public boolean unarmed(Player player) {
public boolean partyTeleport(Player player) { return permission(player, "mcmmo.skills.unarmed");
if (permissionsEnabled) { }
return permission(player, "mcmmo.commands.ptp");
} else { public boolean archery(Player player) {
return true; return permission(player, "mcmmo.skills.archery");
} }
}
public boolean whois(Player player) { public boolean herbalism(Player player) {
if (permissionsEnabled) { return permission(player, "mcmmo.skills.herbalism");
return permission(player, "mcmmo.commands.whois"); }
} else {
return true; public boolean excavation(Player player) {
} return permission(player, "mcmmo.skills.excavation");
} }
public boolean party(Player player) {
if (permissionsEnabled) { public boolean swords(Player player) {
return permission(player, "mcmmo.commands.party"); return permission(player, "mcmmo.skills.swords");
} else { }
return true;
} public boolean axes(Player player) {
} return permission(player, "mcmmo.skills.axes");
public boolean adminChat(Player player) { }
if (permissionsEnabled) {
return permission(player, "mcmmo.chat.adminchat"); public boolean acrobatics(Player player) {
} else { return permission(player, "mcmmo.skills.acrobatics");
return true; }
}
}
public static mcPermissions getInstance() {
if (instance == null) {
instance = new mcPermissions();
}
return instance;
}
public boolean taming(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.taming");
} else {
return true;
}
}
public boolean mining(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.mining");
} else {
return true;
}
}
public boolean fishing(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.fishing");
} else {
return true;
}
}
public boolean alchemy(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.alchemy");
} else {
return true;
}
}
public boolean enchanting(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.enchanting");
} else {
return true;
}
}
public boolean woodcutting(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.woodcutting");
} else {
return true;
}
}
public boolean repair(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.repair");
} else {
return true;
}
}
public boolean unarmed(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.unarmed");
} else {
return true;
}
}
public boolean archery(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.archery");
} else {
return true;
}
}
public boolean herbalism(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.herbalism");
} else {
return true;
}
}
public boolean excavation(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.excavation");
} else {
return true;
}
}
public boolean swords(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.swords");
} else {
return true;
}
}
public boolean axes(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.axes");
} else {
return true;
}
}
public boolean acrobatics(Player player) {
if (permissionsEnabled) {
return permission(player, "mcmmo.skills.acrobatics");
} else {
return true;
}
}
} }

View File

@ -256,6 +256,8 @@ General:
Enabled: true Enabled: true
MOTD: MOTD:
Enabled: true Enabled: true
Disabled_Worlds:
- this_world_has_no_mcmmo
Excavation: Excavation:
Drops: Drops:
Cake: true Cake: true