#help-development
1 messages · Page 1642 of 1
I just need to ask in case you are stupid, you are reloading/restarting the server right?
Does anyone know how I can make an itemstack where the item (say a wooden pickaxe) has the nbt tag "canBreak ___" in spigot?
search spigot nbt api
Google your question before asking it:
https://www.google.com/
I did, like for the past like hour
and I couldn't find anything, so I thought I'd ask
I found it 1st result
I doubt that (first result) https://www.spigotmc.org/threads/tutorial-the-complete-guide-to-itemstack-nbttags-attributes.131458/
Clearly it does
lmao
Hey, I used to follow a tutorial that used
onCommand(I dont remember this part){
if(label.equalsIgnoreCase("mycommand")){
// do something
}
}
After learning some other things non spigot related I wonder if this is the right way to write the code for a command (i.e. the right way when talking about api docs), can someone confirm? (:
correct
no
setting the command executor removes that if statement
getCommand("hi").setExecutor(new MyCommand());
Glad that was you first result, my many results led me down this rabbit hole:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/ItemStack.html
https://www.spigotmc.org/threads/play-effect-block-break-with-itemstack.382802/
https://bukkit.org/threads/setting-item-durability.351123/
https://hypixel.net/threads/bukkit-spigot-adding-and-checking-for-nbt-tags-on-items.383877/
... and more
(a list of a few of my tabs so far)
I was about to ask that lol
codedred right?
then MyCommand()is what the command is gonna do?
next time search "x spigot"
yup lol
he promotes bad practices and shit code
youtube videos are a shit way to learn
Thanks for tip, that is not what i searched, I don't remember exactly, but it was something along the lines of "spigot java x"
Yeah, for what I've read/learnt/everything tutorials are bad bc of bad practices and other stuff
youtube videos teaches bad practice they are a lot of the times outdated and they usually don't even know what they are doing.
I was new to coding overall when I saw those vids so I didn't know how to read docs at all lol
using docs and google is the only option
mhm, they also have their own coding style and other stuff which is personal but try to teach as a lesson sometimes
change api in yml to 1.17
then you have a startup error
the latest api is for 1.17 (but works for 1.17.1)
major.minor
When making a command this way how do I pass the same args used in onCommand()?
I mean... how'd I get the sender and that stuff? ||(again... I'm kinda rusty so I don't remember how it worked hehe)||
? what imagine provided just makes the command execute that, you don't need to provide arguments there.
/command(hello) args(..)
the arguments is not the command (if I understand you correctly)
Then how'd the MyCommand method be written to get the sender and args?
if I make the command "hi <x>" respond with x I just pass "hi" in getcommand
I mean...
when you use onCommand() you get the (label, sender, args, etc) stuff, how do I code that part when using .setExecutor(new MyCommand());?
not the arguments
what are you talking about?
aaaaaa
I'm just trying to figure how to get the sender and args lol
oh wait
MyCommand() is a class which extends something to get all the args and stuff??
Command
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
sender.sendMessage(args[0]);
}
Main
this.getCommand("command").setExecutor(new ClassName());
that is an example of how it would look
yeah but where is that ReloadConfig() part? xd
I just don't completely understand that, but I think ReloadConfig() is a class and the onCommand() is inside that class?
that kinda sounds like an enemy more than a friend hehe
the class
so yeah... that's the class and the onCommand() is inside that class?
yes.. methods goes in classes..
yeah... I was used to do onCommand() inside my main class, that's why I was confused lol
that will make your main file gigantic and a mess, don't do that.
how do you even manage that? skript is like plaing english.
no
just use getCommand()
getCommand().setExecutor() will execute the command
Yeah that's why I'm asking all of this hahaha
use this for your commands
what are you on?
just set the executor in main and make aliases in plugin.yml
you don't need some custom command handler
/ConstantConditions/
I don't know how to work with configs that well
How would I write a hash map to the config
ConfigSections work similar to hash maps in theory
Using bukkit serialization...
Map.entrySet().forEach(entry -> {
String s = entry.getKey();
Location l = entry.getValue();
config.set(s, l);
});
saveConfig();
A bit cleaner but more methods to make your own seralization.
// Save to config
public Location stringToLocation(String s) {
String[] data = s.split(",");
if(data.length < 4) return null;
Location loc = new Location(Bukkit.getWorld(data[0]), Double.valueOf(data[1]), Double.valueOf(data[2]), Double.valueOf(data[3]));
if(data.length == 5)
loc.setYaw(Float.valueOf(data[4]));
if(data.length == 6)
loc.setPitch(Float.valueOf(data[5]));
return loc;
}
public String locationToString(Location l) {
return l.getWorld().getName()+","+l.getX()+","+l.getY()+","+l.getZ()+","+l.getYaw()+","+l.getPitch();
}
Map.entrySet().forEach(entry -> {
String s = entry.getKey();
config.set(s, locationToString(entry.getValue()));
});
saveConfig()
// get from config...
ConfigurationSection cs = YamlConfiguration.getConfigurationSection("");
cs.getKeys(false).forEach(path -> map.put(path, stringToLocation(cs.getString(path))));
private final Map<String, Integer> data = new HashMap<>();
public void deserialize(FileConfiguration configuration) {
ConfigurationSection section = configuration.getConfigurationSection("data");
if(section != null) {
for(String key : section.getKeys(false)) {
data.put(key, configuration.getInt("data." + key));
}
}
}
public void serialize(FileConfiguration configuration) {
for(Map.Entry<String, Integer> entry : data.entrySet()) {
configuration.set("data." + entry.getKey(), entry.getValue());
}
// Save Config here with (saveConfig() or custom config)
}
``` Simpler example
read the top half of my message lol
Would a 1.15 plugin coding tutorial work for 1.16
Or are there major differences between the two versions
Thanks, i'll try it
public Location deserialize(ConfigurationSection cs, String path) {
if (cs.getLocation(path) != null) {
return cs.getLocation(path);
}
return new Location(
cs.getInt(path + ".x"),
cs.getInt(path + ".y"),
cs.getInt(path + ".z")
);
}
Shouldn't be any different besides added nether materials
What abt 1,17
No world?
I've seen no difference aside from needing to change to java 16 to run the server
ConfigurationSection cs = ConfigurationSection.get("locations"); Non-static method 'get(java.lang.String)' cannot be referenced from a static context
The api is generally made to support older and newer versions tho with that being said there’s no guarantee
ConfigurationSection cs = YamlConfiguration.getConfigurationSection("") change yamlconfig to what ever your yaml variable is.
don’t watch YouTube tutorials
So what do u suggest
docs and google
You get it from a FileConfiguration
I was just gonna use codedreds 1.15 vids as an intro and use my Java class in school to continue it
I’d argue for that YouTube tutorials can be good as they might show a concrete way of addressing a problem however 99% of the YouTube tutorials miss a good solid code architecture, so yeah rather just understand the concept than copy pasting.
Wait... is that a capitalized Variable...
Depends what he is using... He might be using YamlConfiguration he might be using FileConfiguration
definitely not him
He teaches bad practice just like imagine said
Like I said earlier
youtube videos teaches bad practice they are a lot of the times outdated and they usually don't even know what they are doing. +they take more time to follow
@ionic dagger do you have Java experience which is not directly derived from spigot related sources?
so from what i'm understanding, this goes into onEnable() ```java
hash.entrySet().forEach(entry -> {
String s = entry.getKey();
getConfig().set(s, locationToString(entry.getValue()));
});
saveConfig();
// get from config...
ConfigurationSection cs = getConfig().getConfigurationSection("locations");
Objects.requireNonNull(cs).getKeys(false).forEach(path -> hash.put(path, stringToLocation(Objects.requireNonNull(cs.getString(path)))));
hash.entrySet().forEach(entry -> {
String s = entry.getKey();
Location l = entry.getValue();
getConfig().set(s, l);
});```
thanks for blocking my view 
Only need
ConfigurationSection cs = getConfig().getConfigurationSection("locations");
cs.getKeys(false).forEach(path -> hash.put(path, stringToLocation(cs.getString(path))));
``` in onEnable because thats when you're loading from the config.
Make sure to read my message cause it looks like you just copied and pasted everything lol
I took an intro to Java last year, and before that I was doin vbnet and py
There are 2 different ways of loading and saving data in that message.
Interesting, what level are you at would you say?
For Java? Not too high, I forgot most of it since I went back to py over the summer
I don't like python
Me neither
It was weird to me
My teacher taught it weird
But do you have any links then for any docs or really anything I can use instead of the videos
Universities are just bad at teaching programming languages.
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.
Thank you
How would one make a message hoverable/clickable in chat? java player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&r &e* &bUser Agreement"));
Anyone know if there is a way to disable the world loading messages in console? Like Bukkit.getWorld("WorldName", boolean displayMessages) (just example usage)
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I copied over the method approach, do I put locationtostring where I want to add the location?
yes
you can always catch sysout
hacky, but works
was hoping not to have to.
it calls server.getWorld() But I'm only finding the interface class of Server
Check CraftServer in CraftBukkit
Yeah checking it
Im getting this error at
player.setPlayerListHeaderFooter(String.valueOf(new ComponentBuilder(bleepo.parseText(player, head.toString())).create()), new ComponentBuilder(bleepo.parseText(player, footer.toString())).toString());
And Im not sure why. anyone know?
private final Map<String, World> worlds;
public World getWorld(String name) {
Validate.notNull(name, "Name cannot be null");
return (World)this.worlds.get(name.toLowerCase(Locale.ENGLISH));
}
```Not seeing where it creates a world from `Bukkit.getWorld(String)`
No I'm saying that method doesn't create a world... so I think I'm missing something...
All I found was
Bukkit.getWorld(String) -> server.getWorld(String) -> (World)this.worlds.get(name.toLowerCase(Locale.ENGLISH));
Where is the world created if its not cached?
one more question, do I put this also where I want to define the location? I did that and it only spawns items 1 gen at a time.
hash.entrySet().forEach(entry -> {
String s = entry.getKey();
Location l = entry.getValue();
getConfig().set(s, l);
});```
you should put it in onDisable
but modify it to use the correct methods.
alright, config still looking like this ```yaml
locations: {}
if you are using the code above its because you are not setting it to locations path.
I did here java ConfigurationSection cs = getConfig().getConfigurationSection("locations");
public void onDisable() {
hash.entrySet().forEach(entry -> {
String s = entry.getKey();
Location l = entry.getValue();
getConfig().set("locations."+s, locationToString(l));
});
saveConfig();
}
TextComponent user_agreement = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&r &e* &bUser Agreement"));
user_agreement.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://bit.ly/halara-rules"));
user_agreement.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to view the User Agreement.")));
``` I apologize in advance I'm very new to this but I have no idea what i'm doing wrong here. No errors and the text simply does not appear in chat.
Where is the rest?
I didnt send it to the user did i
Sending the message etc...
I sure did apologize in advance lol thank you that solved it
👍
Any ideas? #help-development message
Are you trying to create a world?
Yo yapperyapps you got any clue?
Can you rephrase?
Yeah I'm creating a world using Bukkit.getWorld() but based on the code I can't find where it actually creates the world.
WordCreator
As yes, love the WordCreator class 
java.lang.NoSuchMethodError: 'void org.bukkit.entity.Player.setPlayerListHeaderFooter(java.lang.String, java.lang.String)'
Yeah I checked there but as I look through Bukkit.getWorld() it only calls what I show in that message...
Bukkit.getWorld(String) -> server.getWorld(String) -> (World)this.worlds.get(name.toLowerCase(Locale.ENGLISH));
So where does it get called from??? thats what I am looking for lol
it?
sigh If I run Bukkit.getWorld(String) it runs return server.getWorld(String) and that returns return (World)this.worlds.get(name.toLowerCase(Locale.ENGLISH)); but no where through these methods is WorldCreator called
No
It’s a getter
Not a loader
Not a command method
Not a creator
It is just querying the map
WorldCreator has the logic of adding stuff to the map
A function should only do one thing
whats the problem
Ok.................................. IDK how else to explain the question...
If I run Bukkit.getWorld(String) where in the fuck is it calling WorldCreator because thats what I want to access to see if I can tell it not to send the world creation messages.
It’s not calling WorldCreator
Exactly!
That’s done somewhere completely else
Exactly!!!!!
So fucking where is it being ran!
During the bootstrap process?
Is it accessible via the api or would I have to find my own way?
If this is the case might as well just remove from syst out
Wym by accessible? There’s a maximum of three worlds that loads everytime the server bootstraps which is the default ones. iirc they’re loaded in CraftServer or if it was MinecraftServer or one of its derivatives. I don’t know where exactly because it goes extremely deep down. However the worlds are loaded at the time your JavaPlugin::onEnable is invoked if that’s what you mean by accessible.
I load a world via Bukkit.getWorld(String) that causes the console to output the world settings... I don't want the world settings to show in console
like for what you need to even do this
not need, want.
no like whats the pupurpose
What’s the map implementation of that Map<String,World> worlds field
Was hoping I didn't have to listen to system out to clear it. Its purpose is because I don't want to see it ever time I start my server every 10 seconds.
You could try log4j filter
Oh at the start
you can always disable it in bukkit.yml
That’s not the implementation
That’s the field
Anyways imaginedev probably got your answer
Where?
Not seeing any paths relevant to logged world settings
Ive tried everything that i thought may be wrong, And i still havent fixed it
i think its like debug-log: false
Is the server version the same as you compile against
@stone sinew when you're not busy, I am still in need of help here, I don't know how to save the locations to the config and the config only contains locations: {} https://paste.md-5.net/nivebasawa.java
Thanks for all of your help so far though.
Why do you keep adding Objects.requireNonNull(?
to stop a nullpointerexception
It doesn’t stop it
^^^
It just re throws it actually despite the name
And since you are looping through the entry set it wouldn't be null unless you somehow added a null
nullableValue;
if nullableValue == null: throw NPE
ok
Also you are saving the config loading the hashmap then saving again, then loading the config....
And you are always copying defaults in your loadConfig
spigot.yml, server.properties and bukkit.yml all have any "debug" paths as false.
ok now I save it after, i removed the extra saveConfig();
You are reading from a config you don't need to save it in onEnable (Unless you are loading its defaults)
ok
public void onEnable() {
ConfigurationSection cs = getConfig().getConfigurationSection("locations");
cs.getKeys(false).forEach(path -> hash.put(path, stringToLocation(cs.getString(path))));
}
public void onDisable() {
hash.entrySet().forEach(entry -> getConfig().set("locations."+entry.getKey(), locationToString(entry.getValue())));
saveConfig();
}
I edited my message. You don't use "locations." in cs.getString() because its already in the configurationsection
nothing is going into the config now
same thing ```yaml
locations: {}
Let me see your updated code
You are still copying defaults and then saving the config... you need to check if they are set already
You just need to do saveDefaultConfig(); before you load anything.
I did that
nothing is in the config now
So I'm having a really weird issue with a resource pack. I'm generating all the JSON files and such in code for the pack, and then zipping it and it can be immediately applied, or atleast in concept.
Although something seems to go really wrong when I zip it. It just will not apply the textures properly right out of the box. If I unzip the generated zip, everything works flawlessly, and if I re-zip the folder using just the standard Windows Send To ->, it still works.
I also know that Minecraft is able to atleast open the generated zip file, since it can still apply it, and the pack.png is properly set.
The zipped file sizes between the Generated and Windows are different too, with the only difference being that one of the JSON files is slightly larger in the Windows zipped folder.
This is how I'm zipping the resources https://paste.md-5.net/cugiduxava.java
actually I got this ```yaml
locations: {}
Is your map empty...?
Once you save it?
locations: {} normally means that yaml is aware that is is a collection of some sort.
How do i check if a player has armor on
how can I replace an object with another one for a few seconds when clicked in the GUI?
Does anyone recommend using Guava Cache or is it quite hefty for Minecraft Servers?
I would rather have a simple library or class that can handle cache efficiently.
I would recommend Caffeine instead. Its from the guy that wrote the cache stuff for guava.
If you know what you are doing then such a cache can really help with the reactiveness of your
database access.
Yeah just whenever I want to access my cache I was entries that are older than 5 minutes to be cleared.
Thats a really short period for a cache...
Yeah I am doing pagination for an inventory.
What would you recommend normal periods to be?
Depends a bit on the data you want to cache and how high your request frequency is. But for offline player data i would go for at least 45 - 60m
Usually you want to keep most of your data in your cache. Only really old data that doesnt get accessed anymore should be kept out of it.
Even if you keep data of 10k users in cache, its size probably wont exceed 50 - 100MB. And who hasnt that much memory to spare.
Get his Equipment and check if every entry is null
Using a scheduler that replaces the object later again.
Re-install mcdev
I have did the following things :-
- Restarted intellij
- reinstalled intellij and all plugins
- Restarted my pc
nothing helps :<
am gonna die fixing it
help save my life
The minecraft versions are retrieved via the internet. Maybe you have a firewall that blocks the fetching of those versions.
this?
idk. Some firewall.
Disable your firewalls for a min and then re-try
ok
Also if you can get a grasp of the error somehow then we know for sure.
Try getting us the error. There must be a log somewhere.
Cant find anything
Did you find the log?
no
Do you have a project named Heart2 ?
Because this one causes a ton of errors.
yeah
Delete it from your IDEs view and copy the folder somewhere else.
Umm the website is not working properly, I just posted an update for my plugin and its not showing it and when I download its downloading older version.
how can I stop the scheduler after replacing the item?
Just schedule it once. runTaskLater()
how can this be done? and if I use the replacement again, will it work?
@Override
public void onEnable() {
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()){
LOG.info(player.getName());
}
}
}.runTaskTimer(this, 0L, 20L);
}
}
Why doesn't this runnable run? (i feel theres a super stupid mistake, I barely understand runnables)
Also this runnable is in my main classs
Try waiting 1 tick
whats an efficient way of checking when a player enters an area? I've thought of like on move, check if they're in an area but theres probably more efficient ways right?
If your check is really fast then on move is fine. If you plan on supporting a lot of players and willing to sacrifice some precision then you can also do distributed scheduling.
This should run. Did you properly export the jar? Does it show up when calling /pl ?
ill try rn
and i think i properly exported it
I just Built the artifact
in intillej
/pl
alr i will try the second my server restarts
yeah my plugin is there
oh wait im so stupid
plugin.yml?
...
welp
uh
sorry
alr yeah it works
interestly though it didn't work if there wasn't the 1 tick delay
ty for the help
is there any extension/plugin or something for itellij that do stuff about minecraft plugins? for example, telling me when im not declaring a command in plugin.yml, with code snipets of api things, like a class that implements CommandExecutor or some other interface, or to be able create the "a minecraft project" with spigot/paper as dependency, and the package and the main class created already created? extending from JavaPlugin and all that stuff
and another thing that idr if i already asked, I guess i did but idk, do i really, even today, 2021, have to restart the server every time i make a minor change to a plugin? or is there a way i can my a plugin "reload safe"?
i mean, i know that using /reload in "production" is bad, but when developing too? do you all restart your servers bc of a typo in a string?
yes
what about the extension/plugin for intellij
There is an extension to help creating plugins, but I'd never recommend it.
Learning how to do things yourself improves your skills.
dont you use any extension? or did you create your own snippets or something
and once you have learnt it take but a couple of minutes to throw a basic plugin framework together
I use Eclipse. No extensions nor code suggestions.
@fluid cypress Yes there is I am using it right now
how is it called
minecraft dev plugin
You can search for the plugin in IntelliJ
But what you described sounds more like you want to write a custom sonar rule checker for yourself.
Regarding the restarts: You can set up your dev environment allowing hot swapping. So making minor changes will be seen live without reloads needed.
im using it, and since i installed it, it no longer tells me that the plugin class is not being used or that event listener methods are never called, which is good, but it does nothing about undeclared commands in plugin.yml. it wouldnt be too do that, and i would avoid having to use Objects.requireNonNull and some server restarts
The mc dev plugin mainly helps you set up a project with all dependencies and a plugin.yml including a main class which extends JavaPlugin already.
yea, i have to see about that
what do you mean with "allowing hot swapping"
you mean using a config or something
how do I check if the inventory is full?
Hot swapping means you can program and see your changes right there in the running server without having to stop it.
I dont think you want to check if an Inventory is full. You would rather know if a certain ItemStack can fit in the Inventory, right?
yes
i have never heard of that, is that a java thing? or an intellij thing
I need to place an item in the inventory and if there is no space in the inventory, do not place it. if there is the same item in the inventory, put
using the debugger, right?
Thats a java thing. Not very common and has some limitations. Its only useful for minor changes.
Are you fine with adding items and dropping those that dont fit on the ground? Because thats the cheapest way of handling inventory overflow.
no
Then there are 2 approaches:
Lazy but more expensive: Clone the inventory and check if it overflows when you add an ItemStack
Labour intensive, complicated and error prone but possibly cheaper: Write your own method that iterates over the entire Inventory and keeps track of how much you could theoretically fit into the inventory.
No
Why no
Inventory#addItem returns a Map of anything that won;t fit.
- It might just contain a slot that is null
- There could be a stack of that type which could still fit the items he is about to add
main: com.minco.plugin.mplg.Main
name: MyPlugin
version: 1.0
author: me
description: "An Example plugin"
commands:
ping:
description: "Ping Pong"
Why not working? (1.17.1)
L
But it adds the items already. And reverting that is not really possible.
doe he need to revert?
He wants to not add the items if they dont fit completely
ah
h e l p
Honestly there should be a method for that in Inventory like Inventory#canFit(ItemStack...)
I'd probably go with the addItem (one stack at a time). If they don;t fit, take the returned from what you wanted to add, then remove what was added.
What does the console show if you try to start with your plugin installed?
eclipse
Sounds ew.
probably easier than checking for space
I would just clone the inventory, add the items and see if there is overflow. Then return true or false.
Thats the lazy way of checking if an Inventory can fit certain items.
I'm using that
это что?
I guess, so long as you are not doing it often
🤦
Yeah but he doesnt want to drop the items on the ground
No, he can delete dropItemNat ..
But then he possibly deletes one half and just deletes the other half. Thats stupid.
Then you dont need to drop them in the first place lol
No
Sec
Oh you mean in the pickup event
I have all the resources placed in the chest, if there is no place there, they are thrown next to the entity
I think he doesnt want that
I showed him just a for
that is, how to get those elements that did not fit into the inventory
I need to check if there is no space in the inventory but there is the same item that I want to add, add it. if there is no such item and the inventory is full, do nothing
Мне нужно проверить, нет ли места в инвентаре, но есть тот же товар, который я хочу добавить, добавьте его. если такого товара нет и инвентарь заполнен, ничего не предпринимайте
Inside my for , just set item.remove();
[15:44:04 ERROR]: Error occurred while enabling MyPlugin v1.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.minco.plugin.mplg.Main.getCommand(String)" is null
at com.minco.plugin.mplg.Main.onEnable(Main.java:7) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:511) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:425) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.reload(CraftServer.java:893) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.Bukkit.reload(Bukkit.java:675) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:776) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchServerCommand(CraftServer.java:761) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at net.minecraft.server.dedicated.DedicatedServer.handleCommandQueue(DedicatedServer.java:475) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:439) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1217) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1050) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot-1.17.1.jar:3219-Spigot-b166a49-8c6d60c]
at java.lang.Thread.run(Thread.java:831) [?:?]
```\
what
Command registered in plugin.yml?
main: com.minco.plugin.mplg.Main
name: MyPlugin
version: 1.0
author: me
description: "An Example plugin"
commands:
ping:
description: "Ping Pong"
v1.17.1
See if your plugin.yml got exported with the jar. You can just open it with 7zip
if plugin.yml had not been exported, there would have been another error
That is literally not what he wants.
Like Invalid Plugin.yml
He said me in our lang
@lost matrix
how to do it?
Learn java
yes
got exported
You need to write a method for that. Its a bit complicated, logic wise. Give it a try and if you dont figure it out ill provide you with some help.
He doesn't know java
Hm. Show your class pls.
I do not know how to do this
I said
Try it. You will learn a lot.
¯\_(ツ)_/¯
// Main.java
package com.minco.plugin.mplg;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public void onEnable() {
getCommand("ping").setExecutor(new PingExecutor());
}
}
// PingExecutor.java
package com.minco.plugin.mplg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PingExecutor implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
sender.sendMessage("Pong!");
return true;
}
}
Can I add second permission?
This is the first step:
public boolean canFit(Inventory inventory, ItemStack itemStack) {
}
Looks good to me.
and what's the problem?
I said him using Visual Bukkit, cuz he don't know Java, and he don't want learn java
||(https://www.spigotmc.org/resources/visual-bukkit.76474/)||
That would be ambiguous behavior. Does the client need both permissions? Does he only need one of those two?
I would rather just not work with plugins than using this kind of garbage.
Im actually not sure. The only reason could be that your installed jar does not contain the content you provided us with.
so I don't think that this is garbage, for beginners it will go just right
Probably
✌️
Compile again and make sure that your newest plugin version is in the plugins folder. Then open the jar and look inside the plugin.yml to make sure the command is actually in there.
thanks everyone i fixed i changed eclipse tab key to double space
Ah. Dont use tabs in yml. Wait. Choco isnt here so i can trash eclipse: Intellij wold yell at you for that
IntelliJ ❤️
Is there a way to disable advancements for only specific players? The only event i can find for 1.17 isn't cancel-able.
@lost matrix
Yes random cyrillic letters guy.
¯\_(ツ)_/¯
how to do it?
L
R
where to find the item names for different color wool in 1.8
Hm. I guess you could send players different Advancements packets based on certain conditions when they join. The client asks the server what types of advancements are active.
the nbames from 1.17 no work
Deep in the archives of some forum posts or very old javadocs. 1.8 support was dropped over half a decade ago. Update.
Hint: Back then color wasnt done using its own material but rather with extra byte data on the block.
-_-
@lost matrix, how to do it?
🤣
Learn java
That's your answer
причем тут джава?
no china
engish ony
It's russian
Tha fk...
Ive given you all the infos you need.
You need to iterate over the inventories content and count up the amount of items you can fit in there by
either checking if the slot is null or if the ItemStack isSimilar and still has space.
Again: lol
Thats a bit racist actually...
y
Why
ya kakayu v tualete. uh, ebat a 4to tyt tak vonyaet?
You wont get more than this:
public static boolean canFit(final Inventory inventory, final ItemStack itemStack) {
final int amountToAdd = itemStack.getAmount();
final int spaceForItem = 0;
final int maxStackSize = itemStack.getType().getMaxStackSize();
for (ItemStack slotItem : inventory) {
}
return false;
}
okay, thanks
can I have a little more?)
🤦
ya dolboeb
Of course
Nope.
Check if the slot item is null or air -> then add the maxStackSize to spaceForItem
else -> Check if slotItem is similar to itemStack -> then add the (maxStackSize - slotItem.getAmount()) to spaceForItem
Return true if spaceForItem is bigger than amountToAdd
?
how to use
dyeColor
it no work
.setData(DyeColor.RED);
no work
What version?
Then search for ancient forum posts. This version is no longer supported since 2015 or so.
i havew
but the person i make it for dont wnana be nice
they want 1.8
and it annoy me
bcuz i never done 1,8
b4
-> old forum posts
j
u
st
gheklo
i havbe looked at fucking forum posts
it not fucking work
yall useless
Nope. You brought this on yourself by accepting work for horribly old software.
Wait what you trying to do?
useless definition
not fulfilling or not expected to achieve the intended purpose or desired outcome.
that u
To what though?
DyeColor.RED.getData()

still not work
Go away then
XD
u ugly
This will literally yield the same problem.
dude learn some manners
Cute XD
You could just do new ItemStack(Material.WOOL, 1, (short) 14)
We can tell ;D
;p
And that will give you one red wool
Ok
1 = amount
14 = Item data (so what makes it red)
Recommend looking here for the item data https://minecraftitemids.com/types/wool
okk
?learnjava
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.
r u fucking serious
i know fucking java
i jkust didnt know how to set the fucking wool color in 1.8
fuck sake
seems not
setting a fucking wool color
^
and fuckign knowing the languahe
very simple task
I mean the API has changed massively since 1.8 lol
Ik
No, its just knowing what you are doing
and google shows you everything you need to know
Middle clicking is a feature of the ide IntelliJ
Why?
?learnmanners
no
I never asked you either.
i did
i jsut asked a fduckign question]
Two people here have already told you how to create colored wool in 1.8. You seems to not want to listen
not a fuckign invitation for u to fucking piss me off
And you got an answer?
You are free to leave if you dont feel we provide you with the proper help. There are numerous forum posts that meticulously describe you how to achieve what you are trying to do.
what a rebel
stop being a useless fuck omfg

You have your answer. Your question has been resolved.
ok then why are u still tyalking abt it
It seems you want something
Ive just loaded up my dusty 1.8 dev environment and got a red wool block and a red wool ItemStack. Everything provided works. Now its on you to implement it.
XD
so uh I got scammed by the bossbar#setVisible(false) method, is it broken or does it work in a way that I am not seeing?
@lost matrix
@lost matrix
@lost matrix v
v
v@lost matrix @lost matrix
@lost matrix
@lost matrix
v
v
What version are you on (hot topic)
Yes cimex. What do you need?
oh was it broken for a version?
hm
let me check
No idea.
I think you just have to remove people from the bossbar
Not entirely sure though
But try that I guess
seems like this specific test environment is on paper 100 for 1.17.1 for whatever reason
I can test on vanilla spigot in a second if that changes anything
But setting it invisible should work. Thats expected behavior.
setting players won't work for me because that's dynamic and I really don't want to keep a task up just for this
man what am I typing today
Did you test the visibility in a discrete invironment?
this is executing the else part, even when passable blocks is clearly greater than 2, and safeBlocks definitely contains END_STONE at the index 20
Ill test it for you real quick
private BossBar bossBar;
@Override
public void onEnable() {
this.bossBar = Bukkit.createBossBar("§cTest", BarColor.BLUE, BarStyle.SEGMENTED_10);
Bukkit.getScheduler().runTaskTimer(this, () -> this.bossBar.setVisible(!this.bossBar.isVisible()), 10, 10);
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onJoin(final PlayerJoinEvent event) {
this.bossBar.addPlayer(event.getPlayer());
}
you know I somehow suspect this is only happening for dragon specific boss bars and I can test that right quick
If the boss fight is going then im not sure if you can make the BossBar invisible.
it's failing to hide even on the first tick
Works as expected
can you try to do that specifically for the dragon
yeah confirmed
works for my custom boss bar
but not the dragon
well this is fun
Then you’re properly just gonna have to remove the player and add them back again :/
Then the active boss fight prevents the hiding of the bar
so what, remove everyone on every tick?
How do I check for an item by another plugin?
Have you tried printing out the value of passableblocks before the statement?
Sysout the amount of passable blocks before the conditional statements
Can I do it or not?
What’s the other plugin
Depends
no, but could the debugger be wrong? its the second time i use it in intellij, idk how good or bad is it
KitPvP
Uh can’t say I’ve used it before lol… I just System out print to the Minecraft console
Do you know if they have like an API or anything?
Usually its quite good. But you should def encase all blocks in brackets just to be sure. Its also enforced by almost any java code style.
I don't think so. Ig they use spigot api only
Send a link to their spigot page
so
if() {
} else {
}
Also are you using maven @wispy monolith
Yup
See if they have a maven repo and add the KitPvP plugin as a dependency
its not printing it when it should, does it have a delay of a couple of frames or something like that?
i dont know whats happening, the thing i see in the console is totally different from the debugger
like, the debugger says passableBlocks is 12, but the console says its 8, and its still failing the condition
ill do the bracket thing
I can't even make the boss bar invisible when the boss dies, sadface
Tha fk are you doing there?
println should be instantaneous or not?
Yes. Its a blocking call to stdout
even #removeAll() isn't working, this is really annoying
wtf is wrong with this thing
The only reason why the conditional statement could be false is if the collection you call contains() on doesnt have the Material in it. (If we can believe the debugger)
Did you check what type is actually produced by block.getType() ?
Oh yeah you did. Its END_STONE
Just dig the player a hole to make some space XD
maybe something is wrong with what im doing: im using paper for the sv and the paper api, im using maven to compile the jar, and the steps i followed to debug this thing were spigot as debugger, not the ide https://www.spigotmc.org/wiki/intellij-debug-your-plugin/
also i click the build project button, besides the package script from maven, just in case idk
On the bungeecord PluginMessageEvent, how do I get the serverinfo of the server that sent the plugin message?
?jd
Yes.
Check if Connection is instanceof Server. Then cast to Server.
oh lol
Also, im using paperlib that does some things async when running on paper, but that code is running on the main thread, so, i dont think thats a problem
From there just use Server#getInfo()
I honestly didnt bother setting up a debug environment for my spigot/paper projects so i dont know what the implications of remote debugging are.
But if both, sysout and debugger, tell you that the space is bigger than 2 but the condition still fails then you got other problems. Mind sharing more of your code?
Hello! How can I get face of a sign? Face that contains text
Sign implements Rotatable
- Get BlockData
- Check if instanceof Sign
- Cast to Sign
- getRotation() from Sign
Be careful there are 2 Sign classes. You need org.bukkit.block.data.Sign
Same thing just with org.bukkit.block.data.WallSign
It implements Directional so you get the BlockFace using getFacing()
Ohh thanks!
You could just check if BlockData is Attachable, then getAttached
oh I guess not
Sorry thats for trip wires and things
Show what you got so far
throw it off?
public boolean isFullPlayerInventory(Player player) {
for (int i = 0; i < player.getInventory().getSizeInventory(); ++i) {
ItemStack slot = player.inventory.getStackInSlot(i);
if (slot == null) return false;
}
return true;
|
|
|
public static void check(Player player) {
boolean isEmpty = true;
for (ItemStack item : player.getInventory().getContents()) {
if(item != null) {
isEmpty = false;
break;
}
}
if(isEmpty) {
//code
} else {
sender.sendMessage("Please clear your inventory first.");
}
}
Nope. Not even close.
Start from here:
public static boolean canFit(Inventory inventory, ItemStack itemStack) {
int amountToAdd = itemStack.getAmount();
int spaceForItem = 0;
int maxStackSize = itemStack.getType().getMaxStackSize();
for (ItemStack slotItem : inventory) {
}
return false;
}
Then follow this:
Check if the slot item is null or air -> then add the maxStackSize to spaceForItem
else -> Check if slotItem is similar to itemStack -> then add the (maxStackSize - slotItem.getAmount()) to spaceForItem
Return true if spaceForItem is bigger than amountToAdd
Okay, I'll try
huh I just realized that the top google result for my issue is a post I made in 2018 covering what I just recreated now
completely forgot i did that
Why do you want to check if its full? Do you not want to add some items and leave the rest?
Because possibly incinerating have of a players rewards is a bad idea.
how do i use e.disallow() with AsyncPlayerPreLoginEvent? im tryna make it so it kicks them but idk what it means by 'Result' and then string
the result part
ik what the string is
You are just setting the result reason, either whitelsit, ban, full and so on
declaration: package: org.bukkit.event.player, class: AsyncPlayerPreLoginEvent
The String is the message.
Put what ever you want it to be
declaration: package: org.bukkit.event.player, class: AsyncPlayerPreLoginEvent
Its says AsyncPlayerPreLoginEvent.Result because its an inner enum inside the AsyncPlayerPreLoginEvent class.
System.out.println("safeBlocks.contains(Material.NETHERRACK): " + safeBlocks.contains(Material.NETHERRACK));
System.out.println(safeBlocks);
[06:06:03] [Server thread/INFO]: safeBlocks.contains(Material.NETHERRACK): false
[06:06:03] [Server thread/INFO]: [GRASS_BLOCK, COARSE_DIRT, PODZOL, SAND, RED_SAND, TERRACOTTA, SNOW, SNOW_BLOCK, PACKED_ICE, ICE, NETHERRACK, GRAVEL, SOUL_SAND, SOUL_SOIL, CRIMSON_NYLIUM, WARPED_NYLIUM, BLACKSTONE, BASALT, NETHER_QUARTZ_ORE, NETHER_GOLD_ORE, END_STONE]
it makes no sense
What class and type is your collection safeBlocks ?
if using strings
@lost matrix
public static boolean canFit(Inventory inventory, ItemStack itemStack) {
int amountToAdd = itemStack.getAmount();
int spaceForItem = 0;
int maxStackSize = itemStack.getType().getMaxStackSize();
for (ItemStack slotItem : inventory) {
if(itemStack == null || itemStack.getType() == Material.AIR);
}
return false;
}
}
its all Material
2 and 3 did not understand
And collection class?
List
Use an EnumSet
the only thing i can think of is, im getting the list, and im using the contains method later, but if that was the problem, the thing printed in the console should be empty or different
getServerCount(server)
Super weird that this doesnt work. But try an EnumSet
why?
and make it return an int
is there something wrong with lists?
Much much faster than anything else. And its reliable.
Usually not. It only scales O(n) for contains.
how do i make a getter using plugin messaging
like how do i do like
getServerCount(server)
and make it return an int
Set yields a better performance and EnumSet even more so.
ok, ill do that
but
this cant be happening
unless java is broken
Lists are from java, i mean, its not even my own collection class or something
Do you use openj9 or some other jvm fork?
i use openjdk
Then there should be no problem.
Bukkit has a plugin message for that:
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#getservers
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
You need to listen for +send a message
no like
i have a send
and a receive
how do i do like
public int getMinigamePlayersLeft(server) {
return blahblah;
}```
Dont. If you do that then you will produce massive lag.
public void acceptMinigamePlayersLeft(Server server, IntConsumer consumer) {
}
delegate the function via a consumer
public void findGame(ProxiedPlayer p, String minigame) {
p.sendMessage(ChatColor.GREEN + "Server found!");
List<ServerInfo> waitingServers = new ArrayList<>();
for (ServerInfo info : foundServers.get(p)) {
if (getMinigameState(info, not a real method yet).equalsIgnoreCase("PRE_GAME")) {
waitingServers.add(info);
}
}
matchmaking.remove(p);
foundServers.remove(p);
}```
how
idk
Pls describe your setup. Are you writing a plugin for BungeeCord or Spigot or both? What exactly are you trying to do.
how do i create an enumset?? i get 'EnumSet' is abstract; cannot be instantiated
EnumSet<Material> test = new EnumSet<>();
i dont remember too much about abstract classes
thats on a bungee plugin
both
EnumSet.noneOf(Material.class) for example
Thats a bit complicated.
You need to take a really object oriented approach for this or it will be a mess.
The proxy should hold game instances which the servers can register. Then the servers can send users to those game instances. When the queue us full, the proxy sends all players to the right server instance and starts the game.
hey guys ehh I'm fairly new to making plugins and I'm having trouble with dealing with packets
I'm trying to set the items in a inventory created with packets with the help of protocollib
but I can't seem to find a way to set a specific slot in that inventory to an item
The actual implementation strongly depends on your game setup and can get quite complicated fast. Be sure you know how to properly handle async requests and know
how to forward methods using Consumer<>
Why would you need to set items in an inventory with packets...?
How much java experience do you have?
I don't actually know but I figured that it would be harder for players to like uhh dupe I guess with a fake window

I know the basics but not really much
The only reason why you would want packet based ItemStacks is so multiple people see the same ItemStack differently.
Dont tinker with packets. If you properly use the API then dupe save GUIs are possible.
The biggest purpose of ProtocolLib is for a player to see what other players don't see
I still kinda want to know how what I wanna done should be done even if I don't really need it now...
I kinda figured out that I'd just need to do this
PacketContainer pc = main.pm.createPacket(PacketType.Play.Server.WINDOW_ITEMS);
pc.getIntegers().write(0,1);
List<ItemStack> l = new ArrayList<ItemStack>(0);
l.add(new ItemStack(Material.GLASS_PANE, 1));
pc.getItemListModifier().write(0, l);
for adding items
Packets are not part of the API. So if you want to do that then you need to look at the protocol specification:
https://wiki.vg/Protocol#Window_Items
i just wanna know how to do a get system with plugin messaging, i have all the other stuff down
it works
but that only add items like uhh in order I guess?
@lost matrix Have you worked with MongoDB much? If so would you recommend the POJO approach or just plain old documents?
I did look at it but can't really figure out how I should do it if say, I wanna set the 3rd slot of an inventory to something else without messing with the first 2 slots
@lost matrix
having the first 2 itemstack in the list set to null just kicks the client
Pojo is great.
The list you send has to line up with the inventory slots. If you want to make spaces then you need to add null entries in the list
and setting it to air removes the first 2 items
@reef wind
stop
hey prouddesk
I won’t help you again, last time was a pain and you didn’t even listen. @quaint mantle
https://imgur.com/a/av4rlQb
this happens tho if I set it to null
I really like document based databases for minecraft servers. The simple Data -> Gson/Jackson -> MongoDB approach works great for arbitrary data.
It’s a nullpointer
Yeah for sure, I have a soft spot for NoSQL databases
Uhm. Try adding air ItemStacks then.
that simply removes the first 2 items
do you know how to make a method that gets a plugin message value
like if i made a custom plugin message thingy that gets a value from a server and returns it instantly
for example
i have a value which is 7 on my spigot pluign
i want to be able to do like getValue(Server) on my bungee plugin and instantly get the int using plugin messaging
is this possible? if so, how can i do it
do I have to resent the whole inventory if I just wanna change say the 3rd item?
@reef wind
This will block and fk up your server
is there a way around it
how do i make a way around it
No. There is a different packet for that.
cause the packet works with like only 1 item on the list
it didn't work
delegation
@ivory sleet would you kindly kick @quaint mantle ? He keeps pinging people and when you try to help he doesn’t even listen.
it didn't work
public class ExperienceUtil {
public static void setTotalExperience(final Player player, final int exp) {
if (exp < 0) {
throw new IllegalArgumentException("Experience is negative!");
}
player.setExp(0);
player.setLevel(0);
player.setTotalExperience(0);
int amount = exp;
while (amount > 0) {
final int expToLevel = getExpAtLevel(player);
amount -= expToLevel;
if (amount >= 0) {
player.giveExp(expToLevel);
} else {
amount += expToLevel;
player.giveExp(amount);
amount = 0;
}
}
}
private static int getExpAtLevel(final Player player) {
return getExpAtLevel(player.getLevel());
}
public static int getExpAtLevel(final int level) {
if (level <= 15) {
return (2 * level) + 7;
}
if ((level >= 16) && (level <= 30)) {
return (5 * level) - 38;
}
return (9 * level) - 158;
}
ohhhh that's probably what I was looking for ty
I don’t even know what you are trying to do. Stop pinging me, I am not helping you again.
first of all, put that in a paste and second of all I WONT HELP YOU.
I read that it was impossible to take away the experience from the players there
Let me write you a short example

@quaint mantle let me ask you a serious question. Are you five years old or do you just have the IQ of one? I have told you multiple times what to do and you won’t listen. Stop pinging people because you are a pain to deal with.
you were not, I told you what too use.
engl
how do i clone the keyset of a map?
nahuya?
Example:
new ArrayList<>(map.keySet())
learn java or go to Visual Bukkit, i told u
vb pomoika
polubomy
pryam kak tvoya mama
(
This is commonly used for key iteration while modifying the map
poidy vskroyus
Don't get into the JAVA business without knowing JAVA
ya dlya sebya plugin delayu
english might help too xd
is there any more efficient ways to go about creating an inventory that looks like https://imgur.com/a/qrGugId ?
for(int i = 0;i<54;i++)
if(i<9||i>44||i%9==8||i%9==0)
daList.add(new ItemStack(Material.GRAY_STAINED_GLASS_PANE,1));
else
daList.add(new ItemStack(Material.AIR));
?kick @quaint mantle English thanks
Done. That felt good.
but i want a set
Then use a Set...
omg i literally hate java, its so unconsistent
the clone method doesnt exist on a Set
i mean, its private
also, the Set class is abstract
https://docs.oracle.com/javase/7/docs/api/java/util/HashSet.html#HashSet(java.util.Collection)
new HashSet<>(map.keySet())
the most common implementation of a Set (as Set is just an interface)
thats another question, why its always List x = new ArrayList instead or ArrayList x = new... or List x = new List, or Map<> x = new HashMap instead of Map = new Map
i mean, why is the type
different than the constructor
In OOP you usually want to be as abstract as possible when defining variables
A var of type list can hold an array list, a linked list, or any other implementation straight from hell
List is the interface and ArrayList is the implementation. There are several implementations for List with very different properties.
List<String> someList = new ArrayList<>();
List<String> someOtherList = new LinkedList<>();
Both viable but with different properties
because realistically, you don't really care for what implementation of the type it is. List is enough, as you most likely just want to access methods like add, size etc.
mmm
right, the List interface is just telling "this object will have this shape, this structure"
thats why its green, its an interface
but, then i could be able to do ArrayList x = new ArrayList<type>()
Liskov substitution principle (:
idk, its confusing, im tired af, i need to sleep
If it was bordeaux it would still be an interface...
🥴
But right
so wait even using nms the only real way of stopping boss bars from active dragons from being sent is to prevent the packets from being sent?
maybe if I ignore this issue it will go away
Just listen with plib and bash the packets away
chose one player at random and just delegate all that trash to him. See how his client handles all that.
this is so cursed
Actually that sounds like a fun plugin. Randomly shuffling packets to random players.
btw i found the safeBlocks.contains problem. yes, it was a list of strings, not material, being casted to material when reading from the config in a lot of nested for loops
so dont worry guys, java isnt broken
but my question is
how can i cast a string to material??
without a runtime exception or something
^
String -> Enum
Enum.valueOf(String)
how can I cast bad code to good code
I'm having a problem getting my plugin to work on the server.
Logs say the error is in plugin.yml
More specifically at the " main"
I've read the documentation but I can't seem to make it work
Right now it is
main: xceing.plugin.main
main:[packagename].[main class name]
i mean, im not asking how to do it, im asking how can a just cast string type to material type without an error
or youre saying that java does that automatically?
try catch is your friend
the error would be helpful and also is the main class located there?
Material.matchMaterial(string) ?
im asking WHY isnt it throwing an error when i do (Material)String, im not asking how to do it correctly, i already fixed it
You cant randomly cast stuff around. You need to get the Enum from the String by using Enum.valueOf(String)
In Material its safer to use Material.matchMaterial(String)
It is located in that package and extends Java plugin
what is the error?
Cannot find main class
the it’s not located there
That is just weird. Maybe you have a try catch block that just doesnt print the stack trace
ive been using Material.getMaterial, whats the difference?
Read javadocs
Doesn’t throw
matchMaterial is safer in regards to parsing String which might not be in the Material enum
Javadocs is your best friend
?jd
It will literally tell you why the functions exists and what they do
tbf if you're getting bad materials from strings odds are an error wouldn't be bad
Make sure the path to your main class in your plugin.yml matches 100%+
Hello. is it possible to play a sound, and update the location of the sound every 3 ticks or so
I missed a capital, I am so sorry for bothering yall
so it follows an entity
@lost matrix
ok ill use matchMaterial, didnt know about that, thanks
try {
} catch(Exception e) {
System.out.println("§cLook at your config u dumbass");
Bukkit.shutDown();
}
my only regret is how hard it is to rm -rf / from a thrown exception
There are enough people who run their server with the root user
