1

Eclipse Help?

CraftJunkies 8/11/14 11:53 pm
232
8/12/2014 2:03 am
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.
Posted by
CraftJunkies
Level 1 : New Network
0

  Have something to say?

JoinSign in

5

XDdrummer
08/12/2014 2:03 am
Level 5 : Apprentice Crafter
Well, you're on the right track. Let me show you how I usually set these sorts of things up:


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!");
}

}
}
1
CraftJunkies
08/12/2014 2:00 am
Level 1 : New Network
Casteris
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.yml

name: 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
1
Faxwy
08/12/2014 1:53 am
Level 13 : Journeyman Princess
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.yml

name: 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
1
CraftJunkies
08/12/2014 1:49 am
Level 1 : New Network
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:

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 command
1
ShadowCatEXE
08/12/2014 1:37 am
Level 31 : Artisan Toast
Does 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.
1

Welcome