#help-development

1 messages · Page 1779 of 1

quaint mantle
#

wtf

steady rapids
#

Hi, I'm trying to be able to walk inside end portals without being teleported, I tried cancelling the event:

    public void onPlayerTeleport(PlayerTeleportEvent event){
        if(event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)){
            event.setCancelled(true);
        }
    }```
this works only if I'm in the normal world, if im in the end and I enter the end portal, I get stuck in the typical "loading terrain" screen
quaint mantle
#

ohhh nvm

#

its just meant to look weird but its normal

#

package private String test
static initializer, when called: println "testing"

golden turret
#

is there a way to check when a static variable is changed? 😳

#

like

quaint mantle
#

setters

ivory sleet
#

No not really

#

Yeah you can write your code defensively and observe changes

golden turret
#
static String myString = "a"; //dont warn here

myString = "b"; //warn that the string was changed to b
golden turret
#

nvm, just got a better idea

quaint mantle
#

setters

visual tide
#

setters

quaint mantle
hasty prawn
#

Pretty sure the other one fires PlayerRespawnEvent Sapu

steady rapids
#

mmh so I should cancel that too?

#

now i try

wide coyote
#

use PlayerMoveEvent#setTo instead of cancelling it

worldly ingot
#

Its name is the static init block

#

There's an equivalent init block for instances too. Same thing, just without the static modifier. Will call for any new instance

onyx fjord
#

sysout

onyx fjord
quaint mantle
#

hey hey, so im really not sure anymore at this point

#

basically, i have a HoverEvent for SHOW_TEXT on the usernameColored component, right

#

but nothing else

#

that is the only component that should have the event

#

however, every component after that, has the SHOW_TEXT on it

#

and i dont know why

rigid loom
#

This is the part of the code for one of the plugins from my server. whenever I try to execute /rank player rank it says that this.PlayerHandler is null. can someone help?

#

you have to download the txt file to see it all

mystic sky
ivory sleet
#

yeah cursed

mystic sky
#

This guy XD

red sedge
#

also i think switch would be better for the command part

foggy estuary
#
                Bukkit.broadcastMessage("test");
                }
                     ``` anyone know why when i killed the entity it doesnt broadcast it...
mystic sky
#

broadcastMessage

#

Also, where is the entity defined?

mystic sky
topaz cape
mystic sky
topaz cape
#

he just didn't know the event

mystic sky
topaz cape
#

he still can use the tp event

mystic sky
#

Well, it's more simple using the portal event

topaz cape
#

if he sets the teleport to a diff place

mystic sky
#

I guess that he wont xd?

gleaming grove
#

Hi, how can i extend ItemStack lore? This code do not work ;<

ivory sleet
#

I mean

#

getLore returns a copy

#

iirc

gleaming grove
#

ye, but i use setLore() so new lore should be set

ivory sleet
#

Yeah

#

You’re just setting the already existing lore

sullen marlin
#

Look at what you call addAll on

gleaming grove
#

ahh, ok my mistake

sullen marlin
#

Also, this???

gleaming grove
#

i make class that extends itemstack

sullen marlin
#

Pls tell me those are convenience methods and you didnt extend Item….

quaint mantle
#

wasted

sullen marlin
#

Not the worst, but also not the best

gleaming grove
#

i need extend Itemstack for Inventory GUI

sullen marlin
#

Extending classes isn’t stable api and you won’t ever be able to cast the result of getItem back to your item

quaint mantle
#

You probably dont

gleaming grove
#

maybe not but using pure ItemStack as InventryButton would make big mess in code

quaint mantle
#

why so

gleaming grove
#

for example now i can add property OnClick to each InventoryButton instance

young knoll
#

You can do that without extending

quaint mantle
#

what

sullen marlin
#

That won’t actually work btw

#

Event,getItem won’t return your custom class

ivory sleet
#

Yuh, most of the time you actually get your hands on a CraftItemStack when you query stuff

gleaming grove
#

OnInventoryClick event return the Id of clicked slot and thats enough for me

misty current
#

I had a class extending itemstack but it's a bad idea and it turned out useless

sullen marlin
#

Wrap not extend

misty current
#

I Just made a wrapper class with an itemstack as a constructor parameter

gleaming grove
#

ok that make sense

steady rapids
native bloom
#

This is probably a dumb question, but how do you use meta? I have never needed to use it before.
Most permission plugins support it, and some plugins use it for things such as chat-colour or homeset-amounts, etc.

sullen marlin
#

Vault might let you access it

#

Its a weird legacy thing tbh

#

Especially build

native bloom
#

Thanks

proud basin
#

How can you calculate a player's last location?

young knoll
#

What do you mean last

proud basin
#

like their last x

#

I'm trying to calculate a players x distance

#

and to do that i'd need their last location

ancient plank
#

move event's getfrom() and getto()?

raven zealot
#

Just to clarify, api-version: 1.17 will prevent the plugin from being used on a 1.16 server right?

young knoll
#

yes

raven zealot
#

Thank you

proud basin
#

yea they do

#

cool

coral pilot
#

someone know how to modify the Minecraft Chunk Section palette?

bright jolt
#

ok

worldly ingot
proud basin
#

Why was isOnGround deprecated?

young knoll
#

Check the javadocs?

sullen marlin
#

reading is for chumps

proud basin
#

ah

sullen marlin
#

I only accept answers in youtube video explanations

proud basin
#

nah md you like reading articles

young knoll
#

Hmm, youtube only seems to bring up videos about anticheats

#

And the chip shortage

sullen marlin
#

potato chips?!?!? no!!!!!

proud basin
#

Coll is talking about french fries since he's from the UK

young knoll
#

Yep

#

Both of those statements are correct

round finch
#

Sorry to ask but do anyone know .. how someone will be able to detect User Mouse Click vs PC mouse click
and is it possible somehow? in C++
Note: I'm only a java guy but thinking about going over to c++ for software

sullen marlin
#

from a spigot server?

#

also what is a user mouse click vs a pc mouse click

jade perch
#

Only thing I can guess is a npc click maybe

young knoll
#

I don't think this is related to mc at all

jade perch
#

Maybe

#

Wish he would elaborate lol

coral pilot
quaint mantle
coral pilot
#

its like the parent

jade grove
#

is there any event used to launch players into the air, kind of a like a double jump? i tried playertoggleflightevent, which didnt work

proud basin
#

you could probably mess with the players vel

jade grove
#

i tried

waxen barn
#

Hi there, I have one noob question, but I can't find any solution for it. What is the easiest way to completely remove an enchantment?

proud basin
#

how did you do it?

waxen plinth
#

I have implemented double jumps like that

#

You have to make sure to call setAllowFlight(true) on the player so they can fly

#

And set their flight speed to 0 so they can't abuse it

#

Then when they toggle flight you cancel it and set their velocity

jade perch
#

Use setVelocity

#

That's a lot more compatible with anticheats

waxen plinth
#

Well yeah but you still need some kind of input to determine when to set their velocity

#

I thought that was the point of the PlayerToggleFlightEvent for this

jade perch
#

Idk that just seems like a security red flag to me

waxen plinth
#

Not every project is intended to be put on a large server

jade perch
#

If it works it works

#

Just saying setVelocity does it without all the extra sheet

waxen plinth
#

Yes you can set their velocity with setVelocity

#

But again, if you're trying to implement a double jump, you need some way to activate it

proud basin
#

yay so existed to understand packets ugh

jade grove
#

the event just gets cancelled by the looks of it

round finch
quaint mantle
#

because someone told me to .append everything

#

so please explain, what other method can i use

waxen plinth
coral pilot
quaint mantle
quaint mantle
misty current
#

i'm calling spigot().respawn(); on a player on PlayerDeath event, but the dead player picks up the items dropped in the location they died, resulting in a keep-inventory like behavior

proud basin
#

why use packets when you can use bukkit events

#

makes life 10x easier

hollow bluff
misty current
#

i guess that's a solution

#

how do you clear the drops? there's no set drops method

hollow bluff
misty current
#

thanks

proud basin
#

anyone know how I can check if a player is spriting with packets?

young knoll
#

Surly there must be some sort of flag?

proud basin
#

flag for wjat

#

I guess there isn't any packet type for sprinting

young knoll
#

There must be some sort of incoming packet to tell the server

proud basin
#

to know if they are sprinting?

hexed hatch
#

Are there not api methods for checking that?

round finch
#

yes player.isSprinting()

lavish hemlock
#

there's gotta be a isSprinting somew-

#

yeah

round finch
#

that why i asked

#

why packet?

proud basin
#

because

hexed hatch
#

Why are you messing with packets for that

proud basin
#

api bad

hexed hatch
#

That’s.. a bad take but okay

proud basin
#

nah

hexed hatch
#

yah

round finch
#

i assume you're doing packet work

#

with player entity

proud basin
#

currently im doing prediction

lavish hemlock
#

I mean Bukkit's API definitely ain't perfect but you should still use it, probably :p

round finch
#

Maths true and falses

#

😂

hexed hatch
#

I’m just struggling to think of a good reason to work with packets for actions that are already wrapped by the api

lavish hemlock
#

There isn't one.

#

: )

proud basin
#

would you say fly ticks and air ticks are the same?

quaint mantle
waxen barn
proud basin
#

yes

#

maybe

hexed hatch
#

How much air the entity has, in ticks. Fills to a maximum of 300 in air, giving 15 seconds submerged before the entity starts to drown, and a total of up to 35 seconds before the entity dies (if it has 20 health). Decreases while underwater. If 0 while underwater, the entity loses 1 health per second.

sullen marlin
#

Just prevent people enchanting it?

#

PrepareItemEnchantEvent -> delete bad enchants

hexed hatch
#

If you're looking for a api solution, you'd have to ensure that enchanting tables can't give it as well as all loot table sources

waxen barn
hexed hatch
#

you could alter the loot table itself or hook in to LootGenerateEvent

waxen barn
#

it's a private plugin, so I don't have problems with using nms if it would simplify the code alot

sullen marlin
#

Casting a player to an event

#

Bruh

hexed hatch
#

some people just don't learn basic java lol

jade grove
#

oh

#

im retarded

#

i didnt use the interactevent param

quaint mantle
quaint mantle
sullen marlin
#

Idk

#

Try ComponentSerializer.serialize or whatever and see what the json looks like

#

I don't see any show text in your example though

proud basin
#

finally

waxen barn
hexed hatch
quaint mantle
#

i'll try these out

hexed hatch
#

try again

quaint mantle
hexed hatch
#

try again but harder

#

and show code

quaint mantle
#

ding

hexed hatch
#

make a new hover event

#

but I would do what papa md_5 said to do first

quaint mantle
#

like this?

hexed hatch
#

hacky solution should be last resort

waxen barn
# quaint mantle

try inserting the setHoverEvent after append insted of using it for each component after it, because it maybe gets overwritten

quaint mantle
proud basin
#

How good would you guys rate my movement prediction? ```
lastDeltaXZ * 0.91F + (profile.getPlayer().isSprinting() ? 0.026 : 0.02)

quaint mantle
#

boom @sullen marlin

quaint mantle
proud basin
#

Any way to suggest to fix it because I'm getting some falses in it?

#

specially when walking

crisp kiln
#

targetSelector.a(0, new PathfinderGoalNearestAttackableTarget<EntityHuman>(this, EntityHuman.class, true));

#

the pig doesn't walk towards me

proud basin
#

well I know sprinting is faster

#

but this is how im checking difference > 1e-12

#

and it falses when I walk and sometimes when sprinting

sullen marlin
#

@quaint mantle the issue is .reset operates on the component before it. Consider using the append(..., FormatRetention.NONE)

round finch
#

What Math fuction do i use to check how many times 9 goes into 54

#

with java

glossy venture
#

make sure both a and b are ints

#

actually idk if thats required

round finch
#

a is 9 and b is 54? right

#

i forgot about % lel

glossy venture
#

other way around

round finch
#

ok 54 % 9

glossy venture
#

that will return the remainder

#

you will need 54 / 9 to get how many times 9 fits in 54

round finch
#

but reminder is 0

glossy venture
#

yeah

round finch
#

working on inventory

glossy venture
#

but if thats always 0 then why not just use division

#

or a constant value?

round finch
#

intslrubyfacepalm oh gosh me!

#

ofcourse

round finch
#

int modulus = 54 % 9;
int result = 54 / 9;

is that right?

#

54 / 9 = 6 times

#

ok i figured that out

eternal oxide
#

what are you trying to calculate?

#

optimal size or if its a valid size?

round finch
#

Math hidethepainharold

#

i figured it out

eternal oxide
#

Figured what?

#

The size of an inventory to contain x items?

round finch
#

no worry i got it :))

eternal oxide
#
public static int getOptimalSize(final int spaces) {
    return (int) Math.ceil(((double) spaces) / 9) * 9;
}```
round finch
#

oh Thank you i will use that too

eternal oxide
#

nope, if your first value is an int it will cast all others to int too

round finch
#

ok Ceil is up right?

#

then floor is down

eternal oxide
#

I just tested it and you are correct

#

So both will work

#

This is a formula we ended up with after a long discussion in here over teh best way to calculate it

#

There may be some other reasons to cast the first to a double I'm unaware of

#

optimization possibly

quaint mantle
#

Is there a player property that could help me tell if a player is an admin or not?

eternal oxide
#

admin or op?

quaint mantle
#

Uhh op*

eternal oxide
#

admin is not a server role

quaint mantle
#

Sorry- and thank you

carmine urchin
#

Is it better to have multiple small plugins or one plugin with lots of code

young knoll
#

Small plugins will be easier to maintain

#

Performance wise the difference is negligible

carmine urchin
last citrus
#

Is there a java program I can use to unzip a server texture pack?

eternal oxide
#

do you mean decompile?

last citrus
#

I meant to say texture pack sorry

eternal oxide
#

7-zip

last citrus
#

It says its corrupted

eternal oxide
#

then its corrupt

quaint mantle
#

use java to unzip it

last citrus
#

But it works in game

last citrus
eternal oxide
#

link it in here

quaint mantle
#

google

#

lots of stackoverflow posts of extracting a zip in java

last citrus
eternal oxide
#

not a zip file

last citrus
#

I made it a zip but it didnt work so i set it back

sullen marlin
#

linux unzip command extracts that just fine

last citrus
#

I dont have linux

sullen marlin
#

I take that back, everything is empty

eternal oxide
#

try winrar or something then

sullen marlin
#

but what are you trying to do anyway

#

seems like youre pirating another server's resource pack

lavish hemlock
#

I mean his name is "AidanTheBandit" after all

last citrus
#

Is that not allowed?

sullen marlin
#

did the server give you permission?

last citrus
#

No. The server is Mineclub

sullen marlin
#

also if you just wanted to run it outside the server you could just load it anyway

#

you wouldnt need to unzip it for that

last citrus
#

Oh ok

livid tundra
#

if I run ((Creeper) entity).ignite(); when it already ignited, does it reset the ignition?

quaint mantle
#

hey md_5

#

what is the bridge dependency in minecraft vanilla?

sullen marlin
#

its part of the client so idk

quaint mantle
#

hmmm do you have link for it?

sullen marlin
#

its part of the client so idk

#

most mojang code isnt open source

quaint mantle
#

copy pasted... ok

#

hmmm so i have to fork minecraft vanilla by shading its own jar

#

👌

#

oh btw deobfuscation is done before decompile if a jar is deobfuscated?

proud basin
#

you know there is an easier way right...

quaint mantle
#

no i dont

#

...

proud basin
#

Contact mojang and asked them for the github repo

young knoll
#

Lol

quaint mantle
#

i wish i could

#

welp lemme try

#

😂

proud basin
#

I'm actually curious what they would respond with

quaint mantle
#

i think they will just end up give me a long message talking about how they were made in 2009, then in the end they will just say no and block me

#

hmmm???

#

wtf?

proud basin
#

what?

quaint mantle
#

oh wait this isnt general chat

#

sorry wrong chat

quaint mantle
#

you can still use that alias tho

#

it just shows up as rainbow_flag now

worldly ingot
#

I mean :shit: is an alias for 💩 as well

quaint mantle
#

:hankey:

fading pulsar
#

🤔

quaint mantle
#

hey the FormatRetention.NONE didnt do anything

#

acutally idek wjhat it does tbh

summer scroll
#

Basically I have a reputation plugin and players can only give 3 reputation, and after that it will start a countdown 24 hours till player can give 3 reputation again, How can I accomplish countdown timer and format it like 2h 15m? And I saved the LocalDateTime when player ran out of reputation usage.

summer scroll
#

Here's how I saved the LocalDateTime reputationRunOut: 21-11-2021 00:01:44, and I need to check If that time has passed 24 hours (which I already know) and I want to know the remaining time until it pass 24 hours too.

somber hull
#

ok

#

big question

#

when should i save my config?

#

obviously not every time i change it

echo basalt
#

On disable

somber hull
#

or the plugin is restarted wrongly?

echo basalt
#

I generally do a weird system where if I do a ton of changes, I only save once all those changes are done

somber hull
#

hmm

#

what abt like every 5 mins

echo basalt
#

async ofc

somber hull
#

and on disable?

echo basalt
#

Once every 5 minutes might be unreliable

somber hull
#

like if changes have ocurred

echo basalt
#

If you're using a .yml file for a database I'd suggest you stay away from that

somber hull
#

say im not using yml file for a database

#

say im using json

#

then should i save every 5 mins?

echo basalt
#

If you don't need something human readable make a proprietary extension and save often

#

Or just use an SQL database

somber hull
#

i dont wanna get into sql lol

#

i know it wont be hard

#

and i probably should

#

but until i need it

#

im not gonna

summer scroll
#

you'll use it eventually

waxen plinth
#

If you scale up, json is very bad

somber hull
#

but i havent done any big projects yet

waxen plinth
#

SQLite is quite easy

#

It's not about the size of the project

#

It's about the amount of data it needs to handle

dense shoal
waxen plinth
#

Saving a JSON file means you have to write all of the data every time even if only a single value changed

#

SQL on the other hand

#

It's built to scale for handling truly mind-boggling amounts of data

somber hull
#

oki

echo basalt
#

For a public plugin, ideally, you'd add like 25 different ways of storing data

summer scroll
#

and a way to convert between database storage

echo basalt
#

I personally think MongoDB, SQLite and MySQL are solid choices that cover 99% of servers

echo basalt
dense shoal
#

I'm trying to do a custom AreaEffectCloud. I took a look at the documentation and I'm wondering if anyone has better Googlefu than me, but the interface is pretty confusing.

somber hull
#

uhhh

#

leme find it

echo basalt
#

or just packets

#

¯_(ツ)_/¯

somber hull
#

block.getWorld().spawnParticle(Particle.WATER_SPLASH, block.getX() + random.nextDouble(), block.getY() + random.nextDouble(), block.getZ() + random.nextDouble(), 1);

echo basalt
#

that's completely different lmao

somber hull
#

oh

#

really

#

idk

#

i havent worked with the spigot api in 3 months

echo basalt
#

The more you work with spigot, the less you work with spigot

#

Bit odd but that's how it works

dense shoal
#

Believe me, my dev environment has a base library of a couple hundred classes with spigot stuff in it.

echo basalt
#

My dev env is like

#

basic utilities (simple async file loading, simple menu stuff)

#

then 200 classes that have nothing to do with spigot

summer scroll
#

Does anyone know how to get remaining time until LocalDateTime pass 24 hours?

eternal oxide
#

store the long and its simple math

echo basalt
#

24*60*60 - getEpoch % 24*60*60

summer scroll
#

LocalTime#getLong has a parameter of TemporalField, idk what to put there.

dense shoal
#

Circling back to area effect clouds for a second, do I have control over the density of the particles?

eternal oxide
echo basalt
#

Doesn't seem like it

uneven lily
#

how can i add pvp like bedwars in my srver

#

please helkp me

dense shoal
#

Install a plugin that does it

#

I'm listening for PotionSplashEvent and it's not firing when I throw a splash health. Are there any common reasons why this event might not fire?

#

Listener is registered

#

OK, so it seems it's only firing if I throw the potion directly on the ground

eternal oxide
#

are you using a splash potion or a lingering potion?

dense shoal
#

Splash

#

Lingering would be like......uhh, I think just checking EntityDamageByEntityEvent and seeing if the damager is an instance of an AreaEffectCloud

eternal oxide
#

no, there is a lingering potion event

dense shoal
#

wait what

#

Spill

#

Out of interest, I don't need that event right now though

summer scroll
eternal oxide
bright jolt
#

It doesn't work...

summer scroll
#

yess finally

eternal oxide
#

you could do Minutes % 60 to see teh minutes

summer scroll
#

i was gonna ask that, thank you so much

dense shoal
#

OK, so programming 1am mind here, but a PotionSplashEvent only fires if someone gets its effects. I wanted to use PlayerInteractEvent anyways rip

bright jolt
#

mvn install:install-file -Dfile=C:\Users\archi\OneDrive\Desktop\Plugins\MVdWPAPI\pom.xml -DgroupId:be.maximdw -DartifactId=MVdWPlaceholderAPI -Dversion=3.1.1 -Dpackaging=jar -DgeneratePom=true is da cmd im using, cus MVdWPlaceholderAPI doesnt work.

dense shoal
#

OK, nope, I'm still stuck. I'm not sure if this is tired me coding yet or not, but I'm soooo close. This event is only firing if the potion effect from the thrown potion (the clockwork bomb), reaches a player. I need to cancel a potion throw outright. Is using the PlayerInteractEvent not the move here?

#
    // Prevent non Qadirs from using a clockwork bomb
    @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
    public void onPotionThrow(PlayerInteractEvent event)
    {
        // If the event is fired because of a player
        if (MUtil.isntPlayer(event.getPlayer())) return;

        Player player = event.getPlayer();
        UPlayer uPlayer = UPlayer.get(player);
        
        // and the item is a clockwork bomb
        if (!isClockworkBomb(event.getItem())) return;
        
        // and the thrower is a level 3 Qadir
        if (!abilityCheck(uPlayer, 3))
        {
            uPlayer.msg("<i>Only <h>Qadirs <i>may use a <h>Clockwork Bomb<i>.");
            event.setCancelled(true);
            return;
        }
        
        // and the cooldown period has passed
        if (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue() < ConfigQadir.get().clockworkBombCooldown)
        {
            uPlayer.msg("<b>Clockwork Bomb is not ready yet! Wait %s<b>.",
                TimeDiffUtil.formattedVerbose(TimeDiffUtil.unitcounts(ConfigQadir.get().clockworkBombCooldown - (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue())), "<h>")
            );
            event.setCancelled(true);
        }
    }```
echo basalt
#

Anyone more experienced knows how I can stop invisible blocks when loading chunks after modifying their content?

#

I seem to experience weird bugs where if I change the region files and immediately load the chunks, the blocks are there, I can't move, but I'm in a void world

worldly ingot
#

Just don't ignoreCancelled, @dense shoal

#

PlayerInteractEvent will be called with its cancellation state set to true if right clicking the air

#

Just a weird quirk of the interact event

#

Also, as an aside, EventPriority.NORMAL is default. You can omit that too. Just @EventHandler will suffice

dense shoal
#

Good point

#

Removing ignoreCancelled didn't fix my problem sadly

#

Do I need to restart rather than recompile?

worldly ingot
#

Should recompile and reboot your server, yeah.

#

Though if that still doesn't resolve it, debug all your checks to see which one is failing

#

PIE is the event to listen to for this

dense shoal
#

Perfect, thank you so much. I thought I was going nuts.

worldly ingot
#

No problem :))

dense shoal
#

Wait, it's firing twice! fml

echo basalt
#

Once for each hand

worldly ingot
#

Yep. Can ignore if the event.getItem() is null

dense shoal
#

Sadly, we're still having trouble. Redeploying to test.

#

I am logging the item, it doesn't seem to be null.

#
    // Prevent non Qadirs from using a clockwork bomb
    @EventHandler
    public void onPotionThrow(PlayerInteractEvent event)
    {
        // If the event is fired because of a player
        if (MUtil.isntPlayer(event.getPlayer())) return;
        
        // If the item is not null
        if (event.getItem() == null) return;
        System.out.println(event.getItem());

        Player player = event.getPlayer();
        UPlayer uPlayer = UPlayer.get(player);
        
        // and the item is a clockwork bomb
        if (!isClockworkBomb(event.getItem())) return;
        
        // and the thrower is a level 3 Qadir
        if (!abilityCheck(uPlayer, 3))
        {
            uPlayer.msg("<i>Only <h>Qadirs <i>may use a <h>Clockwork Bomb<i>.");
            event.setCancelled(true);
            return;
        }
        
        // and the cooldown period has passed
        if (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue() < ConfigQadir.get().clockworkBombCooldown)
        {
            uPlayer.msg("<b>Clockwork Bomb is not ready yet! Wait %s<b>.",
                TimeDiffUtil.formattedVerbose(TimeDiffUtil.unitcounts(ConfigQadir.get().clockworkBombCooldown - (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue())), "<h>")
            );
            event.setCancelled(true);
        }
    }```
#

I remember there was some kind of duplication checking in a different event, maybe PlayerAnimationEvent. Am I missing something like that?

summer scroll
#

Wait, what is the problem?

dense shoal
#

PlayerInteractEvent is firing twice for some reason and I am getting double messages. I'm making sure that I'm just checking the main hand and that the event.getItem() is not null.

#
    // Prevent non Qadirs from using a clockwork bomb
    @EventHandler
    public void onPotionThrow(PlayerInteractEvent event)
    {
        // If the event is fired because of a player
        if (MUtil.isntPlayer(event.getPlayer())) return;
        
        // If the item is not null
        if (event.getItem() == null) return;
        
        // If the item in the main hand is the potion
        if (event.getHand() != EquipmentSlot.HAND) return;
        
        System.out.println(event.getHand());

        Player player = event.getPlayer();
        UPlayer uPlayer = UPlayer.get(player);
        
        // and the item is a clockwork bomb
        if (!isClockworkBomb(event.getItem())) return;
        
        // and the thrower is a level 3 Qadir
        if (!abilityCheck(uPlayer, 3))
        {
            uPlayer.msg("<i>Only <h>Qadirs <i>may use a <h>Clockwork Bomb<i>.");
            event.setCancelled(true);
            return;
        }
        
        // and the cooldown period has passed
        if (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue() < ConfigQadir.get().clockworkBombCooldown)
        {
            uPlayer.msg("<b>Clockwork Bomb is not ready yet! Wait %s<b>.",
                TimeDiffUtil.formattedVerbose(TimeDiffUtil.unitcounts(ConfigQadir.get().clockworkBombCooldown - (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue())), "<h>")
            );
            event.setCancelled(true);
        }
    }```
summer scroll
#

It still fires twice?

dense shoal
#

Yeah! lol

#

I think this is a product of tired me.

#

But I won't be able to sleep if I can't get this lol

summer scroll
#

It's very unlikely to fired twice after you check the hand.

eternal oxide
dense shoal
#

Nothing

summer scroll
#

Your mouse could be double clicking lol

dense shoal
#

🤔

#

If I left click instead of right clicking the event is only fired once which is interesting.

summer scroll
#

Is throwing splash potion fired PlayerInteractEvent?

dense shoal
#

Yeah throwing a regular splash potion fires twice as well.

summer scroll
#

Then yeah, you have the answer why it fired twice

dense shoal
#

So it's firing twice by functional design?

summer scroll
dense shoal
#

I just happened upon that

summer scroll
#

Same thing happened when you drop item too.

worldly ingot
#

Quick solution would be to Map<UUID, Long> for when they were last messaged and only send a message, say, once every second or so

#

A bit dirty, but it would be a solution

summer scroll
#

Yeah, add a cooldown or something

dense shoal
#

I'm considering using PlayerAnimationEvent

#

Does that seem sane?

summer scroll
#

Never heard of PlayerAnimationEvent before.

dense shoal
#

This might be some crazy person stuff going on, I cannot be trusted right now.

#

I don't know what happens if you cancel the animation event though, it might still allow the other stuff to happen.

#

OK, well the good news it that it only sends one message

#

Is there a way to get the associated PlayerInteractEvent(s) from a related event? Can I do that with handlers?

summer scroll
#

I think you are overcomplicating stuff.

dense shoal
#

Good point. I'm going to do the messaging in PlayerAnimationEvent and the cancellation in PlayerInteractEvent

summer scroll
#

The workaround that Choco gave is enough to fix your issue.

dense shoal
#

Good point

torn oyster
#

what

#

this is in the commands package

dense shoal
#

Have you tried invalidating your cache?

torn oyster
dense shoal
#

In the file menu

torn oyster
#

what ones do i select

dense shoal
#

That should be fine. It will take a few minutes for your IDE to get reacclimated, but it might help!

marble granite
#

I have this: e.getClickedBlock().getState() instanceof Openable in an if statement, but its always false, why is this? i know that the block i clicked was a door.

eternal oxide
#

Openable is BlockData

#

Door,Gate,TrapDoor

marble granite
#

oh, that explains

solar sable
#

guys if i put my recipe in another class and then in main i do Bukkit.getRecipe(MyRecipe); will it work?

waxen plinth
#

Probably not

solar sable
#

hm

#

then how to register the recipe from another class

waxen plinth
#

Best to just pass it around as needed

solar sable
#

i want to have an own recipe class and then that class is registered to main so it will work but im not sure how, anyone know?

quaint mantle
#

Get an understanding of what class is

waxen plinth
#

That question is really unclear

#

But yeah learn about OOP

#

?learnjava

undone axleBOT
bright jolt
#

Can anyone help me with this command it isnt working

#

mvn install:install-file -Dfile=C:\Users\archi\OneDrive\Desktop\Plugins\MVdWPAPI\pom.xml -DgroupId:be.maximdw -DartifactId=MVdWPlaceholderAPI -Dversion=3.1.1 -Dpackaging=jar -DgeneratePom=true

#

It's for MVdW PlaceholderAPI

quaint mantle
#

Just abandon mvdw

dense shoal
#

I'm an enterprise Java developer and I still don't know Java

solar sable
#

damn

quaint mantle
#

Who called you enterprise LoL

lavish hemlock
#

I've never done enterprise work in my life but I know more about Java than 90% of enterprise developers.

summer scroll
#

How come Java is the most used language for enterprise app development?

eternal oxide
#

because its uniform across all architectures.

waxen plinth
#

A lot of reasons

summer scroll
#

Ah, I'm quite surprised actually.

lavish hemlock
#

aight

#

give me a question

waxen plinth
#

It's just kinda conceited

#

I'm not here to test you but even if it's true it doesn't come across well to say such things

summer scroll
#

Do you think Java will still be on the top for at least 1-2 decades

waxen plinth
#

I don't know

#

The landscape changes quickly

#

Java is a very solid language so I doubt it's going away anytime soon

#

It might be overtaken by other, more modern languages

#

It's hard to say though

summer scroll
#

Out of all programming language I only interested in java right now

waxen plinth
#

Mmk

summer scroll
#

python will overtake java

eternal oxide
#

I don;t see that happening

summer scroll
#

haha

lavish hemlock
#

C# : )

eternal oxide
#

if BloodCoinsAPI is your plugin you never use new BloodCoindAPI

#

you will have a big error in your startup log

molten plover
#

nono, the top code snip is the plugin that houses the api

molten plover
eternal oxide
#

then you are setting your bloodCoins too early

molten plover
#

so what you're saying is that bloodcoins is loading after the other plugin trying to access it?

eternal oxide
#

Well I'm only guessing from teh minimal code you posted, and it is confusing

molten plover
#

is there a way to make it load after?

#

I thought that's what depend did

eternal oxide
#

depend will make your plugin load after the depend one

molten plover
#

right, so isn't that what's needed here?

eternal oxide
#

at what point are you initializing your bloodCoins variable?

molten plover
#

you mean the api variable?

#

the BloodCoins prefix to the variable is just the class

#

not a variable

eternal oxide
#

BloodCoinsAPI bloodCoins = BloodCoins.api; is a variable, when are you initializing it?

molten plover
#

No, it's an imported class

eternal oxide
#

bloodCoins is the variable, when is it initialized?

molten plover
#

onEnable

eternal oxide
#

then you'll have to show some actual code as what you describe makes no sence

molten plover
#

I got you, 1 sec

#

This is the code of the plugin trying to access the api

eternal oxide
#

ok you need a reference to the BloodCoins plugin, you can;t just static access it

#

you need the instance

#

getPlugin(BloodCoins.class)

#

or getPlugin("BloodCoins")

molten plover
#

Let me give the other one a go

#

I got a casting error

#

Cannot cast com.example.warzonepoints.WarzonePoints to com.example.bloodcoins.BloodCoins

eternal oxide
#

WarzonePoints?

molten plover
#

That's the plugin that's trying to access the API

eternal oxide
#

why are you getting a plugin reference to itself?

molten plover
#

It's not

eternal oxide
#

Your error and teh code you are showign is impossible

molten plover
#

I can screenshare and show you

#

It's the same piece of code that's being ran

eternal oxide
molten plover
#

I'll re-compile but it's the code being ran

eternal oxide
#

unless you are passing it WarzonePoints.class

molten plover
#

here let me add debug prints

#

just to assure it's the same code

#
[03:21:40 INFO]: [WarzonePoints] Enabling WarzonePoints v1.0-SNAPSHOT
[03:21:40 INFO]: [WarzonePoints] 1
[03:21:40 INFO]: [WarzonePoints] 2
[03:21:40 ERROR]: Error occurred while enabling WarzonePoints v1.0-SNAPSHOT (Is it up to date?)
java.lang.ClassCastException: Cannot cast com.example.warzonepoints.WarzonePoints to com.example.bloodcoins.BloodCoins
        at java.lang.Class.cast(Class.java:3818) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.getPlugin(JavaPlugin.java:408) ~[patched_1.17.1.jar:git-Purpur-1397]...
eternal oxide
#

unless you called your main class in your WarzonePoints plugin BloodCoins thats impossible

molten plover
#

Nope, it's not called or imported into it

eternal oxide
#

?paste show teh full stack trace

undone axleBOT
molten plover
eternal oxide
#

which line is WarzonePoints.java:34

molten plover
#

BloodCoins bloodCoin = getPlugin(BloodCoins.class);

eternal oxide
#

ok, thats an impossible error

molten plover
#

I'm not trolling, I've tried everything to get this stupid variable over

eternal oxide
#

run it on vanilla spigot

#

make sure its not some crazy purpur thing

molten plover
#

ok 1s

#

🙃

quaint mantle
#

(Or just dont use singletones at all)

smoky tinsel
#

guys

#

i want to import import com.comphenix.protocol.events.PacketEvent; this

#

but i dont know how to import this one

#

can i get any help?

eternal oxide
molten plover
eternal oxide
#

its literally impossible for getPlugin(BloodCoins.class) to return the WarzonePoints plugin instance.

molten plover
#

Can we hop in a vc on here and I screenshare it?

#

You don't have to talk or anything. I just want to make sure I'm not going crazy

#

@eternal oxide

eternal oxide
#

try it with getPlugin("BloodCoins")

molten plover
#

do I cast it?

eternal oxide
#

but the errors you show and the code you posted are impossible

random epoch
#

Make sure you’re not overriding the getPlugin method

#

Try super.getPlugin

molten plover
# random epoch Try super.getPlugin

same issue with super
BloodCoins bloodCoins = super.getPlugin(BloodCoins.class);
returned
Cannot cast com.example.warzonepoints.WarzonePoints to com.example.bloodcoins.BloodCoins

eternal oxide
#

yeah, that makes no sense at all. Never seen it before

molten plover
#

Do I cast it with yours?

#

to BloodCoins

eternal oxide
#

yes

molten plover
#

ok so new output:
BloodCoins bloodCoins = (BloodCoins) Bukkit.getServer().getPluginManager().getPlugin("BloodCoins");
returned
class com.example.bloodcoins.BloodCoins cannot be cast to class com.example.bloodcoins.BloodCoins (com.example.bloodcoins.BloodCoins is in unnamed module of loader 'BloodCoins-1.0-SNAPSHOT.jar' @570c3d43; com.example.bloodcoins.BloodCoins is in unnamed module of loader 'WarzonePoints-1.0-SNAPSHOT.jar' @361216a7)

eternal oxide
#

ah

#

you seems to have a class in yoru WarzonePoints plugin called Bloodcoins

molten plover
#

does this channel support embedding links?

eternal oxide
#

or, you have shaded one plugin into the other

molten plover
eternal oxide
#

you have to verify

#

do you use maven?

#

or you added one plugin into the others dependencies and included it when you compiled

molten plover
#

yes

#

I use maven

eternal oxide
#

teh dependency needs a scope of provided in maven

molten plover
#

do I set it to provided?

eternal oxide
#

yes

#

else its shading yoru api jar into your plugin jar and its using the wrong imports

molten plover
#

the error went away

#

let me test it 1s

#

that fixed it @eternal oxide

#

thank you so much

steady rapids
#

anyone knows how to be able to walk inside end portal without being teleported? I tried cancelling the portal event but this works only in the portals that are in the normal world, if I try the same thing in the end world, I get stuck in a loading terrain screen

    public void onPlayerTeleport(PlayerPortalEvent event) {
        if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) {
            event.setCancelled(true); 
        }
    }```
tardy delta
#

trapdoors are instanceof Openable right? but this check never works for trapdoors and doors

worldly ingot
#

Importing the correct Openable?

#

There's a MaterialData as well iirc

tardy delta
#

ugh i have the org.bukkit.material.Openable;

smoky tinsel
gentle laurel
#

it doesnt work, it sends errors at Arrays, newArgs & reason

young needle
#

Is there an alternative for the specialsource-maven-plugin for gradle? I wan't to use mojangs nms mappings

quaint mantle
#

or special-gradle

#

?google jpenilla/special-gradle

undone axleBOT
quaint mantle
#

Oh

young needle
smoky tinsel
#

Could not load 'plugins\plugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: depend is of wrong type
at org.bukkit.plugin.PluginDescriptionFile.makePluginNameList(PluginDescriptionFile.java:1191) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:1070) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:259) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:175) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:409) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.reload(CraftServer.java:908) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.Bukkit.reload(Bukkit.java:697) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:790) ~[spigot.jar:3258-Spigot-dc75aca-960f310]

Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Iterable (java.lang.String and java.lang.Iterable are in module java.base of loader 'bootstrap')
at org.bukkit.plugin.PluginDescriptionFile.makePluginNameList(PluginDescriptionFile.java:1187) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
... 17 more

#

how can i fix this problem

#

this is actually so bad

young needle
smoky tinsel
#

mean my plugin.yml is no long word?

#

*work

young needle
smoky tinsel
#

: Could not load 'plugins\plugin.jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: Unknown dependency ProtocolLib. Please download and install ProtocolLib to run this plugin.
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:269) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:409) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.reload(CraftServer.java:908) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.Bukkit.reload(Bukkit.java:697) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:790) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchServerCommand(CraftServer.java:775) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.dedicated.DedicatedServer.handleCommandQueue(DedicatedServer.java:475) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:439) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1217) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1050) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at java.lang.Thread.run(Thread.java:831) [?:?]

#

after i fix the depend

quaint mantle
#

protocollib is not installed

smoky tinsel
#

what do i have to do?

quaint mantle
#

Install Protocollib

smoky tinsel
#

how??

#

i add protocollib to library

quaint mantle
#

open spigot MC, download jar, put it in the plugins folder ..

smoky tinsel
#

i alr have jar

#

and i actually add that jar to libraries

quaint mantle
#

ok

#

then add it to the plugins folder

smoky tinsel
#

ty dude

coral pilot
#
PacketPlayOutMapChunk.class
int[] biomes; // size is 1536
byte[] blockdatas; // huge byte array
BitSet extractedChunkdata; // size is 64
NBTTagCompound heightmap;
List<NBTTagCompound> tileEntitys;
int chunkx;
int chunkz;

// where is skylight, the blocklight, the blockdata 
and the palette stored and how to read it?
tardy delta
#

isnt blocklight stored in the block itself?

west oxide
#

hey

#

i have question

#

i want to make an array list

#

that is global

#

so that i can access it on all classes

#

is there a way to make that ?

summer scroll
#

static

west oxide
#

oh

summer scroll
#

Create a manager class that manages the ArrayList.

#

And pass around the manager class.

quaint mantle
#

Get an understanding of what class is

summer scroll
west oxide
summer scroll
#

the static thing, i'm joking

west oxide
#

almost fell for it

#

lol

west oxide
#

or am i stupid and mysql wont work for this

summer scroll
#

That has nothing to do with your first question.

west oxide
#

like instead of array list

#

use

summer scroll
#

Depends on what are you trying to do

coral pilot
west oxide
#

trying to make a list of every player that joins the server

#

i'll need info like how many joined,they uuid , name and etc

coral pilot
#

u could read the folder playerdata for this

quaint mantle
#

Mysql is absolutely different concept and it solves absolutely different tasks

west oxide
#

oh okay

quaint mantle
#

Newbies shouldnt know about static at all

west oxide
#

so array list is the way to go ?

summer scroll
#

You want to log every player joined the server?

coral pilot
west oxide
summer scroll
west oxide
#

oh

quaint mantle
#

Because without understanding it can and will lead to bad design solution

#

Yes aka abusing

west oxide
summer scroll
summer scroll
#

On server stops you need to save it somewhere.

#

And load it back on server start

west oxide
#

ooh

#

never thought about that

#

but where save it ;-;

summer scroll
#

mysql, sqlite, or even yaml

west oxide
#

okay

#

i tried doing something before

#

similar to this

#

but used .json file

#

and everyone destroyed me for it

#

lel

jade grove
grave kite
#

Hi, is it possible to access internal Spigot classes that are not in the spigot api? Something like Class.forName("CraftTravelAgent")

west oxide
west oxide
#

they said its just useless and not efficient

jade grove
#

thats common practice

west oxide
#

.json file

#

for discord members database

#

but it gets modified

jade grove
#

lol

west oxide
#

i believe that .json files arent very good when the data changes ?

#

idk

grave kite
# ivory sleet Yes

so Class.forName("org.bukkit.craftbukkit.CraftTravelAgent") would return the CraftTravelAgent class right?

jade grove
#

dont use flatfile unless you want the user to modify the data inside the file

west oxide
#

ok i'll do that

summer scroll
#

Make sure to cache it so you can access it without directly accessing the database.

quaint mantle
summer scroll
#

manya are you nny?

quaint mantle
#

who

summer scroll
#

oh nevermind xd

quaint mantle
#

still interesting what does nny mean

summer scroll
#

nny is a guy

#

he was active in this server

#

and for some reason he got ban and always come back with different account xd

quaint mantle
#

why does he get banned

summer scroll
#

offensive language i think

grave kite
quaint mantle
ivory sleet
#

Yeah they are

quaint mantle
#

im in a BlockBreakEvent and I tried to clear a block's drops when broken, doesn't seem to work. is it correct if i say e.getBlock().getDrops().clear();

grave kite
quaint mantle
#

i mean, org.bukkit.craftbukkit.<version>.CraftTravelAgent

grave kite
summer scroll
west oxide
summer scroll
west oxide
#

but then if i want it to be accessible for other servers aswell

#

that wouldnt work ?

#

for like a bungee network

#

for example if i want that a player is frozen on all the network

#

and i link them all to same database

#

?

#

or is that too advanced for me to understand rn xD

summer scroll
#

you can save and load data on player quit and player join too i guess

west oxide
#

it might get some errors ?

#

but idk

#

afterall am learning so i'll just test around

#

also thank you @quaint mantle for your suggestion xD

grave kite
#
Class.forName("org.bukkit.craftbukkit."+Bukkit.getBukkitVersion()+".CraftTravelAgent");
Class.forName("org.bukkit.craftbukkit."+Bukkit.getVersion()+".CraftTravelAgent");
Class.forName("org.bukkit.craftbukkit.1.12.2.CraftTravelAgent");
Class.forName("org.bukkit.craftbukkit.1_12_2.CraftTravelAgent");

didn't work

tardy delta
#

is there a good tutorial for using sqlite somewhere?

#

i'm not sure if i did it the right way

quaint mantle
#

Show us how you did it

tardy delta
#

?paste

undone axleBOT
quaint mantle
coral pilot
#

tell me your design skills and "rules"

quaint mantle
#

Google "SOLID"

tardy delta
#

hmm md5 paste says something wrong when saving

quaint mantle
tardy delta
quaint mantle
#

static ☹️

coral pilot
# quaint mantle Google "SOLID"

The Open–closed principle: "Software entities ... should be open for extension, but closed for modification."[7]
does that mean always try zo usw private and protected if possible?

tardy delta
#

and this is an example how to use it

ivory sleet
#

You should be able to modify the behavior without changing it

#

For instance using an Enum might break this

#

Because when you get a new constant of said Enum, you have to find all the switches that switch on the Enum

#

But if you use something like a base type

#

Then if you want to add a new type

#

Simply derive the base type

#

And you have changed nothing in the system

#

Apart from adding the new class

coral pilot
#

why should i even use private and protected i dont want anyone to use reflection later lol, i never understand it

ivory sleet
#

Depends

#

But mostly because you want to encapsulate the state and variables of objects

#

Since that’s usually a low level detail

#

If you have a getter or setter, you can at anytime change the behavior of how other classes query and change the data in your class.

ivory sleet
#

Needless to say, it can make your class substitutable for other classes which can save some effort sometimes

quaint mantle
#

its easier to control and edit methods behaviour rather than fields

coral pilot
#

when i create classes i never use getMyString() {
return this.mystring
}
i always use classobject.mystring;
is that bad?

quaint mantle
#

yes

ivory sleet
#

Well bad is probably the wrong term

#

But it’s a poor choice of design

coral pilot
#

just bc all do i t over bc its slower? i mean its less code needed, isnt that better anyway always?

ivory sleet
#

Less code doesn’t make it better.

#

And it is somewhat slower to use getters and setters ofc, but that difference is negligibly small

coral pilot
#

well

ivory sleet
#

It’s just naive and foolish to compare performance in this case

quaint mantle
#

Needless to say that you if you want polymorphism you cant use fields

coral pilot
#

no but i mean its not needed

ivory sleet
#

You don’t know if its not needed

#

It might not be needed right now

subtle folio
#

Im trying to use the #playEffect method in 1.8.8 spigot. But after running that all the other stuff in the file stops working.

ivory sleet
#

But in the future, a change might be necessary

coral pilot
#

i accidently created a thread xD

ivory sleet
#

Preparing yourself for that change is a wise choice

coral pilot
quaint mantle
#

hehe.. (no)

coral pilot
ivory sleet
#

Let’s say someone is depending on your code

quaint mantle
#

you'd have to replace ALL field references with methods

ivory sleet
#

Changing that will make their code break

ivory sleet
#

First of all

#

The change would require a recompile

coral pilot
ivory sleet
#

True

#

But why would you change the getter method name?

quaint mantle
#

well, its much easier to deprecate methods

coral pilot
ivory sleet
#

That’s a you problem

coral pilot
#

i dont find the right words to describe a method

#

is there even a way to learn this or am i stuck

ivory sleet
#

Learn what?

coral pilot
#

to find the right words for something

#

put something in short

#

etc.

#

i am very bad at it

ivory sleet
#

What is this something? xD

coral pilot
#

a thing what a method do not in 3 sentence but in some words

ivory sleet
#

Anyways a method is just a function which is bound to an object and can be invoked by the objects type. To make it even simpler, it is an instruction containing other instructions.

zealous osprey
#

Im playing around with Texcomponents and their events, but it seems there is no neat way of calling a method from a class when a clickevent is triggered without making a command that just calls that method. Am I wrong or can I just call a method directly ?

ivory sleet
#

No you can’t

zealous osprey
#

So I need to make a command that just calls my method ?

ivory sleet
#

Because the click happens at client side

#

Yeah

#

Or smtng like that

zealous osprey
#

annoying, but ok

quaint mantle
#

unavoidable

coral pilot
ivory sleet
#

Yeah you probably don’t get it now, because you’re simply making a mere small plugin

coral pilot
#

yes

#

well what is small

ivory sleet
#

The best way to experience why public fields are disastrous regarding design is by using it a lot such that you can see for yourself all the downsides

quaint mantle
#

Although small project doesnt means you can ignore principles

ivory sleet
#

Indeed

coral pilot
#

minecraft is doing that too

#

its not using alway getter to get fields

west oxide
#

hey

coral pilot
#

hi

west oxide
#

i cant find any tutorials on how to use mysql :(

#

with spigot

#

am sad

quaint mantle
ivory sleet
quaint mantle
#

Thats dumb bukkit with .at that makes almost all fields public instead of creating a getter

west oxide
#

pls

ivory sleet
#

Just picked one

summer scroll
#

but public static final field still acceptable right?

quaint mantle
#

Yes. Static is acceptable if it doesnt have mutable state 🌞

coral pilot
coral pilot
quaint mantle
#

You are probably doing something wrong

coral pilot
#

me?

quaint mantle
#

Yes

#

You shouldnt modify static fields with constructor

rustic gulch
#

is there a plugin where u can steal hearts in 1.16.5?

#

and create hearts?

#

@coral pilot

#

is there?

coral pilot
coral pilot
rustic gulch
#

whats that?

coral pilot
#

u mean having 1 heart instead of 10 yes?

#

like in some lobbys

rustic gulch
#

no

#

when u kill someone

#

u take a heart

#

and they lose one

coral pilot
#

oh

rustic gulch
#

and to craft hearts

#

Like life steal smp

coral pilot
#

player#damage()

rustic gulch
#

?#

#

can we go in a call so u can explain

#

or nah?

coral pilot
#

i dont have micro

rustic gulch
#

so what command do i do

coral pilot
rustic gulch
#

searhc

#

search

coral pilot
#

when do u want to damage or heal a player?

summer scroll
#

this channel is for plugin development

rustic gulch
#

WHen you kill someone it gives your one of there hearts

coral pilot
summer scroll
rustic gulch
#

and they lose a heart(the person you kill)

#

k

plucky fog
#

how can i make it so my plugin includes resource files? like other files that my plugin uses

tardy delta
#

why does JavaPlugin has an empty onCommand and onTabComplete method?

quaint mantle
plucky fog
#

wdym?

quaint mantle
plucky fog
tardy delta
#

for what reason?

quaint mantle
plucky fog
#

oh ok

quaint mantle
#

Plugin is a default command executor for commands you define in plugin.yml actually

tardy delta
#

This class is provided as a convenience to implement both TabCompleter and CommandExecutor.

quaint mantle
#

yes

plucky fog
#

i still get this error tho which is wierd

quaint mantle
#

Checkif your jar contains the file