#help-development

1 messages · Page 1868 of 1

mellow comet
#

and how?

ivory sleet
#

explain what you mean

#

Team::getEntries

#

it will return a set of strings

mellow edge
#

will this get online or offline players?

ivory sleet
#

it will get all registered strings to the team

#

for instance a team can contain the "player name" $ or sth

mellow comet
mellow comet
ivory sleet
mellow edge
#
                        a.forEach((offlinePlayer -> {
                            Player plr = offlinePlayer.getPlayer();
                            if(offlinePlayer.isOnline()) {
                                plr.sendTitle(ChatColor.DARK_RED + "BED DESTORYED", "", 123, 6000, 123);
                            }
                        }));```
#

i did that

tardy delta
#

what's the point of the user factory when it's every time User::new?

#

also i dont understand why using an Optional 😄

young knoll
#

Optional is nice

#

Because you can chain ifPresent

spiral light
#

has anyone an idea on how to prevent stackoverflowerror while replacing all lava in a chunk with air ?

mellow comet
tardy delta
#

yea but in this case idk

spiral light
ivory sleet
#

it makes it more explicit that the return type might intentionally be null

#

thats to decouple User creation from instantiation (the factory)

#

but probably unnecessary

solid cargo
#

is there any plugin that rigs your tps? i need to test my plugin on low tps

ivory sleet
#

I mean the rigging the visual tps wont do anything

#

however if you wanna rig the tps, could just use Thread::sleep

solid cargo
#

i want the server to act like 15 tps

#

any simple plugin to do that?

hybrid spoke
solid cargo
#

ehh ok

ivory sleet
#

hmm unsure actually and yeah probably a question for the hs channel

buoyant viper
#

is there a way to make sure ur plugin gets unloaded last

solid cargo
#

lets move over there

tardy delta
#

conclure, what do you mean with humblestorage (that makes the most sense of those two) and delegatingstorage?
the first one is the super type where the second one is designed for more specific uses?

chrome beacon
tardy delta
#

also i havent thanked you 💗

ivory sleet
tardy delta
#

ah in that way

ivory sleet
#

then we have a wrapper which just incorporates and wraps it around a future

olive lance
#

i feel like if it was a depend in spigot then it would handle accordingly in unloading but nothing says that specifically

ivory sleet
#

its quite a good practice to avoid poor concurrency and multithreaded designs

#

of course you shouldnt follow it blindly like any good practice but yeah

urban bramble
spiral light
tender shard
#

Statistic.html#TIME_SINCE_REST

#

returns the time in ticks, right?

#

I know I could just check it but I thought maybe someone knows

urban bramble
spiral light
tender shard
#

hm

#

Ill have to check it then 😄

spiral light
spiral light
lone jacinth
tender shard
spiral light
#

there should be an value in the player data for that too ^^

urban bramble
urban bramble
#

I really want to, but constraints and how stupid the idea I'm working on make that impossible

spiral light
lone jacinth
spiral light
urban bramble
#

I want it to support multiple versions

#

and I'm way to lazy to use reflection

tender shard
spiral light
urban bramble
#

anyway, it seems like the API should do what it promises to do

#

instead of straight up lying

vale ember
#

will there be an exception if i try to unregister listener via HandlerList.unregisterAll(Listener), if listener isn't registered?

urban bramble
#

maybe I'll make a spigot PR

spiral light
#

also sadly generating worlds in nms is a lot faster then using api ^^

lone jacinth
spiral light
#

i wish i had an idea to get where structures ended and need more generation if the chunks load ^^

sacred mountain
#

can anyone help create some code for me? I need a small snippet of pseudocode made in java.

spiral light
sacred mountain
#

?

spiral light
#

you want pseudocode but dont describe about what

#

noone will know if he can do this for you since the task is unclear

sacred mountain
#

when a player places bucket of liquid:
add location to list
if it gets removed by the plugin regen, remove it from the list
if it gets picked up again, remove it from the list
if it gets blocked by a block then remove it from the list
on pickup water, check if water location is in list of player placd water, if it is then return? and if it sint then cancel and send a message "You can only pickup liquids placed by a player•

spiral light
#

you bassically look for
PlayerBucketFillEvent and PlayerBucketEmptyEvent
and also BlockPlaceEvent

tender shard
sacred mountain
#

since im used to python more

#

how would i add and remove coords from a list

#

or a storage method

visual tide
#

theList.add(location)

sacred mountain
#

and to check it to a playerbucketfill event would be something along the lines of

if pla yer bucketfill location is in mylist

visual tide
#

well check if the list contains the location

sacred mountain
#

or would i have to loop it to check

tender shard
sacred mountain
#

in visual basic i do smn like

for c in mylist:
if location = c

visual tide
#

block location then

sacred mountain
tender shard
tender shard
bitter fulcrum
#

Are there any ways to perform bytecode modification

visual tide
#

asm

sacred mountain
#

can you share it?

#

or how to store coords instead of exact locations

bitter fulcrum
visual tide
#

as dependency

bitter fulcrum
#

Alright

tender shard
# sacred mountain can you share it?
package de.jeff_media.test;

import org.bukkit.Location;
import org.bukkit.World;

import java.util.Objects;

public class SimpleLocation {
    
    private final int x, y, z;
    private final World world;

    @Override
    public String toString() {
        return "SimpleLocation{" +
                "x=" + x +
                ", y=" + y +
                ", z=" + z +
                ", world=" + world +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SimpleLocation that = (SimpleLocation) o;
        return x == that.x && y == that.y && z == that.z && world.equals(that.world);
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y, z, world);
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getZ() {
        return z;
    }

    public World getWorld() {
        return world;
    }

    public SimpleLocation(Location location) {
        this.x = location.getBlockX();
        this.y = location.getBlockY();
        this.z = location.getBlockZ();
        this.world = location.getWorld();
    }
}
bitter fulcrum
#

Do I need to include it in the jar?

visual tide
#

yes

tender shard
#

Just wrote it new, I didnt find the original one lol

sacred mountain
#

ur quick

tender shard
#

you can now just do SimpleLocation simpleLoc = new SimpleLocation(location)

#

then compare them using equals()

sacred mountain
#

so how would i yse that

#

to chdck where a player placed

#

water

#

do i use the playerbucketfill thing to

glossy marsh
#

Hello! I've got a question. I have a plugin in which you can craft custom clocks which have an enchantment attached to them, these clocks have a different colored name when you craft them (the name is green). If you go to an anvil and rename the clock the color of the name will turn to blue instead of green. Is there an easy way to keep the color of the name of the renamed item green (also in the suggested name part of the anvil?)

sacred mountain
#

i think thats texturepacks

#

maybe im wrong but i dont think plugins can change colors of items

visual tide
glossy marsh
sacred mountain
#

ohh

#

translatealternatecolorcodes?

visual tide
sacred mountain
#

okay nvm lmao

glossy marsh
visual tide
#

not sure what you mean with name suggestion part

lethal knoll
#

If I would iterate over all worlds using bukkit.getWorlds() , is that going to be acceptable in terms of performance?
more specific this:

        for(World world: Bukkit.getWorlds().stream().filter(this.sleepService::isEnabledAt).collect(Collectors.toList()))

If I do that every second

glossy marsh
lethal knoll
#

if I do that every second*

visual tide
glossy marsh
misty current
lethal knoll
misty current
#

yes

#

we live in 2021

lethal knoll
#

Alright, thanks for the info

#

Yea, but sitll

misty current
#

computers are not doo doo

lethal knoll
#

I tried to think of different solutions

#

But there is no for now

visual tide
#

on the context

fathom cobalt
misty current
#

most people tend to underestimate modern computing power

lethal knoll
#

yea well

visual tide
#

define modern

glossy marsh
#

Is it possible to upload a video in this channel?

fathom cobalt
lethal knoll
#

I have no idea how heavy it can be

visual tide
#

is a 2018 mac modern?

misty current
#

i'm not saying modern computers can execute any calculation instantly but

lethal knoll
#

Alright, great 🙂

misty current
#

sure they can make pretty hard ones in matter of milliseconds

lethal knoll
#

I'll run it every 20 ticks and I should be good

#

AIght, thanks!

misty current
#

example, i had a plugin that had to check when a player entered or left a custom claim zone

#

there was like a claim block that had a certain radius

#

so on entity move i looped all of these claim blocks

waxen plinth
#

And you did spatial partitioning, right?

#

Oh boy

#

That's not good at all

misty current
#

checked the bounds

#

it was probably not the best way but with 50+ players it had a minimal impact on performancew

#

because all it did was basic math at its core

waxen plinth
#

It's O(n*m) with n players and m claims

misty current
#

more like O(n) where n is the sponges per each player movement

#

in worst case scenario

waxen plinth
#

Might not be terribly problematic until you realize that since the number of claims is directly related to the number of players, it's essentially O(n^2)

#

Talking about per tick here

#

Because player movement is processed once per moving player per tick

misty current
#

iirc player move events can be called multiple times per tick

#

so it might have been even worse

waxen plinth
#

And it's incredibly easy to set up spatial partitioning for that

misty current
waxen plinth
#

Basically this

glossy marsh
#

I made a video to show what I mean. If you rename an enchanted golden apple the suggested name remains pink/purple, whereas if you rename an item with a custom name and a custom color the color will just change to white again. I was wondering if there was some kind of NBT tag which sets the color name of an item causing the golden apples name to remain purple when suggested

waxen plinth
#

Basically just a map for approximate location -> things near that location

visual tide
waxen plinth
#

So you can quickly determine what is near a location and do your extra checks from there

glossy marsh
#

😦

misty current
#

getting the subsection a player is in

visual tide
#

as i said you could listen for anvilPrepareEvent, if it's the item you want to keep the color on, strip all color off with ChatColor.strip and then recolor the stripped new name

misty current
#

and then checking the elements in that subsection

#

yeah that sounds much more efficient

glossy marsh
solemn aurora
#

Hey everyone, I'm stuck on an issue regarding villager trades.
I spawned in a villager with custom trades (diamond for a book).
It does spawn and behaves like a normal villager but when I want to trade the screen shows up for a couple of milliseconds and then disappears.
Does anyone happen to know what might cause this?

chrome beacon
#

What version of Spigot?

solemn aurora
#

for 1.18

spiral light
#

maybe the trade screen will close if the villager has no job or smth

solemn aurora
#

I tried giving it a profession but then it just shakes it head

#

I found the solution.
The vilager checks on spawn if there is a profession block nearby. If not it just reverts to a normal villager.
Somehow normal villagers are not allowed to trade anymore but by setting the experience to an arbitrary value it stays as the profession.

#

setting the level works too

proud basin
#

Anyone know if FileWriter creates a file when when you instantiate it?

waxen plinth
#

Doubt it, but check the docs

#

Why are you using FileWriter though?

proud basin
#

because it's the best

#

and

waxen plinth
#

I prefer nio

proud basin
#

I need to use it

waxen plinth
#

Files.writeString

buoyant viper
#

i believe it only creates once u call .write

buoyant viper
#

it does lack the ability to directly write bytes tho iirc

#

ig it makes up for that by having .newBufferedWriter

waxen plinth
#

Pretty sure you can write bytes directly but I could be wrong

buoyant viper
#

iirc theres no writesBytes or plain .write

#

im also just kinda browsing its javadoc rn

dense heath
waxen plinth
waxen plinth
dense heath
waxen plinth
#

It's mapping things spatially so you don't have to iterate over everything to find an object near a given location

#

The concept is the same

dense heath
waxen plinth
#

It's not a k-d tree but it doesn't need to be

dense heath
buoyant viper
waxen plinth
#

And yes, the concept is the same

dense heath
waxen plinth
#

To split things up based on approximate location to make it easy to find them

dense heath
#

It is log2(n)^2 * x * z insertion efficiency

#

Not even close to how good a k-d tree is

waxen plinth
#

x and z being what

dense heath
#

The size of the square you define

#

I didn't see any support for a third dimension in your implementation

buoyant viper
#

oh im dumb it's right there

waxen plinth
#

Yeah it uses x and z only since the y axis is so tight

dense heath
waxen plinth
#

But insertion is O(1)

dense heath
#

Definitely not

waxen plinth
#

How not

#

It determines where to insert, with simple division, O(1)

#

Then inserts into a set, also O(1)

dense heath
#

A hash set

#

The insertion time for hash sets and hash maps are longer

waxen plinth
#

Yes a hash set has O(1) insertion too lol

dense heath
#

That's bullshit

waxen plinth
#

Bruh

hybrid spoke
#

its not

waxen plinth
#

It's literally how it works I don't know what you want me to say

#

Look it up

young knoll
#

"For HashSet, LinkedHashSet, and EnumSet the add(), remove() and contains() operations cost constant O(1) time."

waxen plinth
#

Hashing an element is O(1)

#

And the array write is O(1)

#

So inserting an element into the region map is O(1)

dense heath
#

I got to go fact check this right now, I'm looking at the implementation

waxen plinth
#

Lmao

dense heath
#

I might actually be retarded

#

There is a chance here

waxen plinth
#

I have literally implemented these days structures before and it's common knowledge that insertion is O(1)

#

That's the entire point of hash sets/maps

dense heath
waxen plinth
#

This region map is not as precise as a k-d tree but it's good enough for the vast majority of use cases

dense heath
#

This is so factually incorrect

#

I have checked the implementation

waxen plinth
#

.-.

dense heath
#

You would expect the average insertion time to be O(1)

hybrid spoke
#

dont feed the troll

waxen plinth
#

Yes worst case is O(n)

dense heath
#

But the worst case insertion time will be O(n)

waxen plinth
#

Just like quick sort has a worst case of O(n^2)

dense heath
#

Always operate your assumption of efficiency on the worst case

waxen plinth
#

But you don't call quick sort an O(n^2) algorithm

#

You fucking dingus

dense heath
#

That's what it is.

waxen plinth
#

...

dense heath
#

Expected may be better *, but it is still at that level.

waxen plinth
#

Quick sort is only O(n^2) if it picks the worst possible pivot every single time

#

The odds of that happening for a large data set are so astronomically low

dense heath
#

but never zero

waxen plinth
#

Much like the odds of a hash collision on every element are astronomically low

#

If you're worried about that you should worry about me mashing random buttons on a keyboard and guessing your password first try

dense heath
#

Regardless, O(n) on the hashset, O(n) on the hashmap, x*z for the insertion on every single address

waxen plinth
#

Or getting struck by lightning whenever you go for a walk

#

Or a UUID collision every time you use UUID.randomUUID()

dense heath
#

Or having a Minecraft developer be a capable individual >:)

waxen plinth
#

We call it O(1) because that's what it's always going to be unless you got odds better than winning the lottery multiple times in a row

waxen plinth
#

So please understand why you come across as insufferable when screaming "FACTUALLY INCORRECT" in the face of common knowledge

#

I'm going to call my region map O(1) on insertion because under all reasonable circumstances that's what it is

dense heath
#

I'll take the L and admit that I'm retarded with most of my claim, but I'm not going to set the fact down that what you have made is, in fact and reality, not a spatial partitioning algorithm.

#

You are inserting objects into a hashmap, that's not partitioning at all.

waxen plinth
#

If you have 100k elements in your HashMap, the odds of them all having colliding hashes and the runtime being O(n) is 1 in 100k^100k, an unfathomably small chance; you'd have better odds of picking a random particle in the observable universe and having it be the same particle 3 times in a row

#

And yes, this is a form of partitioning

dense heath
#

Factually incorrect

waxen plinth
#

It's one way of dividing up the space and mapping objects within it

dense heath
#

"wow look at these buckets! partitioning!"

waxen plinth
#

Yes, it's partitioning

#

Cry about it

dense heath
#

You're simply not partitioning anything at all

waxen plinth
#

It divides the space into equally-sized parts

#

It's partitioning

#

Chunks are a form of spatial partitioning

#

Quit being a pedant

dense heath
#

This is simply not some silly little thing, though

#

You're using a hashmap and calling it spatial partitioning

#

There is no elegance there

waxen plinth
#

How not

dense heath
#

That's not an algorithm, dude

waxen plinth
#

It doesn't need to be "elegant" to be spatial partitioning

#

And sure it is

dense heath
#

You're making a map wrapper

waxen plinth
#

Everything is an algorithm

#

Yeah

#

I am

dense heath
#

You have successfully made a map wrapper

waxen plinth
#

Again, cry about it, it's spatial partitioning

dense heath
#

Definitely not

waxen plinth
#

It's not like I'm claiming something super impressive

dense heath
#

Do you think Google is using hashmaps to position things in their pathfinding algorithms?

waxen plinth
#

I'm claiming to have made something which partitions a space by subdividing it

#

Which is true

dense heath
#

You haven't subdivided anything at all, though

waxen plinth
#

Yes I have

#

It subdivides worlds into equally-sized horizontal regions

dense heath
#

LMAO

#

No way that you're going to tell me using an integer coordinate system is subdividing the space

waxen plinth
#

Chunks work very similarly

#

And that's also spatial partitioning

waxen plinth
#

It literally is lmao

dense heath
#

"The world is a partitioned space because of the atoms in it"

#

Same level brain assertion

waxen plinth
#

I'm grouping areas

dense heath
#

No, no you aren't

waxen plinth
#

PARTITIONING them into horizontal regions

sacred mountain
#

r

waxen plinth
#

Where do you get off?

#

Why are you being an elitist about the pettiest thing

#

This is one way of doing spatial partitioning

#

All you're doing is being an asshole here

dense heath
#

Okay, I'll play along here.

#

Let's say this is spatial partitioning

#

Give me all of the areas associated with a certain group.

ivory sleet
#

whats up

waxen plinth
#

Hi conclure

dense heath
#

For instance, I say that coordinates (10, 10) to (20, 20) belong to some string, "A"

ivory sleet
#

hello Red

waxen plinth
#

Care to tell this guy to quit being a pedantic condescending asshole?

ivory sleet
#

hmm well surrounding what?

dense heath
ivory sleet
#

or yk Ill just read for myself

waxen plinth
dense heath
ivory sleet
#

btw

waxen plinth
#

Sure

ivory sleet
#

big O notation only denotes worst time complexity

dense heath
#

^^^^^^^^^^^^^^^^^^^^^^

buoyant viper
#

@waxen plinth r u as sexy as redlib is?

ivory sleet
#

I mean bk that was to you

waxen plinth
#

You generally refer to average case when talking about these things but sure

dense heath
#

:thonk:

#

O(N) is worst time complexity for a hashset

waxen plinth
#

We never consider quick sort as n^2

waxen plinth
buoyant viper
#

idk i like women

#

nice pillow

#

is that from uhhh

#

i forget the name

ivory sleet
#

Big O notation means worst time complexity
theta notation means average
omega notation means best

waxen plinth
#

Atla

ivory sleet
#

so saying average O(blah) is kinda wrong

tender shard
buoyant viper
#

what

hybrid spoke
#

This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets

ivory sleet
#

anyways O(1) for insertion, contains and removal iirc

waxen plinth
#

Kinda but it's what everyone does because nobody wants to type theta

#

Ye

ivory sleet
#

idk why u'd say O(n) insertion

quaint mantle
#

Hey, Does anyone know what the DataWatcherObject id of customNameVisible boolean is? (1.18.1)

buoyant viper
#

wait red what r yu

ivory sleet
#

sure, the internal array must be resized from time to time

waxen plinth
#

He/him

buoyant viper
#

oh oki

waxen plinth
#

Well the technical worst case would be if all the hashes collide

#

So everything ends up in the same bucket

ivory sleet
#

yeah

waxen plinth
#

That would be O(n) but is so insanely unlikely that there's no use worrying about it

ivory sleet
#

yeah

young knoll
#

Are you saying I shouldn’t just return 1 for my hash codes

waxen plinth
#

lol

#

Technically a valid hash function

ivory sleet
#

insertion might be O(n) also if we consider bucketing

buoyant viper
#

yo mama so fat, sorting her is O(2^n)

quaint mantle
#

🙄

waxen plinth
#

Anyways the main argument was about whether my basic region map implementation is spatial partitioning

#

He says it's not when it's literally subdividing a space, which is what partitioning means

dense heath
waxen plinth
#

You're dividing it up

#

Much like chunks do

#

And again, chunks are another form of spatial partitioning

buoyant viper
#

isnt subdividing dividing the divisions? 🤔😎

waxen plinth
#

I don't know why that is so hard for you to grasp

quaint mantle
#

How to check if a player is flying on elytra or with a fly?

waxen plinth
#

What

dense heath
waxen plinth
#

Oh elytra

buoyant viper
#

how to tell if flight is isFlying or elytra

waxen plinth
#

isGliding vs isFlying

quaint mantle
#

thanks

waxen plinth
# dense heath We're bordering on spherical brain level ideas at this point

Look, you're just being so condescending for no reason. Grouping nearby objects together in equally-sized regions is spatial partitioning, and if the definition of partition doesn't convince you then I don't know what will. You're really getting on my nerves by being so pedantic about it, especially screeching FaCtUaLlY iNcOrReCt like it helps your case

solid cargo
#

anyone has an experience in the plotSquared API here? which event do i use to check if the player is trusted?

tender shard
#

event? there's some method for that

#

I also have a class for PS4 and PS5

solid cargo
#

now tell me where lol

tender shard
#

check the class I sent

solid cargo
#

ok

tender shard
#

it uses reflection though

#

because I didnt know any better back then

solid cargo
#

my client is on p^2 v5 tho

#

same thing?

tender shard
#

then check the other class

#

as said I have classes for PS4, 5 and 6

waxen plinth
#

That's the opposite of spatial partitioning

#

That would be a Map<String, Set<Location>>

#

Mine lets you get objects of an arbitrary type mapped near a given location

#

And I don't want your money

dense heath
#

If I insert a box I ought to be able to figure out where the box is later

waxen plinth
#

A reverse map is a separate thing

vale ember
#

Required type:
capture of ? extends Event
Provided:
PlayerInteractEvent

#

whyyyyyyyyyyyyyyyy

ivory sleet
#

yeah areg

#

whats the code behind that

#

pretty sure we can solve it

vale ember
#

package com.aregcraft.delta.item;

import lombok.NonNull;
import org.bukkit.event.Event;

@FunctionalInterface
public interface EventConsumer<T extends Event> {
void handle(@NonNull final T event);
}

ivory sleet
#

and then?

vale ember
#

package com.aregcraft.delta.item;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;
import org.bukkit.event.Event;

import java.util.List;

@Getter
@AllArgsConstructor
public class TypeInteractionHandler {
@NonNull
private final List<EventConsumer<? extends Event>> eventConsumers;
}

radiant estuary
#

How can i get tools that work like the Elytra? they stop at durabilty 1 and are then unuseable?

ivory sleet
#

EventConsumer<? extends Event> makes no sense

vale ember
#

why

ivory sleet
#

well any class with a generic type parameter is a type of a type constructor

#

Lets say we construct the type EventConsumer<Event>

#

this type is different from EventConsumer<PlayerEvent>

#

(just as an example)

#

usually when we have consumers we are callbacking on a specific argument

#

in this case an instance of Event

#

if you have ? extends Event

#

it means any a capture of any subtype of Event

#

now if we had ? super Event it'd make more sense, as you'd be able to pass an EventConsumer<Object>

opaque plaza
#

is there a way to get the full nms source code with the mojang mappings

ivory sleet
#

if you have an EventConsumer<PlayerEvent> an instance of this type might do operations only the type PlayerEvent would support

#

so then its very risky to pass an object to an EventConsumer<? extends Event> as you don't know which subtype is the correct one

quaint mantle
#

how to check if the player is rotating the mouse?

ivory sleet
#

So your design might be a bit flawed in this case

quaint mantle
#

@ivory sleet

ivory sleet
#

PlayerMoveEvent maybe

#

idk if there are more suitable events for that tho

quaint mantle
#

I use PlayerMoveEvent

ivory sleet
#

alr

#

well check if the location's x,y and z are the same

quaint mantle
#

When I go, I get a message

opaque plaza
ivory sleet
#

but if the yaw and pitch are different

opaque plaza
#

which is obfuscated

ivory sleet
quaint mantle
#

thanks

opaque plaza
ivory sleet
#

oh idk then

#

maybe elgar or mfnalex can help ya

opaque plaza
#

but I can use gradle too

ivory sleet
#

ok

#

then you'd stick with paperweight-userdev plugin probably

eternal oxide
#

--generate-source --remapped

#

switches for BT

north trench
#

i still do not know? can you help?

#

nothing works i am using PlayerInteractAtEntityEvent event

lucid bane
north trench
#

Yes

opaque plaza
eternal oxide
#

there are no spigot mappings in 1.18

lucid bane
lucid bane
sacred mountain
#

it looks like the other gui is ontop of that gui

#

and the whole screen darkes

#

is that gui a texture? the diamond hoe one

spiral light
sacred mountain
#

because when you open your inventory maybe it darkens everything around it including the diamond hoe texture

lucid bane
sacred mountain
#

its not anythingn to do with plugins or code tho

lucid bane
proud basin
#

How can I grab every single line in a text file with bufferedreader?

#

oh wait

#

nvm

#

got it

tardy delta
#

split it by \n would be my guess

solid cargo
#

how can i check if the plotsquared player is trusted?

late sonnet
solid cargo
mental moon
#

What event gets called when a block is broken by forces other than the player? Like Water breaking a torch.
BlockBreakEvent and BlockDropItemEvent are only fired when the Player triggers them.

misty current
#

hey @wet breach, sorry for the ping but i wanted to ask where could I find a version of packetentityapi for 1.8. I have tried to use the latest legacy release i was able to find (0.7.2) but it won't launch because it has inside stuff from later versions. I'm asking because i saw on the spigot page that 1.8 is supported (ping me back when u can reply)

mental moon
woeful crescent
#

does entity.remove() call entitydeathevent?

mental moon
#

I don't believe so

woeful crescent
#

if an armor stand is riding an entity

#

and the entity gets .remove()'d

#

what happens to the stand?

mental moon
#

i would assume it would be dismounted and left there, but it could also get deleted

woeful crescent
#

hmm

mental moon
#

check for passangers, dismount, then remove

woeful crescent
#

when tho

#

idk

quaint mantle
woeful crescent
#

i wanna set armor stands on entities without inserting a line after every time .remove() is called

#

that's not very dynamic

mental moon
#

something like if(ent.getPassengers.size != 0){ do a thing }

quaint mantle
#

Also, you shouldnt execute code in constructor like you do with insertQueryAsync - you just create the object

woeful crescent
mental moon
#

It would be a check before the remove. If you want it to call a death event you can instead do livingEnt.damage(9999)

#

or maybe there's a kill too

quaint mantle
#

I also would remove insertQuery async at all. Database mamanger shouldnt throw async tasks by itself.

#

is there a way that online players can be hidden from tab complete and commands, so that even vanilla commands would not be able to target them?

spiral light
#

is there something to check (packets or api) if a player wants to move a horse while sitting on it for example

spiral light
mental moon
#

Last I remember Horse movement is clientside. If it doesn't fire from PlayerMoveEvent I can't think of where it'd come from

quaint mantle
spiral light
spiral light
quaint mantle
#

hm, I guess I'll have to manually handle that with the command preprocess event then

spiral light
echo basalt
#

Steer_Vehicle packet

#

PacketPlayInSteerVehicle

#

Usually contains a forward and side movement inputs, space and shift status

#

You can then use the ControllerMove's a(float, float) method to strafe any entity as if you were controlling it

#

(1.12) ->

float forward = ...; 
float side = ...;
boolean jump = ...;
boolean shift = ...;

Player rider = ...;
Entity vehicle = rider.getVehicle();

if(shift) {
  rider.leaveVehicle();
  return;
}

net.minecraft.server.v1_12_R1.Entity nmsEntity = ((CraftEntity) vehicle).getHandle();

if(!(nmsEntity instanceof EntityInsentient))
  return;

EntityInsentient insentient = (EntityInsentient) nmsEntity;

ControllerMove move = insentient.getControllerMove();
ControllerJump jumpController = insentient.getControllerJump();
// ControllerLook look = insentient.getControllerLook();

move.a(forward, side); // strafe

if(jump)
  jumpController.a();
#

Will be similar for higher versions, just make sure that the ControllerMove's method takes in 2 floats, or its internals reference strafing

#

If you want to change the strafe speed, you need to access its e variable (often the 4th double) and set the value

#

Hope that helps @spiral light

spiral light
#

the packet helped a lot
thank you^^

echo basalt
#

Cheers

#

Horses will be quite buggy FYI

#

Seems like spigot handles them separate

spiral light
#

yeah there is no api i can see for setting the saddle O.o

echo basalt
#

Also slimes etc will need to have their ControllerMove instance set to something else if you want them to behave like regular entities

echo basalt
#

Pig#setSaddle

spiral light
#

ah wow ... thank you, i had pig but horse has to be different of course ^^

quaint mantle
#

Does anyone here have experience with packages related to ClientboundSetEntityDataPacket?

#

I have an armor level and set the nogravity and customname and customnamevisible and the customname stuff doesn't work does anyone know a fix?

spiral light
#

isnt customname for chat ?

tender shard
#

?

quaint mantle
#

customname for a armorstand

spiral light
#

ah ok

quaint mantle
#

I set both correctly and it just doesn't work, yet it has the other properties but

quaint mantle
#

yes

#

The armorstand is also spawned but without customname

sacred mountain
#

how do i make an event that when a player places a water/lava source it saves the location to a list and i can later remove the location and add more if i need

#

WaterBucketEvent(PlayerBucketEmptyEvent bucketEmptyEvent)

#

is that the right method

hasty prawn
#

It doesn't follow naming conventions but the Event you're using is correct.

sacred mountain
#

ok thanks

hasty prawn
#

Then just call bucketEmptyEvent.getBlock().getLocation() and that should be the location of the source block.

sacred mountain
#

i saw someone say that that would get the Exact location

#

and not the coordinates

quaint mantle
hasty prawn
#

Exact location of what

fervent gate
young knoll
#

The config should be in the same place as the plugin.yml

fervent gate
#

oh ok

sacred mountain
#

this look correct?

#

trying to get the location of a placed water bucket

#

or is that the face that the water is placed on, so the block below.?

light parcel
#

Does anyone know how to listen for events with MockBukkit?

ivory sleet
#

I believe like normal spigot

light parcel
#

Test class needs to implement listener then?

ivory sleet
#

its only the mocking of calling an event which might be different?

#

yeah

#

and for setup you'd register the listener in principle

#

and tear down you unregister it

bitter fulcrum
#

Does Spigot automatically map the Minecraft jar? If so what mappings does it use?

ivory sleet
#

it used to have those nms mappings

#

you can use mojmaps now

#

tho you're not allowed to distribute it iirc so if you're a plugin developer might be sufficient to only depend on mojmaps at compile time

bitter fulcrum
#

Am I able to use yarn?

ivory sleet
#

nope

#

or well

#

dont think anyone has taken the effort to implement such a plugin which would support it

young knoll
#

Doesn’t paper run mapped at runtime

ivory sleet
#

yeah

young knoll
#

Therefor requiring you to distribute mapped jars

ivory sleet
#

yeah it patches the binaries

#

or smtnfg

visual tide
#

is it possible to make a player have potion particles on the without them actually having any effect?

ivory sleet
#

sounds like you'd have to use packets for that

#

but prolly is since the visual effect is just rendered client sided

visual tide
#

yay

#

why can you not use external emojis here

#

sad

#

wanted to express my happiness to be working with packets

young knoll
#

You need to boost

ivory sleet
#

Hmm, I have an interface with a getter, in implementation A its nullable, but in implementation B its not nullable, do I annotate the getter in the interface with @Nullable still?

quaint mantle
#

IMO, yes

light parcel
young knoll
#

Just uhh

alpine urchin
#

just do it

young knoll
#

Make it an optional so it’s not nullable either way

ivory sleet
#

hmm yeah

#

Ik checker qual got @PolyNull but meh

alpine urchin
#

i didnt read much context

#

but do it

young knoll
#

@dark thicketNullable

#

What

#

Gosh dangit

ivory sleet
#

you probably want to isolate the test class from the actual logic

#

like the test class shouldnt be a listener itself lol

#

lol

young knoll
#

@QuantumNullable

light parcel
#

Ah then I'm not sure how to get the "capture" the event in the test?

young knoll
#

It’s both null and not null until observed

ivory sleet
ivory sleet
lavish hemlock
visual tide
#

bruh the only thing i can find on potion particles is how not to show them 😐

visual tide
#

maybe EntityEffect packet?

#

or is that something different

ivory sleet
#
class Test {
  Listener listener;

  void setUp() {
    listener = new MyListnrImpl();
    pluginManager.registerEvents(listener,plugin);
  }

  void givenEventInvocation_doesEventGetCancelled() {
    MyEvent event = new MyEvent();
    pluginManager.callEvent(event);
    assertTrue(event.isCancelled());
  }
}``` @light parcel for instance
#

tho that might actually test the event instead or well both parties actually

ivory sleet
#

a bit problematic if you wanna isolate your units

#

but yeah the way spigot's event system works with explicit types its hard to mock events

light parcel
ivory sleet
#

yeah

#

in that case invoke the according mock methods

#

and assert that the event ran

#

or sth

visual tide
ivory sleet
#

depends if you're testing the listener or the event

#

yeah might wanna use a MockListener then

#

or sth

dense heath
light parcel
#

Both I guess, I've got one event that triggers a second that I listen for - what's sth?

ivory sleet
#

something

#

well thing is

light parcel
#

oh lol

ivory sleet
#

you should separate it to 2 different classes

#

one class testing the listener with a mock event and one testing the event with a mock listener maybe

light parcel
#

Mm yeah it's probably a poorly designed test tbh

ivory sleet
#

well

#

bukkit and minecraft in combo with unit tests is kinda meh

#

but it works almost fine

#

altho its hard to always apply all practices to the letter given the environment

dense heath
ivory sleet
#

we just have to assert certain things that arent gonna happen

ivory sleet
#

because the entire point of using unit tests is to automate the process

#

and then whenever you add some new prod code to your system you run tests and check if everything still passes

dense heath
#

Fuzzing is your friend :)

ivory sleet
#

oh you mean that

#

hows it better tho?

dense heath
#

It is mathematically impossible to break your code if it is formally verified to be correct

ivory sleet
#

is fuzzing the same as mutation tests?

#

because if its that then sure its not a bad way of testing

dense heath
ivory sleet
#

ah right

#

well thing is

lethal oxide
#

Hello there! I am currently in the midst of an unworkaroundable error in my code involving remapped NMS, i have consulted many people and many other servers and if this doesnt work idk what to do then. My problem revolves around the Clientboundinfopacket class and it being ig build tooled improperly. i dont know the root of this error and have tried rebuilding my 1.17.1 build tools 5 different ways now and nothing has worked, along with trying various other work arounds. Here is the error and i would EXRTEMELY appreciate any help if it can be provided as i cannot continue development of this plugin i WAS excited for which would suck. Upon maven clean package building and artifact building with inltellij i receive this error D:\Coding\Intellij projects\DownedRust\src\main\java\me\art\downed\downedrust\BodyListener.java:5:43 java: cannot access net.minecraft.network.protocol.game.ClientboundAddPlayerPacket bad class file: /C:/Users/Blake K/.m2/repository/org/spigotmc/spigot/1.17.1-R0.1-SNAPSHOT/spigot-1.17.1-R0.1-SNAPSHOT-remapped-mojang.jar!/net/minecraft/network/protocol/game/ClientboundAddPlayerPacket.class class file has wrong version 60.0, should be 52.0 Please remove or make sure it appears in the correct subdirectory of the classpath.

bitter fulcrum
ivory sleet
#

mutation tests can take considerably more significant amount of time to do

drifting vault
#

using protocollib, is there a way to cancel the digging sound of a specific block?

ivory sleet
#

so its not those tests you run after every function you write or sth

#

ofc depends if you do tdd or not

#

but yeah

lethal oxide
#

if anyone could help i would much much much appreciate that

dense heath
ivory sleet
#

hmm maybe

dense heath
#

There are special use cases for it, like if you write an actual spatial partitioning algorithm to store your claims

ivory sleet
#

I mean you can test your code regardless?

visual tide
#

build it with java 17

lethal oxide
#

been there done that

ivory sleet
#

just that I hate tdd (to a certain extent)

main dew
#

hi I make aspect plugin use AspectJ and I try load this when I eneable spigot
I should write other argument when I eneable server? java -jar -javaagent:C:/Users/MatDr/.m2/repository/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar spigot.jar

dense heath
lethal oxide
fathom cobalt
#

how can I insert a BaseComponent or any of it's deriving classes into a book?

ivory sleet
#

well yeah I believe the theory and reasoning about writing tests is good

dense heath
#

Imo the only unit tests you should write for your code are the ones where you have special exceptions that should always be accounted for

ivory sleet
#

but tdd became a shit cult people commit to blindly

dense heath
ivory sleet
#

Idk I usually write unit tests for anything with io and networking todo as well as parsing yeah, and possible concurrency

#

but for actual design, unit tests is a big no

visual tide
#

i write unit tests when it doesnt work

#

😐

drifting vault
#

i would like my question to be answered if thats alright

ivory sleet
#

well I believe functional tests and those tests which aren't specifying concrete units are much better as they don't break every other second you decide to change the concretion

dense heath
drifting vault
#

somewhat. i have used the sample code to disable all sounds but i can still hear the walking and digging sounds

new PacketAdapter(getPlugin(), ListenerPriority.NORMAL,
                PacketType.Play.Server.NAMED_SOUND_EFFECT) {
            @Override
            public void onPacketSending(PacketEvent event) {
                // Item packets (id: 0x29)
                if (event.getPacketType() ==
                        PacketType.Play.Server.NAMED_SOUND_EFFECT) {
                    event.setCancelled(true);
                }
            }
        };
dense heath
ivory sleet
#

yeah

quaint mantle
#

i write unit tests because my pc cant handle a minecraft + minecraft + intellij idea opened at the same time.

ivory sleet
#

and then there's the "I want to extract a class" catbolbdevil

dense heath
quaint mantle
#

Such an easy and reliable solution

dense heath
#

Real vim hours

drifting vault
#

NAMED_SOUND_EFFECT

ivory sleet
#

lol

dense heath
drifting vault
#

its probably entity_sound

#

for walking and digging?

dense heath
dense heath
#

I have never paid for something and not received it.

ivory sleet
#

the reliability is probably not the issue

dense heath
quaint mantle
#

simple

young knoll
#

poor = !poor

dense heath
quaint mantle
#

no

visual tide
#

any1 know what the boolean in the ClientboundSetEntityDataPacket constructor is?

dense heath
lethal oxide
#

new problem how do i make this bat @echo off IF NOT EXIST BuildTools ( mkdir BuildTools ) cd BuildTools curl -z BuildTools.jar -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar set /p Input=Enter the version: || set Input=latest java -jar BuildTools.jar --rev %Input% --remapped pause not use java 16 and use 17 instead, bc i dont even have 16 on my pc as a file and dont know why its still using it

quaint mantle
#

Unit tests is a good practice right

visual tide
ivory sleet
dense heath
visual tide
ivory sleet
#

however practices like tdd is imo going in the wrong direction

dense heath
dense heath
lethal oxide
dense heath
lethal oxide
#

yeah but i need to point to the java jar somewhere in there right?

#

to run java 17

#

like u said

dense heath
#

Wait, hold on, I think I'm missing something here

#

Are you saying that you don't have Java installed on your PC, and because of this you are not able to run the java executable file?

lethal oxide
#

pretty kucvh i have jdk 17 installed, and dont have jdk 16. but for some reason running that bat uses JDK 16

young knoll
#

You replace ‘java’ with the java install path

lethal oxide
#

and i could just point to java 17

#

ok

#

that worked

#

thanks

dense heath
#

Wait what? Isn't that what you already said? xd

#

"C:\Program Files\Java\jdk-17.0.1\bin\java" -jar BuildTools.jar --rev 1.18...

lethal oxide
#

i worded it awfully lol

#

sorry for that

dense heath
#

You're vibing lmao

lethal oxide
#

now we just wait and see if this actually fixes the original problem

dense heath
vague swallow
#

How can I check a specific inventory slot for an item?

misty current
#

i've probably found one of the strangest bugs ever

#

i have a custom enchant that plays a lightning bolt packet

dense heath
misty current
#

and when i swap to peaceful and back to normal the packet (which is just sent to the clients) puts fire in the world

#

this is the code

#

sec

#
Location loc = wrapper.getVictim().getLocation();
wrapper.addPureDamage(level * 0.2);

Utils.playSound(Sound.AMBIENCE_THUNDER, 1, 1, wrapper.getAttacker(), wrapper.getVictim());
PacketUtils.playPacket(new PacketPlayOutSpawnEntityWeather(
        new EntityLightning(
                ((CraftWorld) loc.getWorld()).getHandle(),
                loc.getX(),
                loc.getY(),
                loc.getZ(),
                false,
                false
)), wrapper.getAttacker(), wrapper.getVictim());
#

(1.8)

young knoll
#

Why a packet

misty current
#

because else it places fire on the ground

#

which i don't want

young knoll
#

Did strikeLightningEffect not exist in old.old

dense heath
misty current
#

oh sht

#

ok i saw it

dense heath
#

Let me guess, it actually spawns the lightning bolt into the world? xd

misty current
#

yeah the 4th param should be true

#

and weird enough it depends on difficulty

dense heath
#

That's gaming!

misty current
#

something i didn't know about minecraft i guess lol

young knoll
#

Dangit 1.8

misty current
#

dont think so

#

what class is it from

young knoll
#

World

misty current
#

lemme check

#

oh yea its a thing

#

hm

#

something i didn't know +1

#

i've tried googling about it and the only answer i've found was about packets

#

not like it makes any differences for me as it's a private plugin that won't run on modern versions

spare marsh
#

Hi, is it possible to pass an InventoryClickEvent to another class?

#

the whole event

young knoll
#

Sure

#

Just pass the object

spare marsh
#

have a listener and if it is a certain inventory, pass it on to another class to manage the logic

misty current
#

yes, put it as a paramter for the constructor or whatever

#

i have a wrapper that wraps attack events

#

i'll send the class

spare marsh
#

Well I only need it to handle the logic I don't really needed inside the class so I don't want to put it in the constructor

misty current
#

um it's a bit big

spare marsh
#

It is not very important

#

wait why on the constructor if the event can change its data?

misty current
#

yeah anyways you can pass it as any object

spare marsh
#

I did but for some reason it won't work.

#

Is putting the annotation necessary for the method I'm passing it on to?

young knoll
#

No

misty current
#
@EventHandler
public void onEvent(InventoryClickEvent event){
    manageEvent(event);
}

private void manageEvent(InventoryClickEvent event){
    event.setCancelled(true);
}
spare marsh
#

To send it I listened on the actual listener class and then sent it to another class if it is a certain title but for some reason, it won't work.

#

Something similar to that but it won't work.

#
@EventHandler
    public void onClick(InventoryClickEvent event){
        if(event.getView().getTitle().startsWith( Resources.colorMessage("&8Edit member &e≫"))){
            getMemberGUI().applyLogic(event);
        }

    }```
misty current
#

are you sure the event was called?

#

did you register the listener

young knoll
#

And does your if statement pass

misty current
#

^

#

does strikeLightningEffect play the sound

young knoll
#

Try it

fleet imp
#

how do i define a list w/o it throwing 15 errs and warnings at me

spare marsh
#

Yes, the event is cancelled in that same method but I removed it just now, but yes the event is cancelled so when I click it cancels. I am not sure it is passing the logic part tho.

misty current
undone axleBOT
spare marsh
#

Yes the listener is registered and running just not passing it right for some reason

proud basin
#

how can I check if a player is in liquid such as water, lava etc...

misty current
spare marsh
#

Check the block's type maybe?

young knoll
#

Probably the best way

misty current
#

you need to call t_() that handles logic and also sound

young knoll
#

I think either block or material has an isLiquid

misty current
#

also i love that they have 3 methods that are completely empty

#

with no implementations anywhere

#

lol

#

also yea apparently lightning can only leave fire if the difficulty is above easy

upper niche
#

ah yes
thank you terminal for giving such a useful error report

[19:05:03] [Server thread/INFO]: [pvpPlugin] Enabling pvpPlugin v1.0
[19:05:03] [Server thread/ERROR]: Error occurred while enabling pvpPlugin v1.0 (Is it up to date?)
java.lang.ArrayIndexOutOfBoundsException: null
[19:05:03] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
#

i really dont wanna have to test every place that im using an array or List but it seems i might have to

ivory sleet
#

Well

#

It’s during bootstrap

#

So that should narrow down where the error origins from a significant amount

upper niche
#

i mean i guess?

ivory sleet
#

It’s also strange no stacktrace is printed unless someone just decided to print out the error message of the exception instance

#

Or sth

upper niche
#

theres so many things i initialize at startup that its like saying "instead of looking in the entire ocean, its somewhere in the mariana trench"

ivory sleet
#

Wat

upper niche
mental moon
#

Anyone know how to grab the base64 string off of a Player Head item?
I have no issues using the PersistentDataStorage on the Tilestate when it's a block, but I'm having an issue that prevents me from getting that tilestate data before it becomes an item.

ivory sleet
#

Vhoyd since you seem to be a lot more knowledgeable than me I can rest assure you that you’ll figure it out yourself

upper niche
#

lol
even if i did have knowledge i definitely dont have the wisdom

#

what even is knowledge
all i know is stackoverflow and ctrl c/v

ivory sleet
#

A good starting point is to share the code, if you’re comfortable with that btw

ivory sleet
upper niche
#

i mean i can do that but theres just so much inefficient code to dig through
i dont want to be the cause of anyone suddenly finding themselves vomiting

ivory sleet
#

That’s their own fault then

mental moon
ivory sleet
#

Yeah well reflection should be trivial if you know your Java but I think google got some info on this, at least when I googled it tho that was some time ago

mental moon
#

I've managed to avoid reflection for a long time until now 😅

ivory sleet
#

Yeah well

#

It’s basically that you can do fun stuff with your java classes at runtime

upper niche
#

lmfao nevermind
the first method i threw a try catch around for error printing was the method causing the issue
now i just have to figure out why

#

oh cool

#

the stacktrace was actually logged

#

it just wasnt printed for some reason

#

lets go figured it out
i pulled a stupid
changed how a custom inventoryholder was loading so it filled the empty inventory slots with glass panes on initialization but left in another line that did that again
the loop started with the inventory's firstEmpty() which naturally in the second time since it's full would be -1
i am pepega

lethal oxide
#

now what

sudden reef
#

about this

#

I figured it out by..

#

Testing a bunch of things

#

it appears that for some reason

#

It's not enough declaring it 1 time

#
        obj.getScore("test-player").setScore(20);
        num =  obj.getScore("test-player").getScore();
        console.sendMessage(String.valueOf(num)); //says 20
        obj.getScore("test-player").setScore(55);
        console.sendMessage(String.valueOf(num)); //20
        obj.getScore("test-player").setScore(20);
        console.sendMessage(String.valueOf(num)); //20
        sendConsole("scoreboard players set test-player output 10");
        console.sendMessage(String.valueOf(num)); //20

this, wont work.

#
obj.getScore("test-player").setScore(20);
        num =  obj.getScore("test-player").getScore();
        console.sendMessage(String.valueOf(num)); //20
        num =  obj.getScore("test-player").getScore();
        obj.getScore("test-player").setScore(55);
        num =  obj.getScore("test-player").getScore();
        console.sendMessage(String.valueOf(num)); //55
        num =  obj.getScore("test-player").getScore();
        obj.getScore("test-player").setScore(20);
        num =  obj.getScore("test-player").getScore();
        console.sendMessage(String.valueOf(num)); //20
        sendConsole("scoreboard players set test-player output 10");
        num =  obj.getScore("test-player").getScore();
        console.sendMessage(String.valueOf(num)); // 10

this does

#

Any suggestion?

#

I'm thinking of doing a function

#

That can be called num() or something like that

#

And each time it's called it returns a new num

#

ig that could work

#

oh wait

#

I think i have to update the score not the num

#

let's test realquick

#

ok yeah it's the num

proud basin
#

How can you get a players mc version?

subtle folio
#

Im trying to make a combat log, java @EventHandler public void onDamage(EntityDamageByEntityEvent e) { if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) { Player p = (Player) e.getDamager(); Player killer = (Player) e.getEntity(); combatLog.put(p, dur); combatLog.put(killer, dur); p.sendMessage(ChatColor.GREEN + "You have been added to combat log."); killer.sendMessage(ChatColor.GREEN + "You have been added to combat log."); } } But whenever I hit someone, I never get the message you have been added to the combat log

sudden reef
#

wait what

#

it's not the fault of

#

the scoreboasrd

#

with
int num = (int) Math.floor(Math.random()*(50-1+1)+1);
it happens the same

sterile token
#

Hello! Anyone know any good website for learning about syncronized methods?

ivory sleet
#

I mean it’s really simple

#

one thread at a time can run the method

swift adder
#

how would i implement both listener and commandexecutor in the same class?

ivory sleet
#

class X implements CommandExecutor, Listener{…}

swift adder
#

OH YES!

#

How could I forget that

#

Silly me

sudden reef
#

ok nvm

ivory sleet
#

Lol no worries

sudden reef
#

I got really confused

#

this is just like this

lethal oxide
#

Time to put this one in the archives and start something new ig

ivory sleet
#

Or fix your issue?

swift adder
#
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("stats")){
            if (sender instanceof Player){
                Player p = (Player) sender);
                int value = stats.get(p.getPlayer());
                p.sendMessage(stats.get(value + " You got this many blocks"));
            }
        }
        return false;
    }```
Basically I want it to tell the player the Integer in the hashmap.

```java
HashMap<Player, Integer> stats = new HashMap<Player, Integer>();```
#

could anyone help?

ivory sleet
#

What the

#

First of all you can remove the redundant getPlayer() method

swift adder
#

That auto did that and just saw it right now

ivory sleet
#

But yeah you probably want to do something like
sender.sendMessage(Integer.toString(map.get(player));

lethal oxide
ivory sleet
#

turns an integer into a string oofergang

ivory sleet
swift adder
#

not sure which one but it needs something and it aint telling me what

ivory sleet
#

Send the code again

#

?paste preferably

undone axleBOT
ivory sleet
#

Of course an updated variant

swift adder
young knoll
#

Player is the type

#

p is your variable

#

Also don’t use single letter variables

analog prairie
#

Why I use gradle to import gson but it's not work

ivory sleet
#

single letter variables are fine sometimes

analog prairie
#
plugins {

    id 'java'

}

group 'org.example'
version 'Pre-Release'

repositories {
    maven {
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'

        content {
            includeGroup 'org.bukkit'
            includeGroup 'org.spigotmc'
        }
    }

    maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url = 'https://oss.sonatype.org/content/repositories/central' }
    mavenLocal()
}

dependencies {
    compileOnly 'com.google.code.gson:gson:2.8.9'
    compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
    compileOnly 'org.spigotmc![spigot](https://cdn.discordapp.com/emojis/728421352721088542.webp?size=128 "spigot")1.18-R0.1-SNAPSHOT'
}
swift adder
young knoll
#

Because you defined it as such?

swift adder
#

what's wrong with it?

#

if it works does it's fine aint it?

young knoll
#

It’s not descriptive

lethal oxide
ivory sleet
#

oofergang depends on definition of wrong but the name p itself doesn’t tell a lot about where the variable comes from, what it’s intent is and so on

swift adder
dusk flicker
#

rip Conclure

ivory sleet
#

Usually you go by the principle:
The name of a variable should be proportional to the scope it’s contained in

swift adder
#

I dont understand

dusk flicker
#

?learnjava

undone axleBOT
ivory sleet
#

stats.get(p)

swift adder
#

"Player is the type"

ivory sleet
#

btw

swift adder
ivory sleet
#

because p is your variable which contains the player object

#

Player is the class

#

not the variable itself

#

classes != variables

swift adder
#

i shoulda known

ivory sleet
#

Yasir

swift adder
#

testing time!

analog prairie
#
plugins {

    id 'java'

}

group 'org.example'
version 'Pre-Release'

repositories {
    maven {
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'

        content {
            includeGroup 'org.spigotmc'
        }
    }

    maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url = 'https://oss.sonatype.org/content/repositories/central' }
    mavenLocal()
}

dependencies {
    implementation 'com.google.code.gson:gson:2.8.9'
    compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
    compileOnly 'org.spigotmc: spigot:1.18-R0.1-SNAPSHOT'
}
dusk flicker
#

instead of repasting your code just wait

ivory sleet
#

You need to add mavenCentral() as a repo

dusk flicker
#

presume its cause maven central isnt listed

ivory sleet
#

Ya

#

Also why depend on both api jar and the real jar

dusk flicker
#

nms

#

obviously

ivory sleet
#

Well isn’t the real jar sufficient for that?

young knoll
#

Doesn’t spigot already have gson

dusk flicker
#

thought it did

young knoll
#

Actually

#

Minecraft itself has gson

dusk flicker
#

my fork pulls gson from minecraft yeah

ivory sleet
#

I am convinced your project can be rescued if we use gradle @lethal oxide so if you’re willing to commit yourself to gradle then sure

ivory sleet
dusk flicker
#

actually good

#

finally finished the core

ivory sleet
#

Delightful

dusk flicker
#

gonna rebrand under a new name and finally upgrade to 1.18.1 or whatever latest is, and get a survival server up first

ivory sleet
#

Ah noice

dusk flicker
#

As for v1 of the core some stuff isnt it in, mostly just punishments and vanish stuff, but that will be in post release

ivory sleet
#

Open source for core?

dusk flicker
#

trust me you dont want this open source

analog prairie
#

Can I get a server UUID?

ivory sleet
#

Server uuid?

analog prairie
#

Because my plugin needs a database

dusk flicker
#

make a uuid then