#help-development

1 messages ยท Page 404 of 1

tall dragon
#

ngl

remote swallow
#

do you use clean package or just package

charred blaze
#

if i dont care about performance which is better?

tall dragon
#

whichever works best for you

remote swallow
#

depends on if you like verbositiy

hazy parrot
#

its personal preference, you have been told multiple times already

charred blaze
#

anyway... how do i force update minecraft development plugin? (because its not latest)

remote swallow
#

manuall install

charred blaze
#

can i just unistall and install

charred blaze
#

nvm googled it

#

how do i fix this?

#

whats wrong

warm mica
#

you want to code in scala?

charred blaze
#

are you talking to me

warm mica
#

yes

charred blaze
#

what is scala

warm mica
#

a programming language

charred blaze
#

no?

#

why

tall dragon
warm mica
charred blaze
#

i was just trying to install from archive

#

what do i do

analog thicket
#
double angle = 0;

                double centerX = center.getX();
                double centerZ = center.getZ();

                Location currentLoc = stand.getBukkitEntity().getLocation();
                double x = centerX + radius * Math.sin(angle);
                double z = centerZ + radius * Math.cos(angle);
                double y = currentLoc.getY();

                Location newLoc = new Location(currentLoc.getWorld(), x, y, z, currentLoc.getYaw(), currentLoc.getPitch());
                stand.setLocation(newLoc.getX(), newLoc.getY(), newLoc.getZ(), newLoc.getYaw(), newLoc.getPitch());
                PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(stand);
                sendPacket(packet);

Would this work? cant test atm

solar mauve
#

you are not changing the angle

#
  • the angle is in radians, not degrees
analog thicket
#

Forgot to copy it

solar mauve
# analog thicket Forgot to copy it
        getCommand("test").setExecutor((sender, cmd, label, args) -> {

            if (!(sender instanceof Player)) {
                return false;
            }

            if (task == null) {

                Player player = (Player) sender;
                ArmorStand armorStand = player.getWorld().spawn(player.getLocation().add(5, 0, 0), ArmorStand.class);
                Location center = player.getLocation();

                armorStand.setGravity(false);
                center.setY(armorStand.getLocation().getY());

                Location movingLocation = armorStand.getLocation();
                
                task = new BukkitRunnable() {

                    float angleDegrees = 0f;

                    /*
                     * Math.sin and Math.cos is based on radians, not degrees, if you want to use them,
                     * you should multiply the angle based on degrees by (PI / 180)
                     * in order to get the angle in radians
                     */

                    @Override
                    public void run() {

                        double angleRadians = angleDegrees * Math.PI / 180;
                        double radius = armorStand.getLocation().distance(center);

                        movingLocation.setX(center.getX() + (Math.cos(angleRadians) * radius));
                        movingLocation.setZ(center.getZ() + (Math.sin(angleRadians) * radius));

                        armorStand.teleport(movingLocation);

                        angleDegrees++;
                    }
                }.runTaskTimer(PracticePvP.getInstance(), 0, 1);
            } else {
                task.cancel();
            }

            return true;
        });
rain plinth
#

yo can someone help me?

#

im not really good at code im just learning javascript html and css rn

rain plinth
#

it makes rainbow dots,

analog thicket
#

Thanks

solar mauve
rain plinth
#

i want to make a loop to where it keeps on making dots when i hold down the mouse button

rain plinth
#

heres the code rn

#

var canvasEl = document.querySelector("canvas")
var context = canvasEl.getContext("2d")
canvasEl.width = innerWidth
canvasEl.height = innerHeight

addEventListener("click" , (event) =>
{
let x= event.clientX
let y= event.clientY
console.log(x,y)

circles.push([x, y])
}
)
var circles = []
var ticks = 0
function animate()
{
ticks++
context.fillStyle = "black"
context.fillRect(0, 0, innerWidth, innerHeight)

animationId = requestAnimationFrame(animate)
circles.forEach(circle => {
let x = circle[0]
let y = circle[1]

context.fillStyle = "hsl(${ticks}, 50%, 50%)"
context.beginPath()
context.arc(x, y, 10, 0, Math.PI * 2)
context.closePath()
context.fill()
})
}

animate()

solar mauve
#

since you are rotating around the y level (i mean, set the y level to the center location's y), i already did in the code

solar mauve
rain plinth
#

where?

hazy parrot
rain plinth
#

yeah its javascript

solar mauve
torn shuttle
#

there's no spawnProjectile equivalent right

rain plinth
eternal oxide
torn shuttle
#

to spawnArrow

#

like a generic spawnArrow

eternal oxide
#

Player#launchProjectile

torn shuttle
#

not a player

eternal oxide
#

or world#spawn

torn shuttle
#

that's what I thought, thanks

eternal oxide
#

you specify what you are spawning

torn shuttle
#

also is there a method in the api to order something from uber eats, I'm famished

analog thicket
eternal oxide
#

This is Spigot plugin development help. At least use code blocks

analog thicket
#

Oh thanks

torn shuttle
#

pro tip you don't need code blocks if all of your code is in one line

eternal oxide
#

true

rain plinth
#

wait who u talkin to? me?

#

or nah

eternal oxide
#

yes

rain plinth
#

oh ok

eternal oxide
#

?paste for code, or use discord codeblocks

undone axleBOT
torn shuttle
#
        getLocationTargets(scriptActionData).forEach(targetLocation -> CustomSummonPower.summonReinforcement(scriptActionData.getEliteEntity(), targetLocation, blueprint.getSValue(), blueprint.getDuration()));

there's programmers and then there's PROgrammers

#

if it ain't in one line it ain't fine

rain plinth
#
var canvasEl = document.querySelector("canvas")
var context = canvasEl.getContext("2d")
canvasEl.width = innerWidth
canvasEl.height = innerHeight

addEventListener("click" , (event) =>
{
let x= event.clientX
let y= event.clientY
console.log(x,y)

circles.push([x, y])
}
)
var circles = []
var ticks = 0
function animate()
{
ticks++
context.fillStyle = "black"
context.fillRect(0, 0, innerWidth, innerHeight)

animationId = requestAnimationFrame(animate)
circles.forEach(circle => {
let x = circle[0]
let y = circle[1]

context.fillStyle = "hsl(${ticks}, 50%, 50%)"
context.beginPath()
context.arc(x, y, 10, 0, Math.PI * 2)
context.closePath()
context.fill()
})
}

animate() 
#

u mean this?

#

or nah

quiet ice
#

Yeah

#

Albeit the lack of any indentation drives me crazy

torn shuttle
#

oh

#

hm

#

so world#spawn() requires the class of the entity

#

but I am getting this from config

#

oh there's a getentityclass for the entitytype, thank god

regal scaffold
#

Hey, need some help with abstraction

public abstract class MyClass1

public abstract class MyClass2 extends MyClass1

public class MyClass3 extends MyClass1

public class MyClass4 extends MyClass2

pseudo hazel
#

what am I looking at

regal scaffold
#

Wait

pseudo hazel
#

looks like a binary tree

eternal needle
#

the hole?

mortal hare
#

composition > inheritance

eternal needle
#

what is that?

regal scaffold
#

I haven't explained what I'm trying to do but you might be on to something, What is that

eternal needle
mortal hare
#

it allows you to decouple implementation of specific part of the code

#

into separate units

#

of implemented classes

#

which you can swap any time

regal scaffold
#

Hold on let me explain what I want to do

#

Give me 1 minute

mortal hare
#

see Strategy design pattern

#

its the simplest composition type

eternal needle
#

i did post thoes in a link below

regal scaffold
#
public abstract class GUI

public abstract class GUISpecific extends GUI

public class GUITest1 extends GUI

public class GUITest2 extends GUISpecific

What I'm trying to do is as follows:

My class GUI has a method that I overwrite in methods that extend it. But I want to have even more specific "GUI" by forcing a basic layout on only some objects, hence class GUISpecific

My idea is that:

When I create GUITest2 a specific method which I overwrite in both abs classes

-> GUI gets called
-> GUI specific gets called
-> GUITest2 gets called

mortal hare
#

in very basic terms this is better

class Car {
  Engine engine;

  public (Engine engine) {
    this.engine = engine;
  }

  public Engine getEngine() {}
}

rather than

class VolkswagenEngineCar extends Car {
  
}
regal scaffold
mortal hare
regal scaffold
#

Yes that's all sorted

#

But the issue is here

analog thicket
torn shuttle
#

is there a way to check if an EntityType is a projectile?

pseudo hazel
#

cant every type be a projectile? xD

regal scaffold
#

I have a method called openGUI which takes parameters GUI not GUISpecific and even though GUISpecific extends GUI it won't allow me to ass that as a object

#

How can I make the openGUI method work for both types?

torn shuttle
regal scaffold
#

I thought it would work cause of inheritance but it's not

mortal hare
#

show me your code

#

or at least method decl

regal scaffold
#

It is

#

Which is why I'm lost

pseudo hazel
#

you need to provide an actual example cuz we cant follow this

regal scaffold
#

I shall show

mortal hare
#

he did

#

according to him he passed base GUI object

#

as a a param

#

but it errors out

regal scaffold
#

Class GUIManager


public void openGUI(InventoryGUI gui) {}

Class InventoryGUI

public abstract class InventoryGUI {}

Class InventoryGUISpecific

public abstract class InventoryUpgradeGUI extends InventoryGUI

class SlotUpgradeInventory

public class SlotUpgradeInventory extends InventoryUpgradeGUI

Then doing

guiManager.openGUI(new SlotUpgradeInventory());
#

Is casting safe?

#

I didn't want to cause it seems like there is a better way

#

So how can I make the it take both types?

worldly ingot
#

The required type is an InventoryGUI but you're providing a SlotUpgradeInventory. Isn't that... logical? It seems the hierarchy should line up

regal scaffold
#

But SlotupgradeInventory extends InventoryGUISpecific which extends InventoryGUI

#

In the middle I'm overriding methods

worldly ingot
#

Yeah that should still be fine

#

As long as it's somewhere up the hierarchy

regal scaffold
#

Then why is it not liking it

pseudo hazel
#

yeah it looks like it should work

worldly ingot
#

It's why you can pass in an ArrayList to a method that accepts a Collection

#

That's the whole concept of polymorphism

pseudo hazel
#

are there erros in SlotUpgradeInventory?

regal scaffold
#

No errors in any class at all

#

Except that one

mortal hare
#

have you tried invalidating cache in ide?

#

this seems wrong

#

or im too tired

#

i've went to sleep in 7 am today lmao ๐Ÿ˜„

regal scaffold
#

I shall try that

#

I was confused too I'm dumb but not that dumb it should work

mortal hare
#

Maybe you imported wrong class?

regal scaffold
#

I checked

#

Cache wasn't the thing

#

Not getting any errors, overwriting works perfect

#

Just can't use that method with that class

pseudo hazel
#

can you show more of the code?

regal scaffold
#

It's long but I can

pseudo hazel
#

like maybe there is some part we missed

regal scaffold
#

Which is why I cut it

pseudo hazel
#

you cut it to 1 line

regal scaffold
#

it's 5 files lol

pseudo hazel
#

surely 2 lines of code isnt too much

mortal hare
#

this should literally work according to the provided info

pseudo hazel
#

I am talking about where you pass the instance

mortal hare
#

doesnt matter if its abstract or an interface

regal scaffold
#

Let me provide more code

#

?paste

undone axleBOT
torn shuttle
#

how does the livingentity#launchprojectile work?

pseudo hazel
#

yeah inheritance shouldnt have to care about how many classes to put in between the parent and child class

tawdry parcel
#

Why is that purple underlined?

mortal hare
#

you're probably using it inside lambda

regal scaffold
pseudo hazel
#

for it likes to color those bright pink

mortal hare
#

at least in intellij when i use outer variables that underline pops out

regal scaffold
#

It's weird

undone axleBOT
regal scaffold
#

I didn't include any methods in inventoryGUI but it just has some basic abs methods and interface stuff

#

Wait I thought that's how inheritance worked

#

Wheel -> car -> vehicle

pseudo hazel
#

well not the best objects to choose

#

but I get what you mean

regal scaffold
#

But then how can I do what I want? I want to have a "middleman" override for a method from the parent class because I'm gonna be creating like 5 subclasses which all need to follow the same guidelines which I want to specific in the "middleman class"

clever musk
torn shuttle
#

Snowball seems like an already existing Entity right

worldly ingot
#

It is

#

It's a Projectile

torn shuttle
#

right so I have to spawn an entity ahead of time?

pseudo hazel
#

what you have is a ShinyCarWithPully that extends ShinyCar that extends Car, it should stand to reason that methods asking for a car can still take a ShinyCarWithPully as an argument

torn shuttle
#

and then assign it as a projectile?

#

well no it says class hm

worldly ingot
#

Yes you can either cast it as a Snowball or just use the Projectile methods

regal scaffold
torn shuttle
#

problem is I have an arbitrary Entity

#

or EntityType

pseudo hazel
#

yes I dont know why it is not working

torn shuttle
#

I'm not connecting the dots to get to something that is happy with extending projectile

pseudo hazel
#

why does that not work

#

well yeah

worldly ingot
#

What you can do is entityType.getEntityClass().asSubclass(Projectile.class); which should yield you a Class<? extends Projectile>

torn shuttle
#

oh assubclass

#

I was trying to find a way to cast it

#

ayy

regal scaffold
#

It better be a runtime error

torn shuttle
#
        if (scriptActionData.getEliteEntity().getLivingEntity() != null &&
                        (entityType == EntityType.ARROW ||
                                entityType == EntityType.SPECTRAL_ARROW ||
                                entityType == EntityType.SNOWBALL ||
                                entityType == EntityType.DRAGON_FIREBALL ||
                                entityType == EntityType.EGG ||
                                entityType == EntityType.ENDER_PEARL ||
                                entityType == EntityType.FIREBALL ||
                                entityType == EntityType.SMALL_FIREBALL ||
                                entityType == EntityType.FIREWORK ||
                                entityType == EntityType.FISHING_HOOK ||
                                entityType == EntityType.SPLASH_POTION ||
                                entityType == EntityType.LLAMA_SPIT ||
                                entityType == EntityType.SHULKER_BULLET ||
                                entityType == EntityType.THROWN_EXP_BOTTLE ||
                                entityType == EntityType.WITHER_SKULL))
                    scriptActionData.getEliteEntity().getLivingEntity().launchProjectile(entity.getClass().asSubclass(Projectile.class), velocity);
            }

that's hot, that's hot

regal scaffold
#

Cause otherwise, it works

pseudo hazel
#

I mean I can..?

#

unless im misunderstanding

#

oh wait

#

maybe its cuz I used an interface

regal scaffold
#

What

pseudo hazel
#

no nvm

regal scaffold
#

I'm so lost

worldly ingot
#

I mean you could probably clean that up a little too, magma

pseudo hazel
#

yeah you are wrong ๐Ÿ˜›

regal scaffold
#

Oh so we're back to

#

It should work

pseudo hazel
#

but that still leaves us with the question of why does it not work for tom

torn shuttle
regal scaffold
#

I can provide all the code you need but it makes no sense

worldly ingot
#
if (Projectile.class.isAssignableFrom(entityType.getEntityClass())) {
    Projectile projectile = entity.getEntityClass().asSubclass(Projectile.class);
}```
torn shuttle
#

oh

regal scaffold
#

I sent the code

torn shuttle
#

yeah that's convenient

worldly ingot
#

Actually the other way around I think

regal scaffold
torn shuttle
#

also I wrote entity but meant to do entitytype

#

hope that works

worldly ingot
#

I always forget the order

regal scaffold
#

I explained

pseudo hazel
regal scaffold
#

But then how can I do what I want? I want to have a "middleman" override for a method from the parent class because I'm gonna be creating like 5 subclasses which all need to follow the same guidelines which I want to specific in the "middleman class"

#

I will check again

#

Yes, I followed the path on IJ and checked manually

#

That's not the part that's not working anyways, it was also done using smile7 implementation guide

#

The problem is purely inheritance

clever musk
pseudo hazel
#

have you tried just building the project?

torn shuttle
#
        getLocationTargets(scriptActionData).forEach(targetLocation -> {
            if (scriptActionData.getTargetType().equals(TargetType.SELF)) {
                Vector velocity = new Vector(0,0,0);
                if (blueprint.getScriptRelativeVectorBlueprint() != null)
                    velocity = new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript).getVector(scriptActionData);
                if (scriptActionData.getEliteEntity().getLivingEntity() != null && Projectile.class.isAssignableFrom(entityType.getEntityClass()))
                    scriptActionData.getEliteEntity().getLivingEntity().launchProjectile(entityType.getClass().asSubclass(Projectile.class), velocity);
                else {
                    Entity entity = targetLocation.getWorld().spawn(targetLocation, entityType.getEntityClass());
                    entity.setVelocity(velocity);
                }
            }
        });

alright let's see if this even remotely works

regal scaffold
#
incompatible types: me.tomisanhues2.ultrastorage.gui.impl.upgrade.SlotUpgradeInventory cannot be converted to me.tomisanhues2.ultrastorage.gui.InventoryGUI
worldly ingot
torn shuttle
regal scaffold
#

I'm about to turn my pc off for 3 hours see if it fixes itself

pseudo hazel
#

so what

torn shuttle
#

getLocationTargets is a very large logic chain

regal scaffold
#

Cause literally the code that I pasted from zack works lol

#

Yes

#

I can share the entire project

#

I did

#

I followed the path in IJ

pseudo hazel
#

why do you have a different package for impl, is that usually how people work?

regal scaffold
#

Cause abstraction and implementations

#

There's too many GUI's

#

So far it's worked beautiful

hazy parrot
regal scaffold
#

This weird inheritance is the only thing that popped up

worldly ingot
# torn shuttle you don't want to know how much code this runs on the backend
        getLocationTargets(scriptActionData).forEach(targetLocation -> {
            if (scriptActionData.getTargetType().equals(TargetType.SELF)) {
                Vector velocity = new Vector(0,0,0);
                var vectorBlueprint = blueprint.getScriptRelativeVectorBlueprint(); // Don't know the type, using var
                if (vectorBlueprint != null) {
                    velocity = new ScriptRelativeVector(vectorBlueprint, eliteScript).getVector(scriptActionData);
                }

                LivingEntity entity = scriptActionData.getEliteEntity().getLivingEntity();
                Class<? extends Entity> entityClass = entityType.getEntityClass();
                if (entity != null && entityClass)
                    entity.launchProjectile(entityClass.asSubclass(Projectile.class), velocity);
                else {
                    Entity entity = targetLocation.getWorld().spawn(targetLocation, entityClass);
                    entity.setVelocity(velocity);
                }
            }
        });```
pseudo hazel
#

I see

worldly ingot
#

ISN'T THAT SO MUCH NICER TO READ!?

analog thicket
worldly ingot
regal scaffold
#

Something is going on here

#

What

#

IntelliJ is full drugged

analog thicket
worldly ingot
#

getSuperclass()

#

Why? No clue

regal scaffold
#

Ok

#

Lets run this

torn shuttle
worldly ingot
#

BUT

#

IT'S READABLE

#

AND LESS DUPLICATED

torn shuttle
#

it's less duplicated, yes

worldly ingot
#

Yours overflows, mine doesn't PES_Cry

torn shuttle
#

tbf I didn't even know what asasubclass was while writing this

worldly ingot
#

Class is pretty versatile

regal scaffold
torn shuttle
#

actually thinking back I might've used it a couple of times about 4 years ago

regal scaffold
#

ValueOf coming...

torn shuttle
#

yeah...

#

it's been a minute

worldly ingot
#

Just give it a .getName(), tomisanhues

#

getSuperclass().getName(), that is

#

Logger#info() only accepts a String

regal scaffold
#

Fair

#

Choco can you nickname me please

#

Just do Tomas

worldly ingot
#

We keep your names equal to your Spigot name

regal scaffold
#

But i'm not tomis ๐Ÿ˜ฆ

torn shuttle
#

you are now

worldly ingot
regal scaffold
#

Until I unverify

frank kettle
#

Your spigot account is ๐Ÿ—ฟ

pseudo hazel
#

supplier of what? strings I assume

#

yeah so same thing essentially

regal scaffold
#

Dude

#

What is going on

#
                        Bukkit.getLogger().info(new SlotUpgradeInventory(ultraChest).getClass().getSuperclass().getName());
pseudo hazel
#

that looks correct

regal scaffold
#

wtf

#

How can I have 2 different answers

#

For the same output in 1 second

analog thicket
worldly ingot
analog thicket
#

Without smashing the animation smoothness.

pseudo hazel
#

the parent class of the slotupdgrade is the inventoryupgrade is it not?

regal scaffold
#

Oh, yes

#

And the parent of inventoryUpgrade is inventoryGUI

pseudo hazel
#

yes

#

so what it printed seems correct

#

I assume getSuperclass() only goes up one level

regal scaffold
#

Sure lol\

#

bruh

#

It's working

#

Like what

#

?nms

regal scaffold
#
    public void openGUI(InventoryGUI gui, Player player) {
        this.registerHandledInventory(gui.getInventory(), gui);
        player.openInventory(gui.getInventory());
    }

that's the method that is the one that doesn't let me use InventoryUpgradeTest as a parameter

pseudo hazel
#

try making another class that extends inventoryupgradeui

regal scaffold
#

Sure

#

So far so good

inland siren
#

did you read the error and see what intellij is telling you to do?

regal scaffold
#

Nope

regal scaffold
#

Completely different

inland siren
#

intellij isnโ€™t gonna let you call a broken class

regal scaffold
#

....

StorageUpgradeInventory extends StorageInventory which extends InventoryGUI

inland siren
regal scaffold
#

Yes of course, I was showing that inheritance was working correctly

#

And it detected the correct parent class

#

@pseudo hazel You gave up ๐Ÿ˜ฆ

#

Throwing pc out the window

pseudo hazel
#

yeah

#

short of me having the project there isnt much I can do unfortunately

#

is it on github?

regal scaffold
#

Ummm give me a bit

#

I bet it's something dumb and when a heavy hitter comes by they'll just solve it in 1 line...

#

Where the boys when you need them

inland siren
#

pure curiosity why are you shoving an interface into an empty abstract class

regal scaffold
#

It's not emptry

#

It was to reduce the code

#

Cause it's big

#

But regardless, inheritance should work in that case

quaint mantle
#

Who can make plugin free?

#

Barrels will have 50 health, there will be three types of barrels, and things will fall off them if their player breaks with weapons. Make a config so that I can add weapons and damage to the barrel (1.16.5

regal scaffold
#

xd

undone axleBOT
regal scaffold
#

hey Olivo

#

Would you be kind enough to look at something I've been having issues with for a bit and no one has been able to figure out

torn shuttle
#

it blasts off at light speed too

#

I should get it to blow up

analog thicket
#

Mostly the last Runnable

pseudo hazel
#

seems to be off by 1 block both up and to teh left

analog thicket
#

Yep, no idea why..

pseudo hazel
#

just subtract 1 from the center location

analog thicket
#

Hmm how would i get the EyeLocation? i think thats the problem

#

stand.getEyeLocation does not work.

ocean hollow
#

hi guys, please help. I need to remove scope bars.

tardy delta
#

what even are scope bars

ocean hollow
#

lol, sorry

#

square brackets

hazy parrot
#

just use regex

tardy delta
#

what square brackets lol

hazy parrot
#

[] ig

tardy delta
#

that chat?

ocean hollow
hazy parrot
#

if you want to remove [] from message, just do String#replaceAll("\[|\]", "");

ocean hollow
#

thanks

quaint mantle
#

on projectile hit event, check if the projectile is an arrow, modify the player velocity

#

otherwise decompile minecraft with mod coder pack, and just copy the code to calculate the arrow knockback

#

there is nothing in the code to calculate the velocity that mentions the arrow

#

How will it know what direction to throw the player if it doesnt know where the arrow hit you

hazy parrot
#

just side note, pls run ctrl + alt + L if using intellij

quaint mantle
#

you cancelled the event, so the player velocity will be zero

#

actually, i think no matter what in this function, the player velocity will be shown as zero unless you tell the event to run after the event fires

#

i gtg

shy wolf
#

hey, need some help,
trying to get the "currentItem" from a InventoryClickEvent and currentItem is null even tho its not
code:

@EventHandler
    public void e(InventoryClickEvent e) {
        String name = null;
        try{ // get current item return null, error in get item meta, fix lol
            ItemStack c = e.getCurrentItem();
            System.out.println(c == null); // somehow got two prints one is false and the sec is true
            boolean n = c.getItemMeta().hasDisplayName();
            if (n){
                if(c.getItemMeta().getDisplayName() != null){
                    name = c.getItemMeta().getDisplayName();
                } else {
                    name = "";
                }
            }
        } catch (Exception err){
            err.printStackTrace();
            return;
        }
}

error:

paste bin: https://paste.md-5.net/hiyiwopepe.md
#

any one know where's the problem?

tawdry echo
#

java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getItemMeta()" because "c" is null

shy wolf
#

c = e.getCurrentItem();

#

but i do click on a item

tawdry echo
#

if ItemStack is null

#

u cannt get ItemMeta

shy wolf
#

i know

#

im not dum

tawdry echo
#

its logical

shy wolf
#

wait

tawdry echo
#

use normal naming, not single letters

#

method e

#

event e

#

boolean n

#

lol

regal scaffold
#

Are you trying to make a GUI or get the item clicked in the players inventory?

#

@shy wolf

regal scaffold
#

Then don't use that event

#

PlayerInteractEvent

shy wolf
#

hum

#

lemme see

regal scaffold
#

?jd-s

undone axleBOT
shy wolf
#

thanks

#

wait

#

player interact is not for gui

regal scaffold
#

InventoryClickEvent is not for gui

#

PlayerInteractEvent is

#

Yes

#

It's working as intended then

#

It's because you can't just change the event and hope it works

shy wolf
#

this is with InventoryClickEvent

dry yacht
regal scaffold
#

There's is a small chance I did mix them around

shy wolf
#

PlayerInteractEvent is for in game not gui

regal scaffold
#

There is a big chance I mixed them around

#

Apologies

river oracle
#

InventoryClickEvent is for inventories as in the name

shy wolf
#

lol

regal scaffold
#

... y2k.. you know names mean nothing in spigot dev

#

It rarely actually does what the name says

dry yacht
#

Interaction means interacting by swinging with arms or interacting at objects in the world.

river oracle
#

Most of the time the names are very good

regal scaffold
#

It was sarcasm

#

But there's a few that are so random

shy wolf
#

lol

river oracle
#

In this case they do make sense though

#

When I doubt read the docs

shy wolf
#

any way any one know whats the problem?

river oracle
#

?paste the error

undone axleBOT
shy wolf
dry yacht
worldly ice
shy wolf
#

but in game im clicking stain gray glass

worldly ice
#

when that event gets fired your "current item" is null

#

because it's before you actually pick it up

river oracle
dry yacht
dry yacht
river oracle
#

Oh? Hm

dry yacht
river oracle
#

Ok

dry yacht
#

It's like a factory

river oracle
#

True

#

I suppose

dry yacht
#

The handler has to be messed up

shy wolf
#
@EventHandler
    public void e(InventoryClickEvent event) {
        Player player = (Player) event.getWhoClicked();
        UUID UUID = player.getUniqueId();
        String name = null;
        try{ // get current item return null, error in get item meta, fix lol
            ItemStack CurrentItem = event.getCurrentItem();
            System.out.println(CurrentItem == null);
            boolean n = CurrentItem.getItemMeta().hasDisplayName();
            if (n){
                if(CurrentItem.getItemMeta().getDisplayName() != null){
                    name = CurrentItem.getItemMeta().getDisplayName();
                } else {
                    name = "";
                }
            }

        } catch (Exception err){
            err.printStackTrace();
            return;
        }
}
``` *new*
#

this is the sort version of the handeler

#

bc the other part doesn't even fire

dry yacht
shy wolf
#

well

#

um

#

1 thats helpful

#

2 is there a way to some how get the item?

dry yacht
#

Sure thing, take your time. It's not that easy to get into inventories, as there are a few case decisions you just have to know of.

dry yacht
shy wolf
#

ooo right

#

smart

#

lemme do that

tawdry echo
#

just read docs

#

all is described

dry yacht
# shy wolf smart

And don't forget your InventoryDragEvent, so players won't put any items into vacant slots, ๐Ÿ˜‚

#

That's a classic.

shy wolf
#

oh thanks lol

#

right

dry yacht
#

Those are basically the two important events

#

The drag event will get fired even if you only drag across one slot, so it can be quite confusing

dry yacht
shy wolf
#

ok thanks thats cool

#

i didnt even thought about that

regal scaffold
#

As you can see, SlotUpgradeInventory extends InventoryUpgradeGUI which extends InventoryGUI

But for some reason, a method that requires a InventoryGUI as a parameter won't accept it

https://paste.md-5.net/jafayosanu.java

#

Bytes can you give that a look please, We couldn't figure it out with 3 people

dry yacht
#

Gimme a minute, I need to get out of the yaml hacking mindspace and into inheritance, xD

regal scaffold
#

Of course, thanks

dry yacht
#

Which method doesn't accept it?

#

Oh, right

#

I just saw

regal scaffold
#

Obviously you can assume that the openGUI method takes a InventoryGUI as a parameter

dry yacht
#

Can you show me the signature of plugin.guiManager.openGUI?

regal scaffold
#
    public void openGUI(InventoryGUI gui, Player player) {}
dry yacht
#

What does IntelliJ say to you on that error? Any messages, maybe if you hover over it?

regal scaffold
#

Type

#

incompatible types: me.tomisanhues2.ultrastorage.gui.impl.upgrade.SlotUpgradeInventory cannot be converted to me.tomisanhues2.ultrastorage.gui.InventoryGUI

dry yacht
#

Yeah, but it's gotta be more descriptive than that

regal scaffold
#

But, I printed the superclass of SlotUpgradeInventory and it's InventoryUpgradeGUI

#

And I printer the super().super() and it's InventoryGUI

dry yacht
#

Do you have two files called InventoryGUI, by any chance?

regal scaffold
#

Negative, all imports have 100% been checked

#

And all paths to objects have been checked with IJ too

dry yacht
#

So the FQN of the parameter as well as the base classes match? Like, I'm not trying to question anything you've checked yourself, but that very much looks like an issue with same name but different package classes. Maybe IJ has another stuck bug in it's typechecker, have you restarted it? Otherwise, it's gonna be immensely hard without the import sections of classes in question.

regal scaffold
#

Oh no of course, I will triple check anything I just want to solve this

#

I will provide the imports rq

#

?paste

undone axleBOT
dry yacht
#

Please also add the first line of the class definition, so I know what's what

regal scaffold
#

Yes

dry yacht
#

SlotUpgradeInventory, InventoryUpgradeGUI, InventoryGUI as well as the manager

#

That should suffice

regal scaffold
#

Wait I just found something weird

#

The InventoryGUI class according to IJ has 3 inheritors

#

Ignore

#

IJ just trash at updating

dry yacht
#

Was it a typechecker bug? haha

regal scaffold
#

Holy god

#

Listen

#

I'm gonna cry

dry yacht
#

all ears

regal scaffold
dry yacht
#

...

#

What did I tell you

regal scaffold
#

You were indeed correct, how, no idea

dry yacht
#

You need to believe into me more, haha

regal scaffold
#

I did, which is why I checked

#

again

#

Damn

dry yacht
#

Awesome, so that's fixed

regal scaffold
#

Stupid mistake cause move files into a package

#

Thank you

dry yacht
#

Always check the FQN (fully qualified name, name + containing package), instead of just the name token. That's not enough, as you can see. That can throw you for quite the loop, xD

regal scaffold
#

โค๏ธ thanks for your time

dry yacht
#

Aw, happy to help! :)). I know how relieving it can feel to finally clear up a roadblock like that, haha

regal scaffold
#

Steaf don't kill me

#

plz

dry yacht
#

Has anybody ever worked with SnakeYaml on it's own and noticed that it doesn't save anchor names, but rather uses some sort of counting strategy to auto-name them? Is this the same on spigot's builtin config? I'm having such a hard time finding anything about it online...

pseudo hazel
#

lmao

#

i wont kill u

#

I didnt see it either

regal scaffold
#

fair fair hehehe

regal scaffold
#

Didn't he tell you just to lower the height by 1 block?

#

Cause it's just 1 block higher than it should

analog thicket
#

Didnt work :p

#

Still offset by a bit

regal scaffold
#

You probably didn't lower it in the correct places, because there's no other way to change that

#

Play with half blocks

#

Remember a location is a double value

#

And the center of a block is actually 0.5 0.5

#

Not 0 0

analog thicket
#

Yeah i know.

#

Im guessing its something to do with the eyelocation

#

But well 1.8 eye location isn't that easy to get using packets.

dry yacht
# analog thicket bump

What do you mean by "going around"? You're moving it on a circle along the x/y plane. The video also stops prematurely, as I don't see the "Animation done" message. Looks like a circular path to me.

analog thicket
dry yacht
#

I'm just not yet sure on what you meant by around the chest. There are many versions of that which come to my mind, xD.

eternal oxide
#

don;t you mean x/z? unless it's moving above and below

analog thicket
#

But ill take a new vid in a sec

dry yacht
# eternal oxide don;t you mean x/z? unless it's moving above and below

Well, it's always a y-based plane, as it moves in a circle like flat on the imaginary wall the player's looking at. You'd still have to decide on x or z based on the facing direction of the chest. That maybe throws something off. Or maybe the animation has been planned out completely different, that's the thing...

analog thicket
#

Exactly above and below chest y/x

dry yacht
#

So y/x or y/z, based on it's facing direction. Otherwise, it'll not always face the player

#

Btw, have you disabled collisions on the stand?

analog thicket
#

Yeah, just trying to make the animation work at first.

analog thicket
dry yacht
#

setCollidable(false)

#

otherwise, it might also look unexpected

#

The armor stand most definitely intersects the chest

eternal oxide
#

explain exactly what you are tryign to do? move an armor stand in a circle, vertically about a chest?

analog thicket
#

Move it in a circle around the just above then below then above agian

#

If that makes sense.

eternal oxide
#

not really

#

but I have a method you could use

analog thicket
#

Idk if you seen the video?

eternal oxide
#

just edit it to your liking. it has 2 radius so you can control width and height of the circle.

#

?paste

undone axleBOT
dry yacht
#

That part just makes sense to me so far, so I don't see the issue. Again, try disabling collisions and show a full video, if you need any further help.

eternal oxide
eternal oxide
#

that code spawns a ring of flame particles around an origin

#

vertically

#

currently it takes a player and spawns it around them

#

the every variable is how many points it will plot

eternal oxide
#

anchors?

regal scaffold
#

Can anyone give me a little hand with generics

#

Let me explain

analog thicket
#

Hmm i need to update it accordingly so the animation is smooth tho

#

Or i could get alot of points.

eternal oxide
#

more points = smoother

dry yacht
dry yacht
# dry yacht

The names are not persisted, but rather auto-generated.

eternal oxide
#

ah never used them

dry yacht
regal scaffold
#
slot-upgrade-tiers:
  1:
    price: 1000
    slots: 1
  2:
    price: 10000
    slots: 2
  3:
    price: 100000
    slots: 3


storage-upgrade-tiers:
  1:
    price: 1000
    storage: 1000
  2:
    price: 10000
    storage: 10000
  3:
    price: 100000
    storage: 100000

I want to be able to store these in my plugin as a upgrade tier list from a config. I feel like generics is perfect here because I can make a class that can accept different types of upgrades since they will all be in the same format

#

Now, about generics I know enough to understand but not enough to do what I just said

#

So any assistance is welcome

analog thicket
eternal oxide
#

ok first off 1: is not a valid yaml key

#

you have to do `1`

regal scaffold
#

Really?

#

oh

#

I actually didn't remember that about integers

remote swallow
#

that isnt?

regal scaffold
#

'1'

#

Ok

#

Next up

dry yacht
#

It is, actually, xD

regal scaffold
#

... what is it

#

With '1' or without

eternal oxide
#

other than that it all looks fine. Not sure what you are having a problem with

dry yacht
#

I mean, the spec's a mess, but 1 should work as a key, I mean why not

eternal oxide
#

try it, it will nto work

regal scaffold
#

spec's a mess,

carmine rivet
#

Hi guys! I'm new to nms, I was trying to change the biome around the player with a custom biome when is moving and I put together the following code: https://paste.md-5.net/yotalawisa.cs
The problem is that I get this error: java.lang.IllegalStateException: This registry can't create intrusive holders
at net.minecraft.core.MappedRegistry.createIntrusiveHolder(MappedRegistry.java:369) ~[?:?]
at com.zainjx.fogtest.event.PlayerEvents.onPlayerMove(PlayerEvents.java:106) ~[fogtest-1.0-SNAPSHOT.jar:?]
how can I solve?

regal scaffold
#

What this

eternal oxide
#

it will complain about a non string key

regal scaffold
#

Ok ok I changed it

#

no problem

#

But now the storage part

#

How do I implement a tier system that is adaptable to any amount of upgrades and different types

eternal oxide
#

its just a map so treat it as one

regal scaffold
#

Is it that simple?
I wanted to do it a bit more fancy so I could learn new stuff

eternal oxide
#

getConfig(path).getValues() will return you a map

dry yacht
# eternal oxide it will complain about a non string key

Oh wow, you're right, learned something new! :). I thought yaml would just turn it into a string, didn't know it had the same "rules" for keys as values, so that it'd tag the node as a number if it's just numeric. Great info.

regal scaffold
#

Yeah I got that part I know how to get the stuff from the config but I thought there was more fancy ways of doing this

#

I guess not

#

I really wanted to learn generics lol just got no use for it yet I thought this was my moment

eternal oxide
#

๐Ÿ™‚

dry yacht
regal scaffold
#

I am planning on doing that indeed

#

So I guess making 5 classes for 5 upgrade categories is the only way

dry yacht
#

Still no generics needed

#

they all have the same layout

regal scaffold
#

oh wait

#

You mean make 1 class

#

tRUE

dry yacht
#

price,storage would be an entry you can get by tier ID

regal scaffold
#

Ok ok I like that

#

Rip generics

dry yacht
#

So like Map<Integer, Tuple<Integer, Integer>>, or even better replace the Tuple with a descriptively named class

regal scaffold
#

Oh god ok that got real quick

eternal oxide
#

use a record as you are going static values

dry yacht
#

Right, do that if you're on those fancy pants versions, haha

analog thicket
regal scaffold
#

Never used a record, so much new stuff

eternal oxide
#

records are nice for fixed data

dry yacht
eternal oxide
#

looks a little jerky

analog thicket
#

Yeah i need to fix that too..

#

But setCollidable(false) isnt a thing :/

dry yacht
#

Why are you even creating that thing with nms

#

There are craftbukkit methods for it

analog thicket
#

I know, but theres gonna be alot..

dry yacht
#

Maybe the wrapper has the collidable setter

#

Wait, I'mma check that out real quick

analog thicket
#

And i wanna optimize it the best i can ๐Ÿ™‚

mortal hare
#

unless I use them for constants

#

i hate it

pseudo hazel
#

is it a bad idea to use custom events to let my ui manager open menus?

regal scaffold
#

bytes I need a bit more explanation on your Map<<>> idea thing

pseudo hazel
#

instead of using teh manager as a variable everywhere

regal scaffold
#
public class UltraUpgrades {

    double price;
    double value;
    
    public UltraUpgrades(double price, double value) {
        this.price = price;
        this.value = value;
    }
}

that's what a noob would do

analog thicket
analog thicket
dry yacht
analog thicket
#

Well the radius got fixed, but its still off :/ ill send a new vid.

regal scaffold
analog thicket
#

Forgot the radius part. i added 1 to it i forgot..

dry yacht
# regal scaffold ```java public class UltraUpgrades { double price; double value; ...

That's exactly what I meant, that's fine. This is tier. So key 1 would map to that, key 2 to the next instance, etc.

So you iterate the keys of storage-upgrade-tiers, parse the integer, and if it's parsable, get that key + "." + "price"/"storage" to populate your object. Later on, you can store it into a Map<Integer, UltraUpgrades>, where you can get the upgrades by tier. I'd call it upgradesByTier. To map tiers to slot/storage/etc, you'd have to put it into another map. Something like Map<UpgradeType, Map<Integer, UltraUpgrades>>. Would also be nice to make another class for types, so the map notation doesn't get too nested.

regal scaffold
#

Isn't that a massive amount of objects?

dry yacht
#

Well, you're gonna have to define your data in some way. You can also just go crazy on generics, like Map<String, Map<Integer, Tuple<Integer, Integer>>>. It'll work fine, but the question is if you don't want to make use of the language's static typing system to make your life a bit easier.

regal scaffold
fickle ivy
#

Ok. Guys, I need help. But first let me ask, Please do not actually fix this for me. i am learning as I go. Just tell me what I am doing wrong and point me in the right direction. Now for what I am doing. In this class a player uses the command to add a location to a coords.yml file. The file first checks to see if there is a location with that name. If not then it cycles through each stored location and checks if each locations stored is the world the player is in, if it is then it checks to see if the coords are within x blocks as defined within the config of the players location. If none are within x blocks then it will add the location. If one is then they get a message saysing they are too close to another location to add one. But this ALWAYS adds it. the location name check works great but the coords compare does not.

dry yacht
# analog thicket But setCollidable(false) isnt a thing :/

It hasn't been there at 1.8, I just checked... that sucks. But now that I think of it, as the entity is entirely packet based, I don't think that you need to disable either gravity or collisions, as the server simulates those, not the client. Would gravity have been on, then your stand would have fallen way faster than the few pixels we imagined to see there, xD. It's fine. I don't know what that jump there is tho.

analog thicket
#

At this point it's the only thing I can think of

heavy mural
#

Is it normal to drown in many spigot events and exceptions on them when you make a plugin with claims and teams?

eternal oxide
#

for a beginner possibly

dry yacht
heavy mural
#

I suppose ๐Ÿ˜…
I've gotten 500 lines of pure events and exemptions at this point, but am almost finished

analog thicket
#

if i should use*

dry yacht
eternal oxide
#

eye location is where the head is

dry yacht
analog thicket
#

I mean of the ArmorStand.

dry yacht
#

Oh, no, you should just look up it's height online and compensate it's y value

#

As long as that compensation's constant, it should cause no jumps

regal scaffold
#

Something like Map<UpgradeType, Map<Integer, UltraUpgrades>>. Would also be nice to make another class for types, so the map notation doesn't get too nested.
Bytes, lastly so I can stop asking about this topic. What does this mean,

What is UpgradeType? Is it an enum? What do you mean with another class for types to replace map?

heavy mural
analog thicket
dry yacht
# heavy mural Ah good to know. I just am struggling with things like instant damage splashpoti...

That's exactly what you need to figure out in the prototype. It's the same with inventory UIs. If you try to build anything of any significance, you gotta get familiar with the topic first, until you can design a proper solution. I always build a pice of shit first and then rewrite. May sound extreme, but that's reality, as all developers who actually create new and good-ish stuff will tell you.

heavy mural
#

Aight I'll finish it first then and rework after ๐Ÿซก ty

chrome beacon
dry yacht
carmine rivet
golden turret
#

set me see

chrome beacon
dry yacht
heavy mural
#

Which might also not be true but I bumped that wall

heavy mural
#

So used armorstandmanipulateEvent instead

tawdry cedar
#

Anyone here familiar with snakeYAML?

chrome beacon
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

dry yacht
tawdry cedar
dry yacht
dry yacht
regal scaffold
tawdry cedar
#

I wish I was using Bukkit would be so much easier but Iโ€™m not making a plug-in

fickle ivy
#

Ok Guys I need help But first let me ask

dry yacht
dry yacht
regal scaffold
#

Gotcha, thanks a lot bytes

tawdry cedar
tawdry cedar
heavy mural
#

Just to be sure now:
Is it possible that PlayerInteractEntityEvent does not get triggered when a player removes a helmet from an armorstand, but subclass (of PlayerInteractEntityEvent) -> PlayerArmorStandManipulateEvent does trigger?

tawdry cedar
#

Can you send me a link

#

Iโ€™m not sure what that is

chrome beacon
dry yacht
tawdry cedar
#

How else can you input without .dump?

analog thicket
#

Okay, so @dry yacht I found the error, haven't fixed it tho, but for some weird reason, it adds 1 to x...

#

And i can't figure out where this would happend.

dry yacht
dry yacht
tawdry cedar
#

I am unsure where you are finding all the documentation for this

dry yacht
regal scaffold
#
slot-upgrade-tiers:
  '1':
    price: 1000
    slots: 1
  '2':
    price: 2000
    slots: 2

What's the correct way to get all these values in a loop

#

Is it

dry yacht
tawdry cedar
dry yacht
regal scaffold
#
for (String key : getConfigurationSection("slot-upgrade-tiers").getKeys(false))
dry yacht
analog thicket
tawdry cedar
dry yacht
# regal scaffold ```yml slot-upgrade-tiers: '1': price: 1000 slots: 1 '2': price:...

Not trying to be mean, but your questions kinda need books as answers, xD. You're - in essence - asking about how to parse data. That's a huge topic. Iterate the top level keys, then decide on the section, then parse the tiers container, then parse the tiers and populate the container. It's basically a composition of multiple smaller functions which all care about parsing a section of the whole thing.

dry yacht
# tawdry cedar hmm you know if there is a way I can just hook the YamlConfiguration file Spigot...

I don't think it's scattered at all, you might be able to just yoink that package right into your project: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/configuration?at=version%2F1.12.2

As I'm working on very specific projects, I have totally lost connection to what spigot is doing in regards to configs, tbh. I cannot be of much help there, I'm afraid. Of course I understand how it works, but I'm not having the implementation details in the front of my head at the moment.

analog thicket
#

?paste

undone axleBOT
analog thicket
#

Wait

#

1 sec

#

i think i found something

dry yacht
tawdry cedar
#

Yeh thanks.

analog thicket
frank kettle
#

Youtube

fickle ivy
#

my code looks bad right now but I am just trying to get it to work for now.

#

yeah. I do that. but all my code is just in one big class for now. I'll split it out after I figure out what I am doing wrong. I kinda do things weird. lmao

hazy parrot
#

by doing projects

analog thicket
fickle ivy
#

yeah. once I get it working right i'll rewrite it.

dry yacht
analog thicket
#

Ill send a vid in a sec

#

Well its a animation.

wheat flint
#

Hi, i don't know that happened here, i'm trying to call a static void methon on startup from class that is in one of subfolders, it worked one time, but after compiling it just popped out that without modifying anything there is an issue

dry yacht
# dry yacht

You gotta be shitting me... that's the most stupid default implementation I've ever found. So that fixed it... I'm wondering whether I have to handle collisions myself, might just do that. Otherwise, finally.

wheat flint
dry yacht
#

The package and import statements are cut off duke

analog thicket
#

You see the little jump?

wheat flint
analog thicket
#

Oh and its supposed to go around it downwards, but thats a fix for another time.

dry yacht
#

The main class'll always be gray, xD

#

It has no direct accessors, if you're not using the singleton pattern or whatever people do.

#

What should import it? There's nothing accessing that class (yet)

hazy parrot
#

he is talking about import

dry yacht
#

I must be completely misunderstanding it then

hazy parrot
dry yacht
#

Why is the main class circled red then

hazy parrot
#

well, idk ๐Ÿ˜‚

dry yacht
#

That import should work, and I cannot spot what's wrong with it yet, other than naming conventions, which don't matter right now

#

Can't you just delete that line and try an auto-import?

wheat flint
#

it just acts like the Slabs class did not even exist

#

auto completion cannot help when using method, but in import it completes it lol

dry yacht
#

Have you restarted IntelliJ? Just making sure at this point...

wheat flint
dry yacht
#

All of that's besides the point. The class is there, the import matches it's FQN, but the Symbol still cannot be found. Looks like either a stupid IJ bug, or I'm missing something very, very subtle

eternal oxide
#

compile time symbol error?

wheat flint
#

i think remaking class will do the thing

polar atlas
#

can anyone tell me why onPluginEnable event is called multiple times?

dry yacht
# wheat flint still

Yeah, very hard to tell without being able to interact with it. I'm afraid that I can't spot the issue either :/.

wheat flint
eternal oxide
polar atlas
wheat flint
analog thicket
#
double startY = location.clone().getY();
double endY = location.clone().getY() + 0.5;
double increment = (endY - startY) / ticks;

Is .clone unreliable? because its still adding to the normal location variable :?

eternal oxide
#

no clone returns a new object

dry yacht
#

Not kotlin again, duke

eternal oxide
#

it will be called for every plugin when you perform a reload

polar atlas
#

it was just a reload - im printing registering X on its register and registered all event listener at the end of onEnable of my JavaPlugin. also i print onPluginEnable on each of listeners' onPluginEnable event handler.

eternal oxide
#

yes reload will fire every plugins onEnable

dry yacht
#

That event is not just called if your plugin loads

#

You have your own hook in onEnable already

eternal oxide
#

check in the event which plugin it is firing for

dry yacht
#

Would also be helpful to post the code causing confusion rather than just throwing around method names you chose yourself.

#

Wow, that's something massively different than what I was expecting

#

Are you trying to scan packages for classes that implement the listener interface to auto-register them?

polar atlas
#

yes and it works beside triggering onPluginEnable 4 times on each class - i double checked this by adding other listener thats not onEnable or onDisable (e.g. onPlayerJoin) and it didnt print out more than once

dry yacht
#

Why do you use that event, what do you want to achieve that way? just run the registration routine in onEnable

analog thicket
#

I do NOT understand this. This is where the Jump happens. And well no fucking idea why...

#

This is what it should look like :?

polar atlas
dry yacht
polar atlas
#

that is the good way to maintain your code i think? you dont want to put every logics in single class or smth

dry yacht
#

The event is called for every plugin on the server that enables. You will get multiple calls, n calls where n is the number of plugins you add to your server. Just create another class which manages this and instantiate in the onEnable. That's your lifecycle hook, while the event isn't

polar atlas
#

i didnt knew that well thanks

dry yacht
#

The event is basically helpful if you want to prevent other plugins from loading I think, like some sort of blocklist feature.

polar atlas
#

the event name is very confusing ngl i thought it only triggered upon my plugin's enable/disable

dry yacht
#

Yeah... it's a bit misleading. But you can - in general - expect events to be shared information flow, while your own hooks are overridden methods, as on JavaPlugin

polar atlas
dry yacht
#

Yeah, that also works. It's a bit of a rube goldberg machine now, not gonna lie, but if it makes you happy that's all that counts, xDD

analog thicket
#

Damn BlvckBytes I think I gotta rethink all this shit...

dry yacht
#

I was afraid you would have to, yeah... It became a bit messy, maybe that's keeping us from finding what's wrong with it. But hey, it's not that much code yet.

analog thicket
#

True, I think I gotta make the circle thingy first next time. To make sure it works, then implement the other stuff.

#

At this point i can't even go through my own code, because its so messy

prisma sedge
#
        this.saveDefaultConfig();
        this.getServer().getPluginManager().registerEvents(new Core(), this);
        this.getServer().getPluginManager().registerEvents(new onPlayerJoin(), this);
        this.getServer().getPluginManager().registerEvents(new offHandSwitch(), this);
        Objects.requireNonNull(this.getCommand("spawnParticle")).setExecutor(new spawnParticle());
        Objects.requireNonNull(this.getCommand("addSpell")).setExecutor(new addSpell());
        Objects.requireNonNull(this.getCommand("reloadConfig")).setExecutor(new reloadConfig());
        Objects.requireNonNull(this.getCommand("setMana")).setExecutor(new setMana());``` Is there any better way to do this?
#

I mean this looks horrible there has to be right?

ivory sleet
#

yea

#

create some methods to shorten down the width

prisma sedge
#

Explain further please

ivory sleet
#
void registerEvent(Listener listener) {
  this.getServer().getPluginManager().registerEvents(listener, this);
}
#

then just
this.registerEvent(new Core());

prisma sedge
#

Oh you mean litterally just make a methos

#

thank

ivory sleet
#

myea

#

u can even go so far as to make a vararg method

prisma sedge
#

I'm sure this will be enough, thank you

dry yacht
#

Is there some sort of Reader which can have multiple restore points? I'd need to either reset to it's beginning or to a last position. Do I have to write that myself or is there something available?

dry yacht
# hazy parrot https://docs.oracle.com/javase/7/docs/api/java/io/RandomAccessFile.html smth lik...

I'm not sure yet... I basically have an InputStream which I have no control over, and I parse a SnakeYaml root node from that. I want to put a custom reader before the call to parse the yaml and read string lines. If the line starts with a #, I keep on collecting until I either find an empty line and the header comment ends or until I find a non-empty line and that comment belonged to the first key in the config and I gotta put the whole thing back. Now that I think of it, there's no need to create a checkpoint before reading each line... It'll also suck that yaml will likely have offset line-numbers then. I think I need to handle the header comment differently.

I just don't want to have big blocks of comment text be member of the first key. I need different behavior for just that first key. I think that I really should go to sleep and re-think this tomorrow. Thank you for the input! :)

wet breach
#

you need a BufferedReader. BufferedReader.mark(0) BufferedReader.reset()

FileInputStream fIn = ...;
BufferedReader bRead = new BufferedReader(new InputStreamReader(fIn));

// ... read through bRead ...

// "reset" to beginning of file (discard old buffered reader)
fIn.getChannel().position(0);
bRead = new BufferedReader(new InputStreamReader(fIn));
#

method above is slightly different

#

this will reset to the beginning of the file instead of the buffer to illustrate another way

#

However from above it sounds like you are going to need a series of buffers for the things you are wanting

#

and from those buffers perform what you are wanting

dry yacht
wet breach
#

the advantage that it is a file

#

is the fact you can load a copy into memory

#

and do as you please with it without affecting the original

#

so a lot of the operations will be quicker if you are doing it from memory copy

dry yacht
#

Yep, I see... I could also just take the easy route, read the whole stream into a string, perform my operations and then create an input stream from the string to pass to the yaml parser. I was trying to come up with a kind of cut-through method in order to not have to waste all of that memory. I get it that configs should be small, but it still hurts to load that much. I haven't yet considered all viewpoints of this...

wet breach
#

and hopefully that gets you in the right direction and with that I am off to get ready for work ๐Ÿ™‚

#

just fyi

#

the yaml lib automatically loads yaml files into memory

#

so regardless if you decide to come up with a custom solution or not, the part that will always be slow unless you piece meal load it is well loading it, but once in memory it isn't an issue

dry yacht
#

Yep, thanks for the input! I'm gonna take some time to think about it, as I don't want to rush anything. I'm not even sure that I want to handle comments this way. I think it'd be even smarter to extract the header comment from the rood node after parsing, so all node cursors have the right offsets into the file. I really overcomplicate things sometimes, xD.

dry yacht
wet breach
#

also

#

if you are just wanting to keep track of the comments to put them back

#

the reader has the ability to get line numbers

#

so you could just save the comments noting their line numbers and then just put them back

dry yacht
# wet breach if you are just wanting to keep track of the comments to put them back

Oh, no, I'm shading a new-enough snake yaml which parses comments into nodes. I just don't want this to happen, where the header comment is identified as a member of the first key and thus duplicated if I migrate the config automatically by adding a key above that. The header comment should always stay at the top. So I just need to extract it from the first key the parser yields and strip it out of it's comment, I think.

wet breach
#

then obtaining the header and only the header to prevent something being put on top should be easy then

#

just scan for lines that start with # at the top and keep going down the lines until you find no more

#

once no more detected that is your header

dry yacht
#

I still cannot modify the stream, but have to extract it from the root node's first nodetuple entry, as their cursors are screwed otherwise. But well, I don't want to keep you from getting ready for work, sorry! :)

#

The input helped already

wet breach
#

just don't use the API for this

#

then

dry yacht
#

I don't use any APIs, instead of snakeyaml, xD

wet breach
#

that is what I am saying you don't need snakeyaml to obtain the header or know where it is at

#

you can just use File API's in which you would have control over the stream

dry yacht
#

I think I do, otherwise all snakeyaml parser errors are going to have offset line numbers and going to drive the user insane... xD.

#

The context is still going to be matching, but the numbers will be off by the length of lines of the header comment

wet breach
#

then not hard to implement an offset

#

based on header size

#

in either case you have more information then you did previously ๐Ÿ˜›

dry yacht
#

yep ๐Ÿ‘

eternal night
#

from a player ?

sullen marlin
#

?xy

undone axleBOT
hexed falcon
#

For some reason this isn't working, the first part works but everything under the else doesn't, it's supposed to raytrace for 100 blocks and get the block hit by the raytrace and teleport the player to it. but it isn't working.

upper vale
#

How would I go about detecting when an item drop is destroyed in lava?

rough ibex
#

My first idea is to start a timer when an item is dropped and check every some time if it's right next to lava but someone probably has a better answer.

#

and also cancel that timer after a certain amount of time so that every item drop isn't constantly being checked.

#

if it's been like 10 seconds, it's not being dropped into lava.

fossil lily
#

this is why I dont help people because I cant read (sorry demeng)

upper vale
#

I expected there to be some sort of event for this but it doesnt seem like it

rough ibex
#

I don't think there's an item despawn event.

#

there is.

#

but only out of natural despawn.

#

Yeah, it's a tough problem to solve and be efficient at too

#

the only things I can think of are loops that check for lava around items.

marsh burrow
#

Hey mates, would anyone know of a way to change the SpawnData of a spawner?

prisma sedge
#
if (args[0].equalsIgnoreCase("reload")) {}
if (args[0].equalsIgnoreCase("setMaxMana")) {}
if (args[0].equalsIgnoreCase("getMaxMana")) {}
if (args[0].equalsIgnoreCase("executeSpell")) {}
if (args[0].equalsIgnoreCase("addSpell")) {}``` Is there a better way to do this?
prisma sedge
#

Not sure what a switch method is

marsh burrow
#
switch (args[0].toLowerCase()) {
    case "help": //code; break;
    case "reload": //code; break;
}
marsh burrow
#

just remember to use a break after each case, else all lower cases get called

prisma sedge
#

Oh ok, cool thank you

prisma sedge
#

sorry first time using this switch stuff

#

Didnt even know it existed until now

marsh burrow
prisma sedge
#

Oh ok that makes sense, thank

rough ibex
# prisma sedge Not sure what a switch method is

Also, if you're using Java 13+, you can do โ†“ and avoid breaking entirely (+ a bunch of other cool 'enhanced switch' stuff).

switch (A) {
  case 1 -> {
    a();
  }
  case 2, 3 -> {
    b();
  }
  default -> {
    c();
  }
};
glad prawn
undone axleBOT
prisma sedge
glad prawn
#

Fr?

rotund ravine
#

?learnjava!

undone axleBOT
quaint mantle
#

i could not find any useful forms

white root
#

If its not on maven or another repository, youll have to add it as a system dependency

quaint mantle
#

on gradle

#

how do i do it like ik i need to put it in dependencies but what is the code to add it

#

nothing i tried works

jagged monolith
#

You add the dependencies in the build.gradle file

#
dependencies {
    compileOnly 'org.spigotmc:spigot:1.18-R0.1-SNAPSHOT'
}

Example for adding spigotapi as a dependency

#

@quaint mantle

#

compileOnly because it's provided by the server. Not your plugin

quaint mantle
#

I got a forge client and send a custom packet to bukkit server, how to receive it with plugin?

sacred wyvern
#

Can anyone recommend a good reference to create Custom GUI's for minecraft? I wanted to create a custom Admin window but a lot of material out there is outdated or doesn't really explain the concept very well.

glad summit
#

hi!

#

wanted to ask if there is a way to cancel the magma block event?

#

like the buble column sucking entities down

#

(cz i am using boats with model engine that use zombies as entities and have a cusotm map generated with iris , but the map has magma block in water so boats sink)

smoky oak
# glad summit hi!

replace the water block above the magma block with flowing water. Do keep in mind to use the 'no-physics-update' method

chrome beacon
# quaint mantle I got a forge client and send a custom packet to bukkit server, how to receive i...

You can use the plugin messaging channel to communicate with the server.

To see how to implement it on the bukkit server side read the following. (Don't forget to use your own channel rather than the Bungee one) https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/

On the Forge end you'd just register a SimpleChannel like normal. See https://docs.minecraftforge.net/en/latest/networking/simpleimpl/

Do make sure the channel names are the same on both Client and Server. So Spigot should have the channel <namespace>:<path>

quaint mantle
#

so cool and detail, thank you very much

glad summit
#

if the plugin replaces all the water blocks on magma blocks in world i my world is 10k x 10k

chrome beacon
#

You shouldn't replace all the water

#

Just where the zombies are

#

and then replace it back when they move

livid dove
#

Hey guys just as a sanity check (as a "before we accommodate this" sorts deal) .

Back end wise what are the downsides of having 2600 bees in say a 10 chunk radius?

And how much would those be mitigated if we disabled AI and collision under say 18tps?

#

Gut is telling me one thing but wanted a sanity check from u lovely folk before commiting haha

earnest forum
livid dove
#

Was thinking more dev end.

#

As u know before we write the plugin

earnest forum
#

its not programming related though, is it?

livid dove
#

I figure between the general community and the devs, fellow devs would have a better lick on its repercussions resource wise.

chrome beacon
#

Why do you need that many bees

livid dove
#

Just getting a sanity check on how we approach it.

And if there are problems that'll creep up even if we disable ai and collision resources wise

chrome beacon
#

If you disable the ai they will get stuck and do nothing

#

Keep the bees inside their hives if possible

heavy mural
#

Hey, I want to know if this is true:

Is it possible that PlayerInteractEntityEvent does not get triggered when a player removes a helmet from an armorstand, but subclass (of PlayerInteractEntityEvent) -> PlayerArmorStandManipulateEvent does get triggered?

sullen marlin
#

Try and see?

heavy mural
#

I have tried it and it does confirm it, but I just want to make sure that I am not messing something up in the PlayerInteractEntityEvent (almost every other interaction seems to trigger tho).

#

Because due to that exception (and other subclass exceptions) I have a lot more code lines than I thought would be necessary

#

I think this subclass feels more as an "extension" in that case instead of a more specific part of the super class.

#

Which confuses me, hence I am asking if my approach (or perhaps reasoning) is wrong

hybrid turret
#

Is the PlayerInteractAtEntityEvent triggered when clicking on a mob with a name tag?

regal scaffold
#

Do you guys use built in fileconfiguration to do your big configs?

#

Or what good alternatives is there

ivory sleet
#

Uh sure, but I like to define a class that represents the config more accurately

#

For instance

eternal oxide
#

?configs

undone axleBOT
regal scaffold
regal scaffold
#

Is that not a waste? is there better ways of doing it

eternal oxide
#

that link I gave you covers all of it. Exactly what you asked for. Using custom configurations