#help-development
1 messages · Page 951 of 1
how do i make a dependency and the library
Make sure you only call this funcrion from the main thread
Well, there's a toggle
boolean async in the constructor
Make sure your event matches wheter is main thread called or not
i have 2 custom events, one that isn't called in discord listener adapter and doesn't work
another using bukkit listener and works
public void linkPlayer(Player player, User user) {
LinkEvent event = new LinkEvent(player, user);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()) {
String path = "linking." + String.valueOf(player.getUniqueId());
String dc = String.valueOf(user.getIdLong());
String code = Common.getMapKey(linking, player).toString();
linking.remove(code);
config.set(path, dc);
save();
player.sendMessage(Common.colorize("&7Your &aMinecraft &7account has been linked to discord"));
player.sendMessage(Common.colorize("&7Account: &3" + user.getEffectiveName()));
}
}```
That's async
no
i use message receive event with jda
is there any way to create a callback on an Interaction entity for when it gets clicked?
everything i have is dark but intellij lol
why
anyway, i don't see its async
any idea why World#getEntities returns an empty list in my world? i can clearly see entities
Uh, that event doesn't match callevent from bukkit
dang it
how can i fix that
Well, show LinkEvent instead
If it works come back
If it's really async then it's best to make your code handle it properly
Is it possible to get a recipe or a key to it during crafting if you create a Craftitem?
Otherwise you'll get weird bugs
how would i make it proper
it worked
Okay, see why your method is called async
See if you can transform it before it reaches this method
A good way to fix is to use bukkit get scheduler runtask plugin, () - > {your task here}
If you fix it this way remove super
is the task the linkPlayer method calling or event using
Whatever is calling linkPlayer
ok
wasn't there something that bukkit/spigot is not made for being extended?
i vividly remember something there
The inventory holder?
I think people were abusing that by implementing it themselves
in general don't extend anything unless it's explicitly stated that it's fine to do so
ahhhh icic
yeah don't go implementing the interfaces neither
yeah i just mentioned that bc i saw Event being extended
here
(unless it's stated that it's fine)
alright
it worked without super() thx
how can I remove a vanilla NBT data tag from an entity? (/data remove entity .... foo)
what are you trying to do, exactly
so how do i make a library for my plugin :)
xy here is I'm using interaction entities and checkcing in a loop (💀) and trying to remove the old interaction player, which is how i did it with command blocks
uh why exactly do you need to do that
because otherwise the interaction will stay the same
i only want my code to trigger on click
Question, why is my grave command not working? I mean i see i have the grave command in stalled and i have the items in game, just the graves arent coming up when players die
and not every tick after a player clicked
then use the even on entity interaction
ah ty
awesome
something you can shade into your plugin or a plugin on itself?
you can extend event to make your own
if you make your own this won't disrupt any other events so you're free to do so
basically, i want to be able to put a dependency from the plugin i have, in another plugin so i can use its classes
and idk whats the difference in what you said
i mean like that
something you shade will end up being in the jar itself
add the plugin, and use its classes
your jar
okay, click install in maven on the library
then look at the description you gave to that plugin
and then use those in a <dependency> tag
yeah i figured, i just thought it was a nono
there's bukkit get server call event
if this wasn't intentional it wouldn't had been exposed
the artifactID and groupID?
so like this without the packaging
youp
use scope provided
just in case
and there's no packaging
that's specific for this pom
awesome, now you can use this in your plugin
wait, did u put this in the plugin you want to use right?
yea
alright
When trying to consistently track an itemstack in a player's inventory, would inventoryClickEvent be the correct event to use?
Sounds good
but im wondering,
for what i made i can get instance and stuff of plugin
i see other plugins with like
SkyBlockApi.onSkyBlockClaim
not instance and stuff
you can use YourPlugin plugin = getserver getpluginmanager get plugin (YourPlugin.class)
but it's not the best way to access an api
do i put it in the main plugin or the plugin that hooked main plugin
ok
private static final Map<UUID, Integer> petExperience = new HashMap<>();
private static final int BASE_XP = 100;
private static final int XP_INCREMENT = 50;
public static void addExperience(UUID petId, int experience) {
int currentXP = petExperience.getOrDefault(petId, 0);
currentXP += experience;
petExperience.put(petId, currentXP);
}
public static int getLevel(UUID petId) {
int xp = petExperience.getOrDefault(petId, 0);
int level = 0;
int xpForNextLevel = BASE_XP;
while (xp >= xpForNextLevel) {
xp -= xpForNextLevel;
level++;
xpForNextLevel += XP_INCREMENT;
}
return level;
}
public static int getXPForNextLevel(int currentLevel) {
return BASE_XP + XP_INCREMENT * currentLevel;
}```
Could I get your opinion on this leveling system fr33?
is YourPlugin the later or the library
the library
you can add + experience after get or default
or petExperience.put(petId, currentXP + experience);
oh yeah lol
the get level looks alrightish
idk illusion mentioned it, I love to hardcode everything
maybe you want to move it somewhere else
because it does more than get level
usually you want to keep it as simple as you can
so you have control over it
You think I should implement getlevel through every pet class?
no
you can have an int for level
and calculate this at add
so your get is just that
Ok so perhaps implement a setter method for level in the interface, I could just write addExperience out to make the checks for level ups as it were and I think that'll make it simpler
you will also need an object that stores both level and experience in your hashmap instead
right
Would a list be fine for this? I wouldn't need a map for this as I'll check the level ups through addExperience
er
wait
I'm cooked
wait until conclube is online, he'd probably suggest an ImmutableConcurrentReverseSquaredTreeSet or sth
it's not as readable
does it have to be thread safe?
and you def don't wanna end up using something conclube suggested
I mean
I don't believe so actually, so no
It's just gonna be tracking xp increments as it's in the players inventory
so I could do that off main thread right?
i used to have an array where i stored game data, but after a year i forgot which id was which, basically magic ^
so be careful when you want to cut corners
I'd rather do it the correct way (rather the not dumb way)
God damn
English is not englishing tonight
you only need concurrent stuff if
- it needs to be thread safe, or
- if you're lazy and want to be able to insert/remove while iterating over it without an iterator or second collection
Alright so then no haha
Not for a list
no i mean for those from .concurrent
whut
i think they're only for handling multi threads
oh you mean whether you can do sth like this?
for(Something sth : myConcurrentThing.entrySet()) {
if(/* ... */) {
myCOncurrentThing.remove(sth);
}
}
yes, that works
pretty sure it's undefined behaviour
huh? it's definitely allowed for Concurrent collections, isnt it?
maybe, I suppose it has to work for multithread support
javadocs say this, but it doesnt mention that it's not allowed (or undefined behaviour) if the SAME thread is removing/inserting into a concurrent collection
would be cool if java implemented the remove; keyword for loops
since for each loops are just fancy iterators under the hood
there is removeIf, but I agree
Another question to the modern inventory guis...
Let's say, I want to create an admin-tools gui so i create a button for let's say "ban".
I would need another inventory with a list of players (e.g. with player heads or sum).
How would I tell my plugin then to open another GUI and make it remember the action from before?
but you can't really run logic in there
it's out of the contract
you can it's basically a lambda
yes, return true;
Would it be something along the lines of creating a class like in the tutorial the "PianoGUI" But instead of only having AdminGUI, I also need PlayerListGUI and pass the action from the AdminGUI?
you can return true, but the name sounds like it's designed for removing, not iterating
removeIf iterates all entries
yes
any element you return true on will be removed
but i feel like this is a side effect
okay very cool. thanks. always nice to get confirmation on a thought process i have :DD
what if a new update finds a way to process the collection without calling every entry?
what?
for each vs removeif contract
you don't know if removeif will get an optimization later on and not be called after each element
How can we check if entry satisfy criteria if we dont iterate over it
crystal ball?
it's a predicate
Yeah probably
Docs say if element satisfy criteria. That means they assume our boolean logic is based on each element of collection
well, you can do it if you want, i just don't feel it's a good idea
point 44 actually
oh my god i'm loving this, it makes so much sense. now i only gotta figure out how to handle paginated guis
ngl love 7 for that guide
oh my f-king god, I just realized there is actually a matrix operation dedicated to fix the problem I've been having for days
called change of basis
Why is the cooldown not installed and the standard one used? this works only with the chorus
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerItemConsume(@NotNull PlayerItemConsumeEvent event) {
if (event.getItem().getType() == Material.CHORUS_FRUIT) {
event.getPlayer().setCooldown(Material.CHORUS_FRUIT, 10000);
}
}
Fkn linear algebra
The cause of and solution to all 3d problems
I hate this, really
btw you want to know the stupid shit that is causing this?
pre-1.20 display entities face north by default
post-1.20 they face south
also armor stands face south
why is this a problem? Because it flips the coordinates from blockbench
the transforms are all correct, the rotations are all wrong
and I can't just flip it 180 because each individual display entity is wrong
How to run some code right after world is loaded?
load: POSTWORLD would not work, because I also need some code to run at startup
use WorldLoadEvent?
Is it guaranteed to run just once?
?
it should fire on each individual world load
so yea also when another plugin loads a world
Hey, I wanted to know how I can get the teams from the default Minecraft /team. I want to get all teams.
When can an ItemMeta, aquired by using ItemStack#getItemMeta, be null? I've never had that happen.
When the item stack is air afaik
Can anyone teach me how to configure simplevoicechat?
aaah
I want to get the first 54 online players to begin creating a paginated GUI. My current (beginning) approach is this:
@Override
public void decorate(Player player) {
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
int elementsPerPage = 9 * 6;
for (int i = 0; i < onlinePlayers.size(); i++) {
if (i >= elementsPerPage) break;
createPlayerButton(player, ((Player[]) onlinePlayers.toArray())[i]);
}
super.decorate(player);
}
The problem is: I can't just cast Object[] to Player[] apparently. because it will "produce 'ClassCastException' for any non-null value". How could I fix that?
(For now I basically just want to limit the players for the first page and then I'll continue by myself
ScoreboardManager#getMainScoreboard()
probably
oh yeah and: createPlayerButton wants Player and Player
why arent you using an enchanced loop
because of the max amount
i want to limit it to the first 54
i usually didn't have that problem because i used an enhanced loop but now I do
lol
just break from the loop when you have processed 54
tha- uhm
works in enhanced loops too
break simply exits the current level of loop
how do i check for the 54 tho?
a counter
it has to be final is all. you can still add
pleas
if it's final, you can't add, wym?
what? No you can still add to a final variable
int counter = 0;
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
this.addButton(counter, createPlayerButton(player, onlinePlayer));
counter++;
if (counter >= elementsPerPage) break;
}
``` u mean like this?
nnnnno?
final int
tries to modify the int
not primitive
._.
How could I set the texturepack of a player using spigot? If I use serResourcePack("url") the player can just reject the download and continue playing and nothing happens
that's why i was confused!
however, in your case you don;t need it final
I was assuming you would be using a lambda
what-
you are not so it doesn;t matter
you mean Bukkit.getOnlinePlayers().forEach(...)?
this one is fine
in this case
yes
?nms
ahhhhhhhhh i think i know what you mean
in lambda's external variables need to be final
yeahhhhh
i have this in several places in my code
IJ warns you if you don't so yeah anyway
what doesnt IJ warn you about these days
it even nags me to use a more robust logging framework instead of printing the exception like a chad
true
IKR i was so annoyed when it first told me that LMAO
then i redid my logging
lol
Can I somehow get a playerhead with an arrow that points left and one that points right?
plenty of heads online to find
lovely
thanks
If I open an inventory using Player#openInventory while having another open, does the first one close automatically (with the InventoryCloseEvent firing)?
Yes
yes
that's perfect, thanks
As in you want to upload it to the spigot site?
Just make an account and upload it
They've been answered in #general
For InventoryClickEvent would getCursor() return the ItemStack the player is currently holding in their cursor or the item the players cursor hovers above?
in their cursor
k, ty
Yes
I Making Account
https://www.spigotmc.org/wiki/adding-plugins/
probably explains all you need to know
I am currently in the class PlayerListGUI.
Is there a difference between doing:
PlayerListGUI playerListGUI = new PlayerListGUI(this.action, this.guiManager, this.pagination++);
guiManager.openGUI(playerListGUI, player);
```and doing
```java
guiManager.openGUI(this(this.action, this.guiManager, this.pagination++), player);
```?
(I want to switch the pages of my PlayerListGUI, in case it wasn't obvious)
oh nvm the second thing doesnt even work lmao
oopsies
ignore that
System.out.println(supremeSpawnerBlock.getHologramLocation());
CreatureSpawner creatureSpawner = (CreatureSpawner) e.getBlockPlaced().getState();
creatureSpawner.setSpawnedType(supremeSpawnerBlock.getSpawnedEntity());
creatureSpawner.getPersistentDataContainer().set(SupremeSpawnerBlock.SPAWNER_BLOCK_DATA, new SupremeSpawnerBlockDataType(), supremeSpawnerBlock);
System.out.println(
creatureSpawner.getPersistentDataContainer().get(SupremeSpawnerBlock.SPAWNER_BLOCK_DATA, new SupremeSpawnerBlockDataType()).getHologramLocation()
);
creatureSpawner.update();
For some reason, even though supremeSpawnerBlock is clearly not null since printing out the hologram location returns a value, getting the spawner object from the persistent data container and then the hologramlocation again returns null. It tells me it fails to deserialize the SupremeSpawnerBlock class. Heres the full class of the BlockPlaceEvent: https://paste.md-5.net/yuxoruseso.java
@EventHandler
fun onInteraction(event: PlayerInteractAtEntityEvent) {
if (event.rightClicked.type == EntityType.INTERACTION) {
val block = event.rightClicked
val world = event.player.world as CraftWorld
val nmsWorld = world.handle
val nmsBlock = nmsWorld.getBlockEntity(BlockPos(block.location.blockX, block.location.blockY, block.location.blockZ))
val nbtTagCompound = net.minecraft.nbt.CompoundTag()
nmsBlock?.load(nbtTagCompound)
event.player.sendMessage(nbtTagCompound.toString())
}
// ..
}
Spawnerblock class: https://paste.md-5.net/hoheyufose.java
Hello Chat! I want to load the nbt tag of the right-clicked block. However, it keeps returning only empty objects. How should I solve this..?
sorry but "Hello Chat!" lol, idk why but that made me laugh just now
lmao
XD
so.. how to fix that..
That was indeed funny
sorry but what is that??
oh
Show the exception that tells you how the deserialization failed
wait is that kotlin?
not failed.
but that return empty object
other person
you need the TileEntity not the Block
Some blocks simply dont have any nbt data on them
Yo, @lost matrix, would you mind answering this message when you have time?
how to get TileEntity?
Ill take a look
CraftWorld#getTileEntityAt(...
https://paste.md-5.net/exehobixep.js this is my deserialization method
I've made some changes and debugging in the code, before all that the error told me that "hologramLoc" is null, but in fact when retrieving the object from PDC, the whole object was null
Looks like your switch statement is not triggering
Wait there are more problems even
it used to work before, but I made a brand new class for spawnerblocks since I wanted a specific class for Spawner Blocks and Spawner Items
CraftWorld#getHandle().getTileEntity(new BlockPosition(..
Your world is not an nms world, its a CraftWorld
oh..?
?stash for me
Tutorial: https://www.spigotmc.org/threads/tutorial-skulls.135083/#post-1432132
Head: https://minecraft-heads.com/custom-heads/head/83899-plush-arrow-right-double-sided
I'm currently following a tutorial on how to get a custom head.
On the page where I got the head from (linked above), I found this "Minecraft URL" (21534c9bea4a10745128f0d7d5bd8fb1848ac82c793323be5c0612a91dd58bbd)
Is this what I have to encode and put into a game profile? Because the tutorial is talking about important stuff as in "not forgetting the http://" and so on, and this code does NOT look like a URL lol
oh
[HYPERLINK BLOCKED]
Lol
Spigot 1.18.1 added the new PlayerProfiles class, which finally allows us to use custom heads without needing any reflection! You can obtain them as normal items, or actually place them down into the world. I’ll show you how both works: Creating a new PlayerProfile First, we gotta create a new PlayerProfile object. To do so,...
That's better
ohhhh
this is the key part for the https://textures.minecraft.net/texture/...
thanks coll
oh shit with this tutorial i don't even need reflection anymore, that's sick
One question about it tho: why keep using the same UUID for all the profiles with the different textures?
sounds like a caching issue too ^
cause the uuid doesnt really matter. u just need a fake PlayerProfile
It does
By polling for displaying i mean, every time a user is shown the cooldown, you look at the timestamp and calculate the difference to the current time. Then format it and show it to the user. This also includes data being displayed in an interval to the player via a timer. The polling frequency needs to be twice as high as your target resolution frequency. So if you want to have a precision of 1s, then you need to poll every 0.5s. (Nyquist–Shannon sampling theorem)
Differnt UUIDs won't stack
i think the tutorial implies you to have a random uuid
I usually just use a uuid based on the texture
given its static final i dont think so
even tho i don't need them to stack in this case, i'll still use the "random" uuid instead of an actual random uuid.
how does that work?
i really don't know what happens internally, it might not matter
for heads at least
how can i fixx this;
chatgpt said i should open the inventory in an bukkitrunnable but dont works either
you can't run sync code in a async context
The reason to use teh same UUID (was) to prevent teh server cache exploding as creating a new Profile also added it to the UserCache. No idea if it still does
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.nameUUIDFromBytes(url.getBytes()), "Custom");
PlayerTextures textures = profile.getTextures();
try {
textures.setSkin(new URL(TEXTURE_URL + url));
} catch (MalformedURLException e) {
return null;
}
profile.setTextures(textures);
return profile;
}```
Tis what I use
aaaaaaaaah
import com.tomlegendxd.zgiveaways.ZGiveaways;
import com.tomlegendxd.zgiveaways.commands.Gcreate;
import com.tomlegendxd.zgiveaways.util.PublicVariablen;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class Messages implements Listener {
public static String loretitle;
public static String getLoretitle(){
return loretitle;
}
@EventHandler
public void onmessage(AsyncPlayerChatEvent e){
if (PublicVariablen.getTitle() == true){
e.getPlayer().sendMessage("test");
loretitle = e.getMessage();
PublicVariablen.title = false;
e.getPlayer().openInventory(Gcreate.getInventory());
new BukkitRunnable(){
@Override
public void run() {
e.getPlayer().openInventory(Gcreate.getInventory());
}
}.runTask(ZGiveaways.getPlugin());
e.setCancelled(true);
}
}
}
this is the code in need to open the inventory
Awesome. This is so helpful, so thank you very much. As for polling for displaying, I assume I should peek instead so I dont remove it from the priority queue, right? Or should the actions that require displaying be kept elsewhere? My initial thought is to peek at each action and determine if they should be displayed. Is that a good idea? It seems like that may be inefficient given how many actions there may be that don't require displaying.
you can shorten your bukkit scheduler by
i forgot to delete it will it work now?
World#getBlockState(Location) and cast to tile entity
tile entity?
might be tile state
oh i see
What do you need this for btw?
I want to get the nbt tag attached to the interaction block and use it in a conditional statement.
uh, why use nbt when TileStates have PDC?
Which tag?
?pdc
Oh
Spigot has an API for nbt data
wt..
just flag your blocks when you place them in their PDC
Will the nbt tag specified using summon be also loaded?
oh..
although you shoudl be able to format it to add
with the summon command
Its stored as a BukkitValues tag
?gui
tf are tile entities?
brewstand e.t.c
thats why those dont work with pistons cuz mojang wasnt talented enough to make all that move
so many cool things would be possible if they could be moved 😦
Caused by: java.lang.ClassCastException: class net.minecraft.world.level.block.state.BlockState cannot be cast to class org.bukkit.block.TileState (net.minecraft.world.level.block.state.BlockState is in module minecraft@1.20.1 of loader 'TRANSFORMER' @4d09cade; org.bukkit.block.TileState is in module arclight@1.20.1-1.0.5-1a8925b of loader 'TRANSFORMER' @4d09cade)
at org.server.sleepskinplugin.event.MainEvent.onInteraction(MainEvent.kt:114) ~[?:?]
... 24 more
ahhh yes casting
casting and i have our differences since i tried working with doors (idk why it was so hard)
not sure whats hard about it as long as u cast safely
You cant directly cast nms objects to spigot objects
And vice versa
and confusingly enough, an NMS BlockState is not the same as a Bukkit BlockState
NMS' BlockState is wrapped by Bukkit's BlockData
if (event.rightClicked.type == EntityType.INTERACTION) {
val block = event.rightClicked
val world = event.player.world as CraftWorld
val nmsWorld = world.handle
val nmsBlock = nmsWorld.getBlockState(BlockPos(block.location.blockX, block.location.blockY, block.location.blockZ)) as TileState
// val nbtTagCompound = CompoundTag()
event.player.sendMessage(nmsBlock.persistentDataContainer.toString())
}
here is the code
Yeah there's really no reason to be using NMS for that snippet
Or I suppose it's best to ask what your goal is to begin with
am i better off constantly pulling from sql ? or making constructor storing all the info i need for the player. and backing up every x to sql
cache
I ultimately want to import the nbt tag attached to the interaction block.
Always cache
You can cache the pull, but always push changes asynchronously
I don't mind using NMS or anything else, so please tell me how.
i didn't know shit, lol
entity
Because Interaction is an entity
Interaction
Why are you trying to access block PDC then?
Yeah you're checking for an EntityInteractEvent on an INTERACTION entity type
There are no blocks involved
Unless there's a block at the same position as your interaction entity I suppose
You can just put the data on the entity tho
Things are starting to get more and more confusing...
i didn't read the whole conversation, but is there no such thing as block pdc? There's only the CustomBlockData api, no?
tile entitys do have pdc
normal blocks do not
special blocks
interaction block is tile entity?
Square one. Are you wanting to listen for when a player right clicks a block?
no
Interaction is an entity
yes
yeahhh i remember, i needed CBD for my IronDoor key thing lol
Okay, so you want PlayerInteractEvent, but you want to be getting getClickedBlock()
General question: it would make sense to load ALL data, that is stored in files/sqlite-db onEnable, no? for performance reasons?
depends on what kind of data
I already tried this but it didn't work and when I used InteractionAtEntity it worked fine. Even now, I get an error when I right-click, but it works.
if its playerdata. i would say the best lifecycle is just while the player is online
no, load playerdata when the player joins, unless you have some data not related to player?
@EventHandler
private void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block clickedBlock = event.getClickedBlock();
if (clickedBlock == null) {
player.sendMessage("You did not click on a block");
return;
}
player.sendMessage("You clicked on a " + clickedBlock.getType().getKey());
}
This is your basic listener for clicking on a block
e.g. a banlist
ahem
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
isnt a ban tied to a player?
yes
I'm going to square one because everyone is throwing all sorts of nonsense towards this person and they're getting confused when we don't even know their goal
kick him
yeah
i mean how often are you going to check a banlist i would probably not cache that.
i'm doing that rn but i thought about it being... slow? at least on a large scale
You don't need to cache that. If it's a ban list, use the AsyncPlayerLoginEvent
i wouldnt load all the bans, imagine you are hypixel with millions of bans and every server has that cached
Just lookup bans directly in the asyncprelogin event
since i'm calling the file everytime a player joins
You can do tasks synchronously there. The event itself is async
You won't stall the server
right... the memory would explode
didn't think that far tbh
Does the vanilla server load the entire banlist?
hypixel did
deffo is
To go back, I tried this but I got a casting error.
riiiiight... why tf was i not using the Async event for this before? Lol
the beauty about the async event is that it stalls the login untill u have ur logic completed
go all the way back
what is your goal
while not stopping the server
Just don't stall it too long :p
asyncprelogin waits 30 seconds
this is my goal
that doesnt make sense
i suppose AsyncPlayerPreLoginEvent#getUniqueId and #getName returns the player's name and the players uuid?
why..?
you want to get a pdc tag off a block?
oh wait what?
well that makes no sense then
if you are loading a lot of stuff it waits 30 seconds until it disconnects
Up to 30 seconds
meaning you have 30 seconds to do your checks
ahhhhhhhhhh
After that the client will give up
yea
you do not need nms for this
Can't I even get the NBT tag?
would that mean if maaaaaaany players join at the same time, it could give up?
PDC is api
no
or is it per player?
for each player
oh
oh
ok i find how to use pdc
you can
thx chat
?pdc
I would simply not rely on data which was added through the summon command
you check the if the clicked block is null, then if the state is tile state then check the data it has
Wherent we on interaction entities?
We are on blocks now apparently
Alright then...
i think we should go back to square one
uh yes fair enough
@EventHandler
fun onAdvancementDone(event: PlayerAdvancementDoneEvent){
if (event.advancement.criteria.isNotEmpty()) {
try {
event.advancement.criteria.clear()
}catch (e: Exception){
println("Error by remove the Advancements: $e")
}
}
}
Can you help me I am trying to stop the advancements from loading on a player, sometimes (most of the time) this works but I get sometimes the error: java.lang.UnsupportedOperationException
well it might be usefull if we can see the entire error tracktrace
That's what you think 👀
Jokes on you, Hypixel runs vanilla
We actually just mod the straight up vanilla server, no events, nothing
Pure vanilla codebase
can you rate hypixel code from 1 to 10?
(for legal reasons, I'm absolutely kidding lol)
This is only the Error with the catch "Error by remove the Advancements: java.lang.UnsupportedOperationException"
assuming that's allowed
idk depends what part of the codebase. How good is your code from 10 years ago compared to now? :p
uh, a lot better, i guess i get the idea
e.printStackTrace,that is what he asked u to do
My code? An 11. Easy. Best programmer to ever exist. Someone from 2012 who hardly knew what they were doing? meh
/s :p
i remember they had to rework the tnt games server
i assume the code must've been a mess
that's cool
well hypixels anticheat worked fine 6 years ago 
I mean
I could see hypixel doing everything as a server fork
But that would be annoying to maintain
the anti cheat hypixel has is mostly manual isn't it?
well it worked automatically very well back then
Remember. No Mojmaps back then 👀
I'm just saying that pre-1.16 there were no Mojmaps :p
it was 1.14 choco
Maintaining a vanilla server would be hell
get ur facts straight
Fooey
Hypixel could make their own maps :p
choco_named_this_HisSuperCoolName
And yeah Mojmap startted in 1.14, but the original license was cringe
java.lang.UnsupportedOperationException
at java.base/java.util.Collections$UnmodifiableCollection.clear(Collections.java:1086)
at nvm.icrafter_mc.nvmhub.listener.general.player.Advancement.onAdvancementDone(Advancement.kt:12)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589)
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576)
at net.minecraft.server.AdvancementDataPlayer.a(AdvancementDataPlayer.java:232)
at net.minecraft.advancements.CriterionTrigger$a.a(SourceFile:21)
at net.minecraft.advancements.critereon.CriterionTriggerAbstract.a(SourceFile:71)
at net.minecraft.advancements.critereon.PlayerTrigger.a(SourceFile:23)
at net.minecraft.server.level.EntityPlayer.l(EntityPlayer.java:657)
at net.minecraft.server.level.WorldServer.a(WorldServer.java:882)
at net.minecraft.world.level.World.a(World.java:687)
at net.minecraft.server.level.WorldServer.lambda$8(WorldServer.java:452)
at net.minecraft.world.level.entity.EntityTickList.a(SourceFile:54)
at net.minecraft.server.level.WorldServer.a(WorldServer.java:432)
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1384)
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:387)
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1242)
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1054)
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304)
at java.base/java.lang.Thread.run(Thread.java:1623)
i still dont understand why they still obfuscate it if they are going to release maps anyway..
I tried this and it works well. There is no error, but the problem is that when I print the keys, an empty array appears.
Two reasons. File size and to dissuade the average joe from distributing source
Hello, I am trying to make a simple kits system but I am facing a problem. Basically I cant receive kits even though they're created and i can normally also create, delete and list them, there is also no errors here's the code:
Here is the KitsManager code: https://paste.md-5.net/arabepacop.cs
Here is the Kits command code in which I can manage the kits and receive them: https://paste.md-5.net/qixojurebe.java
i guess some of the advancements have an unmodifiablecollection as collection there and other don't
You can't clear advancement criteria
But I only get the error sometimes and not always
You would have to use AdvancementProgress#revokeCriteria() for all criteria
progress.getAwardedCriteria().forEach(progress::revokeCriteria);
which is why i said. some probably have a different collection impl
potentially
but yea. what choco said ^
Yeah probably. Best to assume it's always immutable
but like why does distributing source even matter
its out there anyway.
How can I set the texturepack of a player using spigot? If I use setResourcePack("url") the player can just reject the download and continue playing and nothing happens
if anyone knows the issue ^^ ive been trying to solve it for 2 hours and i tried everything possible to human mind
alright thanks
after setting the items. you might need to call Player#updateInventory() for stuff to actually show up
My code is now
class Advancement : Listener {
@EventHandler
fun onAdvancementDone(event: PlayerAdvancementDoneEvent){
val progress = event.player.getAdvancementProgress(event.advancement)
progress.awardedCriteria.forEach { criteria ->
progress.revokeCriteria(criteria)
}
}
}
but now it doesn't work anymore
thats possible for a human to think of and i said i tried everything possible to human mind xD
ima try again tho
But what should I put in the byte[] hash?
Thanks
You would have to delay it one tick later
welp it didnt work shuriken
At least I believe you have to delay it
welp time to debug then
if ur using intellij use debugger to walk through the method and see if the variables are right.
I tried setting the Kit object in the Map to a String and get that and it worked, also it sends me the receive message so i think thats already done?
the last line works
that doesnt mean everything goes right
yeah but i changed the ItemStack[] value to a String and it sent me that String when i was trying earlier
You shouldn't have to call updateInventory
yeah but we added just because there could be a 0.1% possiblilty xD
ur sure kit.contents() & kit.armorContents() are not empty?
cuz this code looks fine to me
thats where i create it
i wouldnt even need the ArmorContents because getContents includes that but i tried just because it might work some how
does getContents return a copy?
look at impl
where can i find it :p
idk if ur depending on the api or spigot itself
might not be able to see if ur depending on api
why does it matter if its a copy or not tho
cuz u clear ur inve before giving
potentially clearing that array
(i guess)
but i assume its a copy
i will get rid of the clear inventory
yeah same issue
ive tried with and without clear inventory before too
thatss odd.
bro yeah
its actually driving me crazy
it took me hours and i failed to fix it so i came here
well i dont have more time right now. i can try to look at it again when im home if ur still on this by then
when are you home
How can I change the title (name) of the TexturePack in the ResourcePack menu?
pack.mcmeta
Well the pack.mcmeta is:
{
"pack": {
"pack_format": 15,
"description": "Minigame Network made by Silvan!"
}
}
However the Title in MC is:
"World Specific Resources"
Ah wait I think that's just hardcoded for server packs
oh, so I can't change it?
Hello, I have a quick question for you guys.
How can I hide those RUN_COMMAND commands from console?
I am currently working on an update checker to check for plugin updates on multiple platforms (eg. spigot, modrinth, github releases). I currently have a small api and server owners can add plugin information into the config themselves.
As the information is relatively generic I was wondering if getting developers to put their spigot-id or modrinth-slug in their plugin.yml would be frowned upon?
If not, what's the best way to go about getting the plugin.yml file (plugin#getResource("plugin.yml")?)
Why do you need the spigot-id
To get their resource from the api
Where can I get Spigot API?
how am i changing a player's name fully with GameProfiles? anything i've tried lead to errors not being able to send messages anymore
[17:37:50] [Async Chat Thread - #3/ERROR]: Chain link failed, continuing to next one
java.lang.IllegalStateException: Missing key in ResourceKey[minecraft:root / minecraft:chat_type]: ResourceKey[minecraft:chat_type / minecraft:raw]
at net.minecraft.core.IRegistry.e(SourceFile:88) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e]
at net.minecraft.network.chat.ChatMessageType.a(ChatMessageType.java:59) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e]
at net.minecraft.network.chat.ChatMessageType.a(ChatMessageType.java:49) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e]
at net.minecraft.server.network.PlayerConnection.chat(PlayerConnection.java:2121) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e]
at net.minecraft.server.network.PlayerConnection.b(PlayerConnection.java:2189) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e]
at net.minecraft.server.network.PlayerConnection.lambda$17(PlayerConnection.java:1895) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e]
at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) ~[?:?]
at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:842) ~[?:?]
is said error
You can stack up to 8 potions in your inventory, such as to take a potion, click on another and stack it ???
not as far as i know? lol
potions are not stackable
(or at least not by vanilla means)
You can do a spigot update check with just the resource ID
Yeahh that's the id I was referring to
Maybe me calling it spigot-resource-id would make more sense?
Yes, I know, I want to make them stack, but I don't know how?
oh i misunderstood your sentence
If I change a player skin using PlayerProfile shouldn't I see the changed skin as well?
Yep, so the question was more regarding me suggesting others putting it in their plugin.yml for compatibility.
My thought was that it makes sense to be something that goes in the plugin.yml which my plugin will then just quickly scan over to see if it's present
yesss
Api is stupid just yolo
well okay my approach didn't change the skin at all anyway
Yeahh I've got a simple api setup which is pretty much the same thing but with more optional settings. I just thought that saying "just add one line to your plugin.yml" was more convincing lol
Theoretically you don't need
PRIMARY KEY NOT NULL
As primary keys are non null by default
I like to type NOT NULL everywhere regardless if they can be null or not
but for fields where values can be null I dont type it
okay that's a valid approach, just saying
^^^
plez?
I mean it's the same as with annotating @Nullable on fields that already can be null, it's just a hint that an experienced dev can immediately see
yes
hey, can somone help me compile a decompiled plugin
i've been trying for hours
i managed to decompile it but i cant recompile it
i have the jar it has a class thats just giving the person who made the plugin op and stuff and im trying to remove it
and idk how to'
contact the developer
@rapid vigil did u get ur issue fixed yet?
sadly not yet :/
what mc version ru running btw
1.20.4
is ur project on github?
secc sorry for taking time to respond
How to fix this? @sullen marlin
1st that is at least for me an empty image, second of all: you have balls to just ping md_5 lmao damn
check what that method should actually be, let intellij add the override
Wtf to begin with
Just ditch the plugin if it's that scammy?
i really need it and i dont have time to hire a new dev to make it for me
yea
it was nice knowing you
Fernflower often has issues with certain bytecode instructions, assuming you're using a decompiler that utilizes fernflower
What's the issue with recompiling?
Hello, does anyone know how to create achievement categories?
You can't reschedule the same bukkit runnable
create a new instance
I imagined there was a different way than what I did in the print. I wanted to reuse the bukkit instance
What event should i use to make the draggon egg not teleport uppon right click or left click?
Maybe PlayerInteractEvent
For LEFT_CLICK_BLOCK & RIGHT_CLICK_BLOCK
And don't forget that PIE gets called once for every hand
PlayerInteractEvent
I don't have the stamina to type shit in full rn lol
If you want it to break instead of teleporting then yeah you probably cancel, set to air and #dropNaturally
hey uhhh fellas?... Soo..........
I'm getting this error and it is making me feel dumb java.lang.IllegalArgumentException: Plugin already initialized!
I only have one plugin in the same folder and in Main there is only one onEnable()........
are there.... any other reasons why this might be happening?
i have this shit atm
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (event.getAction().toString().contains("RIGHT_CLICK") && event.getItem() != null)
{
if (isFireball(event.getItem()))
{
Vector direction = player.getLocation().getDirection();
player.launchProjectile(Fireball.class, direction);
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
{
return;
}
event.setCancelled(true);
ItemStack fireballItem = event.getItem();
int amount = fireballItem.getAmount();
if (amount > 1)
{
fireballItem.setAmount(amount - 1);
} else
{
player.getInventory().remove(fireballItem);
}
}
}
}```
inserting the check for dragonegg after the if shouldn't be a bad idea right?
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
event.getAction().toString().contains("RIGHT_CLICK") This is kinda weird but ok
oh yeah i was also getting that idea, idr how i solved it
lol
I would personally make a different listener for convenience (code cleanness)
Yeah, I just wanted to know any other possible causes whilst I make an MRE...
Hello! How can i change Y location of launch projectile? I need to launch projectile from player's legs instead of head.
Get the projectile from player.launchProjectile and change its location or velocity and see if that works
Show your main class (and/or any others that may be in any way relevant)
?paste for large code blocks
Might this be enough?
package me.manoszombies;
import me.manoszombies.db.Database;
import org.bukkit.imports;
import java.util.imports;
public final class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
long start = System.currentTimeMillis();
System.out.println("Starting");
this.database = new Database();
try {
this.database.initializeDatabase();
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Database couldn't be loaded...");
}
System.out.println("Plugin took " + (System.currentTimeMillis() - start) + "ms");
}
@Override
public void onDisable() {}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return true;
}
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event) {}
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent event) {}
}
Ill sendthe database class and the entire code if it isnt
not that anyone will steal the code since its so bad 💀
no
i write the shitiest code
youve seen nothing
even if ive seen much less than you
youve seen nothing
is it possible to store data in a permission node
like a player having plugin.perms.perms = some value instead of boolean?
i haven't worked with Permissible
but i think there's a reason that it works the way it does
Is it possible to initialize listeners in one class?
I feel like getServer().getPluginManager().registerEvents(new Main(), this); is going to cause the error i was having previously
(yes I know tryitands.ee)
i saw people do it, but why?
they used a method that registers multiple listeners from var args
this is definetly cause error, you can't create new instance of main class
well, as you can probably tell, I'm really new to Java and something I'm having difficulty with is passing variables from Class to Class in a sane way
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
oh yeah sorry, don't new Main() your java plugin
if your main class is also your listener, you would do
getServer().getPluginManager().registerEvents(this, this);
i thought he wanted to register multiple listeners in one line
How to prevent "your home bed was missing or obstructed"
modify the playerrespawn event
use this instead of new Main()
thanks, tho from fr33styler's reaction I probably should be doing it in another way.....
As I said, I'm having difficulty with having variables hop from class to class, as in giving listeners.PlayerInteractionListener a private variable from Main... I don't even know where to look...?
Its probably something super basic, but yeah
hm ok
have you read the link i sent u ?
umm create a gamesession class and create a instance of it in the plugin class and store all the variables in that class and create a get method from the plugin class
Going through it right now
I'm... not fully sure if this is what I want but I'll try a bit on my own to not annoy you guys. Thanks!
is there any event for a packet being sent to the client ?
@umbral ridge please do not post anything of, from, or referencing, him
ok
thanks
him?
Hello! I need help as I have no idea what should I do next. Well, I'm trying to make all vanilla mobs to be spawned with my custom entity NMS class, but I have no idea how to do it. The reason for it is just I want to add custom fields with some information that is not available in vanilla mob so all mobs will have these fields. Can someone give me an idea on how to do it or maybe any useful link (I tried to search but haven't found anything working for me).
P.S. I'm using 1.20.4 and working with NMS
Adding custom fields to mobs doesnt require nms.
Nms is only useful if you want to change the internal behavior like pathfinding and AI goals.
What are those fields for?
for example I want to create custom field of entity health (not to use vanilla bar as it's 1024 max afaik) and want to add custom defense field (again, in vanilla there's 20 afaik)
as for pathfinding and AI, I want to create my custom bosses with their AI and ofc parameters that extend the max ones
What prevents you from just creating your own class and wrapping it around the spigot entity?
This will eliminate your problems with nms as you simply store your custom data in the PDC of the entity
and load it when the entity loads back.
hmm, will try, I completely forgot about PDC lol
Alright. In that case nms is needed. The main problem is that you need to inject your custom entity in the internal registries which is really tricky.
What do you mean by "parameters that extend the max ones"
max health (1024) & defense (20)
You don't need to replace entities to mess with their AI
spigot.yml limits those
Is it possible to send custom packets as Minecraft server, so I will not have to run Http or Websocket server inside plugin?
So, if I understand correctly, I should use EntitySpawnEvent & ChunkLoadEvent to add info to vanilla entity to the persistent data container?
or ChuckLoad is not really needed?
Do you want to add it to enemies that spawn during worldgen?
I want to add it to ALL mobs that spawn in the already generated world and not generated yet
You would want the spawn event and EntitiesLoadEvent
Okay, thanks
How can i add comments to my config file? I'm using the default config api.
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
What does the path do?
Point to a section
how can I set someone gliding as if they were on the side of a honeyblock
Hi there, i'm looking for a plugin for minecraft java edition which create dialog box that which can be personnalised with a texture pack
like that :
Like origin realms?
Most texture pack related things will he custom made
Too niche of a usecase to be a public plugin
i'm searching the screenshot lol
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
Yeah I doubt theres a public plugin for that specifically
Fully customised experiences like that and public plugins dont go well together
because usually, you have a plugin which create the effect and on thop the server add a visual pack
and the other plugin that i'm looking for is an arrow. I mean when you are connected as a player, you have a big 3D arrow in front of you telling you where to go for the next step
Another one that seems a bit too niche
If you’re after things tailored like that id recommend hire a dev
A lot more issues arise like how will you program the dialogue and where the arrow is pointing
Hi all, I'm working on a plugin for my server and I have a blank project I would like to try and get up and running, however I'm not entirely sure how to add the plugin to the server; considering I'm using the sort of "DIY" version of a server.jar that the minecraft.net page provides. Any help would be greatly appreciated. (also I wasn't sure weather to post this here or in the "help-server" channel, but it is development related, so I figured here would work)
So its not a spigot server but a modified vanilla server, right?
yes
In that case you would modify the vanilla server in a way that lets you load "plugins".
Whatever that means in your context.
That sounds like you gonna have to do an incredible amount of work before you can do anything with it.
i think you should just use spigot, unless you want to create your own server software?
this is fair, I'm fairly new to this kind of development, so if someone could help me to do a quick start for a spigot server (or send a helpful vid/forum page) that would be great. If not I can figure smth out, appreciate the help either way.
Would json be okay to store static data such as drop rates from enemies?
Is there any example of its utilization that I could see to grasp the idea of utilizing it properly?
I havent touched databases or persistence for a long long time and need a refresh
Yeah json is fine for that
Yeah json is fine
ill yaml you
or you can use your own config.<yourExtension>
:)
your own serializer...
I might start doing that in my plugins
won't even save config.yml, will never generate it
Why
but what is there other than yaml, json, xml and toml?
i can't think of another structure that won't look like one of these
I like to save my data in a .txt file
I'll make my own because everyone wants it
the new pkl thing
also
:p
it looks more like a scripting file
but i can't seem to find a file to look at properly
oh nvm, i see
well, it does look like json
Everything is a scripting format if ur brave enough
What about pkl
Awhjh duxk you conclube
Conclure your old name was easier to type why did you do this to me
and from what i see it's also some form of scripting file
does anyone have a video / written tutorial on making persistent or player specific guis?
I plan to make a gui for each player for accessories that would be persistent through the game
Just keep an inventory reference around
like, using a database and caching it?
or do I not get it?
im soww
y
why does it make me suffer
there is no asmap function
sadly
Does anyone know how i could get a navigator going like a lobby navigator item usign a compass? How do i detect right clicks in the air with a compass? PlayerInteractevent doesnt seem to cover that
This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air). For the purpose of avoiding doubt, this means that the event will only be in the cancelled state if it is fired as a result of some prediction made by the server where no subsequent code will run, rather than when the subsequent interaction activity (e.g. placing a block in an illegal position (BlockCanBuildEvent) will fail.
So compass playerinteract event will fire as cancelled by default when the compass interacts with air
Is there a plugin that I can add where it bans specific users from using certain words? I can only find ones that ban all players from specific words.
Multiverse
?
who do u wanna ban from which world
then do a playerChangesWorld Event and check with a simple if clause for the world and for the players and if they match, cancel the even and send the player a message
certain "words" not "worlds"
does Bukkit.getEntity(random player uuid) return a player instance as entity?
in short can it return players too?
I suppose so. Easy to test within 5 minutes though
Just hold an actual Inventory object in memory
And save/load the relevant data for it
I'd have to read about it, I assume spigot API?
is it possible to store map String : Inventory in a database?
You don’t need to store the entire inventory
Just the relevant stuff
For example, just store the accessories the player has equipped
silverfish.setVisibleByDefault(false);
why does this result in
silverfish.addPassenger(player);
to not work? (it does not set it as passenger)
can i not set an entity as a passenger to an entity it doesnt see?
Probably not for players
You’re essentially sending a message to the client to start riding an entity it doesn’t know about
hmm ok
is there a way around? i need the entity to be non existent so i doesnt block arrows or stuff
Use a marker armor stand
it has to be a silverfish tho, it has the perfect size for what im doing
its the only entity with this size
so Id want to just store a list of itemstacks or inventory object that has specific inventory slots?
sorry I am pretty confused on this one
