bukkit

java.lang.IllegalArgumentException: Plugin already initialized. What's going on?

て烟熏妆下的殇ゞ 提交于 2019-12-02 13:58:48
When I'm testing my new plugin an exception keeps getting thrown: java.lang.IllegalArgumentException: Plugin already initialized! Please help! Here's the code: package me.plugin.example; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.event.Listener; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; public class Main extends JavaPlugin implements Listener { @Override public void

Bukkit teleport - nullPointerException

元气小坏坏 提交于 2019-12-02 10:08:30
I am trying to teleport a user to their own realm using the following code: @EventHandler public static void onPortalTravel(PlayerPortalEvent event) throws Exception { if(event.getCause() == PlayerPortalEvent.TeleportCause.END_PORTAL) { int x = event.getPlayer().getLocation().getBlockX(); int y = event.getPlayer().getLocation().getBlockY(); int z = event.getPlayer().getLocation().getBlockZ(); String[] data = getPageData("http://example.com/game.php?type=getRealm&location="+x+":"+y+":"+z ).split(":"); // THIS RETURNS <username>:<oldblockid> String realm = data[0]; int oldID = Integer.parseInt

Scanner nextLine() NoSuchElementException

断了今生、忘了曾经 提交于 2019-12-02 02:31:41
I've been programming a Bukkit plugin for a while now, and this one issue has me stumped. I'm trying to read a line from a file using a Scanner, and add everything on the line before ": " to a HashSet. Every time I try, I get a NoSuchElementException, looking like this: 21:01:01 [SEVERE] Could not pass event PlayerLoginEvent to ServerProtect org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja va:341) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav a:62) at org.bukkit.plugin.SimplePluginManager.fireEvent

Scanner nextLine() NoSuchElementException

橙三吉。 提交于 2019-12-02 02:13:45
问题 I've been programming a Bukkit plugin for a while now, and this one issue has me stumped. I'm trying to read a line from a file using a Scanner, and add everything on the line before ": " to a HashSet. Every time I try, I get a NoSuchElementException, looking like this: 21:01:01 [SEVERE] Could not pass event PlayerLoginEvent to ServerProtect org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja va:341) at org.bukkit.plugin.RegisteredListener

Blank file after writing to it?

*爱你&永不变心* 提交于 2019-12-01 17:12:09
So I have been trying to write a Bukkit plugin for a friend of mine, and for some reason the config generation is not working. The code in question is below, and I will be happy to add any code that people need to help me out with this. When I run the program, the config file that was created ends up blank. The testing file is just fine (I tested that by simply commenting out the line that deletes the file) but once I try to get multiple lines it fails. Can anyone help? PrintWriter out = new PrintWriter(new FileWriter(config)); out.println("########################################"); out

Blank file after writing to it?

℡╲_俬逩灬. 提交于 2019-12-01 16:33:34
问题 So I have been trying to write a Bukkit plugin for a friend of mine, and for some reason the config generation is not working. The code in question is below, and I will be happy to add any code that people need to help me out with this. When I run the program, the config file that was created ends up blank. The testing file is just fine (I tested that by simply commenting out the line that deletes the file) but once I try to get multiple lines it fails. Can anyone help? PrintWriter out = new

Get all nodes under YAML path

走远了吗. 提交于 2019-12-01 07:31:27
I have a YAML file that looks like this: Main: topofhouse: x: 276.4375 y: 71.0 z: -60.5 yaw: -290.7768 pitch: 35.400017 2ndfloor: x: 276.5 y: 67.0 z: -60.5 yaw: -8.626648 pitch: 16.199997 home: x: 276.5 y: 63.0 z: -60.5 yaw: -18.976715 pitch: -32.850002 Is there a way to get all nodes under Main ? r4vn To get the node IDs contained in Main : file.getConfigurationSection("Main").getKeys(false); Output: Set["topofhouse", "2ndfloor", "home"] The ConfigurationSection.getConfigurationSection(String path) method is used to get the path on which to operate. The ConfigurationSection.getKeys(boolean

Java: Difference between initializing by constructor and by static method?

試著忘記壹切 提交于 2019-12-01 06:36:32
This might just be a question of personal taste and workflow, but in case it's more than that, I feel I should ask anyway. In Java, what differences are there between creating an instance via constructor and via a static method (which returns the instance)? For example, take this bit of code from a project I'm working on (written up by hand at time of posting, so some shortcuts and liberties are taken): Plugin main; Map<int, int> map; public Handler(Plugin main) { this.main = main; } public static Handler init(Plugin main) { Handler handler = new Handler(main); handler.createMap(); } public

IllegalArgumentException: Bound must be positive

柔情痞子 提交于 2019-11-29 14:23:09
I get an error saying that my bound must be positive. Here is the line I get it on: inv.setItem(i, items.get(r.nextInt(items.size()))); As far as I know, it comes from the part where I request a random integer from the list of items. This is how I defined the list: List<ItemStack> items = getAllItems(level); Where the getAllItems() method looks like: public List<ItemStack> getAllItems(int level) { List<ItemStack> items = new ArrayList<ItemStack>(); for (String item : settings.getChests().getStringList("chestitems." + level)) { ItemStack toAdd = parseItem(item); items.add(toAdd); } return items

IllegalArgumentException: Bound must be positive

让人想犯罪 __ 提交于 2019-11-27 07:51:17
问题 I get an error saying that my bound must be positive. Here is the line I get it on: inv.setItem(i, items.get(r.nextInt(items.size()))); As far as I know, it comes from the part where I request a random integer from the list of items. This is how I defined the list: List<ItemStack> items = getAllItems(level); Where the getAllItems() method looks like: public List<ItemStack> getAllItems(int level) { List<ItemStack> items = new ArrayList<ItemStack>(); for (String item : settings.getChests()