#help-development
1 messages Ā· Page 947 of 1
I ran put of nitro and discord just wouldn't take my money lol
Literally tried to add my PayPal amd it was just like no
Meh I'll try again tonight
absolutely šÆ
heya, whats the best way of setting all the blocks between two locations to a type? tysm
im using this atm, but its not working and im not sure why
for (int x = edgeMin.getBlockX(); x <= edgeMax.getBlockX(); x++) {
for (int y = edgeMin.getBlockY(); y <= edgeMax.getBlockY(); y++) {
for (int z = edgeMin.getBlockZ(); z <= edgeMax.getBlockZ(); z++) {
edgeMax.getWorld().getBlockAt(x, y, z).setType(getblocktype());
are edgeMin and edgeMax set correctly
are there any errors
is getblocktype returning the right type
no errors, and yea it looks right, i cant send a screenshot for some reason tho, and it should be returning the right type but it dosent even run, everything else in the code works but i made it send me a message in chat when it gets anything from the code at all and i didnt get that message, so it looks like everything after the first for statement isnt working
I will ask a question tomorrow, I will be glad if someone can explain it to me and give me an answer š
?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!
don't build up hype for a minecraft question
update its working now, i restarted the server and it fixed it, not sure what happened, maybe a failed export? (or 10)
yea, do you know what the most efficent way to set blocks is tho? cus it really lags when its doing only like 1-5k ish
?workdistro
tysm ill give it a go
I'm finally getting somewhere. :3
i had a read of it, but im not too sure how i should implement it into my code
LET'S GOOOOO
gg!
ff
Any chance of accessing entities that store block data (e.g ItemFrame) in another thread?
Hey guys where does the R# come from in the craftbukkit package names?
Hello, does anyone know how you can make spawners with, for example: Zombies with a yellow helmet? I'm trying it with CreatureSpawner, but it's not working out well.
Version: 1.20
nms revision
i'm not sure but have you tried making a spawner spawn a zombie with specific nbt?
hm I wonder how I'd go about integrating a web server into my plugin
without using a mysql database as a middleman
mariadb my beloved š£ļø
Make a State class and then use that as the middleman
for directional particles is it possible to make them curve or do they only go in straight lines
Hmmm, should I worry about an update threshold?
Or should every time there's an available update with spigot, throw the 20sec startup delay?
How do I set custom NBT tags on items
?pdc
I want actual NBT tags though
?xy
any idea on how to turn this yml
entries:
- "ROTTEN_FLESH"
- "GOLD_INGOT"
into something like this (i dont know if syntax is right)
entries:
- "ROTTEN_FLESH"
chance: 50
min: 1
max: 3
- "GOLD_INGOT"
chance: 20
min: 1
max: 2
File f = new File(path() + "/loottables/" + file + ".yml");
if (f.exists()){
FileConfiguration cfg = YamlConfiguration.loadConfiguration(f);
List<String> entries = cfg.getStringList("entries");
System.out.println(entries);
// this prints "[ROTTEN_FLESH, GOLD_INGOT]"
// how would i go about implementing the chance and min max values into it?
}
You want to go from a stringlist to a map list
okay ty
Would an effect like this be done with an armor stand holding a remodeled item, or some other way?
Really hard to tell, low quality images, but the textures look stretched slightly so it leans more towards block display entities
Yeah sorry I don't have any better picture
There is no collision but it looks like real block
I looked at display entities and I think you're right
Yeah, display entities don't have collision
okay I used it but is there a way to change it from I can't send screenshots
pluginName:NBTtag
to just
nbttag
would probably need NMS since i believe the spigot api will require a plugin namespace
how would I do that everytime I try too import what I need for NMS intelliJ gives me an error with the imports
is there a resource how to add a loot table to a custom enemy class?
again why
why do you want to do this
well it isn't really necessary but I want some parts of my server too be plugins and some of it to be with skript and it's easier to use the nbt tags with skript without all the extra stuff it's not necessary just easier and I don't see why not?
Hey Guys I need help in creating a plugin. I would love to make a plugin called Hourly Gifts, it gives to every player online a random block (there will be a list of blocks, but I would also like to implement some custom named blocks, renamed ones) every hour, can anyone help? It seems easy but a little bit tricky
use PDC
and just access PublicBukkitValues
ight
question though if I didn't have the plugin like I deleted it for sum reason or smth
or made a new one
mhm?
the nbt would stay?
alr
Sounds like the client sucks
Im doing this on leave & join and when loads of people leave at once. My game just stops responding, for some players itās fine and responds but lag spikes occur. And itās only on these two methods
is it a new entry for every player?
I'm trying to code a gui that opens a gui when a certain slot is clicked on the other gui though I'm not sure how I would do it. Could someone give me a tip
if (ChatColor.translateAlternateColorCodes('&', e.getView().getTitle()).equals(ChatColor.YELLOW + "Shop Menu")
&& e.getCurrentItem() != null) {
switch (e.getRawSlot()){
// Shop menu items
//Building blocks
case 10:
e
break;
// weapons
case 11:
if e.getRawSlot(10) {
e.closeInventory(inv)
e.openInventory(inv)
}
break;
?gui
private void spawnFallingBlock(Player p, Material material, Location loc){
System.out.println(material.toString());
ServerPlayer serverPlayer = ((CraftPlayer) p).getHandle();
CraftFallingBlock nmsBlock = (CraftFallingBlock) p.getWorld().createEntity(loc, FallingBlock.class);
nmsBlock.setBlockData(material.createBlockData());
int id = nmsBlock.getEntityId();
ClientboundAddEntityPacket nmsBlockPacket = new ClientboundAddEntityPacket(nmsBlock.getHandle());
ClientboundSetEntityDataPacket nmsBlockMaterialPacket = new ClientboundSetEntityDataPacket(id , Objects.requireNonNull(nmsBlock.getHandle().getEntityData().packDirty()));``` am i missing any packet? cause the blocks were invisible.
since when is createEntity a thing
it worked with armorstand o:
i mean it did spawn the block..it was just invisible
do u want to see a clip?
uh huh wtf
still the same
is there something i should be worried about ?
oh... oh no
what the hell mojang
I just discovered a new way to get clients to desync entity locations from what the server is doing
i just wanna spawn a packet falling block ;-;
ok so entity.moveTo can actually cause client desyncing
what the hell
how am I supposed to fix that?
How do I make my config.yml save comments
public static void initializeConfigs() {
instance.saveDefaultConfig();
File file = new File(DelightMain.getInstance().getDataFolder(), "config.yml");
instance.getConfig().options().copyDefaults(true).parseComments(true);
instance.saveConfig();
}
current code
comments are saved by default in versions which support them
The latest version isnt one of them?
it is
then I must be doing something wrong
what does your config look like; why are you mixing instance and DelightMain; and why are you saving the config immediately anyway
is there anything i can do to fix this?
ok so if you use moveTo to make an entity move real quick between points repeatedly the client will attempt to smooth the motion on its own and that will override the actual intended location of where things are getting moved to
what is mojang smoking
<Player>.hidePlayer reset on death/spectator etc? Or just when player join/leave?
join/leave
thx
use a real entity with setVisibleByDefault(false) and Player#showEntity ?
okay i will try that
Config looks like this
# Delight plugin configuration
# This is a test
test1: 15
Also I forgot to clean up code last night, I'm doing it now
I'm just testing the comment saving capabilities, and I still have to add stuff to the code
I... actually don't think this is fixable
teleport is just a moveTo with more conditions
Time to go modded
seems fine to me, if you think there's a bug create a bug report with a minimal reproduction plugin; but I'm sure comment saving works fine
I don't really know how forge does it but I suspect the only way this would work is if i create my own modded client and server to change how movement fundamentally works
or at least inject an alternative to it
why do fallingblocks not go thru the blocks?
why would they
I see, thanks
is there a way to make them go thru blocks?
I suspect copyDefaults doesnt copy comments
Unrelated, I just found out that all of the messages pre server startup don't get logged. š¢
I'll try
instance.getConfig().options().parseComments(true).copyDefaults(true); didn't work
not clear why you need copyDefaults at all given you're saving the default before
I thought it was future proofing, like a user accidentally deleting a line on the config or a future update adding a line
I'm trying to stick to whatever is standard in spigot, because the last time I did config on my own was a mess
open a bug report then I guess
how can i make the fallingblock go thru the ground though?
I try to add a loot table to a customZombie like this: ```java
public class CustomZombie extends Zombie {
public CustomZombie(Location spawnLocation, int id) {
super(EntityType.ZOMBIE, ((CraftWorld) Bukkit.getWorld("roguelike")).getHandle());
Level level = ((CraftWorld) Bukkit.getWorld("roguelike")).getHandle();
this.setPos(spawnLocation.getX(), spawnLocation.getY(), spawnLocation.getZ());
this.setId(id);
ResourceLocation lootTable = new ResourceLocation("name","normal.json");
this.lootTable = lootTable;
level.addFreshEntity(this);
}
}```
here is my loot table:https://pastebin.com/wsFwuBFd
But the zombie is always dropping nothing so I assume I saved the loot table at the wrong place. I saved it in the resource folder in my Plugin directory
floss with the best or chug jug with the rest
oh wait
actually I think I just might've accidentally figured out why modelengine does line of sight packet sending
if you keep resetting the packets you sure won't figure out that this desyncs
ok well yeah turns out I have to reset the entity every few seconds or it will drift
lame
fortunately it's really a blink it and you'll miss it update, I wonder if there's a more elegant solution
is there any way to get TAS (tool assisted speedrun) working on a spigot server? assuming stuff like tick rate is also changed etc.
EDIT: if anyone from the future reads this, it turns out /tick rate automatically changes player speed (like, your literal movements are slower client-side). i didnt realize this because i was using /tick freeze, which doesnt slow you down at all. so no mod or plugin is necessary, dont overcomplicate it
what would that even mean, because the server can just do whatever it wants
if you want to teleport a player to the ender dragon and instakill it within the same tick that is possible
well in TAS runs usually you have a mod to slow down your movements, but i donāt understand how/if that would work on a server. to my knowledge, TAS mods in single player slow down the entire speed of the world and the speed of your client-side inputs. but mods obviously canāt control what happens on a multiplayer server, so for example when you tried to move really slowly to place a block, (iām assuming) the server canāt register that. iām wondering if thereās a way to somehow make those sorts of TAS mods with client-side input work with the server itself, e.g. through a plugin which changes the /tick rate
honestly I just see what you want to do here as completely meaningless in the context of multiplayer minecraft
is it impossible to code semi-convincing player movement and interactions and create an ai that can beat minecraft? no, not necessarily impossible, but it's completely fake
it is harder to make a player move in this instance than to just kill the dragon, and it's harder to fake a player hitting an enemy than it is to just delete it
and ultimately it's all just faking anyway
not necessarily, letās say youāre recording a youtube video as a promo for something (e.g. https://youtube.com/shorts/200CGaZDg5g?si=aK1qVsxWQkqXEgTE)
this video would be 10x easier to record with TAS, saying itās meaningless or that āfaking itā makes it not worth doing doesnāt really make sense.
and not in the tool-assisted sense of it, in the "you have to fake the entire interaction" type of way
afaik there isn't even a way to tell a client that it is doing something as basic as hitting a block in spigot
it may be possible if you send packets but it is completely artificial
you'd have to hook that up to an actual behavior
if you're picturing a traditional TAS then no it is not possible
well, mostly not possible
alright thank you for your help
will there be data loss if you convert the number type to double for comparison?
and how critical is it
which number type?
for example long
how critical is it
What do you mean? Its unacceptable because the outcome could be completely unrelated to the original comparison.
How do I rename my config.yml (for backup purposes)
File oldConfig = new File(instance.getDataFolder(), "old-config.yml");
if (!file.renameTo(oldConfig)) DelightConsole.sendWithPrefix("lol didnt work");
instance.saveDefaultConfig();
how can i make it remove the SNAPSHOT from the name of the built jar with intellij?
pom.xml, line 9 I think
just remove the SNAPSHOT in the version
<version>1.0</version>
move the file
ty
theres no move method for java.io.File
I usually use java nio for this.
But the old way (renameTo) should work just fine as well
What about this didnt work?
this? also it doesn't work for me it seems like
if i delete the ones with -SNAPSHOT will that cause problems?
no you can remove all of it and it'll regenerate once you recompile
I assume is that the plugin is still accessing the config (even tho no part of the code is), and so it fails to rename
I know a way to do this but its by scanning and pasting the values onto the new file, but I think theres an even more efficient way for it
If you save the dafult config anways, then you might as well copy the config instead of moving it
Hmm, that gives me a different problem tho, which is saving comments from my config file
It only does it correctly when I do instance.saveDefaultConfig(); (which means the file isnt created yet)
but if it already was created, it wont carry over the comments
.
if that code is stripping comments you are not using Spigot, or not a new version.
well I am, and yet it doesn't work
I know I'm 100% doing something wrong
I meant just copying the entire file. Skipping loading it into a FileConfiguration.
If you simply create a byte-by-byte copy of the file, then the content (like comments) is irrelevant.
but idk what part is wrong
also, you never use file.
Is there a better alternative? also how come
you create the local variable file but never use it
don't copyDefaults(true) unless you actually added some defauls and want to save them
and parseComments is by default true
I did, but whenever I load the plugin, it puts it on the top and loses its comment
both the file line and the options line do nothing in your code
I can only guess you are not using spigot then
loading/saving config with comments works just fine
in Spigot
the code I sent isn't using the file line but I'll need it for a different purpose
I just havent wrote it since I'm stuck with this part of the code
also I'm using 1.20.4 spigot, if thats relevant
public static void initializeConfigs() {
instance.saveDefaultConfig();
//File file = new File(DelightMain.getInstance().getDataFolder(), "config.yml"); TODO
instance.getConfig().options().copyDefaults(true);
instance.saveConfig();
}
``` here
no code you have posted (using Spigot) can do what you are saying it does.
remove the options line
nothing there will remove comments
are you perhaps not showing all the code as you are attempting to merge the packaged config to the saved config to add new values?
This is the config.yml it generated (the file exists already but is empty, this is what it wrote)
test:
testing: 123
# Test Comment
bro: 123
foo: bar
this is what the config.yml in my resource folder has
# Plugin Header
test:
testing: 123
# Test Comment
bro: 123
# Uhh another
foo: "bar"
Thats all the code, there are more but it comes after this (and its currently not in use)
why?
I'm trying to future proof things, so that if I we're to add a new option in the config, it will just paste the default without any error
it works correctly when the file doesnt exist
since yk, saveDefaultConfig
the only way to do that is to load the config from the jar, load the file config and manually copy all values from teh file to memory, then save
ie loop all key/values
its the only way to preserve comments
setDefaults will only set teh values for missing keys. It will not transfer comments
then what does parseComments do
preserves comments in an existing file
I wonder if setDefaults will override an existing value if copyDefaults is already set true
I've never tried it
It isn't, but as I said above copyDefaults(true) doesn't copy commentt
You're welcome to open a bug report
I wouldn;t expect it to copy comments
I was just thinking if copyDefaults was already set true then setting a default might (in thoery) overwrite an existing value.
I don't know what to expect tbh
My though process was, load a config from the Jar. set copyDefaults(true), then setDefaults and point to the existing config file.
in that situation I would expect the defaults to overwrite teh existing values.
I think that's what already happens to the default config
copyDefaults just doesn't handle comments
That "should" take the values from the config.yml and insert them into a commented FileConfiguration
yep I'd only expect it to copy the values
But I've not tested anything. It's just thoughts
Just to note, its the other way around for teh default config. It loads from file, then sets defaults from the jar (for spigot anyway).
hi
so i have a code for a custom config file named linking.yml, and when i add some values to it using a command, and i send the value from config it works
but if i reload the linking.yml file it returns null, but i doesn't reset the file info
like this
it has this value, but if i send it after reloading it it returns null
(it works but breaks after reloading)
did you save the file changes?
How are you getting the file?
i have a manager class for it
public void load() {
file = new File(RelaxDc.getInstance().getDataFolder(), "linking.yml");
if(!file.exists())
RelaxDc.getInstance().saveResource("linking.yml", false);
config = new YamlConfiguration();
config.options().parseComments(true);
try {
config.load(file);
} catch (Exception ex) {
ex.printStackTrace();
}
if(!config.contains("linking"))
config.createSection("linking");
save();
}``` i use this to load it
Where are you getting YamlConfiguration from?
what?
It's not from spigot
import org.bukkit.configuration.file.YamlConfiguration; this is the import
'config = new YamlConfiguration();'
?paste
Can you paste the whole class
here is whole class
So the issue is, it's, after restarting, not finding the file?
the file exists, but it returns null for its values
i check file if it has them and it does
but it doesn't read them
Okay, try debugging then
On the load
Read all the contents from file
See if you are even getting the right fike
File*
in the load method or onEnable in main class
Load method of your config manager
ok
so for some reason it doesn't log any section or key
i added
for(String s : config.getConfigurationSection("linking").getKeys(false)) {
Bukkit.getLogger().info("Section: " + s);
Bukkit.getLogger().info("key: " + config.get(s));
}``` to code but it doesn't log them
no warnings or errors
Your getInstance() in LInkingManager returns the wrong instance
it shoudl return this and scrap your instance Field
or as its a static getter you have to set it correctly, not just new LinkingManager
how should i fix? and is that the problem?
Create a private static instance
Init that in the constructor
Then return that in the getinstance
ok
lets say i have a center coordinate.
and 1 another coordinate
how can i move that coordinate 1 unit towards the center coordinate? (dont mind the circles i was testing something)
Unit?
like this? ```java
private static LinkingManager instance;
private File file;
private YamlConfiguration config;
private LinkingManager() {
instance = this;
}```
like shift it by 1
Yep
1m? since 1 block is 1meter
So 1block
Maybe?
yes
i'll test it rq
transform both to vector, substract middle from your cord normalize
He wants to move one inward tho
is the main coord still in the middle?
did u look at the image?
i have center and the border coordinate
i need the coordinate 1 block inward
unless you need a new radius, the circle is not relevant in moving inwards
i said ignore circle cause i was trying something..
i will explain once more..
I have the center coordinate..(the circle's center)...
I have the corner coordinate (the blue one at the end of the radius r)
i need it 1 block inward
Center 10, 5, 6
Point 10, 7 6
He wants the Point to move on inward while maintaining the diagonal Position
oh i see
i think it's just what i said about vector
with substract
normalize will make it 1 block
Wouldn't that get the center between vector 1 and 2?
so if you apply the vector to a location it'll go 1 block inward
the vector will point towards the center if you normalize it
it'll be 1 block length
Oh I see
no, that is a different formula
you can increase the magnitude if you want more than 1 block
i used to make floating player baloons using this
if you wanted the middle of two end points, you use the midpoint formula. Where you add both x's and both z's together and divide them both by 2
frostalf the smart
well that is just some basic algebra
what should i do though ;-;
I thought Fr33styler answered it o.O
so this?
Vector direction = middle.substract(firstdot).toVector().normalize();
my answer was in regards to someone asking if what they gave for the answer would give the mid point
Location second dot = firstdot.clone .addVector(direction)
Ye me ty
do u need to calculate middle then get it as vec?
i assumed you had it
you kinda need the middle if you want to move it 1 block closer to it
alr
You have the middle location right?
i can calculate it using mid point theorem
i have the dark blue locs and need light blue
k lemme try rq
that's exactly what i wrote to you earlier
you do have the blue dot
that's your middle
the edge blue dot is firstpoint
oh
and the light blue is second dot
xD i thought middle as the point between them my bad
i would need middle as vector right?
it's all in the api
the second line must be done in 3 lines
i think it's just add and not addVector
//loc1 i am standing so first dot
//loc2 is middle
Location loc1 = p.getLocation().getBlock().getLocation().subtract(0,1,0);
Location loc2 = p.getTargetBlockExact(40).getLocation();
Vector direction = loc2.toVector().subtract(loc1.toVector().normalize());
Location second_dot = loc1.clone().add(direction);```
based off my understanding
ye
lemme test
ah alr
you only normalized the first location
yes, but you can do toVector after substracting
oh wait
substract on 2 locations needs to be on one extra line
since it returns void unlike vectors
but here u saying u are using 2 locations..
loc 1 loc 2 are locations
yes but u converted loc2 to vector
so u are saying
to subtract first..then vector it..then normalize it
it does?
yeah
oh that's nice
it is
Vector direction = loc2.subtract(loc1).toVector().normalize(); u ment this
yes
alr
lemme compile and test
bottom one is loc1
top one is loc2
the inbetwen is our block
private Location getdablock2(Player p){
//loc1 i am standing so first dot
//loc2 is middle
Location loc1 = p.getLocation().getBlock().getLocation().subtract(0,1,0);
Location loc2 = p.getTargetBlockExact(40).getLocation();
Vector direction = loc2.subtract(loc1).toVector().normalize();
Location second_dot = loc1.clone().add(direction);
return second_dot;
}```
it works in straight line.
hmm
cap the loc 1 to be 0.5 for x and z
wym and why
0 being the location's x and z
the vector will go from the middle of the block
and not from a corner
so it will look straight even in diagonals
vector is alr going from middle
alr
hmm this is not setting velocity
Location loc = p.getLocation().getBlock().getLocation().subtract(0,1,0);
Location veloloc = shift(loc, p.getTargetBlockExact(40).getLocation().getBlock().getLocation());
BlockDisplay display = p.getWorld().spawn(loc, BlockDisplay.class, pre -> {
pre.setBlock(material.createBlockData());
pre.setVelocity(veloloc.toVector());
});
Bukkit.getScheduler().runTaskLater(GyrokineticWand.instance, display::remove, 200L);
}
private Location shift(Location loc1, Location loc2){
Vector direction = loc2.subtract(loc1).toVector().normalize();
Location second_dot = loc1.clone().add(direction);
return second_dot;
}```
https://paste.md-5.net/ivemewarus.cs i get this error now
it says the instance is null
use this:
Vector direction = loc2.subtract(loc1).toVector().normalize();
for your velocity
not the shift
you probably haven't initiated getinstance
do this:
private static final LinkingManager INSTANCE = new LinkingManager();
private LinkingManager() {}
ew static
public static LinkingManager getInstance() {
return INSTANCE;
}
i did this before but the said not to use it
it's a singleton, at least it's alright
singleton pattern
Who is the
ElgarL
Hmm
Just do what Fr33styler is telling you to, looks fine to me
private void spawnFallingBlock(Player p, Material material) {
Location loc1 = p.getLocation().getBlock().getLocation().subtract(0,1,0);
Location loc2 = p.getTargetBlockExact(40).getLocation().getBlock().getLocation();
BlockDisplay display = p.getWorld().spawn(loc1, BlockDisplay.class, pre -> {
pre.setBlock(material.createBlockData());
pre.setVelocity(loc2.subtract(loc1).toVector().normalize());
});
Bukkit.getScheduler().runTaskLater(GyrokineticWand.instance, display::remove, 200L);
}``` it doesnt do anything
like it doesnt even move an inch
maybe it's because you do it before spawn?
maybee
try it outside
also is it possible to remove Y coordinate from calculation in vector
beat me to it
Hmm, is it theoretically possible to handle events off the main thread?
Like, not to improve performance
Just if in this specific case where I have data I get off-thread and need to put into an event
Display entities do not tick velocity
^^
it depends
you can offload the calculations in most cases off thread
and then send those results back to main thread
but uhm, the main problem isn't fixed
the problem:
i have a linking.yml file, and when i add a value to it with a command it works and sends the value if i send it, but if i reload the file it doesn't delete it from linking.yml but it returns null when i send it
Location loc1 = p.getLocation().getBlock().getLocation().subtract(0,1,0);
double y = loc1.getY();
Location loc2 = p.getTargetBlockExact(40).getLocation().getBlock().getLocation();
loc1.setY(0);
loc2.setY(0);
p.teleport(loc2.subtract(loc1).toVector().normalize().toLocation(p.getWorld()).add(0,y,0));``` is there somethig i am missing cause it returns coords of near 0 80 0
o
as you said, you want to remove y from calculation
assuming it's the player you want to move
anyone here develop for cb 1060
nah i wanna teleport the display block but i used player once cause i couldnt find where the display was going
yea works
ty
help pls :)
yo how do you check if the Inventory opened is the chest gui that i made
?gui
bump
very helpful š
ok mb
"noone" ?
You understand what he's trying to say, right?
So what's the problem?
<rolls eyes>
what does the FileConfiguration getKeys(bool) do if I set the bool to true?
the docs isn't that clear with its wording
very clear
some_key:
foo:
bar: "idk"
bar:
getKeys("some_key", true) would return everything inside some_key,
getKeys("some_key", false) would return foo & bar
pretty simple
oh, so its just me thats stupid
my first thought was correct
it ussually is ;d
hmm, is there a short way to get all the keys and make it appear like
somekey.foo.bar
somekey.bar
or do I have to manually code it
what is ur end goal
get the keys, and print them (for testing)
so I can make something like
foo1:
bar1:
test: 15
bar2:
test: 16
foo2
bar1:
test: 15
bar2:
test: 16
I get the keys and make it
foo1.bar1.test
foo1.bar2.test
foo2.bar1.test
foo2.bar2.test
no short way of doing it?
cuz so far, #getKeys only did
foo1
foo1.bar1
foo1.bar2
foo2
foo2.bar1
foo2.bar2
you'd probably have to make a method to parse it yourself yea
man
alright
thanks
Are you doing getKeys(true) ?
what does to "nms a chat message" mean?
What is the point of using persisentdata containers when I can just serialize my objects to byte arrays, throw them into nbttags as byte arrays and just deserialize them later in order to access the data?
it's supported api
bump
nbt isn't
the thing is when you start working with custom persistent data you need to implement your own serialization methods anyways if you want to store classes that aren't serializable by default
not to mention that items will stop having nbt field in the next update of minecraft, and pdc works on entities and chunks etc
Oh okay so more variety
I mean, you can serialize your type to a byte array, that's supported by pdc
Yeah thats pretty much just using pdc to create custom pdc data types
Its what I did
By default you can serialize only serializable items and only store them
Sht like itemstack and much other needed types aint serializable
So for that you need your own serialization methods
I just made my custom classes implement ConfigurationSerializable
And bukkitoutputstream accepts types that implement that
Aswell as bukkitinputstream
yes
you can then take that same byte array and shove it into the pdc
and vice versa
Yeah I'm doing that, I created my own PDC Datatype and I'm overriding the basic PDC methods in order to be able to serialize my data correctly.
Why do they stop having nbt fields
Is it because of compatibility? Just wondering
mojang is reworking how items are handled internally
they are serialized to nbt, but in memory it will be different
this is why you stick to the API :d
Gotchu
Well its pretty much my first time working with serialization etc
But it aint that complicated after all
thanks
can't wait to redo my NMS stuff
no biggy tho should only take a few minutes since components are unbelievably based
why tho lol
API has most stuff you need chat wise
even spigot has components for chat
then wait till you actually need to use it
there are plenty of valid uses for NMS and chat is definitely not one of them
actually pretty helpful I'm simply encouraging you not to make a stupid mistake
if you come to me with a valid reason to use NMS and ask how do I do this you're bound to get some form of help
can i somehow discourage anonymous use of a class?
I wouldn't be too worried about that :P why do you want to specifically discourage anonymous use
you can anonamously use any class
because some classes are supposed to be extended
there isn't really a way to prevent or discourage it. I'd say by defaults its a discouraged practice that would need to be actively encouraged
How do I listen for a dropped item moving? - Custom Hopper
?stash
why can't you just use sendMessage lol
they wanna learn sms _
what a shitty way to learn NMS kek
chat requires like 2 braincells and is just more annoying than anything
Hey, what is this Bukkit.getPluginManager().registerInterface(); method for ? š
// Adding comments
for (Map.Entry<String, List<String>> comment : comments.entrySet()){
if (comment.getKey().equals("header")) config.options().setHeader(comment.getValue());
else config.setComments(comment.getKey(), comment.getValue());
}
why does #setComments only work when the config file already exists (first start adds the default values without comments, restart the server and it adds the comments). I tried saving it beforehand, then saving it again, I enabled #copyDefaults, I'm so confused
public static void initializeConfig() {
instance.saveDefaultConfig();
File file = new File(instance.getDataFolder(), "config.yml");
FileConfiguration config = instance.getConfig();
setDefaults();
setComments();
config.addDefaults(defaults);
config.options().copyDefaults(true);
instance.saveConfig(); //saving it first as a test, didnt work, also doesnt work without
// Adding comments
for (Map.Entry<String, List<String>> comment : comments.entrySet()){
if (comment.getKey().equals("header")) config.options().setHeader(comment.getValue());
else config.setComments(comment.getKey(), comment.getValue());
}
// Saving
instance.saveConfig();
}
Been working on this. Just looking for any feedback.
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1375/overview
I'm also wondering if there should also be a method created to check for final updates. As there will be final commit for each version of the game.
Hi, I was trying to setup BuildTools and I am receiving an error.
Currently running JDK 1.8.0_201 & tried JRE 1.8.0_201
Here is my BuildTools Debug:
BuildTools Version: git-BuildTools-a50d932-181
Java Version: Java 8
Current Path: C:\Users\pizza\Desktop\Temp folder\Spigot BuildTools
Flags Used: --nogui --rev 1.8.8
Operating System
Windows 10 (amd64)
Kernel Version: 10.0
Computer Information
Memory Usage: 51.2 MB / 5.3 GB
Java Versions Installed:
- JDK 21 at C:\Program Files\Java\jdk-21\bin\java.exe
- JDK 17 at C:\Program Files\Java\jdk-17\bin\java.exe
- JRE 8 at C:\Program Files\Java\jre-1.8\bin\java.exe
- JDK 8 at C:\Program Files\Java\jdk1.8.0_201\bin\java.exe
* JRE 8 at C:\Program Files\Java\jdk1.8.0_201\jre\bin\java.exe```
Thanks in advance
here are my logs: https://pastebin.com/BV5ggYue & the message.txt below
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Did you run BuildTools in an empty directory?
Hi guys.
I have problems while trying to create my gitlab CI (regarding a multi-version spigot plugin).
My CI uses buildtools (--remaped) to save NMS in the runner's cache (in $CI_PROJECT_DIR/.m2/repository folder).
Then my plugin build fails because it can't find this:
[ERROR] Failed to execute goal net.md-5:specialsource-maven-plugin:2.0.2:remap (remap-obf) on project LE-NMS-v1_18_R1: Error creating remapped jar: The following artifacts could not be resolved: org.spigotmc:minecraft-server:txt:maps-mojang:1.18-R0.1-SNAPSHOT (absent): Could not find artifact org.spigotmc:minecraft-server:txt:maps-mojang:1.18-R0.1-SNAPSHOT in enginehub-maven (https://maven.enginehub.org/repo/)
I posted the help request with more details here: https://www.spigotmc.org/threads/build-nms-in-gitlab-ci-multi-version-plugin.642411/
Any help would be appreciated !
try running it again š¤·āāļø other than that we can't help unless you can replicate on latest
1.8.8 is almost 9 years old and not supported
Fair enough
I keep forgetting about that. lol
It should be able to build any version though.
Yea, ez
true but if its an issue with 1.8.8 spigot that really isn't our problem, its 9 years old supporting any form of it just keeps it from getting closer to death
even issues on jira are ignored for 1.8.8
bumping cuz I'm not sure if I need to file a bug report
Fair, but this seems like an envrionment issue.
I wonder if it's because they are using java 8_201 and not the 401 version (aka latest).
Also makes me wonder if we need to check for that in BT. š¤
Well, I wonder if it's because of certain changes that were made in those releases. Compared to what we are developing against.
I'm not saying we have to do it, but it does make me curious as to whether that is the underlying issue.
Or you know, maybe it's time to go scorched earth and only let buildtools compile the latest version. :p
currently trying it with 1.8.0_391 to see if that fixes it, hopefully it does lol
didn't work still, rip
The logs did say that it was using 391 correct?
Cause there may or may not currently be a bug with java version overrides.
Cool
Does
"org.spigotmc:minecraft-server:txt:maps-mojang:1.18-R0.1-SNAPSHOT"
corresponds to the file
"$CI_PROJECT_DIR/.m2/repository/org/spigotmc/minecraft-server/1.18-R0.1-SNAPSHOT/minecraft-server-1.18-R0.1-SNAPSHOT-maps-mojang.txt"
?
You could maybe try deleting the work and Spigot folders created by BT and try again.
worth a shot
Why does it build locally and not on this CI š¢ !
What does $CI_PROJECT_DIR resolve to?
And does it actually contain the /.m2 directory?
Cause usually that lives under the user's home directory.
yea it caused the same issue
$CI_PROJECT_DIR is my runner's build folder that also contains my project. Yes it contains the .m2 folder (retrieved using cache from the previous stage which builds nms).
I added a ls $CI_PROJECT_DIR/.m2/repository/org/spigotmc/minecraft-server/*' command to check this.
The logs ( https://gitlab.com/lasersenigma/lasersenigma/-/jobs/6516970981#L86 L.86) proves it does contain the expected files.
You could maybe try clearing all of the work folders, build the latest version, then try building 1.8.8.
I also asked myself if if maven was using $CI_PROJECT_DIR/.m2 but I defined it well in the $MAVEN_OPS. (https://gitlab.com/lasersenigma/lasersenigma/-/jobs/6516970981#L86 L.86 and L.184-185)
So I really don't know why I get this error
[ERROR] Failed to execute goal net.md-5:specialsource-maven-plugin:2.0.2:remap (remap-obf) on project LE-NMS-v1_18_R1: Error creating remapped jar: The following artifacts could not be resolved: org.spigotmc:minecraft-server:txt:maps-mojang:1.18-R0.1-SNAPSHOT (absent): Could not find artifact org.spigotmc:minecraft-server:txt:maps-mojang:1.18-R0.1-SNAPSHOT in enginehub-maven (https://maven.enginehub.org/repo/)
It's probably a stupid mistake but I just have no idea why ^^
I think the issue stems from maven trying to grab specialsource from the enginehub repo instead of the spigot repo.
Which doesn't seem to be present in your pom.
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
I defined it in the main pom.xml (and not in the submodule pom) ? Aren't repositories inherited from parent to child pom ?
And even if they are not inherited, shouldn't maven find it locally first ?
they're working with NMS so that doesn't even make sense
I think that submodules have their own rules for compiling. Yes they can pull dependencies from the parent, but they can also just use their own.
clearly something is off with their maven local because of the weird setup
hmmm I will try to add the repo then and we will see the result ^^
Are we up to version 2.0.2 in specialsource now?
Hmmm I will check that version too. It's in the spigot hub i suppose
Does anyone know how to use a none base potion for tipped arrows (so without using setBasePotionData)
isn't that artifact only generated by BT?
Again let's remember that it builds locally so both the lact of the repo definition and special source version should not be and issue.
Yes it is. My CI runs buildtools.
Well nuke your mavenLocal and see if it builds
I'm not sure what the classifier is though?
never seen that one before
unless they're manually mapping themselves
?nms
Yes: I followed that (see https://www.spigotmc.org/threads/build-nms-in-gitlab-ci-multi-version-plugin.642411/ for a more detailed description of my issue)
?bt
yea 1.20.4 works, just 1.8.8
Could MD please turn off 2FA? It's the worst thing ever
Like cool for those that like 2FA, but not for the average geolykt
it was turned on for a reason
after doing 1.20.4, then doing 1.8.8 with BuildTools it worked
kek 1.8 moment
Not sure why that works sometimes still, but it seems to be the workaround for older builds.
yea seems quite weird, thank you for helping me though
Guess it actually is time to make BT compile latest regardless of user choice. :kek:
As a wise man once said. "Fuck em"
are you that wise old man?
No comment
how to use upgraded tipped arrows for itemstack
It's kinda strange that the error message doesn't use the valid GAVCE format, though that could be a programmer mistake from who wrote the logger statement
The alternative could of course be that the remapper plugin inverts version and extension even though that is bogus (and probably should be something that happens outside the CI pipeline)
cast the ItemMeta to PotionMeta
and I'm p sure you can then use potionMeta.setBasePotionType(PotionType.X);
but thats base potion
ItemMeta meta;
if (!(meta instanceof PotionMeta pmeta)) {
return;
}
should work fine
Thats the base though so the lowest one when I am trying to have the highest one
as in lowest effect
The more probable cause for this issue is that the specialsource plugin doesn't make use of the custom local maven repository defined by the maven options, but even that is rather unlikely as I'd be surprised if the plugin hardcodes the path to mavenLocal
Another probable cause is that the local maven repository isn't being declared as a local repository but rather as a remote repository, at which point the artifacts become unaddressable and thus cannot be resolved. But that too is unlikely
checked, it's not that
unlikelly indeed
How could you check that?
potionMeta has other methods like addCustomPotionEffect you can mess around with
by specifiying the local repo in the maven command line and reading maven doc
but again, ty for trying to help. I think I have a clue of my problem's origin. I'm currently searching if it's what I think. Will let you know
What I'm going at is that how snapshot versions are stored differ between local repositories and remote repositories (which imo is annoying but what can one do?)
you are missing the mappings
but if the problem is something else entirely I'd not be surprised
the mappings are there, they just cannot be resolved
The problem seems to come from 1.18 instead of 1.18.1
well, I didn't see where they showed what their repo looked like
but it needs to be a txt file
I did wonder why the 1.18.1 module used 1.18 artifacts. But good to see that solved
If you want to see the expected content, it is listed here https://gitlab.com/lasersenigma/lasersenigma/-/jobs/6516970981#L86
Not solved yet but at least I know what to do now š
well I mean it is pretty obvious what the problem is
does it exist in there for 1.18?
no that's the problem. I'm currently modifying every nms/*/pom.xml to change 1.X to 1.X.Y in both <srgIn> and <remappedDependencies>
a question not really about programming itself, but do maps save across worlds? Let's say we have a server with two worlds (1 and 2), I make map of world 1 and move myself to world 2
would that map still show the same thing?
I essentially want to make separate world for such maps that would contain 'custom' imagery
not <remappedDependencies> (that should be 1.X). only <srgIn> (that should be 1.X.Y).
hmmm it's a world storage lifecycle question if I understand well ?
Im not too sure
okay
what if I had world 1 and world 2 on my server
and I wanted to spawn map that contains world 1 in world 2
would that be possible?
all maps are linked by their ID's and there is a limited number of maps that can be made that the server will track. Therefore the map you have in your inventory will always be linked to the place it was created for
yes that is possible as you only need to have the appropriate id to obtain the map
is it possible to freely spawn maps that are filled and linked to X place?
Hm why did I block dusk hmm
to do so with in game mechanics alone, you would need to have discovered all the places the map is for
a plugin can do it easily
programmatically ? So you want to save world 1. Then copy world 1 to world 2. Then load world 2 ?
they are talking about the map item
yes map item
oh sry. Ty for explaining.
I mean I can just make a part of the world to be for custom images
I suspect its just some special metadata that's available to set up from spigot API documentation?
Could anyone recommend some sources for learning NMS? I know what it is and all, I just don't really know how to use it and bind it into my existing projects (I'm probably just dumb and used the wrong sources but yea)
Thx in advance
yes there is API available for making maps
okay cool
It's weird
You basically learn it out of necessity
I need it, that's tht thing, but apparently I'm too dumb to bind it to my projects lmao
The main entry point for everything nms related starts with the craft wrapper
Let's say you have a player
And you want to get the nms player or something
You cast your player to its craft implementation (CraftPlayer) and then call getHandle
And this works for most things
And if it doesn't it's probably in CraftMagicNumbers or CraftItemStack or similar things
I see
and how would I specify it as a dependency, or better, what do I use as the dependency. Do I have to decompile the server jar and there lays the nms stuff? And would I then need to specify the jar as the dependency?
?switchmappings
ty :)
?nms
Hey, I would greatly appreciate if someone can help me find the solution to one of these problems so I can continue my development and hopefully learn something new
https://discord.com/channels/690411863766466590/1224005620949188608
just got back to spigot plugin development, apparently createInventory is deprecated for GUI's, what should I use instead ?
That just means you're using paper lmao
Or a dev build
If you're using a dev build there's MenuType
?paper
mf
?whereami
Does anyone know how to enable both premium and cracked players, who may possess identical usernames, to join the server simultaneously.
For example: the user Intexor can join with cracked and premium at the same time.
if anyone knows a solution for this issue please let me know.
My discord is Intexor
I swear I saw a post on builtbybit for this
and you already copypasted the same exact message twice
Yea
In short - The usernames need to be different
You can either prefix cracked players or prefix premium users
The UUIDs are already different by nature (uuidv3 vs uuidv4) so that's not a problem
Just use the same measures that fastlogin uses to detect premium players and do shit
Should I just use fast login?
yep
Go figure you're reaching out to developers who risk having their shit pirated all the time and asking how to allow piracy
I understand that, I guess youāre right.
My bad.
I aināt trynna do anything wrong
Itās just that itās been so long and I canāt solve this so thatās why I tried to seek for help here
can't get pirated if your software is too bad to be worth pirating
advertising your plugins I see
nah, mine are free
i'm going to pirate them anyway
catch me if you can :>
How to properly make a menu for players?
When the player writes a command to constantly create a new menu object for each of his own?
When starting the server, create 1 instance and open it for everyone?
Then how do I make it so that a certain item is displayed for each player depending on the permission, or that the api placeholder works?
And how to implement the update of this menu?
?gui
Yes
its up to you how you do it
I have never done this, I can create a menu, I just don't understand how I should handle the fillers and should I create a new object for each player or use one for all, I don't understand
you can dynamically display it
you store the 'base'
and then when showing, determine what each part looks like
I have a code, I created it, I can create a menu very easily, but I don't know how to update and display in the placeholders certain data for each player
I would show you the code, but you can't do that here
what do you mean by placeholder
they probably want to display data specific to each player
which is easily possible with the system in that link
if they read all of it
Placeholder API use to item lore
Yes, each player has their own data
?.
Could you watch on the broadcast how I did it and how it can be improved for dynamically Placehplder API
you understand how placeholder API works yes
how do i get this custom head as an ItemStack in spigot?
https://minecraft-heads.com/custom-heads/head/21420-overworld-orb
I dont know what the name of the "player" is and therefore cannot get the playerhead using .setOwner() in the ItemMeta
you have the value
public @NotNull ItemStackBuilder setSkull(@NotNull String url) {
final SkullMeta itemMeta = (SkullMeta) this.itemStack.getItemMeta();
final PlayerProfile profile = Bukkit.createProfile(UUID.randomUUID());
final PlayerTextures textures = profile.getTextures();
try {textures.setSkin(new URL("https://textures.minecraft.net/texture/" + url));}
catch (MalformedURLException e) {Anarchy.getInstance().getSLF4JLogger().error("Invalid skull URL, exception.");}
profile.setTextures(textures);
itemMeta.setPlayerProfile(profile);
this.itemStack.setItemMeta(itemMeta);
return this;
}
Spigot 1.18.1 added the new PlayerProfiles class, which finally allows us to use custom heads without needing any reflection! You can obtain them as normal items, or actually place them down into the world. Iāll show you how both works: Creating a new PlayerProfile First, we gotta create a new PlayerProfile object. To do so,...
thank you I was looking for that
thanks so much
ItemStackBuilder = my custom class!
You need this
// Url texture: 212a03a4c11b4d472472e7e4593d2e126a6259e33cc81f44eb05cf042d076967
public void setSkull(@NotNull String url) {
final ItemStack = itemStack = new ItemStack(Material.PLAYER_HEAD)
final SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
final PlayerProfile profile = Bukkit.createProfile(UUID.randomUUID());
final PlayerTextures textures = profile.getTextures();
try {textures.setSkin(new URL("https://textures.minecraft.net/texture/" + url));}
catch (MalformedURLException e) {Anarchy.getInstance().getSLF4JLogger().error("Invalid skull URL, exception.");}
profile.setTextures(textures);
itemMeta.setPlayerProfile(profile);
itemStack.setItemMeta(itemMeta);
}
.
I submitted the code for version 1.16.5 + if I'm not mistaken
.
PlayerProfile is 1.18.1+
ok got everything
He was still wrong
Yes? setPlaceholders(Player, String)
nuh uh
@rough ibex But I don't know how to use only 1 inventory object but display different data for different players
public abstract class AbstractGui implements InventoryHolder {
private final Map<Integer, Consumer<InventoryClickEvent>> itemHandlers = new HashMap<>();
private final Inventory inventory;
protected AbstractGui(@NotNull String title, @NotNull Integer size) {
this.inventory = Bukkit.getServer().createInventory(
this, size * 9, Utils.parseColor(title)
); this.onInitialize();
}
protected AbstractGui(@NotNull String title, @NotNull InventoryType type) {
this.inventory = Bukkit.createInventory(
this, type, Utils.parseColor(title)
); this.onInitialize();
}
protected abstract void onInitialize();
public void handleClick(@NotNull InventoryClickEvent event) {
final Consumer<InventoryClickEvent> clickConsumer = this.itemHandlers
.get(event.getRawSlot());
if (clickConsumer != null) clickConsumer.accept(event);
}
public @NotNull AbstractGui setItem(@NotNull ItemStackBuilder builder, @NotNull Integer slot, @Nullable Consumer<InventoryClickEvent> callFunctions) {
builder.setItemId(MainConstants.ITEM_MENU_ID); this.inventory.setItem(slot, builder.build());
if (callFunctions != null) this.itemHandlers.put(slot, callFunctions);
else this.itemHandlers.remove(slot);
return this;
}
public @NotNull AbstractGui removeItem(@NotNull Integer slot) {
this.inventory.clear(slot); this.itemHandlers.remove(slot);
return this;
}
public void open(@NotNull Player player) {
player.openInventory(this.inventory);
}
@Override
public @NotNull Inventory getInventory() {
return this.inventory;
}
public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onClickEvent(@NotNull InventoryClickEvent event) {
if (event.getInventory().getHolder() instanceof AbstractGui gui) {
event.setCancelled(true);
gui.handleClick(event);
}
}
}
public class DonateMenu extends AbstractGui {
private final Player player;
public DonateMenu(@NotNull Player player) {
super("Donat Menu", 6);
this.player = player;
}
public void open() {
}
@Override
protected void onInitialize() {
// Decor items.
super.setItems(new ItemStackBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName("&8#"),
0, 1, 2, 3, 4, 5, 6, 7, 8, 36, 37, 38, 39, 40, 41, 42, 43, 44, 10, 19, 28, 16, 25, 34, 47, 51);
super.setItems(new ItemStackBuilder(Material.ORANGE_STAINED_GLASS_PANE).setDisplayName("&6#"),
9, 11, 12, 14, 15, 17, 18, 26, 27, 29, 31, 33, 35, 45, 46, 52, 53);
// Donat items.
super.setItem(new ItemStackBuilder(Material.LEATHER_CHESTPLATE)
.setDisplayName("&4&lGUARDION &f{player} &7- &4&l2578&r ŃŃŠ±Š»ŠµŠ¹ &7(&oWWW.RAGESWORD.RU)")
.addItemLore(
"&4ā &f - &4/ban", )
.addItemFlag(ItemFlag.HIDE_DYE, ItemFlag.HIDE_ATTRIBUTES)
.setArmorColor(Color.RED)
.setAmount(8),
13, event -> {}
);
super.setItem(new ItemStackBuilder(Material.LEATHER_CHESTPLATE)
.setDisplayName("&6&lSHULKER &f{player} &7- &6&l1538&r ŃŃŠ±Š»ŠµŠ¹ &7(&oWWW.RAGESWORD.RU)")
.addItemLore("Lore")
.addItemFlag(
ItemFlag.HIDE_DYE,
ItemFlag.HIDE_ATTRIBUTES
)
.setArmorColor(Color.ORANGE)
.setAmount(7),
24, event -> {}
);
}
}
you can use that player object there to populate the gui with items specific to him
No, I wrote it myself, but something didn't work out
well the example is right there.
change it
add a Player parameter to onInitialize
then use Placeholder api to translate the strings
onInitialize I have it executed when the class itself is created
i can see that
but your design is just flawed
you shoulnt store the player like this
And I constantly create a new object when I open the menu, is it necessary? is it necessary to create only 1 time and then display them differently for everyone?
Should I keep it in the map? Why is it so difficult to understand everything with these gui?
if (args[0].equalsIgnoreCase("kit")) {
new KitsMenu().open(player);
}
if (args[0].equalsIgnoreCase("menu")) {
// new DonateMenu().open(player);
}
if (args[0].equalsIgnoreCase("donat")) {
new DonateMenu(player).open();
}
there is nothing wrong with creating a new class to open a menu
Yes, you noticed correctly, it was a test, I try all the methods by trial and error
instead of this you should call a method that creates all the buttons for that player
like you do here. i assume
I think it's wrong that there should be 1 menu stored in the map and then somehow used, but I don't know how if each menu is a new object, it's also much easier to understand how to update the menu so that it is dynamic
you also should not use InventoryHolders to determine your custom menu
No, it was my very first version
public class KitsMenu extends AbstractGui {
public KitsMenu() {
super("&9Test Menu", 6);
}
public void open(@NotNull Player player) {
super.open(player);
}
@Override
protected void onInitialize() {
// Decor items.
super.setItems(new ItemStackBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName("&8#"),
0, 1, 2, 3, 4, 5, 6, 7, 8, 36, 37, 38, 39, 40, 41, 42, 43, 44, 10, 19, 28, 16, 25, 34, 47, 51);
super.setItems(new ItemStackBuilder(Material.ORANGE_STAINED_GLASS_PANE).setDisplayName("&6#"),
9, 11, 13, 15, 17, 18, 26, 27, 29, 33, 35, 45, 46, 52, 53);
What do I need in order to make a method that will load the player with the necessary items, and in onInitialize() there are default items that do not change?
i dont understand why u would need to seperate that
for dynamic items simply replace the placeholders and for static items dont
And what about loading everything inside at once when creating a class?
dont
And in order to restore the fillers, I will need to create pressure and constantly veto items in the inventory?
Do I need to create a new inventory for the player every time or not? can the new object type be stored somehow?
heavily
@junior cradle in case you're curious why you want to do this in the open method instead of oninitialize, think about debugging in the future. Imagine you have a bug about displaying the items in your GUI. If you set up your code in the open method (which i'm assuming gets called right before the player opens the gui), you'll know for sure that's probably the only place you have to look. Oninitialize, on the other hand, is possibly done far before the menu is opened, so at any point if that menu gets messed with, it could mess up the item arrangement and be extra confusing to debug.
wow
nuh uh
Just think about it as basic getters and setters. dont worry about efficiency since there's no expensive calls here
So just make me open(player) and create items there?
Yep, it sounds like the job of the open method in your case is going to be to set all the items in the GUI--not the job of oninitialize according to Shurkennen
I just thought that if the player will constantly open the menu and a new object will be created, then it will be a death of the same memory type and will not be effective, I thought that it should not be like that
Yes
it really doesnt matter that much
as long as you dont store the Player object in there
Feel free to fact check me, but im pretty sure opening an inventory is not an expensive API call. So you shouldn't need to worry about that
public class DonateMenu extends AbstractGui {
private final Player player; // < - You are about it?
public DonateMenu(@NotNull Player player) {
super("Donat Menu", 6);
this.player = player;
}
yea dont do that
and dont use InventoryHolders to determine if an inventory is your custom inventory
its bad practise
im new to spigot
how can i make a chest gui?
?gui
š
Weather practice? And why should I just take the player that is already in the ``open'' method and transfer it to other methods
what other methods
Not easy
Not certain, but how about the custom name entity metadata field? https://wiki.vg/Entity_metadata#Entity_Metadata_Format
Yep one sec
https://www.spigotmc.org/threads/entity-metadata-packet-format-and-protocollib.522133/#post-4424970 I made a guide a few years ago although IIRC the API has changed a bit. But I think I have the updated code somewhere in an old discord pm ill see if I can find it
It's pretty simple
What version are you on?
Then yeah you have a list of wrapped data values
uH
@iron wraith
private PacketContainer createArmorStandMetadata(int armorStandId) {
PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, armorStandId);
List< WrappedDataValue> metadata = new ArrayList<>();
Optional<?> name = Optional.of(WrappedChatComponent.fromChatMessage("Armor Standd")[0].getHandle());
WrappedDataValue customName = new WrappedDataValue(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true), name);
WrappedDataValue customNameVisible = new WrappedDataValue(3, WrappedDataWatcher.Registry.get(Boolean.class), true);
metadata.add(customName);
metadata.add(customNameVisible);
packet.getDataValueCollectionModifier().write(0, metadata);
return packet;
}
This should get you to the finish line. its creatin ga custom armor stand with a custom name
I wrote it a while ago, but i tested it and confirmed it worked
I think as long as the packet has a custom name and customname visible is true the client will do the rest
uh for players custom names are weird
I just used the BuildTools program in order to create the spigot-1.20.4.jar file. Now how do I decompile this to get the NMS code?
Customnamevisible isn't to hide a nametag, its probably for showing the custom name or the normal name. If players are rendering names differently than other entities however like imillusion suggested, you might need to search for a different packet
But you could try this to confirm:
return new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_METADATA) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket().deepClone();
Integer entityId = packet.getIntegers().read(0);
Player target = getPlayer(entityId);
if(target != null) {
List<WrappedDataValue> metadata = new ArrayList<>();
Optional<?> name = Optional.of(WrappedChatComponent.fromChatMessage("TEST")[0].getHandle());
WrappedDataValue customName = new WrappedDataValue(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true), name);
WrappedDataValue customNameVisible = new WrappedDataValue(3, WrappedDataWatcher.Registry.get(Boolean.class), true);
metadata.add(customName);
metadata.add(customNameVisible);
packet.getDataValueCollectionModifier().write(0, metadata);
event.setPacket(packet);
}
}
};
As for the outer skin layer--that's also part of the entity metadata packet. Probably need to make sure we aren't overwriting that
P.S. you can throw debugger breakpoints in here and get an up close look at the packet if u r curious š
(re: outer skin layer missing) Oh, you don't want metadata null:
List<WrappedDataValue> metadata = new ArrayList<>();
I think would be?:
List<WrappedDataValue> metadata = packet.getDataValueCollectionModifier().read(0);
Hey is it possible to replace the loading plugin message and enabling message
Why
I wanted to add color to make it look nicer
Focus on your plugin rather than an informative message that no one will look at if your plugin is working?
true that's a fair point
Idk I find that the color actually helps to make plugins stand out from each other so I can tell at a glance that everything works
And what happens when every plugin decides to use colours
Suddenly your console is a rainbow and nothing stands out
Then so be it
these custom loading messages are mostly just annoying imo
u find out fast enough if it does not work
by either a big tracktrace or ur plugin showing up red in /pl
I hate it when people use ASCII art. It makes me think a stack trace just exploded into existence
I just thougt it would look nice tbh
Doesn't LP still have a big ascii banner
So is someone gonna help this dude or just say "no don't do that because it annoys me personally"
I mean you can add your own spammy message all you like
But you can't edit the default message
Which functions, amongst other things, to alert you to what executable code is running on your server
Can I place list as value in those special tags that you apply on entities or items?
I forgot it's name
or is it strictly used for more primitive ones such as string and numeric values?
?pdc
^ You can turn any type into a list type
^ You can pet your cat now
So, I got a custom head item with a custom texture. How would I place it as a block and keep the custom texture?
This is the current code:
BlockDataMeta meta = (BlockDataMeta) treasureItem.getItemMeta();
block.setBlockData(meta.getBlockData(treasureItem.getType()));```
Spigot 1.18.1 added the new PlayerProfiles class, which finally allows us to use custom heads without needing any reflection! You can obtain them as normal items, or actually place them down into the world. Iāll show you how both works: Creating a new PlayerProfile First, we gotta create a new PlayerProfile object. To do so,...
what does this require in kotlin?
a string, not an array of an array of strings
we have multiple tho
oh
it's a vararg method so the error msg is a bit confusing / wrong
so then that
i made it a string
oh wait, BungeeCommand is your own class
well you declared 3 constructors,
String
String, String
and
String, String, String
but you're passing 4 strings
a list or vararg?
list
my friend is coding this btw and i dont know kt only java
so im asking for him
then change your constructor to sth like this
class MyClass(name: String, permission: String, aliases: List<String>)
hes nopt in the discord
target entity exists in skript so surely
to string?
you need to change the constructor of the other class
wdym
this is in bungee cmd
one of the raytrace methods in world https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html#rayTraceEntities(org.bukkit.Location,org.bukkit.util.Vector,double)
declaration: package: org.bukkit, interface: World
are you extending net.md_5.bungee.api.plugin.Command ?
this is kt
I know
class MyClass(name: String, permission: String, aliases: List<String>) : Command(name , permission, *aliases.toTypedArray()) {
*aliases.toTypedArray() turns your list into an array to be used with the varargs method
yo is this the clown from CosmicReach who didn't recognize me
what a loserrrr
CLOWN
frfr
hello i search a way to create a api endpoint into a plugin to receive some information there send from a website
The heck is CosmicReach
thanks!
com.sun
Off to a great start
what's wrong with it
Hey if I was storing player warps do you think it should be under the playerData or global data?
Well the API is JDK-specific basically https://docs.oracle.com/en/java/javase/21/docs/api/jdk.httpserver/module-summary.html
Which is in layman's terms means: The JDK people reserve the rights to break everything at will
They've already butchered my beloved sun.misc.Unsafe, so I'd not be surprised that the "there is already public API out there trolololol"-Virus halts there
Fork spigot and CTRL F every private to public and every final to nothing
Boom no more unsafe needed
Well usage of the unsafe goes a bit beyond that
I personally don't use it for anything beyond static final field manipulation, but some of the libraries I use use it for some impressive things
We should just ban Mojang from static final immutable collections
Use a registry smh my head
we should just ban mojang in general
they still haven't added baboons
what even are they doing all day, if not adding baboons
Letting me annihilate the wither with a big cube on a stick
or schnitzel
Yes
well, create is relatively new and massive
Stuff that adds like 50 blocks and entities