mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-02 16:59:56 +01:00
Cleanup and Add 2nd permissions node to mvspawn
This commit is contained in:
parent
532e2c2f75
commit
0885ba3089
@ -3,6 +3,7 @@ package com.onarandombox.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MVPermissions {
|
||||
@ -19,7 +20,7 @@ public class MVPermissions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player has the following Permission node, if a Permissions plugin is not installed then we default to isOp()
|
||||
* Use hasPermission() Now
|
||||
*
|
||||
* @param p The player instance.
|
||||
* @param node The permission node we are checking against.
|
||||
@ -38,6 +39,25 @@ public class MVPermissions {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
// TODO:
|
||||
if (player.isOp()) {
|
||||
// If Player is Op we always let them use it.
|
||||
return true;
|
||||
} else if (MultiverseCore.Permissions != null && MultiverseCore.Permissions.has(player, node)) {
|
||||
// If Permissions is enabled we check against them.
|
||||
return true;
|
||||
}
|
||||
// If the Player doesn't have Permissions and isn't an Op then
|
||||
// we return true if OP is not required, otherwise we return false
|
||||
return !isOpRequired;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a Player can teleport to the Destination world from there current world. This checks against the Worlds Blacklist
|
||||
@ -55,8 +75,8 @@ public class MVPermissions {
|
||||
returnValue = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < blackList.size(); i++) {
|
||||
if (blackList.get(i).equalsIgnoreCase(p.getWorld().getName())) {
|
||||
for (String s : blackList) {
|
||||
if (s.equalsIgnoreCase(p.getWorld().getName())) {
|
||||
returnValue = false;
|
||||
break;
|
||||
}
|
||||
@ -76,8 +96,6 @@ public class MVPermissions {
|
||||
|
||||
List<String> whiteList = this.plugin.getMVWorld(w.getName()).getPlayerWhitelist();
|
||||
List<String> blackList = this.plugin.getMVWorld(w.getName()).getPlayerBlacklist();
|
||||
System.out.print(blackList);
|
||||
System.out.print(whiteList);
|
||||
boolean returnValue = true;
|
||||
|
||||
// I lied. You definitely want this. Sorry Rigby :( You were right. --FF
|
||||
|
@ -170,7 +170,6 @@ public class MVWorld {
|
||||
}
|
||||
|
||||
public boolean addToList(String list, String value) {
|
||||
System.out.print("Trying to add " + value + " to " + list);
|
||||
if (list.equalsIgnoreCase("blockblacklist")) {
|
||||
try {
|
||||
int intVal = Integer.parseInt(value);
|
||||
@ -179,7 +178,6 @@ public class MVWorld {
|
||||
}
|
||||
} else if (this.masterList.keySet().contains(list)) {
|
||||
this.masterList.get(list).add(value);
|
||||
System.out.print(this.masterList.get(list));
|
||||
if (list.equalsIgnoreCase("animals") || list.equalsIgnoreCase("monsters")) {
|
||||
this.config.setProperty("worlds." + this.name + "." + list.toLowerCase() + ".exceptions", this.masterList.get(list));
|
||||
this.syncMobs();
|
||||
@ -187,7 +185,6 @@ public class MVWorld {
|
||||
this.config.setProperty("worlds." + this.name + "." + list.toLowerCase(), this.masterList.get(list));
|
||||
}
|
||||
this.config.save();
|
||||
System.out.print(this.masterList.get(list));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -226,9 +223,6 @@ public class MVWorld {
|
||||
}
|
||||
|
||||
if (this.getMonsterList().isEmpty()) {
|
||||
System.out.print(this.allowMonsters);
|
||||
System.out.print(this.world);
|
||||
System.out.print(this.world.getAllowAnimals());
|
||||
this.world.setSpawnFlags(this.allowMonsters, this.world.getAllowAnimals());
|
||||
if (!this.allowMonsters) {
|
||||
// TODO: Purge
|
||||
@ -341,12 +335,10 @@ public class MVWorld {
|
||||
}
|
||||
|
||||
private void setAnimals(Boolean animals) {
|
||||
System.out.print("Animals setting recieved: " + animals);
|
||||
this.allowAnimals = animals;
|
||||
// If animals are a boolean, then we can turn them on or off on the server
|
||||
// If there are ANY exceptions, there will be something spawning, so turn them on
|
||||
|
||||
System.out.print("Animals setting saved: " + animals);
|
||||
this.config.setProperty("worlds." + this.name + ".animals.spawn", animals);
|
||||
this.config.save();
|
||||
this.syncMobs();
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
@ -27,7 +24,6 @@ enum SetProperties {
|
||||
|
||||
public class ModifyCommand extends BaseCommand {
|
||||
|
||||
private Configuration config;
|
||||
|
||||
public ModifyCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@ -39,7 +35,6 @@ public class ModifyCommand extends BaseCommand {
|
||||
this.identifiers.add("mvmodify");
|
||||
this.permission = "multiverse.world.modify";
|
||||
this.requiresOp = true;
|
||||
this.config = plugin.configWorlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,7 +63,6 @@ public class ModifyCommand extends BaseCommand {
|
||||
value = args[3];
|
||||
property = args[2];
|
||||
}
|
||||
System.out.print(args[0]);
|
||||
|
||||
if (world == null) {
|
||||
sender.sendMessage("That world does not exist!");
|
||||
|
@ -17,18 +17,22 @@ public class SpawnCommand extends BaseCommand {
|
||||
this.minArgs = 0;
|
||||
this.maxArgs = 1;
|
||||
this.identifiers.add("mvspawn");
|
||||
this.permission = "multiverse.world.spawn";
|
||||
this.requiresOp = true;
|
||||
this.permission = "multiverse.world.spawn.self";
|
||||
this.requiresOp = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// TODO: Permissions
|
||||
Player commandSender = null;
|
||||
if (sender instanceof Player) {
|
||||
commandSender = (Player) sender;
|
||||
}
|
||||
// If a persons name was passed in, you must be A. the console, or B have permissions
|
||||
if (args.length == 1) {
|
||||
if(commandSender != null && !this.plugin.ph.hasPermission(commandSender, "multiverse.world.spawn.self", true)) {
|
||||
sender.sendMessage("You don't have permission to teleport another player to spawn.");
|
||||
return;
|
||||
}
|
||||
Player target = this.plugin.getServer().getPlayer(args[0]);
|
||||
if (target != null) {
|
||||
target.sendMessage("Teleporting to this world's spawn...");
|
||||
|
@ -18,12 +18,12 @@ public class TeleportCommand extends BaseCommand {
|
||||
super(plugin);
|
||||
this.name = "Teleport";
|
||||
this.description = "Teleports you to a different world.";
|
||||
this.usage = "/mvtp" + ChatColor.GREEN + " {WORLD}";
|
||||
this.usage = "/mvtp" + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}";
|
||||
this.minArgs = 1;
|
||||
this.maxArgs = 1;
|
||||
this.maxArgs = 2;
|
||||
this.identifiers.add("mvtp");
|
||||
this.playerTeleporter = new MVTeleport(plugin);
|
||||
this.permission = "multiverse.world.tp";
|
||||
this.permission = "multiverse.world.tp.self";
|
||||
this.requiresOp = true;
|
||||
}
|
||||
|
||||
@ -33,7 +33,14 @@ public class TeleportCommand extends BaseCommand {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
Destination d = Destination.parseDestination(args[0], this.plugin);
|
||||
if (d.getType() == DestinationType.World && this.plugin.ph.canEnterWorld(p, this.plugin.getServer().getWorld(d.getName()))) {
|
||||
if (d.getType() == DestinationType.World) {
|
||||
if (!this.plugin.ph.canEnterWorld(p, this.plugin.getServer().getWorld(d.getName()))) {
|
||||
p.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
||||
return;
|
||||
} else if (!this.plugin.ph.canTravelFromWorld(p, this.plugin.getServer().getWorld(d.getName()))) {
|
||||
p.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + d.getName() + " from " + ChatColor.GREEN + p.getWorld().getName());
|
||||
return;
|
||||
}
|
||||
Location l = this.playerTeleporter.getSafeDestination(this.plugin.getServer().getWorld(d.getName()).getSpawnLocation());
|
||||
p.teleport(l);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user