#help-development

1 messages · Page 213 of 1

flint coyote
#

iterate them

#

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

raw prairie
flint coyote
#

loop through them

raw prairie
#

k

raw prairie
flint coyote
raw prairie
#

oh waiat

flint coyote
raw prairie
#

nvm

#

I think i got it

flint coyote
#

for(Block block : sight) {

raw prairie
#

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:

flint coyote
#

nah don't do it that way. You will do line of sight 3 times

sonic goblet
#

int y = (int) x
if(x == y)

flint coyote
#

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

raw prairie
sonic goblet
#

When does that ever return false xd

raw prairie
#

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);
                                }
                            }
                        }```
flint coyote
#
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

raw prairie
#

i get it now,

flint coyote
#

Might have forgotten some brackets. idk

flint coyote
raw prairie
#

I think you can just create location loc

#

and assign it to that doe

flint coyote
#

why would it cause an error?

#

oh yeah you have to do size-1

#

fixed it

wary topaz
#

ignore the "i"

flint coyote
#

By creating the itemstack beforehand, getting its ItemMeta, setting the metas customName and setting the itemMeta back to the ItemStack

wary topaz
#

Can I have a example?

#

oh wait

#

I see what to do

#

thanks

flint coyote
#

Np :)

wary topaz
#

item.setItemMeta(Custom)?

#

whats the custom name object

sonic goblet
#

ItemMeta meta = yourItemStack.getItemMeta();
meta.setDisplayName(“Name”);
yourItemStack.setItemMeta(meta):

wary topaz
#
ItemStack item = new ItemStack(Material.RED_BED);
                                  item.setItemMeta()
                                    inventory.setItem(i, item);```
wary topaz
#

Method invocation 'setDisplayName' may produce 'NullPointerException'
Is that normal?

flint coyote
#

it depends on what you called it with

wary topaz
#

Alr thanks guys

#

you were a real help 😄

sonic goblet
#

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

wary topaz
#

😛 I should

dry forum
#

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

sonic goblet
#

Iterate through the hashmap

#

If you want just the keys: codeMap.keySet()

#

And iterate through them

dry forum
#

the issue is the values arnt being set in to the hashmap

next plume
#

Check isEmpty()

dry forum
wary topaz
next plume
#

Then that three-line snippet of code must not be called.

dry forum
#

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

wary topaz
#

if(clickedItem.equals(new ItemStack(Material.PAPER)) {-- This doesnt do anything, anyone know why?

hasty prawn
#

Should probably use isSimilar, for starters.

wary topaz
#

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();

hasty prawn
#

Does clickedItem have a name, lore, enchants, etc on it?

#

Or is it just straight up a piece of paper

wary topaz
#

name yes

hasty prawn
#

Well thats why it's not working

#

The names arent the same

wary topaz
#

:p

#

how do I put the name in the check

#

if(clickedItem.isSimilar(new "myitemname")) { --??

wary topaz
#

anyone know?

white dew
#

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?

wary topaz
#

Use .isSimilar for the item name

white dew
#

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") {}"

wary topaz
#

Hm, I actually dont know.

#

Tbh I've been asking that question above 😛

white dew
#

oh, It takes actually an ItemStack

#

oooh

#

I see...

wary topaz
#

You can use .getItemMeta but idk what else

#

oh .getitemMeata().getDisplayName

white dew
#

Ooh, that will probably work

#

I'll try something different tho

#

this:

#
if (milk instanceof ChickenMilk) {
            player.sendMessage("Drinking chicken milk!");
        }
wary topaz
#

if(Objects.requireNonNull(clickedItem.getItemMeta()).getDisplayName().equals("")) {

honest echo
#

hey

white dew
#

where milk is the output of event.getItem()

wary topaz
#

okie

honest echo
#

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 ?

wary topaz
#

have you looked at ?jd-s?

honest echo
#

wym ?

wary topaz
#

the java docs may say something about that

#

spigot docs*

worldly ice
#

use pdc instead of checking item names

white dew
dry forum
#

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?

white dew
#

but I'm planning to use "instanceof" instead

worldly ice
#

i think that's only possible during a session tho

white dew
#

because ChickenMilk extends ItemStack

worldly ice
#

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

white dew
#

ah, I see...

honest echo
#

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

worldly ice
#

yeah

honest echo
#

anyways

white dew
#
 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

worldly ice
#

i really don't recommend implementing itemstack

#

if you put it into a chest it'll also break

#

relogging breaks it

river oracle
#

For custom items just use PDC to recognize them and then a custom object

worldly ice
#

^^

white dew
#

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) ?

outer meteor
#

how would you send a hyperlink through a command?

white dew
#

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

worldly ice
#

but you said you changed it

#

so idk

cobalt spoke
#

Alguien que hable en español ?

white dew
#
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);
    }
}
worldly ice
#

yeah, you need to set the item meta back

#

this.setItemMeta(meta)

white dew
#

why, tho? I mean, the meta variable is a reference, right? So shoudn't It automatically change wen I change the properties of meta?

worldly ice
#

getItemMeta returns a copy of the item's meta

white dew
#

ooooooooooooooh

worldly ice
#

but you're implementing itemstack anyways

white dew
#

that makes A LOT of sense

#

thank you

worldly ice
#

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

white dew
#
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

worldly ice
#

that would be correct

white dew
#

I think this is gonna work now

#

Thank you so much

#

I will try It

#

It works!!

#

yayyy

sonic goblet
#

Umm…. How does one milk a chicken 🤨

white dew
#

Now I just need to fix the event for when you actually drink the Item

white dew
#

ahahahaha

#

you can milk ANY entity

#

:)

sonic goblet
#

Kinda sus my guy xd

white dew
#

very sus indeed

#

you can even milk players

#

OwO

sonic goblet
#

I have no words for what you’re creating

#

But I support your journey

#

🫡

white dew
#

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

worldly ice
#

?pdc

worldly ice
#

that covers all you need to know

white dew
#

ok!

rare rover
#

What are people making these days

white dew
#

I'm making a plugin where you can milk ANY entity

#

and gain different effects

rare rover
#

Seems interesting

white dew
#

nice :)

#

thanks

#

It will be used for a funny manhunt

cobalt spoke
#

Could someone tell me how to translate the plugin into Spanish

white dew
#

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

sonic goblet
#

Is it reaching the “reaching here”?

#

Also you should look into PersistentDataContainer as opposed to checking for the item by display name

white dew
#

yeah, true, I will change It later

#

Its is reaching the "reaching here"

white dew
worldly ice
#

what exactly is the problem?

#

is the player receiving the potion effect?

white dew
#

nope

#

they don't receive It

cobalt spoke
#

The plugin does not have any option that translates all the messages or names of the items to Spanish?

white dew
#

but It is reaching the "reaching there"

white dew
worldly ice
#

try souting player.addPotionEffect

#

it returns whether or not the player actually received the potion effect

white dew
#

oooh, I see

white dew
#

but I don't have any potion effect

sonic goblet
#

#

Lucas

#

Ik why

#

You’re drinking fucking milk

worldly ice
#

oh wait

sonic goblet
#

It clears the effects xd

worldly ice
#

lmao

white dew
#

WAIT

#

IT MAKES SO MUCH SENSE

#

LOOOL

#

that makes me laugh loool

sonic goblet
#

I was so confused because the code looked fine lol

white dew
#

Ahahahaha

#

I see

#

not sure how to change that, tho

#

I mean, if I cancel the event

#

the player wont drink right?

worldly ice
#

yeah

#

i would just give the player the potion effect 1 tick later

sonic goblet
#

You can cancel it and delete the itemstack

worldly ice
#

seems like the easiest solution

sonic goblet
#

Or that

white dew
#

that seems like a good idea

worldly ice
#

yeah it depends on whether or not you want to clear potion effects when they drink the milk

white dew
#

I don't know how to make the effect c ome 1 tick later tho 🤔

#

ah

sonic goblet
#

A scheduler

worldly ice
#

?scheduling

undone axleBOT
white dew
#

ooh

#

I think I got It, thanks

knotty gale
#

whats that one good dark theme for eclipse???

#

I just re installed it

#

someone pls help

white dew
#

IT WORKS

#

YAYYY

primal tartan
#

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?

hasty prawn
wary topaz
#

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"

eternal oxide
#

?paste FULL error

undone axleBOT
wary topaz
#

that was the full error

#

I just said

eternal oxide
#

no its not

wary topaz
#

wanna bet

eternal oxide
#

check your latest.log

wary topaz
#

[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

eternal oxide
#

there should be a stacktrace after that

wary topaz
#

its scrolled all the way to the bottom

eternal oxide
#

The stacktrace will give a line number

wary topaz
#

well it didnt ;-;

wet breach
#

your character array is incorrect

wary topaz
#

like?

wet breach
#

it contains more characters then you are expecting it

wary topaz
#

which one

#

I have like 4

wet breach
#

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

wary topaz
#

which one has more characters

#

what line

wet breach
#

....

#

you can't look at your code or something?

#

and see your strings where you turn them to character arrays

wary topaz
#

I have like 4 different ones

wet breach
#

does it matter which one you are looking at?

#

they are all wrong

wary topaz
#

..

wet breach
#

so it doesn't matter

#

point is, spaces count as characters

eternal oxide
#

line 316 has more than 9 across

wary topaz
#

i found the invalid one

eternal oxide
#

His array is where he can place items in his GUI

wary topaz
#

i've been working on this for like 4 hours

wet breach
eternal oxide
#

Yep, not good code

wet breach
#

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

eternal oxide
#

get rid of ALL the uses of Objects.requireNonNull They are doing nothing for you

wet breach
#

but just arbitrarily using toCharArray though on a string, also includes spaces since those are characters still, just ones not visible 😛

eternal oxide
#

its also where your null error is happening. You are just covering up the proper stacktrace error due to using that

wet breach
#

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

wary topaz
#

Why is the arrow not showing up on this page?

#

I've checked everything (Code above)

#

its the 2nd to last page

wet breach
#

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

wary topaz
#

i checked the array it wasnt

wet breach
#

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(" ")

solemn frigate
#

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?

hard pebble
#

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 = ...........

sonic goblet
#

I think that event has that method at least

fluid river
#

sounds like ?learnjava

#

?jd-s

undone axleBOT
faint cypress
#

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

earnest forum
#

its an api question

crimson terrace
# faint cypress Hi. I'm trying to use the Annotation Command Framework(ACF). I understand that I...

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

frail gale
#

best way to make a safe recursion?

hybrid spoke
#

elaborate a bit more

crimson terrace
hazy parrot
#

Have exiting condition that 100% will happen ig lol

crimson terrace
frail gale
crimson terrace
#

probably not

hybrid spoke
#

if you dont tell us your case and keep being generic, you will only receive basic answers

crimson terrace
#

^this

hybrid spoke
#

i mean, make sure to break at some point 👍

crimson terrace
#

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

frail gale
#

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

crimson terrace
#

its definitely not a good solution

#

wastes resources

hybrid spoke
#

if you have to cut it like that a loop/scheduler whatever wouldve been probably better

frail gale
crimson terrace
#

how about you send us the code you wrote

frail gale
hybrid spoke
#

?bing then

undone axleBOT
crimson terrace
#

Cipher is right tho, we cant give you a better answer than google can without knowing the code

hybrid spoke
#

bing* 😠

crimson terrace
#

GOOGLE

hybrid spoke
#

ecosia

#

better bing

crimson terrace
#

agreed

eternal oxide
#

startpage - no tracking

earnest forum
#

internet explorer no?

#

fastest browser ive personally used

hybrid spoke
#

out of service sadly

frail gale
earnest forum
#

always will be in our hearts

crimson terrace
hybrid spoke
#

devs of nowadays browers probably used internet explorer for it 💔

crimson terrace
frail gale
#

after that remove

earnest forum
#

apple basic developers used a book 💀

crimson terrace
frail gale
hybrid spoke
#

not because of your english

glossy venture
eternal oxide
#

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

crimson terrace
crimson terrace
hybrid spoke
glossy venture
#
void hello(int depth) {
    if (depth != 0)
        hello(depth - 1);
}
frail gale
crimson terrace
#

you know its an infinite loop when your server crashes

#

unless youre doing it async

glossy venture
crimson terrace
#

<= would solve that

glossy venture
#

should have them check before calling

crimson terrace
glossy venture
#

js => lambda looks so stupid

frail gale
crimson terrace
#

so you have it figured out?

frail gale
crimson terrace
#

ok, perfect 🙂

glossy venture
hybrid spoke
#

and then continue calling on catch

frail gale
glossy venture
#

if you only care about not overflowing

#

i mean it not exiting when doing so

hazy parrot
#

Don't catch overflow

crimson terrace
#

how deep is the stack? how many calls until it overflows

glossy venture
crimson terrace
#

I shall make a "stackOverFlow()" method which has a call structure so deep it will 100% of the time overflow

glossy venture
#

ik youre not supposed to catch errors but jdk literally does it itself everywhere

#

as well as use unsafe

#

they clearly understand performance > safety

hybrid spoke
#

but actually

#

what happens if you catch the stackoverflow

#

and continue the recursion in the catch

glossy venture
#

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

opal juniper
#

no params or local variables, that’s gonna be going for a while to fill the frame

fluid river
earnest forum
#

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

fluid river
#

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

hazy parrot
hybrid spoke
#

not exactly a learnjava moment, but def worth an unfriendly reminder to use ?jd-s

fluid river
hybrid spoke
#

yeah but that was too friendly

earnest forum
#

really isnt that big of a deal

#

just move on

#

collectively move on

hybrid spoke
fluid river
#

where are we collectively heading to

hazy parrot
#

Best practice tbh

hybrid spoke
#

cant be my fault

#

so rethrow to the next instance idc

fluid river
#

i wanna roast some code

#

guys do you have projects wip

hybrid spoke
#

so open your ide

fluid river
hybrid spoke
#

so nothing to roast then

fluid river
#

coding on laptop

sonic goblet
hybrid spoke
fluid river
earnest forum
hybrid spoke
#

poor guy who had this

fluid river
#

0/10

sonic goblet
#

I love that dude, but go into his message history

#

He asks for help on 90% of his methods

fluid river
#

who

sonic goblet
#

With due respect that’s not coding

fluid river
#

are you talking about

sonic goblet
#

If you know, you know

fluid river
#

well i don't

sonic goblet
#

Pretty sure you commented on the same thing yesterday

fluid river
#

?

#

bro tf you are talking about

sonic goblet
#

I’m on mobile but I’ll try to find it

fluid river
sonic goblet
#

Wasn’t you mb was another fellow blue name

fluid river
#

were you talking about me

#

90% of questions is about help with methods

sonic goblet
#

No not you, you don’t ask for help with 90% of your methods

fluid river
#

never asked

sonic goblet
#

Someone else does and I thought you were the one who first called it out, you are not that’s mb

fluid river
#

😉

#

i do

#

FREE JAVA LESSONS

check my bio

sonic goblet
fluid river
#

anybody know

#

why tf win + shift + s stopped working

hybrid spoke
fluid river
#

why

earnest forum
#

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?

fluid river
#

that was planned

#

when i first put this shit in my bio

#

some kind of joke which i'm now too lazy to remove

pure copper
#

Hey there! 👋
Any mod developer in here to help me write a Mixin for Iris mod by any chance (commissioned)?

earnest forum
pure copper
earnest forum
#

this is a spigot server

#

and ur asking for mod help

pure copper
#

Yeah you are right and I know, trying never hurt anyone.

hybrid spoke
#

i mean, giving up a commission doesnt sound like help either

pure copper
undone axleBOT
glossy venture
hazy parrot
#

You don't "check" for stack overflow, you just don't make inf recursion

glossy venture
#

besides, what are you going to do to interrupt the chain, throw an exception?

glossy venture
hybrid spoke
#

so dont let it go too deep

#

if you get an stackoverflow then its your fault

glossy venture
#

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

hybrid spoke
#

if a stackoverflow is at some point not preventable, then a recursive design is not the right choice

glossy venture
#

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

hybrid spoke
glossy venture
#

so like a max depth?

#

gonna pass in an integer through all those calls

#

?

hybrid spoke
#

yeah you could keep track of it

glossy venture
#

will actually reduce the maximum depth you can go to

hybrid spoke
#

but if you would have somewhat of a depth, you should use a loop

glossy venture
#

like a file system

#

not that that will go too deep

hazy parrot
#

Make it lazy load lol

hybrid spoke
#

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

glossy venture
#
    a
   / \
  b    e
 / \  / \
c   df   g
``` so youre saying you can traverse this with a loop
#

or do you mean a nested loop

hybrid spoke
#

a loop is a loop

glossy venture
#

like max depth amount of nested loops

hybrid spoke
#

whats inside that loop doesnt matter

#

when i say loop

#

i mean loop

#

no matter of the content

glossy venture
#

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"

hybrid spoke
#

pretty easy to understand that

#

so either you are too dumb or trying to get your point through

glossy venture
#

how do you traverse a tree with a single for loop

hybrid spoke
#

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

glossy venture
#

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

hybrid spoke
#

kjhahsjkdas

#

who tf is talking about traversing a tree

#

it was a generic question

#

until you made it a specification

glossy venture
#

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

hybrid spoke
#

if you want to go very specific there

#

just a* it

glossy venture
#

also were talking about depth

hybrid spoke
#

yeah we were talking about the max depth to be reached

glossy venture
#

yeah and how to handle that

hybrid spoke
glossy venture
#

that was the guys question

hybrid spoke
#

there was no question

glossy venture
#

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

hybrid spoke
#

yeah no shit sherlock
we literally just rerolled that and are bullshitting around now

glossy venture
#

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

hybrid spoke
#

just like goksi said

#

never catch that error

glossy venture
#

bruh it works

#

its fast

hybrid spoke
#

and very ugly, a bad practice and never the best option

glossy venture
#

when concerned about performance it is

hybrid spoke
#

no in general it is

#

thats like catching a NPE

glossy venture
#
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

hybrid spoke
#

everytime you stackoverflow it would lag tf out of the application

#

so rather prevent it right away

echo basalt
#

you can... just make your own stack

glossy venture
#
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);
}
echo basalt
#

like a LinkedList<Runnable> or something

glossy venture
#

like this

hybrid spoke
#

Stack<Runnable>

echo basalt
#

yeah

karmic mural
#

Will using ItemStack.SetAmount(0) cause an error or will it simply delete the ItemStack?

echo basalt
#

idk the stack structures

#

deque is both a queue and a stack

#

so works for me

glossy venture
#

by bukkit

glossy venture
#

the recursion problem?

echo basalt
#

StackOverflow

#

I use it on my async flood-fill

glossy venture
#

you need to fill the list right

#

with the operations

echo basalt
#

had to iterate over like 400k blocks

hybrid spoke
echo basalt
#

So just

glossy venture
#

oh yea

karmic mural
glossy venture
# echo basalt So just

add the child nodes in each runnable but add them as other runnables and iterate over them?

#

at the end

echo basalt
#
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

glossy venture
#

yeah

#

smart

#

though that will probably use quite a bit of memory

#

if were talking about really deep structures

hybrid spoke
#

so we are switching now to outofmemoryerror

echo basalt
#

ehh

#

you wanted recursive

#

I mean like

glossy venture
echo basalt
#

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

glossy venture
#

minecraft does that though

echo basalt
#

but doesn't matter much in my case as I run my instances with like 20gb ram

hybrid spoke
#

just merge the runnables

glossy venture
#

just dont use runnables

#

add the blocks

hybrid spoke
#

go native

glossy venture
#

you know what youre gonna do

echo basalt
#

move to assembly

glossy venture
#

create physical hardware chip to aid

hybrid spoke
#

make an external script which load its results to a website you can then just rest call

glossy venture
#

minecraft flood fill co processing chip

echo basalt
#

I can imagine hypixel contracting out to AMD to make a custom minecraft optimized chip

glossy venture
#

lmao

#

best chip for MC is good single core performance

#

i guess

echo basalt
#

not always

#

depends

#

They have the resources to make a custom server impl

glossy venture
#

only thing it uses multithreading for is networking and chat and shit

#

generation as well

echo basalt
#

that's... just spigot / paper forks

glossy venture
#

ima rewrite the whole server and multithread each world

echo basalt
#

they somewhat can

hybrid spoke
remote swallow
echo basalt
#

eh

pallid oxide
hybrid spoke
#

never messed with purpur

#

is there any real multithreading fork

#

at least as much as possible

glossy venture
#

you would need to single out each block of adjacent chunks

#

and execute that in a thread pool

echo basalt
#

or just use minestom

pallid oxide
#

purpur is as good as it gets, but u need to remove the purpur custom ai from npcs or it will break few farms

glossy venture
#

adjacent chunks multithreading would obviously cause issues

hybrid spoke
#

wanted to play on my void world anyways

sterile token
#

For none related programming please use #general

#

Oh my bad this is general channel

wet breach
#

you confused?

sterile token
#

I ha e just get up

#

Its 5 am

karmic mural
#

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

crimson terrace
#

or a anyMatch()

cobalt marlin
# echo basalt they somewhat can

something tells me hypixel is not going to drop several dozen times their yearly income on marginal server performance improvements

echo basalt
#

they do run like 1.5k machines

cobalt marlin
karmic mural
#

Yea, only "multithreading" I've seen involves sharding

cobalt marlin
#

end result is the same

#

sharding is much better as it allows existing software to work fine

karmic mural
#

It does work, but can be wonky. I'll see if I can figure out what it was called

cobalt marlin
#

you can still get 5k players on a multipaper server with the same world

karmic mural
#

WorldQL, not just for MC but games in general

cobalt marlin
#

lol nice meme

karmic mural
#

Is it really that bad? lmao

cobalt marlin
#

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

karmic mural
#

I see, last update posted was like February of this year so I guess it's dead in the water

cobalt marlin
#

there are very few issues compared to any other software

#

it's used in production on large servers

karmic mural
#

I was speaking about WorldQL, but I guess I might be mixing memories or something. Regardless, I remember it being wonky af

cobalt marlin
#

yeah, because it was written by someone that barely knew c++, much less how to make a software of that scale

rough drift
#

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

sterile token
#

On the other hand, it will be really resource intensivo operation

rough drift
#

what?

mighty pier
#

spectator isnt player

sterile token
#

ArmorStand is intensivo so will bit your resources

mighty pier
#

why is it intensive

rough drift
#

For... one player?

#

like damn one entity won't crash anything

sterile token
#

Also send pack I want to see how you are doing it

rough drift
#

What?

mighty pier
#

answer the question

sterile token
#

Url*

rough drift
#

url of what

mighty pier
#

are you stupid

rough drift
#

what pack

sterile token
mighty pier
#

stupid

rough drift
#

Of the server?

#

Like explain yourself a bit lmfao

mighty pier
#

ike stupid

#

alex stupid

sterile token
#

Idk why word corrector replace send url with send pack

#

Url of what more? The code Lmao

remote swallow
#

the github?

sterile token
#

🤡

rough drift
#

Thank you, I could've sent you a rickroll and that would've been a url

#

lmfao

#

I ain't the clown but whatev

sterile token
#

Please dont troll

#

This channel is for coding

rough drift
#

@remote swallow Am I the crazy one here

remote swallow
#

nah ur not

sterile token
#

If u wanna joke please mové to general

rough drift
#

And no, I am not doing anything currently, I just wanted to ask if you could lmfao

sterile token
#

Entities are heavly resource intensivo

mighty pier
sterile token
#

So its important to not play much with them because they will bit your resources

rough drift
#

I found another person to ignore

#

lets go

remote swallow
#

but 1 armor stand to add passengers, probably wont make the server literally just crash

rough drift
#

Yeah

#

Anyways, epic do you know if you can make a spec sit?

sterile token
#

No?

#

Why shit my friend smoke started to make efgext on me?

remote swallow
mighty pier
#

when 6 year olds try to communicate

rough drift
sterile token
#

No one asked you to come and fuck

round finch
#

@mighty pier you're to no help

mighty pier
sterile token
#

Yes lmao we are trying to help that guy came just to distufb

#

So amor stand are resource intensivo or no??

rough drift
#

Oh wait I opened blocked messages: frand has it with me because I called out their host as a scam

rough drift
round finch
sterile token
#

Ok my bad

rough drift
#

It has no ai, it's literally an entity and that's it

sterile token
#

My has vood

#

Dontvlockme

#

I just was trying to help

rough drift
#

You weren't

sterile token
#

Oh my bad

sterile token
#

J thought you were talking about ignorkng me

sterile token
sterile token
#

Private problems must be resolved vía dms

#

Lmao vodo

#

I will take with conclure so he can take Actions

round finch
#

this is not general......!

sterile token
#

Because that guy wont stop

round finch
#

get staff

#

then

sterile token
#

Yes

mighty pier
rough drift
#

just ping adele or optic

round finch
#

ike asked for help

molten hearth
#

lmao we got the whole path reseller squad in here sheesh

round finch
#

then you started say random crap

rough drift
#

Anyways back to developing

#

I got some comms to finish otherwise its cold time

#

(Pellet prices reached 12€/per here)

#

from 6€

sterile token
#

Yeah void explain about entities I know that they should be intensive resource

mighty pier
round finch
#

spectator is gamemode

mighty pier
#

so he would know ehere to kook

round finch
#

lmao obviously

mighty pier
#

no when player is in spectaror

#

what is the player

rough drift
quasi flint
#

the player stays player

#

he is just set to no clip

rough drift
#

And they are hidden

quasi flint
#

basically creative

#

with just less things

rough drift
#

I'll actually try to forcefully sit a player in spec

#

gimme a sec

round finch
quasi flint
#

but should work

round finch
undone axleBOT
rough drift
#

Yeah

rough drift
#

since you can stop them from dismounting iirc

#

wait no dismount event is only on paper right?

round finch
#

armor stand set player

#

try it

quasi flint
rough drift
#

Ye ye ik

sterile token
#

Armor stand is intensive

rough drift
quasi flint
#

ye ok

round finch
#

intensive how?

sterile token
#

Papepr 🤢🤢🤢🤢

round finch
#

just to ask

rough drift
molten hearth
#

any performance issue I've ever had was always linked to armor stands

quasi flint
#

imagine not writing your own server software in brainfuck

rough drift
#

I mean it's the only entity I can use to make a player sit which is cheap

molten hearth
#

but thats because plugins bugged out and spawned a quadrillion invisible ones and never despawned them

sterile token
#

I mean I was reading about entities and they should not abuse them

round finch
rough drift
#

fr fax

rough drift
#

I mean you can't walk trough that

round finch
rough drift
#

a nograv invis armorstand should be fine imho

#

Worst case scenario its 1 per player

#

Best case scenario its zero

quasi flint
#

the movement of the armor stand is what causes the most lag in my experience

rough drift
#

ye

round finch
#

water loop with armorstands

quasi flint
#

yes

round finch
rough drift
#

my pc wants to die lmfao

#

2 mcs, intelli, and a server

molten hearth
#

ded

quasi flint
#

how much ram you got?

rough drift
#

16gb

round finch
#

😂

quasi flint
#

yikes

#

imagine not having 64

round finch
#

16 jikes

round finch
#

only 32

quasi flint
#

64 is absolute overkill

#

l

rough drift
#

I believe I made paper drunk

round finch
#

no perfect for photoshop

molten hearth
#

64 is alright I'd say

round finch
#

ide and minecraft

quasi flint
#

but it can be fun to show your friends you allocated double of the whole ram they have to minecraft

rough drift
#

or no wait nvm

#

Bad naming of events

round finch
#

2 servers and bungeecord

quasi flint
round finch
#

graphic card

rough drift
#

I DID IT

#

IT WORKS

round finch
#

but you need ram doe

round finch
quasi flint
#

upgrading to 128gb be like

rough drift
#

bruh you running a server?

round finch
#

perfection

rough drift
#

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

molten hearth
#

I also cant figure out how to prevent players from hitting it

#

I tried to set the hitbox to none and its still hittable

rough drift
#

I found out how to stop it from dying

#

use entity death event

round finch
#

????

rough drift
#

that also works

#

xD

pliant oyster
round finch
#

Entity....ComBustEvent

#

what is that about?

rough drift
#

when an entity is set on fire

round finch
#

OH!

crimson terrace
#

just not gonna mention how you thought "Bust" was a separate word in this?

rough drift
#

ComBust

#

you see the point

round finch
#

oopsi >:)

#

every day i learn some stuff and new events lol

#

i dont use much

rough drift
#

I am forced to learn it all for my fabric mod thingy, even though I am slow at working on it lmfao

round finch
#

mod api atless easier then looking in a mcp

#

or TLS

rough drift
#

I am not sing a mod api

#

fabric has very little to aid

#

or I haven't found most of it lmfao

round finch
#

oh gosh

#

sounds like pain

rough drift
#

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

hazy parrot
#

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

eternal oxide
#

read the version from the plugin.yml

rough drift
#

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

echo basalt
#

I know

rough drift
#

So um

#

I may be bad, but I don't know how to use euler angles lmfao

#

or I was not converting to radians

fierce whale
#

Is there anyway to play custom resource pack sound in spigot API?

knotty gale
#

why does the import for java plugin not work for me?

#

I have java and spigot installed

remote swallow
#

?paste pom.xml/build.gradle

undone axleBOT
knotty gale
remote swallow
#

the paste site? or gradle/maven

knotty gale
#

I use eclipse btw

trim creek
#

just add the external jar 💀

knotty gale
trim creek
#

right click project > build path > add external jar

trim creek
knotty gale
remote swallow
trim creek
#

doubt

knotty gale
#

I dont even know what those things are

trim creek
#

bruh

#

do you know BuildTools?

eternal oxide
#

How did you create your project in Eclipse?

knotty gale
knotty gale
#

but extends java plugin doesn't work

trim creek
#

you need to add the SpigotAPI

eternal oxide
knotty gale
trim creek
#

after you "build" the jars with BuildTools you need to import SpigotAPI/target/<jarname>-shaded.jar

marsh marlin
#

Then add the spigot-api.jar to your project's "build path"

eternal oxide
#

Use Maven not a default java project. It will save you a nightmare later

knotty gale
#

I AM SO FUCKING CONFUSED, CAUSE IDEK WHAT BUILD TOOLS DOES 💀

trim creek
#

It makes you have some goods of Spigot 🤣

eternal oxide
#

you don;t need buildtools to make plugins.

trim creek
knotty gale
eternal oxide
#

You need it to build Spigot

trim creek
#

Personally I hate Maven lol

marsh marlin
#

You'll need to manually build it if you're gonna need Craftbukkit or whatever

knotty gale
trim creek
#

into a command line

eternal oxide
knotty gale
trim creek
#

or make a txt, type the command in, save as a .bat, and run it

knotty gale
#

I am just gonna make a test server first

eternal oxide
#

Follow that tutorial and it will show you how to create yoru first plugin

trim creek
#

ahhh god 💀

marsh marlin
#

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() ?

knotty gale
#

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?

glossy venture
full holly
#

Hello, Is it possible to speed up the swimming animation also if the player isnt in water?

grim ice
grim ice
echo basalt
#

gradle caches can be painful

#

but it isn't as painful as looking at an xml file

molten hearth
#

true

glossy venture
#

theyre fucking aids

#

but still prefer gradle

hasty prawn
#

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

quaint mantle
#

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?

hasty prawn
#

Maps don't keep insertion order

quaint mantle
#

annoying :/

hasty prawn
#

Or HashMap<> doesn't

quaint mantle
#

static variable it is