#help-development
1 messages · Page 677 of 1
ye
never used protocol xD
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(javaPlugin, ListenerPriority.HIGH, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
@Override
public void onPacketSending(PacketEvent event) {
final PacketContainer packet = event.getPacket();
final String sound = packet.getStrings().read(0);
Bukkit.broadcastMessage(sound);
}
});```
Read the id and figure out which sound corresponds to which id
ah
smort
still ain't working doe
i'm just broadcasting "packet" now
still doesn't broadcast
oh sometimes it does
just not block breaking
whenever i hit something it works
i've also tried ENTITY_SOUND
It’s possible the break sound is client side
I mean, it would make sense to me if it was
Why would there be
hmm
If it’s client side it won’t tell the server that it happened
wth is this
yeah so replace it with a resource pack
Either replace it with a resource pack or implement an entire custom block breaking system
is custom codes are prone to duping? like GUI or smth
bio does not check out
how can I adjust maven for multiversion :l?
I want to be abled to do something like this
Use modules
you need different modules for each nms version you use
essentially that v1-20-1 package needs to become a whole module
that is not a module, errm @tender shard has a guide somewhere but not entirely sure
How do I check if the player has removed the asd helmet
upper version covered last version's database
upper version is upgrade
unless md_5 remove smth
I think you could use this
https://www.spigotmc.org/threads/arnuhs-armorequipevent.545188/
thanks
I use nms :l
o
how to make it possible to change incoming parameters during override
Can you provide an example of what you're trying to achieve ?
it will be long, but I want to remove code repetition, only the successors, as a result of some circumstances, have similar logic, but the input data is different
in abstract classes it is not provided change of input parameters at desire of overwriting?
That is not how override work :l
If you want to do it change it in the parent class
Or may be try overloading
I can think of generics but otherwise you can have some sort of dynamic input object
How do I allow to permission in minecraft Vanilla?
Vanilla doesn't have permissions
you can't. use my shitty permissions plugin (LightPerms) or the default one (LuckPerms)
Hi there! Today I’m going to explain how to setup a multi-module project using maven to support different NMS versions. Important notes about this tutorial: Every step will have detailled screenshots using IntelliJ. I explicitly chose not to include everything as copy/pastable source code, but normal screenshots (you can click on them to show th...
it'S a bit long lol. If you got any question, feel free to ping
i'mma upload the ArmorEquipEvent to maven central ig
Hi, something about Inventories i save them in base64 and to import them i use the Inventory class, there's a method to import it over to a player or i need to loop for the inventory saved and add them to the player (found)
The sacred jedi texts!
Sounds like you wanna wrap your parameters in a class that implements an interface that can change the parameters fields. And then have the parameter just being an implementation of that interface
you already said this yesterday and I have no clue what it means lol
i only saw star wars 3 and I did not like it 🥲
....
I also saw the first one (4th) and I didnt like that either
Source: The Sweater (NFB, Roch Carrier) https://www.youtube.com/watch?v=ZZyDsF-Gp3o
yes this is that one part from skooks but unedited, that's where i saw it first too
cat
Legit question, where does the cat close up to the camera thing come from like?
i took it
🫡
?paste
I get this whenever I try to upload stuff to maven central from within IntelliJ ^
it does work fine if I run mvn deploy from console though
anybody knows why?
for(Class<?> cls : Handlers.getClassesInPackage("me.emerald.plugin.resources.enchants")){
// code to execute creating the enchants here
}
Is this bad to do, or should I just manually be adding the items, like how slimefun does it for example:
https://github.com/Slimefun/Slimefun4/blob/master/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java
yes, that's bad
yuh just make it configurable ffs
wdym configuable
public static ArrayList<Class<?>> getClassesInPackage(String packageName) {
ArrayList<Class<?>> classes = new ArrayList<>();
Reflections reflections = new Reflections(packageName, new SubTypesScanner(false));
Set<Class<?>> allClasses = reflections.getSubTypesOf(Object.class);
for (Class<?> cls : allClasses) {
if (cls.getPackage() != null && packageName.equals(cls.getPackage().getName())) {
classes.add(cls);
}
}
return classes;
}
its reflections
just grabbing all classes in a package
why aren't you at least using Enchantment.class
wdym, what difference would that make
it would only return classes that extend Enchantment
but, now there's a caveat: you should NEVER extend Enchantment yourself anyway
Its used for multiple different classes
like Items or Commands
so i just set it as object so it works with any
the javadocs already tell you not to implement or extend bukkit classes
its not, those are just my class names
unless somehow im doing that here
however if thats an issue, ill need to recode my items then as they are implimenting listener
however I think that scanning the .jar is bad practice
which does extend bukkit classes then
you should rather keep a List<YourCustomEnchantment> and use that instead of scanning all classes
it generates that after scanning on startup for all classes inside that package
so i dont ahve to manually add them to the list
I know, I've also done stuff like this years ago, but it's kinda bad practice
i see
on the other hand, I cannot really give an argument on WHY I think its bad lol
so as said, it would ofc work fine but I still think it's bad haha
fair
im just tryna find the best way to handle this
but either way i will have to recode items in this case as
I would hardcode the list of classes and call it a day
this
gotcha
alright ty ill do that then instead
also can somebody tell me what the hell is this
the name or
yeah but what is this for lol
well from what i can tell somehow your armor equip event class is generating that
did you make it do that or is it doing it on its own
either way it seems to be a list of items that cant be used as armor perhaps?
why a txt tho, better yet why generate that
my ArmorEquipEvent is a fork of the original author's github repo. The list is hardcoded but I wonder what the purpose is
🤷♂️ perhaps they recoded how equipping armor is handled
and made a list of all items that cant be equipepd
well nobody has complained so far, so I guess it's working haha
if its working dont break it
unless you want to make something more efficient lol
but that makes little sense, it would be smarter to keep a list of equippable armor haha
that actually was the point i was going to make
til i thought well maybe they dont wanna add new equippables all the time
then again i still think its odd
but the list of items added that you cannot equip is probably more annoying to maintain then a list of things you can equip
true
wait a sec.. arent you that guy who gave me that blockpersisantdata thingy
i swear i remember you
couple months ago or smth
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
this?
yes
Yeah I made that, I had the idea in a dream
oh awesome
was it useful for you at least lol
thats actually one of the most helpful things ever lol
yes
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
oh damn
i had to manually learn to do taht
package me.emerald.gooberplugin.core.objs;
import com.google.gson.Gson;
import org.bukkit.persistence.PersistentDataAdapterContext;
import org.bukkit.persistence.PersistentDataType;
public class StringListTagType implements PersistentDataType<byte[], String[]> {
@Override
public Class<byte[]> getPrimitiveType() {
return byte[].class;
}
@Override
public Class<String[]> getComplexType() {
return String[].class;
}
@Override
public byte[] toPrimitive(String[] complex, PersistentDataAdapterContext context) {
Gson gson = new Gson();
return gson.toJson(complex).getBytes();
}
@Override
public String[] fromPrimitive(byte[] primitive, PersistentDataAdapterContext context) {
Gson gson = new Gson();
return gson.fromJson(new String(primitive), String[].class);
}
}
created another class for ints as well
oh damn yeah you could just do DataType.asList(DataType.STRING) with MorePDC
Alex living his dreams
oh wow
yeah im 100% saving these for later LOL
it also allows maps, nested collections etc
e.g. Map<String,ItemStack> map = pdc.get(someKey, DataType.asMap(DataType.STRING, DataType.ITEM_STACK));
once i finish sorting out my first issue
what is your issue?
god damn
the white item implimenting listener issue
and how thats really bad for bukkit api
white item?
oh lol
I would indeed just keep a hardcoded list
List<Class<? extends MyCustomEnchantment> myEnchantments = List.of(
MyCustomEnchantment1.class,
MyAnotherEnchtnantment.class,
// etc
);
This might seem annoying to do but relying on reflection to scan your own .jar seems very dirty
idk but it feels like a dirty hack
yeah
i mean, ill show you one reason why i kinda dislike using reflection for this
if(!cls.getName().contains("$2") && !cls.getName().contains("$1")) {
had to make a hacky fix for
these types of classes
so they wouldnt attempt to run and break the code
oh haha why don't you just check if it contains "$"
you probably don't use $ normally in your class names
... bro im stupid LOL
the first time i saw it i was like
"ok ill just check for $1"
haha
a week later "$2" shows up so
😄
i just added an extra check ig
just say you were tired and call it a day
isn't there even isAnonymousClass() or sth 😄
probably i was tired when i coded the reflection stuff however haha
yeah anyway, even though "$$$" is a valid class name, I'm sure you're not actually using that, so just do if(clazzName.contains("$"))
or you could check whether that clazz.isAssignableFrom(YourCustomEnchantment.class)
How would I make a minion generate items even if the owner is offline?
or pull a yandere dev and do a if check for $1 to $infinity
what's the issue?
i would personally make a log of when they logged out
then when they log in use math to calculate how much they earned offline
lmao
use an IntStream
Good idea
👍
Stream<String> illegalClassSuffixes = IntStream.range(1, Integer.MAX_VALUE).map(i -> "$" + i);
lmao
No issues yet lel
wanna hear something funny
i am not sure
until today i had 0 clue about super, for like the past couple months ive been doing stuff without it
whats super
well idk what your minion thing does but why would it require a player to be online?
so now im backtracking tryna use it lol
used to call superclasses of smth
a call to the parent class' constructor
an extension if you will
what is superclass
look up beginner java tutorial on yt
they will help you out
go troll somewhere else
if you find a way to impliment an extension in it yeah
ItemStack in an item class goes hard
extend ItemStack 💪
a call to super is required if the class extends an abstract class that doesnt have a no-args constructor
ah ok thx
speaking of thats the other reason i wanna move away from reflections
is cause i cant use super or extends
it litterally crashes my server
since its infintely loops that
getClassesInPackage function
example for why super() is sometimes needed
java 21 will allow to run arbitrary code BEFORE calling super btw
great addition
because rn super() has to be the first statement
(which makes little sense)
mfw virtual threads
WAIT WHAT
What JEP is that (if any)
i dont know but I saw it
maybe it won't be added in java 21 but there's definitely a "preview feature" thing for that existing
I haven't started working on it yet
I was just asking
well probably your "minion" thing requires chunks to be loaded
idk what a minion is though
but you could save a List<...> of whatever it requires to work
and then when it gets unloaded, save the current time
when it gets laoded again, do some math and figure out what it would have produced during that time
do offline calculation based on average output of when the player was online
for example
That's what the other dude suggested
I'll keep this in mind thanks
Example?
maybe you could explain what this minion does, in the first place
don't got one, never done anything like this
I have Hypixel Skyblock minions in mind
You might have a different minion in mind, so explaining what you mean would be good
It's like those in hypixel
so they place blocks and mine them
so you would know "it places 1 block per second and mines 2 blocks per second" so you know the average output would be 1/2 = 0.5 blocks per second
Well I wouldn't do it that way, what I have in mind is. If a minion is placed under a block, it would constantly generate the block type under it
My vocabulary is limited
I can't explain it well
I learned english in roblox l0l
but still, you'd know at which rate it does that. So you can keep a Date object of when it was unloaded, then a Date when it was loaded again, then you get the difference in seconds between both and calculate what it would have generated in that time difference
haha
Looks like 447, not in 21 tho sadly
yeah I jut said "java 21" because that's the next release, but yeah it probably won't be done then
still, fancy new addition that's long overdue
as a workaround one can currently just declare a method that returns whatever input it got, to avoid this issue
I will do this, thanks for the help
np
anybody? 🥲
hello, how to display above the cat bar a pettite anotatino? with acf you have to add @named but in native spigot library?
when you tape your command argument. At the top of your words/argument we can see for exemple <amount>
what
oh you're asking about Brigadier's command completion
I assume this
ACF >>
Spigot api doesn’t allow argument tooltips
Or well there is no way to add those thru the api
Many command third party libs such as acf, cloud, triumph command do have that support
^
I don’t like annotations (hence I dont use acf) personally so i use brigadier which works fine although its definitely not beginner friendly in the slightest
yes
well you already got the answers. Use ACF or similar, or directly use Brigadier. Spigot itself doesn'tsupport it
You can cast the server instance to craft server i think and grab the brig command dispatcher there
Havent touched spigot in a while but yea
maven central's error messages are kinda useless
the actual issue was "wrong group id"
I#ve shot myself into the own leg with this
oh no wait, actually I didn't
it's actually genius
at first I thought that it'll be stuck in the while loop if there is only one record
but then I noticed the switch lol
can anyone tell if i'm locking the correct lock in the correct places? this method basically loads a player's data from a database in case it is not in memory
@NotNull
public CompletableFuture<CitadelPlayer> getOrLoadPlayer(@NotNull UUID uuid) {
try {
lock.readLock().lock();
CitadelPlayer player = getPlayerNullable(uuid);
if(player != null) return CompletableFuture.completedFuture(player);
return CompletableFuture.supplyAsync(() -> {
try {
lock.writeLock().lock();
CitadelPlayer cPlayer = new CitadelPlayer(this, uuid);
uuidPlayerMap.put(uuid, cPlayer);
return cPlayer;
} finally {
lock.writeLock().unlock();
}
}, executor).exceptionally(throwable -> {
throw new PlayerdataException(String.format("Failed to create new CitadelPlayer. (player: %s)", this), throwable);
});
} finally {
lock.readLock().unlock();
}
}
Try to lock only the part that needs to be async
i'm also locking the other part because getOrLoadPlayer can also be called from another thread so the part that is not in the completable future might also be executed async
And instead of getplayer nullable you can use @nullable annotation
i've already done that, but i think nullable in the name makes it clearer
as an example, i listen for AsyncPlayerPreLoginEvent and load profiles from there using this method
@EventHandler
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
try {
playerController.getOrLoadPlayer(event.getUniqueId()).get();
} catch (Throwable e) {
event.setKickMessage(ChatColor.RED + "Failed to load user data. If this issue persists, please contact an admin.");
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
playerController.unloadPlayer(event.getUniqueId());
Citadel.log(Level.WARNING, String.format("Failed to load playerdata. (uuid: %s)", event.getUniqueId()), e);
}
}
Well an intellij annotation would warn you if you try to use null
You could also use optionals
If you don't think it's clear enough with nullable annotation
in this case i'm blocking the thread handling the connection to not allow the player to login until their data is loaded
Optionals are a bit ugly for me personally
i could do that but optionals are a bit of a bloat
negligible
Optionals - ugly, yes. Bloat, no
why are you catching Throwables?
i had not noticed that, i've copied that part from an old project
and why is that method called "get..." if it doesn't get anything?
it loads the player profile if not in memory and returns the profile
in this case i don't need the returned value
oh ok
Oh and also, methods should generally do one thing
anyways what's the difference between catching exceptions and throwables?
Throwable has 2 subtypes: Exception and Error
Exceptions are of a higher hierarchy
Errors generally should not be caught
i know but here i've made a getOrLoad method because it would not make sense to check if the player is not in memory and load their profile if that's the case each time i need an instance of CitadelPlayer
while(true) {
List<Object> list = new ArrayList<>();
try {
list.add(new Object());
} catch (OutOfMemoryError error) {
System.out.println("Your RAM is now completely used. You can buy more RAM on amazon.com.");
}
}
Don't forget to catch stack overflow
fun fact - the method I sent above does not print anything
DownloadMoreRAM.com - CloudRAM 2.0
Wtf these existed?
well yeah, doesn't list get thrown out by GC ?
no, it's constantly in use
Oh its a joke websitr
obv yes lol
It should
no ? You create new one every loop
so i've got a problem where when i change the players gameprofile the player is vanished to everyone. but when they change it back to themselfs the player appears but the player who ran the command isnt able to do anything, and if they try and interact they get kicked for interacting with themselfs. My code is below (it does the same regardless if i send the packets or not):
boolean _ApplyNickname(Player player, String nickname, String texture, String signature) {
EntityHuman eh = ((CraftPlayer) player).getHandle();
UUID newUUID = Bukkit.getOfflinePlayer(nickname).getUniqueId();
//PacketPlayOutEntityDestroy spawnPacket3 = new PacketPlayOutEntityDestroy(player.getEntityId());
//Bukkit.getOnlinePlayers().forEach(p -> {
// ReflectionUtils.sendPacket(p, spawnPacket3);
//});
// set the new uuid
GameProfile gameProfile = new GameProfile(newUUID, nickname);
gameProfile.getProperties()
.put("textures",
new Property(
"textures",
texture,
signature
));
try {
Field uuidField = gameProfile.getClass().getDeclaredField("id");
uuidField.setAccessible(true);
uuidField.set(gameProfile, newUUID);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
return false;
}
// set the new game profile
try {
Field profileField = eh.getClass().getSuperclass().getDeclaredField("cp");
profileField.setAccessible(true);
profileField.set(eh, gameProfile);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
return false;
}
CraftPlayer newPlayer = new CraftPlayer(((CraftServer) Bukkit.getServer()), (EntityPlayer) eh);
EntityPlayer newEntityPlayer = newPlayer.getHandle();
Player newBukkitPlayer = newPlayer.getPlayer();
// send spawn packet
PacketPlayOutNamedEntitySpawn spawnPacket1 = new PacketPlayOutNamedEntitySpawn(newEntityPlayer);
ClientboundPlayerInfoUpdatePacket spawnPacket2 = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.a.a, newPlayer.getHandle());
PacketPlayOutNamedEntitySpawn spawnPacket4 = new PacketPlayOutNamedEntitySpawn(newPlayer.getHandle());
PacketPlayOutEntityStatus spawnPacket5 = new PacketPlayOutEntityStatus(newEntityPlayer, (byte) 35);
Bukkit.getOnlinePlayers().forEach((p) -> {
p.showPlayer(plugin, newBukkitPlayer);
p.showEntity(plugin, newBukkitPlayer);
//ReflectionUtils.sendPacket(p, spawnPacket4);
//ReflectionUtils.sendPacket(p, spawnPacket1);
//ReflectionUtils.sendPacket(p, spawnPacket2);
p.showEntity(plugin, newBukkitPlayer);
p.showPlayer(plugin, newBukkitPlayer);
});
return true;
}
ooh you're right
?paste
mb
why are you not using mojang maps?!
?nms
wait that exists?
yes, see link above
dammn
oh ive tried to run build tools with --remapped but i get an error about not being able to find sh because i use windows
it should still work fine
BuildTools works fine on Windows
ill try it again ig
if it doesn't, your buildtools is maybe outdated
try to use the latest version from #1117702470139904020
If it stops working do what it tells you and send the log in a paste
Buildtools has a gui now? 😄
can anyone help me to programm a plugin?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Yo, so PlayerSpawnLocationEvent is invoked before the PlayerJoinEvent but in the same circumstances (only at a server join)?
Called when player is about to spawn in a world after joining the server.
Yes
yooo that's dope
But what do you use the event for?
i actually love the buildtools gui
hey quick question, does anyone know if minecraft has a weird limitation on scoreboards to where if the text is the same on two lines it will only display one of the two lines?
uh
If you use teams you can have the prefix/suffix to whatever
as long as the scores are different right
hi all
I am a beginner for plugin
Recently I encountered a strange bug when practicing
The following is the code of the main logic
public class SignEvents implements Listener {
private final JavaPlugin plugin;
public SignEvents(JavaPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.getClickedBlock() == null || !(e.getClickedBlock().getState() instanceof Sign)) {
return;
}
Sign sign = (Sign) e.getClickedBlock().getState();
String text = sign.getSide(Side.FRONT).getLine(0);
if (text.equalsIgnoreCase("test")) {
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
Inventory inv = e.getPlayer().getInventory();
final ItemStack testItem = new ItemStack(Material.DIAMOND_BLOCK, 10);
inv.clear();
inv.addItem(new ItemStack(Material.DIAMOND_BLOCK, 60));
try {
Thread.sleep(1000);
} catch (InterruptedException exception) {
throw new RuntimeException(exception);
}
inv.addItem(testItem);
try {
Thread.sleep(1000);
} catch (InterruptedException exception) {
throw new RuntimeException(exception);
}
inv.removeItem(testItem);
}
}.runTaskTimer(this.plugin, 5 * 20L, 5 * 20L);
}
}
}
don't tread sleep
just built latest version and followed the blogpost that cafebabe sent and im getting this error in maven now:
Could not find artifact org.spigotmc:spigot:jar:remapped-mojang:1.20-R0.1-SNAPSHOT in sonatype (https://oss.sonatype.org/content/groups/public/)
I don't know why removeItem Incorrect
Thread sleep should be removed, no reason to keep it
I mean there are reasons but people misuse it
operable program or batch file.
Error compiling Spigot. Please check the wiki for FAQs.
If this does not resolve your issue then please pastebin the entire BuildTools.log.txt file when seeking support.
java.lang.RuntimeException: Error running command, return status !=0: [C:\WINDOWS\system32\cmd.exe, /D, /C, sh, applyPatches.sh]
at org.spigotmc.builder.Builder.runProcess0(Builder.java:1062)
at org.spigotmc.builder.Builder.runProcess(Builder.java:993)
at org.spigotmc.builder.Builder.main(Builder.java:738)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)```
this is happening when i run build tools with the `--remapped` flag.
I'm using Windows 10 and never had this problem with buildtools before.
do u have git bash
thats what im using
that's freaky then
try running it in git bash even tho iirc bt used to work in powershell as well
alr im trying now
Bt should work in cmd too
i remember i had this issue on ltsc
It would download a portable git bash and use that
¯_(ツ)_/¯
¯_(ツ)_/¯
it is weird tho bc i've already built it with the nms mappings using the gui but maven is saying that it cant find it
Did you reload maven
(If you're using Intellij)
I usually run the command as java -jar BuildTools.jar --remapped from windows cmd
And it works
Yeah as I said it's supposed to use portable
what will be if im using Bukkit.getOfflinePlayer() on player which is online?
It will be instance of Player
You will be given an offline player object of an online player
You can use isOnline and then getPlayer
Or instanceof if you'd perfer that
i need only to get uuid by player name
If u sure he will be online just use Bukkit.getPlayer
im not sure
Bukkit.getOfflinePlayer(String)#getUniqueId()?
Don't forget that might do an api lookup to mojangs server
If you're using isOnline you might as well use getPlayer
yeah it works when i dont add the classifier remapped-mojang for ther spigot dependency but when i add it it just says Cannot resolve org.spigotmc:spigot:1.20-R0.1-SNAPSHOT
Make sure you built 1.20 and not 1.20.1
Sometimes it makes sense to do it if you want to do extra for online players
Try to restart intellij
You can’t build 1.20
Using rev 1.20 will build 1.20.1
https://paste.md-5.net/ubasulenog.xml
(dont mind the fact that the groupid is baileyq.me instead of me.baileyq)
Ah then depend on 1.20.1 @rough pumice
alr
public static UUID getUUIDbyName(String name){
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
if(offlinePlayer.isOnline()){
return Bukkit.getPlayer(name).getUniqueId();
}
return offlinePlayer.getUniqueId();
}```
smth like this?
bruh
why
just Bukkit.getOfflinePlayer(String).getUniqueId()
it would return uuid anyways
Also consider doing it async because of the potential web request
so OfflinePlayer exist anyways if player has logged in server once?
cf is okay or bukkitRunnable?
If player has never joined it will ask Mojang
will just look up for uuid of given player on server data or on mojang server
Cf is fine
ok
because runTaskAsynchronously have this comment: Asynchronous tasks should never access any API in Bukkit
what happens to YourGUI object in this tutorial (https://www.spigotmc.org/threads/creating-guis-the-right-way.156378/) after i end using it? does it get stored in memory and fill it up or is it getting deleted?
dont follow that
GC will get it if it no longer is referenced
isnt he's method of actions easier? he adds actions when adding item stacks in gui right away with interfaces
Yo wtf:
it's a static method
and it throws an error whenever I input null, as there is no instance
"Object is null"
it wants to get something from the object
you pass null
it now cant
is it actually static
so I dunno what to really do now
also if it wasn't another error would be thrown instead
oh
java 21?
not even out yet
I have no idea which version minecraft 1.20.1 uses
java 17
dev stuff is
sure
?paste
whats wrong with this tutorial?
Other stuff works, just this is the only time I need a static method
yea ehm
and this is in the MobEffectList class
your method fetching seems scuffed at best
improper use of static, doesnt have the stuff everyone else following the tut would
what are you going to do if there are two methods ?
with the same return type
in a class
update the plugin
lol
how do you add lores on inventory items in the tutorial you linked?
and add like parameter type checks
usually item builders
Anyway, that's not the issue
also, why tf is there images of code and not code xd
good because there are methods in there
that are not static
and return a MobEffectList
so
the issue is that I can't invoke a static method
stops people from copy and pasting it and not understanding how it works
if you have to write it out you get a better understanding
if you really need sourcecode theres a githuyb linked
meh
hmm I didn't really pay close attention to it in like, 2 years
maybe I should update it fr
aaa just kinda
var meta = item.getItemMeta()
meta.setDisplayName()
item.setItemMeta(meta);
paste item to gui slot
is dat so hard?
Well, that at least is your issue
so, use a way to get the correct method
then you can invoke it with null passed to invoke as param0
or write itembuilder which adds meta in the process
im still getting the error Cannot resolve org.spigotmc:spigot:1.20-R0.1-SNAPSHOT
yet i just built buildtools again now
are you using gradle ?
nope maven
its definatly there
i can find the .pom file for it
intelij can find it but for some reason ig maven can't?
send ur maven depend
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
</dependency>
did you run with --remapped
yeah

i've done the command with both 1.20 & 1.20.1 and it builds 1.20.1 on both
Exactly
they the same nms version

no
its definatly there
as if 
what
so idk why maven cant find the remapped-mojang version?
oh
but not the actual jar
thats weird bc i definatly built it
check ur spigot folder in .m2 again
You are building 1.20.1
(just use 1.20.1 as a dep)
^
the command java -jar BuildTools.jar --rev 1.20 --remapped and 1.20.1 im both using
no
No you aren't
oh mb
your pom says 1.20-R0
i realized
its chill oopsie poopsie
yeah im pretty sure its working now ty for helping me realize that
i wouldnt have spotted it lmao
wait this is weird i can't import EntityHuman
nor any packets
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
oh
under mojang mappings
oh okay
select 1.20 and then type your classes in the search bar and it will give you the class with mojmaps
ty
Does the UUID change for players depending on the "online-mode" value?
Like is it different in offline and online mode for the same players?
then online mode uuid is not?
Online mode UUID is from mojangs servers
hmm so I have to save users based on their name only?
Names can change
you're a different player, don't know you
This is why you don't do offline mode
Propaganda
In online mode UUID is fine
use uuids anyways, they are the same if the name is
hmm
the server saves you as a different player when you have a different name, right?
if you run offline mode yes
but I'm talking about persistent data saving
They still save you by UUID though - just in offline mode your UUID is based on your name. Therefore, when your username changes in offline mode, your UUID changes
about maven modules
it is possible to have modules in module right?
yes i know
but if you run offline mode and someone changed name, the server has no way of knowing the previous username for that player
if you don't use offline mode, the uuid and name is based on your minecraft account and so the uuid is always the same for the same user
he could do something like a database to save the player datas as well as the account infos
so something like username and password not based on the actual minecraft username to login and get your profile?
that could work
Okay then another question:
Suppose the main bukkit thread adds and removes a certain list's elements.
However, the iteration through it is async.
Would clonening the ArrayList make it impossible to have the threads interfere with one another?
but you can't tell the difference between two different accounts in offline mode
the name is the only thing that makes two accounts the same
Yes
Ah damn slow internet sorry XD
not everything is abled to run async
Because what if the list is modified as the array is being cloned?
if you clone the list and use a list on a thread and the copy on the other thread then yes they won't interfere
however you won't see the changes on the other list
sure, array copying is fast, but it isn't impossible to have an error from that, correct?
if you need to see the changes on both threads use a syncronized list
no, The main thread is the only one that modifies the list, the reading one only checks the elements and invokes methods on them
so you write on the main thread and read from another thread?
the only issue i can see with that is if you try to read while the main thread is writing you might pull wrong informations
is the list immutable?
ie do you need to modify the contents of the list after creating it?
if the list is immutable you don't need to clone it
immutable objects are thread safe
that's fine, it doesn't need to be exactly that
how... would I modify it then?
i am asking if you need the list to change
if you do, this is the only issue you can come across based on the actions you need to perform
That's how the code looks
can I just copy the array?
nooo, CopyOnWriteArrayList is not good enough
Collections.syncronizedList(new ArrayList<>(Bukkit.getMaxPlayers()))
O_O
If you're adding to/removing from that array on another thread, you'll want some sort of thread-safe list
nope.
this wouldn't work
why would you not use a thread safe list?
I'm adding and removing from Thread#1
And only reading from Thread#2
Then honestly you're probably fine
I'm really in the need of efficiency
A simple ArrayList will suffice
my only concern is that the list is modified as it's being cloned
Idk why you're cloning it
iterator() would throw a ConcurrentModificationException
a syncronized list is slower than an arraylist, but cloning a list is even slower and pointless
it is not pointless
in this case it is
In this case it aint'
also an iterator won't throw a ConcurrentModificationException
idk why you're shooting down suggestions without having tried them first. The performance hit you'll take from a synchronized list isn't going to bring your server from 20 to 5tps lol
bro
that happens when you use enhanced for loops and modify the contents of the object being iterated
also this^
Collections.synchronizedList does not sync the iterator
Iterators do throw ConcurrentModificationException
i'd rather have thread safety and predictable results from my code and lose on a bit (a VERY small bit) of performance than have hard to trace issues later on the line
The ArrayList can be modified and is not blocked by the extra actions to make the list thread-safe, which are unnecessary. It's only reading it, no modifications are made
It's ignored because the parent already defines that version
If you want to define a more specific version for that module, move that version tag outside the <parent> block
Why do you have q file scope
didn't you just say that the list is being modified from the main thread?
A synchronized collection will prevent multiple threads from adding to/removing from the list simultaneously by imposing a lock on its operations so you're really not going to get any benefit here from one. I think you're totally fine using a regular ArrayList and using a foreach loop
I think you're overthinking this and creating a problem that doesn't yet exist
anyways i agree with choco and you can just use a normal list, as long as you make sure to not write and read at the same time with different threads
no changes can be made when the list is iterated through
i'd use a syncronized list anyways or wrap some actions on the list with a lock
use an iterator
guys what is the return value of player.getInventory().getSize()
i cant try and see
Should be 36
I thought it is 41?
is it 36?
Armour slots aren't part of the inventory
synchronized list src
public void setChestplate(ItemStack chestplate) {
this.setItem(this.getSize() - 3, chestplate);
}
i need the size for this
because config files
Player#getInventory() is only the container slots, which armour slots and the off hand are not
no lock neccessary
Those are separate slots
then what is this code
public void setChestplate(ItemStack chestplate) {
this.setItem(this.getSize() - 3, chestplate);
}
player.getInventory().setItem(EquipmentSlot.CHEST, item);
Choco could you help me with this
Right, okay. So setItem() is used internally to change the contents of the inventory
config
ah i see
im trying to make a config file
you're basically storing the contents of an inventory to configs
for kits
@tender shard
you can store armor contents and inventory contents separately
I don't know why you're not storing these contents separately in your config
well, you can use like EquipmentSlot.valueOf(config.getString("equipment-slot"))
"41" is far less descriptive than "chest"
and list them
well we have non armor items
there's a setArmorContents and getArmorContents method so you can use those
I agree with You. But what about for specific things? Like potions, diferent wood types and glass there You need to use their data Id
i'm coding something to serialize inventories right now and that's how i'll do that
what jar do i need to use after i build my plugin (i am using the nms remapped class stuff)?? because right now im getting an error saying it cant find the property gameProfile??
@Override
public int getContainerSize() {
return this.items.size() + this.armor.size() + this.offhand.size();
}```
It's all slots
My mistake
So 41
I mean I could have told you that based on this alone lol
I still think your config should very clearly outline armour and off hand slots as strings, not numbers
it would get messy in the code
I know
i could do one thing
You can write it so it's not messy lol
Vanilla also stores armour and off hand slots separately
if it was slot: CHESTPLATE
i would get it
and turn it to 38
so i always store ints in the code
why this appears red :l?
Might just need a project refresh. IJ is very particular about maven
yeh this is why lmao
2nd
but that gives me an error saying that it can't find the gameProfile property on the player when i use reflections
Well yeah, because that field doesn't exist at runtime
Your reflective calls aren't remapped
For reflection, yes
Why use reflection for GameProfile?
to set it
what are you using it for?
a nickname system
PlayerProfile is teh API version of it
🤔
oh okay
iml name different from project name iirc
will something like this also update the skin or wil i have to use game profile to update the skin?
PlayerProfile profile = new CraftPlayerProfile(newUUID, nickname);
Which API version?
1.20.1
no need to use CraftPlayerProfile
so how do i set the players name/update the player profile then???
i'd rather change this stuff at a packet level because i'm unsure whether this might affect some internal code leading to unpredictable behaviour
?paste
this is for 1.19.2 but easily updated for skins https://paste.md-5.net/muresopema.java
alr ill try it out now
could you send me your NMSUtils class please?
tysm!
how can i sort my tablist? ever player has a permissionlevel, it should be sorted this way. the highest permlevel is 100, so this needs to be at the top, any ideas?
Skins is just an Interface
alr
public interface Skins {
/**
* Set a new skin on the Player and update all clients.
*
* @param player the Player to have his skin changed.
* @param skin a String[] skin to apply.
*/
public void changeSkin(Player player, String[] skin);
/**
* Change a Players name.
* This name is transient. It will be reset if you change the players skin.
*
* @param player the Player who's name we will change.
* @param newName the new name for this Player.
*/
public void changeName(Player player, String newName);
}```
what?
ty!! @eternal oxide
just figure out it ^^ but thanks
working with modules and stuffs :l
🤔
oh ok, I haven't seen your actual question lol
so you got everything working?
so sorry to bother you again but i just want to ask what nmsPlayer.getLevel() does because i cant seem to find it in 1.20.1
returns the ServerLevel
do you know how I could do that in 1.20.1 because the ServerPlayer class doesnt have a getLevel() function anymore
it should be level()
found it serverLevle() ty!!
not really now into the part of NMS implementation
oh dammn they changed the constructor for ClientboundRespawnPacket, anyone know how I can figure out how to see what it needs to take in now?
look at the constructor?
mb i was just looking at the names of the variables it took in
it changed for every version of 1.19 and 1.20 but not by much
for the debug I guess
what do i put as dataToKeep and portalCooldown??
true
an overriding method can only return the same type or a narrowed down one
i wonder what made spigot's jar be so large in the later updates
its probably still a byte
features
it's not like mojang wrote double their code in that time
look at teh code I gave you, it is all commented
you would have to create a Holder class
or you could just return object and do instanceof
whats the difference?
the player's portal cooldown
no clue what that is but I'm 100% sure that 0 will work fine lol
if you really care, I'll check CB source and check what it does
when a player dies and it sends the respawn packet, they just use the value of Player#getPortalCooldown()
the portal cooldown is used to not teleport a player straight away when they enter a portal, but only after 100 ticks
I wonder what you're using the Respawn packet for
its used to update teh client skin
So the player can see their own skin change
other clients see it by just sending the meta
but your client won't as it expects it when the client joins
oh FFS don't ask me a for an artifact ID if I'm not allowed to change it
why are you using proguard in the first place?
"it works well for some things" isn't exactly the definition for a "good" thing though lol
show the full stacktrace
so good that mc still continues to be decompiled regardless if Mojang helped or not
but mojang released the mappings
only to be nice, wasn't needed
mojang only uses proguard to lower the .jar size, I guess that's everything proguard is capable of anyway
not sure why this even matters
the jar for mc isn't that large even without proguard
doesn't make a difference ?
a properly obfuscated .jar looks like this lol
if you are worrying about your jar size being under 1mb then you are doing something wrong
because at 1mb no one cares and it isn't going to do anything
true, nobody cares about the .jar size
i'm pretty sure that i can use a dictionary of variables
why this happened :l? some is .java and some not?
they are .java if the whole code is commented out
if your jar was creeping to like 300 or 400mb then I would probably say it would be worth doing some optimizing to lower that size down closer to 100mb
it show nothing in there ;-;
then the file is empty
hence it's not a class
hence it's "only" a normal .java file
but anything below 100mb isn't worth worrying about because even a 56k modem would still download it just fine
proguard has an option that does overload fields
wdym with "overloading" fields
Why am I not able to delete the latest update of my plugin from the spigot website?
I can delete any update except the last one
why are you obfsucating? just to get a lower file size?
you have to reupload another version
oh you mean using the same name
yes
I have 3 different versions not including the one that I'm trying to delete
so i don't need a dictionary of keywords
download the 2nd newest, reupload it, then you can delete the now-still-latest
no need to delete it though tbh, just reupload a fixed version
nobody's gonna think "yeah let's download the second latest version"
or you can just make a comment to not have people download it by mistake
nobody reads descriptions
You're right. I would just rather if there weren't unnececery updates
next time, don't upload broken versions 😛
unfortunately unnecessary necessary updates are a thing of development
but yeah it's weird that you cannot delete latest, but that's the way it is
😅
it happens you just try to not make it a common thing
I literally have no clue what my own plugin is doing
how is it even possible to call super() in bytecode as not-first statement
is this something you worked on a long time ago?
i think i got it, it tries to pre init something and fails
because of the multi module aspect
this is the code to select the nms
for the specific version
i guess is best to disable optimizations, not worth it
proposal talking abt something similar
but basically that proposes allowing it officially in the language specificafion since right now it basically works in the bytecode specification fine anyways
(which is what ur seeing rn)
because only the compiler enforces this, not the JVM or the bytecode standard
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.server.network.PlayerConnection.a(net.minecraft.network.protocol.Packet)" because "nmsPlayerToAdd.c" is null i have no clue how to figure out whats causing it because of mappings
if someeone could help me work it out i would greatly appriciate it
the connection is null is my guess
ah yes I remember now
which class is "nmsPlayerToAdd" and which version?
ofc python sucks, everything that's not strictily typed sucks big time
1.20.1 and its of type ServerPlayer
im assuming nmsPlayerToAdd is the serverPlayer you are sending packet to though
yeah
yeah the connection is null i assume from that
it's the "connection" field
the player is probably offline
alr
hopefully they incorporate it because its an old standard thing from way back when before more complex things were necessary or needed in Java. Its original intention was to provide a small bit of safety by ensuring that the parent class is setup before calling anything from the parent and wasn't really a thing or a need back then to have some pre-logic before calling super or this
nice tldr
how would one fix this?:
[08:14:17 INFO]: [org.mongodb.driver.cluster] Exception in monitor thread while connecting to server ac-1ym0zt6-shard-00-01.twcxqhy.mongodb.net:27017 com.mongodb.MongoSocketReadException: Prematurely reached end of stream
is this actually where the error is
yes
how do i re-add a player to the tablist after removing them?????
really wish it wasn't the de facto language for LLMs
declaration: package: org.bukkit.entity, interface: Player
catgirl maid
doesn't give me a caused by
on a different topic
is it possible to /data get on offline players from native minecraft?
then wrap your code into a try/catch (Throwable) and do throwable.printStackTrace()
could you be a bit more precise? /data get entity name doesnt do it
stable diffusion isn't even for llms
for that you use something like oobabooga
fair
and I am plenty aware it exists
lunar landing modules?
what is this, appollo 69?
