#help-development

1 messages · Page 2123 of 1

quiet ice
#

It will probably be still allowed for the same module for a long time to come, but it isn't always allowed to access a private method/field these days

#

Also modifying a private method does not break SemVer as the ABI of private methods can more or less be ignored

#

So differentiating between private and public method can have a large differences when it comes to API contracts

#

A private method is far more likely to change than a public one

sterile token
#

oh ok

#

Geol so how would i use my thing

#

Now that you exlained that before i get mored dumb

quiet ice
#

You are on your own there, I have to go to bed now

ivory sleet
#

good night sleep tight

#

verano what is your thing more specifically?

sterile token
quiet ice
#

The only real way to make something plattform independent is to just rewrite the entire plattform to be plattform independent

sterile token
#

Basically im designing a bosotrap system which allow me to code spigot and bungee plugins in the same way for registering events, listeners and commands

ivory sleet
#

events?

#

those are heavily, extremely platform specific

#

but I mean

#

what you got so far?

sterile token
#

I send code and you will understand

ivory sleet
#

uh Ig

quiet ice
#

He is still stuck at the init logic

sterile token
#

Yeah

ivory sleet
#

ah good to know thanks

sterile token
#
// Platform
public interface Platform<C, L, E> {

  C getCommand();

  L getListener();

  E getEvent();
}

// Or boostrap 
public interface Module<T extends Platform<?>> {

    void onEnable();

    void onDisable();

    T getPlatform();

    boolean fetch();
}


// Module

public interface BungeeModule extends Platform<Command, Listener, Event> {}
#

This is what i have at the moment

ivory sleet
#

this entire thing seems kinda useless and yucky not to sound disappointing or anything but genuinely

sterile token
#

Its okay many people told me

ivory sleet
#

cause like you'd still need some class thats platform dependent on how listeners and commands are registered

#

What you can do is to create platform independent business logic/features

tardy delta
#

im curious about how thats supposed to work

ivory sleet
#

but these small registration and bootstrapping abstractions are useless

#

and will help you diminishingly

sterile token
#

I was trying to do something similar to lookperms

ivory sleet
#

yes

sterile token
#

But they logic its really complex

ivory sleet
#

but this is not similar to what they do

#

cause they create platform independent logic

sterile token
#

Oh its diff?

ivory sleet
#

yes

sterile token
#

And mewhat i did i do?

#

Just to improve

ivory sleet
#

for instance platform independent data model, data storage, api, scheduling logic, api implementation and collection utils

#

not bootstrapping

#

nor registration

sterile token
#

OH OK

#

Now i understand

ivory sleet
#

that shit still goes into the spigot or bungee module

sterile token
#

But thanks i apreciate

ivory sleet
#

yeah good luck tho

#

I tried sth similar years ago

#

didnt result in anything so mye

sterile token
#

My big issue is that i need to create common class with a constructor argument of Platform

#

But them i need to pass the generics, and the generics differ if you are o bungee or spigot

#

So that the reason of getting stuck

ivory sleet
#

mye Idk

#

I mean

sterile token
#

mye?

ivory sleet
#

is Platform, or Module gonna be the interface that the spigot plugin respective bungeecord plugin implement

#

not exactly clear

#

feels like you're circle depending two entry points here

sterile token
#

The BungeeModule and SpigotModule will be implemented in the plugin

ivory sleet
#

example?

sterile token
#

Depeding if you want it for spigot or bungee

ivory sleet
#

so whats the idea behind having this Platform interface then

sterile token
#

To use it on library side

#

So then from therei can get the PluginManager and register the events, etc

#

🤔

#

That was my idea

ivory sleet
#

uh

sterile token
#

But still shity from what i heard

#

😂

ivory sleet
#

Im like super confused

#

cuz the registration logic could be incorporated into your Module derivatives

#

as thats pretty much platform depend logic

#

which Module derivatives are supposed to handle

#

according to your intentions at least

sterile token
#

Yes

#

Its super mess

#

Because from Library side i dont know if you either using Spigot or Bungee

ivory sleet
#

is this a library?

sterile token
#

I dont know how to call it exactly

ivory sleet
#

just explain the relation between this project and other conceivable dependents of this project

sterile token
#

What sorry

#

I didnt understand

ivory sleet
#

okay

#

how are others going to use the thing you're making now

sterile token
#

As maven or gradle dependency

ivory sleet
#

no but like

#

is it a plugin

#

or is it just a library

#

or is it a plugin library

sterile token
#

My goal is to use on bungee and spigot plugins, it will contains commons things for them like Catching, User profile, Database

ivory sleet
#

by the sounds of it you dont need to have anything regarding platform specific stuff

sterile token
#

But for registering commands you need it

ivory sleet
#

make a seperate library extension for that

#

or like module/dependency

sterile token
#

Oh ok

ivory sleet
#

not everyone will want to have those commands of yours along with the rest of the classes right

sterile token
#

And how would be done that part? Because i want to use same Command and Argument class on bungee and spigot

brittle lily
#

hey guys How Can I Use Config In My Main File In Another File?

ivory sleet
#

verano you could take a look at how luckperms does it in this case

#

??di

#

?di

undone axleBOT
sterile token
#

They ue brigadier

ivory sleet
#

@brittle lily ^

#

nah they dont

sterile token
#

That why i didnt take as example

ivory sleet
#

no they do not

sterile token
#

No?

brittle lily
sterile token
#

Lol on their discord they told me that luckperms actually uses Brigadier

ivory sleet
#

yes it uses commodore

#

but it doesnt rely directly on brigadier

#

it has its own command library sort of

#

which is then registered differently depending on platform

sterile token
#

Oh

#

which module?

#

I cannot what you talking sorry

sterile token
#

Ah but you need diff things for that

#

Or not?

ivory sleet
#

wat

#

wym diff things

sterile token
#

yeah you use diff executors class

ivory sleet
#

nah

#

all the logic

#

the arguments

#

permission handling

sterile token
#

My goal is to have a common command and argument executor for bungee inthe same way

ivory sleet
#

action handling and execution is written in common

sterile token
#

Oh ok know i understan

ivory sleet
#

then each platform executor just forwards it

sterile token
#

Conclure

#

Why luckperms plugins are obsessed with threads, daemons, and things like that

ivory sleet
#

wat

coarse finch
ivory sleet
#

daemon just means like background process

#

a thread which runs as daemon doesnt have to be shutdown in order for the java program to terminate

#

threads are fundamental

#

especially when you want to optimize and scale data management horizontally

#

but also for things like talking to IO devices

#

such as file io or databases

sterile token
#

Oh ok conclure

sterile token
coarse finch
#

i know

sterile token
#

So if no one answer just wait

mortal hare
#

is there any ways to get translatable container inventory names via bukkit API

quaint mantle
#

I may be a complete idiot, but I setup johnrengelman's shadowjar, and its not generating as a shadow jar.

sterile token
#

Doesnt have you te method: Inventory#getName() or getTitle()?

quaint mantle
#

Is there something wrong with my build?

sterile token
quaint mantle
#

Im using Intelli

sterile token
#

on the pom

mortal hare
#

but not the translatable key

sterile token
#

what means him?

mortal hare
#

which client uses to determinine default locale name for unnamed container

quaint mantle
#

Whats the full name of it

sterile token
#

pom.xml

#

Are u using maybe or gradle?

quaint mantle
#

gradle

sterile token
#

And that the problem

#

Maven and gradle are diff bulkshit

quaint mantle
sterile token
#

I dotn use gradle

#

So i cannot help

quaint mantle
sterile token
#

I tried gradle i get lot of errors and come back to my reliable maven

quaint mantle
#

The error I recieve happens in the plugin startup code, and here is the error if this helps:

java.lang.NoClassDefFoundError: net/dv8tion/jda/api/hooks/ListenerAdapter

mellow edge
sterile token
#

Gradle == shit

quaint mantle
#

Wont I have to

#

COMPLETELY

#

redo my uhhh

#

plugin

#

to move from gradle to maven?

sterile token
#

No

#

Just copy and paste your source code, into a new maven project and add the dependencies

#

Its simple

#

😂

brittle lily
#

Guys I wanna set boss.name to My Last message But How Can I get Varible from Chat Event (I have already chat event how can I set on config?)

kindred valley
#

is there any way to spawn a block to a location

quaint mantle
#

grap. I forgot how artifiactID works

kindred valley
quaint mantle
#

nvm

sterile token
quaint mantle
#

@sterile token Uhhh. Why is it forcing me in maven to use max 1.15.2???

#

oh hell no

brittle lily
sterile token
sterile token
#

But the methods its called Config#getString/int/()

#

Depending on what you need

#

If need a string config#getString() them, an int config#getInt()

brittle lily
#

Oh Thanks

sterile token
#

But please when dont know something use

#

?jd

kindred valley
sterile token
kindred valley
#

buddy

#

i couldnt find any documents

#

thats why im asking

#

tf

sterile token
#

Oh o

#

1 sec

#
location.getBlock().setType()```
mortal hare
#

this is what im searching (this is NMS class method remapped):

    @Override
    public Component getName() {
        return new TranslatableComponent("container.inventory");
    }
#

i want something like this but in bukkit api

mortal hare
#

to return TranslatableComponent

sterile token
mortal hare
#

to make name of the item or the inventory correspond to the player's locale

kindred valley
sterile token
#

🤔

mortal hare
#

eh, i'll just use adventure

quaint mantle
#

Anybody here know gradle and shadow jars?

mortal hare
#

it has proper component support

quaint mantle
#

Im not switching from gradle

sterile token
#

because luckperms uses Adventure TextComponent and runs on every spigot version...

kindred valley
sterile token
quaint mantle
#

There is 0 results for my issue alone.

sterile token
quaint mantle
#

When I tried any results for my issue as well, for other searches?

#

0 of them fixed this.

sterile token
#

You can also use the ?jd to check what argument has a method

kindred valley
# sterile token I told you: Location location = new Location(wordl, x, y, z); location.getBlock...
BukkitRunnable run = (BukkitRunnable) new BukkitRunnable() {
        @Override
        public void run() {
            Location loc1 = new Location(Bukkit.getWorld("world"), 34, 2, 86);
            Location loc2 = new Location(Bukkit.getWorld("world"), 34, 2, 88);
            Location loc3 = new Location(Bukkit.getWorld("world"), 34, 2, 90);
            Location loc4 = new Location(Bukkit.getWorld("world"), 36, 2, 86);
            Location loc5 = new Location(Bukkit.getWorld("world"), 36, 2, 88);
            Location loc6 = new Location(Bukkit.getWorld("world"), 36, 2, 90);
            Location loc7 = new Location(Bukkit.getWorld("world"), 38, 2, 86);
            Location loc8 = new Location(Bukkit.getWorld("world"), 38, 2, 88);
            Location loc9 = new Location(Bukkit.getWorld("world"), 38, 2, 90);

            loc1.getBlock().setType(Material.PUMPKIN);
            loc2.getBlock().setType(Material.PUMPKIN);
            loc3.getBlock().setType(Material.PUMPKIN);
            loc4.getBlock().setType(Material.PUMPKIN);
            loc5.getBlock().setType(Material.PUMPKIN);
            loc6.getBlock().setType(Material.PUMPKIN);
            loc7.getBlock().setType(Material.PUMPKIN);
            loc8.getBlock().setType(Material.PUMPKIN);
        }
    }.runTaskTimer(Main.getInstance(),0, 100L);
#

This should spawn all the locations pumpkin right?

hasty prawn
#

oh that is very repetitive

kindred valley
#

thank you but its not working

hasty prawn
# kindred valley thank you but its not working
Bukkit.getScheduler().runTaskTimer(Main.getInstance(), () -> {
            World world = Bukkit.getWorld("world");
            if(world == null) return;
            
            for (int x = 0; x < 6; x += 2) {
                for (int z = 0; z < 6; z += 2) {
                    world.setType(new Location(world, 34 + x, 2, 86 + z), Material.PUMPKIN);
                }
            }
            
        }, 0, 100L);

try this

quaint mantle
#

@hasty prawn Do you have experience with gradle?

#
[15:41:31 INFO]: [EmeraldsPlugin] Enabling EmeraldsPlugin v1.0.0
[15:41:31 ERROR]: Error occurred while enabling EmeraldsPlugin v1.0.0 (Is it up to date?)
java.lang.NoClassDefFoundError: net/dv8tion/jda/api/hooks/ListenerAdapter
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:1012) ~[?:?]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[?:?]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:193) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:587) ~[?:?]
    at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:104) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:99) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
    at me.emerald.emeraldsplugin.EmeraldsPlugin.onEnable(EmeraldsPlugin.java:29) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:525) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:439) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassNotFoundException: net.dv8tion.jda.api.hooks.ListenerAdapter
    at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:147) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:99) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
    ... 20 more
#

It keeps erroring for 0 reason

hasty prawn
#

You're not shading it

#

You need the good ol shadow plugin

quaint mantle
#

How do I shade it

#

@hasty prawn

plugins {
    id 'java'
    id 'com.github.johnrengelman.shadow' version '7.1.2'
}

group = 'me.emerald'
version = '1.0.0'

repositories {
    mavenCentral()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
    maven {
        name = 'spigotmc-repo'
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
    }
    maven {
        name = 'sonatype'
        url = 'https://oss.sonatype.org/content/groups/public/'
    }
    maven {
        name = 'jeff-media-public'
        url = 'https://hub.jeff-media.com/nexus/repository/jeff-media-public/'
    }
    maven {
        name = 'minecraft-repo'
        url = 'https://libraries.minecraft.net/'
    }
}

dependencies {
    implementation 'org.projectlombok:lombok:1.18.24'
    implementation 'org.jetbrains:annotations:23.0.0'
    implementation 'net.dv8tion:JDA:5.0.0-alpha.9'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2.2'
    compileOnly 'com.mojang:authlib:1.5.21'
    compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
    compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT-shaded'
}

def targetJavaVersion = 17
java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}

tasks.withType(JavaCompile).configureEach {
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release = targetJavaVersion
    }
}

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}
#

You can see here I have it shaded

hasty prawn
#

How are you building

#

Should be with shadowJar

quaint mantle
#

somebody finally told me how to do it

#

ty

#

yes, also above

#

fixed

left swift
#

When I'm using redis to communication between the servers can I directly publish message to the certain server (server1 -> server2) or better way is doing it through the proxy (server1 -> proxy -> server2)?

quaint mantle
#
public class Items {
    public static ArrayList<?> itemClassList = new ArrayList<>(){{
        add(new IronCoin());
    }};

    public static HashMap<String, ItemStack> itemList = new HashMap<>();
    public static HashMap<String, ShapedRecipe> recipeList = new HashMap<>();

    public static void newItem(String locName, ItemStack item){
        itemList.put(locName, item);
    }
    
    public static void addRecipe(ShapedRecipe recipe){
        recipeList.put(recipe.getKey().getNamespace(), recipe);
        Bukkit.getServer().addRecipe(recipe);
    }

    public static ItemStack getItem(String locName){
        if(itemList.get(locName) != null){
            return itemList.get(locName);
        }
        return null;
    }

    public static HashMap<String, ItemStack> getAlLItems(){
        return itemList;
    }

    public static void setupItems(){
        try {
            for(Object cls: itemClassList){
                Class<?> mClass = cls.getClass();

                Method m = mClass.getMethod("setupItem");
                m.setAccessible(true);
                m.invoke(cls);

                Bukkit.getServer().getPluginManager().registerEvents((Listener) cls, EmeraldsPlugin.jp);
            }
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {}
    }
}
#

It claims that itemList is null at itemList.put(locName, item);

#

any reason why?

echo basalt
#

static abuse what the fuck

quaint mantle
#

leave me be

echo basalt
#

so is the garbage collector

quaint mantle
#

can you just let me know what is wrong instead of making fun of me lol

echo basalt
#

itemList shouldn't be null, but locName might

supple elk
#

more making fun of the garbage collector

supple elk
quaint mantle
#

Items.newItem("ironCoin", this.item);

#

locName shouldnt be null

mortal hare
#

Am I wrong to think that server does not send translatable keys via packets to the minecraft clients? Since i can't seem to find inventory implementation which utilise TranslatableKey() inside NMS

echo basalt
#

due to localization

mortal hare
#

wouldnt the client handle that

#

for example, client could handle localization just by knowing item namespace key

#

why would you send a translatablekey

echo basalt
#

¯_(ツ)_/¯

#

there are more translatable things than just item name

left swift
#

When I'm using redis to communication between the servers can I directly publish message to the certain server (server1 -> server2) or better way is doing it through the proxy (server1 -> proxy -> server2)?

echo basalt
#

redis acts as a type of proxy

#

just send the messages directly

left swift
#

I mean proxy like bungee

#

or velocity

#

😄

echo basalt
#

Yeah I know

#

redis can't tell the difference between a spigot server, a proxy server and just some idiot java program

mortal hare
# supple elk but yeah holy mother of static

Lemme show you my statics lol:

    public static Nameable CHEST_9X1 = Nameable.CHEST_9X1;
    public static Nameable CHEST_9X2 = Nameable.CHEST_9X2;
    public static Nameable CHEST_9X3 = Nameable.CHEST_9X3;
    public static Nameable CHEST_9X4 = Nameable.CHEST_9X4;
    public static Nameable CHEST_9X5 = Nameable.CHEST_9X5;
    public static Nameable CHEST_9X6 = Nameable.CHEST_9X6;
    public static Nameable BARREL = Nameable.BARREL;
    public static Nameable DROPPER = Nameable.DROPPER;
    public static Nameable DISPENSER = Nameable.DISPENSER;
    public static Nameable HOPPER = Nameable.HOPPER;
    public static Nameable BREWING_STAND = Nameable.BREWING_STAND;
    public static Nameable ENCHANTING_TABLE = Nameable.ENCHANTING_TABLE;
    public static Nameable MERCHANT = Nameable.MERCHANT;
    public static Nameable SMOKER = Nameable.SMOKER;
    public static Nameable SHULKER_BOX = Nameable.SHULKER_BOX;
    public static Nameable FURNACE = Nameable.FURNACE;
    public static Nameable BLAST_FURNACE = Nameable.BLAST_FURNACE;
#

these are enum emulation classes

#

its legal

#

just for you know

echo basalt
#

pov: Enchantment

supple elk
#

lol

worldly ingot
#

Like, for one, why? Secondly, surely that's not possible. Though I don't understand the context of this. Are these constants in an enum? Or are they referring to themselves?

mortal hare
#

That's referring to another statics

#

its basically emulating enum inheritance

#

but with classes

#

You guys are disgusted with enum static abuse

#

look at this nms then

#

?paste

undone axleBOT
mortal hare
#

^ That's NMS right here

worldly ingot
#

Well yeah but that at least sort of makes sense

mortal hare
#

that's basically what i've did, but way less

worldly ingot
#

They're constants of types not equal to themselves Hmmm

#

Is this in a different class?

#

If so, that really does lead back to my question of "but why" lol

#

It's not like you're restricting the type or anything

mortal hare
#

These static fields are pointing to the static fields of the inner class

#

which are instances of that class

worldly ingot
#

Oh, okay, THAT makes more sense

mortal hare
#

these are basically convenient static fields

worldly ingot
#

Without context I could not at all decipher that KEKW

mortal hare
#

just for my lazy ass, to not write Type.Nameable.STONECUTTER and just Type.STONECUTTER

#

which both return basically the same thing, and by using this fake "enum" trick it can restrict particular "enums" from compiling due to how class inheritance works (compile time error checking, yay)

#

that way it looks from the IDE view more like an enum class

#

but with inheritance of methods

#

but ofc its fake

#

since its done via classes and enums cannot be extended sadly

#

in short terms, im doing the something similiar ProtocolLib does with their PacketType class

rugged cargo
#

task = new BlockOutlineV2().runTaskTimer(this, 0,2); ... task.cancel()

#

does this do what i expect it to?

#

task = new BlockOutlineV2().runTaskTimer(this, 0,2); starts a task and gives task reference i assume
then task.cancel() cancels said task

#

i think task.cancel() is sufficient after looking at the code of what it does

#

==============
is Damageable supposed to have a getDamage() method?

#

ah i had the wrong Damageable

ivory sleet
#

🥲

rugged cargo
#

lol. is that because you've done the same thing or something else?

compact haven
#

it’s just too easy to import the wrong thing

coarse finch
#

anyone have the server forks relations chart? i tried googling it but couldnt find it

agile marsh
#

hey rq sorry to bother

#

trying to come up with glitch prevention for a crop yield plugin

#

does anyone know difference between entity and block explosion event?

#

also, if you remove a block from the list generated by (ExplosionEvent).blockList, does that preserve the block?

crude estuary
#

i don't know if you Asked this

#

But here

#

This is the Usage

coarse finch
#

it kinda helps...

#

well what servers should i have to test my plugin on?

exotic depot
#

I want to create a shop inventory that updates based on the player's items (how much of a certain item they have). I want to update the inventory every time the player opens/purchases the shop. Should I store the inventory per player and update it that way or do something else?

echo basalt
agile marsh
#

damn no love

echo basalt
#

BlockExplodeEvent says that a block was broken via an explosion, EntityExplodeEvent says that an entity exploded x blocks

exotic depot
agile marsh
#

very pog my friend

#

very pog

echo basalt
exotic depot
#

thanks

deep solstice
#

Hey so I am trying to share data from one plugin to other plugins, what would you all recommend to go about that? My data (for now) is just a list of words/phrases that aren't allowed in things such as nicknames, custom suffixes, etc.

eternal oxide
#

register one plugin as a ServiceProvider

deep solstice
#

i've tried that already, whenever I try to get it, though, I get a null value

eternal oxide
#

in your second plugin you have to get the provider after its been registered. so add a depend in your plugin.yml

eternal oxide
#

show code

eternal oxide
#

getRegistration not load

deep solstice
#

oh yes I believe I have tried that previously as well, let me double check though

#

yep still null

eternal oxide
#

does yoru second plugin have a depend entry for the first in its plugin.yml?

eternal oxide
#

Then no reason it shoudl not work

deep solstice
eternal oxide
#

that seems to say you are not registering yoru provider

deep solstice
#

which i think is weird

#

yeah but i clearly am

eternal oxide
#

Silly question but are you seeing the debug from your provider at startup?

deep solstice
#

yeah I have that debug as well, here it is:

[01:14:26 INFO]: BlockedWordsInterface.class.toString() == interface com.github.dripmh.dripapi.api.blockedwords.BlockedWordsInterface
[01:14:26 INFO]: org.bukkit.plugin.RegisteredServiceProvider@50585b58```
eternal oxide
#

ok The only thing it could be otherwise is you are shading a copy of yoru first plugin into yoru second by accident. Thereby making the interface class not match

deep solstice
#

yeah I am shading it, how would I prevent that from happening?

eternal oxide
#

you set it to provided so its not copied

deep solstice
#

yeah i love you so much mate

eternal oxide
#

np 🙂

deep solstice
#

thanks ❤️

rugged cargo
#

this might be a silly question, but is there a "standard" design for developing inventory menus?

eternal oxide
#

no

hasty prawn
#

The design is 100% up to you

eternal oxide
#

The only "standard" is abiding by the rules in the InventoryClickEvent docs when processing it

rugged cargo
#

alright. i guess i was hoping there was a tried and true design that was universal... oh well. ill just refactor my menu from scratch, because it's logic is messy

#

i was unaware of these rules. thank you for that.

warm trout
#

Hey, how would I rotate a vector a little bit to the left or right

eternal oxide
#

Vectors have a RotateAround method

warm trout
#

Yeah, I'm confused a little on how to use it, I've tried rotateAroundX, but obviously, it just launches backwards when I'm facing north and launches to the side when I'm facing west/east

eternal oxide
#

rotate around Y if you want to affect the Yaw

warm trout
#

Ah alright

#

Oh wait yeah that makes sense Im dumb

eternal oxide
#

Axis can be thought of as masts. Y is a vertical mast (up/down)

warm trout
eternal oxide
#

what are you attempting to do?

warm trout
#

I want to be able to alter the velocity so it shoots a little to the left or the right if I tell it to

eternal oxide
#

for accuracy?

warm trout
#

The opposite, to make it less accurate if they don't shoot when the bar isn't in the middle

eternal oxide
#

If its for simulating drift

#

then you are correct in rotating it around Y and X

warm trout
#

Not sure what it's to simulate tbh lol, was told to do it tho

eternal oxide
#

If its going backwards you are likely rotating it too much

warm trout
#

It works the way I want it to when facing north

eternal oxide
#

Show some code

#

?paste

undone axleBOT
warm trout
#

The rotateAroundY part is me trying to rotate it to the left

#

When I rotate it to the right, it's -3

eternal oxide
#

3 is a LOT of rotation

warm trout
#

Wait that might be the reason hold on lol

eternal oxide
#

there are two methods there, horizontal and vertical

warm trout
#

Ah thank you very much I'll take a look

warm trout
lone beacon
#

I need urgent help

quaint mantle
#

?dontasktoask

#

bruh

#

?ask

undone axleBOT
#

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

lone beacon
#

Im confing a server with mods and plugins using magma

#

and i configured the PermisionPex (and i used other plugins) but i cant see the prefix in chat

#

?ask Im configuring a server with mods and plugins using magma with bukkit
and i configured the PermisionPex (and i used other plugins) but i cant see the prefix in chat

undone axleBOT
#

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

sweet pike
#

would there possibly be a way to make a player, be source of light, and create light for other players when it's dark?

quaint mantle
rugged cargo
#

what is it called when you use static {...}?

rugged cargo
quaint mantle
#
public static HashMap<String, ItemStack> itemList = new HashMap<>();

public static void newItem(String locName, ItemStack item){
    System.out.println(itemList);
    itemList.put(locName, item);
}

It claims itemList is null. Why?

#

The class is public, and I see 0 reason for it to be null.

hot fjord
#

you might need to use .putifEmpty

quaint mantle
hot fjord
#

Also you are printing before putting anything in it

quaint mantle
#

It returns null when printing

hot fjord
#

because it’s null

#

it will remain null until you put things in it

quaint mantle
hot fjord
#

oh yes that one sorry

quaint mantle
#

No, I mean: Does it still work if its not null

hot fjord
#

it wont do anything if something is in it, i dont think

rugged cargo
#

question out of curiosity. if you empty it after using put, will itemList return to null? (id assume not?)

hot fjord
#

that i’m not certain

quaint mantle
#

Heres my question: Why is a HashMap returning null if nothing is in it

#

That makes 0 sense

#

And is completely stupid

hot fjord
#

null means nothing

quaint mantle
#

Why not just return an empty HashMap?

hot fjord
#

that’s why it’s returning null

#

because nothing is in it

#

how would you represent an empty hashmap?

quaint mantle
#

and just allow people

#

to use .put

#

on it

#

:/

hot fjord
#

you’re gonna have to talk to Oracle about that

quaint mantle
#

god damn I will

hot fjord
#

XD

rugged cargo
#

lol. rebel against language design. :)

quaint mantle
#

@hot fjord Okay your wrong, the variable itself is null

#

for some reason

#

just tested that, and its returning null

#

putIfAbsent means that it puts it IF the key is not existant inside the hashmap

#
java.lang.ExceptionInInitializerError: null
    at me.emerald.emeraldsplugin.EmeraldsPlugin.onEnable(EmeraldsPlugin.java:35) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:525) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:439) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
    at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.HashMap.putIfAbsent(Object, Object)" because "me.emerald.emeraldsplugin.data.items.Items.itemList" is null
    at me.emerald.emeraldsplugin.data.items.Items.newItem(Items.java:24) ~[?:?]
    at me.emerald.emeraldsplugin.data.items.misc.IronCoin.<init>(IronCoin.java:45) ~[?:?]
    at me.emerald.emeraldsplugin.data.items.Items$1.<init>(Items.java:17) ~[?:?]
    at me.emerald.emeraldsplugin.data.items.Items.<clinit>(Items.java:16) ~[?:?]
    ... 12 more
rugged cargo
#

well if you are printing that then the hashmaps tostring could be deceiving you? just guessing.... apparently completely wrong guess. lol

quaint mantle
#

im printing the hashmap directly

#

it is returning null

#
public class Items {
    public static ArrayList<?> itemClassList = new ArrayList<>(){{
        add(new IronCoin());
    }};

    public static HashMap<String, ItemStack> itemList = new HashMap<>();
    public static HashMap<String, ShapedRecipe> recipeList = new HashMap<>();

    public static void newItem(String locName, ItemStack item){
        itemList.put(locName, item);
    }

    public static void addRecipe(ShapedRecipe recipe){
        recipeList.put(recipe.getKey().getNamespace(), recipe);
        Bukkit.getServer().addRecipe(recipe);
    }

    public static ItemStack getItem(String locName){
        if(itemList.get(locName) != null){
            return itemList.get(locName);
        }
        return null;
    }

    public static HashMap<String, ItemStack> getAlLItems(){
        return itemList;
    }

    public static void setupItems(){
        try {
            for(Object cls: itemClassList){
                Class<?> mClass = cls.getClass();

                Method m = mClass.getMethod("setupItem");
                m.setAccessible(true);
                m.invoke(cls);

                Bukkit.getServer().getPluginManager().registerEvents((Listener) cls, EmeraldsPlugin.jp);
            }
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {}
    }
}
#

ignore my static abuse

#

im lazy as hell

#

this is my code

rugged cargo
#

well im pretty sure java defaults to calling toString if the object has it when you print. though that's clearly irrelevant here 🤣

rugged cargo
quaint mantle
#

i wonder if its cause im calling a Class < Different Class < Back To The Original Class

rugged cargo
#

also i just learned about the reflection system the other day so that looks insane to me...

quaint mantle
#

OH MY GOD AAAAA

#

WHY ISNT THIS WORKING

quaint mantle
exotic depot
#

can I update the name of an inventory without closing it?

quaint mantle
#

Also, I just took the liberty

summer scroll
#

With packets

quaint mantle
#
public class Items {
    public static ArrayList<?> itemClassList = new ArrayList<>(){{
        add(new IronCoin());
    }};

    public static HashMap<String, ItemStack> itemList = new HashMap<>();
    public static HashMap<String, ShapedRecipe> recipeList = new HashMap<>();

    public Items(String locName, ItemStack item, ShapedRecipe recipe){
        itemList.put(locName, item);
        recipeList.put(recipe.getKey().getNamespace(), recipe);
        Bukkit.getServer().addRecipe(recipe);
    }

    public static ItemStack getItemFromId(String locName){
        return itemList.get(locName);
    }

    public static HashMap<String, ItemStack> getAlLItems(){
        return itemList;
    }

    public static void setupItems(){
        try {
            for(Object cls: itemClassList){
                Class<?> mClass = cls.getClass();

                Method m = mClass.getMethod("setupItem");
                m.setAccessible(true);
                m.invoke(cls);

                Bukkit.getServer().getPluginManager().registerEvents((Listener) cls, EmeraldsPlugin.jp);
            }
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {}
    }
}
#

SERIOUSLY

#

WHY

#

DOES THIS ERROR

#

THERE SHOULD BE 0 REASON FOR IT TO ERROR

exotic depot
summer scroll
#

With packets, no

quaint mantle
quaint mantle
quaint mantle
#

@quaint mantle Somehow, I fixed it

#

Going to double check to see

#

But im praying it works

rugged cargo
#

i didn't realize that making items have their own classes was useful in plugins tbh

#

this is going to sound strange, but refactoring is kind of fun

quaint mantle
#

why does PlayerInteractEvent run twice

waxen plinth
quaint mantle
waxen plinth
#

Check the result of getHand()

quaint mantle
#

@waxen plinth Its returning hand twice

#

thats VERY strange

waxen plinth
#

???

quaint mantle
#

You should share some code?

quaint mantle
#
public class InteractionEvent implements Listener {
    //Values
    Player p;
    PlayerInteractEvent mainEvent;

    ItemStack item;
    ItemMeta itemMeta;
    PersistentDataContainer itemPerst;

    Block block;
    TileState blockState;
    PersistentDataContainer blockPerst;

    //Event
    @EventHandler
    public void clickEvent(PlayerInteractEvent event) {
        p = event.getPlayer();
        mainEvent = event;
        getItem();
        getBlock();

        switch(event.getAction()){
            case RIGHT_CLICK_AIR -> handleRightClickAir();
            case RIGHT_CLICK_BLOCK -> handleRightClick();
        }
    }

    //Functions
    private void getItem(){
        item = mainEvent.getItem();

        if(item != null){
            itemMeta = item.getItemMeta();
            itemPerst = itemMeta.getPersistentDataContainer();
        }else{
            itemMeta = null;
            itemPerst = null;
        }
    }

    private void getBlock(){
        block = mainEvent.getClickedBlock();

        if(block != null){
            if(block.getState() instanceof TileState){
                blockState = (TileState) block.getState();
                blockPerst = blockState.getPersistentDataContainer();
            }else{
                blockState = null;
                blockPerst = null;
            }
        }
    }

    //Handlers
    private void handleRightClickAir() {
        if(item != null){
            Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Air_Item_Off")); //Air clicked by Item.
        }
    }

    private void handleRightClick() {
        if(item != null && block != null && blockPerst != null){
            Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Entity_Item")); //Block Entity clicked by Item.
        }else if(item != null && block != null){
            Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Block_Item")); //Block Regular clicked by Item.
        }else if(item == null && block != null && blockPerst != null){
            Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Entity_None")); //Block Entity clicked by Nothing.
        }else if(item == null && block != null){
            Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Block_None")); //Block Regular clicked by Nothing.
        }
    }
}
#

Here is the code that actually handles the event, to detect Right Clicks

#
public class RightClickItem extends Event {
    private static final HandlerList HANDLERS = new HandlerList();
    private final PlayerInteractEvent event;
    private final String type;

    public static HandlerList getHandlerList() {
        return HANDLERS;
    }

    public RightClickItem(PlayerInteractEvent event, String type) {
        this.event = event;
        this.type = type;
    }

    @Override
    public HandlerList getHandlers() {
        return HANDLERS;
    }

    public String getType() {
        return this.type;
    }

    public PlayerInteractEvent getMainEvent() {
        return this.event;
    }
}

Using spigots eventApi, I made this

#
@EventHandler
    public void onRightClickItem(RightClickItem event) {
        Player eventPlr = event.getMainEvent().getPlayer();
        ItemStack eventItem = event.getMainEvent().getItem();

        System.out.println(event.getMainEvent().getHand());

        if(eventItem == null)
            return;

        PersistentDataContainer itemPerst = eventItem.getItemMeta().getPersistentDataContainer();

        if(itemPerst.get(NamespaceKeyList.getKey("coin"), PersistentDataType.STRING) != null){
            eventItem.setAmount(eventItem.getAmount() - 1);
            eventPlr.sendMessage(ChatColor.GREEN + "Gained 1 coin! Congrats!");
        }
    }
#

This runs twice, with getHand as "HAND" instead of "HAND" and "OFF_HAND"

#

@quaint mantle @waxen plinth

waxen plinth
#

Please stop pinging me

#

This is not the first time I have asked you

quaint mantle
#

Sorry, I asumed you were apart of this help.

#

Only reason I pinged you.

#

Isn't it main hand and offhand?

quaint mantle
#

Instead of hand and offhand.

#

I have 0 idea why

#

And did you check what Redempt said?

quaint mantle
#

First thing I did, and again:

#

Its returning hand twice, instead of hand and offhand.

waxen plinth
#

This is really poorly written

#

I'm on mobile so I'm sure I'm not seeing all the things wrong

#

But why are you doing it this way to begin with

quaint mantle
waxen plinth
#

You're writing methods that use instance fields instead of parameters when they should clearly be taking parameters

#

The event itself doesn't seem to have much reason to exist

#

And I'm quite sure the issue is in the logic of handling the event to call yours

quaint mantle
#

It seems perfectly fine to me

waxen plinth
#

I'm on mobile

#

So I'm not going to try to read through it all with messed up formatting

quaint mantle
#

Yes. It starts from PlayerInteractEvent.

#

then goes thru all of that.

#

Runs the event

#

etc

#

I just did this.

#

And explained this.

waxen plinth
#

There are much more pressing issues with the code

quaint mantle
#

It prints mainhand twice.

waxen plinth
#

Don't use instance fields like method parameters

#

That's just really bad practice

quaint mantle
#

...

#

I sent it.

#

?paste

undone axleBOT
quaint mantle
#

I just explained this-

#

whatever

#

I know that.

#

Im asking: Why is IronCoin running twice, but its hand is main hand wice.

#

intead of main hand and off hand

#

@quaint mantle What.

#

PlayerInteractEvent.

#

Its returning MainHand twice.

#

What the hell?

#

Yes, it is :P

#

Why is it firing twice?

#

Yes I Did.

#

I dont think you understand- Its returning main hand TWICE.

#

not offhand and mainhand each once.

#

hasdbads

#

Please

#

Read

#

I know.

waxen plinth
#

Circles and circles

quaint mantle
#

Im telling you, I checked.

#

Its telling me its main hand TWICE.

#

njasdijdsajdojasdaonlkjsjdsaokjdsa

hybrid spoke
#

seems like you both are stupid

quaint mantle
#

I DID

#

Im trying to explain to you.

#

I chcked getHand.

#

When the event fires twice, it returns MainHand twice.

waxen plinth
#

I said multiple times that the code quality is very poor

quaint mantle
#

So doing a check for OffHand does nothing.

waxen plinth
#

Clean code is easier to debug

quaint mantle
waxen plinth
#

Why don't you start by getting rid of your instance fields

quaint mantle
#

Right now however, I want it to just function

waxen plinth
#

None of them are needed

waxen plinth
#

That's what gets you such bad code in the first place

quaint mantle
#

Do not.

midnight shore
#

Guys calm down

quaint mantle
#

The last thing I want is spoonfeeding.

lone beacon
#

hellow i have a question

waxen plinth
#

Go on

quaint mantle
#

I did, I tested, it returns Hand twice.

#

I also, tried doing a check.

#

It does the same thing

lone beacon
#

is dificult create a private plugin for sponge?

quaint mantle
undone axleBOT
#

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

waxen plinth
#

This is the spigot discord

#

We don't give support for sponge

hybrid spoke
quaint mantle
#

btw

lone beacon
#

what is the discord sponge?

waxen plinth
lone beacon
waxen plinth
#

It has nothing to do with optimization in this case

quaint mantle
#

Also, I just did what you asked @quaint mantle

waxen plinth
#

Writing code that is readable saves you effort debugging down the line

quaint mantle
#

Big suprise! Its still runs twice.

#

At this point I just want to scrap this code altogether.

#

It sucks.

midnight shore
waxen plinth
#

I won't help people who have extremely messy code if they don't fix it first because otherwise they'll just keep writing bad code that is harder to debug

quaint mantle
#
if(Objects.equals(event.getHand(), EquipmentSlot.HAND)){
            switch(event.getAction()){
                case RIGHT_CLICK_AIR -> handleRightClickAir();
                case RIGHT_CLICK_BLOCK -> handleRightClick();
            }
        }
#

Intelli recommended I use Objects.equals

waxen plinth
#

Get rid of the instance fields

quaint mantle
#

but I may be wrong here

waxen plinth
#

You are

#

== for enums

#

That will work but it's not needed

#

== works and that should be a guard clause

quaint mantle
#

also, by remove all the instance fields

#

Do you mean completely remove ALL of them

#

or

waxen plinth
#

Yes

#

You should be passing parameters

quaint mantle
hybrid spoke
#

return exists

waxen plinth
#

The only reason this doesn't explode in your face is because Minecraft servers are single threaded

#

You also should not be using strings for your event

#

It's a collection of named constants

#

In other words, an emum

#

So make it one

midnight shore
#

Can someone tell me in easy words what a Set<T> is?

waxen plinth
#

Parameterized type

#

A Set is not descriptive enough

#

What is in the set?

#

That's what T is

quaint mantle
#

Sure

#

Also, how do I return multiple objects at the same time

midnight shore
#

Yeah but what’s a set? 🤣

waxen plinth
#

Set<Integer> is a set of Integers

quaint mantle
#

Array/Map I assume

waxen plinth
#

A set is a collection which cannot be indexed or store duplicates

midnight shore
#

Uh so no duplicates

#

Thank you

waxen plinth
#

But nothing you're doing should require that

quaint mantle
#

but how would I use it as an object

#

wait @waxen plinth

#

Didnt you say

#

That I should be passing parameters

#

Correct?

waxen plinth
#

Please

#

Stop pinging me

quaint mantle
#

Right sorry

waxen plinth
#

Yes you should be passing parameters

#

You don't even really need that many functions here

#

Why don't you just make an enum for your string constants and a method that, given the context needed, will return the right enum value

#

Then your entire logic can be just a few guard clauses and a few lines to dispatch the event

waxen plinth
#

.-.

#

All I want is to be able to offer help without being pinged every 5 seconds

#

But we can't all get what we want

#

I'll be going now

midnight shore
#

An enum can be contained in a class, but can the class be contained in the enum?

quaint mantle
#

Wait

#

does discord auto ping for whats it called

#

Responding?

#

Whatever its called

#

Sorry had 0 idea

#

Can i disable that somehow

quaint mantle
quaint mantle
#

@ off

waxen plinth
quaint mantle
#

there

waxen plinth
#

I'm still going, I have to sleep

#

Don't try to force a solution by writing big messy code

#

Distill it to the simplest logic that can do what you need it to

#

It also cannot be indexed

waxen plinth
#

Write an enum for your string constants

#

A method that can take the necessary context and return the correct enum value

#

And your listener method which has a few guard clauses and then dispatches your event

#

That should be all you need

quaint mantle
#

Is this better?

#

Removed all redundant code and made it a bit more optimized

#

Intelli said that was better

#

idk lol

chrome beacon
#

You can use an enum instead of strings

quaint mantle
chrome beacon
#

Ah yeah didn't see that

undone axleBOT
quaint mantle
#

there

#

made it an enum

#

Hm, so it runs the event when using if(event.getHand() == EquipmentSlot.HAND){ once

#

... yet RightClickItem event is ran twice

dark arrow
#

when i use particles they just scatter randomly is there any way to make them stay at a place?

quaint mantle
#

ah ok

#

ty

#

So.. my issue still keeps happening bruh

#

2 items are used instead of 1

hybrid spoke
tardy delta
#

why even creating a custom event for that

#

ah for passing it to a custom item class

#

i would just handle the PlayerInteractEvent, assuming that some things are valid cuz they are checked by the 'parent' listener

fickle lintel
#

hi guys, i'm trying to make interactive books in spigot 1.8.8, this is what i've tried:

ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) book.getItemMeta();
bookMeta.spigot().addPage(
    (BaseComponent[])
    new ComponentBuilder("")
                
    .append("Amogus")
                
    .create()
);```

But it says `ItemMeta.Spigot` (return type of `bookMeta.spigot()`) doesn't have `.addPage(BaseComponent[])`, any idea how to add page with BaseComponent?
chrome beacon
#

NMS I guess

#

Otherwise just use strings

fickle lintel
#

i can't use events or colors with strings

#

and i dont know how to use NMS

vocal cloud
#

Then don't use 1.8.8

fickle lintel
#

The server needs to be at 1.8.8... I'm a dev at my frend's server

chrome beacon
#

Time to learn NMS

fickle lintel
#

quick crash course?

chrome beacon
#

There are no good guides but we can help you import it to your project

#

The rest you will have to figure out on your own by looking at the Minecraft source code

fickle lintel
#

oh god

chrome beacon
#

Oh and using it will make your plugin version specific

fickle lintel
#

oh

#

thats a disadvantage

#

is there no way to do it without NMS?

restive mantle
#

does a physics event fire a block break event or no?

fickle lintel
crimson terrace
#

yeah that wont be an enemies to lovers arc zacken, at least not in the near future

brittle lily
#

Hey Guys How can I open a gui that I created in another class in another class?

golden kelp
#

Wha

#

Please elabote

hybrid spoke
#

refer to it

#

whatever

#

many ways

#

but its formulated very vague

remote silo
#

how can i get the essentialsX documentation

hybrid spoke
#

?bing

undone axleBOT
kindred valley
brittle lily
kindred valley
hybrid spoke
undone axleBOT
#

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

kindred valley
# hybrid spoke ?ask

im trying to spawn a block on world somewhere but i couldnt do it its not running the code block

kindred valley
# hybrid spoke ?ask
@Override
            public void run() {
                World world = Bukkit.getWorld("world");
                if(world == null) return;

                for (int x = 0; x < 6; x += 2) {
                    for (int z = 0; z < 6; z += 2) {
                       // world.getBlockAt(x, 2 ,z);
                    }
                }

            }
golden kelp
#

?google ?bing

undone axleBOT
golden kelp
#

weird

golden kelp
#

what is run()?

#

are u using BukkitScheduler?

kindred valley
supple elk
#

generics are so cool

#

whatever class you put in the first bit must be provided as the class for the consumer

golden kelp
#
  • are u sure the world isnt null? check it by printing
kindred valley
kindred valley
golden kelp
#

Ofcourse

supple elk
#

Also I do have a question, is there a way I can easily get a list of the all the events which extend PlayerEvent?

golden kelp
#

Yea

supple elk
#

I don't mean from the docs or whatever

golden kelp
#

oof

supple elk
#

I mean getting a list I can iterate over

#

cause I could manually create one

kindred valley
supple elk
#

which would prob just be easier

#

but if there's a way to easily generate a list that would be cool

#

hi geol 😮

golden kelp
supple elk
#

ty for the help yesterday btw

quiet ice
#

By scanning the jars yes, otherwise no

supple elk
#

sounds like a lot of work

#

I'll just create one

#

I'm trying to assemble a list of all the events which have some kind of getPlayer() function

quiet ice
#

There are a few libraries that allow for what you want, but Most of them are behemoths for No reason at all

supple elk
#

it would be nice if they all extended PlayerEvent

#

but nope there are bunch

supple elk
#

like BlockBreakEvent extends BlockEvent, but super doesn't have a getPlayer event

#

my code would be a lot nicer if it did ;-;

frigid rock
#

yo, i have created an economy plugin and i want to create a placeholder for papi. is that possible to do?

quiet ice
#

Yes

#

But really you should use the vault PAPI Extension If it does what you need

frigid rock
#

uh okay thanks

supple elk
#

Can I have a capture of a class which extends some class and implements an interface?

#

I'd like a capture of a cancellable event

#

so like, Class<? extends Event, Cancellable>

golden kelp
#

when do u want to run that code

quiet ice
supple elk
#

can't have &

brave goblet
supple elk
#

Cancellable is an interface tho

#

you can both extend and implement

#

I need a wild card for a cancellable event

brave goblet
#

Class name extends Event implements Cancellable

quiet ice
brave goblet
#

u can't extend more than one super class

supple elk
quiet ice
quiet ice
brave goblet
#

oh ye right

#

missed the <>

quiet ice
#

It's defo & though, how to use it idk

supple elk
#

doesn't seem to like the & 😔

brave goblet
#

<T extends ClassA & InterfaceB>?

supple elk
#

yeah I just found the same

#

oh yeah that has worked

#

I swear I tried that

#

tf

brave goblet
#

lmao

supple elk
#

maybe I'm just dumb

#

ok ty

brave goblet
supple elk
#

omgg yesss

#

it is complete

#

for each player I keep a map which maps an event class to a lamda which takes said event

#

so now if I want to stop the player from being able to break blocks

#

I add the BlockBreakEvent.class to their map, with null as the result

#

now the event is cancelled for them

#

but I can also change what happens from the default by putting in a new consumer in the map

#

genericcssss

#

This does make it difficult to distinguish between dealing damage and receiving damage however since they're both EntityDamgeByEntity event

quaint mantle
#

Ayo, so im doing some stuff with attribute modifiers, but sometimes I mess something up and then there is a permanent Attribute modifier I don't know of. It there a way to clear all attribute modifiers?

#

nvm found it

brittle lily
kindred valley
# golden kelp where do u call the method
@Override
            public void run() {
                World world = Bukkit.getWorld("world");
                if(world == null) return;
                for (int x = 0; x < 6; x += 2) {
                    for (int z = 0; z < 6; z += 2) {
                        Block block = world.getBlockAt(x, 2 ,z);
                        block.getLocation().getBlock().setType(Material.PUMPKIN);
                    }
                }
            }
#

this should work right?

golden kelp
#

yes but u need to call run()

kindred valley
golden kelp
#

where did u call

kindred valley
#

its calling

#

i mean i debugged

golden kelp
#

where

kindred valley
#

but not triggering

#

command

golden kelp
#

is the world null?

kindred valley
#

no

#

i debugged with sending online players a message

#

and its working but not working with this code

golden kelp
#

weird

kindred valley
#
public static void spawnKoko() {
        BukkitTask run =  new BukkitRunnable() {
            Location loc1 = new Location(Bukkit.getWorld("world"), 34, 2, 86);
            Location loc2 = new Location(Bukkit.getWorld("world"), 34, 2, 88);
            Location loc3 = new Location(Bukkit.getWorld("world"), 34, 2, 90);
            Location loc4 = new Location(Bukkit.getWorld("world"), 36, 2, 86);
            Location loc5 = new Location(Bukkit.getWorld("world"), 36, 2, 88);
            Location loc6 = new Location(Bukkit.getWorld("world"), 36, 2, 90);
            Location loc7 = new Location(Bukkit.getWorld("world"), 38, 2, 86);
            Location loc8 = new Location(Bukkit.getWorld("world"), 38, 2, 88);
            Location loc9 = new Location(Bukkit.getWorld("world"), 38, 2, 90);
            @Override
            public void run() {
                World world = Bukkit.getWorld("world");
                if(world == null) return;
                for (int x = 0; x < 6; x += 2) {
                    for (int z = 0; z < 6; z += 2) {
                        Bukkit.getWorld("world").getBlockAt(x, 2, z).setType(Material.PUMPKIN);
                    }
                }
            }
        }.runTaskTimer(Main.getInstance(),0, 100L);
    }
golden kelp
#

wha

kindred valley
#

nvm about the top code

quaint mantle
#

You realize this places at y level 2 right @kindred valley ?

golden kelp
#

yea

quaint mantle
#

hm weird

kindred valley
#

i have a commandregister method

quaint mantle
#

btw, why are you using Bukkit.getWorld in the for loop again, you have a assigned variable 'world' already

#

minor detail

kindred valley
#
Bukkit.getWorld("world").getBlockAt(34, 2, 86).setType(Material.PUMPKIN);
                Bukkit.getWorld("world").getBlockAt(34, 2, 88).setType(Material.PUMPKIN);
                Bukkit.getWorld("world").getBlockAt(34, 2, 90).setType(Material.PUMPKIN);
                Bukkit.getWorld("world").getBlockAt(36, 2, 86).setType(Material.PUMPKIN);
                Bukkit.getWorld("world").getBlockAt(36, 2, 88).setType(Material.PUMPKIN);
                Bukkit.getWorld("world").getBlockAt(36, 2, 90).setType(Material.PUMPKIN);
                Bukkit.getWorld("world").getBlockAt(38, 2, 86).setType(Material.PUMPKIN);
                Bukkit.getWorld("world").getBlockAt(38, 2, 88).setType(Material.PUMPKIN);
                Bukkit.getWorld("world").getBlockAt(38, 2, 90).setType(Material.PUMPKIN);
golden kelp
#

wha

kindred valley
#

i thought this will change everything but no

supple elk
#

Is this a bukkit runnable or?

golden kelp
#

yea i mean running the rask

supple elk
#

kk

#

yeah then you wanna runnable.runTaskTimer() or whatever

kindred valley
#

why is this not working

#

i will fuck myself

supple elk
#

my guess is that getting the block and setting the type doesn't change the block

green gyro
#

what kind of blocks is it possible to store state in?

golden kelp
kindred valley
supple elk
#

kk

quaint mantle
#

there is no setBlock method

#

its a reference to a block so setting the type will set it in the world

supple elk
#

@kindred valley try putting a print statement inside and check ur console to see if it does actually run or not

#

then check to see if Bukkit is actually getting the world

#

you may want to use Bukkit.getWorlds().get(0)

green gyro
#

bro

#

I'm was asking my own q

#

not about your q

#

c:

kindred valley
green gyro
#

is there an interface for such tickable blocks?

torn vale
#
public final class AutoAd extends JavaPlugin {

    private int currentIndex = 0;

    @Override
    public void onEnable() {
        this.saveDefaultConfig();
        this.start();
    }

    @Override
    public void onDisable() {
    }

    private void start() {
        List<String> list = this.getEntries();
        BukkitTask task = new BukkitRunnable() {
            @Override
            public void run() {
                for (Player p : Bukkit.getOnlinePlayers()) {
                    p.sendMessage("§7[§f§lPVP§4§lCorner§7] " + list.get(currentIndex));
                    currentIndex = (currentIndex + 1) % list.size();
                }
            }
        }.runTaskLater(this, 120);
    }

    private List<String> getEntries() {
        return this.getConfig().getStringList("ads");
    }
}```
why does it only send one of the two messages?
#

it sends one message and than stops...

supple elk
#

I'm guessing cause there is only one person online

#

and the task only runs once

torn vale
#

oh, how can i loop it?

supple elk
#

runTaskTimer() I believe

torn vale
#

what is the difference between long delay and long period?

supple elk
#

delay is how long before it starts

#

period is the time between repeating

#

so a delay of 10 and a period of 1 will cause the function to run every tick, 10 ticks after it was called

torn vale
#

tysm :)

supple elk
#

np

kindred valley
#

getBlock.getDrops.add() sets the drops of this block right?

golden turret
#

no

#

the getDrops is just a copy of the actual drops

#

and they are also from a copy

#

which is generated everytime

#

idk what im saying

#

but you cant simpyl add/remove drops for a block

kindred valley
#

how can i set a blocks drops

golden turret
#

you cant

#

but you can list block break

#

and spawn the drop

#

thanks spigot!

kindred valley
#

hmm how to spawn an item

crude loom
#

Wait I think that I just found out the solution by sending this here xD , I will delete that

kindred valley
#
@EventHandler
    public void blockDropping(BlockDropItemEvent e) {
        if(e.getBlock().getType() == Material.PUMPKIN) {
            e.setCancelled(true);
        }
    }
```this should prevent the pumpkin dropping right?
crude loom
#

I don't see a problem here yes

kindred valley
#

its still dropping

crude loom
#

Check that this event is being fired

#

When I cancel the death of a player in the PlayerDeathEvent and teleport them to somewhere else, their loot is dropped at the teleported position, any idea why? this is my code:

p.setHealth(20);
p.setGameMode(GameMode.SPECTATOR);
MiniGames.skywarsGame.getLstAlive().remove(p.getUniqueId());
teleportToLoc(main.getConfigName(p.getWorld().getName())+"-death-pos",p);
#

By canceling I mean setting their health back to 20

quiet ice
#

You May need to actually cancel it

crude loom
#

There isn't a setCanceled method on the player death event

quiet ice
#

Otherwise you can actually Just clear the list of dropped items

crude loom
#

But if I do that they won't drop at all

quiet ice
crude loom
#

I want them to drop at the original location

quiet ice
#

Ah yeah, you May need to Teleport in the next tick

crude loom
#

Set a scheduled task?

quiet ice
#

Yep

crude loom
#

Ah I see, I will try that

kindred valley
#

The block is Pumpkin but this part of code is not running

#
if(block.getType() == Material.PUMPKIN) {
            e.getPlayer().sendMessage("WORKING 2");
            e.setCancelled(true);
        }
crude loom
#

This means that your event isn't firing, can you send your onEnable method?

kindred valley
#

but this part is not working

crude loom
#

Oh that's weird

quiet ice
#

Are you Sure that Pumpkin applies to Blocks?

crude loom
#

This is probably because of the event you used, I just ran this and it worked:

  @EventHandler
    public void onPlayerDrop(PlayerDropItemEvent e){
        if(e.getItemDrop().getItemStack().getType() == Material.PUMPKIN)
            e.setCancelled(true);
    }
kindred valley
quiet ice
#

I'd Check the javadocs, but 16 kbits

kindred valley
crude loom
#

Oh you want to cancel entities dropping pumpkins?

quiet ice
#

WHAT

kindred valley
quiet ice
#

@crude loom does Material.PUMKIN_BLOCK exist?

crude loom
#

I don't believe it does, but you can check in the javadocs

quiet ice
#

Again, 16 kbits

#

I should really Download the offline Docs one day

kindred valley
#

There is SEED, STEM, PIE

quiet ice
#

Many questions Here need a look at the javadocs

#

I know many parts of the Bukkit API by Heart by Not everything

golden kelp
#

d a m n

#

I just remember smth bout the player class & the entities

quiet ice
#

Should be

golden kelp
#

simple meths

quiet ice
#

Read the Docs to be Sure, But generally everything is in Ticks in mc space

#

Multiply by 50

golden turret
#

20

#

not 50

quiet ice
#

No 50

wet breach
#

20tps = 50ms per tick

golden turret
#

1 second = 20 ticks

harsh totem
#

I have this burn command and when I use it I get this error: Please note that this command is not supported and may cause issues when using some plugins

                    try {
                        Player player2 = Bukkit.getPlayerExact(args[0]);
                        try {
                            int seconds = Integer.parseInt(args[1]) * 20;
                            player2.setFireTicks(seconds);
                        } catch (NumberFormatException nfe) {
                            player.sendMessage(ChatColor.RED + "That is not a valid number");
                        }
                    } catch (IllegalArgumentException e){
                        player.sendMessage(ChatColor.RED + "That is not a valid player");
                    }```
quiet ice
golden turret
#

do you use in schedules, 3 * 20 or 3 * 50?

wet breach
#

depends if the 3 is in seconds

#

or in miliseconds

golden turret
#

seconds

wet breach
#

then you would times it by 20

quiet ice
#

20*20ms=400ms=0.4s

golden turret
golden kelp
harsh totem
#

wtf it doesn't now

quiet ice
#

commands.yml?

harsh totem
#

idk what happened but it now works

golden turret
#

ik what is it