#help-development
1 messages · Page 2145 of 1
Doesn't do everything in console, only when I specifically do System.out.println() which when I look at it now makes sense I suppose.
This may be because spigot uses a logger instead...?
My question remains
rip
how can I detect if a player right clicked and or left clicked on a which block with a specific item
what event should i be looking to use
just like the world edit axe
playwrintersfactebnet
PlayerInteractEvent*
check player's hand item and check the Action.LEFT/RIGHT_CLICK_BLOCK
Is it possible to reload a datapack during runtime?
Or just select parts of it for that matter
this isnt datapack help
I know
Because this is not regarding datapack writing
This is about datapack loading
Yes. The vanilla reload command should be able to
How would I go about changing the max tps?
Yeah
oh what was it
I specificially only need to regenerate dimension types
bc its still not working during runtime
you wouldn’t
Though I don't believe those changes would be applied to works generated with its type
Surely it would be possible though, since a recovering server does it.
it might be possible but it would be a horrible idea
you would pretty much be speeding up your entire server
You can have a billion tps if you rly want to
That would be the point.
but that woulnt help the server's "health"
speedy server
best optimization tehnique
also might break stuff in the client
i don’t think it’s equipped to handle more than 20 tps
hacked clients moment
pretty much
I'm aware that it would result in lag if many things rae happening and some issues regarding physics, although if I just wanted to do something that requires teleporting an entity 20+ times a second then it would not be possible like this.
afaik tho, almost nothing is hardcoded towards the 20 tps
server sided animations?
like w/ entities?
you would literally be speeding up everything on your server though
With armor stands and stuff, yes.
You shouldn't be using system paths for your dependencies. Also you're specifying a main java class which a plugin shouldn't have
ex: every mob on your server would move faster, food would deplete faster, etc
I'm aware.
ok so the main class isnt the problem i already removed it
the system paths ill remove
if you are really intent on doing it it would probably be in nms somewhere
how does that afect my gson error though
It doesn't
that sounds like a better idea tbh
oh
although it might crash the client
so do u have any ideas about that tho
I think you need to relocate gson
yeah idk how to do that
Or use the one provided
is that in maven shade plugin
Yes
Not directly spigot, but does anyone have experience with using shadowJar plugin along side the maven-publish plugin within gradle?
You can read the wiki
yup
Mind taking a look at what I have, I seem to be having some issues?
sure
one sec then
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Ok, so reloading a datapack with modified world height does not actually update dimension types that are already used
(i.e. overworld)
So how would I update them instead
whats the issue?
So, the shadow jar does get published with everything included, however my plugin simply won't recognise that they're there in the lib package
oh so stuff isnt relocating?
Well
It is
I can see it is, but the other gradle project just won't accept that they are yet my maven repo says it has
so they're not relocated and shaded when other maven artifact projects try to add your maven artifact as a dependency?
Yes that is correct
What does bukkit use to log command feedback from CommandSender#sendMessage() to the console if the sender is a console?
it is essentially as if all packages/classes exist but the libs one basically
error in text form: https://paste.md-5.net/ufevipomiy.cs
Is there any way to make the custom name of an armor stand completely invisible? Even if the player looks at the armor stand? I'm using the setCustomNameVisible method, but if the player looks, the custom name appears 😭
finished making a java code flattener anyone want it
turns an entire file into one line
no idea why i made it
?
oh is he the one that gave me the idea?
i remember someone told me to make one
its in python btw because i was lazy and it took like 10 seconds
I'm working on a plugin that lets players enchant up to double the level of enchantments in an anvil and everything but enchantment books seem to work with this if statement, any ideas?
final ItemStack input = Objects.requireNonNull(anvilInventory.getItem(0));
final ItemStack input1 = Objects.requireNonNull(anvilInventory.getItem(1));
What?
wait, I checked if those were null right before that 🤔
Anyway
any ideas?
Objects.requireNonNull doesn’t just make some the object not null magically
cringe
people just put it in because intellij recommends it
They aren't null, I checked before that if
why are you using it then
e
where?
right above those since my event relies on those not being null
regardless, that's not what I asked
well for one you should use == for enum types
also works with xml
try just printing out the type of the items
OH yes
try using my flattener
Doesn't print with enchantment books
Other items do
best way of coding
are you getting an exception anywhere
nope
is the method getting triggered at all?
i would have to assume the item is null somehow because it doesn’t make sense for the type to not get printed
if anyone wants to know, this only takes 36 lines to make
and works with any coding language that allows compressed lines
It's an enchantment book from the creative inventory ¯_(ツ)_/¯
believe its
shadow {
publications {
//TODO
}
}```
yup
The items aren't null and they're both ENCHANTED_BOOK
according to java it isnt
not for the components at least
sure you could have a setter that mutates sth else
oh yeah
but thats because of the limiting target api in annotations
I asked how enchantment books store their enchantments
They don't store them with lore
Enchanted book enchantments are stored in json similar to enchantments
no, they don't
I mean
they have an nbt tag
Enchantments which takes a list of nbt compounds
{Enchantments:[{id:id,lvl:x}]} or sth
but I mean
custom enchants would also go under that tag
its just that they're not handled when it comes to lore
but ye
yes, but I'm talking about vanilla enchantments
You can access the stored enchantment data with EnchantmentStorageMeta
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/EnchantmentStorageMeta.html
declaration: package: org.bukkit.inventory.meta, interface: EnchantmentStorageMeta
men den tillåter inte dig att specificera så specifikt
oh yeah that one is a good example
yup
So they aren't stored the same way as on items
No it's different from regular item enchantments
:yay:
thats interesting
but Ig it makes sense
Yeah it's basically the same format for both just stored under a different name
just remade my code flattener to work with an entire project, so now i can turn the entire spigot api into one class
one line*
NP :>
Hi im stucked trying to do this on my menu
MenuButton button = new MenuButton(itemstack, ClickType.LEFT, (player, click, slot) -> player.sendMessage("Click " + click + " on " + slot));
My goal is to run the black section only when the click type equals to the one from the event
Thanks!
Do you want a constructor like that, or just a way to do it?
Cuz I've made an Icon class and ClickAction class
Which allows me to do that, but it's a lot of code
Snis 1 sec i send code ok?
Kk
public class MenuButton {
private final ItemStack item;
private final ClickType click;
private final Consumer<MenuAction> action;
public MenuButton(ItemStack item, ClickType click, Consumer<MenuAction> action) {
this.item = item;
this.click = click;
this.action = action;
}
public ItemStack getItem() { return this.item; }
public ClickType getClick() { return this.click; }
public void onClick(MenuAction event) { this.action.accept(event); }
}
public class MenuAction {
private final Player player;
private final ClickType click;
private final int slot;
public MenuAction(Player player, ClickType click, int slot) {
this.player = player;
this.click = click;
this.slot = slot;
}
public Player getPlayer() { return this.player; }
public ClickType getClick() { return this.click; }
public int getSlot() { return this.slot; }
}
why can't players be tped into locations with negative x & z coordinates
They can?
@EventHandler
public void onClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
Menu menu = this.handler.getMenu(player.getUniqueId());
if (menu == null) return;
if (!event.getView().getTopInventory().equals(menu.getInventory())) return;
MenuButton button = menu.getButton(event.getSlot());
if (button == null) return;
MenuAction action = new MenuAction(player, event.getClick(), event.getSlot());
if (!action.getClick().equals(button.getClick())) return;
button.onClick(action);
event.setCancelled(true);
}```
They can
Wait, what is your question again? What do you need help with?
How would I get a List of objects from a config
Need help to code this
Serialization?
No lol
Yes
you can cast a List<String> to another generic type?...
I didnt test it, just want to know if there a better way
Most generic is getaList which returns objects
Vs strings
I really don't know if i am working with my config correctly... it's confusing
And also my issue is that it told me that (action) -> bla bla = Is not an interface
So im annoyed how to do it
Should I just get all objects inside a configuration section that i want to work as a list?
I do something like this new Icon(slot, material, displayname, optionalLore).addClickAction(ClickAction...);
is that possible
Can i see your code?
For?
For that
Because im stucked
Lmao
I losted too much time and i want to understand how to fix it
It's like a few hundred rows tho. In like 3 classes
Idk personally for objects I use serialization but you do you
No offense, but I don't wanna give away the code I spent hours making just like that
Have you read my code?
Yeah
So let try to use my code
I can share some, but not all
wdym serialization, ConfigSerialization?
However, don't require click actions
I suggest adding them with a funciton
As you might want filler items or smth later
Before adding MenuAction class, i used to have a Consumer<InventoryClickEvent> on MenuButton class
Oh ok
So i will need to use a function?
So:
MenuButton button = new MenuButton(ItemStack, ClickType, Function<T>) ?
I identify the gui by using NBT tags stored in the items. And when I know what gui it is, i get the icons from that gui. Then I get the icon in the clicked slot and (if the click types are correct for that icon) use a "run" function for that icon, and send the event to get values.
Something like me, but instead of NBT i use player uuid for storing them
Hmm? In like a hash map or...?
Menu => Interface
PaginatedMenu => Implements menu class
InventoryMenu => Implements menu class
Map<UUID, Menu> menus
But menu isn't a class tho?
Menu makes reference either a normal menu or a paginated one
I still don't understand what part you need help with if this is working as it should
:V
The MenuButton class
What part? Is it not showing up? Doesn't it do anything on click? Any errors?
Wat...
Oh messed up you
Im really bad on english
No it's fine. I'm just confused what isn't working
There nothing working, because i dont have the code to doing what i want
Do i explained now?
Sure
Menu#getButton(slot) return a MenuButton object
public class MenuButton {
private final ItemStack item;
private final ClickType click;
public MenuButton(ItemStack item, ClickType click) {
this.item = item;
this.click = click;
}
public ItemStack getItem() { return this.item; }
public ClickType getClick() { return this.click; }
}
Up to know udnerstand right?
Yeah ok, so this returns a gui icon. And you want to add a click action yeah?
Ahh, ok then
But an action like this:
MenuButton button = new MenuButton(ItemStack, ClickType, (action) -> run code here);
I do something like this
private List<ClickAction> actions = new LinkedList<ClickAction>();
@Nonnull
public Icon addClickAction(@Nonnull Iterable<ClickAction> actions) {
assert actions != null;
for (ClickAction action : actions) {
this.actions.add(action);
action.setOwner(this);
}
return this;
}
Hmn im a bit nightmare
And then I have a click action class that looks sort of like this java @Nonnull public static ClickAction exitGUI(@Nonnull Player viewer, @Nullable ClickType... reactTo) { ClickAction act = new ClickAction(Action.EXIT_GUI, viewer, reactTo); return act; }
Don't use assert
Why?
Its behavior is defined by jvm flags
Unless a specific jvm flag is given assertions do nothing
Im stucked between passing the function to MenuButton and parsing it on InventoryClickEvent
Guess no more assert
Also why are you using a LinkedList
That what i want to understand how to do it
Cuz it is SLIGHTLY (I know) faster at adding entries. And I never get the action at an index, I iterate over it
public Icon addClickActions(Collection<ClickAction> actions) {
actions.forEach(a -> a.setOwner(this));
this.actions.addAll(actions);
}```
It isn't though
Isn't it?
No either way
It will average out to have better performance
Yes
Fuq the linkedlist then
I can run a basic benchmark right now
redempt is correc tthis:
Map<Integer, MenuButton> its correct right?
Mhm
That how i manage my buttons
How do I get a Material from a NamespacedKey
Snikus i also want to do this:
MenuButton button = new MenuButton(ItemStack, ClickType, (action) -> run code here);
How do i do the black part lmao?
do i have to myself do the iteration and check
Idk personally for objects I use serialization but you do you
27967μs for 1 million adds to ArrayList, 198200μs for 1 million adds to LinkedList
That's actually so much slower than I expected linked lists to be
Roughly 7x slower
Well the key is the material's name, is it not?
How fast is an if statement
I do this ```java
@Nonnull
public static ClickAction exitGUI(@Nonnull Player viewer, @Nullable ClickType... reactTo) {
ClickAction a = new ClickAction(Action.EXIT_GUI, viewer, reactTo);
return a;
}
Very
If you're worrying about it then you're doing it wrong
Stop prematurely optimizing
Nah I'm just curious
no, it would be something like minecraft:diamond_hoe
Can't you just do Material.valueOf(namespacedKey.getKey().toUpperCase())
okay
And how you parse it on InventoryClickListener? I dont understand
is only way to save and get location from config is to do String.valueOf(the location)
but is that reliable?
No
how
Menu API - Help
You can save a Location directly in config
oh ik that
And get it with ConfigurationSection#getLocation
Yes
Why the FUQ is the LinkedList even a thing? I watched some video on the differences between linked and array lists. And the result was that linkedlists are good for a lot of adding, otherwise bad. But obv it can't even do that
At least in modern versions, the material versions match the in-game keys except for casing
LinkedLists are almost never useful
Its first time hearing that for me
In 99.9% of cases, ArrayList will outperform it
I have only ever had a single use case where linked lists were the better choice
icon.clicked(event); in the event listener, then this.actions.stream().filter(a -> a.validClickType(event.getClick())).forEach(a -> a.run(event)); in the "clicked" function. And the "run" is just a switch for the action types
Which was?
I actually had to implement my own linked list for this because java's LinkedList doesn't expose the nodes and I needed them for this
So it wasn't even useful?
The built-in one was not
It is just pure garbage
Linked lists as a concept were
Hmm
No more linked lists then
Thank you, I would have continued using them otherwise
lol
Shoot
To add to a linked list, what do you have to do
Snisk i think that its better if you help using my own code
You have to create a new linked list node
Ohh
That's an object creation, which involves a heap allocation
Then you have to set that as the next of the tail
Then you have to set that node's prev as the previous tail
Then you have to update the tail of the list
That's an object allocation and multiple memory writes
Sure, you never have to copy memory around to expand a linked list
I'm not really how to do that tho, sorry. It's hard to explain that much code :/
But while each add may be O(1), there's a lot of overhead to what they do
Now consider what it takes to add to an array-backed list
It's literally just a single memory write
You put the pointer to the object at the location in the array
And if you have to expand, the cost is actually very low
Because every modern processor has SIMD instructions
No you can't do that
I mean yeah
You can't just extend it, you do have to reallocate
"Extend"then
Nope
You have to copy
But SIMD makes it not that slow
SIMD stands for Single Instruction Multiple Data
System.arraycopy uses SIMD instructions to copy the contents of an array
I know how an array works, I was just to lazy to write copy ig
SIMD can operate on up to 16 "lanes" at once
And copying memory from one location to another is one of the fastest operations there is because of this
So it doesn't actually take n pointer writes to copy the list, with n being the new capacity
On most modern processors it will take n/8 or n/16 writes
CPUs are just designed to be good with arrays
tldr, linked lists suck
Yeah
That being said I still did not expect adding to a linked list to be 7x slower
I just blindly trusted the video I watched and assumed that making a new node object was faster than growing an array
But ig not
Growing the array doesn't have to be done that often and is a very cheap operation
I'm pissed at my college because they spent the majority of the time in the data structures and algorithms class talking about linked lists
:V
Linked lists have their niche but in the vast majority of cases they are useless
Only case they're really useful is for making data structures like LinkedHashSet/LinkedHashMap and for uses like mine where I have to assemble an expression tree from a list of tokens
Why would that be faster tho?
Why would what be faster
With a linked instead of an array i mean
What do you even mean
Talking to verano there
Though I still do not know what you're asking snis
Redemp can you help me please?
Why is using a linked list better than an array list in this case?
Can you answer my question
^
Because of the unique property that you can do an adjacent remove in O(1)
Ohhh
Basically you have an expression like 1 + 2 * 3
All of those get tokenized
So your tokens end up being [1] [+] [2] [*] [3]
With each thing in [] being a token
You iterate over those tokens and sort them into their own lists based on priority
Storing the node of the token rather than the token itself
Im trying to run code when you click a specific item and slot, but on that function i want to be able to use a variable which can provide getter for the player, slot, click type from InventoryClickEvent
Do i explaine?
Then when I get to * I can remove the 2 before it and the 3 after it and replace it with an Operation token that acts as a value and is lazily evaluated to the result of applying the operator to the two operands
Then you have something like [1] [+] [2*3]
That is why, when I get my icons, I create the actions using something like this openPreviousGUI(@Nonnull Player viewer, @Nullable ClickType... reactTo)
And then you repeat the step for + and you're left with one token that represents the whole expression
And what's stopping you
That makes a lot of sense yeah, did not think of that
I dont know how to execute a function having a variable served
Make a click action class, and add the variables you want to use when you create the instance
public void doThing(Consumer<Integer> func) {
func.accept(1);
}```
Oh jesus why it so diff to get understand
doThing(a -> System.out.println(a + 1));```
I will send again full code
This will print 2
how to compare locations without comparing yaw and pitch
without setting it to 0, 0
Write your own comparison function that only compares x y and z
I dont why its diff to explain whati want if its easy to understand :annoyed:
Imma go try to squeeze a few hours of sleep in. Cya redempt, thanks for the lecture :> Hope you manage to help verano
I probably won't
Yeah, I have to be up in 4.5 hrs. Sorry lol
Get some sleep
Me?
.-.
Yeah prob yes i will go to sleep its 4am
This is kind of why it's hard to help you
I will, thanks for again for the linked list help lol
You gotta provide more context and read the conversation closely
Gn
Yea I'm always down to shit on linked lists :)
Gnight
Allright redempt please 1 more oportunity
hehe
I promise i ill explain really carefully
I didn't even see the beginning of your post so what's the full problem
https://i.imgur.com/Zfn78Lr.png the particles and armorstand should be both teleported / spawned at the same place, but then why do the armorstands only get teleported correctly after 10-20 seconds?
Clientside bug
When an invisible armor stand is teleported sometimes the client doesn't get the memo for some reason
Especially in older versions
What version are you using
1.18.2
My issue is that i want to execute code and be able to use a custom object like this here:
MenuButton button = new MenuButton(ItemStack, ClickType, (action) -> run a custom function);
Hm
And what issue are you running into with that
You might just have to kill and respawn the armor stands instead of teleporting them
I dont have an issue, i just dont know how to run a custom function and be able to ue (action) variable
same problem with visible armor stands
I mean come to think of it, using armor stands like that is probably not gonna work out very well
oh okay
Because even if you do kill and respawn them
When you respawn them, even if you make them invisible immediately, the client will still see them for a tick
Did you read what I posted earlier
trying to imitate that one botania item and i need tools for that
.
In your case you would just take a Consumer<InventoryClickEvent>
If you're not familiar with functional interfaces and how they work you should familiarize yourself
Key of the king's law?
yea
Ah I fucking love botania lol
Yeah i was using that before, but then i realized that i dont need all the getters from InventoryClickEvent
same
i mean teleporting works
Leave gravity on for them and give them velocity
after about 10 seconds
What do you mean
Yeah InventoryClickEvent, contains getWhoClicked(), getSlot(), getRawSlot() and many others right?
Are you trying to say that rather than having it take an InventoryClickEvent, you want to have it take specific properties of the event, like the clicker and the slot?
Yes
What would be the point
ok this is weird, they now slotted into place one after another, but only half of them
..ok, then define your own functional interface
I thin kyou catch what i need
is there a reliable way to copy each message sent to console
@FunctionalInterface
public interface ClickListener {
public void onClick(Player player, Action clickType, int slot);
}```
You can add a log handler
After defining this functional interface your method would just take a ClickListener
Again, if you don't understand functional interfaces, go familiarize yourself with them
tried that
but most plugins use their own logger
But then i would be able to use:
(player, click, slot) -> code code here?
do you really need to annotate your functional interfaces
and I tried to go through all of the loggers but it doesn't show the loggers from some of the plugins
You don't NEED to
Oh allright
okay I was like i've never done that
But there's nothing wrong with it
Sorry
It's kinda like @Override
maybe?
So how would it look?
How would what look
you can trail the latest.log file. this is definitely the best way
Consumer<ClickListener> action right?
This is really cursed but you can get logs another way
So will be:
MenuButton button = new MenuButton(ItemStack, ClickType, ClickListener) right?
tried that but it only works for when plugins use println
trailing the latest.log is the best way
oh okay
PrintStream myStream = new PrintStream(System.out) {
@Override
public void println(String msg) {
CompletableFuture.runAsync(() -> logConsoleMSGToDiscord(msg));
super.println(msg);
}
};
System.setOut(myStream);
this is what I had (courtesy of 7 something I forgot his name)
trail the latest.log file for full console output to be read
why are we ignoring the fact you can just trail the latest.log
the response from minex
seriously just read the file
System.setOut(new PrintStream(System.out, true) {
@Override
public void print(String line) {
super.print("Intercepted " + line);
}
});
System.out.println("Hello!");```
Intercepted Hello!
Oh wait
Yeah don't use that lol
Just get the parent logger of the bukkit logger
And if that's not the root, then repeatedly get the parent until the parent is null and bam, root logger
Redempt i finally understand really thanks
I didnt understand, so i calm down. And try again, so i fixed it
😮💨 🤙
And sorry for being annoyed
@waxen plinth really thanks. Have peacefull night/day, regards
log4j logger doesn't have addAppender() anymore...?
🙏
Hi, I,m trying to implement custom enchantments, but when I try and add one to a book, it doesn't work. No error messages, and when I try and output the enchants, it just isn't there.
Code:
ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
EnchantmentStorageMeta bookta = (EnchantmentStorageMeta) book.getItemMeta(); bookta.addStoredEnchant(CustomEnchantments.TELEPORT, 2, true);
book.setItemMeta(bookta);
((HumanEntity) sender).getInventory().addItem(book);
player.sendMessage(book.getEnchantments().keySet().toString());```
Well you're reading from book.getEnchantments()
That's not going to give you the same result as the stored enchantments
Do I need to register every Listener? Is there anyway I can avoid registering it?
Applied enchantments and stored enchantments are different
Why would you not
1.8 Boss Bar
I remember that when I wrote enchantments that way, it never showed up on the item even if it was applied
if you put them all under one package, then you can auto register them using reflections
Because the client doesn't know how to display the custom enchantment
It's entirely possible that the enchantment is on the book but there's no display
yea just do it like hypixel and add the enchantment to the lore
yeah, you would have to add custom lore in addition to the enchant
say im writing my own Menu class and one of the methods allows you to get the event without having to register its own listener class, like this:
@EventHandler
public void clickHook(InventoryClickEvent event) {
Inventory playerInv = event.getClickedInventory();
if (playerInv != null && this.inventory != null) {
if (playerInv.getHolder() == this && inventory.getHolder() == this) {
this.handleMenu(event);
}
}
}
public abstract void handleMenu(InventoryClickEvent event);
Yeah that's true I just realized, but the problem is the enchantment just isn't there (The glint) even when applying on a bow, for example.
Sidenote
If you want, I've got a custom enchantments library that makes it super easy
It looks something like this
public class HelloEnchant extends CustomEnchant {
public HelloEnchant() {
super("Hello", 1);
addTrigger(EnchantTrigger.BLOCK_BREAK, (e, l) -> e.getPlayer().sendMessage("Hello!"));
}
}```
what do you mean?
make a static set of every menu created -> if the set contains the inventory clicked get it and trigger the click method
This is an example of what a simple enchantment could look like with my library
was thinking that, sounded cringe but oh well
You can register multiple listeners if needed
But using just one is preferable there
It's better for performance, though it'll probably never really make a difference
oh yeah it implements the event and enchant in 1 class, cool I may use it in the future :)
got it
Here's the wiki page on how to use it if you want to
Wow that's really cool
That's part of redlib right?
just gotta make sure you stop the appender in your onDisable method 🙂
Yes
lets gooo
thank you kind sir
Upon further testing, it actually adds the enchantment, but when I give the bow to the player, the enchant's not there. Any ideas why?
Is the enchantment not there, or is it just not being rendered by the client?
are you giving the itemstack with the correct item meta attached
It's not there, I have a command that checks item and it returns {}
how are you giving it to the player
((HumanEntity) sender).getInventory.addItem(bow), last line.
hm
Why are you casting to HumanEntity
sender is a CommandSender type and my idea tells me to cast to humaneentity
Don't blindly cast, either
Sidenote if you want a better way to do commands I've got that too
ok thanks I'll try that
I use lamp for commands 🤷♂️
What's lamp?
A command library
There's a good number to choose from
what one do you use redempt
The one I wrote
nice
I can show you how it works if you want
is it on github or private
It's public and fully documented
send me a link
To the wiki or what?
wiki/source
It still doesn't work, even when casting to player
Also if you want to compare you can give me an example of a command to implement and I'll show you how it'd look
Makes sense, since casting doesn't actually change the type except for primitives
I think doing enchantments that way is just finnicky
Did you register the enchantment?
Can you even register it anymore?
I don't remember how honestly
Mm
I watched a tutorial some time ago when implementing custom enchantments and I just kind of copy-pasted the registering code, as I don't know how reflection or registering works. Here's the code.
If it's being applied but then erased when it's given to the player I doubt addUnsafe would make a difference
I don't think its even being applied
If you don't know how reflection works then you may want to steer clear of doing it that way and just use a library
I watched the same tutorial for the wrapper than exited out
Its a pain to dig through source code 
Ok thanks
if(plugin.getBot() != null && plugin.isEnabled()){
plugin.getBot().logConsoleMSGToDiscord(MiniMessage.miniMessage().stripTags(message));
}
How can I strip that down?
Oh I know why
Wait no I don't
Can I see the actual string printed by the bot
Copy and paste it into a hastebin
?paste
No
What the BOT prints
The raw contents of that string
Then I'll write you a method to clean the string
oh
I could just try to do that myself
for fun
if I fail I'll come back to you 😂
Ok
Before removing all my code and starting over, I tried to manually register the enchant, and it said that teleport has already been registered, so I don't think that can be the problem. Tried with a normal enchant and it works :/
yes
Where some of the metadata has been stripped but it has not yet been turned into the raw string to be displayed
?pdc
i fixed the armorstand not teleporting correctly issue
you just need to spawn them outside of the players render distance
and then teleport them
then it works
lol
this is my current code 💀
// Breaking down the message from colors and such
message = message.replaceAll(String.valueOf('\u00A7'), "");
message = message.replaceAll("^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$", "");
if(plugin.getBot() != null && plugin.isEnabled()){
plugin.getBot().logConsoleMSGToDiscord(MiniMessage.miniMessage().stripTags(message));
}
doesn't do anything
I could probably remove the minimessage thing
Yeah let's see the raw message prior to calling stripTags on it
Can you show me that
it was the same thing
Oh, interesting
There's no good way to do that then
Because if someone just said #000000 in chat you would want to leave that unchanged
There's no way to separate contents from formatting like that
Right, which is why you need to get the message at a different phase of processing
Ok another warning
This is super cursed
But you can open a reader on the log file and have a separate thread watching it for new messages
Yes it does
Hm
whenever my plugin uses hex or whatever I could strip it before I send if the sender is the console, but I can't account for other plugins
Why use hex colors instead of chat colors?
minimessage
hex colors look good
and ^
Apparently idk minimessage
its just a lib for handling them
Can it send hex colors in-game?
yep
o-o-o-o
yeah it's really nice
and the best part is the syntax
I handle all of my hex colors and everything through it now
private void sendHelp(CommandSender sender){
sender.sendMessage(mm.deserialize(" <newline>" +
"<gradient:#B600FF:#FFF700><b><u> Discord Server Panel <reset><newline>" +
" <newline>" +
"<hover:show_text:'<green>Click to suggest command'><click:suggest_command:/panel reload>" +
"reload <dark_grey>- <grey>Starts a new bot with the token from the config<reset><newline>" +
" <newline>" +
"<gradient:#B600FF:#FFF700><b><u> <reset><newline> "));
}
I bet
gradient is SO easy
Yeah gradients are great anyways, everything is handled internally
So it uses an HTML-like syntax
ye
Wonder how they pulled it off inside the lib?
no idea but minidigger is smart
I would be interested in seeing the internal workings
it's part of the Adventure family that paper now runs
I didnt want to switch to adventure and what not but like, once I figured it out its the best thing ever
same
yup
I have advanced a level today XDD
If I wanted to have custom spawning of an ArmorStand with information saved on the ItemStack
could I cancel a PlayerInteractionEvent and do my own logic?
Yes
Could you be a bit more clear? What itemstack? Why is there a playerInteractionEvent?
thanks redempt
It sounds like an easy yes but I'd like to be sure
the itemstack from the event, and the event is an api thing for running code when a player right clicks an item. just a few checks and boom
I'm guessing they want to cancel when the player right-clicks a block with an armor stand and do their own custom logic
yes, i want to handle the actual armor stand spawning logic
Oh I see, yeah that'd be easy enough. I recommend using the PersistentDataContainer if you're storing lots of information.
Ok, cool
Yeah it's one of the best things in all of Spigot imo; you can store so much data in various entities and items
I used them to make ravagers tameable and breedable
is this how you spawn an armor stand?...
ArmorStand stand = player.getWorld().spawn(event.getInteractionPoint(), ArmorStand.class);
how exactly did you do this? im having the same error
add the maven-shade-plugin version 3.3.0, set its goal to shade and it's phase to package, and then set the scope to "compile" in every dependency you wanna shade
permissions:
aetherislesplugin.join.admin: false
aetherislesplugin.join.mod: false
aetherislesplugin.join.member: false
``` ignoring the weird names, is this how I would register permissions in plugin.yml (the false means they are not enabled by defualt, right?)
tysm
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
here's also an example
will take a look, ty
I have a record class that implements ConfigurationSerializable but it didn't serialize when i did
section.set(name, category);
those are for deserializing
huh
u have to tell it how to serialize
wait i think it did serialize correctly
Trashcan:
==: us.iears.pixiedustgenerator.models.ModelCategory
materialId: cauldron
name: Trashcan
is that ==: for the class?...
ew
is there anyway to not have that 💔
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
theres a serialize method
yes its working correctly i presume, i just thought that it broke because its now spouting straight up java like that
its a bit ugly but oh well
api is api, what can you do
It has to be there, otherwise Bukkit wouldn't know how to deserialize it when you get it
So if you're using ConfigurationSerializable, yes. Though if you opt not to use it and just do your own serialization/deserialization (which is certainly an option), you don't have to have it. Though you're going to have to be a bit more careful with how you parse it
Should i be dynamically adding columns to my sql table or should i create a new table for each column
I'm storing stats but i may want to store a lot of stats in the future
I'm wondering if i should do column per stat or tabler per stat
probably just have one table for stats
doesn’t make sense to make a table for every stat
That's how I've done it then i see the innodb limit for columns is only 1000 ish
I'm never gonna store that much but i read that more columns is worse performance
Generally worse*
well you could probably have a different stat table for every gamemode
and then just link the gamemodes in one separate table
presuming you have multiple gamemodes
Table per stat is probably insane. You'll want to keep that in one table and if you really want to add more stats in the future, you may just have to ALTER TABLE
Saw some stats plugins doing that
Yikes
Yeah, ALTER TABLE isn't great
I guess its A solution though right?
It's probably the most sane solution tbh. Because again, you're going to end up with a hell of a lot of tables that contain nothing more than 2 columns
True
Joins are expensive too i think right?
Alter table is just a one time thing at most
Yeah. Unless you have millions of entries it shouldn't be terrible either
honestly a lot of the time i just store data as json in sql
definitely not the most structured but it makes things simple
I just use mongodb
mongolian database
Aboslute Based DB
MongoDB is so secksy
ngl, Mongo would probably be ideal for statistics over SQL
NoSQL is best if you really can't predict what data you're inserting
@humble tulip if that's an option for you, ^
Or if you're writing a public plugin, at least make Mongo an option as well
hey guys with bossbars
how do i show progress changes
is it just bar.setProgress(1-100)
and then it should update
or is there something im missing
Looking for a Part-Time / Full-Time Developer for an upcoming project.
Must be up-to-date with the newest plugins / news as well as being familiar in JS.
Message me if you're interested in knowing more.
ok nvm i fixed that issue
how do u remove boss bars on reload
or just remove them in general
bossBar.removeAll() doesnt remove the bar at all unfortunately
i'm trying to get all cane blocks above the current block, would this be inefficient?
for (Block current = e.getBlock(); current.getType() == Material.SUGAR_CANE_BLOCK; current = current.getRelative(BlockFace.UP)) {
blocks.add(current);
}
Make the boss bar not visible, perhaps?
You need to destroy your bossbar on plugin disable
So it will work fine with bukkit reload maybe, I don't recommend using bukkit reload tho
That's fine.
what is bla*kspigot WEBSITE?
heavenly sings PDC
just store using PDC
Hello, when i always try to do something with a loop in condition it always breaks the loop
how can i provide while loop to wait
I am not dealing with bukkit
and when i use Thread.sleep(); its already leaving from loop and my scanner.nextLine(); answering the more topped loop
wtf
It requires getHandlersList() implemented, but IDE expects from you to implement getHandlers(), which btw I implemented
and no API versions are not mismatching im using the same version of Spigot both for plugin via gradle (Spigot-API) and for minecraft server
nvm, getHandlersList is static and its not extendable from the class since its static
my bad
If i use BaseComponent#addExtra(BaseComponent) and the 2nd component is bold and the first is not, will the 2nd component remain bold
When I use player.getinventory().addItem(ItemStack item) if the player doesn't have enough space in his inventory, the items that are supposed to be added are just not added
is there a way to make the items drop on the floor like in vanila?
best obfuscator w/ string encryption?
How do I make my plugin execute a vanilla command?
/give
Why not use the api?
because if the player doesn't have enough inventory space, the not given items just disappear
they are not dropped
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Or just google Java Hashmap
Uh if inv is full
drop item stack
getWorld().dropItemNaturally(Location, Item);
oh wait nvm i miss read ur question
what's the proper way to get the block sub type (magic value)?
since Block.getData() is deprecated, I'm looking a the right way to do it
package nl.stefanokeizers.grabbelton.listeners;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import nl.stefanokeizers.grabbelton.Main;
import nl.stefanokeizers.grabbelton.utils.Utils;
public class GrabbeltonOpenListener implements Listener {
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player p = (Player) e.getPlayer();
final Integer grabbel = (Integer) Main.grabbelConfig.getConfig().get(p.getUniqueId() + ".Pogingen");
if (e.getAction().equals(Action.LEFT_CLICK_BLOCK) || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
if (e.getClickedBlock().getType() == Material.LIME_GLAZED_TERRACOTTA) {
if (grabbel == 0) {
p.sendMessage(Utils.colorize("&cJij hebt geen grabbelton poging(en)."));
e.setCancelled(true);
}
if (grabbel > 1) {
Main.grabbelConfig.getConfig().set(p.getUniqueId() + ".Pogingen", (Integer) grabbel - 1);
Main.grabbelConfig.save();
p.sendMessage(Utils.colorize("&7Je hebt de grabbelton geopend, succes!"));
// Open grabbelton menu
e.setCancelled(true);
}
}
}
}
}
Hello why does it execute 2 times
Can someone help
can someone help me fix a pom.xml error
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
how do i fix it
^
either the underscore or the plus is problematic
what happens then
i still get the eror
how do i fix this
build failed
@urban kernel you are working with ultra minions?
does someone know if there is an difference between the default spigot and derkutils spigot? (https://github.com/Derkades/Derkutils) ?
yo guys how can I access each block or location in a bounding box
i copied an repository and it needs an jar from this derkades repository
so that I can fill it with any blocks i want
This looks like a library that sits ontop of spigot
how do i "provide a goal"
mvn install, in this case install is the goal
okay
Same problem
thanks
For mvn package, package is the goal
that does not exist
when I try to get the hashmap of the additem function does the function get executed or does it only get the hashmap?
After the arguments
It's mvn install or mvn package in 90% of cases
Ah right, people these days do not know how to use a CLI...
where do i put "the goal"
I am an eclipse user, so you are on your own
oof
@urban kernel Can I send you a DM?
where do i put "the goal"
yessir
Just run maven for the terminal..
Maven can be installed in a portable fashion (similar to gradle), it is just a bunch of scripts after all
When I execute giveAmount(player, Coin, 21875751) is gets an error that says can't drop air
is = is.clone();
is.setAmount(amount);
final Map<Integer, ItemStack> map = p.getInventory().addItem(is);
for (final ItemStack item : map.values()) {
if (!(item.getType().equals(Material.AIR)))
p.getWorld().dropItemNaturally(p.getLocation(), item);
}
}```
idk why
so I need to check if the item is not null
I deleted this line
enums
why is this always true
thats weird
The ItemStack in the players hand is never null. If its empty then its air.