#help-development

1 messages · Page 871 of 1

dry forum
#

1.20.4

young knoll
#

Whey are you using packets then

#

Player.spawnParticle

dry forum
#

i want to send packets to 1 person

#

*particles

young knoll
#

Yes that’s that the method does

dry forum
#

oh....

#

ok tjanks

vapid grove
#

so i dont need to use protcol lib

young knoll
#

What part of it

vapid grove
#

hold on ill send

#
ArrayList<Player> pList = new ArrayList<>(Bukkit.getOnlinePlayers());
            if (protocolManager != null) {

                for (Player p : pList) {
                    int[] time = StringFuncs.getHMS(Instant.now().getEpochSecond() - Main.uptime);
                    PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
                    packet.getChatComponents().write(0, WrappedChatComponent.fromText(String.valueOf(ChatColor.LIGHT_PURPLE) + ChatColor.BOLD + "Survival Enhanced"));
                    packet.getChatComponents().write(1, WrappedChatComponent.fromText(ChatColor.LIGHT_PURPLE + "Online Players: " + pList.size() + "\nPing: " + p.getPing() + "\nUptime: " + String.format("%02d:%02d:%02d", time[0], time[1], time[2])));
                    protocolManager.sendServerPacket(p, packet);
                }
            }
#

i also wanted to have players show their ingame tag beside them

young knoll
#

Player.setPlayerListHeaderFooter

#

Player.setPlayerListName

vapid grove
#

ok awesome ty

cobalt sphinx
#

Hey! Is it somehow possible to get EntityType DEFAULT MAX_HEALTH attribute?
I have entities that have been changed max health and I'd like to get their default value.
I could create a Map including all entity types and their health, but that's not createst solution.

#

Maybe creating a new temporary entity using certain type? Would that affect server performance if it's being done for EVERY spawning entity?

#

LivingEntity*

chrome beacon
#

Just getting the attribute from the entity should work

cobalt sphinx
#

It does not.

chrome beacon
#

Or do you need the default one specifically?

cobalt sphinx
#

Specific entity attribute GENERIC_MAX_HEALTH has been changed so I cannot use that.

chrome beacon
#

So what's the goal here? Why do you need the default max health

cobalt sphinx
#

The goal is to reset all entities health back to default

#

Without killing them

#

Some plugin messed them up

echo basalt
#

getDefaultValue on Attribute

cobalt sphinx
#

Oh what....

#

Really?

#

I'll try, if it's really so easy sorry for wasting your time...

#

Works great! THANK YOU!

#

Oh wait, no, it's not it... It returns entity maximum health, not default health... I think I need t gather default healths and create a map myself.

chrome beacon
#

Default health should be the default max health?

cobalt sphinx
#

For newly spawned Enderman, this returns 40 (which is default in MC)
monster.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()

This returns 20:
monster.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue()

chrome beacon
#

Ah I see

#

Spawning a mob and making a map might be the easiest way then

cobalt sphinx
#

I'll check how much it affects performance. I could initialize map on plugin enable, list all LivingEntity including default health.

hybrid turret
#

Can I make a custom InventoryHolder?

echo basalt
#

We wouldn't suggest

hybrid turret
hybrid turret
hybrid turret
#

Also another thing: I successfully used gson to write stuff to json strings. Now I tried using gson to write to a file by doing:

gson.toJson(object, new FileWriter(jsonFile));

Absolutely nothing happens though. No error message, no writing. The string is there (debugger told me that) but it just... doesn't write?

echo basalt
#

inv holders are a bad approach because getHolder copies the entire inventory if it's a vanilla one

hybrid turret
#

because i had the worry that ppl could exploit chests to manipulate my vault-inventories

#

since logically, at least for me, chest have the InventoryHolder null?

hybrid turret
echo basalt
#

Basically if you do a getHolder check and it fails it copies the entire thing which is not good for performance

hybrid turret
#

I have a Listener that is only supposed to execute code on certain inventories. The only thing that is different to a double-chest (at least from my knowledge) is the title (which can be changed) and the holder (maybe). The current InventoryHolder for my vault-inventories is null. So i check:

if (!event.getView().getTitle().startsWith("Vault") && event.getInventory().getHolder() != null) return;

but I'm not sure if this is unique.

#

That's why I asked if a chest had the IH null

#

(Ping me on an answer please :) )

echo basalt
#

help Im great at naming methods

hybrid turret
wet breach
#

so, no it shouldn't be null for a chest

#

the only way it could be null for such things is if you have a plugin that is overriding

#

well I guess that isn't true technically

#

since a block could get broken while looking at an inventory

#

and then it would be null after that

subtle folio
#

imAlive

#

me when no sendHeartbeat

echo basalt
#

heartbeats are a sep thing

#

need to work on that

#

I want to get this template system working today

#

dont think it gon work

#

gotta make it support proxies n stuff

hybrid turret
hybrid turret
# echo basalt gotta make it support proxies n stuff

stuff like this always humbles the shit out of me, having worked on my (pretty much only java) project for like 5 years or sum, and seeing how I have absolutely no idea what this is about. (Pretty much any network-related stuff in java), haha

echo basalt
#

It's nothing special just networking

hybrid turret
#

exactly, that's why it's so humbling lmao

rough drift
#
try (var bukkitObjectOutputStream = new BukkitObjectOutputStream(stream)) {
  bukkitObjectOutputStream.writeObject(itemStack);
}
```Writing

```java
try (var bukkitObjectInputStream = new BukkitObjectInputStream(stream)) {
  return (ItemStack) bukkitObjectInputStream.readObject();
} catch (ClassNotFoundException e) {
  throw new IOException("Failed to read item stack", e);
}
```Reading

prints `java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "item" is null`, are there known issues with saivng item stacks like this?
rotund ravine
#

Check if it’s null

hybrid turret
#

was about to say that

echo basalt
#

It can return null if you serialize null

rough drift
#

oml I forgot about itemstacks being null 😭

#

why can you retrieve null but not set null

hybrid turret
#

Wait, shouldn't gson take care of null? For me it's writing null to the json, lol

hybrid turret
echo basalt
#

yikes these are some long class names

shadow night
#

In json null is the absence of something

rough drift
#

but I can't

echo basalt
#

whatever this is meant to be basic

rough drift
#

YOOOOO

#

filtered out the null items

#

it works

wet breach
#

renaming the chest doesn't change the holder

hybrid turret
#

but the title

#

and i also check for title

#

that's why the renaming is important

wet breach
#

title isn't what defines a holder

#

the instance of the entity or block does

#

typically the inventory is suppose to close if the chest or something is broken, but there is rare instances where the inventory could stay open. In terms of code the holder would be null, but so would everything else except the inventory itself

#

you can if you wanted arbitrarily give your vaults holders but typically you only do this if you want to give ownership

#

well I should say, its an more easier way to define ownership

#

because the holder of an inventory like a player for example, is always the viewer of their inventories

#

even when they are closed

hybrid turret
#

i had a problem once when it tried always adding a holder to the inventories, so i'll pass for now.

#

imma get this to work first

#

tbh it should work, i tested it. Just couldn't test it with an actual player closing the inventory. only using the console

#

anyway

wet breach
#

well you shouldn't rely on titles

#

since they can be changed

#

however it shouldn't be hard to know when its your vault though

#

just compare the inventory objects

#

I mean its your vault inventory, its not like you don't know when it is created

inner mulch
hybrid turret
#

I looked at this a couple times, and never could get it to work for some reason

#

idek why

#

But I fail at using it

inner mulch
#

you might, but once you understnad what happens there you learned some good design pattern for java

#

as well as some basic java concepts

wet breach
#

its not the only way

#

they obviously have difficulties with it, so probably best they take a different approach

inner mulch
wet breach
#

again, its not the only way

#

its one of many ways

river oracle
#

My way is similar but much more complex then that it's a good exemplar

#

Generally the reason I enjoy that thread is because it teaches you comparison of inventories via equals vs using names

wet breach
hybrid turret
#

i'm with you salvation on that one, but i don't really get it. in the end i want to learn "all" of java anyway and trying to understand the inventory-guis is probably a good idea

river oracle
hybrid turret
#

ummmmmmmmmm

#

i feel semi-called-out

wet breach
#

just give your inventories UUID's >>

hybrid turret
#

using a map?

#

or a wrapper?

river oracle
wet breach
#

why is that an issue?

inner mulch
hybrid turret
#

hmmmm

#

i mean kinda same ig but i'm at the not understanding part lol

river oracle
young knoll
#

It’s also misuse of the api

wet breach
#

ok, but not sure what that has to do with giving your custom inventories UUID's

young knoll
#

Md has stated you aren’t meant to implement inventory holder

wet breach
river oracle
young knoll
#

Your would think

#

But people don’t listen

wet breach
#

its been said idk how many times over the years

river oracle
#

Well you could do custom inplementation of inventory i suppose

wet breach
#

like, this was a question answered over on the bukkit forums

young knoll
#

Wiki page on what you are meant to extend/implement when

river oracle
wet breach
#

ok we are not paper

hybrid turret
river oracle
#

Yet another issue people struggle with

wet breach
cosmic loom
#

is NULL considered AIR?

wet breach
#

in what context?

hybrid turret
young knoll
#

Null is an empty slot

cosmic loom
young knoll
#

Sometimes air is also an empty slot

hybrid turret
wet breach
#

what Coll said

young knoll
#

the api is a bit inconsistent with that

#

But yes functionally they are the same in regards to inventory

hybrid turret
#

air is a weird thing anyways

wet breach
#

air was just always null

river oracle
hybrid turret
#

can't set null for a slot tho, can you?

#

at least iirc

river oracle
#

I hate inventories for their inconsistent null contracts

hybrid turret
#

lmao

river oracle
#

It's annoying as fuck

young knoll
#

You can set a slot to null, yeah

hybrid turret
#

oh

wet breach
hybrid turret
#

oh right, but not an ItemStack

river oracle
#

This wasn't the case 8 years ago but is now and it's the way monang took their api

#

And the issue with that one player one menu aka view

hybrid turret
#

monang

wet breach
river oracle
#

For InventoryView in nms

#

It's essentially the equivalent

hybrid turret
#

what does NMS stand for?

river oracle
#

Net minrcraft server and no man's sky :P

wet breach
#

or non-modified source

hybrid turret
#

lmao

#

in this case?

young knoll
#

net.minecraft.server

wet breach
#

so not sure how that is an issue

hybrid turret
#

ohh

young knoll
#

Although since 1.17 a lot of it isn’t actually in net.minecraft.server

river oracle
young knoll
#

:p

hybrid turret
#

wat

wet breach
river oracle
#

I'm too used to internals

wet breach
#

and inventories allow more then one viewer and player inventories never allowed more then one viewer o.O

#

the only way you can get a player inventory to have more then one is by faking the inventory being a player one

river oracle
wet breach
#

ok, but I still don't see the issue here you claim though

river oracle
#

One sec brushing my teeth lol

wet breach
#

inventory views has been a thing for a long time and it hasn't really changed o.O

hybrid turret
#

What happens to the InventoryViewers when you do:

player.openInventory(target.getInventory());

?

river oracle
river oracle
#

If you open the view directly you can actually allow for dupe glitches and such

#

It's quite wacky

hybrid turret
#

ohhh

#

right

river oracle
#

Generally though for custom menus I highly encourage the 1 to 1 contract though

#

Unless you're working on custom storage its very useful to design like this

young knoll
#

What if I want a static menu

#

Smh

river oracle
icy beacon
#

Oo you got nitro

#

Nice

river oracle
#

Yeah frosty gifted me <3

icy beacon
#

Oo

#

Sick

young knoll
#

Nerd

river oracle
# young knoll Nerd

It really depends on the use case but I also wouldn't be adverse to dipping into nms for custom menus

#

It allows much finer control of everything

young knoll
#

Yes but NMS bad

#

Fix it

river oracle
#

I don't think the api should expose that mostly becuase it'd encourage extending api

young knoll
#

Then expose it betterer

river oracle
#

The best that could be done API wise is a builder pattern for views

#

But again that'd be blegh

pliant topaz
#

Mojang should just finish the Modding API for Java

#

Why did they even change it to bedrock (add-ons) 😭

river oracle
#

Their modding api was never going to be as capable as our current one

#

Json can only do so much

pliant topaz
#

Not datapacks

#

The Java Modding API

#

But they changed it to BE Add-ons (bc we then alr had bukkit etc and they thought it wouldnt be necessary for them to do it for Java anymore)

river oracle
#

I rather have a community maintained modding api than an internally maintained one that's my hot take but yk

pliant topaz
#

If they really made that API, we could have gotten custom blocks, custom inventories everything basically vanilla features completely customizable

river oracle
#

Also BE addons are still all json and JS

river oracle
pliant topaz
#

ik, but I still ike the idea of the api more

river oracle
#

Have a look at internals and watch everything switch to registries and codecs its coming

pliant topaz
#

As it would allow for ingame changing of mods and even configuzre your worlds with mods which (when the world is started) automatically download

#

So no more 'start curseforge and restart for every modpack' etc

river oracle
#

You're just explaining registries syncing which I theorize isn't too far off for some things

young knoll
#

I think something else got codecified recently

pliant topaz
#

It's just what we coul've gotten when they made the api back in 1.3

river oracle
#

Also inherently runtime reloads are leaky especially in Java I highly doubt such a system could be implemented nicely

young knoll
#

"Mojang heavily refactored packets in this version to use the new PacketCodec class"

pliant topaz
#

ik

shadow night
river oracle
#

Daily reminder if mojang ran the place we would have had to all sold our soul to the JS devil

young knoll
#

wut?

river oracle
pliant topaz
#

I mean, the way it's coming along rn I really like it, but mods like we know it, downloadable in mc itself, customizable for every of your worlds. thats still on another level. Welp, we unfortunately don't live in a perfect world..

shadow night
#

Well, JB has a JS IDE so

river oracle
young knoll
#

I'm pretty sure bedrock development is fairly detached from jeb and the gang

pliant topaz
river oracle
#

Personally I wouldn't touch most of that with a 300 foot pole

shadow night
young knoll
#

Afaik they are seperate

#

In the US? idk

river oracle
#

Yeah they're two teams iirc

shadow night
river oracle
#

Ones in the US washing and one in Stockholm

young knoll
#

That explains the job positions

pliant topaz
#

Imagien combining Java and Bedrock into one, but only Java features

#

Also written in C++ for performance

shadow night
pliant topaz
#

basically haha

shadow night
river oracle
#

Wouldn't be a fan of that

young knoll
#

I don't think bedrock even runs that much better half the time

#

kek

river oracle
#

They could just optimize java, java can be optimized too :P

pliant topaz
#

true

pliant topaz
slender elbow
#

the client, not the server

river oracle
#

I mean recently they rewrote the lighting engine

shadow night
slender elbow
#

BE server is literally hot garbage

pliant topaz
#

Let's just agree BE shouldn't exist

slender elbow
#

client is pretty smooth on the other hand

pliant topaz
#

or atleast, shouldnt be advertised as much

river oracle
#

It's good it exists

shadow night
#

I think it should be like back in the days

young knoll
#

It's pretty cool to offer all that crossplay

shadow night
#

PE, console editions, etc.

young knoll
#

It's a shame it wasn't done with Java though

#

Granted it would probably be more work to get java running on all those platforms

river oracle
young knoll
#

Well yeah

shadow night
#

I loved the legacy console editions, the only versions with proper flat world settings

young knoll
#

Marketplace kinda yikes

pliant topaz
#

They only wanna make money

young knoll
#

I mean I hear a decent cut goes to the creators

#

Which is nice

pliant topaz
young knoll
#

Still I don't want to pay for like

shadow night
young knoll
#

10 skins

#

Well yeah

shadow night
young knoll
#

legacy console edition

pliant topaz
shadow night
pliant topaz
young knoll
#

Do you want them to update 1.8 on occasion too

#

:p

shadow night
shadow night
shadow night
#

You wouldn't need to support 1.8 if we just had to seperate 1.20's

young knoll
#

Java players are lucky

#

Bedrock can't play old versions

shadow night
young knoll
#

I mean it is a bit unfortunate they don't want to introduce a gamerule for old combat and yet

#

Bedrock still has old combat

inner mulch
#

Is there a good guide on how to set up a proper database in mongodb or has anyone got tips?

young knoll
#

And the new combat snapshots are pretty dead

shadow night
young knoll
#

It has no cooldowns

#

That's the main thing

shadow night
#

Well, I think the iframes are a bit different

#

Dunno tho

young knoll
#

I only played bedrock pvp for a few hours

#

I kinda destoryed people

shadow night
#

Same lmao

#

Bedrockians are just not good, besides in hive skywars lol

young knoll
#

Tbf I was probably fighting people on phones with a keyboard and mouse

shadow night
#

Lol

river oracle
#

For a certain amount of data

young knoll
#

half a gig iirc

inner mulch
shadow night
inner mulch
#

wdym revenge

young knoll
#

Okay but mongo is nothing to do with spigot forks

#

Okay well

inner mulch
#

im pretty sure i didnt

young knoll
#

Not much swing usage in plugins :p

shadow night
#

Lol

kindred valley
#

does getItemMeta() return the current statement of ItemStack which has been used with setItemMeta() with another meta object

echo basalt
#

Returns a copy iirc

eternal oxide
#

getItemMeta always returns a clone of the current meta

kindred valley
#

I mean

ItemMeta meta;
ItemStack is;

meta = is.getItemMeta();
meta.(??????);
is.setItemMeta(meta);


//After here if i use is.getItemMeta(); || is it returning meta object```
eternal oxide
#

its returning a clone of the meta you just set

kindred valley
eternal oxide
#

String comparison will match, not instance

cosmic loom
#

Is there a way to create a Client Side GUI?

kindred valley
young knoll
#

packets

kindred valley
#

will the display name be changed

young knoll
#

However the question would then be, why

eternal oxide
young knoll
#

It's a clone, you need to call setItemMeta

eternal oxide
#

Item Meta is ALWAYS a clone. if you do not set it back after changes they are lost

kindred valley
#

it doesnt change somehow

#
public void addPlayerToGame(Player p, Game g, ItemMeta meta) {
        g.getPlayers().add(p);
        meta.setDisplayName(g.getName() + " || " + g.getPlayers().size() + "/32");
        g.getIs().setItemMeta(meta);
        p.sendMessage("Lobiye katıldın..");
    }```
eternal oxide
#

We just told you it will not

kindred valley
#

no i get the original meta

#

addPlayerToGame(p, CaptureTheWool.getGame1(), CaptureTheWool.getGame1().getMeta());

eternal oxide
#

what is g.getIs()?

kindred valley
#

ItemStack

eternal oxide
#

what is the ItemStack?

kindred valley
#

game1 = new Game("Game 1", 1,2, new ItemStack(Material.WOOL));

#
public Game(String name, int roomCode, int isEnabled, ItemStack is) {
        this.name = name;
        this.roomCode = roomCode;
        players = new ArrayList<>();
        this.isEnabled = isEnabled;
        this.is = is;
        meta = is.getItemMeta();
        meta.setDisplayName(name);
        this.is.setItemMeta(meta);
    }```
eternal oxide
#

seems quite a mess

#

you store a clone of the meta, but sometimes you use it, others you get a new copy

kindred valley
#

i used the same meta

eternal oxide
#

why are you passing meta to the addPlayerToGame? You already have the meta in Game

#

you also have one ItemStack. Do you give that to a player?

kindred valley
eternal oxide
#

its because you are messing around with ItemStacks and metas across different inventories

kindred valley
#

ok i think i should categorise by inventory slot

eternal oxide
#

if Game already has a reference to teh ItemStack don;t pass the meta around

kindred valley
#
public void addPlayerToGame(Player p, Game g) {
        g.getPlayers().add(p);
        g.getMeta().setDisplayName(g.getName() + " || " + g.getPlayers().size() + "/32");
        p.sendMessage("Lobiye katıldın..");
    }```
#

so shouldnt this change the original meta

eternal oxide
#

not the one on the ItemStack

kindred valley
#

i equal itemstack's itemMeta to meta on constructor

eternal oxide
#

Do you understand what a clone is?

kindred valley
#

yes

eternal oxide
#

You don;t seem to

kindred valley
#

so how can i reach the orignal

eternal oxide
#

a clone is a copy. It is no longer the original. It has the same contents , but it is not the same object anymore

#

any changes you make to meta you MUST call setMeta after

#

You will NEVER have the original Meta, you only ever have a copy.

kindred valley
#
public void addPlayerToGame(Player p, Game g) {
        g.getPlayers().add(p);
        g.getMeta().setDisplayName(g.getName() + " || " + g.getPlayers().size() + "/32");
        g.getIs().setItemMeta(g.getMeta());
        p.sendMessage("Lobiye katıldın..");
    }```
#

so g.getIs returns the itemstack

#

g.getIs().getItemMeta returns meta object

eternal oxide
#

yes, so long as your g.getMeta() returns a meta instance and not pull a fresh meta each time

kindred valley
river oracle
# wet breach whats wrong with this?

Extending api gets weird. But also I don't think the api needs to expose all of those internals like slots are weird since they're bound to specific screen coordinates so you'd need to make wrappers and such

#

I'm making my own api for this in one of my libs so we'll see how it turns out

river oracle
#

There Is no format to dictate your formatting

wet breach
inner mulch
river oracle
#

Do it however you think you should

wet breach
#

it just means a structure isn't forced on you and is left for you to decide how you want it to be

inner mulch
wet breach
#

but why are you trying to use something that you are so unfamiliar with?

#

its not like mysql is slow or anything o.O

#

if that is your concern

inner mulch
#

im setting up a proxy, i noticed that redis would be a great idea to use for sync cache data. I saw redis = nosql therefore using sql to persist is kinda stupid, right? This is why i start to learn mongodb so i can use it with redis

wet breach
#

redis is just a key value cache

inner mulch
#

yes but redis can store json data

river oracle
#

You'd be hard pressed to get it to be equally as fast

wet breach
inner mulch
#

no i didnt realize

wet breach
#

seems you have a lot to learn about mysql then

#

there is plenty it can do

#

more then what most assume

inner mulch
#

but redis is a messagebroker too, so it's probably the best for a proxy

wet breach
#

did you also know that you can create functions in mysql? As well as have mysql invoke those functions itself?

inner mulch
#

i guess

river oracle
#

Yeah but that's fucking cursed

wet breach
#

its not cursed lmao

#

also, mysql has the ability to have slave mysql instances as well

eternal night
#

stored procedures are the best

wet breach
#

point is though, if mysql is what you are most familiar with then you should use that. Not entirely sure what exactly you think is not so great in using it

#

or what others have told you

inner mulch
#

im just not sure bro so many ppl use mongodb and recommend it so i figured it has to be good and in some cases, like a mute system it is really nice to just store as many previous mutes as you want to one player instead of doing some table for all the mutes and collecting them everytime i need them for a certain player

river oracle
#

Meh NoSQL hype train will die soon enough frfr

wet breach
#

mongodb is good but only for the right purposes

river oracle
#

In all seriousness though it kinda depends on your problem which db you should use

valid burrow
#

jusr because something is popular doesnt mean its good.. js caugh caugh

wet breach
#

however most people in the plugin scene are not going to encounter scenarios all that often where they can really see the big differences where it matters

inner mulch
wet breach
#

in other words you need to have an insane amount of data to really make comparisons

wet breach
#

same with all the servers?

inner mulch
#

and redis would do that for me too

wet breach
#

so can mysql....

#

not sure what the cache has to do with anything

inner mulch
#

im caching my data when a player joins the server therefore its not sync with the database

wet breach
#

cache is for internal use, its not meant to be spread around otherwise its not much of a cache at that point

inner mulch
#

when using redis, i would modify the redis values, therefore it would be sync

wet breach
#

which can be done in the same fashion and as efficient with mysql

#

so no difference there so far

#

its not like redis is internal to your application

inner mulch
#

but how would i do that with sql i never heard anyone use sql to cache their data

wet breach
#

well instead of using a myisam or innodb, you would use memory only db

river oracle
#

Why are you using a large DB as a cache

wet breach
#

it doesn't persist and only exists in memory

remote swallow
#

woah y2k booster

river oracle
#

Seems silly billy

wet breach
#

but, I don't understand why the cache needs to be available for all the servers either

inner mulch
#

cache data = fast

#

servers need data

#

every server needs data

wet breach
#

mysql is a lot faster then you seem to think

inner mulch
#

it might be fast but it will never be as fast a cached data

wet breach
#

it can be just as fast

river oracle
#

MySQL.is faster than NoSQL dbs in many cases what's this backwards logic

wet breach
#

mysql can handle literally millions of queries in just mere seconds, second if you use unix sockets you remove the TCP overhead and the bandwidth and speed exponentionally increases

wet breach
#

shouldn't it be 8?

#

if I remember right it should be 8 and 16

#

unless it changed

#

but I don't think it did

#

2^9-1

#

because of the sign

#

it takes up a bit

#

therefore, you have to minus 1

#
Math.floor(x/16)
Math.floor(z/16)
#

probably forgetting to floor

young knoll
#

Steal dinnerbones code :p

remote swallow
#

can i floor cmarcos heartbeat

young knoll
#

Rip dinnerbone coordinate converter is down

#

?pastge

#

?paste

undone axleBOT
remote swallow
#

well done

young knoll
eternal oxide
#

Math.floorDiv(value, 16)

wet breach
#

only if it is an integer and just axing off the bits doesn't always work

young knoll
#

Here's the js code I yoinked from minecraft.tools which they yoinked from dinnerbone

#

If it's any help

wet breach
#

if you are only dealing with ints to begin with, then yes bitshifting should work just fine without anything else

eternal oxide
#

Above is what Towny uses to calculate chunk coords.

wet breach
#

but if you have floats, you need to floor first before bitshifting

#

also, bitshifting on floats doesn't work as you might think either

#

which curiously I wonder how java handles that in particular 🤔

river oracle
#

floats are weird

shadow night
#

How do bukkit tasts work? If I have an async task that holds the process, how does it act?

eternal oxide
#

what?

shadow night
#

I'm not sure how bukkit timer tasks, async ones specifically work

eternal oxide
#

they run async

shadow night
#

If I run a method that holds the process usually, what will happen? It can't just "obey the law of the tick", right?

eternal oxide
#

holds the process? So Sync

#

If you call a method from an Async task it runs Async

#

unless you specifically jump back Sync

shadow night
#

I mean, it usually does, but if I run it in async, how does it act? Running it sync it will actually hold the process, but what will happen to it running every tick with it holding the seperate thread or whatever

#

Does it skip ticks?

eternal oxide
#

the Scheduler fires it off each tick Async, so it does not wait for it to terminate

#

its a fire and forget as its Async

shadow night
#

Hmm

#

Fuck

#

Ig just having a single async (non-timer) task with a while loop is way better

eternal oxide
#

It dependss

#

You have to be careful of not consuming CPU cycles you don;t need.

quaint mantle
#

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

public class DynamitePlugin extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();

        // Проверка, что правая кнопка мыши была нажата
        if (event.getAction().toString().contains("RIGHT")) {
            ItemStack itemInHand = player.getInventory().getItemInMainHand();

            // Проверка, что в руке у игрока огненный заряд с тегом A1
            if (itemInHand.getType() == Material.FIRE_CHARGE && itemInHand.hasItemMeta()
                    && itemInHand.getItemMeta().hasCustomModelData() && itemInHand.getItemMeta().getCustomModelData() == 1) {
                // Спавн динамита в игроке
                player.getWorld().createExplosion(player.getLocation(), 4.0f, false, false);
                player.sendMessage("Boom! Dynamite spawned!");
            }
        }
    }
}```
#

can you please put this code in the plugin file? I just don’t know how to do this, thank you very much for your help.

remote swallow
#

dont crosspost

#

?services too

undone axleBOT
eternal oxide
#

create an explosion at the players location if you right click with a firecharge in hand with custom model data set to 1.

#

ChatGPT spewed out teh code I guess

quaint mantle
eternal oxide
#

Follow a basic plugin tutorial

#

that is really basic as you have all the code you need

shadow night
#

Does BukkitScheduler#runTask run the task now or one tick later? I always keep forgetting that

eternal oxide
#

1 tick later, UNLESS you are already in a task

#

If in a Task it runs it at teh end of the tick

quaint mantle
#

I just don't have an intellij idea

eternal oxide
#

its a free download

#

or use Eclipse, or Netbeans

quaint mantle
#

Yes, but I always get an error when I try to install the jar file edition

eternal oxide
#

it will take you about an hour to follow a decent tutorial

shadow night
livid quiver
#

is there a plugin that logs every event happens in the server online (in online file or smth) so that we can check a member for moderation in big servers?

lavish vortex
#

help

eternal oxide
quaint mantle
eternal oxide
#

Nope

#

We can help you learn but not do for you.

quaint mantle
timid hedge
#

Can someone help me with how to connect to a mysql database?
It dosent connect to mysql and i cant see why

database:
  hostname: "localhost"
  port: 3306
  database: "sys"
  username: "root"
  password: "HIDING IT"
eternal oxide
#

spaces in passwords are never a good idea

#

do you get any errors when trying to connect?

timid hedge
eternal oxide
#

Your setup is wrong Access denied for user 'root'@'localhost' (using password: NO)

eternal oxide
#

those credentials you posted are not being used.

minor junco
#

?nocode

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

livid quiver
#

how can i build my own spigot plugin?

#

what things do I need to know?

timid hedge
# minor junco ?nocode

Its not my plugin, its a custom one. And the one who made it, is saying that he is using linux so he cant help me

eternal oxide
river oracle
undone axleBOT
minor junco
eternal oxide
#

Linux or windows makes no difference when making a Spigot plugin

minor junco
#

this is a #help-development channel to generally help people with developing their plugins

timid hedge
timid hedge
eternal oxide
#

I don't go in General, unless it's to annoy someone.

minor junco
#

@timid hedge best thing you could do is message the author and have a chat with them

#

if they made that plugin for you specifically

timid hedge
#

I have, but as said, im getting 0 help. He dosent respond to me.

shadow night
quiet ice
minor junco
quiet ice
#

Although, sscanf probably works on both with it being in the c stdlib

timid hedge
minor junco
#

try resetting your password first

timid hedge
#

How do i do that?

molten hearth
#

if mysql isn't found use mysqld

timid hedge
molten hearth
#

You don't type that in the mysql shell

timid hedge
#

I justed command line

molten hearth
#

Wait, can you give me a tldr of what exactly you're trying to do

timid hedge
molten hearth
#

This is all hosted on the same machine, right?

eternal oxide
#

Have you installed MySQL?
Have you setup the database in MySQL?

timid hedge
timid hedge
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

eternal oxide
#

How did you setup the database in MySQL?

#

You should be creating your own database not using an already existing sys

timid hedge
#

So the plugin creates a database called "economy" but im getting the error in the console still

molten hearth
#

you didn't configure any password for root right? Worst case you can run the following in mysql

CREATE USER 'username'@'localhost' IDENTIFIED BY 'somepassword';
GRANT ALL PRIVILEGED ON database.* TO 'username'@'localhost';```
eternal oxide
#

then why did you have "sys" showing in your credentials?

#

if the db is actually economy

timid hedge
eternal oxide
#

if your plugin doesn;t have root access it can;t create a database called economy

#

show me your MySQL databases screen shot

timid hedge
#

How do i delete a database, i'll delete them and show

molten hearth
#

Does your base login even work? Try running

mysql -u root -p```

From cmd and don't provide a password
timid hedge
molten hearth
#

do you have some mysql connection tool

timid hedge
#

I dont think so

molten hearth
#

What OS are you running

timid hedge
#

windows

eternal oxide
#

this is clearly where the dev said he could not help you as he ran Linux

#

your basic SQL setup

molten hearth
#

😭

timid hedge
#

?

molten hearth
#

I think this installs mysql-cli?

eternal oxide
#

First, your plugin is most certainly not going to create a database for you. It would be so insecure to allow a plugin root access to create databases.

#

My "Guess" is you are expected to create the database

#

giving whatever user you choose full access to it

#

when you installed MySQL did you specify a password for root?

timid hedge
#

I dont know if the root password is my password or what it is, but i have 1 password that im using for the mysql command line example

#

I have shell installed now

molten hearth
#

if you type mysql in you cli does it work?

timid hedge
#

MySQL JS > mysql
<mysql>

molten hearth
#

o-O

timid hedge
#

Shouldnt i type it in shell?

molten hearth
#

No from CMD

umbral ridge
#

you could completely avoid connecting to the sql server by creating a web api that manages it

timid hedge
molten hearth
#

Do you have a mysql.exe file in your cli

timid hedge
#

how do i check that?

molten hearth
#

I meant in your files sorry*

umbral ridge
timid hedge
#

You mean if i have a program called mysql.exe?

molten hearth
#

yeah

#

Somewhere in your files 😭 🙏

timid hedge
#

nope

umbral ridge
#

run an installer

#

what tf is shell??

#

you need to install it

#

just like python

#

and others

molten hearth
#

He already installed mysql

#

But he doesn't have the cli

umbral ridge
#

then it should be accessible

#

via console

molten hearth
#

Well its not lol

umbral ridge
#

then they've done something wrong

#

reinstall it

timid hedge
#

The only "products" i should have is server and workbench right?

hazy parrot
#

why not just install xampp or smth

umbral ridge
#

probably forgot to check "add to path"

#

or something

hazy parrot
#

i always do that on windows

umbral ridge
#

what is workbench

timid hedge
#

i saw it in a video

umbral ridge
#

install MAMP or XAMPP

hazy parrot
#

workbench is for working with database

eternal oxide
#

it comes with mysql

umbral ridge
#

that way you get a web server and mysql

#

and mail server and others, all in one package

#

then you can access it locally

eternal oxide
#

god no, don;t install extra things

umbral ridge
#

well its optional

eternal oxide
#

he has enough problems using MySQL itself

umbral ridge
#

i have mamp

eternal oxide
#

at a command prompt (CMD

#

type services mysql stop

timid hedge
timid hedge
eternal oxide
#

then type services mysql start

#

it shoudl also give no response

timid hedge
#

yeah

eternal oxide
#

then you have mysql running

#

one sec, openign my workbench

#

ok, open yoru MySQL workbench

timid hedge
#

yeah

eternal oxide
#

you shoudl see a local instance

timid hedge
#

Where?

eternal oxide
#

in the workbench

timid hedge
#

Oh yeah, yeah

eternal oxide
#

ok, double click that box

#

it shoudl open a query window

timid hedge
#

yea

eternal oxide
#

it shoudl show your instance running

#

click on the query tab

timid hedge
#

wait

#

Still getting the error when i launch the server

eternal oxide
#

what server?

timid hedge
#

mc

eternal oxide
#

oh my, do you have a problem with reading?

#

you don;t even have a database to connect to yet

timid hedge
#

Oh sorry my bad, forgot that

eternal oxide
#

click on the query tab

timid hedge
#

yeah

eternal oxide
#

type CREATE DATABASE economy;

#

press enter

timid hedge
#

i somehow already have a database called economy, so how do i delte that to make a new clean

eternal oxide
#

ok, thats fine, if you already have a db

#

expand it and see if it contains anything

timid hedge
#

There stuff in there

eternal oxide
#

like tables

timid hedge
#

it has

#

luckperms

#

isnt there a DELETE DATABASE .... command?

eternal oxide
#

do NOT delete unless you know what you are doing

timid hedge
#

yeah, i havent done anything

eternal oxide
#

under the Server menu

#

pick users and privileges

timid hedge
#

Sorry i gotta go, ill come back soon

cobalt sphinx
#

Hey! How to stop endermites from spawning from enderpearls, but only for certain players?

I'm not even sure if it's possible to find out the reason why Endermite spawns? And if yes, then from which projectile?
I could use ProjectileLaunchEvent, store projectiles to some hashmap and check them after Endermite has spawned.

eternal oxide
#

enderpearl is a Projectile, getShooter()

#

when it hits

cobalt sphinx
#

Yes, but what about endermite?

#

Projectile part is easy

#

How to connect Ender Pearl with newly spawned Endermite?

eternal oxide
#

you don;t

#

you destroy the projectile and cancel the hit event so no endermite spawns

cobalt sphinx
#

But... doesn't it mean ender pearl never flies and player doesn't get teleported?

eternal oxide
#

you still want the player to teleport?

cobalt sphinx
#

Yes, just no endermite

eternal oxide
#

then teleport, cancel hit event, destroy projectile

cobalt sphinx
#

Oof that's hacky... Because I'm pretty sure even teleports have checks built into them.

eternal oxide
#

a pearl teleports you to wherever it hits

cobalt sphinx
#

Maybe it's easier to save Projectile Hit location to map and check for CreatureSpawnEvent, Endermite, location, reason Ender_Pearl

#

Huh :D

eternal oxide
#

Mine is cleaner

#

yours is liable to leaking objects

cobalt sphinx
#

Yeah, probably, need to check which to use, HitBlock or HitBlockFace or HitEntity

#

To get location where to teleport player to

eternal oxide
#

just create a method you can pass the event and it returnsd whichever is hit Location

#

then Player#teleport(getHitLocation(event));

cobalt sphinx
#

Yeah, works great! Thank you!

tender shard
#

why don't they fix their javadocs 🥲

rotund ravine
remote swallow
#

i think its null

shadow night
#

I mark everything as notnull and hope the worst case scenario where it is null does not occur

pallid oxide
#
    
@EventHandler
    public void onPlace2(PlayerInteractEvent e) {
        if (e.getHand() != EquipmentSlot.HAND) return;
        if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
        e.setCancelled(true);
        Block clicked = e.getClickedBlock();
        if (clicked != null) {
            Location loc = clicked.getLocation().clone().add(0,1,0);
            loc.getBlock().setType(Material.BEDROCK);
            e.getPlayer().sendMessage("Bedrock");
        }
    }```
Why does
```java
loc.getBlock().setType(Material.BEDROCK);```

call PlayerInteractEvent ?
If i have that line it calls "Bedrock" twice and sets 2 blocks, I need it to trigger it only once

I have hand checks ect, it works with everything except with setblock
grizzled relic
#

Hello. I want to obfuscate my plugin because it will contain a licence system. How can I do this?

quiet ice
umbral ridge
#

obfuscating the plugin doesn't really add any level of security

#

it's like hiding it in a bottle

cobalt sphinx
#

Is it somehow possible to get player last death location without saving it?
Maybe it's already saved somewhere?

inner mulch
umbral ridge
grizzled relic
inner mulch
inner mulch
grizzled relic
umbral ridge
cobalt sphinx
umbral ridge
#

i dont know how they could null it, if they spend hours to do it, then i guess you cant do anything..

umbral ridge
inner mulch
grizzled relic
#

I just realised. We've got three cat eclipses here lol

umbral ridge
quiet ice
#

Cat what?

umbral ridge
#

I once set up a system where i could remotely disable plugins

#

but yea only where the server was online

#

i guess if you pay for the plugin its expected of you to not share it... but some people are idiots and arent fair

eternal oxide
#

Don't disable a plugin if it's pirated. Make it do odd things

#

Nothing bad, but odd things like change everyones skin to steve

#

Bug reports become hilarious

umbral ridge
#

or start killing players randomly

eternal oxide
#

randomly spawn a wither near a player

grizzled relic
eternal oxide
#

nah, nothgin destructive

umbral ridge
#

i dont know how i would set up a licensing system

eternal oxide
#

You want them to not know they have been found out. You want them to report the odd behaviour.

umbral ridge
#

it would be hard to do it

#

the idea itself sounds simple but to handle everything.. what ifs

eternal oxide
#

Spigot doesn't allow licensing system, but in premium plugins you can insert a key when its downloaded

#

pretty sure you can match that key to a sale

umbral ridge
#

that key has to be somewhere in the db tho for every person that purchased it

#

sounds rather complicated

#

and then check for that key in the plugin

#

again... have to connect to the db of some sort

#

what if they're running an offline server

grizzled relic
#

Some will not know how to resolve the obfuscated plugin. I think they leak more plugins by taking role-style things when they share on some sites. Maybe obfuscate could prevent the freaks who don't know anything.

eternal oxide
#

nope, you only need to ask them for the key when they use support

#

get them to pay for support not the plugin

umbral ridge
grizzled relic
#

but as a result they can use the plugin for free. Their only loss is the lack of support

timid hedge
umbral ridge
#

you could force the player to get the server online in order to check for licensing

#

hmm

#

ill try it

grizzled relic
minor junco
#

Honestly spigot should publicize and allow a native licensing API that strictly follows their rules

minor junco
#

People can just buy a plugin and sell it for less, which ain't great

grizzled relic
grizzled relic
umbral ridge
#

so you can't implement licensing or any kind of plugin disabling logic in free plugins? if you publish them on spigot?=

#

even if its just for statistics, your own database system where you analyze certain things

minor junco
#

well you can as long as users can access the plugin without an internet connection

umbral ridge
#

so thats basically a no

minor junco
#

Unfortunately

grizzled relic
#

So there is no other way to solve this leak problem? I can't think of anything else.

umbral ridge
grizzled relic
#

If this happened, we could embed a value in it somehow and simply cancel the licences.

remote swallow
#

you can use %%nonce%% in a premium plugin

umbral ridge
#

but again that would be an ass.. what if you're switching servers.. meh.
I would handle it myself but spigot policy is an ass

#

idk

remote swallow
#

fym idk

#

it literally gives you placeholders to use for that exact idea

umbral ridge
#

thats still not secure. how are you supposed to know whos using the premium plugin? "y" purchased it but "x" is using it

remote swallow
#

you dont

#

you only care about giving support

umbral ridge
#

that's exactly the issue

remote swallow
#

thats how 90% of premium plugins on spigot work

umbral ridge
#

what if they dont need support

#

XD

remote swallow
#

good for them

#

something breaks that only you know how to fix they cant fix it without verifying a purchase

umbral ridge
#

I guess yeah. and also they'll have to "wait" for updates and bug fixes

#

if they haven't purchased it and are using someone elses

#

i guess its not so bad then

river oracle
tame wolf
#

Most of the time a leak is just a server owner that purchased it giving it to a staff that asked

rotund pond
remote swallow
#

thats the smart thing to do

tame wolf
rotund ravine
#

Don’t encourage naughty things here smh

rotund pond
tame wolf
#

Joke

#

(Hopefully not a real leak)

grim hound
#

This is so advanced I cannot comprehend it

young knoll
#

Wat

grim hound
quaint mantle
#

so much yapping in there

valid burrow
#

how can i give a block this break animation

#

couildt find anything on it

vapid grove
#

or you could use mushroom block states

#

use a texturepack that overlays certain models only by a specific id

valid burrow
#

that all sounds like a horrible ideas

#

i bet its possible with packets somehow

vapid grove
#

probably but i, for some reason, overcomplicate things

valid burrow
vapid grove
valid burrow
#

can a player not recieve multible blocks breaking at the same time?

#

ah i figured it out

#

it cant have the same source id

#

got it

tender shard
#

gradle is so stupid sometimes

#

Easy fix: Set java toolchain to 17 but do not use java in your project, but kotlin. And set the kotlin toolchain to 8. And now you end up with a perfectly fine .jar for java 8 without gradle refusing to access java 17 dependencies

quiet ice
#

If you were to write this method yourself there might be some overhead due to calling INVOKESTATIC, however due to @ForceInline, the method call never occurs, but the GC still considers the argument to be still in use and won't prune it

#

I've yet to figure out if there is a use to that method, but idk there probably is

dry hazel
sand spire
#

How to play a specific sound because this has 10 different sounds and I only need the 2 whistles player.playSound(player.getLocation(), org.bukkit.Sound.ENTITY_DOLPHIN_AMBIENT_WATER,1,1);

ashen vessel
#

Im trying to use a local jar file in my project, I imported it and used a maven command to load it successfully, but it still doesnt work. Is there a chance I could get some help?

vapid grove
tender shard
dry hazel
#

5.3, pretty old stuff now

ashen vessel
#

https://gyazo.com/c15aca0aa0ced9a6fd47e91f5db67722
https://gyazo.com/85fc30e849e60064710dbf1a31e941b0
https://gyazo.com/f3a8f463e89cbe782fc43c675b483904
https://gyazo.com/c1c55616a4f5b5d5b0091b7affb8e84a
So I was talking with a developer who I guess put some work into this PlayerStats plugin. He said he couldnt use the plugin as a direct dependency on maven and had to locally import the jar. So I did, I have it added as a dependency and ran this maven command to import it mvn install:install-file -Dfile=C:\Maven\statz-1.6.2.jar -DgroupId=me.staartvin -DartifactId=Statz -Dversion=1.6.2 -Dpackaging=jar
Im unsure to why some of it is working and the rest not. When the wiki itself says to use this method. The javadoc link does not work....unfortunately.

tender shard
tender shard
#

open it with winrar or sth and check if you find that class

ashen vessel
#

Ok standby

#

would it just be called StatzAPI.class or is it something else im looking for?

sterile token
#

@pseudo hazel sorry for tagging you, but i been rechecking my code and the problem as i said,. was caused by wrong recusivity done while checking permissions

tender shard
#

well there you go, the .jar doesn't include that class

#

so either it's just called API or you got the wrong jar

#

or the docs are just outdated

ashen vessel
#

Ok....let me tinker for a minute

tender shard
#

although it makes little sense to change a class name from StatzAPI to API...

#

is that statz dude hosting their javadocs on a minecraft server 😮

ashen vessel
#

No idea 😄

tender shard
#

yeah anyway, as I said, the docs are outdated or sth, the class is simply called "API"

#

a very bad name for a class but well

ashen vessel
#

Lol yeah, alright let me try that. I was trying to myself but no success

sterile token
ashen vessel
remote swallow
#

its not a static method

tender shard
#

thanks, that'll be useful for the future

ashen vessel
tender shard
#

getStatzAPI is definitely not part of Plugin

#

you have to cast the "statz" plugin instance to its actual class

#
Statz statz = (Statz) getPluginManager().getPlugin("...");
API api = statz.getStatzAPI();
ashen vessel
#

OOOOOk it is making so much more sense now. Everythings working more and more haha. except the getter method for some reason

#

Hovering over error method, says "; excpected"

remote swallow
#

thats a method in a method

#

cant have methods in methos and you cant have it access statzApi there

ashen vessel
#

Right

remote swallow
#

make statzApi a class variable and move the method outside it

ashen vessel
#

Ok.....I think I got it

#

Looks good to me, hopefully it looks good to you

remote swallow
#

yup

ashen vessel
#

Sigh Thank you so much

grim hound
#

Advanced smart-sounding smart stuff

vapid grove
#

how do i get teh servers tps

young knoll
#

I don’t think that’s exposed

#

Actually it might be with the new tick command

vapid grove
#

it be useful

young knoll
#

Well there’s also NMS

#

Papi may also have a placeholder for it somewhere

minor junco
river oracle
#

or you just use the field value minecraft gives you

river oracle
#

but not the servers current tick rate overall e.g. if the real tps was 1 the tick manager would still return 20

tender shard
#

Gpt4 is soo worth it for rewriting code

young knoll
#

Can we shove all of craftbukkit in it

#

Kek

tender shard
#

I guess thatd take a few days lol

keen horizon
#

any idea why my command just doesnt do anything

#
class LivesCommand : CommandExecutor {
    override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {

        val targetPlayerName = args?.getOrNull(2)

        if (targetPlayerName == null) {
            throwUsageError(sender)
            return false
        }

        val targetPlayer = Bukkit.getPlayer(targetPlayerName)

        if (targetPlayer == null) {
            throwUsageError(sender)
            return false
        }

        val targetplayerData = ManagePlayerdata().getPlayerData(uuid=targetPlayer.uniqueId.toString(), name=targetPlayer.name)


        val heartsString = (targetplayerData.maxhp / 2).toInt().toString()
        val msg = Lifestealz.formatMsg(true, "messages.getHearts", "&c%player% &7currently has &c%amount% &7lives!").replace("%player%", targetPlayer.name).replace("%amount%", heartsString)
        sender.sendMessage(Component.text(msg))
        return false

    }

    private fun throwUsageError(sender: CommandSender) {
        val usageMessage = formatMsg(false, "messages.usageError", "&cUsage: %usage%").replace("%usage%", "/lives")
        sender.sendMessage(Component.text(usageMessage))
    }
}

remote swallow
#

that looks like a paper api moment

keen horizon
#

so how would i fix it

eternal oxide
#

Spigot != Paper

#

?fork

undone axleBOT
#

SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.

remote swallow
#

i doubt many people here know kotlin (ignoring alex) and thats paper api so cant help with that

keen horizon
#

o ok

keen horizon
#

sorry im new to plugin makery

keen horizon
#

nevermind

#

still doesnt work

young knoll
#

That gets you the target tps

#

Not necessarily the current tps

tender shard
#

Huh when was that added

#

I remember md refusing to add getTps()

eternal oxide
#

Typo/grammar - Should be than normal

next plume
#

You can grab EssentialsX's TPS number.

tender shard
young knoll
#

It’s a new class that came with /tick

tender shard
#

Fanceeh

young knoll
#

But yeah it isn’t the real tps

#

It’s the target tps

next plume
# next plume You can grab EssentialsX's TPS number.
// Hook in to Essentials
Plugin essentials = Bukkit.getPluginManager().getPlugin("Essentials");
double tps = -1.0;
if (essentials != null && essentials.isEnabled()) {
    IEssentials ess = (IEssentials)essentials;
    EssentialsTimer timer = ess.getTimer();
    if (timer != null) {
        tps = timer.getAverageTPS();
    }
}
#

People can argue all day long what the "real" TPS number is.

young knoll
#

Lol

#

I mean the server stores what it considers the tps

#

So

next plume
#

Doesn't mean it's right.

#

For example, the server's calculation of each player's ping time is mathematically wrong.

young knoll
#

That’s because it’s a rolling average

next plume
#

No, it's not a rolling average.

young knoll
#

What’s the word for an average over a long period of time

#

I guess just an average

#

Kek

next plume
#

A useless number, that's what it is.

#

So make a spreadsheet and put the first entry at 500 (because the player's wifi hiccupped), then follow that with a bunch of lines at 10. Tell me how long it takes for the average to reflect his real ping time of 10.

#

Spoiler: ||An infinite amount of time.||

#

Now a rolling average would be useful! But that's not what the server does.

young knoll
#

Smh people beg for us to expose the method and then it’s not good enough

#

:p

next plume
#

Because Mojang calculates it wrong.

#

For example, the server's calculation of each player's ping time is mathematically wrong.

young knoll
#

Well go ask John Mojang to fix it

#

:p

next plume
#

Dinnerbone will get right on it.

#

Anyway, I was saying that the server's calculation of TPS is not necessarily correct.

eternal oxide
#

mean over time is most accurate, where median would give the most common

next plume
#

Is EssentialsX's any better? I don't know.

#

You'd probably want to throw out any measurements that exceed some standard deviation value. (I'm not a math person.)

eternal oxide
#

depends on what you are after

#

mean will show lag spiked, but median would not

young knoll
#

I mean a rolling average of like 60 seconds seems reasonable

next plume
#

A weighted average back to the beginning of time is not necessarily useful.

eternal oxide
#

yeah, its generally best a rolling time period

young knoll
#

Idk how often keep alive packets are sent, but just the average of the last few would do

eternal oxide
#

Its how I calculated weapon DPS in a plugin for another game years ago

next plume
#

Mojang could have kept track of the last 4 measurements, but that's not what they do. I think they broke it starting in 1.12

young knoll
#

Wonder why

next plume
#

Keep Alive used to be every 25 seconds, now it's every 15 seconds.

sterile token
#

Cant you get tps from MinecraftServer object or something similar

young knoll
#

Yes

#

But it’s NMS

sterile token
#

yeah, thats a good point

next plume
#

The Fork That Shall Not Be Named exposes the TPS, as a three element array with the values over the past 1, 5, and 15 minutes.

late sonnet
remote swallow
#

i think md doesnt think tps should be api exposed

young knoll
#

Yeah he’s said that

eternal oxide
#

Tps is (as he says) a meaningless value

next plume
#

I don't know why, except that you can argue how to calculate it until the cows come home.