#help-development
1 messages · Page 213 of 1
and if they are air go to the next one. If you happen to reach the end of the loop, spawn it in that blocks location
what does iterate mean
loop through them
k
how would I loop through them, for loop or runnable/
You wanna use the InventoryHolder. Create one, set it during creation and check if it's yours
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/Inventory.html#getHolder()
declaration: package: org.bukkit.inventory, interface: Inventory
oh waiat
for loop :)
for(Block block : sight) {
I tried something else
but Ill try that too
if (event.getItem() != null) {
double x = event.getPlayer().getAttackCooldown();
int y = (int) x;
if (x == y) {
List<Block> sight = player.getLineOfSight(null, 0);
List<Block> sight1 = player.getLineOfSight(null, 1);
List<Block> sight2 = player.getLineOfSight(null, 2);
if (event.getItem().getItemMeta().equals(ItemManager.GravHammer.getItemMeta())) {
if(sight.isEmpty()){
Location playersDirection = player.getLocation();
player.getWorld().createExplosion(playersDirection, 5f);
System.out.println("I work");
}
if(sight1.isEmpty()){
Location playersDirection = player.getLocation().add(player.getLocation().getDirection().multiply(1));
player.getWorld().createExplosion(playersDirection, 5f);
System.out.println("I work");
}
if(sight2.isEmpty()){
Location playersDirection = player.getLocation().add(player.getLocation().getDirection().multiply(2));
player.getWorld().createExplosion(playersDirection, 5f);
System.out.println("I work");
}
}
}
}```
:doubt:
nah don't do it that way. You will do line of sight 3 times
int y = (int) x
if(x == y)
If you want it to stick with 2 blocks forever you can do it without a loop. But I don't like coding in a way that doesn't allow changes
stop
When does that ever return false xd
would this work?
its just a stab
if (event.getItem().getItemMeta().equals(ItemManager.GravHammer.getItemMeta())) {
for(Block block: sight) {
if (sight.isEmpty()) {
Location playersDirection = player.getLocation().add(player.getLocation().getDirection().multiply(2));
player.getWorld().createExplosion(playersDirection, 5f);
System.out.println("I work");
}
if(sight.contains(block)){
Location playersDirection = player.getLocation().add(player.getLocation().getDirection().multiply(1));
player.getWorld().createExplosion(playersDirection, 5f);
}
if(sight1.contains(block)){
Location playersDirection = player.getLocation();
player.getWorld().createExplosion(playersDirection, 5f);
}
}
}```
List<Block> sight = player.getLineOfSight(null, 2);
boolean foundBlock = false;
for(int i = 0; i < sight.size()-1; i++) {
Block block = sight.get(i);
if(block.getType() != Material.AIR) {
foundBlock = true;
player.getWorld().createExplosion(block.getLocation(), 5f);
break;
}
}
if(!foundBlock) {
player.getWorld().createExplosion(sight.get(sight.size()-1).getLocation()), 5f);
}
this is what I meant. There are other ways ofc
Might have forgotten some brackets. idk
And that way you can freely adjust the range without having to change anything else :)
sight.get is probably gonna cause an error for the create explosion part
I think you can just create location loc
and assign it to that doe
inventory.setItem(i, new ItemStack(Material.RED_BED));
How can I set the name of the red bed to "hi"
ignore the "i"
By creating the itemstack beforehand, getting its ItemMeta, setting the metas customName and setting the itemMeta back to the ItemStack
Np :)
ItemMeta meta = yourItemStack.getItemMeta();
meta.setDisplayName(“Name”);
yourItemStack.setItemMeta(meta):
ItemStack item = new ItemStack(Material.RED_BED);
item.setItemMeta()
inventory.setItem(i, item);```
thanks
Method invocation 'setDisplayName' may produce 'NullPointerException'
Is that normal?
it depends on what you called it with
Also you should add all of the wonderful people in here to the authors list in your plugin.yml. They’ve arguably written more of your plugin than you have xd
😛 I should
public static HashMap<Integer, UUID> codeMap = new HashMap<>(); int code = generateCode(); codeMap.put(code, p.getUniqueId()); Bukkit.broadcastMessage(String.valueOf(codeMap)); i cant broadcast the hashmap... the value never gets set in to the hashmap when using Bukkit.broadcastMessage("keys: " + codeMap); there are no keys in the hashmap
Iterate through the hashmap
If you want just the keys: codeMap.keySet()
And iterate through them
the issue is the values arnt being set in to the hashmap
Check isEmpty()
its true
https://paste.md-5.net/umetubetuw.java
Line 130, the inventory is not opening for some reason
Then that three-line snippet of code must not be called.
it is because below it i use p.sendMessage(t(MessageUtil.getMessage("linking.minecraft.link").replace("%code%", String.valueOf(code)).replace("%bot-prefix%", BotUtil.getPrefix()))); and it sends me the message
if(clickedItem.equals(new ItemStack(Material.PAPER)) {-- This doesnt do anything, anyone know why?
Should probably use isSimilar, for starters.
ill try it
if(clickedItem.isSimilar(new ItemStack(Material.PAPER))) {
Didnt work (I have debug messages so I know)
just to make sure clickedItem is final ItemStack clickedItem = event.getCurrentItem();
Does clickedItem have a name, lore, enchants, etc on it?
Or is it just straight up a piece of paper
name yes
:p
how do I put the name in the check
if(clickedItem.isSimilar(new "myitemname")) { --??
anyone know?
Hiii, guys, so, I'm making a plugin where there is custom types of milk for each mob. I'm making a class for each milk, like "ChickenMilk", "CowMilk", etc, etc
I want to detect when the item is consumed, so I'm using "PlayerItemConsumeEvent"
however, with this I can retrieve the ItemStack that was consumed, with event.getItem()
I want to do some kind of check to see if the Item retrieved is a "ChickenMilk" object
(ChickenMilk extends ItemStack)
is there a way to make like some kind of id to this Item?
Use .isSimilar for the item name
I'm not sure If I get It, isSimilar checks if the name of the Item is the same as the argument?
So like, if the name of the Item is "Chicken Milk", do I put "if e.getItem().isSimilar("Chicken milk") {}"
Ooh, that will probably work
I'll try something different tho
this:
if (milk instanceof ChickenMilk) {
player.sendMessage("Drinking chicken milk!");
}
if(Objects.requireNonNull(clickedItem.getItemMeta()).getDisplayName().equals("")) {
hey
where milk is the output of event.getItem()
okie
um when i set item meta for LodeStone compass for setting lodestone location it has a weird transition in hand
any way to fix it ?
have you looked at ?jd-s?
wym ?
?pdc
use pdc instead of checking item names
that what I was looking for
im trying to use Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), command); but im getting java.lang.IllegalStateException: Asynchronous command dispatch! (because im using this in JDA and all its stuff is async) so is there a way to run a command in sync?
but I'm planning to use "instanceof" instead
i think that's only possible during a session tho
because ChickenMilk extends ItemStack
when bukkit saves the item stack it doesn't know its a custom one
so after a restart all of your custom items will break
ah, I see...
ah ? bukkit saves itemstacks in item itself
it wont break on restart if you have a code that depends on their pdc or their name whatever
yeah
anyways
if (e.getRightClicked().getType() == EntityType.CHICKEN) {
ChickenMilk chickenMilk = new ChickenMilk();
player.getInventory().setItemInMainHand(chickenMilk);
player.sendMessage("You just milked a chicken");
}
Hi, I'm trying to make so when a player uses an empty bucket on a chicken, he will get a custom Item I made named "ChickenMilk"
However, when I use the command "setItemInMainHand(chickenMilk)", the player gets nothing on their mainHand
I was excepting they to receive the material from the Item chickenMilk
which is declared on the constructor
public ChickenMilk() {
ItemStack item = new ItemStack(Material.MILK_BUCKET, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Chicken Milk");
List<String> lore = new ArrayList<String>();
lore.add("Milking chickens, now that is new");
meta.setLore(lore);
}
oh, wait, I have a theory, a programming theory
lol
I just realized I was creating a new object ItemStack, when I should actually be using super() for that
since ChickenMilk is a subclass of ItemStack
Not sure if this gonna solve the issue, but makes a lot more sense
i really don't recommend implementing itemstack
if you put it into a chest it'll also break
relogging breaks it
For custom items just use PDC to recognize them and then a custom object
^^
ooh
I'm not sure if I understand that. Its my first time making a custom item
lets see...
so how would I make this?
@EventHandler
public void onDrinkChickenMilk(PlayerItemConsumeEvent e) {
ItemStack milk = e.getItem();
Player player = e.getPlayer();
if (milk instanceof ChickenMilk) {
player.sendMessage("Drinking chicken milk!");
}
}
wait
Its wrong D:
nah, Its fine
I should just use milk.pdc == <number for the milk custom item> (or something like that) ?
how would you send a hyperlink through a command?
I see, I will try that later
but I don't really get It why my code isnt working as intended
@EventHandler
public void milkChicken(PlayerInteractEntityEvent e) {
Player player = e.getPlayer();
if (player.getInventory().getItemInMainHand().getType() != Material.BUCKET) return;
if (e.getRightClicked().getType() == EntityType.CHICKEN) {
ChickenMilk chickenMilk = new ChickenMilk();
player.getInventory().setItemInMainHand(chickenMilk);
player.sendMessage("You just milked a chicken");
}
}
this, I mean
It should set the Item of the player to a object of chickenMilk
but instead Its setting to a regular Milk Bucket
in this code snippet you forget to set the item meta back onto the item
but you said you changed it
so idk
Alguien que hable en español ?
I'm not sure if It did, this is what my class looks like:
package me.dotarakotara.eventlisteners.items;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class ChickenMilk extends CustomItem {
public ChickenMilk() {
super(Material.MILK_BUCKET, 1);
ItemMeta meta = getItemMeta();
meta.setDisplayName("Chicken Milk");
List<String> lore = new ArrayList<String>();
lore.add("Milking chickens, now that is new");
meta.setLore(lore);
}
}
why, tho? I mean, the meta variable is a reference, right? So shoudn't It automatically change wen I change the properties of meta?
getItemMeta returns a copy of the item's meta
ooooooooooooooh
but you're implementing itemstack anyways
ah wait
itemstack is an interface
i was gonna say just use the itemmeta var
field
same thign
but you would need to extend CraftItemStack
and i don't even think its protected
public class ChickenMilk extends CustomItem {
public ChickenMilk() {
super(Material.MILK_BUCKET, 1);
ItemMeta meta = getItemMeta();
meta.setDisplayName("Chicken Milk");
List<String> lore = new ArrayList<String>();
lore.add("Milking chickens, now that is new");
meta.setLore(lore);
setItemMeta(meta);
}
}
added the last line
that would be correct
Umm…. How does one milk a chicken 🤨
Now I just need to fix the event for when you actually drink the Item
🤨 🤨 🤨
ahahahaha
you can milk ANY entity
:)
Kinda sus my guy xd
YAYY
@EventHandler
public void onDrinkChickenMilk(PlayerItemConsumeEvent e) {
ItemStack milk = e.getItem();
Player player = e.getPlayer();
player.sendMessage("Reaching here");
if (milk.getItemMeta().getDisplayName().equals("Chicken Milk")) {
player.sendMessage("Drinking chicken milk!");
}
}
I'm doing this to check if the Item is a ChickenMilk object
however, I think there is a better way to do It
I just don't know how
?pdc
that covers all you need to know
ok!
Bro what...
What are people making these days
Seems interesting
Could someone tell me how to translate the plugin into Spanish
Sorry, I don't know spanish very well :(
Hey guys, It seems like the player is not receiving the potion effect that I expected
@EventHandler
public void onDrinkChickenMilk(PlayerItemConsumeEvent e) {
ItemStack milk = e.getItem();
Player player = e.getPlayer();
if (milk.getItemMeta().getDisplayName().equals("Chicken Milk")) {
player.sendMessage("Reaching here");
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 1000, 1));
}
}`
Its sending the "reaching here" message
the problem is the line with the addPotionEffect 🤔
I guess
Isn't 1000 = 50 seconds, and 1 = power 1 ?
oooh, maybe the amplifier has to be 0 since there is not Slow Falling II or whatever
I will try It
Is it reaching the “reaching here”?
Also you should look into PersistentDataContainer as opposed to checking for the item by display name
changing the amplifier to 0 didn't work
The plugin does not have any option that translates all the messages or names of the items to Spanish?
but It is reaching the "reaching there"
no D:
try souting player.addPotionEffect
it returns whether or not the player actually received the potion effect
oooh, I see
It's giving "true" O.o
but I don't have any potion effect
oh wait
It clears the effects xd
lmao
I was so confused because the code looked fine lol
Ahahahaha
I see
not sure how to change that, tho
I mean, if I cancel the event
the player wont drink right?
You can cancel it and delete the itemstack
seems like the easiest solution
Or that
ooooooh
that seems like a good idea
yeah it depends on whether or not you want to clear potion effects when they drink the milk
A scheduler
?scheduling
whats that one good dark theme for eclipse???
I just re installed it
someone pls help
Hi, I have a question about the advanced enchantment plugin.
My community speaks Spanish, is there a way to automatically translate the entire plugin into Spanish?
what is the custom enchantments area
or in this place they can not help me in that?
#help-server might be more help to you @primal tartan
https://paste.md-5.net/ubuxadigis.java
The only error console is giving me when I press "Next" on the command config page is "[23:49:14 ERROR]: Could not pass event InventoryClickEvent to BetterServer v1.0-SNAPSHOT
java.lang.ArrayIndexOutOfBoundsException: null"
?paste FULL error
no its not
check your latest.log
[23:49:12] [Server thread/INFO]: EthanGarey issued server command: /betterserver gui
[23:49:14] [Server thread/ERROR]: Could not pass event InventoryClickEvent to BetterServer v1.0-SNAPSHOT
java.lang.ArrayIndexOutOfBoundsException: null
there should be a stacktrace after that
its scrolled all the way to the bottom
The stacktrace will give a line number
well it didnt ;-;
your character array is incorrect
like?
it contains more characters then you are expecting it
either one, you should be setting up the array yourself instead of just turning a string into a character array especially if you don't control how it should split up the array
spaces count as characters fyi
....
you can't look at your code or something?
and see your strings where you turn them to character arrays
I have like 4 different ones
..
line 316 has more than 9 across
i found the invalid one
His array is where he can place items in his GUI
i've been working on this for like 4 hours
while that may be true it should be done more properly though
Yep, not good code
if it was, this would be avoided as well as spotting where the error is at
I would create the array and just add to it as necessary
or, use a control character to split the array appropriately
get rid of ALL the uses of Objects.requireNonNull They are doing nothing for you
but just arbitrarily using toCharArray though on a string, also includes spaces since those are characters still, just ones not visible 😛
its also where your null error is happening. You are just covering up the proper stacktrace error due to using that
also that character array is redundant between them both as well
or however many you have
you could easily remove them all and just re-use a single array
anyways, recommendation is to refactor and use appropriate code methods for creating a character array that avoids potential errors or introducing characters you didn't intend for it to have
as well as removing redundancy
Why is the arrow not showing up on this page?
I've checked everything (Code above)
its the 2nd to last page
idk, your code is setup in such a way that it makes it extremely difficult to see why that may be, but I am going to assume it has to do with your array
i checked the array it wasnt
well it has to since your entire code operates on the basis of it
the only thing I can think of would be like before
the index number isn't what you think it is
since you never bother verifying how large your array should or should not be, nor verifying the positions of anything.
but this is also why you generally shouldn't hard code either, and if you are going to use an array like you are, you would create the array in a more appropriate way
if you are going to use spaces as your control character
you could do string[] charSplit = String.split(" ")
im trying to send a plugin message to bungeecord from bukkit, my bukkit code looks like this:
`@EventHandler
public void onPlayerChannel(PlayerRegisterChannelEvent event) {
System.out.println("you little!");
out = ByteStreams.newDataOutput();
out.writeUTF("UpdateTabList");
player = event.getPlayer();
player.sendPluginMessage(Bukkit.getPluginManager().getPlugin("RedisPlayerListBukkit"), "BungeeCord", out.toByteArray());
}`
and my bungeecord code looks like this:
@EventHandler public void onPluginMessage(PluginMessageEvent event) { ByteArrayDataInput in = ByteStreams.newDataInput(event.getData()); System.out.println("hiiii " + in.readUTF()); }
for some reason, the plugin message that im trying to send is not printed in the bungeecord console. i have no errors while loading my bukkit and bungeecord plugins, what could be the cause of this?
hii i got a problem with this code
@EventHandler
public void onCraftItem(CraftItemEvent e){
Player p = .getPlayer();
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "Hey, You Cant Craft Any Item.");
p.sendTitle(ChatColor.DARK_RED+"You Cant Craft", "Remember You Are In A Challenge"
what can i add to the Player p = ...........
Player p = (Player) e.getWhoClicked()
I think that event has that method at least
Hi. I'm trying to use the Annotation Command Framework(ACF). I understand that I need to shade it into my compiled plugin.
However, whenever I launch my server I get a NoClassDefFoundError for co.aikar.commands.BaseCommand, so I presume that it's not being shaded correctly.
When I decompile my plugin I can see that the classes are nowhere to be found. Can anyone see what I might have wrong?
Here is my maven .pom file
https://pastebin.com/bLGm8K6R
https://stackoverflow.com/questions/10568275/noclassdeffounderror-on-maven-dependency
Maybe try this... the first solution seems to be what you want, pay attention to the <execution> part of their pom which you dont seem to have
actually, you have that, nvm, was looking at your top plugin
maybe check the other answers
best way to make a safe recursion?
elaborate a bit more
you could count up a static int and check for amount of recursions
Have exiting condition that 100% will happen ig lol
the usual way to do that is to know the code you wrote and the things that happen around it
I was thinking the same way but I asked to know if it’s good practice
probably not
if you dont tell us your case and keep being generic, you will only receive basic answers
^this
i mean, make sure to break at some point 👍
yeah
Ive done a recursive system recently, my way of knowing that it will eventually exit is that the server owner will not have a looped folder system
I usually make a counter and check if it got bigger than some value and if it is then break it because we’re gonna crash
if you have to cut it like that a loop/scheduler whatever wouldve been probably better
this is only for debugging
how about you send us the code you wrote
I’m just only asking
?bing then
Bing your question before asking it:
https://www.bing.com/
Cipher is right tho, we cant give you a better answer than google can without knowing the code
bing* 😠
agreed
startpage - no tracking
out of service sadly
Yeah just asked to see how you are handling these types I mean I do the counter system only on testing so I’ll know I’m not gonna crash the server and then restart again
always will be in our hearts
I handle them by using things I know will definitely happen within a reasonable time from method start
devs of nowadays browers probably used internet explorer for it 💔
you can fake this by setting a static counter but its pretty bad
yeah I just do the counter system because typos happen and then it’ll crash
after that remove
apple basic developers used a book 💀
that sounds really wrong
the circle of life... beautiful and tragic at the same time
my english is not the best
not because of your english
i usually just pass a counter or something i can use to keep track of the call, useful for debugging and eventual other functionality too
but usually recursion isnt used for processing infinitely deep trees unless its a math problem
pass a set to your recursion and add each tested element to the set. then you can tell if you already processed it and not recurse
I do the same for debugging
knowing that an exit condition will definitely happen is sometimes hard too, especially when depending on code you didnt write
then how are you exiting your recursion right now?
our pathfinderimpl has all of that https://github.com/olijeffers0n/Pathetic/blob/master/pathetic-model/src/main/java/xyz/ollieee/model/pathing/PathfinderImpl.java 
void hello(int depth) {
if (depth != 0)
hello(depth - 1);
}
I mean first I add an exit condition but I’m not always sure it will be right so for the first tests I add an int variable and keep a count to know it’s not gonna infinitely loop
starts at -1
you know its an infinite loop when your server crashes
unless youre doing it async
then they are stupid
<= would solve that
should have them check before calling
you guys know the reverse lambda, right? /s
js => lambda looks so stupid
yeah but I don’t wanna crash it and then restart so if the exit condition is not right I just break with counter and then print something to know it’s not right
so you have it figured out?
yeah just doing some over explanation rlol
ok, perfect 🙂
yo im pretty sure you can wrap the call in a
try {
} catch (StackOverflowError e) {
e.printStackTrace();
}
and then continue calling on catch
that’s also a good solution I think
Don't catch overflow
how deep is the stack? how many calls until it overflows
depends on the jvm args and the size of the stack frame
I shall make a "stackOverFlow()" method which has a call structure so deep it will 100% of the time overflow
bruh why not
ik youre not supposed to catch errors but jdk literally does it itself everywhere
as well as use unsafe
they clearly understand performance > safety
just infinitely recurse lol
but actually
what happens if you catch the stackoverflow
and continue the recursion in the catch
void recurseSafe() {
try {
recurse();
} catch (StackOverflowError e) {
recurseSafe();
}
}
void recurse() {
recurse();
}
lol double recursion
will take a lot longer to overflow uncaught
jvm is fucking sick
also pretty sure the size of a stack frame of a void() method with no local variables is like an int or long for the method
so that could go on for a while
no params or local variables, that’s gonna be going for a while to fill the frame
javadocs question, which is part of java
That's like saying I read a book by X author and I'm gonna ask Y author a question about the book because they also wrote a book
if you don't know where you can get stuff, just use javadocs or loop through suggestions, also javadocs are generated with java comment system, which is part of language
Because when you get it, you are obv doing something wrong. You should prevent it, not catch, same with npe
understanding and researching docs is a part of programming
not exactly a learnjava moment, but def worth an unfriendly reminder to use ?jd-s
yeah but that was too friendly
i always rethrow NPEs 👉👈
where are we collectively heading to
Best practice tbh
so open your ide
i don't have ide on pc
so nothing to roast then
coding on laptop
int x = (int) y;
if(x == y) {
you really did him like this
way past uncool
violation
poor guy who had this
0/10
I love that dude, but go into his message history
He asks for help on 90% of his methods
who
With due respect that’s not coding
are you talking about
If you know, you know
well i don't
Pretty sure you commented on the same thing yesterday
I’m on mobile but I’ll try to find it
i will appreciate if you fill me in the details
Wasn’t you mb was another fellow blue name
No not you, you don’t ask for help with 90% of your methods
never asked
Someone else does and I thought you were the one who first called it out, you are not that’s mb
.
probably not worth it
why
do you reckon u need to put ur discord in the bio
because they have to see ur profile to know that ur giving free java lessons no?
that was planned
when i first put this shit in my bio
some kind of joke which i'm now too lazy to remove
Hey there! 👋
Any mod developer in here to help me write a Mixin for Iris mod by any chance (commissioned)?
?whereami
What?
Yeah you are right and I know, trying never hurt anyone.
i mean, giving up a commission doesnt sound like help either
If by any chance any mod Dev sees It it's fine, if its against the rules I remove it.
?services prob
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
in the case of an NPE it is much easier and more performant to prevent than a check for stack overflow every single recursive call
You don't "check" for stack overflow, you just don't make inf recursion
besides, what are you going to do to interrupt the chain, throw an exception?
something can go too deep
Exiting condition?
yo im not saying this the guy wanted to catch a stack overflow
he said for testing he wanted to catch that
tell him that
if a stackoverflow is at some point not preventable, then a recursive design is not the right choice
how are you going to make sure a stack overflow doesnt happen
you dont know how much the stack is
you dont know how many functions it calls
🤔
yeah you could keep track of it
will actually reduce the maximum depth you can go to
but if you would have somewhat of a depth, you should use a loop
you cant use a loop to traverse a tree of arbitrary depth with multiple branches per node
like a file system
not that that will go too deep
Make it lazy load lol
if you determine a depth you will reach anyways in a recursive design no matter what it is about, you could also just use a loop
a recursive design is cool and all, but not always the way to go
but you can always make sure to break at some point. either reached the destination or some other condition
for example if an alternate goal is reached or if its close enough
or simply fail at some condition
a
/ \
b e
/ \ / \
c df g
``` so youre saying you can traverse this with a loop
or do you mean a nested loop
a loop is a loop
like max depth amount of nested loops
whats inside that loop doesnt matter
when i say loop
i mean loop
no matter of the content
in this case it does matter because with one singular loop you cant traverse that
i need to know what youre saying
this is vague as shit
"you can traverse it with a loop, some loop, i dont know or care how but a loop"
pretty easy to understand that
so either you are too dumb or trying to get your point through
how do you traverse a tree with a single for loop
nested loop is a loop inside a loop. but what im talking about is just the upper loop
idc about the scope of that loop
that could be anything
the content does matter here because one loop only does one layer and we need to traverse the whole tree so we need multiple loops
kjhahsjkdas
who tf is talking about traversing a tree
it was a generic question
until you made it a specification
its like the only structure you need recursion to traverse
any kind of tree
i get that you can do something like evaluate a path a.b.c with a while loop and shit
also were talking about depth
yeah we were talking about the max depth to be reached
yeah and how to handle that

that was the guys question
there was no question
the message Goksi replied to was in response to an answer i gave a guy before
it was a specific case i guess because he was worried it would overflow during testing
yeah no shit sherlock
we literally just rerolled that and are bullshitting around now
alright
when there is possibility or guarenteed infinite recursion like some math problem, pass a depth
otherwise just catch StackOverflowError is my generic answer to how to handle max depth
and very ugly, a bad practice and never the best option
when concerned about performance it is
void traverse(File f) {
if (f.isDirectory()) {
for (File f : f.listFiles())
traverse(f);
} else {
System.out.println(f);
}
}
``` so youre going to pass an int through a chain like this
and have some static fixed max depth
id imagine also when a max depth is reached that the chain doesnt exit like nothing happened
imo it would make sense to throw an exception if you were using the exit condition anyways
for that you overload the traverse method
everytime you stackoverflow it would lag tf out of the application
so rather prevent it right away
you can... just make your own stack
public static final int MAX_DEPTH = 5000;
public void traverse(File f) {
traverse(0);
}
private void traverse(File f, int depth) {
if (depth >= MAX_DEPTH)
throw new IllegalStateException();
if (true)
traverse(null, depth + 1);
}
like a LinkedList<Runnable> or something
like this
or the ✨ Stack ✨
Stack<Runnable>
yeah
Will using ItemStack.SetAmount(0) cause an error or will it simply delete the ItemStack?
it will be deleted iirc
by bukkit
to solve what
the recursion problem?
had to iterate over like 400k blocks
basically the same just synchronized
So just
oh yea
Thanks. Was no comment on it in the docs so I wanted to make sure it'd be fine incase my logic required removing 1 item from a stack of 1
add the child nodes in each runnable but add them as other runnables and iterate over them?
at the end
Deque<Runnable> tasks = new LinkedList<>();
trasverse(file, tasks);
Runnable task = null;
while((task = tasks.pop()) != null) {
task.run();
}
public void trasverse(File file, Deque<Runnable> tasks) {
if(file.isDirectory()) {
for(File subfile : file) {
tasks.add(() -> trasverse(subfile, tasks));
}
}
System.out.println(file);
}
type deal
yeah
smart
though that will probably use quite a bit of memory
if were talking about really deep structures
so we are switching now to outofmemoryerror
just catch it 👍
the task itself gets removed when calling pop() but it will still fill up
we could make a sublist and call addAll on a bigger while loop
but doesn't matter much in my case as I run my instances with like 20gb ram
just merge the runnables
go native
you know what youre gonna do
move to assembly
create physical hardware chip to aid
make an external script which load its results to a website you can then just rest call
minecraft flood fill co processing chip
I can imagine hypixel contracting out to AMD to make a custom minecraft optimized chip
only thing it uses multithreading for is networking and chat and shit
generation as well
true
that's... just spigot / paper forks
ima rewrite the whole server and multithread each world
hypixel cant afford it lol
they somewhat can
i mean paper is a bit more advanced on that
i would say they could
eh
purpurclip even more advanced:3
never messed with purpur
is there any real multithreading fork
at least as much as possible
you would need to single out each block of adjacent chunks
and execute that in a thread pool
or just use minestom
purpur is as good as it gets, but u need to remove the purpur custom ai from npcs or it will break few farms
adjacent chunks multithreading would obviously cause issues
wanted to play on my void world anyways
For none related programming please use #general
Oh my bad this is general channel
Ripping my hair out on this one... I want to search a player inventory for an item that has a specific value stored in a PDC and then return the index, but I can't figure out how to go about it. Any pointers? I just can't seem to get a good solution to this.
Oh... Nevermind. It seems that if the slot is empty, it isn't skipped but rather given a value of null
you can stream the inventory contents and check there with a filter
or a anyMatch()
something tells me hypixel is not going to drop several dozen times their yearly income on marginal server performance improvements
they do run like 1.5k machines
there is multipaper, but thats sharding, not "real" multithreading
Yea, only "multithreading" I've seen involves sharding
end result is the same
sharding is much better as it allows existing software to work fine
It does work, but can be wonky. I'll see if I can figure out what it was called
you can still get 5k players on a multipaper server with the same world
WorldQL, not just for MC but games in general
lol nice meme
Is it really that bad? lmao
the developer for that project generated hype and had no knowledge of anything to actually make the project
he didn't get past loading the world
I see, last update posted was like February of this year so I guess it's dead in the water
what is wonky about multipaper
there are very few issues compared to any other software
it's used in production on large servers
I was speaking about WorldQL, but I guess I might be mixing memories or something. Regardless, I remember it being wonky af
yeah, because it was written by someone that barely knew c++, much less how to make a software of that scale
Can I make a spectator player sit on an armorstand to stop them from moving?
Since then you don't have the effect of being teleported back
But you can still look around
Yes you can
On the other hand, it will be really resource intensivo operation
what?
spectator isnt player
ArmorStand is intensivo so will bit your resources
why is it intensive
Also send pack I want to see how you are doing it
What?
answer the question
Url*
url of what
are you stupid
what pack
...
stupid
Idk why word corrector replace send url with send pack
Url of what more? The code Lmao
the github?
🤡
Thank you, I could've sent you a rickroll and that would've been a url
lmfao
I ain't the clown but whatev
@remote swallow Am I the crazy one here
nah ur not
If u wanna joke please mové to general
And no, I am not doing anything currently, I just wanted to ask if you could lmfao
Entities are heavly resource intensivo
you are stupis
So its important to not play much with them because they will bit your resources
but 1 armor stand to add passengers, probably wont make the server literally just crash
i dont sorry
when 6 year olds try to communicate
Alright thanks
Shut up bro dontfuck
No one asked you to come and fuck
@mighty pier you're to no help
can you be literate please uwu
Yes lmao we are trying to help that guy came just to distufb
So amor stand are resource intensivo or no??
Oh wait I opened blocked messages: frand has it with me because I called out their host as a scam
No lol
Ok my bad
It has no ai, it's literally an entity and that's it
You weren't
Oh my bad
idiot
J thought you were talking about ignorkng me
Please stop lmao or I will take Actions
Private problems must be resolved vía dms
Lmao vodo
I will take with conclure so he can take Actions
this is not general......!
Because that guy wont stop
Yes
why does it matter when nobody needs help
just ping adele or optic
ike asked for help
lmao we got the whole path reseller squad in here sheesh
fr fr
Anyways back to developing
I got some comms to finish otherwise its cold time
(Pellet prices reached 12€/per here)
from 6€
Yeah void explain about entities I know that they should be intensive resource
spectator isnt player so i was trying to remember what spectator is
Not all are actually
spectator is gamemode
so he would know ehere to kook
lmao obviously
Spectator is a gamemode, the entity is still a player :D
And they are hidden

cursed
but should work
?tryandsee
Yeah
Yeah, it would make movement cancellation easier
since you can stop them from dismounting iirc
wait no dismount event is only on paper right?
if so, listen for packets ig
Ye ye ik
Armor stand is intensive
I mean it's for a specific person, so since they use paper idrc xD
ye ok
intensive how?
Papepr 🤢🤢🤢🤢
just to ask
agree
any performance issue I've ever had was always linked to armor stands
imagine not writing your own server software in brainfuck
I mean it's the only entity I can use to make a player sit which is cheap
but thats because plugins bugged out and spawned a quadrillion invisible ones and never despawned them
I mean I was reading about entities and they should not abuse them
imagine you're coping and pasteing saying you are developing plugins
fr fax
boat?
I mean you can't walk trough that
i know you can use armorstands to crash servers
a nograv invis armorstand should be fine imho
Worst case scenario its 1 per player
Best case scenario its zero
the movement of the armor stand is what causes the most lag in my experience
ye
water loop with armorstands
yes

ded
how much ram you got?
16gb
😂
16 jikes
I believe I made paper drunk
no perfect for photoshop
64 is alright I'd say
ide and minecraft
but it can be fun to show your friends you allocated double of the whole ram they have to minecraft
2 servers and bungeecord
32gb of ram doesnt help minecraft xd
graphic card
but you need ram doe
gimme me prove
upgrading to 128gb be like
bruh you running a server?
Now
I just need to kill the armorstand on the other player's perspective
OR
Find a way to stop creative players from hitting it
I also cant figure out how to prevent players from hitting it
I tried to set the hitbox to none and its still hittable
I’m doing the same but with 8gb
this sounds funny
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityCombustEvent.html
declaration: package: org.bukkit.event.entity, class: EntityCombustEvent
Entity....ComBustEvent
what is that about?
when an entity is set on fire
OH!
just not gonna mention how you thought "Bust" was a separate word in this?
I am forced to learn it all for my fabric mod thingy, even though I am slow at working on it lmfao
I am not sing a mod api
fabric has very little to aid
or I haven't found most of it lmfao
Most of it is mixins and accessors
And I can't even use many otherwise I loose compat
once I figure out the full fabric api it'll be easier
Anyone have an idea how can I for example
private const val VERSION = "@VERSION@" replace with ${project.version} from maven just during compile time ? I tried using google replacer plugin but it seems it changes source after compalation
How do I make a cobblestone wall falling entity have the left/right attachment things
like this (used debug stikc)
Wall block data has no methods for that
Oh wait
I am dumb
I know
So um
I may be bad, but I don't know how to use euler angles lmfao
or I was not converting to radians
Is there anyway to play custom resource pack sound in spigot API?
why does the import for java plugin not work for me?
I have java and spigot installed
?paste pom.xml/build.gradle
how do I use that?
the paste site? or gradle/maven
just add the external jar 💀
mf I did
right click project > build path > add external jar
SpigotAPI, right?
bro I have no idea what the fuck u are talking about
i dont use eclipse so havent got a clue, using maven or gradle is probably better in the long run
doubt
I dont even know what those things are
How did you create your project in Eclipse?
I mean I have installed it
right clicking new, java project
but extends java plugin doesn't work
you need to add the SpigotAPI
then I recommend you follow a tutorial to use Maven.https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
I have the spigot 1.19.2 thing
after you "build" the jars with BuildTools you need to import SpigotAPI/target/<jarname>-shaded.jar
java -jar ./{build-tools-location} --rev {version}
Then add the spigot-api.jar to your project's "build path"
Use Maven not a default java project. It will save you a nightmare later
I AM SO FUCKING CONFUSED, CAUSE IDEK WHAT BUILD TOOLS DOES 💀
alright
It makes you have some goods of Spigot 🤣
you don;t need buildtools to make plugins.
I use it LOL
exactly what i thought
You need it to build Spigot
Personally I hate Maven lol
You'll need to manually build it if you're gonna need Craftbukkit or whatever
well here, where do I type that command u gave me
into a command line
I gave you a link not a command
someone gave me a command
or make a txt, type the command in, save as a .bat, and run it
I am just gonna make a test server first
Follow that tutorial and it will show you how to create yoru first plugin
alright
ahhh god 💀
I got a question, is there a way to show a TextComponent (Which contains Json data of an item) in a normal message without using the spigot().send() for the receivers list?
Isn't there a way to do that with a message event by Message#setMessage() ?
when creating/running the build tools thing, I did: java -jar BuildTools.jar --rev 1.19.1
it didn't download GIT or wtv the hell its called, any fixes?
gradle > maven
Hello, Is it possible to speed up the swimming animation also if the player isnt in water?
you suck then
you havent dealt with the pain of gradle caches then
true
yeah i have
theyre fucking aids
but still prefer gradle
When Gradle works it's probably one of the best tools out there, when Gradle doesn't work you want to punch 15 holes into your monitor and wish all the developers of Gradle to the depths of hell
Unfortunately the latter is more common
Is it even possible to get the last item in a map? I can't find anything on google
or would I just store that in a static variable?
Maps don't keep insertion order
annoying :/
Or HashMap<> doesn't
static variable it is
