mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Remove non-sourced resolver
Fixes a few issues causing placeholders to not work
This commit is contained in:
1 parent
24602555ff
commit
545d09c574
6 files changed
+23
-101
No files matched your search
@@ -37,7 +37,7 @@ import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageSender;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageSource;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.draycia.carbon.common.messages.ReceiverResolver;
|
||||
import net.draycia.carbon.common.messages.SourcedReceiverResolver;
|
||||
import net.draycia.carbon.common.messages.StandardPlaceholderResolverStrategyButDifferent;
|
||||
import net.draycia.carbon.common.messages.placeholders.BooleanPlaceholderResolver;
|
||||
import net.draycia.carbon.common.messages.placeholders.ComponentPlaceholderResolver;
|
||||
@@ -92,7 +92,7 @@ public final class CarbonCommonModule extends AbstractModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
public CarbonMessages carbonMessages(
|
||||
final ReceiverResolver receiverResolver,
|
||||
final SourcedReceiverResolver receiverResolver,
|
||||
final ComponentPlaceholderResolver<Audience> componentPlaceholderResolver,
|
||||
final UUIDPlaceholderResolver<Audience> uuidPlaceholderResolver,
|
||||
final StringPlaceholderResolver<Audience> stringPlaceholderResolver,
|
||||
|
||||
@@ -98,10 +98,10 @@ public class WhisperCommand extends CarbonCommand {
|
||||
final String message = handler.get("message");
|
||||
final CarbonPlayer recipient = handler.get("player");
|
||||
|
||||
if (sender.equals(recipient)) {
|
||||
this.carbonMessages.whisperSelfError(sender, CarbonPlayer.renderName(sender));
|
||||
return;
|
||||
}
|
||||
// if (sender.equals(recipient)) {
|
||||
// this.carbonMessages.whisperSelfError(sender, CarbonPlayer.renderName(sender));
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (!recipient.online() || !sender.awareOf(recipient) && !sender.hasPermission("carbon.whisper.vanished")) {
|
||||
final var rawNameInput = CloudUtils.rawInputByMatchingName(handler.getRawInput(), recipient);
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2023 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
//
|
||||
// ban - A punishment suite for Velocity.
|
||||
// Copyright (C) 2021 Mariell Hoversholm
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Modified to better fit in Carbon
|
||||
//
|
||||
|
||||
package net.draycia.carbon.common.messages;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import javax.inject.Singleton;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.moonshine.receiver.IReceiverLocator;
|
||||
import net.kyori.moonshine.receiver.IReceiverLocatorResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@Singleton
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class ReceiverResolver implements IReceiverLocatorResolver<Audience> {
|
||||
|
||||
@Override
|
||||
public IReceiverLocator<Audience> resolve(final Method method, final Type proxy) {
|
||||
return new Resolver();
|
||||
}
|
||||
|
||||
private static final class Resolver implements IReceiverLocator<Audience> {
|
||||
@Override
|
||||
public Audience locate(final Method method, final Object proxy, final @Nullable Object[] parameters) {
|
||||
if (parameters.length == 0) {
|
||||
return Audience.empty();
|
||||
}
|
||||
|
||||
final @Nullable Object parameter = parameters[0];
|
||||
|
||||
if (parameter instanceof SourcedAudience sourcedAudience) {
|
||||
return sourcedAudience.recipient();
|
||||
} else if (parameter instanceof Audience audience) {
|
||||
return audience;
|
||||
}
|
||||
|
||||
return Audience.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+11
-4
@@ -43,6 +43,7 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import javax.inject.Singleton;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.moonshine.receiver.IReceiverLocator;
|
||||
import net.kyori.moonshine.receiver.IReceiverLocatorResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -61,10 +62,16 @@ public final class SourcedReceiverResolver implements IReceiverLocatorResolver<S
|
||||
private static final class Resolver implements IReceiverLocator<SourcedAudience> {
|
||||
@Override
|
||||
public SourcedAudience locate(final Method method, final Object proxy, final @Nullable Object[] parameters) {
|
||||
for (final Object parameter : parameters) {
|
||||
if (parameter instanceof SourcedAudience audience) {
|
||||
return audience;
|
||||
}
|
||||
if (parameters.length == 0) {
|
||||
return SourcedAudience.empty();
|
||||
}
|
||||
|
||||
final @Nullable Object parameter = parameters[0];
|
||||
|
||||
if (parameter instanceof SourcedAudience sourcedAudience) {
|
||||
return sourcedAudience;
|
||||
} else if (parameter instanceof Audience audience) {
|
||||
return new SourcedAudience(audience, audience);
|
||||
}
|
||||
|
||||
return SourcedAudience.empty();
|
||||
|
||||
Reference in new issue
Block a user