bukkit

How to get an offline player by UUID?

我们两清 提交于 2019-12-25 06:29:23
问题 How to get an offline player by UUID? I can get an online player by UUID by iterating through all online players and return when an UUID matches, but I don't know how to do this for offline players. 回答1: Beta build of CraftBukkit (1.7.9-R0.1) has the method you need in org.bukkit.Server interface: /** * Gets the player by the given UUID, regardless if they are offline or * online. * <p> * This will return an object even if the player does not exist. To this * method, all players will exist. *

Bukkit (spigot api) listener not responding?

可紊 提交于 2019-12-25 03:49:07
问题 I have been making a bukkit plugin, which shows up in the plugins list but when I do what I want the code to do nothing happens. public class MyClass extends JavaPlugin implements Listener { @EventHandler public void onInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); if (player.isSneaking()) { player.sendMessage("Fire!"); Arrow arrow = player.launchProjectile(Arrow.class); arrow.setShooter(player); arrow.setGravity(false); arrow.setSilent(true); arrow.setBounce(false);

How to get the return with executeQuery() in Java?

此生再无相见时 提交于 2019-12-25 02:52:29
问题 I have this code; String sql = "UPDATE Players SET Losses=Losses+1 WHERE UUID='" + p.getUniqueId() + "';"; stmt.executeUpdate(sql); How can I get the current Losses for a specific Player p ? 回答1: You can get the losses like the following. Seems really trivial, guess you are an absolute beginner. String sql = "SELECT Losses FROM Players WHERE UUID='" + p.getUniqueId() + "';"; ResultSet rs = stmt.executeQuery(sql); int losses = -1; if(rs.next()) { losses = rs.getInt("Losses"); } 回答2: SELECT

Reading arguments as Integer for a Bounty in a Bukkit plugin

我们两清 提交于 2019-12-24 17:00:01
问题 This is just the start of the plugin and there will be more. This is what I want to have: For /bounty <name> <amount> I want to be able to read what is read on the amount to make a variable like int a = args[1] , but I don't know how to do that. I have tried and it gave me some errors. I also want it so it can only be a number on the command. I am using bukkit version: craftbukkit-1.7.10-R0.1-20140804.183445-7 Here is my code: public class Main extends JavaPlugin { public void onEnable() {

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

非 Y 不嫁゛ 提交于 2019-12-19 08:02:14
问题 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

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

丶灬走出姿态 提交于 2019-12-19 08:02:09
问题 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

Should a database connection stay open all the time or only be opened when needed?

橙三吉。 提交于 2019-12-17 06:13:20
问题 I have a bukkit plugin (minecraft) that requires a connection to the database. Should a database connection stay open all the time, or be opened and closed when needed? 回答1: The database connection must be opened only when its needed and closed after doing all the necessary job with it. Code sample: Prior to Java 7: Connection con = null; try { con = ... //retrieve the database connection //do your work... } catch (SQLException e) { //handle the exception } finally { try { if (con != null) {

Bukkit Map Voting

五迷三道 提交于 2019-12-13 23:49:35
问题 I need help. I creating mini game plugin with map voting and I don't know how to do that. HashMap<World, Integer> votes = new HashMap<World, Integer>(); Let's say the votes are closed and the server is choosing map. Which one? What when 2 maps will have the same biggest num. of votes? Thanks for help, eNcoo. 回答1: Tie-Breaker Vote Have another vote, but restrict choices to top worlds with equal high score. Random Tie-Breaker Use a random number generator to break the tie, such as shown in the

Spigot/Bukkit Help : Block Manipulation

末鹿安然 提交于 2019-12-13 21:29:48
问题 I don't know why this isn't working. I tried execute it, but when I type /build , the redstone block doesn't place. plugin.yml name: SkinStandoff version: 0.1 main: com.sumeshdesh.skinstandoff.SkinStandoff commands: arena: usage: /build Main.java public class SkinStandoff extends JavaPlugin implements Listener { public boolean onCommand(Command cmd, CommandSender sender, String label, String args[]) { if (cmd.getName().equalsIgnoreCase("build") && sender instanceof Player) { Player player =

Minecraft One Player Per Config

女生的网名这么多〃 提交于 2019-12-13 10:06:29
问题 I'm going to try to make this quick basically i'm trying to make ONE config per player. So basically when ever I call user.CreateUser(); if the user doesn't exist it registers there own config with there unique id as the name of the yml My problem is that when ever I try to call user.CreateUser(); on the PlayerJoinEvent it shows a error and i'm not sure the UUID u shouldn't be returning null because it's inside a constructor or the other variables. Error [23:57:52 ERROR]: Could not pass event