mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Updating the permissions for the /ptp command and fixing the event it files to properly show who is teleporting where.
This commit is contained in:
parent
57c8c94db7
commit
6498c711ba
@ -81,6 +81,7 @@ public class Config extends ConfigLoader {
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 30); }
|
||||
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||
|
||||
/* Items */
|
||||
public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); }
|
||||
|
@ -14,6 +14,7 @@ import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
@ -129,6 +130,10 @@ public class PtpCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.accept")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
|
||||
|
||||
if ((mcMMOPlayer.getPtpTimeout() + ptpRequestExpire) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
|
||||
@ -149,7 +154,20 @@ public class PtpCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName());
|
||||
if(Config.getInstance().getPTPCommandWorldPermissions()) {
|
||||
String perm = "mcmmo.commands.ptp.world.";
|
||||
|
||||
if(!Permissions.hasDynamicPermission(target, perm + "all", "op")) {
|
||||
if(!Permissions.hasDynamicPermission(target, perm + target.getWorld().getName(), "op")) {
|
||||
return true;
|
||||
}
|
||||
else if(target.getWorld() != player.getWorld() && !Permissions.hasDynamicPermission(target, perm + player.getWorld().getName(), "op")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(target, player, mcMMOPlayer.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@ -164,6 +182,10 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private boolean acceptAnyTeleportRequest() {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.acceptall")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getPtpConfirmRequired()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
|
||||
}
|
||||
@ -176,6 +198,10 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private boolean togglePartyTeleportation() {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.toggle")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getPtpEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
@ -12,6 +18,22 @@ public final class Permissions {
|
||||
return (sender.hasPermission(perm));
|
||||
}
|
||||
|
||||
public static boolean hasDynamicPermission(CommandSender sender, String perm, String defaultType) {
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
|
||||
if(defaultType != null) {
|
||||
m.put("default", defaultType);
|
||||
}
|
||||
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
|
||||
if (manager.getPermission(perm) == null) {
|
||||
Permission.loadPermission(perm, m);
|
||||
}
|
||||
|
||||
return hasPermission(sender, perm);
|
||||
}
|
||||
|
||||
/*
|
||||
* GENERIC PERMISSIONS
|
||||
*/
|
||||
|
@ -329,6 +329,9 @@ Commands:
|
||||
Cooldown: 30
|
||||
Confirm_Required: true
|
||||
Request_Timeout: 300
|
||||
#If true, require players to have a mcmmo.commands.ptp.world.[WorldName] permission
|
||||
#to teleport to, from, or within any given world.
|
||||
World_Based_Permissions: false
|
||||
p:
|
||||
#Allow mcMMO to use player display names in chat instead of their usernames
|
||||
Use_Display_Names: true
|
||||
|
@ -727,6 +727,7 @@ permissions:
|
||||
mcmmo.commands.mmoedit: true
|
||||
mcmmo.commands.mmoedit.others: true
|
||||
mcmmo.commands.mmoupdate: true
|
||||
mcmmo.commands.ptp.world.all: true
|
||||
mcmmo.commands.skillreset.all: true
|
||||
mcmmo.commands.xprate: true
|
||||
mcmmo.commands.defaults:
|
||||
@ -740,6 +741,9 @@ permissions:
|
||||
mcmmo.commands.mctop.all: true
|
||||
mcmmo.commands.party.all: true
|
||||
mcmmo.commands.ptp: true
|
||||
mcmmo.commands.ptp.accept: true
|
||||
mcmmo.commands.ptp.acceptall: true
|
||||
mcmmo.commands.ptp.toggle: true
|
||||
mcmmo.commands.ability:
|
||||
description: Allows access to the mcability command
|
||||
children:
|
||||
@ -913,8 +917,32 @@ permissions:
|
||||
description: Allows access to the party rename command
|
||||
mcmmo.commands.party.unlock:
|
||||
description: Allows access to the party unlock command
|
||||
mcmmo.commands.ptp.*:
|
||||
description: Implies access to all mcmmo.commands.ptp permissions.
|
||||
children:
|
||||
mcmmo.commands.ptp.all: true
|
||||
mcmmo.commands.ptp.all:
|
||||
description: Implies access to all mcmmo.commands.ptp permissions.
|
||||
children:
|
||||
mcmmo.commands.ptp: true
|
||||
mcmmo.commands.ptp.accept: true
|
||||
mcmmo.commands.ptp.acceptall: true
|
||||
mcmmo.commands.ptp.toggle: true
|
||||
mcmmo.commands.ptp.world.all: true
|
||||
mcmmo.commands.ptp:
|
||||
description: Allows access to the ptp command
|
||||
mcmmo.commands.ptp.accept:
|
||||
description: Allows access to the ptp accept command
|
||||
mcmmo.commands.ptp.acceptall:
|
||||
description: Allows access to the ptp acceptall command
|
||||
mcmmo.commands.ptp.toggle:
|
||||
description: Allows access to the ptp toggle command
|
||||
mcmmo.commands.ptp.world.*:
|
||||
description: Implies access to all mcmmo.commands.ptp.world permissions.
|
||||
children:
|
||||
mcmmo.commands.ptp.world.all: true
|
||||
mcmmo.commands.ptp.world.all:
|
||||
description: Implies access to all mcmmo.commands.ptp.world permissions.
|
||||
mcmmo.commands.skillreset.*:
|
||||
description: Implies access to all mcmmo.commands.skillreset permissions
|
||||
children:
|
||||
|
Loading…
Reference in New Issue
Block a user