#help-development
1 messages · Page 568 of 1
Wut?
the first step on that page, for maven is already set to auto download,
the plugin it's talking about I dont have installed, I think I can get ultimate for free since im a student
I'll be, didn't know that was a plugin.
Yes, you can. It's what I am currently doing.
Don't need the plugin then
Although, you shouldn't need the plugin.
But yes you can get ultimate for free if you have a .edu address
I thought indexing was just a general feature of the IDE.
Even in the community edition.
yeah i have an edu. ill make that account and give it a go
It is, the plugin must do something else. I think it said it uses JetBrain's CDN to speed up indexes or something
^
Ill just repost since it's a while up
Why is my enchant not able to be applied?
override fun canEnchantItem(item: ItemStack): Boolean {
return Tag.ITEMS_HOES.isTagged(item.type)
}
val book = ItemStack(Material.ENCHANTED_BOOK)
val meta: EnchantmentStorageMeta = book.itemMeta as EnchantmentStorageMeta
meta.addStoredEnchant(Replanting(key), 1, false)
book.itemMeta = meta
I tried the JDBC java straight from oracle and it never worked
val f: Field = Enchantment::class.java.getDeclaredField("acceptingNew")
f.isAccessible = true
f.set(null, true)
for (enchant in enchants) {
Enchantment.registerEnchantment(enchant)
println("Registered enchantment " + enchant.getName());
}
Wait, do you have oracle java installed? Not the openjdk stuff?
I have openJDK, I just meant I got the JDBC from oracle
not sure if this is relevant info but im using Windows
That shouldn't matter all that much.
Does java care too much if I work on Mac and windows, should I set up a git ignore or something?
It would probably be a good idea to ignore the os specific files. Other than that, it should function the same.
You need to apply it manually with the prepare anvil event
Sure, anything is possible with enough brute force
Would that make them able to be enchanted via enchantment table
and anvil shit
or is that hard coded
Yes
They still won’t work in enchantment previews tho
really :(
that's mean
are enchantment previews hard coded
ig I could just look at nms
They are sent to the client by numeric id
ahhhh
The client won’t know what the numeric id of your custom enchant corresponds to
so client would have no fucking clue
is the Preview itself completely client side
Yes
What method is it for when the plugin first loads up
oof
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Alright, how do I make it so you can apply it inside of it though?
set result?
ye
k
🥳
I can finally help people through telepathy
didn't see it down here 😅
if only you could merge my PR telepathically
:P
MD is all the way in Australia
I need more power for the telepathy to reach that far
I pr'd your bt fork lol
PR-ception
I 🍴 the 🍴 and now want the 🥔 to be merged into the 🍴of the 🍴
thanks for your help @kind hatch and @sterile axle I think ive figured it all out for now
and I think you helped too @river oracle 🙂
Uh I did something ig?
what is the difference between a build and a "shaded" build?
is that a maven thing?
send fork 
need to steal for My gui
How should I set the result?
Don't I need a copy of the first item?
If so how would I do that
nvm
nvm, found
prety good
had sorta meant to do BT-GUI inside of BT but i think it just really wouldntve allowed what i wanted to do bc of things like the PortableGit n Maven downloads
or i would just need to try n take a slightly convoluted approach
its really just this, would not be difficult at all (just specifying working directory in process builder), im just really lazy
[05:32:17 INFO]: [slimeBob] Connected to Database
It's Alive!!!
@kind hatch @sterile axle
its possible to playsound for 100 blocks ?
i mean i playsound and player can hear this sound 100 block around
not without some extra work
find a center point, then get all entities in a radius of 50 blocks in every direction, for each entity, play the sound
Why can I not cast potatos to ageable
code?
println(event.block.type) = Potatoes
if ((Tag.CROPS.isTagged(event.block.type) && (event.block as Ageable).age == (event.block as Ageable).maximumAge)) {
Ill fix the double cast in a bit
just testing rn
block.getBlockData() not Block itself
🫡
what does inventory.addItem return if a players inventory is full?
the items that couldnt be added to the player sinventory
alright
I keep getting java java.lang.NoSuchMethodError: 'com.sk89q.worldguard.bukkit.RegionContainer com.sk89q.worldguard.bukkit.WorldGuardPlugin.getRegionContainer()' with the code java @EventHandler public void onGamemodeSwitch(PlayerGameModeChangeEvent event) { RegionContainer wg = WorldGuardPlugin.inst().getRegionContainer();
make sure world guard is installed on the server & your plugin depends on it in plugin.yml
Whats a good version I should support from (e.g 1.13>)?
My plugin is just a basic tree chopping plugin
It's really upto you. Depends how far back you want to support.
i dont really know
Can you make a secret gate for people with a certain luckperms rank can get through and what plugin would it be?
This channel is for creating/developing plugins as stated in the description. Are you looking to make a plugin or obtain one?
and please elaborate on "secret gate"
yeah
If you dont have the required luckperms rank you cant access that area/ building at my servers spawn
Are you looking to make a plugin or obtain one?
obtane
oh. ok thanks!
when i store itemstacks in arrrays, items' amounts just decrease randomly
can i control furnace cook time ?
onItemSmelt, furnace.setCookTime()
A quick google search doesnt hurt
請問一下
有大老能教我如何把Github的源碼轉成.jar插件檔案嗎?
https://github.com/AndyYu168/Myitems
我想要把這個變成差建檔 但是不知道如何使用
Excuse me
Can someone teach me how to convert the source code of Github into a .jar plug-in file?
I want to turn this into a plugin file but don't know how to use it
package it with maven
Do I need to install this?
yes
How to download?.
press the big blue download button
Preferably add maven to PATH
Clone the repository
CD into it
Run mvn package
can i growth nether fungus without bone meal ?
Well, I'm still not good at it
I don't know what to do after using this command
as in a plugin or just in game?
both
plugins for the most part can pretty much do what they want
custom blocks 😂
??
Are you trying to say you can't create custom blocks with plugins ?
yes
you have to do stupid texture shit and reskin blocks
I wonder in what way you mean that 'cause I am pretty sure I have accomplished mostly fully custom blocks.
incorrect, the reskin part
is there new api features? I don’t think you can apply texture ids to blocks thought that was only@items
there is 2 ways to have custom blocks. There is the visual appearance of blocks and then there is the function of the block. You are free to change the function of any block
nope, you can however use display entities for custom models
the visual portion is mostly client sided
well that’s a different story
some people do re-texture noteblocks since they have what, 800 states, also gives some performance over entity models.
🤣
||``` private static double calculateZombieHealth(int zombieLevel, double startingZombieHealth) {
double baseZombieHealth = startingZombieHealth;
double ZombieHealthMultiplyer = zombieHealthMultiplier;
double zombieHealth = startingZombieHealth * Math.pow(zombieHealthMultiplier, zombieLevel - 1);
double maxHealth = 2048.0; // Maximum allowed health
if (zombieHealth > maxHealth) {
zombieHealth = maxHealth;
}
return zombieHealth;
}```||
Is there a way to caculate all health values at plugin start? instead of needing to caculate everytime a zombie spawns?
Which values can zombieLevel be?
theres minLevel and maxLevel in config
id set a limit from 1 to 99 but it can be changed
hey guys, not related to spigot but does anyone know anything about world cloning with SWM ?
Then it may be kinda dangerous to cache but you could just store it in an array
if the range of levels can be set in config, then yes you could technically calculate all values between the range at the start
However if you support reloading configs you'd need to repopulate the arrays each time which may cause issues
Using array like geol said?
anyone?
I dont
And I don't think that Math#pow is that expensive to begin with
it can be, but if its not super complex stuff then no
Well I want to include every mob so
you would need to be spawning something like thousands of zombies per second to have some kind of effect
Should I just leave it be then?
if it works and you are not having issues definitely
you should only invest in optimizing something like this only after you have done some profiling and research to determine this is something affecting your server in a negative way
however odds are, you will probably have other stuff that is before this piece of code comes up as a culprit
how could I use NMS 1.19.4 to make my LivingEntity move to a specific Location?
you would need to utilize the goals/AI portion of the entity for this
is there any official documentation?
No
how could I use the goals then?
if documentation existed for NMS
there wouldn't be much of a reason for API's like bukkit or spigot
the calculation is such a negligible difference it's not worth over optimising
I believe we covered this already 😛
lol
can i growth nether fungals without bonemeal ?
in what way ?
How?
- As soon as its placed, grow the nether fungi?
- When you run a command?
- Other ways
they must not read the chat
therefore pointless to respond to them if they are not going to participate in a conversation
Hi everybody, good Morning
I've got some errors from my plugin, thease are related with SnakeYaml problem i didn't catch, send you documentation and thanks for help ❤️
- Main class: https://paste.md-5.net/evanijusar.java
- ConfigUtil class: https://paste.md-5.net/xojulecufu.java
- ConsoleError: https://paste.md-5.net/arusekefux.sql
One of the thrown exceptions has the following message
special characters are not allowed
on top of you are using sponge and paper
Also paper
it seems i have to recreate the file with paper right?
Just i copy paste every class?
no, it seems that you have special characters that are not allowed by yaml in the config file
and since you're using paper, you should probably ask on the paper discord
I assume the special character it is complaining about is the section symbol that mc uses
Oh yeah there i put "&" for colorCodes
I think i have to create a string translator it takes "&" as a colorCode translator right?
there is an api for that already
unless paper changed it
which again this isn't the paper discord
ahahahah
https://jd.papermc.io/paper/1.20/org/bukkit/ChatColor.html#translateAlternateColorCodes(char,java.lang.String) they "only" deprecated it
declaration: package: org.bukkit, enum: ChatColor
public static String translateString(String input) {
return ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(HubCore.getInstance().getConfig().getString(input)));
}
what about if i do something like that
instead of Objects.requireNonNull I would rather print out a useful error message or use the default message from your included config
I may not know yaml, but I think it is screaming at you for having the & in the config
So doing stuff with it in code would be pointless
i hope it's going to take the String from the config as input
Or now for the moment just trying running without special character XD XD XD XD
not sure why you are telling me
I don't really care about paper api
so it isn't relevant
Nothing guys, i removed the '&' from the config, but it is still crushing
§ ?
Solved, there was a failure in the creating of the world nether
LOL
Problems with the Main class instance: https://paste.md-5.net/gayakemase.java
Please fix this indentation 😭
instance is null when you try to use it for the first time...
learn how to read exceptions...
I think I have to learn Java
you think ?
This is like textbook example of NPE :D
NPE?
Null Poiner Exception
uh.... right
you call "instance.getConfig()" before you assign any value to "instance"
btw why are you waiting until onEnable to set the instance? why not do it directly?
public final class HubCore extends JavaPlugin {
private static HubCore instance;
{
instance = this; // <- set the instance in the constructor / init block
}
@Override
public void onEnable() {
FileConfiguration config = instance.getConfig(); // also why are you using the instance field instead of "this" here? That's quite useless. Just do "getConfig()" directly
// ...
}
}
the valid use case would be if you are making a static method to obtain main class instance as well as handle server reloads
but otherwise yeah you can do just as you described
Hi guys why using Kyori adventure api i have errors on every method like this: java.lang.NoSuchMethodError: 'org.bukkit.inventory.Inventory org.bukkit.Bukkit.createInventory(org.bukkit.inventory.InventoryHolder, int, net.kyori.adventure.text.Component)'
I can't send Message, or Log in console
Same error
I'm trying to convert my Paper plugin to Spigot plugin to support both
on place
becase that api only exists in paper, you have to shade adventure and convert it to a legacy string
I see this is the time of year where we get an influx of people asking questions in the wrong discord
don't see how they fail to read this is spigot lol
BlockPlaceEvent, check if its the fungi
after ?
i didn't know you could do like that?
private static HubCore instance;
{
instance = this; // <- set the instance in the constructor / init block
}
this i mean
they mean the body of the class
it doesn't have to go in the onEnable() method, it can be set outside of it
🤯
if it is, .applyBoneMeal()
damm
the only thing that is outside of the methods in a class is the class itself lol
can you just read the docs please
wdym 😄
- find out what you want to do
- think of how it might be done
- search for the appropriate event
- check methods
just replace the block with a fully grown one
i ask second one
if i understand or learn this
i will do others
do you have any java knowledge

hi, not really
Random random = new Random();
int range = maxZombieLevel - minZombieLevel + 1;
int zombieLevel;
double scaledRange = Math.pow(range, zombieLevelProbabilityFactor);
zombieLevel = minZombieLevel + (int) Math.pow(random.nextDouble() * scaledRange, 1.0 / zombieLevelProbabilityFactor);
return zombieLevel;
}```
Having big trouble with probabilities, zombieLevelProbabilityFactor is set to 0.5, but doesn't really seem to work, while when set to 10.0, it does
forgot to mention, I want it to spawn lower numbers when zombieLevelProbabilityFactor is a low number, and the opposite when its a high number
How do I code something like this?
can u help me ?
didn't read about your problem, lemme scroll a bit - also I just woke up, I'll try my best
i will ask u now
wait
Aight
its possible to growth crimson fungus without bonemeal ? in normal minecraft
in my opinion
not
Oh it's not a development question? You mean if there's a way to make those small shrooms become a tree without bonemeal?
idk
in my opinion, not
so i need idea for do this
alright
i think something
id guess just modify the nbt data for the block, probably a growth stage or something
am i need spawn structure ?
they have'nt growth sstage
Oh so you want to solve it programmatically. Lemme check some docs
i found this in stucturegrowevent: "treetype"
can i paste this structures with any method ?
generateTree*
do u know any method for
not only trees
only for other structures ?
like desert pyramid
jung temple
for structures might be different but i assume a generateStructure might exist by now
yup also found that this works for mushrooms - you were faster though :)
generics are making me realise some really weird things with bukkit
you need a DishFactory<Schnitzel>
and then you bake() it
BlockBreakEvent according to the jds is called when a player breaks a block, it doesnt extend PlayerEvent, player death event even has Player in the name, but no where extends PlayerEvent
u guys can give me idea for check
empty blocks
i mean vanilla sapling has not growth with blocks above them
or they are formed without damaging other blocks
That's a cool api. Smart to use generics. What implementation of plate do you use to serve it?
Just do 3 nested loops. The common way to check for 3-dimensional cuboids
i don't know, I'm using an API to create food objects, hence I don't know anything about its implementation. this api is called "my boyfriend" lol
unfortunately he's always alseep until afternoon
Sounds like a private api, too bad I guess
it was public at some point, but not anymore
the version on grindr is pretty outdated
https://paste.md-5.net/equkeseqaf.java
Sometimes i wanna die with this generic bullshit 
what event should i use to see when a player has removed a specific potion from a brewing stand
InventoryClickEvent
and INventoryDragEvent (nah that only works for placing things)
very fun
thank you
Too bad when an api like that goes from open source to private repo - I'm glad you were granted access and are happy about it!
doesnt look too bad
might also listen to BlockBreakEvent in case the player just breaks the brewing stand
this should acctully work or?
Particle.DustOptions dustOptions = new Particle.DustOptions(Color.GRAY, 1.0f);
player.spawnParticle(Particle.REDSTONE, player.getLocation(), 50, dustOptions);
yes
wait why cant this just be a normal java object 
but it dont xd
what
maybe its because 1.20.1
i would wanna die dealing with that in map form
oh its not actually hard
anyone know why i get this error
Caused by: java.lang.NoClassDefFoundError: me/filoghost/holographicdisplays/api/HolographicDisplaysAPI
my pom.xml:
<dependency>
<groupId>me.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
do you have the plugin on ur server
is it intentional that you can only have one consumer per event class?
yeah i do
yeah
is a multimap technically just a Map<K, List<V>>
depends on which one you use
MultiMap is just an interface
ArrayListMultimap is indeed a Map<K,List<V>>
its similar, but a multimap allows a key to be mapped to multiple values
there's a ton of Multimaps in guava: ArrayListMultimap, ForwardingListMultimap, ForwardingMultimap, ForwardingSetMultimap, ForwardingSortedSetMultimap, HashMultimap, ImmutableListMultimap, ImmutableMultimap, ImmutableSetMultimap, LinkedHashMultimap, LinkedListMultimap, TreeMultimap
actually, it's a dozen
lol
Random random = new Random();
int range = maxZombieLevel - minZombieLevel + 1;
double probability = 1.0 - Math.pow(random.nextDouble(), zombieLevelProbabilityFactor);
int zombieLevel = minZombieLevel + (int) (probability * range);
return Math.min(maxZombieLevel, zombieLevel);
}```
can someone explain me why when zombieLevelProbabilityFactor = 10.0, numbers high, but when its = 1.0 numbers are random?
That’s bad tho
It violates the fact consumers allow covariance and suppliers allow contravariance
Not the other way around
idk, haven't really checked your code, but why don't you just use ThreadLocalRandom.nextInt(int min, int max) ?
hello, how can I use nms in my spigot plugin (1.19.4, gradle)
e.g. ThreadLocalRandom.current().nextInt(1,11) returns a value between 1 and 10
Random sucks
for gradle, you probably wanna use paper. There's only an official spigot plugin for maven, not for gradle
They can run BT and depend on the spigot artifact
well, how can I use nms ?
maven -> spigot's "specialsource" plugin
gradle -> paper's "paperweight userdev" thing
If you dont want paper stuff, run BuildTools for 1.19.4
as said, in gradle you wanna use paper's paperweight / userdev plugin
so, I can't use nms in spigot ?
And then in ur build.gradle(.kts) change spigot-api to spigot
You can
But its poor
you can its just obsfucated
I don't mind
you can, but you gotta remap it manually, or you use the obfuscated version (don't do that), or you gotta use maven
then just change "spigot-api" to "spigot" and deal with the obfuscated mappings
User friendliness 
be sure to run buildtools for 1.19.4 beforehand
?nms
(that is for maven)
okay thanks
pretty sure he was told long ago Spigot is maven based
yeah probably lol
Wash your mouth out with soap!
🥺 sowwy
yum fish
Schnitzel Wiener Art > Wiener Schnitzel
how else would i do it then
wow, so useful
lmao
Given type A and type B where A <= B meaning a is A subtype of B (like a subset, not to be mixed up with a proper subset) then covariance means a type constructor S<T> will imply the following relation that (A <= B) -> S<A> <= S<B>. Contravariance means A <= B -> S<A> >= S<B>.
That’s the theory part
Now let’s look at the application part
If we have a function addCallback(Consumer<Animal>)
What should happen if we pass a Consumer<Dog> respectively a Consumer<Object> ?
Given that Object >= Animal >= Dog
always
Amazing
Lol, where is that
Well in this case, only a term of the type Consumer<Object> can be passed safely to the function. A Consumer<Dog> could lead to a class cast exception (in Java). Since a Consumer<Dog> may end up invoking methods that only Dog has.
Now ofc of we would be doing something like consumer.accept(new Dog()) in the function addCallback it would be fine. But what about Consumer<Bird> and Consumer<Whale>?
ThreadLocalRandom#setSeed(long). It's there because it extends Random, which does allow setting a seed
Thus we say Consumer is covariant @remote swallow
However the opposite would be the case for Supplier if u compare it like what I did with Consumer
Then if something is both a Consumer and Supplier we call it bivariant on I<T>
since A <= B or A >= B both implies I<A> is equivalent to I<B>
Ah
And ofc sometimes in Java you have to use covariance and contravariance for the wrong stuff to make java not complain etc
But generally speaking this is the theory behind how and why
the only thing I got from taht explanation is that you want to use concrete types in your consumer?
Na
What I mean is that if you have a Consumer<? super Animal>
an instance if Consumer<Dog> wouldn’t work
Because Consumers generally have a covariant relationship
the ? super X means that you just allow covariance (and above I explained why this is the correct one for Consumer)
the ? extends X means that you just allow contravariance
just X would technically be bivariant and just ? is novariant
I just keep things simple
I find that the more complex a system is, the less optimal it becomes
Yeah idk how to better set up a system for events other than that map
I’m open to suggestions tho :p
Yes I mean ideally
Avoid generics
You don’t need it for every subtype system you’re going to write
lmao I think I just found a memory leak in my plugin xD
I have this MenuEventListener where I add inventories to it
but I never remove them
think its fine?
but in some cases I keep making new ones for updating display purposes
You're sacked
yes, but not while the plugin is running
like the issue is I should really be deregistering them as I close the menus
well u only want to register listeners in onEnable in principle
it is
well
you shoudl have ONE listener and pass each event to your menu class
if u wanna extend on that with dynamic registering, you'd create ur own listener event system
idk how I can update a menu and still have it be different for every player for example
okay well I mean adding and removing from teh map
or a Set even
yes
however I am not 100% how a set works in that regard
I mean I suppose it hashes teh class or whatever
but that also depends on the type of Set i am using
like at what point does an instance of a class become a copy of another
if I change some property of the instance is it no a duplicate anymore and does it get added by the set
.hashcode must be the same and then .equals must be true
and liek is it recursive? because I am storing the actual Inventory in such a menu class as well
is that like terrible practise or what
if I were you I'd use a Map(Inventory, Consumer<Event>)
I dont quite understand
right now i have a menuInventory which has an Inventory variable
and those menuinventory objects are being kept by the listener
if I turn that list of menu inventories into a set
does it see a menu with different inventory contents as a duplicate or not?
I'd do a dumb Listener which has event listeners and your Map
idk how to structure Consumer<Event> into a class
if you create a menu inventory you add it as a key in yoru map and a consumer class to handle the events for ity
it doesn;t have to be an actual Consumer
an event handling class of your own design
its just somewhere to put the logic of handlign clicks/drags/close etc
this is how I do the drag for example ```java
@EventHandler
public void onInventoryDrag(final InventoryDragEvent event)
{
if (!menuPrecondition.apply(event.getView()))
{
return;
}
for (MenuInventory inventory : inventories)
{
if (inventory.internalInventory().equals(event.getInventory()))
{
inventory.handleDrag(event);
break;
}
}
}```
is taht similar to what you mean?
also ignore the precondition thing
@EventHandler
public void onInventoryDrag(final InventoryDragEvent event) {
YourEventClass handler = yourMap.get(event.getInventory());
if (handler != null) handler.process(event);```
how do you call openInventory
from like a command? openInventory(player, someMenuObject)?
yeah
yes this would be identical to what I have but instead of a list it would be a map of Inventory and MenuInventory? but then each map value will also contain the key in the form of MenuInventory::getInternalInventory so idk if thats optimal?
you have 1 instance of the manager class and use it accordingly
you don;t need the internal inventory in your handler class, it's already in the event
this code is too old lmao, I need to make it not static, maybe that will help with my clusterfuck of a manager class
but I need to add items to the inventory
how do I add items to the inventory if I dont have access to it from the MenuInventory class?
you have access toit everywhere
in your handler its in the passed event, in your listener it's a key in the map
I guess i can just add the items in the inventoryOpen event then
is that what you mean
right now I am adding items before the inv is opened
but i guess it doesnt really matter
so the only thing I really need to change is to somehow pass the menu manager into everywhere where I create a menu basically
in order to still open the inventories
how does this work for like nested inventories, i.e. right now I have a menu, when you click on an item, a new menu wll open, when you close that menu (by clicking on teh x item or something) it will go back to the first menu
right now I just call parent.open when I close my inventory in the MenuInventory
but my question is can I open a menu from the MenuInventory class
if I dont have the inventory stored in it
if it were me I'd reuse one inventory
well I would love to do that
but idk about any side effects
like what about an inventory that changes contents like a paginated menu
I dont want the page to change for everyone who has that menu opened
In general I do an inventory per player not one universal inventory
hmm
do you maybe have an example?
you mean one inventory per player per custom inventory type?
or like what do you mean by that
a player is only going ot have one open at a time
think of the inventory as nothing more than a screen to view whatever you want to put in it
rather than each custom inventory being it's own instance
yes I am having a hard time pulling the visual menu apart from what I want the menu to ultimately do
maybe I just need to structure the logic differently
like do you have a lot of logic in the customInventory?
when handling events or whatever
all the logic should be in the handler
how do I make a parent menu remember what page it was on when I open and close another menu "on top" of it?
in reality I would wipe out the parent wouldnt I
this page number being a very trivial example of data I want to retain basically until the menu is closed properly, (not by another menu opening overtop of it)
Theres many differeent approaches
have you looked at teh GUI resource by (I think) 7smile7
yes
it was either him or alex
thats where I based mine off of loosely
to get it started
that is where I had teh central listener idea from
but then I didnt quite know how to expand that in the right way I needed so I just fucked around until it worked
if you are doing paginated by player you could do private Map<UUID, List<Inventory>> inventories = new HashMap<>();
the pagination is just one example but basically yeah
except I'd probably do a wrapper on the inventories of a handler class
that is how I add items and stuff to my inventory now
I am wrapping an Inventory object I create in the constructor of the menu
then your dumb listener class just gets teh Map entry for the relevant player and passes the event to the stored handler class
your handler class holds all inventories for that player
hmm
I will need to rethink a lot of what I ahve right now probably , I also need to not be static first off all xD
like rn I have this java public MenuInventory(int size, String title, MenuInventory parent) { this.parent = parent; this.inventory = Bukkit.createInventory(null, size, Message.PREFIX_STRING_SHORT + " " + ChatColor.DARK_RED + title); MenuEventListener.addInventory(this); }
which is kinda bad
yeash get rid of static, not needed
but I need to redesign and define what I actually want my menus to do
yep
because not only do I want to keep the state for each player, but in some cases I want the inventory to update for other players if I change something
like lets say I have a menu full of game settings
ideally 2 people could change the settings for the same game
but then the inventories need to reflect each change to each other
but like
thats like exponentially more complex lmao
I guess its time to use my brain for once
if you have an instance like that then you have to use the same menu instance, or a complex sync system
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.
is there any way to reset a world like after a bedwars game, all world's modification are reseted?
technically deleting the world files and let chunks regenerate
or replacing the world
i guess
I have seen some implementations where they would just store all blocks that people created
and then remove those when restarting
but that will really depend on if players can break other blocks that are part of the map
yes, players can break blocks that are part of the map
and I would not like regenerating the world
is the world a limited area?
nah, just backup the world before and replace it when finished
kinda
file copy or chunk snapshots
I've asked this here a couple times before, so sorry for asking again, but I'm about to resort to hard-coding the mappings which will be tedious, sub-optimal and prevent my plugin from working across versions (I originally wrote it as a datapack and I started re-writing it as a plugin with the intent of it working across versions, so this would be particularly sad) so just want to ask one last time in the hope someone has an idea.
Given an ItemStack where ItemStack.getItemMeta() instanceof SpawnEggMeta, how can I get the EntityType which the spawn egg would summon when used? There used to be a few methods for this, but they all seem to be deprecated in favor of each spawn egg type being a unique material, but making use of this would mean hard-coding all the mappings.
EntityType.valueOf(item.getType().name().replace("_SPAWN_EGG", ""))```
Hi hello ppl!
What would be the best way to hide NBT data of an item from clients ?
Best would be if I were able to specify which tags would be hidden.
(Talking about PDC)
I assume ProtocolLib would be a way, but I think I would have to handle a lot of cases of manipulating the item (moving between slots, updating durability, renaming...)
you can't. Only way would be to just simply not have them to begin with
I remember thinking about that, but for some reason I was thinking that spawn eggs always spawned babies and that for some reason that would make it not work but... ye I don't see why it wouldn't work lol. Thanks!
and yet Hypixels manages...
And I can't afford to not have NBT on items, would be more of a hassle then handeling all cases with ProtocolLib
they don't need nbt data to store information on items
if you don't want the client to know about it, you simply don't have it
and I highly doubt you know hypixels backend intimately
how come this just happens to me all the time anymore even when running as admin?
so how do you know they manage to do something that isn't possible?
like....
have to completely reopen intellij every 15 mins because of this annoying...
there is one case of one item (the seed bag) where you can see an NBT tag popup after update and then disappear
I assume that is the server hiding the NBT
And why do you think it isn't possible
Have you tried it yourself ?
or removing it
read the protocol
where specifically
You can
Same principle behind client-sided lore
if you mean just visible popups sure, but the client can still see the nbt data
Yes, basically just removing the nbt data as I said
otherwise the client knows about it
Ok so it seems that ProtocolLib is the only way to go then
yup
there are 2 packets
containing all the inventory data
one of them is window items
which contains:
- a list of items (array maybe)
- an item for the cursor
and there's also set item
not the only way, it is easier in terms if you don't know how to mess with packets yourself
which is just a position and an itemstack
also there's a weird thing where if you're on creative
it like
duplicates the thing
so you gotta check for that
or well
if you're on creative and you try to copy the item
it copies it client-side
I had lore duplication with client-sided lore and the trick was to remove it server-side
was some weird goofy ahh stuff
I think I'll let creative ppl see the NBT
So no worry on that part, just gotta update all items when player switches gamemodes.
but ty
not my proudest code but it does the client-sided lore
oh tyvm for some example :D
It's really stupid but you gotta remove all the client-sided stuff on the item
and then re-add it once
Hm ok now that I've got spawn eggs working, I did some testing and found that Camels exist in the 1.19.3 API even though they don't exist in that version of the game so I get an error if I try to spawn it. I'm already using EntityType.isSpawnable so I suppose isSpawnable doesn't take into account if the entity is actually available in the version being used. Is there another method I'm supposed to use?
Hey I’m trying to make a link detector, which checks if a link is present in a message. If a link is detected in a message, it nightlights it with Color coding and creates a clickable URL.
The thing is this works with messages that just contains links or text before the link. However, if the link is followed by text, it apparently doesn’t work. Is this even possible? I tried a lot
Regex
Could you show your code? I'd imagine you'd need to use a regex, and define what you count as a link (anything that starts http(s)://? Other protocols? Only if it has a domain? A domain even without the protocol? Do you want to include username/password info?)
post the code
Most important things to know about URL regex and examples of validation and extraction of URL from a given string in JavaScript programming language.
You need to do your checks both with
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/
and
/^[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/
praise whoever made them
https://www.spigotmc.org/threads/how-to-activate-1-19-3-datapack-for-camels.581837/ i think this what gives you the issue
praise the poor man who created it for real
I don't want my plugin to assume 1.20 is enabled on the server, so I just want to exclude any entities exclusive to 1.20 (or, any version other than the one the server is running)
public class ClickableLinks {
private static final String LINK_REGEX = "\\b(https?://[^\\s/]+\\.[^\\s/]+)\\b";
private static final Pattern pattern = Pattern.compile(LINK_REGEX);
public static BaseComponent[] convertLinksToClickable(String message) {
ComponentBuilder builder = new ComponentBuilder("");
Matcher matcher = pattern.matcher(message);
int lastEnd = 0;
while (matcher.find()) {
String textBeforeLink = message.substring(lastEnd, matcher.start());
String link = matcher.group();
builder.append(textBeforeLink);
BaseComponent linkComponent = new TextComponent(link);
linkComponent.setColor(ChatColor.AQUA);
linkComponent.setUnderlined(true);
linkComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
builder.append(linkComponent);
lastEnd = matcher.end();
}
if (lastEnd < message.length()) {
String textAfterLink = message.substring(lastEnd);
builder.append(textAfterLink);
}
return builder.create();
}
}```
pre-compile your pattern!!
its a simple datapack, i don't think the plugin detects them
Wydm?👀
compiling your pattern in every single methodo call is... a little performance killer
But I don't want to require all server owners who use my plugin enable that datapack (they might not necessarily want 1.20 features on their server anyways), I just want my plugin to assume that datapack isn't enabled
you can't probably there's not method or if you can try "decompile" the datapack or if i didn't understand you want to check the datapack is enabled?
Why does Spigot define classes for entities which only even exist if you install a datapack...
because they exist inside the game code so they need to be specified, or the server would crash with a camel imagine that
Wait so how to I pre-compile it? Just asking for a simple hints, I’ll maybe be able to figure it out then
But in that same game code, there will also be code which disabled them by default, meaning there must be code I can use to identify entity types which have been disabled, without having to check for the presense of a datapack which enables them
Run Pattern.compile(LINK_REGEX) outside of the function
just have a static pattern
probably done to prevent crashes? im not a mojang employ they do only 1 milliseconds of code and then done
It wouldn't crash, it would just produce an error, and it still is despite the classes being defined
What? I'm not talking about Minecraft code, I'm talking about Spigot code, Mojang doesn't make Spigot
trycatch it
just activate the datapack probably that's the only solution
As I say, I don't want to force 1.20 onto every 1.19 server which installs my plugin
1.19.4 has datapack API
1.19.3 too
Oh alright thanks 👍 but for my actual issue, any ideas why it doesn’t work? I assume my regex is correct, but I might be wrong?
no he wants to enable the camels without enabling the datapack for 1_20 Update, i thought you meant how to enable the datapack
No, I don't want to enable camels
im so confused
They want to check if an entity is enabled so they can do things with it
I want to identify which entities can be spawned on the server
You can do that with the commit I linked in 1.19.4. EntityType.CAMEL.isEnabledByFeature(world)
That's the better way to do it, but you can also just check if 1.20 is enabled via the DatapackManager
I'm writing a random events plugin, and one of those events is spawning a random entity, but I don't want to randomly select an entity which can't even be summoned, so I need to filter the EntityType by isSpawnable and something else (it appears isEnabledByFeature, I'll have a look!)
Just be aware that these methods don't exist in 1.19.3 despite camels being added in that version
Not that anyone should be running .3 anyways
That's a bit strange, but my plugin is made for 1.19.4 so that's fine!
We just didn't have API around the time is all. Nobody had contributed it
Honestly I didn't even realise camels were added in 1.19 at all, I thought they were only in snapshot versions and 1.20, it's just strange to me that an entity was added which couldn't even be spawned by default
Yeah, experimental datapacks were introduced in 1.19.3 or .2 or something
Oh I've only just realised why this isn't just done by isSpawnable, I forgot datapacks were world-specific
Mhmm
int zombieLevel = getRandomNumber(minZombieLevel, maxZombieLevel);
double zombieHealth = calculateZombieHealth(zombieLevel, startingZombieHealth, zombieHealthAddPerLevel);
zombie.setMaxHealth(zombieHealth);
zombie.setHealth(zombieHealth);
zombie.setCustomName(ChatColor.GRAY + "Zombie (Level " + zombieLevel + ")");
zombie.setCustomNameVisible(true);
}```
is there a way to include damage multiplyers in there? or just setDamage in any way?
Every time the mob is diferent
There can be an infinite amount of zombie varieties I can't make that
Ill do thanks
You could pass that method into it ;p
world.spawn(Zombie.class, location, YourClass::spawnZombieLVL)
hm
Alright
I'd probably make a data class containing zombie attributes
and have an apply(Zombie) method
A dataclass only containing zombie's attributes?
Wouldn't that be alot if done for each mob
Hi, is there a lib to serialise an inventory and save it as data[] or String[] so that I can save it in my database (it's for a backpack plugin)? i use spigot 1.19.4
hi, i wanted to make a few plugins for 1.20.1 but i get "org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.2" with an empty project
Is there a way I can place a locked repeater in a given Location in my world?
put 1.20 instead of 1.20.1 and it should work
Surround 1.20 with ""
?
thank you
i want in my sql database sorry
Hello
You can use a BukkitObjectOutputStream to turn an ItemStack into a byte[]
Can i ask a question
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!
I cant dupe tnt on my server
thank you, but I want to register an inventory, so how do I turn ItemStack[] to byte[]?
Sorry
Just shove each item into the output stream
pretty sure you can shove the entire array
Thanks
like I do here
it's a try-with-resources
Basically it automatically closes the variables you initialize
avoids memory leaks pretty much
I should probably try-with-resources on the deserialize method
Did just that, worked fine, thanks!
I tried the first regex since I need to just check for simple https://... links
It works for messages which just contain the link. However, if the link is mixed with words, it apparently doesn't want to work. The code might be the issue?
https://imgur.com/a/B49AgaX
?pdc
For me^
Try matching each word individually
If I do this for each object, will I generate as many bytes[] as Itemstack?
yes
for me ?
^^'
the problem is that I'd like to save all my inventory in a single byte[].
you can just pass the entire array
like this ?
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream objectOutputStream = new BukkitObjectOutputStream(outputStream);
objectOutputStream.writeObject(Arrays.stream(items).filter(Objects::nonNull).toList());
objectOutputStream.flush();
byte[] serializedData = outputStream.toByteArray();
objectOutputStream.close();
outputStream.close();```
you can just pass the entire array
even null values
also try with resources
I literally send an image of what I did
but sure here it is again
I should probably just call writeByteArray
oh sorry i'v'n see
even the NBTTag has register ?
yeah
nice
here it is with raw bytes
what is the most ? byte or String ?
strings are more appropriate for uhh
writing to a file
it's just encoding honestly
strings also have padding and unicode stuff so they use more bytes
byte[] is simpler but only meant for internal use
yeah use the encoded string if you want to store the data anywhere
public static byte[] serializeItemStack(ItemStack itemStack) {
try {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
GZIPOutputStream gzipStream = new GZIPOutputStream(byteStream);
ObjectOutputStream objectStream = new ObjectOutputStream(gzipStream);
objectStream.writeObject(itemStack);
objectStream.close();
return byteStream.toByteArray();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public static ItemStack deserializeItemStack(byte[] data) {
try {
ByteArrayInputStream byteStream = new ByteArrayInputStream(data);
GZIPInputStream gzipStream = new GZIPInputStream(byteStream);
ObjectInputStream objectStream = new ObjectInputStream(gzipStream);
return (ItemStack) objectStream.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
jk
databases etc
Well you can store bytes too.
yeah you can store bytes
otherwise my cosmos plugin wouldn't be a thing (it stores schematics in multiple databases)
It's useful for some databases and for text-based storage which is mostly used by this communities newbies.
Strings
No need to there is already .dat
thoughhh you probably aren't following any nbt schemes
it's to make a backpack plugin in fact, I think the strings are enough
this is my pom.xml
<dependency>
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>HolographicDisplays</artifactId>
<version>2.1.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/HolographicDisplays.jar</systemPath>
</dependency>
Caused by: java.lang.NoClassDefFoundError: me/filoghost/holographicdisplays/api/HolographicDisplaysAPI
and this is the error i get
huh?
Is the plugin installed on the server?
yes
Are you depending/softdepending on it in plugin.yml
oh
no i mean like the groupId
in the pom
is com.gmail
im just using the wrong imports
my bad
I like em
even then just like
install stuff to mavenlocal I guess
I made a batch script for that
if you're on windows and can't bother
@echo off
cls
set /p file="File name: "
set /p group="Group: "
set /p artifact="Artifact: "
set /p version="Version: "
call mvn install:install-file -Dfile=%file% -DgroupId=%group% -DartifactId=%artifact% -Dversion=%version% -Dpackaging=jar
pause
Here it is if anyone cares
I could probably make something stupid to scan files
but this works
yo I need some help, we're using an old plugin in our server (1.12.2). There is an error going on and I want to decompile the source to fix it. Unfortunately there is an issue with the bytecode causing the decompiler to output not even remotely close code. So what I tried is replacing the class with a little fix included, unfortunately that fix did not work as intended either. So I'm wondering if there is another decompiler that can help with this
The plugin author is 'Twyzl' so if someone knows his discord, i'd be glad if you linked me to him
i have an itemstack[], that gets deserialized from mongo every time the server starts. the first image is from a server that has just been started and the second image is from a server that has been online for like an hour
i notice the values going down untill evetually it reaches 0
it only happens to the arrows
what decompiler have you used ?
jd-gui, fernflower, and luyten
all producing the same gibberish
actually not fernflower, my bad
i had the wrong java version
try IntelliJs decompiler
Just put all the classes into some directory and browse with IntelliJ
that's pretty smart actually
is it correct in the DB?
someone might just be taking the items
Is it possible to make an enchantment a double? And in incrase its level by 0.1 ?
yeah i did that just now actually
i just didnt push changes cause im not sure if itll work
it contains the same errors too
just decompile it manually then :D
out of curiosity, what is the error ?
it's with PrisonMines
it uses the ConfigurationSerializable from bukkit, though one class fails to load correctly
it works fine, but I need that class now
if I use it however it works fine too, it just removed the complete configuration file and causes it to break
this is the error
the weird thing is, it just works
it just removed the config and causes everything to break
is there any problem if in plugin.yml I use yml api-version: 1.8 and in pom.xml I use this dependency: xml <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.13.2-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency>
unless there are api changes, not really
The minimum api version 1.13
That setting didn't exist in earlier versions
valid point
i think < 1.13 just ignores it
ok, tysm
probably a stupid question but: when working on a menu should I instantiate a new invenotry every time a player opens a GUI or can I instantiate one and store it in a variable?
GadgetsMenu moment
several dupe glitches can occur
The plugin is defining by names, so if all of your confirm titles are the same, there will be many errors. 😆
isn't it
Then what are we supposed to use?
InventoryHolder way is actually the most decent one though
you can serve everyone a different GUI without much of a hassle
Anyone knows how to make mobs drop more exp?
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
Would learning NMS be useful? I hear it could be dangerous to use, as in server crashes, and corrupt player data. Would it be of use to learn NMS despite the bad ?
Don't touch nms unless you need to do something which is impossible with just the API
So pretty much don’t worry abt it until I need it?
Either via your plugin's logger (preferred), or System.out.println() will work
it is kind not realated to minecraft or spigot*
What kind of data are you trying to write that console.log() can't do?
if I use log it show pretty detail
Yeah, JSON#stringify() if you want the object
The null and 4 are optional there. Unsure what those do
4 is the indentation
Ah I suppose it's not prettified otherwise
null is the replacer not sure what that does
:l hmm
not every things is json
I hate working with packetdata ;-;
I used to know how but after years I have no clue ;-;
I'm trying to modify packet that playerreceive and send :l
import * as util from 'util' // has no default export
import { inspect } from 'util' // or directly
// or
var util = require('util')
and then:
console.log(util.inspect(myObject))
google is very powerful too 😛
to be percise I'm faking player current location to hide that
:l any better suggestion?
location as in coordinates?
yeh
/gamerule reducedDebugInfo true
:l
that just hide from vanila
not from modded minecraft
with pvpclient or hackclient pp still abled to access those
oh
that sets the gamerule
my bad
i mean to be honest
any mod will bypass that
even when spoofing a location
a mod can simply just get the seed by some tree patterns and nearby bedrock and figure out the pos
bedrock patterns are always the same iirc
have you ever watched this video
After 8 months of searching for this iconic mountain image, the seed to pack.png was finally found! Today, I'm going to show you how this feat was pulled off.
Seed: 3257840388504953787 (Alpha 1.2.2a - Can be generated up to Beta 1.7.3)
Coordinates: x=49, z=0
Pack.PNG Credits: https://docs.google.com/spreadsheets/d/1zdJWcdTydLClg0jy-fpKLH5nR8xT...
Hi I have a big problem that is making my head shake too much. I don't know how to think of a logic to get the instance of the main class. Because as far as I know, entities (User, Bank, etc) should not be initialized by passing them a reference from the main class through the constructor. Because then when you create an instance of the entity you have to pass the instance too. What can I do in this case?
Are scoreboards supported by 1.20? as my scoreboard doesnt show now that i changed to 1.20
yes
did they change in any way?
it depends on your use case, you can inject classes you need
or save an instance of the entity and do stuff in some kind of handler
those guys does really use their computer science degree :l
remember it's only one image
Can you explain more about it, its frustrating me and i want to learn too, for future issues
Because so far doing DI would be really bad, because of what i claim about passing the instance when creating an instance of the entity
what are you trying to accomplish
and clients have the bedrock pattern immediately
I could somehow modify that with stone but :l
well
that is lots of work
I can just replace it with stone clientside
Learn the best way for passing an instance reference to entities or objects, which cant do it via constructor like does DI
Do i explain or i translate to english from my native lang, maybe thats the problem that i dont explain well in English
i think they can bypass that too, not too sure
I believe they can't :l
like
they receive nothing about that
the data is removed not hiden
The problem is that I don't know what is the best design pattern to pass instances to objects, which depend on an instance to work. But at the same time it should not be passed through the constructor (as DI does), since it is a chaos and a bad design when initializing the object (to give you a use case)
Is it more clear @hollow beacon, i have re written the daught ?
A functional example, and the instance i need to pass is the StorageHandler, which will be used in the void methods
I'd say it's not the responsibility of the user to actually do IO
right, what would you suggest? Im here to learn best practices. Sorry for always tagging you
Do it on your user manager
^
right im doing a manager too
why are the methods there
public class UserManager {
private final Map<UUID, User> userMap = new ConcurrentHashMap<>();
public CompletableFuture<User> loadUser(UUID userId) {
...
}
public CompletableFuture<User> saveUser(UUID userId) {
...
}
public User getCachedUser(UUID userId) {
return userMap.get(userId);
}
}


