#help-development

1 messages · Page 1630 of 1

ivory sleet
#

That is if it isn’t empty

stone sinew
#

Yeah i added that before i put x>>4 in () lol thx

humble heath
#

registerEvents(this, new JoinLeave(this));

paper viper
#

No context lol

#

What’s the issue

humble heath
#

event not regestering

paper viper
#

Any exception?

#

Error?

humble heath
#

no

#

nothing no error

#

nothing looks like the event is not regestering

grim ice
#

Method invocation 'toUpperCase' may produce 'NullPointerException'

#

its in a Enum

#

how do i fix it

#

inside of an enum

eternal oxide
#

check what you are trying to set to upper case

grim ice
#

uhuhuuhuhhuhuhuhuhuuhuuuhuhuuhuhuuhuhuhhuhuh

#

where

eternal oxide
#

in your code

grim ice
#

lmao

#
COW(new ItemStack(Material.COW_SPAWN_EGG),
                plugin.getConfig().getString("Cow.matrix1").toUpperCase(), plugin.getConfig().getString("Cow.matrix2").toUpperCase(), plugin.getConfig().getString("Cow.matrix3").toUpperCase(),
                plugin.getConfig().getString("Cow.order").toUpperCase(), new Material[]{Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(0)), Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(1)), Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(2))}),```
#

do i need to use

#

.toString()

eternal oxide
#

See the annotation

grim ice
#

yes

#

Nullable

eternal oxide
#

@Nullable says the returned value can be null.

#

so you have to validate it. Make sure its not null before you attempt to use it

grim ice
#

how

#

i mean

#

uwhHWDHFUHUEFHweufhwef

eternal oxide
#

either use a utility method to check strings or set it to a variable so you can check it.

grim ice
#

i would have like''

#

200 variables

#

if i do that

eternal oxide
#

then a getter utility method

narrow vessel
# grim ice how

if(variable !=null) {
// do something normally
} else {
// handle it by possibly returning with an error
}

#

easiest way to grasp it

grim ice
#

i know how to do that lol

grim ice
eternal oxide
#
private String getStringNonNull(String path) {
    String value = getConfig().getString(path);
    return (value != null)? value: "";
}```
grim ice
#

o

eternal oxide
#

Something like that

#

or use teh get method where you can provide a default value

ivory sleet
#

Objects.requireNonNullElse(str, "") iirc but yeah

grim ice
#

thats way easier

worldly ingot
#

Or, getConfig().getString(path, "");

#

because there is a built-in method for that

eternal oxide
#

Yes, but you'd not understand what its doing if you were just given Objects.requireNonNullElse

grim ice
worldly ingot
#

It's a pretty common thing when working with configuration files. Especially in Bukkit

#

Every getter method in MemorySection has a companion with a default value

eternal oxide
#

Yep. The whole point here is, that ANY time you can have null returned you must confirm its not null before you attempt to use it.

grim ice
worldly ingot
#

tbf I missed that part of the discussion but yeah, Bukkit's methods are all covered with nullability annotations

#

Makes it fairly easy if your IDE supports nullability analyzing

grim ice
#

yeah it removed the warning after it

#

but it didnt show me a fix to it

eternal oxide
#

It expects you to know basic java to fix it

vast sapphire
#
                            public void run() {
                                ItemStack item  = new ItemStack(Material.IRON_INGOT);
                                for(Player p : getServer().getOnlinePlayers()) {
                                    int count = 0;
                                for(Location l : activeLocations) {
                                    if (distanceBetween(p.getLocation(), l) <= 2.2) {

                                        ++count;
                                        }
                                    }
                                item.setAmount(count);
                                p.getInventory().addItem(item);
                                }
                            }
                        }, 0, REWARD_TICK_DELAY);``` I need to give the player an item at each of the active locations but when I spawn more than one location, the player gets more than 1 iron a tick
summer scroll
#

How can I remove fake players only on the tablist? I want to achieve player name tab completer with the fake player.

grim ice
#

that was spigot api

eternal oxide
#

No, null checking is basic java

grim ice
#

the easiest way was*

#

The way choco sent

#

was spigot api

vast sapphire
# vast sapphire ```java public void run() { ...

also, what Is wrong with my distanceBetween method as I get an item anywhere I go instead of a 2.2 block radius ```java
private static double distanceBetween(Location l1, Location l2) {
double x1 = l1.getX();
double x2 = l2.getX();

    double y1 = l1.getY();
    double y2 = l2.getY();

    double z1 = l1.getZ();
    double z2 = l2.getZ();

    double xDist = Math.pow(x1-x2, 2);
    double yDist = Math.pow(y1-y2, 2);
    double zDist = Math.pow(z1-z2, 2);

    return Math.sqrt(xDist + yDist + zDist);

}
eternal oxide
grim ice
#

yes lmao

eternal night
#

why not just use a normal method

vast sapphire
eternal night
#

how does this method solve it xD

vast sapphire
#

public static List<Location> activeLocations = new ArrayList<>();```
#

I need to get each individual location of the blocks from the array, how do I do that?

chrome beacon
#

You loop the array?

vast sapphire
#

Yeah I know I need a loop

worldly ingot
#

Would opt for distanceSquared if you're doing anything comparatively. Unless you're showing something to a user, use distanceSquared

eternal night
#

which also doesn't use Math.pow

#

unless the JIT compiler is finally good enough to optimize Math.pow(x,2) calls to x*x

worldly ingot
#

They want to compare distance between other locations. distanceSquared is the right method here lol

vast sapphire
eternal night
eternal oxide
#

What are your locations for and why do you need the distance between them?

vast sapphire
#

5 every tick because I have 5 block locations

eternal oxide
#

every tick is a heck of a lot of iron

hasty prawn
#

Wouldn't that have something to do with how the iron is being spawned, not really related to the distance?

worldly ingot
vast sapphire
eternal night
#

thank god

#

also, what a move to link java 8 sources

hasty prawn
eternal oxide
hasty prawn
#

Or do that, depends on how you want the game to work ^

vast sapphire
#

I only 1 piece of iron for every location and i have been working for hours trying to fix this

hasty prawn
#

Send your code

#

?paste

undone axleBOT
vast sapphire
#

ok

vast sapphire
round finch
#

what limitation is there to spigot plugin development if it is only spigot api

eternal oxide
#

delete that wait method in your Listener

vast sapphire
#

ok, I was going to use it for something later

#

I can comment it out

eternal oxide
#

never ever sleep the main thread

vast sapphire
#

ok

worldly ingot
#

General rule of thumb is to compile against API until you require something in the net.minecraft package

#

and at that point, make a PR so there is API for it

eternal oxide
#

ok, so you are giving every player who is online 1 ingot in their inventory for each location in your list

echo basalt
eternal night
#

LMAO

vast sapphire
echo basalt
#

I keep seeing people use NMS for this

hasty prawn
#

You don't need to check if the players are close really, they can just pick it up.

eternal night
#

If you cant be bothered to contribute then why should you get to use it :>

worldly ingot
#

API for that isn't actually that hard. implementation is likely along the lines of entity.getNavigation().a(BlockPosition). I haven't looked at mob navigation in a good few years but I remember it being extremely simple

echo basalt
#

Yeah

worldly ingot
#

Just that nobody's done it

echo basalt
#

¯_(ツ)_/¯

#

It's 1 line of code

eternal night
#

Go do it 🥳

worldly ingot
#

I don't have the time to contribute much anymore because I'm either working or doing school

echo basalt
#

making a PR and importing the entirety of spigot in my IDE takes lots of time

eternal oxide
eternal night
#

Tho tbh someone just get the chunk entity pr to merge

#

That'd be kinda nice

#

Since it has been an issue since 1.17 but it's just stale

vast sapphire
vast sapphire
round finch
#

what information do the server receive from the client?

hasty prawn
#

Oh, I see the problem

#

Put

item.setAmount(count);
p.getInventory().addItem(item);

Inside the distance if block

worldly ingot
#

Serverbound packets are what the client sends

hasty prawn
#

Is it just me or is IntelliJ's autocomplete & decompiling far more useful than wiki.vg 🤔

eternal oxide
worldly ingot
#

The wiki and what's decompiled in IntelliJ aren't necessarily the same thing

hasty prawn
#

Yeah and what's decompiled seems to be more accurate

worldly ingot
#

The fields in the packets are used by ProtocolLib whereas the wiki actually documents the protocol itself

#

There is a difference

hasty prawn
#

Ah

worldly ingot
#

If someone wanted to make their own server from scratch, reading through the protocol is how they'd be able to interpret what the client sends

#

They may then implement it however they'd like. So long as the server reads what the client sends properly, you have a server

hasty prawn
worldly ingot
#

It's like a manual on how they communicate ;p

eternal oxide
hasty prawn
#

That makes sense, ty for explaining Choco

worldly ingot
#

o/

vast sapphire
eternal oxide
hasty prawn
#

Oh wait yeah I read it wrong, formatting is really weird

vast sapphire
eternal oxide
#

to slow it down, do the reward every 20 ticks

#

thats 1 reward per second

round finch
#

20 nearly 1 secound

eternal oxide
#

Minecraft ticks != seconds. roughly 20 per second.

vast sapphire
vast sapphire
eternal oxide
#

you are not giving a reward for every location

hasty prawn
#

It is running every 20 ticks

eternal oxide
#

your gif is too small. I can;t see how many its showing

#

I just see it giving a reward every second

#

Oh I see your issue

#

did you run the command each time you placed a generator?

vast sapphire
#

yes

eternal oxide
#

then you have 5 tasks running

hasty prawn
#

ohhhh lmao

grim ice
#

?paste

undone axleBOT
grim ice
hasty prawn
#

Nice catch Elgar

vast sapphire
hasty prawn
#

You should only run the task once

eternal oxide
#

you don't run per block, you run per player

vast sapphire
#

ohhh

grim ice
#

help

#

i got a over 13kb error

hasty prawn
#

Why per player

grim ice
#

fefiweifbawefuabwefuhagbwefyagwefabwefawefuhwagfeuagbewfbwaiyfgaywefbwaeifywa

hasty prawn
#

It loops all the players

eternal oxide
#

yes, one task. will cover all.

#

or one per player dedicated to that player.

#

one for all players is better. but ONLY one task

hasty prawn
#

Yeah, I was just confused when you said per-player lol

eternal oxide
#

So your fix, is don;t start your task in your command

#

run ONE task for the whole server, outside the command

grim ice
#

tbh

#

i dont even understand that error

hasty prawn
#

It's a YAML error, something is wrong with your config.yml

eternal oxide
#

bad yaml formatting

grim ice
#

how

#
Cow:
    matrix1: " D "
    matrix2: " D "
    matrix3: " S "
    order: "DS"
    items: [DIAMOND_SWORD, STICK]```
eternal oxide
#

no clue, show us your yaml

grim ice
#

thats my config.yml

eternal oxide
#

show with formatting

grim ice
#

oh 1s

#

here u go

hasty prawn
#

Probably using tabs instead of spaces

vast sapphire
eternal oxide
#

start it when you load the class

hasty prawn
#

try this @grim ice

Cow:
  matrix1: " D "
  matrix2: " D "
  matrix3: " S "
  order: "DS"
  items: [DIAMOND_SWORD, STICK]
grim ice
#

ok

#

?paste

undone axleBOT
grim ice
vast sapphire
# eternal oxide No, you just need to move the whole runnable out of yoru command

alright so like this? ```java
public final class Generators extends JavaPlugin {
protected static Generators instance;
//public List<Location> locations;
@Override
public void onEnable() {
this.getCommand("Gens").setExecutor(new Commands());
this.getCommand("gm").setExecutor(new Commands());
this.getServer().getPluginManager().registerEvents(new Events(), this);
instance = this;
//locations = (List<Location>) getConfig().get("locations");
saveDefaultConfig();
getConfig().getLocation("locations");
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(Generators.getInstance(), new Runnable() {
@Override
public void run() {

        }
    }, 0, 20);
}``` just don't know what to put in my run() method
grim ice
#

this error is shorter i think

#

yeah its 100 lines shorter

hasty prawn
#

What is RecipesManager line 143

grim ice
#

1s

#
plugin.getConfig().getString("Cow.order", "").toUpperCase(), new Material[]{Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(0)), Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(1)), Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(2))}),```
eternal oxide
#

you need one runnable that runs all the time.

#

same code in the run method you already had

vast sapphire
#

ok

hasty prawn
#

get(2) throws an error

grim ice
#

oh fuck

#

right

#

how do i check if there is tho

hasty prawn
#

Just loop the String List 2Hex

#

There can be more or less than 3

grim ice
#

its inside an enum

austere cove
#

whats this about

#

in the protocol spec

hasty prawn
grim ice
#
public enum Things {
 plugin.getConfig().getString("Cow.order", "").toUpperCase(), new Material[]{Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(0)), Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(1)), Material.getMaterial(plugin.getConfig().getStringList("Cow.items").get(2))}), 
}```
#

there are other stuff

#

but thats the main idea

#

so

#

u there

hasty prawn
#

Yeah hang on

vast sapphire
eternal oxide
#

yes, or the constructor of your command class

vast sapphire
#

ok

hasty prawn
#

It would probably be best if you just... didn't use an enum

grim ice
#

wat

hasty prawn
#

Use a class, that way they can add/remove recipes as they please

grim ice
#

that'll break my whole code tho

eternal oxide
#

its not a difficult change

hasty prawn
#

^

eternal oxide
#

You currently have an enum as you were using fixed recipes created in code

hasty prawn
#

You're not really going to be able to have customization with enums.

eternal oxide
#

you can still use teh rest of your code

#

but instead of an enum you will create a Map of recipes

silver shuttle
#

How do I, in IntelliJ IDEA change the version of an mc plugin? I tried importing the librabry of 1.17.1-R01-Snapshot but it didnt find it

eternal night
#

It is R0.1

#

Not R01

silver shuttle
#

yes i know, i copied it from spigot, it still doesnt find it

eternal night
#

And you have the respective repository added too?

silver shuttle
eternal night
#

Oh fuck what is this

#

Are you not using a build tool ?

#

Like maven or gradle

silver shuttle
#

this is Maven

austere cove
#

that's maven lmfao

eternal night
#

You add dependencies theough a GUI now ?

austere cove
#

it will only find the spigot artifact if you ran buildtools first (and have it install the artifact in your local repository)

eternal night
#

oh lol

silver shuttle
eternal night
#

Do you actually need the server tho

#

Or is API fine

austere cove
#

use spigot-api if you just want to use the API

eternal night
#

Concerning you are new to this, API might be all you need

silver shuttle
#

Sorry, but I have literally no clue what i need to do

eternal night
#

Yeah I think API will be fine for you then XD

silver shuttle
#

like this?

eternal night
#

Yea I guess

#

Tho It still looks to me like you are downloadinf this to a lib folder and are working off of that

eternal oxide
eternal night
#

Instead of a pom.xnl

vast sapphire
silver shuttle
#

quietly dies

#

I just want to change the plugin version from 1.16.5 to be compatible with 1.9 to 1.17.1

eternal oxide
vast sapphire
#

ok

vast sapphire
# eternal oxide if you did it in your command class you for loop the locations, as you did befor...

seems to be doing the same thing?

        BukkitScheduler scheduler = getServer().getScheduler();
        scheduler.scheduleSyncRepeatingTask(Generators.getInstance(), new Runnable() {
            @Override
            public void run() {
                ItemStack item  = new ItemStack(Material.IRON_INGOT);
                for(Player p : getServer().getOnlinePlayers()) {
                    for(Location l : activeLocations) {
                        if (p.getLocation().distance(l) <= 2.2) {
                            switch (l.getBlock().getType()) {


                                case IRON_ORE:
                                    item.setAmount(1);
                                    p.getInventory().addItem(item);
                            }
                        }
                    }
                }
            }
        }, 0, 20);```
eternal oxide
vast sapphire
#

well it's right under java public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) { so that might be the issue

eternal oxide
#

it can NOT be IN your command

unkempt ore
#

Dumb question, but api versions are forward compatible, right?

#

Like if I make a 1.8 plugin using pure API, I can use anywhere 1.8+

eternal oxide
# grim ice thats it?

thats your store. You then load/add all your recipes in your RecipeManager constructor

grim ice
vast sapphire
#

I put it in my onEnable() method and it works! Just had to import my active locations array

chrome beacon
#

Use 1.9 as spigot dependency and Java 8

silver shuttle
#

Okay and how do I make the plugin compatible with 1.17.1 if it was for 1.16.5 previously?

#

(Using IntelliJ IDEA here)

chrome beacon
#

Since you seem to be new with Spigot I doubt you're using NMS which means the plugin already is compatible

silver shuttle
#

it wont load with it

chrome beacon
#

What does it say?

silver shuttle
#

umm one sec

#

umm ok this is awkward

#

it works now, weirdly 😂

vast sapphire
silver shuttle
#

I tested with another plugin previously, but the one I need works weirdly, thank you tho Olivo

vast sapphire
hasty prawn
vast sapphire
#

ok

vast sapphire
silver shuttle
#

How do I read a value from a config file form the main class file? I know how to do it form any other class file
(messages_prefix = myplugin.getConfig().getString("prefix");)
But if I try that in the main class it doesnt work. I need it as a global static

#

Or like how do I make a public static inside the onEnable Event, for example

chrome beacon
#

You create the variable outside it and set it in the onEnable

chrome beacon
#

This should have been convered in Java basics (Which I hope you know)

vast sapphire
#

I just need to look up config manipulation

chrome beacon
silver shuttle
chrome beacon
#

You put the variable outside of onEnable and then set it's value inside of the onEnable

silver shuttle
#

aaaah ok

#

makes sense

#

sorry I am dumb

vast sapphire
grim ice
#

@eternal oxide

#

is there another way

#

i can like

#

get all the existing indexes of a list

#

so i dont mess up if its more or less

#

do you know a way of doing that? if you understood my question

hexed hatch
#

Does anyone know how to go about creating a redstone pulse on a redstone wire?

hexed hatch
#

Ooh, looks like it

#

Thanks

last citrus
#

How would I spawn a entity on a player?

last citrus
#

Ok

left lodge
#

i've updated to 1.17.1 and for some reason, the isSilent parameter of the World.Spigot#strikeLightningEffect​(Location loc, boolean isSilent) method being set to true doesn't seem to make the lightning bolt silent anymore. does anyone know why this might be the case?

silver shuttle
#

How do I, if I have stored an ItemStack in a MySQL, read it from there (as string) and convert it into an ItemStack?

eternal night
#

Maybe its a bug ? If you can replicate it on the latest spigot release with just your test plugin, open a bug report

silver shuttle
#

simplest preffered

waxen plinth
#

The first is with BukkitObjectOutputStream

#

Which is annoying

#

You want my alternative?

silver shuttle
#

sure

waxen plinth
#

My library has a method to convert items to and from JSON strings

silver shuttle
waxen plinth
#

The setup is annoying and it takes up way more space

#

It's something like this if I recall though

fallow dragon
silver shuttle
#

can you store items in a mysql as ItemStack?

waxen plinth
#

No

fallow dragon
#

Don't think so

silver shuttle
#

I mean it is in there in the exact format like the itemStack

left lodge
waxen plinth
#

No

silver shuttle
waxen plinth
#

No, you can't

#

To my knowledge there is no method to convert back from that format

#
ByteArrayOutputStream bao = new ByteArrayOutputStream();
BukkitObjectOutputStream boo = new BukkitObjectOutputStream();
boo.writeObject(item);
boo.flush();
byte[] arr = bao.toByteArray();
String out = Base64Coder.encode(arr);```
#

It's something like this to convert an item to a string using BukkitObjectOutputStream

#

But it's not human-readable and it's not space efficient

#

My library has ItemUtils.toString and ItemUtils.fromString which convert to and from JSON strings

fallow dragon
#

That's convenient. I'd use his library unless you want more control over your database structure

silver shuttle
#

ok now I need to show how dumb I am again: How do you add libraries

fallow dragon
#

Maven dependencies

waxen plinth
#

Well for RedLib

#

You can't shade it

#

You have to have the jar on your server

#

I imagine you don't really want that

#

So honestly the easiest way is to just copy the code from the ItemUtils class and the JSON parser package

silver shuttle
#
    public static ItemStack fromString(String json) {
        JSONMap map = JSONParser.parseMap(json);
        ItemStack item = (ItemStack) deserialize(map);
        ItemMeta meta = item.getItemMeta();
        // Everything except enchantments works. Not sure why, but it has to be done manually.
        if (map.containsKey("meta")) {
            JSONMap jsonMeta = map.getMap("meta");
            JSONMap enchants = jsonMeta.getMap("enchants");
            if (enchants != null) {
                enchants.forEach((k, v) -> {
                    meta.addEnchant(Enchantment.getByName(k), (int) v, true);
                });
            }
        }
        item.setItemMeta(meta);
        return item;
    }

So this section?

waxen plinth
#

It's not shaded because it does a hell of a lot more than just those 2 utility methods but for just those 2 it's not worth the plugin dependency

#

Yes, and toString and all the helper methods they use

hexed hatch
#

I rarely make anything configurable. Is it worth it to make a class that collects and caches all the configurable values or should I just grab them from the config object?

waxen plinth
#

Config is a hashmap

#

It's fine to get stuff directly from it

silver shuttle
#

why tf is there no method to just convert stuff -.-

waxen plinth
#

But you should avoid storing very large amounts of data in config

hexed hatch
waxen plinth
#

Because all of it is loaded into memory when you load it

hexed hatch
#

Yeah I don't plan on it for this little project

waxen plinth
#

Databases are better for large scale

hexed hatch
#

Well aware

waxen plinth
#

Ok

fallow dragon
#

is

silver shuttle
#

how

fallow dragon
#

ItemStack implements ConfigurationSerializable

#

That'sjust not for databases

silver shuttle
#

no I mena

hexed hatch
#

just be a sigma and convert it yourself

silver shuttle
#

I have a string and I want that string to become an itemstack

waxen plinth
#

Yes, it can be stored directly in config

#

My utility methods take advantage of that, the serializable aspects

silver shuttle
#

the string literally was an itemstack before it was put into the mysql

waxen plinth
#

Uses it to convert to json instead of yaml

fallow dragon
#

json is technically yaml iirc

silver shuttle
#

I am a total newbie

waxen plinth
#

Just using toString()

#

You'll need to store it by calling ItemUtils.toString first instead

#

Copy the toString and fromString methods from the ItemUtils class

#

And all the helper methods they rely on

#

Then copy everything in this package

silver shuttle
#

And I just put them into a class file somewhere in my plugin?

waxen plinth
#

Sure

ivory sleet
#

RedLib 😌

waxen plinth
#

You'll need yo copy the json package and make sure the imports for those methods are correct

waxen plinth
ivory sleet
#

Idk I use it for commissions

#

When I need to get something done fast

waxen plinth
#

Oh and Challenger, if you're using my code I would appreciate it if you give me credit 🙂

#

Just a small disclaimer is plenty

silver shuttle
#

sure will

waxen plinth
#

That's the whole idea so I'm glad it helps you

ivory sleet
#

But also crunch is my favorite

waxen plinth
#

❤️

ivory sleet
raw coral
#

hello mr redempt can u halp me again

waxen plinth
#

Sure

#

What do you need

raw coral
#

ok

#

so you were explaining how to

#

use linear interpolation to mimic a parabola

grim ice
#

guys is there a way i can get all the existing Indexes of a list

#

inside of an enum

waxen plinth
#

What

waxen plinth
#

Lerp takes 3 values

raw coral
#

yes

waxen plinth
#

The value to interpolate from

#

The value to interpolate to

#

And the ratio

#

The ratio is a value between 0 and 1

raw coral
#

yeah

waxen plinth
#

Currently you plug in values corresponding to the distance along the line for the ratio, right?

raw coral
#

yes

waxen plinth
#

What would happen if you plugged in 1 - Math.sqrt(ratio) instead

#

Actually I might have that backwards

#

One sec lol

grim ice
#

guys is there a way i can get all the existing Indexes of a list

grim ice
#

like instead of plugin.getConfig().getStringList("Cow.items").get(0)

waxen plinth
#

You can get the size of the list

grim ice
#

plugin.getConfig().getStringList("Cow.items").getAll()

#

smth like that

waxen plinth
#

.-.

grim ice
#

u didnt get me

#

i mean

waxen plinth
#

What would getAll() even do

#

size() returns how many elements are in the list

grim ice
#

instead of:

waxen plinth
#

The max valid index is size - 1

grim ice
#

plugin.getConfig().getStringList("Cow.items").get(1)
plugin.getConfig().getStringList("Cow.items").get(2)
plugin.getConfig().getStringList("Cow.items").get(3
)

waxen plinth
#

The min valid index is 0 if an element is present

grim ice
#

u do

waxen plinth
#

You want a loop..?

grim ice
#

plugin.getConfig().getStringList("Cow.items").getAll()

#

yes but loops dont work inside of an enum so

#

im looking for a different way

waxen plinth
#
for (String entry : plugin.getConfig().getStringList("Cow.Items")) {
  //Do stuff
}```
#

What do you mean "inside an enum"

#

You're trying to pass it as a parameter to an enum constructor?

grim ice
#

No

waxen plinth
#

Then what

grim ice
#

my shit is inside

#

an enum

#

public Enum shit {
}

waxen plinth
#

Just do Math.sqrt(r) instead of r

grim ice
#

breh.

waxen plinth
#

Alternatively you could do 1 - (1 - r)^2

raw coral
#

for(i in 1..10){
armorStands.add(SkyblockHolograms.createFloatingBlock(armorStand.location.lerp(armorStand3.location,i.toDouble()/10), ItemStack(Material.STONE)))
}

so instead of that do this

for(i in 1..10){
armorStands.add(SkyblockHolograms.createFloatingBlock(armorStand.location.lerp(armorStand3.location,Math.sqrt(i.toDouble()/10)), ItemStack(Material.STONE)))
}

waxen plinth
#

Jesus christ

#

Split that up lol

waxen plinth
#

Give me more details

#

"my shit is inside an enum" still does not explain ANYTHING

#

WHERE are you trying to put it

grim ice
#

1s

#

?paste

undone axleBOT
grim ice
#

i want to get all the indexes of a string list

#

from my config

#

and i cant use loops there

raw coral
#

also i hear square roots are expensive for cpu should i just store the values in like an array?

waxen plinth
#

Ok so it IS in an enum constructor

grim ice
#

yeah ig

waxen plinth
#

And good lord please don't do that to your code

#

Are you trying to make craftable spawn eggs or something?

vast sapphire
grim ice
#

decide the recipe

waxen plinth
#

Ah the classic "here is all of my code tell me what's wrong with it"

waxen plinth
grim ice
#

my whole code is based around that

#

i cant just change it

waxen plinth
#

There is already an enum for each mob in the game

grim ice
#

is there no way of doing what i wanted

waxen plinth
#

Sure there is

#

Use an EnumMap

#

Not an enum

#

You can map each EntityType enum to the data for that entity

grim ice
#

how to do that?

waxen plinth
#

And you can programmatically retrieve the spawn egg for each entity

vast sapphire
grim ice
#

uh its not only for spawn eggs

#

i have other items too

waxen plinth
#

Then you could make that configurable

fallow dragon
grim ice
#

HOW

waxen plinth
#

By allowing them to do

waxen plinth
#
COW:
  item: COW_SPAWN_EGG
  recipe:
  - item1
  - item2
  - etc```
#

Something like that

raw coral
#

Does this seem right

for(i in 1..10){
            var ratio = i.toDouble()/10
            ratio = 1-(1-ratio).pow(2)
            val location = armorStand.location.lerp(armorStand3.location, ratio)
            armorStands.add(SkyblockHolograms.createFloatingBlock(location, ItemStack(Material.STONE)))
        }
waxen plinth
#

Oh it's in kotlin lol

grim ice
#

wahat

vast sapphire
waxen plinth
#

Not sure why it took me so long to notice

grim ice
#

what

#

wdym kotlin

waxen plinth
spare prism
fallow dragon
vast sapphire
# spare prism Where do u save ur locations?
                                p.getTargetBlock((Set<Material>) null, 3).setType(Material.IRON_ORE);
                                blockLocation = (p.getTargetBlock((Set<Material>) null, 3).getLocation());
                                activeLocations.add(blockLocation);
                                if (activeLocations != null)
                                    p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Generator Placed at " + blockLocation.getBlockX() + ", " + blockLocation.getBlockY() + ", " + blockLocation.getBlockZ()));
                                    Generators.getInstance().getConfig().set("locations." + blockLocation.getBlockX() + ", " + blockLocation.getBlockY() + ", " + blockLocation.getBlockZ() + " " + blockLocation.getBlock().getType(), activeLocations);
                                    Generators.getInstance().saveConfig();
                                    }``` here
paper viper
#

Dude you can directly save the location itself

#

It’s serializable

chrome beacon
#

?conventions Also please ;/

undone axleBOT
paper viper
#

And also get a better name

vast sapphire
#

ok

paper viper
#

For that key

grim ice
#

Anyone knows how can i get all indexes of a list without loops? like instead of
plugin.getConfig().getStringList("Cow.items").get(1)
plugin.getConfig().getStringList("Cow.items").get(2)
plugin.getConfig().getStringList("Cow.items").get(3
)
u do plugin.getConfig().getStringList("Cow.items").getAll() or something. any ideas?

raw coral
#

did i do something wrong

grim ice
#

imagine no fairy souls

eternal oxide
#

getConfig().get("Cow.items").getKeys(false)

grim ice
#

thank you

raw coral
grim ice
#

t

#

does not

#

exist

raw coral
#

you need to

#

getConfigurationSection

#

not just get

fallow dragon
#

getConfigurationSection("Cow.items")

#

iirc

raw coral
eternal oxide
#

yep, getConfigurationSection not get

#

Hey its from memory here. Do some of the work yourself 🙂

fallow dragon
#

^

grim ice
#

if config is like items: [DIAMOND_SWORD, STICK]

#

will it return DIAMOND_SWORD, STICK

#

or

#

what

waxen plinth
eternal oxide
#

that is not a section, thats an array

grim ice
#

yes

waxen plinth
#

Oh wait I know what's wrong

raw coral
waxen plinth
#

You need to move the points up lol

#

I'm dumb sorry

raw coral
#

ah how do i do that .w.

waxen plinth
#

You don't need to move them further along the lerp line

#

You need to move them up

#

Do you need the third point?

raw coral
#

wdym

waxen plinth
#

Well

#

If you had only 2 points

#

And it automatically just created a curve up

#

Would that be acceptable to you

grim ice
raw coral
#

im auto generating the third point

#

well basically

#

my end goal

waxen plinth
#

Is to have it curve up

raw coral
#

i hjave a starting and an ending point

#

and i want a nice arch

waxen plinth
#

Yes, like a boost pad

raw coral
#

yea

waxen plinth
#

I knew it

#

Ok

#

Lerp straight from start to end

raw coral
#

ok

waxen plinth
#

But move the point up based on how far it is from the midpoint

#

Closer to the midpoint = higher up

eternal oxide
grim ice
#

no

eternal oxide
#

then stop using an enum

raw coral
#

*ok

#

thanks

grim ice
#

i dont know how to do anything else

eternal oxide
#

use a straight map as I told you earlier

raw coral
#

is there an equation i should use

grim ice
#

can you give me a brief idea of how to put stuff in it

#

ik map.put

#

but like the parameters

waxen plinth
#

Let's say l is the length of the line

#

And d is the distance to the midpoint

#

You could do something like this

#

height += sqrt(l/2 - d)

raw coral
#

and i know i want the highest point to be half the distance

#

because thats how i was generating my third point

waxen plinth
#

Yes, that would do it

#
val l = start.distance(end)
val mid = start.clone().add(end).multiply(0.5)
...
for (i in 0..10) {
  ...
  d = point.distance(mid)
  height += sqrt(l/2 - d)```
vast sapphire
# paper viper And also get a better name

I have this now java else { switch (args[0].toLowerCase()) { case "iron": p.getTargetBlock((Set<Material>) null, 3).setType(Material.IRON_ORE); blockLocation = (p.getTargetBlock((Set<Material>) null, 3).getLocation()); activeLocations.add(blockLocation); if (activeLocations != null) p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Generator Placed at " + blockLocation.getBlockX() + ", " + blockLocation.getBlockY() + ", " + blockLocation.getBlockZ())); Generators.getInstance().getConfig().set("generator locations." + blockLocation.getBlock().getType(), activeLocations); Generators.getInstance().saveConfig(); } }

grim ice
#

eeee

#

Anyone knows how can i get all indexes of a list without loops? like instead of
plugin.getConfig().getStringList("Cow.items").get(1)
plugin.getConfig().getStringList("Cow.items").get(2)
plugin.getConfig().getStringList("Cow.items").get(3
)
u do plugin.getConfig().getStringList("Cow.items").getAll() or something. any ideas?

#

3rd repost :D

waxen plinth
#

fngngfnjfjfjflf

#

What the fuck would getAll even DO??

grim ice
#

plugin.getConfig().getStringList("Cow.items").get(1)
plugin.getConfig().getStringList("Cow.items").get(2)
plugin.getConfig().getStringList("Cow.items").get(3)

#

the same as this

waxen plinth
#

Yeah of COURSE that won't work

#

What are you trying to do with them?

grim ice
#

but gets all the existing ones

#

get them

waxen plinth
#

You keep asking an inane question, of course nobody's giving you an answer

#

Get them how

#

A list already contains them all

#

They're all in there

#

What are you doing with them

grim ice
#

i want to get them all

grim ice
waxen plinth
#

Then getting the list already does that

#

They're all in the list

#

Your question makes no sense

grim ice
#

plugin.getConfig().getStringList("Cow.items")

#

gets all the indexes?

#

it does

waxen plinth
#

No, no it doesn't

#

You want them as an array?

#

You want them joined together as a single string?

#

What?

eternal oxide
# grim ice gets all the indexes?

example ```java
private Map<NamespacedKey, ShapedRecipe> recipes = new HashMap<>();

public RecipeManager(JavaPlugin plugin) {
    
    RecipeManager.plugin = plugin;
    
    ConfigurationSection section = plugin.getConfig().getConfigurationSection("recipes");
    for (String entry: section.getKeys(false)) {
        
        NamespacedKey key = new NamespacedKey(RecipeManager.plugin, entry.toLowerCase());
        ShapedRecipe recipe = new ShapedRecipe(key, new ItemStack(Material.matchMaterial(section.getString(entry + ".itemStack"))));
        
        //etc
        recipes.put(key, recipe);
    }
}```
grim ice
#

o

#

aa i dont understand iit well

#

certainly getKeys

waxen plinth
#

I don't even think you understand what you're asking for

grim ice
#

what

#

i do

#

im pretty sure elgar understood me

waxen plinth
#

You want to get all the items in a list

#

A list already contains all of the items

#

What else is there to be done

#

What would getAll do?

grim ice
#

wait what

#

@eternal oxide is what the guy said right

#

im confused af

waxen plinth
#

You have elements in a list

#

You want to "get all of them"

#

You can put them into an array

grim ice
#

no

#

Required type:
String

Provided:
List
<java.lang.String>

waxen plinth
#

So you want to get the first element..?

eternal oxide
#

Just fill in the //etc section to create your recipe

grim ice
#

getting the list does not give all the lements

grim ice
#

to do that

#

for

#

every recipe

eternal oxide
#

there is already a for loop

grim ice
#

oh wait fuck

eternal oxide
#

so "recipe.cow" "recipe.zombie"

grim ice
#

o

eternal oxide
#

that for loop grabs everything under recipe

grim ice
#

.itemStack"

#

why that

#

".itemStack"

#

im getting rid of the enum so i dont think uh

eternal oxide
#

so you have recipe.cow.itemstack: COW_SPAWN_EGG

grim ice
#

my config? no

#

Cow:
matrix1: " D "
matrix2: " D "
matrix3: " S "
order: "DS"
items: [DIAMOND_SWORD, STICK]

eternal oxide
#
recipe:
  cow:
    itemstack: COW_SPAWN_EGG
    //etc```
grim ice
#

i=o

#

ok

waxen plinth
#

Ok so you have a list of items

#

What are you trying to do with the elements of that list

grim ice
#

so ok

#

ill get rid of the enum ig

eternal oxide
#

if you remember from teh enum you specify the ItemStack that is going to be the result

grim ice
#

yes

waxen plinth
#

Look, I really can't help you if you won't specify anything

#

I give up

eternal oxide
#

so you need to include that along with all teh other things like matrix

grim ice
fallow dragon
#

where even is this enum

eternal oxide
#

from example code I wrote for him a week back?!

fallow dragon
#

oh, he material

#

the

eternal oxide
# grim ice o

you can get rid of matrix1 etc, as you are going to a config use matrix: ["AAA", "BBB", "CCC"]

#

no point in keeping them seperate when you will be putting them into an array

grim ice
#

o

#

do i remove

#

addRecipes()

eternal oxide
#

yes, but you will reuse some of its code

grim ice
#

UHH

eternal oxide
#

you put it in the yml as I just showed you

grim ice
#

recipe:
cow:
itemstack: COW_SPAWN_EGG
matrix1: [DDD, SSS, DDD]
order: "DS"
items: [DIAMOND_SWORD, STICK]

#

like that

#

but what i meant is how to get the matrix, when shaping the recipe

eternal oxide
#

String[] matrix = (String[]) section.get("matrix");

grim ice
#

oh right

eternal oxide
#

should work fine

grim ice
#

do i specify

#

specify

#

the index

#

like matrix[0], matrix[1]..etc

eternal oxide
#

no

grim ice
#

mhm so matrix alone is fine

#

okay

eternal oxide
#

you just have one matrix

#

thinking about it that cast may not work. You'll have to test it

grim ice
#

o

#

frick

#

why do u even cast though?

eternal oxide
#

its an easy change if it errors

vast sapphire
#

What do I do to save my activeLocations location array to the config so it saves after reload/restart, it's my first time working with configs

floral flare
#

If anyone can help me with this problem:

#

If I have several numbers in an int variable, is there any way I can select only the largest number?

waxen plinth
#

You mean int[]?

vast sapphire
waxen plinth
#

Or do you have multiple bytes packed into an int or something

#

Cause if you have an int array

#

Arrays.stream(arr).max().getAsInt() will do the trick

grim ice
waxen plinth
#

If it's a list

grim ice
#

but

waxen plinth
#

list.stream().max(Comparator.comparingInt()).get()

grim ice
#

is there a method for string lengths

eternal oxide
#

Do the same to get your items

eternal oxide
#

yes string has a length

grim ice
#

hmmm

#

tbh tbh

eternal oxide
#

.length()

grim ice
#

o

#

OH I WAS USING get

#

not getString

#

my bad

#

@eternal oxide

#

but

#

i dont find it making sense

#

like

eternal oxide
#

what bit?

grim ice
#

here

#

ConfigurationSection section = plugin.getConfig().getConfigurationSection("recipes");

        String[] matrix = section.getObject("matrix", String[].class);
#

like

#

there isnt only 1 matrix

#

there are multiple

#

like

eternal oxide
#

yes there is, in each recipe

grim ice
#

cow:

rabbit:

#

but u didnt specify the path

#

like it should be recipe.cow.matrix

#

not recipe.matrix

eternal oxide
#

You don;t need to. section is only whats under recipes

grim ice
#

hmmm

#

okay i guess

eternal oxide
#

thats why you get a section so you can loop and not need to know any paths

#

its literally like cutting out that section of the file

silver shuttle
#

Umm for some reason I can not import gson

grim ice
#

o

silver shuttle
#

Like I have the library, added it to maven but IntelliJ doesnt let me use it in code

#

Auto import doesnt work aswell

eternal oxide
# grim ice o

oh you do have a point though, you do need to include the entry

#

so java String[] matrix = section.getObject(entry + ".matrix", String[].class);

grim ice
#

o

eternal oxide
#

teh entry is like cow, zombie

grim ice
#

btw

eternal oxide
#

from the for loop

grim ice
#

entry can be used

#

to return the name

#

right

eternal oxide
#

yes

grim ice
#

Okay pog

#

wait

#

what did data.materialKey.length() mean again

eternal oxide
#

thats how many items

#

so your order

grim ice
#

o

eternal oxide
#

how many chars in your order must match the number of elements in yoru items array

#

so getString("entry + ".order")

grim ice
#

uh

waxen plinth
#

If you're trying to get the max digit in a string

#

You don't need to do all that

#

You can just do string.chars().map(i -> i - '0').max().getAsInt()

floral flare
#

Ok

waxen plinth
#

Or better yet

#

string.chars().max().getAsInt() - '0'

grim ice
#

aaa

#

how do i fix Array access 'section.getObject(entry + ".order".charAt(i), items.[i]' may produce 'NullPointerException'

#

i tried many stuff they dont seem to work

waxen plinth
#

It's just a warning

#

You can ignore it

grim ice
#

aefjoawhefuahwfeoauwefoawef

#

for (int i = 0; i < section.getString("items", "").length(); i++) {
recipe.setIngredient(section.getObject(entry + ".order".charAt(i), items[i]);
}

eternal oxide
grim ice
#

?paste

undone axleBOT
grim ice
#

i didnt finish it yet and its all shit but here is it

eternal oxide
grim ice
#

o

#

why are my asserts gone though?

#

assert section != null;
..etc

eternal oxide
#

asserts are a waste of time, they are not used at run time

#

you could add a check for data and section to see if they are null

grim ice
#

o

eternal oxide
#

if section is null return, if data is null continue

grim ice
#

section cannot be null

#

wait

#

wtf

eternal oxide
#

outside the for loop it can

#

inside it can't

grim ice
#

im commiting ....

#

Argument 'data.getString("itemStack")' might be null

#

if(data.getString("itemStack") != null)
continue;
if(Material.matchMaterial(data.getString("itemStack")) == null)
continue;

#

i legit fucking checked if its null 1 line before ??

eternal oxide
#

you have to use a variable, else your IDE does not know its teh same thing

#

so String item = data.getString("itemstack)

#

then null check item

grim ice
#

ok

#

String item = data.getString("itemStack");
if(item != null)
continue;
if(Material.matchMaterial(data.getString("itemStack")) == null)
continue;

#

still

#

same thing

eternal oxide
#

yeah, your ide is annoying. one sec

grim ice
#

Argument 'matrix' might be null

#

Method invocation 'length' may produce 'NullPointerException'

#

Argument 'Material.matchMaterial(data.getString("itemStack"))' might be null

eternal oxide
#

throw your ide in the bin

fluid cypress
#

this is annoying, isnt there a plugin or something for intellij idea that checks for declared commands on plugin.yml?

grim ice
#

i have 6 nulls

#

LMAO

eternal oxide
#

yeah, and they are in a try/catch. Your ide shoudl not care at that point

grim ice
#

yeah ok but now uh

eternal oxide
#

change the NPE to Exception

grim ice
#

o

eternal oxide
#

a catch all shoudl shut it up

grim ice
#

ur talking with misdoc?

#

wait

#

i changed to Exception

#

same thing

#

LOLOLOLOLOLOL

eternal oxide
#

Yeah, eff InteliJ.

grim ice
#

so uh

#

do I rewrite my recipes

#

in config.yml

eternal oxide
#

Stupid IDE is intelligent enough to warn but not cleaver enough to see that it doesn;t matter

quaint mantle
#

how to make a countdown when logging on to the server, with lvl replenishment every second?

#

how to make a countdown when logging on to the server, with lvl replenishment every second?

#

dont spam

eternal oxide
quaint mantle
#

ok

eternal oxide
#

for now config is fine

grim ice
#

o

#

ok

#

oh god

#

i have to write 50 recipes again

#

AAAA

#

i mean if it works, its worth it

grim ice
#

@eternal oxide wait

#

i forgot smth

quaint mantle
#

can we English please

#

как сделать обратный отсчет при входе на сервер, с пополнением lvl каждую секунду?

grim ice
#

the Player join event

eternal oxide
#

yes

floral flare
eternal oxide
floral flare
# floral flare Can this code work?
                    int[] tab = {account.getID()};
                    IntSummaryStatistics stat = Arrays.stream(tab).summaryStatistics();
                    int max = stat.getMax();
                    System.out.println("Max = " + max);```
grim ice
#

Unknown class: 'recipes'

#

what the fuck

waxen plinth
#

And if you only use max why get the whole summary statistics

eternal oxide
grim ice
#

for (recipes recipe : recipes.getKeys(false)) {

floral flare
grim ice
#

or do i send everything

eternal oxide
floral flare
grim ice
#

o

#

what

#

w h a t

eternal oxide
#

for (NamespacedKey recipe : recipes.keySet()) {

#

or close to that

grim ice
#

o

waxen plinth
#

You make an array

#

Put only one element in

#

And then try to get the max

#

What are you expecting to happen

#

It will always just return whatever that one value you put in is

grim ice
#

uhhh

grim ice
#
  1. how do i add enchants
#
  1. how do i check the recipe name
grave sparrow
#

Itemmeta.addEnchant

grim ice
#
  1. how am i supposed to disable certain recipes with their name
#

thats the problem with not using enums :<

eternal oxide
#

exactly as you have already done for disabling.

grim ice
#

what I was doing was getting the enum name

eternal oxide
#

you can get teh name from teh NamespacedKey

#

afk 5 mins

grim ice
#

o

honest iron
#

Hello, my vault isn't hooking for some reason:

[23:04:47 INFO]: [Vault] Economy: null [null]
[23:04:47 INFO]: [Vault] Permission: SuperPerms [SuperPerms]
[23:04:47 INFO]: [Vault] Chat: None [null]```
#

ill show the code in sec

#
        economyImplementer = new EconomyImplementer();
        vaultHook = new VaultHook();
        vaultHook.hook();
    }```
#

this is on my main

#
    private Main plugin = (Main) Main.getPlugin();
    private Economy provider;

    public void hook() {
        provider = plugin.economyImplementer;
        Bukkit.getServicesManager().register(Economy.class, this.provider, Main.getPlugin(), ServicePriority.Normal);
        Bukkit.getConsoleSender().sendMessage(Main.f("&b[&3!&b] &aVaultAPI hooked!"));
    }

    public void unhook() {
        Bukkit.getServicesManager().unregister(Economy.class, this.provider);
        Bukkit.getConsoleSender().sendMessage(Main.f("&b[&3!&b] &aVaultAPI unhooked!"));

    }```
this is my VaultHook class
#

it sends VaultAPI hooked

eternal oxide
#

ok I'm back

ivory sleet
#

Unhook anything before hooking

honest iron
ivory sleet
#

Like iirc some impls register a higher priority

honest iron
#

how do i make my plugin hook first

ivory sleet
#

Try with ServicePriority.Highest

honest iron
#

i mean highest

ivory sleet
#

First

honest iron
#

same issue

#

i don't have any other economy plugin

grim ice
#

i am committing suicide right now

honest iron
#

it still says to my console [!] Hooked

ivory sleet
#

Hmm okay and your plugin depends on vault?

grim ice
#

i hate intelliJ

ivory sleet
#

Use notepad++ then

grim ice
#

LOOK AT HOW MANY NULLS R THERE WTF

grim ice
honest iron
#
  • its easy
ivory sleet
#

Won’t yield any warnings

grim ice
#

no shit im using eclipse

#

it sucks

steep nova
#

lol

grim ice
#

well thats my opinion

ivory sleet
#

It’s actually good

grim ice
#

i mean yeha

ivory sleet
#

Just ridiculous UI arguably 🤒

honest iron
#

K as conclure said Notepad++ won't give u any errors/stuff

eternal oxide
#

I use Eclipse, because I don;t need an IDE nagging me.

grim ice
#

tbh

#

u can say intelliJ is more for beginners

#

since its kinda easy to use

eternal oxide
#

Its really more for corporate

grim ice
#

I tested both

#

I tried both

grim ice
#

intelliJ way easier to use

eternal oxide
#

yes it is

#

easy is not alwasy best

grim ice
#

yep

honest iron
#

IntelliJ is hard for me eclipse is super ez for me

snow vector
#

How would I get if onDisabled has been called in a separate file? I have a system for functions setup, but don't get how I would add it to a Boolean

grim ice
#

ANYWAY

#

can i get intelliJ to stop fucking with me

#

what fuckery is this