1. Содаем плагин
Подключаем интерфейс: PluginMessageListener
В методе onEnable() добавить
Код:
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "opengui");
В теле команды
Код:
player.sendPluginMessage(this, "opengui", text.getBytes());
2.Создаем мод, добавляем аннотации
Код:
@Mod(modid="OpenGuiMod", name="Lalala mod by K773", version="0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false, channels={"opengui"}, packetHandler=OpenGuiListener.class)
Создаем класс OpenGuiListener
Код:
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
import net.minecraft.client.Minecraft;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.client.gui.MyGui;
import net.minecraft.client.Minecraft;
public class OpenGuiListener
implements IPacketHandler
{
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
{
if (packet.channel.equalsIgnoreCase("opengui"))
Minecraft.getMinecraft().displayGuiScreen(new MyGui(new String(packet.data)));
}
}
MyGui.class
Код:
package net.minecraft.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Iterator;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class MyGui extends GuiScreen
{
public MyGui(String text){
this.text=text;
}
private String text = "";
public void initGui()
{
this.buttonList.clear();
}
/**
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
*/
protected void keyTyped(char par1, int par2) {}
/**
* Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
*/
protected void actionPerformed(GuiButton par1GuiButton)
{
switch (par1GuiButton.id)
{
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int par1, int par2, float par3)
{
GL11.glPushMatrix();
GL11.glScalef(2.0F, 2.0F, 2.0F);
GL11.glPopMatrix();
this.mc.fontRenderer.drawString(this.text, this.width / 2, 10, 16777120);
super.drawScreen(par1, par2, par3);
}
/**
* Returns true if this GUI should pause the game when it is displayed in single-player
*/
public boolean doesGuiPauseGame()
{
return false;
}
}
Вот и все, при команде сервер отправляет пакет с текстом, при получении которого клиент открывает новое кастомное Gui и записывает в переменную текст.