[英]Minecraft Forge Mod command isnt working?
I programmed a forge mod for minecraft 1.8.9 which sends a message every 20 seconds if the player typed in the command and when I type in the command in singleplayer it is working, but if I type the command in in multiplayer it says: "Unknown command. Type "help" for help".我为我的世界 1.8.9 编写了一个锻造模组,如果玩家输入命令,并且当我在单人游戏中输入命令时,它会每 20 秒发送一条消息,但如果我在多人游戏中输入命令,它会说:“未知命令。键入“help”以获得帮助。 Here is the code of the command class:下面是命令类的代码:
package AutoAd;
import java.util.Timer;
import java.util.TimerTask;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
public class CommandAutoAD extends CommandBase{
@Override
public String getCommandName() {
return "startAutoad";
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "/startAutoad";
}
@Override
public void processCommand(final ICommandSender sender, String[] args) throws CommandException {
if(sender instanceof EntityPlayer) {
Thread t = new Thread() {
public void run() {
EntityPlayer player = (EntityPlayer) sender;
for(int i = 0; i<=20; i++) {
MSG(player, "Beacons, Karten, Banner und mehr bei /p h 5ty1ne");
try {
Thread.sleep(20000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MSG(player, "Karten, Banner, stackweise Eisenblöcke, Emeraldblöcke und mehr bei /p h 5ty1ne");
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MSG(player, "Shop bei /p h 5ty1ne");
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MSG(player, "Günstig für deinen Shop einkaufen? /p h 5ty1ne");
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
t.start();
}
else {
sender.addChatMessage(new ChatComponentText("In der Konsole nicht verfügbar."));
}
}
public void MSG(EntityPlayer player, String message) {
Minecraft.getMinecraft().thePlayer.sendChatMessage(message);
}
}
and here is the code of the main:这是主要的代码:
package AutoAd;
import net.minecraft.command.ServerCommandManager;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import proxy.ServerProxy;
@Mod(modid = AutoAD.MODID)
public class AutoAD {
public static final String MODID = "autoad";
@SidedProxy(clientSide = "proxy.ClientProxy", serverSide = "proxy.ServerProxy")
public static ServerProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
}
@EventHandler
public void init(FMLInitializationEvent event) {
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
@EventHandler
public void registerCommands(FMLServerStartingEvent event) {
ServerCommandManager manager = (ServerCommandManager) event.getServer().getCommandManager();
manager.registerCommand(new CommandAutoAD());
}
}
I imagine that you have this mod installed on your Minecraft Client but not on your server.我想你在你的 Minecraft 客户端上安装了这个 mod,但没有安装在你的服务器上。 You can start a local development server using the Minecraft Forge gradle, or by compiling into a JAR and dragging and dropping this JAR into the /mods
folder of a Minecraft Forge server.您可以使用 Minecraft Forge gradle 启动本地开发服务器,或者编译成 JAR 并将此 JAR 拖放到 Minecraft Forge 服务器的/mods
文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.