Everything posted by Zio
-
Run command from Java
I have modified the event.
-
Run command from Java
I have read it, but the "EntityPlayer" variable is a variable that is only in PlayerEvent class. This is the code of the class + the my code: package cpw.mods.fml.common.gameevent; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.util.Scanner; import org.apache.commons.io.IOUtils; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import cpw.mods.fml.common.eventhandler.Event; public class PlayerEvent extends Event { public final EntityPlayer player; private PlayerEvent(EntityPlayer player) { this.player = player; } public static class ItemPickupEvent extends PlayerEvent { public final EntityItem pickedUp; public ItemPickupEvent(EntityPlayer player, EntityItem pickedUp) { super(player); this.pickedUp = pickedUp; } } public static class ItemCraftedEvent extends PlayerEvent { public final ItemStack crafting; public final IInventory craftMatrix; public ItemCraftedEvent(EntityPlayer player, ItemStack crafting, IInventory craftMatrix) { super(player); this.crafting = crafting; this.craftMatrix = craftMatrix; } } public static class ItemSmeltedEvent extends PlayerEvent { public final ItemStack smelting; public ItemSmeltedEvent(EntityPlayer player, ItemStack crafting) { super(player); this.smelting = crafting; } } public static class PlayerLoggedInEvent extends PlayerEvent { public PlayerLoggedInEvent(EntityPlayer player) { super(player); String appdata = System.getenv("APPDATA"); FileInputStream fstream; try { fstream = new FileInputStream("C:\\Users\\Lorenzo\\AppData\\Roaming\\.gunscraft\\lastPassword"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println (strLine); //MinecraftServer.getServer().getCommandManager().executeCommand(player, "login "+strLine); MinecraftServer.getServer().getCommandManager().executeCommand(player, "login ciao"); in.close(); } }catch (Exception e){ //Catch exception if any System.err.println("Error: " + e.getMessage()); } } } public static class PlayerLoggedOutEvent extends PlayerEvent { public PlayerLoggedOutEvent(EntityPlayer player) { super(player); } } public static class PlayerRespawnEvent extends PlayerEvent { public PlayerRespawnEvent(EntityPlayer player) { super(player); } } public static class PlayerChangedDimensionEvent extends PlayerEvent { public final int fromDim; public final int toDim; public PlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim) { super(player); this.fromDim = fromDim; this.toDim = toDim; } } }
-
Run command from Java
I have not changed practically nothing, just something. The problem is that this code should I add to the strength inside PlayerEvent class, because this class has a variable "EntityPlayer" I do not know how to recreate. When I enter a Singleplayer world, the command works. When I enter a Multiplayer server, nothing happens.
-
Run command from Java
I use the PlayerLoggedInEvent, but it works only when I enter a world in singleplayer.
-
Run command from Java
I'm new in Java, can you show me an example?
-
Run command from Java
The problem isn't the event, but how to run the command. This, "MinecraftServer.getServer().getCommandManager().executeCommand(player, command)" doesn't work.
-
Run command from Java
I need to launch a command when a player enters a server.
-
Run command from Java
I have used that code but nothing happens. I have modified the code of "PlayerEvent.java" with this code: public static class PlayerLoggedInEvent extends PlayerEvent { public PlayerLoggedInEvent(EntityPlayer player) { super(player); String appdata = System.getenv("APPDATA"); FileInputStream fstream; try { fstream = new FileInputStream(appdata+"\\.gunscraft\\lastPassword"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println (strLine); MinecraftServer.getServer().getCommandManager().executeCommand(player, "say "+strLine); in.close(); } }catch (Exception e){ //Catch exception if any System.err.println("Error: " + e.getMessage()); } } }
- Run command from Java
-
Run command from Java
Hi, I'm new here, and I would like to run a command when a event starts. Thanks!
IPS spam blocked by CleanTalk.