#help-development
1 messages Ā· Page 2056 of 1
new MapDataType(LinkedHashMap.class, LinkedHashMap<K,V>::new, keyType, valueType);
ugly but better than nothing
smth like that ye
did i miss the new java update?
ye
yep it's a Supplier
same as () -> new LinkedHasMap
i know lambda, thank you
:)
buth with <K,V> š
hm weird
isn't this cast totally unnecessary?
intelliJ doesn't say its unneccessary but it also doesn't cry when I remove it
not quite sure on that one, but what I am sure is that your background is broken its white!
this happens in rust intellij whenever it has no idea what the hells going on
stupiJ
you have the Sensei plugin enabled?
the whut?
basically uses cookbooks or rules to evaluate your code
I just use the builtin code inspection
Quick design question
I have a service interface that is designed for sending things
What do I name it? Sender?
How can I transfer an X axis number, to a location object?
Y'know what nevermind, Sender works fine
anyone know why maven can't resolve this dependency?
it was working before and I just copied it again from the website to try and fix it but nothing
did you add repo
why are you asking about maven and showing the gradle example?
can someone help me do a thing?
@EventHandler
public void onClick(PlayerInteractEvent playerInteractEvent) {
ItemStack itemStack = playerInteractEvent.getItem();
if (!this.cache.containsKey(playerInteractEvent.getPlayer()))
this.cache.put(playerInteractEvent.getPlayer(), new HashMap<>());
Talisman talisman = getTalisman(itemStack);
if (talisman != null) {
Map<Attribute, Double> map = this.cache.get(playerInteractEvent.getPlayer());
for (Map.Entry<Attribute, Double> entry : talisman.getAttributes().entrySet()) {
if (!map.containsKey(talisman)) {
playerInteractEvent.getPlayer().sendTitle("§aTalisman §7" + talisman.getKey() + " §aenabled!", "§7§kIF U CAN READ U COOL");
playerInteractEvent.getPlayer().playSound(playerInteractEvent.getPlayer().getLocation(), Sound.BLOCK_BEACON_ACTIVATE, 1, 1);
} else {
removeTalisman(playerInteractEvent.getPlayer(), map, talisman);
}
}
}
}
Idk how to do the ' thing xD
here
basically
i'm making a talisman plugin, that when you use a talisman(configured) it changes some attributes, basically adds a % more to an attribute, so basically, a talisman can be configured to give 3% more health
but i can't figure out how to sum every percentage by the key attribute, to make 1 sum
so like, since there can be more than 1 talisman, i would like to make plugin sum every percentage from all talismans
but i can't figure out how to do it, can someone help?
no
the number has to be the sum of all attributes of the same type, so like if i have more than one talisman, and every talisman gives me a health boost, the applied health boost should be the sum of every health boost of every talisman
my english is bad cuz i'm italian so, idk if i explained well
this because the boost is in percentage, so it has to be 1 sum of all the percentages
Just loop over then and add it all up?
zacken02 btw var CPP = "ugly" is approved
loop through your inventory and/or get your stack size
hard part is not counting but deciding when to update when you add or remove items
I really don't get it and neep help with generics. In line 41, it won't compile until I cast the returned object to (Vector<String>). Is there ANYWAY I can change my code to make it work without the cast? https://github.com/JEFF-Media-GbR/MorePersistentDataTypes/blob/a42772c49835ea2c7a04ba56373fcb292730df4f/src/test/java/com/jeff_media/morepersistentdatatypes/tests/GenericCollectionAndMapTest.java#L41
hey im trying to remove the item in the inventory with the Persistent data container and when i do inventory.remove(item) it deletes 2 items but does not identify the difference in Persistent Data Containers
i want to identify the item based on its nbt tag and not its type
@tender shard based on your github you seem to be the perfect guy to know how i can identify two items that are the same except for persistent data containers
I guess the easiest way is to simply loop over the inventory contents, then check every item's PDC manually
what exactly are you trying to do?
Remove EXACTLY the same item, but spigot removes also items that are the same except for having different PDC data?
yep
i do not want it to remove two items i thought by setting a pdc for the item spigot would realize that they have different data and would remove only the clicked item and not the other item
just loop over the inventory and remove all items that have your custom tag?
inv.setContents(Arrays.stream(inv.getContents()).map(item -> {
if(!item.hasItemMeta()) return item;
PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
if(pdc.has(someKey,DataType.STRING)) return null;
return item;
}).toArray(new ItemStack[0]));
i thought i was good at java
how else would yo do it since you are using assertEquals against a string? - /me is referencing your PDC doc š
I want the PersistentDataType I am creating using DataType.asGenericCollection propagate that it doesn't simply return a Vector but a Vector<String>
this works fine for all my concrete List datatypes like DataType.asArrayList
only the one where someone can provide a collection class is where I don't get it to work
im getting a error
hmm 4. Vector(Collection c): Creates a vector that contains the elements of collection c.
Vector<E> v = new Vector<E>(Collection c);
you create it without the collection - wondering if you are over the 10? Vector(): Creates a default vector of the initial capacity is 10.
even that doesnt make sense
I can create any collection without problems, the problem is that the compiler forces me to cast it when using it
when changing asGenericCollection from <C extends Collection<D>,D> to just <C extends Collection,D> then I can use it as Collection<D> without problems but I want to be be C<D> instead of a generic collection
hm no idea, should work fine tbh
copy/paste that part of code pls
let me paste it into my IDE
which java version are you compiling with? maybe its in the change notes
java 17 but with 8 as target
I'm trying to use protocollib to add item details to the items lore dynamically, so that the information is not in the lore and is added on to the end of the item packet every time it is sent. However, even though I am cloning the item, my detail lines still get added to the actual item's lore (over and over again, no less).
the only real note in 8 is: Unlike the new collection implementations, Vector is synchronized. If a thread-safe implementation is not needed, it is recommended to use ArrayList in place of Vector.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockPistonExtendEvent.html https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockPistonRetractEvent.html the event.getBlock returns the piston?
declaration: package: org.bukkit.event.block, class: BlockPistonExtendEvent
declaration: package: org.bukkit.event.block, class: BlockPistonRetractEvent
my problem has nothing to do with vectors or any specific collection
my problem is this:
static <C extends Collection<D>, D> PersistentDataType<?,Collection<D>> asGenericCollection(final @NotNull Class<C> collectionClazz,
final @NotNull Supplier<C> collectionSupplier,
final @NotNull PersistentDataType<?, D> type) {
return new CollectionDataType(collectionClazz, collectionSupplier, type);
}
This returns a PDC type that uses Collection<D>
static <C extends Collection<D>, D> PersistentDataType<?,C> asGenericCollection(final @NotNull Class<C> collectionClazz,
final @NotNull Supplier<C> collectionSupplier,
final @NotNull PersistentDataType<?, D> type) {
return new CollectionDataType(collectionClazz, collectionSupplier, type);
}
This returns a PDC type that uses a raw C
What I need is a PDC type that returns a parametrized C
bunp?
so there are quirks in 1.7 and 1.8
im getting a error on new ItemStack[0] its says ```
Required type: IntFunction<A[]>
Provided: ItemStack[]
I HATE nms
The namespace is stored with the key right? Its like a hashmap?
In PersistantDataContainers
replace new ItemStack[0] with ItemStack[]::new
inv.setContents(Arrays.stream(inv.getContents()).map(item -> {
if(!item.hasItemMeta()) return item;
PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
if(pdc.has(someKey,DataType.STRING)) return null;
return item;
}).toArray(ItemStack[]::new));
This should work. haven't tested it but I'm sure it'll do
I somehow solved it
by removing the whole CollectionClazz from the constructor
seems like that confused javac since ofc I wasn't able to pass a parametrized class there
might be because using Class<C> and then Vector.class makes it the lowest as possible
yeah thats what i was going to say
now I just get the proper class by calling the supplier.get().getClass() and casting that to C lmao
can i ask what does ::new mean?
it's a method reference
Does anyone know if thereās a way to get a blockās step sound, and then play it (without particles) without nms?
the toArray() method expects a function that returns a T[] array and expects an int as argument
one second
ItemStack[]::new is the same as creating an anonymous IntFunction<ItemStack[]>, like this:
inv.setContents(Arrays.stream(inv.getContents()).map(item -> {
if(!item.hasItemMeta()) return item;
PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
if(pdc.has(someKey,DataType.STRING)) return null;
return item;
}).toArray(new IntFunction<ItemStack[]>() {
@Override
public ItemStack[] apply(int value) {
return new ItemStack[value];
}
}));
@sage merlin
item is null
I don't think so
what is the item itself equal to
wdym?
the item is null
for the spigot plugin is it normal that the highest minecraft version is 1.18.1?
.map(item -> stuff)
simply check if the item is null and if yes, continue
yeah then just do
if(item == null) return null; at the beginning
inv.setContents(Arrays.stream(inv.getContents()).map(item -> {
if(item == null) return null; // <--------
if(!item.hasItemMeta()) return item;
PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
if(pdc.has(someKey,DataType.STRING)) return null;
return item;
}).toArray(ItemStack[]::new));
see the second line I added
i have a question how is this gonna delete the item with a unique PCD
we turn the inventory contents to a stream. the map method takes an itemstack as input and returns another itemstack. in this case, we simply return null when the PDC key is found, otherwise return the original item. so we simply replace all itemstacks in the array with "null" that have the tag you'r elooking for. then we turn the stream back into an array and apply it to the inventory
.?
nope
this is the fancy version of this:
ItemStack[] contents = inv.getContents();
for(int i = 0; i < contents.length; i++) {
ItemStack current = contents[i];
if(current == null) continue;
if(!current.hasItemMeta()) continue;
PersistentDataContainer pdc = current.getItemMeta().getPersistentDataContainer();
if(pdc.has(someKey,DataType.STRING)) contents[i] = null;
}
inv.setContents(contents);
Entity mob = new Entity();
How can I create a new entity like this? I dont want to spawn it yet.
you can't just create an Entity
nms
why would you want to create one without spawning it anyway?
it won't be a Bukkit Entity then but an NMS one. seems like they want to create a bukkit entity without spawning it
hmmm
maybe explain what you need it for
im rethinking stuff
yeah but i dont think you can create a bukkit entity without spawning it in the world
How would you setup the flags for relative teleportation in ProtocolLib?
Current Code:
ProtocolManager protocolManager;
protocolManager = ProtocolLibrary.getProtocolManager();
PacketContainer relativeTeleport = protocolManager.createPacket(PacketType.Play.Server.POSITION);
//Code for PacketType.Play.Server.POSITION
relativeTeleport.getDoubles().
write(0, (double) 0).
write(1, (double) 0).
write(2, (double) 0);
relativeTeleport.getFloat().
write(0, (float) 0).
write(1, (float) 10);
//Tried this but gave me an error for the getSets, it said Byte on the wiki.vg but I have no idea how to set that up
relativeTeleport.getSets().
write(0, new HashSet<>(Arrays.asList(PlayerTeleportFlag.X, PlayerTeleportFlag.Y, PlayerTeleportFlag.Z)));```
https://wiki.vg/Protocol#Player_Position_And_Look_.28clientbound.29
at least not without reflection I guess, but I also don't think it'd ever be needed
lmao I really don't get why people still worry over using protocollib to send packets
using NMS is 10 times easier to send packets
^^^^^
anyone? :/
protocol just makes it harder imo
yep!
Well protocol does have the advantage of reflection
well for listening, protocollib is good
the advantage of reflection? wdym?
cross version compatible
use mojang mappings and your 1.17.1 code will be the same as your 1.18.2 code
ahem SPEAKING OF PROTOCOLLIB
let me look at a project i worked on
sorry for bumping so much
it had something similar to what you're doing
ok
on this
Where's a good place to start with learning NMS instead of protocollib?
it was nms instead of protocol (i didnt make it)
there aren't really any up to date tutorials for 1.17+
in a very dark place
but the NMS packet constructors are quite easy to undertsand
p.getInventory().addItem(e.getBlock().getDrops());
Im trying to add a collection of items to the player inventory, how do i do that?
it makes a nms copy of the item and then sets the item field using reflection
Someone seriously needs to make some proper NMS tutorial series it would get a million views
addItem takes an ItemStack varargs so just turn your collection into an array
I wanted to write one some time but definitely not a video lol
i havent used protocol so i dont know how it works on there, but the nms method above works @woeful crescent
using getDrops().toArray(new ItemStack[0])
alr I'll check it out
wait there's no link @crisp steeple
Well, off to scavenge the internet for scrap pieces of code to find out how it works
yeah it took a turn
rewriting it rn since person who wrote it originally didnt make it clear
I know some NMS and I can provide nice examples but eh
protocollib does 90% of the work
discovering NMS is mostly just middle-clicking stuff until you find what you want
got it
You must remove the lore from the real item, and add it on the client-side item
There are like 2 item packets
š
If you copy an item on creative
the client-side lore becomes real
so you must remove it unless you want duplicating lore
Here's an example
interesting
You gotta remove all the fake lore and re-add it on the item
I believe there's the WINDOW_ITEMS packet that actually has an extra field for the item on the cursor
the code example doesn't include it (because I didn't push the latest version) but you must handle it otherwise dragging an item will make it seem like it has no lore
uhhhhhhhhh
I'm confused
all im doing is sending the client a different item, I thought
Well
Like if I tell the client something different why should that affect what the server thinkks the cliebnt's inv is?
The creative inventory is a clusterfuck to say the least
well i mean, I'm not really talking about creative here
Also items are mutable and such
So like
I'm confused
A player isn't in creative, and gets sent a differnet item than is actually in their inventory. Why does that actually affect their inventory?
Maybe i need to clone the lore since lists are mutable?
Nah
yeah it already does that in getLore()
How are you 100% sure it affects their inventory server-side?
I used a command that prints the item's nbt
and it outputted all those lines
for some reason
@woeful crescent hopefully didnt miss anything
Field[] fields = _packet.getClass().getDeclaredFields();
Arrays.stream(fields).forEach(f -> {
try {
f.setAccessible(true);
net.minecraft.server.v1_8_R3.ItemStack item = (net.minecraft.server.v1_8_R3.ItemStack) f.get(_packet);
if (item != null) {
ItemStack itemStack = CraftItemStack.asBukkitCopy(item);
// do stuff to itemstack
f.set(_packet, CraftItemStack.asNMSCopy(itemStack));
}
} catch (IllegalAccessException e){
e.printStackTrace();
}
});
yeah that's the NMS version
Let's like
rewrite this code a little
There are 2 packets to worry about
correct
SET_SLOT, which just has an item and a slot index
WINDOW_ITEMS, which has the entire inventory and the cursor, one is an itemlist and the other is just an item
yes, that's what i did
ight
The items in the modifier array are also mutable
I believe that's where your error is
Yes
Does the server use that array for anything other than being sent to the plauyer?
Seems like it
On later versions it's a list
try creating a new array and writing it on the packet
instead of modifying the existing one
Would anyone know how I would teleport a list of players to a location e.g.
ListOfPlayers.teleport(location)
for(Player player : listOfPlayers)
player.teleport(location);
how lazy are you to the point of avoiding a for loop
yea sorry its 1am my brain aint functioning
lol
i completely avoid loops cuz they confuse and i keep forgetting them im kind of new
Well you're out of luck
If for loops confuse you, you should use enhanced for loops like imillusion just sent.
It can automatically iterate through any collection and arrays too
iterators are kinda weird with for loops
i know what it does
dont be mean im new to this
for(Iterator<T> iterator = ...; iterator.hasNext();) {
T object = iterator.next();
}
But iterators aren't really used nowadays
ok sorry i just thought you were confused because it's hard to remember the order of normal for loops
at least it was for me
Iterators are pretty much not touched nowadays yeah
only place I see it nowadays is BlockIterator
I understand removeIf (helps avoid CME)
But I stay away from the rest due to personal preference
Mye
Well I just believe it gets a bit more readable by eliminating some boilerplate but none is superior fr
:0
The offhand key sends packets even when there's no item
Which is extremely useful for specific projects (like those "minecraft but.." videos)
Not that I flirt with packets that often but certainly interesting ngl
Because you can trigger actions and have it act as a hotkey
Oo
I just made a basic protocollib action that calls a custom event
Yep
and made mob basketball
Yeah
Epic
but I already had the packet code before I noticed that the event existed :(
š„²
Quite wild the things that you can do with spigot
there's a packet to force a player's fov
Lol
my plugin is saying [00:27:18 ERROR]: Could not load 'plugins/PowermageCore.jar' in folder 'plugins' org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml at java.lang.Thread.run(Thread.java:833) [?:?] Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml when the plugin.yml is there
can you show us ur plugin.yml?
he doesn't have one
Is it there though
no, your plugin.yml is obviously not there
it says something is wrong with the description
ahhh
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
did you open your jarfile to see if its in the correct location?
maybe he put it in the wrong place
are there any good resources documenting packet stuff?
what IDE are you using?
I just opened one
open your .jar with winrar / 7zip / etc and you will se that there is no plugin.yml
That one is nice
thanks
I also have a packet tutorial on spigot if you want to send packets through ProtocolLib
seems like it helped you maybe I can learn nms through that
I actually worked with the author
The tutorial is a bit outdated
ahhhh
yea thats the problem with nms
my experiences with NMS were just me messing around trying to make entities walk to places and make fake block break packets
its always outdated
It's quite hard to make something long-lasting because understanding NMS is like
active work
not something you can learn and remember in 3 years
you gotta decompile half the code and guess a lot
I personally like writing plain nms but I cant understand a word I am writing lol
maybe I will give protocollib a go
nms is a full time job š
ProtocolLib is just for sending packets
has some util methods
metadata packets on protocollib are kinda painful to write
or client-side entities as a whole
Any Efficient way to detect if a player/entity is exposed to rain?
I am so happy. Finally everything is clean, without dirty casts, and with proper type inference ā¤ļø https://github.com/JEFF-Media-GbR/MorePersistentDataTypes/commit/ff917d5a4da715615a84047d9e753e822b351923
might be paperspigot but..
declaration: package: org.bukkit.entity, interface: Player
Still looking for a translation lib with yml stuff?
sure, but not today š
did you already upload it somewhere?
I guess this is good of a reason to move to paper spigot
Once I make it stable I can send a link
that's spigot and it's part of LivingEntity IIRC
ooh this one's great
I've been making a packet library myself and having a resource giving some packet sequence examples is fantastic
thank you
np
it has nothing to do with being exposed to rain though:
Checks to see if an entity is currently using the Riptide enchantment.
looks like someone can't look down the line of suggestions
to check for rain, simply get the uppermost block at the player's position and then check if the player's height is below or above it
World#getHighestBlockAt
why not just use getPlayerWeather??
- Player weather does not affect whether a player is actually in rain
- Noone cares if it's raining at Y=64 when the player is in a cave
which event is called when a wither/ender dragon breaks a block?
EntityChangeBlockEvent iirc
figures spigot has an easy way out on this as well "isInRain()"
yea then just check if the entity is an enderdragon
bungeecord wildin
what packet is sent to players if someone opens a chest?
(so that it plays the chest open animation+sound on their client)
probably multiple packets tbh
one for the animation one for sounds and one for the window items ig
There's a packet for the block status
BLOCK_ACTION
and it uses some weird internal IDs that change every version
on 1.16.5 it was 18970 for trapped chest and 22969 for regular chest
i see, tyvm
mc operates in mysterious ways :d
I believe this is all referenced on a file with all blockstates
where each id has a blockstate
chest-open, chest-closed
^
etc etc
ah, alright
Are there any other commonly used map or collection interfaces/classes that I forget in this list?
Collections
- List
- ArrayList
- Set
- HashSet
- LinkedList
Maps
- Map
- HashMap
- LinkedHashMap
- EnumMap
thx
Sometimes people use IdentityHashMap
oh yeah that one is also nice
Dequeue?
alright that's already 6 new things I can add lmao
iterator š¤”
but that's neither a map nor collection š
TreeMap
PriorityQueue
ResultSet (sql)
I won't need resultset
Hashtable!
noone is going to store a REsultSet in a PDC lmao
oh yeah hashtable
EnumSet
already mentioned
that.. depends on ur needs ig
I just wanna log shit lol
if its just some simple logging i woulnt go for Log4j but i guess its also preference
oh wait
EnumSet is abstract
what's an impl of EnumSet?
Queue is also abstract
Deque is also abstract
You can find usages to find out
EnumSet.noneOf
I didnt find any for EnumSet
lol wtf is a JumboEnumSet
depending on size
how much is Jumbo? š
hm I wouldnt call that really big
Material comes to my mind
that's the only one
I guess
but would you really need an EnumSet for sound
I often use it for like 3-10 materials at most
probably not lol
static <D extends Enum<D>> CollectionDataType<EnumSet<D>,D> asEnumSet(final @NotNull Class<D> enumClazz) {
return asGenericCollection(() -> EnumSet.noneOf(enumClazz),asEnum(enumClazz));
}
so this creates an EnumSet that's empty, right?
yes
perfect
I think that's enough builtin maps and collections now lol. If there's still anything missing, people shall just use asGenericCollection or asGenericMap
Well it is when you consider how many constants you would need to declare to make a set larger than 64
iirc the implementation of RegularEnumSet uses a bit field
While JumboEnumSet useeeess...
A long array
yep
quite interesting idea to do it like that lol
btw does AsyncPlayerChatEvent refer to the sending or receiving of chat messages
it's when the player sends a message to the server
So basically sendMessage would fire a chat event?
no, sendMessage is server -> client
AsyncPlayerChatEvent is client -> server
Or sorry yeah
Last I recall, it does, yes
And specifying the sender in sendMessage makes it appear as if that person sent the message?
No, because sendMessage() just sends the player a string of text
So then what does the sender parameter do?
The sender UUID will determine whether or not the message should be ignored by the client
Oh
(e.g. if ignored in the social menu)
So I mean, yes, you can associate it with a player if you really want
But sendMessage() is just a system message by default
I just double checked. AsyncPlayerChatEvent gets called everytime the client sends a message to the server. Messages from the server to the client don't trigger anything
You don't do it in that packet
There's another packet for specifying window items
Yeah
Since Player implements ConfigurationSerializable, I wonder if this could be abused for some funny stuff
What the fu-
wtf indeed. it's so extremely useless lmao
player:
==: Player
name: mfnalex
I thought it'd contain the attributes, potioneffects, inventory, PDC etc but no, just the name lmao
what is the equivalent to array[1::] (Python) in Java?
what does that do in python?
if you have an array like [1, 3, 37, 18, ...], then it will create a new array without the first element, so [3, 37, 18, ...]
ah okay, then it's this:
Object[] arrayWithoutFirstElement = Arrays.copyOfRange(originalArray, 1, originalArray.length);
thanks š
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
inventoryContents.length
btw that will always return the same size as the Inventory itself
quick q does anyone know off the top of their heads an item that looks invisible when worn as a helmet?
a barrier
unless you're in creative
I guess
doesn't count as a helmet for mobs unfortunately
wdym with "count as helmet"?
actually never mind I found a better way to do it, I think I was editing the wrong file earlier
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.
yeah the helmet thing is a bit too good for its own good lol
[x] is correct
[x] should work
CraftWorld isn't detected by my API still š¤
did you add spigot as dependency?
yep
?paste your pom.xml
you did not add spigot as dependency
only spigot-api
imma make a new project
oh what's the difference
oh so i must've used api for this on e
if you wanna use NMS on 1.17+ you will want to use remapped, check out this ^
ok yes i remember this
will do
i'll come back later if i have the problem again with spigot
oki
Iāve just spent all day trying to update my plugin that uses NMS for 1.18
I give up
Iām gunna recode the entire thing, I canāt take it anymore, what Iām doing probably isnāt even possible anymore
what's the problem?
when in doubt, abuse reflections
not going to work on 1.17+
unless you abuse them properly
when in doubt jank it up till it works then ignore the jank for as long as possible
or just abandon the project
nah
okay tell me how you want to get the playerConnection in 1.17.1, and 1.18.2 with reflection
also it is normal that the minecraft version for the spigot module plugin only goes to 1.18.1 right?
first get the version
1.18 changed so much about the nms, I just have to recode it, I canāt use reflection anymore
then do whatever
bruh since yesterday I have to log in to the Minecraft Launcher every time again :/
and then?
how do you think protocollib does it?
?
yeah why would someone use reflection for that
if it changes with every version anyway, just use maven modules
then you can use mojang mappings and don't have to rewrite your code for every update
reflection made sense when spigot had their own names for some stuff
since 1.17 it's just stupid
well you need a new module for a new version tho.
of course but I can just use the same code as the old version
I don't have to check whether "playerConnection"is now called "a" or "c" or "f"
it'll always just be "playerConnection"
e.g. this is for 1.18:
private static Connection getPlayerConnection(final Player player) {
return ((CraftPlayer)player).getHandle().connection.connection;
}
and in 1.19 it will be the same
with reflection you have to make a list "a.c" in 1.18, "b.f" in 1.19, "y.d" in 1.20, etc
Quick pseudo code
Player player = ...;
final Class<?> playerConClass = Class.forName("net.minecraft.server.network.PlayerConnection");
Field playerConField = Arrays.stream(player.getClass().getDeclaredFields())
.filter(field -> field.getType() == playerConClass)
.findAny()
.orElseThrow(IllegalStateException::new);
// TODO
won't work in 1.18
Why's that?
the Connection field has the type ServerGamePacketListenerImpl
and only that has a field of type Connection
in 1.17, your code would work
god I wish I could just go to the gym rn instead of sitting here trying to make mobs sit still
that's why it was "player.connection" in 1.17 but "player.connection.connection" in 1.18+
setAware(false)
wouldn't work, it's an intricate set of things they need to do / not do
This is 1.18 code, b is the connection
I got it down already just messing with leather color parsing at this point
it's like 2am
exactly, b is the ServerGamePacketListenerImpl and a is the Connection
I could go to bed
it's 2 am, I could go to the gym if 24 gyms were legal
or I could be messing with throwable mobs and projectile-like thrown items
24h*
a() is the sendPacket method
oh huh
wait
This is without mappings btw
then what you sent is 1.17 code?
would you look at this sexy looking gentleman up on these roofs
he's looking dapper
My pseudocode wont work because I accidentally used CraftPlayer instead of the EntityPlayer handle
But the concept is the same, you can loop the fields
pov: imma crash the server
can't think of a way to optimize it further without making a block removal queue that would look weird
1.18+
private static Connection getPlayerConnection(final Player player) {
return ((CraftPlayer)player).getHandle().connection.connection;
}
1.16
private static PlayerConnection getPlayerConnection(final Player player) {
return ((CraftPlayer)player).getHandle().playerConnection;
}
so yeah newer versions have something "inbetween" the player and the actual connection
idk how to tell you this but that's not how you use pickaxes
I assume this is with mappings?
best part: I'm not right-clicking
yes, 1.18 thing is with mappings
add a cooldown?
I'm calling the miner's guild, we're going to sue you for this insult to the profession of mining
Well without mappings it's easier to figure out what's actually going on under the hood
imagine using mappings
Oh they can be useful
I just look at a() and b() all night
yes, way easier to understand, lol
But I couldn't be bothered yet to set up mappings for my small use cases 
aaz(1 * 320 / math.pi * 2); //todo: document this
nms field names are so fun
my comments are better
pretty sure somewhere in the now nearly 1k classes of my plugin I put down a comment saying something like "I know this isn't a good solution but you try to figure a better one out"
so that's why copilot suggests me that crap all the time
My best comment so far, took me pretty long to write and literally no one will ever read it because I decided to throw the project away 
@param radius The radius š š
and the angle is the angle, who would have guessed š
Top tier explaining right there
for some reason math comments tend to be the longest
I used to have my own rotation matrix and boy was the comment for that long
bc math is complicated
or class comments
lol who comments classes
xD
the name of the class is the comment
everyone who does API
holy f*ck
ya see your problem there is that the class name should be that entire comment
ew what the fuck
good idea
top-tier comments right here
That's... a lot 
It looks better in a browser š https://hub.jeff-media.com/javadocs/morepersistentdatatypes/com/jeff_media/morepersistentdatatypes/DataType.html
declaration: package: com.jeff_media.morepersistentdatatypes, interface: DataType
true
who needs comments, not I
I mean it explains the method, maybe you could put a few more articles in there but that's about it
And also apology letters at the top of the class
I always dedicate every single class to someone who inspired me in my life
xD
What do you do when you have a project with like 50 classes?
I have 6 š
I think I have 200?
I never said it was going to be different people
not sure
yes that looks totally empty
meanwhile I'm just vibing with my 8tb NAS
That's quite a small ssd 
I still have 68mb what do you mean
I can fit the entire shrek movie in about 2 pixels worth of quality
meanwhile I am going broke for paying for a 40TB server every month lol
68mb should be enough
When I built my pc I decided to cheap out and buy a 120 GB ssd, I regretted my decision pretty much immediately
I have like 20gb worth of projects idk what to delete
boy that's a lot of pictures of feet
lol
maybe you should start compressing them
the entire 120gb drive is just windows + coding stuff
or at least get pictures of feet that aren't size 14+
for what lol
it's backups of my proxmox VMs. it only says 18TB in total because it's 4x10TB in a raid1. and it only says 3.73TB used because ZFS is extremely nice in compressing data
also just saying 40tb nas costs very little
I'm still waiting for the day where I can make a gui on MS-paint and pass it through a scanner that renders it in-game
My IntelliJ workspace 
damn
you can buy hdds in size 8tb or 10tb for peanuts compared to years ago
true, but backups would take forever with my home internet
that shit costs a whole minimum wage here
I've never deleted a single project, still have all of my beginner stuff
you can get an 8 tb drive for $132
I think there's an EliteHooks.class in like 30% of my plugins lol
what's your min wage
what the fuck
EliteMobsHook.class
that's the price for like a 4tb cheapo drive here
ehh even then
A CMR or SMR drive?
I wouldn't use an 8tb hdd as my boot drive
followed the steps, didn't work
CraftWorld is not found
I wouldn't use hdd's at all anymore, my backup hdd's are terribly slow
then you did something wrong
definitely
?paste your pom.xml again
It's SMR. Rip trying to write to that fast.
hdds are fine for backups it's the industry standard
it's different in every plugin. for example, here's D2I's elitemobs hook:
https://paste.jeff-media.com/?abf1eabe96a407be#3ZtPz9Sd1RH9eGh7MEzBYQnxhRybxpiQerqWrvEDH8Hv
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
some poor souls even still dump to magnetic tape
oh drop2inventory
yep that makes sense
I mean they do the job, but if you hate slow drives don't buy hdds
I added the dependency by clicking on the modules for my project and adding the spigot-1.18.2.jar
is there more I have to do?
imagine not using 2 laptop hdd's on 45k hours each as a raid0 array
that is something I totally do not do
did you click the "maven reload" button?
I mean if you're just backing things up don't just stare at the process, go do your stuff while it happens in the background
My hdd has a write speed at 2 mb/s at max
yup
it's like a dishwasher or a washing machine, it's not blazing fast but you don't have to be there for it either
this one? and still nothing happened?
Then do File -> Invalidate Caches -> tick all boxes and click "Invalidate & Restart"
yep
ok
bet you can get 100 tb of storage for under 1k if you buy during some specific sales or in bulk deals
Idk maybe I'm just weird, but I won't buy hdd's again, even for backups - I like fast drives 
should I spend more than 2 days worth of lunch on a good ssd š¤
You could do that one technique where you buy external HDDs, since they are cheaper than internal, and just destroy the housing for the drives.,
but then I lose the fun of having to wipe my drive every week
well you wait until you have to store over 16tb in backups and then you get to decide just exactly how much cash you want to drop in ssds
sweet! works again
I hope I never get to that point
thanks for your help as always
:3
yeah called shucking or something right
I remember that one
honestly I am going to be fine with my 8tb for a good long while here so I'm not sweating the details
by the time I upgrade I'll probably be buying a 20 tb drive or something
and it will probably cost well under 300usd
Proxmox Backup Server has support for tape backups lol
who do they think I am?! Pixar?! IBM?!
I thought tape was used for archival purposes.
it is
but also as like the 3rd or 4th point of backups
stores like 2 projects and a picture or two
I produce 1.43TB of backups per hour
and has blazing fast speeds of like 242 bytes / second
Who needs tape when you could use punch cards.
it would be a little embarassing if mr putin threw a couple of nukes out and then suddenly the banks are telling us that they just don't remember who has how much money
so they keep that kind of data in tapes in bunkers
but thanks to ZFS only changed files are saved so it's only a few gigabytes per day that need to be stored
how sick must it be to have bunker in your business expenses
You're probably producing more backups than the place I work at lol
I actually use windows file history to do the same thing, it's really cool
everything gets dumped to my NAS
I could set my computer on fire right now and I'd still have the files from 5 minutes ago on the NAS
Maybe I should also start looking into backup solution, I would be really fucked if my drives would suddenly go up in flames 
only since I'm using Proxmox and Proxmox Backup Server lol
I don't think I need a backup solution
I know I need to, but fuck itās an expensive up front cost that Iām saving up for.
is that like mac TimeMachine?
hm idk I never looked too much at timemachine
on google drive, important projects on github and on my work laptop š¤
it just detects new files and file changes and dumps them to the backup
it's just incremental backups, dont know how it works exactly
I think it's basically the same idea yeah
It works like youāve been describing it. If any changes are made to whatever files you want to be backed up, the program responsible for backing everything up looks at those files and the saves them if changes have been made since the last time.
8 TB NVMe 
yeah good example of why I spent 200 euros on a 8tb hdd instead
actually might've been less, I can't remember
190⬠for a Seagate 8 TB hdd
Also, hard drives will last FAR longer than an ssd. If you want a good setup. Use HDDS for storage and have an nvme ssd for a cache.
ymmv?
your mileage may vary
are there any special kinds of collections or maps that do NOT allow null as value?
(i don't care about map keys, just the values)
my C drive gets to 0 available bytes practically every other day
I'd be surprised tbh
me too but better be safe then sorry
why can't I resolve the symbol of my own main class :/
exactly, there isn't even a Tree API in spigot
You could make some sort of wrapper object if you really want some sort of null
yeah but it must work generically for ALL kinds of maps
Yeah well good luck with that then 
Cartographers, artists with nature fetish, tree huggers.
gaddamn tree huggers get the hell off my lawn
oh is SoftcoreSMP an invalid name because of the capital letters at the end?
that's weird
java's picky sometimes and really loose other times
its not invalid
uhh
ok so when i name my main class SoftcoreSMP then it cannot be referenced in other classes
"unknown symbol"
import it..?
screenshot
yeah its called an IDE š³
make me look like an idiot
yeah but only after i deleted and then renamed the class :icant:
š
thanks intellij
what does this spicy thing mean in intellij first time to encounter it
hey don't talk shit about my waifu intellij
i aint talkin shit š³
intellij by far best ide i've ever seen
but still an ide š
jetbrains gave me a free year-long sub to all of their services and I'll be damned if I allow anyone to speak ill of my new waifu
lol
yeah fr what does this mean š¶ļø
I use student account on jetbrains ez 1 year and renewal
lombok ā¤ļø
I'm still using a Jetbrains student license even though my last year of school was three years ago 
I already spent my student license
But it will run out this year :/
oh ok, then my guess is correct with lombok
and I am pretty sure it doesn't cover the whole array of intellij services either
lol I finished studying law in 2018 and I still use Ultimate uni license
As I'm using Getters
goddamn java coders are privileged š
i wish c++ had it as good
idk why they even give out ultimate to law students
rust >>>>>>>>>>>
Student license gives you access to everything
even rider? hm
except hookers
cuz i already like cpp
Yea
And blackjack
yeah RIP
might be the case, might even be the case that wasn't the case years ago when I took my student license
does anyone know whether arrays in java use integers as index?
actually I'm not even sure rider existed when I started the license
I'll have to pay my license in a few months, god Jetbrains is kinda expensive
like can I do new ItemStack[Long.MAX_VALUE] ?
bro just get a free yearlong sub like me
it's easy
lol
magma how is elitemobs doing currently, I missed grinding it myself back in the days
omw to learn rust
Ouch :(
I'm currently procrastinating on the most insane EM endeavors we've ever worked on
You'll probably run out of memory
what kind of endeavors
It's worth it. It gets cheaper every year and you get a PFL
yeah it was just a theoretical question š
oh another question
but yes, integers, not longs
the arena is officially coming out after this long wait and primis chapter 2 is about to come out as well (both coming out before the end of the month)
I have a List<Integer>, is it not possible to turn thisinto an int[]?
Wasn't there a graduation discount thing?
also the arena is a wild ride
.toArray(int[]::new)
and u do this all alone right?
won't work :<
yeah been there, paid one year then they showed up on stream, thanked me for using their services and gifted me a free year sub
Whut
I'll just do mapToInt
mr choco bring me money

Truly something else
I made $5 from it, still remember it
I believe that makes my music career more successful than 99% of artists out there because I lost no money and even made $5
I am just learning SPigot Plugin Development, give me some ideas that I can implement, but not too difficult š
take a topological scan of the earth and recreate it in minecraft in a 1:1 scale
I mean the hardest part is trying to figure out how you're going to deal with the projection distortion
projection distortion?
project a sphere to a plane and tell me how that works out
lol people claim java has autoboxing/unboxing but sometimes it's not that trivial
oh yea I didnt know the english word
int[] from PDC to List<Integer>:
final List<Integer> nullValuesList = Arrays.stream(pdc.getOrDefault(KEY_NULL, DataType.INTEGER_ARRAY, new int[0])).boxed().collect(Collectors.toList());
no
also the annotation syntax for primitive arrays is weird
static List<Integer> intArrayToList(final int @NotNull [] array)
the @ NotNull has to be between int and []
annotations are basically entirely jank
it does feel like it got tacked on at some point throughout java's development
I find them very useful
the best jank is also some of the most useful code out there
that's why no one gets rid of it
if I had to do getters and setters without lombok I'd be serving time for a string of assassinations of java developers at oracle after I lost my mind defining getter #100,203,120
I use Nonnull and don't have the issue
static List<Integer> intArrayToList(final @Nonnull int[] array)
can you create your own Event Listeners like BreakBlock etc?
Yup
it works but now run code inspection
it'll tell you primitives can't be Nonnull
is there any good tutorial on that?
I'm not seeing it lol. 
hm weird, maybe it also depends on java version or whatever
I am still using 8
NotNull warns me but not Nonnull and it runs fine of course
hm yeah maybe that'sthe problem then
theyāre great but just sort of weird being awkwardly packed into reflection
https://www.spigotmc.org/wiki/using-the-event-api/ scroll your way down you'll find it
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ok ty
Ello i am noob i need help
why does the code not work
@Override
Public void onEnablee(){
}
it says Syntax error
and also the method must override or implement a supertype method
please help
I wonder why
and isnt public lower case
and get an ide xD
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
oh no
public void onEnable(){
Bukkit.getLogger.info("hello how are you i am under the water uwuwuwuwuwu");
}
it says the field getLogger not found
ok thx babe
it says error
the dependency not resolved
getLogger is a method not a field my good sir
bro learn java
but a field is also a method?
cuz if you consider the polymorphism field and methods should be one facet of two sides?
stop trolling
?kick @solid forge trolling
Done. That felt good.
lol
check his old messages
xD
he must have amnesia or is extremely retarded
sorry mate sorry mate
sorry dude
just dont
dont do that again
emotional damage
Do it again
Do it
democracy š
ok real question
how does bungeecord complete intent work
š
like im trying to delay a bungeecord login event now
and maybe like delay it for 20 seconds or sth
like is the registerintent and completeintent async or sync?
my next question about maps: is there ANY map that can store null as key more than once? I highly doubt there is but I wanna be sure š
maybe there is a weird map implementation that can store null <> something more than once and then returns a random one when using map.get(null) lol
multimap?
multiple keys
just make one
tbh null can be a key but its just weird
