#help-development

1 messages · Page 2057 of 1

solid forge
#

and multimap should be the one you are looking for

tender shard
#

ah okay, but MultiMap returns a collection

glass mauve
#

isnt it multiple values for one key?

tender shard
#

so a MultiMap is nothing more than a Map<K,Collection<V>> I guess

solid forge
#

idk

#

seldom used it

tender shard
#

and yeah Multimap isn't even a Map

#

so I don't have to worry about it :3

tender shard
solid forge
#

bump
is the registerintent and completeintent in bungeecord async or sync?

tender shard
#

but it doesn't implement Map anyway so I can just ignore it

#

but for real, why would someone store null<>something in a map

#

did you ever see that in real life?

#

I mean I understand null as values, but null as key? why?

glass mauve
#

null as key makes no sense lol

tender shard
#

yeah exactly lol

solid forge
#

just like the whole idea of NFT ooooooooo

tender shard
#

I'll just throw a RuntimeException when someone uses null as key

#

and if they use null as value and the map doesn't support it, so be it, then it's their problem

solid forge
#

can just use an optional wrapper for it?

tender shard
#

nah you don't know what I'm doing, one second

#

this allows you to pass any kind of Supplier<Map> to use it inside a PersistentDataContainer

#

people might now save a HashMap which allows null into a PDC

#

then later they read it again using aTreeMap, which does not support null

#

I don't know whether the map they passed supports null as values, though

#

since everything's 100% generic

solid forge
#

doesnt treemap support null as value tho

#

and man that was trippy

tender shard
#

someone above mentioned that it doesn't

#

I haven't checked it

#

but yeah if someone saves a map with null and then loads it again as a map that doesn't support that, it's their own fault anyway, so I shouldn't worry about it

#

does someone know whether I can get rid of the ugly (Class<C>) cast in the 4th line from the bottom?

public class CollectionDataType<C extends Collection<D>, D> implements PersistentDataType<PersistentDataContainer, C> {

    private static final String E_NOT_A_COLLECTION = "Not a collection.";
    private static final NamespacedKey KEY_SIZE = getValueKey("s");

    private final Supplier<? extends C> collectionSupplier;
    private final Class<C> collectionClazz;
    private final PersistentDataType<?, D> dataType;

    public CollectionDataType(@NotNull final Supplier<C> collectionSupplier,
                              @NonNull final PersistentDataType<?, D> dataType) {
        this.collectionClazz = (Class<C>) collectionSupplier.get().getClass();
        this.collectionSupplier = collectionSupplier;
        this.dataType = dataType;
    }
fluid cypress
#

any idea how to supress this specific warning? how does the minecraft dev plugin do it when it creates all the boilerplate?

crisp steeple
#

@SupressWarnings("unused")

fluid cypress
#

i mean, without modifying the source

#

something inside the .idea folder maybe idk

tender shard
#

it adds everything extending JavaPlugin to the Entry Points

#

probably

fluid cypress
#

mmm that sounds like what i want, where is that entry points stuff?

#

i know almost nothing about java in general so

tender shard
#

but once you have a plugin.yml referencing that class, IntelliJ should be able to detect it itself

tender shard
#

then click on Add as Entry Point

fluid cypress
#

my eyes

#

it adds this <pattern value="io.github.misdocumeno.test.Test" /> inside a component tag in the .idea/misc.xml file

#

so thats what i need i think

#

thanks

tender shard
#

np 🙂

#

why this annotation not allowed here

sharp flare
#

how do I make two checks at the same time with Player interact event, mainhand becomes air when off hand check is being done during the second fire
NVM I was consuming the item in the mainhand

glass mauve
tender shard
glass mauve
#

hm I only know the method way

#

hm it should work

tender shard
#

yeah, they also say it should work, that's why I am confused lol

glass mauve
#

bruh maybe problem with IntelliJ

tender shard
#

I just used //noinspection comment now

#

but I'd rather use the annotation

crisp steeple
#

it works for me

tender shard
#

weird

glass mauve
#

restart IntelliJ 😄

tender shard
#

oh wait

#

it's probably

#

because I am not assigning a local var

#

it's a field assignment

glass mauve
#

yea

tender shard
#

not working

crisp steeple
tender shard
#

working but still showing a warning

crisp steeple
#

think its because using this.thing = thing isnt technically a local variable

tender shard
#

yeah I'll have to use the ugly //noinspection

glass mauve
#

oof

maiden thicket
#

the light

#

it burns my eyes 😟

glass mauve
#

white mode is actually better for your eyes, but I still will use dark mode

tender shard
#

I switch between light and dark mode every other day

#

sometimes I like the light mode, sometimes I don't

#

ugh FML

#

I just spent 20 minutes adding "null" support to my lib for PDC stuff

buoyant viper
tender shard
#

then I realized it's not needed to keep track of null values

buoyant viper
#

wait nvm there is visual studio light mode

tender shard
#

I just must not save them, reading non-existant keys returns null anyway >.<

sharp bough
#

is there a better way of doing this check?
if (Math.max(abs(loc0.getBlockX()), abs(loc1.getBlockX())) - Math.min(abs(loc0.getBlockX()), abs(loc1.getBlockX())) == 1){

tender shard
#

what is that even supposed to do?

sharp bough
#

get the diff of the absolute values of two X coordinates

#
public boolean locsAreAdjacent(Location loc0, Location loc1){
        if (Math.max(abs(loc0.getBlockX()), abs(loc1.getBlockX())) - Math.min(abs(loc0.getBlockX()), abs(loc1.getBlockX())) == 1){
            System.out.println("diff is 1");
        }
        // same for Y and Z if theres two 0 and one 1 then block is adjacent 
        return false;
    }
#

something like that

tender shard
glass mauve
#

yea thats the same

sharp bough
#

nah nvm im just gonna keep what i did

glass mauve
#

y

sharp bough
#

it just looks ugly

tender shard
#

your version is so complicated

#

I don't even understand what you're doing there

#

just do x1 - x2 and then turn it positive if it's negative

#

done

glass mauve
#

just do:
if (Math.abs(loc0.getBlockX() - loc1.getBlockX()))

tender shard
#

no need for Math.min or Math.max etc

#

yeah

sharp bough
#

that would fail if locations are -20 -21

tender shard
#

no

glass mauve
#

no

tender shard
#

it would return 1

#

which is correct

#

-20 - (-21) = 1

sharp bough
#

what abt -20 21

glass mauve
#

and -21 - (-20) = -1 and Math.abs(-1) = 1

sharp bough
#

it would return 40

tender shard
#

that's why we put it inside Math.abs

#

so it would also return 1

sharp bough
#

-20 - 21

tender shard
#

guess what: also 1

#

your code is bloated and prone to error, the code we sent will work 100% guaranteed

tender shard
glass mauve
tender shard
#

into Math.abs = 1

tender shard
glass mauve
#

yea, still works

tender shard
#

it will work in every possible case

#

I also don't get why they ask "is there a better way", then we tell a way better way and then they just say "ugh I'll just stick to my weird version"

#

why did they ask then, anyway

glass mauve
#

lol

#

idk

sharp bough
#

relax

#

i was testing

#

and you were right

glass mauve
#

😄

tender shard
#

yes of course, it's basic math 😛

#

my brain hurts from too much java generics

glass mauve
#

yea normal

manic furnace
#

How can I make spigot show the entire exception, and not 21 more......

hexed hatch
#

What do you mean?

manic furnace
#

Spigot cuts of a part of the error message

river oracle
manic furnace
#

But i need that below

river oracle
#

do you really 🙂

#

are you positive

manic furnace
#

Yes sadly

river oracle
#

send stacktrace

manic furnace
river oracle
#

TestParticleCommand.java:20

#

at.theduggy.deutsch_diewolke.TestParticleCommand.onCommand(TestParticleCommand.java:20)

manic furnace
#

Yes but ther I use the instance of an class and where the error in this class is isn't shown

river oracle
#

code?

manic furnace
#

package at.theduggy.projekt;

import at.theduggy.projekt.Animation.Animation;
import at.theduggy.projekt.npc.NPC;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.Random;
import java.util.UUID;

public class TestParticleCommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
    NPC npc = new NPC(player.getLocation(), UUID.randomUUID(), new Random(1000).nextInt(), "Typ");
    return false;
}

}

river oracle
#

is NPC your class?

manic furnace
#

Yes

river oracle
#

have you checked latest.log

manic furnace
#

There is the same, isn' it

river oracle
#

idk

#

look

manic furnace
#

Normally it is

river oracle
#

no harm in looking

manic furnace
#

I am not at home lol

river oracle
#

what is "Typ" supposed to mean

#

is that like a name

manic furnace
#

Yes

#

The random thing is the entity id

waxen plinth
#

🤨

river oracle
#

maths

glass mauve
#

no he mean x=-20 x2=-21 and then x-x2

#

so -20-(-21)

waxen plinth
#

-20 - -21

#

ok

young knoll
#

(-20) - (-21)

waxen plinth
#

lua is strange lol

#

lets you use -- on a literal

#

Oh wait

#

I know why

#

It's because -- is for comments in lua lmao

#

So it interprets -20 and then the rest of the line is seen as a comment

glass mauve
#

xD

waxen plinth
#

Still my favorite repl for doing math

#

Because

#

In python you gotta use ** but in lua it's ^

glass mauve
#

^ in python is bitwise xor I think

waxen plinth
#

It is

#

Same in java

#

Which is fine for programming but when I'm doing math I want ^ to be exponentiation

warm light
#

A mob drop a custom itemstack. and I added a NBT to that itemstack. but when I pick that itemstack, NBT removed

river oracle
waxen plinth
#

Lua is a nice language

#

It has its quirks

glass mauve
waxen plinth
#

But I actually like it more than python because it's at least got consistent design and is significantly faster

#

Dynamic typing and arrays starting at 1 are both still bad though

#

But technically lua has no arrays, only tables

#

I really don't use it these days except doing math in the repl

young knoll
#

LUA uses -- for comments?

#

That’s very awkward

waxen plinth
#

Yeah

#

I mean not really

#

I don't think it has ++

#

Nor += actually

waxen plinth
#

You gotta do a = a + 1

#

Can't do a += 1 or a++

glass mauve
#

oof also bad

waxen plinth
#

Say what you want but lua is a very easy language to implement

glass mauve
#

I never used lua or

waxen plinth
#

It's got very few keywords, very simple syntax, and is very fast compared to most scripting languages

#

It has easy interop with C/C++

#

And it's pretty damn flexible for what it is

#

It's not OOP but you can recreate OOP behavior with it

waxen plinth
#

?paste

undone axleBOT
nimble torrent
#

is there a way to hide a command from autocomplete and make it look like its an unknown command

waxen plinth
#

Commands should act this way if the sender doesn't have permission by default

nimble torrent
#

how do i make a command have permissions?

waxen plinth
#

Or at least, they shouldn't appear as a tab completion if the sender doesn't have permission

#
commands:
  example:
    permission: permission.node.here```
nimble torrent
#

mk

#

ill try it

glass mauve
#

In this episode of the Spigot Tutorial series, I show you how to work with permissions. It is actually super simple and will allow your plugin to have some more functionality. With this feature you can limit players to have access to certain commands.

This episodes code: https://snippets.cacher.io/snippet/b1f557dd90cdd2502bf3

⭐ Kite is a free...

▶ Play video
waxen plinth
#

I wouldn't bother with the default commands though

#

They suck

#

I guess if you're a beginner you should learn how to use it

#

But as soon as you understand it and feel comfortable with it you should abandon it in favor of a framework

warm light
#

and i checkd it here

waxen plinth
#

You're adding LivingEntityHead.BEE

#

Not the item you created and modified

warm light
#

I tried this. still same

waxen plinth
#

Ok again you're adding the original item, not the modified one

warm light
#

.-.

waxen plinth
#

rename probably returns a new item rather than modifying the instance you gave it

crisp steeple
waxen plinth
#

I don't know where Itemstack is defined though

#

VERY poorly named since it's easily confused with ItemStack

nimble torrent
waxen plinth
#

Why would you ever want that

#

Just set up a proper permissions plugin

#

Set up luckperms

#

Or op yourself lol

warm light
#

Itemstack.rename working fine. problem with NBT

waxen plinth
#

Don't make backdoors

waxen plinth
#

It's that you're creating an NBTItem and then doing nothing with it

#

You're applying a property and then you don't even use it

nimble torrent
waxen plinth
#

Tell the owner to stop being dumb

#

And use a permission plugin

nimble torrent
#

ok

waxen plinth
#

There is no reason to create user-specific backdoors

nimble torrent
#

waht is a backdoor

crisp steeple
#

@warm light can you show where the code for LivingEntityHead.BEE is?

waxen plinth
#

A hidden bypass

nimble torrent
#

oh like popbob

warm light
#

Already fixed. I am dumb

waxen plinth
#

The issue is that you are creating an NBTItem, setting a property on it, and then doing nothing with it

warm light
#

have to use getItem() there

waxen plinth
#

Yes

#

I'm not familiar with the NBT API

#

But it makes sense that you have to get the modified item from it

#

I wouldn't expect it to mutate the item it's constructed with

crisp steeple
waxen plinth
#

It won't if you're creating copies

crisp steeple
#

Doesn’t look like it is though

waxen plinth
#

It looks like rename might

#

But NBTItem doesn't

#

I'm guessing Itemstack.rename is something they made themselves because it's poorly-named with bad default behavior

crisp steeple
#

Even if rename does though it’s not getting stored in a new variable

waxen plinth
#

I would recommend renaming it to something like ItemUtils and having it return a copy of the item with the new name rather than renaming the instance that's passed

warm light
#

okay

waxen plinth
#

Yeah if you change this behavior then you'd need to call rename and then store the return value

warm light
#

it don't return anything just get itemstack from input and rename it

waxen plinth
#

Yeah and I'm telling you to not do that

#
public static ItemStack rename(ItemStack item, String name) {
  item = item.clone();
  ItemMeta meta = item.getItemMeta();
  meta.setDisplayName(name);
  item.setItemMeta(meta);
  return item;
}```
#

Then you'd do something like this

#
ItemStack something; // assume this is populated
something = ItemUtils.rename(something, "name here"); // creates a copy of the item with the given name```
#

Pure function

warm light
#

okay. thanks :D

waxen plinth
#

👍

#

In general you should try to write your utility functions so that they take in values and return other values without modifying the input

#

If a function doesn't modify its input or any sort of internal or global state, then it's called a "pure function"

#

They're preferable because side effects (modifying parameters and state) make things more complicated and are harder to test

neon nymph
#

Is it wise to save every player who ever entered the server into my cache (concurrent hashmap)? I'm debating whether I should load every playerdata from my database on server startup or just retrieve them at the time they're needed or called

young knoll
#

Retrieve them when they join

neon nymph
#

Yea, that's what I'm doing, then I save it to my database after a specified amount of time. Then in the next startup, should I preload their data from the database or just retrieve it again on their join or when it's called (used in commands and such)?

young knoll
#

Join

modern valley
#

how do I make a data folder for the plugin?

young knoll
#

plugin.getDataFolder().mkdir()

modern valley
#

ohk

#

Is the name of the data folder same as the name in plugin.yml?

young knoll
#

Yes

#

Might be all lowercase, don’t remember

modern valley
#

tysm 😄

modern vigil
#

It's the exact same

#

It doesn't make any letter lowercase

modern valley
#

ohk

sand vector
#

Anyone know how to integrate a cache for playerdata with mongodb. I want to have easy access to variables but I can't seem to find anything that looks remotely correct.

#

If you know how let me know or send me in a direction so I can learn myself. (@ me if answering to me tia)

modern valley
#

how do I make my own inventory like ender chest?

#

?

summer scroll
modern valley
#

can someone give me a example of how to use the set_contents and get_contents of an Inventory?

granite burrow
#

why does this not work?

        ItemStack minerHead = new ItemStack(Material.PLAYER_HEAD);
        SkullMeta skullMeta = (SkullMeta) minerHead.getItemMeta();
        skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString("4e94f45c-759c-4293-af16-fdf219237a5d")));
        minerHead.setItemMeta(skullMeta);

The head just defaults to a steve or alex. The player never joined the server I dont know if thats an issue


The only way it works is with

        ItemStack minerHead = new ItemStack(Material.PLAYER_HEAD);
        SkullMeta skullMeta = (SkullMeta) minerHead.getItemMeta();
        skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer("Miner"));
        minerHead.setItemMeta(skullMeta);

but getting offline player by string is depreciated

glossy venture
#

idk u sure you have the right uuid?

granite burrow
glossy venture
#

weird what version are you on?

granite burrow
#

Im in 1.18 but developing for 1.16
API version is 1.16

glossy venture
#

idk why it happens then

granite burrow
#

Yeah, I just tried to get the name of the player by doing

Bukkit.getOfflinePlayer(UUID.fromString("4e94f45c-759c-4293-af16-fdf219237a5d")).getName();

And it just returned null

prisma needle
#

Running Multiple MySQL Statements slowing down server

warm light
#

is there anyway to find var with name from another class?

cosmic pelican
#
public class BigBalls {
    static class balls {
        
        public static String A = "";
        public static String B = "";
        public static String C = "";
        public static String D = "";
        public static String E = "";
        public static String F = "";
        public static String G = "";
        
        static {
            A = "true";
            B = "true";
            C = "true";
            D = "true";
            E = "true";
            F = "true";
            G = "true";
            
            if (Boolean.parseBoolean(A)) {
                if (Boolean.parseBoolean(B)) {
                    if (Boolean.parseBoolean(C)) {
                        if (Boolean.parseBoolean(D)) {
                            if (Boolean.parseBoolean(E)) {
                                if (Boolean.parseBoolean(F)) {
                                    if (Boolean.parseBoolean(G)) {
                                        System.out.println("Hello!");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            
        }
    }
}
#

someone rate the code

#

thanks

warm light
#

Guess I have class name a and in that class, I have a public static var named RRS. now I have to access that var in b class. but not like a.RRS. something like a.valueof("RRS"). how to do that?

cosmic pelican
#

Why do you want to do that

cosmic pelican
#

you know Material is an enum

#

right

warm light
#

yes

cosmic pelican
#

it's not a variable

#

create an enum

#

Man it all started 8 years ago... I have been developing that for so long. It's my masterpiece.

#

💀

#

Nah wanna see something ACTUALLY cool though?!

#

Igh hol' up I'mma send you a friend req

#

lucky man

cosmic pelican
#

You are correct my friend

echo basalt
#

always am :)

cosmic pelican
#

I'd beg to differ

#

no one is right 100% of the time

crimson terrace
#

when a command is added by a different plugin from yours, can you still call it with the dispatchCommand()?

crimson terrace
#

nice thanks

chrome beacon
#

Why would ou want that...

crimson terrace
#

aside from the fact that you shouldnt do that

#

that is called a "Virus"

cosmic pelican
#

thanks

#

if you do some hacky stuff with packets you can crash their client

glossy venture
#

i bet intellij will cover that entire block in warnings

cosmic pelican
#

0 warnings

chrome beacon
glossy venture
cosmic pelican
#

yes you cant do that through a plugin

#

just make a program, send it to them, and tell them to run it.

chrome beacon
#

You can do it through a plugin

crimson terrace
#

System.exit(0) lol

cosmic pelican
#

not the server

chrome beacon
#

We won't help you with that

glossy venture
#

explode their cpu

crimson terrace
#

misread as "turn off server"

cosmic pelican
#

all good

glossy venture
#
List<Double> list = new ArrayList<>();
double i = 0;
while (true) {
  list.add(Math.sin(Math.sqrt(i));
  i += new Random().nextDouble(0, 3);
}
#

explode cpu

chrome beacon
#

That will just cause the server to freeze and kill itself

glossy venture
#

true

#

but if you allocate all memory to the server it might freeze the system

glossy venture
#

oh yeah too fast

cosmic pelican
#

what

crimson terrace
#

"CPU Ouch" i believe its called. run it asynchronosly

cosmic pelican
#

array lists are pretty slow for adding

#

wdym

glossy venture
#

now it has to look up the methods in the vtable

cosmic pelican
#

List is just better practice

glossy venture
#

i mean that using the implementation allows for non virtual calls

#

which mean they dont have to be looked up in a vtable

#

i mean it might still need to do that because ArrayList is not final

cosmic pelican
#

The Liskov Substitution Principle states that any subclass object should be substitutable for the superclass object from which it is derived. This semantic relationship often called behavioral subtyping, is applied to develop more correct, extendable, and reusable software.

ivory sleet
#

I mean ArrayList can be pretty fast as long as you’re not using millions of elements

glossy venture
#

yeah yeah yeah i know

cosmic pelican
ivory sleet
#

uh not really

#

LinkedList also allows for index based access

glossy venture
#

i like to do

ArrayList<V> linear;
HashMap<K, V> mapped;
ivory sleet
#

Yes but HashSet presupposes few hash collisions as possible if you want it to be truly fast

glossy venture
#

for anything that needs to be iterated over but also needs quick lookups

cosmic pelican
#

ArrayList is slower than a LinkedList

ivory sleet
#

In terms of?

#

because that’s not always true

cosmic pelican
ivory sleet
#

Iteration is faster

#

Not necessarily

cosmic pelican
#

yes.

ivory sleet
#

no lol

cosmic pelican
#

an ArrayList needs to free up space in the array for an element

glossy venture
#

like if i need to iterate over something but also need fast lookups

#

usually derive the key from the value

#

like an identified object

ivory sleet
#

If you set the initial capacity, no resizing has to be done as long as the initial capacity isn’t exceeded

cosmic pelican
ivory sleet
#

But even then resizing is extremely fast since it uses system::copyarray which is natively implemented

glossy venture
#

thats why i add an array list for linear shit

#

like in one object

cosmic pelican
#

If you know the size there is no point

ivory sleet
maiden thicket
#

wat

ivory sleet
#

no that’s not what it’s about

glossy venture
#

iteration, getting by index

ivory sleet
#

Initial capacity is a good pre-optimization

glossy venture
#

anything that needs to be ordered

maiden thicket
#

oh for hashmaps getting by index?

ivory sleet
#

If you know approximately the amount of elements the array list will have on average

glossy venture
#

and then do

public void register(Identifiable it) {
  mapped.put(it.getIdentifier(), it);
  linear.add(it);
}
ivory sleet
#

Then setting initial capacity can reduce conceivable resizing operations you might have to go through

glossy venture
#

neglecatble and if i need to iterate over something its much faster

cosmic pelican
#

LinkedList internally maintains doubly-linked lists which store the memory address of previous and next object, so there will be no kind of structure which will keep memory address of the previous node and next node. There is no initial capacity defined for LinkedList, and it is not implementing a RandomAccess interface. LinkedList is faster than ArrayList while inserting and deleting elements, but it is slow while fetching each element.

glossy venture
#

arent ordered

#

theyre sets so they dont retain order

cosmic pelican
#

@faint sage would do better in this conversation than I would but he's offline atm.

maiden thicket
ivory sleet
cosmic pelican
glossy venture
#

that exists?

ivory sleet
#

Bruh

glossy venture
#

ah lmfao

ivory sleet
#

Like, I already told you

#

ArrayList can be faster than LinkedList if you have set the initial capacity

#

Literally

cosmic pelican
#

and when it goes past that initial capacity it isn't

ivory sleet
#

Yes but to some extent if you’re reasonable you’ll be able to predict it thus array list is reasonable even if you add and remove elements frequently

#

And also insertion by index is quite fast for ArrayList

glossy venture
#

it stores the nodes anyway

#

so it really doesnt save memory

#

saves like 4 bytes per pair

#

for the size

maiden thicket
#

why do you store two collections again

#

for sorting purposes?

glossy venture
#

for linear, ordered access and fast lookup access

cosmic pelican
maiden thicket
glossy venture
#

?

#

im not sorting anything

maiden thicket
#

u want ordered access

#

so just sort

glossy venture
#

thats not possible with only a hashmap

maiden thicket
#

u can sort a hashmap iirc

ivory sleet
hybrid spoke
glossy venture
#

otherwise each time i want to iterate over it i have to resort the entire thing in a stream

maiden thicket
#

its maybe more painful

hybrid spoke
#

it really depends on the usecase which one you should prefer

maiden thicket
#

i swear i sorted a non linked one before

#

lol

glossy venture
#

no you cant

#

a non linked one doesnt retain order

cosmic pelican
hybrid spoke
glossy venture
#

isnt that O(log(n))

cosmic pelican
maiden thicket
glossy venture
#

but whatever the memory 'save' is neglectable

cosmic pelican
ivory sleet
#

LinkedHashMap is sort by value with a linked data structure order (can be both by access and by insertion), TreeMap is sort by key with a tree structure order (ofc it’s possible to still sort by value)

#

Actually it might be the other way around

maiden thicket
#

ive never touched linked anything cus tbf ion know how they work loll

#

or why u would use them

ivory sleet
#

Mye it’s the damn other way around

maiden thicket
#

yes i dont get why that has to do anything with the fact i dont use linked shit

hybrid spoke
#

manager

maiden thicket
#

also that yeah

#

not a lead developer meaning im leading a team in development lol

grim ice
#

btw

#

arent ArrayLists

#

just HashMap<Integer, V>

crimson terrace
#

i think theyre Arrays which get extended or something like that

ivory sleet
#

Nah 2Hex

#

All the integer keys in an ArrayList must be positive natural numbers where each number is consecutive

#

and it uses int not Integer :3

unreal quartz
#

ArrayList is an array which gets copied over into a bigger one when it is full, HashMap uses linked list buckets identified by the hashcode of entries to store its values

ivory sleet
#

I mean HashMap also has a backing array

quiet ice
#

And ConcurrentHashMap uses a tree map afaik

#

Or at least something like that

glass mauve
#

is there any method for Arrays to count the null values, like stringArray.count(null); smth like that

unreal quartz
glass mauve
#

I couldnt find it

unreal quartz
#

Collections.frequency also exists

glass mauve
#

How can I check if an element is in both lists,
For example:
List<Integer> list1 // 1, 3, 6, 2
List<Integer> list2 // 7, 9, 5, 3
it should return true because 3 is in both lists

young knoll
#

.contains on both lists?

glass mauve
#

not really I dont want to search for a specific value, I want to know if there is any Integer in both lists

#

so the number of duplicates

echo granite
glass mauve
#

no thats not what I want

echo granite
echo granite
glass mauve
#

yes but not the numbers that are duplicates, instead I want the number of duplicates, so in the example 1 because there is one duplicate

echo granite
#

So you want to check whether there's at least 1 duplicate?

glass mauve
#

yea

echo granite
#

one sec

#

Use Collections.disjoint(list1, list2)

glass mauve
#

ok

#

weird name

echo granite
#

It's a helper method in java.util

glass mauve
#

ok let me test that

echo granite
#

Returns true if the two specified collections have no elements in common.

#

from the docs ^

glass mauve
#

ok thats what I wanted 😄

echo granite
#

🙂

#

Collections offers many more helper methods

modern valley
#

how do I set custom texture for a custom item?

young knoll
#

ItemMeta#setCustomModelData

limber owl
#

How can I make stationary water in 1.18.2?

tardy delta
#

and then use a resource pack

echo basalt
limber owl
warm light
#

why this is a string -_-

limber owl
#

i think it returns for e.g. "r1.18.2"

warm light
#

r?

#

r means?

limber owl
#

idk

warm light
#

but how to get server version then?

summer scroll
sage dragon
#

Hey,

How would I overwrite the bukkit permission system?

In java 8 times, I'd just replace the perm field with a custom one, but I can't do that with Java 17, because it's final

warm light
#

if (server version >= 1.14.4){
register a event
}

summer scroll
worn tundra
warm light
summer scroll
#

Oh you want to check If the version is greater or equals than

warm light
#

Yes

summer scroll
#

There is no easy way, you need to get around with the value from Bukkit#getVersion

warm light
#

thats also string

summer scroll
sage dragon
summer scroll
#

And the example usage

    public static void registerBlockTracker() {
        if (McVersion.isAtLeast(1, 16, 3)) {
            Bukkit.getPluginManager().registerEvents(new BlockTrackListener(), main);
        } else {
            main.getLogger().info("You are using an MC version below 1.16.3 - Block Tracking features will be disabled.");
        }
    }
warm light
#

umm, I guess I can replace the r with null and cast to long. then check?

young knoll
#

As long as it isn’t static final

sage dragon
#

Wait, what? 😅

That would've made so much stuff way easier ._.

tender shard
#

oh, my McVersion class

#

yeah you can just copy/paste that class, it's tiny

ornate heart
#

Is it possible to create a miniature player npc?

Would I have to create a baby zombie NPC and then like apply a skin to it somehow?

tender shard
#

you cannot change skins from certain mobs without a resource pack

ornate heart
#

Gotchu. Could I create a player npc but just make it smaller then? I'm just wondering if this is possible at all.

young knoll
#

No

ornate heart
#

😭 damn

crisp steeple
#

armor stands would be your best bet

#

but that’s pretty complicated

pliant oyster
#

?jd-s

undone axleBOT
tender shard
#

or using existing stuff for it like ModelEngine 😛

pliant oyster
#

uhh how do I create a boss bar that shows an entities health

tender shard
#

Bukkit.createBossBar

#

then use repeating task to set the progress to (mobCurrentHealth / mobMaxHealth)

pliant oyster
#

hmm I see

#

do I do setProgress()?

tender shard
#

yes

#

you also have to add all nearby players to the bossbar

pliant oyster
#

Ye

crimson terrace
tender shard
#

sure, that works too. doesn't really matter whether it's an event or a runnable as it doesn't do anything besides dividing two numbers 😄

crimson terrace
#

true

tardy delta
#

if i wanted to display a actionbar longer than a few ticks, would i need a runnable?

#

or is there another way?

young knoll
#

You gotta keep sending it

tardy delta
#

alr

#

i was reading this and was thinking if i couldnt let the value of the bossbar change when an event happens

#

would still need a runnable ;-;

tardy flame
#

How mysql

#

Is so trash

#

At creating double instances

#

Fuck you mysql

#

No one uses you anyways

#

🗑️

#

What a waste of time

#

Only flat file

tender shard
pliant oyster
tender shard
#

wdym? setProgress(1) and the bar is full, 0 and it's empty

pliant oyster
#

oh

young knoll
#

Yay floats

pliant oyster
glossy scroll
#

Bar goes from 0-1

#

You cannot change

pliant oyster
#

Ye but if I set progress to the current health

tender shard
#

currentHealth / maxHealth will always be a value between 0 and 1

#

e.g. 50% health out of 40 max health will be 20/40 = 0.5

torn iron
#

Hi! I'm running a paper server and I want to make new entities that behave like villagers (namely a villager that has the model of a pigman and a villager that looks like a player character but without replacing any original villagers). How would I achieve this the easiest? I'm not sure if this can be done with some /summon shenanigans but so far I'm stumped. Could this be easiest done as a plugin? Should I make a forum post instead?

pliant oyster
tender shard
#

no, you always set the bar to (currentHealth / maxHealth)

#

bossbar.setProgress(currentHealth/maxHealth)

pliant oyster
#

ohh

#

ok

glossy scroll
torn iron
tardy flame
kind hatch
#

If only it was that simple

echo basalt
young knoll
#

Plus goals don’t cover the trade system

echo basalt
#

I mean the easiest way is to intercept spawn packets

tardy flame
#

You can always create a new goal

maiden briar
#
ReplaceEvent replaceEvent = new ReplaceEvent(this, replacementType, message, player);
System.out.println(replaceEvent);
Bukkit.getPluginManager().callEvent(replaceEvent);
System.out.println("After " + replaceEvent);

The server keeps hanging at callEvent, "After" is not getting print

[15:50:30 INFO]: me.tvhee.advancedreplacer.api.event.ReplaceEvent@35c1b15
echo basalt
#

villagers still act normal even if you remove their goal controller

#

they have routines and "conversations"

tardy flame
#

Wait really?

#

Lol

tender shard
echo basalt
#

if you kill one, they will snitch to each other and make a bad reputation

#

increasing their trade prices

maiden briar
#

No I am not listening for the event anywhere, just an API event

#

And currently no other plugins are listening for it

tender shard
#

show your code for ReplaceEvent

maiden briar
echo basalt
#

and multithreading often hides exceptions

maiden briar
#

Not calling it async, but good thought

#
  • I am calling it in a packet listener
echo basalt
#

okay then it's most likely async

#

super(player) -> super(player, !Bukkit.isPrimaryThread())

#

should fix it

maiden briar
#

Ok I will try

maiden briar
#

Oh T is capital

young knoll
#

Packet listeners are async

minor garnet
#

how to fire an entity towards the player so that it is random from the right or left, but towards the direction player?

if I use #getPlayerDirection().add(new Vector(randomx, randomy, randomz)), it will make it go in any direction

tender shard
#

extend Event instead of playerevent

#

then do super(false)

maiden briar
#

@echo basalt That seems to work fine, thanks!

echo basalt
#

:despai

#

bruh

maiden briar
#

I will name it AsyncReplaceEvent, better I guess

maiden briar
glossy scroll
echo basalt
# minor garnet how to fire an entity towards the player so that it is random from the right or ...
Vector entityVec = entity.getLocation().toVector();
Vector playerVec = player.getLocation().toVector();
Random random = ThreadLocalRandom.current();

int angleOffset = 10; // 10º left or right
double angle = random.nextDouble() * angleOffset*2 - angleOffset;

Vector direction = entityVec.clone().subtract(playerVec);
direction.rotateAroundY(Math.toRadians(angle));

entity.setVelocity(direction);
minor garnet
#

rotateAroundY fuck off if player look tô ground

echo basalt
#

I don't see how the pitch matters there

#

I'm rotating a random angle

#

and rotateAroundY messes with X and Z

minor garnet
#

Is getting the player direction

#

Let me show what happen

echo basalt
minor garnet
#

wait

#

example, I have a method that returns the barrel of the gun, based on some values ​​of the player's direction, I use rotateArounsY but if the player looks up or down this happens:

hasty prawn
#

If they look up or down then rotating around the y axis is not what you want

minor garnet
#

but the way i need to make it look like in the corner of the gun and rotating around the y-axis

tardy delta
#

it would look so much better with the texture lol

pliant oyster
#

for some reason boss bar isnt showing , lemmie send code

#

        double maxHealth = boss.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
        double currentHealth = boss.getHealth();

        bossBarID = Bukkit.getScheduler().scheduleSyncRepeatingTask(BossesMain.getInstance(), new Runnable() {

            @Override
            public void run() {

                bossBar.setProgress(currentHealth / maxHealth);

            }


        }, 0, 1);

        if (boss.getNearbyEntities(50, 0, 50) instanceof Player player){

            bossBar.addPlayer(player);

        }

    }```
tardy delta
#

you have to keep sending it

pliant oyster
#

I do

tardy delta
#

wait

#

thats not an actionbar or what is it

pliant oyster
#

?

#

it's a bossbar

tardy delta
#

also if (boss.getNearbyEntities(50, 0, 50) instanceof Player player){

#

collection cant be nstanceof a player

#

cant type with ice cream in my hand lol

pliant oyster
tardy delta
#

that method is returning some kind of collection of entities

pliant oyster
#

wait

#

do I have to check if it contains players?

tardy delta
#

loop over it and chheck if there are players inside and add them

pliant oyster
#

uhh

#

could u give me an example

tardy delta
#

for entty e : boss.getnearby { if e insanceof player { bossbar.add((Player)e) } }

#

let me eat my ice cream before i can type normal lol

pliant oyster
#

alr

tardy delta
#

that was some serious dedication eating that

pliant oyster
#

Ye I got ice cream too

#

cuz u reminded me I have some in my freezer

tardy delta
#

gimme those too

pliant oyster
#

it's fudge bars from food lion

pliant oyster
#

but

#

it doesnt updated for some reason

#
    public void showBossBar(){

        double maxHealth = boss.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
        double currentHealth = boss.getHealth();

        bossBarID = Bukkit.getScheduler().scheduleSyncRepeatingTask(BossesMain.getInstance(), new Runnable() {

            @Override
            public void run() {

                bossBar.setProgress(currentHealth / maxHealth);

            }


        }, 0, 1);

        for (Entity e : boss.getNearbyEntities(50, 0, 50)){

            if (e instanceof Player player){

                bossBar.addPlayer(player);

            }

        }

    }
young knoll
#

You gotta calculate the health inside the runnable

#

You’re just using the old value every time

tardy delta
#

double currentHealth = boss.getHealth();

#

in the runnable

#

:)

pliant oyster
#

ohh

#

ok

pliant oyster
#

fine

#

give ur adress

#

ill mail it

tardy delta
#

;-;

desert musk
#

cannot resolve method ‘super(net.minecraft.server.level.ServerLevel)

#

trying to make a custom entity

#

the constructor’s super method is underlined in red

pliant oyster
#

send code

tardy delta
#

send ice

pliant oyster
#

yeah ice

desert musk
#

ice?

#

lol

#

🧊

#

um actually i can’t send my code because my school wifi won’t allow it

#

but uh

#

i’ll get back to you on that

pliant oyster
#

alr

pliant oyster
granite owl
#

i can load PDC data from player instances only when that player is online right?

tardy delta
hardy swan
#

Is there a way to apply raw damage to an entity?

#

nvm

vocal cloud
#

set their health - amount

hardy swan
#

I see that DamageModifier is deprecated but I think I don't need it anymore

desert musk
#

and that’s in the constructor of a class that extends Villager

hasty prawn
#

EntityTypes.VILLAGER, ServerLevel maybe?

desert musk
#

ok

#

yeah maybe let’s see

hasty prawn
#

Something like that, not 100% sure what it is exactly.

desert musk
#

you were right

#

spot on

#

thanks

west oxide
#
[11:31:03 ERROR]: Could not pass event PlayerJoinEvent to Core v1.0-SNAPSHOT
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched.jar:git-PaperSpigot-"4c7641d"]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) [patched.jar:git-PaperSpigot-"4c7641d"]
        at net.minecraft.server.v1_8_R3.PlayerList.onPlayerJoin(PlayerList.java:314) [patched.jar:git-PaperSpigot-"4c7641d"]
        at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [patched.jar:git-PaperSpigot-"4c7641d"]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:875) [patched.jar:git-PaperSpigot-"4c7641d"]
        at org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity.teleport(CraftEntity.java:236) ~[patched.jar:git-PaperSpigot-"4c7641d"]
[11:31:03 INFO]: shakiz[/172.18.0.1:49466] logged in with entity id 723 at ([world]-226.9407122602794, 67.0, 536.1383005521543)```
#

uhh idk how to fix this

#
    public void onJoinEvent (PlayerJoinEvent event){

       Location spawnLocation = Utils.getSpawnLocation();

       Player player = event.getPlayer();
        player.teleport(spawnLocation);


        Utils.clearChat(player,250);
        player.sendMessage(Utils.CC(""));
        player.sendMessage(Utils.CC("                                      &f&lShakiz&b&lNetwork&r                     "));
        player.sendMessage(Utils.CC(""));
        player.sendMessage(Utils.CC("              &fWelcome &b" + player.getDisplayName() + " &fto the network !"));
        player.sendMessage(Utils.CC(""));
        player.sendMessage("");
        player.spigot().sendMessage(Utils.discord());
        player.spigot().sendMessage(Utils.website());
        player.spigot().sendMessage(Utils.creators());
        player.sendMessage("");
        player.sendMessage("");

    }```
vocal cloud
west oxide
#

i never got an error like this before

sage dragon
sage dragon
west oxide
#

i didnt realize i was using paper f

west oxide
manic furnace
# manic furnace https://paste.md-5.net/vejaqiyemo.bash

I fixed my problem that there is I random nms class used. It was not randomly use, the name of it was wrong! This was because of I used the remapped nms code and i didn't get reobfuscate the right way. So how can I reobfuscate it the right way?

#

I looked at a older of the plugin, and it doesn't even re obfuscate anything

hasty prawn
#

Are you using Maven or Gradle?

manic furnace
#

Maven

hasty prawn
#

?1.17

undone axleBOT
hasty prawn
#

nope not

#

that

#

wait

#

Scroll down to the 2nd post by md_5, there's a guide for remapping using maven.

manic furnace
#

Ok, I run package, but I keep getting this error:

limber owl
#

hey, if i want to get world face liek NORTH EAST WEST SOUTH

#

is there a enum?

#

or something?

hasty prawn
modern vigil
#

Is it a good practice to pass in my JavaPlugin if I only need the logger?

limber owl
hasty prawn
tardy delta
#

whats even te difference between those two loggers?

hasty prawn
#

Nothing probably

#

Two different ways to get the same thing

quiet ice
#

a lot

#

Bukkit is the generic logger, the plugin logger is the plugin-specific logger

#

the better question would be why one would need the logger in the first place

vocal cloud
#

Always use your plugins logger where you can.

tardy delta
#

why is it even possible to access the bukkits logger then?

quiet ice
#

Bukkit being bukkit

tardy delta
#

kek

vocal cloud
#

Because it's a public field that they can use in their classes

#

Just because you have access to it doesn't mean you should use it

modern vigil
#

So I should just pass in the logger?

manic furnace
viral crag
#

using the server's logger can generate tick issues with large amounts of log spam

vocal cloud
#

I imagine the same would be true for the plugins logger

viral crag
#

not necessarily

#

you can run your own logger on a separate thread

#

is currently fighting log spam on the main thread for a fabric server

vocal cloud
#

I mean you can but you really really shouldn't be logging that much

worldly ingot
vocal cloud
#

Bukkit needs to ask for my consent before logging to my console upsetLiz

viral crag
#

a legacy implementation for Advancements pushed MSPT to 1800

#

and was generating a 5Mb logfile just on startup

vocal cloud
#

Sounds like a dev problem kekw

viral crag
#

yeah it is

vocal cloud
#

Logger abuse

desert musk
#

👍

viral crag
#

so far i've managed to get the MSPT spikes down to a max 83

west oxide
#

ì never got this error before

#

Could not pass event PlayerJoinEvent to Core v1.0-SNAPSHOT

vocal cloud
#

To me it looks like there isn't enough information

viral crag
#

should ask the paperguys what went wrong

vocal cloud
#

Still using paper

west oxide
#
[12:21:06 INFO]: You are 52 version(s) behind```
#

@viral crag ?

#

idk am new to this

viral crag
#

[11:31:03 ERROR]: Could not pass event PlayerJoinEvent to Core v1.0-SNAPSHOT
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched.jar:git-PaperSpigot-"4c7641d"]

vocal cloud
#

You are 52 version(s) behind

west oxide
#

i did /version

vocal cloud
#

update please

chrome beacon
#

^^

west oxide
viral crag
#

most people just read their server file name, since thats the fastest

vocal cloud
#

You don't you just update using buildtools

viral crag
#

😛

vocal cloud
#

Who cares what version you're using it's behind build a beautiful brand spankin new one with buildtools

west oxide
#

how do i paste a link ?

vocal cloud
#

depends what the link is to

west oxide
vocal cloud
#

no

#

no

#

no

#

no

west oxide
#

D:

#

what am i doing wrong

vocal cloud
#

Everything

west oxide
#

idk

vocal cloud
#

?bt

undone axleBOT
viral crag
#

that one have a nice builtin exploit?

west oxide
vocal cloud
#

Use build tools please

#

please

west oxide
#

okay

#

ty

vocal cloud
#

That site you sent is auto removed for a reason

#

It's literally the devil incarnate

viral crag
#

almost, nft guys have that title now

west oxide
#

damn

#

mb i didnt know

#

is it this file ?

#

or this

#

from build tools

vocal cloud
#

the snapshot afaik

west oxide
#

okay

#

ty

vocal cloud
#

Maybe but it'll help fix the fact you're a scary amount of versions behind

viral crag
#

thinks there is no way to fix the 1.8.x issue

vocal cloud
#

Ah I found the issue missing a 1 in front of the 8. 1.18 aha problem solved

viral crag
#

The event problem is possble to fix if you can get an error that tells you something useful

craggy sapphire
#

?paste

undone axleBOT
craggy sapphire
#

could somebody help me fix this issue

viral crag
#

30.03 16:29:59 [Server] INFO java.lang.NoClassDefFoundError: com/gmail/dejayyy/killStats/ksMain

#

define your class

craggy sapphire
#

how do I do that?

viral crag
#

gmail oof

craggy sapphire
#

?

viral crag
vocal cloud
craggy sapphire
#

whats wrong with paper

vocal cloud
#

It's paper

viral crag
#

this is a spigot help server

craggy sapphire
#

arent they very similar

#

and almost the same?

viral crag
#

short answer is ... the paper guys are ex-spigot

#

btw the killstats plugin is broken and has been for a long time

desert musk
viral crag
desert musk
viral crag
#

the only thing I am currently aware of is a rumour of a hard fork soon

late sonnet
#

hard fork?

craggy sapphire
viral crag
craggy sapphire
#

where else should I ask?

viral crag
viral crag
craggy sapphire
#

i know how to compile

#

i just

#

dont code so

#

that didnt come to my head

#

to do that

#

but now I understand

modern vigil
#

Is there a better way to do Stream<Path>#toArray() as Array<Path>?

grim ice
#

needing a lib idea

quaint mantle
#

World Generator, even though there are some out there.

grim ice
#

eh

quaint mantle
#

Oooooor, Region Library.

#

Similar as to what world guard has, but in a library, ya know?

grim ice
#

ehh

#

idk

quaint mantle
#

Or is that bad as well ?

grim ice
#

i feel like the idea isnt so original

quaint mantle
#

Okay just so we're on the right page, a Library is supposed to make the code easier to understand for the person thats using it right?

grim ice
#

ye

quaint mantle
#

Aha.

#

MySQL + Bungee ?

grim ice
#

wat

quaint mantle
#

Yeah I'm retarded I know..

#

Ummm, something that'll sync player's data and server data using a database, my need to be MySQL

#

Does that make any sense ?

viral crag
#

the new java 18 vectors for spigot

shy saffron
#

I get this error when i try to execute the command

#

org.bukkit.command.CommandException: Unhandled exception executing command 'economy' in plugin CoStrength v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:897) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2287) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2098) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2079) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-177]

#

at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1413) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1391) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1384) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1362) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1268) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-177]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at io.github.thelordman.costrength.commands.economy.EconomyCommand.onCommand(EconomyCommand.java:18) ~[CoStrength-1.0.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 21 more

#

anyone know whats up?

#

all of my other commands are working fine

#

and i have registered the command

eternal oxide
#

accessing a zero length array

shy saffron
#

yes i know that

#

but

#

that isnt happening

#

i checked the code

eternal oxide
#

The stacktrace does not lie

shy saffron
# shy saffron

well im not seeing anything causing this error in the code

eternal oxide
#

EconomyCommand.java:18

shy saffron
#

uh

eternal oxide
#

line 18

shy saffron
#

yes

#

but

#

what is wrong with it, do arrays not start with 0?

eternal oxide
#

yes, but yours is empty. it has no element zero

shy saffron
#

ohh yeah true

#

i need to move that one line

#

damn

tardy delta
iron tundra
#

When I am running a piece of code to spawn in a npc I get an error saying CraftServer can't be cast to MinecraftServer but when I change it to not have that, it brings up saying CraftWorld can't be cast to WorldServer. Even worse is after even fixing that it still errors but this time with no stacktrace just an error saying the same line is causing an error.

EntityPlayer npc = new EntityPlayer((MinecraftServer) player.getServer(), ((WorldServer) player.getWorld()), new GameProfile(uuid, name));

Before Fixing
org.bukkit.command.CommandException: Unhandled exception executing command 'npc' in plugin QuestTest v1.0-SNAPSHOT
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R2.CraftServer cannot be cast to class net.minecraft.server.MinecraftServer (org.bukkit.craftbukkit.v1_18_R2.CraftServer and net.minecraft.server.MinecraftServer are in unnamed module of loader java.net.URLClassLoader @58d25a40)
at me.ispeakweeb.questtest.NPCManager.createNPC(NPCManager.java:25) ~[QuestsTest.jar:?]
at me.ispeakweeb.questtest.QuestTest.onCommand(QuestTest.java:35) ~[QuestsTest.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.18.2-R0.1-SNAPSHOT.jar:?]
After Fixing
org.bukkit.command.CommandException: Unhandled exception executing command 'npc' in plugin QuestTest v1.0-SNAPSHOT
Caused by: java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_18_R1/CraftWorld
at me.ispeakweeb.questtest.NPCManager.createNPC(NPCManager.java:25) ~[QuestsTest.jar:?]
at me.ispeakweeb.questtest.QuestTest.onCommand(QuestTest.java:35) ~[QuestsTest.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more

shy saffron
#

how do i check if a string in an array doesnt exist since if (args[2].isEmpty()) doesnt work

eternal oxide
#

if (args.length > 0)

shy saffron
#

oh yeah true

craggy sapphire
shy saffron
#

alright it works now thanks

midnight shore
#

How do i get the first entry in a list?

#

the index is 1 right?

viral crag
quaint mantle
iron tundra
craggy sapphire
midnight shore
#

findFirst returns an optional

#

btw ty

viral crag
craggy sapphire
#

how do i figure out which one the project uses?

eternal oxide
#

Eclipse comes default with both

iron tundra
#

IntelliJ sets it up automatically

craggy sapphire
#

okay

viral crag
craggy sapphire
#

i dont think so

#

im trying to compile this

#

maybe im wrong

viral crag
#

then it is likely gradle and you will have a build.gradle file

eternal oxide
#

its not either

#

you will have to import it

viral crag
#

hmm nope its a bare java

craggy sapphire
#

after I have IntelliJ how do I compile it?

midnight shore
#

Hi, i was wondering how could i make a sort of entry for a Constructor that will define what will happen to the selected entry whenever its picked. As you can see i'm doing a queue system

#

like a Consumer but i don't really know how do they work

tardy delta
#

?

midnight shore
#

how do consumers work? could you help me please?

viral crag
#

is that supposed to spell plugin?

iron tundra
craggy sapphire
#

im just looking for smth

#

to compile the plugin

#

once

#

and be over with

viral crag
iron tundra
#

community is free

craggy sapphire
#

oh yeah I did

iron tundra
#

lol

tardy delta
#

a consumer is something like

Consumer someConsumer = event -> {
  System.out.println(event.getPlayer().getName());
}

void onEvent(Event e) {
  someConsumer.accept(e); // will execute the sysout stuff
}```
midnight shore
#

I'd like having a system that has multiple entries and a runnable that every 25 ticks takes the first entry of the list do some stuff (and i want to specify this. How can i specify a list of code that will happen when an entry is selected?) and then removing that entry.
For example i have a list named PLAYERS_TO_WARP and every 25 ticks it takes the first entry of the list and warps it to the hub. My question is: How do i specify this last thing? How do i specify that the players will be teleported to the Hub?

#

hope its clear

tardy delta
#

or if you write it like this

Consumer<Event> someConsumer = new Consumer<>() {
  void accept(Event event) {
    System.out.println(event.getPlayer().getName());
  }
}```
grim ice
#

e.g pass a consumer to someone

midnight shore
grim ice
#

then do consumer.accept(<T>)

eternal oxide
#

On the github page for the project, click the button marked "code". Then click the copy to clipboard button for the URL.
In Eclipse File menu -> Import.
Expand the Git entry, and select Projects from Git (with smart import).
click next and select Clone URI in the next menu.
Click next and everything should be filled in for you.

tardy delta
#

ayy

eternal oxide
#

Click next and it should be imported

grim ice
#

itll run the code in the consumer

craggy sapphire
#

okay I have InteliJ

#

what should I do now?

iron tundra
#

Create a new project

craggy sapphire
#

yes but

tardy delta
#

i have the admit espresso man's link is better

craggy sapphire
#

how do i clone

tardy delta
#

:)

craggy sapphire
#

from