mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
add MessageKey method to CommandIssuer and misc stuff
This commit is contained in:
@@ -47,6 +47,11 @@ public class BukkitCommandIssuer implements CommandIssuer {
|
||||
return (T) sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(MessageType type, String message) {
|
||||
sender.sendMessage(ACFBukkitUtil.color(format(manager, type, message)));
|
||||
|
||||
@@ -43,6 +43,11 @@ public class BungeeCommandIssuer implements CommandIssuer{
|
||||
return (T) sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return sender instanceof ProxiedPlayer;
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
package co.aikar.commands;
|
||||
|
||||
import co.aikar.locales.MessageKey;
|
||||
|
||||
public interface CommandIssuer {
|
||||
/**
|
||||
* Gets the issuer in the platforms native object
|
||||
@@ -31,6 +33,8 @@ public interface CommandIssuer {
|
||||
*/
|
||||
<T> T getIssuer();
|
||||
|
||||
CommandManager getManager();
|
||||
|
||||
/**
|
||||
* Is this issue a player, or server/console sender
|
||||
* @return
|
||||
@@ -52,7 +56,12 @@ public interface CommandIssuer {
|
||||
*/
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
default void sendMessage(MessageType type, MessageKey key, String... replacements) {
|
||||
getManager().sendMessage(this, type, key, replacements);
|
||||
}
|
||||
|
||||
void sendMessage(MessageType type, String message);
|
||||
|
||||
default String format(CommandManager manager, MessageType type, String message) {
|
||||
MessageFormatter formatter = manager.formatters.get(type);
|
||||
if (formatter != null) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Daniel Ennis (Aikar) - MIT License
|
||||
*
|
||||
* 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 co.aikar.commands;
|
||||
|
||||
import co.aikar.locales.MessageKey;
|
||||
|
||||
public class MessageKeys {
|
||||
public static final MessageKey KEY = MessageKey.of("");
|
||||
}
|
||||
@@ -26,7 +26,6 @@ package co.aikar.commands;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@Deprecated
|
||||
public class MessageType {
|
||||
public static MessageType INFO = new MessageType();
|
||||
public static MessageType SYNTAX = new MessageType();
|
||||
|
||||
+22
-2
@@ -2,7 +2,11 @@
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration />
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>PAPER</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
@@ -18,7 +22,23 @@
|
||||
<orderEntry type="module" module-name="acf-core" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:locales:1.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:minecraft-timings:1.0.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo:paper-api:1.12-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.12-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.mojang:authlib:1.5.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-all:5.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -50,6 +50,11 @@ public class SpongeCommandIssuer implements CommandIssuer {
|
||||
return (T) this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(MessageType type, String message) {
|
||||
message = format(manager, type, message);
|
||||
|
||||
Reference in New Issue
Block a user