Minecraft PC IP: play.cubecraft.net
Status
Not open for further replies.

DrHam

Forum Veteran
Sep 15, 2015
3,615
4,166
518
Kepler-452b
I re-writed the hole plugin!!! and still having errors:
package Gui.test;


import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class Gui extends JavaPlugin implements Listener {

public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}

public void openGUI(Player player) {
Inventory i = Bukkit.createInventory(null, 9, ChatColor.DARK_BLUE
+ "Kits!");

ItemStack PvP = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta PvPMeta = PvP.getItemMeta();

ItemStack Archer = new ItemStack(Material.BOW);
ItemMeta ArcherMeta = Archer.getItemMeta();

PvPMeta.setDisplayName(ChatColor.WHITE + "PvP");
PvP.setItemMeta(PvPMeta);

ArcherMeta.setDisplayName(ChatColor.WHITE + "Archer");
Archer.setItemMeta(ArcherMeta);

i.setItem(3, PvP);
i.setItem(5, Archer);

player.openInventory(i);
}

@EventHandler
public void onInventoryClickEvent(InventoryClickEvent e) {
if (ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!"))
return;

Player player = (Player) e.getWhoClicked();
e.setCancelled(true);

if (e.getCurrentItem() == null
|| e.getCurrentItem().getType() == Material.AIR
|| !e.getCurrentItem().hasItemMeta()) {
player.closeInventory();
return;
}
switch (e.getCurrentItem().getType()){
case DIAMOND_SWORD:
player.performCommand("Help");
player.closeInventory();
player.sendMessage(String.format(
"%s You received the kit %sPvP%s!", ChatColor.GREEN,
ChatColor.AQUA, ChatColor.GREEN));
break;
case BOW:
player.performCommand("Spawn");
player.closeInventory();
player.sendMessage(String.format(
"%s You received the kit %sArcher%s!", ChatColor.GREEN,
ChatColor.AQUA, ChatColor.GREEN));
break;
default:
player.closeInventory();
break;
}

}

@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent e) {
e.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS));
}

@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Action a = e.getAction();
if (a == Action.PHYSICAL || e.getItem() == null
|| e.getItem().getType() == Material.AIR)
return;

if (e.getItem().getType() == Material.COMPASS) {
openGUI(e.getPlayer());
}
}
@error_dan_overflow @TrinityDEV @GingerGeek @rubik_cube_man @Joe Henry
 

Mattuki

Well-Known Member
Mar 21, 2015
455
172
118
28
I re-writed the hole plugin!!! and still having errors:
package Gui.test;


import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class Gui extends JavaPlugin implements Listener {

public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}

public void openGUI(Player player) {
Inventory i = Bukkit.createInventory(null, 9, ChatColor.DARK_BLUE
+ "Kits!");

ItemStack PvP = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta PvPMeta = PvP.getItemMeta();

ItemStack Archer = new ItemStack(Material.BOW);
ItemMeta ArcherMeta = Archer.getItemMeta();

PvPMeta.setDisplayName(ChatColor.WHITE + "PvP");
PvP.setItemMeta(PvPMeta);

ArcherMeta.setDisplayName(ChatColor.WHITE + "Archer");
Archer.setItemMeta(ArcherMeta);

i.setItem(3, PvP);
i.setItem(5, Archer);

player.openInventory(i);
}

@EventHandler
public void onInventoryClickEvent(InventoryClickEvent e) {
if (ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!"))
return;

Player player = (Player) e.getWhoClicked();
e.setCancelled(true);

if (e.getCurrentItem() == null
|| e.getCurrentItem().getType() == Material.AIR
|| !e.getCurrentItem().hasItemMeta()) {
player.closeInventory();
return;
}
switch (e.getCurrentItem().getType()){
case DIAMOND_SWORD:
player.performCommand("Help");
player.closeInventory();
player.sendMessage(String.format(
"%s You received the kit %sPvP%s!", ChatColor.GREEN,
ChatColor.AQUA, ChatColor.GREEN));
break;
case BOW:
player.performCommand("Spawn");
player.closeInventory();
player.sendMessage(String.format(
"%s You received the kit %sArcher%s!", ChatColor.GREEN,
ChatColor.AQUA, ChatColor.GREEN));
break;
default:
player.closeInventory();
break;
}

}

@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent e) {
e.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS));
}

@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Action a = e.getAction();
if (a == Action.PHYSICAL || e.getItem() == null
|| e.getItem().getType() == Material.AIR)
return;

if (e.getItem().getType() == Material.COMPASS) {
openGUI(e.getPlayer());
}
}
@error_dan_overflow @TrinityDEV @GingerGeek @rubik_cube_man @Joe Henry
:v pls explain this to all the persons who want to know about this :3
 
  • Like
Reactions: red_lion

Robke28

Well-Known Member
Oct 4, 2014
4
0
77
26
Hi there,
Your fault is pretty simple and think you just overlooked it

if (ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!"))
return;

Here you are returning if the inventory is named Kits, but you wanna do the reverse, so just change it to:

if (!ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!")){
return;}
 

Mattuki

Well-Known Member
Mar 21, 2015
455
172
118
28
Hi there,
Your fault is pretty simple and think you just overlooked it

if (ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!"))
return;

Here you are returning if the inventory is named Kits, but you wanna do the reverse, so just change it to:

if (!ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!")){
return;}
one day i will know about what are you talking xd
 

DrHam

Forum Veteran
Sep 15, 2015
3,615
4,166
518
Kepler-452b
@Hangar555 I recommend you go to www.spigotmc.org for plugin help, plenty of very experienced devs there and you will get fast replies.
I tried, I prefer to post here, before see 1656647246641.2 mens saying "learn Java" "feel free to learn Java" to "We don't want noobs" or "go away, this is only for pros" (they don't have any cool plugin, I mean, for what you want a portable [and bugged] workbench without perms... So, yes I prefer that you say "I can't help you" or GingerGeek saying "You have too many errors, noob"

But thanks, @error_dan_overflow
 

Thiemo

Well-Known Member
Aug 24, 2015
197
188
118
24
Hi there,
Your fault is pretty simple and think you just overlooked it

if (ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!"))
return;

Here you are returning if the inventory is named Kits, but you wanna do the reverse, so just change it to:

if (!ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!")){
return;}
That doesnt make sense at all..... "I still have an error", he didnt said, help my code is not working correct my event isnt fired at all. So plez, no. And yes, maybe he misplaced the '!', but still it wouldnt fix his error, which in this case we dont have. So how are you even to try solving an error, without a stacktrace, thats my opinion

And eh, @Hangar555 some people at SpigotMC have working plugins where they put time and afford in it, example https://www.spigotmc.org/resources/healthbar.15230/ *shameless selfpromotion xd*
 

ExtendedHorizons

Well-Known Member
Oct 4, 2014
206
167
118
Utah
bit.ly
Hopefully this isn't to much spoon feeding, @Hangar555 I fixed the code for you, and added comments of where and why I did what. Read them!
Code:
package gui.test; //never capitalize package names its not proper syntax

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class SpoonFeeding extends JavaPlugin implements Listener {
    /*
    If this doesn't work, you might not be setting up your plugin.yml correctly
    Also you don't need all of these return statements, Id really only suggest those if you have code after that would be called,
    but since I made it all in a few if statements, if it doesn't get called, it doesn't get called.
    This imo is a lot better then having a bunch of if statements in the code, rather then returning it even though the method doesn't have a return type.

    Sorry for the rough explanation.
    */
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this); //Registers the event
    }

    public void openGUI(Player player) {
        //I wouldn't suggest naming the Inventory to just "i" because later on you might have more variables, ect. Having them named properly helps
        Inventory inventory = Bukkit.createInventory(null, 9, ChatColor.DARK_BLUE + "Kits"); //The name of the inventory used to be "Kits!" when you were checking if the name was just "Kits" later.

        //Camel cased these
        ItemStack pvp = new ItemStack(Material.DIAMOND_SWORD);
        ItemMeta pvpMeta = pvp.getItemMeta();

        ItemStack archer = new ItemStack(Material.BOW);
        ItemMeta archerMeta = archer.getItemMeta();

        pvpMeta.setDisplayName(ChatColor.WHITE + "PvP");
        pvp.setItemMeta(pvpMeta);

        archerMeta.setDisplayName(ChatColor.WHITE + "Archer");
        archer.setItemMeta(archerMeta);

        inventory.setItem(3, pvp);
        inventory.setItem(5, archer);

        player.openInventory(inventory);
    }

    @EventHandler
    public void onInventoryClickEvent(InventoryClickEvent event) {
        Player player = (Player) event.getWhoClicked();
        if (ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("kits")) { // checking if there inventory name (without color) is "kits"
            if (event.getCurrentItem().hasItemMeta()) { //If the clicked item has ItemMeta (you dont need to check if the item is null because if it is, it wouldn't have item meta
                switch (event.getCurrentItem().getType()) { //I personally don't use a switch instead of if statements, but this works.
                    case DIAMOND_SWORD:
                        player.closeInventory();
                        player.performCommand("help"); // I guess you just wanted to test if this part worked by performing this command? I would suggest just adding a debug message like Bukkit.broadcastMessage("DIAMOND_SWORD was clicked in the kits inventory");
                        player.sendMessage(String.format("%sYou received the kit %sPvP%s!", ChatColor.GREEN, ChatColor.AQUA, ChatColor.GREEN));
                        break;
                    case BOW:
                        player.closeInventory();
                        player.performCommand("spawn");
                        player.sendMessage(String.format("%sYou received the kit %sArcher%s!", ChatColor.GREEN, ChatColor.AQUA, ChatColor.GREEN));
                        break;
                    default:
                        player.closeInventory(); //This will close the inventory whenever the item type isn't a diamond sword or a bow, but ok
                        break;
                }
            }
            event.setCancelled(true); //Makes it so they cant move items in the kits inventory around (still calls the if statements)
        }
    }

    @EventHandler
    public void onPlayerJoinEvent(PlayerJoinEvent event) {
        event.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS)); //Add the compass to the inventory
    }

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { //If the action is right clicking air, or a block
            if (event.getItem().getType().equals(Material.COMPASS)) { //If the item the player interacted with is a compass
                openGUI(event.getPlayer()); //Open the GUI
            }
        }
    }
}
 
Last edited:

Thiemo

Well-Known Member
Aug 24, 2015
197
188
118
24
Hopefully this isn't to much spoon feeding, @Hangar555 I fixed the code for you, and added comments of where and why I did what. Read them!
Code:
package gui.test; //never capitalize package names

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class SpoonFeeding extends JavaPlugin implements Listener {
    /*
    If this doesn't work, you might not be setting up your plugin.yml correctly
    Also you don't need all of these return statements, Id really only suggest those if you have code after that would be called,
    but since I made it all in a few if statements, if it doesn't get called, it doesn't get called.
    This imo is a lot better then having a bunch of if statements in the code, rather then returning it even though the method doesn't have a return type.

    Sorry for the rough explanation.
    */
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this); //Registers the event
    }

    public void openGUI(Player player) {
        //I wouldn't suggest naming the Inventory to just "i" because later on you might have more variables, ect. Having them named properly helps
        Inventory inventory = Bukkit.createInventory(null, 9, ChatColor.DARK_BLUE + "Kits"); //The name of the inventory used to be "Kits!" when you were checking if the name was just "Kits" later.

        //Camel cased these
        ItemStack pvp = new ItemStack(Material.DIAMOND_SWORD);
        ItemMeta pvpMeta = pvp.getItemMeta();

        ItemStack archer = new ItemStack(Material.BOW);
        ItemMeta archerMeta = archer.getItemMeta();

        pvpMeta.setDisplayName(ChatColor.WHITE + "PvP");
        pvp.setItemMeta(pvpMeta);

        archerMeta.setDisplayName(ChatColor.WHITE + "Archer");
        archer.setItemMeta(archerMeta);

        inventory.setItem(3, pvp);
        inventory.setItem(5, archer);

        player.openInventory(inventory);
    }

    @EventHandler
    public void onInventoryClickEvent(InventoryClickEvent event) {
        Player player = (Player) event.getWhoClicked();
        if (ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("kits")) { // checking if there inventory name (without color) is "kits"
            if (event.getCurrentItem().hasItemMeta()) { //If the clicked item has ItemMeta (you dont need to check if the item is null because if it is, it wouldn't have item meta
                switch (event.getCurrentItem().getType()) { //I personally don't use a switch instead of if statements, but this works.
                    case DIAMOND_SWORD:
                        player.closeInventory();
                        player.performCommand("help"); // I guess you just wanted to test if this part worked by performing this command? I would suggest just adding a debug message like Bukkit.broadcastMessage("DIAMOND_SWORD was clicked in the kits inventory");
                        player.sendMessage(String.format("%sYou received the kit %sPvP%s!", ChatColor.GREEN, ChatColor.AQUA, ChatColor.GREEN));
                        break;
                    case BOW:
                        player.closeInventory();
                        player.performCommand("spawn");
                        player.sendMessage(String.format("%sYou received the kit %sArcher%s!", ChatColor.GREEN, ChatColor.AQUA, ChatColor.GREEN));
                        break;
                    default:
                        player.closeInventory(); //This will close the inventory whenever the item type isn't a diamond sword or a bow, but ok
                        break;
                }
            }
            event.setCancelled(true); //Makes it so they cant move items in the kits inventory around (still calls the if statements)
        }
    }

    @EventHandler
    public void onPlayerJoinEvent(PlayerJoinEvent event) {
        event.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS)); //Add the compass to the inventory
    }

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { //If the action is right clicking air, or a block
            if (event.getItem().getType().equals(Material.COMPASS)) { //If the item the player interacted with is a compass
                openGUI(event.getPlayer()); //Open the GUI
            }
        }
    }
}
Yeh, go feed them code, they will learn from it! Goodjob!
 
  • Like
Reactions: Dan:

Thiemo

Well-Known Member
Aug 24, 2015
197
188
118
24
Hopefully this isn't to much spoon feeding, @Hangar555 I fixed the code for you, and added comments of where and why I did what. Read them!
Code:
package gui.test; //never capitalize package names

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class SpoonFeeding extends JavaPlugin implements Listener {
    /*
    If this doesn't work, you might not be setting up your plugin.yml correctly
    Also you don't need all of these return statements, Id really only suggest those if you have code after that would be called,
    but since I made it all in a few if statements, if it doesn't get called, it doesn't get called.
    This imo is a lot better then having a bunch of if statements in the code, rather then returning it even though the method doesn't have a return type.

    Sorry for the rough explanation.
    */
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this); //Registers the event
    }

    public void openGUI(Player player) {
        //I wouldn't suggest naming the Inventory to just "i" because later on you might have more variables, ect. Having them named properly helps
        Inventory inventory = Bukkit.createInventory(null, 9, ChatColor.DARK_BLUE + "Kits"); //The name of the inventory used to be "Kits!" when you were checking if the name was just "Kits" later.

        //Camel cased these
        ItemStack pvp = new ItemStack(Material.DIAMOND_SWORD);
        ItemMeta pvpMeta = pvp.getItemMeta();

        ItemStack archer = new ItemStack(Material.BOW);
        ItemMeta archerMeta = archer.getItemMeta();

        pvpMeta.setDisplayName(ChatColor.WHITE + "PvP");
        pvp.setItemMeta(pvpMeta);

        archerMeta.setDisplayName(ChatColor.WHITE + "Archer");
        archer.setItemMeta(archerMeta);

        inventory.setItem(3, pvp);
        inventory.setItem(5, archer);

        player.openInventory(inventory);
    }

    @EventHandler
    public void onInventoryClickEvent(InventoryClickEvent event) {
        Player player = (Player) event.getWhoClicked();
        if (ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("kits")) { // checking if there inventory name (without color) is "kits"
            if (event.getCurrentItem().hasItemMeta()) { //If the clicked item has ItemMeta (you dont need to check if the item is null because if it is, it wouldn't have item meta
                switch (event.getCurrentItem().getType()) { //I personally don't use a switch instead of if statements, but this works.
                    case DIAMOND_SWORD:
                        player.closeInventory();
                        player.performCommand("help"); // I guess you just wanted to test if this part worked by performing this command? I would suggest just adding a debug message like Bukkit.broadcastMessage("DIAMOND_SWORD was clicked in the kits inventory");
                        player.sendMessage(String.format("%sYou received the kit %sPvP%s!", ChatColor.GREEN, ChatColor.AQUA, ChatColor.GREEN));
                        break;
                    case BOW:
                        player.closeInventory();
                        player.performCommand("spawn");
                        player.sendMessage(String.format("%sYou received the kit %sArcher%s!", ChatColor.GREEN, ChatColor.AQUA, ChatColor.GREEN));
                        break;
                    default:
                        player.closeInventory(); //This will close the inventory whenever the item type isn't a diamond sword or a bow, but ok
                        break;
                }
            }
            event.setCancelled(true); //Makes it so they cant move items in the kits inventory around (still calls the if statements)
        }
    }

    @EventHandler
    public void onPlayerJoinEvent(PlayerJoinEvent event) {
        event.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS)); //Add the compass to the inventory
    }

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { //If the action is right clicking air, or a block
            if (event.getItem().getType().equals(Material.COMPASS)) { //If the item the player interacted with is a compass
                openGUI(event.getPlayer()); //Open the GUI
            }
        }
    }
}
Before you think that I'm an asshole, let me just explain why this is not the correct way to help him

••
package gui.test; //never capitalize package names
And why is that wrong? Doenst make sense to just tell him its wrong without giving an argument why its wrong.

••
switch(event.getCurrentItem().hasItemMeta()) { //If the clicked item has ItemMeta (you dont need to check if the item is null because if it is, it wouldn't have item meta

And why do we need to check this? Maybe you should tell him something about an NPE that will be thrown without checking

••
event.getCurrentItem().getType()) { //I personally don't use a switch instead of if statements, but this works.

What is a switch? You dont even tell him what it does or what its used for. You could link him to the javadocs for switch. And explain him why you need a break; etcetc

Im tired of typing, because Im on my phone. But yeh lack of details. And you dont give him extra information sources *cough* docs.

Its okay that you are trying to help, but dont help by rewriting his code and just giving it to him, its just a scream of attention, "look i made ur amazingly good, i procode" Seriously dont spoonfeed, no one will learn from it.

No hate, just my opinion
 
  • Like
Reactions: CasparWolf

Younisco

Forum Professional
May 13, 2014
8,008
19,694
669
22
london
I tried, I prefer to post here, before see 1656647246641.2 mens saying "learn Java" "feel free to learn Java" to "We don't want noobs" or "go away, this is only for pros" (they don't have any cool plugin, I mean, for what you want a portable [and bugged] workbench without perms... So, yes I prefer that you say "I can't help you" or GingerGeek saying "You have too many errors, noob"

But thanks, @error_dan_overflow
I am almost 100% sure that experienced devs won't diss you, lol.
 
  • Like
Reactions: Thiemo

ExtendedHorizons

Well-Known Member
Oct 4, 2014
206
167
118
Utah
bit.ly
sorry *edits the package thing adds "its proper syntax"* <3 Btw I don't "Hate your opinion" sorry that I didn't explain everything with perfect detail. But if I was where he was, this would've been enough to make me understand. And I suck at explaining code :P but ye sorry
Before you think that I'm an asshole, let me just explain why this is not the correct way to help him

••
package gui.test; //never capitalize package names
And why is that wrong? Doenst make sense to just tell him its wrong without giving an argument why its wrong.

••
switch(event.getCurrentItem().hasItemMeta()) { //If the clicked item has ItemMeta (you dont need to check if the item is null because if it is, it wouldn't have item meta

And why do we need to check this? Maybe you should tell him something about an NPE that will be thrown without checking

••
event.getCurrentItem().getType()) { //I personally don't use a switch instead of if statements, but this works.

What is a switch? You dont even tell him what it does or what its used for. You could link him to the javadocs for switch. And explain him why you need a break; etcetc

Im tired of typing, because Im on my phone. But yeh lack of details. And you dont give him extra information sources *cough* docs.

Its okay that you are trying to help, but dont help by rewriting his code and just giving it to him, its just a scream of attention, "look i made ur amazingly good, i procode" Seriously dont spoonfeed, no one will learn from it.

No hate, just my opinion[/QUOT
 

Thiemo

Well-Known Member
Aug 24, 2015
197
188
118
24
sorry *edits the package thing adds "its proper syntax"* <3 Btw I don't "Hate your opinion" sorry that I didn't explain everything with perfect detail. But if I was where he was, this would've been enough to make me understand. And I suck at explaining code :p but ye sorry
Its okay, but Spoon feeding is just a nah
 

Robke28

Well-Known Member
Oct 4, 2014
4
0
77
26
That doesnt make sense at all..... "I still have an error", he didnt said, help my code is not working correct my event isnt fired at all. So plez, no. And yes, maybe he misplaced the '!', but still it wouldnt fix his error, which in this case we dont have. So how are you even to try solving an error, without a stacktrace, thats my opinion

And eh, @Hangar555 some people at SpigotMC have working plugins where they put time and afford in it, example https://www.spigotmc.org/resources/healthbar.15230/ *shameless selfpromotion xd*
Because this plugin only consists of a Main class, I copy pasted it in Intellij, added the things I said he had to change and then tried the plugin out myself (and it worked).
I agree the way I told him to make those changes could be better, but what I said was right.
If you would see the stacktrace you would see that nothing is wrong cause there are no errors.
The only reason the gui didn't open was because he returned (went out of the method) when the name was the name of the item he wanted to use to open the gui, so a simple ! in front would change that and make the plugin work.
 
Status
Not open for further replies.
Members Online

Latest profile posts

I'm now a dedicated member ig
Alright, so, I’m going to be trying to add 2FA onto my account again. Last time I tried to do it I got locked out of my account. But, that was about 2 years ago, and I would like to have extra account security so hopefully it works this time. Just letting y’all know in case I’m suddenly inactive (which means I probably got locked out again 😝).
Eli wrote on Mappoe's profile.
Thank you for the follow!
Reesle wrote on IAmEclipsy's profile.
Thank you for the follow! :) 🐈‍⬛
WorriedSkate940 wrote on ItzJuan's profile.
pro
Top Bottom