#help-development
1 messages · Page 227 of 1
Google your question before asking it:
https://www.google.com/
lol
Bing your question before asking it:
https://www.bing.com/
?yahoo
Yahoo your question before asking it:
https://search.yahoo.com/
so I have this code
public static ItemStack sword;
public static void init() {
ultimateSword();
}
public static void ultimateSword() {
ItemStack ultimateSword = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta meta = ultimateSword.getItemMeta();
meta.setDisplayName("§4§kscary§1Ultimate Sword§4§kscary");
meta.addEnchant(Enchantment.DAMAGE_ALL, 10, false);
meta.addEnchant(Enchantment.KNOCKBACK, 10, false);
meta.addEnchant(Enchantment.FIRE_ASPECT, 10, false);
meta.addEnchant(Enchantment.DURABILITY, 10, false);
ultimateSword.setItemMeta(meta);
sword = ultimateSword;
}```
but when I get the item there are no enchants
that code scares me
are you talking to me
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
i've done it with true but it still dosen't work
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
"does not working" 
uh how
lol
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Cannot resolve method "addenchant" in "itemstack"
nvm i'm dumb
alr alr it's addEnchantment
ok great now it won't give me the item and they're no errors
?sql
which static
i got like 5
public static void ultimateSword() {
``` imma remove this one
nvm that broke my whole code
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(colorize("&4You can't do this!"));
} else {
Player p = (Player) sender;
p.getInventory().addItem(ItemManager.sword);
}
return true;
}```
hmm you could make a loop
apply all your enchantments by enchatment names from a String list
if it works it works
actualy nvm
yeah bs
yea i read it wrong lol
that sounds dumb
cus player can be a sender
tf does that have to do with anything
guess
@Override
public void onEnable() {
// Plugin startup logic
ItemManager.init();
this.getServer().getPluginManager().registerEvents(new ItemEvents(), this);
this.getCommand("ms").setExecutor(new MS());
this.getCommand("ue").setExecutor(new UnEnchant());
this.getCommand("sword").setExecutor(new GetItem());
}
@Override
public void onDisable() {
// Plugin shutdown logic
}```
to late
entire
public class ItemManager {
public static ItemStack sword;
public static void init() {
ultimateSword();
}
public static void ultimateSword() {
ItemStack ultimateSword = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta meta = ultimateSword.getItemMeta();
meta.setDisplayName("§4§kscary§1Ultimate Sword§4§kscary");
ultimateSword.addEnchantment(Enchantment.DAMAGE_ALL, 10);
ultimateSword.addEnchantment(Enchantment.KNOCKBACK, 10);
ultimateSword.addEnchantment(Enchantment.FIRE_ASPECT, 10);
ultimateSword.addEnchantment(Enchantment.DURABILITY, 10);
ultimateSword.setItemMeta(meta);
sword = ultimateSword;
}
}```
that's it other than imports
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
ye
i can ask for help
^^
bc it's just this one small thing
yea
the literal only thing that didn't work was enchants
it works completely fine other than that
it will be a problem later, if the person is not acknowledging the issue
^
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (sender.hasPermission("eagle.multisummon")) {
if (args.length >= 2) {
try {
EntityType entity = EntityType.valueOf(args[0].toUpperCase());
int amount = Integer.parseInt(args[1]);
for (int i = 0; i < amount; i++) {
p.getWorld().spawnEntity(p.getLocation(), entity);
}
p.sendMessage(colorize("&aYou've spawned &e" + args[1] + " " + args[0] + "s"));
} catch (IllegalArgumentException e) {
p.sendMessage(colorize("&4This is not an entity."));
}
} else {
p.sendMessage(colorize("&4/multisummon [mob] [amount]."));
}
} else {
p.sendMessage(colorize("&4You don't have permission to do this!"));
}
} else {
sender.sendMessage(colorize("&4You cannot do this. "));
}
return true;
}```
here I made this just for you
?paste
formatting 💀
💀 ignorance lol
@last temple so changing the meta.addEnchant to this
ultimateSword.setItemMeta(meta);
ultimateSword.addEnchantment(Enchantment.DAMAGE_ALL, 10);
ultimateSword.addEnchantment(Enchantment.KNOCKBACK, 10);
ultimateSword.addEnchantment(Enchantment.FIRE_ASPECT, 10);
ultimateSword.addEnchantment(Enchantment.DURABILITY, 10);
broke it and now it won't give me the sword
i f I r e m o v e s t a t i c m y c o d e b r e a k s
LMAOOO
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
is that the person's link?
damn u guys are just rude i just needed help with one things
me after reviewing the code

Thanks i hate that code
lmfao old code
"if it works dont touch it"

then you break one thing
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Hi sry but i rly suck at dev xD https://pastebin.com/dQTdng5A
hell...
can i get help :/
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
a try to get a GUI
I just died a little
But i can move items :/
public MyPlugin() {
super();
// Initialize final variables
}
```can you do this?
autocorrect sorry
But like
Should be able to
How can i bypass this ?
well youre cancelling the click event only if its gold block or dirt
probs that
yes please
ItemMeta#setLore goes brr
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage("§6§lCraftyStudios §7§l» §f§lRunning on version 1.0");
return false;
}
return false;```
my code, but it is returning /craftycore when I run it...
whats a craftycore
my plugin
when I run /craftycore ingame it is supposed to say waatever is above, but it says /craftycore instead of whatever its supposed to say
plugin version?
no when I run the command it says craftycore, also literatly none of my commands are working, they are not red in the tab complete and I registered them but it says unknown command
register your commands
did you not see the part where i said i did?
yes
/craftycore:reload is not working either
getCommand("CraftyCoreCommand").setExecutor(new CraftyCoreCommand(this));``` the `(this));` is broken saying expected 0 args but found 1
remove what
ok fixed
(Plugin Instance) <--
.getCommand("YourCommand
").setExecutor(new YourCommandClass())
Guys, Why when I cancel player movement when player is on a horse, it just push him out of the horse?
getCommand("Spawn").setExecutor(new Spawn(this));```
ok this one wants me to have a `this`, whats the deal with that
yea but im registering the command like any other ones, its probally fine but i am confused
That object will have different constructor parameters
ok
Oh god it's des
🥜🥜
if (!(sender instanceof Player)) {
sender.sendMessage();
return true;
}
Player player = (Player) sender;
ok
is it possible to completely avoid static?
des nuts
Sure but static can sometimes be useful
I'm trying to code a scoreboard system with config, but the scoreboard won't update because I don't know how to do it. I've already looked at many forums that have worked with teams, but as soon as I tried, there were only errors. Could you please help me out? Pls ping me, if you answer me.```java
public void setScoreboard(Player p){
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
Objective obj = board.registerNewObjective("karakigames","dummy");
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
obj.setDisplayName(main.getInstance().getScoreConfig().getDisplayName());
for (int i=0; i<main.getInstance().getScoreConfig().getScore(p).size(); i++){
obj.getScore(main.getInstance().getScoreConfig().getScore(p).get(i)).setScore(i);
}
p.setScoreboard(board);
}
Like memory?
I guess I can gift that question to the trash can, but I only see examples for Plugin Messaging Channels BungeeCord -> Spigot but none in vice-versa.
Is it possible to send a plugin message to BungeeCord so my Discord Bot running on it can execute its job?
In my example -> Player has done an advancement -> send plugin message to bungeecord which process it and send a message to the channel "Player achieved advancement xyz".
i were thinking of arraylist
i know static methods
lol
pass Main class to Math Class
you mean like that?
hmm nice
but what about static lists and memory?
Noone knows eventually an answer to my question?
theyre just regular channels
register ingoing/outgoing using the messenger service and then send
its exactly the same either way
im trying to make a sethome system, is there a way to create a file in /homes directory with their uuid storing their info and tping to it when they run /home (home)
sql 
absolutly not
no my reaction to what i'm doing
i need folder, wouldnt that be easiest to get values
what are you doing
oh thats why i hate sql
that or I can make a chonky config
do yk how to generate a file and get values from it
beacuse all ik is getConfig
idk how to specify data.yml or smth
?config
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
ty
would this generate a new file
FileConfiguration data = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "data.yml"));
yes
ok and then it will stay and i can generate and pull values like normal?
short!
yes
ok
if(cur == Material.DIRT) return;
if(cur == Material.GOLD_BLOCK) return;
No alternative :/
?
or? switch?
yo md_5 any sql tutorials?
Nooo switches on Material
Remember a couple months ago!?
int x = getConfig().getDouble("<uuid>.x");
int y = getConfig().getDouble("<uuid>.y");
int z = getConfig().getDouble("<uuid>.z");
World w = plugin.getServer().getWorld(getConfig().getString("<uuid>.world"));
Location home= new home(w,x,y,z);
if I were to do something like this, would there be a way to set a string before <uuid> to the home name (/home <name>) so the string will save as <home><uuid><x>
uuid + ".x"
also you can use getLocation to save/get location directly
part of config class
right, but i need this to save for one to data.yml and before the <uuid> to be the home value, because I want them to be able to set more than 1 home
if(cur.getType() == Material.GOLD_BLOCK) return;
nice
if Material name contains in list?
It won't happen
better then writing
if(cur == Material.DIRT) x 100 times with different Materials
can i create a world asynchronously using WorldCreator?
because when i try to do it sync it almost crashes the server
is getResource() broken or something
dont think so
ive tried with plugin.getClass().getResourceAsStream(...) too
but thats probably due to class loading with bukkit
relative?
./

im used to it needing a / at the start
thats required with getResourceAsStream i think
officially day 2 of coding this shit
oh removing the / worked lol
Hey guys, Is there a packet sent when player leave house client side? Cause there is bug when PlayerMoveEvent is cancelled when player is on a horse or so, and it kick the player when you cancel the event only on client side
is there something like Material.ARMOR or something that can check if an item is armor
how i place a head in my Gui :/ Material.Player_Head don't existe ..
Hello, anytime I open an GUI where player heads are inside, the player heads just load really slow. It takes approx. 2 secs till the heads are loaded. Anyone know how to reduce the loading time?
PLAYER_HEAD don't exist in java 8
I'm getting an error trying to use maven to shade external libraries into my plugin. For some reason, the spigot server doesnt load resources from the plugin jar (the third party libraries load data from resources in the plugins jar, but spigot looks for it in the server.jar so returns a "not found exception")
I can remedy it by renaming my plugin file to plugin.zip, extracting the resources and all the library files that is packaged into it from the maven shade and putting them into server.jar but that seems more like a hack than a solution
Im creating an Skull and setting the owner to the player head I need
how can i change a blocks strength/hardness depending on the nbt
so you can only do that with blocks themselves
https://paste.md-5.net/elonuzogop.java can someone tell me how to save values to a specific file then tp the player to those values?
idk but after its broke "Player p = (Player) sender;" and "if(sender instanceof Player) {"
remove the Player p = .. and add change the instanceof Player to instanceof Player player now you can use the player var if its a player
might fix one
its don't work on java 8 :/
ah java 8
newer api best
how would I store values from an argument to a new file. I also need to check if they exist once they run the command to tp back to their home
[19:06:08] [Server thread/ERROR]: Error occurred while enabling CraftyCore v${version} (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "org.craftystudios.craftycore.getCommand(String)" is null
at org.craftystudios.craftycore.onEnable(craftycore.java:44) ~[CraftyCore-1.1-PRE.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
even better
oh im stupid
is there a way to add all commands into plugin.yml? like isnt it /<command>
commands:
cmd1:
cmd2:
you can add that for usage iirc
in the plugin yml? I want them all imputed into plugin.yml
you have to do them all manually
isnt there something like /<command>
why do people even use the plugin.yml for commands its so annoying
like i say about 5 messages ago, you can put that in the usage but you cannot put the commands in plugin.yml automatically
I gotch you bro gimme a second to grab some code
don't bother with the plugin.yml
do you just add the commands to the command map
https://paste.md-5.net/vayorecaci.cs There might be a few discrpencies I just created a static final version from my command api
but this is a gist and its much easier you just need to extend the BukkitCommand class
usually I just make some simple functions on top of it to make it nice and easy
^ just incase your curious as wel
Where would I put this
just put it in a Utility class if you have one otherwise main class works fine
than you use that to register your command make sure you don't do anything with commands in the plugin.yml
https://paste.md-5.net/axuxikuxuz.java sry but...
so really any class works?
or should I make a util class
I have a full utility class I'll show you its really poorly done so I reccomend making something yourself
but that code is good on a standalone?
yea, you still would need to extend the BukkitCommand class and make something yourself for that though
atleast iirc its been a while since I've used anything, but my own
never done that before lol
anyway one question, I have people type in a home name for /sethome, but I need to store their 1) home name in a seperate homes.yml file and then I need to 2) check if it exists to tp the player to the home
https://paste.md-5.net/axuxikuxuz.java can i get some help ?
no
I'm not going to help you
first off explain your problem then someone might want to help you
your just posting code who tf knows whats wrong
i don't think someone here is going to make the full plugin for you.
not asking that
seems pretty straightforward to me just get from the config FileConfiguration is stored all in memory
just do getStringList or whatever than teleport them
only problem is how would I test if it exists so i can return an error message
its null if it doesn't exist
also idk if your thing is going to work with my plugin because it has 30 errors lol
so detect if it is null then return the error
Well if you just copy paste it yea lol you need to format it to your uses
I just gave you an outline of what needs to be done
the rest is up to you
I would recommend learning java before writing minecraft plugins.
I think its fine if your able to figure shit out on your own if you need pushes in the right direction, incbom is clearly not completely lost
^ ik a bit
Yeah but it is kind of essential to have some knowledge about speficic things like saving data
I've never had a large java project outside of Spigot and never independently learned java than spi got
I learned java alongside spigot, while I don't necessarily reccomend this its something to keep yourself interested
It will take a lot more time
... ik how to save data to the config file, its the saving and writing new data to other files im a bit confused of as it is a whole different thing
who cares 🤷🏽♂️
set is able to write all data you need
FileConfiguration#set
than you need to save
The 100 people more you gotta ask for very simple help?
ik
if you don't save the data stays only in memory
yaml for data storage 
Or you learn how to use google lol
I learned google
That does not work for most people
im not aobut to intergate sql into my plugin yet
If you know how to google you are gucci with simple plugin dev
use json then lol
could use some good ol json
debateable, spigot and bukkit forums and stackoverflow
https://paste.md-5.net/axuxikuxuz.java
hi idk but i can't set my skullOwner
ill stick with yml, not much of a difference
Gson is integrated in the devenv of bukkit, I love using that
other than formating and some other junk idc about
exactly. quick and easy
That is not a good mind
why are you setting the meta twice
again your asking a quesiton, yet lack detail error? why can't you set it?
Sticking to things and not caring is very bad
whats happening versus whats intended
Sooner or later, you will see why
I stuck to yml for my first few months 🤷🏽♂️ its useful as hell for getting the ropes
guys can i use == as an equal?
i created a GUI and i hant a Skull in this GUI and set the skull owner to the player who sand the cmd
in some cases
or i need to put equal()
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Google your question before asking it:
https://www.google.com/
there are a trillion stack overflow threads explaining that
so
Uhm bro just because you started with some things does not mean it is good
== is used to compare class instances bassically
like it is exactly the same instance of the class
you can atleast do something
you migrate to better data storage structures later it works
^^
It works but is 10x worse and unefficient
not a good idea on strings
use #equals on Strings
Well you can but it is better to not do that
then how can i modify it
lol efficency doesn't matter if your doing something as a hobby
its a hobby
its about having fun and staying interested
i need to do this?
if (q1 #equals "animal" && q2 #equals "no")
as long as you don't go out selling your shitty code
i want to sell code
if(q1.equals("animal"))
If it should be case independent, use equalsIgnoreCase
should work
Yeah if it is fun for you doing bad things
ok ok ty epic
above that:
public File folder = plugin.getDataFolder();
public File file = new File("homes.yml");
public static YamlConfiguration homes = new YamlConfiguration();
onEnable():```java
if(!folder.exists()) {
folder.mkdir();
}
if(!file.exists()) {
file.mkdir
}
homes.load(file);
}```
is this a way to create a new file?
that file wont be in the plugin folder 😄
you'd create your homes file like
File file = new File(folder, "homes.yml");
^ this ensures its in the plugins folder
first argument is the folder
also accept lots of errors
folder +
not comma
Both works but it looks ugly imo lol
public File folder = plugin.getDataFolder(); "could not resolve symbol plugin"
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html here are the java docs for File
are you in your main class?
Now this hurts
yes
Inheritance in java or java inheritance with single, multilevel, hierarchical, java multiple inheritance and hybrid inheritance with example , parent class and subclass in java, java IS-A relationship.
should read this, but your main class is plugin
You can do Plugin#getDataFolder.toPath().resolve(fileName);
yea path api is very nice
facts
personally do it like this ussually
public static void createFileIfNotExists(Path path) throws IOException {
if (!Files.exists(path)) {
if (!Files.exists(path.getParent())) {
Files.createDirectory(path.getParent());
}
Files.createFile(path);
}
}
even though I barely use it lmao
doesnt explain why plugin is an error
Ofc it does
or anything of the sort with that
plugin isn't a variable defined
but im in main class
@tall dragon my code works ty again
Yes but you have not defined the plugin as a variable
So you cannot use a variable called plugin if you have not defined it
If you’re in your main class you have to use this, which would be the plugin variable you are trying to use basically
the object required is JavaPlugin your main class extends JavaPlugin the article sent explains what that means in particular
not with spigot, but in general java terms which can then be applied
Plugin plugin = this; so that
you don't need to define it because this is a JavaPlugin or Plugin
You don’t need to declare a plugin variable, just use this directly while in your JavaPlugin class
Should define the var for future uses tho
Not really
k, that also works to?
Yes
It is very common to get used, so that should be done
Do you mean as a static variable? I just use DI or JavaPlugin#getPlugin
file.mkdir()
You’re attempting to call a method, all methods have to have ()
k
try {
homes.load(file);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InvalidConfigurationException e) {
throw new RuntimeException(e);
}
}
would this be loading it?
I mean File::mkdir creates the file as a directory
because it was an error plainlybut adding that seems to fix it
you probably want to do it on the parent file if its a config file (which is presumably a directory)?
Conclure you’re upside down
Nobody knows, find it out yourself
You in Australia?
no just up late
how would i prevent the error message saying i need a class or an interface at the end
Incbom, how does your current code look like?
He always ask 💀
?paste
?
Not u
also this is probally not the discord to ask but my sentry.io intergation is not working, the import is wrong
file.mkdir();
Instead of this, you probably want to call file.createNewFile();
probably? 😄
since the former creates a directory/folder and not a file with the given file name
(mkdir written out means: make directory)
Damn I would love to continue coding rn but im sick as shit lol
Hi i try to dev a GUI with a Head in the GUI and the Plugins crash when a try it https://paste.md-5.net/atoramufex.java
so change
if(!file.exists()) {
file.mkdir();
}
to
if(!file.exists()) {
file.createNewFile();
}```
To begin with, yes (:
You can’t cast ItemMeta to SkullMeta unless the ItemStack is a skull
^ there’s no notion of a skull owner regarding glass pane items
yk why it is asking me to make a class or an interface at the bottom of the code?
Can you send a picture of it?
It looks like you may have an extra bracket on the bottom
🥲
still looks as thouhg it wants me to make a class or an interfase
or not
i love intellij idea's visual stuff
how would i send information to the newly created file (homes.yml)
Use Player#getName
This just calls toString on the Player object if you pass the object in the set name method
thx now i have a good name but not a good texture xD
HeadGMS.setOwner("Appolon_"); just don't work :/
skullmeta.setOwner
don't work :/
your setting the meta twice
SkullMeta HeadGMS = (SkullMeta) HeadG.getItemMeta();
HeadGMS.setOwner("Appolon_");
HeadGMS.setDisplayName("Your head's " + p.getDisplayName() +" ");
HeadG.setItemMeta(HeadGMS);
How can I load a custom YML file and edit it?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
don't work :/
use the load method
I already did it.
however thing is, you need to maintain a reference to it otherwise you will get the wrong reference to such and encounter NPE's
plugin.getCustomConfig().getString("<uuid>.x"); using this string, how would i specify the customconfig is homes.yml
Execuse me wtf
22: server = new File(Bukkit.getPluginManager().getPlugin("MobArena").getDataFolder() + "/server.yml");
26: server.createNewFile();
Console: java.io.IOException: The system cannot find the path specified (error at line 26)
fullcode:
public static void setupFiles() {
server = new File(Bukkit.getPluginManager().getPlugin("MobArena").getDataFolder() + "/server.yml");
users = new File(Bukkit.getPluginManager().getPlugin("MobArena").getDataFolder() + "/users.yml");
if (!server.exists()) {
try {
server.createNewFile();
users.createNewFile();
serverFile = YamlConfiguration.loadConfiguration(server);
usersFile = YamlConfiguration.loadConfiguration(users);
server().set("Game.State", "WAITING");
server().set("Game.Mode", "Normal");
server().set("Game.Players", 0);
server().set("Game.MaxPlayers", 24);
server().set("Game.MinPlayers", 16);
server().set("Game.InGame.Players", 0);
server().set("Game.InGame.Wave", 0);
server().set("Game.InGame.MaxWaves", 100);
save();
reload();
} catch(IOException e) {
e.printStackTrace();
}
}
serverFile = YamlConfiguration.loadConfiguration(server);
usersFile = YamlConfiguration.loadConfiguration(users);
}
'k i fixed it by making new folder lmao
how would i run a console command on a specific server w/ bungeecord
https://paste.helpch.at/lapavewipi.csharp
how would I get this to show seconds instead of miliseconds
By dividing by 1000
alr thx
uh divide what exactly ;- ;
Whatever quantity is in milliseconds
10000 - (System.currentTimeMillis() - cooldown.get(p.getUniqueId()))
Presumably
alr technically it's counting in seconds but it's starting from 10000 to 9990
Wdym
if (e.getItem().getItemMeta().equals(itemManager.ultimateSword().getItemMeta())) {
if (!cooldown.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldown.get(p.getUniqueId()) > 10000) {
cooldown.put(p.getUniqueId(), System.currentTimeMillis());
p.sendMessage(colorize("&aYou've used the Ultimate Ability!"));
p.getWorld().createExplosion(p.getLocation(), 15f);
} else {
p.sendMessage("You can't use this for another " + (10000 - (System.currentTimeMillis() - cooldown.get(p.getUniqueId())) / 1000) + " seconds!");
}
}```
Move the 1000 outside the )
alr thanks
is the nms source code good, like how well is minecraft written
tf do you mean by that
exactly what i said
Idk dictate that yourself decompile the server
No ones stopping you
If you feel mojangs code is so bad you'd be unwilling to use it there are an array of other projects trying to make minecraft servers better performance
Good enough
Define well written? Optimized? I mean it's seasoned java engineers so I imagine it's okay. Plenty of community optimizations make it seem like there are areas to work on.
Guys, is there a way to cancel PlayerMoveEvent without it kicking the player from a vehicle (Client Side)?
check if they're on a vehicle?
I do
There is a problem with that
Because I want to cancel the event but they just get kicked (client side) from the vehicle
Why not just freeze the entity they're riding in place?
Hello! I'm new in java, I'm following a tutorial on youtube about passing the plugin instance to another class. I made a getter to access it from my other classes (https://prnt.sc/SuIayrxwQGla) but It's not working for some reason (https://prnt.sc/jefZbNATv5Sx), I also searched google but didnt found anything I was looking for.
I can try that
Show your package structure.
Try declaring a variable and assigning it that value.
In config manager?
I'm pretty sure the error is because you're calling a method in your class file which you cannot do
ah yes, I was following a tutorial tho
A YT tutorial?
yeah, about passing the plugin instance
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Okay, I'll research about it some more
Send me the tutorial lol. I'm curious
here or in dm?
you should be able to send it here
Holy crap a 9m video for a 2m concept
I'm actually a js developer so I get confused when someone says Variables lol
and I'm very new to java still learning
Sadly you had to learn from Kody 
No other series exists
Btw since you saw it, I did the same thing as he did with static getter method
Yes, but you're using it wrongly. Unlike JS you can't just call a method within a class unless you're inside a function or assigning it to a variable.
There is a way around this but you should never be using it.
ah.. yeah thats confusing XD
It'll take some getting used to.
Careful with Kody tutorials. I've heard a lot of bad practice exists within them.
Spigot youtube videos always have bad practices
Its not just kody, every YouTube tutorial shows you the easy way, the challenge is when you try to apply it to your own project
But I have no idea where I can get a headstart so I'm just watching the topics I'm confused about. I just download public plugins and read their decompiled code
Jumping headfirst into plugin development is generally rough because the tutorials don't teach you how to apply your learning they show you a very linear example.
yeah
so any suggestion about how can I pass the instance so I can use it in my other classes? Just tell me the way I can do it, You dont need to spoonfeed me XD
figuring it out myself would be best because I'll learn it in a way
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?di is probably the best tutorial atm. I've been working on my own text based tutorials. Still a heavy WiP
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
okay thanks!
Offtopic: I cant change my spigotmc username?
Not unless you pay.
where do I pay?
Idk tbh never considered it.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
?changename
Name changes on the forums are granted to those who have donated to the project. Donations are processed manually and generally take up to 24 hours. The donation widget can be found on the home page of SpigotMC at: https://www.spigotmc.org/.
10$ I believe
uh okay, I don't really need it. Its just I changed my ign thats why
The biggest problem I have with Kody is so many of his videos are things you should know how to do without his help. He never teaches how to learn by yourself just looking at the titles. Maybe he does but it doesn't seem like it from his titles
Yeah many videos are just spoon feeding code
Well it's not just him. I had to learn js from a paid course to understand it
I'm not a pro but I'm decent
Yeah, Kody isn't teaching java from what I've watched. It's a lot of follow along stuff but not teaching what you need to survive
yeah thats true
You don't have to pay there are plenty of free guides
I'm a guy who needs pressure
In the course we had given assignments every few days
I learned java from scratch by trying to build applications I did in other languages. Same way I've been learning Rust
Lots of text tutorials
Learn concepts not how to make a fly plugin.
but its really hard to survive in that market
I recently started using Vue. I found it much easier to work with than react
ah
Learn to read this and you'll be less likely to ever need to ask a question
🫡
hey, I recently added MockBukkit tests to my plugin, but now I get this error in my kotlin file, what do I do?
i am sure that this is due to mockbukkit (removing it fixes the error)
and well
to me that looks as if your checking if XMaterial is equal to Material
nope, I parse the material at the end of the evaluation
and this is irrelevant to the error anyway
just to clarify, this method works perfectly, but mockbukkit seems to do some dependency conflicts
How can I do a players NameTag invisible ?
how can i send a message as another player
from code
nvm i think i found it
Player#chat(String)
hope that works with formatting and shit
iirc it does
BRO
why is it not excluding the fastutil
ive tried with the dependency too
instead of the package
doesnt the exclude need to be on the real dependency
didnt work either
oh wait maybe i need to do /**
YES
it worked
now my jar isnt 25 fucking megabytes anymore lmao
add minimize() on shadow jar
it took like 30 seconds to upload through FTP every time lol
30 secs to upload 25mb??
bruh wtf thats like 100 kb/s or smth
bro
thats 33 kb/s
it builds so much faster as well
holy shit
reobfJar had to go through 25 mbevery time
makes sense why it took like 20 secs now
hey, I recently added MockBukkit tests to my plugin, but now I get this error in my kotlin file, what do I do?
an XMaterial cannot equals a Material?
.parseMaterial
the function worked perfectly, but I now added MockBukkit and now there's an IDE error
I've done research and none of the solution worked for me
the more time goes forward the more I feel like I'm working backwards
I'm now adding cuboids to my plugin, it's weird to add such a basic shape after all these years of making this plugin
worst tabcomplete i wrote in history
Hi, I have a class in my program that only has static methods
the class is not meant to be instantiated
how can I force this?
Like, make so you cannot instantiate It?
I heard you could declare the class as private
but won't this make all my methods private?
InventoryMoveItemEvent?
Called when some entity or block (e.g. hopper) tries to move items directly from one inventory to another.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryMoveItemEvent.html
declaration: package: org.bukkit.event.inventory, class: InventoryMoveItemEvent
make a private constructor
Inventory
getDestination()
Gets the Inventory that the ItemStack is being put into
Hi how i can clear the chat of my player :/
i seem to have fucked some things up
oh right when i reset my server it doesnt reset the mongodb cluster
wondering if its possible to store my mongodb data locally
plugin.getCustomConfig().getString("<uuid>.x"); using this string, how would i specify the customconfig is homes.yml
by reading https://www.spigotmc.org/wiki/config-files/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
more specially
private void createCustomConfig() {
customConfigFile = new File(getDataFolder(), "custom.yml");
if (!customConfigFile.exists()) {
customConfigFile.getParentFile().mkdirs();
saveResource("custom.yml", false);
}
customConfig = new YamlConfiguration();
try {
customConfig.load(customConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
/* User Edit:
Instead of the above Try/Catch, you can also use
YamlConfiguration.loadConfiguration(customConfigFile)
*/
}
I read that but there is nothing specifying what config file
Ok Ty
why not YamlConfiguration.loadConfiguration(customConfigFile)
broadcast empty line multiple times...
best fix
not sure on what the difference would be except maybe preference
well, in that case they are free to use what they deem fitting and not what you prefer o.O
conclure does :: too 
and ye its just preference
need a new fancy color to display instead of this
just looking for a static hex color ig
#733bfb
color picker
colour picker is okay
i have a program on my pc where i can pick any color on my screen
hmm i forgot but how can i cancel clicks which move an item from the player inv to the top inv?
got this rn
ig put the event.setCancelled in front of the guiitem
fanboy
bruh im trying everything to disable those useless mongodb logs but nothing seems to be working
Level.OFF doesnt work either
how can i use sql in a simple way?
i only know java
its super simple
i'm suffering
you sure the loggers are in this class?
Its a declarative language, what are you trying to do?
on which bit
wdym? whether those are the correct logger? idk i found those answers on stackoverflow
im disabling the logging right before i instantiate anyy mongodb thing
read the description LOL
hahaha
XD
lmfao
try SEVERE
@tardy deltaand with logback? not the best option....
from what i'm getting
FROM
SELECT
IS NOT NULL
INSERT
WHERE
all that string confusion
💀
INSERT INTO whatever (columns..) VALUES (values..)
check w3schools :)
@round finch https://www.w3schools.com/sql/default.asp
so? just do UUID#toString lul
and postgress (?
viewing it agein! thanks :))
i gotta figure out that table stuff
XD i use for a BOT.. not very problems with this..
but require a little "magic" for some types
PGobject
yeah... its very old but was the only form to handle correctly the UUID to a table with UUID
in this time.. i dont check again.. but works then..
XD
Anyone have any idea why it's not letting me open other gui on click?
Already tried that
No, you can open inventories while in another inventory, Even though the docs say it's not recommend, it will work just fine.
In your config, does that path have a color coded string?
If so, you need to translate the color codes.
and itemmeta strings
Yes but i have translated
You're right but it still should work
For testing purposes yes, it will work.
However, you should consider a better approach before you publish it.
You should put some debug messages in your code to see if your if statements are even being reached.
I am trying debugs now
Ah yeah gets stuck at t3
Is there anything wrong with the if statement to get the config?
ChatColor.stripColor is a thing too
Your path is wrong. You need to have a path of ArmorSets.inventory.items.<ITEM NUMBER>.name
ahh kk
Hey so I am trying to make https://github.com/Chopkeys/FreezeGUI compatible with 1.16.5 onwards (As I originally made it in 1.16.5), I have looked up a bunch of stuff but nothing is clear and concise and makes sense. Is there any pages anyone knows of or any tutorials that will make more sense?
As for improving your code. I'd recommend two things.
1st: Switching your item name checks to PDC checks.
The PDC was introduced in 1.14. It gives you unparalleled flexibility with your GUIs. You don't have to check for slot numbers, you don't have to worry about outdated tags, you don't have to rely on item names, it's all treated as nbt data. You'll be able to put the items anywhere in the GUI and have the click events work the same regardless of slot number. It's a worthwhile upgrade.
2nd: Comparing inventory instances instead of inventory names.
This is to prevent people from renaming items with color codes and getting access to your inventories. Plenty of exploits exist rely on developers to compare names instead of instances.
if I put a block on a players head with curse of binding, they'll still be able to take it off right? as in the curse won't do anything?
how would I make the player unable to remove the block from their head?
just cancel the event when they take it off?
Well it looks like you are using methods from the API so it should be forwards compatible. Unless minecraft has another major update that breaks the api, like the 1.12 to 1.13 transition did, then you'll be fine for the most part.
The only time your plugin would become incompatible with other versions is if you are using version specific code. Otherwise known as NMS.
Hmmm ok, so I tried running it on a 1.17 server and the commands didn't come up, any ideas?
the name can be a issue.. maybe can be better set an internal id and check this.. (like using PersistentDataContainer from itemmeta)
any errors? did you register it in the plugin.yml? did you set the executor in your main class?
Hmm, I'm not sure off the top of my head because your code looks fine.
I think it may have said something about the YML not being in the .jar
Well that would def be a problem. lol
lmao
What are you using to compile? Maven I presume?
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
he has the resources folder, however just make sure your compiling with maven
not your IDE as it ignores maven completely
Yeah i will eventually
How to add enchants to config for items in gui anyone?
Now my file isn't compiling :/
Lmaoo
Am I missing something it was just working
gross intellij. Anyways it looks fine
what is the error?
It is the exact same from the GH
How are you trying to run the maven commands?
Command line?
Not sure what you mean
what are you duing doing for compile?
You should be using the panel on the right side of the IDE.
Unless you specify a default goal, but I do not know how it works
default goals are pretty easy
Oh thanks, which one should I do?
Yeah, but I don't think that the default goals are actually executed by default
Slap it at the top of your build, then press the green button.
Not by default no, but once they are in the pom, and you select it, it'll use them.
hey there, I decided to convert one of my utils' class to Kotlin for convenience, but I'm getting this error now (look at the attachment)
the method worked fine in the past, but it's an incompatibility with MockBukkit (I verified, removing MockBukkit fixes the error)
if anyone who's experienced in Kotlin could help me I'd greatly appreciate it 🙂
You'll want to clean then package.
Actually, they seem to get executed - whatever.
Thanks!
You should setup a default goal so that you just have to click the green button at the top and it'll do the steps for you.
<build>
<defaultGoal>clean package</defaultGoal>
...
</build>
You may not have as many modules as I have, but you just need to select the name of your module then press the green button.
the struggle of NMS
Nothing but sometimes.
Alternatively, just build the parent project
In my code I listen on the PlayerJoinEvent, however whenever it actually happens this error occurs -> https://paste.md-5.net/yutesimija.cs
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "java.util.HashMap.get(Object)" is null
at freezegui.freezegui.events.EventsHandler.onRejoinIfFrozen(EventsHandler.java:56) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
... 15 more
explains it pretty well
assign it to a Boolean
boolean b = map.get(whatever) calls Boolean.booleanValue() internally
ah
cuz a boolean cannot be null, a Boolean can
So just do if (FreeCommand.hm.get(p) != Boolean.TRUE) return;
welp thats a way too
forgot Boolean.TRUE and FALSE existed
That works
How to add enchants to config?
I forget the wrapper classes exist all the time. I hardly have a reason to use them.
Also, it's only displaying boots in my gui now?
It was literally working a minute ago before i tried adding enchants...
Are you wanting to just add the glow effect? Because if so, you don't need to put them in the config.
Just put the enchantment on the item, then modify your item meta.
No, i need enchants on them
[geolykt@fedora new]$ rm -f Test.java && echo "class Test {public static void main(String[] args) {Object o = null; Boolean b = (Boolean) o; if (b != true) return; System.out.println(b);}}" >> Test.java && javac Test.java && java Test
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because "<local2>" is null
at Test.main(Test.java:1)
Yep, still NPEs
How would I put this item into the middle of the inventory
That's because objects can be null. Primitives cannot.
setItem
it calls null.booleanValue()?
I know that, just wanted to be sure
Yeah, if you do any operation (as in +, -, ==, etc) with a primitive, both values will be unboxed to a primitive if applicable
mmh
That ofc won't apply if none are primitive, hence
rm -f Test.java && echo "class Test {public static void main(String[] args) {Object o = null; Boolean b = (Boolean) o; if (b != Boolean.TRUE) return; System.out.println(b);}}" >> Test.java && javac Test.java && java Test
Will run
Then you're going to need to a resolver of some sorts. You could probably just store the name of the enchantment and use the namespaced key to convert it to a proper Enchantment object
That would call new Boolean(true).booleanValue() == true, hence returning true
yep does
On the other hand new Boolean(true) == Boolean.TRUE should return false
Why?
yep
It looks like it should be true in that case.
Hence new Integer(), new Boolean(), etc are deprecated for removal
As they make little sense due to the contract of new
Can anyone tell me why it's just showing the boots???
hmm makes sense now, i always thought Boolean.valueOf called the Boolean constructor
Nah, Boolean.valueOf() is more sane there
Same with Integer#valueOf - it will default to the internal cache of integers for certain values
You have an extra . in your path when you set the slot.
damn theres even an entire IntegerCache class
there is?
Yep
another class to explore 
Although most of the magic behind that class are in the JVM itself
change the bounds 
dunno how you would benefit from that
As those are static final you cannot do that easily
Hey guys c; how can I save an arraylist of objects in a yml file so that when server reloads those objects are still in the array
c;
is it even possible to access those with reflection?
Just push the arraylist in that yaml configuration
Unsafe::putInt maybe
Access? Probably. Modify? Unlikely
altho youd still need the field
Like if I were using a variable in the yml?
sun.misc.Unsafe does work though - I have done something similar when setting the internal bukkit unsafe in my hackloader
I've shown it once before I think, it's just a little hack to modify slimefun at runtime without tripping any anti-malware plugins
:o
(It won't trip any anti-malware plugins since I am pretty sure that I am the first to abuse the processClass method)
is it OS
hacky stuff
now i understand why writing a plugin in bytecode would be easy for you ;-;
cool thing tho
im not, cause i dont hate myself
my life is already fucked up
there isn't that much to learn. If you know java, you will get behind JVM bytecode pretty fast
Hey guys How can I detect item dropped on inventory? (Like Item Move to the other Inventory)
I believe you need to first listen for the item being taken and then list for the item being inserted I fear
Is it possible to stop specific structures from generating? Like if I wanted to stop strongholds from spawning, is that possible?
The Item is air, sometimes bukkit returns null instead of an empty itemstack
You shouldn't ignore nullabillity - although I guess you shouldn't use nullabillity when using spigot as the nullabillity documentation is rather lackluster under spigot
So how would I fix this? My brain is quite frazzled as I have been at this for a while lmao
Did you register the event?
if (e.getCurrentItem() != null && eetc eetc etc)
Do you know what the event is used for?
Because in 90% of cases you misunderstood it, and would need to read the documentation again
It's for hoppers n dispensers type deal
Smh, spoiled the fun part

hey there, I decided to convert one of my utils' class to Kotlin for convenience, but I'm getting this error now (look at the attachment)
the method worked fine in the past, but it's an incompatibility with MockBukkit (I verified, removing MockBukkit fixes the error)
if anyone who's experienced in Kotlin could help me I'd greatly appreciate it 🙂
Hi sry but how can i detect when a player join a world ?
declaration: package: org.bukkit.event.player, class: PlayerChangedWorldEvent
Hello! I'm trying to make a plugin but my Spigot server doesn't seem to detect it (showing 0 plugins in-game). The jar is in the plugins folder and the plugin.yml is in the base folder of the jar. Any ideas what's wrong?
send errors that appear in console
i am so dumb i didn't see that it showed an error
don't be ashamed, we all began somewhere
by the way, do you know java or are you just starting?
[12:51:20 ERROR]: Could not load 'plugins\MninPlugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `mnin.MninPlugin;'
at --snip--
and I know java
wait
show you plugin structure
oh my god i just put a ; in my yaml
lmao F
for the main is it supposed to be the file or the class?
like if my package is pkg and my main plugin class is MainPlugin in a file named plug, is main going to be pkg.plug or pkg.plug.MainPlugin
if you are using intellij, install the Minecraft Development plugin and let it handle the creation of your structure
i'm using eclipse
the class that extends JavaPlugin is what you should use
so it would be the latter
that is basically the structure of my project right now (not with those names; plug and MainPlugin map to the same name in mine)
so you have your main class inside of a file with another name?
and i updated my plugin.yml and it's still complaining that it can't find it
w hy
no i'm saying that they have the same name, i was just using different names to clarify what to put in the plugin.yml
the real name is mnin.MninPlugin.MninPlugin
so for the other example it would be pkg.plug?
does plug extend JavaPlugin?
here's an example from my plugin
plugin.yml: com.roughlyunderscore.enchs.UnderscoreEnchants
i just dmed you the filestructure
the main class is in MninPlugin.java
i got it working with mnin.MninPlugin in the plugin.yml
Guys, does anyone has a link or a youtube video where they explain how to save an arraylist of objects so that it's gonna keep its data even if server reloads
I've been looking for a way but can't find what I'm looking for
thank you
you meen persistent data storing?
probably convert it to json, save it to a file onDisable, then read it in onEnable
Yes, It's an arraylist of homes (home class) and I need to store it
I was going to commit to GH but this popped up, should I worry or is it fine?
?pdc then
well, there are multiple ways, but pdc or file
I know it is errors and I know it'll keep going tho
also uh ```java
package mnin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.Bukkit;
public class MninPlugin extends JavaPlugin {
// Fired when plugin is first enabled
@Override
public void onEnable() {
Bukkit.broadcastMessage("Hello, world!");
}
// Fired when plugin is disabled
@Override
public void onDisable() {
}
}
Convert the arraylist to json?
don't do that


