Jump to content

Bets

Members
  • Posts

    153
  • Joined

  • Last visited

Posts posted by Bets

  1. I tried searching everywhere, could not find a legit answer.

    Is it possible to add the autocomplete cycle to cycle through players when pressing TAB?

    (doesn't have to exactly be players, can be other strings inside an array)

  2. On 7/4/2017 at 8:33 AM, Choonster said:

    Extend CommandBase, implement IClientCommand and register it by calling CommandHandler#registerCommand on ClientCommandHandler.instance.

    It says I don't have perms to use the command

    @Mod.EventHandler
    	public void init (FMLPostInitializationEvent event) {
    		ClientCommandHandler.instance.registerCommand(new commandthing());
    	}
    	
    	public class commandthing extends CommandBase implements ICommand {
    
    		@Override
    		public String getCommandName() {
    			// TODO Auto-generated method stub
    			return "cmd";
    		}
    
    		@Override
    		public String getCommandUsage(ICommandSender sender) {
    			// TODO Auto-generated method stub
    			return "use it";
    		}
    
    		@Override
    		public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    			// TODO Auto-generated method stub
    			System.out.println("THIS WORKS DANG IT");
    		}		
    	}

     

  3. Hi

     

    I tried adding a command that only the client can see, just to test things out and it did not work for some reason.

    I tried using the implementation ICommand into a class I added to my main class.

    I tried searching for hours, but I didn't find anything useful for what I want to do. most of the tutorials are including the server too.

    This is what I tried doing:

     

    public class command implements ICommand {
    
    		@Override
    		public int compareTo(ICommand arg0) {
    			// TODO Auto-generated method stub
    			return 0;
    		}
    
    		@Override
    		public String getCommandName() {
    			// TODO Auto-generated method stub
    			return "test";
    		}
    
    		@Override
    		public String getCommandUsage(ICommandSender sender) {
    			// TODO Auto-generated method stub
    			return "test stuff";
    		}
    
    		@Override
    		public List<String> getCommandAliases() {
    			return null;
    		}
    
    		@Override
    		public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    			// TODO Auto-generated method stub
    			System.out.println("testing complete");
    		}
    
    		@Override
    		public boolean canCommandSenderUseCommand(ICommandSender sender) {
    			// TODO Auto-generated method stub
    			return true;
    		}
    
    		@Override
    		public List<String> addTabCompletionOptions(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;
    		}
    		
    	}

     

    What am I doing wrong here? and will this method work only on the client?

    Thanks

  4. 1 minute ago, diesieben07 said:

    Your exception suggests otherwise.

     

    Please stop posting snippets of code and logs.

    Post the complete log and all of your classes that are mentioned in the stacktrace.

     

     

    Maybe it looks like I do because I run it for like 6 times to check 6 different players.

    The thing is, it works! I just want to know how to detect the "429 Error" and handle it. Is something like this even possible?

  5. 3 minutes ago, diesieben07 said:

    That is not the full exception trace. You are missing the most important part, the type and message of the exception:

     

    And are you seriously making a HTTP request to the API every single frame, aka 60 times a second? You can't be serious.

     

    No, it's getting called when you join a server, ones.

     

    Is that it?

    [Client thread/INFO]: [STDERR]: java.io.IOException: Server returned HTTP response code: 429 for URL: api url
    [Client thread/INFO]: [STDERR]:     at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    [Client thread/INFO]: [STDERR]:     at sun.net.www.protocol.http.HttpURLConnection.access$200(Unknown Source)
    ...

     

  6. 3 minutes ago, diesieben07 said:

    This is a terrible way to deal with exceptions. Or rather, it is not a way to deal with them at all. This is just putting your head in the sand.

     

    Show the TheAPI class.

     

    And you still have not shown the actual crash report.

     

     

    This is what I've got in the TheAPI class.

    public class TheAPI {
        private String current_rank;
        public String get_current_rank() {
            return current_rank;
        }
        public void setCurrent_rank(String current_rank) {
            this.current_rank = current_rank;
        }
        @Override
        public String toString() {
            return current_rank;
        }
    }

     

    And this is the crash log:

    -- Head --
    Thread: Client thread
    Stacktrace:
        at me.main.Engine.getRank(Engine.java:361)
        at me.main.Engine.onRenderText(Engine.java:178)
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_Engine_onRenderText_Text.invoke(.dynamic)
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
        at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:695)
        at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:171)

     

  7. 15 minutes ago, diesieben07 said:

    Show your code and the crash.

     

     

    It's not much, but this is the code that loads the JSON:

    public static String[] getRank(String username) {
            String json = null;
            try {
                json = getJson("api url" + username);
            } catch (Exception e) {
                e.printStackTrace();
            }
            
            Gson gson = new Gson();
            TheAPI theapi = gson.fromJson(json, TheAPI.class);
            return new String[] { theapi.get_current_rank() };
        }

     

    The result is just put in a String that's being displayed on the screen. :ph34r:

    The crash log points to the return line in the code I showed before ^

  8. I have a function that loads a specific URL from an API for some data.

    Sometimes I'll get an HTTP error 429 (too many requests) from the API server. When this happens for some reason the game just crashes. All I'm doing is checking an URL for some data and displaying that data on the screen.

    My first idea was to somehow detect when the API returns error 429 but I don't really know how I can do that.

  9. 1 minute ago, diesieben07 said:

    Ok, I don't know what Pahimar is up to there again, but that repository is completely pointless. The mod in it does nothing.

     

     

    And that is why I probably was not able to find anything.

  10. Hi guys

    I need to make a function that when it detects a chat message with a specific string inside it it changes the sent message or deletes it completely (Client side of course).

     

    For example:

     

    Original:

    Someone: Hi, you smell

     

    Edited:

    Someone: Hi, you *****

     

    Thanks :)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.