#help-development

1 messages Β· Page 2204 of 1

quaint mantle
#

from?

#

but java not help i know the baisics of programing

tender shard
#

iirc no

glossy venture
#

shit

#

its with constants

#

shti

#

shit

#

from stackoverflow

#

hopefully they implemented that by now

tender shard
#

well if you do sth like

static final int SIXTEEN = 16;
static final int EIGHT = 16 / 2;

then obviously it uses 8 directly.

If you do stuff like this however

static final int SIXTEEN = 16;

static int half(int num) { return num / 2; }

static final int EIGHT = half(SIXTEEN);

then it definitely can't optimize it to bitshifts because it wouldn't work for negative "num"s

glossy venture
glossy venture
#

i think signed works for both negative and positive

tender shard
#

hm no idea. but I wouldn't worry about it anyway. I mean how often are you ging to divide something? it's probably totally irrelevant for the overall performance in 99.999% of cases

glossy venture
#

block access

tender shard
#

then it's totally unnecessary to worry about it at all imho

rapid goblet
#

Hello can anyone help me I have a server of spigot but after i updated the server to 1.19 it always shows (incomplete sets of tags received from the server) but my friends can join but I cant

glossy venture
#

it might happen a load per tick

glossy venture
#

i mean div is fast but id like to keep highest performance possible

#

yeah

rapid goblet
glossy venture
#

bitshift works on negative numbers

tender shard
rapid goblet
#

πŸ˜”

glossy venture
#

and its not that hard to implement in javac

#

whatever i might change laer

#

later

tender shard
glossy venture
#

that wold be greta

#

wodl

#

i tried to type my typo but i mistyped the typo

tender shard
# glossy venture that wold be greta

I have just tried it a few hundred times for one million divions and one million bitshifts and it's basically the same time for bitshifting or division

glossy venture
#

ok

tender shard
#

sometimes bitshifting is a bit faster, sometimes division is a bit faster

glossy venture
#

nice

#

thanks

tender shard
#

np

glossy venture
#

i need to code chunk system to not have horrible performance

#

for custom blocks

proper pawn
#

anyone?

humble tulip
pastel juniper
#

If I install a custom resource pack with custom fonts, I can for example use this command /tellraw ANFFGaming {"text":"\uE000"} to show the fonts in the chat. How can I do the same with the plugin???

quaint mantle
#

you can check tellraw's source code

#

and recreate it in your plugin

#

`

`
is there way to get string in string like f-string in python
python example:

avar = "some content"
print(f"> {avar}") 

output:

> some content

thanks ash

humble tulip
quaint mantle
#

thx i'll check it out

tender shard
pastel juniper
native falcon
#

hi, how do I make it so my plugin loads after every world has been loaded?

sterile token
native falcon
#

Doesn't work nope

sterile token
#

load: POSTWORLD

#

Like that it was cold

native falcon
#

yeah I tried that, doesn't work..

sterile token
covert karma
#

how do i check if a player is inside lava? similar to player.isInWater()
the problem with checking the block at player position is that the player can stand mostly on one block but still touch the lava to the side

native falcon
# sterile token

yeah I already tested it, it's actually always POSTWORLD when you don't specify anything

vast raven
#

If I declare a variable, will it be deleted after the execution of the last line of code of a class, or until the server restarts?

tender shard
undone axleBOT
tender shard
#

you should learn about "variable scope" and the difference between instance, class and local variables

vast raven
river oracle
#

You don't have to worry about manually managing that

#

When the plugin disables you lose all vars the same as any other program. If you close the program its nolonger going to be holding onto any memory. So again like any other java program if the plugin is disabled ofcourse the variables will be gone. If you want stuff to stick around use a database or if its small identifiers use PersistentDataContainers

late sonnet
echo basalt
#

I heard that the warden is a pain to modify

#

let's hope it's not ender dragon levels of pain

late sonnet
echo basalt
#

mm behaviorcontroller I see

#

imma run buildtools and have a look

late sonnet
#

yeah im try to make a method to force the attack for my PR for methods in Warden

echo basalt
#

I feel like mojang will make all new mobs just use BehaviorController instead of pathfindergoals

#

might just be a new dev tasked with all of this tbh

vital trout
#

Hi guys, I want to make a team system in which players on the same team can see each other with a glowing effect, but I don't want the other teams to see this effect. After some research it seems that I need to use packets but I do not handle them very well actually, anyone got a hint/a piece of code/a link to help me out ? mc version : 1.18.2

echo basalt
#

glowing is done via entity metadata

#

or the glowing potion effect but that's kinda meh

#

you can use GlowAPI if you really need to

vital trout
#

Yeah but GlowAPI relies on PacketListenerAPI and it's not updated for 1.18 yet :(

echo basalt
#

I have a version that works for ProtocolLib

#

doesn't handle colors tho

vital trout
#

Just a white glowing ?

echo basalt
#

yep

vital trout
#

Well a solution with all the colors would be better if someone else know a way to do it

echo basalt
#

uhhh

#

you can do the bukkit team stuff and it should work on top

latent heron
#

anyone know what plugin could possibly be adding $100 to everyone's account every 100 seconds because it's so annoying and we can't figure it out?

latent heron
#

thats the thing I don't have that installed lol so idk what it could possibly be

echo basalt
#

or anything that runs commands on a timer

clever musk
#

What was FriendlyByteBuf called in 1.16.5?

vital trout
echo basalt
#

welp here's the uh

#

unpleasant code I wrote like a year ago

vital trout
#

thanks c:

#

I just need to import protocollib to my project ?

golden kelp
echo basalt
#

or couldn't, at the time

golden kelp
#

generics cry in the corner

echo basalt
#

yessir

golden kelp
#

xd

echo basalt
#

also it allows multiple data types and handles them separately

#

so yeah

golden kelp
#

oh thats sad

echo basalt
#

metadata packets are pain

#

this was the simplest way

golden kelp
#

i dont even know what those are πŸ˜‚

vital trout
#

ok i'll try that later and I'll let you know ^^

echo basalt
golden kelp
#

fr

whole elbow
lavish folio
#
event.getEntity().getWorld().createExplosion(event.getEntity().getLocation(), 6f, false, false, event.getEntity());

6f is power and power is explosion strenght?

echo basalt
#

yes

#

it handles block damage and entity damage

#

6f is wither explosion iirc

#

tnt is a 4

lavish folio
#
Minecraft Wiki

An explosion is a physical event, generally destructive, that can be caused by several different circumstances. It can destroy nearby blocks, propel and damage nearby players, entities, and their armor, and cause one or more fires under correct circumstances. Explosions produce a "shockwave" particle effect.
Multiple close explosions may propel ...

echo basalt
#

welp ig I'm an idiot then

coarse finch
#

what does this mean and how do i fix it

#

its for Player not block btw

lavish folio
#
public void functionName(PlayerBedLeaveEvent event) {}
coarse finch
#

oh thanks

mellow edge
#

working with minecraft client is defenetly harder than with server

lavish folio
#

yes

compact cape
#

Huh, why Statistic.PLAY_ONE_MINUTE returns ticks???

tall dragon
#

because someone in the development team forgot to take their brain with them that day

tender shard
#

what is that even supposed to return

tall dragon
#

playtime

tender shard
#

like why is it called ONE minute

#

why isn't it just called PLAYTIME

tender shard
#

yeah but

compact cape
tender shard
#

even if it would return minutes

#

why would it be called ONE minute

tall dragon
#

yea idk

proper notch
#

fun tidbit, it used to be called play_one_tick, not play_one_minute

tall dragon
#

but it returns playtime in ticks

tender shard
#

all those statistics have those shitty names

#

FLY_ONE_CM instead of FLY_CM or FLY_CENTIMETERS

tall dragon
#

yea its very weird

tender shard
#

like noone would store the amount of TWO minutes played

compact cape
#

I don't mind the shitty name, At least put the ****ing right messure

tender shard
#

int playtimeInMinutes = getStatistic(PLAY_TWO_MINUTES) * 2
lmao wtf

#

so stupid

warm light
#

I want to make a logger plugin for all events. is there any easy way or I have to right all events?

tall dragon
#

you want to listen to all events?

warm light
#

Yes

tall dragon
#

well the only way to do that is to do some reflection magic

warm light
#

Alright. thanks

tender shard
#

logging ALL events? oh boy you're gonna have a bad time

flint coyote
tender shard
#

BlockPhysicsEvent, RedstoneEvent, ...

tall dragon
#

PlayerMoveEvent πŸ˜„

#

those logs are going to be spammed hard

tender shard
#

yeah

#

you should definitely have a blacklist for certain events

warm light
#

umm, I just found it

golden kelp
mellow edge
#

I don't use forge

humble tulip
#

BlockPhysicsEvent

mellow edge
#

I have optifine

humble tulip
#

That's even worse

mellow edge
#

so bassiclly decompiled minecraft client

quaint mantle
#

Im thinking of disabling some of the particle affects done by the warden when sonic booming, however i've never dived this deep into the spigot api so any suggestions on where to start? I've heard it may be something to do with packets

dark arrow
#

I know I have asked the question the 100th time but I think I have to ask again ,How to remove a goal from an entity

pastel juniper
#

How can I send to different clickable messages in one chat line???

dark arrow
pastel juniper
dark arrow
#

so what do you wanna know?

humble tulip
#

Sammu I'm not at my computer rn but is there a way to get the goals?

tender shard
dark arrow
#

I cant you new goals and edit it

dark arrow
#

I saw a method to get list but it was 5 years old and not working

humble tulip
#

U need tognet the goals by reflection or if there is a method

#

U can't remove a "new" goal since you're creating a goal that the enitity doesn't have

coarse finch
#

can i block the player from executing any commands?

dark arrow
#

what's togent?

pastel juniper
humble tulip
#

Get the goal that you want to remove from the entity then remove it

humble tulip
polar pagoda
#

HidePlayer

dark arrow
dark arrow
#

i was getting confused on how can i get it

humble tulip
#

Look in the entity class and see if there's a method that returns the goals

#

Or if there's a feild with the goals

#

Or whatever targetselector is

dark arrow
#

there are many methos but i suspect addBehaviourGoals

humble tulip
dark arrow
#

here all the goals are added

dark arrow
#

i cant find any reutrn

coarse finch
#

can i block the player from executing any commands?

dark arrow
#

i think i need to check more properly

humble tulip
#

See where the goals are stored from adding

humble tulip
coarse finch
dark arrow
#

there is a register goal but i dont think it gonna work

humble tulip
#

See how goals are registered and u can figure how to unregister

#

What is targetselector?

dark arrow
#

the this.addBehaviourGoals

#

and some other goals are registered like that to

humble tulip
#

Yes i know but look deeper than that

#

See what that method does and the methods inside that method as well

#

Playing around with nms requires alot of digging around since it's undocumented

dark arrow
#

this.goalSelector.removeGoal(this.breakDoorGoal);

humble tulip
#

Wait it's a custom entity?

#

Just store the goals and remove it

tender shard
humble tulip
#

U don't even need to look thru a list of goals then

dark arrow
#

Thats what i am saying form the starting

tardy delta
#

Van you write lambdas for abstract classes?

#

Can

humble tulip
#

I didn't know it was a custom entity

dark arrow
#

oh

#

i think i forgot to mention

humble tulip
#

Just store the goals in your customentity class

#

So u can remove them anytime

tender shard
tardy delta
#

Overriding abstract method of abstract class

tender shard
#

you can use lambdas for functional interfaces

public interface MyInterface {

    void apply();

    MyInterface SOME_IMPLEMENTATION = () -> System.out.println("Nothing");
}

tardy delta
#

It has only one

tender shard
#

okay than you have to annotate it with FunctionalInterface

#

one sec let me check my update checker, it uses sth similar

dark arrow
tardy delta
#

Trying to use the java.util.logging.Formatter as lambda

tender shard
#

ah no it must be an interface @tardy delta

tardy delta
#

Ah sad

humble tulip
#

I'll be able to when I'm home tonight

dark arrow
#

ok

coarse finch
#

can i have multiple commands in the same class

tall dragon
#

yes

#

but i cant advize it

coarse finch
#

ok well then how can i access a hashmap from one command class in another

tall dragon
#

?di

undone axleBOT
tardy delta
#

what was i doing lol

polar pagoda
#

can someone help me in my thread?

tardy delta
#

else try {} 😒

mighty pier
#

friend gave me this code

tardy delta
#

that it is doing those things when the class gets initialized

tall dragon
#

static means its constant through instances of the class

tardy delta
#

so same time when static variables are instialized

tender shard
# mighty pier what does just `static{}` mean?

yeah as others said it's run when the class gets initialized. you can do it to run code related to your static fields like this

public class WhatEver {

    private static final Set<Material> ALL_SHOVELS = new HashSet<>();
    
    static {
        Arrays.stream(Material.values())
                .filter(mat -> mat.name().endsWith("_SHOVEL"))
                .forEach(ALL_SHOVELS::add);
    }
}

ivory sleet
#

static { } is a constructor but for static stuff only runs once

humble tulip
#

?di

undone axleBOT
humble tulip
#

And have a getter for an instace of that class in your main class

#

And use dependency injection to pass your plugin to the command classes

tardy delta
#

cant they be abstract?

glass mauve
#

It’s a record

tender shard
tardy delta
#

smh

tender shard
#

why do you need an abstract record?

tardy delta
#

i could just transform 20 lines to 3 lines but java was like no

humble tulip
#

Isn't a record a data class

#

Why u wanna use a record for a command?

glass mauve
misty current
#

can anyone help me with a design choice? I'm making a plugin and I am making wrapper classes for different types of items (enchantable items, ability items, consumables, etc.) and i want each one of them to have a static method to check if the itemstack you provide is that type of item (example, if the item has a certain nbt tag it will be a consumable). Any suggestions for a design i could use?

ivory sleet
#

What have you got so far?

coarse finch
#

i think i messed up the di ```java
private final HashMap<UUID, Boolean> frozenDict;

public UnfreezeCommand(HashMap<UUID, Boolean> frozenDict) {
this.frozenDict = frozenDict;
}```

misty current
#

i have an abstract class with a basic validator (checks if the item is not null or air) and i was making a registry class with all the wrapper classes in a list

misty current
#

something i thought of is making the constructor throw exceptions if the item argument is invalid and making a method in the registry class that tries to construct with reflections the class and catches exceptions to tell if the item is valid or not

humble tulip
#

Put the map in your main class

coarse finch
#

oh ok

humble tulip
#

And then inbthe brackets of ()

#

Put the map variable

#

So u give the map to your command

#

Don't change anything you had already

coarse finch
#

ok

humble tulip
ivory sleet
#

Sounds good kill05

humble tulip
#

Just makenit abstract

ivory sleet
#

Remember the direct values of your registries can always be facades providing access to your factories, observers and what not

ivory sleet
#

Ugh, do you know any design patterns? πŸ˜…

misty current
#

kind of, yea

#

what do you mean with facades

tender shard
ivory sleet
#

^

misty current
#

i should've googled it, right :p

coarse finch
#

umm Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1

coarse finch
#

oh yeh

tender shard
#

your array has only one element so only array[0] exists

coarse finch
#

my brain is not functioning lol

humble tulip
misty current
#

oh so that's called a facade

#

i kind of do it all the time

humble tulip
#

Same lol

tender shard
#

yeah it's probably the most vague of all design patterns lol

ivory sleet
#

Yes kill05 the most generic design pattern in Java in principle but it’s good to have formal names for all of these patterns, makes it easier to talk about design on a higher level

tender shard
#

one could say "it's an object that combines other objects and how they work together" lol

crude cobalt
#

Can I pass a global variable from one plugin to another?

humble tulip
#

U can

misty current
#

i often find naming classes problematic

crude cobalt
golden turret
#

is Player#setWalkSpeed thread safe?

coarse finch
#

i missed one of the args[1] >:(

humble tulip
#

Well it depends

#

But u can

misty current
#

because i don't know how to express what does the class do

golden turret
#

also, is Inventory#getItem thread safe?

humble tulip
#

Bukkit stuff aren't thread safe

torn shuttle
#

quick question, does the player persistent data container survive restarts?

torn shuttle
#

thanks

misty current
river oracle
#

There is no reason to multi-thread inventory access

misty current
#

it's not an expensive operation

river oracle
#

The rule generally is bukkit stuff isn't going to be thread-safe\

crude cobalt
#

I want to pass Hashmap. Any ideas how?

misty current
#

dependency injection

river oracle
humble tulip
#

?di

undone axleBOT
crude cobalt
#

Thnaks

misty current
#

?paste

undone axleBOT
coarse finch
#

what is vanilla walkspeed

misty current
frozen star
coarse finch
#

thanks

misty current
#

and the child classes will implement the isValid method

#

if the isValid method returns false for an item, the constructor will throw an exception

ivory sleet
#

But frequent read writes will not be thread safe by any means

#

kill05 why does it need to throw an exception?

frozen star
#

i'm trying to figure out how to make a player look at an entity (trying to make a diologue thing) and i am having trouble with vectors. here is my code https://paste.md-5.net/kekuyovoco.cs
and i think the main problem is the error on line 6

#

idk how to get the .subtract to work

coarse finch
#

woah, 1 is way too fast

frozen star
#

it might be 10% of what i said

#

1 might be 10 to essentials

coarse finch
#

its .2

misty current
frozen star
#

interesting

coarse finch
#

well according to google its .2

misty current
#

and also so i don't write illegal data to an item's nbt

#

because let's say i try to wrap a consumable as an enchanted item by mistake and i don't notice

#

and then i try to enchant the item, the consumable will have illegal data on it

misty current
ivory sleet
#

Hmm okay I would null return or use Optional upon invalid conversion

midnight quarry
#

I am trying to use Fast Async World Edit API in my code, but when I try to install it through maven and write some code, upon compilation it says it cannot access some classes?

#

cannot access com.sk89q.worldedit.bukkit.BukkitAdapter

nova sparrow
#

How would you start a raid wave through spigot?

tardy delta
#

should i use DateTimeFormatter or is there a newer class?

misty current
ivory sleet
#

Yes almost always use factory methods or classes

#

It’s a so easy yet powerful way to decouple creation and instantiation

misty current
#

can I make the factory into a singleton or is that bad design?

#

i'm pretty sure i would start getting annoyed by having to dependency inject my factory instance everywhere

humble tulip
#

Why wpuld you need the factory everywhere?

crisp steeple
#

static/singleton is usually fine for a factory

humble tulip
#

But ye

#

Esp if u want other plugins to hook

misty current
humble tulip
#

Ah ok

misty current
#

anything i do related to items/entities will be done trough the wrappers

#

tryna experiment different designs to see what i am comfortable with

opal carbon
#

is there somewhere online with some sorta javadocs for Mojang mappings

#

so I can actually find classes and methods for stuff yaknow

#

and also I assume that if I want to use Mojang mappings I will have to use that maven plugin that has been included in the dev section of update logs since 1.17

ivory sleet
#

Or paperweight

iron glade
#

Does anyone know a sound that sounds like turning a page or some sort of short "clicky" sound?

ivory sleet
#

(Gradle)

opal carbon
tardy delta
#

i guess there is a better way lol

tall dragon
vocal pine
#

how do i retrieve an actual entitytype from the registry (my custom entity) to use in it's constructor for an item spawn

humble tulip
#

ITEM_BOOK_PAGE_TURN

vocal pine
#

Registry.ENTITY_TYPE.get(keyThing) returns capture but i need the entitytype itself and i'm not smart enough for that

humble tulip
fringe hemlock
#

Hi y’all, is there anyway to modify a particle packet to make the particle stay visible longer? From what I read it’s hard coded but I just want to make sure

misty current
#

i'm pretty sure the client handles the duration of particles

fringe hemlock
#

That sucks, thank you though! :)

opal carbon
#

you could just try making another particle

dark arrow
#
public NewMob(Location location) {

        super(((CraftWorld) location.getWorld()).getHandle());
          List targetB = (List)getPrivateField("b", NearestAttackableTargetGoal.class, targetSelector);
         targetB.clear();
        this.setPos(location.getX(), location.getY(), location.getZ());
        this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, false));
        this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Pig.class, true));
        this.goalSelector.addGoal(2, new AvoidEntityGoal<Creeper>(this, Creeper.class, 1.0f, 1.0, 1.0));
        this.goalSelector.addGoal(2, new PanicGoal(this, 1.0d));

    }

   public static Object getPrivateField(String fieldName, Class clazz, Object object) {
        Field field;
        Object o = null;
        try {
            field = clazz.getDeclaredField(fieldName);
            field.setAccessible(true);
            o = field.get(object);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();

            return o;
        }


        return o;
    }

This code is suppose to get the list of the goals of my custom entity and clear it but instead it gives internal error

tardy delta
#

returning o in any case /shrug

dark arrow
chrome beacon
crisp steeple
dark arrow
#

?paste

undone axleBOT
dark arrow
sterile token
#

How do i parse urls in java? I need to parse mongo and redis url

humble tulip
sacred mountain
#

hey

#

im finally alive

sterile token
#

Light furry nice to see you again

#

How are you?

dark arrow
humble tulip
#

U can't set it cuz it's final

dark arrow
#

so that means there is no hope now?

humble tulip
#

I feel like you're going about this the wrong way

#

You can set a field to no longer be final

dark arrow
#

i mean the file is read-only

#

oh

#

got it

sterile token
#

Minion, do you know how i can parse url like does mongo or redis?

upper vale
#

What?

sterile token
#

Yeah let say i have the url: "mongodb://username:password@host:port/route"

upper vale
#

I don’t understand what you mean by β€œparse” it?

#

I mean Mongo and redis allows you to connect via a URI directly afaik

#

You don’t need to parse it and extract the credentials yourself

sterile token
#

Im needing to find a way of reading let say the hot, port, etc

#

I know i just want to design my own url that why

royal grove
#

hi i have a question i wanna make soemthing when you shoot an arrw the console sends a message tot that player with the cordinates of that arrow

upper vale
sterile token
quaint mantle
#
//dont actually use
int separator = input.indexOf("://");
String dbProvider = input.subString(separator);

int colon = input.indexOf(":");
String username = input.subString(separator, colon);

int at = input.indexOf(...)
sterile token
#

Ohh ok

#

Thanks imagin i will try

quaint mantle
#

but you should use

#

new URI(input)

sterile token
#

Allright

quaint mantle
#

does all of it for you

sterile token
#

Thanks to the too of you

quaint mantle
#

no dont

#

it does it for you

#

[scheme:][//authority][path][?query][#fragment]

sterile token
#

Ohh ok

#

I just catch it

tender shard
sterile token
#

mfalex, is open source your http client?

royal grove
tender shard
royal grove
#

thx

sterile token
#

Imagin so:

URI bla = URI.create("custom://username:password@host:port");

String[] auth = bla.getUserInfo().split(":");
String user = auth[0];
String pass = auth[1];

quaint mantle
#

do you ever listen to what i say

#

like not even being mean

#

i dont even think you need the username:password

#

well

#

i think authority takes that in

#

so you dont have to worry about that

#

no need to split anything

sterile token
#

Hmn i dont know tho

#

There is no URi getter which returns a the password

quaint mantle
#

kms

sterile token
#

"user:pass@localhost:6379" that what return getAuthority()

quaint mantle
#

weird

sterile token
#

Yes

#

I was listening to you, but the method doesnt return what i expect

vocal pine
#

How do I change network ID of an entity ideally without ProtocolLib? I just want to make my custom entity a different entity to clients but I can't find anything on this specific topic

tender shard
vocal pine
#

Nor can I find anything in NMS itself about it

tender shard
vocal pine
#

Probably just bad at looking but if someone can point me at where to look in NMS to learn I'd appreciate it

tender shard
# sterile token "user:pass@localhost:6379" that what return getAuthority()
        URI uri = URI.create("custom://username:password@jeff-media.com:25565/location");
        System.out.println("Authority: " + uri.getAuthority());
        System.out.println("Path: " + uri.getPath());
        System.out.println("Host: " + uri.getHost());
        System.out.println("Port: " + uri.getPort());
        System.out.println("UserInfo: " + uri.getUserInfo());

this prints out this:

Authority: username:password@jeff-media.com:25565
Path: /location
Fragment: null
Host: jeff-media.com
Port: 25565
UserInfo: username:password
tender shard
sterile token
#

mfalex, also client can display non minecraft entity?

vocal pine
#

because i'm stupid is probably the main reason

i was able to register my entity so I thought hey, why not just pass that to superconstructor

means it saves, reloads, loads, etc. all perfectly fine without janky workarounds like changing the ID on save

#

i know the normal way to do things is pass a different entitytype to superconstructor (matching the class it extends) so it shows like that to clients

#

but i didn't like the janky workarounds purely subjectively so i thought i'd make things harder for myself

#

πŸ‘

tender shard
vocal pine
#

just shows as a pig

tender shard
vocal pine
#

yup

tender shard
#

it's weird that pig is the default entity lol

tender pond
#

Hey guys! Was just wondering if anyone could help me with this...

So I'm using the InventoryClickEvent alongside a InventoryType.ANVIL Inventory Menu.

The inventory is opening all fine, but I'm basically struggling with getting the Display Name of the item in the 3rd Slot, e.g. the final slot. However when trying to print out the DisplayName value it is returning the original name of the item in that slot. Also to clarify, I am setting a NameTag to both Slot 0 and Slot 2 with the name "Rename Me" and when printing out the value even after changing it in the Anvil GUI it is returning "Rename Me".

if (i.getView().getTitle().equalsIgnoreCase("Alliance Creation")) {
            if (i.getSlotType() == InventoryType.SlotType.RESULT) {
                Bukkit.broadcastMessage(i.getCurrentItem().getItemMeta().getDisplayName());
                i.setCancelled(true);
                player.closeInventory();
                gui.add(player);
            }else{
                i.setCancelled(true);
            }
        }
``` here's the code alongside a few screenshots
vocal pine
#

it's pretty cool imo

#

riding pigs around railways

vocal pine
tender shard
#

I have no idea, as said I never really did any custom entities

tender shard
#

pls try again to explain

  1. what you want to do
  2. what happens instead
tender pond
sterile token
#

I endup with this code, if someone want to do something similar in the future then you can use it

URI uri = URI.create("scheme://user:pass@localhost:6379/db-name");

System.out.println("Scheme: " + uri.getScheme());
System.out.println("Host: " + uri.getHost());
System.out.println("Port: " + uri.getPort());
System.out.println("Username: " + uri.getUserInfo().split(":")[0]);
System.out.println("Password: " + uri.getUserInfo().split(":")[1]);
System.out.println("Database: " + uri.getPath().split("/")[1]);
tender pond
#
  1. I want to retrieve the DisplayName of the item in the 3rd Slot after changing it via the Anvil GUI.
  2. When retrieving the DisplayName of the item in the 3rd Slot it is receiving the DisplayName "Rename Me" rather than the Display Name "Rename Medasd" as seen in the Screenshot. So basically it appears the event isn't updating the item meta as I'm changing it simultaneously in the GUI
#

Hopefully that makes sense

tender shard
#

the full code of your listener

tender pond
#
if (i.getView().getTitle().equalsIgnoreCase("Alliance Creation")) {
            if (i.getSlotType() == InventoryType.SlotType.RESULT) {
                Bukkit.broadcastMessage(i.getCurrentItem().getItemMeta().getDisplayName());
                i.setCancelled(true);
                player.closeInventory();
                gui.add(player);
            }else{
                i.setCancelled(true);
            }
        }
#

Here's the InventoryClickEvent

tender shard
#

what is "i"?

#

oh

#

the event

#

that's a weird name for an event lol

tender pond
#

Yeah lol πŸ˜„ Usually I do 'E' instead of 'I' but because it's to-do with Inventory I did 'I' lol

tardy delta
#

not even e

tender shard
#

no idea, from what I see it should be working fine. might have something to do with the fact that you set both slots to the same item. try to do

inv.setItem(2, invitem.clone());
sterile token
#

Also, when asking for support always send full code

tardy delta
#

why having to clone the item again?

tender shard
#

okay let me try sth

tender pond
#

So something funky is happening πŸ˜„

prisma steeple
#

hi there

#

I'm very new to this and i'm trying to understand how things work, and i encountered my first "issue"

#

I'm pretty sure it's a logical error

#
 Integer XCoord = event.getBlock().getX();
            if(XCoord < 50){
                Player player = event.getPlayer();
                player.sendMessage("X = " + XCoord);
#

The intent = if a block is places when the x coordinate is above 50 it sends a message specifically to the player which states the X coordinate

#

however it won't seem to work, no errors

sterile token
prisma steeple
#

makes a difference ?

tender pond
#

Silly question, but have you registered the command/event

sterile token
prisma steeple
#

one moment

#

here

#
public void BlockPlaces(BlockPlaceEvent event){
        int XCoord = event.getBlock().getX();
            if(XCoord < 50){
                Player player = event.getPlayer();
                player.sendMessage("X = " + XCoord);
                
            }


    }
#

pretty much the full code

sterile token
#

That wrong

prisma steeple
#

except the class

sterile token
#

You are missing the annotation @EventHandler

tender pond
#

Do you have @EventHandler above that?

prisma steeple
#

No I do not

#

thank you

sterile token
#

That the reason

prisma steeple
#

I do that just by write @eventhandler ?

sterile token
#

@EventHandler

prisma steeple
#

thanks

sterile token
#

Like that using capitalls

prisma steeple
#

also if you don't mind me asking

#

whats the difference if I write Integer or Int

#

Honestly wrote it bc it was the thing that came up, not because I write integer

#

but nonetheless thanks :)

sterile token
#

int*

prisma steeple
#

int yes my bad

tender shard
tender pond
#

Hmm interesting, thank you! All I basically wanted was the player to be able to name something via this GUI, as I'm pretty sure I've seen it in other plugins before. I really appreciate you for helping with this, let me know if you get it to work πŸ™‚

tender shard
tardy delta
tender pond
#

I found this, but couldn't figure out how to do it

tender shard
tender shard
orchid pollen
#

does anybody know a good spigot tutorial for intelij for begginers

flint coyote
tender pond
tender pond
#

Yep

iron glade
tender pond
tender shard
# tender pond Yep

then you can add the the stuff mentioned in "Usage -> As a dependency" to your pom.xml, click the maven reload button, and then mess around with the AnvilGUI.Builder to build your custom anvil inv

prisma steeple
#

eh- my code still seems to not be working

tender pond
tender shard
#

yeah

prisma steeple
tender shard
#

and then you can provide a BiFunction to the onComplete method

prisma steeple
#

full code

#

oh

#

oh

#

wait

#

nevermind

iron glade
#

why is the @EventHandler so far away from the Event xD

sterile token
#
 @EventHandler
    public void BlockPlaces(BlockPlaceEvent event){
        int XCoord = event.getBlock().getX();
            if(XCoord < 50){
                Player player = event.getPlayer();
                player.sendMessage("X = " + XCoord);
            }
    }
prisma steeple
#

i have no idea, i will arrange it

iron glade
#

not that it would change anything

#

but looked funny

sterile token
#

Out what the issue?

crisp steeple
#

did you register the event

sterile token
#

Alo outlet did you learn how works the api?

#

I think the main issue

prisma steeple
#

the main issue is me not exactly knowing how it works if anything

#

However i don't see anything wrong with this code

iron glade
#

Which code?

prisma steeple
#
package com.outletserver;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import org.bukkit.event.block.BlockPlaceEvent;



public class ChunkLoad implements Listener {
    @EventHandler
    public void BlockPlaces(BlockPlaceEvent event){
        int XCoord = event.getBlock().getX();
            if(XCoord < 50){
                Player player = event.getPlayer();
                player.sendMessage("X = " + XCoord);
                
            }


    }
}
#

this code

#

this is not working

#

it should work

tender shard
prisma steeple
#

I am at X27 placing a grass block

iron glade
#

show your onEnable in your main class

tardy delta
tender shard
#

yeah that's unfortunate

iron glade
sterile token
#

Jut copy-paste what he ent

tardy delta
#

then do it >-<

sterile token
#

Its not my event

sterile token
#

Its him/her even t

iron glade
#

his/her*

crisp steeple
sterile token
iron glade
#

pas de probleme mon ami

sterile token
#

Haha no problem

tender shard
# tender pond Oh... ermmm

I think sth like this should work

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        ItemStack myNametag = new ItemStack(Material.NAME_TAG);
        ItemMeta meta = myNametag.getItemMeta();
        meta.setDisplayName("Rename me");
        myNametag.setItemMeta(meta);
        new AnvilGUI.Builder()
                .itemLeft(myNametag)
                .plugin(this)
                .onComplete((player, name) -> {
                    Bukkit.broadcastMessage(name);
                    return AnvilGUI.Response.close();
                }).open((Player) sender);
        return true;
    }
prisma steeple
#

hold on

#

        public void onEnable() {
            System.out.println("hi!");

            Bukkit.getPluginManager().registerEvents(new ChunkLoad(), this);

        }
        public void onDisable(){
            System.out.println("Server off");

        }
}
iron glade
#

@Override

#

should be above onEnable and onDisable

tender shard
#

(although not needed for it to work)

iron glade
#

yes

prisma steeple
#

what does override do

crisp steeple
tender shard
prisma steeple
#
main: com.outletserver.myfirstplugin
name: Plugin1
version: 1
#

this is what is in there

iron glade
#

api version

#

api-version: *

iron glade
#

what's your main class called?

prisma steeple
#

myfirstplugin

iron glade
#

okay

tender shard
#

that's a weird class name

iron glade
#

which version are you coding against?

tender pond
# tender shard I think sth like this should work ```java @Override public boolean onCom...
[20:55:55 INFO]: RocketManKian issued server command: /alliance create
[20:55:55 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'alliance' in plugin AllianceTag v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[purpur-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:172) ~[purpur-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.dispatchCommand(CraftServer.java:906) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2389) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2200) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2181) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]
        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:51) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1426) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:188) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1403) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1396) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1374) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1256) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:320) ~[purpur-1.18.2.jar:git-Purpur-1628]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NoClassDefFoundError: net/wesjd/anvilgui/AnvilGUI$Builder
        at me.rocketmankianproductions.alliancetag.commands.AllianceTagCommand.onCommand(AllianceTagCommand.java:110) ~[AllianceTag.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        ... 21 more
Caused by: java.lang.ClassNotFoundException: net.wesjd.anvilgui.AnvilGUI$Builder
        at me.rocketmankianproductions.alliancetag.commands.AllianceTagCommand.onCommand(AllianceTagCommand.java:110) ~[AllianceTag.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        ... 21 more
``` hmmm
prisma steeple
#

it's my first plugin

#

so i called it myfirstplugin

prisma steeple
tender shard
#

or you didnt use maven to build your plugin

iron glade
prisma steeple
#

OHH

#

my bad

#

1.17

crisp steeple
#

try just sending a message without any of the conditions just to make sure the listener is registered properly

iron glade
#

then add
api-version: 1.17

#

to your plugin.yml

iron glade
#

anything in the console when loading the plugin?

prisma steeple
#

"did not specify API version"

#

should've read the console

tender shard
#

that's no problem

#

it would still work

#

that's just a warning to inform you that your plugin is the reason for legacy material support being enabled

tender pond
tender shard
prisma steeple
#

so if i specify it won't need to enable it

iron glade
#

anything else in the console @prisma steeple

prisma steeple
#

uh

tender pond
prisma steeple
#

The

iron glade
#

iirc it enables it if your plugin is < 1.13

prisma steeple
#

Server permissions file permissions.yml is empty, ignoring it

tender shard
iron glade
prisma steeple
#
[22:00:04] [Server thread/WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
[22:00:08] [Server thread/WARN]: Legacy plugin Plugin1 v1 does not specify an api-version.
[22:00:08] [Server thread/INFO]: [Plugin1] Loading Plugin1 v1
[22:00:08] [Server thread/INFO]: Preparing level "world"
tender shard
#

I love how everyone uses the weird minecraft development plugin and gets a pom but never use maven to actually compile anything

prisma steeple
#

still doesn't send anything

tender pond
prisma steeple
#
public class ChunkLoad implements Listener {
    @EventHandler
    public void BlockPlaces(BlockPlaceEvent event){
        Bukkit.broadcastMessage("Test");
tender shard
#

it should be 3.3.0

tender pond
#

It's 3.2.4

tender shard
#

set it to 3.3.0

iron glade
#

there you go

prisma steeple
#

nope

#

nothing at all

tender shard
#

?paste your full console log

iron glade
#

?paste

tender shard
#

is the bot offline?

iron glade
#

bruh

tender shard
prisma steeple
vocal cloud
#

Bot no ):

tender pond
vocal cloud
#

?tas

sterile token
#

?task

#

Oh the bot is down

#

?work lmao

sterile token
#

Yeah its definetly down

iron glade
prisma steeple
#

yep

sterile token
#

Any plugin that you know that have a "plugin-jar" and then separate the "plugin-jar-api" for that plugin?

iron glade
orchid pollen
#

does anybody know a good starting tutorial for making a project in intelij

iron glade
#

@tender shard could you have a quick look at my POM? i have the feeling something's wrong there

iron glade
#

idk what but something's bugging me

tender shard
#

why? πŸ˜„

#
            <exclusions>
                <exclusion>
                    <artifactId>FastAsyncWorldEdit-Bukkit</artifactId>
                    <groupId>*</groupId>
                </exclusion>
            </exclusions>
#

this is basically useless

#

it's scope provided anyway

iron glade
#

that's copied from their site

tender shard
#

triumph-gui doesn't have a scope set

iron glade
#

idk why tbh

tender pond
tender shard
mellow edge
#

why is spigot SO eazy?

tender shard
#

the configuration for the output must go inside the maven-jar-plugin

#
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <version>3.1.0</version>
  <configuration>
    <outputDirectory>C:\mctest\plugins</outputDirectory>
    <finalName>MyAwesomePlugin</finalName>
  </configuration>
</plugin>
mellow edge
#

searching in minecraft decompiled client code is hard as fu**

prisma steeple
#

IT WORKS

#

I fixed it

cerulean charm
#

Hello there! Im kinda new in the spigot plugin development.
I have a problem with detecting a player right clicked another player with a specific item.

I know the two events PlayerInteractEvent, PlayerInteractEntityEvent but i dont know how to link them each other.

public void onPlayerSelect(PlayerInteractEvent event, PlayerInteractEntityEvent e) {
        if (event.getAction().equals(Action.PHYSICAL) && event.getItem() != null && event.getItem().getItemMeta().equals(ItemManager.telegem.getItemMeta())) {...}

I tried this but I got an error
[22:06:13 ERROR]: [Hg-Core] Hg-Core vBeta-1.0.1 attempted to register an invalid EventHandler method signature "public void hu.hugaming.hgcore.events.teleportGem.onPlayerSelect(org.bukkit.event.player.PlayerInteractEvent,org.bukkit.event.player.PlayerInteractEntityEvent)" in class hu.hugaming.hgcore.events.teleportGem

tender pond
tender shard
tender shard
tender pond
#

Even after Loading Maven Changes

cerulean charm
tender shard
tender shard
iron glade
#

Do I have to worry that I don't have a maven jar plugin in my pom?

iron glade
#

remove the 2nd

sterile token
#

On listener, 1 method listen to 1 event

tender pond
#

Nvm it says that on the Blog post

#

My bad

tender shard
#
public void myMethod(ItemStack item) {
...
}

@EventHandler
public void onFirstEvent(SomeEvent event) { myMethod(event.getItemStack()); }

@EventHandler
public void onAnotherEvent(AnotherEvent event) { myMethod(event.getItemStack()); }

@cerulean charm

tender shard
cerulean charm
tender shard
#

np

tender pond
quaint mantle
#

trying to use Scoreboard teams for Prefixes but im 100% doing something wrong idk what tho

lean osprey
#

Hey guys! Basically I got some soft-dependencies and from any reason my plugin is loaded before the actual dependencies

iron glade
#

there's a thing called loadafter

#

or smth like that

sterile token
lean osprey
#

πŸ˜„

#

explanation of softdepend: A list of plugins that are required for your plugin to have full functionality.

#

Your plugin will load after any plugins listed here.

#

But I dont really know why it doesnt work

humble tulip
#

I dmed a guy something that works

quaint mantle
iron glade
granite owl
#

why does attempting to retrieve the color from PotionMeta from a valid

#

potionmeta result in a nullptr error

lean osprey
humble tulip
#

?paste

#

?paste

#

Wtf

#

Hello

quaint mantle
#

@humble tulip dm me that lol

humble tulip
#

@undone axle

tardy delta
lean osprey
tardy delta
#

that they specified in their plugin.yml

delicate lynx
lean osprey
lean osprey
#

its being loaded before ModelEngine

granite owl
#
PotionMeta meta = (PotionMeta) potion.getItemMeta();
            
this.red = meta.getColor().getRed();
this.green = meta.getColor().getGreen();
this.blue = meta.getColor().getBlue();
```from a valid Potion ItemStack, why does this result in a nullptr error in the console log?
delicate lynx
#

which part

humble tulip
#

Does it have a color?

granite owl
#

PotionMeta.getColor() returns null

#

for some reason

delicate lynx
#

Plugins should check that hasColor() returns true before calling this method.

granite owl
#

but potions always have colors dont they

delicate lynx
#

apparently not

granite owl
#

where do vanilla potions get their color from then?

#

okayive just used hasColor

#

apparently vanilla potions have no color?

#

why not lol

glossy venture
#

how can i do something async, and then when its done doing the task have all data in the class be synchronized immediately

imagine if i have a class

class Data {
    boolean loadComplete;

    int x, y, z;

    void loadAsync() {
          threadPool.execute(() -> {
               // do some expensive loading task
               // now i want to synchronize all the data
               loadComplete ();
          });
    }

    synchronized void loadComplete() {
         loadComplete = true;
    }
}
patent horizon
#

how do i cast an integer to a double? blind casting isn't working

tardy delta
#

(double)

patent horizon
#

yea i tried that

granite owl
#

double d = (double) whatever

patent horizon
#

oh oops

#

i wasnt using primative

granite owl
#

u need to use the constructor if ur using complex classes

tardy delta
cerulean charm
glossy venture
#

i dont want to synchronize all accesses

tardy delta
#

what Β―_(ツ)_/Β―

#

anyways if i wanted to get some annotation with #getAnnotation what retentionpolicy does it need to have?

#

CLASS i think

prisma steeple
#
 public void BlockPlaces(BlockPlaceEvent event) {
        Player player = event.getPlayer();

if i have this

#

and 2 people place a block

#

what happens

tardy delta
#

nothin

prisma steeple
#

oh

#

they are local to the player?

tardy delta
#

two different events are fired

prisma steeple
#

Ahh when you explain it like that it makes much more sense

tardy delta
#

that player variable refers to the player who played the block

tender shard
tardy delta
#

and will be executed for each blockplace

prisma steeple
humble tulip
#

It's also single threaded so 2 ppl can't place a block at once

prisma steeple
#

no i mean it when that variable is taken up

humble tulip
#

Ohhh

prisma steeple
#

and someone else places a block

sterile token
tender shard
prisma steeple
#

yes

#

mojang noob

tardy delta
tender shard
tardy delta
#

ye but whats the retentionpolicy then?

tender shard
#

oh that's what you mean

tardy delta
#

"how long the annotations are to be retained" doesnt tell me much

tender shard
#

erm tbh not sure. SOURCE is definitely not visible anymore, I think for CLASS it's kinda unspecified. It simply says "need not be retained by the VM" but not that it will definitely discarded

tender pond
#

Hey guys can anyone help with this? I'm very confused... So I'm basically getting a string and sending it through this system, and just to confirm I'm posting the string to make sure it's 100% correct before this if statement.

So for some reason this is entering the if statement even when only using Letters and no numbers for some weird reason, and I have no clue why as I'm pretty sure the regex works

tardy delta
tender shard
sterile token
tardy delta
#

lets find out

tender pond
mighty pier
#

is it possible to send the player turning red death animation when the player hasnt died?

sterile token
prisma steeple
#

how to get player XYZ levels

tender pond
tardy delta
tender shard
#

then it'll work

tender pond
tender shard
tender shard
# tender pond
        "2asd".matches("[a-zA-Z]+") -> false
        "âÀü".matches("[a-zA-Z]+") -> false
        "asd".matches("[a-zA-Z]+") -> true
#

I just tested this

tender pond
#

Cause I'm basically including it under the .onComplete() thing

sterile token
#

Any simple code for genereting random codes with numbers and letters?

tender shard
tardy delta
tender pond
#

Will strip colors just to make sure though

tender pond
#

Still not working

tender pond
tender pond
#

πŸ˜‚

tender shard
nova sparrow
#

How would one start a raid in the spigot api?

tender shard
#
    private static final char[] CHARS = "abcdefghijklmnopqrstuvwxyz0123456789".toCharArray();

    public static String getRandomString(int length) {
        char[] chars = new char[length];
        for(int i = 0; i < length; i++) {
            chars[i] = getRandomChar();
        }
        return new String(chars);
    }

    private static char getRandomChar() {
        return CHARS[ThreadLocalRandom.current().nextInt(CHARS.length)];
    }
sterile token
#

Oh ok

tender shard
#

there doesn't seem to be a way

#

oh

#

wrong reply

tender shard
sterile token
#

What yor issue?

tender shard
#

what is that supposed to do btw?

#

what is a PacketType.Status.Server.OUT_SERVER_INFO ?

sterile token
#

Allright, if doesnt work jut wait until somene help, open a thread on this channel or ask on ptclib discord

#

I cannot send their discord link

#

Ok

#

1 sec

tender shard
#

why do you use protocollib for that

#

RIP

#

it also exists in 1.12.2

#

you can

#

I know

#

that's from the 1.12.2 javadocs

#

ugh well this is from 1.19, I wonder why it exists if it's always just throwing an exception

#

very weird lol

naive bolt
#

its jeff media im in your server

#

Nice

tardy delta
#

all the Player.Spigot methods are throwing an unsupportedexception too arent they?

tender shard
tender shard
#

Player.spigot() is for example to send basecomponent msgs

late sonnet
tardy delta
#

but they are implemented i guess

#

mmh

late sonnet
#

i remember when make the PR for support the hide player info for ping things...

tender shard
late sonnet
#

not sure why...
sounds confuse but that is how works..

tender shard
#

lmao that's really... weird

#

I'm sure there is SOME reason for this

quaint mantle
#

hey guys I've been struggling at finding a working answer on how to do tool durability

tardy delta
#

creating a class in a method brr

tender shard
#

cast the ItemMeta to Damageable, set the damage, then set back the itemmeta

quaint mantle
#

I tried

#

I don't know why it's red

tender shard
#

then hover over it and read it

quaint mantle
#

it cannot resolve the method

tender shard
#

which method?

quaint mantle
#

setDamage

tender shard
#

wrong import

#

you imported org.bukkit.entity.Damageable

#

but you have to import org.bukkit.inventory.meta.Damageable

quaint mantle
#

is this done correctly?

#
            ItemMeta tempPick = inHand.getItemMeta();
            (Damageable) tempPick.setDamage(tempPick.getDamage() - 1);
            inHand.setItemMeta(tempPick);```
tender shard
#

no, that's not even valid syntax

tardy delta
#

((Damageable)meta).setDamage

#

wait no

#

wait yes

#

its too late for me

tender shard
#
Damageable meta = (org.bukkit.inventory.meta.Damageable) inHand.getItemMeta();
meta.setDamage(meta.getDamage() - 1);
inHand.setItemMeta(meta);
tardy delta
#

i wanted to say that but my brain was like meh you need sleep

#

🀀

quaint mantle
#

when casting do I have to put the whole import?

tardy delta
#

na

quaint mantle
#

I imported it at the top

tardy delta
#

only make sure you got yhe right one

quaint mantle
#

maybe I'm doing something wrong

#

instead of taking damage it just repairs the item?

eternal oxide
#

damage goes up not down. 0 = no damage

quaint mantle
#

so should I add instead of subtract?

tardy delta
#

setting a negative damage wouldnt make much sense for me

#

idk if it works like that but ye

quaint mantle
#

I want it to just be as if the pickaxe mined a block

#

but I have to cancel the event so it's not taking damage

#

ok it works

#

thank you guys

#

I just tested and it kind of works

#

it bypasses unbreaking enchants

tender shard
quaint mantle
#

how would I go about doing it?

tender shard
#

otherwise you'd be ignoring vanilla and/or custom enchantments, etc bla bla

quaint mantle
#

where is JeffLib.getRandom() defined?

tender shard
#

it's just an instance of Random

#

just do ```java
private static final Random random = new Random();

quaint mantle
#

alright it works great

#

thanks again

tender shard
#

np

quaint mantle
#

:3

eternal oxide
#

implement ConfigurationSerializable

#

and do everything its Javadoc says to do

native nexus
#

Or simple use gson

eternal oxide
#

gson will not serialize a Location

#

Both require additional steps to serialize

#

So just use teh one thats already coded for you in Bukkit

#

yes

vocal pine
#

was able to figure out stuff from earlier :) custom entity using its own id that client sees as a minecart πŸ‘

#

just feels a bit less janky than the workarounds to respawn a custom entity
no idea if it's more practical or can do anything the ones using another's ID/EntityType cant

eternal oxide
#

if you correctly implemented CS and did as teh Javadoc says and register your Class.

#

In addition to implementing this interface, you must register the class with ConfigurationSerialization.registerClass(Class).

#

in your onEnable, or anywhere before you attempt to read from yrou config

#

nope

tender shard
eternal oxide
#

that is the data you are going to build your object with

tender shard
#
public class Person implements ConfigurationSerializable {
    
    private final String name;
    private final int age;

    public Person(final String name, final int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public Map<String, Object> serialize() {
        Map<String,Object> map = new HashMap<>();
        map.put("name",name);
        map.put("age",age);
        return map;
    }
    
    public static Person deserialize(Map<String,Object> map) {
        String name = (String) map.get("name");
        int age = (int) map.get("age");
        return new Person(name, age);
    }
}

#

and in your onLoad:

ConfigurationSerialization.registerClass(Person.class);
eternal oxide
#

Location is already serializable so you can use map.put("location", location.serialize())

tender shard
#

no need to call serialize

eternal oxide
#

um, true, it will be retained as an object and serialized when needed

tender shard
#

actually if you use serialize() yourself then it will be stored as map so you won't know what to deserialize it to again

#

because it will be missing the "==" field in the yaml or whereever it is stored

eternal oxide
#

oh yeah

ivory sleet
#

So quick question, does anyone here use sth like
(++i)++ as opposed to i+=2