Ajout de la requête NetworkAPI permettant d'envoyer un message depuis la console. La coloration du pseudo est géré par le plugin au lieu de MineAdmin
This commit is contained in:
parent
5a9474822c
commit
c13de458d4
@ -43,6 +43,10 @@ Pareil que `command` mais cette fois, celle-ci n'est pas forcément exécutée d
|
||||
Affiche un message sur le chat pour tout le monde connecté.
|
||||
Le message passé dans la partie **donnée** est diffusé en convertissant les codes couleurs `&x` en `§x`
|
||||
|
||||
#### `chat_send`
|
||||
Affiche un message en tant qu'un joueur donné, sur le chat du serveur
|
||||
La partie **donnée** de la requête contient d'abord le pseudo du joueur concerné, suivi d'un espace, suivi du message.
|
||||
|
||||
#### `player_list`
|
||||
Renvoi la liste des joueurs connectés, avec quelques infos utiles.
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.mc_pandacraft.java.plugin.pandacraftutils.network_api;
|
||||
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.request_executors.RequestExecutorBroadcast;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.request_executors.RequestExecutorChatSend;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.request_executors.RequestExecutorCommand;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.request_executors.RequestExecutorCommandAsync;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.request_executors.RequestExecutorPlayerList;
|
||||
@ -20,6 +21,7 @@ public class NetworkAPI {
|
||||
new RequestExecutorBroadcast();
|
||||
new RequestExecutorCommandAsync();
|
||||
new RequestExecutorPlayerList();
|
||||
new RequestExecutorChatSend();
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@ public class NetworkAPIListener extends Thread {
|
||||
|
||||
private NetworkAPIListener() {
|
||||
super("NetworkAPI Listener");
|
||||
System.setProperty("file.encoding", "UTF-8");
|
||||
plugin.getServer().getLogger().info("System property 'file.encoding' was set to 'UTF-8'");
|
||||
|
||||
|
||||
|
@ -16,10 +16,7 @@ public class RequestExecutorBroadcast extends AbstractRequestExecutor {
|
||||
|
||||
plugin.broadcast(ChatColor.translateAlternateColorCodes('&', data), false);
|
||||
|
||||
Response rep = new Response();
|
||||
rep.good = true;
|
||||
rep.data = "";
|
||||
return rep;
|
||||
return new Response(true, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package net.mc_pandacraft.java.plugin.pandacraftutils.network_api.request_executors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import ru.tehkode.permissions.PermissionUser;
|
||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.Response;
|
||||
|
||||
public class RequestExecutorChatSend extends AbstractRequestExecutor {
|
||||
|
||||
public RequestExecutorChatSend() {
|
||||
super("chat_send");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Response run(String data) {
|
||||
|
||||
String[] dataSplit = data.split(" ", 2);
|
||||
if (dataSplit.length != 2)
|
||||
return new Response(false, "bad_data : at least one space");
|
||||
|
||||
PermissionUser permUser = PermissionsEx.getUser(dataSplit[0]);
|
||||
|
||||
if (permUser == null)
|
||||
return new Response(false, "user_not_exist : user is not registered in permission plugin");
|
||||
|
||||
String displayName = permUser.getPrefix() + permUser.getName() + permUser.getSuffix();
|
||||
|
||||
|
||||
String finalMessage = "["+ChatColor.GRAY+"Console"+ChatColor.RESET+"]<"+displayName+ChatColor.RESET+"> "+dataSplit[1];
|
||||
|
||||
plugin.broadcast(ChatColor.translateAlternateColorCodes('&', finalMessage), false);
|
||||
|
||||
return new Response(true, "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user