#help-development

1 messages · Page 74 of 1

compact glen
#

yea lets just ignore that this ever happened

reef brook
#

is there any chance that my nms 1.15 code will work for a 1.19 client with viaversion on a 1.15 server?

charred blaze
#

how to check that when they first type? xDD

chrome beacon
latent bone
#

this simple line does not work

public boolean getClass(boolean className){
        return className;
    }```
This is in the main class, I try to access it from another, and I can't? What am I doing wrong
Sorry if I sound stupid, it's early in the morning
river oracle
#

?learnjava

undone axleBOT
compact glen
#
package me.datoeb.gunpowdergoboom;

import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public final class GunpowderGoBoom extends JavaPlugin implements Listener {
        @Override
        public void onEnable() {
            recipeFurnace();
        }

        private void recipeFurnace() {
            ItemStack result = new ItemStack(Material.TNT);
            ItemMeta im = result.getItemMeta();
            im.setDisplayName(ChatColor.GOLD + "Boom");
            result.setItemMeta(im);
            FurnaceRecipe recipe = new FurnaceRecipe(result, Material.GUNPOWDER);
            recipe.setExperience(0);
            getServer().addRecipe(recipe);
        }



        @EventHandler
        public void onBurn(FurnaceBurnEvent e) {
            System.out.print("Test");
        }
}

would anyone care to explain why this doesnt work the recipe does exists but it doesnt print Test with the furnaceburnevent

river oracle
river oracle
compact glen
#

oh

#

im dumb how to do

latent bone
river oracle
river oracle
compact glen
#

oh i see

#

tysm

young shell
#

Since Java 17 removed the --illegal-access flag, is there any way to achieve the same thing now?

waxen plinth
worldly ingot
#

Generally speaking we want to discourage use of reflection entirely and encourage API contributions instead

lime jolt
#

anyone know if it is possible to code a minecraft plugin with others (like change the same jar file when we code)

dusk flicker
#

theres CodeWithMe in IntelliJ

#

also a thing called Git, but not really 'real time'

worldly ingot
#

There have been attempts at IDE plugins for that, though I don't know of any that have survived

dusk flicker
#

CodeWithMe in IntelliJ works fairly decent, but its only in IntelliJ. It is limited on what it can do to an extent

buoyant viper
#

gotta get those unsafe suns 😎

worldly ingot
#

Seems there's one called CodeTogether as well which has extensions for Eclipse, IntelliJ, and VSCode

#

Saros was the long-standing pair-programming extension for a while but it died a little while ago

compact glen
#

how do i kill entities in a 5 block radius of a location

for (Entity nearby : w.getNearbyEntities(furnaceBlock.getLocation(), 5,5,5)) {
  nearby.setHealth(0);
}

doesnt work

eternal oxide
#

CodeTogether is quite good, but it did have one issue where you couldn't see the Package explorer

#

probably fixed now though

compact glen
#

aight bet

#

i get that you cant use setHealth on a non LivingEntity but i was wondering how would i kill the entity since i cant use setHealth

compact glen
#

yea i looked at that

#

cant find much of help

chrome beacon
#

I assume you don't know how to use a javadoc?

compact glen
#

well ig so

chrome beacon
#

Basically the link above shows that you can use remove() on your entity

compact glen
#

i tried that

#

it didnt work

chrome beacon
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

compact glen
#

and im also trying to kill the player

#

as well as the entity

chrome beacon
#

Check if it's a player/living entity then set hp or damage it

#

if it's not use remove()

compact glen
#

aight

#

so yea i did that and it still says cannot find symbol at the setHealth(0) part

for (Entity entity : w.getNearbyEntities(furnaceBlock.getLocation(), 5,5,5)) {
  if (entity.getType() == EntityType.PLAYER) {
    entity.setHealth(0);
  }
  else {
    entity.remove();
  }
}
chrome beacon
#

Cast entity to player

compact glen
#

bless you what

#

ohhhh

chrome beacon
#

Just to be safe you can use an instanceof check instead

compact glen
#

aight

#

ahå

#

i see

#

it worked

#

🍪 here have this cookie as a thanks

warm galleon
#

i tried using ChatColor. and using the translate alt code and typing in the codes myself, for some reason it keeps making my text go past the item tooltip border, any fix?

dusk flicker
#

I dont know if I have ever actually seen that

#

my best guess would be the characters on the start/end of it

warm galleon
#

lore.add(ChatColor.translateAlternateColorCodes('&', "&6&l&kV&6&l LEGENDARY SPECIAL WEAPON &6&l&kV"));

dusk flicker
#

Oh thats what it is

warm galleon
#

does it not count bold text?

#

i tried without bolding and it works

#

but bold text goes past

dusk flicker
#

Thats a weird one lol

#

Someone else might have a solution, ive never seen an error like that

sly surge
#

Maybe it's your client?

dusk flicker
#

a PDC or smth else?

#

I believe they have to be online

#

?pdc

sly surge
#

If you need to get these things when the player is not online then you probably shouldn't use the pdc for this

dusk flicker
#

a quick google search says "no"

#

It says its possible but a headache

warm galleon
dusk flicker
#

Are you using the normal MC launcher or smth else Kyrok?

#

I should say client rather than launcher

warm galleon
#

maybe its glitching out with spaces? ill try to do it again with &r before every space

dusk flicker
#

Try without the &k formatted text in it

warm galleon
#

kk

dusk flicker
#

Thats my only guess tbh

iron glade
#

Native speakers, do I say "When a player gets teleported" or "When a player is teleported" ?

eternal oxide
#

is

#

but context matters

dim bronze
#

english is my first language and even I'm not sure

#

yeah I think the full sentence is needed

iron glade
#

Well the full sentence is "Whether to play a sound when the player <word> teleported"

eternal oxide
#

either then

#

is sounds better, but both are acceptable

iron glade
#

I'll use is than, thank you

worldly ingot
#

The two are interchangeable

iron glade
#

Good to know, I thought one would be "more correct" than the other

worldly ingot
#

Yeah, anybody that speaks English isn't really going to be all that pedantic about it. Both are correct to me and I would use either one.

dim bronze
#

Choco do you mind if I DM you about a forums question or should I send an email?

worldly ingot
#

Depends on the subject lol

dim bronze
#

name changes :/

worldly ingot
#

If it can, should go as a report

#

Ah

#

I mean name change requests are offered to donors (even if it's just $10 or whatever the minimum is)

dim bronze
#

I know they are allowed in exceptional circumstances, just want clarity on the circumstance

#

And yes, donors

worldly ingot
#

You can DM me for clarification that's fine, though the request would go in an email because I can't actually change your name

#

md's the only one that authorizes and performs name changes on the forums

dim bronze
#

dumb question

worldly ingot
#

;p

dim bronze
#

oh really

worldly ingot
#

Mhmm

dim bronze
#

there isn't any admins?

worldly ingot
#

md's pretty much the only admin

#

thinkofdeath was the only other one but he's not been around since 1.8

dim bronze
#

Oh wow, I didn't realise. Well then I may as well send an email. Thanks

worldly ingot
#

o/

warm galleon
dim bronze
sleek badge
#

what should i put after the this.

sonic cosmos
#

Main class instance

#

(Without this if you dont use depedency injection)

compact glen
#

how do i get the type of a dropped item
for example
if (entity instanceof item && item.itemtype == material.diamond) {}

crisp steeple
#

there’s a method on item entity called getItemStack

compact glen
#

oh alright tysm

plain vapor
#

Hey guys, I'm decently new to Spigot development. I code in C# for work and am picking up Java while developing so actual code isn't a big problem for me. Just wanted to get opinions on storing temporary data during the plugins runtime. I'm making a simple chat plugin and have setup msg and reply commands for players. Currently I hold a GUID, GUID hashmap instance during plugin runtime to track which player each player will reply to when they use the reply command. It works and all, but I can't help but think that if the plugin was run on a server with LOTS of players that the hashmap could chew up a bit of memory. Hashmaps are obviously more efficient than arrays but is storing temporary data like that better to do with temporary yml files so that the plugin isn't using as much memory? Or it doesn't matter that much? Or is there an even better way of holding data like that that I don't know of?

eternal oxide
#

Nope, what you are doing is fine

#

So long as your reply isn;t rmembered between server boots

plain vapor
#

Yeah okay cool, cheers. It clears on restarts and is added to and removed from on player join and leave

#

Also, is it better practice to just read from config file whenever you need values or create class instances that hold config data so you can just inject those sections. I feel like the latter is cleaner, but it would use up unnecessary memory right?

eternal oxide
#

read from Plugin#getConfig() it's held in memory

rigid loom
#
java.lang.NullPointerException: Cannot invoke "games.kingdoms.kingdoms.Kingdoms.getCommand(String)" because "this.plugin" is null
        at games.kingdoms.kingdoms.economy.commands.CommandManager.setup(CommandManager.java:27) ~[?:?]
        at games.kingdoms.kingdoms.Kingdoms.mongoDbStuff(Kingdoms.java:181) ~[?:?]
        at games.kingdoms.kingdoms.Kingdoms.onEnable(Kingdoms.java:55) ~[?:?]```
plain vapor
#

Roger, thanks

rigid loom
#

will look for the important code to post in a special page in a sec

eternal oxide
rigid loom
#

ie whatever the link is for posting this stuff

worldly ingot
eternal oxide
#

actually

#

yep plugin is null

rigid loom
#

whats the website to post code? or do we just do it in code blocks?

wet breach
#

?PASTE

rigid loom
#

?paste

wet breach
#

?paste

undone axleBOT
rigid loom
#

thanks

#

i think thats the most important stuff

iron glade
#

Native speakers, is it Whether to play a sound when an action is successfull or successfully ?

#

As intelliJ wants to correct it to successfully

upper vale
#

Neither

#

should be successful

iron glade
#

is completed successfully?

#

so, is successfully completed

iron glade
upper vale
#

no

iron glade
#

I'm happy the only problems I'm facing rn is grammar stuff :d

#

bruh I even had it right the first time and changed it :c

upper vale
#

asList isn’t modifiable I think

upper vale
#

problem should be is

#

yeah not exactly sure what’s going on there lol

worldly ingot
#

It's a weird internal List implementation

iron glade
worldly ingot
#

Yeah. Arrays#asList() is modifiable, but you can't add/remove from it. It's fixed-sized. Things like List#set() will work, or #replaceAll(), but if any operation changes the size of the backing array, you get an UnsupportedOperationException

#

They stupidly named that implementation ArrayList as well by the way, for some weird reason. FixedSizeArrayList would have been better

upper vale
#

Thanks Choco:)

sullen turtle
#

I can't figure out how to shade in mongodb to my plugin, everything I've found online wont work

sullen turtle
#

Yeah I've done that

#

I think I'm doing it wrong or something

vale veldt
#
cPlayer.getHandle().b.a(packet);``` How can I find out what makes these methods obfuscated? There was a website that helped you with this but apparently it is no longer available.
river oracle
sullen turtle
#

1s

rough blaze
#

how could I play a particle above a player, without apis?

sullen turtle
#

I'm using compile output with an artifact

dusk flicker
#

How do I compile a plugin with gradle? I've never used this lmao

river oracle
#

if you use intellij to compile as artifcat it won't run anything you have done with maven

river oracle
#

thats why its not working

sullen turtle
#

I made a config to start the server with the artifact

#

Is there a way I can fix it and still use that?

river oracle
#

I don't use intellij

#

couldn't help you

#

but you have to compile with maven

rough blaze
#

how would I get a random color for a particle?

river oracle
#

make a list of colors and grab a random one

#

you could do a random int within a bound or use some random list selection method java has iirc

rough blaze
#

Thanks

#

?paste

undone axleBOT
rough blaze
sullen turtle
#

Thanks

river oracle
#

but that works too

sullen turtle
#

wait that didn't work lol

river oracle
#
                <configuration>
                    <finalName>${project.artifactId}</finalName>
                    <outputDirectory>${basedir}/../output</outputDirectory>
                </configuration>
#

this is what I do in my shade plugin configuration

#

then your run maven package

#

and it outputs to the specified directory

#

note that it can be absolute path you don't need the env variables I used

sullen turtle
#

Where do I put that config

#

the shade-plugin?

#

yep

rough blaze
sullen turtle
#

works

rough blaze
#

your pom

#

right?

iron glade
#

?di

undone axleBOT
sullen turtle
rough blaze
#

alright

sullen turtle
rough blaze
#

how could I keep my particle in a set offset

#

its in between 0 - 4

#

Just want it to be 4

river oracle
sullen turtle
#

ty

rough blaze
#

how could I put a particle above the players head?

drowsy helm
#

theres a heap of overloads for spawnParticle some with offset values

rough blaze
fervent robin
#

Hey, For obfuscation what classes do I need to exclude? I keep getting this

drowsy helm
fervent robin
#

I am

drowsy helm
#

btw have a look at spigot guidelines for obfuscation if you plan on uploading it

#

theres a few rules

fervent robin
#

Yes I have

#

im following them

drowsy helm
#

usually you dont have to exclude anything for it to work

#

which obufscation tool are oyu using

fervent robin
#

Proguard

rough blaze
drowsy helm
rough blaze
drowsy helm
#

wdym?

#

have you tried the ones with offset parameters

rough blaze
#

yes

#

the offset

#

does 0-1 as it position

iron glade
fervent robin
grave charm
#

optimized is hardly true

iron glade
#

So just cause it's a premium resource?

fervent robin
vocal cloud
#

As if obfuscation does anything to prevent your jar from being cracked lol.

fervent robin
vocal cloud
#

Well I think if your plugin is undesirable that's more of a deterrent

#

If your plugin is worth stealing it's going to be

fervent robin
#

Ok... do you know how to fix the problem though?

worldly ingot
#

The names of your class, method, and variable names does not deter me from pressing Ctrl + C, and Ctrl + V

#

I can still reupload your plugin just the same

fervent robin
worldly ingot
#

And if you put in some sort of piracy check, it's as easy to remove as looking through the decompiled code. If someone has enough time, they can map your whole code as well. A lot of vanilla Minecraft is reverse engineered and mapped

fervent robin
#

Yes like I said "deter"

#

not prevent

worldly ingot
#

It's really not much of a deterrent

#

but sure

vocal cloud
#

You have a licensing system that I bet can be bypassed easily

#

We'd probably have a lot more high quality plugins if people didn't worry about this stuff

fervent robin
#

Ok thats cool I am just asking if anyone knows how to solve the problem

fervent robin
#

I understand its easy to bypass just want to have it obfuscated though

vocal cloud
#

Are you obfuscating a finished jar?

fervent robin
vocal cloud
fervent robin
#

Yes but I am using the jar version

golden turret
#

guys

#

i forgot how to use the chunk persistent data to store data based on blocks 😭

shadow zinc
#

whats a better way of doing this?

#
if (initialKeyValue instanceof ArrayList) {
            new ListEditor(player, (ArrayList<Object>) initialKeyValue```
iron glade
shadow zinc
waxen plinth
#

But also

#

Do instanceof List and (List<?>) instead

#

I highly doubt you specifically need ArrayList

#

Don't be more specific with types than you need to be

#

It makes code more reusable

#

But what're you trying to do anyways?

shadow zinc
waxen plinth
#

It's not

fervent robin
#

Maybe I am missing it but I dont see it in the rules

waxen plinth
#
All resources must run directly from downloaded file without any manual installation steps or access to a specific server. This means that licensing systems of any form are prohibited. This also means that all applicable code must fail-safe in the event of (web) server error.```
fervent robin
#

I see I have seen many plugins use a DRM so thats surprising

native edge
#

Why wont this work: 0 errors

command /advertise:
permission: op
Permission message: "You may not use this command"
trigger:
set {_t} to a new text component from "&aClick the copy and past to copy the ad &6Here"
set click event of {_t} to click event to copy "/Join Jediboxs &l&6Join the community | &l&9Great staff | &l&9Updates every 1-2 days" to clipboard
send component {_t} to player

eternal oxide
#

Permission message: is not a valid key

#

there is much about that which looks odd

#

I'll guess skript

sullen turtle
#

That's skbee right?

compact haven
#

@native edge yeah that’s Skript, you should ask in the SkUnity discord

shut field
#

how do I play the player swing arm animation without using CraftPlayer?

young knoll
#

swingMainHand

drowsy helm
#

bit of a swing in the dark but does anyone have code to calculate status bar offset

shadow zinc
#

so how do I check a cast?

#
    public static <newType, oldType> ArrayList<newType> cast(ArrayList<oldType> list){
        ArrayList<newType> newlyCastedArrayList = new ArrayList<newType>();
        for(oldType listObject : list){
            //Check cast
            newlyCastedArrayList.add((newType)listObject);
        }
        return newlyCastedArrayList;
    }```
drowsy helm
#

if(object instanceof Class)

#

or Class.isAssignableFrom()

#

it's sorta hard with type erasure though

shadow zinc
#

yeah its not really working

#

?paste

undone axleBOT
shadow zinc
drowsy helm
#

i might be wrong but i dont think you can check a type's class unless you have an instance of it

#

which you don't

shadow zinc
#

which part are you referring to?

drowsy helm
#

for your cast method

#

you might have to blind cast and just throw an exception

#

you can't do newType.getClass() unless you have an instance of newType

shadow zinc
#

I probably just might need to read up on generics, then it should be obvious

drowsy helm
#

yeah keep me updated i've had similar issues before aswell

sullen marlin
#
      return (ArrayList<newType>) (ArrayList) list;       
}
#

lol

#

the method is pretty evil

drowsy helm
#

yeah nasty casting

shadow zinc
#

Lol quite a list of warnings

#

the middle one is kinda whatever

drowsy helm
#

ArrayList cast isnt necessary right?

sullen marlin
#

the outcome is the same as yours

shadow zinc
#

yeah I'm still trying to figure out/find an alternative method or approach

drowsy helm
#

Don't think theres any safe way of doing it tbh

shadow zinc
#

makes me think that I need to reevaluate my code then

lost matrix
#

There is none. The only way you can cast every element is by providing more runtime type information like a Class<newType> parameter.

drowsy helm
#

i mean you could have a try/catch for each element

shadow zinc
#

na I need a completely different approach

drowsy helm
#

or

lost matrix
#

You just need to hope that the list you are casting only contains elements which are of the target type. Or else this will get nasty.

drowsy helm
#

newType<? extends oldType>

#

obv not proper java

#

but to that extent

lost matrix
shadow zinc
#

So essentially what I am doing is handling lists, the code starts off here

#

so it begins in the form of a wildcard arraylist

#

To my knowledge there isn't really another way?

lost matrix
#

Generalize it. Make it a List<?>

shadow zinc
#

k

drowsy helm
#

i mean, if its not for an api

#

it should be fine

#

i doubt you'll be putting weird types in the collection anyways

#

good ol @SupressWarnings

shadow zinc
#

k, anyways then I pass it to my listeditor

#

that creates a whole bunch of guis

#

?paste

undone axleBOT
shadow zinc
drowsy helm
#

almost got my left align working

#

the math for this is a pain in the ass

lost matrix
shadow zinc
#

its such a pain though when you have so many fields you need to create

shadow zinc
#

Nevermind I will just use the builder pattern

tepid thicket
#

For this code I get different results.

YamlConfiguration config = new YamlConfiguration();
config.set("material", Material.STONE);
config.save("myfile.yml");

During test-time

material: !!org.bukkit.Material 'STONE'

During runtime

material: !!org.bukkit.Material
  data: {}

Any ideas?

wet breach
#

?paste

undone axleBOT
tepid thicket
#

Well, it's pretty much the code that produces the file. One in a main-method the the other was tested for the plugins onEnable/onDisable context.

#

Or what else do you need?

#

Oh, I actually found what makes the difference. The test environment was 1.13 and the runtime 1.19.

#

When the test environment is 1.19 too the results are identical. Well, still strange this changed between the versions.

wet breach
#

It isn't strange

#

code changes in the implementation of the server between versions

#

in this case Material was changed

#

Material isn't an enum in the latest version if I recall

#

where as in prior versions like your test environment it is

tepid thicket
#

Oh. Yeah, this could explain the change in behavior.

#

Seem then like direct material serialization fails in the current version.

#

Because as you can see, the information that it was a stone before is lost.

shadow zinc
#

Also I just realised I could have used @Getter and @Setter but its still the same thing

tepid thicket
#

I might store it as a String then instead. Adds some code, but still seems to be the best workarround.

#

Thx for the help there.

chrome beacon
shadow zinc
chrome beacon
#

Why did you talk about @Getter and @Setter then :p

shadow zinc
#

Thats a big of an exaggeration, I honestly wasn't aware of that lol 😂

faint frost
#

This is bugging me. Every time I try to call these methods it says its null.

chrome beacon
#

Why are you doing String valueOf the file

faint frost
#

Do i need to? Every time I dont it gives me an error

chrome beacon
#

I doubt you have a file as a key in your config

faint frost
#

no you right

shadow zinc
#

I'm going to show you my config manager, Olivo, can you find some bad stuff in as well, thx

chrome beacon
#

I just woke up

#

Let me start my pc

#

1 sec

chrome beacon
#

ManagerManager 👀

#

Star imports ;/

#

static plugin instance.. use di

faint frost
#

i feel ashamed but im still getting a nullpointerexception with this guy

chrome beacon
#

Does it say what's null

#

Also why is pConfigFile a class variable

#

It should be a local one

#

also also instead of naming it getpConfigFile name it getPlayerConfigFile

faint frost
#

org.apache.maven.supersaiyan.SSJ.getpPc() my bad, the error was in another class. I'm testing code so its not final, i understand its sloppy to do that. also will do.

chrome beacon
#

Wait what why are you using the maven package

faint frost
#

no that was the error in the console

shadow zinc
rough drift
#

there are two different things

#

one is API

#

the other is impl

#

You'd want to only save Material.STONE.name()

#

and then Material.valueOf(name)

faint frost
#

i feel like im missing some simple di method

blazing ocean
#

heres the error: [plugin] has been compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 61.0

subtle tapir
#

Class major Version 62 corresponds to Java 18

blazing ocean
#

i actually started the project with jdk 18 but then changed it

#

at least i thought

wet breach
#

what it is saying, the version of java you are using to run the server is older then the version of java used to compile the plugin

#

update the java version for the server

blazing ocean
#

when i hit package it used /usr/lib/jvm/java-17-openjdk/bin/java and thats the exact same i use for the server

wet breach
#

or just ignore what I said

#

guess you don't need help after all

shadow zinc
#

so DI is essentially using interfaces and passing instances through constructors?

wet breach
#

yes

blazing ocean
tender shard
shadow zinc
# wet breach yes

okay but what if I am too lazy to pass/inject the instance every time?

blazing ocean
shadow zinc
#

Any acceptable alternatives?

wet breach
shadow zinc
#

like a singleton?

wet breach
#

singleton is a way, but not something you want to always use

#

purpose of a singleton is when it isn't ok to have more then one instance and you want to ensure the best you can that there isn't a way for that to happen

shadow zinc
#

So essentially this is the best method?

#
public class PluginName
{
    private OtherClass otherClass;

    @Override
    public void onEnable()
    {
        otherClass = new OtherClass(this);
    }

    public OtherClass getOtherClass()
    {
        return otherClass;
    }
}
public class OtherClass
{
    private final PluginName plugin;

    public OtherClass(PluginName plugin)
    {
        this.plugin = plugin;
    }

    public void doSomething()
    {
        Something something = plugin.getSomethingManager().getNewSomething();

        something.something();
    }
}
wet breach
#

best method is whatever you decide really, we can only advise or tell you what would be more appropriate

#

DI is really only necessary if you intend to allow other plugins interface with it or if you have an API

#

otherwise it really doesn't matter all that much

shadow zinc
#

well this is an API

wet breach
#

then you want to stick with DI as much as possible then

shadow zinc
#

alright

blazing ocean
tender shard
#

the <plugin> tag has to be inside <plugins> ofc

#

but yeah, that works too, unless you overwrite this in an existing maven-compiler-plugin declaration. that's why I always suggest to declare it explicitly

shadow zinc
wet breach
#

ManagerManager?

shadow zinc
#

yes

wet breach
#

if so, the reason being is that it isn't descriptive in what kind of manager it is

shadow zinc
#

Its the manager of managers

tender shard
#

the CEO

shadow zinc
#

lol

#

call it managers or managerofmanagers or ceo?

wet breach
#

ManagerHandler

#

would be better then

shadow zinc
#

so dumping it in the main class would be less ideal?

blazing ocean
fiery prairie
shadow zinc
wet breach
#

you need to set it by using the maven compiler plugin

#

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>
wet breach
#

but you could just compile too for an older version

#

anyways, the above should work, make sure to do a clean build as well

tender shard
#

it's only there for people who are lazy and don't do "JeffLib.init(this)" in their onLoad() or init block

#

and the 50 lines there are just to tell you exactly where you called a method that needed init

shadow zinc
#

Ah, does .init have an advantage over overriding the onEnable in the main class?

tender shard
#

the { } init block gets called immediately when your plugin instance gets created, and before it gets enabled

#

it basically gets called at the moment when all your fields get instantiated

#

so if you only set something in onEnable, then your class object is basically in some kinda "void" state until onEnable gets called

#

doesn't really matter in 99% of cases

grim ice
#

Some mofo just told me workload distribution is multithreading

#

Lmao

wet breach
#

it can be, but doesn't necessarily have to be

#

in fact doesn't even need to be the same program or language either

grim ice
#

multithreading uses more than 1 processor, workload distribution doesn't need to use more than 1

wet breach
#

multi-threading refers to using multiple threads, what you are getting confused with is multi-coring

#

two different things

#

multi-threading is one of the easiest ways you could distribute a workload however it doesn't really work all that well on single core cpu's

#

exception there is if you have multiple CPU's which isn't the same as multi-core

grim ice
wet breach
#

yes

grim ice
#

Whats the difference between multithreading and multi coring and workload distribution then?

wet breach
#

multi-coring refers to being able to specifically target/utilize multiple cores

#

multi-threading just refers to being able to use or create more threads

#

world load distribution is just a concept or talks about concepts in how to break down your workload into smaller ones and how you can go about using or creating mechanisms to then work on those smaller bits instead of just having this one big task

#

however, since it isn't really something specific and more of a concept, what you decide to leverage is up to you. Hence why I said technically you don't have to use the same program it originated from or the same language

grim ice
#

I see

wet breach
#

multi-threading is a form of workload distribution

#

if done properly

#

hence why whoever you were arguing with associates it with multi-threading

#

however, multi-threading isn't necessary for workload distribution you could go with asynchronous tasks

#

asynchronous tasks would distribute the workload as well but those don't necessarily use or create threads to accomplish it

shadow zinc
wet breach
shadow zinc
#

But thats not DI right?

wet breach
#

How would you instead then make your main class accessible ?

shadow zinc
#

by passing the instance?

wet breach
#

how do you pass an instance of your class to something you don't know?

#

it is for others using their API to get the main class instance easily

shadow zinc
#

But it uses the INSTANCE internally

wet breach
#

also a bit handy for yourself too

blazing ocean
shadow zinc
#

I thought you couldn't do this?

wet breach
#

The error says the compiled version is java 18

#

and you are using java 17

#

Which won't work

grim ice
#

don't take example from that

wet breach
#

I have told you above how to fix it, obviously you could just compile for java 17 and told you how to make that happen

shadow zinc
#

Okay I thought I was going crazy

wet breach
#

or you could just upgrade java to java 18

grim ice
#

they don't to have a static variable

wet breach
#

and nothing to worry about

grim ice
#

or a variable at all

#

they can just pass (this) to the classes that use the JavaPlugin

shadow zinc
grim ice
#

the variable isnt being used at all.

wet breach
grim ice
#

its literally redundant

#

@wet breach look at the code, the variable is literally never used

wet breach
#

also, when it comes with statics, since the main class never goes away a static for it is just fine

wet breach
#

it is for the other people using the API

grim ice
#

it's private.

#

wdym not for them..

#

oh wait

#

its public

grim ice
#

well thats bad eitherway

#

static abuse

grim ice
#

mhm, they're doing static abuse

wet breach
grim ice
wet breach
#

is the main class expected to go away?

grim ice
#

they're using the static keyword, on a global state, to pass around the main class

vivid cave
#

Change tag above player name...

shadow zinc
wet breach
#

the main class of a plugin will not magically disappear

grim ice
#

Yes, and?

wet breach
#

therefore using static for it is fine

grim ice
#

What

#

i never said you shouldnt use static for it

#

they don't even have a getter for it

wet breach
#

one of the problems with using static is that whatever you declare static, will never get GC'ed

blazing ocean
shadow zinc
#

But I was literally just told by multiple people that using static in my main class was a bad idea

grim ice
#

it's just public static

wet breach
#

since the main class will never get GC'ed anyways, using a static for it is fine

grim ice
shadow zinc
#

Thats now my current understanding

grim ice
#

the problem isnt in static

#

the problem is how they use it

#

e.g making the static variable public to gain access to it from other classes

#

which is called static abuse

wet breach
#

that is one of the reasons for making it static

river oracle
#

Generally don't reccomend using static over di in most cases but it's fine in quite a few cases imo

shadow zinc
#

not in this case?

wet breach
#

Yes

grim ice
#

using the static keyword is 100% fine

#

except you dont make it public, and instead user a getter

river oracle
#

Bruh want me to say singleton to make your happy

grim ice
#

since bukkit classes are singletons, its fine for that

wet breach
#

Not sure where you are getting in how it is being used is inappropriate o.O are you insisting that they create an entire method to just return the instance?

wet breach
#

that is dumb and a waste of resources

grim ice
#

global state is usually not right, that's what most people think

shadow zinc
#

an entire method, its not that much of a bother

grim ice
wet breach
#

because you are wasting space on the stack when you can just make it public like they have it in the main class

#

in this manner, the only thing on the stack is just the variable and not also an entire method

grim ice
wet breach
#

what advantage does making that a method have over how they are doing it?

#

if there is none, then I don't see how you are being very convincing it shouldn't be done that way

grim ice
#

using "public static" for instances, is just against oop?

shadow zinc
#

isn't it for security?

wet breach
#

security against what?

wet breach
river oracle
#

Generally yes methods like that are to make sure the singleton exists however you knowe that main class of the plugin Is there fully registered 100% of the time

wet breach
#

Functional programming is sometimes necessary in java and is actually more optimal then OOP sometimes

river oracle
#

Oop and functional work well together using fully one or the other Is inconvient imo

wet breach
#

I already told you how it wasn't

river oracle
#

It will also never be discarded prior to the plugin disable

grim ice
#

so in conclusion, i can just forget about di and whatever i just learnt

wet breach
#

The reason it works for the main class is because bukkit already ensures there is ever only 1 instance of your main class

grim ice
#

and just use public static for everything

hasty obsidian
#

Does anyone know what is wrong with my code?

river oracle
#

Not what he is saying

wet breach
grim ice
#

i can do whatever?

river oracle
#

I use di for My main outside of a few isolate cases

#

Generally I find it more readable and maintainable

wet breach
river oracle
#

My exception to this is Bukkit runnable and logging

buoyant viper
#

just dont use static ezpz

grim ice
#

but is there harm to use getters?

buoyant viper
#

dependency injection all the way 💪

wet breach
#

that is main reason for why statics shouldn't be used is because sometimes you can get in a state of the static no longer pointing at the appropriate instance, as well as statics don't get GC'ed

#

but if the class that the static is used for there will ever only be 1 instance and if that class will never go away

#

then the two downsides are a non-issue anyways

grim ice
#

ic

wet breach
#

also, the purpose of the class is important too

#

if it isn't important that your main class gets passed to it or whatever other class, then using a static is also ok as well

#

not all classes require DI

grim ice
#

well ill use getters eitherway since it looks less ugly, even if it's not useful

grim ice
#

i mostly use singletons

wet breach
#

singletons can be bad too

grim ice
#

for what reason?

wet breach
#

but you use singletons but static is used for them

#

which is odd since you were stating it isn't OOP

grim ice
#

i didnt think static is the problem, i thought that using static without getters is

wet breach
#

ah

#

well with singletons you need a getter

grim ice
#

yes

wet breach
#

otherwise you will have lazy singleton

vivid cave
#

I hate getters damn
Sometimes they are understandable for encapsulation and more control of the public/private
But when for small classes like Vector that should be straight forward and hold few data very irritating to write .getX() instead of .x
But u will say it's advised to design like this according to java

wet breach
#

which isn't really something you want all the time

grim ice
#

thats no reason to hate them

wet breach
#

getters are necessary for everyone else not necessarily yourself although can be beneficial for yourself

#

as it makes more clear what it is you are getting

tender shard
wet breach
#

for everyone else, helps maintain a level of control on what it is you are allowing them to get 🙂

vivid cave
grim ice
#

there is a reason why vectors have getters

vivid cave
#

I get the reasons but sometimes I think it's overkill anyway

tender shard
#

but dont tell anyone

vivid cave
#

Haha same

grim ice
#

it's because they're inherented

#

BlockVector is a child of Vector

#

and perhaps for a specific child

#

you may need to override the getter

#

to ensure some conditions

#

e.g if u want the coordinates to never be negative or some thing

vivid cave
#

You can also ovveride the field and the field type...

grim ice
#

field type?

#

no

vivid cave
#

Ah yeah nvm Ur write about this

grim ice
#

what

vivid cave
#

Yeah I understand because of BlockVector the coordinates are ints

#

Whereas in Vector they are floats

#

Makes sense to put getters there yeah

shadow zinc
grim ice
#

No

#

theyre doubles

wet breach
grim ice
#

in both classes

terse lake
#

What api do you recommend spigot or sponge? Why?

grim ice
#

the constructor accepts floats and ints and doubles

#

but then casts them to doubles

#

as far as i know

grim ice
#

and use paper for your server

terse lake
shadow zinc
#

wot bruv

terse lake
shadow zinc
#

💪

terse lake
#

Jokes aside

shadow zinc
#

Spigot because I go no idea about sponge

tender shard
#

damn wtf

#

this as JPG on LOWEST quality is 50kb and it looks like SHIT then

terse lake
tender shard
#

but on PNG, with no quality loss, its only 17kb

#

why is PNG so much smaller than jpg lol

grim ice
#

sponge allows for plugins

#

and mods

#

but bukkit or its forks

#

don't work

#

on sponge servers

terse lake
#

Yeah that's why I asked

grim ice
#

it depends on your case

wet breach
grim ice
#

though, sponge is less famous, afaik

wet breach
#

because they keep changing their API constantly and they are not out of beta

wet breach
#

they been around for like 4 years now or something

#

and still have no set standards

shadow zinc
wet breach
#

uh oh

terse lake
grim ice
#

PNG's two-stage LZW compression takes strings of bits contained in the image's data, then matches those longer sequences to accompanying short codes held in a dictionary (sometimes referred to as a codebook) that is stored within the image file. The result is a smaller file that maintains high quality

#

google

terse lake
shadow zinc
#

spigot for the win

grim ice
#

maybe rename the getters

shadow zinc
#

which?

grim ice
#

instead of adventure()

wet breach
grim ice
#

use getAdventureInstance()

terse lake
grim ice
#

or something like that

#

usually most getters start with "get"

#

or if theyre booleans, use "is"

shadow zinc
#

if thats all you can find then I am happy

terse lake
hasty obsidian
#

Does anyone know a way to create an explosion without destroying blocks

grim ice
#

the Logger variable, i suggest you make it private

wet breach
#

I would redo that

#

your instance can be null if the class hasn't been instantiated but is being accessed via the static

grim ice
#

and fields shold be at the top of the class

#

not in the middle

vivid cave
wet breach
#

and since it can be null and not disabled, throwing that exception isn't quite right

shadow zinc
#

How are you meant to know?

wet breach
#

well how you know something is disabled is because they would get a error on their side that the method they are running is null because your plugin is disabled 😛

#

your plugin can't know that it itself is disabled since you know its not running

shadow zinc
#

what are you saying? just warn?

wet breach
#

I think the logic wasn't clear enough

#

there isn't anything to worry about when your plugin isn't running

shadow zinc
#

so there is no need to check if its null?

wet breach
#

if your plugin is somehow disabled, none of the code runs so I mean

ornate mantle
#

what version do yall use nms in, and do you use mojang mappings or spigot mappings for it?

wet breach
#

how is your plugin checking for something if none of the code is running because you know its disabled

wet breach
#

ok I guess I have to go with an analogy on this one

grim ice
wet breach
#

how does your computer know there is something wrong if it isn't on?

grim ice
#

your whole plugin

#

wont even work

#

if its disabled

#

so nothing will be printed

#

meaning the getInstance() method wont even be in the stack

shadow zinc
#

so essentially he is saying its an unnecessary check?

grim ice
#

No, it is necessary

#

your warning message is somewhat unclear though

#

"disabled" is not really the right word

wet breach
#

it isn't that isn't necessary, just throwing that exception and the resulting message is unncessary

grim ice
shadow zinc
#

Tried to access instance when the plugin was hadn't initialised yet, please make sure you extend Api in your main class!

buoyant viper
#

damn we still on this? just use the service provider bukkit comes with or something

#

avoid static's altogether ezpz

grim ice
wet breach
grim ice
#

ah i misread what u said

wet breach
#

I was just saying you won't have a case of the plugin being disabled and something ever being returned from that code 😛

grim ice
#

"it isn't that isn't" this confused me a bit

wet breach
#

you are the only one to spot it

shadow zinc
#

waewae

#

why

grim ice
#

probably because im not native

buoyant viper
#

did i just get a ghost ping or

shadow zinc
#

I accidentally replied to you

#

And I'm just going to assume my new message will suffice

blazing ocean
#

how do i detect a projectile/arrow launch event?

blazing ocean
#

yes but how do i need to call the method with @EventHandler?

#

like java @EventHandler public void onIdk() {}

buoyant viper
#

also wouldnt they want ProjectileLaunchEvent? lol

blazing ocean
#

yeah that too lol

shadow zinc
#

sorry I didn't really read their message

blazing ocean
#

lmao

buoyant viper
#

u missed one word out of that whole message

#

arguably the most important word besides projectile

#

smh

shadow zinc
#

🤨

buoyant viper
#

also u would do like

@EventHandler
void onProjectileLaunch(ProjectileLaunchEvent event) {
    // do stuff
}```
blazing ocean
#

ok thanks

buoyant viper
#

forgot annotation woops

#

make sure the class the method is in implements like org.bukkit.event.Listener or whatever it is @blazing ocean and then register the class with the server pluginmanager

#

so like in main plugin class do getServer().getPluginManager().registerEvents(new YourEventListener(), this);

shadow zinc
#

They would definitely benefit from some tutorials on the basics of Spigot API

blazing ocean
#

reading the wiki rn

quiet ice
#

it depends

#

You can always perform mitigations, but there are indeed issues that cannot be fixed by the server

distant wave
#

can i somehow make item wearable on head

quiet ice
#

Afaik setting the item as the helmet makes it wearable

#

If you wish to add the interactibility for it however you need to listen to the PlayerInteractEvent and act accordingly if the item is equipped

distant wave
quiet ice
#

?jd-s

undone axleBOT
distant wave
#

oh

#

but i want the player to be able to equip it(so he can drag and drop it to head armor slot)

quiet ice
#

that is a bit harder to do

#

As far as I know you need to emulate the behaviour but there is no clearly defined way of doing it

kindred valley
#

how to use minecrafts original border

tardy delta
#

?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!

shadow zinc
#

how to ask

hushed pawn
#

Hello, i have interesting math problem
first number is Y velicity before hit happen
second is right after

what is the formula of Y knockback?
can someone solve it?

-0,07 0,46
-0,15 0,42
-0,23 0,38
-0,3 0,34
-0,37 0,31
-0,44 0,27
-0,9 0,04
-0,96 0,01
-1,19 -0,09
-1,86 -0,43
-3,44 -1,22

lost matrix
hushed pawn
shadow zinc
#

Then why are you asking?

hushed pawn
#

i bad at math

lost matrix
# hushed pawn where?

Between the first and second value and between every value pair. Those values are completely chaotic. This is not a math problem.

shadow zinc
#

read what 7smile7 wrote

#

its chaotic

#

no formula

lost matrix
shadow zinc
#

You would be better off feeding tens of thousands of those values into a neutral network, but thats still not a correct solution, and most likely won't work

sly surge
#

Do you have a math trauma or sth?

hushed pawn
shadow zinc
sage patio
#

Hi, how a block under players feet falls like TNTRun? somebody can explain a little bit?

hushed pawn
shadow zinc
hushed pawn
#

for bot

lost matrix
sage patio
shadow zinc
#

Whats the bot/npc for?

hushed pawn
lost matrix
hushed pawn
shadow zinc
hushed pawn
shadow zinc
#

I'm assuming you are applying the "calculated" velocity to the bot, when do you do this? Is it on hit, random?

quiet ice
hushed pawn
#

i need it to be natural

lost matrix
shadow zinc
#

Hey smile could you help me with managing DI in my projects, there are couple knowledge gaps on the correct way to do things relating to my commandManager

lost matrix
#

So its
yAfter = 0.5 + yBefore * 0.5

ashen quest
#

Bukkit.getWorld("world") returns null

any idea why?

hushed pawn
#

alot

opal juniper
ashen quest
#

ou

opal juniper
#

use the WorldCreator to load / create worlds

ashen quest
#

ohhhh its because I am loading the plugin on sratup

#

startup*

#
load: STARTUP
opal juniper
#

that would also do it :)

vivid cave
dire marsh
misty ingot
#

anyone know how to get player nbt (spigot 1.19)? cant find it anywhere

#

I know how to get item nbt but I need player nbt for the persistent data stuff

eternal oxide
#

?pdc

misty ingot
#

oh.. I can just do player.getPersistentDataContainer()

tender shard
#

I think I was drunk when I wrote this

eternal oxide
#

lol

#

its not not

tender shard
#

it makes sense though

misty ingot
#

lol wat de fok

tender shard
#

remove means remove from the drops. and after it was removed, it has to be removed from the list that contains the items to be removed lol

ashen quest
#

hey guys, whats something i can detect to open a creative inventory. that does not make sense so ill explain

I am making a op items pack

theres an item which u can use to activate creative (no player shall no, if they do, they get the creative item)

i dont want to give players creative, so I thought of opening the creative inventory when certain events happen

what can the event be, i thought of opening it when the player has X item in the off hand and Y item in the main hand

do u know something thats hard to guess but still possible

basically its an easter egg

tender shard
#

you cannot open a creative inventory without giving them creative gamemode

ashen quest
#

what

#

how does hypixel do that then

eternal oxide
#

Creative is almost completely client side

drowsy helm
#

When does hypixel do it

tender shard
ashen quest
drowsy helm
#

They give you creative mode?

ashen quest
#

i m pretty sure its survival but creative inventory

#

should i make a custom inventory then

tender shard
#

then they just send you a packet telling you you're in creative mode or sth

eternal oxide
#

what makes you think its survival?

ashen quest
#

cuz i played it a few days ago

drowsy helm
#

It’s 100% survical

drowsy helm
#

Thats creative

tender shard
#

ClientboundPlayerInfoPacket with Action.UPDATE_GAME_MODE

drowsy helm
#

Making your own custom Inventory would be a mega pain in the ass

tender shard
#

well there is a method to get the creative category of any given item

ashen quest
ashen quest
tender shard
drowsy helm
#

Wouldnt sending the packet cause a lot of issues

tender shard
#

that way you can detect items they click in their fake creative inv

drowsy helm
#

They cant pick the items

ashen quest
#

how to listen to inc packets? is there an event?

ashen quest
tender shard
#

you need a custom netty handler or you use PacketEvents library

ashen quest
#

ill just create an inventory which shows all the items in the game

#

except legacy materials

tender shard
#

dont forget to check if isItem()

ashen quest
#

with pages and search as well

drowsy helm
#

Why cant they actually have creative though?

tender shard
#

otherwise it would show AIR, WATER etc too

ashen quest
#

cuz then they have godmode

drowsy helm
#

Ah

ashen quest
#

i want them to still stay in survival and eat that fatass damage

tender shard
#

as said, just send a packet telling them they are creative. then listen to ServerboundSetCreativeModeSlotPacket. Then you know the itemstack they clicked. then you send them back to survival

#

that's the easiest method by far and probably how this weird 1.8 server does it

ashen quest
#

xd "weird 1.8"

#

lord choco has entered the chat

worldly ingot
ashen quest
#

lord choco left the chat without saying anything

#

nvm lord choco did say stuff

tender shard
#

let me try it

shadow zinc
#

Is there any way to restrict my class class to only be obtained from a certain classes getter?

worldly ingot
#

Not sure what you mean exactly. You could do some access restrictions. e.g. a package-private constructor if you're constructing and returning a new instance

#

Or a private one if it's a nested class

drowsy helm
shadow zinc
drowsy helm
#

Yeah just use an access modifier on the constructor

worldly ingot
#

Then yeah. Classes in the same package, package-private constructor

shadow zinc
#

so its a language manager but I only to be accessible from my ManagerHandler class

tender shard
#

dirty solution: get the calling class in your contrusctor and throw an exception if it's not the class you want lol

worldly ingot
#

aPES_Laugh That's disgusting, please don't do that

shadow zinc
tender shard
#

lol

#

it was a joke

worldly ingot
#

Wouldn't you have to throw an exception to do that? lol

shadow zinc
#

ik lol

ashen quest
#

even better, throw multiple exceptions directly in the entry point of your plugin

tender shard
worldly ingot
#

ye

ashen quest
#

no plugin, no problem

tender shard
#

no, you can just get the current stacktrace, or create e.g. a LinkageError without throwing it, bla bla

worldly ingot
#

Yeah that's what I mean

#

It's a quick and dirty way to get a stacktrace ;p

tender shard
misty ingot
#

java is hell

ashen quest
#

kotlin 😍

#

brainfuck 😍 😍 😍 😍 😍 😍 😍

misty ingot
#

why couldnt they make minecraft in python

drowsy helm
#

Lmao python

ashen quest
drowsy helm
#

If you want 2fps, sure

ashen quest
#

why couldnt they make minecraft in js

#

and render it in the browser

tender shard
misty ingot
#

lmao

ashen quest
#

minecraft.sheeshhhhh

shadow zinc
#

make minecraft with css

ashen quest
#

yes

shadow zinc
#

There are some really impressive projects done completely in css

misty ingot
#

anyway so I am tryna make this simple cosmetic plugin and I need to store the current active cosmetic of the player (just a string as the name)
should I go ahead and burn my eyeballs and use MySQL or should I just go with Persistent Data Storage?

#

I have no experience with persistent data storage so I thought I should ask before using it

ashen quest
#

pdc is so secksy use it

#

i m gay for pdc is what ill say

shadow zinc
#

my first plugin used messaging channels as a database to the bungeecord server lol

misty ingot
#

it saves even after player leaves and joins back right?

#

...

tender shard
#

yes, that's why its called PERSISTENT

shadow zinc
#

it worked well tho lmao

ashen quest
misty ingot
#

yeah I think my brain needs some rest after that one @tender shard

tender shard
#

otherwise it'd be called VolatileDataContainer 😛

misty ingot
#

trololololol

shadow zinc
#

🤪

ashen quest
#

or even better

#

FuckYouContainer, whenever you try to add data, it just throws FuckYouException

misty ingot
#

lmao

#

best feature

shadow zinc
#

essentially thats setting up mysql for the first time

ashen quest
#

i will make a FuckYouPlugin

#

and it will print FuckYou

#

thats all

shadow zinc
#

fuck thats hot

ashen quest
#
  • make it premium
shadow zinc
#

send me jar

ashen quest
tender shard
#

the max allowed price on spigot is 20 USD

#

🥲

ashen quest
#

nah

#

ill ask md5 to change it

#

he will defo change it for the FuckYouPlugin

shadow zinc
#

md5 understands

ashen quest
#

yep

misty ingot
#

I think I'll stick to my current project for now

#

and die trying to make cosmetics work

shadow zinc
#

or you could fork a cosmetic plugin?

misty ingot
#

cya guys after another 6 hour coding session full of lots of bugs and not so "lots" of progression

misty ingot