Résolu Lancer une command non player
-
Bonjours,
Je voudrai faire un bouton qui execute une commande, j’ai fait sa :
this.mc.thePlayer.sendChatMessage("/broadcast " + this.mc.getSession().getUsername() + " A choisi la classe Druide");
sauf que comme sa il faut que le joueur est la permission mais sa je veut pas. Aprés j’ai penser de faire un ICommandSender mais j’y arrive pas.
Voilà mon code entier.
package fr.darkvince.facrpg; import java.awt.Desktop; import java.awt.Menu; import java.io.IOException; import java.net.URI; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiOptions; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.I18n; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; public class GuiGrade extends GuiScreen { private int xSize; private int ySize; protected int guiLeft; int displayX; int displayY; protected int guiTop; private float xSize_lo; private float ySize_lo; private Minecraft minecraft; private EntityPlayer player; private ICommandSender cmd; private int field_146445_a; private int field_146444_f; private static final String __OBFID = "CL_00000703"; public GuiGrade(Minecraft minecraft, ICommandSender command, EntityPlayer entityplayer, GuiScreen par1GuiScreen, InventoryPlayer inventory) { this.displayX = (this.width - this.xSize) / 2; this.displayY = (this.height - this.ySize) / 2; this.xSize = 250; this.ySize = 202; this.mc = minecraft; this.cmd = command; this.player = entityplayer; } /** * Adds the buttons (and other controls) to the screen in question. */ public void initGui() { this.field_146445_a = 0; this.buttonList.clear(); boolean var1 = true; boolean var2 = true; this.buttonList.add(new GuiButton(0, this.width / 2 + 70, this.height - 110, 98, 20, I18n.format("Druide", new Object[0]))); this.buttonList.add(new GuiButton(1, this.width / 2 + 70,this.height - 80, 98, 20, I18n.format("Paladin", new Object[0]))); this.buttonList.add(new GuiButton(2, this.width / 2 -170,this.height - 80, 98, 20, I18n.format("Mage", new Object[0]))); this.buttonList.add(new GuiButton(3, this.width / 2 -170,this.height - 110, 98, 20, I18n.format("Néogicien", new Object[0]))); this.buttonList.add(new GuiButton(4, this.width / 2 -170,this.height - 50, 98, 20, I18n.format("Guerrier", new Object[0]))); this.buttonList.add(new GuiButton(5, this.width / 2 + 70,this.height - 50, 98, 20, I18n.format("Assasin", new Object[0]))); } protected void actionPerformed(GuiButton p_146284_1_) { switch (p_146284_1_.id) { case 0: this.mc.thePlayer.sendChatMessage("/manuadd " + this.mc.getSession().getUsername() + " Druide"); this.mc.thePlayer.sendChatMessage("/broadcast " + this.mc.getSession().getUsername() + " A choisi la classe Druide"); player.closeScreen(); player.inventory.setInventorySlotContents(player.inventory.clearInventory(Main.itemGrade, 1), null); this.openUrl("http://ultrafight.fr/"); break; case 1: this.mc.thePlayer.sendChatMessage("/manuadd " + this.mc.getSession().getUsername() + " Paladin"); this.mc.thePlayer.sendChatMessage("/broadcast " + this.mc.getSession().getUsername() + " A choisi la classe Paladin"); player.closeScreen(); player.inventory.setInventorySlotContents(player.inventory.clearInventory(Main.itemGrade, 1), null); this.openUrl("http://ultrafight.fr/"); break; case 2: this.mc.thePlayer.sendChatMessage("/manuadd " + this.mc.getSession().getUsername() + " Mage"); this.mc.thePlayer.sendChatMessage("/broadcast " + this.mc.getSession().getUsername() + " A choisi la classe Mage"); player.closeScreen(); player.inventory.setInventorySlotContents(player.inventory.clearInventory(Main.itemGrade, 1), null); this.openUrl("http://ultrafight.fr/"); break; case 3: this.mc.thePlayer.sendChatMessage("/manuadd " + this.mc.getSession().getUsername() + " Neogicien"); this.mc.thePlayer.sendChatMessage("/broadcast " + this.mc.getSession().getUsername() + " A choisi la classe Neogicien"); player.closeScreen(); player.inventory.setInventorySlotContents(player.inventory.clearInventory(Main.itemGrade, 1), null); this.openUrl("http://ultrafight.fr/"); break; case 4: this.mc.thePlayer.sendChatMessage("/manuadd " + this.mc.getSession().getUsername() + " Guerrier"); this.mc.thePlayer.sendChatMessage("/broadcast " + this.mc.getSession().getUsername() + " A choisi la classe Guerrier"); player.closeScreen(); player.inventory.setInventorySlotContents(player.inventory.clearInventory(Main.itemGrade, 1), null); this.openUrl("http://ultrafight.fr/"); break; case 5: this.mc.thePlayer.sendChatMessage("/manuadd " + this.mc.getSession().getUsername() + " Assasin"); this.mc.thePlayer.sendChatMessage("/broadcast " + this.mc.getSession().getUsername() + " A choisi la classe Assasin"); player.closeScreen(); player.inventory.setInventorySlotContents(player.inventory.clearInventory(Main.itemGrade, 1), null); this.openUrl("http://ultrafight.fr/"); break; } } public void openUrl(String url) { if (Desktop.isDesktopSupported()) { try { URI uri = URI.create(url); Desktop.getDesktop().browse(uri); } catch (IOException e) { e.printStackTrace(); } } } public static void drawPlayerOnGui(Minecraft par0Minecraft, int par1, int par2, int par3, float par4, float par5) { GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef((float)par1, (float)par2, 100.0F); GL11.glScalef((float)(-par3), (float)par3, (float)par3); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); float var6 = par0Minecraft.thePlayer.renderYawOffset; float var7 = par0Minecraft.thePlayer.rotationYaw; float var8 = par0Minecraft.thePlayer.rotationPitch; GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-((float)Math.atan((double)(par5 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); par0Minecraft.thePlayer.renderYawOffset = (float)Math.atan((double)(par4 / 40.0F)) * 20.0F; par0Minecraft.thePlayer.rotationYaw = (float)Math.atan((double)(par4 / 40.0F)) * 40.0F; par0Minecraft.thePlayer.rotationPitch = -((float)Math.atan((double)(par5 / 40.0F))) * 20.0F; par0Minecraft.thePlayer.rotationYawHead = par0Minecraft.thePlayer.rotationYaw; GL11.glTranslatef(0.0F, par0Minecraft.thePlayer.yOffset, 0.0F); RenderManager.instance.playerViewY = 180.0F; RenderManager.instance.renderEntityWithPosYaw(par0Minecraft.thePlayer, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); par0Minecraft.thePlayer.renderYawOffset = var6; par0Minecraft.thePlayer.rotationYaw = var7; par0Minecraft.thePlayer.rotationPitch = var8; GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } /** * Called from the main game loop to update the screen. */ public void updateScreen() { super.updateScreen(); ++this.field_146444_f; } /** * Draws the screen and all the components in it. */ public void drawScreen(int par1, int par2, float par3) { drawRect(0, this.height - 120, this.width, this.height, -1728053248); drawRect(0, 0, this.width, 15, -1728053248); drawRect(this.width / 2 - 60, this.height - 170, this.width / 2 + 60, this.height - 120, -1728053248); drawRect(this.width / 2 - 50, this.height - 160, this.width / 2 + 50, this.height - 30, 1728053248); String var4 = EnumChatFormatting.AQUA + "Bienvenue sur le menu " + EnumChatFormatting.GREEN + this.mc.getSession().getUsername() + EnumChatFormatting.AQUA + ", choisi ta Classe ?"; this.drawString(this.fontRendererObj, var4, this.width / 2 - this.fontRendererObj.getStringWidth(var4) / 2, 4, -1); drawPlayerOnGui(this.mc, this.width / 2 - 0, this.height - 40, 60, (float)(this.width / 2 + 51) - (float)par1, (float)(this.height + 0 - 100) - (float)par2); super.drawScreen(par1, par2, par3); } }
-
Euh déjà résolue ?! Regarde ta balise ? SI oui, explique comment tu as fait
-
Pas besoin d’exécuter une commande …
Tu envoies un paquet et dans l’action du paquet tu envoies à tout les joueurs du serveur le message. (une petite boucle for + player.sendChatMessage)