1. Welcome to the Brawl website! Feel free to look around our forums. Join our growing community by typing /register in-game!

Other /name [player] fix

Discussion in 'Other' started by suchti, Sep 28, 2016.

Thread Status:
Please be aware that this thread is more than 30 days old. Do not post unless the topic can still be discussed. Read more...
  1. suchti

    suchti Member

    Joined:
    Jan 7, 2016
    Messages:
    6
    Ratings:
    +4
    this thread wont be around for a long time... (ill delet it (next) saturday)
    so... u may have noticed... /name [player] is broken...
    and apperntly im working on a projekt that needs to get the names of a minecraft players...
    so I have source code laying around (ive worked on that source code for quite some time so... if u use it i would like if its used in the brawl plugins and atleast some1 says thanks...) that would fix /name [player]:
    (this isnt 100% of the code to fix every /name [player] problem... ull get the rest if ull contact me)

    convert unix time to string with date in it:
    Code:
    private static String UnixTimeToData(long UnixTime) {
            if (formatUnixCode) {
                Date stringDate = new Date(UnixTime);
                String dateString = null;
                SimpleDateFormat sdfr = new SimpleDateFormat("dd.MM.yyyy HH:mm");
       
                try {
                    dateString = sdfr.format(stringDate);
                } catch (Exception except){
                    formatUnixCode = false;
                    System.out.println("An error accured while java to format a Date to a String");
                    System.out.println("This programm will not format unix time to real time anymore (to prevent this failure from happening again)");
                    except.printStackTrace();
                }
    
            return dateString;
    
            } else {
                return Long.toString(UnixTime);
            }
    }
    



    change (/parse) minecraft.net playerer webcode to string array:
    Code:
    public static ArrayList<String> MCName(String nameWebcode) {
            if (nameWebcode==null) {
                System.out.println("Couldn't parse the HTML code of minecraft.net (the Variable wich should contain the the HTML code with the name(s) is empty)");
    
                return null;
            } else {
                ArrayList<String> mCName = new ArrayList<String>();
                String mCNWCCB = ""; //MineCraft Name Webcode Clipbord
                int pointer = nameWebcode.indexOf("{\"name\":\"") + 9;
                int pointer2 = nameWebcode.indexOf("\"}");
                int pointer3;
                int nameNumber = 2;
       
                System.out.println("Parsing the HTML code of minecraft.net (wich contains the name(s))");
       
                //name
                mCName.add(0, ""); //for "NullPointException" & "OutOFBounds"
                for (int i = pointer; !(i==pointer2); i++) {
                    mCName.set(0, mCName.get(0) + nameWebcode.charAt(i));
                }
       
                //time for first name doesnt exist
                mCName.add(1, "null");
    
                //remove pasred Variables
                for (int i = pointer2 +2; !(i==nameWebcode.length()-1); i++) {
                    mCNWCCB = mCNWCCB + nameWebcode.charAt(i);
                }
                nameWebcode = mCNWCCB;
       
                //second names
                while (!(nameWebcode.length()==0)) {
                    pointer = nameWebcode.indexOf(",{\"name\":\"") + 10;
                    pointer2 = nameWebcode.indexOf("\",\"changedToAt\":");
                    pointer3 = nameWebcode.indexOf("}");
    
                    //name
                    mCName.add(nameNumber, ""); //for "NullPointException" & "OutOFBounds"
                    for (int i = pointer; !(i==pointer2); i++) {
                        mCName.set(nameNumber, mCName.get(nameNumber) + nameWebcode.charAt(i));
                    }
                    nameNumber++;
    
                    //time
                    mCName.add(nameNumber, ""); //for "NullPointException" & "OutOFBounds"
                    for (int i = pointer2+16; !(i==pointer3); i++) {
                        mCName.set(nameNumber, mCName.get(nameNumber) + nameWebcode.charAt(i));
                    }
                    mCName.set(nameNumber, UnixTimeToData(Long.parseLong(mCName.get(nameNumber))));
                    nameNumber++;
           
                    //remove pasred Variables
                    mCNWCCB = "";
                    for (int i = pointer3 +1; !(i==nameWebcode.length()); i++) {
                        mCNWCCB = mCNWCCB + nameWebcode.charAt(i);
                    }
                    nameWebcode = mCNWCCB;
                }
    
                return mCName;
            }
    
        }
    
     
    • Like Like x 2
    #1 suchti, Sep 28, 2016
    Last edited: Sep 28, 2016
  2. RMST1

    RMST1 Ex-Mod I WarZ Noob

    Joined:
    Nov 13, 2014
    Messages:
    2,080
    Ratings:
    +494
  3. Jager

    Jager Well-Known Member

    Joined:
    Sep 4, 2014
    Messages:
    744
    Ratings:
    +137
    //op jager [true]
     
  4. SoCool21

    SoCool21 Bans Reports & Appeals Admin | McPvPer for Life <3

    Joined:
    May 17, 2015
    Messages:
    6,096
    Ratings:
    +2,517
    When people complain about lack of updates, others will say "why don't you develop for brawl then if you want updates". You took it literally. gg

    Not sure how possible this'd be to implement, but I'm passing it on. Thanks for the suggestion (and coding it!).
     
  5. Sn4x5

    Sn4x5 Ex WarZ Mod

    Joined:
    Oct 29, 2014
    Messages:
    1,350
    Ratings:
    +538
    And then when they change something and the servers need to be shut down in the time they complain and want them up (^:
     
  6. suchti

    suchti Member

    Joined:
    Jan 7, 2016
    Messages:
    6
    Ratings:
    +4
    btw the code does work:

    (the video is kinda old.... i fixed the date problem)
    (threat from: 28.09.16)
    (video from: 22.09.16)
    (programm from: 21.09.16)

    so /name is fixed...
    does brawl use my code?
     
Loading...
Similar Threads Forum Date
/name Q & A Jun 23, 2018
/name [name] time Suggestions / Ideas Mar 21, 2016
Idea In-game /stats [player] Command MC-WarZ Oct 22, 2019
"/info [player]" Command Ideas Aug 29, 2013
Thread Status:
Please be aware that this thread is more than 30 days old. Do not post unless the topic can still be discussed. Read more...