I Want to add a server command I set it up and am not getting any issues or anything the command is simply not showing up via /help.
When I tried simply doing /fly and the log comes up with "You do not have permission to access this command".
I have also messed with permissions via the code and nothing is working as well.
I also tested being op on the test server. Any help?
Main class
package zTestMod;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandManager;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
@Mod(modid = Ztestmod.MOD_ID, name = Ztestmod.MOD_NAME, version=Ztestmod.VERSION, acceptableRemoteVersions = "*")
public class Ztestmod {
public static final String MOD_ID = "Ztestmod";
public static final String MOD_NAME = "Ztestmod";
public static final String VERSION = "1.10.2";
@EventHandler
public void severStart(FMLServerStartingEvent e) {
MinecraftServer server = e.getServer();
e.registerServerCommand(new Fly());
}
}
Fly Class
package zTestMod;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
public class Fly extends CommandBase{
private final List<String> aliases = new ArrayList<String>();
public Fly()
{
aliases.add("fly");
aliases.add("Fly");
aliases.add("Flying");
}
@Override
public int getRequiredPermissionLevel()
{
return 4;
}
@Override
public String getCommandUsage(ICommandSender commandSender)
{
return getCommandName() + " help";
}
@Override
public List<String> getCommandAliases()
{
return aliases;
}
@Override
public int compareTo(ICommand o) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
// TODO Auto-generated method stub
}
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args,
BlockPos pos) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isUsernameIndex(String[] args, int index) {
// TODO Auto-generated method stub
return false;
}
@Override
public String getCommandName() {
// TODO Auto-generated method stub
return "/fly";
}
public boolean canCommandSenderUseCommand(ICommandSender sender) {
return true;
}
}