#help-development
1 messages · Page 844 of 1
try rejoining
yes, i have recreated it 3 times
since biomes update on the world loading
yeee
if you wanna update it to the player immediately you'd need to do some packet spoofing
Could you help me with that too?
which packets should I use
yeah, but you should totally use a packet library
PacketEvents
would be best
most optimized
but isn't it possible to do this with nms?
it is
if it were me, I'd do it with reflection
Just let ProtocolLib or PacketEvents handle it
or are you fine with having your plugin support only 1 mc version?
No ProtocolLib.
It's too slow.
and too unflexible
It's good enough
Why use that when there's a better option?
I can't find a tutorial on how to add his to project.(packetevents)
Same reason why people use 1.8
Also, PacketEvents is more intuitive?
they like it ig
or
there's an even faster way
you could teleport the player to like, the nether and teleport him back
this way it'd refresh his chunks
the momental teleport needs to be to another world tho
@sterile flicker
can i just unload and load chunks
or is there a built-in method for updating chunks
Worse
no idea if that'd work
you can try it tho
I don't really know what I'm looking at
hahahah
you could also just
go to like File > Project Structure > Libraries > +
and add select the nms jar file
you should already have it downloaded on your pc
Required type:
String
Provided:
TextComponent
speaks for itself
I smell paper and a lack of java knowledge
This isn't the place for paper if you have paper related questions go to their discord
works fine. thank you
np
which yaw and pitch should I set for the nms entity so that it looks straight ahead?
@tender shard ok i fixed the texture its working do i add the custom_model_data number here
?
wait is there custommodeldata for blocks too?
no
but I also observe one problem the snow is not falling clearly in chunks around the player but somewhere nearby
I dunno what that means
even after relogging?
No, it's more accurate to say that the snow is spreading around the territory too slowly. I just now noticed that it is where I called it.
is it possible to speed up this process
?
uhhh
as you can see, there is snow only around and it has fallen in the center
try relogging
I was replying to your other question
after the relogging, it stopped snowing altogether
What do you mean
debug your values
for (Chunk c : ChunkLoader.getChunks(player.getLocation(), 8)) {
int chunkXStart = c.getX() << 4;
int chunkZStart = c.getZ() << 4;
for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++)
c.getWorld().setBiome(chunkXStart + x, chunkZStart + z, Biome.SNOWY_TAIGA);
}
});``` can I change the ChunkLoader.getChunks() radius to 16 and for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++) to for (int x = 0; x < 32; x++)
for (int z = 0; z < 32; z++)
to have snow in all 32 chunks
nope
not how that works
this only iterates through the 16 blocks of the chunk
That’s not how you use the fork join pool framework, let alone how you use the common pool
u’re hurting overall performance by harassing the common pool like that
Tell him clubi
Let alone calling spigot methods from it, which will simply throw an exception most of the time or result in undefined behavior
can I use bukkit runnable runtaskasync
Why does it need to be async lol
then just .runtask or don't use anything at all or maybe something else?
Well, what exactly are you actually trying to do
set a snow biome in chunks and blocks around the player to replace rain with snow
and is there a better way to update the weather to snowy than packetevents?
wat
why are you watting me?
ah I see
I'm asking why it's bad
because you rarely ever wanna dump a huge io or cpu bound task as a single runnable to a fork join pool
Rather
and why is that?
You wanna split it up and properly take advantage of how fork join pool works under the hood by having smaller tasks
Because the entire point of fjp is “work stealing”
And that cannot be done if you have one fat task
I mean it's still better than using the bukkit async scheduler
each thread has its own queue of tasks, if a thread or aka worker has no tasks it can steal a task from another worker
Nah not really, depends, I mean the bukkit async scheduler uses a cached thread pool in the end
in general, I would say that firstly, the snow is spreading too slowly and also updating the weather by unloading and loading chunks is not a very good way, how do you think, conclube?
So assuming you don’t run epidemically long tasks
it can be done later on, for now he just needs to figure out how to do his logic without crashing the server
Its fine to use the bukkit async scheduler
Yes ofc, but I still commented on it, better to be aware of than to be oblivious of it
?
Yeah its sadly used wrongly in alot of scenarios even in popular libs
Not sure if you need to unload and reload chunks
I mean isn’t there a packet that can do the magic (assuming there isn’t an api method for it)
I don't want to use packetevents just for this
Packetevents? U mean the library?
in addition, everything is unstable for me, the weather resets after rejoin, my nms entity disappears, and I have to wait a very long time for snow
yes. is there really no built-in method or way to update this?
Let me check, one moment
Hmm, I looked at some stuff, but its heavily packet dependent
@lost matrix do u know if its possible to do this with spigot api? (W/O packets)
how do i stop maven from giving me the normal and the shaded jar (i only want the shaded one)
Uhm. Nope.
Use the mojang mappings
yeah im doing that
i already installed the mappings
but
the old version of the plugin
its obfuscated
like
1.16.3 obf -> 1.20.2 mapped
?switchmappings
that shows you the old and new method names etc
Is there a way to add methods to locked classes? I want to add an isTool() method to the Materials class for a plugin?
Na not really
I mean yes but those solutions would require bytecode manipulation, instrumentation etc
You can prob just create a static utility method that takes a Material as its argument
Extension methods when
Ah gotcha
Oh wait Kotlin
Its really sad that it doesnt work, if we would be able to hook into these we would have been able to create events that we need and not wait until its added
Example: BlockChangeTypeEvent
hmm what should I do if I want to remove an object from an arraylist in a loop? i cant do it normally cause ill get a stacktrace
iterator
I mean you can freely create custom events
But you can't inject code to fire them into NMS
stargets.removeIf(gate -> get.getName().equals(gatename))
Yes ofc but the change type event would not fire when I do setType
And i want the event because commands can delete blocks
Or the good old add to list and call removeAll later
But this looks like you should not use a List but a Map.
Yeah the super cursed semantic
Iterator, or removeIf, or use a second list and add the entries you wanna remove there, then loop over the other list, or a concurrent collection
Dont use it then
wut
removeif(candidate -> candidate.getName().equals(someGate.getName()))
hm?
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.
yes
Extension methods wouldn't help with that :p
Say I want a method that occurs when a player acquires an item. How would I set that up? I keep playing with the EventHandler but I don't quite fully understand it. I want something like this to occur when acquiring an item.
// Creates Abundance Diamond
public static void createADiamond() {
ItemStack item = new ItemStack(Material.DIAMOND, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Abundance Diamond");
meta.addEnchant(Enchantment.LOOT_BONUS_BLOCKS, 3, true);
meta.addEnchant(Enchantment.LOOT_BONUS_MOBS, 3, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
abundanceDiamond = item;
}
public static void abundanceAbility(PlayerEvent event) {
Player player = event.getPlayer();
Inventory inv = player.getInventory();
if (inv.contains(abundanceDiamond)) {
for (ItemStack itemStack : inv) {
if (itemStack.equals(Material.IRON_AXE) || itemStack.equals(Material.IRON_PICKAXE)) {
itemStack.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
itemStack.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
}
}
}
}
I still want that event tho 😭 welp its a dream that wont come true
Have u ever used the bukkit event api
PlayerPickupItemEvent
Nope, my only experience with modding and plugins is with Forge atm
unpopular opinion: spigot should have a native item builder
?event-api
Sadly won’t happen since its mutable 😭
Agree even tho i dont understand what its functions should be
just make it modify a mutable itemstack
Thank you! Y'all are a lot more informative and helpful then the Forge coders fr fr
Yeah but by principle if something is mutable you don’t really need a builder for it, i mean u can still add it, but its not as meaningful,
Forge coders is just looking at other source code and learning from it. The best way
I do agree tho it would be useful in terms of convenience partly
Ig there are cases in which a builder could still be useful
Yes for immutable objects its useful
I mean for mutable objects
unpopular opinion: spigot should have native mixins
well, usually it isn’t
There could be some edge case scenario in which it can be good
I like that opinion
Yeah all nice apart from debugging which can become hell
It's hell, but imagine the possibilities
Also, when will we get nms-less packet handling in spigot?
wym with that lol
Then I have to either use another lib or some goofy injections
I mean there is gonna be an injection somewhere
Whether its runtime or compile time
Anyway I heard packet events is good, tho I dont have any real experience w it
But can't spigot do it and give me some more conviniencing stuff?
the protocol is not stable lol, how would you make a decent api out of it
Last time I used protocollib I still needed nms because it wouldn't let me use the normal methods and forced me to use nms classes like Pairs and stuff
I guess spigot as a service could, but like, packet stuff changes from version to version, so its hella lot to maintain
Well yeah, but it's a very common thing to fuck with packets
Yup
Spigot/bukkit is known for deprecating all old stuff in favor for new stuff, but can't we get an exception with packets?
The issue as ZlataOvce also said is that its hella fkn unstable
and its the lowest level stuff that exists in mc
Will we atleast get tracking events from forge
And since spigot is trying to do everything and abstract everything to a high level, it becomes a bit goofy
I hate using packets 😭
Tracking events as in?
Don’t think any1 likes it
But its powerful when you need it at least
When a Player starts/stops Tracking an entity
Will it still work even if it's deprecated?
Also when custom block support
Very useful, especially when making server-sides for forge mods
when the new regitry api stuff is merged draco
Hmm, that might be possible to api-ify
The non deprecated one is EntityPickupItemEvent
Wait... so it might come soon?
I'm trying to get the player but not if the player is a killer?
@EventHandler
public static void abundanceAbility(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
Inventory inv = player.getInventory();
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.
https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
Will it support custom textures too?
hmm
Hard to say
The pr is just a draft
But its fully plausible :)
I mean since a lot of minecraft server side has leaned more towards resource pack magic, I’d say there are good chances
Well, that’s during when a player picks an item up
How do I calculate the trajectory of a bow?
It’s no directly bijective to players killing one another
It sort of depends on how charged the arrow is
how do you calculate it?
That's what I'm curious about. The non deprecated event is this:
@EventHandler
public static void abundanceAbility(EntityPickupItemEvent event) {
Player player = event.getEntity().getKiller();
Inventory inv = player.getInventory();
``` but it only triggers when a player kills the entity?
Regardless of killing another entity? huh. Thanks!
Remove the getKiller
Player player = (Player) event.getEntity();
Also check if its a player
Yeah, there is the PlayerDeathEvent and EntityDamagedByEntityEvent if u wna check damage hits and deaths
I'm just trying to check whether or not the player picks up a certain item
.
It is certain
In the event class name it says Player as a prefix so…
Oh wait
Its the entity one
Fuck me
Conclube pls read code before responding 😭
Yeah then you need sth like
if (event.getEntity() instanceof Player player) {
…
}
?ban @ivory sleet
I cannot let you do that. Self-harm is bad 😔
Is it advanced to calculate the trakectory of a bow, therefore what I need it for is to retrieve all the Locations the arrow will pass
Use math
hmm, yeah I think the trajectory of an arrow shot from a bow is actually calculated on the go
Since something could end up blocking it, etc
Like half way in yk
Well yeah
it is
It's called physics :p
You just shoot an arrow and it does physic
ya
But you can simulate said physics without the arrow
lol yeah, prob easiest way
Pretty sure it's just basic gravity + bounding box checks
yea, or just read about it on the internet lil fast
Well there is luckily a way to create custom blocks rn
But using itemdisplays / skulls is really too much work
I mean the api might offer resource pack functionality that is yet not in the api
but not more than that I’d suspect
What would one need
@quaint mantle answer this ^
Ok i will write it in a document and paste it here
I spigotted before
full of malware by KEK
Man replied to a message from july
Stuff that spigot needs (My opinion)
- More Events (BlockTypeChangeEvent, BlockDataChangeEvent, etc.)
- PDC for every Block
- Custom Blocks
- Custom Items
- Custom UI Texture (already possible trough fonts, but we need it as a feature)
- The custom stuff should be able to have a custom tag
- Builders (ItemstackBuilders, etc.)
Only my opinion
And what cannot currently be done with spigot api?
Uh read it
Component names
The events
but didnt choco have a pr for that alr olvio
I cant do it with spigot api
adding all the needed component stuff
Idk can't check without account
Yeah I’ll link u, sec
Doesnt pr mean personal record 😭
Yes he has
kekw
pull request
Pull Request when in the context of programming
Mainly the events and the custom tag i think
Yeah I need an account to view that
i dont think you can see them at all without an account
Ah, well its component stuff basically, for the stuff that used to miss it
Let's hope it gets merged soon 🙏
Yes pls
🙏🙏
probably a 1.21 merge most likely
when everything else gets merged, yea
Sent them an email about some of the ones I found pre-downloading all their stuff. No idea if they'll even do anything kekw
"we dont care" i bet
Well uh ignore world generation
so ive never been great with YAML so if someone could help me out that'd be wonderful.
oak_bark: "stripped_oak_log": to: "oak_log" costs: 1 drops: 'None' "stripped_oak_wood": to: "oak_wood" costs: 1 drops: 'None'
If I had this within a YML file how would i access it via java?
I need the names of the stripped_oak_log and stripped_oak_wood.
I currently have config.get("block_rclick_events.switch_block." + oHandItem) which returns the oak_bark class which Im pretty sure is either a List or Dict.
Maybe a 100k times if you load new chunks
for spigot configs it would be a config section
for the keys directly use getKeys
What do you mean i'd be a config section?
one sec
oak_bark: # This is a config section, can be gotten with getConfigurationSection("oak_bark")
"stripped_oak_log": # Also a config section but can be retrived from ConfigurationSection#getKeys(false)
to: "oak_log"
costs: 1
drops: 'None'
"stripped_oak_wood": # Same as above
to: "oak_wood"
costs: 1
drops: 'None'
Yea i currently have it in a YML pretty much exactly like that.
the comments explain stuff
switch_block: #Swap block on clicked with item (ex. Waxing, Stripping, and Rebarking)
oak_bark:
"stripped_oak_log":
to: "oak_log"
costs: 1
drops: 'None'
"stripped_oak_wood":
to: "oak_wood"
costs: 1
drops: 'None'```
also how does one use multi-line code in discord?
three backticks
you can use getConfigurationSection("block_rclick_events.switch_block.oak_bark").getKeys(false)
that would return the 2 strings "stripped_oak_log" and "stripped_oak_wood"
with no quotes
yes
Even better
Thanks a ton, currently making it so peeps can put bark back on the trees since it sucks when you accidentally strip a log lol
Set<String> blocks = config.getConfigurationSection("block_rclick_events.switch_block." + oHandItem).getKeys(false);
for (String temp : blocks) { //Loop Through all items
Bukkit.broadcastMessage(temp);
}
}
Should work
yeah
Thanks for the help, I dont usually store data in the keys names themselves so I wasnt sure what to do.
Well that’s if you want it deduplicated
How does this look?
@EventHandler (priority = EventPriority.MONITOR)
public static void abundanceAbility(EntityPickupItemEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
Inventory inv = player.getInventory();
ItemStack aDiamond = event.getItem().getItemStack();
if (aDiamond != null && aDiamond.isSimilar(abundanceDiamond)) {
for (ItemStack itemStack : inv) {
itemStack.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
itemStack.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
Bukkit.getLogger().info(itemStack + " was enchanted."); // check for enchantment
}
}
}
}
for (ItemStack itemStack : inv) what
Dang you enchanting their whole inventory
is that chatgpt code
You can merge the instanceof and the line below it into a single line on modern java
Assuming you do want to enchant every item in their inventory, that looks fine
no
No idea. Making a scraper though kekw
I was trying to enchant only the tools but ItemStack doesn't have a boolean filter for that. Closest is the getItem method but the Material enum doesn't include the tools and weapons in the getItem method
so next best option is just enchant everything or add a huge filter in the if logic
Use tags or enchantment targets
Or make a set of only the materials you want to enchant
create an enum that contains the items i want and just filter through them?
word
EnumSet is like a HashSet but for enums yk :)
But what about when we kill the enum!!!1
true :(
Maybe Sets.newSetFromMap(new IdentityHashMap<>());

Idk if the method is in guavas Sets, or if one exists in Collections
but yeaa
we dont kill it
just badly damage it
@Deprecated 
@Deprecated(forRemoval = true) is a better death
what's the reference to tags?
yeah important to explicitly set the annot data lol
?
declaration: package: org.bukkit, interface: Tag
^^
Thx!
Does anyone know how i can set the biome of a chunk (org.bukkit.chunk) with a net.minecraft.world.level.biome object?
The biome is custom
yeah it's nms exclusively
How does this look?
@EventHandler (priority = EventPriority.HIGHEST)
public static void abundanceAbility(EntityPickupItemEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
Inventory inv = player.getInventory();
ItemStack aDiamond = event.getItem().getItemStack();
// Set<Material> tools = Tag.ITEMS_TOOLS.getValues();
if (aDiamond != null && aDiamond.isSimilar(abundanceDiamond)) {
for (ItemStack itemStack : inv) {
if (Tag.ITEMS_TOOLS.isTagged(itemStack.getType())) {
itemStack.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
itemStack.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
Bukkit.getLogger().info(itemStack + " was enchanted."); // check for enchantment
}
}
}
}
}
doing that on monitor hurts
Sorry, my java is still elementary
why does in the BlockFormEvent
Block block = event.getBlock();```
return the same block? does somebody know how i can get the real new block, after the formevent?
use highest or no priority
Besides the priority, do you think it'll work?
what is it supposed to do?
so we can tell you if it would work
So when I pick up an "Abundance Diamond" it'll enchant all the tools in my inventory
lol all good
use Tag.ITEMS_TOOLS.isTagged(material) rather than creating a set
its cleaner, but other than that i think it should work
I updated it. How does it look?
wait are you looking for cleaner code, or are you worried about it working?
Working
testing it atm but I haven't even been able to enchant anything
so the enchanting part doesnt work?
Nope
did you test if the aDiamond.isSimilar(abundanceDiamond) fires correctly?
maybe you are picking up the wrong itemstack
you can add debug messages after each of your if's and see which fire and which stop your code
word
?
i'm checkign with new logger msgs atm
Is there a way to check for the lazily loaded textures on an ItemStack (such as player heads)?
Using "vanilla" spigot
What replaced level.chunk#getBiomeIndex and #markDirty() ? Looking at a tutorial for 1.17 but trying to update it to 1.20
what did getBiomeIndex return
It returned a ChunkBiomeContainer
looks like it was just removed
im guessing for data driven biomes
markDirty was removed too it seems
That sucks. This was the code I’ve been trying to update: ```
private void setBiome(int x, int y, int z, World w, BiomeBase bb) {
BlockPosition pos = new BlockPosition(x, 0, z);
if (w.isLoaded(pos)) {
net.minecraft.world.level.chunk.Chunk chunk = w.getChunkAtWorldCoords(pos);
if (chunk != null) {
chunk.getBiomeIndex().setBiome(x >> 2, y >> 2, z >> 2, bb);
chunk.markDirty();
}
}
}
I’m also using mojang’s remapping instead.
i couldnt see anything on mappings, check with ur ide and see if thers any methods that take a Biome that might reference setting it
Originally I was hoping to use ChunkBiomeContainer in hopes I could input the biome as an argument, but theoretically I could just use chunk.setBiome() instead right? The problem is it takes a Holder<Biome> instead. How might I convert this biome “bb” to this?
nope its a pack you can buy
@opaque scarab
Oh alr nice
@orchid gazelle got more code?
why does this not remove the player from the hashmap?
it does but somehow it doesn't```
uhm I got 500 lines associated with it lmao
is player a key or a value?
player is the key
bad probably
I also tried removing the value
Can you make it UUID instead to begin with/?
your hashmap isn't like final or static is it?
well I can but it should only apply to online players in the first place
my HashMap is static
Hmm, well if you got more code it would be easier to figure out
alright imma search for what may be important
you’re not reloading the server or anything?
no
it could be related to your map being static but I don't have enough info to go off of to really determine that
sessions.remove(player);
}``` is a method I am statically calling from another method independent from it
this cancel object is in the HashMap as the Value and may basically delete itself from the hashmap
Yeah sounds about right
now, whenever I throw off another call that checks for the value, it is still there
U doing anything async?
well I am calling the check if it is still there in an AsyncPlayerChatEvent
you should check if it has a null key
and its a regular HashMap?
maps are allowed to contain a single null key
the Key is still the player after I remove it
I let it print out the key entries on message
DaFeist
yes
public static HashMap<Player, ChatPrompt> sessions = new HashMap<>();
Try switch it to a concurrent hash map first and foremost
I am suprised you are not getting a CME here
because a regular hashmap may not at all be appropriate depending on what u’re doing in the async chat event
sorry what is a CME again?
done
but in some situations it may not get thrown
now im getting Caused by: java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null at java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1111) ~[?:?] at java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1102) ~[?:?]
well
well no it makes sense
you were using the same key, null all along
in the ChatEvent
1sec
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if(!ChatPrompt.inSession(player)) return;
ChatPrompt session = ChatPrompt.getSession(player);
boolean valid = session.procCurrentInput(player, event.getMessage());
if(!ChatPrompt.inSession(player)) return;
event.setCancelled(!valid);
}```
where did u print it
right before the first if clause
Ugh yeah thats weird
well, do I just remove key AND value now?
sessions.remove(player, this); like this
you could, but its probably due to how you are removing the stuff in that the value is doing the removing and the only thing that was keeping the value alive was the map, but the value can't go away because its being used
uhmm lol
the only acceptable thing that could happen here is the key turns null and the later the value should disappear if the object goes away
so do I make cancel() static and then invoke sessions#remove with sessions#get from the argument?
I’m already quite surprised you use a static hash map in a concurrent environment
it manages all sessions
you're asking for memory leaks
can only be in the map there if player is on server
and only one session per player
basically the issue you are running into is the whole self derefencing thing. Its not easy to setup an object to make itself null without issues and generally you need something else to make it null or go away
like that?
not sure if making it static would work, because all that does is makes the method stay in memory. I think your issue is more or less the map being static. But try having your value object use another object to do the removing
so the value isn't the one removing itself
well if it's static it isn't it removing itself
so I guess imma try that out rq
boom NullPointerException lol
yay it is fixed
thanks a lot! I would have had a hard time finding out what this is, as I already had for like 2 hours of debugging lmao
just calling java public static void cancel(Player player) { sessions.remove(player); } now


the proper fix though
is to make your map not static
and make methods to remove or add static instead
AKA encapsulation
then I have like a Singleton lol
no
you can make methods static for the removing so you can access anywhere without making the object istelf static
since that is what you want
that would have solved your entire problem instead of making a bunch of other methods static because your map is static
what Object is it associated then?
HashMap is an object
public class MyDataManager {
private final Map<UUID, Whatever> myMap = new ConcurrentHashMap<>();
public Whatever getWhatever(UUID playerId) {
return myMap.getWhatever(playerId);
}
public void putWhatever(UUID playerId, Whatever whatever) {
myMap.put(playerId, whatever);
}
public void invalidate(UUID playerId) {
myMap.remove(playerId);
}
}
ezpz
I am confused
map wrapper
yeah ok fair
it doesn't need to be static, but you are making it static because you want to access it easily everywhere. Instead you should make 2 methods that are static that interact with the map
well to be fair I am only making one method static for it
at the moment
^
DI it around
I am already wrapping it with getSession
just using sessions.remove twice outside ofi t
then getSession should have been static. All I am saying is your problem you had was because you made your map static and was using it incorrectly. There is a lot that goes on with map's and hashmaps beyond just the code you make
getSession is static
yeah that's fair
yeah I am not a fan of it either, but its not my project so all I can do is just explain the issue XD
imma change that rn
but that's still a singleton then
since I have to have that one manager lol
your plugin main class doesn't go away
so you can easily initialize a map there and it won't go away along with making methods to access it
plugin main class can be accessed statically
which is one of the few classes at the beginning where its acceptable to do that
does anyone know how to use packetsevents to update the weather?
No need
Playerweather is exposed in the API
then how do I do it after updating the biome?
Uh i cant buy vulcan
is there a way to increase npc size
i see that on the hive bedrock
but was wondering if it was possible in java
use a custom server side resource pack
How do I set the damage for a snowball?
Snowball.class,
player.getLocation().toVector()
.subtract(snowman.getLocation().toVector()));```
can someone help identify the problem from this crash report, the plugin started to heavily load the server and crashed it like this

you need to learn how to read crash reports
that crash report is actually vague to be fair however I have a pretty good idea what might be the cause of it
yeah me too 
which repository would you guys recommend if i want to make an api easy to import for others
maven central?
ItemStack item = new ItemStack(Material.NETHERITE_SWORD);
ItemMeta itemMeta = item.getItemMeta();
assert itemMeta != null;
itemMeta.setDisplayName(ChatColor.DARK_AQUA + "Excalibur");
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, "Excalibur"), item);
recipe.shape(" N "," N "," R ");
recipe.setIngredient('N', Material.NETHERITE_INGOT);
recipe.setIngredient('R', Material.BLAZE_ROD);
Bukkit.getServer().addRecipe(recipe);
} ```
my code is like this. My problem is that the name Excalibur in the "displayname" does not appear on my sword. can anybody help me?
you haven't set the item meta back to the item yet
getItemMeta() does not get the item meta currently on the item, it gets a copy of it
so changes made to this item meta dont immediately reflect to the item
?
Selfhosted or central
Central requires setting up pgp keys
You didnt set back the itemmeta
what about jitpack or is that unreliable
I want to register my nms entity so that it doesn't disappear so easily, but the problem is that entityplayer doesn't extend the EntityInsentient class. please help public void registerEntity(String name, int id, Class<? extends EntityInsentient> nmsClass, Class<? extends EntityInsentient> customClass) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { List<Map<?, ?>> dataMap = new ArrayList<Map<?, ?>>(); for (Field f: EntityType.class.getDeclaredFields()) { if (f.getType().getSimpleName().equals(Map.class.getSimpleName())) { f.setAccessible(true); dataMap.add((Map<?, ?>) f.get(null)); } } if (dataMap.get(2).containsKey(id)) { dataMap.get(0).remove(name); dataMap.get(2).remove(id); } Method method = EntityType.class.getDeclaredMethod("a", Class.class, String.class, int.class); method.setAccessible(true); method.invoke(null, customClass, name, id); }
Just register for maven central if you dont wanna self host
cool cool
Which version?
1.16.5
Try Grim instead
Oh, hello. can I ask you to take a look at the correctness of the method that I use to update chunks and weather?
Sure
private final net.minecraft.server.v1_16_R3.Chunk chunk;
public PacketMapChunk(final World world, final int x, final int z) {
this(world.getChunkAt(x, z));
}
public PacketMapChunk(final org.bukkit.Chunk chunk) {
this.chunk = ((CraftChunk)chunk).getHandle();
}
public final void send(final Player player) {
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(chunk, 20));
}
public static final void refreshChunk(final Chunk chunk) {
refreshChunk(chunk.getWorld(), chunk.getX(), chunk.getZ());
}
public static final void refreshChunk(final World world, final int x, final int z) {
final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
refreshChunk(world, x, z, players.toArray(new Player[players.size()]));
}
public static final void refreshChunk(final World world, final int x, final int z, final Player... players) {
final PacketMapChunk packet = new PacketMapChunk(world.getChunkAt(x, z));
for(final Player player : players) {
packet.send(player);
}
world.refreshChunk(x, z);
}
}```
int chunkXStart = c.getX() << 4;
int chunkZStart = c.getZ() << 4;
for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++)
c.getWorld().setBiome(chunkXStart + x, chunkZStart + z, Biome.SNOWY_TAIGA);
PacketMapChunk.refreshChunk(c);
}```
because I think it could have caused the crash above, what do you think?
Seems probable
You should know that the chunk itself is probably updated
But the packet telling the player that isn't sent
I think you could my approach with just teleporting the player to another world and teleporting him back a tick later
why is packets being messed with?
why do you want to buy vulcan?
Bc it is a decent anticheat
There're literal fly bypasses for it
And grim only false flags his non-major checks
better off just hiring someone to make you one for what you need
Like placing and breaking stuff
Yeah ok
is it possible to fix this code, it is very inconvenient when the player is teleported somewhere?
you don't need everything from the anti-cheats out there, most times you only need some very specific things
You know how terrible an anticheat made on request for 20$ will be?
depends what you are trying to stop
most of the stuff is do able from api only
again it depends. Lets say you have a mini-game, there is only very specific things you would only need to stop in such a scenario
?
Finding an existing ac is much better than hiring someone to do it
Doesn't matter
it does
I've been an ac dev for 2 years
So it really doesn't matter
If you only need a specific thingy blocked, you wouldn't be seeking an ac to buy
and I have been a dev with java since nearly its beginning, how long you been a dev isn't relevant in whether you need to stop all cheats that are not relevant to the game
if you don't have pvp enabled for example, why do you need an AC for pvp?
but I digress you know more I suppose so I will just go back to what I was doing before 🙂
can anyone help with this problem?
I don't really why you're doing World#refreshChunk
I don't think you understand that being in a certain field expands your knowledge about that field
But I guess pride isn't something I can argue with
The checks just wouldn't work then?
if I remove this, do you think there will be additional problems?
I am probably more versed in the realms of cyber security then 90% of anyone here, don't have to tell me but self proclaiming yourself as being better doesn't make you better
Most ac have a config capable of disabling checks
Well you're only supposed to refresh the chunks with a packet
So it could be the thing crashing your server
What?
You're talking about how self-proclaiming doesn't matter yet you
Do it yourself?
Do you even pay attention to what you write
I was trained in the military which I can prove and have done so
so its not a self proclomation
And you didn't even take into account what I've written before
How the fuck does that matter?
Now you're just throwing words
Disprove this
I understand I can't register nms PlayerEntity?
Why would you need that?
Are coding a completly new entity, with a new hitbox and texture?
but have you ever won against jamer oliver in monopoly?
the entity disappears when I log out of the server even though I have @EventHandler public void onEntitySpawn(CreatureSpawnEvent event) { event.getEntity().setRemoveWhenFarAway(false); }
Who's that
it has been a very long time since I have played monopoly so I am not entirely sure lmao
You could just do LivingEntity#setPersistent(true)
And I assume you'd be fine with using an already existing mob
World#spawnEntity
And just put like Zombie.class
Or whatever mob you wanna use
public void onSpread_GlowBerry(BlockSpreadEvent e) {
BlockState state = e.getNewState();
BlockData bd = state.getBlockData();
if (bd.getMaterial() == Material.CAVE_VINES) {
state.setType(Material.CAVE_VINES_PLANT);
}
}```
the block doesn't change even if it matches the if statement. how can i fix it?
the cancellation is normal, but it looks like CAVE_VINES is growing even though I set it to Material.CAVE_VINES_PLANT.
I quite want something that works along with commands
/tp player 0 0 $scoreboard players get player Zcord$
i just want to do a plugin that can look at every commands, and change whats between $ by numbers and also give the command back to minecraft
i know that a /tp is ez to recreate so i could just overide it
but i quite want to use it in /execute and stuff
also i just want to know if it's possible
You can use the Preprocess event to catch and modify commands
thx
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
Hello, how can I check if a block isn't complete? (like a flower or grass)
Probably cast it to some class that I forgot
get the block state I think
and then cast it to some class that is related to growth or damageable or something
maybe !isSolid()?
that is probably for when you want to check if the block is solid or not
like water
then, I'll except fluids
isSolid checks if you can place against sth, so a layer of snow is solid
perfect, exactly what I want
but not for flowers 🤔
flowers should be solid too
is it possible to stop certain logs with specific text to not show in the console? (smthing like Console Spam Fix)
Spigot uses Log4j to log console output, hence making it easy to listen to incoming console messages, or to block certain console messages from appearing. Prequisities You need to have Log4J on your classpath. We simply add the dependency to our pom.xml using the provided scope, as Spigot already contains those classes on runtime: Create...
can u force any head to not even place not even for a split second like hypixel?
maybe cancel the interact event
that places it for a split second
i want it to be like adventure mode
but wihtout adventure mode
you'll need adventure mode
Theres no way
Ah yes, ignore the errors that you need to fix.
same topic
i'm using preprocess and it seems promising (thx Olivo)
But in:
/execute as @a at @s run tp @s 0 0 $scoreboard players get @s Zcord$
how do i know who is the @s in the $ $?
and sometime it gets even more complexe so I can't recode every @
||for exemple:
execute at @a[scores={OpNum=5..13},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick"}}] as @s run tp @s ^ ^ ^$scoreboard players get @sZcord$||
Bukkit.selectEntities
thx
that evaluates the @s (and others) into a list of entities
How do I make a fake player appear in tab to certain players, with a skin on? I'm trying to hide players (including armour) from specific other players, and the only thing that seems to do that also removes them from tab
You'd need to change their skin I think
Hey, I need help with a scoreboard plugin. Why do all player have the same scoreboard, even tho I use Bukkit.getScoreboardManager().getNewScoreboard()?
I'm talking about displaying a fake player because the real one is invisible, not changing their face in tab
Ah
I think you would needed to add a player into the world for that since that's linked to tab, atleast that's how I remember it being
does it exist for command blocks?
Hello, how do I fix when I using a lobby created by /mv import (name of file). how do I make so new people spawn there instant when they join and not to the ''world'' (using multiversecore)
getNewScoreboard creates a new scoreboard
You need to still have it cached somewhere else its gonna get gcd
And you then you also need to set it explicitly
Is it new year bug or em I missing something? But plugin file size limit went down to 2MB for spigotmc uploads.
My guess php.ini got a reset and all files got hard 2MB limit
thats what I do. It doesn't work.
@worldly ingot
Ah, possibly a bug due to the upgrade. Will let md know
4.5mb
8 for free 4 for prem
md did some upgrades to PHP so ye. Probably that
not the other way around?
i never reached the limit
It probably is the other way around - why would premium resources have less storage than free ones?
please help. the nms entity disappears when I log out of the server even though. also I have @EventHandler public void onEntitySpawn(CreatureSpawnEvent event) { event.getEntity().setRemoveWhenFarAway(false); event.getEntity().setPersistent(true); }
Load and unload the entity yourself
What do you mean and how?
how?
well, actually this problem was even before I updated chunks to change the weather and I still don't understand what I need to save and how
Hi, does any have a Minecraft server stresser bots software ? I want to test my plugin with a lot of players on local ? my version is 1.18.2 I didn't found anything on the internet up to this server version, thanks
you want me to re-spawn the npc when the player relogging? but what about the other players who will stay on the server
re-spawn when necessary
is there a better way to do this so that all players can see the nms entity and it is visible to everyone until it is killed?
Look around in the internals and see how it's handled
You're working with NMS you need to be able to read the code yourself
I looked at the codes of other npc plugins but did not find what I need
You could just use an existing plugin like Citizens if you don't know how to read NMS code
Hello, how do I fix when I using a lobby created by /mv import (name of file). how do I make so new people spawn there instant when they join and not to the ''world'' (using multiversecore)
solution is @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { if (EntitySilkworm.summoned) { PlayerConnection connection = ((CraftPlayer) event.getPlayer()).getHandle().playerConnection; connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, EntitySilkworm.entityPlayer)); connection.sendPacket(new PacketPlayOutNamedEntitySpawn(EntitySilkworm.entityPlayer)); } }
Yeah
Does look like your code contains some static abuse or not following naming conventions
Yes
is there a class for inheriting from an ifrit entity?
ifrit?
what is an ifrit entity
You mean blaze?
ifrit?
just extend the blaze class?
Ig man just didn't know what a blaze was called in english lol
I just used the Russian name and didn't find the class thanks
1.20.2 code of someone cancelling the same event
does anyone know?
Hello! now this code gives a vector / block, I would have liked a more detailed list, so more vectors how do I do it? So the goal of this is to retrieve the projectile's Trajectory 🙂
I think it actually is a paper only feature, the lower event does the same using spigot/bukkit only it seems(?)
player death event is has the setCancelled on paper not spigot
Well, so my suspicion was true
i see
And you need the entity damage event and see when the player basically dies
so does this plugin just need to be a paper one?
if you want the easy way to cancel yeah, if not use the damage event and do the math
Either you use the entity damage event solution or you can switch to paper
interesting
But you'll have to ask for support at paper if you use paper
also don't release your plugin on spigotmc if it doesn't support spigot
thanks
thankfully there is hangar these days
Is there a way to deactivate the slot highlight for certain items when hovering over them in the inventory?
heresy!
I just started using Mojang Brigadier and one problem i have is that CommandSourceStack does not exist. I'm using 1.0.18 (latest), and i don't really know what to do. Any ideas on how could i fix that?
A lot of types are defined under server internals
Hey, is it possible to disable skins when the players join? in a plugin?
i think it is, with packets, i dont know how tho
What do I do to make a player completely invisible to others, but not in tab?
maybe Player#hideEntity(otherPlayer)
no
not sure if it works on players
then there wouldnt be a player in tab
i thought that only applies to hidePlayer
i am not sure though lol
i guess @storm scaffold has to try
hidePlayer and hideEntity both seem to make them disappear in tab
cometcake why dont you just use invisibility
you can hand out infinite invisibility without particles
then there would be a player in the tab lsit
Because I want to hide their armour too
You could possibly use hidePlayer and make them reappear on the tab with a plugin lika TAB, if that's possible and if you're just doing it for yourself
I'm making a plugin to upload, so I'd rather not have to use other external plugins, is there a way to do it inside the plugin?
Alternatively you could block the spawn player packet from getting sent
How do I do that?
Have you not thought of just sending an add player packet and spawning the player in some ass of the world or is that not an option?
You could take a look at protocollib, there are surely some tutorials available out there
I don't know how to send packets, ideally I'd just hide the player and keep them in tab though since there's less to deal with - is there a way I could intercept the actual player's packet and hide them?
Is there a way to do it with NMS? I'd rather not have any dependencies, and I already need to use NMS in the plugin for another part of it so it wouldn't make any difference
there is
there always is
what's wrong with just sending an entity destroy packet
it'll still appear on tab
How do I send that though?
with nms
Players will flicker when they spawn
:)
Someone knows a Annotation based commands libs?
ACF, Cloud command
k thanks
what about intercepting that packet?
I have found this for 1.8.8 https://www.spigotmc.org/threads/nms-1-8-8-how-to-read-intercept-packets-before-the-playerjoinevent-is-called.506881/ but it should be similar for the newer versions
Maybe there's an up-to-date tutorial available somewhere
remember NMS changes every version
Yeah, so you'll have to do some funky stuff to keep it working
yeah you wanna avoid using NMS. It gets messy ( https://blog.jeff-media.com/maven-multi-module-setup-for-supporting-different-nms-versions/ )
With protocollib you could do that more easily while supporting cross-version
yeah listening to packets is one of the few situations where I'd also use protocollib
So I am trying to create a method that goes through the players inventory and names everything, (this is for testing). However, it only names the items in the player's hotbar. Any suggestions on getting the players complete inventory?
@EventHandler
public void itemPickupEvent(EntityPickupItemEvent event) {
Player player = ((Player) event.getEntity()).getPlayer();
Inventory inventory = player.getInventory();
for (ItemStack item : inventory) {
player.sendMessage(item.getTranslationKey() + " is in your inventory.");
}
}
is there a way to preprocess a command executed by a command block??
I know there is PlayerCommandPreprocessEvent.
Should i create a fake player (somehow) then make him execute every command send by a command block?
any other idea?
new WorldCreator(World).createWorld(); expects just the folder name in the server's directory or absolute path?
declaration: package: org.bukkit.event.server, class: ServerCommandEvent
tysm
Intercept packet
What do you think cancelling the BlockPlaceEvent does? :p
You just can't. The client makes predictions and places the block. So unless you're in adventure mode, you cannot stop that single tick placement. The server is the one saying "no no no, your prediction is wrong" and sends back a packet saying otherwise
You have to stop it in the client to begin with, which you do with adventure mode (or the CanPlaceOn tag of an item)
can anyone help me with plugin messaging?
im trying to check their bungee server thru bukkit
What is better:
Having multiple Queues (3) with different types of objects
or
Having one Queue that accepts "Object" (any object) and using instanceof when looping through the queue
If the objects are each your own defined types, maybe making an interface for them is better. Otherwise, maybe a wrapper type. If they're all distinct from one another, three separate queues is fine. It depends on the situation
do yall think executing a discord webhook would be laggy
Im trying to figure out what is causing lag in my code
Wrap webhook.execute() in bukkit async task.
Unless it's async already in which case whatever, but yeah. Just be sure your web requests are done asynchronously
issue: im executing it quite often and I dont want to slow down my code
fix: Get better internet
Try time travel
see if it slows down my stuff
unless you are spawning hundreds of threads, doing something async will not change the speed at which it runs
should I be unit testing exceptions
Async math
like illegal state, nullpointer, etc
Async rendering
Depends on how thorough you want to be with your unit tests
We test some exception throwing in Bukkit tests, but sometimes we just want that thoroughness
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/test/java/org/bukkit/MaterialTest.java#36
I create a new thread every time I send a message to my player so it arrives faster
yeah keep doing that
also
public class FileJsonConfigDao implements ConfigDao<JsonObject> {
@NotNull
public static FileJsonConfigDao newInstance(@NotNull Path configFolder, @NotNull Gson gson) {
return new FileJsonConfigDao(configFolder, gson);
}
@NotNull
public static FileJsonConfigDao withTypeAdapters(@NotNull Path configFolder, @NotNull Map<Type, Object> typeAdapters) {
GsonBuilder gsonBuilder = new GsonBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting();
typeAdapters.forEach(gsonBuilder::registerTypeAdapter);
return new FileJsonConfigDao(configFolder, gsonBuilder.create());
}
@NotNull
public static FileJsonConfigDao createDefault(@NotNull Path configFolder) {
Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting().create();
return new FileJsonConfigDao(configFolder, gson);
}
private final Path configFolder;
private final Gson gson;
private FileJsonConfigDao(@NotNull Path configFolder, @NotNull Gson gson) {
Preconditions.checkNotNull(configFolder, "Parameter configFolder is null.");
Preconditions.checkNotNull(gson, "Parameter gson is null.");
this.configFolder = configFolder;
this.gson = gson;
}
Would static constructors be appropriate here, this is kinda of more of a "internal" thing
Factories
I thought abt it
I'd call newInstance within your methods though
wdym
@NotNull
public static FileJsonConfigDao createDefault(@NotNull Path configFolder) {
Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting().create();
return FileJsonConfigDao.newInstance(configFolder, gson);
}
type deal
oh
and I'd prob call your withTypeAdapters(Collections.EMPTY_MAP) or sumn
basically if you were to change any of the methods the others should adapt to the new changes
Yes but it will clog up the threads
then use a single thread Executor so it keeps one alive instead of spawning one every time you need it
look let me explain how my code works
lol
You can make Queue
Every n ticks head of queue poped and processed.
How would I go about checking the ItemStack value of an item that I pick up? I've tried the following statement but nothing happens when I pick something up.
@EventHandler
public static void itemPickupEvent(EntityPickupItemEvent event) {
if (event.getItem() == ItemManager.abundanceDiamond && event.getItem() != null) {
Player player = ((Player) event.getEntity()).getPlayer();
Inventory inventory = player.getInventory();
for (ItemStack item : inventory) {
if (item.containsEnchantment(Enchantment.LOOT_BONUS_BLOCKS) || item.containsEnchantment(Enchantment.LOOT_BONUS_MOBS)) {
player.sendMessage("Enchantments have already been added");
} else if (item.getType().equals(Material.IRON_AXE) || item.getType().equals(Material.IRON_PICKAXE)) {
player.sendMessage(item.getTranslationKey() + " is in your inventory.");
item.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
item.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
player.sendMessage(item.getTranslationKey() + " is now enchanted.");
}
}
}
}
ItemStack.isSimilar
Although pdc is probably better
omg this mongodb async library is so shit im going insane
does anyone know if i can even tell if it connected successfully
Prob js lib copy paste
MongoClient client = MongoClients.create(null);
client.listDatabases()``` doesnt even throw an error
You can actually use sql
huh
Does anyone remember some project that uses classical gradle shading out of the top of the head?
Okay figured it out - it's something along:
task uberJar(type: Jar, dependsOn: remapJar) {
archiveClassifier = 'remapped-all'
from remapJar
configurations['uberDependencies'].forEach {
from zipTree(it).getFiles()
}
}
Obviously that doesn't work yet but the idea is there
Why not just use shadow? Otherwise you can just create a custom configuration (eg call it shaded), then configure that task to „collect“ the jars with ziptree thingy
Didn't know whether that would work with my setup
Opted for the safer option
Create a task of type Jar that collects the ziptree of all dependencies that have your custom configuration
Well or just let it collect everything thats scope implementation or whatever
Yeah, I only need to set the duplicate stuff strategy and remove dependencies that shouldn't belong there
Thats why i‘d create a custom configuration for the shaded stuff
Yeah, but transitive deps are here to mess your day up
Yes probably:')
Actually my approach does not work as it puts everything in the root directory by default... Somehow
configurations { shade }
dependencies {
shade "groupid:artifactId:version" // optionally exclude transitive stuff or whatever
compileOnly "groupid:artifactId:version"
}
tasks.register<Jar>("shadedJar") {
from(configurations.shade.collect { it -> it.isDirectory() ? it : zipTree(it) })
}
shouldnt sth like that work?
Yeah that is the approach I'll go with
Does the Inventory class only relate to the players hotbar?
no
It relates to any "gui"
As in horses, villagers, chests, brewing stands, furnaces
They all have inventories
Ah
gotcha
just dug through the javadoc and found what I was looking for as well lol
should varchar be uppercase
no
ok
yes for me
if you want to follow the semantic rules or whatever it is called then yes
ah so its something similar to “variable names must begin with lowercase”
Where it isnt required
yeah, it helps distinguish what is keywords and what is not in the queries
and you already do it in your queries partially
with the CREATE TABLE statement might as well keep consistency 😛
also you can reduce your columns
just store location either as a string or a base64 string
then you can remove all those columns and have a single one for location
if you store as a normal string, you just expand on every ,
