#help-development
1 messages · Page 464 of 1
YamlConfiguration.loadConfiguration
okay so, i'm working on an SQLite database for my plugin and i was wondering if i should store all the information in a Map instead of retreving the playerdata everytime the player joins. And if i dont do that how would i make leaderboards since it wouldn't be stored on a map therefore cannot sort without retreving all the data again which doesn't seem like the best way. But if i make it all load onto a Map it'll use up alot of ram
i need someones opinion
Load player data when they join
Use a query to make a leaderboard
You can cache said leaderboard and refresh it regularly if you wish
okay, you are referring to putting it into a Map / TreeMap for top 10 players
correct?
and make it update every like 5 minutes or so
Mhm
okay, thank you. I will work on that
Is it possible to put components on itemstack lores and if it is, do translatable components work in lore?
With nms it's possible?
Yes
I'm trying to save a list of Enum names to a config file. Not sure how to do it. Here's what I have:
config.set("Attributes", itemData.getAttributes());```Here's what it does:```java
Attributes:
- !!me.combatborn.realms.mechanics.realmitem.ItemAttributes {}
- !!me.combatborn.realms.mechanics.realmitem.ItemAttributes {}
- !!me.combatborn.realms.mechanics.realmitem.ItemAttributes {}```
Any suggestions?
Thank you
That sounds interesting, if you get it done please send it hear sounds really cool
Hopefully that api will come through soon
How?
I can’t really give much direct advice without the code in front of me
But you should be able to convert bungee components into their minecraft counterparts, and then work with them directly with the NMS version of an ItemStack
Alr ty
I'll have a look
Any ACF tryhard online again?
Is it possible to hide a subcommand in autocomplete, like when a player starts typing a subcommand it doesn't show in the list
So a "hidden" but available command
Yes
It's annotation whose name I forgot
go to the wiki, they have an Annotations section
can I register a service provider during onLoad
or do i need to wait until onEnable
i want other plugins to be able to load my service during on load
What Nat told you is poop. Just use "@nothing" as second completion parameter.
So
@CommandCompletion("@contacts @nothing")
And dont use a String... at the end.
Just use a String. The last String can contain spaces on default.
@Subcommand("text")
@Description("Text a contact.")
@CommandCompletion("@contacts @nothing")
public void onTextCommand(Player sender, String phoneNickname, String message) {}
The phoneNickname is single on default and message will contain the rest of your input
💀
Will do the changes right now
I have a question
I know that UUID doesn't have a serializable option
So I'm pretty sure using UUID.toString() is the best way
Would it be worth making a class that extends UUID and implement Serializable into that
You can serialize uuid to 2 longs
To straight up serialize it instead of toString
"best" in terms of readability.
But in reality a UUID is just a 128bit number and can be stored in two 64 bit longs.
Yes
Is it that much better than just a String?
Yes
Wait so you're saying on a big program, storing UUID as 2 longs would be noticeably better than 1 string? performance wise
I can imagine having to split it into 2 longs is.... tough for the eyes
And for performance it depends on your persistency system. How good can you handle 128bit numbers
If your program serializes and deserializes them a lot
??
And could probably have a custom UUID which is just 64bits
You can
128 seems overkill
Just let the first long be 0
How many uuids are you storing
Technically
If your serialisation system relies on reading two strings and parsing them into two longs then
the performance might be not too far off from just storing a single String.
what even are 'yall on about
uuids
With 64bit you couldnt even create enough minecraft accounts for 1/4th of the human population
meh. If you store it as bytes then i would def prefer the msb/lsb approach
128 bits is nothing
also possible but in the end of the day it doesnt really matter
5.3 x 10^36 possible choices
fun fact: it is not
tf really
if you aren't gonna do it multiple million times at once its wayne what method you choose
is this a microoptimization
yes it is
(maybe)
What’s that like 8k uuids in a megabyte
1,099,511,627,776
0.12mb
Yes
you can get a 240gb ssd for 15$
1,073,741,824
that's about 1$ / billion uuids
what a deal
It’s more than that
2^128
are we topic hopping or what are we on about rn
Didn't we just say it was hex
3.4028237e+38 -> 2^128
1.8446744e+19 -> 2^64
4294967296 -> 2^32
That definately seems overkill for... anything
But I guess I'm wrong
I’m sure people said that about ipv4 too
UUIDs are meant to be universally unique
Same thing
So I don’t want any uuid collisions with any aliens out there
"Nobody will ever need more than 640k RAM"
You can't compare 4.3bil with 3.4028237e+38
say that to my java program
Keep in mind every entity you spawn in minecraft has a uuid
you'd need 2^65 exabytes to store all the uuids that could ever exist
keep in mind that UUIDs aren't only used for minecraft
Still less than the number of ways to shuffle a deck of cards
yeah stay native
We were just talking about micro optimizations
Use int or sumn
Use a byte
better go machine code
256 options, take it or leave it
Cause instead of storing a UUID as 2 longs, you can most likely get away with just as 1
or write it on paper
I think assembly is indeed the better choice here
no its not
aren't UUIDs like impossible to collide because the first part is timebased
they can collide
in what scenarios
lol
ah per second
"Thus, the probability to find a duplicate within 103 trillion version-4 UUIDs is one in a billion. "
section .data
uuid db 0x10, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x40, 0x00, \
0x80, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00
section .text
global _start
_start:
; Call getrandom() to generate 16 random bytes
; into the "uuid" buffer
mov rax, 318 ; getrandom system call number
mov rdi, uuid
mov rsi, 16
mov rdx, 0
syscall
; Set the UUID version to 1 (time-based)
mov byte [uuid + 6], 0x10
; Set the UUID variant to the RFC 4122 variant
mov byte [uuid + 8], byte [uuid + 8] & 0xbf | 0x80
; Call uuid_generate_time_safe() to convert the
; random bytes into a time-based UUID
push rax
lea rdi, [uuid]
call uuid_generate_time_safe
pop rax
; Print the UUID in hexadecimal format
mov rdi, uuid
mov rsi, 36
lea rdx, [uuid_str]
call uuid_unparse_lower
; Print the UUID string to stdout
mov rax, 1
mov rdi, 1
mov rsi, uuid_str
mov rdx, 36
syscall
; Exit
mov rax, 60
xor rdi, rdi
syscall
section .bss
uuid_str resb 37
This is the way
gotcha
Did you write that
Of course not
chatgpt ftw
TLDR of micro optimization
Just use UUID
I'm curious if it actually wrote it correctly lol
Also there is the probability in creating a duplicate on first time as well as shorter times just because
Does anyone have an example implementation of a command that has a [NEXT PAGE] when there's too much stuff to display in 1
https://paste.md-5.net/jefuqesija.java @regal scaffold
Interesting
Thanks!
And last question for the night
Lets say I want to store a simple "date" in a object that gets written to a file:
DD-MM-YYYY-TIME
dateTimeFormatter.format(LocalDateTime.now())
I assume this is not serializable
It should be possible to just store it as a timestamp
Provided you don’t need to go earlier than 1970
SImplest way is System.currentTimeMillis()
I need something more readable
Well then you cant use a timespamp
Could I just store it as a string?
Use Instant now = Instant.now()
It can be serialized pretty easily
idk how hard it would be to convert it back
Oh
Ok
map.put("timeSent", timeSent.toString());
Instant timeSent = Instant.parse((String) map.get("timeSent"));
Logically makes sense I wonder how the format is
Shouldn’t be too hard to format System.currentTimeMills into something readable
Any preferred collection system to be able to sort Collection<Object> by a field inside the object?
DateTimeFormater should work
I was using this just not sure if it's serializable
I think if I make my Object implement Comparable<Object>
You have to serialize the Instant using the DateTimeFormatter#ISO_INSTANT
If you want to parse it again
Ohhh ok ok
Instant now = Instant.now();
DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT;
String serialized = formatter.format(now);
Instant deserialized = Instant.parse(serialized);
If you’re able to keep it stored internally as a long I’d do that
And then parse it when displaying it to players
Indeed
Pretty slick
Any preferred collection system to be able to sort Collection<Object> by a field inside the object?
Like lets say I want to keep the list organized
Do you want it to automatically sort
Sorted by, what we just did, date
PriorityQueue for example.
Or TreeSet
Yes!!! I forgot about those, I couldn't remember the name
You just need to pass a Comparator to the constructor
@Override
public int compareTo(Text other) {
return this.timeSent.compareTo(other.timeSent);
}
Are you sure I can't just implement Comparable<Text>?
public static class SomeClass {
private final long timestamp;
public SomeClass(long timestamp) {
this.timestamp = timestamp;
}
public long getTimestamp() {
return timestamp;
}
}
private final TreeSet<SomeClass> sorted = new TreeSet<>(Comparator.comparingLong(SomeClass::getTimestamp));
Oh yeah. You can also let your class implement Comparable<Self> and not pass a comparator
Sickkk
Is Set<?> serializable
How can I know if it is
I want to be able to stop asking
Looking at the javadocs is there any way to tell?
But how can I know without having to ask each time, there's got to be somewhere to look
And if it's not... annoying
?jd-s
Try it out. Havent used spigots serialization in a while.
If not then try adding set.toArray()
There's really no way to know looking at docs/implementation?
Well classes will implement ConfigurationSerializable
But obviously java classes don’t have that
Other than that Map and List are natively representable in yaml
Spigot handles various objects from the standard java library
I’m not sure if they are listed anywhere
So if it’s a Bukkit object check for the interface
If it’s a standard java object then yeah, idk
I do know all primitives work, as well as lists and arrays
I’m sure there is more
set.toArray will do
If I'm doing toArray to serialize
What am I deserializing to
List and then passing it to the TreeSet i guess
There is no diff between array and list in yaml
Oh
Set<Text> phoneTexts = new TreeSet<Text>((List<Text>) phoneData.get("phoneTexts"));
Jesus lol
Call getList
hello, is there a way to set the light level without using light blocks
Oh wait I still need to cast
Not with the api
You need to cast as well
Does it even matter then?
I'm brain melted for tonight
I need sleep
Thanks for the help
I can say tho
It worked
Like a charm
Jesus
That is so damn cool
Opinions on Adventure?
Alone it’s not much different than bungee components
But if you use minimessage to parse stuff it can be quite useful
I searched on how to do BaseComponents with config files and the first answer was using Adventure was a good option
TextComponent.fromLegacyText go brrr
adventure probably is the better option bc u can use minimessage for some cool parsing
like clickable text and hover stuff
all stuff u can do with Spigots components too, but no built-in parser :v
how do i delete a world
after unloading it
i call bukkit#unloadworld(world, false)
and listen for worldunloadevent and delete the folder when done
it doesn't work on restart
Thanks ❤️
@Override
public void onEnable() {
// ...
ItemStack other = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta meta = other.getItemMeta();
meta.addEnchant(Enchantment.DAMAGE_ALL, 5, true);
meta.addEnchant(Enchantment.FIRE_ASPECT, 2, true);
meta.addEnchant(Enchantment.SWEEPING_EDGE, 3, true);
meta.addEnchant(Enchantment.DURABILITY, 10, false);
other.setItemMeta(meta);
Map<String, Object> serialized = other.serialize();
serialized.computeIfPresent("meta", ($, meta1) -> {
ConfigurationSerialization.deserializeObject(meta.serialize(), ItemMeta.class));
}
System.out.println(ItemStack.deserialize(serialized));
}```
Why does serialized ItemMeta not serialize back properly via ConfigurationSerialization? Result:
```[Server thread/INFO]: Expected: ItemStack{DIAMOND_SWORD x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, enchants={DAMAGE_ALL=5, FIRE_ASPECT=2, SWEEPING_EDGE=3}}}
[Server thread/INFO]: Actual: ItemStack{DIAMOND_SWORD x 1}```
this is on 1.19.4
Figured out the issue, the format of serialized ItemStacks must have changed at some point
item meta used to be under the key "meta", now it's "UNSPECIFIC_META"
Why would you need packets for title????
?jd-s
declaration: package: org.bukkit.entity, interface: Player
That doesn't sound right, are you confusing with .toString
It serializes back correctly after changing it to that ¯_(ツ)_/¯
I'm only using the #serialize methods
Are you using spigot spigot or something else?
If I had to guess different servers could produce different outputs
strange
For what purpose are you doing this?
gson deserialization via Bukkit's ConfigurationSerializable API
though i just realized i was printing the string value of the item stacks rather than the serialized maps after all, lol
I'm still looking into it more
Have you tried simply throwing the map into gson?
err. personally, no. but afaik that would throw errors because ItemMeta is just an interface
Unless I'm misunderstanding what you mean
Readability is preferred since it's part of the main config
Then you should not use json...
¯_(ツ)_/¯
I can't see my arms, hotbar, and others when i do Player#setGameMode(GameMode.SPECTATOR). How do i make them visible while in spectator
That's the normal behavior of spectator mode, and pretty sure it's clientside
oh so how about hypixel? how do they do that?
They simply hide the player from others
Yea how?
Nobody can answer that for you.
But the spigot way is just Player#hidePlayer(Player)
oh so i hide one player to another player
If I had to guess - some packet shenanigans.
Nothing too complicated
I'd not recommend that route though unless performance is important
hey guys
hello there
can somone tell me how to check blockstate ? (i wanna know if a furnace is lit or not)
i tried e.getBlock().getState()
but when i do BlockState. there is no block State To compare
Is there a way to do it without nms and packet?
So ((org.bukkit.block.Furnace) e.getBlock().getState()).getBurnTime() > 0
oh lol i was trying to cast BlockState. itself , thx a lot mate <.3
quick questoin
I have 2 types of a block in my plugin when i they both are supossed to triggera diffrent listeners. Whats the best identifier to set for the listeners to regonize them
What type of blocks
Barrels
In this specific case you could store data in the PDC of the barrels
oke
hey guys, can someone tell why when i cast a block when i call its method its doesn't return anything ? i mean
why this work
but this one doesn't
Bukkit.getServer().getPlayerExact("__Mental_").sendMessage(((org.bukkit.block.Furnace)e.getBlock()).getWorld().toString());
Hey, ive never really understood how these namespaced keys work when im creating a recipe or using the persitentdatacontainer on items.
Is it valid to use NamespacedKey.minecraft("recipe_name") or should you use new NamespacedKey(this, "recipe_name") (or "item_name")?
What is the difference?
One adds minecraft as the namespace the other uses your plugins name.
Okay but what actually is a namespace and is it recommended add stuff to minecraft's namespace?
okay, why are you not supposed to add stuff to minecraft's namespace?
okay
You should not add keys to any other namespaces than your own in general
shouldnt the method be deprecated then or something?
It’s not an old festure
It has its use cases if you want to create namespaced keys for minecraft resources
It’s useful when you know what to use it for.
examples?
vanilla recipes
can you explain more ? i should throw what exception ? and is this a proper way to do it ? i wanna check if a furnace is lit or not by casting it to furnace and the get the burn time
Cast the BlockState of a Block to Furnace and check
thx mate
if im making an RPG plugin, I obviously need to hold some additional variables that "belong" to the player object. My solution to this is basically creating a PluginPlayer class that holds my additional data. Of course then I need a way to get a PluginPlayer from a player since all bukkit api gives me are regular Player objects so I store a map of UUID - pluginplayer pairs for all currently online players and pass that in to whatever needs it. Am I on the right track with this or is there a more elegant solution I'm missing.
im a bit of an amateur
This sounds like the proper approach. A manager class which holds a Map<UUID, RPGPlayer>.
should my "RPGPlayer" hold a copy of the Player object too? That was my original plan but I feel its not needed at all
please make agility less grindy if you implement it btw
Never hold references to live objects like Player, Entity, Chunk etc.
If you need a reference then use an identifier like the UUID.
I would add the players UUID so that you can actually get back to the player
object when needed.
that was what I figured, would you care to explain why not to hold live objects
doesnt need to be basic explanation or anything
I like to learn
for context the player one is invalid as soon as they logout
they're fragile
that could be handled
It easily leaks memory by preventing the garbage collector from collecting it
these objects usually have a lot of state
that makes sense
WeakMap
which is works but is still gc dependent
it will get gced, the question is when
Has anyone here sent custom advancement messages? Im a bit lost.
public static void sendAdvancement(Player player, ItemStack icon, Component title, FrameType frameType) {
DisplayInfo displayInfo = new DisplayInfo(icon, title, Component.literal(""), null, frameType, true, true, false);
Criterion criterion = new Criterion(new NotifyTrigger());
AdvancementRewards rewards = AdvancementRewards.EMPTY;
String[][] requirements = {{criterionId}};
Advancement advancement = new Advancement(identifier, null, displayInfo, rewards, Map.of(criterionId, criterion), requirements);
AdvancementProgress progress = new AdvancementProgress();
progress.update(Map.of(criterionId, criterion), requirements);
progress.grantProgress(criterionId);
ClientboundUpdateAdvancementsPacket packet = new ClientboundUpdateAdvancementsPacket(true, List.of(advancement), Set.of(), Map.of(identifier, progress));
ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection;
connection.send(packet);
connection.send(removePacket);
}
for a toast message? or just a custom advancement
Just the toast message on the top right corner
doesnt alex have a lib for those toast messages
So adding an advancement and then instantly completing it
yes which is a problem is u do certain types of test
and debugging where u use epsilon for instance
Where does he translate this into a packet?
one moment
well epsilon is a special type of gc that doesnt really free memory
Avoid writing the same code over and over again - use JeffLib for your Spigot plugins! - JeffLib/NMSHandler.java at master · JEFF-Media-GbR/JeffLib
ah
and problem with weakhashmap is also that it just doesnt prevent gc, like assuming gc doesnt sweep for a while (which can be the case for some gcs wherre it doesnt happen for a longer time), then the object can be strongly reclaimable also
I dont want to register the advancement anywhere. The message is steteless. This sadly doesnt help much.
Does bukkit store strong references to bukkittasks?
yes?
for some time yes
Until cancellation?
as long as they are scheduled ig
ye minion
Do any of you guys have a good reference that goes in depth on the garbage collector
So i can put bukkittasks in a weakhashset to cancel the ones that haven't been cancelled?
I have a rough idea but my brain doesnt work unless I fully understand things
Else they would just vanish into oblivion
You should in generall not worry about that
I wish it was so easy
I know calling cancel on a already cancelled task is fine
So what i really wanna know is if it's psossible for currently shceduled tasks to be gced
You said bukkit keeps a reference so i assume it isn't
I guess I'm just trying to understand what the inherent flaw would be with storing references to player objects in regards to the garbage collector
that storing references to "RPGPlayer" objects wouldnt have also
ZGC performs all expensive work concurrently, without stopping the execution of application threads for more than 10ms 10ms 😳
its configurable but ye
BaseComponent
As i know, the default bukkit api doesnt supports
Title creation with base components
The main problem is accidentally holding a reference to a player object when said player has disconnected. The object becomes invalid even more so if they reconnect. This is in essence a memory leak because you have retained something that was marked invalid
Okay I think I got you, to clarify if I create an RPGPlayer object when a player joins, I'd have the same exact issue if I didn't clean it up on disconnect
But so as long a single reference is held the gc cant collect it and dispose of it
Depends on your object. The player object is tied to server internals and api. Where as your object doesnt have to be
Think they are called block entities now
Feel free to ask more questions. Plenty of us here who are well versed. You can store a player object reference just really need to be careful and since it is easy to lose track where you have references, it is the reason we always recommend not storing the player object and instead uuid since that is still unique and can be used to obtain a valid player object if it is needed
Yeah I've already decided I'm going to go the UUID route, just makes more sense in every way.
I'm mostly self-learning to code and really trying to focus on doing things the right way
Well at least you are smart enough to actually seek out those who may know the answer instead of just assuming lol
And asking in a coherent and polite way
And that too
Well I was hoping to be able to conveniently customize the hover event, clickable events and colors from config
?pdc
Not sure if this mentions it
then yeah, Adventure :p unless u want to make ur own format&parsee
Json format, same as /tellraw is always an option
i think im gonna go insane
why is this so complicated
nothing makes sense
pls help
for blocks you can use CUstomBlockData
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
Alright thanks
xD
Yo alex, maybe you got an idea what im missing here. Im trying to send a toast message by simply adding it, sending
a completed progress in the same packet and sending a removal packet afterwards.
public static void sendAdvancement(Player player, ItemStack icon, Component title, FrameType frameType) {
DisplayInfo displayInfo = new DisplayInfo(icon, title, Component.literal(""), null, frameType, true, true, false);
Criterion criterion = new Criterion();
AdvancementRewards rewards = AdvancementRewards.EMPTY;
String[][] requirements = {{criterionId}};
Advancement advancement = new Advancement(identifier, null, displayInfo, rewards, Map.of(criterionId, criterion), requirements);
AdvancementProgress progress = new AdvancementProgress();
progress.update(Map.of(criterionId, criterion), requirements);
progress.grantProgress(criterionId);
List<Advancement> advancements = List.of(advancement);
Map<ResourceLocation, AdvancementProgress> progressMap = Map.of(identifier, progress);
ClientboundUpdateAdvancementsPacket packet = new ClientboundUpdateAdvancementsPacket(true, advancements, Set.of(), progressMap);
ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection;
connection.send(packet);
//connection.send(removePacket);
}
The advancement is there but i dont get a toast (presumably because the progress is not properly completed)
that's fun
Hey, been a while since I've done anything Minecraft related, I can't seem to build my plugin using the shade:shade goal, saying Failed to create shaded artifact, project main artifact does not exist.
I'm not sure what could cause this, any info would be greatly appreciated
Use package instead
That doesn't put all the libraries in, right?
Sent you a friend request
what if you add a trigger to your criterion
If I run package -f pom.xml i'll run into ClassNotFound exceptions
what the friggn hell
can anyone confirm that the JNI's jni.h header wrongly includes the jni_md.h file under the windows 64 bit version of literally any jdk version? xD
The JNI header has traditionally been broken. So could be.
xD
it is not wrongly included
you need to include the appropriate directory which is platform dependent
from my jdk, the jni_md.h is under the win32 sub directory and the jni.h
#include "jni_md.h" without the sub dir
and this is since jdk 9 or so
include the appropriate directory....
which again is platform dependent hence why it isn't there automatically
as in they expect me to modify the header or in the project settings?
if you don't want to bother with compiling it yourself then get a precompiled binary
It's a header ... you don't compile a header
but a header is needed to compile
I'd just edit the header so it works and if it works it works
xD
its safe to edit the header since it is platform dependent anyways
that is, whatever it is you are targeting that binary will only work for that platform or similar possibly
also i installed it from the PUBLIC jdk installer, and the header is licensed as confidential lmao ive already reported this to oracle a year ago with the jdk 18 and they still didnt fix it
I mean with JDK 18 you probably want to use panama instead
17*
but still
how can it happen that they publically release something marked as strictly propritary and confidential
because header is only needed for compiling it isn't strictly needed depending on what you are doing
@lost matrix why are you setting the clearCurrent field to true? that resets advancements
might be why
yea ofc since i need a jdk for each target platform
but the linux jdk 20 is marked as open source ^^
and that means it can't have something proprietary?
individual files can have their own licenses attributed to them that is separate from the entire project
Hm this should only result in the current advancements being removed. Ill try to change it.
Ok that was literally the problem...
Makes no sense, but thanks for the input
about this, i use multiple jdks for each respective target platform and i use conditional compiling to have it work from the same code base
The OpenJDK install I have (under linux) don't have any of such mentions
Well but the data is there (As shown in the screenshot). Ive only wiped the old data.
well you're wiping away all the progress
because advancements are only registered once
even if it did, I think they forget that oracle doesn't need to give themselves permission to release something
yea its only the windows version thats so oddly broken
but it would limit the end user as to how to use it, for example i cant include it in my projects repo as standalone installation
then you mis-interpret what it means to be open source
I tried to give spawner with different entity but it will turn into a pig spawner when I placed it down even If I try to give myself an iron golem spawner.
public static ItemStack createMobSpawner(EntityType type, int amount) {
ItemStack stack = new ItemStack(Material.SPAWNER, Math.max(amount, 1));
BlockStateMeta bsm = (BlockStateMeta) stack.getItemMeta();
CreatureSpawner cs = (CreatureSpawner) bsm.getBlockState();
cs.setSpawnedType(type);
bsm.setDisplayName(SodeSpawners.color("{type} Spawner"
.replace("{type}", SodeSpawners.capitalizeFully(type.name().replace("_", " ")))));
bsm.setBlockState(cs);
stack.setItemMeta(bsm);
return stack;
}
do u have op? only an admin can place a spawner with meta data
Oh really? I didn't know about that lmao.
otherwise its always defaulting to a pig spawner with empty metadata
What would you suggest If I want to give players sheep spawner for example?
But I'm op and it still turns into a pig.
Manually add the data from the ItemStack to the placed blockstate with the place event
or that
that would prevent the block from getting removed and re-placed
Alright, I'll do that, thanks guys!
also @summer scroll try using an online spawner generator that creates a give command just to verify it works at all xD
then u know that something in ur format went wrong
You would also have to copy the data into an item in the break event
Assuming you want to pick them up with silktouch or whatnot
Yeah, I'll remember that.
that i did with cancelling the drops and instead dropping the spawner block if the item is a pickaxe with silk touch
i mean thats how i made spawners mine-able
in the blockbreak event i think
You mean as in declared the most or used most amount of times during runtime
interesting
Declared the most
Declared i would say InventoryClickEvent
block *
Because everyone want to add guis nowadays
@austere cove ban pls
Yeah inv click seems reasonable
you know what we can do
make optic run a server with all spigot plugins and run spark
tbh im astounded by how many times i asked how to write my own command completer and ppl told me it doesnt work
when i finally learned how to dig trough apis and their docs
As for called the most during runtime imma guess block physics
theres literally onTabComplete as member of JavaPlugin
its in TabCompleter and TabExecutor too
Who told you that it doesnt work?
Sounds like someone who has no idea about Spigot.
ofc thats where it comes from
Also: You should only use that for very small plugins.
For bigger ones you should implement the appropriate spigot interfaces and register
them for each command individually
as in having a class inherit BukkitCommand and register that?
command class extends/implements TabExecutor and you can do it there
for really big plugins you make a command system and register each subcommand as its own class
why big plugins, i do that for most'

why cant i just have one main onTabComplete and switch trough the command.Name().toLowerCase()
in java strings in switches are hashed anyways
you can, nothing stops you
No you shouldn't really ever use BukkitCommand unless you plan to do something like register them automatically through reflection
as such there shouldnt be a performance penalty
Simple, separation of concerns
thats what i did before xD
switch through the hashcode
Because thats dirty
is 7smile having a stroke
xD
before i actually write my plugins i first need to finish my importer for my ini parser (the jni thing) xD
and probably need to find a dedicated server provider since every mc provider is not all too keen of allowing me to use binaries
just rent a vps
Ignoring the fact that ini is a terrible file format, why would
you want to trouble yourself with jni just to parse some files.
its not a terrible format lol
its a simple format
a simple format for simple config files
this is micro optimization at its worst
you can do byte parsing in java, manually
basic readInt readWhatever, there's no need for jni
my parser is written to be loaded in various languages, ive finished my c, c++ static and dynamic importers
working on the c# and java rn
and more to come at time
readInt
Smh.
I would assume that it doesnt even optimize anything unless you are parsing megabytes of data.
And at that point you are missing the point of inis.
The performance is more limited by your hard drive than the language for file IO
its written in c++ with all the neccesseary memory management and error handling incl. handling bad allocs internally
its not running on asm speed lvls anyways
Meh. If you really like tinkering with that then go ahead.
But there is nothing to gain but trouble with this.
like i said one lib can be loaded from various languages
one code base for multiple langs
I always wanted to write a machine code generator lib in java.
Should do it for maximum speed (Yes - nasm exists; but why not generate those executables at runtime?).
its for me in the first place
if ppl think its a terrible product honestly idm ill release it under the MIT license and while its ofc good to listen to critics
in the end its free
GraalVM compiles java into native machinecode
so if ppl dislike it its not like id lose money since i didnt ask for anything in the first place 😛
I'm talking about implementing a machinecode assembler in java
probably already exists though
Not compiler - assembler.
A compiler i would understand
i dont think its even possible with pure java
iirc ghidras GUI is in java and the decompiler/compiler and disassembler are in C++
Fun fact: The java compiler (javac) is written in java
me who wanted to create some custom bytecode interpreter in java :(
it is possible - but you don't want to.
idk how deep java lets u dig in its internals tbh
I mean it is just writing a file
How hard can it be (outside of reading a LOT of documentation)
You can write an assembler in any language.
I wrote a disassembler in Ada once.
the hardest will be to read trough the standards how to format ur binaries so that the machine instructions can be read and then u need to have an engine that translates the developers nonsense in primitive usually cisc instructions
isnt that just the job of a parser?
The binary formatting/packaging will be the biggest pain
so u need to understand how languages in general work on a basic level
Its all just GOTO in the end 
Jars are so much simpler on that front
java bytecode will prob be alot easier since oracle could basically define their own instruction set
Java bytecode is incredibly easy
its still terrible to read imo🤣
But I've been extensively working with it for the past two years so ...
lets see how long it takes them to learn that JNI doesn't get optimized by JIT or anything else in Java
i like that jar files always include a copy of the source code by default
alongside the bytecode
🤣
Eclipse moment.
Makes meta programming possible.
And runtime exceptions arent just
You fked up somewhere. Dumped memory
since my eclipse broke upon trying to update it
I just delete the eclipse install folder and start from scratch if there is a serious fault
eclipse moment
I have an entity, I want to deal damage considering entity's armor, how should I do it? Yes there is a formula on wiki, but is there a way without manually calculating this damage?
for exception stack trace info you dont need the sources
each class file stores the source file and it uses the methods LineTable or whatever
But I have only encountered such a scenario once (which was a CDT install so not that important anyways)
I believe that if you damage an entity while providing a damage source the armor and potion effects are taken into account.
But test that theory.
the moment i dumped eclipse was when i installed the 2023 version and got a warning that there are unsigned dependencies from google and oracle and i must allow to install from unknown sources in order to install eclips
that was my fk it moment
I mean coredumps are powerful given that they include the entire state of the machine at the time it crashed.
But you need to correct tooling for it
does this even work? im tryna find out if my mistake is in creating or reading the pdc
most likely gson, javax inject and other libs
But can I somehow nullify knockback effect because of providing a damage source?
I dont think this applies a knockback
If I'm not mistaken it does...
that should work
still that + the fact that eclipse crashes on trying to update it + it being super bloated with features and maven unfriendly which i need for plugins made me dump it in the end
if(state instanceof Barrel barrel) {
...
barrel.update();
}
🤷
Listen to the EntityDamageEvent, get the final damage and cancel the knockback then
Okay I will try thanks!
netbeans exists
Then you got an up-to date prof.
Fk frostalf sniped me
Was about to bring up Netbeans
xD
lucky you
maven unfriendly?
i got a university license for clion and intellij
Are you deep in writing maven plugins or something else?
so i was like sure whatever
Currently working with netbeans at class, this autocompletion is awful
who knows what they are doing when they decided to use JNI to read a basic ini file
im not a fan of maven its super bloated in features but it does have benefits like auto updating apis
bloated?
Why would you auto update libraries lol
you do realize maven at its core is slim, it only bloats the more plugins you decide to toss into the pom
isn't that the whole purpose of a build tool?
Wait until you see make
to keep my plugins updated with the latest api?
Gl when getting breaking change in minor update
xD well the ide will show me where
ya
not if you are using JNI

It will be painful in a few years though when you have to guess the version you wanted to compile it with
I get the feeling you been waiting this entire time to finally use that
nah I use it often
heehee
one of these days I am going to start a collection of stupid ideas derived from this discord XD
pycharm!
xD
or whatever its called
woo 17
im actually on 19 but nobody cares
:( We are still on Java 14
not like the concepts of java changed
our prof said he doesnt care which jdk we use since we work with the basic features only that exist since java 9 or so
we love virtual threads!!
we were using bluej in the first semester so its a good improvement
some new syntax sugar :D
The biggest thing about modern java is that classloaders have names
as long as java doesnt change like .NET 6+
where the main class and namespace are hidden
and make it look like u code in the global scope
java modules :)
🤣
then realizing it fucks with your reflection
If you mean like in a huge breaking change; it probably will happen in the future
;-;
technically you do when you initially creating a java application given a true main class needs statics everywhere
well i mean a plugin is ofc different to a java program
Project leyden might be fun for modders and valhalla might brick quite a few libs depending on how it is implemented and other things
when ive written a plugin api in c++ for a different project i adapted bukkits mechanics
idk if that was so smart tho
plugins as .dll
it wasn't
xD
there is a lot of things in bukkit that were designed purposely flawed
yea i figured
Bukkit's event bus isn't that great I have to admit
well event driven system is more ideal
i mean i used both
isn't that still kinda like events?
since most of everything is derived from player input whether directly or indirectly
well i mean if u view a dlls entry point as onLoad
it could prob be seen as an event
but its more versatile
well the only alternative that could work is a subscribing system
isnt that the bukkit way?
i think
is jump effect the only way to prevent player from jumping?
no, bukkit is events and it will send out an event regardless of who is listening
i did use events tho
i let the plugins notify the loader to add their function pointer to an array that was then being iterated
or remove their function pointer
to unregister the plugins event
in a subscription system, if you sent an event and there are no listeners, isnt the event discared too?
That sounds more like C than C++
like i said i wrote a plugin system in c++
in which i adapted bukkits mechanics
on how to do things
Yes but using function pointers and storing them in arrays sounds very C.
no, as long as the cancel isn't set, it will just continue. It isn't discarded just the server moves more quickly then before since nothing actively wanting to do something with that particular event
i have no idea what the dif is actually
u cant iterate c++ objects in inline assembly
but u can iterate primitive C arrays by index
so the overlaying system was c++ with a mix of c and assembly to iterate the registered events
its kinda weird tho
whats that
so what is the problem now the creation or the listener
wanted to make some kind of assembly/ bytecode looking like lang but i regret making the syntax look like that
basically if u wanna iterate an arrays entires on byte level u do ```txt
(startingAddress + (index * sizeof(array data type)))
thats what i did
another dumb quastion but how i can run a bukkit command in a async event ?
i tried
Bukkit.getScheduler().callSyncMethod(Mco.getPluign(),() -> p.getWorld().spawnEntity(p.getLocation(), EntityType.CAT));
and
new BukkitRunnable() {
@Override
public void run() {
p.getWorld().spawnEntity(p.getLocation(),EntityType.CAT);
}
};
but none of them worked
i only fucked up at the sizeof(type), it worked before but then i decided to change the impl and it didnt longer work :(
Just runTask
?scheduling
uh oh manually instantiating bukkitrunnables
anyone know how i can find out of my barrel creation actually added the pdc
Any nbt editor or trough code
well whats the easiest way
It would probably show up in the data command
btw when did vanilla mc add the feature of adding a teams prefix and suffix
A very long time ago
what isnt working
no i mean via a vanilla team command
ah 1.13 is the earliest I can find on the wiki
also it is better practice to store NamespaceKeys as like a static thing somewhere
asm{
loop1:
mov ax, this->var
...
dec ax
cmp ax, 0
je exit
jmp loop1
}
thats still along time ago xD
nothing too hard there
well nothing is really. the block does get created but my listener doesnt cast ig(onbreak). I dont know if the listener is wrong or the commannd doesnt add the pdc
isnt the loop counter in the cx register?
🤔
iirc cx is both loop counter and return value
have you got the correct Barrel Also, does the stuff inside the instanceof run?
How to add custom ID's to blocks, (Im working on a miner robot system) so that players can upgrade their miner robot lvl etc?
You can make that namespcaed key a constant
It doesn't change
i said that
nvm it got the pdc
is your listener running?
also it should be cmp X, 0 and then jne loop1
should yes
are you sure?
why check if its 0?
also, is that config valid? You do a null check and that would cause nothing to happen
we wouldn't be iterating if it was 0
ur using a decrementing loop dont u?
that isn't a decrementing loop
dec ax decrements
configs valid i use it everywhere else too. It shouldnt have anything to do with the listener itself i suppose cause it worked before i added the pdc part
then compare ax to 0
ok show the whole event listening method please
I can work with ZYX ID's, but if i break the block and place it somewhere else, the ID will be changed and everything will be reseted inside
ah forgot I posted the decrementing one
so how should i do that?
so it should be cmp ax, 0 then jne loop1
what I posted is correct
also im pretty sure the loop counter is in cx
it is if ur using a 2.nd label u didnt show here
i swear it was such a pain in my ass when i started
and had a corrupted stack
cause i didnt know cx stores the return value
🤣
EAX, EBX, ECX, EDX, ESI, and EDI these registers are safe to use without restoring them to original values
depends xD
stolen bytes cough
This code is not very readable. Are you storing the contents of a storage object in a yml config though? That is a horrible idea if so
i would reccommend attaching a debugger
no doesn't depends. C++ or C has no expectation that those registers will ever remain the same or should be reverted
however those are not the only registers you could use
just those are the guaranteed safe ones
no its like a luckyblock you could say. its a config file and when you break the block it has a chance of dropping the things listed in the config
funny to even find someone who digged trough assembly nowadays
ok. still, use a debugger
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
a = 8bit, ax = 16, eax = architecture dependent right?
its the ultimate final way to optimize 😉
ya but despite minor tasks i would NEVER want to write higher programming concepts in it. like that guy who wrote this roller coaster park game xD
EAX is 32bit
AX is 16bit
order from greatest to least, EAX, AH, AL, AX
from chatgpt
AH and AL are technically part of AX
for 64bit register
but you can split AX to get AH and AL
In x64 assembly, registers are 64 bits wide, and they are denoted with a "R" followed by a number. Here are some examples of x64 registers:
RAX
RBX
RCX
RDX
RSI
RDI
RBP
RSP
R prefix
idk if gpt is right but i doubt its wrong with such a standard
just because a CPU has 64 bit instruction sets doesn't mean you have to only use 64bit instruction sets
it is better to use 32bit sets unless you need 64bit
i want 2^256 gold in my game
🐒
i think thats the main reason why most mmos use copper silver gold for currencies tbh
xD
wait we are still using the x86 instruction set today right?
depends
yes
i clearly didnt learn 64 bit registers exxisted then
on the target system u compile it for
the architecture
but just because u compile for 64bit it doesnt mean u everything must be 64bit
but for example pointers will be
the server im using rn isnt a local host is it really that good that i should bother setting one up rn?
ok i was confusing things
only if you need addressing greater then 2GB or 3GB
64bit instruction sets and 32bit sets coexist together these days
but i was only allocating 64 bytes for my program so no problemos
thats what i do to store my pointers on javas end
so it is valid to still learn x86 but worth to also learn AMD_64
i mean
and arm is another thing then
theres hardly much difference between learning the difference between 16bit to 32bit
and 32 to 64
its just larger
there is a big difference
instruction encoding?
while yes larger numbers, there is still major differences especially in how things are done
or wdym
oh god dont tell me my brother is going with the vacuum cleaner through his ps3
man never heard of discharge
he cleaned it with water
🐒
dont ask me what that dude is doing
imean u can clean it with watee
controller was laying outside and in the meanwhile it rained 💀
tbh I've done that on my PC before
The PC is going strong after 10 years
brrrrr
Block block = event.getBlock();
block.setType(Material.AIR);
block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.PURPUR_BLOCK, 1));
event.setCancelled(true);
how to add a custom name to this blockdrop?
my laptop is already slow asf and i only got it half a year
imma reinstall windows ig
i did clean my old pc once with a vacuum cleaner, afterwards it had random bsod's due to i presume a static discharge from the cleaner to the hardware. lesson learned but i was just dumb and like 15 back then xD
now to even open my pc casing
#general
i put it and hardware it and myself to the heading pipe
💀
and put it on a esd protection mat
I want to give it a name when someone breaks the block, it will be called "Robot Miner"
oh man he removed the backside of it and is going though the ventilator with the vacuum cleaner
gotta make sure its clean 💀
get the itemstack and rename it there?
How can I save the mobdata of an entity and spawn an entity with the same data?
either u store each attribute or u try to serialize the entire thing
the only way to ensure it doesn't over heat. There is some PS3 models that have a defect where they build up an abnormal amount of dust due to the duct not being very well designed
like in the itemstack?
So
ItemStack(Material.PURPUR_BLOCK, 1, setName("This"))
ok, thank you. Hoped there would be an easier way
no clue, he got it second hand so it wont be the best quality at least
prob id get a reference first tho since u need to address it in multiple individual instructions
u could hack the maps or whatever it is to inject ur custom mob with its custom behavior but idk how
and thats hardly easier
but idk how mobs are stored exactly as that prob involves alot of nms too
Bullet extends Snowball
[NMS]
int postDeathTicks = 0;
@Override
public void tick() {
if (shotFrom == null) {
super.tick();
}else {
double distanceTraveled = shotFrom.distanceTo(this.position());
if (distanceTraveled >= maxDistance) {
postDeathTicks++;
this.setDeltaMovement(0,-1,0);
if(postDeathTicks >= 50){
this.remove(RemovalReason.DISCARDED);
}
}else {
super.tick();
}
}
}
Im trying to achieve Bullet drop, but instead of it going down, it just starts teleporting around before removal
because u set it by -1
u need to deltatime the movement
otherwise if it teleports randomly around then theres another problem idk there yet
how do I delta time it
and I thought -1 on Y would make it down
by measuring the real world elapsed time and multiply that by the movement?
can someone give me a quick example of how to run a bukkit method in a async event ? i tried everything but it just dosent work
Bukkit.getScheduler().runTaskAsynchronously(Mco.getPluign(), new Runnable(){
@Override
public void run() {
p.getWorld().spawnEntity(p.getLocation(), EntityType.CAT);
}
});
i wanna summon a mob on chat event

