1
Eclipse Help?
Hello Modders,
I am new to modding though I have attempted to do such in the past. Please bare with me, but my Eclipse is not showing any code in the editor window. I have set it up correctly but I can't figure out why my package won't display its source code.
I am new to modding though I have attempted to do such in the past. Please bare with me, but my Eclipse is not showing any code in the editor window. I have set it up correctly but I can't figure out why my package won't display its source code.
5
Well, you're on the right track. Let me show you how I usually set these sorts of things up:
One thing you did forget is the 'else', and past the first 'if' statement your code got pretty messy.
Also, to get the command entered, use commandLabel, as shown.
When sending a message to Console, .sendMessage(""); does nothing. You want to log to console, and you use (plugin).getLogger().info(message); to do so. You also cannot log colors to console.
Along with that, it is good practice to return false; after commands as opposed to what you are doing (return true;).
The 'usage' section of your plugin.yml is unnecessary.
I hope this helps, and happy programming. For further help, I recommend researching 'Appljuze' and 'TheBCBroz' on YouTube. I highly recommend you learn Java Basics before Bukkit, however, and you can learn that from 'thenewboston'. All the basics to starting Bukkit coding can be learned in my article, found here: http://www.planetminecraft.com/blog/how ... t-plugins/
You may also add me on skype (xddrummer7) for additional advice, tips, and possibly lessons ;p
Just make sure you tell me who you are.
BTW, here's what your whole class would look like:
if(sender instanceof Player){
Player player = (Player) sender;
if(commandLabel.equalsIgnoreCase("test")){
player.sendMessage("You ran the test command in-game!");
}
}else{
this.getLogger().info("You ran the test command from console!");
}
One thing you did forget is the 'else', and past the first 'if' statement your code got pretty messy.
Also, to get the command entered, use commandLabel, as shown.
When sending a message to Console, .sendMessage(""); does nothing. You want to log to console, and you use (plugin).getLogger().info(message); to do so. You also cannot log colors to console.
Along with that, it is good practice to return false; after commands as opposed to what you are doing (return true;).
The 'usage' section of your plugin.yml is unnecessary.
I hope this helps, and happy programming. For further help, I recommend researching 'Appljuze' and 'TheBCBroz' on YouTube. I highly recommend you learn Java Basics before Bukkit, however, and you can learn that from 'thenewboston'. All the basics to starting Bukkit coding can be learned in my article, found here: http://www.planetminecraft.com/blog/how ... t-plugins/
You may also add me on skype (xddrummer7) for additional advice, tips, and possibly lessons ;p
Just make sure you tell me who you are.
BTW, here's what your whole class would look like:
package com.optisize.test;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Test extends JavaPlugin {
public void onEnable() {
Bukkit.getServer().getLogger().info("Test Plugin is enabled");
}
public void onDisable() {
Bukkit.getServer().getLogger().info("Test Plugin is disabled");
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[]args) {
if(sender instanceof Player){
Player player = (Player) sender;
if(commandLabel.equalsIgnoreCase("test")){
player.sendMessage("You ran the test command in-game!");
}
}else{
this.getLogger().info("You ran the test command from console!");
}
}
}
CasterisCraftJunkiesI figured it out, It was because I didn't make a class yet XD. Anyways, I wrote my first test plugin but the command isn't working:
here is my code:
package com.optisize.test;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Test extends JavaPlugin {
public void onEnable() {
Bukkit.getServer().getLogger().info("Test Plugin is enabled");
}
public void onDisable() {
Bukkit.getServer().getLogger().info("Test Plugin is disabled");
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[]args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.GREEN +"The console ran the test command!");
return true;
}
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("test")) {
player.sendMessage("You ran the test command");
}
return true;
}
}
and my plugins.ymlname: test
version: 0.1
main: com.optisize.test.test
author: Optisize
description: a test plugin.
commands:
test:
usage: /<command>
description: a test command
Further then I've gotten lol
But my command doesn't work and I'm not sure why
CraftJunkiesI figured it out, It was because I didn't make a class yet XD. Anyways, I wrote my first test plugin but the command isn't working:
here is my code:
package com.optisize.test;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Test extends JavaPlugin {
public void onEnable() {
Bukkit.getServer().getLogger().info("Test Plugin is enabled");
}
public void onDisable() {
Bukkit.getServer().getLogger().info("Test Plugin is disabled");
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[]args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.GREEN +"The console ran the test command!");
return true;
}
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("test")) {
player.sendMessage("You ran the test command");
}
return true;
}
}
and my plugins.ymlname: test
version: 0.1
main: com.optisize.test.test
author: Optisize
description: a test plugin.
commands:
test:
usage: /<command>
description: a test command
Further then I've gotten lol
I figured it out, It was because I didn't make a class yet XD. Anyways, I wrote my first test plugin but the command isn't working:
here is my code:
and my plugins.yml
here is my code:
package com.optisize.test;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Test extends JavaPlugin {
public void onEnable() {
Bukkit.getServer().getLogger().info("Test Plugin is enabled");
}
public void onDisable() {
Bukkit.getServer().getLogger().info("Test Plugin is disabled");
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[]args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.GREEN +"The console ran the test command!");
return true;
}
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("test")) {
player.sendMessage("You ran the test command");
}
return true;
}
}
and my plugins.yml
name: test
version: 0.1
main: com.optisize.test.test
author: Optisize
description: a test plugin.
commands:
test:
usage: /<command>
description: a test commandDoes all the other packages show? (The pre-installed ones) If not, then you clearly didn't install it correctly.
When you run the gradlew.bat, wait for everything to finish and wait for the cmd to say that it has been installed fully. Otherwise I can't help you any further ^,^
Thats what I assume you meant..
If it's that when you go to open a class file, and it doesn't show up, then you don't have the editor window open. You would have to re open it.
When you run the gradlew.bat, wait for everything to finish and wait for the cmd to say that it has been installed fully. Otherwise I can't help you any further ^,^
Thats what I assume you meant..
If it's that when you go to open a class file, and it doesn't show up, then you don't have the editor window open. You would have to re open it.
