#help-development

1 messages · Page 1954 of 1

quaint mantle
#

Or use something like teams

manic crater
#

if i put all that code in the runnable will it fresh it? Cuz im planning to use the scoreboard to get the users coins and stuff

quaint mantle
#

Yes, it will

tender shard
quaint mantle
#

Your current code won't refresh because it have been created before the runnable

tender shard
#

you want to do this:

midnight shore
#

Please

tender shard
#
1. On join, assign the scoreboard to the player
2. Run a runnable that updates the CONTENTS of the scoreboard
#

that's it

manic crater
#

yeah and im trying to refresh in this case update the scoreboard in a runnable

#

so im trying to figure that out

tender shard
#

yeah well change some values maybe?

quaint mantle
tender shard
#

you only say you want to "refresh" it

#

scoreboard.setScore(...)

young knoll
#

Yeah just make the creeper invis

manic crater
#

im a type something out u tell me if it will work

young knoll
#

The aura will still show

manic crater
#

Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask
(this, new Runnable() {
public void run() {
score1.setScore(11);
p.setScoreboard(board);
}
}, 0, 120);

finite inlet
#

What is the slot id of the helmet slot in 1.18.1?

manic crater
#

Would that refresh/update it?

quaint mantle
tender shard
#

p.setScoreboard is TOTALLY useless in that runnable

manic crater
#

oh

#

ok lol

tender shard
#

the player already has this scoreboard

young knoll
#

You only need to set the scoreboard to the player once

#

When they join

manic crater
#

ok ok,

#

i thought to refresh it i had to do it like that

#

my bad

tender shard
#

no, that's not needed

#

you set the scoreboard once, then you can just change the scores

midnight shore
tardy delta
#

i love how intellij tells you that you can use a lambda expression instead of new runnable uwu

midnight shore
#

I think it’s a problem with my client, cause my friend can see it

finite inlet
manic crater
tender shard
tardy delta
#

o.O

quaint mantle
#

I love Eclipse ❤️

#

eclipse for C sucks tho

tardy delta
#

just the idea hurts my brain

midnight shore
#

I would love to use IntelliJ but my brain hurts when I use it

midnight shore
tender shard
#

no it's dark mode

quaint mantle
quaint mantle
#

Wait what

#

me too

tardy delta
tender shard
quaint mantle
#

That's now trick, i just learnt that you can use {} instead of static {} or public Class() {}

tardy delta
tender shard
#

it of course works differently 😄

quaint mantle
tender shard
#
public class MyClass {
    
    public static void main(String[] args) {
        new MyClass("asd");
    }

    static {
        System.out.println("Static Init Block");
    }

    {
        System.out.println("Init Block");
    }
    
    public MyClass(int a) {
        System.out.println("Constructor with int");
    }
    
    public MyClass(String a) {
        System.out.println("Constructor with String");
    }
}

This will print

Static Init Block
Init Block
Constructor with String
young knoll
#

I usually use static {}

tender shard
#

e.g. I always use { } to set the instance, of course that woudln't work in static { }

young knoll
#

Why not do it online

#

Inline

#

Oh I see it’s a static var

tender shard
tardy delta
#

people using static block to init static variables 🙁

tender shard
#

well sometimes

#

you need it

tardy delta
#

if they dont need it 🙁

tender shard
#

then it's stupid, yes lol

young knoll
#

I mean

tender shard
#

I use it for stuff like this

public class CustomBlockData implements PersistentDataContainer {

    private static boolean hasWorldInfoGetMinHeightMethod;

    static {
        try {
            Class.forName("org.bukkit.generator.WorldInfo");
            hasWorldInfoGetMinHeightMethod = true;
        } catch (final ClassNotFoundException exception) {
            hasWorldInfoGetMinHeightMethod = false;
        }
    }
young knoll
#

Using anything you don’t need 🙁

tardy delta
#

hmm ye then its useful

young knoll
#

Why use the API when you could use asm to achieve the same result

tardy delta
#

watching comic stuff lol

#

going to forget the stuff i learnt for the test tomorrow

#

:C

sand hinge
#

how to fix

young knoll
#

You can’t just call getPlayer on an OfflinePlayer

#

They need to be online for that to work

sand hinge
#

I want it to show up even though it's not online.

young knoll
#

Also doesn’t OfflinePlayer have a getName anyway

midnight shore
honest breach
#

Hello, any idea why i can't import this ?

sturdy ivy
#

is there easier way to do that?

tardy delta
#

?main

tender shard
#

but it might be null 😄

midnight shore
honest breach
young knoll
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

tender shard
hexed hatch
#

✨Don’t name your class main✨

midnight shore
#

Have you got the imports?

honest breach
honest breach
tender shard
#

doesn't look like it

#

you manually added the normal spigot.jar

#

you should instead add spigot-api using maven

honest breach
#

first i create the java project and after i add the spigot libs

tender shard
#

you must add spigot-api as dependency to your pom.xml

midnight shore
honest breach
#

Oh okay thanks

midnight shore
#

Its fine

honest breach
#

How can i add spigot-api as dependency please ?

midnight shore
#

you can also use it without maven if you don’t have it installed

tender shard
#

do you actually have a file called pom.xml?

honest breach
tender shard
#

no, so you're not using maven, o

#

o

tardy delta
#

no :C

tender shard
#

just add spigot-api.jar like you added spigot.jar

midnight shore
#

If it shows up an import

#

Press it

tender shard
honest breach
#

So i need to download maven at first ?

tender shard
#

no

#

but switching to maven might be very helpful

midnight shore
tender shard
honest breach
#

Okay i go to maven

midnight shore
tender shard
honest breach
#

Okay i try and i tell you

#

thanks !

tender shard
#

np

midnight shore
#

I hate this kind of things that use slashes and backslashes to make parameters

#

Or whatever they are called

midnight shore
#

Yeah but I don’t really code Windows

tender shard
#

do you mean stuff like taskkill /F /PID 9

midnight shore
#

No I mean <dependency><dependency/> or whatever is it

tender shard
#

XML

midnight shore
#

That

tender shard
#

why do you hate it lol

young knoll
#

Wait until you see HTML :p

tender shard
#

it's basically like yaml without having to worry about indents

manic crater
#

yeah uh my scoreboard still doesnt update

#

i have to rejoin for it to update...

grim ice
#

isnt using maven easier

tender shard
manic crater
#

?paste

undone axleBOT
manic crater
midnight shore
manic crater
#

............

#

it has a runnable tho

tender shard
#

ugh no

#

the scoreboard should be reused and not recreated everytime

manic crater
midnight shore
#

I meant just for debugging

manic crater
#

Cuz i got told to not do p.setScoreboard(); for bukkit runnables

grim ice
#

also

#

(getConfig().contains("Stars." + p.getUniqueId() + ".Level"))) {
getConfig().set("Stars." + p.getUniqueId() + ".Level", 0);
getConfig().set("Stars." + p.getUniqueId() + ".LevelColor", "&7");
getConfig().set("Stars." + p.getUniqueId() + ".EXP", 0);

#

is ugly

#

make a class for accessing

#

those stuff

manic crater
#

okay i will later

#

but for the time being,

tender shard
#
    @EventHandler
    public void onJoinScoreboard(PlayerJoinEvent e) {
        Player player = e.getPlayer();

        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        Objective objective = board.registerNewObjective("test", "dummy", ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "Cyan" + ChatColor.AQUA + "" + ChatColor.BOLD + "Mines");
        objective.setDisplaySlot(DisplaySlot.SIDEBAR);

        Score score = objective.getScore("Test");
        score.setScore(ThreadLocalRandom.current().nextInt());

        player.setScoreboard(board);

        Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask
                (this, new Runnable() {
                    public void run() {
                        score.setScore(ThreadLocalRandom.current().nextInt());
                    }
                }, 0, 20);
    }
midnight shore
#

Basically what you are doing is creating a String that contains a variable and setting it to a place in the screen, if you don’t actually update the variable itself, it would not update magically

tender shard
#

you can easily update the existing scoreboard score without rejoining or anything

#

see my video and the code above

#

(although it's not a good idea to spawn one task per player)

vocal cloud
#

Ugh getnewscoreboard sad

tender shard
vocal cloud
#

It's a curse that I will forever mald over

manic crater
tender shard
#

no

midnight shore
#

Replace the threadlocalrandom with the value you want

tender shard
#

no

vivid cave
#

okay guys, i really need your help on this:
I need to make trigger a bungee event (event that will trigger on bungee proxy plugin, using bungee api) from a spigot plugin using spigot api, and passing somehow a string as event payload
I don't care how unrelated the event may be from my simple goal of exchanging string data from a plugin to another of two different apis, and btw i'm assuming this is a bad practise and things shouldn't be done this way, but to put it short i don't care, to do things correctly I would have to rewrite my whole plugin so it supports bungeeapi, and i have very few time left (and i don't want to hassle too much as well, as its for a private plugin)

tender shard
midnight shore
#

Oh

tender shard
#

I just wanted to show with my code that rejoining is not needed to update any scoreboard stuff

manic crater
#

mmmmmmmmmmmmm

#

ok ok, wait can i have an example with my existing code?? without using ur integer code addition to mine?

#

if that makes sense

manic crater
#

so then i get the general idea and then i can stfu and move on with life

tender shard
vivid cave
#

as i read it doesn't seem like so

#

tysm

tender shard
tender shard
#

because you can't change already existing objective's names iirc

#

I think

#

not sure, I'll try some stuff

#

never did any scoreboards before

tender shard
manic crater
young knoll
#

Yea they do

tender shard
#

you just don't know the difference between scores, objectives, etc

#

all you did in your code was to set the score of an already existing objective to 12

#

I even sent a video that proves that runnables "wor with scoreboards" 😄

manic crater
#

Ik then i asked u if u could provide an example using my code and not modifying my code, so then i can understand a bit better

#

but then you ignored me

tender shard
tender shard
manic crater
#

k

tender shard
#

I guess you will need teams, but as said, not sure

#

score names cannot be updated

honest breach
#

mh any idea what is the green under this :

tender shard
#

hover with your mouse over it

#

and read what it says

honest breach
#

(i follow the doc you give me)

tender shard
vocal cloud
#

MY EYES

tender shard
#

it's underlined in green because of spelling correctino

honest breach
#

👀

tender shard
#

you guys really all have bad eyes

#

did you ever go out during the day anytime?

young knoll
#

No

hexed hatch
#

no

honest breach
#

yes haha

vocal cloud
#

The dimmer the monitor the dimmer the room

#

Less catches my eye I can focus easier

tender shard
young knoll
#

The sun makes me catch fire

vocal cloud
#

Wait do you use light mode on discord too?

honest breach
#

i can continue ?

tender shard
#

lol yes?

grim ice
tender shard
hasty prawn
#

Pretty sure you're the outlier here alex

grim ice
#

are ur eyes ok

#

do u srsly stay hours coding with light mode wtf

tender shard
#

also noone seems to have problems with wikipedia screenshots

#

somehow people's eyes are only hurt when they see intellij light mode, but not when they see a wikipedia screenshot that's also black on white

vocal cloud
#

Cause if I can fix it without one of those sketchy plugins I would

hasty prawn
#

Just because Wikipedia is light mode doesn't make it okay

tender shard
#

tbh dark mode on almost all websites looks ugly

desert tinsel
#

?customconfig

grim ice
#

thats not for me

vocal cloud
#

GitHub finally made a dark mode and it's so niceeee

grim ice
#

ig others but i also cant stand wikipedia white background

hexed hatch
tender shard
#

fun fact, I have discord in white mode too

grim ice
#

there is

hasty prawn
#

I mean I know it's a preference thing, but dark mode is just straight up easier on the eyes, especially in dark rooms.

grim ice
#

wtf

vocal cloud
#

god dammit

#

I feel like you're trolling

grim ice
#

lemme try it

tender shard
#

no. I always use a theme for like 3 weeks, then it annoys it and I switch

grim ice
#

OH GOD

#

MY EYES

#

this looks terrible

dusk flicker
#

ew browser discord ver

tender shard
#

on mac my intellij and discord always switch themes automatically when it gets darker in the room

#

ALL not builtin themes always look disgusting

grim ice
#

im always having a browser open and discord

#

why not have them on the same tab if i can

hasty prawn
#

You're not allowed to have opinions if you use Browser Discord btw

grim ice
#

ic

hasty prawn
#

Browser Discord is for alt accounts only

grim ice
#

how

hasty prawn
#

how what

grim ice
#

i cant manage having many tabs open

tender shard
#

just use a VM for alt accounts

grim ice
#

im too lazy to move my mouse btw so i just alt tab

grim ice
#

why would u have a whole vm just for an alt account what

tender shard
#

well it only takes me 30 seconds to create one

hasty prawn
#

Takes me 5 seconds to open a new tab that's already logged into my alt

tender shard
#

yeah but what if you have 5 alts

grim ice
#

ever heard of chrome profiles

hasty prawn
#

Chrome, Opera, Firefox, Edge, IE KEKW

grim ice
#

lmoa

#

nah only chrome is enough

#

have multiple chrome profiles and done

tender shard
grim ice
#

you like light discord

#

why do people hate browser discord

tender shard
#

because when you have 50 tabs open, it's hard to find the discord tab you're looking for

dusk flicker
#

and just

#

why

tender shard
#

for me, I use a browser to browse the internet, and discord to use discord

hasty prawn
#

I mean I'm fairly sure Browser Discord and the application are the exact same thing

ivory sleet
grim ice
#

i put each related group of tabs in a group in chrome

tender shard
#

e.g. ctrl+T doesnt work in browser discord

grim ice
#

it does

ivory sleet
#

You can’t still alt tab unless you have multiple windows tho

tender shard
grim ice
#

by clicking ctrl t

grim ice
tender shard
#

yeah exactly

#

so discord's ctrl+t doesnt work in browser...

grim ice
#

what happens when u do ctrl t

#

in app

tender shard
#

it's like cmd-space in macOS

ivory sleet
#

God white theme

mortal hare
#

can someone test

#

if this spigot issue

#

or not

#

item duplication glitch

#

player.openInventory(player.getOpenInventory());

#

it really acts funky

dusk flicker
#

what ver are u on

#

and are you up to date

mortal hare
#

1.18

#

but im on a fork

#

that's why im asking

dusk flicker
#

then fork-off

#

/j

mortal hare
#

if this is a spigot issue to someone test it

vocal cloud
#

The chances that you've found a duplication exploit in spigot are pretty low

mortal hare
#

can someone test

dusk flicker
#

you can

vocal cloud
mortal hare
#

i have paperweight-userdev on my side and building via buildtools for me just for this just seems unpractical

dusk flicker
#

then dont test it ¯_(ツ)_/¯

#

report it to paper, doubt they will do anything

mortal hare
#

fine

#

i'll not test it

dusk flicker
#

if I had to guess its a visual glitch, and either way not a important glitch considering you have to open your own inventory for it, which isnt done natively

mortal hare
#

its not

#

closing it

#

its subtracts items

grim ice
tender shard
grim ice
#

lol

tender shard
#

why would you want to open the already open inventory

#

that makes no sense

mortal hare
#

i've just tested this feature

grim ice
#

it exists in discord browser

mortal hare
#

out of curiosity

grim ice
#

click ctrl k

vocal cloud
#

If doing something weird produces a dupe it's not a bug it's a feature you've introduced

tender shard
#

what kind of inventory even is the one you've opened "twice"?

mortal hare
#

its a playerinventory

#

you can open playerinventories

#

if you didnt know

#

but its usually for player to open other player's inventories

#

not for his own

tender shard
#

yeah sure you can, but normally a player's inventory is actually InventoryType.CRAFTING and not PLAYER

mortal hare
tender shard
#

?

#

if you don't have an inventory open, player.getOpenInventory returns a CraftingInventory

#
    @Default
    public static void onSet(Player player, Material material) {
        main.setMaterial(material);
        player.openInventory(player.getOpenInventory());

    }
mortal hare
#

don't use getOpenInventory()

#

use getInventory() instead

hasty prawn
#

You used getOpenInventory didn't you

grim ice
#

he did

mortal hare
#

i didnt

tender shard
mortal hare
#

My bad

#

its getInventory()

#

i've miswrote that

tender shard
#

ok will try again

#

yes it bugs out

mortal hare
#

probably its even craftbukkit bug

tender shard
#

but tbh it's not really a bug, more like undefined behaviour because now top and bottom inventory are the same which isn't exactly meant to ever happen

mortal hare
#

Achievement unlocked!
Find a bug in server software.

young knoll
#

Is that how essentials does invsee

mortal hare
#

probably

tender shard
#

I guess, but essentials doesn't let you open your own inv twice

vocal cloud
#

Do something you're not really supposed to do and call it a bug rather than an unsupported feature

mortal hare
#

I inputted valid method argument, thus it should support that feature

#

or just throw exception

#

that's a bug

vocal cloud
grand venture
#

How do I leave leave the Title blank? I only want a subtitle..
player.sendTitle("Title", "§fWelcome to §6§l" + config.getString("ServerName"), 1, 2, 1);

tender shard
#

new NamespacedKey("ASD","asd"); and it will throw an error although it expects a string

grand venture
#

ty

tender shard
#

if it's @ Nullable

grim ice
#

throw new RuntimeException();
then call it a bug

grand venture
tender shard
#

maybe openInventory should add this add the beginning

public void openInventory(Inventory inventory) {
  if(inventory == getInventory()) throw new IllegalArgumentException("Can't open player's own inventory");
blazing scarab
#

Throw an exception with 1% chance 🙂

blazing scarab
grim ice
mortal hare
#

i probably know why its so random

#

with dragging

grim ice
#

if that doesnt work add a space

#

player.sendTitle(" ", "§fWelcome to §6§l" + config.getString("ServerName"), 1, 2, 1);

mortal hare
#

it probably uses raw slots or converted slots

#

to set dragging, which could result dragging with an offset

tender shard
#

so empty strings should work

grand venture
#

I will try it again

mortal hare
#

that would explain why items end up in the helmet equipment slot

tender shard
#

because you can drag between two inventories

honest breach
#

Can you help me please, i'am starting in dev so it's my first pl

#

Where can i find my error

tender shard
#

click on the uppermost thing on the left

#

"HelloNiriaa [package]"

#

then you see the full error

honest breach
#

?

tender shard
#

the top left entry

#

the red exclamation mark with "HelloNiriaa [package]"

vocal cloud
#

ahhhhhhhhhhhhhh

tender shard
#

ugh

vocal cloud
#

?paste

tender shard
#

?paste that pls

undone axleBOT
honest breach
#

sorry

tender shard
#

dont worry, noone died

honest breach
tender shard
#

paste your pom.xml

honest breach
grim ice
#

old jdk

vocal cloud
#

wow 6

honest breach
#

?

#

i just install intelji :'

#

and start follow the guide

grim ice
tender shard
#

erm

grim ice
#

this should work

tender shard
#

you set your jdk version to 6

vocal cloud
#

Uh stop following said guide what the fuck

tender shard
#

why did you do that?

honest breach
grim ice
#

ur jdk is 1,8 but in the maven compiler its set to 6

vocal cloud
#

White paper?

tender shard
honest breach
#

i don't know the english world for "guide paper"

tender shard
#

my guide is fine 😛

honest breach
#

so how can i fix that please guys

grim ice
#

the answer

tender shard
#

replace the 6 with 8 in lines 48 and 49

grim ice
vocal cloud
#

Maybe using light theme lowers target version by 2

honest breach
#

<source>1.8</source> <target>1.8</target>

grim ice
#

yes

honest breach
#

thanks i try!

tender shard
#

I still wonder why you had that in your pom

grim ice
grim ice
#

nice job tho

tender shard
#

well except for properties -> java.version

tender shard
vocal cloud
#

You're website is as white as your IDE's

tender shard
#

white sites matter

lost matrix
#

Someone knows if papi has a discord? Im about to rant.

tender shard
grim ice
#

nah his site

#

looks pretty cool

honest breach
#

omg i think it's good ?

#

i test.

grim ice
#

it isnt as bad as intellij light theme

tender shard
tender shard
grim ice
#

it looks like a java swing application tho

vocal cloud
tender shard
grand venture
#

Why doesnt Action.RIGHT_CLICK_BLOCK work with a Disk?

tender shard
grim ice
#

it does

tender shard
#

seems like you're clicking air

grand venture
#

Only the disk doesnt work

tender shard
#
    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            event.getPlayer().sendMessage("Right Click Block");
        }
    }
vocal cloud
#

/reload

tender shard
#

what even is that? some 1.16 pre version?

tender shard
honest breach
#

?paste

undone axleBOT
wary harness
#

how does spigotsave comments in yml file

#

which version is that added

#

?

#

1.18?

honest breach
grim ice
#

learning java will help

#

or googling

tender shard
#

that has nothing to do with music discs?

grim ice
#

"Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0"

tender shard
grim ice
#

ur trying to access first element of an empty array

honest breach
tender shard
#

what is a left click?

grim ice
#

no

tender shard
#

bruh for real, i am not too stupid to tell the difference between left and right

grim ice
#

click to the right

tender shard
#

I meant to ask "what's a left click" because I didnt do any left clicks

#

so I was asking to what you were referring to

#

obviously, right click works fine with music discs

vocal cloud
#

Wat

tender shard
#

I actually wrote "right click" at first, mb lol

vocal cloud
#

You don't need glasses on to see the lack of music disc movement

tender shard
#

anyway as said, right-click works fine on music discs

grand venture
#

What is wrong? 🥲

vocal cloud
#

Then maybe get them first thonk

tender shard
#

the itemmeta isn't equal to the meta you are comparing to

honest breach
#

my first pl

#

finaly work

#

so strange sensation

tender shard
#

I still wonder

honest breach
#

thanks guys

tender shard
#

why you added jdk 6 to your pom.xml

honest breach
wary harness
#

CAn spigot latest version keep comments on saving ?

#

I heard some people it can

#

is there some special method to save

ancient jackal
#

I can't figure out how to get a Chest from inventory holder, any ideas?

tender shard
#

if it's a chest, you can cast it to (Chest)

ancient jackal
#

event#getInventory()#getHolder()

tender shard
#

Chest chest = (Chest) inventoryHolder;

ancient jackal
#

that hasn't been working

tender shard
#

hm wait

#

questino: what do you need the Chest object for?

ancient jackal
#

persistent data container

#

I'm storing the UUID of the person who placed it

tender shard
#

okkk is it maybe a double chest?

ancient jackal
#

let me test

tender shard
#

Chest and DoubleChest are two different things

ancient jackal
#

ah, I see, that might be a problem but I'll fix that

tender shard
#

if your holder is a doublechest, you must cast it to doublechest, then you can do getLeftSide and getRightSide and get each chest by casting either getLeftSide or getRightSide

#

because

#

if you have a double chest and use it's PDC, you are fucked if one breaks only one part of the chest

#

the doublechest itself can't have PDC

ancient jackal
#

everytime someone places a chest it assigns their UUID in the PDC

shadow oriole
#

hi, how can i make it so that when a player tries to place a block, this block is not placed on the ground but it is removed from the inventory? (im using BlockPlaceEvent)

ancient jackal
#

would that make it so both sides have their UUID?

tender shard
tender shard
ancient jackal
#

also yeah, using double chests was the issue. I'll fix that

#

thank you

tender shard
#

np

#
@EventHandler
public void onPlace(BlockPlaceEvent event) {
  event.setCancelled(true);
  event.getItemInHand().setAmount(event.getItemInHand().getAmount()-1);
}
#

@shadow oriole

tender shard
ancient jackal
#

log when someone tinkers with a chest that isn't their own

tender shard
#

if so you should also check on placing chests to prevent players connecting their chest with an already placed foreign chest

quick aurora
#

ur welcome

tender shard
young knoll
#

You don’t need to place it on the side of the other chest

shadow oriole
sand hinge
#

How to get player name form UUID whether they are online or not

young knoll
#

You probably need to delay the setAmount by one tick

young knoll
ancient jackal
young knoll
#

No idea what you’ll get if the uuid isn’t a valid player

#

Probably null

sand hinge
#

display player name for blockprotect gui

#

i save data form uuid

young knoll
#

Then yeah getOfflinePlayer with the uuid

sand hinge
#

sad moment

young knoll
#

Sure, if you do it yourself

sand hinge
young knoll
#

Stop calling get player

#

We already told you this

#

You cannot have a Player instance for a player that isn’t online

#

You have to use OfflinePlayer

shadow oriole
young knoll
#

?scheduling

undone axleBOT
shadow oriole
#

just one

#

i already tried, the item is removed but comes back at the same time, as if isCancelled is conflicting with this

ancient jackal
#

I assume casting a doublechest#getLeftSide() to Chest works

shadow oriole
#

nothing yet, is something wrong? ```kt
e.isCancelled = true
Thread.sleep(100);
e.itemInHand.amount = e.itemInHand.amount -1;

young knoll
#

You can just use runTask for a 1 tick delay

#

Please don’t use thread.sleep

#

¯_(ツ)_/¯

ancient jackal
#

player

#

player 100%

ivory sleet
#

I mean sometimes one letter variable names are fine

#

You probably don’t want anything else than i for a fori loop

#

What

ancient jackal
#

i and j

ivory sleet
#

No that’s not how it works

#

A variable’s name should be proportional to the scope it’s contained in, is the general convention

ancient jackal
#

nested for loops just choose the next character that looks like i and hope you remember it

#

I go i > j > k

ivory sleet
#

i, j, k are also conventions

ancient jackal
#

wait actually?

ivory sleet
#

For a fori loop yes

#

Well they derive from mathematical sigma notations probably

ancient jackal
#

oh I thought i was just iteration

#

or index

ivory sleet
#

Anyhow no one uses index because it’s utterly redundant

young knoll
#

Heh...

ivory sleet
#

I mean that’s what abstraction is for like we got interfaces and stuff

shadow oriole
#

same thing ```kt
e.isCancelled = true
Bukkit.getScheduler().runTaskLater(PluginMain(), {
e.itemInHand.amount = e.itemInHand.amount -1;
}, 1)

ivory sleet
#

Well, set the itemInHand rather than the amount property

young knoll
#

Usually the events give you mutable stacks

#

Guess this one doesn’t?

ivory sleet
#

Since itemInHand just returns an ItemStack copy

#

Probably

#

But like, they’re essentially context objects regardless

shadow oriole
#

and what is to instantiate? the file where the events are is an object

shadow oriole
ivory sleet
#

What event are you using

shadow oriole
#

BlockPlaceEvent

young knoll
#

Is that like

#

Half Kotlin

ivory sleet
#

Fully hmm, I still don’t know if you can directly manipulate the ItemStack (as if that’d have any impact post event procedure)

#

So instead, mutate the players itemstack directly using the setter/property assignment

novel kiln
#

List<String> comments = pl.getConfig().getComments("?path?");
Always returns blank list.
I tried config.yml for path, tried Configuration Section, but I can't get comments.
They are inside config file

ivory sleet
#

How does your config.yml look (the contents)

young knoll
#

With its eyes

ivory sleet
#

Hilarious derp

young knoll
#

Thank you

shadow oriole
ivory sleet
#

In the event callback or scheduled after?

ivory sleet
young knoll
#

I assume an empty path doesn’t work

shadow oriole
ivory sleet
#

Maybe try getComments(“Hotbar”)

ivory sleet
#

Still no

#

e.itemInHand.let {
Bukkit.getScheduler().runTask(plugin,{
e.player.inventory.removeItem(it);
});
}

#

perhaps?

#

Idr if let can be used that way

young knoll
#

What in the name of Kotlin hell is that

ivory sleet
#

Functions every object has basically

#

a lot more than what java Object class got

young knoll
#

Blasphemy

#

Burn it

shadow oriole
ivory sleet
#

Your plugin instance

shadow oriole
#

main class?

ivory sleet
#

The one that derives JavaPlugin

shadow oriole
#

ah ok

#

its him

#

nothing :/

ivory sleet
#

Oh yeah btw

#

You need to register the listener and annotate it with @EventHandler

#

And if you use kotlin you could create an inline function

#

iirc that’s what they’re called

low temple
#

@ivory sleet MainPluginClass.getPlugin(MainPluginClass.class) gets the plugin instance without needing to pass anything right?

shadow oriole
low temple
#

assuming MainPluginClass extends JavaPlugin

ivory sleet
#

Ye

low temple
#

Ok cool just making sure, ive always passed the instance

ivory sleet
#

I prefer passing the instance but yeah

ivory sleet
#

?paste

undone axleBOT
shadow oriole
ivory sleet
#

Myeah, the more the better

shadow oriole
young knoll
#

The heck does let even do

ivory sleet
#

let(Consumer<T>) iirc

#

Or if it’s a UnaryOperator (returns the instance also)

young knoll
#

I see

ivory sleet
#

Fully well, may I just ask, why you use durability

#

They have different name spaces nowadays

#

Also make sure you’re recompiling when trying things out

#

Happens to a lot of times someone just happens to use an odd compilation procedure in combination with shitty plugman

young knoll
#

Maybe they are on 1.8

ivory sleet
shadow oriole
young knoll
#

Right but that hasn’t used metadata since 1.13

#

Actually metadata hasn’t even existed since 1.13

shadow oriole
#

yes, im using 1.8

ivory sleet
#

Oh then I don’t know

#

There are a lot of bugs in 1.8

#

So might be one of them you’ve just encountered

shadow oriole
#

I see, i will think about what i can do here :/

#

thanks anyway

ancient jackal
#

if I modify a chest PDC do I have to set something about the chest to its new PDC? Using the same exact key to get a value from before from the chest PDC is returning null despite a String being put in that key it when the chest was placed. I've even printed the owner's name from UUID grabbed from the PDC with the same exact key when they placed it, so I'm not sure why it's returning null the second time I grab it

eternal night
#

you'll have to update the state

ancient jackal
#

I see

#

how would I do that?

eternal night
#

Well after you write to the chests pdc you grabbed from the block state

#

you call BlockState#update

ancient jackal
#

I see setdata and settype but not state

eternal night
#

no that method exists on the block state you use to get the PDC

ancient jackal
#

oh. gotcha

willow stream
#

while this is exactly what I wanted to do, it has one side effect - ball doesn't go behind the player when too high up (to define "too high up": y+1 or 2), it just bounces off and continues going forward even though it wasn't hit in the air, it was just raised

shadow oriole
#

@ivory sleet a question, this removeItem was to remove the item even in the creative?
it is not working even without setCancelled

ancient jackal
#

still getting null from the PDC

willow stream
ancient jackal
#

chest.getBlock().getState().update();

eternal night
#

no

#

states are snapshots

#

getState creates a new copy

ancient jackal
#

so I cast

#

((BlockState) chest.getBlock()).update();

young knoll
#

What

eternal night
#
final Block chestBlock = ....
final Chest chestBlockState = (Chest) chestBlock.getState();
chestBlockState.getPDC().......
chestBlockState.update();
#

That chestBlockState is a snapshot of the block state in the world at the time you call getState

ancient jackal
#

chest.update(); then

eternal night
#

you modify that snapshots PDC

#

only if you call update on that specific snapshot you modified will the PDC changes be written

#

yes

#

if chest is the instance you grabbed the PDC from

ancient jackal
#
public static void setChestOwner(Chest chest, UUID uuid) throws IOException {
        PersistentDataContainer chestPDC = chest.getPersistentDataContainer();
        String encodedOwner = UuidCoder.encodeToBase64(uuid);
        chestPDC.set(chestOwnerKey, PersistentDataType.STRING, encodedOwner);
        chest.update();
    }``` yeah this is what the method looks like
#

so it's just chest#update(); then

eternal night
#

Yes looks good

dusk flicker
#

is it just me that hates that UuidCoder is lowercase for the UUID

eternal night
#

I mean, using base64 to encode a uuid is also rip

dusk flicker
#

lol

eternal night
#

the PDC offers a byte array you can piggyback to store uuid

ancient jackal
#

too lazy to change

#

one day though

eternal night
#

iirc the javadocs for PersistentDataType actually contain a functional data type of uuids

ancient jackal
#

dead ass?

young knoll
#

Yes

dusk flicker
#

my ass is very much alive

eternal night
ancient jackal
#

haha it works now thank you

willow stream
young knoll
#

🥄

willow stream
#

nope.. I even tried with the Player#getVelocity, still the same story, I'm so confused right now

#

i love how it worked for one hit and then after that it was the same

quaint mantle
#

🧽

ancient jackal
#

when TNT is ignited, is BlockIgniteEvent not called?

#

I've registered BlockIgniteEvent correctly and made the listener but it's not doing anything

sly trout
#

which one is better? gradle or maven?

eternal night
#

you could argue for either, the job at hand has an impact, your preference, etc

sharp flare
sullen marlin
#

What is your point

sharp flare
#

is that even good or bad

sullen marlin
#

It’s nothing

sharp flare
#

well you confirmed it then, imma head out appreciate it

tender shard
young knoll
#

Graven

#

Mavdle?

tender shard
#

Madle

#

or if we add ant to:

#

madle'nt

neon minnow
#

How to get gray dye material 1.8

young knoll
#

INK_SACK with some data

#

Idk what one

neon minnow
#

ok

kind hatch
#

Does anyone know how the new yaml comment saving feature added in 1.18.1 works? I thought that it would no longer remove comments if I called #saveConfig(). Apparently this is not the case. .-. I really don't want to call #setComments() every single time I need to save the config. Is there not a way for this functionality to be automatically applied to existing files?

kind hatch
#

Nevermind, turns out being 36 versions behind the latest release was enough to miss the change that added comment support.

manic crater
#

how do i make it so console can only send a certain command?

#

meaning no players can but console

young knoll
#

Check if the sender is ConsoleCommandSender iirc

manic crater
#

tysm

ancient jackal
#

block ignite event isn't called when tnt is ignited

fallow merlin
#

When you are in a 6 row chest do the inventory slots shift in numbers?

worldly ingot
#

That depends on a few factors. Whether or not you're using raw slots or relative slots, and which inventory you're calling methods on

muted sand
#

would it use a lot of my resources if i had a block state change every tick?

or would it be more efficient grouping muitiple changes into one, and changing them every 20 ticks?

#

eg BlockFormEvent, just stuffing changes into an arraylist and modifying it every second
or does it not matter

#

and erk, how would i change a large area of blocks
i see small, minor noticeable lag when using a for loop when setting the blocks and it just bothers me :}

sharp flare
#

a question guys, 1.16 yaw is in degrees right?

buoyant viper
#

pretty sure its in degrees in all the versions

brave sparrow
#

Yeah it’s always degrees

#

Same with pitch

hexed orbit
#

Hello guys, I'm using packets to appear a block in the world, but the block that appears when it breaks does not drop any items and the sound of breaking is stone, but the block is dirt, could anyone help me? I'm using this code:

#
 WrappedBlockData loke = WrappedBlockData.createData(targetBlock.getType());
 pacote.getBlockData().write(0, loke);```
neon minnow
#

I checked javadocs, but cant seem to understand why getRawSlot() is an unresolved refernece

#

i wanna check the number of slot that was clicked??

#

how can id othis

#

also how can i get the player of InventoryClickEvent

neon minnow
sharp flare
#

#getWhoClicked

#

check and cast to player

neon minnow
#

how do i use #

sharp flare
#

event.getWhoClicked, please learn java

neon minnow
#

im learning right now

sharp flare
#

do your own research if you're learning

neon minnow
#

How do i check the slot that was clicked

#

and get its number

#

because getRawSlot() doesnt work

sharp flare
#

I'm not gonna spoonfeed you anymore sorry

neon minnow
#

Lmao

#

this kid

sharp flare
neon minnow
#

you are funny

#

i am already looking on google, actually..

#

I been looking at this

#

but getSlot does not work.

sharp flare
#

wow look who knows what he's doing calling me kid

neon minnow
#

How old are you?

sharp flare
#

lol bro I'm not gonna waste my time on you, no one gonna spoonfeed you and learn java

neon minnow
#

lmfao

#

nevermind i fixed it

#

im tired and i put e.inventory instead of e.

#

lol

wet breach
neon minnow
#

huh

wet breach
#

in regards to your prior interaction lmao

#

anyways # is used in place of . sometimes because of urls etc

#

for future reference

neon minnow
#

I got a question

neon minnow
#

(!(joinqt.toBoolean())).toString()

This flips the boolean and converts it to string right?

#

so it would be false -> "true"

wet breach
#

not sure if you could do it one go but if it lets you, that is what that would do

neon minnow
#

Hell yeah

#

it works

wet breach
#

and ! means not or false. So how it reads is if joinqt is not true toString()

neon minnow
#

Yeah

#

It flipped it

#

if its a boolean it just flips it if there is no ==

#

cool

wet breach
#

I was just clarifying it, glad it works for you though 🙂

hardy swan
neon minnow
hardy swan
#

Why is there a .toBoolean()

#

What is joinqt's class

neon minnow
hardy swan
tardy delta
#

It's kotlin i guess

neon minnow
#

it had to be

grim ice
#

what are u converting to string, the if statement?

neon minnow
#

no

grim ice
#

can u send the whole line

sand hinge
#

how to create setting
example
setting: {
first: true,
second: false
}

#

in config

lost matrix
grim ice
sand hinge
#

br

#

setting
id:
setitng
fist: true

#

?

#

setting.id.setitng.first

grim ice
#

i guess but u forgot a : in front of setitng

sand hinge
#

Thanks

#

it's really hard

spare prism
#

is there a way to get an offline player in BungeeCord or do I have to do it manually using Mojang API?

lost matrix
light eagle
#

I was wandering if anyone could make a plugin so that u can change the colour/name of a block mined
also can u make it compatible with fortune

glossy venture
#

?services

undone axleBOT
light eagle
#

y not?

undone axleBOT
tender shard
#

sorry

willow stream
tender shard
willow stream
#

so i have

@EventHandler
public void onMove(final PlayerMoveEvent event) {
  final UUID playerID = event.getPlayer().getUniqueId();
  final Deque<Location> locations = this.lastLocations.computeIfAbsent(playerID, key -> new ArrayDeque<>());
  if (locations.size() == 2) locations.poll();
  locations.add(event.getTo());
}

public Vector getLastMoveVector(final UUID playerID) {
  final Deque<Location> locations = this.lastLocations.get(playerID);
  if (locations == null) return null;
  final Location last = locations.poll();
  final Location secondLast = locations.poll();
  if (last == null || secondLast == null) return null;
  final Vector vector = last.toVector().subtract(secondLast.toVector());
  vector.setY(vector.getY() / 2);
  locations.add(last);
  locations.add(secondLast);
  return vector;
}

to get vector of the player, then I use length() from that vector to setVelocity to my cube (slime)
it works great but the only issue is that when you are moving the cube forward and since I also have PlayerInteractEntityEvent#onRightClick() method I can give the cube additional Y which raises the cube in the air, the problem is that no matter how much you raise it the cube continues going forward instead of for example hitting the head of a player when falling down and staying behind

#

this is a problem because when another player kicks the cube, no matter how high the player that's in front will just block it even though its ex 5 blocks above him, no need to hit it or anything

grim ice
#

how do i make intellij make everything final by default

willow stream
#

I'm using it in EntityDamageByEntityEvent to calculate power += this.getLastMoveVector(player.getUniqueId()).length() * 2 + 0.4; kicking power

#

(default kicking power being power = 0.4)

tender shard
willow stream
#

It's used again in my scheduler#runTaskTimer task to calculate new cube velocity ```java
double power = this.getLastMoveVector(player.getUniqueId()).length() / 3 + oldV.length() / 6;
newV.add(player.getLocation().getDirection().setY(0).normalize().multiply(power));

tender shard
#

you can go to code inspection settings and tell it to warn you when you didnt declare something final that could be final

#

and then run the quick fixes over it

grim ice
#

ill just do it myself then

tender shard
#

how many people are going to cry now? 🥲

grim ice
#

thats a bot though

#

it isnt a plugin, or does that apply to bots too

tender shard
#

I know

grim ice
#

I assume it doesnt since a bot isnt an addon to something

tender shard
#

although I actually don't understand the reasoning for plugins neither

grim ice
#

i read in some thread that since

#

a plugin is just an addon to the main software which is bukkit

#

so it cant have a class called Main, only Bukkit can

tender shard
#

yeah makes sense but also, a plugin also has it's own kinda thing of a main class

#

public static void main() is basically onLoad() and onEnable()

#

I understand that "Main" is a fucked up name if your plugin has an API

#

because people have to do stuff like
Main chestSort = (Main) Bukkit.getPlugin("ChestSort");

grim ice
#

well yeah but onLoad and onEnable are just event listeners connected to a bus which is the actual main in bukkit, no?

tender shard
tender shard
grim ice
#

ic

tender shard
#

but yeah "Main" is not exactly a nice name for a plugin main class but still ,nothing to cry about imho

grim ice
#

btw what are the benefits of making a variable final

#

does it increase performance

#

it probably doesnt?

tender shard
#

not really

#

you can't accidently change it

#

if it's final you'll always know it still has the same value as the actual parameter given

#

if it's a local variable

#

and for fields, well

eternal oxide
#

same assignment, not value

tender shard
#

yeah I was thinking of primitives and strings

grim ice
#

whats the difference

tender shard
#

you can make a Location final

#

but you can still do myFinalLocation.add(0,0.5,0)

#

so it's the same location but it has changed nonetheless

grim ice
#

oh right

#

so assignment means that its the same object

tender shard
#

it just means you can never reassign it to another object

#

or primitive value

grim ice
#

yeah

#

hmm how about, when to use Weak and Soft references, and are they worth using to boost performance

eternal oxide
#

You use a weak ref when you are unsure if anyone else is going to keep a reference to any of your objects.

tender shard
#

I don't really know

#

but

#

yaaay my pull request made it into bukkit

#

I wonder why md_5 always declines pull requests, yet still somehow merges them 😄

spiral light
#

what did you change ?

tender shard
#

the javadocs now contain the datatype for all particles that take special data

#

e.g. "Uses BlockData as DataType" lol

#

so basically nothing except some javadocs comments lmao

#

but it was really annoying that this was missing

spiral light
#

uh nice

#

but no wonder thats nothing he needs to check again...

#

or maybe just test if the classes are ok

humble heath
spiral light
#

did you add dependency to your plugin.yml ?

#

so "depend: [Vault]"

humble heath
spiral light
#

show full log

vale ember
#

is the error message spigot's or custom? (sorry if im stupid)

spiral light
#

custom

tender shard
naive bolt
#

lol my plugin is doing well

vale ember
#

then the problem is 100% in code

#

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#

you should make it premium 10$

tender shard
#

convert it to skript

spiral light
#

dont know.... but isnt dis bannable on spigot ?

naive bolt
#

lets hope not

tardy delta
#

Is a HashSet.entryset.filter an more expensive operation than #contains?

#

Wait

humble heath
#

public static Economy getEconomy() {
return econ;
}

#

private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
return econ != null;
}

#

public void isecon() {
if (!setupEconomy()) {
log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
getServer().getPluginManager().disablePlugin(this);
return;
}
}

glossy venture
#

contains calls containsKey on the internal hashmapmap while get calls get(key) on the internal hashmap

#

so is containsKey faster than get

#

idk

eternal oxide
#

contains is likely faster as it doesn;t actually fetch any value

glossy venture
glossy venture
#

hashset doesnt have get

ivory sleet
#

It’s actually O(n)

glossy venture
#

containsKey in a hashmap is O(1) right

ivory sleet
#

Ω(1) but O(n)

tender shard
vale ember
ivory sleet
#

Best vs worst case

vale ember
#

oh ok

humble heath
#

if (!setupEconomy()) {
log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
getServer().getPluginManager().disablePlugin(this);
return;
}

glossy venture
#

yeah worst case if there are n collisions its O(n)

humble heath
#

that is the fail message

#

so plugin cant see vault

tender shard
#

I was asking which one of the if statements in your setupEconomy() method returns false

#

Does anyone know whether I can read two yaml files into SnakeYaml? I want to first read the default config, then read the "user-changed" config

humble heath
crude estuary
vale ember
tender shard
#

and I still wonder - which one of those is returning false?

#

the first one?

#

the escond one?

#

the third one?

#

add some debug output to find out

humble heath
#

nothing dont print anything

#

is there a different way to do it in 1.18 because it worked in 1.17

spiral light
#

maybe vault did not load becasue of an error or smth

vale ember
#

did you added statement before first if?

spiral light
#

would help to see your log

willow stream
#

old method for power was to update a HashMap with the player's uuid and sqrt of PlayerMoveEvent event.getFrom() - event.getTo()

tender shard