This should work properly. Let me know, I may have missed something Code:java File exFile = new File(exampleDir + "example.yml");exFile.delete();
if you have that file in a variable, file.delete(), it will remove true or false depending on whether it's successful
thank you Also, how do i get integer from yml file? Doing int likes = profiles.getInt(player.getDisplayName + ".Likes", 0); And the config is setup like Likes: 2 always seems to give back 0, even when the numbers in the config change. :/
because there is nothing before before the Likes, say it was for me, it would have to say: wwsean08.Likes: 2 for it to give you 2
You have to load the changes in the config every time you save to the file. The information stored in the cache does not change until you reload the file. Edit: Or edit it directly
sorry, im on my phone, so it doesn't have my code on, but i have say NeoSilky, then inside that, so kinda set out like 'permissions', as property i have Likes: andthenanumber. i want the fault to be 0, but it doesn't read the path So do you mean saving the file when its been likes has changed? Or loading it when i ask for it? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
You want to save after you change the file, and load it whenever the data in the file has been changed.
ahhh, that makes sense, so when i want the code in the section, load the file? ALSO... using a string builder? Someone gave me some code, it it gives error, it looks practical to work, it just doesnt i just want to get all text after the first args and put it in one string
well once you get back on your comp upload the string builder code that is erroring and we can take a look
You want to make one string out of many? Would you mind sharing a snippet so I can see what exactly you are trying to do?
right, i had a look, but i'm pretty sure, this is different to the code i recieved from somewhere which i've been using, but here: Code: StringBuilder message = new StringBuilder(); for(String arg: args) { message.append(" "); message.append(arg); } Strg msg = message.toString().trim(); Even if it did work, then it still doesnt take away the first args actually found the code that i was sent by another person, this one should technically work, but it doesn't, they said i should take the String Builder bit of of the if statement i have surreound the code but.... StringBuilder message = new StringBuilder(); for(int i = 1; i < args.length; i++) { message.append(args); message.append(' '); } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I can't really help right now because I'm in class, but if you still are up in two hours I'll be glad to help you
If you are still having trouble concatenating all the elements. Although I ask that, if you use it, credit me as it is a full method. Code:java /** * This method concatenates the Strings in an array with a space between * them, but ignores the first element in the array. * * @author SagaciousZed * @param args * Array of type String to be concatenated * @return returns The output string with the elements */ private String concatRestArrayWithSpace(String[] args) { switch (args.length) { case 0: case 1: return ""; case 2: return args[1]; default: StringBuilder stringBuilder = new StringBuilder(args[1]); stringBuilder.append(" "); for (int n = 2; n < args.length; n++) { stringBuilder.append(args[n]); if (n != args.length - 1) { stringBuilder.append((" ")); } } return stringBuilder.toString(); } } EDIT: this is really the kind of problem any programmer worth his salt can solve. How elegant and efficient however, is a different matter.
I think this should work: Code: String str = Joiner.on(" ").join(Arrays.copyOfRange(args, 1, args.length)); Joiner is com.google.common.base.Joiner from Google Guava, which I believe CraftBukkit depends on...
Found this in the pom.xml Code: <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>10.0</version> <type>jar</type> <scope>provided</scope> </dependency> EDIT: and thats an elegant solution.
Cool. I also never noticed it was an explicit dependency for Bukkit as well, so I take that to mean Guava is "part of the plugin API."