#help-development
1 messages · Page 815 of 1
however there is a library for that
^
Please tell me 😄 that would be very kind
The library covers a lot of cases
I'll give it lookover either way
will open jdk 21 work on 1.20.1 plugins?
probably
ok i'm having some troubles with this, how exactly can I do this?
for context I'm trying to make a custom vehicle
this works when i do a full file path, but not when i do a relative file path
im using new File(filepath) btw
what path are u talking about
path inside of jar file ?
a java class or different
if its inside of your jar file, that wouldn't work
how should i handle it differently?
what do you want to do
inside my jar/project
what do you want to do with them
EntityDamageByEntity or ProjectileHit
aight
ProjectileHit doesnt hold the hit entity so yeah
if it calles EntityDamage thats great
currently just get the folder/package
dude what do you want to do with it
do you need an instance of the class for something, bc this gives xy vibes
the fuq
do you want to somehow export it outside of jar
I type in "MobEffectList" in the mappings
or just get all classes inside of package
and it shows me the "MobEffect" class
no just get the package with the files insde
after clicking on the "MobEffectList" suggestion class
what do you want to do with the files after
?xy
Asking about your attempted solution rather than your actual problem
version: 1.20.2, hash: 32ddd73f0f
Mappings change between every version. Shouldn’t be that surprising. :p
I want to get the folder/package "Commands" so i can get a list of the files inside of it so i can store it as a File[]
still xy
okay, why do you need the file array of commands
you can't easly get File instance of thing inside of your jar
Why are ya looking in packages
It was probably replaced with something else. Ran into a similar issue with Advancements.
tf do I do now
because i want to get their names, delete them, create new ones etc
but how would I find
a replacing method
What is in your commands package
you want to delete the classes and create new ones at runtime?
yeah that isn't really way to do it
some txt files and other folders with classes

They shouldn’t be in your package
mmm
packages are exclusive for .class files, all other should go to resources
but still, you can't add files there at runtime
i also want to read the other packages inside of it, how do i do that
what is in those
is there more text files in those packages
classes
Show
?
just the names
Why
well that's really easy
I guess you have to use the generic MobEffect class and go from there. It seems that it just points back to that class.
why not a method that takes a name and an instance
so how would i get to it?
Idek what this is used for, but it is the spigot equivalent of MobEffectList
Read them
i would heavily advise against trying to load those classes without just hard coding them
There is very little reason to get them in your own plugin
Whatever you are trying to do is either completely shitty or stupid
I see that
but
they removed the static method
for getting a MobEffectList from an id?
are there any specific circumstances?
I am not registering the commands with it though, i just need it
Why?
no? i don't think so
Asking about your attempted solution rather than your actual problem
Why?
I mean Class#getSimpleName
Decompiling shows that it uses the internal registry. You can use that instead.
BuiltInRegistries.MOB_EFFECT.byId()
Well that would require him to use the classes
not really
Class.forName
or does he not want to load them?
.getSimpleName is already using the class
It’s dumb
can you
You should not have floating classes like that
Does anyone have an example of implementing another api?
nvm ig
Do you use spigot?
Not really, but it should be accessible in IJ if you ran BuildTools with the --remapped flag.
yeah
That class (BuiltInRegistries) is still available in 1.20.2, so you should be able to use it.
Then look at your plugin
I've been staring at it for a while actually... not much is happening
Oh wait, I misread that.
https://mappings.cephx.dev/1.20.2/net/minecraft/core/registries/BuiltInRegistries.html
it's called "IRegistry"
in my spigot
Do you not use the mojang mappings?
it was IRegistry a while ago I think
but the registries have moved
to Registries.java
old versions smh
yep
Any particular reason for that? They've been available in spigot since 1.17. Plus they were originally added all the way back in 1.14
I've been using the same spigot build for the past 2 years
and never actually needed the originals
I also never knew whether they were present on spigot servers
The mappings are purely for development purposes. So that you don't have to dig through all the obfuscated names.
do entities have uuids or something similar
yes
your plugin should be reobfuscated on compile time
BuildTools will generate the remapped names in your local maven repo (provided you use the --remapped flag) and then the maven plugin will convert those back to the obfuscated names so that the spigot server can actually understand what you wrote.
The reason it's done this way is because Mojang said not to distribute the mappings. Hence why the spigot jar still uses the obfuscated names at runtime.
How would i code ai for some nms player npcs im making a post apocalyptic rp kinda server if you've played rust kinda like the scientists
Might want to look into how Citizens does it.
Or just use the Citizens API
ive already got spawning npcs working with nms
look into the vanilla entities like Zombie
Spawning them is the easy part
they have pathfinding goals in there you can learn from
How can you make it so that you cannot duplicate items in the inventory in creative?
Well that's hard
You'd need to track and count each item in the inventory yourself
no
can you create a pickaxe with a different durability, eg. for stone pickaxe default durability is 131. can I make it like 200?
only for specific item, not for all on the server
is a IRegistry<MobEffectList>
I allow you. You can
I don't understand
you shouldn't need to
its defined at compile time whether or not a field can be or is IRegistry<MobEffectList>
if you're not going to answer then don't bother giving useless replies that don't help a single living soul
You lied to me.
I just answered your question
"Can you create (...)?"
"Yes"
you never asked how
I do need to
I still need to check it
but I already found it on the web
what I didn't do is ask if you allow me to do it. thanks for the weird ass answer
I see you're repulsive to humor
CoreProtectAPI.ParseResult parseResult = CoreProtect.getInstance().getAPI().parseResult(result);
String lookupPlayer = parseResult.getPlayer();
if (!lookupPlayer.startsWith("#")) {
if (!hasPlaced) {
if (!hasRemoved) {
AlertObject alertInfo = new AlertObject();
alertInfo.griefer = player;
alertInfo.block = block;
alertInfo.material = material;
alertInfo.frameItem = new ItemStack(Material.AIR);
alertInfo.type = 0;
alertInfo.timeStamp = System.currentTimeMillis();
alerts.put(blockNumber, alertInfo);
doAlert = true;
}
}
}
break;
}```
in theory that "break;" would make it so I get the first element only?
I see you dont know how to answer questions
yes
ok thanks
how so?
Can someone please help me, so my problem is that i have opened another eclipse project in intellij, and after i have closed that and opened a new one all the depencyes are at the other projects location. How do i fix that so i dosent be at the same location?
What
very simple
you can set a map
a renderer
and when the servers decides to render something
it'll fire the render method
uh ok is there a reason why it only runs once in my case?
maps are usually
rendered only once
ok I have a custom renderer, how can I let it run automatically?
ItemStack item = new ItemStack(Material.FILLED_MAP);
MapMeta meta = (MapMeta) item.getItemMeta();
if (!meta.hasMapView()) meta.setMapView(mapView);
for(MapRenderer renderer : mapView.getRenderers()) mapView.removeRenderer(renderer);
mapView.addRenderer(new SexyRenderer());
item.setItemMeta(meta);
ok let me give some more context:
this.renderer = new Renderer();
MapView view = Bukkit.createMap(world);
view.getRenderers().forEach(view::removeRenderer);
view.addRenderer(renderer);
item = new ItemStack(Material.FILLED_MAP);
MapMeta meta = (MapMeta) item.getItemMeta();
if (meta != null) {
meta.setMapView(view);
item.setItemMeta(meta);
}
I have this for my Map
like this
public class Renderer extends MapRenderer {
private final @NotNull Queue<PixelChange> renderUpdates = new ArrayDeque<>();
@Override
public void initialize(@NotNull MapView map) {
map.setTrackingPosition(false);
}
@Override
public void render(@NotNull MapView view, @NotNull MapCanvas canvas, @NotNull Player player) {
while (!renderUpdates.isEmpty()) {
PixelChange update = renderUpdates.poll();
canvas.setPixelColor(update.x(), update.y(), update.color());
}
}
public void setPixel(@NotNull Color color, int x, int y) {
renderUpdates.add(new PixelChange(color, x, y));
}
private record PixelChange(@NotNull Color color, int x, int y) { }
}
im doing this already
so what's the problem?
my MapRenderer#render only runs once
but I want it to continuously run
but the image on my map updates
oh I see
but the method isn't called?
I just solved that using packets
so if you want I can link you my github
I use packets as well, for sending the Item Frame + Map already
but I thought the rendering would work automatically
I use player.sendMap(view)
to send the MapView
I thought so, but the MapRenderer only runs once
to update a MapView I add a MapRenderer
Here's how I do it with packets
just go into the related classes
but this should work without packets
Can someone help me fix this error?
https://pastebin.com/Yd9wHiwy it is mcp
Is there an easy way to test a plugin that involves multiplayer interactions with other players? I only have the one account.
npc plugins
I have an example here, all the locations are like this: D:\clients\minecraft\abaac\workspace\jars\versions\1.8.8\1.8.8.jar but it should be: D:\clients\minecraft\FC-1.8\workspace\jars\versions\1.8.8\1.8.8.jar, and it is also like that with every other dependency with mcp (the abaac is the earlier project i wrote about)
which ones?
Okay thanks 👍
I'm trying to make a custom drivable vehicle. I've already made a resource pack to replace a mob, but how can I make the mob drivable?
I might just make the mob a pig so I don't have to do player input packets
but how can I make that mob drivable without having to hold a player on a stick?
or is that not possible
alright I'm rusty on the API, how can you tell if a LivingEntity is fireproof?
PacketPlayInSteerVehicle is where you want to start looking
There's getMaxFireTicks, maybe that helps
if you're using the mojang remappings I think it's ServerboundPlayerInputPacket now
yeah
maybe, but I'm not sure if this actually works for lavaproof mobs as well
for my purposes though it should be alright ig
thanks
ah ok. Is this going to be complicated? cuz if so i might just try to find another way
Maybe it returns 0 for them, you could debug
It's not that bad IMO but also I've been writing code since I was 11 lmao
well, I'm replacing the burning effect, so I don't really need to worry about it I suppose
as long as they can't be on fire lmao
ah ok gotcha
where do you think the best place to start learning is?
neither, but not well really familiar with the technical side of stuff like packet reading
ah, that
I'll be honest, I don't do it much, but if you're already familiar with spigot then the best way to learn is to just mess around with it
alr, thx for the help!
this might be of use
it's a bit dated
if you're using remappings it's probably not that useful actually
anything more recent on this?
the materials ive found seem to be moderately to extremely outdated
you could try replacing the entity via NMS and overhauling the collision hitbox, I guess
or use your own custom hitbox but if you're trying to do it for regular game events that's probably excessive
man, this is probably silly, but is there any reference in spigot to what cooks to what, or do I have to manually set that up? i'm replacing the "on fire" mechanic with one that doesn't devour your iframes
hey guys
anyone have good resources on bungeemessaging?
for some reason my bungee messaging only works for players in versions <1.20
im running 1.8 spigot backend and 1.20 waterfall bungee
waterfall is not bungee
so i need to use bungee for bungeemessaging to work properly @sullen marlin ?
Is anyone familiar with ProtocolLib?
I'm trying to use it and can't seem to install it even though i'm following a tutorial
nevermind, apparently i had to reset my cache or something but i'm good now i think
where
Can someone explain to me how I can import this library to my project please? https://github.com/mfnalex/ArmorEquipEvent
how i can create addon support in my plugins. I know what addons are but not at the software level
You serious? It's written very clearly in the first lines of the readme
is it possible to make in mmocore so that when you tap on column 1 displays the skill branch 1, and when you tap on I column 2 displays the skill branch 2?
Ever imported any other libary?
If not i would suggest you search on google how to add a libary to my maven project or the second option you just copy paste the 4 files directly into your project
Sometimes I feel like people don't value other people's time at all when they ask for the most basic shit you could google within 2s instead of waiting 2 hours for a response
I have this, and wanted to ask what i can do with "World.Environment.CUSTOM". Can i change the sky so it matches end?
WorldCreator wc = new WorldCreator("world_moon");
wc.environment(World.Environment.CUSTOM);
wc.type(WorldType.NORMAL);
wc.generator(moonGenerator);
wc.generateStructures(false);
Bukkit.getConsoleSender().sendMessage("Started creation of the moon...");
wc.createWorld();
Bukkit.getConsoleSender().sendMessage("Moon created!");
How could I get the skull owner from BlockData?
well I can get a skullOwner from the Skull, but how do I get a Skull from a BlockData?
don;t use BlockData
TileState, BlockState
hmm, I'm using the coreprotect API and trying to get a skullowner, could I get a blockstate or tiledata from blockdata?
Does that API return a Bukkit BlockData or an NMS one?
what is the difference between #sheduleSyncRepeatingTask and #runTaskTimer
as far as I know you can;t go from BlockData to a Skull
Rip
isn't there a SkullData class
The return values. For the former you get the task id and the latter returns a BukkitTask (given you dont use the callback)
if i use return in the runnable it cancels the task?
Nope, return simply jumps out of a method early. It doesnt affect anything else.
so how can i cancel the task from the runnable itself
You would have to extends BukkitRunnable for that. It can cancel itself.
thanks
No one that could provide a link that i can follow? I looked at the java docs already
Here is an example:
public class TimerRunnable extends BukkitRunnable {
private final int targetTicks;
private int currentTicks;
public TimerRunnable(int targetTicks) {
this.targetTicks = targetTicks;
}
@Override
public void run() {
if(++this.currentTicks >= this.targetTicks) {
this.cancel();
return;
}
System.out.println("Tick " + this.currentTicks);
}
}
(PS: Dont use runnables like that for timers or cooldowns)
is it good to send message that for example. i have a cooldown of something and its 5 minutes and i want to send a message that in 5 min then 1min and 15 seconds player will be able to do it again
then cancel if current ticks == target ticks
Cooldowns should always be done with timestamps in the future. Displaying the diff between now and this future timestamp can be done
with a runnable. In your case, its probably better to start a task for 5min in the future, which then starts a task for 1min later and each task
starting a new one with a shorter time delta to itself.
But running a single task with a tick timer internally is also viable because increment and modulo are very cheap operations.
Honestly scrap the idea of starting a new timer each time. Internally spigot does this increment & modulo for tasks anyways iirc
so just 1 task will be better?
Its def easier to maintain
I personally would even go for a single task, which is started when the plugin loads and never stops. This task would
have the responsibility of displaying any cooldown to anyone. I almost never create tasks then cancel them.
hmm, would having one main task running from plugin load to stop affect performance when you're doing a bunch of stuff inside?
- how do i ignore java version in start.bat ?
- or spigot 1.16.5 works with jdk 17 ?
- will i have a problem if i ignore the java version?
There should also be overload which takes consumer
Its possible but not recommended. You should stick to supported java versions for your server.
Everything you do in your plugin affects its performance.
wouldnt it be better to split it up into different tasks?
i think starting more tasks is more expensive than just 1 task
Performance wise def not. I would argue that it would even be worse for performance.
Hmmm, since tasks start and cancel, wouldnt it be better than having one that runs all the time? Like splitting the workload into different tasks and when they're done, they would just cancel.
You can also split the workload by using just a single task. The only difference is that spigot doesnt need to track N tasks but only one.
so like a bunch of if statements in one task?
and like skip it if not needed?
Yeah like that
hmm
If you want a more in-depth guide then you can read my post about splitting workloads
*Only makes sense if you have a bit of programming experience
Alright, thanks
yes but how exactly
Actually I might have a workaround for this
Ill handle collision checking using custom logic
How could I translate this into human readable stuff?
maybe setKnockback(0)?
check the spigot docs
for the exact method
first, dont use the bukkit logger use your plugins and Logger#log(level, message, ex)
there is tntprimeevent
and blockexplodeevent
tnt would use entity explode event
Tnts are entities
because it becomes an entity
e.getMessage() ig
I'm really confused
I have this variable
public static final IRegistry<net.minecraft.world.effect.MobEffectList> e
and the
net.minecraft.core.Registry class
but when I check
e.getType().isAssignableFrom(theRegistryClass)
is shows false
Is IRegistry Registry? I think not
Oh
That's why I'm checking like this instead of ==
Weird naming conv smh
isAssignableFrom works the other way around
wdym?
theRegistryClass.isAssignableFrom(e.getType())
Determines if the class or interface represented by this
{@code Class} object is either the same as, or is a superclass or
superinterface of, the class or interface represented by the specified
{@code Class} parameter.
yes
yeah now it works
this class (registry) is a superinterface of the class represented by the specified class parameter
"Does anyone know how to connect three servers using BungeeCord? We have two servers, one serving as the main hub and the other running on BungeeCord. Additionally, we have a friend who operates their server on a different hosting platform. How could we link these three servers using the BungeeCord proxy to facilitate seamless interaction between them?
i was use another code for find random location in the quadratic zone https://paste.md-5.net/deremibeto.cpp but still outside the radius (for example from 1000 to 2000 and from -1000 to -2000)
what the hell is that
this code for find random location
like this?
so not a radius?
"square radius"
x/z +- min to max
this implies r^2
/\
easy stuff
(random.nextInt(1000) + 1000) * (random.nextBoolean() ? -1 : 1)
^ once for x and again for z
the problem is that if my speed check is correct, then it is slower than the code that I sent
that looks such a mess
you just want a random location around the center at a minx/max distance?
yes
but
make the randomness more uniform while maintaining or improving the same search speed
what? search speed?
https://github.com/DailyStruggle/RTP/wiki/Compiling-and-Editing i was use code from here - https://github.com/DailyStruggle/RTP/wiki/Compiling-and-Editing
uniform random
while keeping the search speed the same
um random is random, there is no uniform
just look this topic
your getLocation is fine, but don;t pass a random. Not needed
your getLocation2 is junk
Does anyone know how to connect three servers using BungeeCord? We have two servers, one serving as the main hub and the other running on BungeeCord. Additionally, we have a friend who operates their server on a different hosting platform. How could we link these three servers using the BungeeCord proxy to facilitate seamless interaction between them?
look this topic and you will understand what I want to say
I'm not reading a page of text
you drew a picture and asked hwo to get a random location in teh outer box
oh wait this wrong link
I wanted to optimize the location search by making it more uniform in area and took the code from here, but I couldn’t understand why it went beyond the required area
or whatever your Location uses
um, in your picture you drew boxes. In the page you linked it uses an actual radius
which are you wanting to do?
scroll down there is a square picture
then the code I just posted will do that
except don;t use new Random
I only put it there as I was too lazy to type
Does anyone know how to read Kotlin code as knows the Java-transcribed equivalent of https://github.com/JetBrains/kotlin/blob/master/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/ScriptingHostTest.kt#L108
I've somehow managed to figure out that the function call can be traced back to https://github.com/JetBrains/kotlin/blob/master/libraries/scripting/jvm-host/src/kotlin/script/experimental/jvmhost/BasicJvmScriptingHost.kt#L33, but is there an easy way to trace it back deeper? It does not seem as if I can call inlined functions from java code, hence my question
and the location itself, in what way is it searched, what is this code used for, it’s just similar to Location = get(get));
There is no search, its Random
it biases the result?
no
I mean why is a ready-made location accepted for input?
That's why I asked how to get it to uh get it again?
No idea what you are asking
i mean what method is used to create a ready-made location that is included in this method
public static getRandomLocation2D(int minRadius, int maxRadius, --> Location2D location <--) {
it doesn;t really matter if you pass in a Location2D or an X and Z
its just an origin
I understand this is a 2nd layer to make the location more unique?
no
an origin is the point you start at
Might be 0/0, might be something else
what?
so you could have an origin of 0,0 or 23423423,12312
oh you mean center ?
i see
actually that math is wrong
that would only give locations in teh 4 corners squares
Hi i have a weird problem with redis , so :
i made a system where it get the arena data , etc etc and that's cool and all , but my problem that it works only for the first user who clicks it? it send him to the arena , but if i go back to the lobby server it does not do anything upon clicking on the gui
did you try to debug the clicks and the recieved data ?
Let me try to do that now and see what's wrong .
so in the onEnable main class i have this [in Game moudle] it send the data .. i will change the time when it send it ..
https://paste.md-5.net/papoluzani.java the gui class i use
is there an error in console or did you try to send a simple message to the player when he clicks on a item
it should send him to the sw server, and it did in the first try
but when i rejoined in lobby it stoped working
i will restart both of servers and see what will happen
using redis publish and subscribe for it
i added a remove method for the arena , from the redis map i created, so if a server closed it will be removed from redis
and the map
so in the gui , it will not duplicate i guess
Ok how I understand is that first part 1 will run, then part 2 will run on a different thread, and after part 2 is done running part 3 will run?
nope... part 2 runs outside of the pther parts
so how could I make it so it runs like I mentioned?
so it says "Rollback started" then the rollback happens and it says "Rollback complete"
yes
ok
If anyone could explain me why it is not updating?
System.out.println(itemStack.getItemMeta().getPersistentDataContainer().getKeys());
((CraftPersistentDataContainer) itemStack.getItemMeta().getPersistentDataContainer()).putAll(write(new CompoundTag()));
System.out.println(itemStack.getItemMeta().getPersistentDataContainer().getKeys());
Output:
[14:59:02] [Server thread/INFO]: [plugin:weapon_definition, plugin:slots]
[14:59:02] [Server thread/INFO]: [plugin:weapon_definition, plugin:slots]
Method write:
@Override
public CompoundTag write(CompoundTag compoundTag) {
compoundTag.put("name", StringTag.valueOf(name()));
compoundTag.put("rarity", StringTag.valueOf(rarity().name()));
compoundTag.put("id", IntTag.valueOf(1));
compoundTag.put("eventClass", StringTag.valueOf(actionClass().getSimpleName()));
return compoundTag;
}
Because i am getting confused asf. And the best part is that
you need to use getItemMeta().setPeristendData ...
so like this
yes
ok thanks
when the async task is finished you need to go back into the sync task for bukkit stuff.... i think it will work
ItemMeta is copied*
it is
You need to save it in a variable and then update it using setMeta
it is just a copy
Swhat I meant mb

💯
💯™️
Well silly me if that works
ItemMeta itemMeta = itemStack.getItemMeta();
System.out.println(itemMeta.getPersistentDataContainer().getKeys() + " : " + itemMeta.getPersistentDataContainer());
((CraftPersistentDataContainer) itemMeta.getPersistentDataContainer()).putAll(write(new CompoundTag()));
System.out.println(itemMeta.getPersistentDataContainer().getKeys() + " : " + itemMeta.getPersistentDataContainer());
itemStack.setItemMeta(itemMeta);
That's how you do it my friend
It didn't work
Should check out whatever your write api is
[15:06:31] [Server thread/INFO]: [plugin:weapon_definition, plugin:slots] : org.bukkit.craftbukkit.v1_17_R1.persistence.CraftPersistentDataContainer@8eef6bb7
[15:06:31] [Server thread/INFO]: [plugin:weapon_definition, plugin:slots] : org.bukkit.craftbukkit.v1_17_R1.persistence.CraftPersistentDataContainer@ba9da361
Even the addresses are changed afet "putAll" HOW?
What? I don't get it
Why are you printing the memory address that isn't going yo be helpful to see if things change
Whats the difference between Material.CARROT and CARROTS?
Items copy stuff a ton the memory address is bound to change unless you do literally nothing
OKay but the memory addrese should stay still
Item vs Blocks
Not necessarily
I thought Material was only for blocks and ItemStack was for items
Nein Material is for Item and Block Types ItemStacks is for items that can be used in Inventories etc Block are physical blocks in the world
I belive you put then how can i write this into this itemstack DataContainer?
Idk what that random api is that u use to write nbt so I can't help you
I'd assume that's the issue if it's not writing but again your sysout statements don't give you info on whether or not it actually wrote data
I don't use any API
It's just a spigot
net.minecraft.nbt.CompoundTag
that is internals
why are you using internals with the PDc
you can literally do nested PDCs with the API
whats the best way the get all items on the ground
Like I the entire world?
yeah so i can take them into gui
Why not? I did not think that's bad
I thought about Bukkit.getWorld(world).getNearbyEntities(location, x, y, z)
PDC covers nbt so you don't need to use NBT
Use World#getEntities() and filter for Items note this might get heavy if their are a ton of entities. Also is limited to loaded chunks
To get items in unloaded chunks you either have to load them or read the chunks dat file
yeah i think loaded chunks will be ok
What is even PDC?
persistent data container
Persistent data container it wraps nbt
And allows you to use nbt to store data persistently
The fact that it wraps NBT is an implementation detail
its an API that you can throw data at in a speciifc format
and it persists it across restarts
what is nbt
Oh yea now i get it
Named Byte Tag a binary storage format that minecraft uses under the hood
So i should create new PDC, add values normally without using Remapped, and then add this newly created PDC to the itemstack PDC?
?pdc
Again important to stress you don't need craftbukkit internals or nms for this if you need help after reading please ask
what is the difference between nbt and pdc
PDC store NBT inside ItemMeta
PDC Is api accessible and easier to use IMHO
NBT I'd more powerful but you need NMS and you sacrifice the convenience of multiversion support
Most things you can do with NBT can already be achieved by the api
Pdc is nbt
Exception would be reading .dat files from disk
What? It wraps NBT you are turning my understanding upside down
Pdc and itemmeta are both nbt
All PDC is NBT one way or the other, but not all NBT is PDC
Literally i fell so confused XD
Just cause it wraps does not change what it is
Don't worry about internals man
The api is there so you don't have to :P
Live in the blissful ignorance
If you look at it from this side, yes
Okay i'll try without using remapped thanks
Wha?
@eternal night big fan of inventories? 😈
If the question is whether you want to use NMS - then don't.
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
saveDefaultConfig();
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (getConfig().contains("join-reward")) {
String itemMaterialString = getConfig().getString("join-reward.item");
int amount = getConfig().getInt("join-reward.amount");
String displayName = getConfig().getString("join-reward.display-name");
Material material = Material.matchMaterial(itemMaterialString);
System.out.println(itemMaterialString+"\n"+amount +"\n"+displayName+"\n"+material.toString());
if (material != null) {
ItemStack itemStack = new ItemStack(material, amount);
ItemMeta meta = itemStack.getItemMeta();
if (meta == null) {
meta = Bukkit.getItemFactory().getItemMeta(material);
}
List<String> loreList = getConfig().getStringList("join-reward.lore");
if (loreList != null && !loreList.isEmpty()) {
meta.setLore(loreList);
}
meta.setDisplayName(Utils.color(displayName));
itemStack.setItemMeta(meta);
player.getInventory().addItem(itemStack);
player.sendMessage("Girişte item başarıyla verildi!");
} else {
getLogger().warning("Config dosyasındaki malzeme geçerli değil: " + itemMaterialString);
}
} else {
getLogger().warning("Config dosyası hatalı");
}
}
config.yml:
join-reward:
item: DIAMOND
amount: "1"
display-name: "Join Reward"
lore:
- "Line 1"
- "Line 2"```
Error: Material cannot be null
how can i solve this
What is#help-development arguing about today? :p
Nothing actually
trying to get redis working :p
Runtime or compile-time?
If it is compile-time, just slap an assert material != null; in it
(or do proper null checking :P)
Me passing AIR to make the plugin explode
Material material = (Material.matchMaterial(itemMaterialString) == null ? Material.AIR : Material.matchMaterial(itemMaterialString));
XDDD
I'm sorry I have difficulty understanding
What exactly is missing or wrong
Ah no, it has to do with you Sysout @shell robin , material.toString() means that material now cannot be null
how to check if entity is a dropped item
instanceof Item, Item is the entity class for
And thus your if-statement is superfluous, which is why your IDE complains about it
instaceof ItemStack?
Item
No.
okay, i deleted
should it work right now?
I wouldn't delete the if-statement per-se but rather the system.out.println
Or use Objects.toString(material) instead of material.toString()
@river oracle is there any diffrence if i create new PDC using
new CraftPersistantDataContainer()
or using PDC context?
Or not use .toString() at all in which case it will default to a behaviour similar to Objects.toString(object)
Uh, do you have any idea what you are doing?
Y
What you are doing is highly alarming and is most likely wrong.
I feel like you are using internals when you should not have them
How else then can i store data inside ItemStack?
Like, what do you need the CraftPersistentDataContainer for? Can't you get it from somewhere else?
literally the API
you are using internals for 0 reasons
why are you even depending on internals ?
ItemMeta extends PersistentDataHolder which provides https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataHolder.html#getPersistentDataContainer()
I just asked a question? If there is diffrence between doing it from PDC context or using internals
It is simple answear Yes\No
or more complex answaer Yes because...\No because..
Well it is dangerous to say the least
yes, using internals is a braind dead move and the internal type might be renamed next release
use the API and the pdc context instead
You might for example overwrite other entries that already exist for one reason or another (other plugins?)
You answaer should insead of this
What you are doing is highly alarming and is most likely wrong.
be this
You should use PDC context. Don't use Internals when you can do something without them
Simple as that
Well I don't know the context. All solutions have a proper problem. But a problem cannot be solved with any solution willy-nilly
So you don't even know what i am asking about and you are answearing me. So please tell me if you don't know PDC Context how can i create new PersistantDataContainer instance without using internals?
What I am saying is that I don't have enough context
Ohh okay that way mb
Is there someone here who could help with a small kotlin app?
What do you need the PDC instance for? Why the hell do you even consider using internals (conscious bias!)? etc. these are all questions that result in me not being able to give a definitive answer for these questions
I need to put new container inside existing container
?jd-s
persistentDataContainer.set(Namespace.DATA, PersistentDataType.TAG_CONTAINER, persistentDataContainer.getAdapterContext().newPersistentDataContainer());
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
declaration: package: org.bukkit.persistence, interface: PersistentDataAdapterContext
Use case? No?
What's wrong with this?
But yeah, in that case - you now know the answer
I don't know
I would love to use paper but unfortunetly i have custom spigot fork and i can not use Paper
That's a new one
Wdym new one?
I didn't fork paper
I mean, if you are using PDC, just implement a custom data type honestly
makes this whole ordeal a tad easier
Fr or you joking?
you can 100% implement a data type that converts some POJO into a PDC and stores it
Well, paper has the only good serialize to bytes method right now as it uses DFU
Do i need to register somewhere this data type or just implement and use?
You just implement it
shhh stop saying what they do I need to beable to legally make my PR for spigot
Well, perhaps not for PDC but for itemstacks in general
the javadocs have an example
@vagrant stratus I have a really weird request for a removal of a review on a review section that involves me but isn't for my plugin
Uh, that is not really how cleanroom works I think
Thanks i'll try
Finals faster smh
you or any other resource staff lurking right now?
this week is my last week of actual classes then I have 4 of my finals in the first 2 days of the week of the 11th then I'll pretty much be okay to start doing stuff again
Can anyone tell me why my enchantment wont work java mc 1.20.2?
https://hastebin.com/share/fozezuheyo.typescript
registered in onEnabled like so;
NamespacedKey key = new NamespacedKey(this, "vein");
VeinEnchantment veinEnchantment = new VeinEnchantment(key);
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
no errors showing
This in in itself shouldn't do anything
so how are you using your enchantment
implementing enchantments in the API is not supported
while potentially workable rn, there is an open PR to completely clap API only enchantment additions
A lot of people still do it that way, somehow.
not for much longer
Well thankfully EnchantmentPlus won't be affected by such a PR
The last major breakage was when spigot started to purge superfluous color codes from lores
@worldly ingot are you lurking ? I need help with some, uh, forum drama
must be some really spicy drama if you ping pretty much everyone
im then testing by using essentials /enchant vein, also tried giving the player an item with the enchant in code
didn;'t work
yeah it's causing me to start shit and get pinged across different discords servers and it should not have happened in the first place
No surprises to be had here
Your enchantment is semi-invisible to other plugins
That is as long as you don't insert it into internal registries, they will only partially know of it's existence.
@red mauve last ping try, do we have forums / resource staff lurking?
bros desperate
damn
do I just report the user and link to the review?
because i can't report the review itself
yes you report the user and link
getting reviews removed is hard to do but it can be done if the user is abusing other, posting things which are not reviews or making accusation which are clear lies.
Anything good?
Ok, so any guidance?
I think it's a reasonable ask, I sort of would've liked to get a direct answer to the query is all
yeah that's sort of why I wanted to talk about it, because I'm not sure it breaks the rules per se but it's not something I want my fanboys to start doing at all either
Is it cause epic called u a nerd? 🤪
I am afraid I cannot really help you much here. I personally don't bother extending Enchantment at the cost of not supporting other plugins (well I still do through bytecode transformation whereever applicable)
foncused could you just give me an idea of whether my ask is reasonable ?
based on the report I just filed
However, cross-plugin support isn't viable anyways
if not I'll try to find out who did it, problem is that's clearly a random username and I'm not sure I'll be able to find them
if i were to add a plugin to another plugin's dependencies and set the scope of that dependency as compile would it essentially be two plugins in one or how does that work
is there any way i can achieve that or is that against the rules
now you got me curious, whats the review about
spill the tea
Ok can you advise what the best solution is for custom enchantments? I assumed the API was the best way
i just put the custom enchantments in the item's persistent data container and display them with lore
does the job
I’ve seen that before, but really I wasn’t to do it the “proper” way
unfortunately the "proper" way is kind of shit
The pdc is the proper way though
Pdc? Sorry
persistent data container
.
Oh my bad
Why is this guy blcoked on my side did he do smth dumb
i just put a string like this
ench:level;ench:level;ench:level
and to read them i split on ; to get each enchantment and then : to get the level
Hello i'm getting this error while getting a value from a mysql database. java.sql.SQLException: Column 'PLAYTIME' not found. I dont get why it isn't finding the PLAYTIME column. It is present on the database. This is the code: java try{ PreparedStatement statement = plugin.getDb().getConnection().prepareStatement("SELECT ID, RANK, BALANCE, KILLS, DEATHS, FIRSTJOINED FROM playerprofiles WHERE UUID = ?;"); statement.setString(1, uuid.toString()); ResultSet rs = statement.executeQuery(); if(rs.next()){ id = rs.getString("ID"); rank = rs.getString("RANK"); balance = rs.getInt("BALANCE"); kills = rs.getInt("KILLS"); deaths = rs.getInt("DEATHS"); firstJoined = rs.getTimestamp("FIRSTJOINED"); playtime = rs.getTime("PLAYTIME"); }
How did you make ur table and show us a database viewer of it
sure
This is the db structure:
This is how i put the values in the table: java PreparedStatement statement1 = TWCore.getInstance().getDb().getConnection().prepareStatement("INSERT INTO playerprofiles (ID, UUID, RANK, BALANCE, KILLS, DEATHS, FIRSTJOINED, PLAYTIME) VALUES (" + "'" + id + "'," + "'" + uuid + "'," + "'" + rank + "'," + "'" + balance + "'," + "'" + kills + "'," + "'" + deaths+ "'," + "'" + firstJoined+ "'," + "'" + playtime + "');"); statement1.executeUpdate();
Don’t you get conflicts with other plugins or all good?
conflicts as in? other plugins dont see the enchantments because they're not registered to the server, no
The lore
but in terms of mechanics that really depends on how you program your enchantments
oh the lore isnt a big deal
i just match on the enchantment name and replace that line or remove it or whatever
@rotund ravine So did you find any errors?
if there's plugins that wanna add lore that's the same as one of my enchantment's names thats just a skill issue on their part
if you want to look at the source code on how i did it look at enchantssquared
Okay can you link sorry I’m out atm on mobile
at the end of the day though something like that shouldn't effect your enchantments functionality though as you'd be using pdc
yeah it wont affect functionality
unless you define your enchantments based on the actual lore, which you shouldnt do
Thanks for the info, it just feel really hacky? I thought spigot would’ve supported it properly
Thank you
i think minecraft just doesnt support it well
Ah okay
spigot just does what bukkit does and bukkit does what minecraft does
you don't use the EnchantmentWrapper here right?
the what
its a hack some plugins use to inject into Bukkit's Registry
and EnchantmentWrapper is getting murdered soon
?
surfin bird and peter grifin in fortnite
YOU DONT KNOW WHAT SURFIN BIRD IS ?!?!?!
yeah whats surfin bird
uncultured swine
now this is a bit too off topic
this is totally the right place for this
shhh staff are here hide
oh that one
I'm wondering why chunks in my server doesn't unload properly
8 tps with 130 on
And the problem are the chunks
hello I'm stuck on how to create an evaluation bar in swing for my chess project:
I can easily use a determinate value and just .setValue(), but it ends up jumping all over the place when my engine hasn't reached a sufficient depth. I'm not sure how to include an animation that will constantly update to the values being generated:
For instance, if there is a short period where the engine evaluates a +5.00 position, and then back to +0.00, it should have little movement, sort of balancing out.
And lastly if the values being outputted are similar, the bar will hover around that area
i was thinking something like taking the average of the last 10 values or something
not too sure how to implement it as a constant animation though
Hm, I can only think of bezier curves
But not sure if you can do it in a fluid fashion
Hey,
is it possible to do in a switch(slots) this case:
case 23|24|25:
so if it is slot 23 or 24 or 25 do something?
sure
just dont break after cases
case 23, 24, 25 in this case
depends which switch you're using because in newer java versions there's a different one
case 23:
case 24:
case 25:
bla bla
break;
oh so with , not |
you can do
switch(slot){
case 23:
case 24:
case 25: {
...
}
}
or
switch(slot){
case 23, 24, 25 -> {
...
}
}
nice i will use the 2. it is more smooth
in the second one you also dont need to use break
zyrox, are you using this for an invenotryclickevent?
ya
its up to you how you design your ui, but i would highly suggest creating ui like this https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
ya i see the thing is slot 23,24,25 should do the same so it kinda makes more sence for me if it is case 23, 24, 25
???
Is it fine to use the logger from Plugin#getLogger asynchronously?
Should be
Yeah everyone keeps telling me to do this yet when I do nothing but errors happen so thanks for being useless dicks… I really appreciate it
And that's not to say maybe I'm doing something wrong but saying to just look at the 4 files doesn't really help...
Also I tagged the wrong person on that, rotz if you see this it was not inteded for you
Hello i'm getting this error while getting a value from a mysql database. java.sql.SQLException: Column 'PLAYTIME' not found. I dont get why it isn't finding the PLAYTIME column. It is present on the database. This is the code: java try{ PreparedStatement statement = plugin.getDb().getConnection().prepareStatement("SELECT ID, RANK, BALANCE, KILLS, DEATHS, FIRSTJOINED FROM playerprofiles WHERE UUID = ?;"); statement.setString(1, uuid.toString()); ResultSet rs = statement.executeQuery(); if(rs.next()){ id = rs.getString("ID"); rank = rs.getString("RANK"); balance = rs.getInt("BALANCE"); kills = rs.getInt("KILLS"); deaths = rs.getInt("DEATHS"); firstJoined = rs.getTimestamp("FIRSTJOINED"); playtime = rs.getTime("PLAYTIME"); }
i actually asked this before but no one answered...
Playtime is a present column in your player profiles?
Also did you perhaps misspell it?
I'm also pretty sure the column name is case sensitive so there might be an issue there
is getTime returning time from the timestamp?
The timestamp
getTime is returning me an error and the error is: ```
java.sql.SQLException: Column 'PLAYTIME' not found.
So playtime should be getting the time played to present from timestamp right?
i'm just setting playtime and trying to get it now
ah ok
playtime is just a value
i can explain how it's calculated but i don't think it really is important to solve this error
i can show you how it's set tho
This is how i put the values in the table: java PreparedStatement statement1 = TWCore.getInstance().getDb().getConnection().prepareStatement("INSERT INTO playerprofiles (ID, UUID, RANK, BALANCE, KILLS, DEATHS, FIRSTJOINED, PLAYTIME) VALUES (" + "'" + id + "'," + "'" + uuid + "'," + "'" + rank + "'," + "'" + balance + "'," + "'" + kills + "'," + "'" + deaths+ "'," + "'" + firstJoined+ "'," + "'" + playtime + "');"); statement1.executeUpdate();
And you're sure your entry has a playtime
wdym?
the PLAYTIME column has a value yes
I wish i worked more with sql so I could help more... but as far as I can see it looks correct...
Why does this not fill the players inventory slots 9 to 35?
public static void fillinv(Player player) {
ItemStack filler = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
ItemMeta fillermeta = filler.getItemMeta();
assert fillermeta != null;
fillermeta.setDisplayName(" ");
filler.setItemMeta(fillermeta);
for (int i = 0; i < player.getInventory().getSize(); i++) {
if(i >= 9 & i <=35) {
player.getInventory().setItem(i,filler);
}
}
}```
I get no error
how are you calling the function
why not i = 9; i <= 35?
public static void Charmaker(Player player){
//fillplayer inv
fillinv(player);
}```
are you sure that the fillinv function runs?
^ add a print statement
exactly
to verify its being called
public int[][] getPixelsFromImage() throws IOException {
File file = new File("C:\\Users\\Charlie\\Downloads\\Server\\plugins\\image.jpg");
BufferedImage image = ImageIO.read(file);
int[][] innerPixels = new int[][]{};
int index = 0;
for (int x = 0; x < image.getWidth(); x++) {
for (int y = 0; y < image.getHeight(); y++) {
int colour = image.getRGB(x, y);
int red = (colour & 0x00ff0000) >> 16;
int green = (colour & 0x0000ff00) >> 8;
int blue = colour & 0x000000ff;
innerPixels[x][y] = new int[]{red, green, blue};
index++;
}
}
return innerPixels;
}
a little java help here
why is this happening on the innerpixels line
An int isn't an int array
i added it player.sendMessage("sasa"); public static void fillinv(Player player) { ItemStack filler = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); ItemMeta fillermeta = filler.getItemMeta(); assert fillermeta != null; fillermeta.setDisplayName(" "); filler.setItemMeta(fillermeta); for (int i = 0; i < player.getInventory().getSize(); i++) { if(i > 8 & i <36) { player.getInventory().setItem(i,filler); } } player.sendMessage("sasa"); } and it still does not work the player gets the message but not the fillers
innerpixels is a two dimensional array, and you're setting a value on the nested array
so its an int
and not an int[]
how can i make an array of int arrays
int[][]
Hi I'm wondering what would be the best way to achieve what I'm trying to do: /lockstand command that locks an armour stand and nobody can attack/modify it, and only the player who locked it can unlock the stand again. What I'm specifically wondering is whats the best way to save the player data for the armour stand? Should I make a yml file with all of the armour stands and thier player uuids, or should I somehow use NBT ?
add the print inside the second if statement
see if it prints then
i did that?
yes but that means you basically got a square of ints
use PDCs
If not I wonder if the method call isn't in the correct place
you're setting one of those ints to another array
like this?
ItemStack filler = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
ItemMeta fillermeta = filler.getItemMeta();
assert fillermeta != null;
fillermeta.setDisplayName(" ");
filler.setItemMeta(fillermeta);
for (int i = 0; i < player.getInventory().getSize(); i++) {
if(i > 8 & i <36) {
player.getInventory().setItem(i,filler);
player.sendMessage("sasa");
}
}
player.sendMessage("sasa");
}```
Yeah like that, try this
so what am i doing wrong
Oh hey
does anyone know how to solve this?
are you dense
instead of .setItem, try .addItem
the problem with add item is you can not set it on special slots
i would also recommend you make like a simple Pixel class and make it a Pixel[][] instead of an int[][][]
makes it easier to add information to that pixel if needed
The second if statement should only set it 9-36 though correct?
Which I thought was the point
9 to 35 so thats why i coded >8 <36
right
also instead of <36 just do p.getinvnetory size
It's more accurate based on the inventory you are trying to modify... a bit safer if you will
Try the add item method instead though, see if that works
Because if that does, I have a way you can set things to a specific place in the inventory, its just a bit messy
then also the hotbar would be filled and this not what i want
You tested this yes?
give me some time i need to delete some Characters to test it 😄
No worries... I've always had so much trouble with .setItem especially in player inventory... I usually just use additem and make an if for each slot I don't want filled
Or perhaps a switch
Let's say I have a 3d shape sized (2,3,1) following a player, how do I keep its relative size to Player the same at all times
yes generally speaking, querying data is safe to do async pretty much anytime (not entirely true but *generally)
hi, can somehone helps me, how do i check if an armorstand has a specifc item as helmet?
if (armorStand.getHelmet()) i tried this but doesn't work
Will the function be triggered when an armor stand is "manipulated" by a player?
As in when you are wanting to check for the armor stand having a helmet when it that function called/triggered
thats is crazy i got all the sasa but i dont got the items 😄
Still using .setItem?
ya
okey i saw waht happend i got 24 glass and than it cleard my inventory
public void onArmorStandInteract(PlayerInteractAtEntityEvent event) {
Player p = (Player) event.getPlayer();
ItemStack macchinetta = new ItemStack(Material.PURPUR_BLOCK);
ItemMeta itemMeta = macchinetta.getItemMeta();
itemMeta.setCustomModelData(16);
macchinetta.setItemMeta(itemMeta);
if (p.hasPermission("eternitystaff")) {
if (event.getRightClicked().getType() == EntityType.ARMOR_STAND) {
ArmorStand armorStand = (ArmorStand) event.getRightClicked();
if (armorStand.getHelmet() == macchinetta){
p.sendMessage("Its Working");
}
}
}
}```
thats the code, without the `if (armorStand.getHelmet() == macchinetta)` works
== checks for reference equality, not value
thats my issue XD in the createChar function there us a mysql functgion where the player inv gets resetet in the start 😄
I think you try .equals no?
like onjoin?
if (armorStand.getHelmet().equals(macchinetta)) like this? doesn't work
Probably because that itemstack isnt a helmet? or is it?
no i launch the createchar void when a character get createt ther is the filler and a MYSQL void. in this myql void there is a player.getInventory().clear(); so this cleared my inventory XD
I don't think you can put that on your head haha
try making the itemstack a diamond helmet or something
how? sorry if im asking
public void onArmorStandInteract(PlayerInteractAtEntityEvent event) {
Player p = (Player) event.getPlayer();
ItemStack macchinetta = new ItemStack(Material.DIAMOND_HELMET);
//ItemMeta itemMeta = macchinetta.getItemMeta();
//itemMeta.setCustomModelData(16);
//macchinetta.setItemMeta(itemMeta);
if (p.hasPermission("eternitystaff")) {
if (event.getRightClicked().getType() == EntityType.ARMOR_STAND) {
ArmorStand armorStand = (ArmorStand) event.getRightClicked();
if (armorStand.getHelmet() == macchinetta){
p.sendMessage("Its Working");```
like this right?
yes
its not working
It could be because you are trying to cast armorstand to a click event
if (armorStand.getHelmet().isSimilar(macchinetta))
Could be if you're writing for whenever it was deprecated +
so it may not work if you are running a local host (ie: latest mc version)
You can use the javadocs for spigot/bukkit api and see if there is a non deprecated method
package index
getEquipment.getHelmet
How long have you worked with spigot api?
Wish I had your knowledge haha
Why would you want to?
okay
https://youtu.be/a7p_GMk49hM
in overworld texture is black, but in the end and nether it works perfectly
Does that change without using shaders?
Looks to me like an armorstand is within your block, creating a shade on it.
This is a common problem for armorstands and there is no real solution. What do you back the blocks with?
here is how i spawn the entity:
https://pastebin.com/iXzCZNBS
it is not armorstand
item display
NERD
Item display can also become dark if there is a block in its location
But you can override their light levels
Try setting its brightness
i think i find solution
wait
will check
okay, i dont know why, but now it works
i thought problem in
ent.setPersistent(true);
ent.setInvulnerable(true);```
because i comment this lines
but when i decomment lines it also works
also works with shaders
is it a way to faster spawn entiry?
or another way to spawn entity?
are PDC's mutable or if I edit the PDC do i need to set the itemstack's meta to it again?
You always need to re set the meta if you change something
The PDC itself is mutable however you need to always set the meta again as getMeta always returns a copy
does anyone know how well optimized the raycasting is in spigot?
It’s decent enough
wondering since I'm working on a custom one
?stash
Oh i suppose it’s minecraft raytracing being used
I'm in a async context in a vehicle plugin, in a for loop I'm using teleportAsync() sometimes a vehicle has a delay instead of calling the same method in a sync context
should I wait the end of the completablefuture?
?whereami
depends
we can actually forget that and just use the bukkit scheduler to run a sync task instead of using teleportasync but if you're intended to you should be jailed
so let's keep using paper
if the sole purpose of your async thread is to teleport the vehicle then sure
but its prob not
yeah running gameplay events in async is a great way to desync
no
do u need to wait for the teleportation
or are you just checking nearby entities
even using async workarounds I have no big deals, it's just a little delayed
but starting a sync task for each teleport, it would be painful instead of making all sync
Is that method even intended to be run async 👀 jkjk
and this is wrapped in a for loop inside a timer task
y-yeep..
AsyncSuperDuperPlayerTeleport
you execute a query to create the DB