_Zerys Posted August 3, 2016 Posted August 3, 2016 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; } } Quote
SHsuperCM Posted August 3, 2016 Posted August 3, 2016 last time i tried to make a command i wasnt even an op.... sometimes i stupid am.... Quote Doing stuff n' things
_Zerys Posted August 3, 2016 Author Posted August 3, 2016 I think you misread what I put, I stated that I was indeed opped and still having issues. Quote
SHsuperCM Posted August 3, 2016 Posted August 3, 2016 first try lowering that: @Override public int getRequiredPermissionLevel() { return 4; } to 2 i think Quote Doing stuff n' things
_Zerys Posted August 3, 2016 Author Posted August 3, 2016 Already tried that, It was having none of it. Quote
SHsuperCM Posted August 3, 2016 Posted August 3, 2016 Already tried that, It was having none of it. what do you mean? errors? if still it says that you dont have permissions lower again until you see that it works... im currently have my head on my mod but that's the only thing i can think of that would cause no permissions stuff.. its not spigot/bukkit or something.. it should be basic power levels Quote Doing stuff n' things
_Zerys Posted August 3, 2016 Author Posted August 3, 2016 lowered it to 2, then 0 and still getting you don't have enough permission to use these commands, the commands are registering. The other issue is i'm not seeing them in /help either. Quote
_Zerys Posted August 3, 2016 Author Posted August 3, 2016 Found the issue, I needed to essentially tell the code to check the required permission. An oversight to say the least. For those that are having a simliar issue this is what I changed. @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { return true; } Quote
_Zerys Posted August 3, 2016 Author Posted August 3, 2016 Can you tell me why I shouldn't override said methods? Since removing them doesn't throw any error's why are they there to begin with? Still rather new to Java. Quote
SHsuperCM Posted August 3, 2016 Posted August 3, 2016 Can you tell me why I shouldn't override said methods? Since removing them doesn't throw any error's why are they there to begin with? Still rather new to Java. they got generated i think... its never happend to me.. i guess its an eclipse thing? Quote Doing stuff n' things
Draco18s Posted August 3, 2016 Posted August 3, 2016 Can you tell me why I shouldn't override said methods? Since removing them doesn't throw any error's why are they there to begin with? Still rather new to Java. Only override a method if you plan on DOING something with it. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.