#development

1 messages · Page 118 of 1

wicked comet
#

Heyo, any ideas why maven is failing to download PAPI?

hoary scarab
#

How would I make a blank ItemMeta object for a certain item? For some reason ItemStack.getItemMeta() is returning null (on ItemStack{Stone x 1}).

lyric gyro
#

thonk that 10000% shouldn't be the case

#

the only case ever getItemMeta returns null is when it's AIR

hoary scarab
#

Wait... read the wrong line I think. 🤦

#

Oh it was my config. I have 1.18 material names 🤦

winter nimbus
#

What's a good way to go from &6 (string) to for example NamedTextColor.GOLD

proud pebble
#

is that a paper color?

graceful hedge
#

NamedTextColor.NAMES.value("6") iirc

winter nimbus
winter nimbus
lyric gyro
dusky harness
#

¯_(ツ)_/¯

#

idk if it'd work as a replacement tho

#

idk how components workk

winter nimbus
#

Do you have to work with components in paper or are there other solutions aswell?

spiral prairie
dusky harness
#

that requires converting 6 to gold

#

if it's just to get the color, used NamedTextColor

if it's to convert an entire legacy string, use LegacyComponentSerializer

winter nimbus
#

I have a database where I have ranks, so I want the prefix of for example a specific role to be &6&l (gold and bold)

#

However if this is the case I now need to make two columns with one having color and the other a boolean for bold

lyric gyro
#

Oooor just have the Style json-serialized thonk

winter nimbus
#

Oh :o

dusky harness
#

u can also store it with the NamedTextColor enum name

lyric gyro
#

it's not an enum

winter nimbus
#

I mean that's a good solution on my end

dusky harness
#

oh wait

winter nimbus
#

But bold aint in NamedTextColor

#

Bold is in TextDecoration

dusky harness
#

for that you'll have to use decoration

lyric gyro
#

exactly, that's why you'd store the serialized Style

dusky harness
#

in the db u can have gold,true :))))))))))))))))))))))

lyric gyro
#

..

winter nimbus
#

Nahh xD

dusky harness
#

lol

lyric gyro
#

storing it as json costs you nothing

winter nimbus
#

Yea true

#

Currently looking at the docs of kyori (for the NamedTextColor part) however I dont see how you could only put the style in a json

#

Ahh wait nvm I think I already understand

proud pebble
#

any ideas on what i could do to make it so the server doesnt lag?

#

ok turns out i shouldve been doing this async not sync...

#

running the delete and insert queries async worked

proud pebble
#

turns out it didnt work, just stopped stalling the server while it processed the query

#

didnt stop the lag that nuked the server after a couple breaks

warm steppe
#

load world in server start

#

do the queries when server starts

#

then uodate blocks locally in some list or smth

#

and make a repeating async task to update the database

#

so it runs once in 5 or 10 mins

#

ezpz

river solstice
#

Wouldn't it lag with even more data?

#

Since he said logging couple of blocks async still lags

tall anchor
#

Hello! Can anyone help me to get TPS?
This doesn't work: double tps = Bukkit.getServer().spigot().getTPS()

wheat carbon
#

that doesn't look like a real method

#

I don't see it on the javadocs

dusty frost
#

maybe 1.8?

dense drift
#

could also be paper

#

d;paper server#gettps

uneven lanternBOT
#
@NotNull
@org.jetbrains.annotations.NotNull double[] getTPS()```
Description:

Gets the current server TPS

Returns:

current server TPS (1m, 5m, 15m in Paper-Server)

wheat carbon
#

@tall anchor ^ don't call .spigot()

tall anchor
#

Huh aight, I made a mistake there, developed "Bukkit" plugin... I'll do Paper then :)

dusty frost
#

Bukkit is just the API

wheat carbon
#

not sure bukkit has a method for getting the tps

dusty frost
#

Spigot and Paper are implementations

wheat carbon
#

iirc people used to use nms

dense drift
#

ye

tall anchor
#

Understood, I just chose "Bukkit Plugin" from IntelliJ "Choose plugin or mod platform".
Should've done Paper Plugin.

winter nimbus
#

In spigot, how can I disable default commands like /help and so on? That players won't be able to do for example either /help or /minecraft:help

#

I've tried to remove their permission minecraft.command.gamemode however that doesn't work

dense drift
#

try to negate it instead

winter nimbus
#

Wdym?

shell moon
#

if that command requires a permission, negate it

winter nimbus
#

So -minecraft.command.help should do it? Because that does not work for me

dusty frost
#

Are you using Luckperms?

#

If so, you need to set the normal permission and set it to False instead of True

winter nimbus
#

Ty

dusty frost
#

In Luckperms, it has always been like that

#

PermissionsEx and GroupManager used the dash for negation though

rare trail
#

Can you create Placeholder with BungeeCord Plugins? The wiki shows that I need org.bukkit.OfflinePlayer..?

hushed badge
#

PAPI doesnt work on bungee, so no

rare trail
#

Alright

rare trail
atomic trail
#

Is there a packet for hiding attributes? Like ItemFlag#HIDE_DYE - it's for bedrock edition so itemflag is not a possibility

fading stag
#

I want to add a delay to one of my events. For example: When player joins it will wait for 2 secs and then it will send message but I don't know how to add that delay

torpid raft
#

with a BukkitRunnable or with the bukkit scheduler, i believe bukkitrunnable is recommended

fading stag
#

tx

shell moon
#

if its a bungeecord plugin, commands are handled in bungeecord

proud pebble
#

connect your plugin to mysql on all your instances.

#

not much point having a punishment system on bungee only even if it would be convienient

void orchid
#

?paste

neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

void orchid
#

wrong channel, whoops

spiral prairie
#

SOO PEOPLE, how would you do a world cycler? like for minigames that switches the world every 10 minutes or so

#

ive thought of a class implementing Runnable and having an iterator with all worlds

#

would that technically work?

shell moon
#

minigames that switches the world?

#

if you mean that your ffa rotates map every X minutes, then yes

#

a runnable and that stuff

torpid raft
#

every time you're about to start a minigame, you can get the current time and use that as an offset to your list of possible maps

#

like if your time is for example 12:01-12:10 am you'll use map 1, if it's 12:11 - 12:20 am you'll use map 2, etc.

#

from there i'm sure you already have logic to load the players into the correct world and all that

torpid raft
spiral prairie
#

That sounds harder than just running a runnable with an iterator

#

And the time measuring will still be done thru a runnable or something similar

fading stag
#

What is the Best way to compare two guis?

#

I mean what is the Best way to learn is gui1 equals gui2

vestal forge
#

equals

#

lol

night ice
graceful hedge
rigid mountain
#

Hey, So im getting the enchants on an item with ItemStack#getEnchantments which is a map of <Enchantment, Integer> and i want to get a random enchant form that. How can i get the key?

light ice
#

But from what I know.. it shouldn't?

loud sorrel
#

"Could not parse ChatColor 0§F§FX" means that you're trying to get an invalid color code

#

line 85 of TipsPro

light ice
#

I was using #FF0000 but it didn't work with that either

loud sorrel
#

Are you using bungee?

light ice
#

The chat color import for it?

loud sorrel
#

Yeah

light ice
#

Yes

loud sorrel
#

make sure your importing the right one

light ice
#

As far as I know there's only bukkit's chatcolor and bungee's chatcolor, and bungee is the right one

loud sorrel
#

try bukkit

light ice
#

If I use bukkit's then ChatColor.of doesn't exist lol

loud sorrel
#

just use ChatColor.get or whatever the method is

#

i dont remember the name

light ice
#

Also ChatColor.translateAlternateColorCodes won't exist

loud sorrel
#

why wouldn't it?

light ice
#

Oh, well that one does

#

But like, 90% sure hex colors are from the bungee import

loud sorrel
#

try it

#

i havent used hex colors yet but its worth a shot, no?

light ice
#

Fine, well for one, ChatColor.get(color) doesn't really work, color is a string, soooo I guess I'll try ChatColor.getByChar(color) ?

#

Hmm, nope..

#

Using &c&lTipsPro &8&l| #FF0000H#00FF00E#0000FFX #D49E9Bcode support! just made it look like this:

torpid raft
#

if you're actually just measuring the time it takes to do (something), you can just subtract the final time from the initial time; you dont need to manually increment anything

deep halo
#

Hey there, sorry if this is a noobish comment but I was using cpulimit just to host a test server locally since 1.18 was really taking a toll on the machine I use for a test server. Unfortunately after using this command
cpulimit -l 400 -- java -jar -Xmx2048M -Xms2048M server.jar nogui
I cannot type anything into the console, which is very annoying. Is there a solution to this?

warm steppe
#

dont use cpulimit?

deep halo
#

I'm sharing it with family members and I don't want it using all the resources

naive yacht
#

is the speed of the processor (Ghz) ​​really useful for a server or do the cores compensate?

warm steppe
#

uhh

#

imo at least 2-3 cores are needed

#

it really depends on what u do

#

iirc you need cpu with good single core performance

torpid raft
torpid raft
#

additionally, the clock speed of the processor is only one factor in determining how performant it is. CPUs made in 2011 that can run at 3.5ghz are SIGNIFICANTLY WORSE than modern cpus that run at 3.5ghz

#

You want modern CPUs, which usually have a higher IPC and useful features like various SIMD instructions - only pay attention to clock speed if you're comparing two cpus from the same generation

atomic trail
sterile hinge
#

like any other jvm arguments

#

that said, using guice 5 solves the issue too afaik

sterile hinge
#

ah lol, I'm just a little bit confused

#

guess that's resolved in up to date gson versions too tho

atomic trail
#

Or will it automatically override it if I add a new dependency?

#

Getting this error now, using jdk17 everywhere though

General error during conversion: Unsupported class file major version 61

java.lang.IllegalArgumentException: Unsupported class file major version 61
#

Could not compile settings file 'C:\Users\45512\Desktop\JAVA\NetherPortals\settings.gradle'.

#

Okay this doesn't make sense, my gradle version is 7.3.3 and JDK 17 which should work according to this (from gradle website) But I get the unsupported class file major version error

wheat carbon
#

file > settings > build/execution/deployment -> build tools -> gradle

#

make sure gradle is using jdk 17

atomic trail
#

Exact same JDK as the one in project structure

#

I have tried to invalidate caches also

prisma briar
atomic trail
#

And the gradle version is indeed 7.3.3

wheat carbon
#

try building via cli

#

./gradlew build

atomic trail
#

Hmm

wheat carbon
#

./

#

ew

#

windows

#

gradlew.bat build

atomic trail
#

Same error

wheat carbon
#

paste bui.d.greadle

atomic trail
#

I tried removing the gson dependency since I think it happened after adding it (not sure) but didn't work.

wheat carbon
#

replace L10-L14 with sourceCompatibility = JavaVersion.VERSION_17

atomic trail
#

how about target compatibility?

wheat carbon
#

useless

atomic trail
#

what is it for?

wheat carbon
#

literally no clue

atomic trail
#

Oh lol, well same error...

wheat carbon
#

get rid of your "gson" repo

atomic trail
#

Failed

#

gradle loads correctly when reloading it, but can't compile

wheat carbon
#

gradlew.bat clean build

atomic trail
#

used gradle.bat clean build but didnt work

#

as I don't have gradlew for some reason

wheat carbon
#

show directory structure

#

of root dir

#

type dir

atomic trail
#

wait

#

when running this

#

task it works

#

Like when not using the console

wheat carbon
#

pro tip you can run that same task from the top right of ij

#

don't need the gradle tab open

atomic trail
#

Oh ye, but do you know why it only works there?

#

This is my dir btw

C:\Users\45512\Desktop\JAVA\NetherPortals>dir
 Volume in drive C has no label.
 Volume Serial Number is 2CF3-1DB5

 Directory of C:\Users\45512\Desktop\JAVA\NetherPortals

26/01/2022  14.39    <DIR>          .
25/01/2022  23.20    <DIR>          ..
25/01/2022  23.21             1.637 .gitignore
26/01/2022  14.40    <DIR>          .gradle
26/01/2022  14.15    <DIR>          .idea
25/01/2022  23.42    <DIR>          build
26/01/2022  14.39               547 build.gradle
25/01/2022  23.20    <DIR>          gradle
25/01/2022  23.20                 0 gradle.properties
25/01/2022  23.20                35 settings.gradle
25/01/2022  23.20    <DIR>          src
               4 File(s)          2.219 bytes
               7 Dir(s)  115.692.630.016 bytes free

atomic trail
#

How can I add java args to gradle?

java --add-opens java.base/java.lang=ALL-UNNAMED
flat anchor
dense drift
atomic trail
#

Hmm

dense drift
#

try now

atomic trail
#

gradle loaded correctly, building now

#

Well

warning: [options] --add-opens has no effect at compile time
1 warning
#

ohhh

#

It has to be there at runtime also I assume

spiral prairie
#

or did you try that already

atomic trail
spiral prairie
#

java --add-opens java.base/java.lang=ALL-UNNAMED -jar your.jar

atomic trail
#

On in the start.bat?

spiral prairie
#

yeah

#

start command

atomic trail
#

Ahhh I see

#

Might've worked not sure, still getting this error though

[15:08:51 ERROR]: Error occurred while enabling NetherPortals v1.0 (Is it up to date?)
java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @7568852c
spiral prairie
#

ohh so thats a minecraft plugin

#

why are you using reflections?

atomic trail
#

I'm not, java is

spiral prairie
#

what

atomic trail
#
            for (JsonElement element : parser) {
                dataList.add(GSON.fromJson(element, Data.class));
            }

Since java 9 they use reflections for this or smth

#

for json

sterile hinge
#

you need to add the flags to the start script of your server

atomic trail
sterile hinge
#

java.lang.ref isn't java.lang

atomic trail
sterile hinge
#

no, packages don't have any hierarchy

sterile hinge
#

yes, and it fails to invoke that constructor

#

because worldName is null

#

at the time of invocatio of the getWorld method

atomic trail
#

That's weird

#

The world has been generated

#

and the string is indeed "world" in the plugin

#

Ohhh wait I might see what you mean

#

Not sure how else I could set it up though

lyric gyro
lyric gyro
#

anytime

pulsar ferry
lyric gyro
#

yes

dense drift
spiral prairie
#

just put it in after world name

#

in your constructor of the data class

atomic trail
atomic trail
winter eagle
#

is there a way to make the code continue only after a bukkitrunnable ended?

worn jasper
#

confusion

#

isn't this the right repo?

#

https://papermc.io/repo/repository/maven-public/

fervent jacinth
#

im not where to ask for help, but i am trying to install buildtools on debian WSL while following this link: https://www.spigotmc.org/wiki/buildtools/#running-buildtools but I got a bunch of errors having to do with import org.bukkit.material cannot be resolved. the last one before the process ended looks like this Exception in thread "main" java.lang.RuntimeException: Error running command, return status !=0: [sh, /mnt/d/plugin-dev/apache-maven-3.6.0/bin/mvn, -Dbt.name=582a, clean, install]

#

trying to create my own plugins for a 1.8.8 paper server

lyric gyro
worn jasper
lyric gyro
#

ya

worn jasper
#

k ty

lyric gyro
#

uh if I were you I'd ask in the spigotmc discord about that one

fervent jacinth
lyric gyro
#

mhm

proud pebble
#
private void saveChunk(int chunkX,int chunkY,HashSet<Location> set) {
        Bukkit.getScheduler().runTaskAsynchronously(FernCore.getInstance(), () -> {
            try {
                PreparedStatement ps = connection.prepareStatement("INSERT INTO fc_block VALUES (?,?,?,?)");
                for (Location loc : set) {
                    ps.clearParameters();
                    ps.setInt(1,getWorldID(loc.getWorld().getName()));
                    ps.setInt(2, (int) loc.getX());
                    ps.setInt(3, (int) loc.getY());
                    ps.setInt(4, (int) loc.getZ());
                    ps.addBatch();
                }
                ps.executeBatch();
            } catch (SQLException e) {
                Bukkit.getLogger().log(Level.SEVERE, "FAILED TO SAVE CHUNK AT "+chunkX+", "+chunkY);
                e.printStackTrace();
            }
        });
    }

is this a decent method for inserting the chunk into the db?

#

or should i split it up so that it handles lets say every 256 requests or smth

winter eagle
#

is there a way to make a delayed task inside of a for loop?

amber storm
#

how do I write a BitSet into a ProtocolLib PacketContainer?

worn jasper
#

confusion

#

getServer().getPluginManager().getPlugin("Vault") not detecting Vault?

dense drift
#

do you depend on vault?

shell moon
#

he's probably making it wrong

#

Vault is the first plugin loading

#

so even if he didnt add the depend or soft-depend

worn jasper
shell moon
#

it would still return true

worn jasper
shell moon
#

Yeah

#

it says:

if (getServer().getPluginManager().getPlugin("Vault") == null) {

#

make sure you have that

worn jasper
#

yup

shell moon
#

or send your code

#

so we can check it

worn jasper
#

1s

dense drift
#

d;spigot PluginManager#ispluginenabled

uneven lanternBOT
#
boolean isPluginEnabled(@NotNull String name)```
Description:

Checks if the given plugin is enabled or not

Please note that the name of the plugin is case-sensitive.

Parameters:

name - Name of the plugin to check

Returns:

true if the plugin is enabled, otherwise false

dense drift
#

this is better

worn jasper
#

the thing is... vault is enabled xD

#

but yes will use that

#

^^ my main

#

just noticed, forgot to remove Strings.format lol

shell moon
#

that doesnt mean vault is not loading

#

that means there is no economy plugin loaded

#

which added the economy class

#

to the provider

worn jasper
#

isn't vault already an economy plugin

#

by itself?

shell moon
#

...

worn jasper
#

ok

#

ignore that I said that

#

xD

dense drift
#

vault is an API

worn jasper
#

ye.

#

noticed that

#

1s after I sent the message

dense galleon
#
    "requirement": {
      "trigger": "minecraft:entity_hurt_player",
      "conditions": {
        "damage": {
          "dealt": {
            "min": 12,
            "max": 30
          },
          "blocked": true,
          "source_entity": {
            "type": "earth:rubro",
        --> "nbt": "{Deepslate:0}" <--
          }
        }
      }
    }``` Does the NBT section check that the source entity matches the given nbt?
#

That's what I understood from this

#

But it doesn't really seem to be working

amber storm
atomic trail
dense drift
#

you need a custom TypeAddapter in that case

dense drift
dense galleon
dense drift
#

3rd arrow should point to source_entity mb

atomic trail
# dense drift you need a custom TypeAddapter in that case

Hmm, I think I'll just do this

    public Location bukkitLocation() {
        return new Location(Bukkit.getWorld(worldName), x, y, z);
    }

    public void setLocation(Location location) {
        worldName = location.getWorld().toString();
        x = location.getBlockX();
        y = location.getBlockY();
        z = location.getBlockZ();
    }

Not sure if it's bad for performance or not tbh

#

I just need to null check ofc

dense drift
#
    "requirement": {
      "trigger": "minecraft:entity_hurt_player",
      "conditions": {
        "damage": {
          "dealt": {
            "min": 12,
            "max": 30
          },
          "blocked": true,
          "type": {
            "source_entity": {
              "type": "earth:rubro",
              "nbt": "{Deepslate:0}"
            }
          }
        }
      }
    }```
dense galleon
#

i'll try that, if it doesnt work Ill try figuring it out tomorrow I was about to go to sleep 😅 thank you tho

dense drift
#

and make sure the entity has that exact nbt

dense galleon
#

That's impossible

#

Cause it will have other NBT like age noAi

#

Age especially is impossible to replicate

#

I thought that it wasnt working because I need the same exact NBT

dense drift
#

I don't think it checks 1:1

#

but rather "contains"

#

what I meant is, check if the entity has Deepslate:0 using your code or whatever

dense galleon
#

Yeah it does, I spawn it with that nbt

#

Doesnt seem to work

dense drift
#

is that tag inside a compound?

dense galleon
#

So now it works no matter the NBT

#

Wait wht

#

I'm confused, hold on

#

Nah it doesn't work I think

dense drift
#

what if you remove the NBT?

#

and, can you send the NBT of the entity?

#

im about to go to sleep as well, maybe we can figure this out really quick

dense galleon
#

I have no clue how to check an entity's NBT

#

The debug stick doesnt do anything

#

Removing the NBT also doesnt work

dense drift
#

there should be a selector or whatever, /data get, could also use an EntityDamageEven

dense galleon
#

Keep in mind I am using Fabric now 😂 but I asked help here since jsons work the same everywhere

#

Should I send the NBt of the entity that should work?

#

Don't mind the italian bit, was testing out my translation file

#

If it doesn't work it's alright, I can make the advancent work through other means

#

I'm going to sleep now tho, goodnight!

dense drift
#

What about Deepslate:0b?

#

Gn

paper hollow
#

Anyone know any useful API's?

proud pebble
#

chunks that are positive work fine when loading data from sqlite, chunks that are in negatives do not.

#

weird

#

they work, but they are offset by 1 chunk

#

currently using "SELECT wid,x,y,z FROM fc_block WHERE wid = ? AND x / 16 = ? AND z / 16 = ?" to figure out the data that wouldve been in the chunk

lyric gyro
#

Math.floor(x / 16.0), that's the actual chunk coord

#

Same for z

shell moon
proud pebble
lyric gyro
#

I mean flooring 100% works

#

that's how the game calculates the chunk coord from the absolute block coord lmao

proud pebble
#

well i tried using floor and it was the same as without it

#

maybe its cause i specified 16 instead of 16.0

#

¯_(ツ)_/¯

lyric gyro
#

well.. yeah

#

it's a floating point division, then applied floor

proud pebble
#

ive had autocommit on all this time...

#

no wonder it was so sluggish

#

that change made my plugins's disable finish in ms instead of a few seconds

#

the limiting factor now is the chunk amount, which i can do the same thing with and just leave world size cause at most its 3 or 4 worlds

tall anchor
#

Does anyone know how to unregister a village so that whenever someone comes there with bad omen there won't be a raid?

#

WorldGuard doesn't seem to have a flag for that. What I'm trying to do is deny getting raids on spawn village, pillagers can't spawn there anyway (denied spawning), but people still lose their bad omen effect.
Is any way to disable that village from triggering raid therefore losing bad omen?

warm steppe
#

iirc there is an event for structure spawn

tall anchor
#

There's raid start event I could cancel

#

But thought maybe I could use some built-in solution, wouldn't want to create yet another plugin for cancelling one event...

noble grotto
#

whats the place holder to put someone's xp on a scoreboard?
I use animated scoreboard if that makes a dif

vapid shuttle
#

my intuition, is that the value strings will contain a sequence of key, string[] if ALL entries in the list are strings?

topaz gust
#

Likely your best option

tall anchor
#

Trying to "read" my custom flag, but can't do it... My JAVA is pretty basic so please help me out.
I register custom flag with this: https://worldguard.enginehub.org/en/latest/developer/regions/custom-flags/

And how can I read it in events class?
For example:

Player player = event.getPlayer();
Location loc = BukkitAdapter.adapt(player.getLocation());
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
ApplicableRegionSet set = query.getApplicableRegions(loc);
for (ProtectedRegion region : set) {
    // Check if region has RAID flag true/false (allow/deny)
}
tall anchor
#

I'll try, maybe this works:
if (region.getFlag(plugin.RAID) == StateFlag.State.DENY) {

atomic trail
topaz gust
#

Secondary can you show me a debug of all of those lines printed out when requesting them

#

Including worldName

atomic trail
atomic trail
#

Prints this

topaz gust
atomic trail
topaz gust
#

Thx

#

worldName = location.getWorld().toString();

#

Isn’t it meant to be getName()

#

Ohh wait nevermind maybe not

atomic trail
#

Btw it also creates this for some reason

#

That json file shouldn't be there

#

The correct one is in the NetherPortals directory in plugins folder

topaz gust
#

Check around there will be a reference somewhere

atomic trail
#

But it works now! It seems

#

Wanted to update the first location and it did update

topaz gust
#

Perfect

atomic trail
#

Just confused why that file is there

topaz gust
#

Gotta love those docs

#

Not what I wanted 🤦‍♂️

atomic trail
#

Only file in my plugin is this File file = new File(netherPortals.getDataFolder(), "portals.json");

wheat carbon
#

toString isn't a method of WOrld

atomic trail
topaz gust
atomic trail
topaz gust
#

It’s inherited

atomic trail
#

Ah yeah probably

topaz gust
#

He is correct

wheat carbon
#

it's inherited from object but it won't show on docdex because docdex sees world as an interface, which doesn't directly inherit object

#

the implementation of world does

topaz gust
#

Makes sense

atomic trail
#

Ahhh yeah ty

topaz gust
#

But anyway sounds like your issues have been resolved now

atomic trail
#

Yup, one harmless problem left but yeah

#

dunno why its happening

topaz gust
#

Idk there will be a call somewhere but it might be really indirect

atomic trail
#

Ohhh it's from here

    public void updateDataFolder() throws IOException {
        for (Data data : dataList) {
            GSON.toJson(data, new FileWriter(netherPortals.getDataFolder() + "portals.json"));
        }
    }
#

I thought it would make a path to the NetherPortals folder though?

topaz gust
#

Don’t use a plus

#

Use a File.SEPERATOR

#

you just combined the strings

atomic trail
#

Oh yeah true

wheat carbon
#

File.SEPARATOR is only for visual purposes, just use "/"

#
  • "/portals.json"
topaz gust
#

Or listen to big daddy supposing he is here

wheat carbon
#

File.SEPARATOR is when you need to show a path to a user with their operating system's separator character

#

java's file system uses forward slashes

topaz gust
#

Interesting

#

Well I guess some of my stuff has potentially hidden bugs in it

#

Fun fun

atomic trail
#

Lmao, alright well adding a / would be a bit simpler lol

wheat carbon
#

it should still work with File.SEPARATOR, or even if you use backslashes like when on windows

#

it's just you don't need to

#

forward slashes work perfectly fine on all operating systems in java

atomic trail
#

not sure how the separator works so yeah

topaz gust
#

I use it more for my own sake when reading back I clearly see I’m trying to separate

#

But honestly the way you suggested is easier

atomic trail
#

Oh well, it just cleaned my entire json file lol

#

Didn't write anything

wheat carbon
#

is data empty?

atomic trail
#

I guess I need more to deserialize

        for (Data data : dataList) {
            GSON.toJson(data, new FileWriter(netherPortals.getDataFolder() +  "/portals.json"));
        }
atomic trail
#

Now it is empty

topaz gust
atomic trail
#

now**

topaz gust
#

Now that’s a double negative if I’ve ever seen one 😂

atomic trail
#

mb haha

atomic trail
wheat carbon
#

first debug by checking if data is being properly converted to json

#

so just sout gson#toJson(element)

#

get rid of the file stuff

atomic trail
#

Alright, testing now

atomic trail
#

From this LOGGER.error(GSON.toJson(data));

#

Looks like correct json format

dense galleon
wheat carbon
#

valdemarF

dense galleon
#

that might make sense since 0b tells minecraft it's a boolean

wheat carbon
#

idk why it's doing that

#

but it doesn't matter because this system won't work anyway as is

#

instead of looping through data and writing each individual datum, simply write the whole list at once

#

GSON.toJson(dataList, blah)

wheat carbon
atomic trail
#

Because it would need a new line every time?

#

To append properly?

wheat carbon
#

no, json doesn't care for new lines

#

it's just not valid json

#

it'd look something like this

{"blah": "yes"}
{"blah": "yes"}
{"blah": "yes"}
#

it needs to look like

#
[
{"blah": "yes"},
{"blah": "yes"},
{"blah": "yes"}
]```
#

^ serializing the list will do that

atomic trail
#

Yeah... That's what I'm trying to do, I thought this would serialize it though

wheat carbon
atomic trail
#

This would be proper json format right?

[{"worldName":"world","x":-209,"y":70,"z":34},{"worldName":"world","x":-201,"y":66,"z":35},{"worldName":"world","x":-205,"y":68,"z":37},{"worldName":"world","x":-297,"y":65,"z":29}]
wheat carbon
#

yes

#

and passing dataList into toJson will do that for you

atomic trail
wheat carbon
#

if the file writer thing doesn't work then I'd try an alternative approach to writing the file, e.g. Files.write

atomic trail
#

Files.write works I believe

[{"worldName":"world","x":-209,"y":70,"z":34},{"worldName":"world","x":-201,"y":66,"z":35},{"worldName":"world","x":-297,"y":65,"z":29},{"worldName":"world","x":-205,"y":68,"z":37}]
#

I'll just make new lines to make it more readable

#

But thx a lot for helping! :))

wheat carbon
wheat carbon
#

show me how you load it

atomic trail
#

Ohhh yeah I load it as a named array

#

JsonArray parser = JsonParser.parseReader(reader).getAsJsonObject().get("portalsData").getAsJsonArray();

wheat carbon
#

JsonParser.parseReader(reader).getAsJsonArray()

atomic trail
#

Thanks

dense galleon
#

@dense drift It worked! Deepslate:0b, needed to specify that 0 is a boolean and not an int! thank you!

dense drift
#

nice

dense galleon
#

It makes sense it works this way

#

otherwise what would be the point 😂

#

But I guess that if I want to see if the entity's age is above a value

#

that's impossible

naive yacht
#

I have a question I use PufferPannel for my server and I want to define 3-4 CPU cores / servers do you know how I can do that ?

atomic trail
#

How can I specify a json object name when writing to a json file?

wheat carbon
#

show me an example of the json you want to generate

atomic trail
#

This

  "linkedPortals": [
    {
      1:3,
      2:4
    }
  ]
#

I think I can read it like this

Type typeOfHashMap = new TypeToken<Map<Integer, Integer>>() { }.getType();
linkedPortals = GSON.fromJson(JsonParser.parseReader(reader).getAsJsonObject().get("linkedPortals").getAsString(),
typeOfHashMap);

So I just need to write it somehow

wheat carbon
#

any chance you're using guice

atomic trail
#

No idea what it is ngl

wheat carbon
#

anyway just pass in a map when u save it

#

Map.of("linkedPortals", data)

wheat carbon
#

just asked because it has a util that makes typeOfHashMap a bit cleaner

#

Types.mapOf(Integer.class, Integer.class)

atomic trail
atomic trail
wheat carbon
atomic trail
#

It's not stored in the data instance anymore

wheat carbon
#

show me how you're saving it

atomic trail
#

It's just in my manager class

And then this runs when I start the server

            Type typeOfHashMap = new TypeToken<Map<Integer, Integer>>() { }.getType();
            linkedPortals = GSON.fromJson(
                    JsonParser.parseReader(reader).getAsJsonObject().get("linkedPortals").getAsString(),
                    typeOfHashMap);
wheat carbon
#

you know there is one easy way to do this

atomic trail
#

Would be great lol

wheat carbon
#

instead of deserializing all these parts of your config individually

#

just create one object that represents your entire config

atomic trail
#

Yeah I was wondering if that would be better for performance, but kinda wanna know how I save a named object to a json file

wheat carbon
#

or you can build the json manually with jsonobject or whatever gson provides

#

performance wise, it doesn't make any difference, it's a quality thing

atomic trail
wheat carbon
#

yes

atomic trail
#

That explains a lot, but how would you store it all in one instance? I only have one linkedPortals map and a lot of locations from data?

#

Just wondering

wheat carbon
#

show me your config

atomic trail
#

wait no

#

paste is missing smth

#

Basically every data instance also contains an id

#

which is how I'm linking them in the linkedPortals

wheat carbon
#

can you paste the correct config

atomic trail
#

Idk why it's indented like that but yeah

#

Idk why it's indented like that but yeah

#

Idk why it's indented like that but yeah

wheat carbon
#

mix of tabs and spaces likely

atomic trail
#

Probably yeah

#

Would preferably have it like this also

  "portalLocations": [
    {
      "worldName": "world",
      ...

To name the list

#

But doesnt matter much for now

wheat carbon
#

aight

#
public final class Config {
    private List<PortalLocation> portalLocations;
    private List<Map<Integer, Integer> linkedPortals;

    public List<PortalLocation> portalLocations() {
        return portalLocations;
    }

    public List<Map<Integer, Integer>> linkedPortals() {
        return linkedPortals;
    }
}

public final class PortalLocation {
    private String worldName;
    private int x;
    private int y;
    private int z;
    private int id;

    // getters
}```
#
public final class Config {
    private List<PortalLocation> portalLocations;
    private List<Map<Integer, Integer> linkedPortals;

    public List<PortalLocation> portalLocations() {
        return portalLocations;
    }

    public List<Map<Integer, Integer>> linkedPortals() {
        return linkedPortals;
    }
}

public final class PortalLocation {
    private String worldName;
    private int x;
    private int y;
    private int z;
    private int id;

    // getters
}```
#
public final class Config {
    private List<PortalLocation> portalLocations;
    private List<Map<Integer, Integer> linkedPortals;

    public List<PortalLocation> portalLocations() {
        return portalLocations;
    }

    public List<Map<Integer, Integer>> linkedPortals() {
        return linkedPortals;
    }
}

public final class PortalLocation {
    private String worldName;
    private int x;
    private int y;
    private int z;
    private int id;

    // getters
}```
#

think discord is dying

#

took 3 tries to send that code block

atomic trail
wheat carbon
#

but anyway gson can fully handle those objects

#

you'd just go gson.fromJson(str, Config.class)

#

gson.toJson(config)

atomic trail
#

And then the same with PortalLocation I assume, and then add them all to the portalLocations list in Config class?

wheat carbon
#

no

#

PortalLocation is only used in Config

#

gson handles it by itself

atomic trail
#

Ohhh yeah I see

#

Smart!

#

I'll try

#

Wouldn't I need this?

            Reader reader = new FileReader(file);
            JsonArray parser = JsonParser.parseReader(reader).getAsJsonArray();
            
            for (JsonElement element : parser) {
                config = GSON.fromJson(element, Config.class);
            }

Not sure how you would retrieve that String or Element otherwise

spiral prairie
#

or smh like this

spiral prairie
#

or smh like this

#

discord dying

#

doesnt want to send my messages

spiral prairie
#

or smh like this

#

discord dying

spiral prairie
atomic trail
wheat carbon
#

String.valueOf won't work for that

spiral prairie
#

idk it should take an InputStream

atomic trail
#

Oh

atomic trail
wheat carbon
#

just pass in file reader

#

also make sure to put a name on the portal location array

#

in the json

#

and a comma after the array ends

#

(the json you pasted earlier is invalid)

atomic trail
#

Not the parser?

wheat carbon
#

don't need the parser anymore

#

we're skipping it

atomic trail
#

Oh nice

wheat carbon
#
  • gson.fromJson(str, Config.class)
  • gson.toJson(config)
#

these are like the only two gson interactions u need

atomic trail
wheat carbon
#

missing a comma l31

atomic trail
#

Ohhh yeah since it's all in one object now

#

And it's not possible to just make this into a map?

    public Set<Map<Integer, Integer>> linkedPortals() {
        return linkedPortals;
    }
wheat carbon
#

yes

#

just make it a map

atomic trail
#

aight nice

wheat carbon
#

and alter the json accordingly

atomic trail
#

Says it expects a name here but there's already one?

  "portalLocations": [
wheat carbon
#

paste json

atomic trail
wheat carbon
#

what's the exact error

atomic trail
#

Might be wrong indentation?

#

I probably used space or smth

#

Is it required to use tab?

wheat carbon
#

no

atomic trail
wheat carbon
#

show objects

#

config

#

and portallocation

atomic trail
wheat carbon
#

the config doesn't accurately represent the json

#

you updated the config to use a map, but not the json

atomic trail
#

Oh yeah

#

Fixed

#

Thank you very much for all the help! :))

prisma briar
dusty frost
#

eclipse 🥶

sterile hinge
#

jdt peensive

prisma briar
#

I have to 😮‍💨

dusty frost
#

IntelliJ literally exists

prisma briar
#

I'm using IntelliJ but I need to use eclipse compiler to fix the problem that I have right now.

dusty frost
#

oh no

digital garden
#

where can I get help pls?

dusty frost
#

Ask your question in the requisite channel

digital garden
#

requisite?

dusty frost
#

The channel that suits your needs

#

If it's a development problem, this channel

digital garden
#

okay thx

prisma briar
flat anchor
#

Hello guys! Who know how to build gradle sub modules with different java versions? (Like, module1 will use java 8, module2 java 16 and etc.)

lyric gyro
#

in each build script set the language version the compiler will use and emit

tasks.compileJava {
    options.release.set(11)
}

or 8, or 9, or 17, you get the idea

obtuse totem
#

Good, in which section of the config, can I disable the special characters? Since I can't find it, thanks.

pulsar ferry
#

Uh, what is "the config" you're talking about? Also what special characters?

obtuse totem
spiral prairie
#

what

pulsar ferry
obtuse totem
neat pierBOT
#
FAQ Answer:

Spigot Account Linking
To get support for a premium plugin owned by Clip or Glare you will need to verify your spigot account using =spigot in the #bot-commands channel. After you have successfully linked your spigot account you should ask your question in the coresponding channel for that plugin. If you have already linked your account and want to update your roles, run this command =spigot check.

atomic trail
#

Can someone help?

Could not compile settings file 'C:\Users\45512\Desktop\JAVA\Infection\settings.gradle'.
> startup failed:
  General error during conversion: Unsupported class file major version 61

  java.lang.IllegalArgumentException: Unsupported class file major version 61

Project SDK is 17
Gradle JVM is 17
Gradle version is 7.3.3

It works when using the gradle task in the menu of right side, but not when ran through console in IntelliJ

hard wigeon
#

Does anyone know what packet(s) enable the spectator shader for creepers, spiders, etc?

icy shadow
#

i'd expect it's client side

hard wigeon
#

well how does it know when to enable it?

icy shadow
#

although i have no evidence whatsoever

icy shadow
hard wigeon
lyric gyro
#

probably

#

but yeah there is no packet for "apply shader", it's handled by the client depending on the entity you're spectating

lyric gyro
#

what are you running exactly?

#

also show build script

atomic trail
#

I'm running gradle buildJar but it happens in all my plugins

#

Even with the simplest build task

#

Could it be openjdk 17 that doesn't work properly or something? It's downloaded from Oracle

lyric gyro
#

run and share the output of gradle -v

atomic trail
#
C:\Users\45512\Desktop\JAVA\Infection>gradle -v

------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------

Build time:   2021-05-14 12:02:31 UTC
Revision:     1ef1b260d39daacbf9357f9d8594a8a743e2152e

Kotlin:       1.4.31
Groovy:       3.0.7
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          17 (Oracle Corporation 17+35-2724)
OS:           Windows 10 10.0 amd64

Oh yeah gradle 7.0.2 in this but it should still work with any version above 7

lyric gyro
#

eh yesn't

atomic trail
#

Wait doesn't it need 7.3?...

lyric gyro
#

7.3.3 is the latest but yeah

atomic trail
#

Yeah...

#

It is 7.3.3 in the gradle-wrapper properties file though

#

Figured it out ^^^

lyric gyro
lyric gyro
atomic trail
#

Yeah gotcha, ty

#

It's working now

#

Damn well this is annoying...

dusky harness
#

¯_(ツ)_/¯

#

../ to exit a dir

#

so I think ../Paper18/plugins

#

(it's ../. in this case because the folder name is .TestServers in case u got confused from that)

forest jay
#

hey! I have a plugin that does loads of stuff when a player joins the game, I have done my best to optimize it, but I am still getting some weird issues. If I restart the server, and a player joins, they sit with the world unloaded for multiple seconds, before everything loads in. Every other time they connect, it is perfectly fine. And the funny this, I am not caching anything, so idk why this is happening.

dusky harness
#

it can also be caused by a low-end server

forest jay
#

it definitely is the plugin,

forest jay
#
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();

        LobbyPlayer newP = new LobbyPlayer(p);
        PlayerUtils.addPlayer(newP);
        Bukkit.getScheduler().scheduleSyncDelayedTask(LobbySystem.getInstance(), () -> {
            DatabaseUtils.initialJoin(e.getPlayer());
        }, 40);

        p.setHealth(10);
        newP.sendLoginMessage();
        e.setJoinMessage("");
    }
#

that is my on player join

dusky harness
#
        Bukkit.getScheduler().scheduleSyncDelayedTask(LobbySystem.getInstance(), () -> {
            DatabaseUtils.initialJoin(e.getPlayer());
        }, 40);
```does this run database code sync or async?
forest jay
#

as far as I know async

dusky harness
#

scheduleSyncDelayedTask runs sync

forest jay
#

I added that afterwards

#

I thought it might help

dusky harness
#

in initialJoin do u have anything that redirects it to async?

forest jay
#

no

dusky harness
#

then it's running sync rn

forest jay
#

made no difference

dusky harness
#

wait

#

shouldn't u be using AsyncPlayerJoinEvent

#

wait

#

no thats chat

forest jay
#

yeah

dusky harness
#

you'll have to do Bukkit.getScheduler().runTaskLaterAsynchronously

forest jay
dusky harness
#

assuming that LobbyPlayer and PlayerUtils.addPlayer doesn't run any heavy/database calls either

forest jay
#

the lobbyplayer runs a ton of db calls

#

it gathers a bunch of information in one call

#
    public static ArrayList<Object> getPlayerValues(Player p) {
        MongoDatabase database = mongoClient.getDatabase("player-data");
        MongoCollection<Document> col = database.getCollection("main");

        Document filter = new Document("id", p.getUniqueId());

        ArrayList<Object> values = new ArrayList<>();

        for (Document doc : col.find(filter)) {
            values.add(doc.get("exp"));
            values.add(((Date) doc.get("first-join")).toInstant()
                    .atZone(ZoneId.systemDefault())
                    .toLocalDateTime());
            values.add(doc.get("shark-scales"));
            values.add(doc.get("gold"));
            values.add(doc.get("chat-color"));
            values.add(doc.get("welcome-message"));
            return values;
        }
        return values;
    }
dusky harness
#

that's probably why - the server is halted until all of the database data is retrieved

dusty frost
#

yeah do that bad boy async

dusky harness
dusty frost
#

or do a spark profiler with only long tick times if you want to be sure

forest jay
#

I ran some System.out.println() and the print appeared in console almost immediately yet the player was still stuck in mid air.

dusky harness
#

where did you put the print?

dusty frost
forest jay
#

And I also dont understand why this only happens on the first join when a server restarts

dusky harness
#

and can you try removing the listener and seeing if it's still happening?

formal crane
#

Why is a display name null if i didnt rename the original item?

dusky harness
#

if it isn't, then run spark report

dusky harness
#

hmm

dusky harness
forest jay
dusky harness
#

not the vanilla name

formal crane
#

can i get the vanilla name?

dusky harness
#

(since it doesn't use a hardcoded string, it changes based off of the language and resource pack)

dusky harness
dusky harness
forest jay
#

ye

#

but the other thing is

#

is that the db calls change the items in the player inventory and the stuff that appears on screen, If for like 3 seconds they dont see that, it would look very janky

forest jay
#

and Hypixel has to do a bunch of that stuff and they dont have a problem

#

so idk what is different

dusty frost
forest jay
dusty frost
#

if you need speed, use Redis or something and keep that shit loaded into memory

dusty frost
forest jay
dusty frost
#

99% of their stuff doesn't have persistence

forest jay
#

never suspended in air

dusty frost
#

I mean just run a damn spark report

#

We can sit here all day speculating

#

Or we can find out immediately

forest jay
dusky harness
forest jay
#

I can try again if you would like

dusty frost
dusky harness
forest jay
dusky harness
#

very odd

forest jay
#

I think it has to do with creating a new LobbyPlayer

dusky harness
forest jay
#
    public LobbyPlayer(Player player) {
        p = player;

        RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
        LuckPerms lp = provider.getProvider();
        user = lp.getUserManager().getUser(player.getUniqueId());
        rank = user.getPrimaryGroup();
        ArrayList<Object> values = DatabaseUtils.getPlayerValues(p);
        chatColor = ChatColor.valueOf((String) values.get(4));
        scales = (int) values.get(2);
        playerVis = VisibilityUtils.generateItem();
        joinMessage = (int) values.get(5);
        gold = (int) values.get(3);
        updateSocials();
        createProfile();
        updateInv();
        updateDisplayName();
        currentInv = p.getInventory();

        Bukkit.getScheduler().scheduleSyncRepeatingTask(LobbySystem.getInstance(), () -> p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("\uDB86\uDDFA" + Translator.numToUni(Translator.formatInt(gold)))), 0, 40);
    }```
dusky harness
#

oh wait

forest jay
dusky harness
#
        Bukkit.getScheduler().scheduleSyncDelayedTask(LobbySystem.getInstance(), () -> {
            DatabaseUtils.initialJoin(e.getPlayer());
        }, 40);
```it might be this part, since it runs 2 secs after which might not be enough for the player to load it? 🤷
dusky harness
#

can u try the entire listener?

dusky harness
#

or did u try that already

dusky harness
forest jay
#

it printed right as the clients screen loaded

dusky harness
forest jay
#

so it has to do with something inside the listener

forest jay
dusky harness
#

send spark report

#

:))

dusty frost
#

alright i need to ignore this conversation

forest jay
#

😢

dusty frost
#

y'all are trying to sink a nail with your hand while a hammer sits right next to you

forest jay
#

is it a plugin?

dusty frost
#

yes

dusky harness
dusty frost
#

have you heard of timings

#

it's like that, but better

forest jay
#

sort of

dusty frost
#

and you can set it so that it only profiles during ticks that are extra long

dusky harness
#

in console (before player joins): spark profilerthen once the player joins and the world loads, do /spark profiler --stopas a player cmd or ```
spark profiler --stop

#

then send the link that it generates here

forest jay
#

wait

#

so like

#

I have a custom skull thing

#

and I guess that is literally causing all the issues

dusky harness
#

ooof

I'm guessing it takes about 4 seconds slower for the player to load in?

dusky harness
forest jay
#

yeah

#
    public static ItemStack getCustomSkull(String id) {
        String url = "http://textures.minecraft.net/texture/" + id;
        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        PropertyMap propertyMap = profile.getProperties();
        if (propertyMap == null) {
            throw new IllegalStateException("Profile doesn't contain a property map");
        }
        byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
        propertyMap.put("textures", new Property("textures", new String(encodedData)));
        ItemStack head = new ItemStack(Material.LEGACY_SKULL_ITEM, 1, (short) 3);
        ItemMeta headMeta = head.getItemMeta();
        Class<?> headMetaClass = headMeta.getClass();
        ReflectionUtils.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
        head.setItemMeta(headMeta);
        return head;
    }```
dusky harness
#

I think what's happening is that spigot is connecting to that URL synchronously which is where the 3.5 seconds come from

forest jay
#

this is getting a custom skull for the socials

#

so I think I can handle this on startup

#

and create a new instance and then just edit the lore when the player joins

dusky harness
dusky harness
#

does this require being sync? or could you run this async?

forest jay
#

this is for a specific block

#

it looks like the discord icon

dusky harness
#

ah

forest jay
#

it doesnt need to be different per player

dusky harness
#

I think a player head updating 4 seconds later is better than a player floating in midair for 4 seconds 🙃

#

🥲

forest jay
#

ye

dusky harness
# forest jay ye

although note that interacting with the world async is unsafe (I think spigot throws an error) so you'll have to run the code async using runTaskAsynchronously/etc then when you get the ItemStack, you go back to sync: runTask and set the block

forest jay
#

k

dusky harness
# forest jay k

LobbyPlayer.sendLoginMessage and PlayerUtils.getPLayerLevel are also each taking up 44ms (so 2 ticks in total), so you'll want to run those async also

#

btw in the future, for reading spark reports you just go to the top right and click this: https://i.imgur.com/7ibnPB2.png until it says sources, then where you see your plugin you click Server thread then that's where you can see where it's lagging the server

forest jay
#

yeah ik

dusky harness
#

alr

forest jay
#

I found that out pretty quick

#

k

#

so

#

I got it fixed

dusky harness
#

pog

forest jay
#

I made it call the textures.minecraft.net when the plugin loads

#

and then just grab that item whenever the player needs it

#

also

#

for Redis

#

I have it setup, and I use it for a few things, but how would I store a bunch of player stuff? cause as far as I know I can only store strings, kinda like a hashmap

#

with a key and a value

#

would I do like "<player_uuid>.gold", "2837"?

atomic trail
vestal forge
#

Considering a someCompletableFuture which is doing some heavy task, is there difference between those 2? Is thenApply going to block thread waiting for someCompletableFuture to finish?```java
someCompletableFuture.thenApplyAsync{
//some code
}

someCompletableFuture.thenApply{
//some code
}

tall anchor
#

Hey! Does Bukkit/Spigot/Paper have "village entry" event?
I know there's "RaidTriggerEvent" that gets triggered when player enters a village and has bad omen.

tall anchor
#

But I'd still have to use some event for triggering.

atomic trail
#

Why? You can just run this in a runnable and checking within a specific radius

tall anchor
#

True, maybe 10sec timer or something

atomic trail
tall anchor
#

Would you happen to know if its possible to cancel "removing bad omen" effect, when triggering RaidTriggerEvent?
At the moment I'm using "EntityPotionEffectEvent" to see if Bad Omen gets removed from player when it shouldn't, but it's very spammy...

Not even sure why Bad Omen gets removed even with RaidTriggerEvent is cancelled - maybe it's a bug.

amber storm
#

is there a way to get the names of all different types of entities?

wheat carbon
#

d;fields spigot entitytype

uneven lanternBOT
#
Fields:
org.bukkit.entity.EntityType%HOGLIN
org.bukkit.entity.EntityType%FISHING_HOOK
org.bukkit.entity.EntityType%SHEEP
org.bukkit.entity.EntityType%SNOWMAN
org.bukkit.entity.EntityType%SPECTRAL_ARROW
org.bukkit.entity.EntityType%TURTLE
org.bukkit.entity.EntityType%IRON_GOLEM
org.bukkit.entity.EntityType%VEX
org.bukkit.entity.EntityType%EXPERIENCE_ORB
org.bukkit.entity.EntityType%SILVERFISH
org.bukkit.entity.EntityType%CAVE_SPIDER
org.bukkit.entity.EntityType%MAGMA_CUBE
org.bukkit.entity.EntityType%ELDER_GUARDIAN
org.bukkit.entity.EntityType%MINECART_TNT
org.bukkit.entity.EntityType%MINECART```
wheat carbon
#

that enum has all the entities

amber storm
#

t

#

y

wheat carbon
#

can call Enum#values then #getName on all the values

#

turns out getName is deprecated actually you're meant to call getKey I think

shell moon
#

if i have a plugin that requires pemission.1 permission.2 etc etc
but i want to allow also permission.2-5 for ranges, what would be the best way to make it?

dense drift
#

Filter their permissions and then get the numbers?

shell moon
#

you mean get (effective) permissions and that stuff?
check if format is similar, get the min-max part, separate by dash

dense drift
#

Yeah or using vault (if it has such function)

shell moon
#

parse ints, catch errors, and check it

#

i was expecting another solution :,v

dense drift
#

If you are looking for a certain value, could be worth to see if they have that permission first

shell moon
#

yeah, already doing that

#

just wondering if there was another option

#

maybe something i was missing

dense drift
#

Well, since permissions are just some strings and don't have a set format, i don't think there's many options

#

Could also keep a cache of permission -> range in case you are checking for this frequently

#

A Cache<String, Pair<Integer, Integer>> maybe

shell moon
#

well, range use is optional, hopefully no one will enable it

dense drift
#

If you have such function, they will xd

shell moon
#

it's disabled by default, its hidde in config

#

otherwise they need to use

#

heads.1 heads.2 heads.3 heads.4

#

and so on until heads.42000

dense drift
#

Then why do you add it if is hidden lol

shell moon
#

i wasn't sure if that was the best way

#

xD

dense drift
#

Allow multiple ranges xd

#

heads.1-5,10-20

shell moon
#

no way xd

silk rover
#

hi, im looking up for a way to place blocks randomdly using worldedit/fawe. I have been searching but there's not more results than 5 or 6 and all of these are above 1.8 spigot, which is in the version where im developing ;/

lyric gyro
#

1.8
I'm sorry to hear that 😟

icy shadow
#

im not

silk rover
#

🥸

brittle thunder
icy shadow
fading stag
#

What is [20:47:57 WARN]: Enabled plugin with unregistered PluginClassLoader? When I use my plugin's reload command it says this.

lyric gyro
#

what the hell are you doing in your reload command

fading stag
#

send message to sender and

Bukkit.getPluginManager().disablePlugin(plugin);
Bukkit.getPluginManager().enablePlugin(plugin);
dense drift
#

No

sterile hinge
#

oh god

dense drift
#

Dont

lyric gyro
#

yeah no don't do that

#

like

#

ever

#

never

dense drift
#

Bukkit#shutdown

fading stag
#

What should I do instead?

dense drift
#

Reload config, load stuff like messages

#

Define your own reload logic

fading stag
#

I'm adding placeholders to PAPI, Should I register placeholders again at reload?

dense drift
#

no

worn jasper
#

Yo, how can I turn a List<String> into a List<Component>? (I want to set the lore of an item, but newer versions need component lol)

dense drift
#

d;adventure Component#text

uneven lanternBOT
#
@@Contract(pure=true) @@NotNull
static TextComponent.Builder text()```
Description:

Creates a text component builder.

Since:

4.0.0

Returns:

a builder

lyric gyro
#

if they're legacy strings you'll want to use the LegacyComponentSerializer tho

worn jasper
#

wdym with legacy strings

dense drift
#

&cHey

lyric gyro
#

or § but that's the "idea"

worn jasper
#

oh ye then yes, I am using those

#

but the thing is, doesn't Component.text only accept a string as input

#

not a list of strings

dense drift
#

Stream#map

#

or just a for loop

dusky harness
hushed badge
#

for loop yup

worn jasper
dusky harness
dusky harness
worn jasper
#

k ty

vale spindle
#

Hi, I have a problem registering custom placeholders using PlaceholderAPI.

This is my code:

        getConfig().getStringList("connected-servers").forEach(server -> {
            sqlModules.addServer(server);
            PlaceholderAPI.registerPlaceholderHook("adminutils_" + server, new EZPlaceholderHook(this, "adminutils_" + server) {
                @Override
                public String onPlaceholderRequest(Player p, String s) {
                    return String.valueOf(getSqlModules().getOnlinePlayers(server));
                }
            });
        });```

The list is this:
```YML
connected-servers:
  - "lobby-1"
  - "event"```

But when I try `/papi parse me %adminutils_event%` it returns %adminutils_event%. Could someone help me out?
hushed badge
#

use the PlaceholderExpansion instead of EZPlaceholderHook

vale spindle
hushed badge
#

i am also very confused about what is happening there

dusky harness
#

wait what is EZPlaceholderHook

hushed badge
#

im pretty sure its the very very very old way of registering expansions

dusky harness
#

oh 🥲

hushed badge
#

i think it was even taken out in newer versions

vale spindle
#

@hushed badge When I try to use this, it says that the #registerPlaceholderHook() is gonna be removed. Do you know what I can use for something like this?

        getConfig().getStringList("connected-servers").forEach(server -> {
            sqlModules.addServer(server);
            PlaceholderAPI.registerPlaceholderHook("adminutils_" + server, new PlaceholderHook() {
                @Override
                public String onRequest(OfflinePlayer player, @NotNull String params) {
                    return String.valueOf(getSqlModules().getOnlinePlayers(server));
                }
            });
        });```
#

"'registerPlaceholderHook(java.lang.String, me.clip.placeholderapi.PlaceholderHook)' is scheduled for removal in version 2.13.0"

hushed badge
#

follow the guide, u should be creating a new class that extends PlaceholderExpansion, and to register that expansion u would use new YourClassThatExtendsPlaceholderExpansion().register(), and only register this once, so preferably in onEnable()

#

PlaceholderHook and EZPlaceholderHook are both the old ways of creating expansions 🥲

lyric gyro
leaden sinew
#

So I'm using the Paper API currently for a plugin, but I also want it to support Spigot.
I'm mostly only using it for components, and also I used the armor change event.
What would be the best way to support Spigot too?
Should I separate them into modules?

pulsar ferry
#

Separate modules or don't use Paper API and use just the Bukkit platform of adventure

atomic trail
#

This can be static since it's just a config util right?

graceful hedge
#

doesnt look like a util to me

dense drift
#

Ye

leaden sinew
pine flax
#

i'm working on something where i need to modify or cancel the player's chat message, but having venturechat on the server breaks it. i found their VentureChatEvent, but it can't be modified or cancelled. so far i've tried listening to AsyncChatEvent with priority = highest. i also considered copying how they send messages to players in their chat listener, but i don't think that'll work. any ideas?

lyric gyro
#

anyone know why this code isnt working? im not getting any errors, and i use this EXACT same code all over my plugin

public class OnRespawnEvent implements Listener {
    private Classes main;

    public OnRespawnEvent(Classes classes){
        this.main = classes;
    }

    @EventHandler
    public void onRespawn(PlayerRespawnEvent e) {
        Player ply = e.getPlayer();
        UUID plyID = ply.getUniqueId();
        String calledClass = main.getConfig().getString(String.valueOf(plyID));
        // String realClass = CustomConfig.get().getString(calledClass);

        if (calledClass != null) {
            for (String section : CustomConfig.get().getConfigurationSection(calledClass + ".effects.").getKeys(false)) {

                PotionEffectType type = PotionEffectType.getByName(CustomConfig.get().getString(calledClass + ".effects." + section + ".type"));
                int potency = CustomConfig.get().getInt(calledClass + ".effects." + section + ".potency");
                ply.addPotionEffect(new PotionEffect(type, Integer.MAX_VALUE, potency));

            }
        }
    }
}```
warm steppe
#

that class name tho 😫

#

calledClass is probably null

dense galleon
#

Does the order which advancements are shown in the advancement tab depend on anything

#

or is it semi random

dense drift
#

I think it is based on their relation

#

Because as you can see, they are connected

dense galleon
#

Yeah but

#

Why is the line of advancements following the iron pickaxe above the deepslate one

#

And not the other way around

#

If I had to guess it's alphabetical order tbh

#

It's not

dense galleon
#

What other order could it be then

#

Online it says it's based on file name but doesnt seem like it to me

fading stag
#

Does

Bukkit.broadcast("message", "permission")

sends message to Operator's who don't have specified permission?

dense drift
#

d;spigot Bukkit#broadcast

uneven lanternBOT
#
public static int broadcast(@NotNull String message, @NotNull String permission)```
Description:

Broadcasts the specified message to every user with the given permission name.

Parameters:

message - message to broadcast
permission - the required permission permissibles must have to receive the broadcast

Returns:

number of message recipients

dense drift
#

Broadcasts the specified message to every user with the given permission name.

fading stag
#

tx

patent zephyr
neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use