bukkit

NullPointerException thrown after field is check if it is null

房东的猫 提交于 2019-12-13 09:16:19
问题 I am developing a plugin for Bukkit (http://bukkit.org) and after verifying that it is not null, it gives me a NullPointerException at the 2nd line String description = getConfig().getString("core.commands."+cmd+".description"); if (!(description.isEmpty())) getCommand(cmd).setDescription(description); else getLogger().warning("NO description assigned to: " + cmd); description = null; 回答1: isEmpty() is different from null check. isEmpty() checks is String is empty String (which means "" ).

Bukkit - Displaying null when getting a string from the config file

﹥>﹥吖頭↗ 提交于 2019-12-13 03:32:00
问题 So I've been working on a custom feature for my minecraft server, one of the things that I need to do is get an integer from the config file that is specific to each player to display how many Packages(keys) they have (Virtual items) The issue that I am having is that in the GUI it is displaying 'null' instead of how many they have... Could anyone help me please? Item in the gui Code for creating the player's instance in the config (Using a custom file class that was provided to me by a

TCP client/server only receives first two messages

帅比萌擦擦* 提交于 2019-12-13 02:59:05
问题 I am setting up a server/client interaction for bukkit. The custom minecraft client will send data over a socket to the server which will read that data and send a message back to the client. Both client and server have the same code for the sockets, however the client uses the client class and the server the server. This is the server code import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import java.util.List; import com.cmg

Create 'Custom' Bukkit Plugin YAML File

时光怂恿深爱的人放手 提交于 2019-12-13 02:15:33
问题 everyone. I have just recently gotten into writing Bukkit plugins for Minecraft. I've already got dev versions for my first two plugins running fine on my server, and they haven't given me much trouble at all. I'm currently working on a third, and I've run into some trouble. I am trying to figure out how exactly to create a YAML file and read/write data from/to it. Just to clarify, I am NOT referring to a config.yml file, as I am not having any trouble with that. I know how to create a

HashMap saving with ObjectOutputStream

我的未来我决定 提交于 2019-12-12 13:10:04
问题 To save teleportation points on command, I have an HashMap : public HashMap<Player, Location> mapHomes = new HashMap<>(); Which is accessed like this: if(cmd.getName().equalsIgnoreCase("sethome")){ Location loc = player.getLocation(); mapHomes.put(player, loc); sender.sendMessage("Home set !"); return true; } if(cmd.getName().equalsIgnoreCase("home")){ Location loc1 = mapHomes.get(player); player.teleport(loc1); sender.sendMessage("Teleported to home"); return true; } return false; Since

Spell Scroller doesn't work

好久不见. 提交于 2019-12-12 07:04:37
问题 I'm making a MagicBows plugin where you can select spells by doing left click and if you shoot the bow the selected spell will give its effect, but the selector doesn't work. I'm not sure how to fix this. This is my Main file: package me.Pixel; import java.util.ArrayList; import java.util.List; import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org

invalid plugin.yml bukkit plugin error

前提是你 提交于 2019-12-12 06:35:30
问题 Hey so I did look this issue up on multiple sites before I posted this and I did everything correct, but I still get this error when I try to load my plugin, it says error could not invalid plugin.yml, and then just gives a bunch of code lines and stuff (i'm assuming from the code in the bukkit files and whatnot, and yes my plugin.yml is saved in the src folder not a package, and when I export it I do export it as a .jar, anyway here's my plugin.yml file name: ProtHome main: com.yahoo

Java Nashorn - ClassNotFoundException - Java.type()

时间秒杀一切 提交于 2019-12-12 04:58:08
问题 I am currently creating a plugin for the Bukkit-Server, but i have a problem using the Nashorn scripting engine. I am evaluating the external javascript file from my Java-Plugin. I cant get my javascript to import the classes from my plugin, only standard java classes are working (like var JavaBool = Java.type('java.lang.Boolean'); , but not var Holder = Java.type('io.github.advtest1.js.JSHolder'); ) Whenever I try to load one of these I get the following error: Caused by: java.lang

Bukkit - Using static variables causing problems

无人久伴 提交于 2019-12-12 03:43:42
问题 So I've got this plugin I'm working on, I'll explain the feature so that you get an idea of what it's suppose to do: -/showcps : tells the sender whenever the specified player left/right clicks So, let's say there are two players, Bob and Billy on a server running this plugin; Bob does the command /showcps Billy and sees whenever Billy clicks. Then Billy types the command /showcps Bob , and now Billy sees when Bob clicks. The problem is that Bob can no longer see when Billy is clicking. That

Referencing 'this' from a class that is not extending JavaPlugin

旧街凉风 提交于 2019-12-12 02:27:02
问题 I am trying to make a plugin that starts a Scheduler task with this method: public void newCountdown() { Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { public void run() { for (Player player : Bukkit.getServer().getOnlinePlayers()) { player.sendMessage("Hey"); } } }, 0, 20); } The problem is, when I try to call the method, it says it needs to be a static method. Then, when i change it to static the first parameter "this" says it cannot be used in a static