#help-development
1 messages · Page 711 of 1
wtf is this wg shit you talking about
wg = worldguard
He means we = world edit
They have an api where you can create classic world edit schematics
or copy/paste regions.
I can also explain a way to you on how to copy a region between two points by yourself if you want to.
Yes, I want to do it myself, without some kind of api even tho I do have worldedit on my server lol
Yep i get that. Alright ill lead you through.
First we want to scan the block data for each block in this region.
Step one: Find out how to properly iterate over x, y and z from the lowest to the highest point.
Location cornerA = ...;
Location cornerB = ...;
Preconditions.checkState(cornerA.getWorld().equals(cornerB.getWorld()), "Locations must be in the same world.");
World world = cornerA.getWorld();
int xMin = ...;
int xMax = ...;
int yMin = ...;
int yMax = ...;
int zMin = ...;
int zMax = ...;
for(int x = xMin; x <= xMax; x++) {
for(int y = yMin; y <= yMax; y++) {
for(int z = zMin; z <= zMax; z++) {
}
}
}
}
Complete this code for me and send the result.
Hmm
Just the xmin xmax etc part
int xMin = -9;
int xMax = 8;
int yMin = 50;
int yMax = 60;
int zMin = 7;
int zMax = 57;```
should be something similar to that, if I understood you right
Given two locations (A and B) find out min and max for x, y and z of those two locations.
Hint: You can utilize Math.min and Math.max for this.
You can do it using a plugin or some code. But there is no config value afaik
If you have a plugin for that
yes i can code
This is a very intricate question. Because what exactly do you mean by "disable enchantments"
Do you want to mitigate the effects?
Do you want the enchantment to no occur on the enchantment table?
Do you want to block enchantments from villagers or dungeon chests as well?
maybe remove the enchantment from the item?
InventoryClickEvent, InventoryDragEvent as well
thanks
❔
How does Minecraft search for Nether Portals?
Because of the way my world is handled, I apparently need to make my own portal logic...
Why is that?
Well... If I enter a portal, the event is cancelled
So I need to bypass this, since I can't just remove the plugin that cancels it
That sounds like a hacky solution
Yeah, but it's just for my own server 🤷
Isnt there a bypass permission in the plugin?
No, even with OP, I cannot use Nether Portals
What are nether portals used for then if they are blocked?
They aren't used at all, that's the problem.
I want them to work
Anyways you can just register a listener with an increased priority and simply un-cancel the event if a user has a certain permission
Why does the plugin block them then?
allow-nether is set to true
I can try that
does anyone see any obvious errors 🤔 this isnt really in my experience lol
https://hastebin.com/share/qibojutuya.typescript
Even with priority HEIGHEST, it doesn't work :/
Did you print out the event result?
Thanks for reminding me 😅
I just had to set the correct world before the uncancel to allow the teleport 😅
Thought something like that
Which event should we use to move the items in my inventory?
What do you mean by that? You dont use events to move items anywhere.
Events are fired when something is happening in the world and you need to
react to that.
is there a way i can change the nametag above the players head?
nms
is there a doc or something for that?
You can also do that without nms
how
So what I mean is that in the world named "arena", the player should arrange his pvp items according to himself.
ie putting the item in the 1st slot into the 2nd slot.
There are a ton of different approaches to this.
It all depends on how many side effects you are willing to include.
Do you want to change only the name above his head or also his name
in the tab list or the name he has in chat
Listen for when a player enters a world and then set his inventory slots.
A world can be entered by either spawning in it or teleporting into it using the PlayerTeleportEvent
tab and chat i got working i only need to get the nametag working
What is the event of customize items according to yourself?
not this my man
You mean arranging items in an inventory?
yes
Explain what your overall plan is pls. You are a bit confusing.
Send the rename packet by using ProtocolLib
idk how protocolib works
I just want to prevent moving the slots of items in the inventory. That is, the item in the 1st slot should not be in the 2nd slot.
Cancel the InventoryClickEvent, PlayerDropItemEvent and PlayerSwapHandItemsEvent
Use one of the name nickname apis then
i triend finding one but they are not up to date
YThanksss
Are you able to just listen for like Inventory event
Or u gotta do each individual
You cant listen for abstract events
Figured
Do you know where in Minecraft / spigot code it loads the items into a players inventory (from player data)
I’m tryna fork spigot to load items from db
I’m doing other stuff and already have a spigot fork
@lost matrix can you help me with executable items?
Ah, no idea but i would follow the bread crumbs from the login handling
Sure, what do you need
I would like to know if it is possible and if so how, with which external plugin or with Executable items, if it is possible to add two items. that is to say. item "a" in slot "t" of the inventory, item "b" in slot "y", I open the inventory and take item "a" in my hand as if to move it to the inventory, and I move it above the item "b", as if to stack them. now I try to stack them and what I would like to happen is that a certain item "c" appears in the item "b" slot. and items "a" and "b" disappear from the inventory
is difficult but i REALLY need it
i tried activator inventory click, but i can only set the slot, not the specifical item.
Why not just create a crafting recipe like everyone else?
or use a different inventory that is made for combining items
and you can set the result however you want
yeah tell me a plugin
you can do it, by checking the item on the cursor when you click the inventory
i didn't found it
Sure, you can do that. So your plan is to combine items if they land in the same inventory.
This can be done using the InventoryClickEvent and some logic.
how
Alright
7smile7 do you know hypixel skyblock crafting menu
Yeah
guys, no I don't understand anything about it, I was looking for someone who could give me a quick tutorialguys, no I don't understand anything about it, I was looking for someone who could give me a quick tutorial
How do you recon the quick crafting works
When creating a prefix for example §8§l[§5§lHello§8§l] without legacy chatcolor, is there any other way than combining 3 textComponents?
i maybe create only chaos if i try it
Mibumsssage
Mini messages
Mind shwoing me a clip. Dont know what you mean by quick crafting.
Yes there are component builders in spigot
That's not really punching staff irl guys its part of rank on hypixel.
hope you watch the video and enjoy.
this video is not endorsed by hypixel but its not really doing anything but saying they are a good server.
I believe that shows
someone can give me a tutorial? or a plugin that can do that, or a video that explain how to do that? i suck with logic
?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.
Simple. They look up your items, hash their recipes and create a priority collection with the top 3 most valuable items
this is not the right place to ask for someone to write your code, if you have a fork of spigot, we expect you to atleast understand what you are forking (in this case the spigot API)
Mm makes more sense
otherwise there is no reason to fork in the first place
wait im confused
my bad xD
I read too much today 😫
seems they want someone to lead them through step by step to create this custom crafting thing they want
regardless not many if any will do that lol
you should read the docs and learn how to use the api
Aren’t you getting two dir convos mixed up
no
if you know java, this wont be too easy to understand
what is API?
no, I was
no
is an italian Bee?
an API stands for application programming interface
in this case I am just referring to spigot
multiple conversations can happen and refer to people other then just you, if it doesn't seem to fit you then odds are its not about you 🙂
yeah sorry for the confusion
Nah I asked smth bout crafting I thought the other guy was asking about items being clicked
So I thought you was taking to me
oh
well the other guy was asking about someone showing them tutorials in how to make it and etc
Hey everyone! 👋 I'm fairly new to the Minecraft development scene and I'm eager to improve. I'd really appreciate any constructive criticism on my plugin, PixelPaste. Whether it's praise or pointers, your feedback will be invaluable for my development journey. The code is open-source, and you can check it out directly via the GitHub link on the Spigot plugin page.
🔗 PixelPaste on Spigot
https://www.spigotmc.org/resources/pixelpaste.112531/
Thanks in advance for taking the time to help me out! 🙏
you shouldnt have directories that are one class
I kinda dont wanna redirect you but there is actually a thread on this channel meant for feedback directly if you want more looksies #1100941063058894868
What do you see this? Can you please go into more detail as well.
Your talking about the packing structure?
yes
i dont like that you out every class into different directories
like math has only MathUtil
which you dont need to do
and imo your package and class naming is a bit vague
and the naming of the directories doesnt impact the actual name of classes
It's designed for the ease of implementing other features and readability. These packages, ''whether empty, or 1 class" are essentially placeholders for future implementations. The code is heavily abstracted (franky overengineered) for this ease of use.
I see.
but like
well you can always extract it out into more packages later
I agree, take for instance the logic package, all code is in my mind considered "logic"
however the java class doesnt even have in name logic or something
and MathUtil would rather be in util class than math class
I see, your questioning the relevance of the package names to the inner classes. That makes sense, they should be relevant to the classes function. I will look into that more.
your directories are only made for one classes
instead of multiple classes
you have also multiple logic directories
in different places
same for core
Adding additional packages might look like overkill at first, but it's really about future-proofing your code. Personally, I prioritize ease of use and readability when I'm coding. But for a production-ready plugin, these concerns should be minimized.
what is the difference between core and logic in your opinion?
i mean
logic should be in core right?
Are you referring the 'core' that's a inner package of the Command package?
there is many core packages in your project so
It's referring to the 'core' of the commands package, containing the core classes for functionality.
which concerns? future proofing?
and they all have the same problem
and what's in logic if the functionality is in core
Just to make it more organized for whenever I add more classes in the given package.
what i would do is first remove the packages in utilities and bring all the class on the same level package
The functionality of the command system is in core. Each package has a inner core package that holds the main functionality. The name 'logic' may not be appropriate though.
Good idea.
I appreciate the constructive feedback on the package structure and naming conventions in PixelPaste. I understand the concerns about over-complicating the directory structure, and I'll look into simplifying it. The intent was to future-proof the code, but I get that it might be causing more confusion than it's worth right now. I'll also reconsider the naming of the 'core' and 'logic' packages to better reflect their actual functionalities. Thanks again for the insights, they're invaluable for a newbie like me.
okay
also
as for your processing setup, it looks fine
but one thing is nagging at me, is2D
you should really have 2 classes, Process2D and Process3D
look at std library in java btw, many classes are on the same level package
thats why you made an interface for a processor I imagine
That's correct. Thanks for pointing that out.
yeah i would make one IEProcess and add Process2D and Process3D
and then just implement for both
this also extends to PixelCommand in some regards, but its not really switched on too much
I originally had 2 classes, however I figured I would put it in one to minimize duplication of similiar code. But your approach seems more reasonable now that you mention the interface.
whats IEProcess mean
its always about a balance between code duplication and having your code be usable/readable
Is the approach I have with returning a Bukkit Runnable while waiting for confirmation seem reasonable?
IE means interface
people use it in c# and other languages too
lol
you say you want to minimize duplication, but tbh, you already have a process2D and process3D function xD
right
I never use prefixes
now you will see :troll:
it should not matter for your code whether its an interface or not
everything is an interface to some extent
because you are always interfacing with the class
just try not to use abstract classes and use final classes
final class are not extendable
I would like to get your guys opinion on my argument for keeping it on class.
Reusability: Both methods are essentially doing the same thing—resizing an image. Keeping them in the same enum ensures that anyone using this enum immediately knows that there are multiple strategies for resizing images.
Ease of Use: Consumers of this enum don't have to search for a separate class or method to find alternate resizing strategies. They just need to pick a different value from the same enum.
Abstraction: The abstract method resize is implemented differently for each enum value, which is a nice use of polymorphism. This can make adding more resizing algorithms in the future easier. Just add a new enum value and implement the resize method for it.
Context: Having them in the same enum provides context that both are resizing strategies, which can be helpful for code readability and maintainability.
However, I understand following Single Responsibility Principle and that it's important.
Could you guys provide productive counter arguments so I can tell the pros and cons?
what enum are you talking about exactly?
RESIZE_2D {
@Override
public BufferedImage resize(BufferedImage image, int maxDimension) {
int originalWidth = image.getWidth();
int originalHeight = image.getHeight();
double aspectRatio = (double) originalWidth / originalHeight;
int newWidth = Math.min(maxDimension, originalWidth);
int newHeight = (int) (newWidth / aspectRatio);
BufferedImage resizedImage = new BufferedImage(newWidth, newHeight, image.getType());
AffineTransform transform = new AffineTransform();
transform.scale((double) newWidth / originalWidth, (double) newHeight / originalHeight);
AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
op.filter(image, resizedImage);
return resizedImage;
}
},
which class is this?
Strategy
should not be in utils as its teh basis for your whole plugin
and this also has not much to do with the whole Process thing
uh you should not use enum for stuff like that tho idk
i feel like just creating one selead interface and some classes
instead of enums
using an enum is fine, but dumping all your logic in it does not make sense
furthermore, the upper half of resize seems identical
you can extract this into a separate function
I see, I was misunderstanding you guys at first. I was referring to the Strategy class not the process class. Ill look at that class again with your points in mind.
and then you will have less duplication and more reason to keep it split
Fair.
I would keep the strategy enum, but instead create a class around it that you can easily extend like ResizeStrategy and have ResizeStrategy2D and ...3D with just a single method resize, making ResizeStrategy a functional interface
or like an easy to use interface
and then just have some switch or if statement to resize depending on the enum value
I see, that makes a lot more sense.
If you don't mind me asking, do you have a github? I would like to study accurate code regarding mc dev.
then you can even just reuse resizing or combine them for other weird stuff
eehm
I only made a single plugin
xD
and its not a shining example of good java code since I only started doing actual java with this plugin
Well, I have to say I'm impressed. For someone who doesn't use java, you know a lot about it's concepts (or just generic oop concepts).
I mean my dayjob is programming in c++ so oop is not foreign to me
Even then, this project still looks impressive to me.
its just teh java nuances are kinda lacking
C++? Diabolical
I didnt even know you could do that stuff with enums until you showed me
Ah, well im happy we both learnt something.
yes I mean I have been working on this off an on for a few years so it has gotten relatively big for a simple minigame
Makes sense. I'm still new to spigot development. I'm just trying to learn as much as possible so maybe I can get a job before I have to do a speech class next year for my major.
Spigot development(for me) is like a gateway for learning how to problem solve better in code. Not really for getting a 'job'.
Also my ADHD brain needs constant dopamine and if I don't see something happen after a few minutes I lose all motivation. Hence why I started MC development.
Is there any guides on the new way to make custom player heads
Current code VVV
PlayerProfile pp = Bukkit.createPlayerProfile(UUID.fromString(skullinfo.getId()));
pp.setTextures(); //What goes here???```
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,...
Hello, do you know if there is a library (not a plugin) to display a player's face in the chat when he sends a message ?
difference is that core can't be changed or it must exclusively be present otherwise nothing functions. Hence core code. Logic code is more dynamic and not always necessary to have and has more freedom to be changed
so core code is the foundation and doesn't necessarily contain just the minimum but the princible is minimum code necessary that is needed to make things work
I guess , but I think this structure works better for way bigger projects then
thats a good way to look at it though
I would just remove logic package and put the rest into the parent package directly
next to core
ideally. good news is there is many design principles to follow
this is just one of the many
yes
because if its consistent and you wanted to say change such a principle or need to make changes in many classes for the most part it should be fairly easy to know where you are looking or what needs to change
since every class and package should follow the same design
yes
it is why many open source projects implement rules to creating PR's
[X] I have read this and that bla bla bla ...
[X] I haven't read anything and simply checked all the checkboxes
spigot?
hello, i got 2 enums called Item and Weapon. This is my code (the top method is in the Weapon Enum and the bottom one in the Item Enum) https://paste.md-5.net/goyehavulo.cs
ItemStack itemStack = event.getItem();
if (itemStack == null || itemStack.getType() == Material.AIR) return;
System.out.println(1);
Item item = Item.getByItemStack(itemStack);
System.out.println(2);
if (item == null) return;
System.out.println(2.5);
Weapon weapon = Weapon.getByItemStack(item.getItemStack());
System.out.println(3);
if (weapon == null || weapon.isMelee()) return;
System.out.println(3.5);
``` ^ this is in a listener
i debugged my code a bit and it sucessfully is going through all items to find the right one and it has found it (so its not null). But when I try to get the Weapon by the itemstack from the Item (which was not null) it gives me a null pointer exception for the method `Weapon#getByItemStack`
it gives me a null pointer exception for a thing which was not null before
like when we tab on a multiplayer game, there is our head next to us, I would like to do the same in my chat plugin
That's impossible
for me ?
yes
okay thanks
You can do that with a resourcepack
This is usually done with 8x8 pixels.
Meaning you need 64 font characters, replace them with shifted pixels and
color them using rgb chat colors. Its quite the hustle to get right.
and re-send the pack to every online player when someone new joins in :trollface:
You replace 64 font characters and use them for all faces.
Like a 8x8 canvas that can be used to display anything.
how to get Potion from item?
Potion a = (Potion) ItemStack
Returns error
item.getItemMeta()?
if yes then how to add 1 level to effect?
Something like this.
public static Potion superDuperMegaUltraChickenNuggetPotionLeveler() {
int magicalChickenNugget = 0;
// String of bewildering operations
magicalChickenNugget += Math.tan(Math.sqrt(42) * Math.random()) * 0;
magicalChickenNugget += (int)(Math.PI * Math.E * Math.sqrt(2) - Math.PI * Math.E * Math.sqrt(2));
magicalChickenNugget += (Math.log(1) + Math.exp(0) - 1);
magicalChickenNugget += ((Math.sin(30) + Math.cos(60)) * 0);
magicalChickenNugget += (Math.pow(3, 2) + Math.pow(4, 2) - Math.pow(5, 2));
magicalChickenNugget += Math.abs(-2) + Math.abs(2) - Math.abs(0);
magicalChickenNugget += (Math.round(Math.random() * 10) - Math.floor(Math.random() * 10));
magicalChickenNugget += (Math.ceil(Math.random() * 20) - Math.ceil(Math.random() * 20));
magicalChickenNugget += ((2 + 2) * (2 - 2) / 2);
magicalChickenNugget += ((int) Math.sqrt(Math.pow(4, 2) + Math.pow(3, 2)) - (int) Math.sqrt(Math.pow(4, 2) + Math.pow(3, 2)));
magicalChickenNugget += Math.floorMod(-1, 2) - Math.floorMod(1, 2);
// Wrapping up the bedlam by actually doing something useful in Minecraft
magicalChickenNugget += 1 + 1;
// Create a new Potion and set its type to Healing
Potion potion = new Potion(PotionType.HEALING);
// Increment the potion level by 1
potion.setLevel(potion.getLevel() + 1);
System.out.println("Utilizing the Super-Duper Mega Ultra Chicken Nugget Potion Leveler, the potion level is now: " + potion.getLevel());
return potion;
}
0-0 it's ok but idk how to get potion type of the potion
there are no potion.getType
Are you getting the PotionMeta?
yeah
Here, is some sudo code
public static void main(String[] args) {
// Assume itemStack is an ItemStack object for a potion
ItemStack itemStack = ...;
if (itemStack.hasItemMeta() && itemStack.getItemMeta() instanceof PotionMeta) {
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
for (PotionEffect effect : meta.getCustomEffects()) {
PotionEffectType effectType = effect.getType();
System.out.println("Effect Type: " + effectType.getName());
}
// If the potion has a base effect (e.g. Healing, Strength)
if (meta.getBasePotionData() != null) {
System.out.println("Base Effect Type: " + meta.getBasePotionData().getType().name());
}
}
}
I am unfamiliar with the API, but documentation serves well. I would check that out.
Obviously you can't implement that as is.
oh thx
Thanks but new Potion is deprecated and i can't figure it out how to change amplifier of potion using potion meta
oh i found out
thank you for your contribution of utmost importance to the conversation, it is very much appreciated

alr buddy
Is there a way to get a players b64 texture without having to use NMS? Looking for solutions for 1.16 to 1.18 tooo
Use Mojangs API to get player information from there UUID. Parse the JSON response(properties key). That should return the base64 texture (encoded)
use the PlayerProfile
I was under the impression this was added after 1.18
oh you want it pre 1.18
Mojangs API is the only way, unless you find another API.
Do you know what the rate limit is for the api? I assume I'd have to handle that
you can do it with a little reflection
i couldnt tell you, I would check the documentation.
Sounds good thank you
I haven't actually messed around with reflection yet, only used NMS for single version projects, do you happen to have a link to any resources regarding it?
Yeah I understand the logistics of it, just not reflection as such
I know you can do something along the lines of ((CraftPlayer) player).getHandle()
are you just looking to read it?
Thank you
Yeah was just looking for some resources more than anything, this should be great :)
Anyone got any ideas?
There is probably a field in the Player object you can use, or just create a new GameProfile using the correct UUID/namejava GameProfile profile = new GameProfile(id, name); profile.getProperties().get("textures")
I'm asuming weapons a custom thing you made. What's the code in Weapon#getbyitemstack
I would add debug statements to print the itemstack before passing it to weapon.getByItemStack to make sure its not null. Check inside your getByitemstack method to see if your potentially accessing a field on a null object. I would also check the stack traces. Its hard to help you without more code.
also you can do actual debugging with spigot, it takes a bit of setup tho
oh btw chat's async, right? Is there a sync event when people type in chat or do you need to do somesort of async->sync thing?
I am improving the Structure API. I am adding a chainPlaced method which allows instead of placing the structure and entities in a single tick to split it in multiple ticks.
The only issue I got is that I want to support including entities (like placing them). I tried with teleporting them (using their Location as an offest), but they still don't appear/exist in game...
It seems that they don't really exist in the World implementation so I thought that maybe spawning them through the World interface would work but I just realized that there's not really a method that spawns them right...
I mean, there's not even a method in the API that copies an entity PersistentDataContainer to another and such and I wanted to not use NMS as much as possible, just trying to keep it Bukkit/Spigot API in order to improve maintenance
Does anybody knows a work around?
cant u clone the pdc
How do I apply it?
While you're at it make a method to create an empty structure
To the new spawned entity?
with given dimensions
...loop pdc keys?
is there a reason you couldnt just foreach the pdc keys and apply it to the new entity
What do you mean by empty structure?
Air
Is it not possible with Structure API?
can someone pls tell me how does the give potion effect stuff work? I got it working, but it only lasts for like... 1 tick
and that's..
...that's not something I want 😆
Hello, someone tried having the ownership of a premium plugin transferred to me but it said I don't have the requirements.
what website is this i want to scientifically prove that someone is an npc
if a recipe is registered by a plugin, does it still persist after the plugin is disabled?
I'd say its a possability if the plugin was disabled prior to the server being disabled.
I'm not sure how Bukkit handles shutting down plugins while the server is still running
tested it, gets disabled apparantly
on a different topic
why does this work with inventories but not with recipes lolbruh
public void onItemCraft(CraftItemEvent event){
if(!(event.getRecipe() instanceof ClassExtendingRecipe recipe)) return;
its registering the recipe to the server
so where does that part where its a different class get lost?
client doesn't know how to interpret that extending bukkit classes will almost never give a proper result
all im doing is server side tho
InventoryHolders only work because it never has to be sent to the client (though its a bad practice regardless)
recipes have to be sent to the client
but if its crafted its still using a recipe aint it?
arbitrarily extending a recipe class and adding stuff to it won't work
why would you ever need to query a recipe once its in the server
because its supposed to be enabled for specific players only
the problem is
recipe doesnt have a permission field, so it'd have to be handled in a 'u cant craft this' way in the event
but EVERYTHING else in my plugin is setup in a 'alright, you specifically can do this' kinda way
I suppose you'd have to send packets to specific players instead of all to say the recipe is there and then not allow certain players to use it by using patterns
wait wtf
how can you init a namespaced key with a plugin but not check if a namespaced key is inited with a plugin
you don't really need to
i kind of need to check if its my plugin that made the key
terrible solution ™️```
NamespacedKey key = new NamespacedKey(this,"master");
String namespace = key.getNamespace();
can't you just do .equals
I mean namespaced keys really just are pluginname:string so 🤷♂️
hi, does anyone know if what the warden throws is considered an entity? as is the wither with the heads it throws
declaration: package: org.bukkit.entity, interface: WitherSkull
yes, wither skulls
but I mean the sonic boom that the warden makes
What I want to do is that when that is activated, the place where it arrives appears a tnt, do you know if it can be done?
particles arent tracked on the server, so not easily
And do you know if I can make it so that when the warden activates that, he also sends a wither head?
I guess you could use EntityDamageEvent to check for a sonic boom and go from there
how would you check it?
But how do I check when I activate the sonic boom?
pretty sure a warden only sonic booms when they target and damage an entity
so how would you know when they point to an entity? Sorry, I'm a little new to entities
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
So guys, can anyone help me? How can I properly register my cargoReposity event in my main?
Main.class
public void onEnable() {
this.getCommand("setargrupo").setExecutor(new SetarGrupoCommand(cargos));
this.cargos.put("mod", "admin");
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new CargoPlaceholderExpansion(this).register();
}
}
CargoPlaceholderExpansion.class
private CargoRepository cargoRepository;
private final HIDTags plugin;
public CargoPlaceholderExpansion(HIDTags plugin, CargoRepository cargoRepository) {
this.plugin = plugin;
this.cargoRepository = cargoRepository;
}
I have a question about threads. I'm making a plugin like MKing but for newer versions
There are 3 streams.
WaitPlayerInGame - waiting until there are enough players to play
StartingGame - start the game
WinningTimer - timer for EACH player that counts the time
The question is in this place in the StartingGame class. When the timer is over it stops the StartingGame thread
And StartingGame itself creates new WinningTimer threads. Could it be that if the WinningTimer stops the StartingGame thread. The remaining WinningTimer threads will continue to work
this true?
or all be nice
you can't reregister tasks
this 1
1 wait thread, 1 game start thread, timer thread for each player
always pushing from one to another
this looks like a headache to maintain in a month
lol
i make minigames and i have 1 task sync and 1 single thread executor
it's pretty easy to maintain
tho it might be more difficult to debug lagg in your run this way
Do you do commissions?
me?
Yep
but that means you put the game states in 1 thread
I share them
One thing I've been stuck on is completing my minigame engine, it's been like 10 years lol
Literal mental block
On the bright side, making progress now
What is a minigame engine?
Basically defines the structure for how minigames are created on the server, and manages them
something like this
It uses nms?
It can
yeah
Depends on the needs
I'm making mine open source
But not complete yet
Interesting
😿
so how you think obaut my question?
theads not will stop?
Timer tasks
i don't think this will trigger
ever
you can't realistically ever be in the same exact location
decimals will never match
also double has floating point innacuracies
use distance
or a selection and check if it's in selection
1?
<= 1
or
I just need a player at a specific location
the more precise the better
then lower the distance until you happy
usually you just wanna test your own code so you can learn from your mistakes instead of asking for help from others
you'll can't learn without making mistakes
if this kind of error occurs, it’s better to ask than to test for 3-4 hours and think where the problem is
lol I might just learn from other people's mistakes
Well, you told me that you can’t compare locations like that, so I won’t
😀
sure, but i can't be here to guide you every time you need help
and the more your program advances the harder is for people to help you as they won't know how your code works
I know, but it’s more effective to ask complex questions related to flows than to solve them yourself for a long time
besides, I have limited time for this plugin
I simply don't have time to experiment
although when I tried to find a way to compare locations, I couldn’t find a way to compare them anywhere on the Internet and assumed that "equals" would work
not only this, but as you become more knowledgeable your problems start requiring resolutions in the areas of concepts where no one is likely to have a premade fix for and you are left to implement the concept yourself to resolve whatever issue you are havin
it's harder than you think
Well, personally, I have weaknesses in working with threads, especially when you think about their synchronization
if you have a large or complex code for you, you will have to spend a lot of time on it
Can you give me a scenario?
although it all depends on length and experience as well as on thinking
what?
A scenario when you ran into a synchronization issue
scenario?
Like an example
oh ok
#help-development message/11 - here is
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
oh wait
not
this
Ah having multiple threads stopping each other
I'd probably either use a state machine or atomic booleans
but boolean requires checks. Are you saying that you can create a separate thread to check boolean?
So basically the logic would work like this
- There is a method for switching states
- When the state is switched, unrelated tasks will be cancelled
- Related tasks will be started
And I'm guessing that these states will switch based on events
So we can call it in those listeners
Idk, just how I would do it
Probably can be simplified further if I was actually writing the code
how do I get a location from a config file?
ru actually using new threads everytime?
or just new bukkit tasks?
and you run them asynchronously or nah?
cuz if you do, then thats pretty identical to booting up new threads
not async
The Weapon#getByItemStack method should work, but the item for Weapon#getItem is suddenly null. The Item is from my custom item enum
config.getLocation("path.to.location");
https://paste.md-5.net/goyehavulo.cs
the method first method is in the Weapon enum and the second in the Item enum
You should use the PersistentDataContainer of ItemStacks to tag your custom weapons
honestly, i could try that
You can add a tag like this on your item:
CustomItemType: "crystal_sword"
And then internally have a Map<String, Weapon>.
This way you can just look at the tag of the itemstack and have the weapon type in no time.
What spigot version?
ooh true, i will try that later. thanks for your help
Btw i got an andvanced tutorial on how to handle custom items.
Might be overkill for you but you can take a look if you want
https://www.spigotmc.org/threads/how-to-handle-custom-items.593039/
1.8 sadly
if I have to do it all myself, ig I have to
interesting, a bit overkill for my current project tho. Might save that for later. thanks tho
lol never thought you'd be the one to use enums to polymorphorize behavior like that
Can get messy, I have a different approach
You can still keep the enum
But instead of doing raw checks on a listener (which is a bit more performant) you make a class for each item
And in my case I still use string keys because I'm an idiot
And the end item looks something like this
Yeah this is half a year ago. I wouldnt use enums today.
The curse of old code that makes you cringe 
good sign that indicates you're becoming better tho, so pog :)
I feel like im perpetually here.
Especially after getting deeper into machine learning and quantum computing for my master
mount stupid is where prompters are
people that prompt exclusively
mfs life depends on openai credits
proomting away. I've started creating my own dataset and fine tuning a few models from huggingface. SDXL is an insanely complex base model which
has the potential to bring Midjourney grade generations to open source projects.
The main problem is that datasets are excrutiating to prepare. And that i need to write python 
Maybe you're there
But not in the spigot world
I'd say I'm about here in terms of spigot stuff
My biggest handicaps are like
not knowing anything beyond 5th grade math
lmfao
PersistentDataContainers dont work on spigot 1.12.2 ig
yea
so, in the item enum I got this entry for example
FLAMETHROWER("flamethrower", ItemBuilder.from(Material.BLAZE_POWDER).name(Component.text(ChatColor.GRAY + "Flammenwerfer")).lore(Component.text(ChatColor.GOLD + String.valueOf(Weapon.FLAMETHROWER.getAmmo()) + "/" + Weapon.FLAMETHROWER.getMaxAmmo())).build()),```
and in the weapon enum this
```java
FLAMETHROWER(Item.FLAMETHROWER, 5, 3, 1000, 1000, 100, 1000, 0.0F, 0.0F, false, false),```
When I do Item#getByItemStack the item is not null, but when I try to do Weapon#getByItemStack with the itemstack from Item#getItemStack as an arg, the itemstack is null
but i can get an item ingame using Item#getItemStack
I am trying to get a player's textures by using reflection - I currently have the below but CraftPlayer is specific to versions, what is the best way to go about proceeding with this?
public static String getTexture(Player player) {
CraftPlayer craftPlayer = (CraftPlayer) player;
GameProfile profile;
try {
Method getProfileMethod = craftPlayer.getClass().getDeclaredMethod("getProfile");
profile = (GameProfile) getProfileMethod.invoke(craftPlayer);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return "";
}
Property property = profile.getProperties().get("textures").iterator().next();
return property.getValue();
}
Use the profile API
I offer support for versions pre 1.18
get their profile, get textures, get skin and format it from the url
move to 1.18.1 or 1.18.2
if you cant you have to use reflection
I'm happy to use reflection
use Bukkit.getServer().getClass() and format it to remove after the v1_20_R1
yeah but invoking properties will need it
oh true
He only neeeds it for CraftPlayer
Apologies I don't quite follow, how would I use this?
Ooh doing player.getClass() returns the relevant CraftPlayer class
awesome news, thank you
Use nbt data then
Try to prevent checking names, lore or items on equality. Use pdc or NBT api if you must.
dissallow shift click?
from first inv to player inv?
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
- Check if clicked inventory is top inventory
- Check the InventoryAction
This makes it easier to distinguish what is happening than checking if the click was a shift click.
i recently learned that the cursor item is hold by the player class and not by event, it took me a while till i figure it out why i couldn't get the item in the player's hand
@ivory sleet have you used hibernate before with the libraries feature in plugin.yml
i feel like i saw you talking about it here at somepoint
do you know spigot classloaders
plugin classloaders spigot uses
https://hub.spigotmc.org/jira/browse/SPIGOT-6569 this is what happens when trying to libraries feature
md sent https://stackoverflow.com/questions/41176863/hibernate-5-and-jpa-and-setting-entity-classloader-dynamically but none of the classloaders i could find worked
hmm yes
so essentially it seems like hibernate tries to load the class CustomDrop on its own
not my issue btw, just one that already exists
but pretty much exactly the same info
QueryBuilder<PlayerStats,String> qb = dao.queryBuilder();
// select 2 aggregate functions as the return
qb.where().eq("gang","sus ");
// the results will contain 2 string values for the min and max
GenericRawResults<String[]> rawResults = dao.queryRaw(qb.prepareStatementString());
// page through the results
List<String[]> results = rawResults.getResults();
results.forEach(s -> System.out.println(Arrays.toString((String[]) s )));
[19:34:27] [Server thread/INFO]: [09ed5c77-bdd7-4436-8167-50f4eefe5144, ORANG3I, sus , rookie]
[19:34:27] [Server thread/INFO]: [89f6be0a-a27b-3415-86ef-c9acc095b61c, orang3ikr, sus , rookie]
this is the output
how do pull out the usernames alone
ORANG3I and orang3ikr
array[1]
Yeah just index the array
Do you only want to query the names? In this case you need a projection.
no i need the uuid too
yeah just index the array
yeah works thanks

results.forEach(s -> System.out.println(s[1]));
Sure, i just couldnt comprehend that simply accessing the array was your question...
yeah sometimes i cant comprehend myself i am confused with pointers
the issue coll found, i just thought of something to test
i could just sout the classloader in one of the classes and see what it says
and then hope i can access that classloader
so its the plugin classloader
but i added that
huh
i think the reason it doesnt work is because the class isnt loaded, at all
okay it isnt, thats jank
i just used my brain on this, same issue yeah
Hi ! i have a big problem, i'm trying tro use Java Reflections in my plugin but my ide didnt know Reflections object... In my .jar file, Reflections is correctly shaded and the depenencie is in my maven pom.xml
Yes
an Artifacts issue most likely
You likely are not using the maven tab to build your project
not if you use artifacts
But do you actually use maven?
Yes
How do you compile?
package
Show your pom
can u send the quote for code plz
``
?paste
thanks
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>fr.toutcourt.moonapi</pattern>
<shadedPattern>fr.toutcourt.moonapi.shaded</shadedPattern>
</relocation>
</relocations>
<outputDirectory>../../Minecraft Server/1.18.2/plugins</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
just the important code
um your relocation pattern seems to be useless
maybe
@remote swallow alr it took some time to fix my env, but i think its fixable
you only relocate your own api?
no
i use reloaction in opther plugin
and it always work
but when i try to import org.Reflection in my ide, that didnt work
import org.reflections.Reflections;
if you prefere
aren't all reflections in java.reflect?
The .jar file i've set to come into my server when i press "rebuild", can i rename that file without it breaking the plugin in any way?
java.lang.reflect*
There's a library called Reflections
i see
do you use intellij?
yes
Can the bounding box of an NPC, which was created using packets, be adjusted or resized? The NPC is currently in a sleeping pose, causing its bounding box to be too small. This makes it almost impossible for players to locate the interaction area when trying to interact with the NPC.
@remote swallow what code did u use btw
you can make your own interact in this case
by raytracing nearby entities
with a bounding box of your own
for which
how do I teleport a player but not kill him (e.g. if a player is falling and I tp it to X location it won't die from fall damage)
Teleport him to the ground instead of the air...
I meant if he has been falling before he will die then
Set the ticks the player was in the air to 0
setting the classloader? or getting it
or just in general
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Entity.html#setFallDistance(float)
Ah not falling ticks but fall distance
declaration: package: org.bukkit.entity, interface: Entity
thank you
i can't get amplifier of base potion
like i have item stack of potion
and if i'm trying to get it's amplifier i'm getting it's meta
its always 1 iirc
turtle potion 💀
nope, you can upgrade it
frst level of turtle potion:
slowness 4
resistance 3
scnd level of turtle potion
slowness 6
resistance 4
try System.currentTimeMillis() - yourTime
or something like that
:p
i still can't figure it out, i need code to add 1 level to the minecraft base potion but it works really strange to me
cast it to potion meta, get base potion data, set it to upgraded, set base potion data, set potion meta back to item
and if potion is already upgraded?
cry
Im not to familiar with raytracing and how I'd be able to do that. Any resources I could check out, or examples?
so maybe there is a way to get base potion duration and base potion amplifier?
none that ive found, would probably need to use an enum or something and then figure out upgrade durations
😭
Does anyone know how to do something when a player closes a gui
like brodcast a message or something
InventoryCloseEvent
how can i tell if it is a specific gui
ok
vector get direction and then add it onto a location, preferably eye
that is the premise
getdirection normalises it to 1 per block
so every time you add the vector on your location it advances it by 1 block
Your code u used to bootstrap hibernate
the session factory?
Myeah I assume that
The builder stuff basically, like ur onEnable
Cuz I didnt get anything
Like no errors
want the error too
Yeah why not
Ok, but how would I be able to tell if im looking at the target npc? and you mentioned making a custom interact, how would that work?
annotated class: https://paste.md-5.net/laduluzino.java
error: https://paste.md-5.net/fofeveboya.rb
session factory: https://paste.md-5.net/uxohoxazav.java
just make it 2 blocks 1 player location and the other a block above
if one of the check triggers stop the ray tracing and that's your npc
you do need to loop through your npcs or at least
get the angle and distance
to use those to reduce the number of checks
it's up to you what approach you take
Maybe someone else knows how to do that?
Is it better to make plugins for your server separately like make multiple plugins for your own server or to make just 1 that does everything for your server? (or does it rly just not matter at all)
Just making sure I got what you said, I need to have 2 blocks (Im assuming the location) 1 being the block location of the npc and another above the actual block location. I then run rays from the players eyeLocation, and if it hits 1 of the 2 blocks I know it's my npc?
yes
Doesn't matter but I find it easier to have all my stuff in one
you can also make it more precise with a custom bounding box
usually you would split different functions into different plugins
a selection
How would that work?
I want to update my premium plugin, but it says my file is too big, what can I do?
thats what I do
make it smaller
dont shade un-needed stuff, minimize, use the plugin.yml libraries feature
You can say that but how? It contains all important features.
this seems a lot harder because I would have to make dependencies for the plugins to get data from one another and would take a lot longer to keep making new projects right
I do already minimize it lol
but it does make sense for organizing
nope no nms
mysql driver yeah
why?
use the libraries feature in pluign.yml
because I had issues with it
so I would compile it?
?paste your pom
libraries:
- 'group:artifact:ver'
I have gradle but wait
And how does ur main look?
move this to the libraries feature
and the kotlin std lib
okay, so I can use compileOnly then?
libraries:
- 'mysql:mysql-connector-java:8.0.33'
- 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10'
yep
also move all the adventure stuff
the snapshots are
?
a selection would fix the blocky feeling
or distance check would fix it too
what about javase from com.google.zxing?
there are so many ways to solve it
are you using the library loader or are you shading hibernate?
one sec
yeah
never worked with hibernate but maybe you need to specify the ClassLoader somewhere?
well you'd still have to, no? what if you change the thread context classloader?
Yeah that makes sense but earlier though you were talking about a custom boundbox, how would that work?
i get the same error, and i removed it after i tested something earlier
hm reading the stack trace it's trying to use its own classloader, there's probably another way somewhere to specify it, no clue otherwise
Is there a method to set the bounding box?
no
List<ClassLoader> classLoaders = new ArrayList<>();
classLoaders.add(PrisonCore.class.getClassLoader());
properties.put(AvailableSettings.CLASSLOADERS, classLoaders);
same error even if it has that
you have to make your own class
and its loaded by that classloader
lol libraries from plugin.yml recuded the file size by 3mb
Through reflection or soemthing else?
no
create a selection class
that takes min and max
or at least with math min and max
and then check if they're in these 2
why not
final var classLoaders = List.of(PrisonCore.class.getClassLoader());
afirst thnig that came to my brain so just wrote it
Im a little confused, is the min and max locations or how big the bounding box is? And im I checking if the ray hits them both or something else?
I am having trouble making custom entities, what i am trying to do is have an interface containing the base entity logic like storing its custom health etc, and have various classes which implement it and add features like abilitys, custom weapons and armor, etc. What i am having a problem with is making it serialize into a yml file nicely.
Try checking out this video, it might help https://www.youtube.com/watch?v=3OLSfOkgPMw&t=509s
Time to continue our talk about Persistent Data Containers! In this episode, I talk about custom persistent data types. This allows us to save whole custom objects to the containers. This way, we can get more data out of our container without having to save multiple values or even multiple namespaced keys. I hope you all enjoy this video, see y'...
yes
2 locations
if persistent data is advanced then im a magician
pdc easy
i ideally want to use ConfigurationSerializable though and store the data in yml files
Personally I wouldn't store it in yml files because its not really the best for data storage. Json works well and isn't to complicated to use.
yml files are more commonly used and user friendly i might publish the plugin if i actually make it work
basically i can simplify my issue into one question, if i have a class which implements my customentity interface and serialize it in config, if i deserialize it will it still be a valid class?
As far as I know, yml are mostly used as config files, for flatfiles its perferred to use Json/Gson.
Yes iut should be\
ok i'll come back in a bit if it doesnt work
Makes sense, but do you mean that the ray is in the two locations or the player it self?
Ok I have most things figured out, the only question that comes to mind is how that would work for the body. From what I know the block location of the npc would be the block under its legs (Since its in the sleeping pose). So would the raytrace only work for its legs and not the body? Or am I missing something.?
oh, then you have to mess with the selection to make it more like a sleeping person
@ivory sleet find anything?
not atm, he'd probably add you though
@young knoll add conclube to prisoncore for hibernate debug

huh who what
conclube (helper above) to prisoncore to try fix hibernate shading
small jar
github is conclube too
aight
In what way though? Thats what im stumped on.
@ivory sleet to make hibernate a library change implementation to bukkitLibrary in the core build.gradle
what is the event for when a player gets damaged by potion
and how to get the player that thrown the potion
publish it to a maven repo or mvn install it and add the respective maven info to ur other project
ok thx can i have the link
for which
the maven repo
maven central, jitpack, repsy
maven central requires a domain or a github package, jitpack uses github, repsy doesnt care
all are online just require local setup for setting the user and token
I am using an event listener for if someone closes and inventory to detect if they are clsing a gui, then if they are i reopen the gui
it works
but it opens an inventory not a gui
so i can take out items and stuff
you have to cancel the events
how can I do that
inventory click event and inventory drag event
call setCancelled(true) if it sur inv
ok thanks
and the second problem is
if i close it, it opens , but if i close it agian it doesnt open again
you arent recreating it the same
i do if
you need to update that
maybe show some code
ok wait lemme see
can you make a giant's move it's arms in other ways than attack and neutral?
Animations are client sided
is there a way to get all loaded spawners?
im working on stacked spawners and not wanting to deal with storing spawner locations
and i need to tick them every 5s
I'm still having trouble coding custom entities the problem that i'm having is whether i should use an interface or abstract class to handle custom health, etc and just implement/extend that but will that work with ConfigurationSerializable or will it just return the extended class and not convert it into the desired class
like for example if i had this:
public abstract class CustomEntity implements ConfigurationSerializable {
}
and this:
public class CustomZombie extends CustomEntity {
}
If i serialize the customzombie class into a config.yml and deserialize it will it return the CustomEntity or CustomZombie class, and also how would i handle the serialize and deserialize methods
if your customZobie has serialization it will be saved as a zombie
if only your custom entity has serialization then it will be saved as a custom entity
I think it depends on whether you implement the serialize function
i.e. dont implement it in your abstract class
or override it in your zombie class to add more stuff to it
oop style
ok so i just use the abstract class as a base and put the actual serialization in the class that extends it
yes like I said at the end though you can have it both ways
but just make sure to actually register the class for serialization xD
but isnce its abstract you should never have to serialize your base class anyways
Does someone know the way to add 1 level to the base minecraft potion?
why this not reload config.yml plugin.getConfig().set("Location",location);
plugin.saveConfig();
plugin.reloadConfig();
maybe create an abstract function called serializeEntity() in customEntity and then implement serialize
but idk
that will probably require generic magic to get the type correct
but the problem is i want the abstract class to have the basic variables that all custom entities have like custom health and stuff how would i handle that
well essentially you just make it like how I described
you implement serialize on both classes
ok so that will work then i'll try it
and your child class will just call the super
if that doesnt work maybe create a protected function on your abstract called getSerialized() where it just serializes the base class and then combine that with the rest of the inherited class
wow ChatGPT feeling honorous
Sounds good to me. You dont like cake?
not when im having to talk to chatgpt
anyone know
just store them!
Spawners are TileEntities, they have a PDC
yes
i would think storing them in a list is faster then searching through all tile entities?
is there a way to find all loaded ones?
Do you know how to add 1 level to the potion with base data?
like.. even to upgraded
Just get all tile entities in a chunk when it loads and filter out those of type Spawner.
Also check them when they are placed.
You cant. You need custom potion data if you want to create custom potions.
The base potions can only be upgraded or extended.
Okay, then how to get base potion duration and amplifier
like is there any enum or something like that to get base potion duration or base potion amplifier?
What version are you on?
1.19.4
I dont see anything that could be used to find out the default potion values.
oh...
then i should create new enum
💀💀💀 turtle master potion with slowness 4: Hello
anyone know if its possible to make custom advancements that work in all worlds, or is that just default
i think using datapacks it's possible
if its possible in datapacks i could probably nms it
can I do that async
Why would you want that?
Its probably slower than if you would do it sync.
Couldnt that possibly be a slow task to do that, and uh i dont need the title entities in the first ms
Getting the tile entities takes a few micros
it's cached when the chunk is loaded
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
BlockState[] blockStates = event.getChunk().getTileEntities();
for (BlockState state : blockStates) {
if (state instanceof CreatureSpawner spawner) {
PersistentDataContainer container = spawner.getPersistentDataContainer();
// Do your stuff
}
}
}
ic
can someone help me i dont know what commands to use to like withdraw and stuff
im trying to make a server for me anmd my ffriends and idk what to do
I would like to do cleaner work on my plugins, so far I have not selected a build system.
but from what I understand it's better to choose one but I don't know which one adapts better to the plugin between Maven or Gradle ?
its entirely personal preference
Maven has a lot more coverage in spigot.
Gradle is used a bit more when working with paper.
I would suggest starting out with Maven and then trying out gradle at a later point in time.
thanks you
How to get Color of hex?
like
i have hex
and i need object Color
from hex
but i need bukkit.Color
not chatcolor
well maybe you can just convert it to bukkit color after
if you have a hex string, Bungee's ChatColor.of is the easiest way
and.. hot to solve this?
didn’t read full messages
