mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-08-22 14:12:48 +02:00
Update Sponge module to API 12
This commit is contained in:
@@ -29,7 +29,6 @@ import me.lucko.luckperms.common.locale.TranslationManager;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.TranslatableComponent;
|
import net.kyori.adventure.text.TranslatableComponent;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@@ -38,7 +38,7 @@ include (
|
|||||||
'sponge',
|
'sponge',
|
||||||
'sponge:loader',
|
'sponge:loader',
|
||||||
'sponge:sponge-service',
|
'sponge:sponge-service',
|
||||||
'sponge:sponge-service-api8',
|
'sponge:sponge-service-proxy',
|
||||||
'velocity',
|
'velocity',
|
||||||
'standalone',
|
'standalone',
|
||||||
'standalone:loader',
|
'standalone:loader',
|
||||||
|
@@ -2,6 +2,9 @@ plugins {
|
|||||||
alias(libs.plugins.shadow)
|
alias(libs.plugins.shadow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 17
|
||||||
|
targetCompatibility = 21
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||||
}
|
}
|
||||||
@@ -9,15 +12,16 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':common')
|
implementation project(':common')
|
||||||
implementation project(':sponge:sponge-service')
|
implementation project(':sponge:sponge-service')
|
||||||
implementation project(':sponge:sponge-service-api8')
|
implementation project(':sponge:sponge-service-proxy')
|
||||||
compileOnly project(':common:loader-utils')
|
compileOnly project(':common:loader-utils')
|
||||||
|
|
||||||
compileOnly('org.spongepowered:spongeapi:8.0.0') {
|
compileOnly('org.spongepowered:spongeapi:12.0.0') {
|
||||||
exclude(module: 'configurate-core')
|
exclude(module: 'configurate-core')
|
||||||
exclude(module: 'configurate-hocon')
|
exclude(module: 'configurate-hocon')
|
||||||
exclude(module: 'configurate-gson')
|
exclude(module: 'configurate-gson')
|
||||||
exclude(module: 'configurate-yaml')
|
exclude(module: 'configurate-yaml')
|
||||||
}
|
}
|
||||||
|
compileOnly 'com.google.guava:guava:33.3.1-jre'
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@@ -2,12 +2,15 @@ plugins {
|
|||||||
alias(libs.plugins.shadow)
|
alias(libs.plugins.shadow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 17
|
||||||
|
targetCompatibility = 21
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.spongepowered:spongeapi:8.0.0'
|
compileOnly 'org.spongepowered:spongeapi:12.0.0'
|
||||||
|
|
||||||
implementation project(':api')
|
implementation project(':api')
|
||||||
implementation project(':common:loader-utils')
|
implementation project(':common:loader-utils')
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"id": "spongeapi",
|
"id": "spongeapi",
|
||||||
"version": "8.0.0"
|
"version": "12.0.0"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -2,11 +2,14 @@ repositories {
|
|||||||
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 17
|
||||||
|
targetCompatibility = 21
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':common')
|
implementation project(':common')
|
||||||
implementation project(':sponge:sponge-service')
|
implementation project(':sponge:sponge-service')
|
||||||
|
|
||||||
compileOnly('org.spongepowered:spongeapi:8.0.0') {
|
compileOnly('org.spongepowered:spongeapi:12.0.0') {
|
||||||
exclude(module: 'configurate-core')
|
exclude(module: 'configurate-core')
|
||||||
exclude(module: 'configurate-hocon')
|
exclude(module: 'configurate-hocon')
|
||||||
exclude(module: 'configurate-gson')
|
exclude(module: 'configurate-gson')
|
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.sponge.service.proxy.api8;
|
package me.lucko.luckperms.sponge.service.proxy;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.context.ImmutableContextSetImpl;
|
import me.lucko.luckperms.common.context.ImmutableContextSetImpl;
|
||||||
import me.lucko.luckperms.sponge.service.model.LPPermissionDescription;
|
import me.lucko.luckperms.sponge.service.model.LPPermissionDescription;
|
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.sponge.service.proxy.api8;
|
package me.lucko.luckperms.sponge.service.proxy;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
import me.lucko.luckperms.sponge.service.model.LPPermissionDescription;
|
import me.lucko.luckperms.sponge.service.model.LPPermissionDescription;
|
||||||
@@ -130,6 +130,6 @@ public final class PermissionDescriptionProxy implements PermissionDescription,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "luckperms.api8.PermissionDescriptionProxy(handle=" + this.handle + ")";
|
return "luckperms.PermissionDescriptionProxy(handle=" + this.handle + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.sponge.service.proxy.api8;
|
package me.lucko.luckperms.sponge.service.proxy;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
@@ -169,6 +169,6 @@ public final class PermissionServiceProxy implements PermissionAndContextService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "luckperms.api8.PermissionServiceProxy(handle=" + this.handle + ")";
|
return "luckperms.PermissionServiceProxy(handle=" + this.handle + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.sponge.service.proxy.api8;
|
package me.lucko.luckperms.sponge.service.proxy;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
import me.lucko.luckperms.sponge.service.model.LPProxiedServiceObject;
|
import me.lucko.luckperms.sponge.service.model.LPProxiedServiceObject;
|
||||||
@@ -43,7 +43,6 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public final class SubjectCollectionProxy implements SubjectCollection, LPProxiedServiceObject {
|
public final class SubjectCollectionProxy implements SubjectCollection, LPProxiedServiceObject {
|
||||||
private final LPSubjectCollection handle;
|
private final LPSubjectCollection handle;
|
||||||
|
|
||||||
@@ -86,7 +85,7 @@ public final class SubjectCollectionProxy implements SubjectCollection, LPProxie
|
|||||||
return this.handle.getLoadedSubjects().stream().map(LPSubject::sponge).collect(ImmutableCollectors.toSet());
|
return this.handle.getLoadedSubjects().stream().map(LPSubject::sponge).collect(ImmutableCollectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public @NonNull CompletableFuture<Set<String>> allIdentifiers() {
|
public @NonNull CompletableFuture<Set<String>> allIdentifiers() {
|
||||||
return (CompletableFuture) this.handle.getAllIdentifiers();
|
return (CompletableFuture) this.handle.getAllIdentifiers();
|
||||||
@@ -102,13 +101,13 @@ public final class SubjectCollectionProxy implements SubjectCollection, LPProxie
|
|||||||
return this.handle.getService().getReferenceFactory().obtain(identifier(), subjectIdentifier);
|
return this.handle.getService().getReferenceFactory().obtain(identifier(), subjectIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public @NonNull CompletableFuture<Map<SubjectReference, Boolean>> allWithPermission(@NonNull String s) {
|
public @NonNull CompletableFuture<Map<SubjectReference, Boolean>> allWithPermission(@NonNull String s) {
|
||||||
return (CompletableFuture) this.handle.getAllWithPermission(s);
|
return (CompletableFuture) this.handle.getAllWithPermission(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public @NonNull CompletableFuture<Map<SubjectReference, Boolean>> allWithPermission(@NonNull String s, @NonNull Cause cause) {
|
public @NonNull CompletableFuture<Map<SubjectReference, Boolean>> allWithPermission(@NonNull String s, @NonNull Cause cause) {
|
||||||
return (CompletableFuture) this.handle.getAllWithPermission(this.handle.getService().getContextsForCause(cause), s);
|
return (CompletableFuture) this.handle.getAllWithPermission(this.handle.getService().getContextsForCause(cause), s);
|
||||||
@@ -154,7 +153,7 @@ public final class SubjectCollectionProxy implements SubjectCollection, LPProxie
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "luckperms.api8.SubjectCollectionProxy(handle=" + this.handle + ")";
|
return "luckperms.SubjectCollectionProxy(handle=" + this.handle + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.sponge.service.proxy.api8;
|
package me.lucko.luckperms.sponge.service.proxy;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import me.lucko.luckperms.common.util.CompletableFutures;
|
import me.lucko.luckperms.common.util.CompletableFutures;
|
||||||
@@ -49,7 +49,6 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public final class SubjectDataProxy implements SubjectData, LPProxiedServiceObject {
|
public final class SubjectDataProxy implements SubjectData, LPProxiedServiceObject {
|
||||||
private final LPPermissionService service;
|
private final LPPermissionService service;
|
||||||
private final LPSubjectReference ref;
|
private final LPSubjectReference ref;
|
||||||
@@ -77,7 +76,7 @@ public final class SubjectDataProxy implements SubjectData, LPProxiedServiceObje
|
|||||||
return !this.enduring;
|
return !this.enduring;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Map<Set<Context>, Map<String, Boolean>> allPermissions() {
|
public @NonNull Map<Set<Context>, Map<String, Boolean>> allPermissions() {
|
||||||
return (Map) handle().thenApply(handle -> handle.getAllPermissions().entrySet().stream()
|
return (Map) handle().thenApply(handle -> handle.getAllPermissions().entrySet().stream()
|
||||||
@@ -148,7 +147,7 @@ public final class SubjectDataProxy implements SubjectData, LPProxiedServiceObje
|
|||||||
return handle().thenCompose(handle -> handle.clearPermissions(CompatibilityUtil.convertContexts(contexts)));
|
return handle().thenCompose(handle -> handle.clearPermissions(CompatibilityUtil.convertContexts(contexts)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Map<Set<Context>, List<org.spongepowered.api.service.permission.SubjectReference>> allParents() {
|
public @NonNull Map<Set<Context>, List<org.spongepowered.api.service.permission.SubjectReference>> allParents() {
|
||||||
return (Map) handle().thenApply(handle -> handle.getAllParents().entrySet().stream()
|
return (Map) handle().thenApply(handle -> handle.getAllParents().entrySet().stream()
|
||||||
@@ -158,7 +157,7 @@ public final class SubjectDataProxy implements SubjectData, LPProxiedServiceObje
|
|||||||
))).join();
|
))).join();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public @NonNull List<org.spongepowered.api.service.permission.SubjectReference> parents(@NonNull Set<Context> contexts) {
|
public @NonNull List<org.spongepowered.api.service.permission.SubjectReference> parents(@NonNull Set<Context> contexts) {
|
||||||
return (List) handle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts))).join();
|
return (List) handle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts))).join();
|
||||||
@@ -189,7 +188,7 @@ public final class SubjectDataProxy implements SubjectData, LPProxiedServiceObje
|
|||||||
return handle().thenCompose(handle -> handle.clearParents(CompatibilityUtil.convertContexts(contexts)));
|
return handle().thenCompose(handle -> handle.clearParents(CompatibilityUtil.convertContexts(contexts)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Map<Set<Context>, Map<String, String>> allOptions() {
|
public @NonNull Map<Set<Context>, Map<String, String>> allOptions() {
|
||||||
return (Map) handle().thenApply(handle -> handle.getAllOptions().entrySet().stream()
|
return (Map) handle().thenApply(handle -> handle.getAllOptions().entrySet().stream()
|
||||||
@@ -253,6 +252,6 @@ public final class SubjectDataProxy implements SubjectData, LPProxiedServiceObje
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "luckperms.api8.SubjectDataProxy(ref=" + this.ref + ", enduring=" + this.enduring + ")";
|
return "luckperms.SubjectDataProxy(ref=" + this.ref + ", enduring=" + this.enduring + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.sponge.service.proxy.api8;
|
package me.lucko.luckperms.sponge.service.proxy;
|
||||||
|
|
||||||
import me.lucko.luckperms.sponge.service.CompatibilityUtil;
|
import me.lucko.luckperms.sponge.service.CompatibilityUtil;
|
||||||
import me.lucko.luckperms.sponge.service.model.LPPermissionService;
|
import me.lucko.luckperms.sponge.service.model.LPPermissionService;
|
||||||
@@ -49,7 +49,6 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public final class SubjectProxy implements Subject, LPProxiedSubject, LPProxiedServiceObject {
|
public final class SubjectProxy implements Subject, LPProxiedSubject, LPProxiedServiceObject {
|
||||||
private final LPPermissionService service;
|
private final LPPermissionService service;
|
||||||
private final LPSubjectReference ref;
|
private final LPSubjectReference ref;
|
||||||
@@ -169,6 +168,6 @@ public final class SubjectProxy implements Subject, LPProxiedSubject, LPProxiedS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "luckperms.api8.SubjectProxy(ref=" + this.ref + ")";
|
return "luckperms.SubjectProxy(ref=" + this.ref + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,15 +2,17 @@ repositories {
|
|||||||
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 17
|
||||||
|
targetCompatibility = 21
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':common')
|
implementation project(':common')
|
||||||
|
|
||||||
compileOnly('org.spongepowered:spongeapi:8.0.0') {
|
compileOnly('org.spongepowered:spongeapi:12.0.0') {
|
||||||
exclude(module: 'configurate-core')
|
exclude(module: 'configurate-core')
|
||||||
exclude(module: 'configurate-hocon')
|
exclude(module: 'configurate-hocon')
|
||||||
exclude(module: 'configurate-gson')
|
exclude(module: 'configurate-gson')
|
||||||
exclude(module: 'configurate-yaml')
|
exclude(module: 'configurate-yaml')
|
||||||
}
|
}
|
||||||
compileOnly 'com.google.guava:guava:21.0'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -77,26 +77,20 @@ public final class CompatibilityUtil {
|
|||||||
|
|
||||||
public static org.spongepowered.api.util.Tristate convertTristate(Tristate tristate) {
|
public static org.spongepowered.api.util.Tristate convertTristate(Tristate tristate) {
|
||||||
Objects.requireNonNull(tristate, "tristate");
|
Objects.requireNonNull(tristate, "tristate");
|
||||||
switch (tristate) {
|
return switch (tristate) {
|
||||||
case TRUE:
|
case TRUE -> org.spongepowered.api.util.Tristate.TRUE;
|
||||||
return org.spongepowered.api.util.Tristate.TRUE;
|
case FALSE -> org.spongepowered.api.util.Tristate.FALSE;
|
||||||
case FALSE:
|
default -> org.spongepowered.api.util.Tristate.UNDEFINED;
|
||||||
return org.spongepowered.api.util.Tristate.FALSE;
|
};
|
||||||
default:
|
|
||||||
return org.spongepowered.api.util.Tristate.UNDEFINED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Tristate convertTristate(org.spongepowered.api.util.Tristate tristate) {
|
public static Tristate convertTristate(org.spongepowered.api.util.Tristate tristate) {
|
||||||
Objects.requireNonNull(tristate, "tristate");
|
Objects.requireNonNull(tristate, "tristate");
|
||||||
switch (tristate) {
|
return switch (tristate) {
|
||||||
case TRUE:
|
case TRUE -> Tristate.TRUE;
|
||||||
return Tristate.TRUE;
|
case FALSE -> Tristate.FALSE;
|
||||||
case FALSE:
|
default -> Tristate.UNDEFINED;
|
||||||
return Tristate.FALSE;
|
};
|
||||||
default:
|
|
||||||
return Tristate.UNDEFINED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -44,8 +44,7 @@ abstract class AbstractForwardingContextSet extends AbstractSet<Context> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if (o instanceof Context) {
|
if (o instanceof Context context) {
|
||||||
Context context = (Context) o;
|
|
||||||
return !context.getKey().isEmpty() && !context.getValue().isEmpty() && delegate().contains(context.getKey(), context.getValue());
|
return !context.getKey().isEmpty() && !context.getValue().isEmpty() && delegate().contains(context.getKey(), context.getValue());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -31,6 +31,7 @@ import me.lucko.luckperms.common.locale.TranslationManager;
|
|||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
||||||
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
||||||
|
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.Order;
|
import org.spongepowered.api.event.Order;
|
||||||
import org.spongepowered.api.event.filter.IsCancelled;
|
import org.spongepowered.api.event.filter.IsCancelled;
|
||||||
@@ -48,18 +49,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class SpongeConnectionListener extends AbstractConnectionListener {
|
public class SpongeConnectionListener extends AbstractConnectionListener {
|
||||||
|
|
||||||
// Sponge API 11
|
|
||||||
private static final Method DISCONNECT_EVENT_PROFILE_METHOD;
|
|
||||||
static {
|
|
||||||
Method disconnectEventProfileMethod;
|
|
||||||
try {
|
|
||||||
disconnectEventProfileMethod = ServerSideConnectionEvent.Disconnect.class.getMethod("profile");
|
|
||||||
} catch (ReflectiveOperationException e) {
|
|
||||||
disconnectEventProfileMethod = null;
|
|
||||||
}
|
|
||||||
DISCONNECT_EVENT_PROFILE_METHOD = disconnectEventProfileMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final LPSpongePlugin plugin;
|
private final LPSpongePlugin plugin;
|
||||||
|
|
||||||
private final Set<UUID> deniedAsyncLogin = Collections.synchronizedSet(new HashSet<>());
|
private final Set<UUID> deniedAsyncLogin = Collections.synchronizedSet(new HashSet<>());
|
||||||
@@ -184,28 +173,8 @@ public class SpongeConnectionListener extends AbstractConnectionListener {
|
|||||||
|
|
||||||
@Listener(order = Order.POST)
|
@Listener(order = Order.POST)
|
||||||
public void onClientLeave(ServerSideConnectionEvent.Disconnect e) {
|
public void onClientLeave(ServerSideConnectionEvent.Disconnect e) {
|
||||||
Identifiable player = null;
|
Optional<GameProfile> profile = e.profile();
|
||||||
|
profile.ifPresent(p -> handleDisconnect(p.uniqueId()));
|
||||||
if (DISCONNECT_EVENT_PROFILE_METHOD == null) {
|
|
||||||
// sponge API < 11
|
|
||||||
player = e.player();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// sponge API 11+
|
|
||||||
try {
|
|
||||||
//noinspection unchecked
|
|
||||||
final Optional<GameProfile> profile = (Optional<GameProfile>) DISCONNECT_EVENT_PROFILE_METHOD.invoke(e);
|
|
||||||
if (profile.isPresent()) {
|
|
||||||
player = profile.get();
|
|
||||||
}
|
|
||||||
} catch (ReflectiveOperationException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
handleDisconnect(player.uniqueId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -31,8 +31,11 @@ import me.lucko.luckperms.sponge.LPSpongePlugin;
|
|||||||
import net.luckperms.api.messenger.IncomingMessageConsumer;
|
import net.luckperms.api.messenger.IncomingMessageConsumer;
|
||||||
import net.luckperms.api.messenger.Messenger;
|
import net.luckperms.api.messenger.Messenger;
|
||||||
import org.spongepowered.api.ResourceKey;
|
import org.spongepowered.api.ResourceKey;
|
||||||
|
import org.spongepowered.api.Server;
|
||||||
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
||||||
import org.spongepowered.api.network.EngineConnectionSide;
|
import org.spongepowered.api.network.EngineConnectionSide;
|
||||||
|
import org.spongepowered.api.network.EngineConnectionState;
|
||||||
|
import org.spongepowered.api.network.ServerConnectionState;
|
||||||
import org.spongepowered.api.network.ServerSideConnection;
|
import org.spongepowered.api.network.ServerSideConnection;
|
||||||
import org.spongepowered.api.network.channel.ChannelBuf;
|
import org.spongepowered.api.network.channel.ChannelBuf;
|
||||||
import org.spongepowered.api.network.channel.raw.RawDataChannel;
|
import org.spongepowered.api.network.channel.raw.RawDataChannel;
|
||||||
@@ -46,7 +49,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
/**
|
/**
|
||||||
* An implementation of {@link Messenger} using the plugin messaging channels.
|
* An implementation of {@link Messenger} using the plugin messaging channels.
|
||||||
*/
|
*/
|
||||||
public class PluginMessageMessenger extends AbstractPluginMessageMessenger implements RawPlayDataHandler<ServerSideConnection> {
|
public class PluginMessageMessenger extends AbstractPluginMessageMessenger implements RawPlayDataHandler<ServerConnectionState.Game> {
|
||||||
private static final ResourceKey CHANNEL = ResourceKey.resolve(AbstractPluginMessageMessenger.CHANNEL);
|
private static final ResourceKey CHANNEL = ResourceKey.resolve(AbstractPluginMessageMessenger.CHANNEL);
|
||||||
|
|
||||||
private final LPSpongePlugin plugin;
|
private final LPSpongePlugin plugin;
|
||||||
@@ -60,7 +63,7 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
|
|||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
this.channel = this.plugin.getBootstrap().getGame().channelManager().ofType(CHANNEL, RawDataChannel.class);
|
this.channel = this.plugin.getBootstrap().getGame().channelManager().ofType(CHANNEL, RawDataChannel.class);
|
||||||
this.channel.play().addHandler(EngineConnectionSide.SERVER, this);
|
this.channel.play().addHandler(ServerConnectionState.Game.class, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,7 +105,7 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePayload(ChannelBuf channelBuf, ServerSideConnection connection) {
|
public void handlePayload(ChannelBuf channelBuf, ServerConnectionState.Game state) {
|
||||||
byte[] buf = channelBuf.readBytes(channelBuf.available());
|
byte[] buf = channelBuf.readBytes(channelBuf.available());
|
||||||
handleIncomingMessage(buf);
|
handleIncomingMessage(buf);
|
||||||
}
|
}
|
||||||
|
@@ -31,11 +31,11 @@ import me.lucko.luckperms.sponge.service.model.LPProxiedSubject;
|
|||||||
import me.lucko.luckperms.sponge.service.model.LPSubject;
|
import me.lucko.luckperms.sponge.service.model.LPSubject;
|
||||||
import me.lucko.luckperms.sponge.service.model.LPSubjectCollection;
|
import me.lucko.luckperms.sponge.service.model.LPSubjectCollection;
|
||||||
import me.lucko.luckperms.sponge.service.model.LPSubjectData;
|
import me.lucko.luckperms.sponge.service.model.LPSubjectData;
|
||||||
import me.lucko.luckperms.sponge.service.proxy.api8.PermissionDescriptionProxy;
|
import me.lucko.luckperms.sponge.service.proxy.PermissionDescriptionProxy;
|
||||||
import me.lucko.luckperms.sponge.service.proxy.api8.PermissionServiceProxy;
|
import me.lucko.luckperms.sponge.service.proxy.PermissionServiceProxy;
|
||||||
import me.lucko.luckperms.sponge.service.proxy.api8.SubjectCollectionProxy;
|
import me.lucko.luckperms.sponge.service.proxy.SubjectCollectionProxy;
|
||||||
import me.lucko.luckperms.sponge.service.proxy.api8.SubjectDataProxy;
|
import me.lucko.luckperms.sponge.service.proxy.SubjectDataProxy;
|
||||||
import me.lucko.luckperms.sponge.service.proxy.api8.SubjectProxy;
|
import me.lucko.luckperms.sponge.service.proxy.SubjectProxy;
|
||||||
import net.luckperms.api.model.data.DataType;
|
import net.luckperms.api.model.data.DataType;
|
||||||
import org.spongepowered.api.service.permission.PermissionDescription;
|
import org.spongepowered.api.service.permission.PermissionDescription;
|
||||||
import org.spongepowered.api.service.permission.SubjectCollection;
|
import org.spongepowered.api.service.permission.SubjectCollection;
|
||||||
|
Reference in New Issue
Block a user