#help-development
1 messages Β· Page 1976 of 1
int myNumber = 3;
chrome extension, css and js editor for a specific webpag
gib
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.
what do u want to do
Object object = someObject
String string = someString
PlayerProfile profile = somePlayerProfile
no
put in the corresponding ones when u isntall the extension
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.
ty light
that's why I sent 5 links
okay I will explain it quickly
every Object in java has a specific class associated
mfn do u srsly think anyone will listen tbh
e.g. String is a class
that represents, well, text etc
your have a custom class called PlayerProfile
to run a method inside a class from my oneable can i do this:
new TestClass().testMethod();
so if you declare a variable called "profile" and say it's of the type PlayerProfile, it has to be an object that is either of class PlayerProfile, or any class that extends or implements PlayerProfile
ye
aight cool
huh where
Variable without a value:
Player player = null;
Variable "without" a type nor value:
Object object = null;
so (new TestClass()).testMethod();
o ok
Car car = new Mercedes(); // OK
Car car = new Human(); // No
i mean
it still has a type
lmao
Thats why i added quotes.
Everything is a car if you're brave enough OWo
you WILL HAVE TO LOOK at the basic java tutorials or you won't understand anything
Well I feel like the closest one is "var"
It has a type but unknown atm
nah "var" is still strictly typed
No var has a very specific type.
var is just short form
var asd = new WhatEverClass()
is the same as
WhatEverClass asd = new WhatEverClass
No its not unknown. Ist just syntax sugar
same applies for "val" except that it's also final then
kotlin in java uwu
The context decides the type. Thats why var x = null; is not valid java because the type can not be determined from the context.
tbh i like how intellij draws that ovelay
so if u type
var x = new Integer();
intellij draws
var x: Integer = ...
Yeah it has some nice features like that. Same goes for parameters or call chains.
nah it actually overlays an error message π
you're unfunny but HAHHAHA
I have my class named Integer, and it has an empty constructor B)
get the correct import, boy
and why is ur maven bar
there
wtf
Nice to know what type a chain has at every moment
so I have more space in the structure tab
I recently installed IntelliJ and the only thing I don't like is that, by default, it formats single line methods on the same line. (for enums)
i dont even use it Lol
very useful for large classes
just disable it
it's called auto fold or sth like that
yea I know. I just need to find the option somewhere
i just Ctrl+F
You can disable that if you want
do you know the name of the option? if not, I'll just find it on google
I mean it probably depends
Settings -> Editor -> General -> Code folding , disable the "One line methods" option in the "Collapse by default" section.
Unrelated question but, for example If I wanna do some code that changes durability of an item and does some cool magic on it
can I have it on a utility class
i find it ugly to have methods not really related to my class purpose on my class, since the method is being used in other places too
its not supposed to be only for the class
thanks
sure, create a class "ItemStackUtils" and add a public static void changeDurability(ItemStack item, int durability) method or sth like that
I don't, but when I asked for topics I can use to progress conclure suggested ClassLoaders
I mean i asked for advanced topics
I never needed custom classloaders so I've never looked at them
I just learn stuff not cuz i need them
i want to get to a good level in the next 5 months (my first year with java is about to end :o)
Very usefull: Properly learn how to use streams
It teaches you so much about lambdas, functional programming, scopes and so on.
They are a gateway to understanding CompletableFutures for example.
well, then take a look at them if you're interested π
streams are like one of the best things ever added to java
Well I do know somehow an amount of using streams
new BreakableItem(itemStack).setDurrability(0);
π
That's useless
Why would you make a class for that
You would have to make a class for utility as well
you can add other methods to the BreakableItem too and rename it
Because sadly extensions are not a thing. This is just a helper wrapper class. I personally are also more of a util class fan but this is fine too.
That's an object oriented way
I use this to damage items
/**
* Damages given ItemStack by specified amount
* @param amount damage amount to be applied
* @param item ItemStack to be damaged
* @param player Player who damaged the item
*/
public static void damageItem(int amount, final ItemStack item, @Nullable final Player player){
final ItemMeta meta = item.getItemMeta();
if(!(meta instanceof Damageable) || amount < 0) return;
final int durability = item.getEnchantmentLevel(Enchantment.DURABILITY);
int k = 0;
for (int l = 0; durability > 0 && l < amount; l++) {
if (JeffLib.getRandom().nextInt(durability +1) > 0){
k++;
}
}
amount -= k;
if(player != null){
final PlayerItemDamageEvent damageEvent = new PlayerItemDamageEvent(player, item, amount);
Bukkit.getServer().getPluginManager().callEvent(damageEvent);
if(amount != damageEvent.getDamage() || damageEvent.isCancelled()){
damageEvent.getPlayer().updateInventory();
}
else if(damageEvent.isCancelled()){
return;
}
amount = damageEvent.getDamage();
}
if (amount <= 0)
return;
final Damageable damageable = (Damageable) meta;
damageable.setDamage(damageable.getDamage()+amount);
item.setItemMeta(meta);
}
since like an itemstack is already breakable
Not always
is there no included method in spigot to damage items?
of course there is
look at the last 3 lines of the method I sent
Well is it worth to make a class for every method
that's the "builtin" way
yes, awesome idea lmao
oh I didn't see that.
But what is all that junk above the last 3 lines? Why would you need a random number?
for Durability enchantment
I think that's to replicate vanilla unbreaking enchant.
depends. You should keep classes as simple as possible, 5 methods ideally. Single Responsibility
shouldn't this return a boolean
yeah why not
return; is silent, it wont tell you anything
i've never needed to know whether it was damaged so it's void rn
I assume you would want to return a boolean so you know the outcome of the method
yeah feel free to PR π
And instead of arithmetically calculating the damage you do iterations for every point in durability...
someone PRed that method
I've not really looked at it
no idea what their intention was. I just accepted the PR
@tawdry scroll
why are you looping over the durability level
Which?
here
damageItem method
imagine people having unbreaking level 100k
Oh thats how its done in mc
You can check to confirm
nah I believe you lol
if vanilla does it like, it should be kept like that
so that it will behave exactly the same
people who enchant their stuff with 10000000 levels are stupid anyway
PRing is such a long operation tbh
No i mean really
Can be mistake from me in reading the nms code
yeah, takes about 30 seconds
no idea
btw
ConfigurationSections
they dont read the contents from the config
everytime
you use them right?
yes, so?
Correct
so they store it
of course
Mhm
cool
pretty bookish scenario
FileConfigurations do fully exists in memory. But you should still not use them as data structures.
nothing
well let's rather say
how about I make my config like this:
Config:
example: xd
example2: lol
exampleList:
- "xd"
- "xd1"
then i can get a configuration section Config, then just access it when i wanna use my config
a final variable can be assigned once or zero times
It makes the variable immutable. What it does not, is making the Object itself immutable.
this
that would be better than using the FileConfiguration as a data structure, right?
or is it the same
alright i'm an idiot then
FileConfiguration is a subclass of ConfigurationSection
No you can use it wherever. The only thing you cant is re-assign a value to it.
so I should just parse the values of the config and store it in a data class, right?
a final variable is like a CD-R. You can read it many times but write to it only once
Yes you got the message π
Ah. Interesting analogy
sometimes I'm big brainzz
well depends what you consider a crop
if you consider all ageables to be a crop, sure that's fine
fire
You could easily just put the blocks you want in a set
CaveVines
Bamboo, CaveVines, Cocoa, Fire
You donβt farm fire?
not on farmland at least
because it can age and will only spread when it's full age I guess
or it will die when it's full age
I guess so it can be turned out a some point
to check for crops: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Tag.html#CROPS
declaration: package: org.bukkit, interface: Tag
ah makes sense
that's the only proper solution and will also work in all future versions I guess
Nether ones
maybe nether ones?
nether
coll i had a dream of you btw
so LOGS includes LOGSTHATBURN
i actually did
a nightmare probably
Kinky

I doubt it
If you are speaking of the placed Block then yes.
wait
just plant a sapling and check with F3 screen
and ur discord is Josh, not Coll?
what blocks infinitely burn?
my dream didnt know that
ah perhaps
you can check with F3 screen
there is 3 separate tags for blocks that Infinitely burn in end, nether, and overworld
the stupid fandom mc wiki is too narrow
the stupid "popular pages" overlay overlays the actual content
yeah one can click on "expand" at the top
but
why
why doesn't it just use full width by default
at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[patched_1.16.5.jar:git-Paper-792]
at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:85) ~[patched_1.16.5.jar:git-Paper-792]
at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:73) ~[patched_1.16.5.jar:git-Paper-792]
at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:61) ~[patched_1.16.5.jar:git-Paper-792]
at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:47) ~[patched_1.16.5.jar:git-Paper-792]
at main.kappelo99.zlecenia.Bounty.bountyGUI(Bounty.java:676) ~[?:?]
at main.kappelo99.zlecenia.Bounty.onCommand(Bounty.java:514) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-792]
... 19 more``` What is this?
?paste
"Material cannot be null"
Pretty clear
show bounty class line 676
You are calling: new ItemStack(null)
new null(null)
works in bytecode :3
Report a bug to spigot, since they use Validate.notNull(material) in the ItemStack constructor! /j
boxed null
no
ItemStack list = new ItemStack(listBountyItem);
that's the internal ItemStack validator
listBountyItem is null
ez
and you prob should use descriptive variable names
what is 'list'
tbh working on client side applications requires way more java knowledge
since if you make something laggy
people are gonna suffer
but most servers have better System Specs than Users'
if what's a boolean?
Yes, indeed I'm very glad I don't have to pay to use an IDE, or use a text editor
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.
means noob
they tell you because you NEED the basics to know why your stuff doesn't work
at main.kappelo99.zlecenia.Bounty.bountyGUI(Bounty.java:690) ~[?:?]
at main.kappelo99.zlecenia.Bounty.onCommand(Bounty.java:514) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-792]
... 19 more``` I changed some code but it isn't work
noone means to offend someone by doing ?learnjava
you can't cast itemstacks to itemmeta
because itemstack does not implement itemmeta
I was made fun of for not learning java on my first weeks
you have to use getItemMeta() and cast that
so that isn't totally right
yeah people make fun of people who do not want to learn java
not because you haven't done so yet
people nowadays have it a lot easier tbh
I still remember learning java using actual books lol
oh wait no
wasn't java
it was C
I actually did what i always tell people not to do: I learned java using spigot only at first.
SkullMeta headMeta = (SkullMeta) head.getItemMeta();``` here is error or not?
What is that
but yeah if you do not why you get a nullpointerexception when you try to call a method isLoaded() while the object you are calling it on is null, then sorry but you have to learn the basics first
Everyone did
no one went and learnt java
that should work
its fucking boring to do without an api to spice it up
I did this at first too, I never even knew OOP was a thing for a while :/
Pretty sure everyone did it like that
how is it?
I learnt java using "Hamster Simulator"
dunno, but when i was getting screamed at to learn java, i found it boring
idk how an api would help
Eh i was quite early there. I think after 3 weeks i overused abstract classes an interfaces because i found
that everything needed to be super abstract. Was a clusterfk. But i also had a somewhat experienced dev
that taught me 10hrs a day then.
For me. even when I chose to learn java before spigot, when I go to java related servers I get made fun of
it allows you to do actual useful things instead of "a caltulator" or a "program that prints out the sum of two integers" etc
yes, if you do not have any profile, you cannot checker whether it's loaded
it's like saying hello to a neighbour if you don't have neighbours
Mental illness?
BettanationsNeighbour.sayHello() can't work if you don't have neighbours
I regret not learning plain java first
profiles and players can never be cast to a boolean
a boolean is a primitive type represnting "yes" or "no"
a player is not "yes or no"
yes
it will throw MentalIllnessException
what do you mean with "check a specific person"
Uhm which version should i use for 1.8 to 1.18?
as API? 1.8
1.8
i forgot how to run methods that require to be on the main thread from async, how do i do that again?
i dont know guys i never made a plugin from 1.8 to 1.18 lel
use the scheduler, run a synced task
runTask
ty
always use the lowest API version you wanna support
and in pom.xml should i use the lastest version?
no
the lowest version you want to support
yes of course it has changed
Oh right I remebered
but nothing was really removed
I don't want to run buildtools for each version I wanna support for my plugin
(Im using nms)
do I just use
you have to though
Reflect
condolences
i made the plugin in 1.18
either reflection (don't) or use nms for each version (don't)
I wish I knew how to import nms
what version?
the fuck do i do to access nbt then
what's NMS
it might work in 1.8 if you didn't use any new features
the only time i used nms was to handle the packets a player sent right after they arrived
damn i dont know whats changed lel
net minecraft server iirc, allows you to access stuff the api doesn't
Not Motherly Surrounded
lemme change api and see if its broke it
like CraftPlayer
then try running it in 1.8 and see what happens
aka motherless
Any, I just can't get my mind around how to import it. There's this real good api I want to use but I can't get it because the maven thing is messed up and the dev won't respond :/
the most boring space exploration game ever, no man's sky
SO WHAT DO I DO HELP
just replace "spigot-api" with "spigot" in maven
do i like
then you have NMS
yes obv
and gradle?
fine ill use reflection
i got that already
wait when did CraftPlayer become a thing
I wanna use https://github.com/yannicklamprecht/WorldBorderAPI but it's a mess to import :/
Since forever
it's a thing since CraftBukkit was released
so maybe... 14 years ago?
ok i figured
11 years
oh ok
Minecraft wasnβt around 14 years ago
Player = Bukkit (API) CraftPlayer = CraftBukkit (Implementation)
hm idk. I bought MC beta 1.2 when I was 15 and I'm 27 now
huh CraftBukkit older than me
damn that's surprising how long it's been out
Beta was in 2009
2008 came the first snapshot of minecraft iirc
i dont remember when i got it but it was 1.0 release
born in may 2009
Classic was may 2009
alpha 1.0 = july 2010
I also got it at 1.0
end of 2011 i guess i got it
beta 1.3 was released on my 16th birthday
1.8 or 1.8.8?
lol may 2009. Means minecraft is older than most of the 1.8 community
whatever you want to support
i dont understand why you want to support 1.8 anyway
Wait, endermen came before the end?
pvpreee
yes
I didn't know that lol
im just aking anyway i want 1.8.8+
another quick thing, how can you check how many slots a player has free?
was there an ending before the end got added?
i tested the plugin and its work perfectly in newest version of spigot
loop over the inv, check every slot and count some counter up
les test it in 1.8.8
it's been almost 8 years since microsoft bought it?!
No
I didn't know there were two other founders carl and Jakob
yeah but do i check if the item is unll?
sad
damn bro mojang kinda sold only 2.5b for minecraft?
i never killed the enderdragon by myself anyways
I still remember when the nether came out.
We rallied up in the basement and did a lan party through the night. Good times.
by doing a null check on the item and then check if the item is amount == 0 or not
k
public static int getFreeSlots(Inventory inventory) {
return (int) Arrays.stream(inventory.getContents()).filter(item -> {
return item != null && item.getAmount() > 0;
}).count();
}
now i kinda wanna play minecraft survival
public static int getFreeSlots(Inventory inventory) {
return (int) Arrays.stream(inventory.getContents()).filter(item -> item == null || item.getAmount() == 0).count();
}
yeah, this
almost as fast as you xD
item.getAmount() > 0 
is that even possible. I think not.
huh no? it must be 0 amount to be empty
not larger than 0
You used to be able to get weird items with a red 0 for the stack size
Not sure if you still can
An item with the amount of 0 will automatically be nulled
Then you should just be checking if itβs null or air
Should I store player data in a file or in PDC
what u talkin about it was still possible in 1.7 iirc
depends on what playerdata you are talking about
also if you need that data offline or not
that doesn't contradict what I said
fair
Pdc is not relational. It is impossible to get data offline without hacks and hard to wipe
if you have large data, or data you need also when a player is offline, do not use PDC
otherwise I'd use PDC
what's pdc
?pdc
?pdc
oh yeah
it's like "proper NBT"
just load the player.dat file
smh don't call it nbt!
ok my plugin works perfectly in 1.8.8 to 1.18.1
data you need when the player is online, or data you also need when the player is offline?
i mean ig like 2-4 mbs of data at max
also i dont think i will need the data when the player is offline
^
imagine you have 100 players
then you have a 400mb players.dat file
doesn't sound very good lol
"An api to store persistent data built on top of NBT"
yep
no
A relational database > just a file smh
that's like saying "java is just ones and zeros"
Nbt is an implementation detail
well that's basically what PDC is
it's an API to save ANY type of data, using NBT internally
I mean, who knows if mojang just moves to a new data format in 3 versions
how to do
net.minecraft.server.v1_16_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle(); in reflection?
maybe im missing smth but i dont see a reason to not have it
why do you need reflection? what versions to you need to support?
CraftEntity.class.getMethod("getHandle").invoke()
feel free to PR it
that makes no sense as CraftEntity is in a "versioned" package itself
Youβd have to use Class.forName
I have but what you sent is valid java code
ok??
all my exams in school were asking us to write hand written pseudo code lol
it was also allowed to just "describe" the code you would have written
actually not a bad idea imho
Thats good training
As said again, thats an implementation detail, like packets. This is not just an api to store custom values. Mojang can easily change storage method
then you're totally fucked lol
since 1.17 there's mojang mappings
field, class and method names changes with every version
you can't use reflection for 1.17+
you could use it for 1.16 and below
you want to create one NMS module for every version now
you kinda can with relfeciton-remapper, even using readable names...
do it like I did
https://github.com/JEFF-Media-GbR/JeffLib
That's better than reflection. But even better is to not use nms at all
yeah sure
but for many things you just have to use it
nbt
im trying to copy an entity
so i have to use nms
We should contribute api methods for these things
if only there was like a fork of spigot that had a entity de/serializer
so you can easily copy an entity
Hehehehe
if only that would be included in spigot
there is always need for NMS at some point
it's a binary data saving stuff thingy
even if you PR functionality, older versions will not get the backport
that's the best explanation I can come up with
Supporting older versions π
So what does it do
using old versions = not deserving any support tbh
I mean people also don't complain that MSFS2020 doesn't run on windows XP
I mean, the dream is just maintaining your own custom fork where you can PR whatever API you need
somehow it's only 13 year old MC players who still use 1.8
no idea why the MC community is so reluctant to use supported software
so you can click fast
what exactly?
Everything
oh yeah awesome lol
what r u doing
the core module has an interface like "NBTWrapper"
then there's one module per NMS version that implements this wrapper
that's basically it
well "performance"
I would beg to differ 1.12 offers better performance than 1.8
Windows XP runs faster than Windows 10 you know
the main reason why people still use 1.8 and 1.12.2 is they are still using "1:0" instead of "dirt"
What
they are using hundred years old plugins that never actually respected that all the "magic ids" were deprecated since 5 years
in ancient versions, you didn't say "dirt", you said "1"
and for "stone" you used "2"
Oh yeah I didnβt realize what the 0:1 meant
Stone is 1 tho I though t
it was an example
it was announced 5 years prior that this will be removed, but plugin devs didnt care
then 1.13 came and
boooom
all bad plugins died
that was also why I started uploading plugins - because ClickSort was dead
I donβt think thatβs the main reason people didnβt switch tho
Def clicking fast
well there's so many plugins to restore old pvp
What I really donβt understand
Is why 1.8 and not 1.7
Everyone used to love 1.7
And hated 1.8
Because block hitting
erm why would one use 1.(X-1) if they could use 1.X
Block hitting
cant find it
what changed?
it was an example
You could right click and left click at the same time
look at core/.../internal/nms
But I guess if you said only 13 yos play 1.8 they prob donβt know about block hitting then
it makes no sense anyway
so, runTask does not run sync for some reason, so i tought about using scheduleSyncDelayedTask, with a delay of 0, would that work
It was so cool
nah man im not installing each version's build tools
runTask does run sync
The sword would swing in crazy directions when you did it
buildtools is universal
ik
latest buildtools can compile all versions
oh yeah i got the wrong exceptions xD
Look up a video of it and tell me it is not lit af
download?
you can't download them
you have to build every version
same thing
just write a bat file
takes a long time
well I also don't want to work but I have to to make plugins
I also wish I could just explain to intelliJ would I'd like to do but we aren't that far yet
is there another way without nms to copy entities
copilot go brrrrrrrrrr
not with spigot
Ok literally why is 1.7 not in buildtools I swear for the longest fn time nobody wanted to play 1.8. It was either kids who wanted to play latest version 1.9 or 1.7 for pvp. 1.8 literally nobody played
The worst update
Version *
I wonder why buildtools support anything below 1.16 anymore anyway
Why not under 1.8
1.18*
i wonder why it supports 1.16 at all
well I understand big servers can't immediately update
but they should at least be able to update within a year or two
so I guess supporting 1-2 versions behind is okay
after all windows 10 still is supported although win11 exists
its more than a year old and people yet go like "i hab us becs unatiin laaaag" bro viaversion is there for a reason
how to serialize entities
same for debian 10 and debian 9
i wanna serialize an entity
do it on your own or use paper
I think paper can serialize entities
not sure though
ok im installing pape
Win xp do be fast tho
actually
no one uses pape
isnt there
a serializer
for anything
no
What entity are you serializing
all
Ah
all types of entities
the majority does
o what's tihs
idc
if i make a paper plugin
oh nice
Paper api do be kinda sexy tho
to 90%
ye ye
im on the edge of raging tbh
Itβs even got entity ai support
imho paper should do implementation only and move their API to spigot
anyways
i made my ls plugin for 1.17 paper at first, got so many complaints had to port to 1.16.5 spigot, and yet i still get requests like "can you make a 1.14 version?"
isnt there a way to serialize any object
does viaversion let 1.7 players connect
still, no
no
viaversion is for future versions only
viabackwards is for old versions
if the object implements Serializable, yes
and viarewind is for ancient versions like 1.7
thats what i was thinking of then
imo <1.16 should be dropped for everything
yes, I think so too
can i make my own entity serializer
even then, 1.16 is a year old
if I was md5, i wouldn't even have added the log4j fixes
i believe so
I would have fixed log4j for 1.16+ and tell all others "well, update already"
gets each field on the class, turns it into a hashmap
yeah smort
And very time consuming
It says if you want to support 1.7 on a proxy then you dont need legacy support but without a proxy you do? is that true
from the hashmap
Yeah fuck it ill have all versions supported like that
and Ill make a library
for it
using bungee or not has nothing to do with this
better support 1.7
it changed the outcome on that site you linked
You are still mirroring already existing functionality
actually what if some versions didnt have a field
well if it doesnt have the field it will still work
i can do it
you either install via* on the bungee only or only on all backend servers
simply don't fuck and do reflection imo
using it on all backend servers and NOT on the bungee is the recommended option
is via* a plugin or is that just talking about viaversion+rewind
You'd need to do some fuzzy reflections
you CANNOT PROPERLY use reflection only for 1.16+
give me an algorithm, or psuedo code or some sort
im not doing nms
You can
not properly
Dont rely on names, but analyze method return types and args at runtime
it will get soooo messy that you could just directly use proper modules + mojang mappings
okay how would you go about the changes between 1.17 and 1.18?
nothing has changed related to nbt in 1.17 and 1.18
in 1.17 it's Player.playerConnection, in 1.18 it's Player.connection.connection
so there's an intermediary object
good luck doing that
Actually it says you need Velocity on the proxy instead
i dont want code yet, ill try it on my own
Lol just match a field with connection class
hm might be, no idea, I don't do any viaversion stuff anymore
Also 2hex pls provide a proper implementation for Paper
and how would you know whether you need to call another object on that object then?
yeah but ill prob make it a library
as said in 1.18 it's player.connection.connection (two dots)
closed my server when 1.9 dropped
still, how do i do it
but only two-object-chain in 1.17
cost like 3x as much to run the server when 1.9 came out
do i like loop through the methods, get their return type, invoke them
and also it's not called "connection" in either 1.17 or 1.18
and store the name
it's only called "playerConnection" in 1.16 and below
with a class like a Triple
Just return types and params
in 1.17 it's maybe .a and in 1.18 it's a.b. or sth
the return types change in every version because the names are obfuscated and also the CLASS NAMES are obfuscated
No
this is spigot-api
not nms
yes
Classes names arent obfuscated
mfn
r u talking about the thing we're talking about??
this is spigot not nms
im trying to serialize and deserialize an entity
I don't know, what exactly are you talking about lol
a bukkit entity or an NMS entity
you'll have to write your own serializer
That iss what im doing
No, in spigot names from spigot mappings are used
I need some guidance on it though, so I'm asking manya on a base idea on how to do it
only in 1.16 and below. since 1.17 spigot uses obfuscated names
oh wow how the fuck did I end up on #4 on google
No
As you can see it's net.minecraft.core.MinecraftSerializableUUID in Spigot
how to get methods from an object
yes, and it's different in mojang lmao
do I just .getClass()
net.minecraft.core.SerializableUUID
Mojang
Spigot: net.minecraft.core.MinecraftSerializableUUID
but the Bukkit entity class wont have the properties of the entity object
Ikr
Class names are not obfuscated especially
so just use renamed class names in reflection?
uhh
okay to make this clear, let's say you have a method that sends any Packet<?> to a bukkit player
sendPacket(Packet<?> packet, Player player)
we're not talking about packets
how would you do that work for 1.16, 1.17 and 1.18 using reflection?
i assume .getClass() will remove its properties, it will just get org.bukkit.entity.Entity class
not the class of the object including its properties
I am talking about NMS in general, and that includes packets. and all the other NMS stuff
I still have no idea what you are talking about though
no, getClass() get's the actual implementation class
e.g. net.minecraft.world.entity.Creeper or however it's called
it will NEVER return a bukkit creeper
oh wait actually, bullshit
if you call it on a bukkit creeper, it will return the CraftCreeper class
all actually game related things in spigot are just interfaces, while the CraftThingies are the actual implemantation, and those are actually just wrappers for the underlying NMS class
Creeper (NMS) -> wrapped by -> CraftCreeper -> implemenets -> Creeper (Bukkit)
I woudlnt use relfeciton for packets, lol. Reflection is acceptable on simple things and i think cloning an entity is pretty simple
I think you're completely misunderstanding what he's saying.
I think we are both talking about two completely different things and we both don't understand what each other is talking about
serializing / deserializing an entity as a whole object is simply not possible without NMS
how else would you be able to ensure them to have the same entityID and UID
hey yall so i have a minecraft server and i have an issue with mcmmo the players do not gain almost any xp and they cant enchant with the xp they have for some reason
or go to mcmmo's discord
I'm working on an "offline bonus" system in which I need to subtract the OfflinePlayer#getLastPlayed with current time to know how much time has passed since his last login.
I would like to know when is this timestamp defined. Can I catch the old one on a player login ? or is it updated earlier ?
getLastPlayed prints the last time the player logged out iirc
Just beware that it might be decades ago if it is the first time the player played
finally uploaded my plugin lol
Returns:
Date of last log-in for this player, or 0
I'd just get the map of all offlineplayers and their last login time on onEnable
Bukkit.getOfflinePlayers()
Oh well. Either way, the diff will be an non-issue for such a system
Though idk really now
Eh, just try and see
My suggestion is this:
You would map all those timestamps on startup ? and update it on logout ?
Issue with such a way of doing it, is that i'm working with a large playerbase, around 100k unique
tbh actually I'd do it totally different
- in PlayerQuitEvent save "logout-time" as PDC with current system milliseconds in the player object
- when a player joins, get their last-logout-time, and done
what does PDC means
?pdc
smh
Damn you had that ready
Forgot to say I'm building against 1.8 API
bruh
I know that Paper for sure has a method to get last logout time
why didn't you ask that question 8 years ago when 1.8 was released
for now I'm doing a PlayerLoginEvent on a monitor priority
priority doesn't matter
the event is not cancellable
oh wait
login event
sorry
i thought joinevent
but they need the logout time
not login time
the big question is: Is the server updating the lastPlayed timestamp before or after calling PlayerLoginEvent
yeah that's paper only
if it's after then I'm fine, but before is an issue
π¦
getLastPlayed is spigot and returns login time, getLastSeen is paper only :/
The player has not played yet in teh login event, not until the player join event
To be honest it is an ambiguous name and should be changed
yeah but it'd break existing plugins so it will not change
Ok, I'm going to try it and will figure out if it's broken
A soft deprecated for removal will always do the trick
also for this, I would love to switch to a newer Spigot version but sadly, on a performance view, i can't go further than 1.8
that doesn't do anything, remember the 1.13 update? 80% of plugins broke because the numeric IDs were removed although it was announced 5 years prior
especially with 600+ players on one instance
At some point you need to for changes
thanks god i'm on a custom fork so I can use Java 15
The same thing will happen to the material enum
tbh I'd just use a yaml file on startup and shutdown
or mysql
where you can store lastlogouttime
What's going to happen with the material enum
It's going to be changed to a normal class
btw is there any discord mods for support ? looks like i'm banned on my main but i don't really know why
Do you know why
:o
although I never read any official announcements
Internally materials are represented as registries, representing them as enums make no sense for a decade now
Horizontal scaling > Vertical scaling.
There is no justification for wanting to have 600 players on a single instance.
Yeah true, custom Materials would be great.
unless they are all in the same world I guess π
Can we make that change faster
but pretty useless unless vanilla supports it
I think biomes are the first to get it
we're on one world
But materials are officially going to be de-enumified
then imho spigot should change it ASAP too
it will break ALL existing plugins though that use any kind of material reference
Future API
There are plans underway to change the way many enums in the API are handled so that custom content can be better supported. These changes are not expected to break most plugin jars (backwards compatibility will be provided), however they may unavoidably break plugin source code (though the Maven version will be bumped if this occurs). To reduce the risk of breakage, please consider avoiding the use of switch statements and EnumSet over enums which implement 'Keyed'.
Planned Removal of commons-lang
The API currently includes a very outdated copy of commons-lang. This API dependency is now deprecated and will be removed from the API and eventually the Server in a future release. Please consider switching to Google Guava (which is a supported bundled API) or using your own copy of the much more recent commons-lang3.
How would i get an object methods, getClass() would get the Bukkit Entity class for example, that doesnt include the object's properties
I guess spigot will add some wrapper that will be fine to use for 5+ years again
wdym
getClass gives you the class
then you do getFields() and getDeclaredFields()
honestly, at runtime it is kinda-easy to have enums behave like regestries thanks to ASM and the likes. Until something invokes Class#valueOf
Ahh yeah I remember reading that now, ty
yes but
like
imagine the class is
class Person {
private int x = 0;
void setX(int i) { x = i; }
int getX() { return x; }
}
i made a person object
and set the x to 5
if i call getClass on the person object
and get the method
getX
will it return 5
or 0
how I can make a mob to move to a specific coordinates
teleport it (if you have a mob), else spawn it
I want it to walk up there
move from possible A (spawn location) to point B
nms will also work for me
that makes no sense
getClass returns an object of the class java.lang.Class
your Class object doesn't have a method getX
you can only use getMethod on your Class object
then invoke that using Method#invoke and then you have to pass your original instance of your Person class
and then it will return 5, yes, of course
reflection requires two tings:
- the method object
- the instance object
then it simply invokes the method on that instance
java.lang.Class is basically a descriptor for a class
java.lang.Object is the root instance of any class - for now
yeah and instance, well... is the instance of such a class lol
LWorld is going to change a few things
what's LWorld
Valhalla project. Basically adds "Q" types next to the traditional "L" types from what I know. However I may be contanimated with outdated information
damn
I have no idea what you are talking about lol
java objects types are prefixed with L in fields descriptors in bytecode
I am sure you saw stuff like [Ljava.lang.String at some point
Basically it is the project behind value types (now known as inline types) that have different memory structure and thus cannot be null from my understanding
ah okay. I've never really looked at bytecode because I never needed to
but yeah now that you mention it, I've seen this before