i have a few questions. if i had one boolean. and each player could have eather true or false and one is true and one is false would they overwrite each other or does each player have there own boolean? or would i have to make loads of booleans? how would i make the chat color go the color of a string? so if i had a string called chatcolor and it was = to RED would doing this work? ChatColor.chatcolor + "my message" Thanks for your help
About the chatcolor - yes, ChatColor.RED + "message" would give a red message. You might have to be more clear about the first issue... Have you thought of using a HashMap of Player-Boolean?
I also use this method, but it puts formatting characters into the console of the server. Or I am doing something wrong Also, fullwall is right, the HashMap is the clear way to do this. One boolean would get overwritten and many booleans are of fixed count.
I think that's a bug XD. There was an update that was supposed to clear formatting characters from the console because it doesn't support colour (yet).
sory i wasnt very clear on any of them i ment that i wanted the chatcolor to be equal to the string so for example String test = RED; Chatcolor.test + "my message" ok ill use hashmaps thanks
I don't know how to spawn them, but there's a few plugins floating around I think. I don't think there is a function to get you the mob entity from name, but you could just go though all MobType (that's a string enum, see javadocs) with a for loop and just check it on string equality. Dirty, I know, but should work.
? You want to know how to assign a string to a variable or something? The sample plugin uses commands I think so you got everything already there, just store it.
thanks how would i do something like this: Code: public static void read(){ try { BufferedReader br = new BufferedReader(new FileReader("mclsplayer.txt")); String curLine; while ((curLine = br.readLine()) != null){ StringTokenizer strTok = new StringTokenizer(curLine, ":"); if (strTok.nextToken().equals(name)){ String Level = strTok.nextToken(); level = Integer.parseInt(Level); String Nextlvl = strTok.nextToken(); nextlvl = Integer.parseInt(Nextlvl); String Prestige = strTok.nextToken(); prestige = Integer.parseInt(Prestige); // Here you can do whatever you want with the rest of the tokens. Just use strTok.nextToken() to get the rest of the token, split by colons. } } // This catches all the exceptions. You can go more in detail here if you want. } catch(Exception e){ e.printStackTrace(); System.out.println("error reading the mclsplayer.txt file. does it exist?");} } public void write(){ how would i overwrite just the level int for that one player? }
To get the mob name, use onPlayerCommand in player listener: Code: String mobName; public void onPlayerCommand(PlayerChatEvent event) { String[] split = event.getMessage().split(" "); if((split[0].equalsIgnoreCase("/mob"))) { mobName = split[1]; } } Though this should work for storing it in a string, it would only be able to hold one mobname at a time, but this is basically it.
each player has a line in a txt file like this: 1337:10:500:1 the first one is player name the next one is there level the one after is the points to the next level and the last one is like there prestige i would like to just change 1337's or anothers player level but not by making a new line for them, i just want tochange his level to his new one how would i do this? --- merged: Feb 10, 2011 7:44 PM --- bump
Not sure, I'm a java noob, though i probably would transfer the contents to an array list then transfer them back.
Since you have no fixed width there, it will not be nice solution For example in my warp plugin I just remove the old line and then append the new one. You can use the same technique, the problem is that removing is done by creating a new, temporary, file. Then copying everything except the one line to change and then adding the new one.
Well I'm not saying there is not, but I didn't think of any easier way when i coded my plugin, so if you find out, PM me