Cleanup Bukkit/Nukkit dummy classes, some aren't necessary anymore

This commit is contained in:
Luck 2020-05-11 21:58:24 +01:00
parent c7a0e59919
commit b88819b9bb
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
13 changed files with 129 additions and 280 deletions

View File

@ -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; }
}

View File

@ -23,7 +23,9 @@
* SOFTWARE. * 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.PermissibleBase;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
@ -33,14 +35,8 @@ import org.bukkit.plugin.Plugin;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
public class DummyPermissibleBase extends PermissibleBase { public class DummyPermissibleBase extends PermissibleBase {
private static final Field ATTACHMENTS_FIELD; private static final Field ATTACHMENTS_FIELD;
@ -61,13 +57,9 @@ public class DummyPermissibleBase extends PermissibleBase {
public static void copyFields(PermissibleBase from, PermissibleBase to) { public static void copyFields(PermissibleBase from, PermissibleBase to) {
try { try {
ATTACHMENTS_FIELD.set(to, ATTACHMENTS_FIELD.get(from)); ATTACHMENTS_FIELD.set(to, ATTACHMENTS_FIELD.get(from));
} catch (Exception e) {
// ignore
}
try {
PERMISSIONS_FIELD.set(to, PERMISSIONS_FIELD.get(from)); PERMISSIONS_FIELD.set(to, PERMISSIONS_FIELD.get(from));
} catch (Exception e) { } catch (IllegalAccessException e) {
// ignore throw new RuntimeException(e);
} }
} }
@ -76,29 +68,11 @@ public class DummyPermissibleBase extends PermissibleBase {
private DummyPermissibleBase() { private DummyPermissibleBase() {
super(null); 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 { try {
ATTACHMENTS_FIELD.set(this, new ArrayList<PermissionAttachment>(){ ATTACHMENTS_FIELD.set(this, EmptyCollections.list());
@Override public boolean add(PermissionAttachment permissionAttachment) { return true; } PERMISSIONS_FIELD.set(this, EmptyCollections.map());
@Override public void add(int index, PermissionAttachment element) { } } catch (ReflectiveOperationException e) {
@Override public boolean addAll(Collection<? extends PermissionAttachment> c) { return true; } e.printStackTrace();
@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
} }
} }

View File

@ -221,9 +221,7 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public @NonNull LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin) { public @NonNull LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin) {
if (plugin == null) { Objects.requireNonNull(plugin, "plugin");
throw new NullPointerException("plugin");
}
LuckPermsPermissionAttachment attachment = new LuckPermsPermissionAttachment(this, plugin); LuckPermsPermissionAttachment attachment = new LuckPermsPermissionAttachment(this, plugin);
attachment.hook(); attachment.hook();
@ -232,12 +230,8 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public @NonNull PermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value) { public @NonNull PermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value) {
if (plugin == null) { Objects.requireNonNull(plugin, "plugin");
throw new NullPointerException("plugin"); Objects.requireNonNull(permission, "permission");
}
if (permission == null) {
throw new NullPointerException("permission");
}
PermissionAttachment attachment = addAttachment(plugin); PermissionAttachment attachment = addAttachment(plugin);
attachment.setPermission(permission, value); attachment.setPermission(permission, value);
@ -246,9 +240,7 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin, int ticks) { public LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin, int ticks) {
if (plugin == null) { Objects.requireNonNull(plugin, "plugin");
throw new NullPointerException("plugin");
}
if (!plugin.isEnabled()) { if (!plugin.isEnabled()) {
throw new IllegalArgumentException("Plugin " + plugin.getDescription().getFullName() + " is not enabled"); throw new IllegalArgumentException("Plugin " + plugin.getDescription().getFullName() + " is not enabled");
@ -264,12 +256,8 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value, int ticks) { public LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value, int ticks) {
if (plugin == null) { Objects.requireNonNull(plugin, "plugin");
throw new NullPointerException("plugin"); Objects.requireNonNull(permission, "permission");
}
if (permission == null) {
throw new NullPointerException("permission");
}
LuckPermsPermissionAttachment attachment = addAttachment(plugin, ticks); LuckPermsPermissionAttachment attachment = addAttachment(plugin, ticks);
attachment.setPermission(permission, value); attachment.setPermission(permission, value);
@ -278,9 +266,7 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public void removeAttachment(@NonNull PermissionAttachment attachment) { public void removeAttachment(@NonNull PermissionAttachment attachment) {
if (attachment == null) { Objects.requireNonNull(attachment, "attachment");
throw new NullPointerException("attachment");
}
LuckPermsPermissionAttachment luckPermsAttachment; LuckPermsPermissionAttachment luckPermsAttachment;

View File

@ -27,7 +27,6 @@ package me.lucko.luckperms.bukkit.inject.permissible;
import com.google.common.base.Preconditions; 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.config.ConfigKeys;
import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.node.factory.NodeBuilders; import me.lucko.luckperms.common.node.factory.NodeBuilders;
@ -106,7 +105,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
private PermissionAttachment source; private PermissionAttachment source;
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, Plugin owner) { public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, Plugin owner) {
super(DummyPlugin.INSTANCE, null); super(owner, null);
this.permissible = permissible; this.permissible = permissible;
this.owner = owner; this.owner = owner;
@ -114,7 +113,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
} }
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) { public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) {
super(DummyPlugin.INSTANCE, null); super(source.getPlugin(), null);
this.permissible = permissible; this.permissible = permissible;
this.owner = source.getPlugin(); this.owner = source.getPlugin();

View File

@ -25,7 +25,6 @@
package me.lucko.luckperms.bukkit.inject.permissible; 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.calculator.result.TristateResult;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.query.QueryOptionsImpl; import me.lucko.luckperms.common.query.QueryOptionsImpl;

View File

@ -25,7 +25,6 @@
package me.lucko.luckperms.bukkit.inject.permissible; package me.lucko.luckperms.bukkit.inject.permissible;
import me.lucko.luckperms.bukkit.inject.dummy.DummyPermissibleBase;
import me.lucko.luckperms.bukkit.util.CraftBukkitImplementation; import me.lucko.luckperms.bukkit.util.CraftBukkitImplementation;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -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;
}
}
}

View File

@ -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; }
}

View File

@ -23,7 +23,9 @@
* SOFTWARE. * 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.PermissibleBase;
import cn.nukkit.permission.Permission; import cn.nukkit.permission.Permission;
@ -32,13 +34,8 @@ import cn.nukkit.permission.PermissionAttachmentInfo;
import cn.nukkit.plugin.Plugin; import cn.nukkit.plugin.Plugin;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
public class DummyPermissibleBase extends PermissibleBase { public class DummyPermissibleBase extends PermissibleBase {
private static final Field ATTACHMENTS_FIELD; private static final Field ATTACHMENTS_FIELD;
@ -59,13 +56,9 @@ public class DummyPermissibleBase extends PermissibleBase {
public static void copyFields(PermissibleBase from, PermissibleBase to) { public static void copyFields(PermissibleBase from, PermissibleBase to) {
try { try {
ATTACHMENTS_FIELD.set(to, ATTACHMENTS_FIELD.get(from)); ATTACHMENTS_FIELD.set(to, ATTACHMENTS_FIELD.get(from));
} catch (Exception e) {
// ignore
}
try {
PERMISSIONS_FIELD.set(to, PERMISSIONS_FIELD.get(from)); PERMISSIONS_FIELD.set(to, PERMISSIONS_FIELD.get(from));
} catch (Exception e) { } catch (IllegalAccessException e) {
// ignore throw new RuntimeException(e);
} }
} }
@ -74,29 +67,11 @@ public class DummyPermissibleBase extends PermissibleBase {
private DummyPermissibleBase() { private DummyPermissibleBase() {
super(null); 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 { try {
ATTACHMENTS_FIELD.set(this, new ArrayList<PermissionAttachment>(){ ATTACHMENTS_FIELD.set(this, EmptyCollections.list());
@Override public boolean add(PermissionAttachment permissionAttachment) { return true; } PERMISSIONS_FIELD.set(this, EmptyCollections.map());
@Override public void add(int index, PermissionAttachment element) { } } catch (ReflectiveOperationException e) {
@Override public boolean addAll(Collection<? extends PermissionAttachment> c) { return true; } e.printStackTrace();
@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
} }
} }

View File

@ -224,9 +224,7 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public LuckPermsPermissionAttachment addAttachment(Plugin plugin) { public LuckPermsPermissionAttachment addAttachment(Plugin plugin) {
if (plugin == null) { Objects.requireNonNull(plugin, "plugin");
throw new NullPointerException("plugin");
}
LuckPermsPermissionAttachment attachment = new LuckPermsPermissionAttachment(this, plugin); LuckPermsPermissionAttachment attachment = new LuckPermsPermissionAttachment(this, plugin);
attachment.hook(); attachment.hook();
@ -235,12 +233,8 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public PermissionAttachment addAttachment(Plugin plugin, String permission) { public PermissionAttachment addAttachment(Plugin plugin, String permission) {
if (plugin == null) { Objects.requireNonNull(plugin, "plugin");
throw new NullPointerException("plugin"); Objects.requireNonNull(permission, "permission");
}
if (permission == null) {
return addAttachment(plugin);
}
PermissionAttachment attachment = addAttachment(plugin); PermissionAttachment attachment = addAttachment(plugin);
attachment.setPermission(permission, true); attachment.setPermission(permission, true);
@ -249,15 +243,9 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public PermissionAttachment addAttachment(Plugin plugin, String permission, Boolean value) { public PermissionAttachment addAttachment(Plugin plugin, String permission, Boolean value) {
if (plugin == null) { Objects.requireNonNull(plugin, "plugin");
throw new NullPointerException("plugin"); Objects.requireNonNull(permission, "permission");
} Objects.requireNonNull(value, "value");
if (permission == null) {
return addAttachment(plugin);
}
if (value == null) {
return addAttachment(plugin, permission);
}
PermissionAttachment attachment = addAttachment(plugin); PermissionAttachment attachment = addAttachment(plugin);
attachment.setPermission(permission, value); attachment.setPermission(permission, value);
@ -266,9 +254,7 @@ public class LuckPermsPermissible extends PermissibleBase {
@Override @Override
public void removeAttachment(PermissionAttachment attachment) { public void removeAttachment(PermissionAttachment attachment) {
if (attachment == null) { Objects.requireNonNull(attachment, "attachment");
throw new NullPointerException("attachment");
}
LuckPermsPermissionAttachment luckPermsAttachment; LuckPermsPermissionAttachment luckPermsAttachment;

View File

@ -30,7 +30,6 @@ import com.google.common.base.Preconditions;
import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.node.factory.NodeBuilders; 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.model.data.DataType;
import net.luckperms.api.node.NodeBuilder; import net.luckperms.api.node.NodeBuilder;
@ -107,7 +106,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
private PermissionAttachment source; private PermissionAttachment source;
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, Plugin owner) { public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, Plugin owner) {
super(DummyPlugin.INSTANCE, null); super(owner, null);
this.permissible = permissible; this.permissible = permissible;
this.owner = owner; this.owner = owner;
@ -115,7 +114,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
} }
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) { public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) {
super(DummyPlugin.INSTANCE, null); super(source.getPlugin(), null);
this.permissible = permissible; this.permissible = permissible;
this.owner = source.getPlugin(); this.owner = source.getPlugin();

View File

@ -30,7 +30,6 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.query.QueryOptionsImpl; import me.lucko.luckperms.common.query.QueryOptionsImpl;
import me.lucko.luckperms.common.verbose.VerboseHandler; import me.lucko.luckperms.common.verbose.VerboseHandler;
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent; import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
import me.lucko.luckperms.nukkit.inject.dummy.DummyPermissibleBase;
import net.luckperms.api.util.Tristate; import net.luckperms.api.util.Tristate;

View File

@ -25,8 +25,6 @@
package me.lucko.luckperms.nukkit.inject.permissible; package me.lucko.luckperms.nukkit.inject.permissible;
import me.lucko.luckperms.nukkit.inject.dummy.DummyPermissibleBase;
import cn.nukkit.Player; import cn.nukkit.Player;
import cn.nukkit.permission.PermissibleBase; import cn.nukkit.permission.PermissibleBase;
import cn.nukkit.permission.PermissionAttachment; import cn.nukkit.permission.PermissionAttachment;