#help-development

1 messages · Page 362 of 1

drowsy helm
#

elaborate then

#

your question doesnt make sense

grand flint
#

What does that method do excatly?

drowsy helm
#
The player's client will download the new resource pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached the same resource pack in the past, it will perform a file size check against the response content to determine if the resource pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.```
grand flint
#

Okay thank you, and I can provide a url with that method?

drowsy helm
#

yes

#

so depending on their choice, you can use a diff url

grand flint
#

Last question, I can run that method any point the player is in the server right? Not just when they join

drowsy helm
#

yes

grand flint
#

Okay thank you very much

#

Oh, lastly that is a bukkit method right

drowsy helm
#

uuh not sure if its bukkit

grand flint
#

So it won't work without the spigot jar?

drowsy helm
#

youll have to look that up yourself im not sure

#

no one uses standalone bukkit anyways

grand flint
#

Okay no worries, thank you

#

I have my own jar that is why

remote swallow
#

most things are a fork of spigot or paper so should all work

#

if you arent using spigot or paper to fork ( ignoring minestorm) you messed up

half arrow
hazy parrot
half arrow
hazy parrot
#

can you send MySQLHelper.java:27

#

also are you sure

#

that your mysql server is running

#

like can you connect to it outside of plugin

half arrow
#

I assume so, its hosted by hostinger - surely if its getting to this point its connecting

hazy parrot
#

doesn;t have to be

half arrow
#

ah okay

hazy parrot
#

also maybe your user doesn't have required permissions for database

#

try to connect it with workbench or smth

half arrow
#

i've opened the db up so anyone can connect

#

ill try that

hazy parrot
#

it usually have one more chained exception which describes issue closer

#

not sure why its not case here

#

also consider using prepared statements for queries if input may be declared by player

half arrow
#

will do, just need to get it connecting first

half arrow
hazy parrot
#

lmao

#

i noticed just now

hazy parrot
half arrow
#

whoops!

#

lemme get it

hazy parrot
#

looks like multicraft skipped actual error

half arrow
hazy parrot
#

javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

#

ig you can just disable ssl in your connection url

#

as looks like driver isn't supporting it or whatever

#

?useSSL=false

half arrow
#

changed the error, access denied now 😒

#

at least it's accessing the page now

hazy parrot
#

your user doesn't have permission to access database

#

have you granted it all permissions ?

half arrow
#

strange, its the user that created the DB

#

yeah, just gone and saved them again

#

....

#

I had the host as the username...

#

Genuinely surprised i've made it this far in life so far... thanks @hazy parrot

wet breach
#

Dont need ssl if db is on same host anyways. Just make sure you disbale listening for outside connections and make it listen on loopback only

hazy parrot
real fable
#

Players in same scoreboard team can see each other while invisible, is there any way to disable that and let the player be invisible for everyone ?
found team.setCanSeeFriendlyInvisibles(false); will try it

lost matrix
novel totem
#

Is there a way to bypass the 4 parameter limit in createExplosion method or are there any other way to create an explosion with more parameters?

hazy sapphire
#

Help, I try to build my plugin but everytime I do I get this error. Unsupported class file major version 60

#

I need it is because of the java version that my dependencies use but honestly the only one I see that can affect is bstats and if I disable it, it will give me an error saying I need it for other dependencies

quaint mantle
#

anyone know how to load a plugin from a jar that came over rest api
not a physical jar?

rotund ravine
#

Just update your java?

#

@quaint mantle Save the jar, load the jar. Delete after use.

regal scaffold
#

Is it possible to make a custom item (Block ) and then detect when that item is placed or something? Can I attach a event trigger to an item? Do I have to listen for BlockPlaceEvent and check that it's my item?

rotund ravine
#

I mean, yes everything is possible.

regal scaffold
#

Is the best and simplest way just to listen to blockplaceevent? rephrase

rotund ravine
#

Yes

regal scaffold
#

What are good ways to identify if the item is the one I need?

#

Name?

rotund ravine
#

?pdc

regal scaffold
#

Oh yeah forgot about those

#

Alr thanks jan

rotund ravine
#

What does he need more parameters for anyway

regal scaffold
#

What was a good tool to decompile plugins I was once told. It had a 1 word name

#

To convert to .java not just view

rotund ravine
#

There’s plenty of decompiler.

#

Fernflower etc.

regal scaffold
#

There's 1 someone in this chat said. Someone that talks a lot

#

Seems good enough

rotund ravine
#

Quiltflower too

regal scaffold
#

Luyten

rotund ravine
#

That’s a decompiler gui

regal scaffold
#

Ummm is there a difference or it just has a GUI compared to the others?

rotund ravine
regal scaffold
#

It still allows to convert to a zip so I assume it's the same

rotund ravine
#

Sure, it’s just a gui on top of some sort of decompiler then

regal scaffold
#

Thought so. Thanks

wet breach
#

There is also jd gui too

#

Simple and lets you extract to a zip or directory. Nothing fancy but lightweight if that is all you need

sterile token
#

Okay findind new Gson issues, let go ahead

Error dispatching event PostLoginEvent(player=Alexito2060) to listener dev.alex.net.inviter.bungee.listener.UserListener@1a1d3c1a
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a long but was BEGIN_OBJECT at line 1 column 129 path $.played

Please let me know!!!

regal scaffold
#

Is StringUtils not part of java?

#

Cannot resolve symbol 'StringUtils'

tardy delta
#

Bukkit paxkage

#

Probably StringUtil

regal scaffold
#

Different one, with an S at the end

#

How is that possible

tardy delta
#

Dunno which one you are talking about

regal scaffold
#

Someone sent me a snippet of something and they used
StringUtils.deleteWhitespace(s) where s is a String

#

And there is no class called StringUtils

tardy delta
#

Maybe their own

sterile token
#

So it must be a custom class

regal scaffold
#

They don't have one called that

#

I'm looking at them all

#

Used search

sterile token
#

🤔

regal scaffold
#

Oh. it's apache commons lang

sterile token
#

Look for the class import

#

Oh yeah, also apache commons lang is already included with the spigot

regal scaffold
#

Annoying lol

sterile token
regal scaffold
#

Dependency to use a single method 8 times

#

That's all

sterile token
#

🤔

#

You are wrong, apache commons lang, is used for more things inside the Spigot

#

For example Locale if im not wrong

wet breach
#

Also has some other handy methods too

regal scaffold
#

Is

import java.util.*;
import java.util.stream.*;

Redundant? Doesn't util.* include everything? Why would this be here

earnest forum
#

doesnt include sub packages

#

im pretty sure

regal scaffold
#

Oh what seriously. tf I had no clue

#

I'm over here just doing code analysis

#

Collector<? super Object, ?, List<String>>)Collectors.toList()

error is

#

Could it be a difference in versions?

tardy delta
#

Show code

regal scaffold
#
    public static List<String> placeHolder(final List<String> list, final Map<String, String> map, final boolean b) {
        Validate.notNull((Object)list, "The string collection can't be null!");
        Validate.noNullElements((Collection)list, "The string collection can't have null elements!");
        return (map == null) ? list : list.stream().map(s -> placeHolder(s, map, b)).collect((Collector<? super Object, ?, List<String>>)Collectors.toList());
    }
onyx fjord
#

Any lightweight just color library?

#

Must have unlimited gradients

#

And shit like that

#

I like iridium but there's only single gradient

sterile token
#

I having some troubles parsing mongo long fields, what do suggest? Im parsing them via Gson

#

Because so far, mongo uses something really weird for storing the longs, its store as {"$longNumber": "1941841541"}, and so far gson cant serialize the object

#

Im getting this annoying issue while converting a user data from Mongo, into java object

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a long but was BEGIN_OBJECT at line 1 column 129 path $.played
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224)
    at com.google.gson.Gson.fromJson(Gson.java:887)
    at com.google.gson.Gson.fromJson(Gson.java:852)
    at com.google.gson.Gson.fromJson(Gson.java:801)
    at com.google.gson.Gson.fromJson(Gson.java:773)
    at dev.alex.net.inviter.core.manager.UserManager.load(UserManager.java:32)
    at dev.alex.net.inviter.bungee.listener.UserListener.onJoin(UserListener.java:22)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
timid jetty
#

hey whats a good way to send notifications to the player other than chat messages?

hybrid spoke
#

you can spam them with sounds

#

morsecode the message

timid jetty
#

like text updates

hybrid spoke
#

in what context

timid jetty
#

player does action -> text pop up on screen
probably dont wanna use boss bars here or chat

#

i wanted to know if there is alternatives

hybrid spoke
#

hotbar, title, sound, hologram

timid jetty
#

whats hotbar?

#

and whats hologram

#

title is also a bit too big

#

okay i found action bars ty

wet breach
#

You could even use scoreboards

#

Which might be better because you can hide the scoreboard after a delay

#

Hologram would be handy if you wanted them to stop and read it if it pops up in front of them

#

Hotbar is at the bottom where you can see items, you can have text above that

rough drift
#

@timid jetty Try using achievements

timid jetty
#

achievements interesting

#

how would that works

rough drift
#

Achievements have text in them, so you can use them as small action indicators (such as legendary item notif or something)

regal scaffold
#
    public static List<String> placeHolder(final List<String> list, final Map<String, String> map, final boolean b) {
        Validate.notNull((Object)list, "The string collection can't be null!");
        Validate.noNullElements((Collection)list, "The string collection can't have null elements!");
        return (map == null) ? list : list.stream().map(s -> placeHolder(s, map, b)).collect((Collector<? super Object, ?, List<String>>)Collectors.toList());
    }

error is

rough drift
#

You'd just need to register one achievement

timid jetty
#

okay interesting

#

i mean i dont think thats really the best UX for what im working on right now but ill keep that in mind ty

wet breach
#

Only thing you would need to do though is remove the achievement unless they are all unique

timid jetty
#

anybody have any resources on creating particles in an aura around the player before I go and make it myself lol

tender shard
#

every single of your casts is unneccessary and the last one is even wrong

#

and you also cannot throw "s" into your placeHolder method because "s" is a string and not a List<String>

#

what is it even supposed to do? I don't really get it

regal scaffold
#

I'm not doing them myself. I'm analyzing code

tender shard
#

in case "map" is a list of placeholder->replacement, and you wanna apply it to all strings in "list", you'd do it like this:

    public static List<String> placeHolder(final List<String> stringsToApplyPlaceholdersTo, final Map<String, String> placeholders) {
        return stringsToApplyPlaceholdersTo.stream().map(entry -> {
            for(final Map.Entry<String, String> placeholderEntry : placeholders.entrySet()) {
                String placeholder = placeholderEntry.getKey();
                String replacement = placeholderEntry.getValue();
                entry = entry.replace(placeholder, replacement);
            }
            return entry;
        }).collect(Collectors.toList());
    }
regal scaffold
#

What I'm trying to figure out is why would this actually compile and work on a different system when on mine it won't

tender shard
#

because your decompiler is weird

#

or is that actual source code? o0

regal scaffold
#

Yes

#

Source code

#

Straight

tender shard
#

it cannot compile

regal scaffold
#

Yeah I thought so

tender shard
#

where did you get it from lol

timid jetty
#

Quick Question: with a delayed task in bukkitscheduler, can you somehow delay the task even more after its been created?

tender shard
#

you can with CraftBukkit code

#

BukkitScheduler().runTaskTimer(...) actually returns a CraftTask

#

CraftTask has a a package-protected method "setNextRun(long)"

glossy venture
#

you need bson right

#

for mongo document

timid jetty
tender shard
#
        CraftTask task = (CraftTask) Bukkit.getScheduler().runTaskTimer(null, () -> {
            System.out.println(System.currentTimeMillis());
        }, 1, 1);
        try {
            Method setNextRunMethod = task.getClass().getDeclaredMethod("setNextRun", long.class);
            setNextRunMethod.invoke(task, 12345L);
        } catch (ReflectiveOperationException ignored) {

        }
#

this would set the "next run" of the task to 12345, which is probably is in "ticks since server startup"

timid jetty
#

okay i see

tender shard
#

it would be easier to just run your runnable every tick, then manually check if it should do sth now

wet breach
#

Instead of reflection you can optionally just cancel the task and reachedule it

timid jetty
tender shard
#

I'd ust do sth like

on every tick:
  if(this is correct tick) doSomething
  set correct tick = current tick + nextDelay
wet breach
#

But the better thing might be to create a method to check if it should run inside the task

#

And then this way you are not constantly cancelling tasks

#

Which is also what alex is saying

timid jetty
#

yeah i mean what alex is saying is definitely valid, but if im having a timer that refreshes on player action then what would be the most efficient way of dealing with that?

timid jetty
#

java.lang.IllegalStateException: EntityDamageByEntityEvent cannot be triggered asynchronously from another thread.
I got this error with a very simple line of code i dont know what the issue is here

    public void run() {
        // TODO Auto-generated method stub
        
        target.damage(damage, source);```
tender shard
#

wrap target.damage(...) into a scheduled task

#
@Override
public void run() {
  Bukkit.getScheduler().runTask(() -> {
    target.damage(...);
  }, myPlugin);
}
timid jetty
#

beautiful you absolute life saver

quaint mantle
#

hi

#

is there a good library for doing inventory GUIs?

#

i dont mind using another library for making inventory GUIs but i was just lazy and may have thought i would not need it, although, i might actually need it now.

eternal night
#

IF is nice

quaint mantle
#

i am writing a lot of boilerplate code i think right now.

eternal night
quaint mantle
#

probably writing boilerplate code that other libraries may already have something that abstracts it away.

#

dont wanna have NIH syndrome occuring to me.

#

or nvm

#

i might be too lazy to read that documentation probably i guess cuz i can just write my own code at this point and probably would end up taking the same amount of time.

#

yep, i am too lazy to read that documentation.

#

just gonna write my own event handlers.

tender shard
#

and I haven't used neither

echo basalt
#

ehh

#

I just make my own

#

I also made an image rendering lib similar to java AWT

#

very similar to my menu system

#

because my menu system is basically a low resolution screen

primal goblet
#

how to track when player right clicked on armorstand made by packets?

tender shard
#

ServerboundInteractPacket

#

probably

#

lemme check

#

yeah that seems to be it

#

it has a field "entityId"

#

and that's the NMS id of the clicked entity

safe ibex
#

I'm trying to make a small undertow API so I can send requests to my server via my plugin to do stuff triggered on other platforms, but it's not working.

This is the error:

[12:24:57 ERROR]: Could not load 'plugins\mcplugin.jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: Unknown/missing dependency plugins: [undertow-core, undertow-servlet, undertow-websockets-jsr]. Please download and install these plugins to run 'HeathSynchronisation'.
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:289) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_19_R2.CraftServer.loadPlugins(CraftServer.java:436) ~[paper-1.19.3.jar:git-Paper-399]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:273) ~[paper-1.19.3.jar:git-Paper-399]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1101) ~[paper-1.19.3.jar:git-Paper-399]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-399]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]

And in my pom.xml file I have this as dependencies:

<dependency>
  <groupId>io.undertow</groupId>
  <artifactId>undertow-core</artifactId>
  <version>2.1.0.Final</version>
</dependency>

<dependency>
  <groupId>io.undertow</groupId>
  <artifactId>undertow-servlet</artifactId>
  <version>2.1.0.Final</version>
</dependency>

<dependency>
  <groupId>io.undertow</groupId>
  <artifactId>undertow-websockets-jsr</artifactId>
  <version>2.1.0.Final</version>
</dependency>
#

So it should be fine...

vocal cloud
#

Jeez 3 different deps for one thing?

safe ibex
#

And in my plugin.yml it's like this:

depend: [undertow-core, undertow-servlet, undertow-websockets-jsr]
safe ibex
#

I just want to make a simple API inside of my plugin for external things to connect to to do things on the server that I design

#

@vocal cloud do you know what the issue is or a better way to acheieve what I want to do?

vocal cloud
#

Wait I'm confused. Did you put them as dependencies in your plugin.yml?

safe ibex
#

Yeah

#

Was I not supposed to

tender shard
#

only if "undertow-core", etc are separate/standalone PLUGINs

vocal cloud
#

^

safe ibex
#

I put them there AND pom.xml

tender shard
#

you probably just want to shade your three dependencies. remove the "depend" from plugin.yml

#

also did you add the maven-shade-plugin to your pom?

vocal cloud
#

dependencies in your .yml are other plugins that need to load before because your plugin depends on them

safe ibex
#

Ok it’s now only in the pom.xml file, so imma try it now

#

Different error now

tender shard
#

"depend: [mfnalex]" in plugin.yml means "I will not go the party before mfnalex has arrived.
"depends in your pom: mfnalex" means "I will go the party and I'll bring mfnalex with me"

safe ibex
#
java.lang.NoClassDefFoundError: io/undertow/Undertow
...
Caused by: java.lang.ClassNotFoundException: io.undertow.Undertow
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:177) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:124) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
tender shard
#

?paste your whole pom.xml

undone axleBOT
tender shard
#

you didnt shade your dependencies

#

as I said earlier, you need to use the maven-shade-plugin

safe ibex
tender shard
#

how did you compile? File -> Build artifacts?

#

because that's wrong

#

you gotta use maven. are you using intellij?

safe ibex
#

yeah I built artefacts

tender shard
#

thats wrong. In the upper right corner of IJ, there's a "maven" tab. Go there, then go to "YourPluginName" -> Lifecycle -> Double click on "package"

#

now you got a working .jar in <yourProjectFolder>/target/YourPluginName-1.0.0.jar or similar

safe ibex
#

ok I double clicked package

#

but wait why did youtubers etc say to build artefacts then

#

it's been working up until I want a dependency

opaque latch
#

Did they remove PersistentDataType.STRING_LIST?

tender shard
tender shard
#

Use this:

#

?morepdc

undone axleBOT
safe ibex
#

Wait how do I change that package location then when I run that script? @tender shard

#

So it goes straight into a diff folder than target

tender shard
upbeat hornet
safe ibex
#

Wait which plugin scope of my pom.xml file do I put it in? There's a plugin entries for the following artefact IDs: maven-compiler-plugin and maven-shade-plugin

tender shard
#

You need to add the whole block as a separate plugin

safe ibex
#

So

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

Inserted into my plugins part of my pom.xml?

tender shard
#

yes

#

Correct

safe ibex
#

Ok!

#

One second

tender shard
#

sth like this

#

if in doubt, send your current pom.xml again

#

and I'll check

safe ibex
#

"Plugin 'org.apache.maven.plugins:maven-jar-plugin:3.3.0' not found"

tender shard
#

no problem, just hit "package" and it'll download it

#

it's just IJ complaining that it isnt downloaded yet, but maven will do that automatically

safe ibex
#

Ay it worked putting it there

#

So now I'll try the plugin

tender shard
#

be sure to check that you don't have two versions of your plugins in your plugin folder though

safe ibex
#

Yeah I got rid of the old one, thanks

tender shard
#

oki np

safe ibex
#

Uhhh looks ok?

#

AHAH: [io.undertow] starting server: Undertow - 2.1.0.Final

#

Yay it works, thanks a lot man - appreciate it :)

tender shard
#

great! no problem

#

90% of my work here is to send my blog posts lmao

safe ibex
#

Lmfaooo yeah

#

I get that

#

I mean I'm coming from an entirely TypeScript and C++/Rust experience background, with some Kotlin - but no Java lol

#

But yeah thanks :)

tender shard
#

yeah well you can ofc do java without using maven

#

but maven makes your life much easier in the long run. only at first, it's very confusing

safe ibex
#

Yeah but then you don't get the sweet packages 🤤

onyx fjord
#

Always use a build system

tender shard
#

yeah

safe ibex
#

Did use Gradle with kotlin at one point and it was more painful than this lmao

onyx fjord
#

Doesn't matter if it's gradle or maven

onyx fjord
tender shard
#

you can also use kotlin just fine with maven

onyx fjord
#

They mean gradle kotlin syntac

safe ibex
#

pog API is all working, got a Hello World back 🤣

#

Alright thanks guys, have a lovely day <3

onyx fjord
#

God bless

tender shard
cobalt thorn
#

Hi, i made the plugin add an effect but the effects don't combine, there's a way? this is the code i used

p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20 * Config.XANAX_COOLDOWN.getInt(), Config.XANAX_AMPLIFIER.getInt()));
tender shard
#

Lmao a benzodiecapine plugin

hazy parrot
#

Xanax

#

Cool

tender shard
#

Wheres lorazepame?

#

Or valium

#

Why only alprazolame 😦

hazy parrot
#

xanax = increse damage

#

good to know

tender shard
#

Makes sense though, you hurt yourself all the time and do not really notice

onyx fjord
#

Add weed

#

(regeneration)

#

Or instant healing

safe ibex
#

Does anyone know how to get a string property from a config.yml file?

The following is all of my files in the plugins folder of the server:

bStats
config.yml
HeathSync.jar

The plugin is HeathSync.jar and I want to read off a config.yml file that I created that looks like this:

api-secret: "xxxxxx"
hazy parrot
#

config.yml of your plugin must be inside of folder named same as your plugin

#

you shouldn't manually just yeet config inside of plugins folder

safe ibex
#

so then put that yml in a folder called HeathSynchronisation

#

oh yep

#

that works

#

thanks 🤣

tender shard
# onyx fjord Add weed

how would weed regenerate or make someone healthy lol. weed would just make you anxious or sleepy and hungry

tender shard
half arrow
#

hey, can anyone suggest a stress test method for my database helper class? realistic when will i start to notice lag using HikariCP/Mysql

tender shard
#

just wrap every statement into a for(int i = 0; i <= 100; i++) statement lol

#

or run stress-ng on your database server with idk, 128 cpu workers lol

#

that's the best I can imagine

half arrow
#

its more how many players will start to cause lag, the database update/inserts happens when a player leaves/quits

tender shard
#

are you doing your database queries synced or async?

#

you would normally would want to use sth like CompletableFuture for stuff like this

#

then you can do DB queries WITHOUT blocking the main thread

half arrow
#

Okay i'll take a look in to that

tender shard
#

be sure to notice one thing: If you right now do stuff like this:

public void onJoin(...) {
  int money = myDbHelper.getMoney(player);

you CANNOT just replace it with futures

#

you have to rewrite everything where you get your data from

#

a CompletableFuture is an object that does stuff in the background, you will make your code also want to wait until it got an "answer" without just calling .get() on it

#

Baeldung has a nice tutorial about CompletableFutures

half arrow
#

thank you

tender shard
#

it doesn't make you healthy, it just removes symptoms

#

if you broke your leg, morphine doesnt make it "unbroken" again, it just makes you not feel the pain anymore

#

I bet that weed causes more health problems than it solves, e.g. people suddenly starting to get anxiety problems or simi lar through smoking too much weed

#

but help-dev is probably not the right place to discuss this

quaint mantle
#

Hey guys, How can I detect click item in a inventory to player inventory?
Like below pic

quaint mantle
quaint mantle
#

I think it's literally drag event

echo basalt
#

InventoryClickEvent

quaint mantle
#

use getAction method ?

worldly ingot
#

Yeah, you want InventoryClickEvent but there are going to be two of them. One for clicking in the top inventory, one for clicking in the bottom

quaint mantle
#

Oh I'll try it

#

thank uu

quaint mantle
rotund ravine
#

No

worldly ingot
#

You should only need to listen for the one

tawdry parcel
#

I want to change the death message in chat, so I wrote:

    @EventHandler
    public void onPlayerDeath(PlayerDeathEvent event) {
        event.setDeathMessage(ChatColor.GRAY + "» " + ChatColor.RESET + event.getDeathMessage());
    }
```but of course that also changes the death message in the menu, how can I fix that?
quaint mantle
tawdry parcel
#

oh okay :C

vale ember
tawdry parcel
terse ore
#

maybe

#

there's a way to not send the death message

#

but probably not possible to do with spigot api

tender shard
#

You just added >> to the message and it did that?

rough drift
#

Making a fork

terse ore
tender shard
#

no way to change this except maybe resource packs or sth

rough drift
#

if you send a death cause it changes

tender shard
#

even if, you still cannot use a "custom message"

#

if you want it to read "asdasd", you need a resource pack

#

that changes the language file

#

(if that's possible, at all)

#

doesnt it always say "You died!"?

#

no matter what the cause is?

rough drift
#

nope

#

it changes

#

Such as "was prickled to death", "fell out of the world", etc

tender shard
#

you mean the second line?

rough drift
#

Yeah

tender shard
#

because the first line is always "You died!"

rough drift
#

that's what they want to change

tender shard
#

aaah now I understand

#

yeah ok

rough drift
#

Separate chat message and the 2nd line

tender shard
#

ok, then I have no idea if that's possible

rough drift
#

It is actually

tender shard
#

and how?

rough drift
#

Don't know if the API can

#

But basically when the death is sent iirc there is some death cause

#

lemme check

tender shard
#

yeah a death cause, but that still only then uses the default vanilla translation

rough drift
tender shard
#

ah ok

#

99.99% sure the API cannot change it

#

gotta listen to outgoing packets and change it there

rough drift
#

Yep

tender shard
#

time for a pull request

#

since my first actual CraftBukkit PR was merged, maybe this could be my second one lol

#

if someone opens a feature request on jira, I'll add it

rough drift
#

Hey alex

#

talking about that

#

I did it before I just forgot how lol

tender shard
#

?contribute

tawdry parcel
#

And I also wanted to change the /kick message, how would you do that?
I tried this but for some reason it's not working (no error message or something like that):

package com.koner.the5utils.punishments;

import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerKickEvent;

public class KickCommand implements Listener {
    @EventHandler
    public void onPlayerKick(PlayerKickEvent event) {
        event.setCancelled(true);
        event.getPlayer().kickPlayer(ChatColor.RED + "You were kicked!\n" + ChatColor.RESET + ChatColor.BOLD + "Reason: " + ChatColor.RESET + event.getReason() + ChatColor.BOLD + "\nAuthor: " + ChatColor.RESET);
        //event.setLeaveMessage(event.getPlayer() + " was kicked because of " + event.getReason());
    }
}
tender shard
#

the message doesnt change, or the player doesnt get kicked at all?

opal juniper
#

StackOverFlow waiting to happen

tender shard
#

why dont you just use event.setMessage(...) or sth?

tawdry parcel
tender shard
#

your server probably dies

opal juniper
#

^

tender shard
#

because as oli said, it's an infinite loop

#

original event -> your listener -> new event -> your listener -> ...

tawdry parcel
#

ohhhhh

tender shard
tawdry parcel
#

oh i'm dumb

tender shard
#
public void onKick(PlayerKickEvent event) {
  event.setReason("Get rekd");
}
#

this should do it

tawdry parcel
#

but my server is still working fine xD

opal juniper
#

maybe it just shat the bed halfway through and carried on

tender shard
#

maybe kickPlayer doesnt call an event

opal juniper
#

is it registered?

tender shard
#

anyway, just change the kick message instead of kicking the player again

tawdry parcel
#

thank you

lost matrix
#

Does someone know if ProtocolLib has an enum for resolving this stuff?

opal juniper
#

not normally

lost matrix
#

The type int

novel totem
#

How would I need to add the explosionDamage, knockback and setfire so it would work? It currently gives me an error if I try to add any of them.
Cannot resolve method 'createExplosion(org.bukkit.Location, float, boolean, boolean, boolean)'

https://hastebin.com/share/vujepevave.java

runic plaza
#
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

public class SpawnerMinePlugin extends JavaPlugin implements Listener {

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

    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
        Block block = event.getBlock();
        if (block.getType() == Material.SPAWNER) {
            CreatureSpawner spawner = (CreatureSpawner) block.getState();
            ItemStack spawnerItem = new ItemStack(Material.SPAWNER, 1);
            spawnerItem.setItemMeta(spawner.getSpawnedType().name());
            block.getWorld().dropItemNaturally(block.getLocation(), spawnerItem);
        }
    }
}

So i have this code and the terminal gives me a long error when i want to compile it, can somebody help me please?

runic plaza
opal juniper
#

?paste

undone axleBOT
glad prawn
runic plaza
opal juniper
lost matrix
glad prawn
tawdry parcel
hybrid spoke
runic plaza
primal goblet
#

i'm trying to change the player skin but i'm facing a problem when trying to refresh or reload the player, how can i do it?

hybrid spoke
#

you will have to either use a wrapper or modify the fields directly

safe ibex
#

How would I find a player that's currently on the server based on their username?

hybrid spoke
hybrid spoke
hybrid spoke
#

maybe there's a cause

wet breach
#

its so good having 7smile7 back 🙂

#

so many more people will get help 😄

#

should say quality help lol

hybrid spoke
#

wasn't alex and me enough? :(

opal juniper
#

your help is bad 👎

wet breach
hybrid spoke
wet breach
#

o.o

opal juniper
#

someone forgot how git works

#

i have a copy locally lol

smoky oak
#

question for anti-cheat, if an item gets duplicated, is the duped item in any way different than the original aside from not fulfilling the == check? If yes, how?

runic plaza
#

@opal juniper can you help me in dms?\

hybrid spoke
wet breach
#

it is different because it is a new instance

opal juniper
#

nope, do it here, whats the problem

wet breach
hybrid spoke
runic plaza
#

so i downloaded maven to compile a java code

opal juniper
#

yep

hybrid spoke
safe ibex
#

Can you find a player that is currently offline and access their PersistentDataContainer?

#

And modify it?

smoky oak
#

get player from offlineplayer

tawdry parcel
eternal oxide
opal juniper
twilit wharf
#

I want to check for when a potion is fully drank. Not just interacted. How can I differentiate it? I couldnt find an event relating to it.

smoky oak
#

its just better to use uuid instead of name

hybrid spoke
lost matrix
eternal oxide
#

There is no Player for OfflinePlayers

safe ibex
# smoky oak get player from offlineplayer

I've got an array of offline players like this:

OfflinePlayer[] offlinePlayers = getOfflinePlayers();

However, when I try and do offlinePlayers.find or get there isn't such method

wet breach
safe ibex
#

It's just an array of OfflinePlayers

eternal oxide
wet breach
#

you can create player objects in spigot o.O

safe ibex
#

Wait how

#

I just want to get the dude if he isn't online basically

wet breach
#

its not exactly easy and not recommended if you are still learning

eternal oxide
#

well, you could fake a player object

wet breach
#

^

smoky oak
tawdry parcel
hybrid spoke
#

to give it a UUID is most likely the best you can do

safe ibex
wet breach
#

the only way you could check for dupe, is by monitoring the amount of items at any given time. Items currently existing, and items expected to generate

#

and then you detect if an item was created outside of this

#

if it was, it is a dupe

smoky oak
#

well i dont want to track dupes like carpet n stuff just items that have a lot of 'value'

#

idfc about carpet dupers

wet breach
#

then don't track carpets

#

doesn't change what I said though

eternal oxide
hybrid spoke
wet breach
#

you have to always know what items currently exist in the world, and basically all you are looking for is if an item gets created or generated that isn't expected to spawn or be created.

smoky oak
#

like my idea is to just periodically check all 'expensive' items in player inventories for their PDC and delete them if theres two with the same tag

safe ibex
wet breach
eternal oxide
safe ibex
smoky oak
wet breach
#

not always

#

depends on how it was duped

smoky oak
#

how the fuck do you dupe an item while deleting its nbt

hybrid spoke
#

but lore does dankfingers

eternal oxide
#

If a player is offline then mute is pointless. You only need to read data/mutes for Online players

safe ibex
wet breach
eternal oxide
#

oh an admin mute

safe ibex
#

Yeah!

eternal oxide
#

Use the world PDC

safe ibex
#

Oh the world PDC?!

#

How do I access that?

wet breach
#

so, an instance where the server will create an item out of nowhere is by abusing world saving 🙂

smoky oak
#

just do world.getpersistent...

eternal oxide
#

Bukkit.getWorlds()...

safe ibex
#

Wait but what if they were in the nether for instance

#

Would it carry over

#

Or would I set it on every world?

eternal oxide
#

store your data in world[0]

#

unless you want per world mutes

safe ibex
#

Oh right ok nvm yeah I'm being stupid

#

Alright thanks mate 🤣

runic plaza
wet breach
#

need to resend some packets

#

consult that ^

primal goblet
#

@wet breach packets of what?

#

i tried these and it doesn't work

CraftPlayer craftPlayer = (CraftPlayer) player;
                    EntityPlayer entityPlayer = craftPlayer.getHandle();
                    PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, entityPlayer);
                    PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityPlayer.getId());
                    PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
                    DataWatcher dataWatcher = entityPlayer.getDataWatcher();
                    PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(entityPlayer.getId(), dataWatcher, true);
                    entityPlayer.playerConnection.sendPacket(playerInfoPacket);
                    entityPlayer.playerConnection.sendPacket(destroyPacket);
                    entityPlayer.playerConnection.sendPacket(spawnPacket);
                    entityPlayer.playerConnection.sendPacket(metadataPacket);
wet breach
#

packets that hold player game profile information

#

such as the tab list

#

etc

primal goblet
#

i made the skin changer things, but i cannot refresh/reload the player to itself, other players can see me changed my skin/name

wet breach
#

basically the issue isn't that the server isn't updating it, rather clients cache other players information and you need the server to basically tell the client to refresh

primal goblet
eternal oxide
#

can't help sorry

primal goblet
#

hide and show is useless tho

wet breach
#

Just respawn the player

safe ibex
#

Wait can I store an object in the PDC of the world? E.g. one with their name and timestamp which they are muted until?

primal goblet
wet breach
#

well its 1.8 so I don't know the relevant methods

safe ibex
smoky oak
wet breach
#

I don't use outdated stuff nor do I care to remember outdated stuff as I don't use it

eternal oxide
#

simplest way is to encode to a byte array and store that

eternal oxide
#

its not hard to write a new DataType

#

look at teh javadocs, it has an example of creating one for UUID

safe ibex
#

Is there a string array?

#

If so I can format it like uuid;muteduntil in a string lmao

eternal oxide
#

all you do is the same as that btu for yoru own object which holds a UUID and a Long for teh timestamp

#

you could just use a string

safe ibex
#

oh right yeah

#

and use a seperator or something

#

I guess

eternal oxide
#

yep csv

safe ibex
#

uhhh this will be scuffed but I guess it'll work 🤣

smoky oak
#

java is weird

safe ibex
#

Yeah... tell me about it lmfao

#

Anway, yeah imma try my scuffed method now 👌

wet breach
#

String is not primitive

#

You can't modify a string after it is created

#

as it is immutable

#

so when ever you doing your operations to strings, it technically creates a new string object. But String is an object not a primitive

orchid gazelle
#

hello, how do I create a temp Structure Block just with Blocks and then send the blocks to the client?

eternal oxide
#

You need a Structure already saved

#

you can then place a Structure block and set it's data or you can simply place the Structure using the Manager

river oracle
#

String? Sorry I use CharSequence

orchid gazelle
#

I wanna create the Structure Block temp tho, I just wanna use it to send fake blocks

eternal oxide
#

Then you don;t need a Structure Block

orchid gazelle
#

I do

eternal oxide
#

ok

orchid gazelle
#

otherwise it would lag like hell

#

What I need is Arr-of-Blocks -> Create Temp Structureblock -> Send Structureblock to Client -> Remove Structureblock again

eternal oxide
#

If you want to listen rather than argue...

#

save your Structure... It will create a nbt file..

#

you can then load/register the Structure

orchid gazelle
#

I cannot just save thousands of structures

eternal oxide
#

you can access the internals of that registered Structure and read teh block array

#

use that and send fake blocks

orchid gazelle
#

the array is already given

quaint mantle
#

how do i remove stuff that i have posted?

orchid gazelle
#

can I just feed the loading with my block array?

eternal oxide
#

If you already have an array of Blocks you don;t need to go anywhere near Structures

#

just x,y,z loop over teh array sending fake block change

orchid gazelle
#

that lags like actual hell then

#

I have even tried to send Multiblock-Changes

eternal oxide
#

break it up into manageable chunks

#

so you are not sending the whole set of blocks at once

orchid gazelle
#

no im not

eternal oxide
#

?workdistro

orchid gazelle
#

but it even lags like hell when I spread it

eternal oxide
#

then you are not spreading it correctly

orchid gazelle
#

also, given of how hella fast minecraft loads structure blocks thats a literal joke

eternal oxide
#

lol MC is TERRIBLE with Structures

orchid gazelle
#

it sends the client a shit load of blocks in a matter of ticks

#

problem is not server processing, it is the client rendering too much garbage

#

(or some weird networking)

eternal oxide
#

well its a combination. Server processing, Server/client Bandwidth and client processing

orchid gazelle
#

I actually timed server time, it does not take long at all

eternal oxide
#

I wrote a worldgen using Structures and it's terrible

#

SO much worse than normal worldgen

orchid gazelle
#

well, but, am I right that minecraft sends a shit load of blocks to the client via structure blocks?

#

so why won't that work with my fake blocks

eternal oxide
#

because you don;t want to place teh Structure

orchid gazelle
#

doesn't the client do the same thing?

#

Receive block updates -> render

eternal oxide
#

No clue

quaint mantle
#

how do i remvoe posts

eternal oxide
#

press ... and select delete

quaint mantle
eternal oxide
#

I just told you

quaint mantle
#

i dont find it

eternal oxide
#

Hover over a post, press ... on the right hand side and choose Delete

quaint mantle
#

i find more options...

eternal oxide
runic plaza
#

@opal juniper you still here?

proud furnace
#

anyone know of a plugin for 1.8 for when you eat a gap it gives you full health?

spice shoal
#

Guys , How to resize the face of teleport in spigot?

hybrid spoke
#

rightclick + delete = 5Head

runic plaza
#

can somebody help? i want to compile my code in intellij ide but it gives me errors all the time (i dont know anything about programming)

hybrid spoke
#

rightclick + delete + enter = elmoburn

cunning canopy
#

Anyone know how I can deal with the fact that minecarts set its pitch and rotation every tick, so setting its pitch and yaw in spigot results in it going back to the normal almost instantly? Can i create a super of the Nms minecraft class and remove that part of the code?

quaint mantle
#

how do i remove posts on spigot

lost matrix
lost matrix
lost matrix
lost matrix
spice shoal
#

sorry for my bad english

lost matrix
spice shoal
lost matrix
#

Ah.

#

Use packet entities. They dont do anything unless you tell them to

cunning canopy
#

Got any resources for me?

#

Is it a part of spigot?

lost matrix
#

Nope, you need to use NMS or ProtocolLib for that.
But it wont lag your server then. I can imagine that using
thousands of minecarts for some jets in the sky will put
quite a strain on your servers performance.

cunning canopy
#

Ah. So how do I proceed using Nms? And i am guessing that I won't be able to use spigot api for that packetless entity?

lost matrix
#

You wont be able to use any spigot api for that. You should probably write your own classes just for that.
Maybe first try getting it done without packets.

Why are you using Minecarts? Why not just ArmorStands?

cunning canopy
lost matrix
cunning canopy
#

What is that?

lost matrix
#

You can literally rotate them in every possible direction there is

#

*The heads at least

cunning canopy
cunning canopy
# lost matrix Yes

But I still need to rotate the main node of the plane where the player sits using a minecart.. Can you put minecarts on armorstands heads?

idle umbra
#

i cant use economy shop gui ı cant write /shop but it has files files are loded

tardy delta
smoky oak
tawdry parcel
#

what is the easiest way to get the current tps of my server?

round skiff
#

Any to hwlp me to setup voting plugin dm me

smoky oak
#

man this server needs a #recruitment channel

#

the forum is so much harder to navigate

sullen coyote
#

There was nothing against it in rules my friend.

vagrant stratus
#

Yea, that's against the rules lol

#

?services

undone axleBOT
vagrant stratus
#

@sullen coyote

snow lava
#

what the ":" and the "?" means on a return sintax

#

in NMS are there returns and i don't understand what it means

#

for example:
return entityliving == null ? false : (!entityliving.isAlive() ? false : (!this.c ? !this.a.getNavigation().m() : (!this.a.a(entityliving.getChunkCoordinates()) ? false : !(entityliving instanceof EntityHuman) || !entityliving.isSpectator() && !((EntityHuman) entityliving).isCreative())));

pseudo hazel
#

thats called a ternary operator

#

in this case its a shorthand for an if statement

#

condition ? conditionTrue : conditionFalse

hazy parrot
#

Don't nest ternary pls

pseudo hazel
#

so saying 27 + 3 == 30 ? "thats right" : "Nope" would return "thats right"

#

but that code you posted is ugly AF

#

and should be deleted from existence

smoky oak
#

the real issue with tenary is that if/else and tenary gets compiled differently

hazy parrot
#

If you want to nest ternary, just use if in that case

smoky oak
#

so the fucking code up there is faster than an if else chain

snow lava
#

thanks steaf

pseudo hazel
#

oh, is that because of the short circuiting?

#

like how does it get compiled diffrent

smoky oak
#

idk the exact bytecode but i know that the jmp is different

#

iirc either elgarl or 7smile actually knows the difference

pseudo hazel
#

hmm

bold vessel
hazy parrot
smoky oak
# pseudo hazel hmm

a quick round of googling: the tenary pushes conditionally without storing

pseudo hazel
#

yeah I figured

#

interesting

#

fill every slot thats at either the first x or last x and any y

#

or any slot thats the first y or last y and any x

pseudo hazel
#

is /tps not a thing?

#

oh

bold vessel
pseudo hazel
#

then teh /tps I use is from paper probably haha

bold vessel
#

The assaut map dont work som1 know why

tawdry parcel
pseudo hazel
#

oh

#

no I was in the wrong channel haha, I thought this was help server

#

srry I cant help you then

smoky oak
tawdry parcel
onyx fjord
#

does bungee and spigot have google guava?

tardy delta
#

spigot does

onyx fjord
#

any util/lib to do stuff with colors ? (multi gradients, rgb, rainbow)

lost matrix
#

nvm it has been merged into adventure now

onyx fjord
#

i dont wanna use adventure for it

#

id prefer something minimal

bold vessel
lost matrix
bold vessel
#

Idk why the assaut isnt working

lost matrix
#

Because you didnt import Assaut

#

Hover over Assaut and let your IDE import it

bold vessel
#

I cant import it, this file is the manager of "Assaut"

lost matrix
#

Where is your Assaut class?

bold vessel
#

Wait i send u the whole code

lost matrix
#

Thats the AssautManager class. Where is your Assaut class?

bold vessel
#

i havent its WOAssaut

#

omg

#

im so dumb

lost matrix
#

?!

glad prawn
#

xd

opal juniper
#

what is an assuat

kind hatch
#

Sounds like a type of sausage.

sick ermine
#

@lost matrix why is it triggered on every event

lost matrix
sick ermine
#

sorry there is no triggering problem, i took care of it 👍

lost matrix
#

ok

bold vessel
sterile token
#

For some reason it's having troubles while working with double and long values

#

Atleast integer works perfect

#

I think Is something related to how bson serialize/deserialize numbers

deep echo
#

Is there any possibility to download premium resource from Spigot via API? The only possibility i saw is to use Spiget (don't know if it works), but still it's only for free resources.

remote swallow
#

that would just be an easy bypass to paying for them, doubt it exists or will ever exist

kind hatch
#

It could exist if there were login requirements for the API, but as it stands currently, it's not possible.

deep echo
desert tinsel
#

can I someone send a broadcast message but only for players, not for console

#

is a for loop good?

lost matrix
desert tinsel
#
        for (int i = 0; i < 200; i++)
                for (Player ps : Bukkit.getOnlinePlayers()){
                    ps.sendMessage(" ");
                }``` but is it the most optimal solution?
opal juniper
#

why are you sending so many

desert tinsel
#

for a clear chat command

opal juniper
#

send a tonne of newlines?

desert tinsel
#

how can I do it in another way?

raw epoch
#

Hello !

I've a small problem i don't have any variables names anymore :/ (inteliji) I don't know why, i've the same build.gradle as another project and i've not the prob here.

If anyone knows the solution it will be helpful ty !!

(i can't post screen here)

kind hatch
#

?img

undone axleBOT
opal juniper
raw epoch
opal juniper
#

is one spigot-api and one spigot

raw epoch
opal juniper
#

welp, i mean ultimately it doesnt matter

livid dove
#

So general development hell question

#

Rideable pigs

#

ive been wracking my brain all day to try and figure out the best approach to getting a pig that rides like a horse

sterile token
#

So then you can send pictures and all we can see them

livid dove
#

Actually better question

#

if a veichle had somehow stopped being controlable, (lets say a horse) how would you set it back to being controlable?

#

So essentially I have libsdisguise and i have disguised a horse as a pig

#

and i want to be able to turn back on the pig's rideability

sterile token
#

Any other alternative for saving player time played, because mongo actually is having troubles for working long values

lost matrix
sterile token
hazy parrot
#

Isn't there like built in api to see time played on server

#

Or I dreamt that

sterile token
#

Hmn im not sure tho

#

But i need to do it for bungee, so meh

#

The problem is when loading the document tho

#

I have tried many ways, like that in the picture, getting with Document#get("field", Long.class), with Gson

#

Im really confused, because i didnt have issues with numbers before while working with mongo

tender shard
#

shouldn't that rather be a static method?

sterile token
#

Yeah prob, but statics be like 💀

tender shard
#

new User().load(...)

#

that seems inherently broken API design choices

sterile token
#

Yeah i know

#

I will change it then

tender shard
#

anyway, sorry, I cannot answer your question

sterile token
#

But the issues is with long type numbers

#

n a its okay i can udnerstand

tender shard
#

what exactly is the problem?

#

any errors/stacktraces?

sterile token
#

yes 1m

#

Let me start the server

tender shard
#

oki

sterile token
#
Error dispatching event PostLoginEvent(player=Alexito2060) to listener dev.alex.net.inviter.bungee.listener.UserListener@1a1d3c1a
java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Integer (java.lang.Double and java.lang.Integer are in module java.base of loader 'bootstrap')
    at org.bson.Document.getInteger(Document.java:243)
    at dev.alex.net.inviter.core.api.User.load(User.java:30)
    at dev.alex.net.inviter.core.manager.UserManager.load(UserManager.java:34)
    at dev.alex.net.inviter.bungee.listener.UserListener.onJoin(UserListener.java:23)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
    at net.md_5.bungee.event.EventBus.post(EventBus.java:46)
    at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:399)
    at net.md_5.bungee.connection.InitialHandler$6$1.run(InitialHandler.java:537)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at java.base/java.lang.Thread.run(Thread.java:833)```
#

Mainly issues with numbers casting

proper notch
#

Is there a reason you're not using Document#getLong?

sterile token
#

I tried many ways and all have the same issue

proper notch
#

If you look at the type in your database, is it actually saved as an Int64?

sterile token
sterile token
#

1m i will send the db document to have a more near look

proper notch
#

See coz getLong has worked for me in the past

sterile token
#
{
"_id": ObjectId("63eb4428e4d2ef2bfa2bc55d"), 
"uuid": BinData(3,"hz5tv5G9ev6A0W4V9LH9sQ=="), 
"name" : "Alexito2060", 
"played": NumberLong(-5737), 
"points" : 1000, 
"invites": 10, 
"inviter": null 
}```
#

That is my current doc for testing

tender shard
sterile token
proper notch
#

random unrelated other thing, is there a reason you're not just using the player's UUID as the _id?

sterile token
proper notch
#

Oh. Interesting

sterile token
#

Yeah and everything was okay, so that why i didnt use it

tender shard
#

if you do not tell use what exactly is "User" line 30, it's a waste of time to discuss anything about it here

sterile token
tender shard
#

why are you casting it to "Number" in the first place?

#

just use the appripriate get<WhatEverNumberTypeYouNeed> in the first place, as people already suggested

sterile token
#

That is like 30, in first place used to be a Document#getLong() but caused the same issue, so i read on overflow that mongo deals with numbers diffenrent

#

But in my case happens backwards, the issue is caused when i need to read a Long value

tender shard
#

the dude in the SO issue casts it to Long instead of long

#

Long != long

sterile token
#

right, my field type is "long"

tender shard
#
this.played = document.getLong("played");
#

what happens if you do this?

sterile token
#

Let me check because, before i was having the current issue

#

1m

#

Ash fkg maven multi modules, it takes ages to compile a simple 20 modules project 💀

#

Also is correct to load the document when the player joins? or need to load it when plugin start?

#

Because i have been reding arguments about that and there are big dicussions abou t it

tender shard
#

tbh if you got 20 modules, it's not a "simple 20 modules project"

#

20 modules automatically means that your project is not "thaaaaat simple" anymore

sterile token
tender shard
#

no clue what you're talking about

eternal night
#

actually, its only 2 seconds

#

so like

#

idk what you are talking about

tender shard
#

do you actually have a parent pom that consists of 20 sub modules? If so, I wouldn't exactly call it "simple"

tender shard
sterile token
eternal night
#

100%

#

any project for that matter

tender shard
#

sure, maven ALWAYS needs 2 seconds

#

@sterile token

#

You can literally compile the whole linux kernel within 2 seconds

sterile token
#

I proba have to move up to Graven the new technology for java

tender shard
#

maven's O(...) thing is == 2 seconds

sterile token
#

wait im an idiot i didnt even open mc, to test the plugin

tender shard
#

you know, lynx and me are something of a scientists ourselves

eternal night
#

🧑‍🔬

tender shard
#

if only I still had a photoshop license

sterile token
#

Same issue mfalex

#
19:10:48 [ADVERTENCIA] Error dispatching event PostLoginEvent(player=Alexito2060) to listener dev.alex.net.inviter.bungee.listener.UserListener@1a1d3c1a
java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Integer (java.lang.Double and java.lang.Integer are in module java.base of loader 'bootstrap')
    at org.bson.Document.getInteger(Document.java:243)
    at dev.alex.net.inviter.core.api.User.load(User.java:30)
    at dev.alex.net.inviter.core.manager.UserManager.load(UserManager.java:34)
    at dev.alex.net.inviter.bungee.listener.UserListener.onJoin(UserListener.java:23)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
    at net.md_5.bungee.event.EventBus.post(EventBus.java:46)
    at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:399)
    at net.md_5.bungee.connection.InitialHandler$6$1.run(InitialHandler.java:537)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at java.base/java.lang.Thread.run(Thread.java:833)
sterile token
#

this.played = document.getLong("played")

proper notch
#

are you sure you're getting the line correct?

tender shard
#

then just do getInteger()

#

or however it's called

sterile token
#

integer != long ?

proper notch
#

getLong does not call getInteger, so I don't think it can be that

tender shard
sterile token
#

but im not getting an it

#

Im saving a time that why im using long and not int

#

remember that int is limited and not use for time

proper notch
#

getLong -> get -> documentAsMap

getInteger is not called anywhere when doing getLong, so that's a separate error.

sterile token
#

So what do oyu think roller?

#

Is my issue or mongo related to?

tender shard
tender shard
proper notch
#

Either you're not updating your plugin correctly, or line 30 is something different.

sterile token
# tender shard ^

But integer cant be used for working with timestamps or time based fields

proper notch
#

That error does not point to you running getLong at all. getLong is not called anywhere with that error.

tender shard
#

you are casting a Long to an Integer, which is isn't.

#

Long != long

tender shard
#

you can cast a "long" to an "int" but you cannot cast a "Long" to an "Integer"

sterile token
tender shard
#

primitives != erm... the wrapper types

proper notch
#

Line 30 is this.points = ... 🤦‍♀️

tender shard
proper notch
#

Not this.played

sterile token
#

🤦‍♂️

#

But still doesnt make sense, because im not saving it as a long

proper notch
#

What type is this.points and what type is points in the database?

tender shard
#

you have sth that's an Integer and you do cast it to a Long

#

that does not work

tender shard
#

1000 obviously is not a Long...

proper notch
#

mfnalex if I'm gonna be honest, ur lost.

sterile token
#

i mean the isue is confusing

tender shard
#

no, you guys do not understand the differences between primitives and wrapper types

proper notch
#

We're not talking about a long any more, because the line referenced was incorrect. The issue now is that the different field, this.points which should be an Integer is a Double.

tender shard
#

you cannost just cast a Long to an Integer.
you can cast a long to an int but you cannot cast a Long to an Integer

alpine swan
#

is there any way to instantly delete an entity (like without waiting for a tick)

alpine swan
sterile token
alpine swan
#

hmm

#

i could implement the same thing abusing metadata a bit

gleaming grove
#

Why when server invokes command event is triggered but when players does there is no event? @EventHandler public void cmd(PlayerCommandSendEvent event) { Bukkit.getConsoleSender().sendMessage(ChatColor.BLUE+"Player CMD event "+event.getPlayer().getName()); } @EventHandler public void serverCmd(ServerCommandEvent event) { Bukkit.getConsoleSender().sendMessage(ChatColor.BLUE+"Server CMD event "+event.getSender().getName()); }

sterile token
#

So my issue change mfalex, i thought that line 30, was the long thing which was wrong that line

sterile token
#

So now the issue im having is that mongo is treating my int points as a double value

proper notch
# sterile token ```json { "_id": ObjectId("63eb4428e4d2ef2bfa2bc55d"), "uuid": BinData(3,"hz5tv...

ngl no idea what the type of the numbers actually here is. Is there maybe a different way that you can output the document?

I'm used to reading them like this:

{
  "_id": {
    "$binary": {
      "base64": "mPwMGiHiTZec49XHlD7sZQ==",
      "subType": "04"
    }
  },
  "currentUsername": "TS3Moderator",
  "currentlyOnline": false,
  "firstLogin": {
    "$date": {
      "$numberLong": "1675813679000"
    }
  },
  "lastOnline": {
    "$date": {
      "$numberLong": "1675813684000"
    }
  },
  "totalPlaytime": {
    "$numberLong": "5762781913"
  }
}```
#

Also gonna check my previous mongo code to see how I save a regular integer.

gleaming grove
# tender shard what?

I would need to listen for commands in form of events so I wounder how to achieve that

sterile token
tender shard
sterile token
#

roller right now mongo confused me a lot, because why would he treat my int field as long, doesnt make sense

proper notch
#

Ok I don't do anything special when saving/reading an integer, so I'm not quite sure. Could you send your whole User class please.

undone axleBOT
sterile token
proper notch
#

Yh I would recommend changing the methods btw like earlier. Not sure though

tender shard
#

@sterile token

sterile token
alpine swan
#

is entity metadata cleaned when removing the entity?

tender shard
#

yes

proper notch
#

Do you have the document with types? Similar to the document I sent above

tender shard
#

stop using racist database types and you'll see that everything's going to work just fine ;P

proper notch
#

I just use Mongo Compass and then copying it from that gives it to you

sterile token
proper notch
#

The TLDR is basically, for some reason points is coming back from your db as a Double type, not an Int32

tender shard
#

why would you use mongodb in spigot plugins anyway? like 99.99% of servers use SQL databases

#

"mongo"db has its usecases, but spigot plugins aren'T one of them. also fuck mongodb for choosing that name, "mongo" is an insult against disabled people in at least 20+ languages, including german, and the dude who invented this weird system is a german so yeah... fuck mongodb

lost matrix
#

mongodb is beste. I will never go back to relational databases in spigot.

tender shard
#

lol

sterile token
#

I cant go back to sql neither for webs/nest apis

proper notch
#

See I love mongo, but I don't use spigot sooo I don't apply to it anyway 😆

tender shard
#

okay, let me just forget for one minute that the original developer of "mongodb" chose an insulting racist slur for the name of his db system - can someone give me an example on how/why mongodb does anything different/better than usual SQL databses? (honest question, I am curious)

sterile token
tender shard
#

no clue what you mean

#

how are you going to access any data if the value is not associated with any key?

sterile token
tender shard
#

you cannot just do "gimmeTheCorrectData()" right?

#

you always need a key

sterile token
#

In mongo you dont have a ugly syntax which you have to remmeber for example, you use Flters instead