#help-development

1 messages Β· Page 336 of 1

regal scaffold
#

So the only solution I found was putting activateDungeon() inside a runnable instead of otherway

kind hatch
#

Just don't run that method in a timer.

#

Make sure it only runs once.

regal scaffold
#

But I need that method to never go out of scope

#

Like I need the stuff inside that method to be constantly running during the game

kind hatch
#

Yes, but that's handled by whatever runnable you have inside of #activateDungeon().

regal scaffold
#

And that's not gonna call generateDungeon() anyways?

kind hatch
#

I'm assuming that #activateDungeon() calls #generateDungeon()?

regal scaffold
#
public void activateDungeon() {
        //Generate switch logic with no code inside of them
        switch (state) {
            case IN_PROGRESS -> {
                generateLevel();
                setWorldBorder();
            }
}
#

Indeed

#

I can see how this is starting to be fucked :/

kind hatch
#

Ok then yea. Let that be handled by its runnable. You can just call #activateDungeon() as is and NOT inside of a timer runnable.

regal scaffold
#

So only run activate dungeon once?

kind hatch
#

Yes

regal scaffold
#

But then the rest of the gamelogic

#
public void activateDungeon() {
        //Generate switch logic with no code inside of them
        switch (state) {
            case WAITING -> {
            }
            case PAUSE -> {
            }
            case IN_PROGRESS -> {
                generateLevel();
                setWorldBorder();
            }
            case BOSS_FIGHT -> {

            }
            case ENDING -> {

            }
            case RESETTING -> {

            }
        }
    }
#

Like there's more stuff in there I'm just deleting it

#

Pretty much like when something has to change any method in the game just changes the state and that changes what's happening

#

But seeing how this is going Im gonna need to rewrite the whole thing

kind hatch
#

Shouldn't the method be named accordingly then? Because, to me at least, activateDungeon() sounds like it should just switch the gamestate to IN_PROGRESS instead of what its doing now.

regal scaffold
#

Fair

#

Yeah so best thing I can do is rewrite that logic correct?

#

I have no idea how to but I'll figure it out

kind hatch
#

It would help. I'd set this up so that I have a DungeonManager class that handles Dungeon instances. I'd put a runnable on the Dungeon class so that it can do gamestate stuff. That way it's tied to that instance and not the manager.

regal scaffold
#

Ok ok I think I understand that part

kind hatch
#

As for how many runnables you would need, I'm not too sure.

#

I haven't exactly done this myself before.

regal scaffold
#

I understand, I appreciate the help

rare rover
#

hmm

kind hatch
#

Well, hold on. Maybe this isn't too hard to figure out.

rare rover
#
    at org.sqlite.core.DB.newSQLException(DB.java:1030) ~[sqlite-jdbc-3.36.0.3.jar:?]
    at org.sqlite.core.DB.newSQLException(DB.java:1042) ~[sqlite-jdbc-3.36.0.3.jar:?]
    at org.sqlite.core.DB.execute(DB.java:881) ~[sqlite-jdbc-3.36.0.3.jar:?]
    at org.sqlite.core.DB.executeUpdate(DB.java:922) ~[sqlite-jdbc-3.36.0.3.jar:?]
    at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:98) ~[sqlite-jdbc-3.36.0.3.jar:?]
    at me.outspending.embarkkmines.API.Database.Database.addPlayer(Database.java:63) ~[EmbarkkMines-0.0.1.jar:?]
    ... 27 more```?
#

this is my first time using sqlite

#

so

remote swallow
#

?paste database class

undone axleBOT
rare rover
regal scaffold
#

ebic so you're willingly staying out of this conversation I see

rare rover
#

everything works except for getPlayerData()

remote swallow
#

my brain hasnt turned on yet

regal scaffold
#

lol what time is it for you

remote swallow
#

7:30am

regal scaffold
#

Try to crack this infinite loop with tasks and terrible code with shadow and you'll literally be flying afterwards

remote swallow
#

sysout the class it comes from

#

might help you figure out where the loop starts

regal scaffold
#

We know where it's comin from

#

In another task lol

#

We

#

We're looking for solutions now

rare rover
#

πŸ€·β€β™‚οΈ

kind hatch
# kind hatch Well, hold on. Maybe this isn't too hard to figure out.

You'd have your gamestate runnable inside the Dungeon class. Then you could either create separate runnables for each state OR you could make criteria with events that can change the gamestate once the critieria has been met.

Take the exploration phase of a dungeon. If that's called IN_PROGRESS, then just make a listener class that checks when they enter the boss room and then change the gamestate to BOSS_FIGHT. The gamestate runnable will take over and then move on to the next phase.

Any additional runnables could be for special boss moves or particle animations. Then you'd cancel them when the phase ends.

regal scaffold
#

oh

#

oh

#

I really like the criteria with events and listeners

#

There's no need for any runnables except spawning mobs

#

Non-stop

#

And I guess I could do that in a while loop

#

I've never done that about making my own listeners and such but I'm down to try

kind hatch
#

You'd have to check a bunch of stuff to make sure they only fire in the right phase, but it shouldn't be hard.

regal scaffold
#

Hmmm alright. seeing a example plugin with that would be useful cause there's a lot of things I don't get just yet

remote swallow
rare rover
#

oh

#

what do i change?

remote swallow
#

one sec

kind hatch
#

I'd remove the newline characters first.

rare rover
#

intellij did that for me

#

i thought i needed that

#

since intellij usually knows whats going on

remote swallow
#
String sql = "CREATE TABLE IF NOT EXISTS tablename (uuid TEXT PRIMARY KEY, name TEXT NOT NULL, /* this cant be location */ NOT NULL"
kind hatch
#

The other thing that looks wrong is the type of data stored. SQL doesn't know what a Location is. So I'd store it as text.

#

At least to get started.

remote swallow
#

might be able to convert location to byte[]

#

okay

kind hatch
rare rover
#

java.lang.RuntimeException: java.sql.SQLException: no such column: 'uuid'?

#

i have uuid in there

kind hatch
regal scaffold
rare rover
#

String u = set.getString("uuid"); 41

regal scaffold
#

Shadow is that a good example?

kind hatch
regal scaffold
#

Well I was just reading through it

#

This is hard

#

Well I have another idea now. What if I remove the runnable from activateDungeon() and make methods call it

#

There's only a few triggers that happen that are not player commands

#

@kind hatch Does cancel() inside a runnable start the run() method from the start?

#

And return gets it out of scope completely, right?

#

How can I like cancel execution but then continue from the start

kind hatch
austere solstice
#

Hi. How we can cancel set spawn event with bed? I don't want the cancel PlayerInteractEvent. Any idea?

regal scaffold
#

Ummmmm continue isn't allowed inside void run()

remote swallow
#

if ij is saying "YOU DONT NEED THAT" just ignore it

regal scaffold
#

Nah it won't even compile

#

continue outside a loop

remote swallow
#

dafuq

regal scaffold
#

lmao

#
        new BukkitRunnable() {
            @Override
            public void run() {
                continue;
            }
        }.runTaskTimer(plugin, 0, 10);

#

No bueno

kind hatch
#

Oh whoops, I meant return not continue.

#

It's 2am

regal scaffold
#

Wait are you sure?

#

Return doesn't go out of scope?

kind hatch
regal scaffold
#

Sick. thanks

remote swallow
#

if it was a for loop continue would move to the next possible value to iterate over

rare rover
#

Is there a way to store any type data then get it back later without parsing it

#

Gson maybe? Idk

chrome beacon
#

Gson can do that for basic types but not any type

rare rover
#

So what could?

chrome beacon
#

Nothing. You will have to write serializers for complex types

rare rover
#

Ah

#

That shouldn't be too hard..

regal scaffold
#

I wanna add a safety check to my task

#

How can I check if the task is already running, if so, don't rerun it

#

I fixed it btw @kind hatch thought you wanna know hehe

remote swallow
#

you use bukkit runnables right?

#

oh wait

#

i just brained

regal scaffold
#
        new BukkitRunnable() {
            @Override
            public void run() {

        }.runTaskTimer(plugin, 0, 20);
#

I think I can't if I do it this way

remote swallow
#

create a boolean outside of the method and set it if its false

regal scaffold
#

oh ok true

#

ummm wait no

#

That won't work

#

I got an idea, it's alr

remote swallow
#
private boolean methodRunning = false;

public void myVeryCoolMethod() {
    new BukkitRunnable() {
        @Override
        public void run() {
            if (!methodRunning) 
        }
    }
}
regal scaffold
#

Oh I guess

#

And then just cancel

remote swallow
#

yeah

regal scaffold
#

alr ty

remote swallow
#

if it is running cancel the task

regal scaffold
#

But then

#

Where would I set it, and where would I set it back to false

#

I guess before any cancel

#

Ok yeah I rsorted it

#

cool

remote swallow
#

if it is false set it

regal scaffold
#

yup yup done it

jade rock
#

event.getEntity().getKiller() doesn't work in playerdeathevent

remote swallow
#

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

jade rock
remote swallow
#

is the killer a player

jade rock
#

no

#

Entity killer = event.getEntity().getKiller()

#

it just says killer is null

remote swallow
#

theres your answer, some reason getKiller is only an entity if its a player

jade rock
#

slain by a mob doesn't count?

remote swallow
remote swallow
jade rock
#

hmm alright

remote swallow
jade rock
#

alr thanks

crimson vault
#

Hey I see more and more on Minecraft servers really cool custom texture packs where the scoreboard is added with new icons that don't exist in the game and so on. Therefore I have a question. How can something like this be implemented?

past wedge
#

Hello, I have a quick question: how can I convert a string to a class. For exemple, I have the following string: "Arrow" and I want to covert it to Arrow.class, how can I do this please ? thanks in advance !

rare rover
#

Caused by: java.lang.ClassNotFoundException: me.outspending.variableapi.testing.test@46854d26

#

heh?

#

oo nvm

#

i see the problem now

rare rover
#

Um, question. How do y'all keep track of all the classes? Because im cramming like 6 different ones and it gets so confusing since im trying to make it work. Any suggestions?

crimson vault
drowsy helm
#

How are you structuring your project

drowsy helm
#

Or something to that effect

rare rover
#

Bed*, but its hard like fixing things because most of those go in different directions so

drowsy helm
#

Doesnt look that complicated yet

crimson vault
drowsy helm
#

Jsut make sure you are following the SRP rule

#

Single responsibility per method

rare rover
#

I have 0 idea what that is but I'll look it up

#

Ah

drowsy helm
#

Well full name is single responsibility principle

#

It’s a good guide to have clean, readable code

rare rover
#

Well uh, my thing is split up into like 6 classes as you can see

#

I could probably remake it and make it 1

#

😳

drowsy helm
#

What does the sterilizer do

#

Sometimes multiple little classes is better than one big

rare rover
#

Im making my own storage system so you can register whatever you want

#

And then retrieve the same thing

drowsy helm
#

Register to what?

rare rover
#

Whenever the variable is the class Location it will convert it above but this is very early and like i wanna change alot of stuff

drowsy helm
#

Waiiit

#

Do you mean serialize?

#

Serialization is already a thing

rare rover
#

Yeah i spelt it wrong πŸ™„

#

Yes but im making my own system

drowsy helm
#

Gotcha

rare rover
#

Atleast try

#

Feel like it's easier in the long run

drowsy helm
#

Fun system to make

rare rover
#

Its super fun so far I've gotten decently far in like 1 hour

#

I feel like ima run into alot of problems but πŸ€·β€β™‚οΈ

drowsy helm
#

Not doing it right if you dont have issues lol

rare rover
#

True true!

#

But its pretty fun so far

#

Haven't really coded it the best, i like to make a template then make it good afterwards, not sure if that's a good thing or not

drowsy helm
#

Eh refactor later

#

Never a good thing to over optimise early

rare rover
#

Yeah exactly

#

And most likely you'll change it so why make it optimized if you're just going to remake it

#

Afterwards ima optimize alot of it. It definitely needs some optimizations πŸ˜…

edgy crystal
tardy delta
#

no no no dont use wait or Thread.sleep things

#

?scheduling

undone axleBOT
remote swallow
#

ur pfp man

edgy crystal
tardy delta
#

they have a scheduler too

ivory sleet
#

^

past wedge
#

String "Arrow" to Arrow.class ?

edgy crystal
hazy parrot
#

Thread sleep is still an problem

glacial shell
#

How would I get an item/itemstack from another class? I tried doing ClassName.ItemName/ItemStackName but that didn't work

undone axleBOT
tardy delta
#

?di

undone axleBOT
icy monolith
#

Guys im new to java. Where can i find help in this area and what are the best documentations for minecraft java plugin development

hazy parrot
#

?jd

weak kayak
icy monolith
#

Also what do i do if i have made my InteliJ project kotlin and i want to go back to just java. i see that kotlin almost has no info on minecraft development and it would be better to do it in java.

icy monolith
frank kettle
#

?paste

undone axleBOT
weak kayak
#

observing code and trial & error are the best ways to learn imo, at least they work for me

#

if you ever feel stuck though feel free to dm me, i'm always free to help

icy monolith
#

What about if i have my inteliJ plugin made into kotlin. How do i make it Java again without needing to make a new plugin?

hazy parrot
#

It's probably better to start with java

weak kayak
#

if you don't wanna rewrite it, you could compile it and use something like JD-GUI to decompile it into java

icy monolith
#

yes, thats why im asking

hazy parrot
#

Java and kotlin are different languages, compiling and decompiling will not guarantee that code will do what its supposed to

icy monolith
hazy parrot
#

There are kotlin stuffs which you can't do in java

icy monolith
#

The code can break

weak kayak
#

kotlin and java both compile to java bytecode, don't they?

tardy delta
#

yes

icy monolith
#

Dont rly need it it was just me messing around

hazy parrot
#

They do, but kotlin have some implementations java doesn't

gleaming grove
weak kayak
#

it still compiles to java bytecode and can be ran on a JRE, i reckon it could be decompiled into java code with only a few issues

frank kettle
#

The class code: https://paste.md-5.net/otuvosotam.cs

the 1st event (PlayerInteractEvent) is working fine, but the block event isn't(is not getting called at all), anyone knows why?

(ignore rest of code cause i copied from old plugin and I want to improve now but first wanted to see this work)

weak kayak
hazy parrot
#

it's not guarantee to work

icy monolith
hazy parrot
#

Plus with kotlin, you will use kotlin stdlib which is not available in java

weak kayak
#

oh, that's a fair point

#

although you could use the kotlin standard library as an external library, could you not?

hazy parrot
#

You can, but at that point just use kotlin

icy monolith
#

Under Tools>Kotlin>(the "decompile to java" option is gray and unclickable)

pseudo hazel
#

my advice is to start over but on java

#

there are multiple reasons why this is a good idea but I think one if the important one is that you learn more

icy monolith
#

Yes im trying

pseudo hazel
#

if you are going to convert your old code you might end up with stuff that leaves you even more confused

icy monolith
#

thing is that i have no code

#

i just want it to go back to java from kotlin

pseudo hazel
#

well then whats the issue xD

rotund ravine
#

Decompiling kotlin does indeed produce javacode, but like it won't be as pretty as normal java code.

pseudo hazel
#

just make a new project

weak kayak
icy monolith
#

Dam, so a new plugin it is?

hazy parrot
icy monolith
#

ok

hazy parrot
rotund ravine
weak kayak
pseudo hazel
#

yeah it will be a new plugin, whats the problem with that?

rotund ravine
#

You can just continue in kotlion

weak kayak
#

that is also an option

tardy delta
#

have fun dismantling the bytecode

hazy parrot
weak kayak
#

beautiful

icy monolith
#

Ok where can i see all the inteliJ projects so i can delete them?

rotund ravine
#

wherever yo usaved them

fierce whale
#

Is there a way to entity face specific entity?

weak kayak
timid jetty
#

Might be stupid question but how do I spawn a block at a certain location?

weak kayak
remote swallow
#

location.getBlock().setType() @timid jetty

weak kayak
weak kayak
#

no problem

weak kayak
#

it seems to not be using the math i remember it using, i must have misremembered and thought of the forge way to do it

warm light
icy monolith
#

Worked Erdi__.

#

Ill try making something and see

weak kayak
#

if you have any further problems, feel free to ask

grizzled oasis
#

Hi with bukkit task i tried to remove sponge block but my server litteraly dies, what can i try to fix and not giving player sponge

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.

rotund ravine
#

?nocode

grizzled oasis
hazy parrot
#

Send code

icy monolith
# weak kayak that's great to hear

One thing i noticed with kotlin was that it allowed me to update my plugin without needing to delete and replace the old jar file. Is that possible here?

weak kayak
#

i can't be of much help

#

sorry

remote swallow
#

you can use the debug tools in intellij to run a server but running one outside of ij is better

timid jetty
#

Quick question, sorry it's been a while since I've done any development stuff. On player death, when the player drops their items, is each stack considered a separate event for PlayerDropItemEvent

remote swallow
#

i dont think that will get called on aplayer death

#

been as drops are access drops from player death event

timid jetty
#

Hmm okay

icy monolith
#

Feels like a lot of time

weak kayak
timid jetty
#

hmm okay so if i wanna keep track of an item on death how would I best go about doing that

weak kayak
pseudo hazel
#

i rarely have to restart, usually /reload is enough

hazy parrot
timid jetty
#

kk

pseudo hazel
#

automate it how

weak kayak
hazy parrot
pseudo hazel
#

yeah ig, all of my static fields are final anyways haha

pseudo hazel
hazy parrot
#

I can send you mine pl

#

Which do it

pseudo hazel
#

sure

#

thanks

warm light
hazy parrot
#

If you compile with -p export-local it will go into plugins

#

Without it, it will be normal

timid jetty
#

quick question again sorry, if im running an event on the death event, is the players inventory already empty at this point or can I check if players inventory contains something before checking all the drops

#

kk

weak kayak
#

such as decompiling the plugin and removing the auth() call

icy monolith
#
    public void onBlockBreak(BlockBreakEvent event){
        if event.getblock() == "Grass_Block" {
            event.setCancelled(true);
        }
    }```
Prob dum question, but i'm new. I tried to make it so when a grass block is broken it cancels the event. 
Would this work? Also getBlock() shows as red/error.
weak kayak
#

or the auth() method altogether, or its contents

undone axleBOT
tardy delta
#

use .equals() on strings

warm light
tardy delta
#

and probably want block.getType() == Material.GRASS_BLOCK

glossy venture
#

ah yes

remote swallow
#
if (event.getBlock().geType() == Material.GRASS_BLOCK) {
    event.setCancelled(true);
}
tardy delta
#

lmao

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

weak kayak
#

i don't know any ways to prevent piracy

tardy delta
#

:)

remote swallow
#

getType will give you something you can check against things

grizzled oasis
# hazy parrot Send code
       BukkitScheduler scheduler = Bukkit.getScheduler();
        scheduler.runTaskTimer(this, () -> {
            if(Bukkit.getOnlinePlayers().isEmpty()) {
                return;
            }    

            for(Player player : Bukkit.getOnlinePlayers()) {
                for(ItemStack i : player.getInventory().getContents()){
                    if(i.getType() == Material.SPONGE) {
                        player.getInventory().remove(i);
                    }
                }
            }
        }, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);

This is inside the main class, my server crash

rotund ravine
#

what's the crash log?

remote swallow
#

listen to inventory click, drag, item pickup ect and check if it contains sponge not forever loop over players and their inventory

hazy parrot
#

Isn't there just contains method in inventory?

grizzled oasis
hazy parrot
#

Or smth like that

remote swallow
#

yeah

civic saddle
#

Use listeners

#

As epic said

icy beacon
civic saddle
#

You can do it by just using the event when the player clicks, picks up, drags

icy monolith
#

@weak kayak Where do i get the .jar after?

civic saddle
#

That's an easy and nicer method to do that

grizzled oasis
civic saddle
#

Instead a loop that kills your server

river oracle
grizzled oasis
civic saddle
weak kayak
grizzled oasis
weak kayak
#

i can't provide much help, apologies

pseudo hazel
civic saddle
#

A dev did that?

grizzled oasis
civic saddle
#

He lied my friend

grizzled oasis
#

i did that function for testing

civic saddle
#

Oh ok

#

I don't have the listeners in my brain

#

Use the autocompletion

#

It's something like Playersomething

#

Just search in the completion list

#

It is quite obvious once you find

remote swallow
#

listen to inv click, inv drag, item pickup and listen to inventory open

glossy venture
#

bruh what

ivory sleet
#

guess u have to cast String[] to String[]

glossy venture
#

when i click it it does nothing

#

doesnt add cast

chrome beacon
#

Two different types of String or smth?

glossy venture
#

hope not

chrome beacon
#

It's probably IJ being drunk though

trim creek
#

Can I somehow send a BungeePluginMessage without any players online?

glossy venture
#

yeah intellij is terrible with groovy

chrome beacon
ivory sleet
#

you can emulate a player on both the sending and receiving server

#

but its sort of a pain and bug prone

trim creek
chrome beacon
ivory sleet
#

indeed

glossy venture
#

or rabbitmq

trim creek
#

I mean... The command is literally ran when the server goes online ;-;

glossy venture
#

redis only supports string values in messages

grizzled oasis
#

#getInventory().remove removes even stuff inside the main hand and second hand?

tardy delta
#

ij did a verano move

ivory sleet
#

you can send bytes if u want to

glossy venture
#

o

#

oh

#

already implemented rabbitmq shit now

#

probably better anyways as its optimized for messaging

ivory sleet
#

rabbit is better

#

yes

#

cuz redis uses its in memory db at the end to become a message broker

chrome beacon
#

I've seen more plugins use Redis than rabbitmq

glossy venture
#

oh

ivory sleet
#

meanwhile rabbit does it properly in and out

glossy venture
#

but now i do have to host redis, rabbitmq and mongodb

ivory sleet
#

and then it also supports larger messages iirc

glossy venture
#

and more exchange types and shit

#

i think

#

more flexible

trim creek
#

except

#

I don't know how to do that lol

glossy venture
#

id set up redis

icy monolith
#

How do i get the .jar file from InteliJ project. I tried using the CTRL + ALT + SHIFT + S to auto upload the .jar file to the correct folder, but it dosnt seem to have worked.

chrome beacon
#

I don't recommend using artifacts to make your jar

#

Use Maven or Gradle

icy monolith
#

And how i can do that? @chrome beacon

ivory sleet
trim creek
#

and thus I don't get how it works as well

ivory sleet
#

Take the opportunity to learn it maybe then (:

trim creek
#

I probably will

ivory sleet
#

Redis is quite widely used and popular

trim creek
#

but not at this time

glossy venture
#

so using rmq now

trim creek
#

only thing I could really do with Redis I think

#

is to use multiple proxies

#

but all I want to send the bungee message

#

is to just notify me that server X is online again xd

icy monolith
#

Where do i get the .jar file from in intelJ

ivory sleet
#

Oh that was to neon

#

But orby, you know rabbitmq isnt too different from just a raw socket impl

trim creek
#

I can't just write an event to a Bungee plugin that checks whenever a server goes online lol

grizzled oasis
glossy venture
#

sockets are p2p

#

i could write my own rmq server

grizzled oasis
glossy venture
#

but i need to comminucate between any node, cluster or proxy and another one on any machine through the network

#

so i dont think p2p sockets would work

#

or would be very nice

ivory sleet
trim creek
#

This is an example of the message sent AFTER I joined the server. Before I wasn't online on it I could not send it because player was null. This translates into "The builder server is online again.".

glossy venture
#

place to place

grizzled oasis
#

yes

glossy venture
#

idk what the technical term is

#

but rmq is centralized and nodes dont need to confirm to something other than rmq that they are online

ivory sleet
#

No a socket consists of a client and a server where the communication is bidirectional

glossy venture
#

yeah so still direct

#

place2place

#

client2server

ivory sleet
#

Yes thats rabbit also

#

It has a server and clients

glossy venture
#

yeah

ivory sleet
#

Every publisher/subscriber is a client

glossy venture
#

but otherwise id have to write a custom message broker

#

ik

ivory sleet
#

Yes, well you could just run it on the proxy, or a seperate jvm

#

The serverware that is

glossy venture
#

true

#

might do that

ivory sleet
#

Mye

glossy venture
#

after all all communication is abstracted anyways

ivory sleet
#

True

glossy venture
#

so i can just swap impl

ivory sleet
#

Abstraction 😌

glossy venture
#

the impl is a bit goofy

ivory sleet
glossy venture
#

i love java

#

jvm is lit

remote swallow
#

who

#

ohh

#

yeah

icy beacon
icy monolith
#

import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class EcoCave extends JavaPlugin {

    @Override
    public void onEnable() {
        System.out.println("[EcoCave] We are online!");

    }

    @Override
    public void onDisable() {
        System.out.println("[EcoCave] We are signing out!");
    }

    @EventHandler
    public void onBlockBreak(BlockBreakEvent event){
        if (event.getBlock().getType() == Material.GRASS_BLOCK) {
            event.setCancelled(true);
        }
    }
}```

After added the .jar and loaded in game the onBlockBreak event was supposed to cancel the block break event, but i was still able to break the blocks. Its under the regular class that gets auto created when making a project.
glossy venture
#

you dont implement Listener

#

^

#

and dont register shit

remote swallow
#

you appear to be missing an S

icy monolith
#

Ok, Thanks!

ivory sleet
weak kayak
icy monolith
#

Im learning πŸ™‚

#

this.getServer().getPluginManager().registerEvents(this, this);
I had an error for this line:
Illigal start of type
invalid method declaration; return type required
Expected ";"
Code:

    this.getServer().getPluginManager().registerEvents(this, this);

    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
        if (event.getBlock().getType() == Material.GRASS_BLOCK) {
            event.setCancelled(true);
        }
    }
}```
#

oh

weak kayak
#

there's nothing wrong with learning by trial and error, in fact i believe it's a great way to learn

icy monolith
#

Worked i fixed it. Thanks

icy beacon
icy monolith
#

So i basicly just put each class in its own file right? and then anything that is in it must be under an event or some sort of execution.

pseudo hazel
#

wdym by that last part xD

#

I mean if you never call a method it wont get executed yes

#

if thats what you mean

remote swallow
#

each class should be its own file and stuff should be in their method, constructor or be setting a private/public/protected variable

icy monolith
#

like you can't put lets say math stuff right after class line. It must be in an event such as onEnable

pseudo hazel
#

not an event

#

just inside of a method

remote swallow
#

those are called methods

weak kayak
pseudo hazel
#

an event is a method that the game will call when the event happens

icy beacon
weak kayak
#

fair point

icy beacon
#

I can't speak out on this too much, I started with not learning Java either but at one point or another I had to review my basics

#

though I did know a bit of python

#

and well, the basics of programming

icy monolith
#

i do know basics of programing its not like im 100% blindly going into this

icy beacon
#

that surely makes everything better, so you kinda just need to get familiar with the syntax of Java really

weak kayak
#

it helps if you know a language like C# beforehand, or any c-like language for that matter

paper viper
#

This channel is for spigot/bungeecord api usage, not fixing syntax issues

#

period

remote swallow
#

wanna know something cool

remote swallow
#

syntax may sometimes be included in spigot/bungee api help

paper viper
#

uh no

weak kayak
remote swallow
#

uh yeah

paper viper
#

How so?

icy beacon
weak kayak
#

Ask development-related questions here

icy beacon
#

this so

opal juniper
#

hello pulse

#

how are you

paper viper
#

I'm good

#

Wbu?

paper viper
remote swallow
#

it is not

paper viper
#

after all read the first sentence

icy beacon
#

if it did it'd say so

opal juniper
remote swallow
#

notice the | between them

icy beacon
weak kayak
icy beacon
#

why the hell would they say "this is a channel for spigot dev help | this is a channel for spigot dev help"?????????????

weak kayak
#

it means anything related to spigot

remote swallow
#

anyway, what does helping people with syntax do here

weak kayak
#

java is related to spigot

#

and bungeecord

#

helping people understand java is by extension helping them program spigot/bungee plugins

icy monolith
#

paper is included under spigot right?

icy beacon
#

no

#

paper is a fork of spigot

weak kayak
#

paper is a fork of spigot

paper viper
#

well, i personally think that syntax should be a given before learning parts of the language

weak kayak
#

lol jinx

icy monolith
#

kk

remote swallow
#

?paperdev

undone axleBOT
#

Make sure to ask in the appropriate server concerning development towards different JAR types such as PaperMC. (Tip: Google them!)

icy beacon
#

xD

pseudo hazel
#

insert "sir this is spigot" here

remote swallow
#

normally from md

pseudo hazel
#

yeah

icy beacon
remote swallow
#

most of us just ?whereami

weak kayak
paper viper
#

They do

remote swallow
#

there is a paper discord

icy beacon
#

i mean 99% of spigot plugins should work under paper

remote swallow
#

yeah

icy beacon
#

yeah and kinda unreasonable

paper viper
#

not really

remote swallow
#

im pretty sure paper are making breaking changes to their api soon

pseudo hazel
#

yeah you dont need paper especially when you are starting out

icy beacon
#

are they*

remote swallow
#

paper start crying at 1 patch version out

paper viper
#

they aren't really rude tbh, that's something that all people experience when joining some mc discord lmao

remote swallow
#

we dont like supporting 1.8

paper viper
#

after all spigotmc is pretty rude for someone new tbh

weak kayak
remote swallow
#

yeah

remote swallow
icy beacon
#

paper is a good thing in terms of being a server core, but it might be a bit sad to develop for lol

remote swallow
#

^^

icy beacon
remote swallow
#

i dont really read the replies

#

i just look at the code

weak kayak
#

stackoverflow is newbie hell

icy beacon
#

yeah

weak kayak
#

also this topic might need to move to #general

remote swallow
#

this happens enough

#

its fine

icy beacon
#

we still talking about development haha

paper viper
#

The only reason why people think paper is rude is because they don't talk there lol

icy beacon
#

this is "help-development" after all

weak kayak
remote swallow
pseudo hazel
#

well yeah you dont go to Stack overflow to ask questions since all questions have already been asked

icy beacon
weak kayak
icy beacon
#

oh and it's also off-topic

pseudo hazel
#

exactly

remote swallow
#

if people couldnt talk in here unless it was for help i doubt any help would actually get given

pseudo hazel
#

so yeah just assume if you cant find the answer on stack, it doesnt exist

icy beacon
#

i've once read that "stackoverflow should be a last resort after you've done plenty of research", but i thought SO was a QnA site...

#

there's a good video on stackoverflow problems somewhere

#

i'll go look for it

weak kayak
#

i don't like stackoverflow, i personally hack something together whenever i don't know what to do

#

that totally turns out great

#

just don't look at my github

remote swallow
#

most of the time something doesnt work for me

#

i just try and jank something together

#

if that doesnt work i go to the spigot forums or something

icy beacon
remote swallow
#

then stackoverflow

weak kayak
#

i've made like two posts on spigot forums and both of them were newbie level questions

paper viper
#

a lot of people dont realize that you are going to face toxic people no matter what developing skill you are

weak kayak
#

nowadays i don't even really make spigot plugins that often so i don't have to ask anything

paper viper
#

i was flamed years ago when i made my first mod and they were like shitting on me so much...

icy beacon
#

haha that works too

pseudo hazel
#

there are toxic people in everything, not just dev

paper viper
#

Yeah

#

Though i think the toxicity purpose on SO is so people ask meaningful questions that can add to their database

#

rather than some duplicate whatever.

icy beacon
#

it's a qna site

#

not a database

weak kayak
paper viper
weak kayak
#

it was made in java, efficiency is not my priority

#

and it wasn't made to be used in anything

#

it was just an exercise lel

weak kayak
#

paper's discord

opal juniper
#

.gg/papermc

icy beacon
remote swallow
#

bad

#

cafebabe is gonna ban you

weak kayak
icy beacon
#

it still stays q&a

remote swallow
opal juniper
#

nah it gets automod

remote swallow
#

cafebabe just yeets it normally

icy beacon
#

and i've not yet seen a qna site that explicitly hates duplicates and bad questions with this power

paper viper
#

im not using it for any "computer science" way

weak kayak
hazy parrot
icy beacon
hazy parrot
#

No duplicate answers and nicely asked questions

paper viper
#

... i never said that

icy beacon
paper viper
#

ok.. lol

icy monolith
#

But does anything change code wise?

remote swallow
#

yeah

#

they use Components not strings on pretty much everything

icy monolith
#

Everything or some aspects?

remote swallow
#

quite a lot

weak kayak
remote swallow
#

paper change a lot

weak kayak
#

they also have more api stuff

remote swallow
#

they deprecate all string methods

rotund ravine
#

They won’t abandon spigot tho, so you can just code for spigot.

weak kayak
#

precisely

#

you can also use any spigot knowledge

#

even if it is deprecated on paper

#

they won't remove it, that would be stupid

frank kettle
#

For some reason one class of BlockBreakEvent being cancelled is blocking all others to not happen? Is there a way to make all work no matter what?

river oracle
#

Event priority or better logic on your behalf

frank kettle
#

I want like players to not build in that world but be allowed to break certain blocks and I'm doing this in different classes

remote swallow
#

event priority

frank kettle
#

I kinda don't want to put all in the same class

river oracle
#

Seems like the latter is better for you

frank kettle
#

Which priority would be for this? Low?

#

For the classes on top

remote swallow
#

high for the thing to run last, no priority for the other stuff

frank kettle
#

Low happens first right?

river oracle
#

He hates you

remote swallow
#

lowest happens first, but highest has final control

frank kettle
#

Hm

#

I'll play around with it then

#

Ty

glacial shell
#

does anyone know if i should put a space between the ) and the { ?:

if(blockface.equals(BlockFace.UP) || blockface.equals(BlockFace.DOWN)){
if(blockface.equals(BlockFace.UP) || blockface.equals(BlockFace.DOWN)) {
fossil lily
#

How can I prevent my jar from growing to 44mb when I have a bunch of dependencies?

fossil lily
remote swallow
#

maven or gradle

fossil lily
#

Gradle

remote swallow
#

do you have shadow plugin

fossil lily
remote swallow
#

add minimizeJar() to your shadowJar section

fossil lily
#

Alright il give it a shot

remote swallow
#

you can probably just ignore that

fossil lily
#

Is it just minimize?

remote swallow
#

yeah

#

it removes classes you dont use

fossil lily
#

seems like it

#

aight its half the size now, still pretty large though.

icy beacon
#

out of curiosity, what dependencies do you use? xD

paper viper
#

be careful when you use minimize if you use any classes with reflection

lavish hemlock
#

All of them

paper viper
#

it doesnt account for if you define a class with reflection and simply removes it

icy beacon
#

oh firebase

fossil lily
#

is firebase just big?

paper viper
weak kayak
fossil lily
paper viper
#

you can make spigot install libraries for you

#

before you load your plugin

remote swallow
#
libraries:
  - "org.example:something:version"
#

in plugin.yml

paper viper
#

it only works from maven central

icy beacon
#

should be in maven central

weak kayak
#

odd thing, on the mvnrepository page it says the firebase admin jar is just 980 KB

remote swallow
#

^^

icy beacon
#

jinxed

weak kayak
#

it seems to have hella dependencies though

remote swallow
#

if you add it to plugin.yml change implementation to compileOnly

paper viper
#

No

#

the firebase

icy beacon
#

and then you could set it to compileonly in gradle i assume

remote swallow
#

it would mean you dont shade it in

icy beacon
#

don't really know how gradle works

paper viper
#

set it to either compileOnly or compileApiOnly

fossil lily
#

interesting

paper viper
#

depending on your needs

#

another way is to use a runtime dependency loader

#

i made my own library but there are tons of other libraries that can download jars at runtime and load them

fossil lily
#

oh well using that library thing made my plugin 1.1mb

#

lets see if it still works

icy beacon
#

haha

remote swallow
#

how fucking big is firebase

icy beacon
#

i think it will download it to /libraries/ on your server

paper viper
#

I don't know if kotlin sdk is in maven central

icy beacon
#

and then use it from there

paper viper
#

but include that too

fossil lily
#

oh god

#

seems to be working

paper viper
#

Yeah its downloading all the deps for it

remote swallow
#

that should only happen once

fossil lily
#

yea aight

#

thanks people

icy beacon
fossil lily
#

everything is working

icy beacon
#

many letter = workinhg

weak kayak
icy beacon
#

that's true

fossil lily
paper viper
#

there are issues with the libraries feature tho but i dont think you should worry about them because they are rare

weak kayak
icy beacon
remote swallow
#

my mom is bigger

icy beacon
#

when i see a lot of words it's probably working

fossil lily
remote swallow
#

kilograms

#

not bytes

fossil lily
#

xd

weak kayak
icy beacon
remote swallow
#

my mom is deffo heavier

icy beacon
#

and say it's working

fossil lily
#

πŸ‘ real dev

weak kayak
icy beacon
#

yeah

weak kayak
#

i am math

icy beacon
#

probably less than 0.0001kg then

#

no way 40mb weigh 0.1g

#

i refuse

fossil lily
#

yall are smart

weak kayak
icy beacon
#

absolutely

#

Throwable ignored*

fossil lily
#

also anyone know the potion length I should use if I want it infinite

paper viper
#

Integer limit

icy beacon
#

use max value for int ig

remote swallow
#

Integer.MAX_VALUE or something

icy beacon
#

maybe -1 works too

#

check docs

fossil lily
#

thats what I tried

icy beacon
#

oh you probably set the amplifier

#

not duration

fossil lily
#

OH FK

remote swallow
#

MIN

icy beacon
#

xD

fossil lily
#

lmfao

remote swallow
#

MAX

fossil lily
#

im dumb

remote swallow
#

lmfao

icy beacon
#

the moment of realization

weak kayak
icy beacon
#

rubber duck effect

remote swallow
#

sameeee

#

not only am i dumb, im a certified idiot

weak kayak
#

dumbengers, assemble!

fossil lily
#

wait so why dont I have all my dependencies as libraries and have a 44kb jar

remote swallow
#

instructions unclear, drowning in my sink

fossil lily
#

sound fun

remote swallow
fossil lily
#

spigot api is

remote swallow
#

it is?

weak kayak
fossil lily
#

oh it alr is doing that one innit

remote swallow
#

and you dont shade spigotapi anyway

fossil lily
#

yea just realized

#

well looks like I can do it with org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21 too

paper viper
#

update to jdk 17

#

😠

fossil lily
#

yes sir yes sir

#

idk why its 8

paper viper
#

but i do appreciate you for using kotlin

weak kayak
#

java 1.8 is my comfort zone

fossil lily
#

this should be 17 too or

paper viper
#

yes

weak kayak
#

yes

remote swallow
#

fuck java 8

fossil lily
#

xd

paper viper
#

hell no

river oracle
remote swallow
#

if a version doesnt use java 16 or higher i couldnt give a shit about supporting it

fossil lily
#

kotlin best

weak kayak
fossil lily
#

well fk

paper viper
paper viper
fossil lily
paper viper
#

probably different version

fossil lily
#

there are 2

weak kayak
paper viper
#

first one probably

paper viper
remote swallow
paper viper
#

List.of, Set.of

#

Pattern matching

weak kayak
paper viper
#

too many features to name

paper viper
fossil lily
#

wait this is confusing becayse the version of kotlin is 1.8 but idk what java version

paper viper
#

🀒

paper viper
#

Why?

#

they arent even immutable and stuff

paper viper
#

If you are going to use java 8, using smthing like vavr cause it provides some features from java 17 at least

fossil lily
#

40kb gaming

#

somehow before I was using jdk 17 and kotlin 1.8

rotund ravine
#

That's fine.

weak kayak
paper viper
#

that's so long

#

why would you want to do that

weak kayak
#

makes me feel smarter than i am

paper viper
#

Now what about

#

Map.of

weak kayak
#

hmm, fair point

paper viper
#

well i think the smarter move is to make your life easier not harder

#

πŸ˜‚

fossil lily
#

didnt it used to show ** ** lol

rotund ravine
#

It doesn't anymore.

weak kayak
remote swallow
#

yeah

fossil lily
#

sadge

remote swallow
#

changed it in 1.19.3

fossil lily
#

why though

weak kayak
#

mojang do be making questionable choices

fossil lily
#

its not like its counting down but

worldly ingot
#

It was technically a bug

weak kayak
#

it was?

worldly ingot
#

Yes

fossil lily
#

:(

remote swallow
#

why did it show * if it was a bug

weak kayak
#

yeah

#

how would that work

worldly ingot
grizzled oasis
#

yes

remote swallow
#

wait a fucking minute

#

that got fixed like 3/4 months ago

worldly ingot
#

Yeah, 1.19.3

remote swallow
#

THAT WAS 4 MONTHS AGO?

worldly ingot
#

Not quite. It was fixed for a snapshot release

icy beacon
#

why tf is this happening java.lang.NoSuchFieldException: numPlayers at final Field players = ev.getClass().getField("numPlayers"); (screenshot of the class attached)

weak kayak
#

that is odd

worldly ingot
#

I wish they'd added potion durations of -1 to allow for infinite potion effects to resolve that, but meh

fossil lily
#

uhh changing to kotlin 17 removed all my kotlin shorthand

icy beacon
paper viper
icy beacon
#

yeah

#

but like

#

not first

paper viper
#

show full code

worldly ingot
#

Where is numPlayers? Is this a server internal field? If so, they're reobfuscated at runtime

paper viper
#

^

icy beacon
#
 @EventHandler
  public void onPing(final ServerListPingEvent ev) {
    try {
      final Field players = ev.getClass().getField("numPlayers");
      players.setAccessible(true);
      players.set(ev, 32958); // test value
    } catch (final Exception e) {
      e.printStackTrace();
    }
  }
worldly ingot
#

Oh, Bukkit

#

Yeah it should be getDeclaredField()

icy beacon
#

it was what I tried initially

#

to no avail unfortunately

#

maybe a fresh compile..

weak kayak
#

definitely try again

icy beacon
#

yeah i'll do that

worldly ingot
#

I don't think what you're trying to do is going to work though

#

afaik SLPE doesn't use that to adjust player count

icy beacon
#

there was a "ProxyPingEvent" at some point in time apparently

#

that had a #setNumPlayers

#

isn't this a replacement

onyx fjord
#

what packet is used to send entities to player?

worldly ingot
#

There's an add entities packet iirc

onyx fjord
#

what i wanna achieve is to change the range entities are seen per player

#

i guess i can check the distance and cancel the packet?

#

unless theres non packet way

weak kayak
worldly ingot
#

ServerListPingEvent is one of those specially handled events, ZBLL. Internally, that event is extended before it gets called. So when you call ev.getClass() you're getting the internal child class that inherits that numPlayers field but doesn't actually contain it. You can get around this by doing ServerListPingEvent.class.getDeclaredField()

icy beacon
weak kayak
#

or was it PAPI, i keep forgetting my apis

#

the one that allowed you to intercept packets

icy beacon
icy beacon
#

interesting, i'll try this now, thanks

weak kayak
#

that's the one

worldly ingot
#

but again, I don't think this change to that field is going to do what you think it will

weak kayak
#

massive brainfart lol

worldly ingot
#

SLPE doesn't use it internally

icy beacon
rotund ravine
#

getDeclaredField will only return private fields if you are doing it on the class that actually declares it.

icy beacon
rotund ravine
#

I didn't read anything.

icy beacon
#

haha

weak kayak
#

i definitely recommend protocollib for what you're trying to do

icy beacon
#

yeah it doesn't work πŸ˜„

#

looks like i'll have to dig into packets

weak kayak
#

i might have something

#

i remember playing around with protocollib

#

i'll check

icy beacon
worldly ingot
#

It's community maintained but a good chunk of it is Pokechu

icy beacon
#

good to know, thx

worldly ingot
#

A large contributor is Pokechu*, rather. I should clarify. He frequents protocol discussions

onyx fjord
#

oh i see that spigot has entity-tracking-range so that would interest me, however i would want that to be per player

#

without nms ideally

grizzled oasis
weak kayak
#

@icy beacon

ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(plugin, new PacketType[] { PacketType.Status.Server.SERVER_INFO }) {
            public void onPacketSending(PacketEvent event) {
                WrappedServerPing ping = event.getPacket().getServerPings().read(0);
                ping.setPlayersOnline(69420); // example amount
                event.getPacket().getServerPings().write(0, ping);
             }
        });``` this might help
#

It's using protocollib

icy beacon
#

thanks, i'll look into this πŸ™‚

#

i'm just experimenting with what's possible atm

weak kayak
coarse hazel
#

What is the "main class directory" in this context?

To avoid conflicts with other plugins with the same Main class directory, the general guideline is:

#

is it just src?

remote swallow
#

name it what your plugin is

coarse hazel
icy beacon
#

it's not exactly clear

remote swallow
#

the correct location for the class is src/main/java/your/package/plugin

icy beacon
#

bit*

remote swallow
#

eg if i had a plugin i would use src/main/java/me/epic/mycoolplugin

icy beacon
coarse hazel
#

yes but what is a "Main class directory"?

icy beacon
#

perhaps the very top level folder where the main class resides