mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 03:25:19 +01:00
Cleanup Bukkit/Nukkit dummy classes, some aren't necessary anymore
This commit is contained in:
parent
c7a0e59919
commit
b88819b9bb
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.bukkit.inject.dummy;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Dummy plugin instance
|
||||
*/
|
||||
public class DummyPlugin implements Plugin {
|
||||
public static final DummyPlugin INSTANCE = new DummyPlugin();
|
||||
|
||||
private DummyPlugin() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public @NonNull File getDataFolder() { return null; }
|
||||
@Override public @NonNull PluginDescriptionFile getDescription() { return null; }
|
||||
@Override public @NonNull FileConfiguration getConfig() { return null; }
|
||||
@Override public InputStream getResource(@NonNull String s) { return null; }
|
||||
@Override public void saveConfig() {}
|
||||
@Override public void saveDefaultConfig() {}
|
||||
@Override public void saveResource(@NonNull String s, boolean b) {}
|
||||
@Override public void reloadConfig() {}
|
||||
@Override public @NonNull PluginLoader getPluginLoader() { return null; }
|
||||
@Override public @NonNull Server getServer() { return null; }
|
||||
@Override public void onDisable() {}
|
||||
@Override public void onLoad() {}
|
||||
@Override public void onEnable() {}
|
||||
@Override public boolean isNaggable() { return false; }
|
||||
@Override public void setNaggable(boolean b) {}
|
||||
@Override public ChunkGenerator getDefaultWorldGenerator(@NonNull String s, String s1) { return null; }
|
||||
@Override public @NonNull Logger getLogger() { return null; }
|
||||
@Override public @NonNull String getName() { return null; }
|
||||
@Override public boolean onCommand(@NonNull CommandSender commandSender, @NonNull Command command, @NonNull String s, @NonNull String[] strings) { return false; }
|
||||
@Override public List<String> onTabComplete(@NonNull CommandSender commandSender, @NonNull Command command, @NonNull String s, @NonNull String[] strings) { return null; }
|
||||
|
||||
}
|
@ -23,7 +23,9 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.bukkit.inject.dummy;
|
||||
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||
|
||||
import me.lucko.luckperms.common.util.EmptyCollections;
|
||||
|
||||
import org.bukkit.permissions.PermissibleBase;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@ -33,14 +35,8 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class DummyPermissibleBase extends PermissibleBase {
|
||||
private static final Field ATTACHMENTS_FIELD;
|
||||
@ -61,13 +57,9 @@ public class DummyPermissibleBase extends PermissibleBase {
|
||||
public static void copyFields(PermissibleBase from, PermissibleBase to) {
|
||||
try {
|
||||
ATTACHMENTS_FIELD.set(to, ATTACHMENTS_FIELD.get(from));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
PERMISSIONS_FIELD.set(to, PERMISSIONS_FIELD.get(from));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,29 +68,11 @@ public class DummyPermissibleBase extends PermissibleBase {
|
||||
private DummyPermissibleBase() {
|
||||
super(null);
|
||||
|
||||
// we want the singleton dummy attachment to be stateless
|
||||
// the behaviour of this class is to fail silently, so we can't use Collections.emptyX
|
||||
try {
|
||||
ATTACHMENTS_FIELD.set(this, new ArrayList<PermissionAttachment>(){
|
||||
@Override public boolean add(PermissionAttachment permissionAttachment) { return true; }
|
||||
@Override public void add(int index, PermissionAttachment element) { }
|
||||
@Override public boolean addAll(Collection<? extends PermissionAttachment> c) { return true; }
|
||||
@Override public boolean addAll(int index, Collection<? extends PermissionAttachment> c) { return true; }
|
||||
});
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
PERMISSIONS_FIELD.set(this, new HashMap<String, PermissionAttachmentInfo>() {
|
||||
@Override public PermissionAttachmentInfo put(String key, PermissionAttachmentInfo value) { return null; }
|
||||
@Override public void putAll(Map<? extends String, ? extends PermissionAttachmentInfo> m) { }
|
||||
@Override public PermissionAttachmentInfo putIfAbsent(String key, PermissionAttachmentInfo value) { return null; }
|
||||
@Override public PermissionAttachmentInfo compute(String key, BiFunction<? super String, ? super PermissionAttachmentInfo, ? extends PermissionAttachmentInfo> remappingFunction) { return null; }
|
||||
@Override public PermissionAttachmentInfo computeIfPresent(String key, BiFunction<? super String, ? super PermissionAttachmentInfo, ? extends PermissionAttachmentInfo> remappingFunction) { return null; }
|
||||
@Override public PermissionAttachmentInfo computeIfAbsent(String key, Function<? super String, ? extends PermissionAttachmentInfo> mappingFunction) { return null; }
|
||||
});
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
ATTACHMENTS_FIELD.set(this, EmptyCollections.list());
|
||||
PERMISSIONS_FIELD.set(this, EmptyCollections.map());
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -221,9 +221,7 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public @NonNull LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
Objects.requireNonNull(plugin, "plugin");
|
||||
|
||||
LuckPermsPermissionAttachment attachment = new LuckPermsPermissionAttachment(this, plugin);
|
||||
attachment.hook();
|
||||
@ -232,12 +230,8 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public @NonNull PermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
if (permission == null) {
|
||||
throw new NullPointerException("permission");
|
||||
}
|
||||
Objects.requireNonNull(plugin, "plugin");
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
|
||||
PermissionAttachment attachment = addAttachment(plugin);
|
||||
attachment.setPermission(permission, value);
|
||||
@ -246,9 +240,7 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin, int ticks) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
Objects.requireNonNull(plugin, "plugin");
|
||||
|
||||
if (!plugin.isEnabled()) {
|
||||
throw new IllegalArgumentException("Plugin " + plugin.getDescription().getFullName() + " is not enabled");
|
||||
@ -264,12 +256,8 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value, int ticks) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
if (permission == null) {
|
||||
throw new NullPointerException("permission");
|
||||
}
|
||||
Objects.requireNonNull(plugin, "plugin");
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
|
||||
LuckPermsPermissionAttachment attachment = addAttachment(plugin, ticks);
|
||||
attachment.setPermission(permission, value);
|
||||
@ -278,9 +266,7 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public void removeAttachment(@NonNull PermissionAttachment attachment) {
|
||||
if (attachment == null) {
|
||||
throw new NullPointerException("attachment");
|
||||
}
|
||||
Objects.requireNonNull(attachment, "attachment");
|
||||
|
||||
LuckPermsPermissionAttachment luckPermsAttachment;
|
||||
|
||||
|
@ -27,7 +27,6 @@ package me.lucko.luckperms.bukkit.inject.permissible;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import me.lucko.luckperms.bukkit.inject.dummy.DummyPlugin;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.factory.NodeBuilders;
|
||||
@ -106,7 +105,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
private PermissionAttachment source;
|
||||
|
||||
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, Plugin owner) {
|
||||
super(DummyPlugin.INSTANCE, null);
|
||||
super(owner, null);
|
||||
this.permissible = permissible;
|
||||
this.owner = owner;
|
||||
|
||||
@ -114,7 +113,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
}
|
||||
|
||||
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) {
|
||||
super(DummyPlugin.INSTANCE, null);
|
||||
super(source.getPlugin(), null);
|
||||
this.permissible = permissible;
|
||||
this.owner = source.getPlugin();
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||
|
||||
import me.lucko.luckperms.bukkit.inject.dummy.DummyPermissibleBase;
|
||||
import me.lucko.luckperms.common.calculator.result.TristateResult;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.query.QueryOptionsImpl;
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||
|
||||
import me.lucko.luckperms.bukkit.inject.dummy.DummyPermissibleBase;
|
||||
import me.lucko.luckperms.bukkit.util.CraftBukkitImplementation;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.util;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Empty collections that do not throw {@link UnsupportedOperationException} on mutate operations.
|
||||
*/
|
||||
public final class EmptyCollections {
|
||||
private EmptyCollections() {}
|
||||
|
||||
private static final EmptyList<?> LIST = new EmptyList<>();
|
||||
private static final EmptyMap<?, ?> MAP = new EmptyMap<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> List<E> list() {
|
||||
return (List<E>) LIST;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <K, V> Map<K, V> map() {
|
||||
return (Map<K, V>) MAP;
|
||||
}
|
||||
|
||||
private static final class EmptyList<E> extends AbstractList<E> {
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class EmptyMap<K, V> extends AbstractMap<K, V> {
|
||||
@Override
|
||||
public Set<Entry<K, V>> entrySet() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.nukkit.inject.dummy;
|
||||
|
||||
import cn.nukkit.Server;
|
||||
import cn.nukkit.command.Command;
|
||||
import cn.nukkit.command.CommandSender;
|
||||
import cn.nukkit.plugin.Plugin;
|
||||
import cn.nukkit.plugin.PluginDescription;
|
||||
import cn.nukkit.plugin.PluginLoader;
|
||||
import cn.nukkit.plugin.PluginLogger;
|
||||
import cn.nukkit.utils.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Dummy plugin instance
|
||||
*/
|
||||
public class DummyPlugin implements Plugin {
|
||||
public static final DummyPlugin INSTANCE = new DummyPlugin();
|
||||
|
||||
private DummyPlugin() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public File getDataFolder() { return null; }
|
||||
@Override public PluginDescription getDescription() { return null; }
|
||||
@Override public Config getConfig() { return null; }
|
||||
@Override public InputStream getResource(String s) { return null; }
|
||||
@Override public boolean saveResource(String s) { return false; }
|
||||
@Override public void saveConfig() {}
|
||||
@Override public void saveDefaultConfig() {}
|
||||
@Override public boolean saveResource(String s, boolean b) { return false; }
|
||||
@Override public boolean saveResource(String s, String s1, boolean b) { return false; }
|
||||
@Override public void reloadConfig() {}
|
||||
@Override public PluginLoader getPluginLoader() { return null; }
|
||||
@Override public Server getServer() { return null; }
|
||||
@Override public void onDisable() {}
|
||||
@Override public void onLoad() {}
|
||||
@Override public void onEnable() {}
|
||||
@Override public PluginLogger getLogger() { return null; }
|
||||
@Override public String getName() { return null; }
|
||||
@Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { return false; }
|
||||
|
||||
}
|
@ -23,7 +23,9 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.nukkit.inject.dummy;
|
||||
package me.lucko.luckperms.nukkit.inject.permissible;
|
||||
|
||||
import me.lucko.luckperms.common.util.EmptyCollections;
|
||||
|
||||
import cn.nukkit.permission.PermissibleBase;
|
||||
import cn.nukkit.permission.Permission;
|
||||
@ -32,13 +34,8 @@ import cn.nukkit.permission.PermissionAttachmentInfo;
|
||||
import cn.nukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class DummyPermissibleBase extends PermissibleBase {
|
||||
private static final Field ATTACHMENTS_FIELD;
|
||||
@ -59,13 +56,9 @@ public class DummyPermissibleBase extends PermissibleBase {
|
||||
public static void copyFields(PermissibleBase from, PermissibleBase to) {
|
||||
try {
|
||||
ATTACHMENTS_FIELD.set(to, ATTACHMENTS_FIELD.get(from));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
PERMISSIONS_FIELD.set(to, PERMISSIONS_FIELD.get(from));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,29 +67,11 @@ public class DummyPermissibleBase extends PermissibleBase {
|
||||
private DummyPermissibleBase() {
|
||||
super(null);
|
||||
|
||||
// we want the singleton dummy attachment to be stateless
|
||||
// the behaviour of this class is to fail silently, so we can't use Collections.emptyX
|
||||
try {
|
||||
ATTACHMENTS_FIELD.set(this, new ArrayList<PermissionAttachment>(){
|
||||
@Override public boolean add(PermissionAttachment permissionAttachment) { return true; }
|
||||
@Override public void add(int index, PermissionAttachment element) { }
|
||||
@Override public boolean addAll(Collection<? extends PermissionAttachment> c) { return true; }
|
||||
@Override public boolean addAll(int index, Collection<? extends PermissionAttachment> c) { return true; }
|
||||
});
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
PERMISSIONS_FIELD.set(this, new HashMap<String, PermissionAttachmentInfo>() {
|
||||
@Override public PermissionAttachmentInfo put(String key, PermissionAttachmentInfo value) { return null; }
|
||||
@Override public void putAll(Map<? extends String, ? extends PermissionAttachmentInfo> m) { }
|
||||
@Override public PermissionAttachmentInfo putIfAbsent(String key, PermissionAttachmentInfo value) { return null; }
|
||||
@Override public PermissionAttachmentInfo compute(String key, BiFunction<? super String, ? super PermissionAttachmentInfo, ? extends PermissionAttachmentInfo> remappingFunction) { return null; }
|
||||
@Override public PermissionAttachmentInfo computeIfPresent(String key, BiFunction<? super String, ? super PermissionAttachmentInfo, ? extends PermissionAttachmentInfo> remappingFunction) { return null; }
|
||||
@Override public PermissionAttachmentInfo computeIfAbsent(String key, Function<? super String, ? extends PermissionAttachmentInfo> mappingFunction) { return null; }
|
||||
});
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
ATTACHMENTS_FIELD.set(this, EmptyCollections.list());
|
||||
PERMISSIONS_FIELD.set(this, EmptyCollections.map());
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -224,9 +224,7 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public LuckPermsPermissionAttachment addAttachment(Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
Objects.requireNonNull(plugin, "plugin");
|
||||
|
||||
LuckPermsPermissionAttachment attachment = new LuckPermsPermissionAttachment(this, plugin);
|
||||
attachment.hook();
|
||||
@ -235,12 +233,8 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String permission) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
if (permission == null) {
|
||||
return addAttachment(plugin);
|
||||
}
|
||||
Objects.requireNonNull(plugin, "plugin");
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
|
||||
PermissionAttachment attachment = addAttachment(plugin);
|
||||
attachment.setPermission(permission, true);
|
||||
@ -249,15 +243,9 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String permission, Boolean value) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
if (permission == null) {
|
||||
return addAttachment(plugin);
|
||||
}
|
||||
if (value == null) {
|
||||
return addAttachment(plugin, permission);
|
||||
}
|
||||
Objects.requireNonNull(plugin, "plugin");
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
Objects.requireNonNull(value, "value");
|
||||
|
||||
PermissionAttachment attachment = addAttachment(plugin);
|
||||
attachment.setPermission(permission, value);
|
||||
@ -266,9 +254,7 @@ public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public void removeAttachment(PermissionAttachment attachment) {
|
||||
if (attachment == null) {
|
||||
throw new NullPointerException("attachment");
|
||||
}
|
||||
Objects.requireNonNull(attachment, "attachment");
|
||||
|
||||
LuckPermsPermissionAttachment luckPermsAttachment;
|
||||
|
||||
|
@ -30,7 +30,6 @@ import com.google.common.base.Preconditions;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.factory.NodeBuilders;
|
||||
import me.lucko.luckperms.nukkit.inject.dummy.DummyPlugin;
|
||||
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeBuilder;
|
||||
@ -107,7 +106,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
private PermissionAttachment source;
|
||||
|
||||
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, Plugin owner) {
|
||||
super(DummyPlugin.INSTANCE, null);
|
||||
super(owner, null);
|
||||
this.permissible = permissible;
|
||||
this.owner = owner;
|
||||
|
||||
@ -115,7 +114,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
}
|
||||
|
||||
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) {
|
||||
super(DummyPlugin.INSTANCE, null);
|
||||
super(source.getPlugin(), null);
|
||||
this.permissible = permissible;
|
||||
this.owner = source.getPlugin();
|
||||
|
||||
|
@ -30,7 +30,6 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.query.QueryOptionsImpl;
|
||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||
import me.lucko.luckperms.nukkit.inject.dummy.DummyPermissibleBase;
|
||||
|
||||
import net.luckperms.api.util.Tristate;
|
||||
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
package me.lucko.luckperms.nukkit.inject.permissible;
|
||||
|
||||
import me.lucko.luckperms.nukkit.inject.dummy.DummyPermissibleBase;
|
||||
|
||||
import cn.nukkit.Player;
|
||||
import cn.nukkit.permission.PermissibleBase;
|
||||
import cn.nukkit.permission.PermissionAttachment;
|
||||
|
Loading…
Reference in New Issue
Block a user