#help-development

1 messages · Page 1620 of 1

proven sierra
#

well that was never it

#

playerConnection

#

but md obfuscated it :D

#

because spiget!

vagrant galleon
#

ahhhh

#

Do you know to do this?

craggy cypress
#

If i use DecimalFormat("0.00") to store a double in the config, It wil place a double like this: 100,00 instead of 100.00

#

How can i fix that?

dense goblet
#

@smoky finch

float f = 0.1f;
float a = 3;
Vector fwd = location.getDirection().toVector();
fwd.y = 0;
fwd.normalize();
Vector right = Vector.rotate(fwd, Y, 90) //whatever the function actually is
for(float i = 0; i <= distance; i += increment) {
    float offset = 2*a*(Math.abs((i*f % 1.0f) - 0.5f) - 0.25f)
    Location loc = location.clone().add(fwd*i).add(right*offset);
}
smoky finch
#

What's \*?

dense goblet
#

Oops

smoky finch
#

Oh you were trying to escape it

tame coral
#

yeah those are markdown escape characters

dense goblet
#

Forgot you don't need to escape them in code blocks

kind coral
dense goblet
#

double round(double d, int precision) {
int mult = Math.pow(10, precision);
return Math.round(d*mult)/mult;
}

smoky finch
# dense goblet <@416294920895332384> ```java float f = 0.1f; float a = 3; Vector fwd = location...

https://imgur.com/a/1bvKbAL

new BukkitRunnable() {
    double distance = 1;
    static final double maxDistance = 10;
//    boolean odd;
    float f = 0.1f;
    float a = 3;
    Vector fwd = location.getDirection().setY(0).normalize();
    Vector right = fwd.rotateAroundY(Math.toRadians(90));

    @Override
    public void run() {
        double offset = 2*a*(Math.abs((distance*f % 1.0f) - 0.5f) - 0.25f);
        Location loc = location.clone().add(fwd.clone().multiply(distance)).add(right.clone().multiply(offset));
        player.getWorld().spawnParticle(Particle.FLAME, loc, 1,0,0,0,0);
        if (distance++ >= maxDistance) cancel();
    }
}.runTaskTimerAsynchronously(plugin, 0L, 3L);
#

Wait I think I figured it out

#

Oh wow it actually worked

#

I just forgot to fix your clone() on the right vector

#

I still gotta understand what the hell is happening here, but thanks a lot

torn shuttle
#

quick q because I've not used lambdas that much, if I create a bukkit task using Bukkit.getScheduler().runTaskLater(plugin, (task)->{}, 20L}; is there a way for me to store a reference to the task outside of the task itself?

smoky finch
#

Nope, use a BukkitRunnable like I'm doing above ^

torn shuttle
#

that's what I was doing previously but then every time I post any code with one people go on a witch hunt for not using lambda expressions

smoky finch
#

Huh really?

eternal night
#

if you want the bukkit task on the outside, you could use the runTaskLater with a Runnable

torn shuttle
#

oh yeah.

eternal night
#

store the returned BukkitTask in an AtomicReference

#

and access inside if you need it inside

#

should be pretty safe concerning the Scheduler never ticks the runnable on the method stack it is scheduled

torn shuttle
#

I heard some mixed feelings about atomic reference previously, I mean is there a point in using lambda expressions if it requires these workarounds?

eternal night
#

tbh I have no idea why the method does not return the task as well

torn shuttle
#

I do feel like it should return the task id

eternal night
#

well no the ID

#

those times are behind us

torn shuttle
#

or the task itself

#

either works for me

#

something at least

eternal night
#

Yeaaa idk why it isn't returned

torn shuttle
#

guess I'll just use the good old method for now

#

not worth the hassle

#

thanks

summer scroll
#

Can we add tab completer without command?

#

Or the text suggestion I should say.

tough bay
#

Can someone help me with my code?

#

I wanna write something in a file when someone is using a command imgame

#

whats wrong with my code

wraith apex
#

where is your code

tough bay
#

package eu.hausgans.dc;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.FileWriter;
import java.io.IOException;

public final class Main extends JavaPlugin {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    try {
        FileWriter myWriter = new FileWriter("test.txt");
        myWriter.write("Files in Java might be tricky, but it is fun enough!");
        myWriter.close();
        System.out.println("Successfully wrote to the file.");
    } catch (IOException e) {
        System.out.println("An error occurred.");
        e.printStackTrace();
    }
    sender.sendMessage("Dein Discord Name Wurde Verifiziert!");
    return true;
}

}

maiden briar
#

How can I get rid of You have no bed or respawn anchor message?

wraith apex
#

works fine

#

although usually you might want to save it to your plugins data folder

tough bay
#

If i use the command there got nothing in the file it only is printing ingame Dein Discord Name Wurde Verifiziert!

#

the test.txt is empty

wraith apex
#

where is text.txt being saved to?

#

where does it appear in the server files?

tough bay
#

But i put it there the plugin should only write in and not create it

#

Oh i am lost

#

It works

#

thanks ^^

wraith apex
maiden briar
#

I have fixed with setting 0,0,0 as bedspawn location

wraith apex
#

ah ok

tough bay
#

How i can get the name of the Player in a Variable?

#

the player who used the command!

wraith apex
#
CommandSender sender;
Player p = (Player) sender;
tough bay
#

is p the variable?

wraith apex
#

I usually universally just call Player p

#

you don't have to name the variable p

tough bay
#

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
FileWriter myWriter = new FileWriter("/home/DC-Verify/DC.txt");
Player p = (Player) sender;
myWriter.write("Jemand ist ein Kek z.B. " + p);
myWriter.close();
System.out.println("Successfully wrote to the file.");
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
sender.sendMessage("Dein Discord Name Wurde Verifiziert!");
return true;
}

}

wraith apex
#

Do note that the cast will fail if it is the console executing the command not the player
Some people might do the following instead

// Check the CommandSender is not the console
if(!(sender instanceof Player)) { return; }
Player p = (Player) sender;
tough bay
#

is that right?

wraith apex
#

I'd imagine home is the name of your plugin data folder?

tough bay
#

Yes but I wanna use it with a discord bot

#

but is the thing with the player right?

wraith apex
#
// This is more reliable if the name of the data folder changes
new FileWriter(this.getDataFolder() + File.separator + "DC-Verify" + File.separator + "DC.txt");
#

this.getDataFolder() will work in your main class. The class extending JavaPlugin

hybrid spoke
#

Player#getName
p.getName()

wraith apex
#

Adding the player on the end will not print their name

hybrid spoke
#

otherwise you will just get the #toString result

wraith apex
wraith apex
flat kindle
#

Are there any other reasons we want to prevent a console/non player from executing a command,besides some obvious errors it would cause in most use cases?

smoky finch
hybrid spoke
wraith apex
#

fairs

wraith apex
eternal oxide
#

an int yes

wraith apex
#

like interacting with blocks, opening GUI's, hitting mobs etc.

hybrid spoke
flat kindle
flat kindle
#

Security etc?

hybrid spoke
#

no

#

just the fact that the console isnt a player

#

and cant have a location, cant get opened an inventory

#

etc

wraith apex
#

Console is above op

#

but if you really wanted to, for security reasons you could prevent the console executing certain commands

#

if say, you wanted to mandate that a command be executed by a player on the server even though it may not require it from a technical point of view

torn shuttle
#

?paste

undone axleBOT
torn shuttle
#

it seems really straightforward

wraith apex
#

It doesn't technically have to

#

For instance all you really need is the 3 second delay or x number of seconds as the delay

quaint mantle
#

is it possible to change a players skin without them rejoining the server?

quaint mantle
#

put the code in a runnable?

torn shuttle
wraith apex
torn shuttle
#

and 3 seconds is a frustrating amount of time to wait for something that was cancelled without you knowing

wraith apex
#

if they move you can cancel it

torn shuttle
#

that's what I was doing before and it was using even more power

#

as it would

wraith apex
#

Ah, you're trying to do this using fewer cycles

#

Ok

#

how about this

torn shuttle
#

I'm fine with a tops 1s delay between notifications for performance reasons but this is using silly amounts of power

#

how is it even doing that

lavish wave
#

I want to automaticly update my plugin from spigotmc

wraith apex
#

A HashMap containing a entries of teleports that are about to happen. When requesting to teleport, you can add a Class containing the source and destination locations of the teleport and the player. Right after adding it, you can create a runnable that after 3 seconds will remove it from the hashmap, check if it's null, and then procceed to teleport of the source location matches the players current location

#

that way you will not have to deal with cancelling

#

it gets removed from the map anyway

torn shuttle
#

that's basically what I'm doing but with extra steps

wraith apex
#

ah

torn shuttle
#

and fewer cancellable abilities

wraith apex
#

well besides the playermovementevent that seems like an optimal solution for fewer cycles

torn shuttle
#

I mean did you read the class

#

I can't imagine a task that would use fewer cycles and still notify people of cancellations

lavish wave
#

Can someone please help me? I want to update my Plugin automaticly. I have code a Downloader so what is the url?

wraith apex
#

which makes sense, you could deploy malicious code to the server through an update

#

which is why spigot doesn't allow this. Other plugin hosting sites I'm not sure on.

#

You can still do this though

#

but you're not going to be able to host the plugin on spigot

torn shuttle
#

also might be possible to update based on a prompt

wraith apex
torn shuttle
#

as long as it requires admin interaction

wraith apex
#

my implementation would of been to move all the code in the runnable outside of the runnable

#

since you don't need it in there anyway

torn shuttle
#

it only ever is used by the runnable, not much of a point in extracting it

wraith apex
#

I meant from a space complexity standpoint you could have that code in the remove method of the hashmap

#
1. Someone requests teleport
2. Add a class to a map that holds the source and destination location Map<UUID,TeleportRequest>
3. After adding this class run a new DelayedTask to call a method to handle the removing of the teleport request from the map 3 seconds later
4. When the delayed task calls your remove() method you can grab the TeleportRequest class and run your checks before then deciding to teleport the player or not
#

This means you never have to mess with cancelling the BukkitRunnable

torn shuttle
#

I mean I would since I am still going to be checking and notifying players if the teleport was cancelled on every second

wraith apex
#

Looking at your class idk why you're running it every 20 ticks if you wanted to wait 3 seconds

#

Oh

#

I see

torn shuttle
#

I don't want people to wait 3 seconds just to let them know it was canceled 0.5 seconds into it

#

feedback-wise that is terrible

wraith apex
wraith apex
smoky finch
#

Is location.getDirection() always a normalized vector?

#

Am I right

wraith apex
#

Well your best options are what you have now or the movement event

torn shuttle
#

the question I have here is not how to do it differently but rather how is it using so much power

#

or at least reporting that it is using so much power

#

hm I wonder

#

is it because it is passing the same performance impact as the teleport event which is passing the performance impact of all the chunk loads somehow?

#

that would be the only thing that actually makes sense to me

#

I guess technically the teleport is in the task

#

and the teleport causes chunk load

#

so this is chunk load lag?

wraith apex
#

nope it's not normalized

wraith apex
smoky finch
#

"unit-vector" = normalized...?

wraith apex
#

sorry, other way around

#

my head is not working today

smoky finch
#

lol

wraith apex
#

but I do think the fact you're making IO calls each second the teleport counts down might be a factor

#

Grabbing stuff from the config file every second

tardy delta
#

to check if a plugin is activated can i just use bukkit.getpluginmanager.getplugin(... != null) ?

wraith apex
#

instead of grabbing it during server startup and storing it somewhere

wraith apex
#

As long as the name is correct

#

which may not be the same the name of the jar

torn shuttle
wraith apex
#

why would it be cached?

proud basin
#

l would like to personally bump this

wraith apex
#

I'm not seeing any variables for caching

torn shuttle
#

ok so I was right actually regarding the chunk loading

#

a plugin I was using was adding a 26% overhead to chunk loads

#

and the teleport event was indirectly reporting it

#

I disabled the plugin and the exact same code uses ...

#

actually idk it dropped off the timings

wraith apex
#

so an external plugin caused it

wraith apex
torn shuttle
#

a plugin was messing with chunk loading and that was reporting chunk load performance indirectly

#

so yeah

wraith apex
#

What is an IPlayer?

torn shuttle
#

it's been a hot minute since I've seriously looked at timings, I need to get into it more

wraith apex
#

timings is awesome

torn shuttle
#

yeah just been too busy doing a rewrite to look at them, now that the rewrite is done I'm collecting user timings to improve performance

wraith apex
#

could alternatively run that on another thread

torn shuttle
#

I do hope spigot will get to use timings v2 at some point, though at this stage it's looking unlikely

wraith apex
#

does it not already?

hybrid spoke
wraith apex
#

So.. just Player

hybrid spoke
#

its a naming convention for interface and subclass with the same name

torn shuttle
#

unless my memory is actively failing me I am almost dead certain I've gotten a timings v1 report for a pure spigot 1.17.1 server just a couple of days ago

wraith apex
#

You might have, I've not used pure spigot for years

#

mosty Paper or Tuinity

torn shuttle
#

also I went and double checked, yes I am pulling the config values from cached files

#

not io ops

wraith apex
#

is ConfigValues a custom class of yours then?

torn shuttle
#

sorry cached configs

wraith apex
#

that caches

torn shuttle
#

yeah it is one of mine

wraith apex
#

ah fairs

torn shuttle
#

old system from 2017, legacy garbage at this point

wraith apex
#

haha

torn shuttle
#

i'm gradually phasing it to cached final values instead

wraith apex
#

code we wrote a year ago can be considered garbage

torn shuttle
#

a year ago? code from 3 weeks ago is garbage

wraith apex
#

:pog:

#

awww

#

:c

torn shuttle
#

wanna see my shiny new config system

wraith apex
#

Haha sure

hybrid spoke
#

code one second ago is garbage cries

wraith apex
#

Code a few nano seconds ago tho

torn shuttle
#

?paste

undone axleBOT
hybrid spoke
#

it seems fine

#

...until i compile...

torn shuttle
wraith apex
#

md 5 secretly collects code in his paste bin and uses it to compile a hung over confused AI

hybrid spoke
#

your comments be like

// this is a player
Player player = (Player) sender;
torn shuttle
#

my comments?

wraith apex
#

dear lord the number of try catches

torn shuttle
wraith apex
torn shuttle
#

though they can probably be condensed a bit

hybrid spoke
#

fuck exceptionhandling

#

just do it like a real man

wraith apex
#

if the code is obvious at face value, don't need no comments

#

if its not super obvious then commenting helps

ancient whale
#

Hey, I saw that ppl sometimes serializes stuff (like itemstacks) in base64 instead of using the one provided, is this a better way to do it ?

wraith apex
#

like for some complicated math function

hybrid spoke
#

you should also name your classes, methods and variables so you dont even have to describe it

#

because its doing it on theirselfs just by the names

torn shuttle
tardy delta
#

return Bukkit.getServer().getPluginManager().isPluginEnabled("Vault");

hybrid spoke
#

what are you doing

tardy delta
#

registering a vault listener if vault is activated

torn shuttle
#

yeah that would prolly work

#

it's how I do it

hoary knoll
#

anyone know how to fill a map without travelling using a custom MapRenderer

dense goblet
wraith apex
#

Load all the chunks required for the map to render.
Depending on the map scale, grab the colour of each block.
Use MapCanvas to set each pixel of the map

tardy delta
#

what would be the best way to give a player rewards for their onlinetime

#

like every hour they get some coins

#

but i have to figure out a way to check their time

wraith apex
#

then you don't have to be constantly checking

tardy delta
#

and i probably want to store their time in a file

#

in case they leave.

#

?

hybrid spoke
#

cache it and if they leave write it to a file

wraith apex
#

in the event they leave:

- Create a Date object and get the time value (should be a long type)
- When they come back on you can do some math and create a new delayed task with the time remaining
left swift
#

why this send mi message two times?

    @EventHandler
    public void onInteract(PlayerInteractAtEntityEvent e) {
        Player p = e.getPlayer();

        if (e.getRightClicked() instanceof ItemFrame) {
            p.sendMessage("//");
        }
    }```
left swift
tardy delta
#

lemme figure it out

hybrid spoke
#

check the hand

#

you have a e.getHand method

#

check if its EquipmentSlot.HAND

wraith apex
#

^

hoary knoll
#

how do you get the number of blocks per pixel from the scale?

#

MapView.Scale

astral acorn
#

hi

#

im learning how to make pluggins

chrome beacon
#

Hi

astral acorn
#

i just made that hello plugin which ig every new plugin maker makes at first

#

im having trouble testing it tho

#

u see, the problem is that i play the free version of minecraft

#

from

chrome beacon
#

Buy the game

pulsar zenith
#

We dont support piracy

hybrid spoke
#

we are just pirates

kind coral
hybrid spoke
#

since you didnt provide code

#

i cant say more

kind coral
#

ehm its a yaml issue not code

#

so i mean

hybrid spoke
#

password: "C6BEu(}p^\<sHz2A" that your password?

kind coral
#

yes

hybrid spoke
#

nice

kind coral
#

so? its localhost

hybrid spoke
#

idc i will hack your localhost

kind coral
#

kk

hybrid spoke
#
    at com.astral.roleplay.managers.ConfigManager.load(ConfigManager.java:142) ~[AstralRolePlayCore-1.0-SNAPSHOT.jar:?]
    at com.astral.roleplay.managers.ConfigManager.reload(ConfigManager.java:96) ~[AstralRolePlayCore-1.0-SNAPSHOT.jar:?]
    at com.astral.roleplay.managers.ConfigManager.create(ConfigManager.java:57) ~[AstralRolePlayCore-1.0-SNAPSHOT.jar:?]
    at com.astral.roleplay.managers.ConfigManager.create(ConfigManager.java:68) ~[AstralRolePlayCore-1.0-SNAPSHOT.jar:?]
    at com.astral.roleplay.managers.ConfigProcessor.<init>(ConfigProcessor.java:11) ~[AstralRolePlayCore-1.0-SNAPSHOT.jar:?]
    at com.astral.roleplay.Roleplay.<init>(Roleplay.java:28) ~[AstralRolePlayCore-1.0-SNAPSHOT.jar:?]
wraith apex
hybrid spoke
wraith apex
#

Map view has 5 different levels

quaint mantle
#

Does anyone know how to use ItemMeta.addEnchantments()
I'm trying to add multiple enchants with just one line

wraith apex
#

Closest is zoom step 0

#

Farthest is zoom step 4

wraith apex
tardy delta
#

is there a way to let my command override the essentials one?

quaint mantle
kind coral
wraith apex
#

meta.addEnchantments() is not a method of meta

#

its a method of ItemStack

quaint mantle
#

o ok

kind coral
hybrid spoke
#

https://paste.md-5.net/ nice

#

your configprocessor and configmanager would be important

#

since the error is coming from there

wraith apex
# quaint mantle o ok
stack.addEnchantments(new HashMap<Enchantment,Integer>() {{
    put(Enchantment.DAMAGE_ALL,2);
    put(Enchantment.ARROW_DAMAGE,2);
}});
hybrid spoke
wraith apex
tardy delta
#

oh oky

wraith apex
#

The command map is full of commands without a fall back prefix, and commands with their fall back prefixes.

#

for example essentials will add

eco
essentials:eco
left swift
#

how can i change itemstack durability? i use normal method setDurability() but it is deprecated and it doesn't work for me

wraith apex
#

Bear in mind this doesn't "set" the durability, this sets the amount of damage that will be taken away from the items total durability

#

weird, I know

#

If you want a "Set Durability" method, you can use mine

#
/**
 * Sets the durability of the item
 * 
 * <p>Durability values that go beyond the materials maximum will be set
 * to the materials maximum and values that go below 1 are set to 1.
 * @param dura The new durability of the item
 * @return ItemBuilder
 */
public void setDurability(int dura)
{
    if(stack.getItemMeta() instanceof Damageable)
    {
        ItemMeta meta = stack.getItemMeta();
        int durability = stack.getType().getMaxDurability();
        
        if(dura > 0 && dura <= stack.getType().getMaxDurability())
        {
            durability = stack.getType().getMaxDurability() - dura;
        }
        else if(dura <= 0)
        {
            durability = stack.getType().getMaxDurability() - 1;
        }
        else if(dura > stack.getType().getMaxDurability())
        {
            durability = 0;
        }
        
        ((Damageable) meta).setDamage(durability);
        stack.setItemMeta(meta);
    }
}
eternal night
#

imagine cloning item meta twice 😢

wraith apex
#

?

tardy delta
#

is the plugin called Essentials or EssentialsX?

wraith apex
#

EssentialsX is the modern version yes

#

Essentials was the og

paper viper
kind coral
#

how can i get \< without parsing it ( YAML )

paper viper
#

getItemMeta returns a copy

wraith apex
#

imagine caring about pre optimisation

paper viper
#

I mean it is pretty heavy sometimes lol

eternal night
#

With item meta you probably should

#

yea

maiden briar
#

How can I limit drops? Like if there are already 40 iron ingots, I will stop spawning more of them

hoary knoll
#

@wraith apex how do I get the byte of a specific color in MapCanvas#setPixel(int, int, byte)?

wraith apex
eternal night
#

probably not xD

wraith apex
wraith apex
ancient whale
wraith apex
#

The reason is if methods change or new variables are introduced into ItemStack, base64 don't care

#

it will turn everything into a neat string

paper viper
#

The two ints are for the X and Y coordinates of the canvas and the byte is the color from the map palette

wraith apex
#

I also believe that the inbuilt one doesn't save a few other things

paper viper
#

Because Map colors are limited unfortunately to a byte

#

And are stupid and don’t support full RGB

wraith apex
#

xD

#

Map colours be like

#

256 colours is all you get

#

which is a tad sad :c

wraith apex
#

ah found the list

#

@hoary knoll

hoary knoll
#

i was just looking at that but they are all deprecated

wraith apex
#

I wonder if it's because any byte can be accepted as a colour?

#

0-255?

left swift
wraith apex
#

((Damageable) meta).getDamage();

hybrid spoke
#

?jd

wraith apex
#

Honestly, for durability I think I'll spoonfeed. The docs really don't help with how tf you get durability the new way

#

the docs lack examples of use

hybrid spoke
#

they do

#

just read the @deprecated comment

#

they directly lead to Damageable#getDamage

wraith apex
#

Yeah this

#

This is not an example

hybrid spoke
#

yeah, what can you misunderstand?

wraith apex
#

Damageable.setDamage

hybrid spoke
#

"is now a part of Damagable"

wraith apex
#

where and how do you get an instance of Damageable

#

is what I would of loved to know a few years ago

hybrid spoke
#

its an interface

#

there is none

#

obv.

wraith apex
#

Yeah I eventually worked that out

dense goblet
#

You cast the meta :)

#

These things should be better documented tbh

wraith apex
#

I know you can cast it, my point is for people who don't have the book of knowledge on spigot, an example would of been nice

dense goblet
#

Also pls javadocs in the api

wraith apex
#

literally just ((Damageable) meta).setDamage(int); would of been fine

chrome beacon
dense goblet
#

I haven't been following the convo

chrome beacon
#

Might be hard to spot though

dense goblet
#

Is there any reason the docs aren't available locally

#

Instead gotta look them up online

wraith apex
#

you can make your own docs if you want

#

the spigot code is open source

chrome beacon
wraith apex
#

^

#

sorry not docs, I meant attaching source to the IDE

dense goblet
prisma needle
#

If I have a location with yaw and pitch, how would I go about shifting that location forwards, relative to the pitch and yaw?

chrome beacon
#

Multiply the vector

paper viper
#

But you still have to/can use it sometimes

#

Like the scheduler

chrome beacon
paper viper
#

It just means they are working on a replacement some time in the future

chrome beacon
#

(Or entities)

wraith apex
#

That defeats the point of something being deprecated

prisma needle
paper viper
#

Don’t ask me

#

Ask Spigot

#

I personally think they should warn their users in a different way instead of labeling it directly as @Deprecated

wraith apex
#

@Unsupported

paper viper
#

Such as the @Beta annotation Gson uses but for different manner

wraith apex
#

?

paper viper
#

Yeah

prisma needle
#

for example, if I have new Location(world, 0, 100, 0, 45, 45), and I add a vector to it, what values would I put into the vector :P

wraith apex
#

x, y, and z

prisma needle
#

but, xyz of what?

#

I simply want to shift the location 2 blocks forward in the direction it is facing

#

so, in the end I am trying to get the xyz of the new location... but how do I get the new location :P

wraith apex
chrome beacon
wraith apex
#

I know there is some annoying math shiz

chrome beacon
#

Read this it will help with what you need

wraith apex
#

to do with calculating angles

#

but I get what you're trying to do

prisma needle
#

perfect thanks, will read that rn

chrome beacon
#

Anyway use Location#getDirection multiply that with how far you want to go and then turn it back in to a location

#

Oh and understanding that math will be helpful in math lessons at school

arctic summit
#

rand.nextInt only returns whole numbers right

wraith apex
#

correct

arctic summit
#

ok ty

dusty herald
#

yes because it's an integer and not a double 😳

arctic summit
#

thanks guys

left swift
#

which event is fired when player pickup item from itemframe?

tame coral
#

You mean the right click so that the item drops ?

dusty herald
#

probably playerinteractevent 🤷

tame coral
#

Yeah

dusty herald
#

or PlayerInteractEntityEvent

#

then check if the entity interacted with is an itemframe then u should be golden

left swift
#

ok, thx, and how can i destroy item frame? (kill it)

tame coral
#

event.clickedEntity.remove()

arctic summit
#

i have to stagger my enchants by one, like if i want knockback 5 i do
m.addEnchant(Enchantment.KNOCKBACK, 4, true);

#

right?

fluid cypress
#

this is how i get the total experience of a player, right?

int xp = player.getExpToLevel()

but how do i set that exp back to the player? player.setTotalExperience(xp) doesnt work

hexed hatch
#

So you start at 1

unkempt ore
#

Where and how would you guys recommend storing NamespacedKeys

#

They need the plugin instance, which makes it a little awkward, so what should I do to make them cleanly accessible

hexed hatch
#

I usually store NamespacedKeys as a constant and use a main instance getter to initialize it

#

I either throw them in the main class or in a class dedicated to storing keys

eternal night
#

I usually have an enum indexing all my namespaced keys and, onEnable, create one for each of the Enum.values() and throw those into an enum map

#

pass that (wrapped in a class) around

unkempt ore
#

I want to avoid passing around

hexed hatch
#

or you can do it like mr. fancy here

paper viper
#

That isn’t Mr. Fancy, that is the proper way to do it lol

unkempt ore
#

Yeah it sounds proper

#

But I want to avoid passing around

#

Since the thing that needs these keys is exposed as API, and I don't want to put that burden on my clients

#

I made a static onEnable(Plugin) in the place that needs it and initialized the keys in that place. I believe it's the best I could do

eternal night
#

If you want to just use static, you could very much just statically define them in, lets say an interface, and call your static plugin instance provider

#
interface Keys {
    NamespacedKey KEY_ONE = new NamespacedKey(JavaPlugin.getPlugin(SpigotTestsuite.class), "key-one");
}
#

somewhere along those lines

unkempt ore
#

Doesn't need to be an interface then

eternal night
#

I mean, clean way to ensure no one creates dumb instances or does other useless stuff with it

unkempt ore
#

Private ctor

eternal night
#

also removes the need for public static final

unkempt ore
#

True

oblique pike
#

Is there a proper way to cancel EntityTargetLivingEntity event? Even if i cancel it - it keeps processing after a few retries

chrome beacon
#

Keep cancelling it

tardy delta
#

when i do /home (my own command) and put a space i get a nullptr for the tabcomplete for essentials :/

#

it has the same command

chrome beacon
#

Disable the Essentials one

#

You can do it in the config

tardy delta
#

mmmh good plan

chrome beacon
#

Oh and uh you could probably just override things by setting your own tab completer

tardy delta
#

i have one

fickle helm
#

what's the best way to get the minecraft version, such as 1.17 or 1.17.1 ?
I saw calling Bukkit.getServer().getBukkitVersion() has it but other info as well. Is this the most reliable way?

chrome beacon
chrome beacon
#

Let me get the example from CombatLogX...

tardy delta
#

huh it still gives error

#

i disabled it

chrome beacon
#

Send error

eternal night
tardy delta
#

?paste

undone axleBOT
manic bison
#

Hey, does anyone have a simple video / tutorial on how to use AnvilGUI ?
I've read the github tutorial from WesJD (his class) but i dont understand anything through builders and the use of maven
If anyone has an example of code to retrieve anvil strings or a simple tutorial or video that'll be very helpful 🙂

tardy delta
chrome beacon
#

What's the isAuthorized method

tardy delta
#

it checks permission

chrome beacon
#

Something is null

#

Find what and fix it

tardy delta
#

this is my tabcomplete i dont think there's something wrong with it

@Override
    protected List<String> tabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {

        if (args.length == 1) {
            arguments.add("set");
            arguments.add("remove");
            arguments.add("list");
            arguments.add("tp");
            arguments.add("help");
            return StringUtil.copyPartialMatches(args[0], arguments, new ArrayList<>());
        }
        return null;
    }
narrow vessel
dusk flicker
#

return an empty list

#

on the bottom one

narrow vessel
#

that

tardy delta
#

i'll try

stone sinew
tardy delta
#

uhh by empty list you did mean new arraylist or something no?

lost matrix
#

Make the arguments list final and immutable if its not a dynamic completion.

charred summit
#

hi

chrome beacon
#

Hi

tardy delta
#

hi

quaint mantle
#

Hi

charred summit
#

i'm a newby in java development and I have a bug, I search on forum but I don't find how to fix the issue
when i create my main java class, I want to import javaplugin, but when I import it, it doesn't work

tardy delta
#

so i assume its dynamic

charred summit
chrome beacon
tardy delta
#

what are you trying

charred summit
chrome beacon
#

I'd say you didn't

tardy delta
#

it has to look like this

charred summit
chrome beacon
#

Are you using Maven or Gradle?

tardy delta
#

can your code maybe that would be easier

undone axleBOT
chrome beacon
charred summit
tardy delta
#

i dunno

chrome beacon
charred summit
chrome beacon
#

How did you get that error

tardy delta
#

how do you export your plugin in eclipse.

charred summit
#

oh it's good

#

I don't know what I do but it's working

tardy delta
#

ImmutableList.of(my original list) or something

ivory sleet
#

List.of(vararg)

#

ImmutableList.of(vararg)

#

ImmutableList.copyOf(collection)

#

actually Collections.unmodifiableList(list) is a thing also

tardy delta
#

👀

#

don't make my brain goes brr

#

it's my birthday smh

ivory sleet
#

happy bday 😄

tardy delta
#

thanks

#

😄

#

wew there's the stacktrace again

#

this is stupid why does essentials makes an tabcomplete whilst the command is disabled

chrome beacon
#

The error isn't comming from essentials

#

You're causing it

tardy delta
#

every tabcomplete from my side return a new arraylist instead of null

chrome beacon
#

Send stacktrace

tardy delta
stiff topaz
#

How can I get a download link for the latest version of a plugin

#

I can only get a link for a specific version

opal juniper
#

is there a good way to Location#getBlock() async

tardy delta
#

on the spigot/ bukkit site

vagrant galleon
#

can someone send me some tutorials about npcs?

chrome beacon
chrome beacon
vagrant galleon
#

npc

dense goblet
#

That's what I hear should be used

tardy delta
chrome beacon
chrome beacon
#

Fix it

tardy delta
#

the second thing it says is basecommand: 46
thats this

if (!Utils.isAuthorized(p, cmd.getPermission())) {

the cmd.getPermission() comes from the plugin.yml permission string and i'm 100% sure i've set that

chrome beacon
#

Run some null checks

opal juniper
#

null checks are for losers

narrow vessel
tardy delta
narrow vessel
#

Which causes it to return null

tardy delta
#

💙

#

that method takes the permission from the plugin.yml

narrow vessel
#

show your plugin.yml too then

tardy delta
#

and it it here

#

.basic is default

narrow vessel
#

you need a seperate permissions: thing

tardy delta
#

wdym

#

oh that way

#

one sec

#

?paste

undone axleBOT
narrow vessel
#

Permissions block

tardy delta
narrow vessel
#

ah ok

tardy delta
#

running a null test on that now

#

smh does not even work

#

i did a null check in the tabcomplete and it isnt executed :/

narrow vessel
#

have you registered it

#

show

ivory sleet
opal juniper
#

I like this man ^^^

quaint mantle
#

Can someone help me to increase the size of the editor? when formatting it does not pass the line.

plush gulch
#

how do I play a sound effect to all players?

quaint mantle
#

Bukkit#getOnlinePlayers().foreach(ps -> {
ps.playsound(ps.getlocation, Sound.ENTITY_ITEM_PICKUP, 1.0F, 1.0F);
});

plush gulch
#

thanks

quaint mantle
#

yes

grim ice
#

its really bad

ivory sleet
#

its fine

grim ice
#

its not

#

IntelliJ way better

ivory sleet
#

and I want you to drop this debate right now, thanks 😄

grim ice
ivory sleet
#

Yelling at him that he's using the wrong IDE is everything but helpful

grim ice
#

his ide is bugged

#

better if he switches it :P

ivory sleet
#

first and foremost its not bugged

#

pretty sure eclipse has line wrapping also

plush gulch
ivory sleet
#

forEach

undone axleBOT
plush gulch
#

sorry I just wasn't sure

grim ice
#

lol its fine

#

all java methods r camelcase

ivory sleet
#

yeah lowerCamelCase

grim ice
#

just camel case

ivory sleet
#

its lowerCamelCase tho

grim ice
#

really weird but .clone() is a method right

ivory sleet
#

yeah

grim ice
#

same for example uhh, getOnlinePlayer()

#

its getting the method from that class

ivory sleet
#

pretty sure OfflinePlayer does not extend Cloneable

grim ice
#

right

ivory sleet
#

yeah

grim ice
#

i know its an example

#

ok pog

quaint mantle
#

im trying to make a plugin where if an item is in your inventory it becomes transparent but i have no clue what im actually doing

grim ice
#

if you mean it disappears

#

your question isnt clear

lavish wave
#

Where is the code, when I install BuildTool(1.16.5), that can I import for my plugin proyekt?

chrome beacon
quaint mantle
# grim ice Packets

just transparent. if you would hover over the item then it still would be there and usable

lavish wave
chrome beacon
grim ice
#

you want them to look like NOTHING

#

or

#

just a bit transparent

#

if nothing (So it looks like an empty slot) it is possible with packets

#

but i dont know anything about packets so i cant help you

quaint mantle
plain oxide
#

Please tell me how to hide the items in my hand from players other than myself .

indigo iron
#

?paste

undone axleBOT
chrome beacon
indigo iron
chrome beacon
#

That's not an null error

#

You can't cast EndCrystal to Damagable

indigo iron
chrome beacon
#

Yeah and EnderCrystal isn't a LivingEntity

#

It doesn't have health

prisma needle
#

how can I cancel all running tasks for a player?

burnt current
#

Quick question: When you make a shaped recipe, how can you make it so that you need several items on one slot for the recipe? e.g. you make a recipe for which you need 10 earth blocks. one earth block must be on each crafting slot and 2 earth blocks must be on a certain slot?

stone sinew
grim ice
#

I mean you can

#

with a event

shy wolf
#

how to change ladder facing?

grim ice
#

ladder.setFacingDirection(BlockFace.DIRECTION);

#

replace DIRECTION with WEST or EAST or whatever

shy wolf
#

ok ty

burnt current
grim ice
#

PreCraftItemEvent or smth similar

burnt current
#

ok thank you

grim ice
#

cast to Directional maybe

burnt current
#

I have another question: is it possible to use self-made item stacks as an ingredient in shapedrecipes?

manic bison
#

hey, anyone knows in java how to wait for a string to be set
i have a playerchatevent, and i want to set it to String message (public string) then retrieve it in another, but in this other method, how could i wait for the string to be completed

#

player sends a message, i retrieve this message in a public string, and in another method, wait for the string to be not null

plain oxide
chrome beacon
burnt current
#

Quick question: How can one, when setting stairs (through the plugin), set them in a certain direction?
I have already tried with the following code. Unfortunately it did not work:

event.getBlockPlaced().getLocation().add(-1, 4, 4).getBlock().setType(Material.BRICK_STAIRS);
                event.getBlockPlaced().getLocation().add(1, 4, 4).getBlock().setType(Material.BRICK_STAIRS);

                Block stair1 =  player.getWorld().getBlockAt(event.getBlockPlaced().getLocation().add(-1, 4, 4));
                BlockData stair1Data = stair1.getBlockData();
                MultipleFacing facing1 = (MultipleFacing) stair1Data;
                facing1.setFace(BlockFace.EAST, true);
                stair1.setBlockData(stair1Data);

                Block stair2 =  player.getWorld().getBlockAt(event.getBlockPlaced().getLocation().add(1, 4, 4));
                BlockData stair2Data = stair2.getBlockData();
                MultipleFacing facing2 = (MultipleFacing) stair2Data;
                facing2.setFace(BlockFace.NORTH, true);
                stair2.setBlockData(stair2Data);

Can anyone help me with this by any chance?

prisma needle
#

How can I make a location face another location?

chrome beacon
#

Use Vectors

#

Let me get the Javadoc for you

chrome beacon
prisma needle
#

Ah perfect, ty!

shy wolf
#

[Server] INFO Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.block.impl.CraftLadder cannot be cast to class org.bukkit.block.data.MultipleFacing (org.bukkit.craftbukkit.v1_16_R3.block.impl.CraftLadder and org.bukkit.block.data.MultipleFacing are in unnamed module of loader 'app')

#

help?...

#
        Material ladder = Material.LADDER;
        world.getBlockAt(210 ,46 ,-363).setType(ladder);
        Block ladder2 =  world.getBlockAt(210 ,46 ,-363);
        BlockData ladder2Data = ladder2.getBlockData();
        MultipleFacing facing2 = (MultipleFacing) ladder2Data;
        facing2.setFace(BlockFace.EAST, true);
        ladder2.setBlockData(ladder2Data);```
tame coral
#

you can't cast org.bukkit.craftbukkit.v1_16_R3.block.impl.CraftLadder to org.bukkit.block.data.MultipleFacing

hybrid spoke
#

can you

#

maybe explain it

#

so dumb people like me can understand that?

hybrid spoke
chrome beacon
#

Only Fence, Fire, GlassPane, GlowLichen, Tripwire use that interface

tame coral
#

you can't do that

chrome beacon
#

Use the Directional interface

manic bison
# hybrid spoke what?

in method1, i need to return a string (event.getMessage from playerchatevent), this string is public, so i can retrieve it in method2, problem is i need, in this method2, to wait until the string isnt null (wait until the string is set)

#
    public void onChat(PlayerChatEvent event) {
        Player player = event.getPlayer();
        String message = event.getMessage();
        if(player.hasPotionEffect(PotionEffectType.WEAKNESS)) {
            event.setCancelled(true);
            chat = message;
        }
    }```

```public String chat;```

```player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 200, 1, false, false, false));
                    if(chat == null) Bukkit.broadcastMessage("null");
                    Bukkit.broadcastMessage(chat);
                    cooldowns.put(player.getName(), System.currentTimeMillis());```
hybrid spoke
#

use a consumer as a callback

manic bison
#

consumer ?

#

hashmaps ?

#

i set a callback function, and in player chat event i fire this function ?

hybrid spoke
#

so you would have a consumer, which you do instantiate in your second method and accept in your first one

last citrus
#

Is there a Player take damage event?

hybrid spoke
#

EntityDamageEvent

last citrus
#

Thanks!

hybrid spoke
#

nvm there is no PlayerDamageEvent. you will have to go over the EntityDamageEvent

last citrus
#

Ok

last citrus
#

How do I summon a primed peace of TnT at the player location?

hexed hatch
#

World#spawn(location, TNTPrimed.class)

last citrus
hexed hatch
#

not at all lol

last citrus
#

Oh

hexed hatch
#

I would recommend learning Java

last citrus
#

I am taking a class right now

hexed hatch
#

You get the world object from the event I believe, or from the player

tame coral
#

?learnjava

undone axleBOT
tame coral
#

event.getPlayer().getWorld()

hybrid spoke
tame coral
#

A # means that the method is part of a certain class

quaint mantle
tame coral
#

yeah

ivory sleet
#

might be static method, no?

hybrid spoke
quaint mantle
hybrid spoke
#

it means, that its a method of the class X

#

the class X contains the # method

quaint mantle
#

nobody does StaticClass.method

#

its ObjectInstance#method

hybrid spoke
#

totally

#

what about statics

ivory sleet
#

they're cool

quaint mantle
#

static is good

ivory sleet
#

my favorite keyword

hybrid spoke
#

in several designpatterns you'll find statics.

quaint mantle
#

bro nobody is talking about static

hybrid spoke
#

the topic is javadocs

quaint mantle
hybrid spoke
#

and a # for a method

ivory sleet
#

ya

quaint mantle
hybrid spoke
#

oh sorry didn't knew you were talking to yourself

quaint mantle
#

talking to that guy who actually typed in Class#method

last citrus
#

How do I summon the TnT. Maybe that is a better question

hybrid spoke
#

and i am talking to the guy who gives the guy who actually typed in Class#method false inputs

#

:(

quaint mantle
#

?

#

y'all are talking about javadocs im talking about java

hybrid spoke
manic current
#
at net.squidstudios.mfhoppers.tasks.TaskManager.runItemsTask(TaskManager.java:584)
at net.squidstudios.mfhoppers.tasks.TaskManager$3.run(TaskManager.java:85)
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101)
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57)
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:831)```
This plugin throws this error when it tries to pick up items from the ground. I'm trying to update it to 1.17... Something is changed in 1.17?
Here is the code: https://pastebin.com/zv0FP5GL
hybrid spoke
#

anyways

quaint mantle
#

JavaDoc: Class#anyMethod (the way its shown)

Java: ObjectInstance#method (for help clarification reasons)

hybrid spoke
#

that was the question

quaint mantle
#

im just helping the guy

#

i feel flamebaited

hybrid spoke
hybrid spoke
manic current
#

I don't know what it does because it's not my plugin :/ I just want to update to 1.17

hasty prawn
#

We need to see EntitiesGatherer line 112

manic current
#

Object worldServer = WORLD_GET_HANDLE.invoke(world);

#

The whole EntitiesGatherer

astral burrow
#

I have a custom inventory and I would like to disable that some can put items into it but allow to take from it. I tried some articles from the forums but I didnt got it to work

hasty prawn
hasty prawn
astral burrow
#

which event are you reffering to?

hasty prawn
#

InventoryClickEvent#getCursor

astral burrow
#
if (event.getCursor() != null) {
   event.setCancelled(true);
   }
astral burrow
hasty prawn
#

Check if it's null or if it's air

#

It can be either one for whatever reason

astral burrow
#

yea thats not really fixing it

astral burrow
#

I assume I avoid some null pointer exception with that but I am still doing something wrong here

hasty prawn
#

if(event.getCursor() == null || event.getCursor().getType() == Material.AIR) then cancel

astral burrow
#

okay I will compile and check

#

nope I can not take from inventory anymore now.

hasty prawn
#

Can you put them in

astral burrow
#

nope I can not get item to cursor now

hasty prawn
#

Well you should only do this check if they click on the top inventory

#

And I think I sent the if statement backwards, invert it and it should work the other way around. (So allow items to be taken but not to be placed)

astral burrow
astral burrow
hasty prawn
#

Well make sure it's also not air

astral burrow
#

yea

hasty prawn
#

So add && event.getCursor().getType() != Material.AIR

astral burrow
#

okay

#

well thats interesting

#

Now I can not predict if I can put into the invetory.

#

Sometimes its blocking sometimes it allows it

gentle venture
#

ahh i have some questions about working with YML files if anyone here knows a bit about them 🥲 can do it in dms so it doesn't get in the way of the current conversation

grim ice
#

+1, doesnt switch the convo to whatever he likes selfishly, good person

astral burrow
#

Like if I try some slots to put it in, he blocks it and cancel the event successfully, but then I try a different slot and it works :D

#

sometimes works first try :D

#

dropping with draging not affected so far

crude sleet
#

Is it possible du give the respawn anchor the "portal" effect in the middle without giving him glowstone?

astral burrow
#

if that happend the item should be thrown out on the ground or sth.

#

Because the cursor only descirbes if someone got soemthing

quaint mantle
#
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
    if (e.getInventory() != myInv) {
        return;
    }
    e.setCancelled(true);
}

@astral burrow

#

this blocks anyone from putting an item into your inventory

#

but if you want the inventory to not be taken from/ put stuff in at all, listen to the inventoryclickevent

astral burrow
quaint mantle
astral burrow
astral burrow
#

Right so you can see I have the custom inventory "Rest in Peace Meister". I assume that in your code in line 3 you are reffering with "my Inv" to this inventory I have here. But I am not so sure how to give it there

quaint mantle
#

just use your inventory

manic bison
#

hey, i tried making consumer callbacks and it outputs me error on method onClick
onChat((chat) -> {
msg = chat;
})
The target type of this expression must be a functional interface

and my initialized callback method :
@EventHandler
public void onChat(PlayerChatEvent event, Consumer<String> callback) {
Player player = event.getPlayer();
String message = event.getMessage();
if(player.hasPotionEffect(PotionEffectType.WEAKNESS)) {
event.setCancelled(true);
chat = message;
callback.accept(chat);
}
}

i tried following this tutorial
https://medium.com/@pra4mesh/callback-function-in-java-20fa48b27797
but without barely understanding anything

if someone could help me understand this, it'd be awesome

#

nb : underlined = errors on eclipse ide

quaint mantle
#

what are you trying to do?

#

?xy

undone axleBOT
manic bison
#

oh

astral burrow
manic bison
#

in method onChat, i need to return a string (event.getMessage from playerchatevent), this string is public, so i can retrieve it in onChat method. problem is i need, in this onChat method, to wait until the string isnt null (wait until the string is set) and i tried callbacks

ivory sleet
#

What’s the meaning of that callback

cursive trellis
#

is there any spigot 1.8 plugins to save and view players ips

ivory sleet
#

Ur event method is literally a callback already

quaint mantle
#
public class MyInventory implements Listener {
    private Inventory inventory = null;

    public void register(Plugin myPlugin) {
        Bukkit.getPluginManager().registerEvents(this, myPlugin);
    }

    public Inventory getInventory() {
        return inventory;
    }

    public void makeInventory() {
        // Create your inventory here.
        inventory = Bukkit.createInventory(null, 3 * 9, "My Inventory");
    }

    @EventHandler
    public void onClick(InventoryClickEvent event) {
        if (event.getInventory() != inventory || event.getClickedInventory() != inventory) {
            return;
        }
        // Prevent clicking items.
        event.setCancelled(true);
    }
}

@astral burrow
use this example

#

@ivory sleet > example

ivory sleet
#

Fair

manic bison
proud basin
#

so im printing my map and this is what its giving me ```{weeklyKit=0}

[22:26:31 INFO]: {weeklyKit=0, pvpKit=0}
[22:26:31 INFO]: {dailyKit=0, weeklyKit=0, pvpKit=0}I have a feeling that this is doing it but im not to sure because none of the kits were chosen so they shouldn't even be in the mapjava
public long getTime(IPlayer iPlayer, String cooldown) {
PlayerData data = playerMap.get(iPlayer.getUuid());
System.out.println(data.cooldownMap);
if (data.cooldownMap.get(cooldown) == null) {
data.addCooldown(cooldown, 0L);
}
return data.cooldownMap.get(cooldown);
}

kind coral
#

Hi guys, im trying to make an "API" for my plugin, i was thinking of creating addons for it and i have an abstract class that "almost" does the job, the only thing is that i need to reload addons via a command, just one ( by name ) or every addon

I just need:
• The name of the items added by the addon
• The name of the addon
• The items ofc
• And the possibilty to reload one or all the addons as previously described

I currently have this class which only provides me the items and their names without telling me which addon added them.
https://paste.md-5.net/ihuyuyupen.java

ivory sleet
#

Each addon has its own jar?

kind coral
#

yes.

#

an addon can contain multiple items such an armor set and other things

ivory sleet
#

I like the idea of independent deployment 🙂

kind coral
#

wdym?

quaint mantle
quaint mantle
#

not the addons

#

the api

kind coral
quaint mantle
kind coral
#

they kinda need to be "toggleable"

quaint mantle
ivory sleet
#

Make a KeyedItemStack maybe which encapsulates an addon

astral burrow
ivory sleet
#

And then the abstract method getItem has to return the KeyedItemStack

kind coral
#

what is a Keyeditemstack?

quaint mantle
#
@Getter
@AllArgsConstructor
public class PluginItemStack {
    private final ItemStack item;
    private final Plugin plugin;
}

@kind coral this is what i do

ivory sleet
#

Lombok is a fucking cult I swear lol

quaint mantle
#

then you can have a map running

kind coral
quaint mantle
#

then your core plugin can rely on that

kind coral
#

yeah ofc

quaint mantle
#

and then your addon would make their own pluginItemstack

kind coral
#

like im working so hard on this ahaha

ivory sleet
#

Oo

#

Hope you don’t use Lombok 😉

kind coral
#

i use it-

#

why?

quaint mantle
#

lombok is fine

ivory sleet
#

No worries

#

Not gonna pull up my hatred here

astral burrow
#

i dont like that lombok is not providing me with the argumets a construtor takes if I call a constructor from somewhere else

kind coral
#

so you guys think i should just make a normal class ( that ofc contains the plugin that added the items and the items themselves ) and then get the core plugin instance and place it inside the map?

hybrid spoke
kind coral
dusty herald
#

how do i learn java

ivory sleet
#

Hmm, I’ll pass for now

kind coral
dusty herald
#

i wanna make minecraft but plugins

ivory sleet
hybrid spoke
quaint mantle
#
@Data
public class MyData {
    private final String myString;
    private final Plugin registeredPlugin;
}
public class MyDataManager {
    private final Set<MyData> myDatas = new HashSet<>();

    // Handle MyData here
}
public class MyPluginAPI {
    private static MyPluginAPI instance;

    private final MyDataManager manager;

    public MyPluginAPI(MyDataManager manager) {
        this.manager = manager;

        instance = this;
    }

    public MyDataManager getManager() {
        return manager;
    }

    public static MyPluginAPI getInstance() {
        return instance;
    }
}

@kind coral

kind coral
#

NO

#

I HATE SPOONFEED

#

but thanks

quaint mantle
#

its

#

not spoonfeed

kind coral
#

well kinda

quaint mantle
#

its not

#

but okay

hybrid spoke
#

manager

#

singleton

quaint mantle
#

then your addons could just

MyPluginAPI.getInstance().getManager().addData(new MyData(myString, this));

@kind coral

ivory sleet
quaint mantle
hybrid spoke
#

but i am not saying anything

dusty herald
#
public class Main {
      private static void test = true;
}```
quaint mantle
#

much rather prefer the singleton

ivory sleet
hybrid spoke
#

singleton bad bad antipattern

ivory sleet
#

I almost flamed Spleed lol

#

Singleton isn’t always an anti pattern but definitely used erroneously very often in spigot plugins for some reason

dusty herald
#

i like lombok ):

astral burrow
dusk flicker
#

lombok is nice

ivory sleet
#

Bump it captain sry

dusty herald
#

dude

#

make ur async plugin

#

use everything lombok

shadow gazelle
#

Why tf is this giving me an out of bounds warning in onCommand

if (args[1] == null)
dusk flicker
#

because args[1] doesnt exist

ivory sleet
#

And then the fact that spigot has singletons for plugin instances already

hybrid spoke
#

and anywhere other too. ofc., in some cases it has its advantages but you should always prefer DI

dusty herald
#

i hate using asnyc

kind coral
shadow gazelle
kind coral
#

string and itemstack actually

quaint mantle
dusk flicker
#

no

#

not for lists

kind coral
astral burrow
# dusty herald use everything lombok

If I use lombok to create constructor its not providing me the argument names when I create an instance. I NEED to go every time to check the order. So anoying

dusk flicker
#

check if the length is what you need

ivory sleet
quaint mantle
dusty herald
#

maybe don't do that if you don't like it

hybrid spoke
dusty herald
#

DI? just static void everything

quaint mantle
#

facts

astral burrow
quaint mantle
#

public static Object for the win

ivory sleet
shadow gazelle
#

ffs Java

dusty herald
#

also idk what you're on about because i can use create constructors with it and get the argument names

#

🤷

hybrid spoke
ivory sleet
#

It’s global in the application because that class would be the highest scope

#

Since there would be no dependencies

hybrid spoke
#

technically not global

ivory sleet
#

Depends on pov

shadow gazelle
astral burrow
quaint mantle
undone axleBOT
dusty herald
#

idk

#

i just use it

ivory sleet
dusty herald
#

for absolutely no reason

#

i dont like having infinite getters and setters and im lazy so

manic bison
#

anyone knows how can i set a BukkitScheduler that waits to be fired with runTask ?

A bukkit task i put somewhere in my code (a runnable) that gets fired with a command ?

ivory sleet
#

Lombok lowkey fucks encapsulation of state but I guess it’s effective in source

astral burrow
quaint mantle
quaint mantle
ivory sleet
#

Elaborate

astral burrow
dusty herald
#

6h on what

ivory sleet
#

this

dusty herald
#

i hate you

manic bison
#

I set Bukkit.getScheduler() somewhere in my code that gets fired with Bukkit.getScheduler().runTask(taskid);

dusty herald
#

wanna know how I like to handle commands now?

#

/command argument1="testing" argument2="testingasdaf"

#

because fuck anything else

astral burrow
old sun
#

hi jochyoua

manic bison
#

is it Bukkit.getScheduler().createTask ?

old sun
#

remember me?

dusty herald
#

no i don't

ivory sleet
#

I remember you! - Jochyoua

old sun
#

😦

ivory sleet
#

Oh nvm

old sun
#

i think we used to be friends

dusty herald
#

who are you