#help-development
1 messages Β· Page 310 of 1
does not compute
getPlayerGroups(player)
.map(g -> new Group(this.config, g))
.sorted(Comparator.comparingInt(Group::getPriority))
.forEach(
group -> group.isWhitelist() ? commands.addAll(group.getCommands()) : commands.removeAll(group.getCommands())
);
@compact haven you mentioned ternary operators, i thought i'd give it a try
unfortanetely...
Wrap it up in arg -> { <code goes here> }
^ that's because addAll and removeAll actually return a boolean
and the type is Consumer<Group, Void> or smth similar
Just Consumer<Group>
yeah, i just didnt know how to fix it
it can't be a consumer<void>
sorry mb, Function<Group, Void>
or Supplier<Group>
whatever the fuck it is
You confused the heck out of me
LMAO
its Consumer<Group>
Supplier takes in no args and returns the type
not a statement
yeah I know, I realized after I sent it
Consumer takes in the arg and returns void
should i assign it to smth?
semicolon
f*ck java
ternary is an expression, it should be returning something
yeah just don't use ternary in this case my friend
but anyways, what is the whole stream?
honestly no point in using streams if u have it like that
try and engineer it to be 1 whole stream
thats impossible unless there are functions i havent heard of before
and couldnt find
walk me through the logical process
I'm using this method to send a message to a player using ChatComponent API but the API generates a line break between every chat component, how do I cancel it?
//Sends a message to the player using ChatComponent API
public static void stringToTextComp(String message,Player recipient){
ComponentBuilder builder = new ComponentBuilder();
String[] split = message.split("%");
for(String s : split){
if(s.length() == 0) continue;
TextComponent text = new TextComponent(s.substring(1));
text.setColor(fromCodeToChatColor(s.charAt(0)));
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/helloworld2"));
builder.append(text);
}
for(BaseComponent textComponent : builder.create())
recipient.spigot().sendMessage(textComponent);
}
Set<String> commands = new HashSet<>();
getPlayerGroups(player)
.map(g -> new Group(this.config, g)) // cast it to a `Group`, contains fields (name, priority, isWhitelist, commands)
.sorted(Comparator.comparingInt(Group::getPriority)) // sorts all the groups based on their priority
.forEach( // loop over the groups, if isWhitelist, add the functions, if not isWhitelist remove them
group -> {
if (group.isWhitelist()) {
commands.addAll(group.getCommands());
} else {
commands.removeAll(group.getCommands());
}
}
);
i need a second set to manipulate, rather than the stream
unless i can do it recursively maybe lol
idk
comments unnecessary but do need the other stream
the plugin im reading the config from, allowes blacklists, whitelists and a priority for each group (so if someone has two or more groups which collide, like one group blacklists the command, but the other one whitelists it, then the priority is taken into consideration)
well from the code in the ss
it seems commands is used not
like you manipulate it but the returning stream doesn't use it
ohh yeahh
because i was still editing it
it should be return comands; at the end
dammit
i forgot to edit it before the build
how would I check if an item equals this item ItemStack sword = ItemStack unranked = new ItemStack(Material.IRON_SWORD);
ItemMeta unrankedItemMeta = unranked.getItemMeta();
unrankedItemMeta.setDisplayName(ChatColor.RED + "Unranked Queue");
unranked.setItemMeta(unrankedItemMeta);
#isSimilar would be better, applying a pdc tag is even better
Im trying to add org.apache.commons.net.ftp.* to my Eclipse project, and I see what I can add it in plugin.yml under libraries but not sure exactly how to put it there? Does anyone know I can add it in?
yeah I sure tried @zinc egret, there's no way I can think of to make it 1 stream
even with bullshitting some of the functions not meant for it, u cant because a stream is an Iterator internally, and no method allows you to backtrack
I've made a few of my classes ConfigurationSerializable but when I save them to the default config, my classes are being prefixed in the file with :== my.package.my.Class . Is there any way to stop that happening? They load in fine without that annotation.
without it the config doesnt know how to deserialize it
but you have to pay for citizens right? :C
nah
yep
As I say, without the annotation, my class loads from the config just fine.
is that legal?
its probably some jank (craft)bukkit internal
oh lol but why is it on spigot so expensive
fuck knows
ok thank you
bump
You pay for support
if i pass YamlConfiguration into one of my commands and then use reloadConfig from another command, it doesnt update the YamlConfiguration i passed to the other command
what should i do?
pass plugin to the original command, make a reloader config function in the original command class, etc...?
Objects in java are passed by reference, so if you reload configuration you passed trough Di or smth, it will be reloaded
maybe it doesnt work bcz it got cast or smth?
Reloading it would create a new YamlConfig from the file
alright π thanks
what event should I be listening for when a player tries to open a smoker?
interact event
ahh makes sense thanks
check if the action is right_click_block also
π€ wait, what if they use the smoker in the hand
they can only right click it as a block
good thought, hmmm I will cross that bridge when I come to it
guys how i can stop death screen?
stop in what way
on death event
how much tick?
Hey,
I have a small problem. I made myself a custom ShopItem and ShopItemList class to handle the Items I save in a YML file for my shop Plugin. In the ShopItemList I have an ArrayList I always refresh from the file when calling the constructor.
I thought can now use it and when showing the items an in inventory I change the lore of the items so the price is shown and because I call the constructor nothing is going to be saved until I call the save() Method which I am not calling when just displaying the items.
A a CommandListener I want to be able to add new Items. So when I enter a command, it calls the Constructor and saves it to a variable. Now it adds the Item the admin has in his Hand with a add() method and than calling the save() method to save it to the file.
But now the Problem. When opening the display inventory before adding a new item, to all before added items the lore.
What am I making wrong?
1 tick
thx
If you're on 1.15+ you can use the doImmediateRespawn gamerule
can you reword your problem, I can hardly read the sentence. Do you mean you need to add items to the inventory before displaying it?
ok, π
I have a costum List Handler with some methods to edit the list like add, get, remove, save(). When creating a new Instance of the Handler the List is newly gotten from a yml file. when calling the save() method, it is saved to the file.
Not when the player enters a command I will create a new Instance of the Handler and show him the Items. To display some data I add a lore to the item meta. But this List is not going to be saved.
When the Admin enteres a command, a new Instance of the Handler is created and the item he has in his main hand is added to the list and after that I call the save() function.
But now when I look into the file, the lore I added when viewing the items in the inverntory is save eventhough the lists have nothing to do with eachother.
How do I get the code of a ChatColor?
I assume spigot formats it as something like : ChatColor.BLUE +Hello World = %bHello world, how do I get that '%b'?
getChar will? or toString?
ChatColor.toString()
assuming you are using bungee version of ChatColor I guess
probably bukkits version too
I see, it's very hard to debug since it doesn't show in chat, is there a way to print the string as color code+text instead of the actual colored text?
System.out.println() would work
it doesnt seem to like that i am passing a string to that function
xD
any Idea?
you didnt listen to what you were told
lol
Bukkit.getPluginManager().getPlugin
yes, I would just save the material names and save/load teh actual items that way
sometimes code does very weird things xD
thanks π
well i didnt get told about the Bukkit.getPluginManager part (i had never heard of it)
sometimes you tell your computer to run the wrong calls and assume it's just weird
shouldnt you already know your plugin name in your own plugin class π€
or have the plugin instance
namely this
I did that before but now I want to save the whole ItemStack with alle the data with it.
i said PluginManager#getPlugin
if not what other data do you mean
yes and i actually tried PluginManager#getPlugin(name) thinking it was just something i just hadnt heard of before, but you just meant call getPlugin on an instance of PluginManager
thats javadocs notation
im only reading parts of the messages people sent me
no, It does it but I don't want it to. I don't even know why it is doing it. It seams like one ArrayList in the Handle is shared between multiple Instances of it. I don't want this ether.
I also don't know why he is event saving the lore to the list because I also never want this to happen. everything is broken
yea, I will ?pase it here
?paste
yes
yea xD
How to achieve something like this? https://www.youtube.com/watch?v=BfhMvNNBzKE
These aren't maps
ShopItem:
https://paste.md-5.net/quhiwuruze.cpp
ShopItemList:
https://paste.md-5.net/jirehuhupo.java
It's also not resource pack and vanilla only
how do you know they arent maps
How do you know it's not maps?
They aren't having this animation
When you break them
I'm using String.split to try and split a String containing ChatColor like so:
String[] split = message.split("\\?");
Why am I getting [?aHello World ?eYellow World] (length=1)
On the input : ChatColor.GREEN+"Hello World "+ChatColor.YELLOW+"Yellow World"
They also don't hide when you look in other direction
well you are seriliazing the whole itemStack so it will also save any lore at that point
what animation
Maybe there's a setting in Minecraft to keep them on?
I don't think so
It's vanilla
Particles when you break map
those are maps
when he's using shaders so he has optifine.
maybe because it is not spliting
so im asking if maybe there's an option for maps
Even if it's he is not using it
you try to split at a \ but maybe there is no \
I atleast think so
Yeah it's not, but why?
yea, but I never save the lore to the array of ShopItems
where do the question marks come from? o0
if you use ChatColor toString, it would use Β§ and not ?
Its the code of the ChatColor
Oh what
where do the double // come from
to escape the question mark operator
It works on vanilla
you should just split by Β§
And these aren't maps
oh I didnt know strings had a ? operator xD
The guy killed all entities
strings don't, that's regex
String#split(String) takes a regular expression as argument
Oh that works, thanks !!
Why did it print question marks though ? π€
np! probably your terminal couldnt display UTF8 characters
I just used system.out.println
I am unfamilliar with any way of doing this that doesn't involve maps @tardy flame
or mods
It is possible that this plugin is just very, very clever, but I highly doubt so
https://paste.md-5.net/jacesekise.cpp
Hello PEOPLE, This code is what I use to change what a player looks like into an entity and it has been working nicely in OW
but going to the nether it seems to not work? This is executed on PlayerChangedWorldEvent to refresh both players in Nether and the Player joining Nether and if the disguised player walks in Nether first then refreshed when someone joins him it doesn't work. but it does work when the disguised players joins after other players join. is there any logical explination for this?
It's not even plugin
@tender shard Hey again. Do you have any idea what I am doing wrong?
Friend of mine did it
What would it be then?
And they wrote this in skript
And they say it is a Minecraft feature from 1.8+
That's in the game
Using some packets
Oh then it is likely maps
A Datapack?
can you show code of when you are showing teh inventory to the player? and the add mthod you talked about
send server ip
They are using shaders for showcase
Just that the maps are a bit different than what you are familiar with
Not public yet
ok
That looks like maps
He said that this block is just a normal block
So I assume they render something on them
But it can't be map
You can overlay a map on it even if the server is not familiar with it
Why not?
Clientside entities are a thing
why dont you just ask them how it works lol
They don't want to share it
They said that it's not used anywhere else
so then you are just playing a guessing game?
Yeah
Could you use them like that?
Drawing stuff on maps without direct protocol access is a death sentence
They defo use maps but do the entire drawing pipeline themselves.
Fun fact: this is the reason LWJGL is an optional dependency for minestom
are the blocks any thicker than the other ones
Then 100% maps
Pixel before
i wanted to run minestom and then i realized i got exams
so its maps
But it's not maps
@pseudo hazel
ShopItem:
https://paste.md-5.net/quhiwuruze.cpp
ShopItemList:
https://paste.md-5.net/jirehuhupo.java
Showing Items in inventory:
https://paste.md-5.net/ayukehuqez.cs
Shaving new Item:
https://paste.md-5.net/ezibarovuh.coffeescript
how is it not maps
It's fake maps
I have no idea
Wdym?
The maps are not on the server
But are simply sent directly into the netty pipeline
Only the client and plugin knows about them
remove the datapack from the world and try if it is still working
There is no data pack sire
The datapack wouldn't be able to do anything
bump #1063929625056661524
And maps were changed in 1.8 to be more useful, so it explains his 1.8+ constraint
He still says that it doesn't use any maps
Any other feature such as shaders would require post-1.14 features
Then he is lying
yeah he can be just lying to advertise something that doesn't exist
wait till he opens server and u can look at it yourself
Yeah I will
whats the point of that ShopItemList class?
since you are adding the item from the players hand into the shoplist, it will copy all the items data, including lore
just to manage the List
makeing it easier
WAIT, you are right but I thought I had no Items with lore in my hand. Where are thy from ?
why not using a List<ShopItem> then?
because I need it in much more classes so it is easier
I need it in multiple commands and Listender classes
a list of shopitems instead of a shoplist isnt gonna fix the issue
anyways, where is the lore being used
probablt want a Map<ItemStack, ShopItem> then, dunno itemStack::equals impl is good but whatever
is there like an inventory gui or what
those are so fun to code
I display the items in a inventory gui yes
can you show the code for adding those items to the gui, since thats also where you would need to get them from
arent you better off with storing a pdc tag in the items itemmeta and then using that to retrieve the ShopItem?
the code where I add the lore is in the paste
the rest is opening an closing the inventory
and the showing is not the problem but saving+
now it is working but I still don't know how the items with the lore came in my inventory at the same slots as I had the other before
well yes but you say thats the only source of the lore these itemstacks must actually be the ones that get saved at some point
wait its fixed?
I think so
I had the Items with the lore in my inventory and I didn't notise
I have no idea how they did get there
so I always safed them with the lore from ly hand xD
lol
yes xD
you probably at one point forgot to lock the items in the inventory you shown
by like not cancelling inventory events
Does client map have witdh?
ne, it is a admin view so the item should be given to the admin when clicking on it. but there is still the bug that the lore is given too. But I did never click on an item I think
he's not showing it working in that pic tho
as in what?
a client map still shows just the model of a 3d map model in the game
As the normal map if you look it from an angle you will see that it's bigger than block it's placed in
And on this map you don't see it
Or whatever this is
But it surely doesn't look like map
he's not showing it working there tho
why doesnt OfflinePlayer have hasPermission
so in my plugin i am setting a block with this code
loc.getBlock().setType(oakLeaves, b);
Context:
Location loc , gotten when method that code is in is called
Material oakLeaves = Material.OAK_LEAVES
boolean b = false
problem is that i am setting the applyPhysics option to false so it doesn't update observers ..... problem is that it's still doing it and i have no clue why
most events have an iscancelled method with a boolean return
The real problem is that the item in my inventory is replaced with the ine with the lore when opening the inventory gui, I don't know how this happened but this was all. xD
just went to check an event and it didn't have it, werid
why do u need to set it as false?
so that the block won't update an observer and other stuff around it
how does your ShopItemCreator work?
How do I create a list of type net.md_5.bungee.api.chat.hover.content?
I mean how do I create the object itself sorry
Any NameTag API?? without nametagedit?
instance one of its subclasses
i.e. Entity, Text, etc
since its abstract you cant directly instance it unless you make an anonymous or actual class
Ahhh I see, how did you get it's subclasses?
its on the docs
If that's actually a map, it makes use of some orthographic projection to create this feeling of depth. This would be possible, but I don't know whether you can get it to look as good as the game does. It's still a 128x128 canvas. You could tile multiple of them together to create something similar tho.
making teh itemframe invisible makes the map have a razor-thin border
it's basically just a 2d image
How can I check if player have an advancement?
Google your question before asking it:
https://www.google.com/
declaration: package: org.bukkit.entity, interface: Player
?jd-s
^^
I try to find out if it client limit, bug in spigot api or how i use it. The problem:
Seams you can't do #undiscoverRecipe() and then #discoverRecipe() that combo only works when player join server not when he is on the server.
The problem is it remove the recipes fine, but when it shall force player to learn it not work so long he is online on the server (it bug out) and if you make the recipe without help of the green book it never get added to the book.
And when google on anything recipe relented, seams like all hate the custom recipe system (no info anywhere). I have try on 1.19.3 and i think this "bug" will persist for long time (seams no one care about fix the recipe api in bukkit/spigot). If that not are intended behaviour.
Thanks
I like how I've been using spigot API for 2 almost 2 years now and still have no clue wtf period and delay mean in the Schedulers so I just brute force the numbers until I get the desired result
yeah I know that
runTaskTimer, the delay is before it runs, the period is how often it runs
okay ππ½ bless
hello I'm Miles
Hi everybody guys, is possible to block blocks breaking from tnt explosion but keep damage from those?
Sincerely i would do something like that with every type of explosion but i don't know if is possible
Hey I'm looking for a specific piece of lore in some ItemMeta but I'm not sure how to do it without causing a NullPointerException, any help?
public void onRightClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
List<String> lore = p.getInventory().getItemInMainHand().getItemMeta().getLore();
if (lore == null) { return; }
p.sendMessage(lore.get(0));
}
ItemMeta is null if the item is air
I'm only looking for a right click with a specific item, not just any item
So check if it has item meta before using it
do a check for the item and check if item in main hand is AIR and return
Better to check if the item has item meta
This is the part causing errors so I'm not sure checking it after would really help
1am moment
aaauu
id better go to bed instead of this nonsense
the docs are your answer to everything
yeah i couldn't find as much info as i needed about this lol
idk maybe i'm just being dumb
Same, Good Night 
gn man
π
? check if it has a meta and a lore
I fully agree, this should easily work
Canβt cause a null pointer if this is checked before
thats what im tryna check in that line?
im outta here
the meta stands a chance to be null
no, thats you
if (!item.hasItemMeta() || item.getItemMeta().getLore().isEmpty()) return;
oh ok
Use hasLore
thats a method?
thats a method?
well it is but it still causes the same problem
"ah yes, my boolean function will return null"
if you have the null item meta null check first you wont get it
I think the error is actually talking about the item meta
if (!i.hasItemMeta() && i.getItemMeta().hasLore()) return;
you need to invert the 2nd
oh yeah woops
if i doesnt have item meta it will fail teh second check doesnt it?
ah right
okay that makes more sense
its too late for our brains to brain
meh it's fine
it's still throwing warnings at me but i'll test it anyway
intellij isnt smart
and ij probably complains because you dont explicitly check for if the itemmeta is null , but using teh hasItemMeta is good enough
it doesnt know that your checking the thing that you use next
yeah it worked
thanks
i only asked because i've had this same issue before and i'm pretty sure my previous "solution" was a try catch block π
Trying to emlulate slow falling but with a boots enchantment, I'm using this code to slow the fall however it also impedes natural horizontal movement. Any suggestions how to improve it?
Vector v = e.getPlayer().getVelocity();
if (v.getY() < -0.3) {
v.setY(-0.3);
e.getPlayer().setVelocity(v);
}
why not apply slow falling when the player has the boots on
you can hide the icon iirc
and the particles
It felt cheaty I don't know how to hide the effect
imo this feels more cheaty
i dont remember how to hide the effect but im sure there was a way
theres no such thing as cheaty, but thats definitely a much more janky way of doing it
create the effect with https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffect.html#<init>(org.bukkit.potion.PotionEffectType,int,int,boolean,boolean,boolean)
declaration: package: org.bukkit.potion, class: PotionEffect
then just apply it to the player
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
?cc
What would you use to send text to a player above their hotbar?
Itβs called the action bar
?ecosia
Ecosia your question before asking it:
https://www.ecosia.org/
how to fix??? the args doesnt work
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
oh
Why are you trying to import that
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I'm shocked your IDE even suggested importing those
im using onCommand and it suggested importing it
IJ suggests them at the buttom if at all
i used intellij
it's telling u that u are not putting @urban grotto on them not to import stuff
o
Your command should work fine. The unused imports you have can be removed. If you have to import anything from sun.*, you're probably doing something wrong
Hey guys, i always used breakNaturally() method without any problems, but today i was trying to use it with a pressure plate and it didn't work, setType() also didn't work. The objective of the code is to create an explosion after steping on the pressure plate, and that part is working, but after that the pressure plate just stays floating in the air (really don't know how), that's why i'm trying to force it to break or set the type to AIR... The code is super simple:
@EventHandler
public void test(PlayerInteractEvent event) {
Block block = event.getClickedBlock()
if(block.getType().equals(MATERIAL.STONE_PRESSURE_PLATE // and some other conditions) {
block.breakNaturally()
// do some other stuff, create explosion
}
}
Sorry, i didn't think it was relevant, since everything is working except for the breakNaturally part, i'll get the full code
nothing
send a pic of it floating
I also need some reassurance that you actually make it to that statament.
I'm sure because the explosion part of the code is just after the breakNaturally method call
Idk, try waiting a tick
The logic is inverted on my code, but it behaves the same way. Also i tried putting the breakNaturally method after the explosion but it had no difference
@EventHandler
public void onStepOnPressurePlate(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
if(!event.getAction().equals(Action.PHYSICAL) || !event.hasBlock()
|| !block.getType().equals(Material.STONE_PRESSURE_PLATE)
|| !block.getRelative(BlockFace.DOWN).getType().equals(Material.GRAVEL)
) {
return;
}
block.breakNaturally();
block.getLocation().getWorld().createExplosion(block.getLocation(), EXPLOSION_POWER);
}
You tried a tick after?
with the bukkit scheduler?
yeah
does it make any difference? I'm not a java dev i really don't know
oh god not this again
not particularly, unless you override the default equals method i believe
It doesn't really, but it's a good habit.
^
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
() -> {
block.breakNaturally();
block.getLocation().getWorld().createExplosion(block.getLocation(), EXPLOSION_POWER);
}, delayInTicks);
Good to know ty
That worked! thanks a lot guys
Why did i need to wait this 1 tick for it to work?
π€¨
events happen before it the action sometimes it's weird.
lol now i don't even need the breakNaturally, the explosion is now breaking the pressure plate
IntelliJ fucks up every now and then
its not not often i get suggested sun classes or even the completely wrong String class
Haven't really had that in ages, though I also have copilot
I have little problem with HoverEvent. My code is this:
TextComponent message = new TextComponent(ChatColor.GREEN + "[" + "JAJ" + "]");
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Tohle je nΔjakej text").create()));
linkedAdvancement.put(PlayersAll, advancementName);
PlayersAll.sendMessage(prefix + ChatColor.YELLOW + ChatColor.BOLD + "TvΕ―j advancement je: " + message);
And I am getting result on the picture.
Player#spigot is what?
I used Player.sendMessage(component);
ok
I will try it
Hey. I am spawning a chest with a custom name and want to add items to it.
Somehow this isn't working, can someone help me with it?
Block chestBlockLocation = chestLocation.getBlock();
chestBlockLocation.setType(Material.CHEST);
Chest chest = (Chest) chestBlockLocation.getState();
chest.customName(Component.text("Β§cMeteorite"));
locBlock.set(blockX, y2, blockZ).getBlock().setType(chest.getBlock().getType());
chest.getBlockInventory().addItem(new ItemStack(Material.STONE, 1));
chest.getBlockInventory().setItem(2, new ItemStack(Material.STICK, 1));
chest.update();```
No errors, but there isn't a item in the chest :o
One more question, how can I connect two Text components together in one message? Because + doesn't work
ok
using paper api but still doing colors the old way π
What exactly do you mean? :D
not even
the Adventure components have styling and coloring methods
with like NamedTextColor
What do you mean with that? ^^
Oh I see. It's a function that places blocks, everything works fine, only the items are not going in the chest ^^
I can send you the whole method code, if you want :)
exactly yes
It's spawning, with the name and where I want it, but no items :o
Yeah, it's really messy, but I will update it :D
It's just so I get an rough idea how I want it to look xD
ew
Whats the best way to make blocks invisible for a single player, temporarily?
I know i can use sendBlockChange, and store all the blocks, but that seems really inefficent, and doesnt feel ideal.
All ideas are appreciated :)
That's ideal.
It is ideal tho
declaration: package: org.bukkit.entity, interface: Player
Oh wow, thank you ^^
didn't knew that I wouldn't need it, don't even know where I got that line of code from :D
chest.customName(Component.text("Meteorite", TextColor.fromHexString("#FF5555")));
chest.update();
locBlock.set(blockX, y2, blockZ).getBlock().setType(chest.getBlock().getType());
chest.getBlockInventory().addItem(new ItemStack(Material.STONE, 1));
chest.getBlockInventory().setItem(15, new ItemStack(Material.STICK, 1));```
Now it's working :D
Are those Components also used in spigot or is this a paper only thing? ^^
theyre part of paper through Adventure api
spigot has its own components but theyre not as integrated with the api yet like paper iirc
Ah okay good to know, thank you! ^^
choco has gotten a lot done though π₯³ for progress
Sorry got another completely different question :D
When creating a custom minecraft item, with a custom texture and I want to use CustomModelData what Item is the best choice to use for that. CustomModelData works only on usable items right? So like a carrot on a stick for example or is there a better item to use for it?
you can use CustomModelData on any item
I keep meaning to finish it
I want to eventually pr changing inventory titles
Oh wow really?
Didn't knew that, the last time I used it or the thing that was before it is a long time ago.
Then I should take a look back into it :)
We have an issue where we try to teleport two players to an Area, but when the teleport triggers, that server falls behind and eventually times out the player.
Any ideas?
player.teleport(team.getId() == 1 ? locationA.toBukkitLocation() : locationB.toBukkitLocation());```
what is toBukkitLocation()?
any errors ?
No errors
@hazy parrot, any ideas?
π€·ββοΈ
run a spark profiler to see whats going on i guess
We've run a timings report on the server and that's how we got to narrowing down this command as the issue.
can i see the report ?
Here it is (https://timings.spigotmc.org/?url=ugonulevor)
guessing the teleport line is inside onGameStart then ?
yea, cant get much wiser from this. i think you guys will benefit from running a spark profiler
Here it is (https://spark.lucko.me/5FmZ0tRQCX)
looks like its stuck loading the chunk
looks like ur making some sort of practise pvp plugin
you should probably load the chunks beforehand
Hey! I need some help
How can I use PersistentDataStorage to store a list of strings and respective ints. I need to create a primitiveDataType but that's the part where I'm completely lost. I can't seem to wrap my head around how this works
well what have you got so far.
I've gotten a fully functional code which allows me to store PersistentData with a string and a int
But only 1 element
Trying to scale to multiple strings and matching ints
so ur storing an object that contains a String and int?
and now u want to store a list of those?
Yes, exactly
According to this https://www.spigotmc.org/threads/a-guide-to-1-14-persistentdataholder-api.371200/ I need to create a primitiveDataType to go with this
u can just create a custom persistent data type that takes an array of your object
Currently I'm using the PersistentDataContainer.set() method which takes
set(NamespacedKey key, PersistentDataType<T,Z> type, Z value)
And i'm using PersistentDataType.STRING
but
Hold on
Read this
I'm using 2 different keys, since it's only for a single item it's no issue.
example: I'm using string for the name and amount for the amount.
I don't mind using those 2 NameSpacedKeys but I need to be able to string String[] ( or similar ) and int[] ( or similar )
Ideally just use 1 key and contain a datatype which has <String[],int[]>
but that seems even harder
hmm let me write something up for you
Don't put too much into it I like figuring things out this just seems to be way more advanced than what I know
Like I've been lost for hours
Appreciate it β€οΈ
yea. il just show you how u could do it
im guessing he wants a key - value thing tho
Well for me it's quite hard at the moment. I'm just having trouble figuring out the PersistentDataType<>
I do want a key value
String - int
in a list
ya
even if it had to be key value
still wouldn't be hard
you would use a key that would be easily to tell it belongs for another data
Actually just thought about something now I need another field to add to that
Specifically a UUID field
Wait let me rephrase that
I need a UUID[] String[] and int[] for each
I started creating a class to then use as my data
you could also consider just using this cool lib my mfnalex https://github.com/JEFF-Media-GbR/MorePersistentDataTypes
Much rather learn to do it myself than use a lib
Although it seems insanely quick
fair
I won't give up just yet
anyway. one way you can do it. is to create your own Persistent data type
public class SuperCoolPdcType implements PersistentDataType<byte[], SuperCoolObject[]>
{
@NotNull
@Override
public Class<byte[]> getPrimitiveType() {
return byte[].class;
}
@NotNull
@Override
public Class<SuperCoolObject[]> getComplexType() {
return SuperCoolObject[].class;
}
@NotNull
@Override
public byte[] toPrimitive(@NotNull SuperCoolObject[] src, @NotNull PersistentDataAdapterContext pdac) {
// convert to byte array
}
@NotNull
@Override
public SuperCoolObject[] fromPrimitive(@NotNull byte[] bytes, @NotNull PersistentDataAdapterContext pdac) {
// convert byte array back to array of your custom object
}
}
Yes that's exactly what I'm doing rn
the obj being something like this
public class SuperCoolObject
{
String string;
int numba;
public SuperCoolObject(String string, int numba) {
this.string = string;
this.numba = numba;
}
}
sure
Wait real quick
Why not use String[] in the object?
And use it in the <byte[], SuperCoolObject[]>
i mean. u can but then ur storing an array of your object containing an array of strings
Can I remove it from <byte[], SuperCoolObject[]>?
So I only store 1 object?
Or is that a bad idea
i mean. then u still dont achieve ur goal right?
1 object with arrays of stuff inside
then u might as well just store a list of string and a seperate list of integers
1 sec
public class ItemInformation {
private List<String> itemName;
private List<Integer> itemAmount;
private List<UUID> playerUUID;
public ItemInformation(String[] itemName, int[] itemAmount, UUID[] playerUUID) {
this.itemName = new ArrayList<>();
this.itemAmount = new ArrayList<>();
this.playerUUID = new ArrayList<>();
}```
implements PersistentDataType<byte[], ItemInformation>```
@tall dragon
uh. but i mean how do you know which amount belongs to which name
That means I can access all 3 lists using just 1 namespacedKey no?
Alright so the way it's working is
wait I need to clarify this in my own head
I'm gonna draw
So confusing
Alright @tall dragon
Apologies for this
thats ok
Don't blame the angle
I think the way I'm saying it would work
In this case the unique identifier for each object would be it's location since no 2 items can be at the same location at the same time
Right?
prolly better if you first tell me what ur even trying to create
Infinite Storage of 1-9 unique items
If you wanna hop in a call I can show you what I've got so far
ok
why do we need pdc?
hes storing those items in a "special chest"
items?
So we got items, being stored in a special chest, got it so far
and what is the goal?
yea bassically hes making a plugin that can store up to 9 different items with unlimited amounts
inside a special chest
so for example 5k cobblestone
store pdc on the items to make them infinitely stackable basically overriding the minecraft system seems like best way to do that
hes not tryna override the minecraft system tho
it should only stack like that inside the chest
not sure if you are going to get the items to stack like that
he just has a menu to take like 64 items and some other options i believe
oh so now there is a menu involved
π
how else would you do it? Overriding the mc stack system makes sense otherwise you get desync with client and server
with amounts above 64 ofc
if we have a menu why we worrying about pdc again?
wouldn't it be best to serialize the ItemStack
not really
what if it has custom data
best way is to just record overall amount and how much has left, subtract from amount being recorded
until it reaches 0
can you add custom menus to chests? I've always serialized the contents of my custom menus
i personally don't rlly like pdc for this kinda stuff either
i just use it to tag entities
I am a very big fan of using DB's lol
mainly because I have to use one at some point anyways
therefore, why clutter my world files with a bunch of data when I can just use a DB
also, I have been curious
mainly because i suck at writing sql
if a plugin gets removed, does the server know to remove the relevant pdc the plugin created?
another reason I wouldn't use it then or recommend it
Frostalf I am making regenerating blocks, and when chunks unload I'm saving the data, rn I am saving the data to the pdc of the block using mfnalex's api, its just 2 long values time left and time saved, would you rec a DB.
yeah its like a layer
blocks can't actually have pdc. I'm pretty sure the api just adds it to the chunk internally
you can use pdc for this, but personally I would probably just have an nbt file for this that contained the relevant information for the block but I don't know enough of what you have going on. Are all blocks able to regenerate or just certain ones?
just certain blocks from my plugin
NBT file?
I thought all pdc did was add to NBT data
yeah, you can store an insane amount of information in an nbt file
a file that uses NBT
store it in binary 
hmmm how would I go about doing that / managing that? never used NBT files before
Anyways, some years ago I helped someone create a creative control type plugin. It saved all the data of any blocks touched/modified by those in creative
anyways, the data was saved using NBT
using memory mapping, and about 1GB extra ram to load the file
we got it to load 10million blocks of information in about 6 seconds and it saved it in 3 second
you would use something like JNBT and you would use MC's structure for NBT and save the data to your own file
similar to how worldedit uses nbt to create its schematic files
would I make a wrapper for a block or something?
woulnt just storing a byte array be faster?
I honestly don't even know much about MC's NBT structure
nope
oh disregard then
Now I'm trying to serialize and deserialize
package me.tomisanhues2.deepstorage.utils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class ItemInformation implements Serializable {
private static final long serialVersionUID = 1L;
private List<String> itemName;
private List<Integer> itemAmount;
private List<UUID> playerUUID;
public ItemInformation(String[] itemName, int[] itemAmount, UUID[] playerUUID) {
this.itemName = new ArrayList<>();
this.itemAmount = new ArrayList<>();
this.playerUUID = new ArrayList<>();
}
public List<String> getName() {
return itemName;
}
public List<Integer> getAmount() {
return itemAmount;
}
public List<UUID> getUUID() {
return playerUUID;
}
}
it would be about the same. The problem most encounter with say yaml and trying to do the same thing, is that when you memory map the file, the OS has to translate everything into binary which can take some time. NBT is already binary, therefore no translating needs to be done.
ah yea. fair point
so I can use JBNT I got that, but how would I map a block to NBT or whatever. I don't know where to begin there, or even how to use minecrafts structure
look at how worldedit creates schematics
also where would I store the NBT file just in my plugins data folder
sure, not sure where else you would want to put it
Why are you messing with NBT if you want to use Structures?
I think you misread that
Question frost, what's the difference between using PersistentDataType as byte[] and NBTTagCompound
One is the object type the other is binary form of the type
Any benefits of one or the other? Is it this that you said?
I haven't looked at worlds edit code cuz I couldn't find it yet, but do you need to asynchronously load data from NBT files like something like sqlite or is all the data loaded into memory
well not sure what exactly the benefit would be to using a byte array yourself as opposed to obtaining a NBTTagCompound in regards to PDC since it has its own structured layout. But some advantages however in using a byte array could be, faster reading depending how you loop. You can use bitshifting with byte arrays which can really speed things up if you know what you are doing. They are a smaller memory footprint. All things you really don't need to worry about unless you need to
memory mapping is part of the NIO package in Java
In that case would implementing with NBT be simpler than byte[]?
so with memory mapping you have 2 options to load files
you can either load the entire file all at once, recommended way to go for small files which yours will most likely will be
or you read through it as needed
so you would create like a buffer that dictates how much of the file to load at a time
is this the correct JNBT lib? https://github.com/Morlok8k/JNBT
if so do I need to shade it or does minecraft jar already do so
nvm legit says its a fork
smh
how do I obtain the JNBT dependency do I need to manually install the jar from somewhere
worldedit also has JNBT
but theres is slightly different and tailored to worldedit
anyways, you would shade JNBT into your plugin
minecraft has NBT too, but doesn't use the same names I don't think
Hey forst, sorry to bother but I'm still not able to figure out how to serialize and deserialize my object for PDC
JNBT just lets you use NBT without having to depend on NMS for NBT utilization π
not sure how you are serializing
you could just base64 it and just store that lol
Anyone know about persistant entities being saved when chunks unload?
I want to save their UUID and for certain entities delete them when they load back in but its acting like the uuid changes or somthing making the entity undetectable?
lol so much PDC stuff tonight for some reason
weird, UUID's shouldn't change for the entity
even though technically entities die when they unload
but I don't think that would be the issue at hand
so to make sure I'm getting this right. I essentailly create a .nbt file or whatever extension probably doesn't matter and load it with the in and out stream and save all my block data to that file? also NBT is a key value storage system? so I can store blocks location as a key and the data as the data pertaining to the block and just make a simple wrapper.
yep, and extension doesn't matter its whatever you want it to be. Best part about memory mapped files is that if the application dies, the memory mapping is separate from the application and handled by the OS and will eventually between 5-10 minutes get saved
also memory mapped files is a handy way to transfer information between applications of two varying types too
since multiple things can access the same memory mapped file
yeah this was very enlightening
one thing I've always wondered is when to use pdc vs nbt vs database
well you can use pdc for this, just I am not a fan of it since it seems it won't clean itself up
its a pet peeve of mine where game files get bloated with no system in place to clean up
Required parameters for PersistentDataContainer.set() is (@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type, @NotNull Z value)
How do I pass my PersistentDataType<T, Z> as argument. ?
this?
Current class I'm on is declared as follows public class ItemNameDataType implements PersistentDataType<PersistentDataContainer, ItemInformation> {
think you need to extend?
otherwise you are going to have issues where casting is necessary or used
?pdc
what this code do
Nowhere on that page does it say anything about extend. If we're talking about the same one
This is only for the seialize part
@Override
public PersistentDataContainer toPrimitive(ItemInformation complex, PersistentDataAdapterContext context) {
PersistentDataContainer pdc = context.newPersistentDataContainer();
pdc.set(Aliases.CHEST_KEY, this, complex);
return pdc;
}```
whats hte latest version of your nbt lib i tried
<dependency>
<groupId>org.jnbt</groupId>
<artifactId>JNBT</artifactId>
<version>1,8-SNAPSHOT</version>
</dependency>
and
<dependency>
<groupId>org.jnbt</groupId>
<artifactId>JNBT</artifactId>
<version>LATEST</version>
</dependency>
``` for some reason its bugging out
my repo doesn't exist anymore
someone help me out π
is it fine if I host it?
go for it, its not mine
bruh someone help me out π
alright lol
JNBT was created by someone else
bruh someone be patient π
and it was hosted on sourceforge
naw trust what does this code do π
their license permits you to modify it and what not as long as you leave the license intact
and give them credit etc etc
idk but its shitty clde
the reason I have JNBT in my repo
is because I updated it since it was missing NBT tags
and its a nice tool for NBT
and since MC doesn't change often in regards to NBT
why so
I only have to update it every so many years XD
@river oracle π
@wet breach
id like to report broken link on ur sourceforge
both Doc pages actually
i'd need to see more of it to be sure but a static CraftPlayer is almost never a good sign
public static too
they are just straight up ignoring oop
anyone know how to bypass or avoid this?
[22:36:12 WARN]: Entity EntityIronGolem['Tower Defender 3'/104, uuid='0fd2c9f4-c207-4cf3-aabd-a6e20e3707ba', l='ServerLevel[world]', x=-432.80, y=72.00, z=-327.38, cpos=[-28, -21], tl=130, v=true] is currently prevented from being added/removed to world since it is processing section status updates
How can I pass a List<String> as a parameter for (@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type, @NotNull Z value)
PersistentDataType<T, Z>
you can't by default
I'd reccomend mfnalex's more persistent data type lib if you need to do lists
I didn't want to do a lib π¦
Wanted to try figuring it out myself
To learn but it's way over my head
do you know of any other projects that use NBT neatly besides wedit its so big I legit can't find there shit nvm found some stuff myself
?????
hey, trying to use the Set Container Slot packet to rename an item, it says that if I set the window id to -2 then no item animation will be played, yet the item still does it
Y2K how do you suggest I make a custom PersistentDataType which includes List<Object> as fields
Use alex's library I'll send a link
Appreciate it
Ok I tried
But having issues
public class ItemInformation implements ConfigurationSerializable {
private static final long serialVersionUID = 1L;
private List<String> itemName;
private List<Integer> itemAmount;
private List<UUID> playerUUID;
public ItemInformation() {
this.itemName = new ArrayList<>();
this.itemAmount = new ArrayList<>();
this.playerUUID = new ArrayList<>();
}
public static ItemInformation deserialize(Map<String, Object> map) {
ItemInformation im = new ItemInformation();
im.setItemName((List<String>) map.get("itemName"));
im.setItemAmount((List<Integer>) map.get("itemAmount"));
im.setPlayerUUID((List<UUID>) map.get("playerUUID"));
return im;
}
public List<String> getName() {
return itemName;
}
public List<Integer> getAmount() {
return itemAmount;
}
public List<UUID> getUUID() {
return playerUUID;
}
public void setItemName(List<String> itemName) {
this.itemName = itemName;
}
public void setItemAmount(List<Integer> itemAmount) {
this.itemAmount = itemAmount;
}
public void setPlayerUUID(List<UUID> playerUUID) {
this.playerUUID = playerUUID;
}
@Override
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("itemName", itemName);
map.put("itemAmount", itemAmount);
map.put("playerUUID", playerUUID);
return map;
}```
So that's my class
Then I assume I need to create a ItemDataType which I declared public class ItemNameDataType implements PersistentDataType<PersistentDataContainer, ItemInformation>
And then I'm lost
Like I'm confused as to what I'm actually passing, how do I access the elements inside one of the lists, for instance
holy crap this is confusing
mojang removed the NBT docs
Notch used to have documents in regards to all the NBT stuff
and then after he left, it disappeared and what not lol
but the sourceforge page is not mine
it belongs to whoever initially created JNBT
realized that after a little while yeah
That's dumb
I suppose mojang can do whatever though it's their code
its their website too
documents were hosted on the minecraft.net site
which is where most of all you read about NBT
is it came from there
just we had copied it all before it disappeared fortunately π
I wonder if that's saved on way back machine
Would be interesting to look and potentially useful
there you go
levelformat didn't get saved by wayback machine
but levelformat wouldn't be useful today anyways because it described the region file format
but for a format that is now outdated and not used lol
the NBT document wayback managed to save is outdated in that it doesn't contain the added tags since then
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("You can't teleport to other servers, console!");
} else {
Player p = (Player) sender;
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF("lobby");
p.sendPluginMessage(this.main, "BungeeCord", out.toByteArray());
}
return true;
}``` current code
[06:39:04 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'lobby' in plugin SlashLobby v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:916) ~[paper-1.19.2.jar:git-Paper-307]
at org.bukkit.craftbukkit.v1_19_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.2.jar:git-Paper-307]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.2.jar:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:305) ~[?:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:289) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2294) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2248) ~[?:?]
at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:185) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1389) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-307]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: org.bukkit.plugin.messaging.ChannelNotRegisteredException: Attempted to send a plugin message through the unregistered channel `BungeeCord'.
at org.bukkit.plugin.messaging.StandardMessenger.validatePluginMessage(StandardMessenger.java:544) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer.sendPluginMessage(CraftPlayer.java:2037) ~[paper-1.19.2.jar:git-Paper-307]
at frostyservices.org.slashlobby.Commands.Lobby.onCommand(Lobby.java:34) ~[SlashLobby-1.0.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
... 23 more``` Error
My end goal is to send a player to a specific server using a Spigot plugin. Would anyone by chance know how to do this?
sir this is spigot
I'm having issues converting a class to a PersistentDataType<T,Z>
I need to be able to access and modify efficiently the fields inside of it.
This is my class
package me.tomisanhues2.deepstorage.utils;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Item;
import java.io.Serial;
import java.io.Serializable;
import java.util.*;
public class ItemInformation implements Serializable {
private List<String> itemName;
private List<Integer> itemAmount;
private List<UUID> playerUUID;
public ItemInformation() {
this.itemName = new ArrayList<>();
this.itemAmount = new ArrayList<>();
this.playerUUID = new ArrayList<>();
}
public List<String> getName() {
return itemName;
}
public List<Integer> getAmount() {
return itemAmount;
}
public List<UUID> getUUID() {
return playerUUID;
}
public void setItemName(List<String> itemName) {
this.itemName = itemName;
}
public void setItemAmount(List<Integer> itemAmount) {
this.itemAmount = itemAmount;
}
public void setPlayerUUID(List<UUID> playerUUID) {
this.playerUUID = playerUUID;
}
}
neither Serializable nor ConfigurationSerializable have much to do with PersistentDataType
you need to make your own serializer/deserializer for your type
?pdc
I've already tried making a TagType which implements PersistentDataType<> but then I was having problems with the topromitive and fromprimitive
See " Custom PersistentDataTypes and how to use them ?"
Yeah i've pretty much memorized that doc
But it's all about Primitive data types
And the example on UUID doesn't really relate that much since i'm trying to store List<Object>
well thats kind of like a PersistentDataContainer[]
I dont think there's a generic list type however
Hmmm this might be way over my head
Maybe you can suggest an alternative to what I'm trying to do
I'll explain
store it as a string and send it to/from YamlConfiguration lol
I'm trying to store
List of strings, "itemname"
Numbers of items for each string, "itemamount"
Those work like a key
and a list of UUID, all for 1 block
Now I thought about yaml but there has to be a better way
Isn't that insanely slow to access and modify any data
store it as a byte[] and write your own serializer/deserializer
Just like the example shows, I'll try that again I guess
new DataInputStream(new ByteArrayInputStream
Is that better than the example in the doc you linked?
probably about the same but easier
Ok great I'll give that a go
if you want to learn a couple of things if you are going the yaml route, you could learn how to use memory mapping from java's NIO package and NBT using the lib linked earlier π
i compiled my plugin with temurin 1.8 and installed it on a 1.8.8 server
u sure the compiler was in fact ur temurin 1.8 install?
i tried with jdk 8
file = new File(ProxyServer.getInstance().getPluginsFolder() + "/config.yml");``` How could I make it have its own folder? Doing `"/SlashLobby/config.yml"` does not work, so I'm quite confused on this.
Why when I use getPersistentDataContainer().set() and etPersistentDataContainer().get() in the same method it works but otherwise if I call it from a different method it returns null
you call mkdir()
mkdir will create a directory
and then when you create the file object you use the appropriate path
create a file object and call mkdirs() and it will create all folders as needed
All my data is working fine on creation, just after that even running getPersistentDataContainer().getKeys() returns null
public static void createNewStorage(Chest chest) {
//Call location persistence also
ItemInformation itemInformation = new ItemInformation();
List<String> itemName = new ArrayList<>();
List<Integer> itemAmount = new ArrayList<>();
List<UUID> playerUUID = new ArrayList<>();
String json = gson.toJson(itemInformation);
Bukkit.getLogger().info(json);
chest.getPersistentDataContainer().set(STORAGE, PersistentDataType.STRING, json);
Location location = chest.getLocation();
chest.getPersistentDataContainer().set(LOCATION, PersistentDataType.STRING, location.toString());
Bukkit.getLogger().info("Created new storage at " + location.toString());
}```
public static ItemInformation getStorage(Chest chest) {
//Call location persistence also
String json = chest.getPersistentDataContainer().getKeys().toString();
Bukkit.getLogger().info("The obtained string is + " + json);
return gson.fromJson(json, ItemInformation.class);
}```
Null already
File f = new File("F:\\program\\program1");``` Would something like this work?
I searched mkdir in google and I found this: https://www.geeksforgeeks.org/file-mkdir-method-in-java-with-examples/
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Just unsure if it would work in this scenario
file = new File(ProxyServer.getInstance().getPluginsFolder() + "F:/SlashLobby/config.yml");
Boolean bool = file.mkdir();``` Yeah, I'm just completely lost.
don't use a pluse
file = new File(ProxyServer.getInstance().getPluginsFolder() + "F:/SlashLobby/config.yml");
this is almost correct
it should be this instead
file = new File(ProxyServer.getInstance().getPluginsFolder() + "/SlashLobby", "config.yml");
notice I added a comma in there
anyways, only thing is to ensure your directory for your config is created and that should work π
file = new File(ProxyServer.getInstance().getPluginsFolder() + "/SlashLobby", "config.yml");
Boolean bool = file.mkdirs OR mkdir();``` `file` still appears to return null
Oh, wait a second
It created SlashLobby/config.yml just config.yml isn't a file
So, nearly there I think? :P
Why when I use getPersistentDataContainer().set() and etPersistentDataContainer().get() in the same method it works but otherwise if I call it from a different method it returns null.
All my data is working fine on creation, just after that even running getPersistentDataContainer().getKeys() returns null.
public static void createNewStorage(Chest chest) {
//Call location persistence also
ItemInformation itemInformation = new ItemInformation();
List<String> itemName = new ArrayList<>();
List<Integer> itemAmount = new ArrayList<>();
List<UUID> playerUUID = new ArrayList<>();
String json = gson.toJson(itemInformation);
Bukkit.getLogger().info(json);
chest.getPersistentDataContainer().set(STORAGE, PersistentDataType.STRING, json);
Location location = chest.getLocation();
chest.getPersistentDataContainer().set(LOCATION, PersistentDataType.STRING, location.toString());
Bukkit.getLogger().info("Created new storage at " + location.toString());
}```
```java
public static ItemInformation getStorage(Chest chest) {
//Call location persistence also
String json = chest.getPersistentDataContainer().getKeys().toString();
Bukkit.getLogger().info("The obtained string is + " + json);
return gson.fromJson(json, ItemInformation.class);
}```
Null already
Hey, I'm trying to modify the item's attributes (diamond sword for example) the vanilla attack damage is 7, but I'm struggling to increase it to 8 attack damage, can someone help me?
is it possible to generate vanilla structures in custom chunk generation?
make the directory first before the file
the way you did it
it assumed you wanted a directory named config.yml
so just remove the config.yml part
in file object
call make directory
update file object to have the file you want
also you are going to want to surround the making the directory with a try catch block
to catch IOException in the event one is thrown
bump <>
declaration: package: org.bukkit.generator.structure
So what I have currently is making the directory, then I do what I had in the first place with the directory object?
yep
but how can I generate with chunk generation?
Do you guys also make config files for plugins that you only make for yourself?
Chest.update()
See the methods available for override in ChunkGenerator
and shouldn't I use this api here instead of the normal plugin: https://ci.citizensnpcs.co/job/CitizensAPI/
wtf did they change the java colors
for code blocks
bump #1063929625056661524
i feel left out
What have you got so far
No one likes threads
π¦
i used a thread because this is like 5th time i ask for help about the same issue
I hardly ever look at threads.
I never check them, because I prefer normal channels. I don't really like the threads.
https://paste.md-5.net/jacesekise.cpp
Hello PEOPLE, This code is what I use to change what a player looks like into an entity and it has been working nicely in OW
but going to the nether it seems to not work? This is executed on PlayerChangedWorldEvent to refresh both players in Nether and the Player joining Nether and if the disguised player walks in Nether first then refreshed when someone joins him it doesn't work. but it does work when the disguised players joins after other players join. is there any logical explination for this?
OKE IS THIS BETTER NOW WILL PEOPLE STOP MAKING FUN OF ME FOR USING THREADS π
Is the event too early maybe?
nope the world seems to be the nether
That's what It sounds like. Player not getting refreshed at the right time
here's the thing i refresh the player when walking in Nether to other people on switching the world and it works but it doesn't work for people walking on the disguised player
so it's definitely not a timing problem
since i get the world from the refreshed and not the target
ill try sending it 4 ticks late still
Maybe add a function that repeats every 1 tick checking if the players location isn't null and then set his disguise? Maybe event is called before the chunks itself being loaded and so it can't update the player?
Does anyone know how e.g. LuckPerms uses MongoDB while keeping a file size < 1MB?
When I shade Morphia into my plugin it bloats up to over 10MB, I figured I could use the libararies feature in plugin.yml, but it doesnβt seem like they are doing it that way
Probably doing a similar thing manually - downloading it
but if I use the api it outputs me an error in console:
[09:56:50] [Server thread/ERROR]: Could not load 'plugins\citizensapi-2.0.30.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:170) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.CraftServer.loadPlugins(CraftServer.java:428) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3633-Spigot-d90018e-a0d3dfa]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:219) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3633-Spigot-d90018e-a0d3dfa]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:973) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3633-Spigot-d90018e-a0d3dfa]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:301) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3633-Spigot-d90018e-a0d3dfa]
at java.lang.Thread.run(Thread.java:1589) ~[?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more
wdym with against?
So shouldn't I put the API in the plugins folder?
hi md_5
well, what does Citizens themselves tell u to do?
my guess without looking anything up would be that u would probably need to run Citizens plugin itself on server to use api
to put some stuff in the pom.xml of my plugin:
<repository>
<id>citizens-repo</id>
<url>https://maven.citizensnpcs.co/repo</url>
</repository>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-main</artifactId>
<version>2.0.30-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
but i thought I also need to put the api.jar into the plugins folder of my server
You set it to provided, so you need to make sure you run the plugin on the server as well
ok is there a way that i only need to have the api on my server?
and for what is the api then, if you need the entire plugin, not only the api?
The API is needed to talk to the main plugin
but the main plugin already contains the api
no like the citizens api needs the citizens plugin to do stuff
The CitizensAPI in your plugin needs to talk to the actual Citizens plugin. Otherwise the API won't be able to do anything
?paste
but I thought the citizensapi need to talk to my own plugin?

you use Citizens API in your plugin to interface with the Citizens plugin
you still need the Citizens plugin itself on the server to make it work
The way that the CitizensAPI:
Your plugin includes the citizensAPI, which tells the Citizens plugin to do specific tasks. It's the same reason you need the SpigotAPI in your plugin when you're using a spigot jar. Otherwise you wouldn't be able to change anything at all.
The API is like a messenger. It sends messages to the Citizens plugins to do what you want it to do. The API alone isn't enough.
oh okay this makes sense, so i need to add the CitizensAPI to my external librarys in intellij, and the normal Citizens plugin into the plugins folder of my server right?
You add the API to your plugin as instructed on the citizens api page, then add the citizens plugin to your plugins folder.