#help-development
1 messages · Page 1098 of 1
that kinda sucks
Yeah body movement is somewhat relative to a minimum head rotation threshold
tf are u on about
says the unverified
Isnt Coll sending crakced minecraft link?
lol
mods ban this filth
You should click the link for more information!
classic twitter user brain
but yeah honestly I think the mods should ban coll for sending such a link /s
well
its more like if you take a bit more time to read what was actually said, and by who it would make more sense why they send that
How can I get a block NBT should I use nms?
blocks dont have NBT
TileEntity I mean, like a chest
I am using packet events, to send a chunk data packet I need to give an array of TileEntity but TileEntity object dont really exist for spigot, there doesn't seem to be a method for builds so I have to do it myself from the nbt of the tiles entities
so I have to use nms?
thanks
Block b = e.getBlock();
TileState tileState = (TileState) b.getState();
System.out.println(tileState.getBlockData().getAsString());
I am getting minecraft:chest[facing=west,type=single,waterlogged=false]
its nbt?
You can't get the NBT from a tile entity, nor construct one
You would have to do it from server internals
I see
You can cast a TileState to a CraftBlockEntityState and call getSnapshotNBT() to get the NBTTagCompound() of the snapshot data (which is probably all you need)
Then there's a loadData(NBTTagCompound) which will load the snapshot
when using the data guide, i keep getting the following error when logging in (for PlayerData)
?paste
it didn't do that from the beginning
but now fsr it does, the event is suddenly null and i have no idea why
Can someone pls help me make a plugin for me to add custom end armour with recipes and a crystal and ingot cause I have tried and it doesn't work
?notworking
"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.
?paste your code
It's multiple dif files
what a complication
oh noooo
What method should I use to display the message if it times out?
?
I hate when my projects have more than one file
you know what if something isn't working about your code. Send the stacktrace, send the related code to the stacktrace. Then we can actually help you
Should I add the money back to the senderUser if there is an error adding the money to the receiverUser?
No one will be making your plugin for you unless you pay them
"does not work" maybe, who wrote that
So I am making discord bot for my plugin
now I am thinking should each user create there own bot and add its token to config file?
or should I just create my own bot
hard coded its token in plugin
you should not host your own bot. Imagine you do and your token is in the plugin
config
and each user could invite my bot
Should I add the money back to the senderUser if there is an error adding the money to the receiverUser? https://imgur.com/a/t8kqTUW
and boom you're token is leaked
ok I see
but could I make it so it is using my bot some how without adding token to plugin
let the user add their own token
make the user add their own token
if their are smart enough to use plugins, they are smart enough to make a discord bot
hmm that's quite the stretch in logic
but I got slight problem
but regardless you should force the user to add their own token
someone awsner
if they use plugin on multiple server would that not create multiple instance of bot
can yall tag me on an answer? i gotta go for now :/
lmao what
that's a problem you gotta figure out now isn't it
should bot be hostes on one instance
that's the thing with development there are always those damn plugins
depends on your scenario really
I mean there are times where spinning up multiple bots under the same token is no big deal, it really depends what the bot is doing
yeah you'll be fine with multiple bot instances
I don't see how that would cause issues
I was curious how whole think work
have no expiriance with it
for example if u run SocketServer instance it can only be one on same port
CafeBabe is actually 2 bots under 1 token 😉 so you can do it
thanks for all info
make the user define ports
@river oracle
don't ping me
hello ive created a plugin that uses a gui and the gui dont load in game here are the 2 classes that should be the one to control my gui https://paste.md-5.net/rodejuvesa.java
ok
I didn't answer because I didn't feel like it
or u dont know?
idk didn't read seemed like an ambiguous question and I don't feel like answering
wdym by not loading
is there a stacktrace?
im new to this
although it just says
in game opening then it dont open
I don't think it says that
going to need a stacktrace
Is there some way to have a method run in the event a runnable is cancelled?
from the context where you created it
not sure what you mean byt his
im using runnables and theres various things i am looking for and cancelling the task in certain cases. I wanted to send a message to the player when its cancelled but it would be the same for any reason it would be cancelled
just make a callback
you can wrap BukkitRunnable to store some information on creation
you could also wrap BukkitTask too
depends how you wanna do things
What would be the difference effectively between the 2? I am looking at just wrapping runnable
the stack trace is in the command when the server loads rright ?
does playermoveevent fire when swinging a sword
like this?
@EventHandler
public void onBreak(BlockBreakEvent e) {
TileState tileState = (TileState) e.getBlock().getState();
CraftBlockEntityState craftBlockEntityState = (CraftBlockEntityState) tileState;
CompoundTag compoundTag = craftBlockEntityState.getSnapshotNBT();
NBTCompound nbtCompound = new NBTCompound(); //packet events nbt
for(String key: compoundTag.getAllKeys()) {
nbtCompound.setTag(key, new NBTList(NBTType.LIST, (List) compoundTag.get(key)));
}
}
Bukkit.getLogger().log(Level.WARNING, e.getMessage()); is thread safe?
depends on teh Bukkit version
Log4j is thread safe, but Bukkit has not always used it
seems SLF4j is too, so I'm going to say yes.
just tired to invite my bot in discord server and it is not showing up
Your bot obtained sentience.
What does that have to do with spigot development tho?
Does anyone here know how exactly the custom crop plugins work, from what ive gathered they use blockentities but from what i can see i wouldnt be able to display the crop properly
You mean this?
https://github.com/Xiao-MoMi/Custom-Crops
hello, im developing a spigot plugin which modifies the item from fishing
Cool
but
i got problem
public void reload() {
this.clear();
ConfigurationSection cfg = null;
for (String key: getLootConfig().getKeys(false)) {
cfg = getLootConfig().getConfigurationSection(key);
if (cfg == null) continue;
plugin.getLogger().info(cfg.toString());
add(key, cfg.getItemStack("item"), cfg.getDouble("weight"));
}
}
What is 'getLootConfig()'
when i deserialize my config file to ItemStack, it throws my a error
[22:40:33 ERROR]: [org.bukkit.configuration.serialization.ConfigurationSerialization] Could not call method 'public static org.bukkit.inventory.ItemStack org.bukkit.inventory.ItemStack.deserialize(java.util.Map)' of class org.bukkit.inventory.ItemStack for deserialization
java.lang.IllegalArgumentException: Material cannot be null
The given material returns null
private ConfigurationSection getLootConfig() {
return plugin.getConfig().getConfigurationSection("LootItems");
}
Or isnt present
LootItems:
salmon:
weight: 100
item:
==: org.bukkit.inventory.ItemStack
type: SALMON
this is my config
Yea something like that, ive seen the plugins have custom models for the crops and ive tried looking through the src of other plugins but cant find exactly how its acomplished
Did you write that item manually in to the config
yes
this is my confing
i dont know why it said java.lang.IllegalArgumentException: Material cannot be null
cuz i wrote that type
and SALMON did exist in my mc version
btw theres a thing unnormally
[22:40:31 WARN]: [org.bukkit.craftbukkit.v1_20_R1.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
i got this warning
https://paste.md-5.net/uqegecowuz.java hello my script isnt Resolvinmg my symbol for "SlashEffect" does anyone have an idea of what i should do ?
What symbol?
SlashEffect, what dependency?
Set api-version in your plugin.yml
Then you have another legacy plugin installed
I just realized something mildly interesting
if you use ai regularly you end up slowly building up a resistance against confidence men
Gets ghosted
confidence men?
because AI is always 100% confident no matter what
> plugins
[22:50:18 INFO]: Server Plugins (1):
[22:50:18 INFO]: Bukkit Plugins:
[22:50:18 INFO]: - FishInControl
show your plugin.yml
name: FishInControl
version: '${project.version}'
main: net.fishport.fishincontrol.FishInControl
api-version: '1.20'
folia-supported: true
commands:
fishincontrol:
aliases: [fic]
usage: /<command> reload
permission: fisnincontrol.admin
permissions:
fisnincontrol.admin:
description: Allows reloading config file with /fisnincontrol reload.
default: op
fisnincontrol.bypass:
description: Bypass item replacement.
default: false
fisnincontrol.forced:
description: forced item replacement.
default: false
I like your style magic man
lol, i just forgot to add it
basically charismatic people who seem 100% certain of what they're talking about no matter what even if they're wrong and bullshitting, it's somewhat of a sales / stocks term
using folia actually
okay but like what's the point with your message
even worse
i have to create paper-plugin.yml?
?whereami
apparently TradeSelectEvent#getMerchant() instanceof AbstractVillager always returns false, how does this work?
magic
sharing a mildly interesting fact, as prefaced
OH I READ IT AS INFURIATING
lmao
.
what do u mean ?
where do you expect that class to come from
A merchant is a (special) type of inventory
it's not really an entity
it has abstractvillager as subinterface though
getMerchant will return CraftMerchant
🤔 that's true
might be an implementation oversight
?jira
^^ make a report ig
Looks like CraftMerchant just wraps the villager
((Villager)((CraftMerchant) event.getMerchant()).getMerchant()).getBukkitEntity()
would work
but that's a bit hacky
yeah right now im just avoiding using Villager or Merchant alltogether and using them as entities instead
Not all keys part of a tile entity are going to be lists 
I want to say CompoundTag has a getter that gets things as an NBTBase and you can set those instead, or probably even a copy method to copy one tag's contents into another
I can't remember off hand though
i switched to spigot and it still not working 😦
sorry, im using spigot api to develop and testing on spigot 1.20 server idk why i need to ask in paper discord now☠️
material cannot be null
put in null checks then
public void reload() {
this.clear();
ConfigurationSection cfg = null;
for (String key: getLootConfig().getKeys(false)) {
cfg = getLootConfig().getConfigurationSection(key);
if (cfg == null) continue;
plugin.getLogger().info(cfg.toString());
add(key, cfg.getItemStack("item"), cfg.getDouble("weight"));
}
}
private ConfigurationSection getLootConfig() {
return plugin.getConfig().getConfigurationSection("LootItems");
}
i cant because its Configuration deserialize
LootItems:
salmon:
weight: 100
item:
==: org.bukkit.inventory.ItemStack
type: SALMON
my config
item is incorrectly serialized maybe
idfk, thought you were running paper, ItemStack::material nullable maybe
im thinking thats not even the correct config
im running spigot
You need to specify what version of itemstack it is
otherwise it will default to legacy
create ItemStack in code, then getConfig().set("path", itemStack);
^^ will add the correct version info
is there like a villager trade prepare event
so that i can change a trade's output without changing the trade itself
declaration: package: org.bukkit.event.entity, class: VillagerAcquireTradeEvent
oh didn't read second part
Doesn't look like it
setting item index 2 to something else doesnt seem to actually change it weirdly enough
its getting worse 😦
?
legacy? you do not have a version in your plugin.yml
did you save the config after you set the itemstack?
Does anyone here know how to create a custom crop similar to that found in oraxen with custom models aswell?
it throws me this error
else your config is still old
then you have done nothing
no
oh
And I don't mean api-version
your item: in your config.yml is broken, stop using it
Do what ElgarL said ^^
replace it with getConfig().set
ok ill keep config.yml empty
and my code will be
ItemStack itemStack = new ItemStack(Material.BUCKET);
getConfig().set("aaa", itemStack);
let me try
and saveConfig()
Could just set your actual path
okay
ItemStack itemStack = new ItemStack(Material.BUCKET);
getConfig().set("LootItems.bucket", itemStack);
saveConfig();
Material cannot be null
you are still trying to read yoru old Item
?paste your onEnable
to make plugins using nms compatible with multpliqe version, I should import "all" nms version and choose it depending on the one I want to execute, is there a libs/api for that?
because somewhere your old code is still reading junk
and what's the error
how can it read the old file
that code will not throw that error
☠️
on Enable line 16
getConfig would try to deserialize
https://paste.md-5.net/amumozadac.cs this is right?
config.yml is empty before it set, i swear
be sure to stop server/start server between tries. No reloads
yes
?
maybe the problem is
Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!?
That happens when you use getItemStack when the item stack has no version set
as I said it will default to legacy
its impossible that it is empty as that error can;t try to deserialize an ItemStack from an empty config
Delete the config entierly
an empty config would do absolutely nothign when used with getConfig()
do you have a broken config in your plugin.jar?
ill replace it with a empty config file
empty
and
wait
your right
finally 😭
so i have to define this when i setting it manually?
yes
its much easier if you create the items in code then save them. as you can do everythign without having to write it all maually
guys, i saw a PlayerDamageEvent on a forum but i cant find it
was it removed or smthn?
EntityDamageByEntityEvent or EntityDamageEvent and check if entity is player
what the hecc
I just noticed people are stealing my style in their update logs
I will sue for style theft
lil bro you sure it was ever yours to begin with?
https://paste.md-5.net/igixicizik.java If I create a user with a Player field and the player leaves the player and accesses this user field, will the Player field return null?
no
variables dont just become null
Do not store Players. We've told you many times
but that said the Player object is considered invalid once logged out, that is no longer in session so u should release it
It's not that easy
GlobalPlugin.INSTANCE.getUserService().get(player.getName()).thenAccept(globalUser -> {
if (user.getPlayer().isOnline())
switch (user.getRadiation()) {
case 100 ->
BukkitUtils.sendTitle(player, lang.getString(globalUser.getLanguageType(), "title"), lang.getString(globalUser.getLanguageType(), "subtitle1"), 20, 60, 20);
case 300 ->
BukkitUtils.sendTitle(player, lang.getString(globalUser.getLanguageType(), "title"), lang.getString(globalUser.getLanguageType(), "subtitle2"), 20, 60, 20);
case 500 ->
BukkitUtils.sendTitle(player, lang.getString(globalUser.getLanguageType(), "title"), lang.getString(globalUser.getLanguageType(), "subtitle3"), 20, 60, 20);
}
});
Its really that easy lil bro
the player can log out until thenaccept is executed, although the user is no longer in the cache, I can still use user#getplayer and check if he is online to send the title
what does user::getplayer do?
https://paste.md-5.net/beqozutoci.cpp this is thread safe?
return Player instance
alright thats poor code
Change it up and use UUID
And then you can use Bukkit.getPlayer(uuid)
If Bukkit.getPlayer(uuid) is null => offline
im dipping now, good luck and listen to my advice lil broski
no need
If User is only in the cache if he is online, then I don't need to do this
extremely needed
of course not
If User is only in the cache if he is online, then I don't need to do this
why not just use uuid or weakref
doing BUkkit.getplayer(uuid) is just one more load every time
more load
?
But your code doesnt do that right now
Holding stale Player references is a memory leak
Your code legitimately sucks
I don't know if you know but accessing a map always has a cost
XD
nobody is gonna help you otherwise
seems like this is rude one, im out
If I can simply access it without going through any list, more performance
It's not worth it
He argues over everything
I'm changing all my plugins to async because I was told lol
Ok noobski look up some facts before yapping about performance
give me a reason why you would store UUID instead of Player in a User that is only in a cache if the player is online
i dont know the context, but maps are faster than lists when trying to access somethign
It is
Is a map faster than accessing user#getplayer?
i dont know the context
give me a reason why you would store UUID instead of Player in a User that is only in a cache if the player is online
this is a context
no make senses storage the uuid
because ur cache class sucks and u gonna shoot urself in the foot
uuid is legit THE PRACTICE you use
BRO AHHAAH
The Player class is only a context api class you use to invoke behavior on players
tbh this isnt really a reason
Worrying about the access time of a Map when you are holding stale Player references is asinine.
it very much is
@rough hinge just use a player reference as long as you clean it up
tbh i dont see the reason for the uuid debate
They could just go w a WeakHashMap
but thats besides the point
yep
yes of course but I don't need to clean it. Just remove the users you create from the cache and the gc will clean it
You just don’t hold players
yes, thats what i meant
Because you have terrible code like this, you should not rely on Player objects as keys
I don’t understand how you can sit here and have the audacity to argue when you’re shooting yourself in the foot as we speak
Shameless
im out
Ohh alr thanks man
he is still in the process of learning, i dont get why ur upset if he asks why something is? If he just accepts everything you say as true, he will become a spoonfed programmer and not some1 with critical thinking abilities
that’s not what spoonfeeding means
There are like 10 people explaining it to them
i dont get why ur upset if he asks why something is
not true
If they cant grasp the situation, thats on them
he is rude
oh
nice then
i didnt see that
I am rude
The issue is he argues his point over and over even when confronted by Multiple experienced devs and helpers.
I would like to know who said I am using Player as a key? Are you a hacker and hacked my PC?
yes
Well either way you’re storing it like a potato
No i dont hack people that’s goofy
On god please make a getInstance Function
You already said earlier you are on 1.8 using player names as keys, fetching a user object which holds a Player reference
And use UUIDs instead of names
my server isnt premium lul
he is
ola I still cant grasp you out of touch with reality you are when Elgar, Goksi, Bedless and Salvation is legit giving you free knowledge and improvements
its beyond shameful
you are lucky that you receive help in the first place haha
bye
he was arguing with 7Smile7 earlier about async 🙂
a tale as old as time (since 01/01/1970)
yeah
lol, I get teh reference 🙂
before that time didnt exist
when time equals zero
at first there was the big bang, and 0 seconds into the big bang all of my resource packs were created
it must be because they're all dated from 01/01/1970
and it was good 😎
hey guys
im trying to detect when a player middle clicks an inventory, but the event.getClick() never returns a middle click, only left and right
is there a way for me to check it on survival?
does the event trigger at all for middle?
what does middle click do in an Inventory?
I would like to know, how can I tp to a player on another server, imagine this:
- bungeecord
- lobby-01
- lobby-02
I am from lobb-01, I want to be TPed to a player on lobby-02, how may I do? 🤔
transfer using PMC
where you turn up will be upto the server you are going to
?pmc
why is javadoc rendering popup so poor and weird with kotlin libraries?
i dont even know what exception would throw
Try downloading docs 🤷♂️
Thx :>.
might give better description
i did
theres no way
public fun myMethod(myInput: String) : String { return myInput + " hello!" }
public String myMethod(String myInput) { return myInput = " hello!"; }
I can do a completablefuture and then use the value returned with thenaccept and keep checking how the player executed the command, for example if he only executed /money it shows his balance (his balance based on the value returned by the future), if he typed /money <nick> it returns the balance by the value returned by the future, but for example if nickOfflinePlayer#hasPlayedBefore returns false, I will not use the value returned by the future. Do the developers choose to do a completablefuture in the entire command even in some cases not using the returned value, or do they make a separate completable future if there is a case that will not use this returned value?
has this guy ever even seen kotlin code
So kotlin people don't write proper docs?
I have to do it with packets so its okay
and a great deal of distress in the same world?
yes I want to send send them in advence
that makes no sense
im making a repaly system who restore old chunks To avoid problems, it's easier to send them in advance.
the client (as far as I know) does not understand worlds.
it can;t hold a chunk in memory for a world its not in
it seems to me that because, for example, when you change world there is a screen, whereas when you change world there is a screen
but you have reason
as far as I know teh client only references the current world at a time
packet just contain X and Z nothing about world
yes
so if you send a chunk for a different world, it will not understand it is a different world. it will take it as the current world
Can you not send packets as if you’re the server? Or am I misunderstanding something about mc protocol
What even is the point of this
?
quite
in fact it's not true like showed ElgarL
the client 👀
I've no idea what you are doign either
I like to feel mysterious
How’s the client gonna understand a chunk load packet when they’re not even in the world that contains the chunk
I think I was just being dumb
no seriously, for replay I want to restore old blocks and chuks so I send the old chunk to the client
it just load the chunk in the curent world
I see what you are doing
but any interaction by the client will cause issues on teh server if the current world is not updated with the new data
But that’s not what you’d want? It’s supposed to be in a different world right?
his "other" world is a backup
Oh right
the worlds original state
yes I have to be very careful with all of them, I haven't seen any replay plugins that do this, it must be for this reason
generally they just replace any changed blocks to reset the chunk
yes
the worry is that if all the chunk has been changed it will send more or less 70 000 packets block update (its a really bad idea)
most plugins require you to define a "camera" zone in advance, so it's easier to modify blocks in this case.
Why differ from other implementations then?
what
The code is always executed in the same thread, correct? The code inside the task? If you just modify the hashmap, there is no need for it to be concurrenthashmap, right?
Or does it need to be concurrenthashmap for reading the hashmap in another thread?
getRanking is subject to race conditions
why?
everyone's racing for the ranking
?
If I only modify the contents of the hashmap in a single thread, can I not read it in other threads without be concurrenthashmap?
Concurrent just means only a single thread can access it at a time iirc
no
Not quite
imagine a reallocation happens due to a put
please enlighten me con
In this case it means it supports concurrent operations, like put, get and compute (read-modify-write) at the same time on multiple threads
all buckets are reallocated but not filled yet
then the os switches to the other thread that performs a get
what do you think the result is
being fully atomic in all of that ^^
Wait so there are differences of the definition based on the usecase
ofcourse?
I mean there is no harm in using a CHM in a single threaded environment, but its slower
differences of the definition on the usecase
what
Con confused me with the "in this case"
Is this how the concurrent map works always?
concurrent hashmap partially locks itself
I described its semantic reassurance
Much like you need to use AtomicReference if u want to read, write and read-modify-write to variables that may be operated on with the aforementioned operations on multiple threads
or well not need, you can hop over AtomicReference, but you lose atomicity and memory visibility (unless you use other tools like volatile, synchronized or VarHandle etc)
Hmm alright
that's why I use AtomicReference of an ImmutableMap :sunglas:

Other than performance as an example, what other benefits are there from doing stuff from multiple threads?
but yea good thing Emily points out sort of, immutable is free thread safety
thinking you can split your problem in two but now you have two problems
kek
I mean, sometimes you quite literally just have to, not for performance reasons
especially when it involves networking and such
for example, the game has a tick loop, but it also has to wait for connections to read them
So in terms of spigot, when running an "async" task, is this task actually ran on another thread? And how is this new thread (if any) handled before, during, and after said operations
tasks dispatched through the scheduler (runTaskAsync) do run on a separate thread
Yes, spigot is using a thread pool internally to run your tasks
So then what does "async" actually mean?
it's basically just a thread pool that waits for tasks in a queue to run them, then once you queue a task the thread runs them, and once it's finished it becomes free and waits for a new task
it just means "this task will run at any moment in the future, not now", it isn't synchronous with the current code flow
Ah ok gotcha
"sequential" might be a word you could think of
Yeah no this explained that well, thank you
Concurrency is hard man D:
println("1")
runTask(() -> println("2"))
println("3")
1 and 3 are synchronous, but 2 is asynchronous as it doesn't run with the current flow of execution, although it runs on the main thread
it is! and thread safety is a whole other beast :)
is there a spigot way to make a mob not quite not have ai but not do any movement including turning around
I know I could probably lobotomize it via nms
Yeah I always thought the concurrent map meant only a single thread can read/write/read-write-modify at a time
I don't want to go that high effort either
Question:
Should homes be an object?
public class Home {
private final Home home;
private final Location location;
private final double x, y, z;
private final World world;
public Home(Home home, Location location) {
this.home = home;
this.location = location;
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.world = location.getWorld();
}
public Location getLocation() {
return location;
}
public Home getHome() {
return home;
}
public World getWorld() {
return world;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
}```
I think a home should def be an object. But why do you pass a Home to the constructor of a Home?
instead of a string?
Also x,y,z and world are redundant
How do you even create a Home instance if it requires another home instance lol
a fridge is a home for food inside your home
-.-
doll houses
Location already stores a world
Yeah almost checks out
So instead of passing Home it should just be a String?
new Home(new Home(new Home(null, loc), loc), loc) lol
Yes, a String makes more sense
you make sense lol
i just need to remember k.i.s.s
public class Home {
private final String home;
private final Location location;
public Home(String home, Location location) {
this.home = home;
this.location = location;
}
public Location getLocation() {
return location;
}
public String getHome() {
return home;
}
}```
rename your home field to something better fitting like name or homeName
getName
Because the string is not actually your home. Its just its name.
hii, how would you fix the issue with color codes support on components? I really need a solution to that issue, for some reasons when applying color codes
lemme guess? there is no support?
i mean yes and not. What happens is next, when applying colo codes. First lines get color the others dont
Its an issue which has been there for years and years, and im not sure why they havent already fixed
not sure if you can solve that with a component builder
what i was thinking is to clone the component which has color codes, replace each color by hand and map it into ChatColor.COLOR and finally put all into a new component
Well reverse engineer a little bit, what is your end goal. And tbf just a bit simpler to think about when it comes to all the lingo you probably come across
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.style.Style;
Component component = new TextComponent("first line").setStyle(Style.EMPTY.withColor(Formatting.RED));
Component secondLine = new TextComponent("second line").setStyle(Style.EMPTY.withColor(Formatting.BLUE));
Component combined = component.append("\n").append(secondLine);
player.sendMessage(combined, player.getUUID());
What the hex is that, thats not mc for sure
nms
oh conclure
you know about the issue right? explain me please why spigot didnt fix till
Issue
When you use direct color codes (&c or any color code) on text that spans multiple lines, the color is applied only to the first few lines and then not to the following lines. This occurs because the conversion between text formats may not handle line changes correctly, causing the color to be "lost" in the process.
Cause
This may be due to how the processing and conversion of multi-line text is done. Color codes & may not be handled correctly in texts that include line breaks, and this may lead to formatting only being applied to the initial part of the text.
Here is the issue with good english described @tardy delta
that only happens in components
what happens when you do new componentbuilder().append(line 1).color(x).append(\n line 2).color(y)
i will try it, but when i did using directly ChatColor.COLOR no color missing happened.
let me try it and seem what happens
thanks for being kinfull and not getting mad cause of tagging
variables my man
you don;t need it
its a Home so you will be teleporting (I assume) so you only need the location
the Location itself has getX etc
i store the world, x, y, z in the file not the whole location
hi,i have a uick question, am i supposed to unregister my listeners in onDisable() ?
nope
alr ty
They get unregistered automatically
unless you're saving stuff then theres no reason
you can directly save location object in cofig files:
Location location = player.getLocation();
getConfig().set("location", location);
Location homeLocation = (Location) getConfig().get("location");```
I know this, i just dont think it looks the best 🤷♂️
i know its easier to do and get and set
getLocation() buddy
why? no ned to reinveint the wheel when already exists, what you looking forward?
you can use the approach and use that time to build your goals
good point, i just like to make things harder on myself i guess. lol
i used to be like that, i used to lost hours and hours creating things just because of personal preferences, instead of using that time to create amazing things
Yeah, i've spent like a week working on a player data object and @river oracle is like stop being stupid lol.
public void setHome(String name, Location location) {
Home home = new Home(name, location);
fileHandler.getConfig().set("Location", home.getLocation());
}```
yeah lmao, he knows more than us. He has more years, and we should appretiate that people instead of trying to over complicate ourselfs
depends how you are saving the config
fileHandler.getConfig().set(String.format("Homes.%s.Location", home), home.getLocation());
my bad
lol
be carefull
im still seeing it wrong
because a player can have many homes
or what you doing exactly? give more context
Shouldnt be saved like?
Homes:
playe-uuid-one:
home-uuid-1:
name: ""
location: bla bla
home-uuid-2:
name: ""
location: bla bla
playe-uuid-two:
home-uuid-1:
name: ""
location: bla bla
home-uuid-2:
name: ""
location: bla bla
...
No the files are saved seperately.
ohh okay, that makes sense known
Yeah sorry, that would be confusing lol
i seen smile typing too much, i wish i could know what he is typing
You should separate your persistence handling from your data.
First set up the data structure containing your data in memory, then tinker with persisting it to configs etc.
Write a manager class:
public class HomeManager {
private final Map<UUID, List<Home>> loadedHomes;
public void loadHomes(UUID playerId)...
public void saveHomes(UUID playerId)...
}
or
public class HomeManager {
private final Map<UUID, Map<String, Home>> loadedHomes;
}
And then come back.
When a player joins -> load his homes
When a player quits -> save his homes
While a player is online, you only interact with your manager class.
My UserManager does just that. my User class saves lol
private final HashMap<UUID, User> playerData = new HashMap<>();
So does a User have a List<Home> in it?
do you know, you can skip manual serialization? You can take approch of ConfigurationSerialization object
(extend ConfigurationSerializable)
*implements
Anyways, if you want to truly not care about your serialization, you can throw your objects at Gson and see what sticks.
public class PlayerData implements ConfigurationSerializable {
private String playerName;
public PlayerData(String playerName) {
this.playerName = playerName;
}
public PlayerData(Map<String, Object> map) {
this.playerName = (String) map.get("playerName");
}
@Override
public Map<String, Object> serialize() {
Map<String, Object> data = new HashMap<>();
data.put("playerName", playerName);
return data;
}
public String getPlayerName() {
return playerName;
}
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
}```
And then just use Config$set() and Config#get() by using object casting
smile, are you free? if you would want to read the issue i would like to know if spigot will fix or not?
Hmm...
I don't know why, but this recipe isn't working (the recipe exist but the result slot is empty if i don't fill the "*" items) :
@Override
public ShapedRecipe getRecipe() {
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(HekaCite.getPlugin(), "decapitator"), this.build());
recipe.shape("*d*","*D*","*N*");
recipe.setIngredient('d', Material.DIAMOND);
recipe.setIngredient('D', Material.DIAMOND_BLOCK);
recipe.setIngredient('N', Material.NETHERITE_INGOT);
return recipe;
}
(cause of undefined items)
But, this one works and it has undefined items:
@Override
public ShapedRecipe getRecipe() {
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(HekaCite.getPlugin(), "crab_rune"), this.build());
recipe.shape("aia","imi","aia");
recipe.setIngredient('m', Material.EMERALD);
recipe.setIngredient('i', Material.ARMADILLO_SCUTE);
return recipe;
}
Can someone help me 🙏 ?
PlayerHomeData
I've been avoiding nesting maps :)
"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.
Yes, yes. Nested collections means you should wrap them.
what do you mean exactly by not working? describe in "deep" what happens
i've edited
detail not deep
Set your shape as "d", "D", "N" instead.
yeah that, i couldnt remember the word. Thanks for that assist
cause it's a line craft okayy thx mate
thx a lot GL !
And if you want to enforce empty slots, use spaces
🤔 gotta make a tournament system for a minigame network
should I make template vs instanced classes or just have empty entries
"d", "D", "N"
Works for
d## | #d# | ##d
D## | #D# | ##D
N## | #N# | ##N
but " d ", " D ", " N "
only works for
#d#
#D#
#N#
yeahh i see
not yet, havent gotten that far
Looks like you're slowly getting the hang of it :P
Already better than before
Thank you y2k for showing me. I didnt understand how to save till i thought about it and thats all User does lol
Guys, I recently made a plugin with Kotlin, I get the head from the Minecraft-heads section with the command block. And when I said /addhead, I was saving this head. The server I set up via Windows was also fine, but I rented a server at Apex hosting and when I said /addhead there, it gives this error.l
An error occurred while saving the skull: null value in entry skull-owner-null
What's this?
There is absolutely no problem with the code, because I can download the head plugin and save any head
I don't only get things from the Minecraft-heads website.
Well there is the io part, like file downloading, file operations, database calls etc, things that may take an arbitrarily long time to compute. Here concurrency is key, the fact that we can download a file and at the same time continue to run our app.
Then there’s the parallel part, that is often if you compute let’s say a very big mathematical task, such as multiplying a series of colossally large numbers (stupid example). This won’t take an arbitrarily long time, but heck does it take a long time. Here since multiplication is commutative by definition (=order does not matter), we can divide this into smaller problems, and then we can compute these smaller problems on different cores on the cpu at the same time (in parallel) if we have hardware that allows us to, this is far faster than to only let one core do all the work.
when i push a commit to github through intellij for some reason it says BuildTools is the author of the commit. But Im logged into my account in settings
you can save it after doing something with it
assuming you do it asynchronously
you can also save it optimistically
Ah I remember I had that
meaning that you only save it if its currently not saving
I do, but should i have a timer that saves it every x minutes?
how did you fix it?
It depends
If it's a highly uh
volatile?
environment
where data changes a lot
Then saving once in a while is aite
Change the git username and email. It happens if you build spigot before setting your git username
The only time you realistically would wanna stick with running a buffer that syncs and saves all the data is if you for example don’t wanna bother the database constantly or ur file system, which is understandable if you aim to horizontally scale where you can compromise on high real time data availability lets say
Where is it set? I have it in settings>Github and the only option is to remove the account
In git
ty
@lost matrixcan u look here sir
every time you change it
well you'll never have data losses
But you hammer your persistent storage medium
you definitely deserve a little beating
i love beating my postgres
Lets say you want to track the distance a player has traveled via a certain mount.
For this you use the PlayerMoveEvent with a delta. Imagine now starting a query for 20 players in the PlayerMoveEvent.
This will lead to problems in no time
well that's what you cache stuff for
Caching writes?
starting a query
writes
Guys, I recently made a plugin with Kotlin, I get the head from the Minecraft-heads section with the command block. And when I said /addhead, I was saving this head. The server I set up via Windows was also fine, but I rented a server at Apex hosting and when I said /addhead there, it gives this error.l
An error occurred while saving the skull: null value in entry skull-owner-null
What's this?
There is absolutely no problem with the code, because I can download the head plugin and save any head
I don't only get things from the Minecraft-heads website
How about you dont start a query every time your data changes. 🙂
by query do you mean a write or read operation
Persisting in any way
The proper way would be to flag your data as dirty and only persist it every few minutes, if it changed.
Spigot version?
spigot 1.8.8
🤷
1.8
glhf
Support for that version was dropped half a decade ago
I don't think it has anything to do with the version.
Because I have installed many heads plugins so far and they worked successfully.
Could be, we will never know
any language is a configuration language if you twist reality enough
how do i make gson throw an exception when deserialized object has null fields instead of just leaving them null?
i wanna make sure that my object never has any null field
i think it by default should omit null fields
it does yeah
i need it to throw instead or just make the whole deserialized object null
so i can easily validate
I program a 1.20 minecraft plugin and want to use sendBlockChange but ist doesnt work
Hmm, I think one way is to wrap with a custom TypeAdapter or TypeAdapterFactory
but idk
You could validate the nullness in the class itself
like whatever class/type u deserialize, in its constructor
Can someone help me with that
Okay im stuck, whats a good way to ignore a configurationSection thats null?
public Set<String> getPlayerHomes() {
if (fileHandler.getConfig().getConfigurationSection("Homes").getKeys(false) == null) {
return null;
}
return fileHandler.getConfig().getConfigurationSection("Homes").getKeys(false);
}```
.contains...... lol
?components
For hoverable, clickable, hex colored, or otherwise complex text, use the component API. Documentation can be found here:
https://www.spigotmc.org/wiki/the-chat-component-api/
yes
but
that does not answer my question
actually it does
For hoverable, clickable ...
A basic java question: suppose you have a class which takes a boolean as a parameter, and it contains a while loop, and this while loop will do some math, and then based on the boolean, will do one of two sets of math, before ultimately returning a value. I want to avoid re-checking the boolean inside the while loop again and again and again -- isn't there like some kind of consumer thing to avoid having basically two classes that are almost exactly the same except for the chunks of code related to the boolean? Anyone know a resource for this?
Very insightful sir, I appreciate it!
declaration: package: org.bukkit.event.entity, class: EntityDismountEvent
I'm trying to be teleported to a player on any server where he is (using Bungeecord), I'm not getting any error but it does not work, if someone has a solution:
https://hastebin.skyra.pw/exupicuyof.kotlin
.kotlin
it's java
hastebin moment
Hello, I created a plugin that allows you to make holograms and I would like to know how to add different lines such as displaying the player's name, the only track I have is protocolib
what bukkit version?
Consumer for boolean?
Wait dou have the actual code at hand?
why is the boolean checked inside the while loop, is it supposed to dynamially change what kind of operation it is doing mid-computation?
it's not
i'm just
trying to figure out a way to not have two classes all with almost the same code
except
one is like
while (fartloving = true) {
x = x+10;
if (farteater) {
x = x +1;
} else {
x = x*2;
}
if (x > 100) {
fartloving = false;
}
print("I love farts!");
}
if you have two classes whose code share a good chunk of logic, the common way to deal with that is parametizing whatever logic is shared
love the variable names
farteater being the boolean
Hi is there any where I can request commissions in spigot discord or the website?? would the forums work?
lol
you'd have to clarify
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
thanks!
i'd like to do something like
class void FartMaster(Codechunk codechunk) {
while (fartloving = true) {
x = x+10;
codechunk(x);
if (x > 100) {
fartloving = false;
}
print("I love farts!");
}
}
i just dunno how to do that
just cant remmeber what that is
I mean one way is to pass a single abstract method interface
aka functional interface
Consumer perhaps
I thought you were asking for something far more complex for a second, what you want is just a consumer
well, in this case rather, a Supplier since you'd need to mutate x
Just google around about “Java functional interfaces” its basically the equivalent of passing around functions, since java doesn’t really support that semantic like other languages we need to create classes with a single method instead
here I was thinking they were trying to convert the branch into a bitmask lol
Yea well the original issue was somewhat poorly worded
🥺
This usually indicates that they have missed some fundamental aspects of learning the language; they are aware it's possible but lack the knowledge of how to proceed. I would take a basics course to serve as both a refresher and to reaffirm my foundations if I were you
@restive mango ^
I assume you already registered incoming and outgoing
I tried to phrase it in a non-condescending way but I lack the writing skills to do that apparently lol
What can I do to solve my problem? 😦
Eh let me fire up my pc
xd dw :).
@dense falcon I dont remember correctly
but iirc I think "bungeecord" channel consumes messages and whitelists the special subchannels like ConnectOther
i havent fiddled with it in ages
but either,
use "BungeeCord" + bungee sub channel specification
or use custom channel all along
id advice former
Hey @ivory sleet if you remember that registry system I posted in the mega thread, all I did was remove the abstract modifier from the class, does this pretty much clear up the design?
I think the only reason it was abstract was because I wanted to implement some abstract methods but never did so it ended up just being used as the base impl for other registry classes
yes
for sure
Ok cool yeah I think I was probably stoned or something lol
u got it on github?
Forgive the naming, I changed it like 3 days ago or wtv and haven’t touched it since
I was also gonna put it a clearAllEntries method but not sure anything else beyond that
the register method may wanna reject duplicates
else its fine
I think at least
:)
I was expecting to override a lot of entries with the other registry implementations so I think that’s alright
More edge case stuff?
just in general
like else u'd have to do sth like
get(x) == null -> throw blah every time
Right right
Is what I’m doing with this system somewhat common? I feel like the fact that all you have to do for the actual implementations is define the generics and then it’s good to go
Well rather smart I guess
ig so
I just feel weird having a visually empty class
not sure why GUIRegistry needs to be a class still
I mean the Registry impl is reusable on its own
To define the generics right?
na
Go ahead
You just blew my mind kek
:,)
what is this supposed to be for
Idk why it never occurred to me
right now with that it just looks like a wrapper around a Map
i assume a registry implementation similar to mojangs registry stuff
Originally it was just practice with interfaces and abstraction
ye makes sense
anyway, u should look at mojangs registry impl
its a bit more complicated due to that they care about ownership of values significantly
but it has some good stuff u could yoink
I hate yoinking code! D:
inspiration
Kek
:,)
Even when I’m using something as “reference” I feel it ends up being too similar and no longer follows my use case anyway
So I guess I just have to learn more about implementation practices
yeah sure, but at some point reading others' solutions can be quite helpful
Well solutions sure, but I mean currently it does what it’s supposed to, ie: no solution is needed, there’s only room for improvement
Which I guess you could consider a solution
Eh fair enough
yea well solutions/improvements/inspirations w/e
Yeah
whenever I implement something I am always super curious to see how others have done it
that said ofc its not always I have the time to look into such stuff
but ye
Well I’ll certainly have to look at mojangs implementation
Do you know where I find this?
All registries are a glorified map Wrapper:P
Some are just more complex glorified map wrappers
I mean, the line that differs them is what additional functionality they add
for example, Mojang's is supposed to be a replacement for enums and facilitating their serialization framework on top
So in other words basically what I have with extra methods kek
yea another example is inverse mapping, w a value to key identity map ^^
Sorry didn’t mean to cut ya off con
lol allg
So this is probably a question that I just go look for an answer but I’m lazy, how does mojang freeze their registries during runtime?
I assume this is called after all the entries are submitted as it were?
yes mojang buffers a set of consumers that populate the registries
thats also when the registries get frozen
iirc on fabric and/or forge they inject and change it up somewhat
the registry, when frozen, will bound all keys to their respective value
you can only reference the value of a key by their Holder.Reference and if a value is changed at runtime, it'll throw an IllegalStateException
well yeah, but that'll most likely break things that expect the registries to be frozen and whatnot
it for sure will
😭
Hey if Mojang didn’t want me to add stuff to the registries
They shouldn’t have made them registries
Fair enough kek
as if people weren't adding things to enums before registries were a thing lmao
Well yeah but that’s even more jank
its a pity there's still enums around
in mojangs code
like hey, i wanna be able to add new item rarities
Tbf they don’t do much
yea well in my mod I had to do some quirky goofy mixins injecting the backing enum array etc
:c
Isn’t it just the item name color
yea
well it still has to abide by dfu w codecs and shit since its being shipped through item components
would be nice if it were a registry just :/
Just uhh
Force the item to always have a custom name with the color
yea true, thats one way
Although that would get janky in anvils
So then when are enums actually useful?
they're useful if you don't need things to be data driven
also short things like Results etc registries or interfaces for that would be overkill
I consider an enum basically a list of static constants, is this correct thinking?
e.g. Imagine a simple transaction system
public enum TransactionResult {
SUCCESS,
FAIL,
TIMED_OUT,
}
a fixed list
or rather set, but w/e
Right yeah
But there’s still ways around this isn’t there?
As in making dynamic changes to said enum?
uhm with bytecode sure
but you can do anything with bytecode
so that's not really a good argument for enums
Hmm alright
idk I mean a lot of systems that do end up relying heavily on enums eventually come to regret it, for example ChatColor, and other enums in the api has over time had to be changed into classes partly because mojang changes its code
and then as y2k said, bytecode, lovely commodore is needed
I wish I could be around you nerds irl, I feel like I’d retain so much more sigh
aren't you a nerd as well? :>
just go to college
in my own code here are examples of registries vs enums
enum Measurement // measurements don't change :P unless metric system blows up
class CollectorMetaRegistry extends Registry // We can arbitrarily register CollectorMeta at runtime to support additions via other plugins
enum Operator // We don't just magically add math operators safe to say this is a safe enum
class ItemRegistry extends Registry // we can just register items at runtime
I’ve only read like 6 books since January I don’t think that’s nerd level yet
bunch of compsci nerds to get sniped
most compsci students are idiots
I plan on a cs boot camp of sorts later on, also I dropped out of high school
I've only met a few who actually know whats going on
everyone is an idiot by that standard, I'm mostly talking about people who plan to go for a master's
those are the actual nerds
I'd go for a masters, but its way too expensive lol not gonna drop another 100k I'm good with 2 years of college for my Bachelors
maybe if a company payed for it
but no way out of my own pocket
Well that’s why I want to go to a boot camp
boot camps kinda suck lowkey you're better of spending time just obsessively coding projects you enjoy]
