mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
quick chat
This commit is contained in:
1 parent
22f86a9268
commit
6cde90d39b
4 files changed
+32
-3
No files matched your search
@@ -3,6 +3,7 @@ package net.draycia.carbon.api.users;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import net.draycia.carbon.api.channels.ChatChannel;
|
import net.draycia.carbon.api.channels.ChatChannel;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.identity.Identified;
|
import net.kyori.adventure.identity.Identified;
|
||||||
@@ -172,4 +173,14 @@ public interface CarbonPlayer extends Audience, Identified {
|
|||||||
*/
|
*/
|
||||||
void spying(final boolean spying);
|
void spying(final boolean spying);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the message as the player.
|
||||||
|
*
|
||||||
|
* @param message the message to be sent
|
||||||
|
* //@return the message result
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
// TODO: change return type, provide information useful like what message was actually sent?
|
||||||
|
void sendMessageAsPlayer(final String message);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -253,4 +253,11 @@ public final class CarbonPlayerBukkit extends CarbonPlayerCommon implements Forw
|
|||||||
return this.carbonPlayer.identity();
|
return this.carbonPlayer.identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessageAsPlayer(String message) {
|
||||||
|
Bukkit.getScheduler().runTask(Bukkit.getPluginManager().getPlugin("CarbonChat"), () -> {
|
||||||
|
Objects.requireNonNull(this.player()).chat(message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.draycia.carbon.common.channels;
|
package net.draycia.carbon.common.channels;
|
||||||
|
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
|
import cloud.commandframework.arguments.standard.StringArgument;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
@@ -119,12 +121,18 @@ public class CarbonChannelRegistry extends RegistryImpl<Key, ChatChannel> implem
|
|||||||
register(channelKey, channel);
|
register(channelKey, channel);
|
||||||
|
|
||||||
var command = commandManager.commandBuilder(channelKey.value())
|
var command = commandManager.commandBuilder(channelKey.value())
|
||||||
//.literal(channelKey.toString(), channelKey.value())
|
.argument(StringArgument.<Commander>newBuilder("message").greedy().asOptional().build())
|
||||||
.permission("carbon.channel." + channelKey)
|
.permission("carbon.channel." + channelKey)
|
||||||
.senderType(PlayerCommander.class)
|
.senderType(PlayerCommander.class)
|
||||||
.handler(handler -> {
|
.handler(handler -> {
|
||||||
((PlayerCommander)handler.getSender()).carbonPlayer().selectedChannel(channel);
|
if (handler.contains("message")) {
|
||||||
this.messageService.changedChannels(handler.getSender(), channel.key().value());
|
final String message = handler.get("message");
|
||||||
|
|
||||||
|
((PlayerCommander)handler.getSender()).carbonPlayer().sendMessageAsPlayer(message);
|
||||||
|
} else {
|
||||||
|
((PlayerCommander)handler.getSender()).carbonPlayer().selectedChannel(channel);
|
||||||
|
this.messageService.changedChannels(handler.getSender(), channel.key().value());
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.build(); // TODO: command aliases
|
.build(); // TODO: command aliases
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
|||||||
this.spying = spying;
|
this.spying = spying;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessageAsPlayer(String message) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identity identity() {
|
public Identity identity() {
|
||||||
return Identity.identity(this.uuid);
|
return Identity.identity(this.uuid);
|
||||||
|
|||||||
Reference in new issue
Block a user