#help-development

1 messages · Page 2136 of 1

kind hatch
#

That’s pretty easy is it not?
Just compare the instance of the inventory and then on click, add item to the players inventory.

crisp steeple
#
  1. listen for inventory click event
  2. check if it’s the correct inventory
  3. cancel the event
  4. clone the item they clicked on and add it to the players inventory
kind hatch
#

^

harsh totem
#

should I calculate the amount of items that can be given in a function?

flint coyote
#

Either that or you remove the amount they received (first one is cleaner tho)

kind hatch
#

Just check to see if the player has an open slot.

flint coyote
harsh totem
viscid girder
#

Hi, does anyone know how to get Packet Enums in 1.18?

kind hatch
harsh totem
#

i'll calculate the amount of items that can be given in a function

hexed hatch
#
    public static int getPullTime(ItemStack stack) {
        int i = 0;
        if (EnchantmentHelper.get(stack).containsKey(Enchantments.QUICK_CHARGE)) {
            return i == 0 ? 25 : 25 - 5 * EnchantmentHelper.getLevel(Enchantments.QUICK_CHARGE, stack);
        }
        if (EnchantmentHelper.get(stack).containsKey(GizmosEnchantments.BALLISTA)) {
            return BallistaEnchantment.DRAW_TIME;
        }
        return 25;
    }```
Just wondering if a more skilled Java developer sees a glaring way to optimize this better than I have it
flint coyote
#

You can remove the if curly brackets if that counts 😛

hexed hatch
#

Does that optimize it in any capacity?

tall dragon
#

nope

kind hatch
#

I don’t think it does. It’s just another way to write the statement

tall dragon
#

it will be compiled all the same.

hexed hatch
#

Figured as much

tall dragon
#

little hard to figure out any optimizations without context

#

what is it

hexed hatch
#

This actually isn't spigot at all, it's a mixin that overwrites the getPullTime method for crossbow loading time and apparently it executes often

kind hatch
#

What exactly are you trying to optimize?

flint coyote
#

it increases readability but yes, performance wise it's the same

tall dragon
#

what should it do

flint coyote
#

Are you doing something with the value of EnchantmentHelper.get(stack)?

hexed hatch
#

for the item stack

flint coyote
#

So the value is the level?

hexed hatch
#

Correct

flint coyote
#

Alright wasn't sure from what I can see above

#

So you say it's called multiple times in very short intervals?

hexed hatch
#

apparently for almost every tick that a crossbow is in someone's inventory

#

for each crossbow

flint coyote
#

o.o that sounds weird

hexed hatch
#

that's how the vanilla game does it lol

kind hatch
#

That sounds like good exploit potential

flint coyote
#

even if it's not equipped or used?

hexed hatch
#

I'm just overwriting the method that's present in the vanilla game

#

Like, that happens in vanilla apparently

flint coyote
#

On the first glance I'd blame that on an intern

hexed hatch
#

working with minecraft's source code is eye opening lol

tall dragon
#

i would assume it only gets called when someone pulls one right?

hexed hatch
#

you'd think but apparently not lol

#

ticks pillagers too

flint coyote
#

Well as weird as it is: You could consider caching the result of your calculations per itemstack

steel swan
#

is there a way to get the players in front of a player, in a certains radius, in a straight line in front of the original player?

hexed hatch
flint coyote
#

May I know what class you found that in? I wanna know if spigot optimized that

hexed hatch
#
    public static int getPullTime(ItemStack stack) {
        int i = EnchantmentHelper.getLevel(Enchantments.QUICK_CHARGE, stack);
        return i == 0 ? 25 : 25 - 5 * i;
    }```
#

CrossbowItem.java

#

using yarn's mappings atm

hexed hatch
steel swan
hexed hatch
steel swan
#

then i will just get the idstance

hexed hatch
#

I'd love to know

steel swan
#

but i know how to do that

#

i just dont know how to detect the players on the crosshair of an other player

tall dragon
#

shoot a ray from the original player's eye location in the direction hes watching. and see if it hits any other players

steel swan
tall dragon
#

thought if you want to detect whenever this happens. you would need to do this on a time loop. which might not be good for performance

flint coyote
hexed hatch
steel swan
tall dragon
#

so then you are fine using the method i explained above

steel swan
kind hatch
hexed hatch
#

honestly from looking at this it seems like it'd be more sensible to store the pull time of a crossbow as nbt

harsh totem
# crisp steeple 1. listen for inventory click event 2. check if it’s the correct inventory 3. ca...

I got this and there is still the problem that the slot with the stack becomes 1

    public void OnClick(InventoryClickEvent event){
        if (event.getCurrentItem() == null || event.getClickedInventory() == null){
            return;
        }
        if (event.getClickedInventory().getHolder() instanceof getCoinsInv){
            ItemStack clone = event.getCurrentItem().clone();
            ItemStack[] items = event.getWhoClicked().getInventory().getContents();
            Player player = (Player) event.getWhoClicked();
            int amount = amountOne(items);
            if (event.getCurrentItem().getAmount() > amount){
                player.sendMessage(ChatColor.RED + "You don't have enough inventory space!");
            } else {
                player.getInventory().addItem(clone);
                event.getClickedInventory().setItem(event.getSlot(), clone);
                player.sendMessage(ChatColor.GOLD + "You've been given coins!");
            }
            event.setCancelled(true);
        }
    }```
steel swan
#

ik bad version

#

but i dont have a choice

tall dragon
#

well then raycasting is not a thing yet

steel swan
steel swan
tardy delta
#

class names should start with an uppercase character pls

tall dragon
steel swan
#

hmmmmm any link to a method lmao?

tall dragon
#

read dis

harsh totem
flint coyote
#

Are you sure you are recompiling your code? Like is the message you receive correct? @harsh totem

tall dragon
harsh totem
steel swan
tall dragon
#

cus ur calling it on the location

#

Vector entityLoc = entity.getLocation().toVector();
Vector playerEntityVec = entityLoc.subtract(playerEyeLoc);

#

its shown like this

steel swan
#

.ohh yeah im stupid

#

honnestly, i didnt even know toVector() was a thing

#

thats gonna be usefull

tall dragon
#

yup

flint coyote
hexed hatch
flint coyote
flint coyote
hexed hatch
#

It's not like it would affect much of anything, and clearly it doesn't, but it does seem terribly unnecessary

midnight shore
hexed hatch
#

Might be why pillagers have had a history of being heavy on servers

#

because for every tick they're existing, the game is checking the pull time on their crossbow

harsh totem
flint coyote
flint coyote
steel swan
# tall dragon yup

ok so i m a bit lost in the tutorial :
so this gets the vector :

Vector playerLookDir = player.getEyeLocation().getDirection();
                                    Vector playerEyeLoc = player.getEyeLocation().toVector();
                                    Vector entityLoc = player.getLocation().toVector();
                                    Vector playerEntityVec = entityLoc.subtract(playerEyeLoc);
                                    float angle = playerLookDir.angle(playerEntityVec);

and this the nearby entities:

player.getNearbyEntities(20, 20, 20)

but how do i combine the 2?

midnight shore
hexed hatch
#

I feel myself getting sucked into the fabric black hole

tall dragon
tardy delta
midnight shore
#

nothing just starting up my server

tardy delta
#

no plugins?

tall dragon
steel swan
midnight shore
#

yeah there are plugins but i didn't change anything and it does this, before it worked with no difference to the plugins

tardy delta
#

i guess stop the server and try again

midnight shore
tall dragon
#

wait a sec il make you a quick method

midnight shore
#

i'm doing this 300 times

#

still getting same error

tardy delta
#

try to remove all plugins and see if its still there

tall dragon
midnight shore
#

i'm trying to delete the worlds

tardy delta
#

uhm do plugins first

tall dragon
steel swan
#

thx lmao im so lost with this one

tall dragon
# steel swan thx lmao im so lost with this one
public Player getClosestToCursor(Player player) {
        Vector playerLookDir = player.getEyeLocation().getDirection();
        Vector playerEyeLoc = player.getEyeLocation().toVector();

        Entity selected = null;
        float selectedAngle = 5; //Set to 5 initially since the angle will always be smalled than this.
        for (Entity entity : player.getNearbyEntities(20, 20, 20)) { // Search for all players in a radius around the original player.
            if (!(entity instanceof Player)) continue; // check if the entity is a player.

            Vector targetLoc = entity.getLocation().toVector();
            Vector entityVec = targetLoc.subtract(playerEyeLoc);
            float angle = playerLookDir.angle(entityVec);

            if (angle <= MAX_ANGLE) { // check if the angle is less than some maximum number. you can change this to find how much you like. can be a number from 0 to PI, i suggest something like 0.2 - 0.5
                if (angle < selectedAngle) {
                    selected = entity;
                    selectedAngle = angle;
                }
            }
        }
        //return the selected entity. or null if none were close enough.
        return (Player) selected;
    }

i think something like this should do the trick.

steel swan
#

OH MY udid smth very complete 😅

#

lemme try to understand how it works

tall dragon
#

well. good luck 🙂

steel swan
#

ok so there are a few parts that i dont get, but i think i get how it works

tall dragon
#

but i can understand if you dont understand all the math. vector math is a bitch 😄

steel swan
tall dragon
#

ik this looks very scuffed xD

#

but it kinda explains it

steel swan
#

OH

#

i see

tall dragon
#

the angle will return a number between 0 and pi(3.14), which you could convert to radians

#

but thats not rlly needed

#

so now you see, the smaller the angle

#

the better the match is

dusk flicker
#

stop

#

put it in a paste

#

?paste

undone axleBOT
dusk flicker
#

we dont need your spam here

half leaf
#

o

#

alr

#

chill out

undone axleBOT
half leaf
#

bro it wasnt even the whole code

#

chill

#

also ty ty

#

💋

#

so

#

i was doing a punch bow command
which it gives me a bow with punch 10 and INFINITE
it all works fine
but i made a lil listener which it disables the fall damage that is cuzed by shooting myself
and for some reason
it doesnt work
also i dont have any errors in console
im using spigot 1.8.8

tardy delta
#

dont save players in a list

half leaf
#

mmmm

tardy delta
#

use a Set<UUID> instead

half leaf
#

o okay

tardy delta
#

theres no reason to store pplayer objects instead of just their 'ids'

#

and a set wont allow duplicated elements

#

im wondering if a set has a better performance than an arraylist :/

#

i guesss not

eternal night
#

I mean HasSet#contains is also just a lot faster than ArrayList#contains

low temple
#

Not when it comes to using .contains

ivory sleet
#

I mean worst case scenario

eternal night
#

hashset does not iterate, that is why you hash 😅

#

well

#

depends on collision logic but generally it does not want to iterate on contains calls

#

ArrayList#contains iterates from 0 to len-1 and .equals each until it finds it

mortal hare
#

do you guys separate your interfaces and classes from bukkit api as much as you can

#

it seems a good way to ensure backwards compatibility and cross server software support

#

by only providing impl classes

#

for example for bukkit api

eternal night
#

Well you end up with a lot of "copies" from the bukkit api

quaint mantle
#

is it possible to make a "then" after a try catch

eternal night
#

e.g. representing a location, you now need your own interface

quaint mantle
#

not finally

eternal night
#

what would that then do ? 👀

valid bay
#

question: I'm trying to make it so when the player clicks green wool within a GUI, it checks for a certain recipe and provides an item based on whether they have the correct resources.

I've managed to do this fine--however, I'm having an issue where the player must have a specific stack of a material (ie. 20 dirt) but would anyone be able to point me in the right direction to how I would make it so it would remove 20 dirt from any-stack of that material and not IF it's just a specific stack of 20?

brave sparrow
mortal hare
#

also it eats memory like a chrome tab

#

since its based on hash principles

brave sparrow
#

HashSet can insert and search in amortized constant time

#

ArrayList can iterate quickly but is somewhat slow for large amounts of inserts or removing by index, and searching is linear time

mortal hare
#

If you need to insert lots of values, but have the same linear structure use linkedlist instead

#

by default arraylist capacity is 10

#

if you add more than 10 that array which got filled will get copied by each index to a new array

#

which is expensive

#

especially with large lists

brave sparrow
#

You can allocate a larger array if you know you’ll need it

eternal night
#

cool kids just know the size of their array list beforehand

brave sparrow
#

And the larger it grows the more you can insert before it needs to grow again

mortal hare
#

cool kids use primitive arrays in their impl hidden in private fields

low temple
#

Do arraylists grow by 10 each time it’s filled?

valid bay
# valid bay question: I'm trying to make it so when the player clicks green wool within a GU...

``` `` if (e.getCurrentItem().getType() == Material.GREEN_WOOL) {
boolean checking = true;

            if (checking == true && sword == true) {
                ItemStack swordstack = new ItemStack(Material.DIRT,20); // error: must be exactly 20
                if(!(player.getInventory().contains(swordstack))) {
                    player.sendMessage("Invalid Resources");
                    sword = false;
                    return;
                } else {
                    player.getInventory().removeItem(swordstack); ``` (here is the portion of code so far if anyone has the time to take a look. tysm^^ let me know if so)
brave sparrow
#

All data structures have trade offs, that’s why it comes down to more complex choices than “A is better than B”

mortal hare
#

if data is fixed size

brave sparrow
#

It typically doubles

low temple
#

Makes sense

#

Hash sets are maxed out at 16 but each index has a linked list right?

brave sparrow
#

What do you mean maxed out at 16

mortal hare
#

huh

brave sparrow
#

The amount of buckets is based on increasing powers of 2, it’s not fixed

low temple
mortal hare
#

afaik hashsets expand dynamically if the load coefficient is higher than specific value

brave sparrow
#

It’s not always 16 no

low temple
#

Idk I might be wrong about that

mortal hare
#

to amortize its time complexity

brave sparrow
#

It grows as needed to reduce the number of hash collisions

#

The structure reallocates itself at runtime to keep the size of each LinkedList very small

#

Which is why it’s amortized constant time

#

Java in particular uses power of 2 buckets because it’s faster to compute the bucket index with bit operations than mod

mortal hare
#

Oh well i didnt knew that sets used linked lists

#

i thought these were just plain arraylists

brave sparrow
#

HashSet is backed by a HashMap

#

Which is an array of LinkedLists

mortal hare
#

but it makes sense i guess

#

it probably uses bucket technique where instead of placing the element at the place next to the collision index it chains it at the same index with linked list and then iterates the values until it finds the right one

#

right

#

that's why it uses it right?

worldly ingot
#

fwiw, if all you're storing is a few UUIDs (even up to a thousand UUIDs or more tbh), the performance difference between an ArrayList and a HashSet are going to be negligible lol

#

Use the right tool for the job, but all things considered, you're going to save maybe a couple nanoseconds

mortal hare
#

sometimes i think hashmaps are slower than just plain old iteration

#

i mean

#

if you have lets say 10 values

#

some people still use maps for that

ivory sleet
#

probably due to scalability

brave sparrow
#

The larger the number of buckets, the less such collisions will occur

mortal hare
#

thats what I said basically.

brave sparrow
tender shard
#

in 99.9% of cases, it doesn't mater at all which kind of collection or map you use

mortal hare
#

whoever named those parts as "buckets" should burn to hell

mortal hare
#

i remember when i researched this

#

I thought

#

who tf would name something like this

#

a bucket

brave sparrow
#

It’s a bucket of data

#

It makes perfect sense to me

tender shard
brave sparrow
#

Lol

mortal hare
#

pepega

brave sparrow
#

I love data structures, I used to help teach it at my university

ivory sleet
#

which one's your favorite?

tender shard
#

Map<String,Object> is definitely the most useful one ❤️

mortal hare
#

in my case i would probably use it

#

since i already use it in my own generic interfaces

eternal night
#

I mean, how will you use generics for that

mortal hare
#

i would let the impl define the type

eternal night
#

A bukkit Location and a sponge whatever will not align

#

yea but how do you on your end then work with that

#

or API wise

#

like if your impl says I expect a bukkit locaiton here

#

what API type do you provide

ivory sleet
#

Maybe if you have a base interface that acts like an adapter (for locations), then you have specific implementations that prototype the underlying location delegate. Which could be useful if you need to use bukkit specific shit in conjunction with your "common" abstraction or sth. Though this sounds like a contradiction in terms of design but yeah.

mortal hare
#

thats what i would do

#

i would create an generic interface

#

then implement it with bukkit specific calls

eternal night
#

I mean yea then you end up with

interface YourAPILocation {
  double x();
  double y();
  double z();
}

interface BukkitAdapter {
  YourAPILocation location(org.bukkit.Location location);
}
#

at which point, yea you are writing "copies" of your spigot api etc

#

which is fine if you explicitly want to support multi version

#

but if you are not actively planning on it, I don't think I'd call it a good design for a spigot plugin api

grim ice
#

hey kids

mortal hare
#

hey adult

grim ice
#

what happens if i contribute to a repo

eternal night
#

you get github street creds

grim ice
#

while someone has the changes before i contribute

#

and he alr did his local changes

ivory sleet
#
interface LocationAdapter<O> {
  double x();
  double y();
  double z();
  O prototypeDelegate();
}

class BukkitLocationAdapterImpl implements LocationAdapter<Location> {
  Location prototypeDelegate() {
    return loc.clone();
  }
}

record BukkitListener(Platform<LocationAdapter<Location>> platform) implements Listener {
  @EventHandler void onEvent(var e) {
    var location = platform.process(e.entity()).prototypeDelegate();
  }
} 

this looks like shit design but hey

grim ice
#

and he contributes after i do without the changes i did

ivory sleet
#

guess if you're into generics then perhaps

eternal night
#

either it merges properly because you didn't fuck up

#

or they have to merge/rebase

tender shard
grim ice
#

so

#

i dont get what that means :o

#

well ii dont really contribute to other projects i dont really know many of the concepts

tender shard
#

if there's a merge conflict, the repo owner who wants to merge your (now outdated changes) basically gets a GUI/text file and then they have to manually "mess with that file"

grim ice
#

wat

#

they have to merge both the changes of your code and the other code

tender shard
#

you don't have to worry about it until it happens. and when it happens, you'll see how it works

grim ice
#

maually?

tender shard
#

i'd love to show you an example but I can't

#

it's really nothing special

#

it takes like 2 minutes and you're done, most of the time

grim ice
#

oh ok

ivory sleet
#

if two changes are incompatible for instance if they both change the same set of lines then you manually have to go through that in principle to tell how the changes are supposed to be applied

crisp steeple
tender shard
#

commits are always supposed to only change small things

grim ice
#

this is the same problem

#

as concurrency issues

crisp steeple
#

i remember one time someone accidentally changed the indents on every annotation in a multi-module git project somehow

grim ice
#

different threads accessing the same thing

ivory sleet
#

ugh wat

crisp steeple
#

that took a while to fix

ivory sleet
#

I mean to some extent

grim ice
#

and changes overlap

tender shard
grim ice
#

since individual computers have their own threads

crisp steeple
#

i still think it’s on the weird indents now since they added more than me

ivory sleet
#

but like you could probably come up with hundreds of examples similar to the ones concurrency brings

grim ice
#

ig

#

they should make locks for contributing! (im jk thats a terrible idea)

ivory sleet
#

myea or avoid locks with atomicity if possible :p

ivory sleet
#

?

#

Move to another channel, this isn't the one for this type of chitchat

#

?kick @gritty hawk stop trolling

undone axleBOT
#

Done. That felt good.

knotty meteor
#

Does someone know?

quaint mantle
#

why does setHealth not make the player screen move as if they're taking damage

#

how can i make it be realistic

lost matrix
quaint mantle
#

double?

lost matrix
#

Yes. The data type

quaint mantle
#

create a EntityDamageEvent?

lost matrix
#

LivingEntity#damage(double)

quaint mantle
#

oh

#

lmao

#

thanks

#

what a stupid question mb

somber hull
ivory sleet
#

make your instance variables in SimpleGraves.java private

#

and final if possible

#

you could encapsulate that map in another class

somber hull
#

True, i never do that in most of my plugins

#

i forget

ivory sleet
#

myeah but its mostly to write code defensively

somber hull
#

Yea, i get that

ivory sleet
#

this map looks a bit out of place

#

I'd like to see it in its own class

somber hull
#

Oh, yea i only use it in listeners tbh

#

I could move it into listeners?

somber hull
#

But changed a bunch of stuff

ivory sleet
#

I mean sure, but there's this principle called single responsibility principle

#

and it states, that a class must only have one major reason to change thus it most only carry one significant responsibility

#

usually managing a Map implementation is considered a big enough of a responsibility such that it deserves its own class

somber hull
#

Really?

ivory sleet
#

also I'd say use this whenever applicable, yes not everyone uses it

#

but for readability its extremely nice

somber hull
ivory sleet
#

yeah

#

also, register the listener in onEnable

#

not in the constructor of Listeners.java

somber hull
#

Why not?

#

It runs the same? And it reads better?

#

Imo

ivory sleet
#

it doesnt read better

#

you couple instantiation with registration

#

your SimpleGraves.java is the class that should register things accordingly

#

therefore that logic in principle should belong to your SimpleGraves.java

#

for you method onPlayerDeath, I'd certainly reduce it into smaller methods/functions

#

big functions are rude to the reader

#

or well, functions that do a lot of things

#

because if we want to know what they do, we need to read the entire funciton

somber hull
#

yea

ivory sleet
#

Your LocationManager is nice

#

however

#

the name Manager is quite unspecific

hasty prawn
#

Put everything in one method as a new way to "obfuscate" codenoted

ivory sleet
#

so if you can, find a more specific name

somber hull
#

For DataManager?

ivory sleet
#

consider LocationRepository or LocationRegistry more concrete names

#

oh yeah

#

DataManager

#

whatever, but yeah manager in general

somber hull
#

Well it manages the data config

ivory sleet
#

wym by manage?

#

thats extremely abstract and unspecific

somber hull
#

Like it creates it, saves it, gets it

#

Would you rather me call it a handler lol

ivory sleet
#

Sounds like a StorageFacade then

somber hull
#

StorageFacade?

ivory sleet
#

yes

somber hull
#

Not understanding the facade part of that

ivory sleet
#

a facade is when you have a (single) class that simplifies logic of several other classes by encapsulating instances of those classes

#
    Data config;
    SimpleGraves plugin;
    File configFile;
    ObjectMapper om = new ObjectMapper();
#

the more low level, complicated, implementation specific stuff

somber hull
#

got it

ivory sleet
#

your methods

initializeConfig
saveConfig
getConfig

is like a nice button menu

#

anyway this is very nitpicky

#

but yeah you asked for it

somber hull
#

Lol yep

ivory sleet
#

so allow me to continue

somber hull
#

Go ahead

ivory sleet
#

File.java sucks

#

use Path.java, Paths.java and Files.java instead

somber hull
ivory sleet
#

    Many methods didn't throw exceptions when they failed, so it was impossible to obtain a useful error message. For example, if a file deletion failed, the program would receive a "delete fail" but wouldn't know if it was because the file didn't exist, the user didn't have permissions, or there was some other problem.

    The rename method didn't work consistently across platforms.

    There was no real support for symbolic links.

    More support for metadata was desired, such as file permissions, file owner, and other security attributes.

    Accessing file metadata was inefficient.

    Many of the File methods didn't scale. Requesting a large directory listing over a server could result in a hang. Large directories could also cause memory resource problems, resulting in a denial of service.

    It was not possible to write reliable code that could recursively walk a file tree and respond appropriately if there were circular symbolic links.

somber hull
#

Odd that it would be fixe don the other ones and just left ignored on File.java

ivory sleet
#

mye

#

well it probably will get deprecated sooner or later

#

as soon as more apis and libraries have favored Path to File

#

the name of your class Listeners.java also suggests the class is held responsible for several significant accountabilities

somber hull
#

I dont think the writevalue method for the object mapper will allow me to use path

ivory sleet
#

because you can pass a Writer or an OutputStream

#

anyway thats all I believe

#

there are some other things

#

but those nitpicks wont even benefit you

somber hull
#

Alr

#

Thank you

ivory sleet
#

since you're not doing enterprise :3

knotty meteor
#
    public void onPacketReceiving(PacketEvent event) {
        PacketContainer packet = event.getPacket();
        if (event.getPlayer().getVehicle() == null) {
            return;
        }
        if (!(event.getPlayer().getVehicle() instanceof ArmorStand)) {
            return;
        }
        ArmorStand armorStand = (ArmorStand)((Object)event.getPlayer().getVehicle());
        float forward = ((Float)packet.getFloat().read(1)).floatValue();
        float side = ((Float)packet.getFloat().read(0)).floatValue();
        Player player = event.getPlayer();
        armorStand.setHeadPose(new EulerAngle(player.getLocation().getDirection().getY() * -1.0, 0.0, 0.0));
        float speed = 1.2f;
        if (forward > 0.0f) {
            this.goForward(armorStand, speed);
        }
        else if (forward < 0.0f) {
            this.goForward(armorStand, -speed);
        } else {
            armorStand.setVelocity(armorStand.getLocation().getDirection().multiply(0.01F));
        }

    }

    public void goForward(ArmorStand armorStand, float speed) {
        armorStand.setVelocity(armorStand.getLocation().getDirection().multiply(speed));
    }
    public void goBackward(ArmorStand armorStand, float speed) {
        armorStand.setVelocity(armorStand.getLocation().getDirection().multiply(speed));
    }```
Does someone know why this is not working?
Im trying to make a packetadapter with protocollib for "flying" on a armorstand.
If you are riding an armorstand and go forward then you would go forward to the direction you are looking at
When im riding a armorstand it just does nothing now
I also depended protocollib in the plugin.yml and i implemented this class in the main
ivory sleet
#

I assume this instance of ArmorStand is a normal entity, so no custom entity?
And it has gravity on?

echo basalt
#

how are you registering it?

#

If the armorstand has either noAI or noGravity set to it, setVelocity won't work

vocal cloud
#

Is the scope provided in the pom?

serene juniper
#

hello,do you know how hypixel made for example on skyblock now basiclly map,so if you click on map and for example click on your island it teleports you

#

is that hard?

#

i mean this

vocal cloud
#

Man that is one low-res image

serene juniper
#

sry

#

sec

#

now?

manic delta
#

Guys, how can I code a countdown? I can't think of how

#

I want to put the time in a scoreboard using the PlaceHolderAPI (I can this, but the countdown doesn't occur to me)

dusk flicker
knotty meteor
serene juniper
knotty meteor
dusk flicker
#

I wish we could do stuff like that serversided lol

echo basalt
#

teleports still work

knotty meteor
#

So i need to set gravity to true? or not

echo basalt
#

setting it to true makes the stand fall

#

you can apply counter-velocity or use fancy nms and override some tick methods

#

or you can just teleport it

knotty meteor
#

Ahh then im going to use teleport instead of velocity

marble rivet
#

how do i make an item frame invisible, it doesn't seem to have a method despite that being added 2 years ago

nvm

#
itemFrame.setVisible(false) ```
golden turret
knotty meteor
#
armorStand.teleport(armorStand.getLocation().getDirection().multiply(1.2f));```
Does someone know why the teleport part doesnt work?
I get this error: `The method teleport(Location) in the type Entity is not applicable for the arguments (Vector)`
i also cant use setVelocity because then it just doesnt teleport the armorstand
knotty meteor
#

Thank you! I will try it :D

#

Now when i try it in minecraft it doesnt teleport the armorstand, but the debug message works so if the code worked it should have teleported the armorstand

armorStand.teleport(armorStand.getLocation().getDirection().multiply(speed).toLocation(Bukkit.getWorld(armorStand.getLocation().getWorld().getName())));```
This is my code now, and i get no errors now
manic delta
#

Guys to convert this countdown timer to bukkit plugin (because I can't use while) i need to use one Runnable to Subtract the time right?

knotty meteor
#

armorStand.setRotation(player.getEyeLocation().getYaw(), player.getEyeLocation().getPitch());
Does someone know how i could do this on 1.12.2? Because armorstand setrotation doesnt work

quaint mantle
#

you look quite dapper in your profile picture 🧐

hexed hatch
#

Damn you’re not kidding

quaint mantle
#

ikr??

knotty meteor
#

Thank you

quaint mantle
#

no thank you bro

#

for pleasing my eyes, no homo

knotty meteor
#

haha no problem man

maiden acorn
#

Okay, I see the HeightMap type in the Spigot API, but I'm not sure how to obtain a HeightMap for a particular chunk. Anybody know?

ivory sleet
#

I believe its mostly used as an argument for the api functions, not really something thats returned?

maiden thicket
#

can one use the data generators to generate a dimension codec?

echo basalt
#

pretty sure you can generate custom dimensions through packets 🤔

#

There was a plugin for it on 1.16.5

ancient plank
#

Math.

knotty meteor
#

When i try it in minecraft it doesnt teleport the armorstand, but a debug message works so if the code worked it should have teleported the armorstand

armorStand.teleport(armorStand.getLocation().getDirection().multiply(speed).toLocation(Bukkit.getWorld(armorStand.getLocation().getWorld().getName())));```
next zinc
#

Anyone know of a way to make custom player skulls in 1.18?

last sleet
#

whats the difference between itemstack.getEnchantments() and meta.getEnchants() ?

quaint mantle
#

how to loop in radius x of a location?

ivory sleet
knotty meteor
quaint mantle
#

to set a block to something at a location u have to create a new location right

#

is there any other way

quaint mantle
#

you can just use Entity#getWorld

sharp flare
#

and you don't have to handle nms shit

next zinc
#

Issue is one part of it is broken in 1.18

knotty meteor
#
public class ArmorstandMovement extends PacketAdapter {

    public ArmorstandMovement() {
        super(JavaPlugin.getPlugin(Main.class), ListenerPriority.HIGHEST,
                new PacketType[] { PacketType.Play.Client.STEER_VEHICLE });
    }
    public void onPacketReceiving(PacketEvent event) {
        Player player = event.getPlayer();
        PacketContainer packet = event.getPacket();
        Entity e = player.getVehicle();
        if (e instanceof ArmorStand) {
            ArmorStand armorStand = (ArmorStand) player.getVehicle();
            float forward = ((Float) packet.getFloat().read(1)).floatValue();
            float side = ((Float) packet.getFloat().read(0)).floatValue();
            armorStand.setHeadPose(new EulerAngle(player.getLocation().getDirection().getY() * -1.0, 0.0, 0.0));
            float speed = 1.2f;
            if (forward > 0.0f) {
                event.getPlayer().sendMessage("[debug] forwards");
                armorStand.teleport(armorStand.getLocation().getDirection().multiply(speed)
                        .toLocation(Bukkit.getWorld(armorStand.getWorld().getName())));
            } else if (forward < 0.0f) {
                event.getPlayer().sendMessage("[debug] backwards");
                armorStand.teleport(armorStand.getLocation().getDirection().multiply(speed)
                        .toLocation(Bukkit.getWorld(armorStand.getWorld().getName())));
            } else {
                final Vector f = armorStand.getLocation().getDirection().multiply(0.01F);
                armorStand.setVelocity(f);
            }
        }
    }
}```
This is the whole class, it sends the debug message when i press W or S but it doesnt teleport the armorstand
echo basalt
#

then you can't teleport it

#

you could set the gravity to true while moving

knotty meteor
#

Ooh alright thanks! Then i will do that

next zinc
# next zinc

Anyone know if anything can be done about this?

chilly fox
#

hyy there is a plugin BedWars1058 - OpenSource 22.3.4 which is open source can anyone please add 1.18.2 support in it?

manic delta
#

Guys to convert this countdown timer to spigot countdown plugin (because I can't use while) i need to use one Runnable to Subtract the time every 20L right?

chilly fox
#

if anyone can that will be so helpful

undone axleBOT
chilly fox
#

or can anyone just tell me how to import a plugin with source code in eclips?

manic delta
#

That's why i said runnable

manic delta
chilly fox
quaint mantle
#

are you using maven

chilly fox
quaint mantle
#

yes

ivory flume
#

as a modder from forge/fabric i normally use an Identifier/ResourceLocation for item ids

#

like, minecraft:diamond_axe would be for diamond axe

#

is there anything similar?

dusk flicker
#

NamespacedKey iirc

kind hatch
#

You mean part of spigot?

#

Pretty sure you can still use ResourceLocation if you use NMS.

#

But yea, NamespacedKey is part of the API.

ivory flume
#

i need a tutorial on NMS

dusk flicker
#

yeah good luck

ivory flume
#

i have it set up in my thing but i don't want to use it

#

like, is there mixin? no? then why do I care

dusk flicker
#

spigot is the api ontop of nms

ivory flume
#

yes

dusk flicker
#

so use that

ivory flume
#

i do use spigot

#

anyway, thanks for NamespacedKey

#

i was using Enum#name because the Material was an enum

quiet ice
#

Material might not be an enum for long. Do not rely on that behaviour

kindred valley
#

Do you have any tutorial about guis

quaint mantle
#

?guis

#

?gui

#

?inventoryapi

#

bad

quaint mantle
#

bruh

#

?guis

undone axleBOT
quaint mantle
#

Caused by: java.lang.NoClassDefFoundError: net/minecraft/world/entity/npc/Villager

#

how do i fix my project to get the latest buildtools stuff

dark arrow
#

i have created a bossbar for a mob but when there is more that 1 mob of that kind it justs confilcts instead of creating new bossbar?

dark arrow
#

How can i add attributes

crimson terrace
serene juniper
quiet ice
dark arrow
#

like strenght

safe notch
#

I think you need nms for that

crimson terrace
#

I usually just modify the EntityDamageByEntityEvent since I already have a setup for my mobs to be identified

#

alternatively you can apply potion effects

steel swan
#

hey, i am using hashmap to give each player an integer. Problem : when the player disconects and reconnects, the number is reset, how to solve that

blissful pumice
#

what do you do when a player leaves?

crimson terrace
#

I suppose the player instance wouldn't be the same when they reconnect, so using the player as a key is not the best thing

eternal needle
#

Hi my plugin does crash and i don't now what it is but it goes som hours and then it crash

crimson terrace
#

?paste

undone axleBOT
eternal needle
steel swan
# hybrid spoke use the UUID

so instead of :

public HashMap<Player, Team> team = new HashMap<Player, Team>();

I'd do

public HashMap<UUID, Team> team = new HashMap<UUID, Team>();
crimson terrace
eternal needle
crimson terrace
#

how big is your plugin? send some code you think might be crashing it in the paste thingy above

eternal needle
#

it's big

hybrid spoke
crimson terrace
#

probably some infinite loop

eternal needle
crimson terrace
#

of your server

eternal needle
#

i don,t even now if it's my plugin

earnest forum
#

there has to be an error if it crashes

hybrid spoke
#

send the logs

eternal needle
#

i can't bacus i am yusing multicraft and the logs is not readebel

earnest forum
#

look at console when the server crashes

#

something has to happen

eternal needle
#

ok

earnest forum
#

can you recreate the crash?

eternal needle
#

but it now that is a command that sends in consol in every 2 min /list but don't now how to disebel it

crimson terrace
#

how many lines is your plugin? if its like 200 lines I think its easier to read through the code

hybrid spoke
#

debug

hybrid spoke
#

remove every plugin until it doesnt crash anymore

#

start with your plugin

earnest forum
#

u might be able to disable it googlin something

eternal needle
#

ok

#

but i can't remove any plugins all is importen

earnest forum
#

well then find an error for us

#

we can't help you if we don't have any info

lost matrix
spring minnow
knotty meteor
#

Already tried that but then also nothing happens that

hybrid spoke
knotty meteor
#

Where? I didnt saw it

kindred valley
#

I need a guy who knows c++

#

I rly need

#

😎

daring lark
#
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.github.MilkBowl</groupId>
            <artifactId>VaultAPI</artifactId>
            <version>1.7</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>```
#

why am i can't use vault api?

#

i have some errors but everything should work fine

knotty meteor
#

armorStand.setRotation(player.getEyeLocation().getYaw(), player.getEyeLocation().getPitch());
Why isnt this working? I get this error
The method setRotation(float, float) is undefined for the type ArmorStand

low temple
#

Meaning the version in ur ide isn’t the same as the server

knotty meteor
#

But i mean i get the error in my ide

tender shard
#

I wonder what's the best way to parse console commands in my discord bot. I currently have a parseCommand(...) method. It's possible to run commands both from console (terminal) and of course through actual discord messages. But I'm wondering whether the "console" part should be inside my bootstrap main class or directly inside the bot's "main" class. This is my current bootstrap "main" class, which only creates the bot instance, and then listens for incoming input, I wonder if that's a good solution or not:

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

summer scroll
low temple
knotty meteor
#

Do you maybe know a alternative? Because my friend send this but i think he uses another version i use 1.12.2

low temple
#

Maybe set location?

summer scroll
#

Use the correct parameters

daring lark
tender shard
#

what's your version?

knotty meteor
#

Jep i use 1.12.2 😂
But the server i work on is 1.12.2 so i have no other choice

tender shard
daring lark
tender shard
#

basically clone the location of the armorstand, change pitch and yaw, then teleport it to the new location

knotty meteor
#

Aah alright, then i will do that, thank you!

tender shard
daring lark
#

what is it?

#

i mean

#

where i need to write it in my code or sth?

tender shard
#

then enter mvn clean package -U and hit enter/return

daring lark
#

i can't

quiet ice
#

Why

daring lark
#

i have stuff like tihs

hybrid spoke
tender shard
#

alrighty, then I'll keep it in the bootstrap class, thx

tender shard
daring lark
#

i can only edit configurations and run blockEconomy

tender shard
#

no, you can also just click the button I sent a screenshot of

daring lark
#

i clicked

tender shard
#

so what's the problem?

daring lark
tender shard
hybrid spoke
tender shard
hybrid spoke
#

fuck

dark arrow
#

i am unable to use nms packages even tho i have install the build tools.What to do?

eternal night
#

Did you declare it as a dependency ? 👀

dark arrow
#

like this

eternal night
#

you want the mojang mapped version no ?

daring lark
dark arrow
eternal night
tender shard
eternal night
#

follow the maven examples in the second post

dark arrow
#

ok

tender shard
daring lark
# daring lark i have exit code 1 not 0 so something is wrong
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
``` i have this error
eternal night
#

man is literally on a self promotion hustle 24/7

tender shard
tender shard
#

also did you just assume my gender? triggered

dark arrow
tender shard
#

ugh shit the squirrel came into my apartment again

eternal night
#

sorry for that image xD

tender shard
#

I have to make it leave brb

eternal night
#

not what I meant

earnest forum
#

mfnalex's blog >

hybrid spoke
summer scroll
#

How can I detect if player collide or bump into a wall?

tender shard
#

maybe there's better solution, if so, I don't know it yet

summer scroll
#

Damn, sounds so complicated

vocal cloud
#

Simple but expensive resource wise

tender shard
#

again related to JDA:

    public static void deleteMessage(Message message) {
        if (message != null) {
            new Thread(() -> {
                try {
                    message.delete().complete();
                } catch (Exception ignored) {

                }
            }).start();
        }
    }

Is there a better way of doing this? I cannot instantly delete the message because then it might throw an "Unknown Message" exception when the message was already deleted by other means. I have to use the blocking "complete()" instead of the async "queue()" method because otherwise I cannot catch the exception, so I wrapped it up in a thread myself

summer scroll
#

I need to deal with nms right? to get the bounding box

tender shard
#

no

#

that's API

#

someBlock.getBoundingBox()

#

someEntity.getBoundingBox()

#

then you can use BoundingBox#intersection or BoundingBox#overlaps (probably the first one is the only one that'll work)

#

the resulting boundingbox will probably have a width, height or length of 0, but at least ONE of those values will be a positive number

#

if yes, there's a collision

vocal cloud
summer scroll
tender shard
#

the reason why I ask this is that I have a config option "delete-command-messages" that can be true globally, so all command messages get deleted instantly. however, I also have some commands where I wanna delete the message, regardless of the global setting, so I am basically calling this method twice in some cases, yielding this exception :<

#

unfortunately there's a Message#delete() method, but no Message#isDeleted()

tender shard
hybrid spoke
#

by invoking queue() at the end

vocal cloud
hybrid spoke
midnight glen
#

Is there a CommandExecutedEvent?

#

I need to check if a command is targeted at players/entities in other worlds

tender shard
tender shard
tender shard
vocal cloud
#

The error part of queue doesn't catch the messagenotfound error?

tender shard
vocal cloud
#

It looks a bit nicer I imagine. Sadly I'm not sure there is any other way to do it

tender shard
#

yeah it does indeed look nicer lol

    public static void deleteMessage(@Nullable Message message) {
        if (message != null) {
            message.delete().queue(unused -> {}, throwable -> {});
        }
    }

and it works, too

#

I still don't like it, knowing that it will throw exceptoins in 50% of the time :/

prime kraken
#

Hello team ! How is it possible to do : I have a maximum click on block of 20 click. I would like to show in action bar how many time the player have clicked on the block, is it possible ?

chilly fox
tender shard
prime kraken
tender shard
#

you could create a Map that stores the amount of clicks per player and block

#

sth like
Map<Location,Map<UUID,Integer>>

earnest forum
#

i think uuid,map<location, integer>> is better

tender shard
#

doesn't really make a difference imho

prime kraken
#

thanks for your help

earnest forum
#

well you can easily access all of the player's clicked blocks

#

i guess the same could be said about the other weay

tender shard
#

yeah true, but from what they told, that's not needed

#

but yeah maybe they need it later, so yeah, doesn't really matter which way the maps are nested 😄

summer scroll
midnight glen
#

Is there any way to check if a command executed is targeted at a player from another dimension/world? I want to make so that @a only works on players in the same world

earnest forum
#

you can get both player's locations

#

and from that get the worlds

midnight glen
#

what if it is a command block?

earnest forum
#

you should be able to do the same thing

#

with the block

tender shard
midnight glen
#

what event do I use

earnest forum
#

no event

#

command executor

#

ive never done command block command support before

#

but commandsender should be an instanceof something that a commandblock is

#

it might have a special class CommandBlock

#

you could look into it

summer scroll
midnight glen
#

Is there a way to get the targeted players?

earnest forum
#

yeah with arguments

midnight glen
#

Let me explain what I need again

#

I want to check every time a command is run if the targeted players/entities are in a different dimension/world

#

I have trouble getting every command and finding the targets

earnest forum
#

do you know how to get arguments?

#

like /command <arg0> <arg1>

midnight glen
#

ik

earnest forum
#

you can do

#

Bukkit.getPlayer(arg[0])

#

if this is null

midnight glen
#

but different commands have different places for arguments

earnest forum
#

its not a player

summer scroll
tender shard
#

although I have no idea how, lol

summer scroll
#

How do you even see the blocks' bounding box?

prime kraken
earnest forum
#

theres no clicked block variable

tender shard
#

you are passing three arguments instead of two

tender shard
summer scroll
#

I was testing it with entity, and now with blocks it doesn't send anything.

tender shard
earnest forum
prime kraken
#

I will try

earnest forum
#

i think you meant to use block

tender shard
prime kraken
#

clickedBlock is my Map

earnest forum
#

m

#

mb

#

i am blind

summer scroll
earnest forum
#

whats not working

tender shard
#

it even says "exepcted 2 arguments" 😄

earnest forum
#

@prime kraken the second argument is a hashmap

#

theres no 3 arguments

tender shard
prime kraken
#

So how can i write ?

tender shard
undone axleBOT
earnest forum
#

if the player has a map assigned to them

#

1 sec

prime kraken
#

yeh

tender shard
#

send your code as text pls

#

?paste

undone axleBOT
prime kraken
#

yep

#

    @EventHandler
    public void actionBar(PlayerInteractEvent e){

        Player p = e.getPlayer();

        Block block = e.getClickedBlock();
        Location loc = e.getClickedBlock().getLocation().add(block.getY(), block.getX(), block.getZ());
        int clickedAmount = 0;

        if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().equals(Material.DIAMOND_BLOCK)){

            clickedBlock.put(p.getUniqueId(), loc, clickedAmount);

        }

    }
earnest forum
#

clickedBlock.put(p.getUniqueId(), clickedBlock.get(p.getUniqueId()).put(loc, clickedAmount);

#

sorry im playing a game rn cant explainw ell

prime kraken
#

yes don't worry i will try

summer scroll
tender shard
earnest forum
#

^

prime kraken
tender shard
summer scroll
tender shard
#

check the link I sent, and expand it to work with 3 dimensions instead of 2

#

oh wait

#

the link I sent is for overlapping, too

#

I googled "collide" and not "overlap" >.<

#

sorry I don't have time to write this out, but basically yo uhave to check if any of your minX, maxX, minY,minZ, ... is between the other boxes' minX,maxX, etc

#

and then do it for all three axis

#

e.g. collision is true when player's minX OR maxX is BETWEEN the block's minX and maxX, AND if the player's minY OR maxY is BETWEEN the block's minY and maxY, and same for Z

#

(not sure though lol)

#

yo @summer scroll

#

I have an alternative solution

#

that is extremely simple

#

enlarge the player's boundingbox by 0.0001 to EVERY side

#

now you can check if they overlap

summer scroll
#

okay

#

that could work

pearl glade
tender shard
#

isn't that exactly the same?

earnest forum
#

shorter

summer scroll
pearl glade
#

no beacause you put evertime in map so we add process

hybrid spoke
#

oh yeah, shorter always better

tender shard
summer scroll
#

thank so much

#

you're sexy

tender shard
#

np

#

I know, I'm waifu material

hybrid spoke
#

can you uwu for me?

tender shard
#

uwu :3

hybrid spoke
#

hot

tender shard
pearl glade
tender shard
#

fun fact: I once dated a guy, and... okay I better shut up

hybrid spoke
faint harbor
#

How can I get the "anvil uses" of an item. I cant find anything in the docs that seems relevant.

tender shard
faint harbor
#

ahh I see, thanks!

hybrid spoke
pearl glade
tender shard
earnest forum
#

that is beautiful

fossil lintel
#

What the

knotty meteor
hybrid spoke
#

not the players one

#

and well your goForward and goBackward methods are effectively the same

#

as well as goBackward is never invoked anywhere anyways

knotty meteor
#

Ooh yes i see
Now the direction flying works, but when im entering the armorstand i cant go forward at first, if i go backwards 1 time then i can go forward

grim ice
#

is it possible to turn a 1.17 Structure into a schematic

dark arrow
#

i am unable to use nms even i have installed the build tools and changed the repsotory pls help

sterile grotto
tender shard
#

why wtf? 😄 that project has rules: a maximum of 3 ; per line lol

#

and no contributor must change/add more than 25 lines in total (except for imports and package declaration)

#

so yeah lol

dark arrow
#

I only get errr if i tru to use nms package

sterile grotto
dark arrow
#

Nope

cold field
quaint mantle
#

Nope

#

Got database error

knotty meteor
#

rip spigot

sterile grotto
dark arrow
#

Yup

sterile grotto
#

and have you check those NMS libs been imported correctly?

tardy delta
#

new ItemStack(Material.WAIFU)

dark arrow
dark arrow
sterile grotto
dark arrow
#

Sure

#

?paste

undone axleBOT
sterile grotto
#
 <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <classifier>remapped-mojang</classifier>
        </dependency>
#

like this one

dark arrow
#

so i should replace it with the old one?

sterile grotto
#

<classifier>remapped-mojang</classifier>try add this line down below the <scope>provided</scope>

dark arrow
#

ok

sterile grotto
dark arrow
#

Could not resolve dependencies for project me.Sammu212:CustomBossssssss:jar:1.0-SNAPSHOT: org.spigotmc:spigot:jar:remapped-mojang:1.18.2-R0.1-SNAPSHOT was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during

#

i dont think it could find the mojang remapped there

kind hatch
sterile grotto
#

yes you need to do that

dark arrow
#

how?

tardy delta
#

java -jar BuildTools.jar --remapped or smth

#

?

karmic void
dark arrow
#

ok it started

#

hope it works

sterile grotto
#

the post on spigotmc can't be access right now

kind hatch
#

java -jar BuildTools.jar —rev 1.18.2 —remapped

dark arrow
#

what to do

kind hatch
#

Well if you don’t specify a version it will default to the latest build anyways.

dark arrow
#

ohk

#

i got scared

#

i wanted to do for latest only

#

java -jar BuildTools.jar --remapped

#

it completed

dark arrow
sterile grotto
#

if you can means NMS worked

dark arrow
#

nope i cant

sterile grotto
sterile grotto
dark arrow
sterile grotto
#

it should has libs like this

dark arrow
#

there is a spigot api library but i dont think its useful

sterile grotto
#

then you should try reboot your IDEA or rebuild your maven project

dark arrow
#

hmm

#

i used minecraft devlopment plugin to create project

#

will that effect?

sterile grotto
#

which kind of plugin, IDEA's plugin?

dark arrow
#

yah

#

a plugin in intelligi

sterile grotto
#

I don't think that would affect your NMS package using or importing

noble lantern
#

did you 100% run build tools with the --remapped option in the command line

#

i got a similar error when doing that myself

#

and my issue was i ran build tools without the remapped option

sage merlin
#

for some reason my death is not getting registered even tho i got killed by someone

sterile grotto
sage merlin
#

on line 64 im subtracting the death count by 1 when the player is killed by another player

#

but for some reason my death does not get registered tested it twice

tender shard
#

intellij or maven doesn't randomly break for some people

sage merlin
tardy delta
#

👻

prime kraken
#

Hello ! I have one class with all my arrayList, i use these arrayList in different other class, I would like to check when i click on an item, if the player is already in a arrayList (UUID) if it is not, put in the specific ArrayList(associate to the item..), Is there any fast method to check that ? Is it possible to use a switch ?

fast path
#

contains?

tardy delta
#

use a HashSet, it wont allow duplicates and you can try Set#add and it will return true if it could be added

#

Set<UUID> ye

fast path
#

I am not sure about what you told.

prime kraken
sterile grotto
tardy delta
#

anyways is it possible to have a gui, made in C# code, which communicates with java code?

prime kraken
# fast path I am not sure about what you told.

My english is bad x) For exemple, I have 20 arraysList like public static ArrayList<UUID> kit1 = new ArrayList<>(); in a specific java class, i would like in a InventoryClickEvent check if the player is in one of 20 arrays list and if it's not in one, put in a specific

fast path
#

oh

#

then you can use HashMap<String,List<UUID>>

#

Map<String,List<UUID>> listMap=new HashMap<>(){{
put("type",new ArrayList<>());
}};

sterile grotto
fast path
#

and when you want to use do listMap.get("type").contains //check
and when you want to use do listMap.get("type").add //add

prime kraken
fast path
#

just try it

tardy delta
#

memory leaks go brr

fast path
#

lol

tardy delta
#

and it looks ugly too

prime kraken
#

xDDD

fast path
#

if you think it looks ugly

tardy delta
fast path
#

you can use enum instead string

hybrid spoke
fast path
#

so you don't need worry about memory leak

tender shard
#

I actually don't understand your question in the first place

fast path
tardy delta
#

a static block exists for a reason

fast path
tardy delta
tender shard
#

also pls do not ping me unless you're replying to any of my messages

hybrid spoke
#

@tender shard a_COOL

tender shard
fast path
#

lmao

boreal sparrow
#

How do I save a player's inventory when they leave (im using PlayerQuitEvent), and reload it later when the join back?

tardy delta
#

save the contents to a file or database or somthing

tender shard
#

there's a reason why I don't like useless pings

tardy delta
#

one tag more or less :p

tender shard
#

they automatically get their inventory back when they join

fast path
#

yeah

sterile grotto
safe notch
#

serializing items would be a better idea tbh

tardy delta
#

Itemstack is configurationserializable

#

that was a long word smh

safe notch
#

lol ye

sterile grotto
fast path
#
    public static String toYML(ItemStack i) {
        YamlConfiguration yml = new YamlConfiguration();
        yml.set("i", i);
        return yml.saveToString();
    }

    public static ItemStack fromYML(String s) {
        YamlConfiguration yml = new YamlConfiguration();
        try {
            yml.loadFromString(s);
        } catch (InvalidConfigurationException e) {
            e.printStackTrace();
        }
        return yml.getItemStack("i");
    }

    public static String convertItemStackToString(ItemStack what) {
        return Base64.encode(toYML(what));
    }

    public static ItemStack convertStringToItemStack(String data) {
        return fromYML(Base64.decode(data));
    }

    public static String convertItemStackArrayToString(ItemStack[] what) {
        List<String> r = new ArrayList<>();
        for (ItemStack i : what) r.add(toYML(i));
        return Base64.encode(StringUtils.join(r, "(ITEM)"));
    }

    public static ItemStack[] convertStringToItemStackArray(String data) {
        return Arrays.stream(Base64.decode(data).split(Pattern.quote("(ITEM)"), -1)).map(ItemStackSerializer::fromYML).toList().toArray(new ItemStack[0]);
    }
tardy delta
#

loop over the contents lol

sterile grotto
#

so if you wanna store item you need to store them one by one

hybrid spoke
#

?paste

undone axleBOT
dark arrow
fast path
#
public class Base64 {
    public static String encode(String s) {
        return java.util.Base64.getEncoder().encodeToString(s.getBytes());
    }

    public static String decode(String s) {
        return new String(java.util.Base64.getDecoder().decode(s));
    }
}
#

Try this

tardy delta
#

base64 takes so much place in a file

#

i got like 2 itemstacks and a bunch of nulls and it took 10 lines

fast path
#

It in a single line

safe notch
#

I stored an entire inventory once as a single line and it took 5000 char 💀