From 6e13eb70703f858133711402c9347aad31243023 Mon Sep 17 00:00:00 2001 From: Riaku Date: Thu, 7 Feb 2013 16:06:55 -0600 Subject: adding per-group teleport permissions node: essentials.teleport.groups. config: per-group-teleport: false --- Essentials/src/config.yml | 3 +++ Essentials/src/net/ess3/commands/Commandtp.java | 5 +++++ Essentials/src/net/ess3/commands/Commandtpa.java | 6 +++++- Essentials/src/net/ess3/commands/Commandtpahere.java | 5 +++++ Essentials/src/net/ess3/commands/Commandtpall.java | 2 +- Essentials/src/net/ess3/commands/Commandtphere.java | 8 ++++++++ Essentials/src/net/ess3/commands/Commandtpo.java | 7 +++++++ Essentials/src/net/ess3/commands/Commandtpohere.java | 5 +++++ Essentials/src/net/ess3/permissions/Permissions.java | 1 + Essentials/src/net/ess3/settings/General.java | 2 ++ EssentialsGroupManager/src/Changelog.txt | 6 +++--- 11 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 94d83a444..33c4376bc 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -290,6 +290,9 @@ no-god-in-worlds: # This does not affect the /home command, there is a separate toggle below for this. world-teleport-permissions: false +#Set to true to enable per-group teleporting permissions. +per-group-teleport: false + # The number of items given if the quantity parameter is left out in /item or /give. # If this number is below 1, the maximum stack size size is given. If over-sized stacks # are not enabled, any number higher than the maximum stack size results in more than one stack. diff --git a/Essentials/src/net/ess3/commands/Commandtp.java b/Essentials/src/net/ess3/commands/Commandtp.java index 11ab0f56a..5608a1070 100644 --- a/Essentials/src/net/ess3/commands/Commandtp.java +++ b/Essentials/src/net/ess3/commands/Commandtp.java @@ -27,6 +27,11 @@ public class Commandtp extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName())); } + if (settings.getData().getGeneral().isPerGroupTeleport() && !Permissions.PERGROUPTELEPORT.isAuthorized( + user, ess.getRanks().getMainGroup(player))) + { + throw new Exception(_("noPerm", "essentials.teleport.groups." + ess.getRanks().getMainGroup(player))); + } if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() && !Permissions.WORLD.isAuthorized( user, player.getPlayer().getWorld().getName())) { diff --git a/Essentials/src/net/ess3/commands/Commandtpa.java b/Essentials/src/net/ess3/commands/Commandtpa.java index ac7d9205b..f4d3995da 100644 --- a/Essentials/src/net/ess3/commands/Commandtpa.java +++ b/Essentials/src/net/ess3/commands/Commandtpa.java @@ -22,8 +22,12 @@ public class Commandtpa extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName())); } - ISettings settings = ess.getSettings(); + if (settings.getData().getGeneral().isPerGroupTeleport() && !Permissions.PERGROUPTELEPORT.isAuthorized( + user, ess.getRanks().getMainGroup(player))) + { + throw new Exception(_("noPerm", "essentials.teleport.groups." + ess.getRanks().getMainGroup(player))); + } if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions() && !Permissions.WORLD.isAuthorized( user, user.getPlayer().getWorld().getName())) { diff --git a/Essentials/src/net/ess3/commands/Commandtpahere.java b/Essentials/src/net/ess3/commands/Commandtpahere.java index 42c6ed041..5f4310ad6 100644 --- a/Essentials/src/net/ess3/commands/Commandtpahere.java +++ b/Essentials/src/net/ess3/commands/Commandtpahere.java @@ -24,6 +24,11 @@ public class Commandtpahere extends EssentialsCommand } ISettings settings = ess.getSettings(); + if (settings.getData().getGeneral().isPerGroupTeleport() && !Permissions.PERGROUPTELEPORT.isAuthorized( + user, ess.getRanks().getMainGroup(player))) + { + throw new Exception(_("noPerm", "essentials.teleport.groups." + ess.getRanks().getMainGroup(player))); + } if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() && !Permissions.WORLD.isAuthorized( user, user.getPlayer().getWorld().getName())) { diff --git a/Essentials/src/net/ess3/commands/Commandtpall.java b/Essentials/src/net/ess3/commands/Commandtpall.java index ae061e0df..330fff3fc 100644 --- a/Essentials/src/net/ess3/commands/Commandtpall.java +++ b/Essentials/src/net/ess3/commands/Commandtpall.java @@ -27,7 +27,7 @@ public class Commandtpall extends EssentialsCommand final IUser player = ess.getUserMap().matchUserExcludingHidden(args[0], getPlayerOrNull(sender)); teleportAllPlayers(sender, player); } - + private void teleportAllPlayers(CommandSender sender, IUser user) { sender.sendMessage(_("teleportAll")); diff --git a/Essentials/src/net/ess3/commands/Commandtphere.java b/Essentials/src/net/ess3/commands/Commandtphere.java index 46c9879f9..ec0726f51 100644 --- a/Essentials/src/net/ess3/commands/Commandtphere.java +++ b/Essentials/src/net/ess3/commands/Commandtphere.java @@ -1,8 +1,10 @@ package net.ess3.commands; import static net.ess3.I18n._; +import net.ess3.api.ISettings; import net.ess3.api.IUser; import net.ess3.economy.Trade; +import net.ess3.permissions.Permissions; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -16,6 +18,12 @@ public class Commandtphere extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName())); } + ISettings settings = ess.getSettings(); + if (settings.getData().getGeneral().isPerGroupTeleport() && !Permissions.PERGROUPTELEPORT.isAuthorized( + user, ess.getRanks().getMainGroup(player))) + { + throw new Exception(_("noPerm", "essentials.teleport.groups." + ess.getRanks().getMainGroup(player))); + } user.getTeleport().teleportToMe(player, new Trade(commandName, ess), TeleportCause.COMMAND); user.sendMessage(_("teleporting")); diff --git a/Essentials/src/net/ess3/commands/Commandtpo.java b/Essentials/src/net/ess3/commands/Commandtpo.java index 0ca3df387..d8b1c3c2a 100644 --- a/Essentials/src/net/ess3/commands/Commandtpo.java +++ b/Essentials/src/net/ess3/commands/Commandtpo.java @@ -1,6 +1,7 @@ package net.ess3.commands; import static net.ess3.I18n._; +import net.ess3.api.ISettings; import net.ess3.api.IUser; import net.ess3.permissions.Permissions; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -19,6 +20,12 @@ public class Commandtpo extends EssentialsCommand //Just basically the old tp command final IUser player = ess.getUserMap().matchUser(args[0], false); + ISettings settings = ess.getSettings(); + if (settings.getData().getGeneral().isPerGroupTeleport() && !Permissions.PERGROUPTELEPORT.isAuthorized( + user, ess.getRanks().getMainGroup(player))) + { + throw new Exception(_("noPerm", "essentials.teleport.groups." + ess.getRanks().getMainGroup(player))); + } // Verify permission if (user.getPlayer().canSee(player.getPlayer()) || Permissions.TELEPORT_HIDDEN.isAuthorized(user)) { diff --git a/Essentials/src/net/ess3/commands/Commandtpohere.java b/Essentials/src/net/ess3/commands/Commandtpohere.java index fdadfe88d..b477cef55 100644 --- a/Essentials/src/net/ess3/commands/Commandtpohere.java +++ b/Essentials/src/net/ess3/commands/Commandtpohere.java @@ -27,6 +27,11 @@ public class Commandtpohere extends EssentialsCommand { throw new Exception(_("noPerm", "essentials.world." + user.getPlayer().getWorld().getName())); } + if (settings.getData().getGeneral().isPerGroupTeleport() && !Permissions.PERGROUPTELEPORT.isAuthorized( + user, ess.getRanks().getMainGroup(player))) + { + throw new Exception(_("noPerm", "essentials.teleport.groups." + ess.getRanks().getMainGroup(player))); + } // Verify permission diff --git a/Essentials/src/net/ess3/permissions/Permissions.java b/Essentials/src/net/ess3/permissions/Permissions.java index 60eb45b6a..facdf8962 100644 --- a/Essentials/src/net/ess3/permissions/Permissions.java +++ b/Essentials/src/net/ess3/permissions/Permissions.java @@ -167,6 +167,7 @@ public enum Permissions implements IPermission } public static DotStarPermission ENCHANT = new DotStarPermission("essentials.enchant"); + public static DotStarPermission PERGROUPTELEPORT = new DotStarPermission("essentials.teleport.groups"); public static MaterialDotStarPermission GIVE = new MaterialDotStarPermission("essentials.give", PermissionDefault.TRUE); public static DotStarPermission RANKS = new DotStarPermission("essentials.ranks"); public static DotStarPermission HELP = new DotStarPermission("essentials.help"); diff --git a/Essentials/src/net/ess3/settings/General.java b/Essentials/src/net/ess3/settings/General.java index 6fbdb5b8c..ed956c840 100644 --- a/Essentials/src/net/ess3/settings/General.java +++ b/Essentials/src/net/ess3/settings/General.java @@ -59,6 +59,8 @@ public class General implements StorageObject }) private boolean worldTeleportPermissions = false; private boolean worldHomePermissions = false; + @Comment("Set to true to enable per-group teleporting permissions.") + private boolean perGroupTeleport = false; @Comment("Delay to wait before people can cause attack damage after logging in ") private long loginAttackDelay = 0; diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 4a3c232be..992e49bf5 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -34,10 +34,10 @@ v 1.3: (for all worlds named in config.yml) - Attempt to stop GM wiping groups/users yml's on a bad shut down. - Added event handling to manage new world creation at runtime. - - Added the ability to handle unknown worlds at server start. - (GM will create the data files for any worlds it finds which are not in the config.yml) + - Added the ability to handle unknown worlds at server start. + (GM will create the data files for any worlds it finds which are not in the config.yml) - Fix for Bukkit passing a null To location on a player Portaling - - Fixed manudelsub not correctly selecting the group to remove. + - Fixed manudelsub not correctly selecting the group to remove. - Added two new permission nodes - groupmanager.notify.self & groupmanager.notify.other These allow players/admins to be notified when players are moved between groups. v 1.4: -- cgit v1.2.3