#help-development

1 messages · Page 602 of 1

gray talon
#

this is how i deal with stuff

#

ok i finally figured out

#

my own problem

#

the client drop player's item

#

the item you see burst out of a player when death

#

is handled client side

#

suprise suprise

#

how the server triggered it

#

is simple

#

new PacketPlayOutEntityStatus(entity, (byte)3)

#

now i can just cancel it

#

good lord this took me 2 hours to figure out

#

im so stupid

umbral ridge
#

Question regarding "Respawn point set" message in the game chat when a player interacts with bed - when their bed spawn location updates. Can you modify or remove that message in the chat along with the action bar message? Can either of those be customized or removed or cancelled via packets?

API method(s) used
I've used an override method onPacketSending with a PacketEvent parameter.
In there I am checking for packet type like so: PacketType.Play.Server.<enum>
The enum part is where the enum goes and I've tried even some deprecated ones such as BED, USE_BED, ANIMATION, GAME_STATE_CHANGE, CHAT, BLOCK_ACTION - for which I figured that is for players who send a message to the game chat.

This is the only thing I've tried so far because I can't think of another.
I've tried messing around with the PlayerInteractEvent but that didn't give me an expected result.
I'm looking for a little help and tips in which direction I should be going instead, with the code.

I'm using Minecraft Spigot 1.19.2 with ProtocolLib 5.0.0

Expected behavior
I'm expecting to be able to modify/remove the message in the game chat and action bar.

Code
This is an example code of how I'm handling packet intercepting

public class PacketInterceptor extends PacketAdapter {

    public PacketInterceptor(Main main) {
        super(main, ListenerPriority.NORMAL, PacketType.Play.Server.BED);
    }
    
    @Override
    public void onPacketSending(PacketEvent event) {
        event.setCancelled(true);
    }
}```
upper hazel
#

@gray talon hey in bukkit api not exists analog metod for speed up update?

gray talon
#

the fuck is analog method

upper hazel
#

my friend say he use bukkit

#

this mean bukkit api?

#

just i dont want load another api

#

for it

autumn cave
#

Yo @flint coyote mf, looks like ChunkSnapshots are not that thread safe after all. Turns out ChunkSnapshot::getBlockData(...) was what slowed everything down. Executing theses calls in the main thread and caching them for async made everything as fast as sync.

golden turret
#

is there a way to create an item like this

compact haven
#

wut

golden turret
#

each color represents a separated model

#

separated .jsons

#

but they are combined into 1 item

compact haven
#

to my knowledge 1 item = 1 model

golden turret
#

the client wants like 5 items to be combined into 1

#

and have a model based on the 5

compact haven
pseudo hazel
#

just make a model with the 5 items

chilly hearth
#

whats the event for tnt ignited ?

eternal oxide
#

TNTPrimeEvent

chilly hearth
#

iam getting a event called TNTPrimed is it the same ?

chilly hearth
#

so is it the same ?

worldly ingot
#

TNTPrimed is the entity

eternal oxide
#

TNTPrimed is not an event

chilly hearth
#

like its not recongnizing the event

#

just giving red

eternal oxide
#

you are not importing the event

chilly hearth
#

package me.airforce.plugin;

import org.bukkit.Material;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

public final class Plugin extends JavaPlugin implements Listener {

@Override
public void onEnable() {
    // Plugin startup logic
    System.out.println("Plugin is started!");
    getServer().getPluginManager().registerEvents(this,this);

}
@EventHandler
public void onTNTExplode(TNTPrimeEvent event) {


}
chilly hearth
eternal oxide
#

when it primes is not when it explodes

#

as I said, you are not importing the event

compact haven
#

what version are you on

#

paste your pom.xml

chilly hearth
compact haven
#

I'm like 90% positive you're on a far too old version

chilly hearth
compact haven
#

do you have a pom.xml

chilly hearth
#

iam on 1.18.1

chilly hearth
compact haven
#

ctrl a, ctrl c, ctrl v

eternal oxide
#

no

#

we don;t need your pom

chilly hearth
#

it says it exceeds the limit of 2000 characters

chilly hearth
eternal oxide
#

just import the TNTPrimeEvent if you want to use it

compact haven
eternal oxide
#

ah true

chilly hearth
#

iam not on 1.8

compact haven
#

?paste

undone axleBOT
compact haven
#

I'm still curious

worldly ingot
#

TNTPrimeEvent was only added in 1.19.4

compact haven
#

oh, shit

#

well that explains

eternal oxide
#

ah

chilly hearth
#

<version>1.18.1-R0.1-SNAPSHOT</version>

#

BRUH

eternal oxide
compact haven
#

well it might not be 1.8 but it's still too old lmfao

#

if you want an alternative, you can run a schedular from interact -> explode and check for prime then, then fire your own prime event

eternal oxide
#

TNT is a Block. When primed it becomes an Entity

gray talon
#

me in 1.7

eternal oxide
#

so listen the explode event for it blowing up

gray talon
#

ha what are people talking about

compact haven
#

you have to be a fake user

chilly hearth
#

by cenceling it

gray talon
river oracle
#

Bro stuck in the past someone froze his clock but tis okay

gray talon
#

the thing that kept me from moving is the legacy codebase

#

if it still works

#

why touch it

#

the fact there is a wish copy of the 1.19 warden

#

in 1.7 server core

#

no terrain generator tho

autumn cave
#

Anyone know why ChunkSnapshot#getBlockData(...) is very very slow when running async?

gray talon
#

version?

autumn cave
#

1.20.1

gray talon
#

nms implementation

autumn cave
#

mojang mappings?

gray talon
#

inside CraftBlockData.class

autumn cave
gray talon
#

what is MAP field

#

what data type

autumn cave
#
private static final Map<Class<? extends Block>, Function<BlockState, CraftBlockData>> MAP = new HashMap();
gray talon
#

tf is Function

#

send me the declaration of the actual thing

#

it should not be slow

#

all of them are jus standard java elements

autumn cave
#

Here basically:

static {
        register(AmethystClusterBlock.class, CraftAmethystCluster::new);
        register(BigDripleafBlock.class, CraftBigDripleaf::new);
        register(BigDripleafStemBlock.class, CraftBigDripleafStem::new);
        register(AnvilBlock.class, CraftAnvil::new);
        register(BambooStalkBlock.class, CraftBamboo::new);
        ...
}

private static void register(Class<? extends Block> nms, Function<BlockState, CraftBlockData> bukkit) {
    Preconditions.checkState(MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
}
gray talon
#

hm

#

it should not happend

#

as far as my knowledge goes

autumn cave
#

I see alot of casts though, isin't that bad for performance?

gray talon
#

nope

autumn cave
#

o_O

gray talon
#

i mean

#

is it a BIG lag spike

#

or just nanosecond delay

#

WAIT

autumn cave
#

xd

gray talon
#

like

#

where it is actually used

#

where did you use it

autumn cave
#

136 x 36 x 202 region capture of all block data:
running sync, takes 1784 ms = 1.7 sec
running async takes 125011 ms = 125 sec
Executed within commands

gray talon
#

how would you "Execute" it

#

send the code

#

there

autumn cave
#
for (x in 0 until size.block.x) {
    for (y in 0 until size.block.y) {
        for (z in 0 until size.block.z) {
            val position = Vector(x, y, z)
            map[position] = getBlockData(position)
        }
    }
}
gray talon
#

is that kt

autumn cave
#

yes

gray talon
#

like

#

how you used Async

autumn cave
#

I've tried all of them: Bukkit.getScheduler().runTaskAsynchronously(...), Thread and now I'm on the kotlin one. All same result. When its sync its just running as is

gray talon
#

how did you use this

#

Bukkit.getScheduler().runTaskAsynchronously

#

where did you put it

autumn cave
#

In the command execution

gray talon
#

bruh

#

like

#

whats come after Bukkit.getScheduler().runTaskAsynchronously

remote swallow
#

?scheduling

undone axleBOT
gray talon
#

im not asking questions

remote swallow
#

Yeah

autumn cave
#

Nothing, the command ends, well I do send a message to the player saying its done but that is within the lambda async

gray talon
#

ok so

#

did you surround this

gray talon
autumn cave
#

Yes

#

That's what I'm saying. When its surrounded = 125 sec, when not = 1.7sec

round finch
#

js?

gray talon
#

kotlin

remote swallow
#

Run it in a completeable future

round finch
#

me: seeing kotlin react_diesofcringe

gray talon
#

CompletableFuture

autumn cave
#

yeah you think it will help?

gray talon
#

try it and see

remote swallow
#

Bukkit async isnt always the best

gray talon
#

or straight up

#

do this

#
new Thread(() -> {

}).start();
autumn cave
#

Should I use it like this?

Executors.newCachedThreadPool().submit(() -> {
        Thread.sleep(500);
        completableFuture.complete("Hello");
        return null;
    });
flint coyote
remote swallow
#

CompletableFuture.supplyAsync

autumn cave
#

CompletableFuture.supplyAsync(() -> "Hello").get() ?

remote swallow
#

Get blocks

gray talon
#

do a little benchmark

autumn cave
remote swallow
#

Calling get on an async future forces it to run blocking main

autumn cave
#

so how do I run it?

remote swallow
#

You have to use whenComplete or thenAccept

remote swallow
autumn cave
#

ah ok

gray talon
#

the f is that sentence

remote swallow
#

Which

gray talon
#

you have you use

#

my head just trip a wire rifht there

remote swallow
#

Me on phone

gray talon
#

autocorrect

#

am ir ght

autumn cave
#

Still taking forever with completable future

flint coyote
icy beacon
#

?paste for myself

undone axleBOT
autumn cave
remote swallow
#

If you want some better explanation of cfs read this

flint coyote
gray talon
#

im out

#

this is more absurd than the EntityPlayer issue

autumn cave
#

Its only when I use ChunkSnapshot#getBlockData(...)

flint coyote
#

Odd. I'll still run a test

cunning crater
#
@EventHandler
    private void entityChangeBlockEvent(EntityChangeBlockEvent e) {
        if (!game_running) {
            return;
        }
        if (e.getBlock().getWorld() != world) {
            return;
        }
        if (e.getBlock().getType() == Material.ANVIL) {
            e.getBlock().getDrops().clear();
            e.getBlock().setType(Material.AIR);
            e.setCancelled(true);
            return;
        }
        if (!e.getEntityType().equals(EntityType.FALLING_BLOCK)) {
            return;
        }

        FallingBlock fb = (FallingBlock) e.getEntity();
        if (!fb.getMaterial().equals(Material.ANVIL)) {
            return;
        }
        Location loc = fb.getLocation();

        Block block = world.getBlockAt(new Location(world, loc.getX(), loc.getY() - 1, loc.getZ()));
        if (block.getType() == Material.QUARTZ_BLOCK) {
            block.setType(Material.AIR);
        }
    }

I have this code I wrote long ago for falling anvils breaking blocks and disappearing (probably inefficent, I don't remember why I did it like this exactly), however when they break the block and disappear, they drop a no texture Anvil item, and some people crash when placing it. (1.8.8) Any idea why this happens or a better way to do this?

autumn cave
#

Btw world.getChunkAt(x, z).getChunkSnapshot() is the correct way to create a chunk snapshot right?

flint coyote
#

Is the chunk loaded when you capture that snapshot?

autumn cave
#

@remote swallow @gray talon CompletableFuture.supplyAsync(() -> ...) still runs very very slow compared to running sync ChunkSnapshot#getBlockData(...) calls

gray talon
#

im still processing my own issue

#

please halt

autumn cave
flint coyote
#

Try to load them beforehand. Just to be sure.
This line on the docs make me question what's loaded to create a snapshot If the chunk is not yet fully generated and data is requested from the chunk, then the chunk will only be generated as far as it needs to provide the requested data.

#

I mean it's talking about generation, not loading but I'd still try if I were you

autumn cave
#

Yeah it is talking about generation. I just tried, they are all loaded

#

ohh wait!!! I forgot to mention perhaps a crutial part!! @remote swallow @flint coyote I do a position convertion to get the correct chunk block:

private fun getBlockData(position: Vector): BlockData {
    val location = position.toLocation(world)
    val chunkSnapshot = snapshots[location.chunk.x][location.chunk.z]
    val local = (origin + location).run { Location(world, (x).mod(CHUNK_SIZE), y, (z).mod(CHUNK_SIZE)) }
    return chunkSnapshot.getBlockData(local.block.x, local.block.y, local.block.z)
}
#

Is creating a Location object with a world reference not thread safe? I don't access anything, I just use Location for cooredinates x y z

flint coyote
#

I mean it uses a WeakReference to the world. I'd have to check if those are threadsafe

autumn cave
#

ahh I see

#

no, I messed up

#

local.block.x

vital yacht
#

Doesn’t location.getChunk() force load the chunk?

autumn cave
#

accesses a Block reference ;-;

vital yacht
#

So you’re loading the chunk async

autumn cave
#

I solved my problem

flint coyote
#

oh, yes that makes sense.
That's why you have all the functions in the snapshot to avoid using sync data

autumn cave
gray talon
#

i managed to paste 4M blocks in 200ms

eternal oxide
#

now correct the lighting 😉

gray talon
#

it is correct tho

#

nothing is off

eternal oxide
#

not if you pasted 4M in 200ms

#

thats not correct lighting

#

thats fully lit

gray talon
spare hazel
#
        inv.setItem((9 * 3) + 4, createGuiItem(Material.DIAMOND_BLOCK, ChatColor.GREEN + "" + ChatColor.BOLD + "Stat Rewards", List.of("", ChatColor.RED + "Health: +" + skill.getHealthRewards(), ChatColor.AQUA + "Defense: +" + skill.getDefenseRewards(), ChatColor.BLACK + "Damage: +" + skill.getDamageRewards())));

why does this item only contain the first 2 lore lines? the third argument is for the lore

gray talon
autumn cave
#

is there an int vector in bukkit/spigot?

eternal oxide
#

a vector is 3 doubles

pseudo hazel
#

so no

eternal oxide
#

you convert to int if you need

autumn cave
#

nother types of vectors or similar?

eternal oxide
#

no

#

or Location.getBlockX etc

spare hazel
# gray talon

can you give me the math that you used to calculate the velocity to add to the armor stand for the skyblock hyb jump pads? it looks like you are remaking hypixel skyblock

gray talon
#

just a parabolic array

#

is this what you meant @eternal oxide

eternal oxide
#

yes

gray talon
#

that torch over there is trippy

#

still some hiccups

cunning crater
gray talon
#

fairy room

#

lit

#

welp

#

still need engine rewrite

spare hazel
gray talon
#

nope

spare hazel
#

k

#

how long did it take you to make this plugin?

gray talon
#

its a project

#

not a plugin

#

this isnt a plugin

#

@eternal oxide i see now

#

very cool lighting

spare hazel
#

no i mean the hypixel skyblock core plugin

gray talon
#

thats not a plugin

#

thats the entire server software

spare hazel
#

no way

gray talon
#

it doesnt work like drag+drop

spare hazel
#

but how long did it take to come this far?

gray talon
#

the lighting is just nuts lmao

flint coyote
#

The damage?

spare hazel
young knoll
#

What does createGuiItem look like

flint coyote
#

uhm was that meant to respond to my other message?

flint coyote
#

then show us the method that Coll asked for, please

spare hazel
flint coyote
#

paste it here

chrome beacon
#

?paste

undone axleBOT
spare hazel
#
protected ItemStack createGuiItem(final Material material, final String name, List<String> lore) {
        final ItemStack item = new ItemStack(material, 1);
        final ItemMeta meta = item.getItemMeta();

        // Set the name of the item
        meta.setDisplayName(name);
        meta.setLore(lore);
        meta.addItemFlags(ItemFlag.HIDE_DYE, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_DESTROYS);

        item.setItemMeta(meta);

        return item;
    }
spare hazel
flint coyote
#

yeah that method looks fine

fresh timber
#

How would I make a boss bar that I send to a player every second and then remove the last one but change the new one a little. I'm basically doing a second by second timer and I want it to change every time and then remove the last one.

chrome beacon
flint coyote
#

Can you try whether the empty string is a problem that messes with the lore on the client? Try adding a letter instead of "" and check if all three appear

spare hazel
chrome beacon
#

...

gray talon
flint coyote
#

imagine losing at tictactoe

young knoll
#

Imagine remaking skyblock

#

Again

gray talon
#

yea ik

fresh timber
#

stop flooding chat

#

use ?paste

#

?paste

undone axleBOT
spare hazel
#

wait... there was an empty line at the end so the prroblem could be the color leme try both @flint coyote's suggestion and mine

young knoll
#

Why do you want to keep sending a new boss bar

#

Just update the existing one

fresh timber
#

yea i got no idea how to do that

#

I cant create a new bossbar object and i have no idea how to send one

gray talon
spare hazel
fresh timber
#

alr

gray talon
#

the other things are easy

spare hazel
gray talon
#

hm?

#

you dont need to

#

hypixel forces player to ride an invisible EntityArmorStand

spare hazel
#

yes i know that

gray talon
#

which moves according to the parabolic curve

#

moves = teleport

spare hazel
#

theres no way that it teleports
if it teleports, then the armor stand would start falling when the player's connection gets laggy

chrome beacon
#

It's not hard calculating the required velocity

gray talon
#

hypixel AC doesnt like player velocity

spare hazel
chrome beacon
#

It's just one formula you could google it

#

I have it at my pc for when I launched other stuff

quaint mantle
#

If you look at tab you will see a special font! Any idea on how to get that?

worldly ingot
#

RGB and some unicode characters

quaint mantle
#

wdym?

#

OHH

quaint mantle
worldly ingot
#

Yes

quaint mantle
#

Ok thanks

worldly ingot
#

Unsure which specific ones they're using

quaint mantle
#

So like how do I actually use this?

quaint mantle
worldly ingot
#

They're just regular characters

quaint mantle
#

Do I copy the U+????

worldly ingot
#

\u210A for example would be the unicode representation of the char, yeah

quaint mantle
#

ok

young knoll
#

I love how unicode just has other fonts in it

#

Because why not

worldly ingot
#

If you want to just write out a string and convert each char you can add the first char

#

e.g.

char monospaceA = '\u1D670' + ('Z' - 'A');
char monospaceE = '\u1D670' + ('Z' - 'E');```
#

Actually that's wrong lol

#

There we go. That would probably work for uppercase monospace fonts

quaint mantle
#

K

#

thanks alot

young knoll
#

Cursed code

worldly ingot
#

It's super general but yeah, a little cursed

young knoll
#

char is just weird

worldly ingot
#

You're weird

young knoll
#

It's like a string and a number at the same time

worldly ingot
#

Well, no. It's just an integer lol

#

If you ignore the fact that it can even be represented by a string then it's easier to work with them. Any time you use 'a' it's just treating it as its code point

young knoll
#

Don't care

#

Cursed

worldly ingot
#

cringe

young knoll
#

Ur cringe

umbral ridge
worldly ingot
#

I don't really look at DMs unless I'm expecting something. If it's a question you could probably just ask it here. I'm sure someone else could answer it too

umbral ridge
#

Could you answer it right since I'm lucky enough to have you in the chat?

#

This is it

cunning crater
worldly ingot
young knoll
#

Assuming that method exists in 1.ancient

cunning crater
#

I tried, still dropped these weird no texture anvils

umbral ridge
upper hazel
#

@gray talon oddly enough, but the tick start event in practice is slower than the same code with a flow of 0 ticks

young knoll
worldly ingot
#

You can

#

block.minecraft.bed. something

upper hazel
#

or by speed

umbral ridge
young knoll
#

Server resource packs exist

#

But if players are really annoyed by it they should just get a chat filtering mod

umbral ridge
#

They do exist but they're optional to each player, they can choose whether they want to use it or not. So yeah if it would be possible with a plugin, that'd be nice, so far I've managed to modify the action bar message but the chat message is little bit trickier I guess

#

I've posted the same message on ProtocolLib github but they're not really active that's why I came here

upper hazel
#

is there anything faster in terms of executing code in a loop than
tickStart event

young knoll
#

wtf is a tick start event

eternal oxide
#

not spigot

upper hazel
#

paper

#

oh

#

not say what you not use paper

young knoll
#

I mean it's probably your fastest option

upper hazel
#

demm

#

this is not enough

#

i need more speed

rose trail
#

I want to put my library in the Github repository. I did everything according to the instructions https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry. No matter how many tokens I create, it's still an error. Help who can) [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ library --- Uploading to github: https://maven.pkg.github.com/Xemii16/YeLibrary/com/yecraft/library/1.1-SHAPSHOT/library-1.1-SHAPSHOT.jar Uploading to github: https://maven.pkg.github.com/Xemii16/YeLibrary/com/yecraft/library/1.1-SHAPSHOT/library-1.1-SHAPSHOT.pom [IJ]-1-MojoFailed-[IJ]-source=LIFECYCLE-[IJ]-goal=deploy-[IJ]-id=com.yecraft:library:jar:1.1-SHAPSHOT-[IJ]-error=authentication failed for https://maven.pkg.github.com/Xemii16/YeLibrary/com/yecraft/library/1.1-SHAPSHOT/library-1.1-SHAPSHOT.jar, status: 401 Unauthorized [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.208 s [INFO] Finished at: 2023-07-05T15:45:10+03:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project library: Failed to deploy artifacts: Could not transfer artifact com.yecraft:library:jar:1.1-SHAPSHOT from/to github (https://maven.pkg.github.com/Xemii16/YeLibrary): authentication failed for https://maven.pkg.github.com/Xemii16/YeLibrary/com/yecraft/library/1.1-SHAPSHOT/library-1.1-SHAPSHOT.jar, status: 401 Unauthorized -> [Help 1]

remote swallow
#

is the credentials in the settings.xml

remote swallow
#

the settings.xml should be the global one

#

in USERHOME/.m2

eternal oxide
#

Did you create a personal access token with write access?

rose trail
eternal oxide
#

did you put that access token in yoru settings.xml?

#

as the password?

young knoll
eternal oxide
#

what is the exact mvn command you are using to deploy?

steep plaza
#

How can I make that an item that is given in the inventory can't be moved

remote swallow
rose trail
remote swallow
#

c/users/uruser

eternal oxide
#

I create a bat file in my project to deploy as it shoudl only be called once per release.```bat
@echo off
@echo.
@echo #################################################################
@echo # #
@echo # WARNING - Deploy should only be run once per release. #
@echo # #
@echo #################################################################
@echo.

setlocal
:PROMPT
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END

mvn deploy -Dregistry=https://maven.pkg.github.com/ElgarL -Dtoken=GH_TOKEN
pause

:END
endlocal```Replace ElgarL with your github user name.

steep plaza
#

How can I make that an item that is given in the inventory can't be moved?????

young knoll
#

Give it a PDC tag

#

And cancel all inventory events for items with that tag

candid kindle
#

im trying to iterate through the names of all my resources but am also getting the names of resources ive renamed/deleted, does anyone know why or how to stop this? heres how im doing it (just the relevant chunk):

jar = new JarFile(jarFile);
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
    JarEntry entry = entries.nextElement();
    String entryName = entry.getName();
    System.out.println("Entry name is " + entryName);
    String configPrefix = CONFIGS_DIRECTORY_NAME + "/";
    if (!(entryName.startsWith(configPrefix))) {
        continue;
    }
    System.out.println("Entry " + entryName + "starts with " + configPrefix + "!");
}```
and then heres my resources folder and the logs, and obviously the plugin is finding resources which dont exist anymore, which i dont want
pseudo hazel
#

and they are also removed in your servers plugin folder?

lost schooner
#

That's in there temporarily

candid kindle
quaint mantle
#

NO

quaint mantle
#

As many of you know, you can log to the console in three ways:

/* Way 1 */
System.out.println("Message");
 
/* Way 2 */
Logger log = Logger.getLogger("Minecraft");
log.info("Message!");
 
/* Way 3 */
Logger log = Bukkit.getServer().getLogger();
log.info("Message!");```
How do you log to the console? And what is the best way to it?
shadow gazelle
#

Is there a mapping viewer for Spigot -> MCP for 1.12?

shadow gazelle
young knoll
#

Use your plugins logger, JavaPlugin#getLogger

shadow gazelle
#

so that's obviously not it

kind hatch
young knoll
echo basalt
#

This is not really that easy with the Plugin Messaging Channel as you need a player online to actually receive the data

#

I'd just do it with redis and maybe an sql database to actually store the player positions

shadow gazelle
rose trail
# remote swallow c/users/uruser

i have a new error: org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT/maven-metadata.xmlfailed to transfer from https://maven.pkg.github.com/xemii16 during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of github has elapsed or updates are forced. Original error: Could not transfer metadata org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT/maven-metadata.xml from/to github (https://maven.pkg.github.com/xemii16): authentication failed for https://maven.pkg.github.com/xemii16/org/spigotmc/spigot-api/1.20.1-R0.1-SNAPSHOT/maven-metadata.xml, status: 401 Unauthorized

rose trail
echo basalt
#

That's what redis is for

#

Redis is a database type that basically works like a Map

#

but there's this thing called Pubsub which allows you to send "messages" on a "channel"

#

And those messages can just be binary data

quaint mantle
echo basalt
#

So in theory you can make a packet system that works with json strings, or in my case dumps a byte[]

#

And send that to the channel

#

And subscribe to that packet on the other end and add an entry

#

Should give you an idea

vital sandal
#

what is the issue with this?

remote swallow
#

uuid varchar(36) non null primary key iirc

dull schooner
#

hey, when i set a result that isnt possible in vanilla, like in the anvil, how to i allow the player to get the result? cause for me it keeps locked

brave pivot
#

For the brightness in a Display (using NMS), what int should I pass to the method?
The method is: SynchedEntityData.DataValue.create(new EntityDataAccessor<>(15, EntityDataSerializers.INT), <int>
Do I literally have to pass "(block << 4 | sky << 20)" and just replace block and sky with numbers?

vital sandal
#

how should I correct it?

remote swallow
#

remove the primary key(uuid) on the end and add primary key to the uuid at the top

zealous osprey
# vital sandal

Why are you storing so much?
Also, couldn't you use enums for stuff like "chatcolor" or "rank"?

rose trail
remote swallow
#

no

vital sandal
remote swallow
#

uuid varchar(36) not null primary key,
nick varchar...
rose trail
vital sandal
#

still err

remote swallow
#

paste the sql here rq

vital sandal
#

create table if not exists Player(
uuid varchar(36) not null primary key,
nick varchar(40) not null,
displaynick varchar(40) not null,
money double not null default 0,
passwd varchar(129) null,
slt varchar(129) null,
chatcolor varchar(120) null,
rank varchar(120) null
);

wet breach
vital sandal
wet breach
#

seems like there might have been an extra space somewhere possibly?

#

or maybe just have some kind of issue using whatever it is you are using

vital sandal
#

if I remove the 2 last line it work

#

no Idea why

wet breach
#

idk what your DB setup looks like, but either there was a space in there or some other hidden character

#

have you tried from the console?

vital sandal
vital sandal
wet breach
#

just remove all that extra space

vital sandal
#

Hmmm

#

I know what is wrong :l

wet breach
#

your issue could be because of the ); being on a separate line and not immediately at the end

vital sandal
#

the key should not be rank

#

I changed it to rankP

#

and it work ...

#

?

wet breach
#

then quite possible you already had something in there named rank

#

idk, I don't recall it being a protected name

#

again depends on your DB setup so

vital sandal
#

this is an empty DB :l

wet breach
#

the only thing I see in that screenshot which would have a protected name

#

is passwd, I think its just all the extra spacing at the end

ionic terrace
#

Does anyone know why doing getString() on a FileConfiguration class would cause a NullPointerException?

vital sandal
#

but I think I used to have the same issue in the past

ionic terrace
lost schooner
umbral ridge
# umbral ridge Question regarding "Respawn point set" message in the game chat when a player in...

For anyone who wants to know how I have solved it.

look here: https://github.com/dmulloy2/ProtocolLib/issues/2472

I've figured out that the "Respawn point set" message along with the action bar message is sent to the client ONLY when a player interacts with the foot part of an entire bed block (1x2, foot and head).

With that you basically cancel an interact event if player interacts with bed "foot" part and message will not be shown! and you can still manually update the location. So yeah, if player interacts with the "head" part of a bed block, messages suprisingly are not sent (I don't know if this is a bug or a feature?)

@worldly ingot I'm sorry for tagging you, I've solved it :D

eternal oxide
#

a plugin should not really give permissions, unless its for certain commands

#

but if you have to its a permission attachment on the player

obsidian spruce
#

hi guys

quaint mantle
obsidian spruce
#

it's possible to hook all events with a function that has @EventHandler?

#

tried but seems not working java @EventHandler public void onEvent(Event e) { System.out.println(String.format("%sonEvent (%s): %s.", ChatColor.LIGHT_PURPLE, e.getClass(), e.toString())); }

remote swallow
young knoll
#

You can only listen to events that have a getHandlerList method

remote swallow
umbral ridge
#

xd

zenith gate
#

I cannot get this function to be called.

@EventHandler
    public void FrozenAspect(EnchantItemEvent event) {
        event.getEnchanter().sendMessage("Enchanting");

        ItemMeta itemMeta = event.getItem().getItemMeta();
        PersistentDataContainer itemData = itemMeta.getPersistentDataContainer();

        if (itemData.has(new NamespacedKey(ToastsRPG.getPlugin(), "FrozenAspect"), PersistentDataType.INTEGER)) return;

        int randomNum = (int) Math.random();

        if (randomNum <= 3) { // The chance of getting Frozen Aspect I is 3%
            itemData.set(new NamespacedKey(ToastsRPG.getPlugin(), "FrozenAspect"), PersistentDataType.INTEGER, 1);
            List<String> lore = itemMeta.getLore();
            lore.add(ChatColor.BLUE + "Frozen Aspect I");
            itemMeta.setLore(lore);
            event.getItem().setItemMeta(itemMeta);
            event.getEnchanter().sendMessage(ChatColor.BLUE + "You have received a bonus `Frozen Aspect I` enchantment!");
        }
    }

the docs say this should be executed when a player has enchanted an item, but it never executes. It is registered.

echo basalt
#

ew Math.random

zenith gate
#

Math.random not good?

lost schooner
echo basalt
#

It's decent and works but

zenith gate
#

i saw Random as well..

echo basalt
#

ThreadLocalRandom.current()#randomInt

zealous osprey
#

^

echo basalt
#

It works, only creates a single instance per thread etc

#

I've had issues where Math.random() was icky and caused severe slowdowns in multi-threaded environments

zenith gate
#

Ah okay, welp I just changed it out. its now ThreadLocalRandom

remote swallow
zenith gate
#

??

remote swallow
#

create them in ur main class and use a getter or have a constants class where they're public static final

zenith gate
#

Okay, I will do that after I figure out why EnchantItemEvent isn't being called.

remote swallow
#

is the class registered

zenith gate
#

yes

#

both of them are

mellow edge
#

why is Bukkit.getScheduler().runTaskTimer now depercated?

#

lol I was using BukkitRunnable instead of normal runnable

#

I do

#

I do

#

but now I created a function getRunnable and I can not use lambda

#

thanks anyway

static cave
buoyant viper
#

?jd-s AiSmug

undone axleBOT
buoyant viper
#

ill be damned, it do

mellow edge
#

thank you for help!

buoyant viper
#

it shouldnt rly matter which u use id imagine, internally they probably call the same methods

#

:P

mellow edge
#

yes but if it is depercated it may be removed and I don't want to change my code rly in the future

remote swallow
#

we cant remove anything

#

if we do we loose backwards compat

mellow edge
#

ok

#

good

slate mortar
#

you can always remove shit and don't give a shit

round finch
#

toliet paper api

#

next fork on paper

young knoll
#

That exists

#

It's OriginRealms fork

round finch
#

anyway how do i make a spigot plugin there can rizz some b ¤%+.... beautiful ladies

#

@young knoll do i need chatgpt api for this?

young knoll
#

Probably

round finch
#

./getRizzed

#

Thank you Coll wise as always

static cave
zenith gate
round finch
#

Origin

craggy estuary
#

which one is better to use AttributeInstance#getValue or AttributeInstance#getBaseValue after changing the value? ( I haven't worked with the newer api so I really don't know which one to use)

#

^

young knoll
#

getValue to get the value with all modifiers applied

craggy estuary
quaint mantle
#

shout out to lambda

opal juniper
#

shoutout to lambda until I need to use Atomic values

chrome beacon
#

Then you're doing it wrong

#

Usually*

warped vigil
#

Hi im combining items in inventory. In creative it works fine but in survival it duplicates the item what should i do?

eternal oxide
#

Not use creative

warped vigil
#

But in creative it works

eternal oxide
#

make it work in survival only

warped vigil
#

i dont know how

mellow edge
#

I need help again. So is there a function in TNTPPRimed that controls how far away the entites in the explosion will be pushed to?

eternal oxide
#

creative is all client side. The server does whatever the client tells it

rare rover
#

would anyone change anything about this?

#

it seems fine to me but idk

eternal oxide
#

I'd not use Lombok but thats a personal choice 😉

rare rover
#

i actually kinda like it

#

cleans up code

eternal oxide
#

it does

rare rover
#

especially with @Cleanup

charred blaze
#

java.lang.NullPointerException: Cannot invoke "net.md_5.bungee.config.Configuration.contains(String)" because "this.plugin.config" is null
[Server] INFO at net.multylands.friends.events.JoinListener.onJoin(JoinListener.java:22) ~[?:?]

eternal oxide
#

in which case why are you not using an @allargs constructor?

charred blaze
#

help

#

i load my config like this onenable

rare rover
charred blaze
fervent gate
#

hey @eternal oxide, I've used your NPC spawning files but the NPC is despawning after like 15 seconds, any idea why?

paper cosmos
#

Oh my God. I've finally managed to build the server, after a few days of suffering

eternal oxide
#

not a clue

#

I've not used teh code in a while as I only wrote it to play around. but it worked fine when I did

fervent gate
#

strange, I'll try some things

charred blaze
#

Can anyone look into my issue please?

eternal oxide
#

possibly don;t send a remove packet which removes it from tab

#

functionality may have changed

remote swallow
charred blaze
#

why is plugin.config null?

remote swallow
#

show the Friends class

charred blaze
#

ok wait

#

whats problem?

eternal oxide
#

when do you call saveConfigIntoData ?

charred blaze
#

when editing config

eternal oxide
#

config in your Friends class doesn;t seem to be the same one as used in your listener

charred blaze
#

Why

eternal oxide
#

in your listener you are using `plugin.config

charred blaze
#

and?

eternal oxide
#

in your Friends class you are using a class field

#

is Friends your main plugin class?

charred blaze
#

yes

eternal oxide
#

ah ok

charred blaze
#

Whats wrong with my code?

eternal oxide
#

from what you have shown I see no issues

eternal oxide
#

no clue you never showed the top of your friends class

charred blaze
#

btw when i opened msg.yml it was ending with this weird thing

charred blaze
eternal oxide
#

move all yoru registerListener calls below setting up yoru config

charred blaze
#

why

#

ah

#

i get it

#

is this fine?

eternal oxide
#

yep

charred blaze
#

ah

#

i was starting my proxy when error happened

#

maybe player tried to join too early

#

thx

craggy estuary
#

If creating enchantments is thing how can I create a custom enchantment?

wet breach
#

they are sometimes not fully joined

#

so, its better to wait a few ticks or so after they join to do stuff

charred blaze
#

im not doing anything really intensive

wet breach
#

also, since you are messing with file related things, you should move those things to their own threads or make use of async tasks

#

look in the NIO package for thread safe file stuff

charred blaze
#

how do i do async on bungee?

wet breach
#

not sure if bungee provides async tasks, if it doesn't you will just have to do it yourself in making your own threads

#

anything that doesn't need to be done on the main thread shouldn't be done on the main thread when possible

charred blaze
#

it doesnt even take 1% cpu or ram to edit config i think...

wet breach
#

that isn't the issue

#

its blocking

#

when you stop the main thread it causes interruptions everywhere else to include connections

charred blaze
#

i know

#

but what is that interruption in my case

#

like

#

1milisecond?

wet breach
#

its not about the amount of time

#

its about whether or not other things can even reliably handle such things

#

connections are at times tollerent of minor interruptions but not always

#

and then you have other code that isn't expected to be hung up either

charred blaze
#

Ill get it to work async somehow

#

thanks

wet breach
#

I mean if it works for you now that is awesome, just letting you know you should move any code that doesn't need to be on main thread

#

off the main thread

#

this will allow everything to be a lot smoother

#

also allows you to make better use of your hardware at the same time

charred blaze
#

wait

#

it is already async?

wet breach
#

probably, you can always look at its code on stash

#

?stash

undone axleBOT
wet breach
#

if its scheduler is async you can if you want use that as it will make use of a thread pool

charred blaze
wet breach
#

or you can just opt to make your own threads, in either case the end goal is the same

charred blaze
wet breach
#

or right

#

bungee is on github lol

charred blaze
#

dont even know what class i need to check

wet breach
#

always forget bungee's repo is not on stash 😛

wet breach
#

anyways, essentially looking at the code would be looking at the scheduler implementation

charred blaze
#

ProxyServer.getInstance().getScheduler().schedule()

#

like this?

wet breach
#

seems about right

#

?tas

undone axleBOT
pseudo hazel
#

if I make a bukkittask and then cancel it later, if I then replace the reference variable I have to it with a new task, does the canceled task get gc'd or does bukkit keep the task hostage

charred blaze
#

ProxyServer.getInstance().getScheduler().runAsync(plugin, task)

#

this one

wet breach
#

so if you schedule a new task it will get a new task id

slate mortar
#

that's why any spigot-plugin that is using the AdvancementDisplay class will just throw a NullPointerException on paper servers

pseudo hazel
#

yes so then its safe to say that when my only reference to the task gets replaced and I cancel the task it will get gc'd sooner or later

wet breach
#

since you can query the scheduler for tasks it has

pseudo hazel
#

yes

#

oh okay

quaint mantle
#

How y’all do this coding bs I can’t wrap my head around it

pseudo hazel
#

good to know

#

practise, experience, motovation and having fun

charred blaze
# wet breach if its scheduler is async you can if you want use that as it will make use of a ...
    public void onJoin(PostLoginEvent e) {
        Runnable task = () -> {
            ProxiedPlayer p = e.getPlayer();
            String uuid = p.getUniqueId().toString();
            if (plugin.config.contains("Data."+uuid)) {
                return;
            }
            plugin.config.set("Data."+uuid+".DoNotDisturb", false);
            plugin.config.set("Data."+uuid+".SocialSpy", false);
            plugin.config.set("Data."+uuid+".FriendToggle", false);
            plugin.config.set("Data."+uuid+".Friends", "");
            plugin.saveConfigIntoData();
        };
        ProxyServer.getInstance().getScheduler().runAsync(plugin, task);
    }```
#

happy now?

cinder abyss
#

Hello, how can I display text below entity's name using nms 1.19 ?

quaint mantle
#

Fym practice u can’t learn anything from yt vids it’s just letters that do stuff how u meant to understand

wet breach
#

if I can tell a few things to make others better at what they are doing why not, whether you choose to use that advice is up to you 😛

quaint mantle
#

Y’all a bunch of nerds

wet breach
#

part of the reason a thread is better to have other then it doesn't stop the main thread is that the OS can opt to move it to another cpu core

#

which as I said earlier is good because it makes better use of hardware 🙂

charred blaze
#

Can i use bungee's scheduler to do JDA stuff?

#

would be super cool

wet breach
#

don't see why not

lost schooner
#

How do I instantiate a global hashmap so I don't have to remake it every time I check a value against it

#

More of a Java question than a Spigot question I guess

craggy estuary
#

If thats what you are going for?

lost schooner
#

Should I just put it in the root class

craggy estuary
lost schooner
#

Hmm, I'm not entirely sure how to make a static class

craggy estuary
lost schooner
#
public class EnchantUtils {
    public static HashMap<Enchantment, Integer> MAX_ENCHANT_LEVELS = new HashMap<>();

    // Combines all the enchantments of an item, both standard and stored, into a single map
    static Map<Enchantment, Integer> getAllEnchantments(ItemStack item) {
        if (item == null) {
            return null;
        }

        // Get the standard enchantments of the item
        Map<Enchantment, Integer> allEnchantments = new HashMap<>(item.getEnchantments());

        // Get the stored enchantments of the item if it is an enchanted book
        // (Only enchanted books have an EnchantmentStorageMeta)
        ItemMeta meta = item.getItemMeta();
        if (meta instanceof EnchantmentStorageMeta) {
            EnchantmentStorageMeta enchantmentMeta = (EnchantmentStorageMeta) meta;
            // Combine the stored enchantments of the book with its standard enchantments
            // Generally books should never have both standard and stored enchantments, but this is here just in case
            allEnchantments.putAll(enchantmentMeta.getStoredEnchants());
        }

        return allEnchantments;
    }
...
}
#

Like this?

craggy estuary
#

yeah

lost schooner
#

Where do I add all the kv pairs

craggy estuary
wet breach
#

since you know the number of enchantments that can exist, you can presize your hashmap

lost schooner
wet breach
#

it prevents the hashmap taking up more memory then necessary

#

default size is going to be larger then what you need from it

lost schooner
#
public class EnchantUtils {
    public static HashMap<Enchantment, Integer> MAX_ENCHANT_LEVELS = new HashMap<>();
    MAX_ENCHANT_LEVELS.put(Enchantment.DAMAGE_ALL, 10);
    MAX_ENCHANT_LEVELS.put(Enchantment.DAMAGE_UNDEAD, 10);
    ...

    // Combines all the enchantments of an item, both standard and stored, into a single map
    static Map<Enchantment, Integer> getAllEnchantments(ItemStack item) {
        if (item == null) {
            return null;
        }

        // Get the standard enchantments of the item
        Map<Enchantment, Integer> allEnchantments = new HashMap<>(item.getEnchantments());

        // Get the stored enchantments of the item if it is an enchanted book
        // (Only enchanted books have an EnchantmentStorageMeta)
        ItemMeta meta = item.getItemMeta();
        if (meta instanceof EnchantmentStorageMeta) {
            EnchantmentStorageMeta enchantmentMeta = (EnchantmentStorageMeta) meta;
            // Combine the stored enchantments of the book with its standard enchantments
            // Generally books should never have both standard and stored enchantments, but this is here just in case
            allEnchantments.putAll(enchantmentMeta.getStoredEnchants());
        }

        return allEnchantments;
    }
...
}
#

This does not work

wet breach
lost schooner
#

Where do I put the .put calls

remote swallow
lost schooner
remote swallow
#

yeah

lost schooner
#

I've not used Java for a long time lol

craggy estuary
lost schooner
#

Thanks

vivid cave
#

Can someone tell me what an "no item animation" refer to ?

#

Context: Container Set Slot packets, with container id = -2

chrome beacon
#

Arm swing

#

Maybe

vivid cave
#

thats what i thought, and hoped for tbh

#

i'll try

#

is the armswing related to slot update or equipment HAND update tho?

#

cuz those are 2 completely different things for the protocol

neon nymph
#

Hello! How do I use the new Type.PROFILE for the BanList? Type.NAME is deprecated now and I want to update my code to use the former, but the IDE just errors it out when I do Bukkit.getBanList(Type.PROFILE).addBan(Bukkit.createPlayerProfile(uuid), reason, date, source);

quaint mantle
#

I’m not too sure really

#

Sorry man can’t help you

#

I’m pretty sure no one can either

#

We use eclipse around here bud

neon nymph
flint coyote
#

I am on 1.20 o.o

eternal oxide
#

profile is new

flint coyote
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.20-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
quaint mantle
neon nymph
flint coyote
#

oh

neon nymph
#
<dependency>
      <groupId>org.spigotmc</groupId>
      <artifactId>spigot-api</artifactId>
      <version>1.20.1-R0.1-SNAPSHOT</version>
      <scope>provided</scope>
    </dependency>
neon nymph
#

Hmm, then this should work, right?

Bukkit.getBanList(Type.PROFILE).addBan( Bukkit.getOfflinePlayer(uuid).getPlayerProfile() , reason, date, source)

It's still giving me a The method addBan(String, String, Date, String) in the type BanList<capture#1-of ?> is not applicable for the arguments (PlayerProfile, String, Date, String)

#

If I use the isBanned method, this'll appear

Bukkit.getBanList(Type.PROFILE).isBanned(Bukkit.getOfflinePlayer(uuid).getPlayerProfile())

The method isBanned(capture#2-of ?) in the type BanList<capture#2-of ?> is not applicable for the arguments (PlayerProfile)

prime epoch
#

is there a way to disconnect the player from the server using bukkit?

orchid gazelle
#

Just kick them I guess

neon nymph
prime epoch
vivid cave
#

Can anyone find an explanation to this ?

eternal oxide
vivid cave
#

And explain me the red part?

eternal oxide
neon nymph
eternal oxide
#

you shouldn;t need to but do it to be sure

echo basalt
#

Generic types are pretty wacky

flint coyote
#

Yeah you have to cast because that generic is wack

neon nymph
#

Oh, it worked!

((ProfileBanList) Bukkit.getBanList(Type.PROFILE)).addBan(  Bukkit.getOfflinePlayer(uuid).getPlayerProfile()  , reason, date, source);
#

The error's gone

#

Though it should work without needing to cast it right? Anyway, thanks for the help 😄

echo basalt
#

if the generics are properly made you wouldn't need to cast

wet breach
#

mainly because the server uses flat file to store the bans

flint coyote
#

In that case it won't work without the cast. The generic will be ? if you don't

neon nymph
flint coyote
river oracle
remote swallow
wet breach
#

but the entries are an array as well

echo basalt
#

public BanList<T> getBanList(BanType<T> type)

#

hm

flint coyote
#

How large can a file that holds bans be? 5 MB on huge networks?

echo basalt
#

lmao no

wet breach
#

on huge networks it can get quite large

flint coyote
#

5MB is quite large for just text

wet breach
#

have to remember that every entry is on its own line

echo basalt
#

Well

#

In YML 5mb takes minutes to load

#

source: I've had to refactor 5mb+ yml files before due to server hanging on startup

wet breach
#

if the bans were stored in binary form with just a character separator, then it would be more optimal because it is making use of space

young knoll
#

Mojang has a named binary format

#

Idk why they don’t use it

wet breach
#

idk

#

maybe because sometimes the ban list gets corrupted

#

and it would be a pain to fix that file

orchid gazelle
#

Hypixel probably has like 150mb of bans

wet breach
#

without wiping the entire thing

young knoll
#

They should have a backup then

orchid gazelle
#

Or 50?

#

Idk

echo basalt
#

hypixel has to store a reason, ban id, player id, as well as all the profile data regardless

wet breach
#

also, the banlist only works for that server, when you have a network, typically just easier to use something like mysql to keep track for the entire network 😛

flint coyote
whole gust
#

trying to store and retrieve meta data from a placed block. How do I go about doing this with bukkit api?

young knoll
#

Do you want it to persist over restarts

echo basalt
#

?morepdc

undone axleBOT
whole gust
#

yeass

young knoll
#

?blockpdc

undone axleBOT
young knoll
#

Use that

whole gust
#

thank you <3

wet breach
#

which you can throw the event yourself

#

would be nice if more devs did this lol

orchid gazelle
#

How do huge servers like hypixel check bans

flint coyote
#

Had to ban Notch about 24.000 times with reason "banned by an operator" to reach 5MB on the ban file

young knoll
#

They have a database

orchid gazelle
#

Like wouldn't their server explode checking 150mb of bans for every join?

wet breach
#

they don't use the banlist

#

they have a DB

young knoll
#

That’s what databases are designed for

orchid gazelle
#

Still

flint coyote
#

databases are hella fast

orchid gazelle
#

Thats a huge amount of checks

flint coyote
#

400k entries are nothing for a db

young knoll
#

No it isn’t?

orchid gazelle
#

You gotta iterate through every single entry

neon nymph
wet breach
#

no

young knoll
#

Lol

#

No

flint coyote
#

databases don't iterate

#

that's why you have an index

wet breach
flint coyote
#

The complexity to find a key on an index is way below O(n)

orchid gazelle
#

Internally they have to iterate through every player string to?

flint coyote
#

should be O(log(n))

wet breach
#

also this isn't even factoring in caching on the DB

#

and caching in the application

orchid gazelle
#

I'd guess they have all bans loaded in some redis db to check bans

wet breach
#

MySQL has memory only storage too

orchid gazelle
#

Like db -> redis on start

wet breach
#

you don't need redis for caching

zealous glen
#

Do nether portals get created when a player teleports into the nether or when they flint and steal the portal?

young knoll
#

When they teleport

flint coyote
#

I know there's more factors to consider. Yet still I'd imagine the lookup without further improvements to be about log(n)

orchid gazelle
wet breach
#

faster then MySQL? probably not since redis is just an easy to cache any kind of data not data specifically from a DB

#

MySQL lets you create functions and has functions built in, where you can easily pull information from the DB and have it at the ready ahead of time before anything else

#

also with appropriate indexes and keys setup its super quick

#

mysql can easily handle 1mil+ queries to it a second

flint coyote
#

To understand database lookup data structures you can start at the base of optimization: Understanding binary trees.

Like this:

orchid gazelle
#

Do you think they have a backup-db syncing in realtime?

wet breach
#

the main reason most people choose to use redis is down to skills. Not many people are DBA's

wet breach
#

so most likely yes

#

if you use slaves, you can have a slave DB on every host

#

and then the master is the only one allowed to alter

#

and then sends it to the slaves

orchid gazelle
#

That's good

wet breach
#

this allows each server on a host to always be quick

#

and then however many hosts you have

#

is however many DB backups you have

#

yeah MySQL can do a lot and not just a lot, but do so with not much resources given to it XD

#

give it 1GB and its good for a long time lmao

orchid gazelle
#

Well what I wonder is

#

Is it worth using something like redis as a cache for single servers since they can just... store in RAM?

#

but at the same time, network-connecting for the cache takes a long time

wet breach
#

well if you don't need a db and just want a caching server or that is all you need for now, then yeah use redis

orchid gazelle
#

You'd have like 10ms delay for redis on other hosts

#

Why not just throw your data in the memory itself

wet breach
#

depends if those hosts are in the same DC or not

#

if they are in the same DC its like 5ms or less

orchid gazelle
#

Still

#

5ms is a lot for cache

#

Compared to memory

wet breach
#

why waste memory on the host that can be used for other things when you already have a host for caching?

orchid gazelle
#

Let me reformulate my question: what are the advantages of using a caching-database for a single server running locally

#

Compared to throwing your data into ram directly

wet breach
#

advantage is that if the data being cached comes from the DB anyways, then its faster and would know how to do it better then some outside thing

orchid gazelle
#

I mean

craggy estuary
#

I don't know what im doing wrong but:

No legacy enum constant for NETHERITE_BLOCK.

Im using Spigot 1.19.4

wet breach
#

the advantage of caching in ram directly is that you have the objects formed using the data from the DB

orchid gazelle
#

Software -> Redis -> Software

wet breach
#

so its faster in that the objects are already there and don't need to be intialized

orchid gazelle
#

Instead of Software -> RAM(example: any string") -> Software

wet breach
umbral ridge
orchid gazelle
river oracle
young knoll
#

1.19

umbral ridge
#

"api-version: 1.17" 😀

dawn plover
#

how do i make specific Id's for items to keep track of them
currently i am doing it via a ugly number within the lore (it doesnt really matter what the id is, as long as it is unique and less confusing to the user (best would be not visible at all) )

#

i tried making a unique sequance of those colors, but that wont work, it will just take the last one as the onlyone

tawdry echo
#

Pdc?

#

?pdc

dawn plover
#

but for that i need an api, is it posible without?

remote swallow
#

pdc is built in

dawn plover
#

oh woops, mb

remote swallow
#

more pdc and block pdc are external

dawn plover
#

amazing, this makes my job way more easyer

echo basalt
#

This also helps :p

young knoll
#

Meh

#

I just made a class called PersistantTypes that makes it a bit nicer

#

I also have my custom types in there

remote swallow
#

why are these T T not K V

tender shard
young knoll
#

T for type

tender shard
#

that only allows to use PDC types where primitive and complex are the same class

#

e.g. byte[] or int[]

#

but not for e.g. Integer, as that is int, Integer

#

change PersistentDataType<T,T> to ?,T

young knoll
#

Nah even the integer are the same

#

Integer, Integer

#

However boolean is not

tender shard
#

oh right. but it won't wor for Boolean, r custom datatypes

#

just replace the first T with ? and it'll be fine

#
public class ConfigurationSerializableDataType<S extends ConfigurationSerializable>
    implements PersistentDataType<byte[], S> {

this would eg break

echo basalt
#

mhm wacky

young knoll
#

Yeah I don’t think that will ever work out

#

Internally they are still registered with just the material, spigot just does some filtering for you

tender shard
#

ExactChoices only properly work on ShapedRecipes

#

only fix I know is to use shaped recipes instead

carmine mica
#

exactchoices work on shapeless ||on paper||

young knoll
#

And it’ll never be pushed upstream 😔

sage patio
#

can i create a method to use instead of doing hundreds of .replace?

#

for example:

player.sendMessage("[PLACEHOLDER] [PLACEHOLDER]".doReplacements());

does this:

player.sendMessage("[PLACEHOLDER] [PLACEHOLDER]".replace([PLACEHOLDER]", "Example").replace("[PLACEHOLDER]", "Example"));
worldly ingot
#

but idk maybe I'm just crazy

young knoll
#

Maybeee

prime epoch
#

Do i need a main class besides onEnable in my plugin?

#

because i get Could not load 'plugins\hcfcore-1.0-SNAPSHOT.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: Cannot find main class `org.ayple.hcfcore.old.Hcfcore'

prime epoch
echo basalt
river oracle
dull schooner
#

what this means?

remote swallow
#

sir this is spigot

dull schooner
#

oh sorry

lost schooner
#
    static boolean hasMoreThanOne(Map<Enchantment, Integer> enchantments, Enchantment[] incompatibleEnchantments) {
        int count = 0;
        for (Enchantment enchantment : incompatibleEnchantments) {
            if (enchantments.containsKey(enchantment)) {
                count++;
                if (count > 1) {
                    return true;
                }
            }
        }

        return false;
    }

Is there any stdlib method that basically does this?

rough ibex
#

Yes, you can do ```java
enchantments.keySet().retainAll(Arrays.asList(incompatibleEnchantments)).size() > 0

#

Set#retainAll is a destructive intersection with a collection, and then if the intersected set size is > 0 (1 or more), there's at least 1 in both sets.

brave lynx
#

hey quick question, if im trying to check if player A has any sort of metaData, is there any way to see all of the metaData player A has, or would I have to specify which metaData I want

drowsy helm
#

But no you have to know the key to get the value

brave lynx
drowsy helm
#

Yeah theres pdc for any entity

vital yacht
#

Change e in incompatibleEnchantments to some type of contains call, by converting the array to a Set or some other way

remote swallow
#

why do that when you can do retainAll

lost schooner
#

How do I use the singleton pattern on my Plugin instead of DI for util classes containing only static methods

vital yacht
lost schooner
vital yacht
#

Why not just call them statically and pass the plugin instance? Or you can use JavaPlugin.getPlugin(YourPlugin.class)

lost schooner
#

Because it's really kind of a global variable, it just isn't written that way

#
public class AnvilUtils {
    static double MATERIAL_REPAIR_COST_MULTIPLIER =
            JavaPlugin.getPlugin(BetterAnvils.class).getConfig().getDouble("material-repair-cost-multiplier");

Is this acceptable

remote swallow
vital yacht
remote swallow
#

depends on usage

vital yacht
vital yacht
#

And you should really avoid modifying parameters unless that’s explicitly the purpose of the method

remote swallow
#

if it matters that much just get them to clone the keyset then

vital yacht
#

Why are you so against using a stream?

remote swallow
#

im not, its just way more effort than you need

vital yacht
#

In what way?

remote swallow
#

no need for you to stream it, when you can just keyset and retain all

vital yacht
#

It’s more readable

#

And it’s not more effort

#

It’s actually the same number of method calls

quiet ice
#

And then you'll have geol that complains about streams being inherently more expensive

sterile breach
#

Why is bad ?

rare rover
#

why ain't this working?

@EventHandler
    public void onJoin(PlayerJoinEvent e) {
        Player player = e.getPlayer();
        player.setResourcePack("url", "hash");
    }```
#

url and hash are correct

#

do i need to wait?

remote swallow
#

follow 7smiles forum post