This commit is contained in:
lucko authored and GitHub committed 2026-01-24 12:49:30 +00:00
1 parent 840ac52f83
commit a60d3f1a4b
37 files changed
+3291 -115

No files matched your search

@@ -78,7 +78,8 @@ public interface Platform {
FABRIC("Fabric"),
NEOFORGE("NeoForge"),
FORGE("Forge"),
STANDALONE("Standalone");
STANDALONE("Standalone"),
HYTALE("Hytale");
private final String friendlyName;
@@ -25,24 +25,18 @@
package me.lucko.luckperms.common.calculator;
import me.lucko.luckperms.common.cache.LoadingMap;
import me.lucko.luckperms.common.cacheddata.CacheMetadata;
import me.lucko.luckperms.common.cacheddata.result.TristateResult;
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.verbose.event.CheckOrigin;
import net.luckperms.api.node.Node;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
/**
* Calculates and caches permissions
*/
public class PermissionCalculator implements Function<String, TristateResult> {
public class PermissionCalculator extends PermissionLookupCache {
/** The plugin instance */
private final LuckPermsPlugin plugin;
@@ -50,73 +44,24 @@ public class PermissionCalculator implements Function<String, TristateResult> {
/** Info about the nature of this calculator. */
private final CacheMetadata metadata;
/** The processors which back this calculator */
private final PermissionProcessor[] processors;
/** Loading cache for permission checks */
private final LoadingMap<String, TristateResult> lookupCache = LoadingMap.of(this);
public PermissionCalculator(LuckPermsPlugin plugin, CacheMetadata metadata, Collection<PermissionProcessor> processors) {
super(processors);
this.plugin = plugin;
this.metadata = metadata;
this.processors = processors.toArray(new PermissionProcessor[0]);
}
/**
* Performs a permission check against this calculator.
*
* <p>The result is calculated using the calculators backing 'processors'.</p>
*
* @param permission the permission to check
* @param origin marks where this check originated from
* @return the result
*/
@Override
public TristateResult checkPermission(String permission, CheckOrigin origin) {
// get the result
TristateResult result = this.lookupCache.get(permission);
// log this permission lookup to the verbose handler
TristateResult result = super.checkPermission(permission, origin);
this.plugin.getVerboseHandler().offerPermissionCheckEvent(origin, this.metadata.getVerboseCheckInfo(), this.metadata.getQueryOptions(), permission, result);
// return the result
return result;
}
@Override
public TristateResult apply(@NonNull String permission) {
// convert the permission to lowercase, as all values in the backing map are also lowercase.
// this allows fast case insensitive lookups
permission = permission.toLowerCase(Locale.ROOT);
protected void observePermission(String permission) {
// offer the permission to the permission vault
// we only need to do this once per permission, so it doesn't matter
// that this call is behind the cache.
this.plugin.getPermissionRegistry().offer(permission);
TristateResult result = TristateResult.UNDEFINED;
for (PermissionProcessor processor : this.processors) {
result = processor.hasPermission(result, permission);
}
return result;
}
/**
* Defines the source permissions map which should be used when calculating
* a result.
*
* @param sourceMap the source map
*/
public synchronized void setSourcePermissions(Map<String, Node> sourceMap) {
for (PermissionProcessor processor : this.processors) {
processor.setSource(sourceMap);
processor.refresh();
}
}
public void invalidateCache() {
for (PermissionProcessor processor : this.processors) {
processor.invalidate();
}
this.lookupCache.clear();
}
}
@@ -0,0 +1,106 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.calculator;
import me.lucko.luckperms.common.cache.LoadingMap;
import me.lucko.luckperms.common.cacheddata.result.TristateResult;
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
import me.lucko.luckperms.common.verbose.event.CheckOrigin;
import net.luckperms.api.node.Node;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
/**
* Calculates and caches permissions
*/
public class PermissionLookupCache implements Function<String, TristateResult> {
/** The processors which back this calculator */
private final PermissionProcessor[] processors;
/** Loading cache for permission checks */
private final LoadingMap<String, TristateResult> lookupCache = LoadingMap.of(this);
public PermissionLookupCache(Collection<PermissionProcessor> processors) {
this.processors = processors.toArray(new PermissionProcessor[0]);
}
/**
* Performs a permission check against this calculator.
*
* <p>The result is calculated using the calculators backing 'processors'.</p>
*
* @param permission the permission to check
* @param origin marks where this check originated from
* @return the result
*/
public TristateResult checkPermission(String permission, CheckOrigin origin) {
return this.lookupCache.get(permission);
}
@Override
public TristateResult apply(@NonNull String permission) {
// convert the permission to lowercase, as all values in the backing map are also lowercase.
// this allows fast case insensitive lookups
permission = permission.toLowerCase(Locale.ROOT);
observePermission(permission);
TristateResult result = TristateResult.UNDEFINED;
for (PermissionProcessor processor : this.processors) {
result = processor.hasPermission(result, permission);
}
return result;
}
protected void observePermission(String permission) {
}
/**
* Defines the source permissions map which should be used when calculating
* a result.
*
* @param sourceMap the source map
*/
public synchronized void setSourcePermissions(Map<String, Node> sourceMap) {
for (PermissionProcessor processor : this.processors) {
processor.setSource(sourceMap);
processor.refresh();
}
}
public void invalidateCache() {
for (PermissionProcessor processor : this.processors) {
processor.invalidate();
}
this.lookupCache.clear();
}
}
@@ -334,6 +334,16 @@ public final class ConfigKeys {
*/
public static final ConfigKey<Boolean> APPLY_SPONGE_DEFAULT_SUBJECTS = notReloadable(booleanKey("apply-sponge-default-subjects", true));
/**
* If Hytale virtual groups should be applied
*/
public static final ConfigKey<Boolean> APPLY_HYTALE_VIRTUAL_GROUPS = notReloadable(booleanKey("apply-hytale-virtual-groups", true));
/**
* If LuckPerms should delegate permission checks to the Hytale permissions provider for users/groups not managed by LuckPerms
*/
public static final ConfigKey<Boolean> DELEGATE_TO_HYTALE_PERMISSIONS_PROVIDER = notReloadable(booleanKey("delegate-to-hytale-permissions-provider", true));
/**
* The algorithm LuckPerms should use when traversing the "inheritance tree"
*/
@@ -745,6 +755,16 @@ public final class ConfigKeys {
*/
public static final ConfigKey<String> RABBITMQ_PASSWORD = notReloadable(stringKey("rabbitmq.password", "guest"));
/**
* If the chat formatter is enabled
*/
public static final ConfigKey<Boolean> CHAT_FORMATTER_ENABLED = booleanKey("chat-formatter.enabled", true);
/**
* The chat formatter format string
*/
public static final ConfigKey<String> CHAT_FORMATTER_MESSAGE_FORMAT = stringKey("chat-formatter.message-format", "<prefix><username><suffix>: <message>");
/**
* If the editor key should be generated lazily (only when needed)
*/
@@ -29,6 +29,7 @@ import me.lucko.luckperms.common.actionlog.LogDispatcher;
import me.lucko.luckperms.common.api.ApiRegistrationUtil;
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
import me.lucko.luckperms.common.calculator.CalculatorFactory;
import me.lucko.luckperms.common.command.access.CommandPermission;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter;
@@ -131,6 +132,10 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
// load some utilities early
this.permissionRegistry = new AsyncPermissionRegistry(getBootstrap().getScheduler());
for (CommandPermission permission : CommandPermission.values()) {
this.permissionRegistry.insert(permission.getPermission());
}
this.verboseHandler = new VerboseHandler(getBootstrap().getScheduler());
// load configuration
@@ -41,6 +41,10 @@ public class JarInJarClassPathAppender implements ClassPathAppender {
this.classLoader = (JarInJarClassLoader) classLoader;
}
public JarInJarClassLoader getClassLoader() {
return this.classLoader;
}
@Override
public void addJarToClasspath(Path file) {
try {
@@ -148,7 +148,8 @@ public class TreeView {
.add("uploader", new JObject()
.add("name", sender.getNameWithLocation())
.add("uuid", sender.getUniqueId().toString())
);
)
.add("platform", sender.getPlugin().getBootstrap().getType().getFriendlyName());
JObject checks;
if (user != null && checker != null) {
@@ -262,7 +262,8 @@ public class VerboseListener {
.add("uuid", this.notifiedSender.getUniqueId().toString())
)
.add("filter", this.filter.toString())
.add("truncated", truncated);
.add("truncated", truncated)
.add("platform", this.notifiedSender.getPlugin().getBootstrap().getType().getFriendlyName());
JArray data = new JArray();
for (VerboseEvent event : this.results) {
@@ -152,7 +152,7 @@ public class WebEditorRequest {
private static JObject createJsonPayload(Map<PermissionHolder, List<Node>> holders, Map<Track, List<String>> tracks, Sender sender, String cmdLabel, ImmutableContextSet potentialContexts, LuckPermsPlugin plugin) {
return new JObject()
.add("metadata", formMetadata(sender, cmdLabel, plugin.getBootstrap().getVersion()))
.add("metadata", formMetadata(sender, cmdLabel, plugin.getBootstrap().getVersion(), plugin.getBootstrap().getType().getFriendlyName()))
.add("permissionHolders", new JArray().consume(arr ->
holders.forEach((holder, data) ->
arr.add(formPermissionHolder(holder, data))
@@ -167,7 +167,7 @@ public class WebEditorRequest {
.add("potentialContexts", ContextSetJsonSerializer.serialize(potentialContexts));
}
private static JObject formMetadata(Sender sender, String cmdLabel, String pluginVersion) {
private static JObject formMetadata(Sender sender, String cmdLabel, String pluginVersion, String platform) {
return new JObject()
.add("commandAlias", cmdLabel)
.add("uploader", new JObject()
@@ -175,7 +175,8 @@ public class WebEditorRequest {
.add("uuid", sender.getUniqueId().toString())
)
.add("time", System.currentTimeMillis())
.add("pluginVersion", pluginVersion);
.add("pluginVersion", pluginVersion)
.add("platform", platform);
}
private static JObject formPermissionHolder(PermissionHolder holder, List<Node> data) {
@@ -27,31 +27,19 @@ package me.lucko.luckperms.common.calculator;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.common.cacheddata.CacheMetadata;
import me.lucko.luckperms.common.cacheddata.result.TristateResult;
import me.lucko.luckperms.common.calculator.processor.AbstractOverrideWildcardProcessor;
import me.lucko.luckperms.common.calculator.processor.DirectProcessor;
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
import me.lucko.luckperms.common.calculator.processor.RegexProcessor;
import me.lucko.luckperms.common.calculator.processor.SpongeWildcardProcessor;
import me.lucko.luckperms.common.calculator.processor.WildcardProcessor;
import me.lucko.luckperms.common.model.HolderType;
import me.lucko.luckperms.common.node.factory.NodeBuilders;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.query.QueryOptionsImpl;
import me.lucko.luckperms.common.treeview.PermissionRegistry;
import me.lucko.luckperms.common.verbose.VerboseCheckTarget;
import me.lucko.luckperms.common.verbose.VerboseHandler;
import me.lucko.luckperms.common.verbose.event.CheckOrigin;
import net.luckperms.api.node.Node;
import net.luckperms.api.util.Tristate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Map;
import java.util.stream.Collectors;
@@ -60,17 +48,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
@ExtendWith(MockitoExtension.class)
public class PermissionCalculatorTest {
private static final CacheMetadata MOCK_METADATA = new CacheMetadata(
HolderType.GROUP,
VerboseCheckTarget.of(VerboseCheckTarget.GROUP_TYPE, "test"),
QueryOptionsImpl.DEFAULT_CONTEXTUAL
);
public class PermissionLookupCacheTest {
private static final Map<String, Node> EXAMPLE_PERMISSIONS = ImmutableMap.<String, Boolean>builder()
// direct
@@ -100,18 +79,6 @@ public class PermissionCalculatorTest {
e -> NodeBuilders.determineMostApplicable(e.getKey()).value(e.getValue()).build()
));
@Mock private LuckPermsPlugin plugin;
@BeforeEach
public void setupMocks() {
lenient().when(this.plugin.getVerboseHandler()).thenReturn(mock(VerboseHandler.class));
lenient().when(this.plugin.getPermissionRegistry()).thenReturn(mock(PermissionRegistry.class));
}
private PermissionCalculator createCalculator(PermissionProcessor... processors) {
return new PermissionCalculator(this.plugin, MOCK_METADATA, ImmutableList.copyOf(processors));
}
@ParameterizedTest
@CsvSource({
"test, UNDEFINED",
@@ -119,10 +86,10 @@ public class PermissionCalculatorTest {
"test.node2, FALSE"
})
public void testDirect(String node, Tristate expected) {
PermissionCalculator calculator = createCalculator(new DirectProcessor());
calculator.setSourcePermissions(EXAMPLE_PERMISSIONS);
PermissionLookupCache lookupCache = new PermissionLookupCache(ImmutableList.of(new DirectProcessor()));
lookupCache.setSourcePermissions(EXAMPLE_PERMISSIONS);
TristateResult result = calculator.checkPermission(node, CheckOrigin.INTERNAL);
TristateResult result = lookupCache.checkPermission(node, CheckOrigin.INTERNAL);
assertEquals(expected, result.result());
assertNull(result.overriddenResult());
@@ -151,10 +118,10 @@ public class PermissionCalculatorTest {
"*, false, direct",
})
public void testWildcard(String node, boolean expected, String type) {
PermissionCalculator calculator = createCalculator(new DirectProcessor(), new WildcardProcessor());
calculator.setSourcePermissions(EXAMPLE_PERMISSIONS);
PermissionLookupCache lookupCache = new PermissionLookupCache(ImmutableList.of(new DirectProcessor(), new WildcardProcessor()));
lookupCache.setSourcePermissions(EXAMPLE_PERMISSIONS);
TristateResult result = calculator.checkPermission(node, CheckOrigin.INTERNAL);
TristateResult result = lookupCache.checkPermission(node, CheckOrigin.INTERNAL);
assertEquals(Tristate.of(expected), result.result());
assertNull(result.overriddenResult());
assertNotNull(result.node());
@@ -176,10 +143,10 @@ public class PermissionCalculatorTest {
"one.two.test, true, wildcard",
})
public void testSpongeWildcard(String node, boolean expected, String type) {
PermissionCalculator calculator = createCalculator(new DirectProcessor(), new SpongeWildcardProcessor());
calculator.setSourcePermissions(EXAMPLE_PERMISSIONS);
PermissionLookupCache lookupCache = new PermissionLookupCache(ImmutableList.of(new DirectProcessor(), new SpongeWildcardProcessor()));
lookupCache.setSourcePermissions(EXAMPLE_PERMISSIONS);
TristateResult result = calculator.checkPermission(node, CheckOrigin.INTERNAL);
TristateResult result = lookupCache.checkPermission(node, CheckOrigin.INTERNAL);
assertEquals(Tristate.of(expected), result.result());
assertNull(result.overriddenResult());
assertNotNull(result.node());
@@ -205,10 +172,10 @@ public class PermissionCalculatorTest {
"regexps4, FALSE",
})
public void testRegex(String node, Tristate expected) {
PermissionCalculator calculator = createCalculator(new DirectProcessor(), new RegexProcessor());
calculator.setSourcePermissions(EXAMPLE_PERMISSIONS);
PermissionLookupCache lookupCache = new PermissionLookupCache(ImmutableList.of(new DirectProcessor(), new RegexProcessor()));
lookupCache.setSourcePermissions(EXAMPLE_PERMISSIONS);
TristateResult result = calculator.checkPermission(node, CheckOrigin.INTERNAL);
TristateResult result = lookupCache.checkPermission(node, CheckOrigin.INTERNAL);
assertEquals(expected, result.result());
assertNull(result.overriddenResult());
@@ -234,10 +201,10 @@ public class PermissionCalculatorTest {
}
};
PermissionCalculator calculator = createCalculator(new DirectProcessor(), new WildcardProcessor(), overrideProcessor);
calculator.setSourcePermissions(EXAMPLE_PERMISSIONS);
PermissionLookupCache lookupCache = new PermissionLookupCache(ImmutableList.of(new DirectProcessor(), new WildcardProcessor(), overrideProcessor));
lookupCache.setSourcePermissions(EXAMPLE_PERMISSIONS);
TristateResult result = calculator.checkPermission("overridetest.test", CheckOrigin.INTERNAL);
TristateResult result = lookupCache.checkPermission("overridetest.test", CheckOrigin.INTERNAL);
assertEquals(Tristate.FALSE, result.result());
assertSame(AbstractOverrideWildcardProcessor.class, result.processorClass());
+56
View File
@@ -0,0 +1,56 @@
plugins {
alias(libs.plugins.shadow)
}
sourceCompatibility = 21
targetCompatibility = 21
dependencies {
implementation project(':common')
compileOnly project(':common:loader-utils')
implementation 'com.google.guava:guava:19.0'
implementation 'com.google.code.gson:gson:2.7'
compileOnly 'com.hypixel.hytale:Server:2026.01.24-6e2d4fc36'
}
repositories {
maven { url 'https://maven.hytale.com/release/' }
}
shadowJar {
archiveFileName = 'luckperms-hytale.jarinjar'
dependencies {
include(dependency('me.lucko.luckperms:.*'))
include(dependency('com.google.guava:guava:.*'))
include(dependency('com.google.code.gson:gson:.*'))
}
//relocate 'com.google.common', 'me.lucko.luckperms.lib.guava'
//relocate 'com.google.gson', 'me.lucko.luckperms.lib.gson'
relocate 'net.kyori.adventure', 'me.lucko.luckperms.lib.adventure'
relocate 'net.kyori.event', 'me.lucko.luckperms.lib.eventbus'
relocate 'com.github.benmanes.caffeine', 'me.lucko.luckperms.lib.caffeine'
relocate 'okio', 'me.lucko.luckperms.lib.okio'
relocate 'okhttp3', 'me.lucko.luckperms.lib.okhttp3'
relocate 'net.bytebuddy', 'me.lucko.luckperms.lib.bytebuddy'
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
relocate 'redis.clients.jedis', 'me.lucko.luckperms.lib.jedis'
relocate 'io.nats.client', 'me.lucko.luckperms.lib.nats'
relocate 'com.rabbitmq', 'me.lucko.luckperms.lib.rabbitmq'
relocate 'org.apache.commons.pool2', 'me.lucko.luckperms.lib.commonspool2'
relocate 'ninja.leaping.configurate', 'me.lucko.luckperms.lib.configurate'
}
artifacts {
archives shadowJar
}
+32
View File
@@ -0,0 +1,32 @@
plugins {
alias(libs.plugins.shadow)
}
dependencies {
implementation project(':api')
implementation project(':common:loader-utils')
compileOnly 'com.hypixel.hytale:Server:2026.01.24-6e2d4fc36'
}
repositories {
maven { url 'https://maven.hytale.com/release/' }
}
processResources {
filesMatching('manifest.json') {
expand 'pluginVersion': project.ext.fullVersion
}
}
shadowJar {
archiveFileName = "LuckPerms-Hytale-${project.ext.fullVersion}.jar"
from {
project(':hytale').tasks.shadowJar.archiveFile
}
}
artifacts {
archives shadowJar
}
@@ -0,0 +1,61 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.loader;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import me.lucko.luckperms.common.loader.JarInJarClassLoader;
import me.lucko.luckperms.common.loader.LoaderBootstrap;
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
public class HytaleLoaderPlugin extends JavaPlugin {
private static final String JAR_NAME = "luckperms-hytale.jarinjar";
private static final String BOOTSTRAP_CLASS = "me.lucko.luckperms.hytale.LPHytaleBootstrap";
private final LoaderBootstrap plugin;
public HytaleLoaderPlugin(@NonNullDecl JavaPluginInit init) {
super(init);
JarInJarClassLoader loader = new JarInJarClassLoader(getClass().getClassLoader(), JAR_NAME);
this.plugin = loader.instantiatePlugin(BOOTSTRAP_CLASS, JavaPlugin.class, this);
}
@Override
protected void setup() {
this.plugin.onLoad();
}
@Override
protected void start() {
this.plugin.onEnable();
}
@Override
protected void shutdown() {
this.plugin.onDisable();
}
}
@@ -0,0 +1,14 @@
{
"Group": "LuckPerms",
"Name": "LuckPerms",
"Version": "${pluginVersion}",
"Description": "A permissions plugin",
"Authors": [{"Name": "Luck"}],
"Website": "https://luckperms.net",
"ServerVersion": "*",
"Dependencies": {},
"OptionalDependencies": {},
"DisabledByDefault": false,
"Main": "me.lucko.luckperms.hytale.loader.HytaleLoaderPlugin",
"IncludesAssetPack": false
}
@@ -0,0 +1,104 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale;
import com.hypixel.hytale.server.core.command.system.AbstractCommand;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.ParseResult;
import com.hypixel.hytale.server.core.command.system.ParserContext;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.command.utils.ArgumentTokenizer;
import me.lucko.luckperms.common.sender.Sender;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class HytaleCommandManager extends CommandManager {
private final LPHytalePlugin plugin;
public HytaleCommandManager(LPHytalePlugin plugin) {
super(plugin);
this.plugin = plugin;
}
public void register() {
this.plugin.getLoader().getCommandRegistry().registerCommand(new Command());
}
public CompletableFuture<Void> execute(CommandSender sender, String inputString) {
Sender wrapped = this.plugin.getSenderFactory().wrap(sender);
List<String> arguments = ArgumentTokenizer.EXECUTE.tokenizeInput(inputString);
if (!arguments.isEmpty()) {
String first = arguments.get(0);
if (first.equals("luckperms") || first.equals("lp") || first.equals("/luckperms") || first.equals("/lp")) {
arguments.remove(0);
}
}
return executeCommand(wrapped, "lp", arguments);
}
public boolean hasPermissionForAny(CommandSender sender) {
Sender wrapped = this.plugin.getSenderFactory().wrap(sender);
return hasPermissionForAny(wrapped);
}
// public List<String> suggest(CommandContext ctx) {
// Sender wrapped = this.plugin.getSenderFactory().wrap(ctx.sender());
// List<String> arguments = ArgumentTokenizer.TAB_COMPLETE.tokenizeInput(ctx.getInputString());
// return tabCompleteCommand(wrapped, arguments);
// }
private class Command extends AbstractCommand {
Command() {
super("luckperms", "LuckPerms command");
addAliases("lp");
setAllowsExtraArguments(true);
}
@Override
public @Nullable CompletableFuture<Void> acceptCall(@NonNull CommandSender sender, @NonNull ParserContext parserContext, @NonNull ParseResult parseResult) {
return HytaleCommandManager.this.execute(sender, parserContext.getInputString());
}
@Override
protected @Nullable CompletableFuture<Void> execute(@NonNull CommandContext ctx) {
throw new UnsupportedOperationException();
}
@Override
protected boolean canGeneratePermission() {
return false;
}
@Override
public boolean hasPermission(@NonNull CommandSender sender) {
return HytaleCommandManager.this.hasPermissionForAny(sender);
}
}
}
@@ -0,0 +1,46 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale;
import me.lucko.luckperms.common.config.generic.adapter.ConfigurateConfigAdapter;
import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import java.nio.file.Path;
public class HytaleConfigAdapter extends ConfigurateConfigAdapter implements ConfigurationAdapter {
public HytaleConfigAdapter(LuckPermsPlugin plugin, Path path) {
super(plugin, path);
}
@Override
protected ConfigurationLoader<? extends ConfigurationNode> createLoader(Path path) {
return YAMLConfigurationLoader.builder().setPath(path).build();
}
}
@@ -0,0 +1,54 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale;
import com.hypixel.hytale.server.core.plugin.PluginBase;
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
import me.lucko.luckperms.common.event.AbstractEventBus;
public class HytaleEventBus extends AbstractEventBus<PluginBase> {
public HytaleEventBus(LPHytalePlugin plugin, LuckPermsApiProvider apiProvider) {
super(plugin, apiProvider);
// register listener
// TODO
}
@Override
protected PluginBase checkPlugin(Object plugin) throws IllegalArgumentException {
if (plugin instanceof PluginBase) {
return (PluginBase) plugin;
}
throw new IllegalArgumentException("Object " + plugin + " (" + plugin.getClass().getName() + ") is not a plugin.");
}
//public void onPluginDisable(PluginDisableEvent e) {
// Plugin plugin = e.getPlugin();
// unregisterHandlers(plugin);
//}
}
@@ -0,0 +1,62 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale;
import com.hypixel.hytale.logger.HytaleLogger;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
public class HytalePluginLogger implements PluginLogger {
private final HytaleLogger logger;
public HytalePluginLogger(HytaleLogger logger) {
this.logger = logger;
}
@Override
public void info(String s) {
this.logger.atInfo().log(s);
}
@Override
public void warn(String s) {
this.logger.atWarning().log(s);
}
@Override
public void warn(String s, Throwable t) {
this.logger.atWarning().withCause(t).log(s);
}
@Override
public void severe(String s) {
this.logger.atSevere().log(s);
}
@Override
public void severe(String s, Throwable t) {
this.logger.atSevere().withCause(t).log(s);
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale;
import me.lucko.luckperms.common.plugin.scheduler.AbstractJavaScheduler;
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
import java.util.concurrent.Executor;
public class HytaleSchedulerAdapter extends AbstractJavaScheduler implements SchedulerAdapter {
public HytaleSchedulerAdapter(LPHytaleBootstrap bootstrap) {
super(bootstrap);
}
@Override
public Executor sync() {
return this.async();
}
}
@@ -0,0 +1,173 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandManager;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.console.ConsoleSender;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.receiver.IMessageReceiver;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import me.lucko.luckperms.common.locale.TranslationManager;
import me.lucko.luckperms.common.sender.Sender;
import me.lucko.luckperms.common.sender.SenderFactory;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.luckperms.api.util.Tristate;
import java.util.Locale;
import java.util.UUID;
public class HytaleSenderFactory extends SenderFactory<LPHytalePlugin, IMessageReceiver> {
public HytaleSenderFactory(LPHytalePlugin plugin) {
super(plugin);
}
// Enforce that sender is either a `PlayerRef` or `CommandSender`
private void checkType(IMessageReceiver sender) {
if (sender instanceof PlayerRef || sender instanceof CommandSender) {
return;
}
throw new IllegalArgumentException("Unsupported sender type: " + sender.getClass().getName());
}
@Override
protected String getName(IMessageReceiver sender) {
checkType(sender);
if (sender instanceof Player player) {
return player.getDisplayName();
} else if (sender instanceof PlayerRef playerRef) {
return playerRef.getUsername();
}
return Sender.CONSOLE_NAME;
}
@Override
protected UUID getUniqueId(IMessageReceiver sender) {
checkType(sender);
if (sender instanceof Player player) {
//noinspection removal
return player.getPlayerRef().getUuid();
} else if (sender instanceof PlayerRef playerRef) {
return playerRef.getUuid();
}
return Sender.CONSOLE_UUID;
}
@Override
protected void sendMessage(IMessageReceiver sender, Component message) {
checkType(sender);
Locale locale = null;
if (sender instanceof Player player) {
//noinspection removal
locale = TranslationManager.parseLocale(player.getPlayerRef().getLanguage());
} else if (sender instanceof PlayerRef playerRef) {
locale = TranslationManager.parseLocale(playerRef.getLanguage());
}
Component rendered = TranslationManager.render(message, locale);
sender.sendMessage(toHytaleMessage(rendered));
}
@Override
protected Tristate getPermissionValue(IMessageReceiver sender, String node) {
return Tristate.of(hasPermission(sender, node));
}
@Override
protected boolean hasPermission(IMessageReceiver sender, String node) {
checkType(sender);
if (sender instanceof CommandSender commandSender) {
return commandSender.hasPermission(node);
}
if (sender instanceof PlayerRef playerRef) {
return PermissionsModule.get().hasPermission(playerRef.getUuid(), node);
}
throw new AssertionError();
}
@Override
protected void performCommand(IMessageReceiver sender, String command) {
checkType(sender);
if (sender instanceof CommandSender commandSender) {
CommandManager.get().handleCommand(commandSender, command).join();
}
if (sender instanceof PlayerRef playerRef) {
CommandManager.get().handleCommand(playerRef, command).join();
}
throw new AssertionError();
}
@Override
protected boolean isConsole(IMessageReceiver sender) {
return sender instanceof ConsoleSender;
}
public static Message toHytaleMessage(Component component) {
if (!(component instanceof TextComponent text)) {
throw new UnsupportedOperationException("Unsupported component type: " + component.getClass());
}
Message message = Message.raw(text.content());
TextColor color = text.color();
if (color != null) {
message.color(color.asHexString());
}
TextDecoration.State bold = text.decoration(TextDecoration.BOLD);
if (bold != TextDecoration.State.NOT_SET) {
message.bold(bold == TextDecoration.State.TRUE);
}
TextDecoration.State italic = text.decoration(TextDecoration.ITALIC);
if (italic != TextDecoration.State.NOT_SET) {
message.italic(italic == TextDecoration.State.TRUE);
}
ClickEvent clickEvent = text.clickEvent();
if (clickEvent != null && clickEvent.action() == ClickEvent.Action.OPEN_URL) {
message.link(clickEvent.value());
}
message.insertAll(text.children().stream()
.map(HytaleSenderFactory::toHytaleMessage)
.toList()
);
return message;
}
}
@@ -0,0 +1,303 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale;
import com.hypixel.hytale.common.util.java.ManifestUtil;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.auth.ProfileServiceClient.PublicGameProfile;
import com.hypixel.hytale.server.core.auth.ServerAuthManager;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.PluginClassLoader;
import com.hypixel.hytale.server.core.plugin.PluginManager;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import me.lucko.luckperms.common.loader.LoaderBootstrap;
import me.lucko.luckperms.common.plugin.bootstrap.BootstrappedWithLoader;
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
import me.lucko.luckperms.common.plugin.classpath.ClassPathAppender;
import me.lucko.luckperms.common.plugin.classpath.JarInJarClassPathAppender;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import net.luckperms.api.platform.Platform;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.nio.file.Path;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Bootstrap plugin for LuckPerms running on Hytale.
*/
public class LPHytaleBootstrap implements LuckPermsBootstrap, LoaderBootstrap, BootstrappedWithLoader {
private final JavaPlugin loader;
/**
* The plugin logger
*/
private final PluginLogger logger;
/**
* A scheduler adapter for the platform
*/
private final HytaleSchedulerAdapter schedulerAdapter;
/**
* The plugin class path appender
*/
private final JarInJarClassPathAppender classPathAppender;
/**
* The plugin instance
*/
private final LPHytalePlugin plugin;
/**
* The time when the plugin was enabled
*/
private Instant startTime;
// load/enable latches
private final CountDownLatch loadLatch = new CountDownLatch(1);
private final CountDownLatch enableLatch = new CountDownLatch(1);
public LPHytaleBootstrap(JavaPlugin loader) {
this.loader = loader;
this.logger = new HytalePluginLogger(loader.getLogger());
this.schedulerAdapter = new HytaleSchedulerAdapter(this);
this.classPathAppender = new JarInJarClassPathAppender(getClass().getClassLoader());
this.plugin = new LPHytalePlugin(this);
}
// provide adapters
@Override
public JavaPlugin getLoader() {
return this.loader;
}
@Override
public PluginLogger getPluginLogger() {
return this.logger;
}
@Override
public HytaleSchedulerAdapter getScheduler() {
return this.schedulerAdapter;
}
@Override
public ClassPathAppender getClassPathAppender() {
return this.classPathAppender;
}
@Override
public InputStream getResourceStream(String path) {
// avoid picking up resources in other mods
URL url = this.classPathAppender.getClassLoader().findResource(path);
try {
return url != null ? url.openStream() : null;
} catch (IOException e) {
return null;
}
}
// lifecycle
@Override
public void onLoad() {
try {
this.plugin.load();
} finally {
this.loadLatch.countDown();
}
}
@Override
public void onEnable() {
this.startTime = Instant.now();
try {
this.plugin.enable();
} finally {
this.enableLatch.countDown();
}
}
@Override
public void onDisable() {
// hack - allow us to load classes during disable
ReentrantReadWriteLock lock = null;
boolean didUnlock = false;
try {
PluginManager pluginManager = HytaleServer.get().getPluginManager();
Field lockField = PluginManager.class.getDeclaredField("lock");
lockField.setAccessible(true);
lock = (ReentrantReadWriteLock) lockField.get(pluginManager);
try {
lock.writeLock().unlock();
didUnlock = true;
} catch (IllegalMonitorStateException e) {
// ignore
}
} catch (Exception e) {
// ignore
}
try {
this.plugin.disable();
} finally {
if (lock != null && didUnlock) {
lock.writeLock().lock();
}
}
}
@Override
public CountDownLatch getEnableLatch() {
return this.enableLatch;
}
@Override
public CountDownLatch getLoadLatch() {
return this.loadLatch;
}
// provide information about the plugin
@Override
public String getVersion() {
return this.loader.getManifest().getVersion().toString();
}
@Override
public Instant getStartupTime() {
return this.startTime;
}
// provide information about the platform
@Override
public Platform.Type getType() {
return Platform.Type.HYTALE;
}
@Override
public String getServerBrand() {
return "Hytale";
}
@Override
public String getServerVersion() {
return ManifestUtil.getImplementationVersion();
}
@Override
public Path getDataDirectory() {
return this.loader.getDataDirectory().toAbsolutePath();
}
@Override
public Optional<PlayerRef> getPlayer(UUID uniqueId) {
return Optional.ofNullable(Universe.get().getPlayer(uniqueId));
}
@Override
public Optional<UUID> lookupUniqueId(String username) {
ServerAuthManager authManager = ServerAuthManager.getInstance();
String sessionToken = authManager.getSessionToken();
if (sessionToken == null) {
return Optional.empty();
}
PublicGameProfile profile = authManager.getProfileServiceClient().getProfileByUsername(username, sessionToken);
return Optional.ofNullable(profile).map(PublicGameProfile::getUuid);
}
@Override
public Optional<String> lookupUsername(UUID uniqueId) {
ServerAuthManager authManager = ServerAuthManager.getInstance();
String sessionToken = authManager.getSessionToken();
if (sessionToken == null) {
return Optional.empty();
}
PublicGameProfile profile = authManager.getProfileServiceClient().getProfileByUuid(uniqueId, sessionToken);
return Optional.ofNullable(profile).map(PublicGameProfile::getUsername);
}
@Override
public int getPlayerCount() {
return Universe.get().getPlayerCount();
}
@Override
public Collection<String> getPlayerList() {
List<PlayerRef> players = Universe.get().getPlayers();
List<String> list = new ArrayList<>(players.size());
for (PlayerRef player : players) {
list.add(player.getUsername());
}
return list;
}
@Override
public Collection<UUID> getOnlinePlayers() {
List<PlayerRef> players = Universe.get().getPlayers();
List<UUID> list = new ArrayList<>(players.size());
for (PlayerRef player : players) {
list.add(player.getUuid());
}
return list;
}
@Override
public boolean isPlayerOnline(UUID uniqueId) {
return Universe.get().getPlayer(uniqueId) != null;
}
@Override
public @Nullable String identifyClassLoader(ClassLoader classLoader) throws ReflectiveOperationException {
if (classLoader instanceof PluginClassLoader) {
Field pluginField = PluginClassLoader.class.getDeclaredField("plugin");
pluginField.setAccessible(true);
JavaPlugin plugin = (JavaPlugin) pluginField.get(classLoader);
return plugin.getName();
}
return null;
}
}
@@ -0,0 +1,273 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale;
import com.hypixel.hytale.server.core.console.ConsoleSender;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.permissions.provider.HytalePermissionsProvider;
import com.hypixel.hytale.server.core.permissions.provider.PermissionProvider;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.universe.Universe;
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
import me.lucko.luckperms.common.calculator.CalculatorFactory;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
import me.lucko.luckperms.common.messaging.MessagingFactory;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.model.manager.group.StandardGroupManager;
import me.lucko.luckperms.common.model.manager.track.StandardTrackManager;
import me.lucko.luckperms.common.model.manager.user.StandardUserManager;
import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin;
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
import me.lucko.luckperms.common.sender.Sender;
import me.lucko.luckperms.hytale.calculator.HytaleCalculatorFactory;
import me.lucko.luckperms.hytale.calculator.virtualgroups.VirtualGroupsLookupProvider;
import me.lucko.luckperms.hytale.chat.LuckPermsChatFormatter;
import me.lucko.luckperms.hytale.context.HytaleContextManager;
import me.lucko.luckperms.hytale.context.HytalePlayerCalculator;
import me.lucko.luckperms.hytale.listeners.HytaleConnectionListener;
import me.lucko.luckperms.hytale.listeners.HytalePlatformListener;
import me.lucko.luckperms.hytale.service.LuckPermsPermissionProvider;
import me.lucko.luckperms.hytale.service.PlayerVirtualGroupsMap;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.query.QueryOptions;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
/**
* LuckPerms implementation for Hytale.
*/
public class LPHytalePlugin extends AbstractLuckPermsPlugin {
private final LPHytaleBootstrap bootstrap;
private HytaleSenderFactory senderFactory;
private HytaleConnectionListener connectionListener;
private HytaleCommandManager commandManager;
private StandardUserManager userManager;
private StandardGroupManager groupManager;
private StandardTrackManager trackManager;
private HytaleContextManager contextManager;
private PlayerVirtualGroupsMap playerVirtualGroupsMap;
private VirtualGroupsLookupProvider virtualGroupsLookupProvider;
private LuckPermsPermissionProvider luckPermsPermissionProvider;
public LPHytalePlugin(LPHytaleBootstrap bootstrap) {
this.bootstrap = bootstrap;
}
@Override
public LPHytaleBootstrap getBootstrap() {
return this.bootstrap;
}
public JavaPlugin getLoader() {
return this.bootstrap.getLoader();
}
@Override
protected void setupSenderFactory() {
this.senderFactory = new HytaleSenderFactory(this);
}
@Override
protected Set<Dependency> getGlobalDependencies() {
Set<Dependency> dependencies = super.getGlobalDependencies();
// required for loading the LP config
dependencies.add(Dependency.CONFIGURATE_CORE);
dependencies.add(Dependency.CONFIGURATE_YAML);
dependencies.add(Dependency.SNAKEYAML);
return dependencies;
}
@Override
protected ConfigurationAdapter provideConfigurationAdapter() {
return new HytaleConfigAdapter(this, resolveConfig("config.yml"));
}
@Override
protected void registerPlatformListeners() {
this.connectionListener = new HytaleConnectionListener(this);
this.connectionListener.register(this.bootstrap.getLoader().getEventRegistry());
}
@Override
protected MessagingFactory<?> provideMessagingFactory() {
return new MessagingFactory<>(this);
}
@Override
protected void registerCommands() {
this.commandManager = new HytaleCommandManager(this);
this.commandManager.register();
}
@Override
protected void setupManagers() {
this.userManager = new StandardUserManager(this);
this.groupManager = new StandardGroupManager(this);
this.trackManager = new StandardTrackManager(this);
}
@Override
protected CalculatorFactory provideCalculatorFactory() {
this.virtualGroupsLookupProvider = new VirtualGroupsLookupProvider();
return new HytaleCalculatorFactory(this, this.virtualGroupsLookupProvider);
}
@Override
protected void setupContextManager() {
this.playerVirtualGroupsMap = new PlayerVirtualGroupsMap();
this.contextManager = new HytaleContextManager(this, this.playerVirtualGroupsMap);
HytalePlayerCalculator playerCalculator = new HytalePlayerCalculator(this, getConfiguration().get(ConfigKeys.DISABLED_CONTEXTS));
playerCalculator.registerEvents(this.bootstrap.getLoader().getEventRegistry());
playerCalculator.registerSystems(this.bootstrap.getLoader().getEntityStoreRegistry());
this.contextManager.registerCalculator(playerCalculator);
}
@Override
protected void setupPlatformHooks() {
// permissions
PermissionsModule permissionsModule = PermissionsModule.get();
// find the hytale provider
HytalePermissionsProvider hytaleProvider = null;
for (PermissionProvider provider : permissionsModule.getProviders()) {
if (provider instanceof HytalePermissionsProvider hpp) {
hytaleProvider = hpp;
break;
}
}
// register our provider
this.luckPermsPermissionProvider = new LuckPermsPermissionProvider(this, hytaleProvider, this.playerVirtualGroupsMap);
permissionsModule.addProvider(this.luckPermsPermissionProvider);
// remove all other providers
for (PermissionProvider provider : permissionsModule.getProviders()) {
if (provider != this.luckPermsPermissionProvider) {
permissionsModule.removeProvider(provider);
}
}
// chat
if (getConfiguration().get(ConfigKeys.CHAT_FORMATTER_ENABLED)) {
LuckPermsChatFormatter chatFormatter = new LuckPermsChatFormatter(this);
chatFormatter.register(this.bootstrap.getLoader().getEventRegistry());
}
// general
HytalePlatformListener platformListener = new HytalePlatformListener(this);
platformListener.register(this.bootstrap.getLoader().getEventRegistry());
}
@Override
protected void removePlatformHooks() {
PermissionsModule permissionsModule = PermissionsModule.get();
HytalePermissionsProvider hytaleProvider = this.luckPermsPermissionProvider.getHytaleProvider();
if (hytaleProvider != null) {
permissionsModule.addProvider(hytaleProvider);
}
permissionsModule.removeProvider(this.luckPermsPermissionProvider);
}
@Override
protected AbstractEventBus<?> provideEventBus(LuckPermsApiProvider apiProvider) {
return new HytaleEventBus(this, apiProvider);
}
@Override
protected void registerApiOnPlatform(LuckPerms api) {
}
@Override
protected void performFinalSetup() {
}
@Override
public Optional<QueryOptions> getQueryOptionsForUser(User user) {
return this.bootstrap.getPlayer(user.getUniqueId()).map(player -> this.contextManager.getQueryOptions(player));
}
@Override
public Stream<Sender> getOnlineSenders() {
return Stream.concat(
Stream.of(getConsoleSender()),
Universe.get().getPlayers().stream().map(p -> getSenderFactory().wrap(p))
);
}
@Override
public Sender getConsoleSender() {
return getSenderFactory().wrap(ConsoleSender.INSTANCE);
}
public HytaleSenderFactory getSenderFactory() {
return this.senderFactory;
}
public VirtualGroupsLookupProvider getVirtualGroupsLookupProvider() {
return this.virtualGroupsLookupProvider;
}
@Override
public AbstractConnectionListener getConnectionListener() {
return this.connectionListener;
}
@Override
public HytaleCommandManager getCommandManager() {
return this.commandManager;
}
@Override
public StandardUserManager getUserManager() {
return this.userManager;
}
@Override
public StandardGroupManager getGroupManager() {
return this.groupManager;
}
@Override
public StandardTrackManager getTrackManager() {
return this.trackManager;
}
@Override
public HytaleContextManager getContextManager() {
return this.contextManager;
}
}
@@ -0,0 +1,88 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.calculator;
import me.lucko.luckperms.common.cacheddata.CacheMetadata;
import me.lucko.luckperms.common.calculator.CalculatorFactory;
import me.lucko.luckperms.common.calculator.PermissionCalculator;
import me.lucko.luckperms.common.calculator.processor.DirectProcessor;
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
import me.lucko.luckperms.common.calculator.processor.RegexProcessor;
import me.lucko.luckperms.common.calculator.processor.SpongeWildcardProcessor;
import me.lucko.luckperms.common.calculator.processor.WildcardProcessor;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.hytale.LPHytalePlugin;
import me.lucko.luckperms.hytale.calculator.virtualgroups.VirtualGroupsLookupProvider;
import me.lucko.luckperms.hytale.context.HytaleContextManager;
import me.lucko.luckperms.hytale.service.VirtualGroups;
import net.luckperms.api.query.QueryOptions;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class HytaleCalculatorFactory implements CalculatorFactory {
private final LPHytalePlugin plugin;
private final VirtualGroupsLookupProvider virtualGroupsLookupProvider;
public HytaleCalculatorFactory(LPHytalePlugin plugin, VirtualGroupsLookupProvider virtualGroupsLookupProvider) {
this.plugin = plugin;
this.virtualGroupsLookupProvider = virtualGroupsLookupProvider;
}
@Override
public PermissionCalculator build(QueryOptions queryOptions, CacheMetadata metadata) {
List<PermissionProcessor> processors = new ArrayList<>(6);
processors.add(new DirectProcessor());
if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) {
processors.add(new RegexProcessor());
}
if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) {
processors.add(new WildcardProcessor());
}
if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS_SPONGE)) {
processors.add(new SpongeWildcardProcessor());
}
boolean integratedOwner = queryOptions.option(HytaleContextManager.INTEGRATED_SERVER_OWNER).orElse(false);
if (integratedOwner && this.plugin.getConfiguration().get(ConfigKeys.INTEGRATED_SERVER_OWNER_BYPASSES_CHECKS)) {
processors.add(ServerOwnerProcessor.INSTANCE);
}
if (this.plugin.getConfiguration().get(ConfigKeys.APPLY_HYTALE_VIRTUAL_GROUPS)) {
Set<String> virtualGroups = queryOptions.option(VirtualGroups.KEY).orElse(VirtualGroups.EMPTY).groups();
if (!virtualGroups.isEmpty()) {
processors.add(new HytaleVirtualGroupProcessor(this.virtualGroupsLookupProvider.getLookup(virtualGroups)));
}
}
return new PermissionCalculator(this.plugin, metadata, processors);
}
}
@@ -0,0 +1,51 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.calculator;
import me.lucko.luckperms.common.cacheddata.result.TristateResult;
import me.lucko.luckperms.common.calculator.PermissionLookupCache;
import me.lucko.luckperms.common.calculator.processor.AbstractPermissionProcessor;
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
import me.lucko.luckperms.common.verbose.event.CheckOrigin;
/**
* Permission Processor for Hytale "virtual groups".
*/
public class HytaleVirtualGroupProcessor extends AbstractPermissionProcessor implements PermissionProcessor {
public static final TristateResult.Factory RESULT_FACTORY = new TristateResult.Factory(HytaleVirtualGroupProcessor.class);
private final PermissionLookupCache lookup;
public HytaleVirtualGroupProcessor(PermissionLookupCache lookup) {
this.lookup = lookup;
}
@Override
public TristateResult hasPermission(String permission) {
return RESULT_FACTORY.result(this.lookup.checkPermission(permission, CheckOrigin.INTERNAL).result());
}
}
@@ -0,0 +1,49 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.calculator;
import me.lucko.luckperms.common.cacheddata.result.TristateResult;
import me.lucko.luckperms.common.calculator.processor.AbstractPermissionProcessor;
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
import net.luckperms.api.util.Tristate;
/**
* Permission processor which is added to the owner of an integrated server to simply return true if no other processors match.
*/
public class ServerOwnerProcessor extends AbstractPermissionProcessor implements PermissionProcessor {
private static final TristateResult TRUE_RESULT = new TristateResult.Factory(ServerOwnerProcessor.class).result(Tristate.TRUE);
public static final ServerOwnerProcessor INSTANCE = new ServerOwnerProcessor();
private ServerOwnerProcessor() {
}
@Override
public TristateResult hasPermission(String permission) {
return TRUE_RESULT;
}
}
@@ -0,0 +1,104 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.calculator.virtualgroups;
import com.google.common.collect.ImmutableMap;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import me.lucko.luckperms.common.node.factory.NodeBuilders;
import net.luckperms.api.node.Node;
import java.lang.reflect.Field;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class VirtualGroupsAccess {
/** Reflective access to PermissionsModule.virtualGroups field */
private static final Field VIRTUAL_GROUPS_FIELD;
static {
try {
VIRTUAL_GROUPS_FIELD = PermissionsModule.class.getDeclaredField("virtualGroups");
VIRTUAL_GROUPS_FIELD.setAccessible(true);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
/**
* Exports the virtual groups mapping from Hytale's PermissionsModule into a map of maps of {@link Node}.
*
* @return the exported mapping
*/
public static Map<String, Map<String, Node>> export() {
Map<String, Set<String>> virtualGroups = getVirtualGroups();
return virtualGroups.entrySet().stream().collect(Collectors.toMap(
Map.Entry::getKey,
e -> transformSet(e.getValue())
));
}
/**
* Reads the virtual groups map from the PermissionsModule.
*
* @return the virtual groups map
*/
@SuppressWarnings({"unchecked", "rawtypes"})
private static Map<String, Set<String>> getVirtualGroups() {
PermissionsModule permissionsModule = PermissionsModule.get();
try {
return (Map) VIRTUAL_GROUPS_FIELD.get(permissionsModule);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
/**
* Transforms a set of Hytale permission strings into a map of {@link Node} ready for lookup.
*
* @param permissions the input
* @return the transformed map
*/
private static Map<String, Node> transformSet(Set<String> permissions) {
ImmutableMap.Builder<String, Node> builder = ImmutableMap.builder();
for (String permission : permissions) {
boolean value = true;
if (!permission.isEmpty() && permission.charAt(0) == '-') {
value = false;
permission = permission.substring(1);
}
builder.put(
permission.toLowerCase(Locale.ROOT),
NodeBuilders.determineMostApplicable(permission).value(value).build()
);
}
return builder.build();
}
}
@@ -0,0 +1,75 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.calculator.virtualgroups;
import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.common.cache.LoadingMap;
import me.lucko.luckperms.common.calculator.PermissionLookupCache;
import me.lucko.luckperms.common.calculator.processor.DirectProcessor;
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
import me.lucko.luckperms.common.calculator.processor.WildcardProcessor;
import net.luckperms.api.node.Node;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class VirtualGroupsLookupProvider {
private final Map<Set<String>, PermissionLookupCache> caches;
private Map<String, Map<String, Node>> virtualGroupToNodesMap;
public VirtualGroupsLookupProvider() {
this.caches = LoadingMap.of(this::buildCache);
refresh();
}
public void refresh() {
this.virtualGroupToNodesMap = VirtualGroupsAccess.export();
this.caches.clear();
}
public PermissionLookupCache getLookup(Set<String> virtualGroups) {
return this.caches.get(virtualGroups);
}
private PermissionLookupCache buildCache(Set<String> virtualGroups) {
Map<String, Node> sourceMap = new ConcurrentHashMap<>();
for (String virtualGroup : virtualGroups) {
sourceMap.putAll(this.virtualGroupToNodesMap.getOrDefault(virtualGroup, ImmutableMap.of()));
}
List<PermissionProcessor> processors = new ArrayList<>(2);
processors.add(new DirectProcessor());
processors.add(new WildcardProcessor());
PermissionLookupCache lookupCache = new PermissionLookupCache(processors);
lookupCache.setSourcePermissions(sourceMap);
return lookupCache;
}
}
@@ -0,0 +1,102 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.chat;
import com.hypixel.hytale.event.EventRegistry;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.event.events.player.PlayerChatEvent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.hytale.HytaleSenderFactory;
import me.lucko.luckperms.hytale.LPHytalePlugin;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.TagPattern;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.jspecify.annotations.NonNull;
public class LuckPermsChatFormatter implements PlayerChatEvent.Formatter {
private final LPHytalePlugin plugin;
private final String format;
public LuckPermsChatFormatter(LPHytalePlugin plugin) {
this.plugin = plugin;
this.format = plugin.getConfiguration().get(ConfigKeys.CHAT_FORMATTER_MESSAGE_FORMAT);
}
public void register(EventRegistry registry) {
registry.registerGlobal(PlayerChatEvent.class, this::onPlayerChat);
}
private void onPlayerChat(PlayerChatEvent e) {
e.setFormatter(this);
}
@Override
public @NonNull Message format(@NonNull PlayerRef playerRef, @NonNull String message) {
String username = playerRef.getUsername();
String prefix = "";
String suffix = "";
User user = this.plugin.getUserManager().getIfLoaded(playerRef.getUuid());
if (user != null) {
prefix = user.getCachedData().getMetaData().getPrefix();
if (prefix == null) {
prefix = "";
}
suffix = user.getCachedData().getMetaData().getSuffix();
if (suffix == null) {
suffix = "";
}
}
Component component = MiniMessage.miniMessage().deserialize(
this.format,
parse("prefix", prefix),
parse("suffix", suffix),
Placeholder.unparsed("username", username),
Placeholder.unparsed("message", message)
);
return HytaleSenderFactory.toHytaleMessage(component);
}
private static TagResolver parse(@TagPattern String key, String value) {
boolean containsLegacyFormattingCharacter = value.indexOf(LegacyComponentSerializer.AMPERSAND_CHAR) != -1
|| value.indexOf(LegacyComponentSerializer.SECTION_CHAR) != -1;
if (containsLegacyFormattingCharacter) {
TextComponent component = LegacyComponentSerializer.legacyAmpersand().deserialize(value);
return Placeholder.component(key, component);
} else {
return Placeholder.parsed(key, value);
}
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.context;
import com.hypixel.hytale.server.core.Constants;
import com.hypixel.hytale.server.core.modules.singleplayer.SingleplayerModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import me.lucko.luckperms.common.context.manager.SimpleContextManager;
import me.lucko.luckperms.hytale.LPHytalePlugin;
import me.lucko.luckperms.hytale.service.PlayerVirtualGroupsMap;
import me.lucko.luckperms.hytale.service.VirtualGroups;
import net.luckperms.api.query.OptionKey;
import net.luckperms.api.query.QueryOptions;
import java.util.Set;
import java.util.UUID;
public class HytaleContextManager extends SimpleContextManager<PlayerRef, PlayerRef> {
public static final OptionKey<Boolean> INTEGRATED_SERVER_OWNER = OptionKey.of("integrated_server_owner", Boolean.class);
private final PlayerVirtualGroupsMap playerVirtualGroupsMap;
public HytaleContextManager(LPHytalePlugin plugin, PlayerVirtualGroupsMap playerVirtualGroupsMap) {
super(plugin, PlayerRef.class, PlayerRef.class);
this.playerVirtualGroupsMap = playerVirtualGroupsMap;
}
@Override
public UUID getUniqueId(PlayerRef player) {
return player.getUuid();
}
@Override
public void customizeQueryOptions(PlayerRef subject, QueryOptions.Builder builder) {
if (Constants.SINGLEPLAYER && SingleplayerModule.isOwner(subject)) {
builder.option(INTEGRATED_SERVER_OWNER, true);
}
Set<String> groups = this.playerVirtualGroupsMap.getPlayerGroups(subject.getUuid());
builder.option(VirtualGroups.KEY, new VirtualGroups(groups));
}
}
@@ -0,0 +1,184 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.context;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentRegistryProxy;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.EntityEventSystem;
import com.hypixel.hytale.event.EventRegistry;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.event.events.ecs.ChangeGameModeEvent;
import com.hypixel.hytale.server.core.event.events.player.AddPlayerToWorldEvent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.context.ImmutableContextSetImpl;
import me.lucko.luckperms.common.util.EnumNamer;
import me.lucko.luckperms.hytale.LPHytalePlugin;
import net.luckperms.api.context.Context;
import net.luckperms.api.context.ContextCalculator;
import net.luckperms.api.context.ContextConsumer;
import net.luckperms.api.context.ContextSet;
import net.luckperms.api.context.DefaultContextKeys;
import net.luckperms.api.context.ImmutableContextSet;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class HytalePlayerCalculator implements ContextCalculator<PlayerRef> {
private static final EnumNamer<GameMode> GAMEMODE_NAMER = new EnumNamer<>(
GameMode.class,
EnumNamer.LOWER_CASE_NAME
);
protected final LPHytalePlugin plugin;
protected final boolean gamemode;
protected final boolean world;
private final Map<UUID, GameMode> playerGameModes = new ConcurrentHashMap<>();
public HytalePlayerCalculator(LPHytalePlugin plugin, Set<String> disabled) {
this.plugin = plugin;
this.gamemode = !disabled.contains(DefaultContextKeys.GAMEMODE_KEY);
this.world = !disabled.contains(DefaultContextKeys.WORLD_KEY);
}
public void registerEvents(EventRegistry registry) {
registry.registerGlobal(AddPlayerToWorldEvent.class, this::onAddPlayerToWorld);
}
public void registerSystems(ComponentRegistryProxy<EntityStore> registry) {
registry.registerSystem(new ChangeGameModeSystem());
}
@Override
public void calculate(@NonNull PlayerRef target, @NonNull ContextConsumer consumer) {
Ref<EntityStore> ref = target.getReference();
if (ref == null || !ref.isValid()) {
return;
}
Store<EntityStore> store = ref.getStore();
Player player = store.isInThread() ? store.getComponent(ref, Player.getComponentType()) : null;
if (this.gamemode) {
GameMode mode;
if (player != null) {
mode = player.getGameMode();
} else {
mode = this.playerGameModes.get(target.getUuid());
}
if (mode != null) {
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
}
}
World world = store.getExternalData().getWorld();
if (this.world) {
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(world.getName(), consumer);
}
}
@Override
public @NonNull ContextSet estimatePotentialContexts() {
ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl();
if (this.gamemode) {
for (GameMode value : GameMode.values()) {
builder.add(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(value));
}
}
if (this.world) {
for (World world : Universe.get().getWorlds().values()) {
String name = world.getName();
if (Context.isValidValue(name)) {
builder.add(DefaultContextKeys.WORLD_KEY, name);
}
}
}
return builder.build();
}
private void onAddPlayerToWorld(AddPlayerToWorldEvent event) {
Holder<EntityStore> holder = event.getHolder();
PlayerRef playerRef = holder.getComponent(PlayerRef.getComponentType());
if (playerRef == null) {
return;
}
this.plugin.getContextManager().signalContextUpdate(playerRef);
Player player = holder.getComponent(Player.getComponentType());
if (player != null) {
GameMode gameMode = player.getGameMode();
if (gameMode != null) {
this.playerGameModes.put(playerRef.getUuid(), gameMode);
}
}
}
private void onGameModeEvent(PlayerRef playerRef, ChangeGameModeEvent e) {
this.playerGameModes.put(playerRef.getUuid(), e.getGameMode());
}
private final class ChangeGameModeSystem extends EntityEventSystem<EntityStore, ChangeGameModeEvent> {
ChangeGameModeSystem() {
super(ChangeGameModeEvent.class);
}
@Override
public void handle(int index, ArchetypeChunk<EntityStore> archetypeChunk, Store<EntityStore> store, CommandBuffer<EntityStore> commandBuffer, ChangeGameModeEvent event) {
Ref<EntityStore> entity = archetypeChunk.getReferenceTo(index);
PlayerRef playerRef = entity.getStore().getComponent(entity, PlayerRef.getComponentType());
if (playerRef == null) {
return;
}
onGameModeEvent(playerRef, event);
}
@Override
public Query<EntityStore> getQuery() {
return Archetype.empty();
}
}
}
@@ -0,0 +1,126 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.listeners;
import com.hypixel.hytale.event.EventPriority;
import com.hypixel.hytale.event.EventRegistry;
import com.hypixel.hytale.server.core.event.events.player.PlayerDisconnectEvent;
import com.hypixel.hytale.server.core.event.events.player.PlayerSetupConnectEvent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.locale.Message;
import me.lucko.luckperms.common.locale.TranslationManager;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
import me.lucko.luckperms.hytale.LPHytalePlugin;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class HytaleConnectionListener extends AbstractConnectionListener {
private final LPHytalePlugin plugin;
private final Set<UUID> deniedAsyncLogin = Collections.synchronizedSet(new HashSet<>());
public HytaleConnectionListener(LPHytalePlugin plugin) {
super(plugin);
this.plugin = plugin;
}
public void register(EventRegistry registry) {
registry.register(EventPriority.EARLY, PlayerSetupConnectEvent.class, this::onPlayerPreLogin);
registry.register(EventPriority.LAST, PlayerSetupConnectEvent.class, this::onPlayerPreLoginMonitor);
registry.register(EventPriority.LAST, PlayerDisconnectEvent.class, this::onPlayerQuit);
}
private void onPlayerPreLogin(PlayerSetupConnectEvent e) {
/* Called when the player first attempts a connection with the server.
Listening on LOW priority to allow plugins to modify username / UUID data here. (auth plugins)
Also, give other plugins a chance to cancel the event. */
if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
this.plugin.getLogger().info("Processing pre-login for " + e.getUuid() + " - " + e.getUsername());
}
if (e.isCancelled()) {
// another plugin has disallowed the login.
this.plugin.getLogger().info("Another plugin has cancelled the connection for " + e.getUuid() + " - " + e.getUsername() + ". No permissions data will be loaded.");
this.deniedAsyncLogin.add(e.getUuid());
return;
}
/* Actually process the login for the connection.
We do this here to delay the login until the data is ready.
If the login gets cancelled later on, then this will be cleaned up.
This includes:
- loading uuid data
- loading permissions
- creating a user instance in the UserManager for this connection.
- setting up cached data. */
try {
User user = loadUser(e.getUuid(), e.getUsername());
recordConnection(e.getUuid());
this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUuid(), e.getUsername(), user);
} catch (Exception ex) {
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUuid() + " - " + e.getUsername(), ex);
// deny the connection
this.deniedAsyncLogin.add(e.getUuid());
Component reason = TranslationManager.render(Message.LOADING_DATABASE_ERROR.build());
e.setCancelled(true);
e.setReason(PlainTextComponentSerializer.plainText().serialize(reason));
this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUuid(), e.getUsername(), null);
}
}
private void onPlayerPreLoginMonitor(PlayerSetupConnectEvent e) {
/* Listen to see if the event was cancelled after we initially handled the connection
If the connection was cancelled here, we need to do something to clean up the data that was loaded. */
// Check to see if this connection was denied at LOW.
if (this.deniedAsyncLogin.remove(e.getUuid())) {
// their data was never loaded at LOW priority, now check to see if they have been magically allowed since then.
// This is a problem, as they were denied at low priority, but are now being allowed.
if (!e.isCancelled()) {
this.plugin.getLogger().severe("Player connection was re-allowed for " + e.getUuid());
e.setCancelled(true);
}
}
}
private void onPlayerQuit(PlayerDisconnectEvent e) {
final PlayerRef player = e.getPlayerRef();
handleDisconnect(player.getUuid());
}
}
@@ -0,0 +1,70 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.listeners;
import com.hypixel.hytale.event.EventRegistry;
import com.hypixel.hytale.server.core.command.system.AbstractCommand;
import com.hypixel.hytale.server.core.command.system.CommandManager;
import com.hypixel.hytale.server.core.event.events.BootEvent;
import me.lucko.luckperms.hytale.LPHytalePlugin;
import java.util.Collection;
public class HytalePlatformListener {
private final LPHytalePlugin plugin;
public HytalePlatformListener(LPHytalePlugin plugin) {
this.plugin = plugin;
}
public void register(EventRegistry registry) {
registry.registerGlobal(BootEvent.class, this::onBoot);
}
public void onBoot(BootEvent e) {
insertCommandPermissionsIntoRegistry();
this.plugin.getVirtualGroupsLookupProvider().refresh();
}
public void insertCommandPermissionsIntoRegistry() {
insertCommandPermissionsIntoRegistry(CommandManager.get().getCommandRegistration().values());
}
private void insertCommandPermissionsIntoRegistry(Collection<AbstractCommand> commands) {
for (AbstractCommand command : commands) {
String permission = command.getPermission();
if (permission != null) {
this.plugin.getPermissionRegistry().insert(permission);
}
Collection<AbstractCommand> subCommands = command.getSubCommands().values();
if (!subCommands.isEmpty()) {
insertCommandPermissionsIntoRegistry(subCommands);
}
}
}
}
@@ -0,0 +1,189 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.service;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.permissions.provider.HytalePermissionsProvider;
import com.hypixel.hytale.server.core.permissions.provider.PermissionProvider;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.verbose.event.CheckOrigin;
import me.lucko.luckperms.hytale.LPHytalePlugin;
import net.luckperms.api.node.types.InheritanceNode;
import net.luckperms.api.util.Tristate;
import org.jspecify.annotations.NonNull;
import java.util.AbstractSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public class LuckPermsPermissionProvider implements PermissionProvider {
private static final String PERMISSION_PROVIDER_NAME = "LuckPerms";
/** LuckPerms plugin */
private final LPHytalePlugin plugin;
/** The Hytale built-in permission provider implementation */
private final HytalePermissionsProvider hytaleProvider;
/** The map of player virtual groups */
private final PlayerVirtualGroupsMap playerVirtualGroupsMap;
/** Whether to delegate operations on groups/users not managed by LuckPerms to the built-in Hytale provider */
private final boolean delegateToHytaleProvider;
public LuckPermsPermissionProvider(LPHytalePlugin plugin, HytalePermissionsProvider hytaleProvider, PlayerVirtualGroupsMap playerVirtualGroupsMap) {
this.plugin = plugin;
this.hytaleProvider = hytaleProvider;
this.playerVirtualGroupsMap = playerVirtualGroupsMap;
this.delegateToHytaleProvider = hytaleProvider != null && plugin.getConfiguration().get(ConfigKeys.DELEGATE_TO_HYTALE_PERMISSIONS_PROVIDER);
}
public HytalePermissionsProvider getHytaleProvider() {
return this.hytaleProvider;
}
@Override
public String getName() {
return PERMISSION_PROVIDER_NAME;
}
@Override
public Set<String> getUserPermissions(@NonNull UUID userUniqueId) {
User user = this.plugin.getUserManager().getIfLoaded(userUniqueId);
if (user == null) {
return this.delegateToHytaleProvider
? this.hytaleProvider.getUserPermissions(userUniqueId)
: Set.of();
}
return new LuckPermsPermissionsSet(user);
}
/**
* A dodgy way to trick {@link PermissionsModule#hasPermission(Set, String)} into always returning according
* to LuckPerms data.
*/
private static final class LuckPermsPermissionsSet extends AbstractSet<String> {
private static final String WILDCARD_PERMISSION = "*";
private static final String NEGATIVE_WILDCARD_PERMISSION = "-*";
private final User user;
private LuckPermsPermissionsSet(User user) {
this.user = user;
}
@Override
public boolean contains(Object o) {
if (!(o instanceof String permission)) {
throw new IllegalArgumentException("Not a string: " + o);
}
if (WILDCARD_PERMISSION.equals(permission) || NEGATIVE_WILDCARD_PERMISSION.equals(permission)) {
return false; // let LuckPerms handle wildcards itself
}
boolean inverted = false;
if (!permission.isEmpty() && permission.charAt(0) == '-') {
inverted = true;
permission = permission.substring(1);
}
Tristate result = this.user.getCachedData().getPermissionData().checkPermission(permission, CheckOrigin.PLATFORM_API_HAS_PERMISSION).result();
return inverted != result.asBoolean();
}
@Override
public Iterator<String> iterator() {
throw new UnsupportedOperationException();
}
@Override
public int size() {
throw new UnsupportedOperationException();
}
}
@Override
public void addUserToGroup(@NonNull UUID userUniqueId, @NonNull String groupName) {
this.playerVirtualGroupsMap.addPlayerToGroup(userUniqueId, groupName);
}
@Override
public void removeUserFromGroup(@NonNull UUID userUniqueId, @NonNull String groupName) {
this.playerVirtualGroupsMap.removePlayerFromGroup(userUniqueId, groupName);
}
@Override
public Set<String> getGroupsForUser(@NonNull UUID userUniqueId) {
Set<String> virtualGroups = this.playerVirtualGroupsMap.getPlayerGroups(userUniqueId);
User user = this.plugin.getUserManager().getIfLoaded(userUniqueId);
if (user == null) {
return virtualGroups;
}
List<InheritanceNode> inheritanceNodes = user.getOwnInheritanceNodes(user.getQueryOptions());
Set<String> groups = new HashSet<>(virtualGroups);
for (InheritanceNode node : inheritanceNodes) {
groups.add(node.getGroupName());
}
return groups;
}
@Override
public void addUserPermissions(@NonNull UUID userUniqueId, @NonNull Set<String> permissions) {
if (this.delegateToHytaleProvider) {
this.hytaleProvider.addUserPermissions(userUniqueId, permissions);
}
}
@Override
public void removeUserPermissions(@NonNull UUID userUniqueId, @NonNull Set<String> permissions) {
if (this.delegateToHytaleProvider) {
this.hytaleProvider.removeUserPermissions(userUniqueId, permissions);
}
}
@Override
public void addGroupPermissions(@NonNull String groupName, @NonNull Set<String> permissions) {
if (this.delegateToHytaleProvider) {
this.hytaleProvider.addGroupPermissions(groupName, permissions);
}
}
@Override
public void removeGroupPermissions(@NonNull String groupName, @NonNull Set<String> permissions) {
if (this.delegateToHytaleProvider) {
this.hytaleProvider.removeGroupPermissions(groupName, permissions);
}
}
@Override
public Set<String> getGroupPermissions(@NonNull String groupName) {
return this.delegateToHytaleProvider ? this.hytaleProvider.getGroupPermissions(groupName) : Set.of();
}
}
@@ -0,0 +1,82 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.service;
import com.google.common.collect.ImmutableSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
* A thread-safe map of player UUIDs to their virtual groups.
*/
public class PlayerVirtualGroupsMap {
private final Map<UUID, ImmutableSet<String>> uuidToGroups = new ConcurrentHashMap<>();
public void addPlayerToGroup(UUID uuid, String group) {
this.uuidToGroups.compute(uuid, (key, existing)-> {
if (existing == null) {
return ImmutableSet.of(group);
} else {
if (existing.contains(group)) {
return existing;
} else {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
builder.addAll(existing);
builder.add(group);
return builder.build();
}
}
});
}
public void removePlayerFromGroup(UUID uuid, String group) {
this.uuidToGroups.computeIfPresent(uuid, (key, existing) -> {
if (!existing.contains(group)) {
return existing;
} else {
if (existing.size() == 1) {
return null;
}
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
for (String g : existing) {
if (!g.equals(group)) {
builder.add(g);
}
}
return builder.build();
}
});
}
public Set<String> getPlayerGroups(UUID uuid) {
return this.uuidToGroups.getOrDefault(uuid, ImmutableSet.of());
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* 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.hytale.service;
import com.google.common.collect.ImmutableSet;
import net.luckperms.api.query.OptionKey;
import net.luckperms.api.query.QueryOptions;
import java.util.Set;
/**
* A {@link QueryOptions} option key for virtual groups.
*
* @param groups the groups
*/
public record VirtualGroups(Set<String> groups) {
public static final VirtualGroups EMPTY = new VirtualGroups(ImmutableSet.of());
public static final OptionKey<VirtualGroups> KEY = OptionKey.of("virtual_groups", VirtualGroups.class);
}
+672
View File
@@ -0,0 +1,672 @@
####################################################################################################
# +----------------------------------------------------------------------------------------------+ #
# | __ __ ___ __ __ | #
# | | | | / ` |__/ |__) |__ |__) |\/| /__` | #
# | |___ \__/ \__, | \ | |___ | \ | | .__/ | #
# | | #
# | https://luckperms.net | #
# | | #
# | WIKI: https://luckperms.net/wiki | #
# | DISCORD: https://discord.gg/luckperms | #
# | BUG REPORTS: https://github.com/LuckPerms/LuckPerms/issues | #
# | | #
# | Each option in this file is documented and explained here: | #
# | ==> https://luckperms.net/wiki/Configuration | #
# | | #
# | New options are not added to this file automatically. Default values are used if an | #
# | option cannot be found. The latest config versions can be obtained at the link above. | #
# +----------------------------------------------------------------------------------------------+ #
####################################################################################################
# +----------------------------------------------------------------------------------------------+ #
# | | #
# | ESSENTIAL SETTINGS | #
# | | #
# | Important settings that control how LuckPerms functions. | #
# | | #
# +----------------------------------------------------------------------------------------------+ #
# The name of the server, used for server specific permissions.
#
# - When set to "global" this setting is effectively ignored.
# - In all other cases, the value here is added to all players in a "server" context.
# - See: https://luckperms.net/wiki/Context
server: global
# If the servers own UUID cache/lookup facility should be used when there is no record for a player
# already in LuckPerms.
#
# - When this is set to 'false', commands using a player's username will not work unless the player
# has joined since LuckPerms was first installed.
# - To get around this, you can use a player's uuid directly in the command, or enable this option.
# - When this is set to 'true', the server facility is used. This may use a number of methods,
# including checking the servers local cache, or making a request to the Mojang API.
use-server-uuid-cache: false
# +----------------------------------------------------------------------------------------------+ #
# | | #
# | CHAT SETTINGS | #
# | | #
# | Controls how LuckPerms should format messages from players in the chat. | #
# | | #
# +----------------------------------------------------------------------------------------------+ #
# Configuration for the built-in LuckPerms chat formatter.
#
# Note: This functionality is only intended for simple chat formatting needs. For more advanced
# chat formatting, we recommend using a dedicated chat plugin that integrates with LuckPerms.
#
# When enabled, LuckPerms formats the chat using the format defined below.
# The following placeholders are supported:
#
# - <prefix>: The players prefix meta value
# - <username>: The players username
# - <suffix>: The players suffix meta value
# - <message>: The actual chat message sent by the player
#
# The format string, as well as the prefix and suffix values support formatting using MiniMessage:
# https://docs.papermc.io/adventure/minimessage/
#
chat-formatter:
# If LuckPerms should handle chat formatting.
enabled: true
# The format to use.
message-format: "<prefix><username><suffix>: <message>"
# +----------------------------------------------------------------------------------------------+ #
# | | #
# | STORAGE SETTINGS | #
# | | #
# | Controls which storage method LuckPerms will use to store data. | #
# | | #
# +----------------------------------------------------------------------------------------------+ #
# How the plugin should store data
#
# - The various options are explained in more detail on the wiki:
# https://luckperms.net/wiki/Storage-types
#
# - Possible options:
#
# | Remote databases - require connection information to be configured below
# |=> MySQL
# |=> MariaDB (preferred over MySQL)
# |=> PostgreSQL
# |=> MongoDB
#
# | Flatfile/local database - don't require any extra configuration
# |=> H2 (preferred over SQLite)
# |=> SQLite
#
# | Readable & editable text files - don't require any extra configuration
# |=> YAML (.yml files)
# |=> JSON (.json files)
# |=> HOCON (.conf files)
# |=> TOML (.toml files)
# |
# | By default, user, group and track data is separated into different files. Data can be combined
# | and all stored in the same file by switching to a combined storage variant.
# | Just add '-combined' to the end of the storage-method, e.g. 'yaml-combined'
#
# - A H2 database is the default option.
# - If you want to edit data manually in "traditional" storage files, we suggest using YAML.
storage-method: h2
# The following block defines the settings for remote database storage methods.
#
# - You don't need to touch any of the settings here if you're using a local storage method!
# - The connection detail options are shared between all remote storage types.
data:
# Define the address and port for the database.
# - The standard DB engine port is used by default
# (MySQL: 3306, PostgreSQL: 5432, MongoDB: 27017)
# - Specify as "host:port" if differs
address: localhost
# The name of the database to store LuckPerms data in.
# - This must be created already. Don't worry about this setting if you're using MongoDB.
database: luckperms
# Credentials for the database.
username: root
password: ''
# These settings apply to the MySQL connection pool.
# - The default values will be suitable for the majority of users.
# - Do not change these settings unless you know what you're doing!
pool-settings:
# Sets the maximum size of the MySQL connection pool.
# - Basically this value will determine the maximum number of actual
# connections to the database backend.
# - More information about determining the size of connection pools can be found here:
# https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
maximum-pool-size: 10
# Sets the minimum number of idle connections that the pool will try to maintain.
# - For maximum performance and responsiveness to spike demands, it is recommended to not set
# this value and instead allow the pool to act as a fixed size connection pool.
# (set this value to the same as 'maximum-pool-size')
minimum-idle: 10
# This setting controls the maximum lifetime of a connection in the pool in milliseconds.
# - The value should be at least 30 seconds less than any database or infrastructure imposed
# connection time limit.
maximum-lifetime: 1800000 # 30 minutes
# This setting controls how frequently the pool will 'ping' a connection in order to prevent it
# from being timed out by the database or network infrastructure, measured in milliseconds.
# - The value should be less than maximum-lifetime and greater than 30000 (30 seconds).
# - Setting the value to zero will disable the keepalive functionality.
keepalive-time: 0
# This setting controls the maximum number of milliseconds that the plugin will wait for a
# connection from the pool, before timing out.
connection-timeout: 5000 # 5 seconds
# This setting allows you to define extra properties for connections.
#
# By default, the following options are set to enable utf8 encoding. (you may need to remove
# these if you are using PostgreSQL)
# useUnicode: true
# characterEncoding: utf8
#
# You can also use this section to disable SSL connections, by uncommenting the 'useSSL' and
# 'verifyServerCertificate' options below.
properties:
useUnicode: true
characterEncoding: utf8
#useSSL: false
#verifyServerCertificate: false
# The prefix for all LuckPerms SQL tables.
#
# - This only applies for remote SQL storage types (MySQL, MariaDB, etc).
# - Change this if you want to use different tables for different servers.
table-prefix: 'luckperms_'
# The prefix to use for all LuckPerms MongoDB collections.
#
# - This only applies for the MongoDB storage type.
# - Change this if you want to use different collections for different servers. The default is no
# prefix.
mongodb-collection-prefix: ''
# The connection string URI to use to connect to the MongoDB instance.
#
# - When configured, this setting will override anything defined in the address, database,
# username or password fields above.
# - If you have a connection string that starts with 'mongodb://' or 'mongodb+srv://', enter it
# below.
# - For more information, please see https://docs.mongodb.com/manual/reference/connection-string/
mongodb-connection-uri: ''
# Define settings for a "split" storage setup.
#
# - This allows you to define a storage method for each type of data.
# - The connection options above still have to be correct for each type here.
split-storage:
# Don't touch this if you don't want to use split storage!
enabled: false
methods:
# These options don't need to be modified if split storage isn't enabled.
user: h2
group: h2
track: h2
uuid: h2
log: h2
# +----------------------------------------------------------------------------------------------+ #
# | | #
# | UPDATE PROPAGATION & MESSAGING SERVICE | #
# | | #
# | Controls the ways in which LuckPerms will sync data & notify other servers of changes. | #
# | These options are documented on greater detail on the wiki under "Instant Updates". | #
# | | #
# +----------------------------------------------------------------------------------------------+ #
# This option controls how frequently LuckPerms will perform a sync task.
#
# - A sync task will refresh all data from the storage, and ensure that the most up-to-date data is
# being used by the plugin.
# - This is disabled by default, as most users will not need it. However, if you're using a remote
# storage type without a messaging service setup, you may wish to set this to something like 3.
# - Set to -1 to disable the task completely.
sync-minutes: -1
# If the file watcher should be enabled.
#
# - When using a file-based storage type, LuckPerms can monitor the data files for changes, and
# automatically update when changes are detected.
# - If you don't want this feature to be active, set this option to false.
watch-files: true
# Define which messaging service should be used by the plugin.
#
# - If enabled and configured, LuckPerms will use the messaging service to inform other connected
# servers of changes.
# - Use the command "/lp networksync" to manually push changes.
# - Data is NOT stored using this service. It is only used as a messaging platform.
#
# - If you decide to enable this feature, you should set "sync-minutes" to -1, as there is no need
# for LuckPerms to poll the database for changes.
#
# - Possible options:
# => sql Uses the SQL database to form a queue system for communication. Will only work when
# 'storage-method' is set to MySQL or MariaDB. This is chosen by default if the
# option is set to 'auto' and SQL storage is in use. Set to 'notsql' to disable this.
# => pluginmsg Uses the plugin messaging channels to communicate with the proxy.
# LuckPerms must be installed on your proxy & all connected servers backend servers.
# Won't work if you have more than one proxy.
# => lilypad Uses LilyPad pub-sub to push changes. You need to have the LilyPad-Connect plugin
# installed.
# => redis Uses Redis pub-sub to push changes. Your server connection info must be configured
# below.
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
# configured below.
# => nats Uses Nats pub-sub to push changes. Your server connection info must be
# configured below.
# => custom Uses a messaging service provided using the LuckPerms API.
# => auto Attempts to automatically setup a messaging service using redis or sql.
messaging-service: auto
# If LuckPerms should automatically push updates after a change has been made with a command.
auto-push-updates: true
# If LuckPerms should push logging entries to connected servers via the messaging service.
push-log-entries: true
# If LuckPerms should broadcast received logging entries to players on this platform.
#
# - If you have LuckPerms installed on your backend servers as well as a BungeeCord proxy, you
# should set this option to false on either your backends or your proxies, to avoid players being
# messaged twice about log entries.
broadcast-received-log-entries: true
# Settings for Redis.
# Port 6379 is used by default; set address to "host:port" if differs
# Multiple Redis nodes can be specified in the same format as a string list under the name "addresses".
redis:
enabled: false
address: localhost
username: ''
password: ''
# Settings for Nats.
# Port 4222 is used by default; set address to "host:port" if differs
nats:
enabled: false
address: localhost
username: ''
password: ''
# Settings for RabbitMQ.
# Port 5672 is used by default; set address to "host:port" if differs
rabbitmq:
enabled: false
address: localhost
vhost: '/'
username: 'guest'
password: 'guest'
# +----------------------------------------------------------------------------------------------+ #
# | | #
# | CUSTOMIZATION SETTINGS | #
# | | #
# | Settings that allow admins to customize the way LuckPerms operates. | #
# | | #
# +----------------------------------------------------------------------------------------------+ #
# Controls how temporary permissions/parents/meta should be accumulated.
#
# - The default behaviour is "deny".
# - This behaviour can also be specified when the command is executed. See the command usage
# documentation for more info.
#
# - Possible options:
# => accumulate durations will be added to the existing expiry time
# => replace durations will be replaced if the new duration is later than the current
# expiration
# => deny the command will just fail if you try to add another node with the same expiry
temporary-add-behaviour: deny
# Controls how LuckPerms will determine a users "primary" group.
#
# - The meaning and influence of "primary groups" are explained in detail on the wiki.
# - The preferred approach is to let LuckPerms automatically determine a users primary group
# based on the relative weight of their parent groups.
#
# - Possible options:
# => stored use the value stored against the users record in the file/database
# => parents-by-weight just use the users most highly weighted parent
# => all-parents-by-weight same as above, but calculates based upon all parents inherited from
# both directly and indirectly
primary-group-calculation: parents-by-weight
# If the plugin should check for "extra" permissions with users run LP commands.
#
# - These extra permissions allow finer control over what users can do with each command, and who
# they have access to edit.
# - The nature of the checks are documented on the wiki under "Argument based command permissions".
# - Argument based permissions are *not* static, unlike the 'base' permissions, and will depend upon
# the arguments given within the command.
argument-based-command-permissions: false
# If the plugin should check whether senders are a member of a given group before they're able to
# edit the groups data or add/remove other users to/from it.
# Note: these limitations do not apply to the web editor!
require-sender-group-membership-to-modify: false
# If the plugin should send log notifications to users whenever permissions are modified.
#
# - Notifications are only sent to those with the appropriate permission to receive them
# - They can also be temporarily enabled/disabled on a per-user basis using
# '/lp log notify <on|off>'
log-notify: true
# Defines a list of log entries which should not be sent as notifications to users.
#
# - Each entry in the list is a RegEx expression which is matched against the log entry description.
log-notify-filtered-descriptions:
# - "parent add example"
# If LuckPerms should automatically install translation bundles and periodically update them.
auto-install-translations: true
# Defines the options for prefix and suffix stacking.
#
# - The feature allows you to display multiple prefixes or suffixes alongside a players username in
# chat.
# - It is explained and documented in more detail on the wiki under "Prefix & Suffix Stacking".
#
# - The options are divided into separate sections for prefixes and suffixes.
# - The 'duplicates' setting refers to how duplicate elements are handled. Can be 'retain-all',
# 'first-only' or 'last-only'.
# - The value of 'start-spacer' is included at the start of the resultant prefix/suffix.
# - The value of 'end-spacer' is included at the end of the resultant prefix/suffix.
# - The value of 'middle-spacer' is included between each element in the resultant prefix/suffix.
#
# - Possible format options:
# => highest Selects the value with the highest weight, from all values
# held by or inherited by the player.
#
# => lowest Same as above, except takes the one with the lowest weight.
#
# => highest_own Selects the value with the highest weight, but will not
# accept any inherited values.
#
# => lowest_own Same as above, except takes the value with the lowest weight.
#
# => highest_inherited Selects the value with the highest weight, but will only
# accept inherited values.
#
# => lowest_inherited Same as above, except takes the value with the lowest weight.
#
# => highest_on_track_<track> Selects the value with the highest weight, but only if the
# value was inherited from a group on the given track.
#
# => lowest_on_track_<track> Same as above, except takes the value with the lowest weight.
#
# => highest_not_on_track_<track> Selects the value with the highest weight, but only if the
# value was inherited from a group not on the given track.
#
# => lowest_not_on_track_<track> Same as above, except takes the value with the lowest weight.
#
# => highest_from_group_<group> Selects the value with the highest weight, but only if the
# value was inherited from the given group.
#
# => lowest_from_group_<group> Same as above, except takes the value with the lowest weight.
#
# => highest_not_from_group_<group> Selects the value with the highest weight, but only if the
# value was not inherited from the given group.
#
# => lowest_not_from_group_<group> Same as above, except takes the value with the lowest weight.
meta-formatting:
prefix:
format:
- "highest"
duplicates: first-only
start-spacer: ""
middle-spacer: " "
end-spacer: ""
suffix:
format:
- "highest"
duplicates: first-only
start-spacer: ""
middle-spacer: " "
end-spacer: ""
# +----------------------------------------------------------------------------------------------+ #
# | | #
# | PERMISSION CALCULATION AND INHERITANCE | #
# | | #
# | Modify the way permission checks, meta lookups and inheritance resolutions are handled. | #
# | | #
# +----------------------------------------------------------------------------------------------+ #
# The algorithm LuckPerms should use when traversing the "inheritance tree".
#
# - Possible options:
# => breadth-first See: https://en.wikipedia.org/wiki/Breadth-first_search
# => depth-first-pre-order See: https://en.wikipedia.org/wiki/Depth-first_search
# => depth-first-post-order See: https://en.wikipedia.org/wiki/Depth-first_search
inheritance-traversal-algorithm: depth-first-pre-order
# If a final sort according to "inheritance rules" should be performed after the traversal algorithm
# has resolved the inheritance tree.
#
# "Inheritance rules" refers to things such as group weightings, primary group status, and the
# natural contextual ordering of the group nodes.
#
# Setting this to 'true' will allow for the inheritance rules to take priority over the structure of
# the inheritance tree.
#
# Effectively when this setting is 'true': the tree is flattened, and rules applied afterwards,
# and when this setting is 'false':, the rules are just applied during each step of the traversal.
post-traversal-inheritance-sort: false
# Defines the mode used to determine whether a set of contexts are satisfied.
#
# - Possible options:
# => at-least-one-value-per-key Set A will be satisfied by another set B, if at least one of the
# key-value entries per key in A are also in B.
# => all-values-per-key Set A will be satisfied by another set B, if all key-value
# entries in A are also in B.
context-satisfy-mode: at-least-one-value-per-key
# LuckPerms has a number of built-in contexts. These can be disabled by adding the context key to
# the list below.
disabled-contexts:
# - "world"
# +----------------------------------------------------------------------------------------------+ #
# | Permission resolution settings | #
# +----------------------------------------------------------------------------------------------+ #
# If users on this server should have their global permissions applied.
# When set to false, only server specific permissions will apply for users on this server
include-global: true
# If users on this server should have their global world permissions applied.
# When set to false, only world specific permissions will apply for users on this server
include-global-world: true
# If users on this server should have global (non-server specific) groups applied
apply-global-groups: true
# If users on this server should have global (non-world specific) groups applied
apply-global-world-groups: true
# +----------------------------------------------------------------------------------------------+ #
# | Meta lookup settings | #
# +----------------------------------------------------------------------------------------------+ #
# Defines how meta values should be selected.
#
# - Possible options:
# => inheritance Selects the meta value that was inherited first
# => highest-number Selects the highest numerical meta value
# => lowest-number Selects the lowest numerical meta value
meta-value-selection-default: inheritance
# Defines how meta values should be selected per key.
meta-value-selection:
# max-homes: highest-number
# +----------------------------------------------------------------------------------------------+ #
# | Inheritance settings | #
# +----------------------------------------------------------------------------------------------+ #
# If the plugin should apply wildcard permissions.
#
# - If set to true, LuckPerms will detect wildcard permissions, and resolve & apply all registered
# permissions matching the wildcard.
apply-wildcards: true
# If LuckPerms should resolve and apply permissions according to the Sponge style implicit wildcard
# inheritance system.
#
# - That being: If a user has been granted "example", then the player should have also be
# automatically granted "example.function", "example.another", "example.deeper.nesting",
# and so on.
apply-sponge-implicit-wildcards: false
# If the plugin should parse regex permissions.
#
# - If set to true, LuckPerms will detect regex permissions, marked with "r=" at the start of the
# node, and resolve & apply all registered permissions matching the regex.
apply-regex: true
# If the plugin should complete and apply shorthand permissions.
#
# - If set to true, LuckPerms will detect and expand shorthand node patterns.
apply-shorthand: true
# If the plugin should apply Hytale "virtual groups". These act a bit like default permissions for
# built-in commands.
#
# - If set to true, LuckPerms will consider virtual groups after LuckPerms permissions have been
# checked.
apply-hytale-virtual-groups: true
# +----------------------------------------------------------------------------------------------+ #
# | Extra settings | #
# +----------------------------------------------------------------------------------------------+ #
# A list of context calculators which will be skipped when calculating contexts.
#
# - You can disable context calculators by either:
# => specifying the Java class name used by the calculator (e.g. com.example.ExampleCalculator)
# => specifying a sub-section of the Java package used by the calculator (e.g. com.example)
disabled-context-calculators: []
# Allows you to set "aliases" for the worlds sent forward for context calculation.
#
# - These aliases are provided in addition to the real world name. Applied recursively.
# - Remove the comment characters for the default aliases to apply.
world-rewrite:
# world_nether: world
# world_the_end: world
# Define special group weights for this server.
#
# - Group weights can also be applied directly to group data, using the setweight command.
# - This section allows weights to be set on a per-server basis.
group-weight:
# admin: 10
# +----------------------------------------------------------------------------------------------+ #
# | | #
# | FINE TUNING OPTIONS | #
# | | #
# | A number of more niche settings for tweaking and changing behaviour. The section also | #
# | contains toggles for some more specialised features. It is only necessary to make changes to | #
# | these options if you want to fine-tune LuckPerms behaviour. | #
# | | #
# +----------------------------------------------------------------------------------------------+ #
# +----------------------------------------------------------------------------------------------+ #
# | Miscellaneous (and rarely used) settings | #
# +----------------------------------------------------------------------------------------------+ #
# If LuckPerms should produce extra logging output when it handles logins.
#
# - Useful if you're having issues with UUID forwarding or data not being loaded.
debug-logins: false
# If LuckPerms should allow usernames with non alphanumeric characters.
#
# - Note that due to the design of the storage implementation, usernames must still be 16 characters
# or less.
allow-invalid-usernames: false
# If LuckPerms should not require users to confirm bulkupdate operations.
#
# - When set to true, operations will be executed immediately.
# - This is not recommended, as bulkupdate has the potential to irreversibly delete large amounts of
# data, and is not designed to be executed automatically.
# - If automation is needed, users should prefer using the LuckPerms API.
skip-bulkupdate-confirmation: false
# If LuckPerms should prevent bulkupdate operations.
#
# - When set to true, bulkupdate operations (the /lp bulkupdate command) will not work.
# - When set to false, bulkupdate operations will be allowed via the console.
disable-bulkupdate: false
# If LuckPerms should allow a users primary group to be removed with the 'parent remove' command.
#
# - When this happens, the plugin will set their primary group back to default.
prevent-primary-group-removal: false
# If the plugin should run in "read-only" mode for commands.
#
# In this mode, players or the console will only be able to execute commands that read or view
# data, and will not be able to execute any LP commands that modify data.
#
# If enabling read-only mode for just players, be aware that some other plugins may allow players
# to execute commands as the console, allowing them to run LP commands indirectly.
#
# Note: This does not affect interactions with LuckPerms via the API.
commands-read-only-mode:
players: false
console: false
# If LuckPerms commands should be disabled. When true, this will prevent all LP commands from being
# executed. In a sense this is a more extreme version of read-only mode (see above).
#
# LuckPerms will still act as the permission manager, but server administrators will be unable to
# make changes via commands.
#
# If disabling commands just for players, be aware that some other plugins may allow players to
# execute commands as the console, allowing them to run commands indirectly.
#
# If commands are disabled for both players and the console, LuckPerms will not attempt to register
# a command with the server at all & in a sense will be invisible to both players and admins.
#
# Note: This does not affect interactions with LuckPerms via the API.
disable-luckperms-commands:
players: false
console: false
+2
View File
@@ -35,6 +35,8 @@ include (
'forge:loader',
'nukkit',
'nukkit:loader',
'hytale',
'hytale:loader',
'sponge',
'sponge:loader',
'sponge:sponge-service',