mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-14 02:24:16 +02:00
Modified BetterLocation, and new Permission-System
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import com.earth2me.essentials.api.IPermission;
|
||||
import com.earth2me.essentials.perm.BasePermission;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatPermissions {
|
||||
private static Map<String, IPermission> permissions = new HashMap<String, IPermission>();
|
||||
|
||||
public static IPermission getPermission(final String groupName)
|
||||
{
|
||||
IPermission perm = permissions.get(groupName);
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new BasePermission("essentials.chat.",groupName.toLowerCase(Locale.ENGLISH));
|
||||
permissions.put(groupName, perm);
|
||||
}
|
||||
return perm;
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@ import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IGroups;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
@@ -77,7 +78,7 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
protected void formatChat(final PlayerChatEvent event, final ChatStore chatStore)
|
||||
{
|
||||
final IUser user = chatStore.getUser();
|
||||
if (user.isAuthorized("essentials.chat.color"))
|
||||
if (Permissions.CHAT_COLOR.isAuthorized(user))
|
||||
{
|
||||
event.setMessage(Util.stripColor(event.getMessage()));
|
||||
}
|
||||
@@ -141,10 +142,7 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
|
||||
if (event.getMessage().length() > 1 && chatStore.getType().length() > 0)
|
||||
{
|
||||
final StringBuilder permission = new StringBuilder();
|
||||
permission.append("essentials.chat.").append(chatStore.getType());
|
||||
|
||||
if (user.isAuthorized(permission.toString()))
|
||||
if (ChatPermissions.getPermission(chatStore.getType()).isAuthorized(user))
|
||||
{
|
||||
final StringBuilder format = new StringBuilder();
|
||||
format.append(chatStore.getType()).append("Format");
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.chat;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@@ -52,7 +53,7 @@ public class EssentialsLocalChatEventListener implements Listener
|
||||
|
||||
if (delta > event.getRadius())
|
||||
{
|
||||
if (user.isAuthorized("essentials.chat.spy"))
|
||||
if (Permissions.CHAT_SPY.isAuthorized(user))
|
||||
{
|
||||
type = type.concat(_("chatTypeSpy"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user