#help-development

1 messages · Page 869 of 1

gray saddle
#

hey i tried sending a message of a big arraylist to myself but it shows empty

#

when its shorter it actually shows any solution to this

slender elbow
#

any errors in the console?

#

there is a max length limit for messages, but I don't remember how much that is

halcyon hemlock
#

you can send arraylist to players??

slender elbow
#

yes there is

halcyon hemlock
#

i sent entire bee script to player and it worked

#

lol

gray saddle
halcyon hemlock
gray saddle
#

ok

half arrow
#

Whats the best way to show countdown timers inside lore of an item that's sat inside a inventory? can't be move etc. Loop the inventory while open?

slender elbow
halcyon hemlock
#

8 kilo bytes

#

no

#

tf am i saying

#

anyway

young knoll
#

256kb

halcyon hemlock
#

256k / 2 => amount of chars

slender elbow
#

not necessarily

young knoll
#

You’re assuming it’s just raw characters

halcyon hemlock
#

isn't it

young knoll
#

But there’s also the component data

slender elbow
halcyon hemlock
young knoll
#

utf8 means each character is 1-4 bytes

gray saddle
# halcyon hemlock show the code
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
        if (warpsc.getConfigurationSection("warps") != null) {
            commandSender.sendMessage("§bAvailable Warps: §f" + String.join(", ", GetWarpList()) );
        } else {
            commandSender.sendMessage("§cThere are currently none existing warps.");
        }
        return true;
    }
#

there

halcyon hemlock
#

so it says "Available warps are: "

#

in your player message?

gray saddle
#

sends me this

#

yeah

halcyon hemlock
#

tf

gray saddle
#

example like Available warps: home, castle, etc

halcyon hemlock
#

open chat and scroll up

gray saddle
#

i cleared chat because of other player messages

#

thats the only thing that came out

halcyon hemlock
#

and open chat

#

and see

gray saddle
#

see

halcyon hemlock
#

2 empty lines?

gray saddle
#

no just me spamming

#

it just sends me 1 empty line

halcyon hemlock
#

wtf

gray saddle
#

this wasnt an issue before but when the warps list got really big it went empty like that

molten kestrel
#

split the warp list into a multiple messages

halcyon hemlock
#

bro your minecraft is broken

gray saddle
#

but apparently

#

it does work in console tho

halcyon hemlock
#

or maybe same thing

gray saddle
#

yeah im using String.join

young knoll
#

Anything in the client logs

#

Because looking at that code it should always send something

gray saddle
#

it used to work but stopped working sometime when the list got pretty big

halcyon hemlock
#

try removing the String.join part and see what it logs then

#

if not you could always debug with breakpoints

rare rover
#

So I'm making an armor system that gives buffs to the player. Would the best way to do this is make a custom nbt which has all the armor buffs then grab the nbt each time?

#

I feel like this would be the most efficient way

young knoll
#

Pdc

#

Yeah

valid burrow
#

if im correct there is no such thing as a haste attribute so what would be a way of giving a player haste without an Effect

halcyon hemlock
#

packets

young knoll
#

Uhh, manually block breaking system

halcyon hemlock
#

👍

young knoll
#

I mean with packets it would still be via the effect

#

Just not server side

halcyon hemlock
#

block breaking packets

#

not haste packets

#

you could make a custom mining system

valid burrow
#

anything i can do thats easy?

halcyon hemlock
#

haha

valid burrow
#

i dont want to a million lines now

#

cause its tzhis smal ting

#

in my large ass code

halcyon hemlock
#

I have the hypixel code

#

hypixel mining system code

valid burrow
#

im sure you do

halcyon hemlock
#

not the actual code, the implementation of it

river oracle
#

Everyone has the hypixel mining system code

halcyon hemlock
#

real y2k?

river oracle
#

? Ig I'm the only y2k I know of

#

Does that make me the real one I suppose

halcyon hemlock
#

basically

young knoll
#

I mean you don’t even need any packets for it on modern versions

#

Well, maybe for client side effects

valid burrow
#

im on mordern version ;D

#

newest to be exact

young knoll
#

Well then yeah you only really need the BlockDamageEvent, BlockDamageAbortEvent, schedulers, and player.sendBlockDamage

gray saddle
#

still sends me an empty line

#

but still works in console

molten kestrel
#

try different client

halcyon hemlock
#

so it's not even the problem with string.join

#

client smoking some good stuff?

young knoll
#

You can always try splitting it

#

Sending a few entries at a time

gray saddle
#

this happens for everyone else on the server btw

young knoll
#

What kind of stats

halcyon hemlock
#

still doesn't work then other problem

molten kestrel
#

I think they said it already, if the list is long its not showing on the chat

gray saddle
gray saddle
young knoll
#

Doesn’t have to be a single message per ward

#

Could be like 10 at a time

river oracle
#

@young knoll @Staff very important question what sounds better
Transaction#submit or Transaction#complete

inner mulch
#

complete

young knoll
#

Hmm

#

Well is it being submitted or completed

young knoll
#

Are you sending it off to something

river oracle
#
class RepairTransaction(private val item: ItemStack) {
    private val meta: Damageable = item.itemMeta as Damageable
    private var expRequired: Int = 0
    private var damage: Int = 0
    private var conditions: MutableList<(Player) -> Boolean> = ArrayList()
    private var failure: (Player, FailureReason) -> Unit = { _, _ -> run {} }
    private var success: (Player) -> Unit = {}

    fun exp(exp: Int) = apply { this.expRequired = exp }
    fun damage(damage: Int) = apply { this.damage = damage }
    fun success(function: (Player) -> Unit) = apply { this.success = function; }
    fun failure(function: (Player, FailureReason) -> Unit) = apply { this.failure = function }
    fun condition(function: (Player) -> Boolean) = apply { this.conditions.add(function) }

    fun submit(player: Player) {
        if (!conditions.all { it.invoke(player) }) {
            failure.invoke(player, FailureReason.FAILED_CUSTOM_CONDITION)
            return
        }

        if (player.getTrueExperience() < this.expRequired) {
            failure.invoke(player, FailureReason.NOT_ENOUGH_EXP);
            return
        }

        meta.damage = this.damage
        item.setItemMeta(meta)
        success.invoke(player)
    }

    enum class FailureReason {
        NOT_ENOUGH_EXP,
        FAILED_CUSTOM_CONDITION,
    }
}```
young knoll
#

Or are you just finishing it

river oracle
#

also I should switch FailureReason to a class instead of an enum

#

I just thought that'd be much more flexible

young knoll
#

The heck is getTrueExperience

river oracle
#

its an extension function that actually gets the correct value

young knoll
#

PR when

#

Anyway I think complete is fine

river oracle
#

not my code

young knoll
#

Smh

#

Surly the internal player must store that value somewhere

slender elbow
#

Transaction#finish

#

finalize :trollface:

young knoll
#

Transaction#transact

vapid grove
#
public <T> T getUserData(UUID id, String location, Class<T> type, T def) {
        if (data.isSet(formatLocation(id, location))) {
            return type.cast(data.get(formatLocation(id, location)));
        }
        return def;
    }

Im scared to test this as I dont wanna break user data
Would this work for MemorySelection/FileConfiguration for getting a users data?
Or is this risky to do because instead of using something like getBoolean for a boolean, im casting it directly to the type

young knoll
#

You should at least check before you cast

vapid grove
young knoll
#

Class#isInstance

vapid grove
#

So like this?

public static <T> T getUserData(UUID id, String location, Class<T> type, T def) {
    if (data.isSet(formatLocation(id, location))) {
        Object value = data.get(formatLocation(id, location));
        if (type.isInstance(value)) {
            return type.cast(value);
        }
    }
    return def;
}
young knoll
#

Yeah looks alright

#

You could store the result of formatLocation in a variable so you don’t call it twice

vapid grove
#

Found out that MemeorySelection has a getObject (which asks for a class)
But im reciving unboxing errors for booleans and have 0 idea why that is

#

Infact a lot of things are returning as unboxing warnings, like Integers

young knoll
#

Warnings or errors?

vapid grove
#

I think I know why though

#

Its cause theres a chance of there being a null

#

And I added a check and it disappeared

slender elbow
#

let's go

young knoll
#

Wrapper types

#

😩

vapid grove
#

Result of 'PlayerData.getUserData(p.getUniqueId(), "TagEquipped", Boolean.class).equals(key)' is always 'false'

#

lovely now this pops uuppppp

#

UGHHHH

#

I dont understand why that decided to show up

quaint mantle
#

I want to change the name of all diamond swords in the player inventory in the game to a random name every 1 minute.

#

But how can I do this since I cannot do this with any event?

young knoll
#

Scheduler

quaint mantle
#

So we don't use timers only in event methods?

young knoll
#

What

quaint mantle
#

I thought I could only call schedulers within event methods

young knoll
#

No

#

You can use them anywhere

vapid grove
#

Yes I ask a lot of questions lmao, this I cant find the answer to anyhwere online

public MetaFuncs(ItemStack item) {
        this.item = item;
        this.tags = new LinkedHashMap<>();
        ItemMeta itemMeta = item.getItemMeta();
        if (itemMeta != null) {
            PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();

            for (NamespacedKey key : dataContainer.getKeys()) {
                Object value = dataContainer.get(key, perst.getOrDefault(key.getKey(), PersistentDataType.STRING));
                if (value != null) {
                    this.tags.put(key.getKey(), value);
                }
            }
        }
    }

Is there a generic type for PersistentDataType? For any class type including weird ones like a String List?

vapid grove
#

I cant seem to find anything to do that and id like to allow for any persistant data type to be used instead of purely just strings

quaint mantle
#

Use ByteBuffer as helper

vapid grove
# quaint mantle Create custom datatype

I have custom ones, like this:

public class StringListTagType implements PersistentDataType<byte[], String[]> {
    public StringListTagType() {
    }

    public @NotNull Class<byte[]> getPrimitiveType() {
        return byte[].class;
    }

    public @NotNull Class<String[]> getComplexType() {
        return String[].class;
    }

    public byte @NotNull [] toPrimitive(String @NotNull [] complex, @NotNull PersistentDataAdapterContext context) {
        Gson gson = new Gson();
        return gson.toJson(complex).getBytes();
    }

    public String @NotNull [] fromPrimitive(byte @NotNull [] primitive, @NotNull PersistentDataAdapterContext context) {
        Gson gson = new Gson();
        return gson.fromJson(new String(primitive), String[].class);
    }
}
#

Im unsure how id approach this perfectly however, to work with ANY class

quaint mantle
#

Noo dont use json

vapid grove
#

I dont like the idea of having to manually do it one at a time

quaint mantle
#

Just write int and string bytes

#

Int for length

#

And read n int and get n bytes

vapid grove
#

Okay, but Im still stuck on my other question

#

As to how I can use generic classes with PersistantDataTypes

quaint mantle
#

new YourType()

#

I think

vapid grove
#

Yeah I get that but thats not hte implementation of generic classes

#

Im talking be able to do PersistantDataType<T, T>

#

Here ill give an example

#
public void materialize(ItemMeta itemMeta) {
        for (String key : this.tags.keySet()) {
            Object value = this.tags.get(key);
            PersistentDataType dataType = PersistentDataType.STRING;

            if (value instanceof Integer) {
                dataType = PersistentDataType.INTEGER;
            } else if (value instanceof Integer[]) {
                dataType = new IntListTagType();
            } else if (value instanceof String[]) {
                dataType = new StringListTagType();
            }

            itemMeta.getPersistentDataContainer().set(new NamespacedKey(Main.instance, key), dataType, value);
        }
#

This is part of my code to materialize the keys back to the item for my MetaFuncs class

#

I want it so PersistantDataContainer can use Generic classes and not specific classes

#

Similar to what I did here:

#
public static <T> T getUserData(UUID id, String location, Class<T> type) {
        String format = formatLocation(id, location);

        if (data.isSet(format)) {
            Object value = data.get(format);

            if (value != null) {
                if (type == Boolean.class && value instanceof Boolean) {
                    return (T) value;
                } else {
                    return data.getObject(format, type);
                }
            }
        }
        return (T) "null";
    }
#

Ignore the fact I used a string for null, it wouldnt silence the "potential null value" warning

#

its temporary

#

However if this isnt physically possible thats fine, I would like for it to be a possibility however

quaint mantle
#

You cant just convert any object to data

#

It will break on loading

vapid grove
quaint mantle
#

You should do proper implementation

vapid grove
#

That way I can just create a list of the ones I need

vapid grove
#

I made this MetaFuncs code back when I had started to learn java to code spigot plugins

#

And havent made really big changes since, but realized inefficiencys with it and was wanting to fix them

#

I dont know a ton on how PersistantData works with the containers so I decided to ask how I could do so

molten kestrel
#

Anyone got a good Subcommand & tabcomplete template?

dry hazel
#

general advice would be to use a real command framework

#

like cloud, acf, commandapi, ...

vapid grove
#

or you can code your own if you really feel like torturing yourself

#

for example i made mine around a managment framework

vapid grove
dry hazel
#

no

vapid grove
#

Well im stumped them on how to do this

sterile token
#

they write everything into bytes and an int for the lenght of the data, seems good

dry hazel
#

huh?

sterile token
#

not like a buffer specific, more like data serialization

dry hazel
#

serializing it to json is not the way

#

wrap the byte array with Guava's ByteStreams, read a length int, read x bytes, turn the read bytes into a string, append to list and repeat until you reach an EOF marker or read x items from a list length written at the beginning of the stream

quaint mantle
#

Bros wanted list of strings

#

I thought it not for json

sullen marlin
#

You can use the new list type

vapid grove
tender shard
vapid grove
#

As this is awesome

tender shard
#

sure, np

vapid grove
#

Yay my code works now 👍

dawn silo
#
            protocolManager.sendServerPacket(target, packet);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }```

error is Exception 'java.lang.reflect.InvocationTargetException' is never thrown in the corresponding try block
#

any Idea?

dry hazel
#

the try-catch is useless

echo basalt
#

p sure the method throws an error

#

under niche occasions

dry hazel
#

apparently not in the throws then

#

ITE is checked, so it either has to be defined or PLib/whatever uses a trick to rethrow it unchecked

dawn silo
#

okay

quiet ice
#

Throwing checked exceptions without declaring them isn't nice

vapid grove
#

Well I just finished removing static abuse from a bunch of my code

sand spire
#

Does anyone know?

solid cargo
#

As long as it works why worry?

#

I might use entityremovefromworldevent tho

#

Or just be normal and use entitydeathevent

sand spire
#

They all don't work, i found out after writing this xd

#

ItemDespawnEvent is for dropped items, EntityDeathEvent for living entities, and EntityRemoveFromWorldEvent doesn't have a cancel method

umbral ridge
#

It should work. Did you try to debug it?

#

ItemDespawnEvent

#

Unless if you have a plugin like ClearLag that manually clears dropped items every x seconds

#

Actually I think arrow isnt a dropped item. Its an entity of some sort

#

but ItemDespawnEvent.. should still catch it

#

EntityRemoveFromWorldEvent.. if it doesnt have a cancel method, you could just get the current entity thats about to despawn and spawn a new one of the same type and everything

sand spire
#

I will try this thank you 🤝

molten kestrel
#

What is the best way to get random rewards based on their chances.
This is what i currently have (its very bad)

    public Reward getRandomReward() {
        double random = Math.random();
        for (Reward reward : rewards) {
            if (random < reward.getChance()) {
                return reward;
            }
        }
        return null;
    }
sand spire
valid burrow
#

please never call random ints dice again

sand spire
#

sorry

#

thats how i learnt it

valid burrow
#

u can use random ints to make a dice

#

but the methods themselves have nothing to do

sand spire
#

so i'm calling random ints "number"

#

or something like that

valid burrow
#

ints are numbers

#

so essentially random ints are random numbers

#

ints are whole numbers

#

-1,3,926,-192

#

etc etc

#

you can use the random object to generate a random int

#

or a random whole number

sand spire
#

So is my answer to their question wrong or did I just say it in the wrong way?

valid burrow
#

answer itself isnt wrong but calling it a dice is very wrong

#

its a random int

sand spire
#

It was an example

valid burrow
#

a weird one xd

#

you are assuming someone knows how to code a dice using random ints but doesnt know what random ints are

#

thats

#

very confusing

unborn vigil
#

in the code snippet the user has provided it shows that they are using the Math.random() class, so im assuming they know what random ints are?

sand spire
umbral ridge
#

make it static

#

on top of the class

#

if you've used Random... yeah not for Math class

molten kestrel
#

Got it, thanks!

glad prawn
# molten kestrel What is the best way to get random rewards based on their chances. This is what ...
        double random = spr.nextDouble(getTotalChance());
        
        for (Map.Entry<Material, Number> entry : items.entrySet())
            if ((random -= entry.getValue().doubleValue()) < 0) 
                return entry.getKey();
        
        return Material.COBBLESTONE;
    }```
I used this to get random Material. Get the random value from the total weight (chance) of all keys, loop through the map entry, if the value of random after subtracting the weight of the entry is less than 0, the key of that entry will be selected.
quaint mantle
#

I feel like that makes some items very biased lol

#

Hey guys Im using database and I have two questions
Am I have to use Mysql with Redis?
What is advantage to use Redis?

molten kestrel
wary harness
#

How would I retrieve Villager entity object from InventoryClickEvent from Merchant Inventory

wary harness
#

even if u got getMerchant

late sonnet
#

and you check like getMerchant instanceOf?

wary harness
#

return false

late sonnet
#

any instanceOf return false?

hazy parrot
#

print getClass().getName() ¯_(ツ)_/¯

shadow night
#

if I start a new thread from my code and the /stop the server, will it stop the thread too or will it keep the server up?

echo basalt
#

what unspoken hackery are you trying to achieve?

river oracle
#

Hax

echo basalt
#

The thread will outlast onDisable but will still die to the process termination iirc

#

unless bukkit does sumn hacky

#

which it prob does

river oracle
#

I'd clean your shit up onDisable tho

shadow night
river oracle
#

Like for love of god

shadow night
#

actually, wait

#

are there async timers in bukkit

echo basalt
#

?scheduling

undone axleBOT
shadow night
#

fucking 2fa

#

huh why did it not work

#

ah finally

young knoll
#

TL;DR yes

kind nexus
#

Hey anyone has experience with creating a economy provider for Vault?
When I register my custom economy provider it doesn't seem to work because when I use Vault API to deposit money it gets added to essentials balance and not my custom provider balance.

logger.info("Registering CoCEconomy as a Vault economy provider...");
economyProvider = new EconomyProvider(this);
if(Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
    logger.severe("Missing Vault dependency");
    getServer().getPluginManager().disablePlugin(this);
    return;
}
Bukkit.getServer().getServicesManager().register(Economy.class, economyProvider, this, ServicePriority.Highest);
Economy adapter = Bukkit.getServicesManager().load(Economy.class);
logger.info("Registered economy adapter: " + adapter.getName());

Here I log the adapter on the last line and it prints my adapter name instead of Essentials one.
So it seems like it registered properly but Vault doesn't seem to use it.

young knoll
#

Maybe it depends on load order?

#

You could try using loadbefore or softdepend to see

rough oak
#

Hello, I have a problem, I am coding a Minecraft plugin for the first time by following tutorials, however an error is preventing me from continuing: "Incompatible operand types ItemType and Material"

worldly ingot
#

ItemType?

kind nexus
worldly ingot
#

ItemType isn't in the API yet

rough oak
worldly ingot
#

I don't know what ItemType you're using. What does your code look like? Where is ItemType imported from?

rough oak
#

it's the code :

#

package fr.DreamerXU.PowerGems;

import java.util.Arrays;

import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

@SuppressWarnings("deprecation")
public class PowerGemsLestiners implements Listener {

@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    player.getInventory().clear();
    
    player.getInventory().addItem(new ItemStack(Material.IRON_PICKAXE, 2));
    
    ItemStack customsword = new ItemStack(Material.IRON_SWORD, 1);
    
    ItemMeta customM = customsword.getItemMeta();
    customM.setDisplayName("§cMa super épée custom");
    customM.setLore(Arrays.asList("première ligne", "deuxieme ligne"));
    customM.addEnchant(Enchantment.VANISHING_CURSE, 1, true);
    customM.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    customsword.setItemMeta(customM);
    
    player.getInventory().setItemInOffHand(customsword);
    
    ItemStack customwool = new ItemStack(Material.WHITE_WOOL, 8);
    player.getInventory().setHelmet(customwool);
    
    player.updateInventory();
}

@EventHandler
public void onInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Action action = event.getAction();
    ItemStack it = event.getItem();
    
    if (it != null && it.getType() == Material.DIAMOND_HOE) {
    player.sendMessage("Vous venz de faire un click");
}
    
}

}

placid timber
#

Hey i want a plugin helphIs there any command from which i can make znpcs work as a consoleIf a non-op player cliks on that znpcSo it gives creative

worldly ingot
#

Oh. Item_Stack_, not ItemType

worldly ingot
hybrid spoke
hybrid spoke
#

there is nothing wrong with it

placid timber
hybrid spoke
worldly ingot
#

It's been 3 minutes :p

shadow night
rough oak
worldly ingot
#

No no not you KEKW

#

Your question is fine here. It's programming-related

rough oak
#

ok sorry

worldly ingot
#

But your code looks fine. I don't see any issue with it. The error you sent doesn't make sense. Did you save the file?

shadow night
#

And another thing is, are you sure it even is in that class

shadow night
#

Where is the error and what is the error exactly

hybrid spoke
#

you could try to invalidate caches

rough oak
#

but in the line import org.bukkit.Material;

material is crossed out

#

I can't upload an image, but it looks like this: import org.bukkit.Material;

autumn dagger
#

Hey I'm working on a plugin that lets you take exits in a minecart highway, anybody got simple ideas for if you want to go east/west when entering the main line? I'm using an overpass thing here

rough oak
#

and the error is in :
if (it != null && it.getType() == Material.DIAMOND_HOE) {
player.sendMessage("Vous venz de faire un click");
}

hybrid spoke
#

what api are you using

rough oak
hybrid spoke
rough oak
river oracle
#

You clearly aren't using spigot api we can't help you

rough oak
#

i use this API : spigot-api-1.20.2-experimental-20231021.103123-1

river oracle
#

Why are you using experimental if you're toying around with it you should know what you're doing

shadow night
#

I didn't know exp builds existed

river oracle
#

In the experimental builds Material has been deprecated in favor of ItemType and BlockType please use them accordingly

rough oak
#

thank you for helping me, it works, have a nice day

young knoll
#

Sometimes I wonder how people even get a hold of that

shadow night
#

Fr

river oracle
#

You specifically have to seek it out

young knoll
#

Buildtools can build it

shadow night
#

I dev spigot for more than one year and I didn't know that

young knoll
#

But you either need to know the flag or click the gui button

#

And the gui button comes with a nice big warning

river oracle
#

Maybe third party distributor??

#

I wouldn't rule that out

kindred valley
#

what was interacting item event

#

playerinteract

#

ok

echo basalt
#

roundabout but for minecarts

#

@autumn dagger

lone jacinth
sterile token
echo basalt
#

new devs should import the regular builds

#

Experimental builds should still be able to be imported for tests but not as easily accessible ???

#

So just make it a niche odd version that no one remembers and call it a day

lone jacinth
#

And potentially provide feedback.

lethal knoll
#

Does anyone know a good way to execute something when a very specific time has met? Example, execute some code when the time is exactly 6000 ticks

sterile token
sterile token
sterile token
lethal knoll
sterile token
lethal knoll
#

So the problem is also more about, what is reliable? As currently I am using if time >= 6000 && time <= 6020 (which I don't like at all)

sterile token
#

Its executed 1 time, its queue and once the time go away its executed

lethal knoll
#

And how am I going to check when that very specific time tick is reached? it's not about delaying, it's about executing for example exactly during midnight

sterile token
#

you have to be really specific when asking MrGeneral

#

because then we have this type of confusions and not really good comprenhenssion of your objective

lethal knoll
#

Apologies if it was confusing, but is the problem statement clear now? I cannot find a way to do this in a reliable manner without having a task run every tick

#

But the range is not reliable, so I'm looking for a way to do this without a range of ticks. And executing every tick, could potentially cause performance issues

#

so I I were to configure my taks to run every tick, and I don't make it too heavy, should be fine?

sterile token
lethal knoll
#

Not sure what that means, but I'll remember that

sterile token
#

we really over engeenier many things about minecraft, and we end just losting time. Instead of using what first works and not giving many rounds around it

#

is basically the first rule of development, if it works, don't move it

lethal knoll
#

Believe me, I prefer not changing it, but users sometimes experience the code running twice and as a result some other things happening. I'll most likely mark this is a bug with low probability and move on

#

Anyhow, thank you for the ideas

hollow oxide
#

is there a way to do like a hopper in an Bukkit.Inventory?
or something like inventory.append(itemstack)

finite comet
#

When running my plugin i get a java.lang.NoClassDefFoundError error. I never had this before and I didn't really change any code. What could cause this?
https://paste.md-5.net/cuhegohufi.xml

lethal knoll
hollow oxide
lethal knoll
finite comet
#

already tried that a couple of times and did it again just to make sure but didnt fix it sadly

lethal knoll
chrome beacon
finite comet
chrome beacon
#

?img

undone axleBOT
#

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

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

finite comet
#

some classes are just placeholders

finite comet
lethal knoll
#

it's supposed to be under: gg/school/commands/SpawnCommand

finite comet
#

well the code is ye, i thought u ment the class

lethal knoll
#

The error literally means that your server is trying to find your class under that path .If it's not there, you get that error

finite comet
#

if i decompile the plugin again, its there, thats why im just not getting it why it drops an error

lethal knoll
#

did you restart your server?

finite comet
#

imma try that again to make sure

#

same error again

lethal knoll
#

wait a second

#

ah nvm

chrome beacon
#

Clean and then package

finite comet
#

thank u so much

#

do u have an explanation of what the "clean" thing does?

chrome beacon
#

To prevent it from compiling every class it caches things

#

Clean empties the cache

finite comet
#

i see, ty

open lava
#

guys anyone knows why protocol lib latest version doesn't work in 1.20?

fast spade
#

Hello people of the spigot discord. I am currently having some issues with my invsee command and have no idea how to fix it.
So the command when ran will open up the specified person inventory. And I have implemented a way to make it so when the person who has the inventory open and makes an edit like moves the an item to a different item slot it should update on the player's inventory and it does not. the code of my plugin. How would I make so it does that.
https://pastebin.com/gMXUDHAh

wind sorrel
#

Hey! I've released some time ago my first plugin, and now that I'm planning for a v2, I wanted to know if someone could help me out and help me review my code, because it's very far away from perfection and I know there are a lot of issues, but I don't know where to start. I can send the repo if someone is willing to help, don't wanna make any kind of self-promotion or anything. Thanks!

river oracle
vocal cloud
river oracle
#

post a github link

river oracle
quaint mantle
#

Are inventories like one per player meaning new objects aren't made

river oracle
#

considering it just maps the inventory to a GENERIC_9x4 menu and is absolutely disgusting

quaint mantle
#

yeah

fast spade
quaint mantle
#

like how does it work

vocal cloud
#

Have you tried just opening the other players inventory for the other player?

fast spade
river oracle
# quaint mantle yeah

Internally inventories aren't really a huge deal. Internally what bukkit calls Inventories are called Containers and the real deal is Menu's aka InventoryViews. I mean if you think about it its a glorified ArrayList

quaint mantle
#

also why does bukkit create a new Player every tick

vocal cloud
#

Inventories are just arrays mapped to slots on the client

river oracle
quaint mantle
#

oh

#

I thought it did lol

vocal cloud
#

Player is created/destroyed on join/leave

#

hence why you use UUIDs

river oracle
quaint mantle
#

so wait, is it safe to cache a Player as a field

vocal cloud
#

no

river oracle
quaint mantle
#

Not a map or anything

#

It's a field that only exists when a player is online

vocal cloud
#

It's safer to just use UUID

river oracle
#

for Menu's I usually preserve the field object because it'll be thrown out when the player logs off

#

so I save the player object in the field since I know it won't stay in scope outside of its expected life time

#

when it comes to caching data in Maps etc player object is usually a dumb idea

quaint mantle
#

Well yeah

#

Doesn't the hashcode change through its lifetime

river oracle
#

I'd have to double check but I'm pretty sure the hashcode is just the UUID

vapid grove
#

Checked out new ListPersistentDataTypes, and now my code is unable to distinguise an array from a regular value

for (String key : this.tags.keySet()) {
            Object value = this.tags.get(key);

            NamespacedKey namespacedKey = new NamespacedKey(Main.instance, key);
            PersistentDataType dataType = PersistentDataType.STRING;

            for (PersistentDataType<?, ?> persistentDataType : PRIMITIVE_DATA_TYPES) {
                Class<?> cls = persistentDataType.getComplexType();

                if (cls.isInstance(value)) {
                    dataType = persistentDataType;
                    break;
                }
            }

            itemMeta.getPersistentDataContainer().set(namespacedKey, dataType, value); //Errors here
            //The provided value was of the type String[]. Expected type String
        }

From what im aware, PersistantDataType.STRING == ListPereistentDataType.STRING
So im unsure how to tackle this problem

vapid grove
#

At least thats what intellij says

quaint mantle
#

what

river oracle
quaint mantle
#

I could've sworn when I used a player key it didn't work

vapid grove
river oracle
#

ListPersistentDataType.STRING is a list

vapid grove
#

For some reason

fast spade
vapid grove
#

ok nvm now its not wth

quaint mantle
#

Here y2k ima look at the hashcode function

#

vrb

#

Brb

vapid grove
#

0 idea why it was before, it was giving me warnings about it

river oracle
#

beat you to it @quaint mantle

quaint mantle
#

I'm on a phone

river oracle
# quaint mantle I'm on a phone
        if (hash == 0 || hash == 485) {
            hash = 97 * 5 + (this.getUniqueId() != null ? this.getUniqueId().hashCode() : 0);
        }
        return hash;
#

yeah its just hte UUID prey much

quaint mantle
#

Ok then

#

why doesn't a Player key work

river oracle
#

it does, until the object gets collected

#

I mean pleanty of plugins use Player as a key even though its stupid its done

quaint mantle
#

Oh wait nvm

#

I know why it didn't work

#

I think I did String, Something

But I called Player#toString

vapid grove
# river oracle those aren't the same thing

"The provided value was of the type String[]. Expected type String"
Just updated the array and its still saying the same error (both list and basic types)

Class<?> cls = persistentDataType.getComplexType();
Would this line have something to do with it screwing up, if so what is the best solution to check if its a list or regular value

quaint mantle
#

This was like a year or so ago tho

vocal cloud
#

I mean technically you can store it and add/remove on join but man alive that gets so difficult to deal with

river oracle
#

seems like a learnjava moment

vocal cloud
#

UUID is king

quaint mantle
#

Ye I use uuid only now

vapid grove
#

ty for the help

#

nope nvm im not stupid, tested it with a hashmap and its telling me that PersistentDataType and the list version are Duplicate Map keys

#

which makes 0 sense

sharp heart
#

Hello I have a problem, when i'm summoning an ItemDisplay with spigot api and setting the GUI DisplayTransform, it's the same as the display in inventory,
But, with packets, even if I set the same scale and same Display transform, it show me a texture like a resource pack.

#

Or, if someone know how to rotate on himself an itemdisplay

vapid grove
#
PRIMITIVE_DATA_TYPES.put(PersistentDataType.STRING, String.class);
PRIMITIVE_DATA_TYPES.put(ListPersistentDataType.STRING, String[].class);
// Why is ListType and DataType apparently the same key, its apparently a duplicate wihich makes 0 sense
eternal night
#

because they are

#

PersistentDataType.LIST.strings()

#

is how you get the string type for lists

#

not that it will yield you a String[].class anyway tho

#

it would be a List<String>

vapid grove
#

oh

vapid grove
#

Confused me

#

Then again that is my fault for not fully reading the docs

eternal night
#

Well, your way doesn't work because ListPersistentDataType extends PersistentDataType

#

which is why you can do ListPersistentDataType.STRING

#

the interface inherits those fields from its parent

lavish vortex
#
    @EventHandler
    public void onPlayerDamage(final EntityDamageByEntityEvent e) {
        if (!(e.getDamager() instanceof Player) || !this.main.isOn()) {
            return;
        }
        final Player p = (Player)e.getDamager();
        for (final PotionEffect effect : p.getActivePotionEffects()) {
            if (effect.getType().equals((Object)PotionEffectType.INCREASE_DAMAGE)) {
                final ItemStack weapon = (p.getItemInHand() != null) ? p.getItemInHand() : new ItemStack(Material.AIR);
                final int sharpnessLevel = weapon.containsEnchantment(Enchantment.DAMAGE_ALL) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_ALL) : 0;
                final int smiteLevel = weapon.containsEnchantment(Enchantment.DAMAGE_UNDEAD) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD) : 0;
                final int baneLevel = weapon.containsEnchantment(Enchantment.DAMAGE_ARTHROPODS) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS) : 0;
                final int strengthLevel = effect.getAmplifier() + 1;
                final int damagePerLevel = this.main.getConfig().getInt("damage-per-level");
                final double totalDamage = e.getDamage();
                final double weaponDamage = (totalDamage - 1.25 * sharpnessLevel - 1.75 * smiteLevel - 1.75 * baneLevel) / (1.0 + 1.3 * strengthLevel) - 1.0;
                final double finalDamage = 1.0 + weaponDamage + 1.25 * sharpnessLevel + 1.75 * smiteLevel + 1.75 * baneLevel + damagePerLevel * strengthLevel;
                e.setDamage(finalDamage);
                break;
            }
        }
    }

I have an error with this code, upon hitting an entity with a sharpness enchant everything work perfectly, but if I hit them with a sword that has both enchant like SMITE and SHARPNESS than the strength potions doens't add up any damage.

river oracle
eternal night
#

Maybe I am just everywhere at all times

dry hazel
#

true

little rampart
#

Hi guys, im trying to debug my spigot plugin. it worked fine until i added SpiGUI as dependency. now it only works when packaged, but when debugging the plugin doesnt start and throwsa java.lang.NoClassDefFoundError: com/samjakob/spigui/SpiGUI

Im using maven and spigot for 1.20.4

Does anyone has an idea?

echo basalt
#

Did you shade it?

little rampart
#

i'm fairly new to java development. how would i do it in intellij?

sterile token
tender shard
# little rampart i'm fairly new to java development. how would i do it in intellij?

People just getting started with maven always ask me the same 3 questions, so here’s a a short FAQ! How to change the output directory? Read this. How to shade dependencies and what it means Sometimes you are using certain libraries (for example, my CustomBlockData class, or similar stuff) that is not already present at...

winter galleon
#

e.getVehicle().removePassenger(e); does this make "e" dismount?

worldly ingot
#

Yes

winter galleon
#

ty

tender shard
#

if I Cmd+B / Ctrl+B onto Message(getString(path)!!), shouldnt IJ jump to the String constructor instead of the class? At least that's what it does in java, why not in kotlin 🥲

river oracle
#

sounds like someone doesn't use eclipse keybinds

tender shard
#

ofc not, I use the IJ defaults

little rampart
little rampart
eternal night
#

Well you use a build system like maven or gradle

#

to manage dependencies and packaging for you

tender shard
#

do not run any special goals or lifecycles

#

mvn package will compile your code, throw it into a .jar, and then also shade all dependencies into that same .jar

winter galleon
#

how can i put an item in cooldown? like the shield when get hitted by a pillagerù

little rampart
winter galleon
tender shard
#

look at the method signature

#

check the type of what you use instead

#

and read what your IDE tells you

eternal oxide
#

5 ticks is 1/4 of a second

tender shard
eternal oxide
#

yeps

winter galleon
#

and how can i put in cooldown the item in main hand

river oracle
#

you can't cooldowns apply to all items of the type

eternal oxide
#

Your code will not even compile

river oracle
#

There is no ability to apply a cooldown to just 1 item

tender shard
torn shuttle
#

anyone with experience making websites have any idea of why the fuck chrome and brave which both run on chromium have such a big difference in font size displays

#

I inspected elements and they're both set to 1.15 rem base size which I understand might different from browser to browser but these are basically the same browser

#

should I just hardcode the root size myself?

kind hatch
#

It looks like a different font is being used.

torn shuttle
#

it feels like that to me too

kind hatch
#

Brave may not use the fonts provided by google by default.

torn shuttle
#

so I'm not going crazy?

#

it's supposed to be open sans

kind hatch
#

Is that what your website is set to use?

torn shuttle
#

yes

kind hatch
#

Link?

torn shuttle
#

very cool very good website

#

10/10 totally very feature complete too

kind hatch
#

See, it says it's Open Sans, but I know it's not. Image on the right is what the font should look like.

split lichen
#

A theoretical question - when spawning armor stands through a custom plugin on a local server (localhost, my machine), everything works fine, but when the same plugin is put on a live server (a server host), with the same plugin layout as the local server, the armor stands don't spawn. What could be the issue?

ivory sleet
#

conflicting other plugins is my nr1 guess

split lichen
ivory sleet
#

ah u're running a single plugin?

split lichen
#

The only thing that's different is that it works locally, but not on the live server

split lichen
ivory sleet
#

hmm, interesting

split lichen
#

I'm not even sure where to go from since everything works perfectly fine when tested locally

ivory sleet
#

and we go under the presumption both servers are configured the same, that is the config files for the server and the plugins

split lichen
#

100% identical, made sure of that, plus all the plugins are updated

ivory sleet
#

I also assume u've tried to recompile the plugin and restart the server

split lichen
#

so there are no outdated mismatched versions

eternal oxide
#

My guess, your server host is effing with you by adding its own plugin

split lichen
#

if another plugin were added

torn shuttle
#

oh I fixed it

#

this page specifically didn't have the link to the font

eternal oxide
#

some hosts add their own plugin for advertising (free hosts)

torn shuttle
#

but chrome had the font regardless

#

ok then

kind hatch
#

Yep, it looks different for me now too.

split lichen
eternal oxide
#

no clue then

torn shuttle
#

I need to go make a proper global html importer that is site-wide

eternal oxide
#

Some config is different, world name or somethign silly

ivory sleet
#

^ else u can maybe try to intercept the entity spawn event

sterile token
#

If its free host, some of they limit entities spawning

ivory sleet
#

that could be it also :>

split lichen
winter galleon
#

e.setCooldown(Material.SHIELD, 40);
why it doesn't set cooldown for the shields i have in my inventory

split lichen
ivory sleet
#

what was the issue?

#

:o

sterile token
split lichen
young knoll
#

How did… what

split lichen
#

and it resolved the issue

ivory sleet
#

🥲

split lichen
#

no idea lol

#

but thanks for mentioning the spawn packet part

#

made my draw my attention to it

winter galleon
#

e.setCooldown(Material.SHIELD, 40);
why it doesn't set cooldown for the shields i have in my inventory

ivory sleet
#

do u have more code?

eternal oxide
#

cooldown is on a MATERIAL not an item

young knoll
#

It’s for all items of that type

winter galleon
# ivory sleet do u have more code?
    public void onRightClick(PlayerInteractEntityEvent event){
        Player p = event.getPlayer();
        Player e = (Player) event.getRightClicked();
        ItemStack taser = new ItemStack(Material.STICK);
        ItemMeta tmeta = taser.getItemMeta();
        String tnome = this.getConfig().getString("nome-taser");
        tnome.replaceAll("&", "§");
        tmeta.setDisplayName(tnome);
        Integer tcmdata = this.getConfig().getInt("cmdata-taser");
        tmeta.setCustomModelData(tcmdata);
        if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals(tnome)) {
            if (!taserati.contains(p)) {
                if (!cooldown_taserate.contains(p)) {
                    if (!taserati.contains(e)) {
                        if (e.isBlocking()) {
                            if (p.getFacing() == e.getFacing()) {
                                taserati.add(e);
                                cooldown_taserate.add(p);
                                Integer durata = this.getConfig().getInt("durata-taser-in-secondi");
                                durata = durata*20;
                                e.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,  durata, 3));
                                e.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,  durata, 255));
                                for (Player lp : Bukkit.getOnlinePlayers()) {
                                    if (lp.getLocation().distance(p.getLocation()) < 8) {
                                        lp.playSound(lp.getLocation(), "minecraft:block.anvil.land", 1, 2);
                                    }
                                }
                                e.getVehicle().removePassenger(e);
                                e.setCooldown(Material.SHIELD, 40);

// more code```
#

xd

ivory sleet
#

oh my....

young knoll
#

Is it making it to that line

winter galleon
#

yp

#

the remove passenger works

vapid grove
#

do not nest your code like this

#

agony

echo basalt
#

pow

vapid grove
# echo basalt pow

actually taught me how to make my code much more beautiful ngl so thank you

echo basalt
#

took me a solid hour to write ❤️

sterile token
#

Hi, i have been reading too much about n-ario trees and i will apply it for commands. But im struggling a bit the looping for finding a child node of a child node

sterile token
sterile token
#

not sure how many different types are but they all trees structure

#

i just struggling with how i will find a child node of a child node, i fail at that part because of recursivity which i dont really manage it well

ivory sleet
#

ru just writing a naive implementation?

sterile token
#

So i realized the structure is that tree type specific which is called n-ario tree

#

i already know the theory of the tree type i want to apply, just messing around finding child nodes of child node

valid burrow
#

Hikari sucks

slender elbow
#

skill issue

wary harness
#

is there any plugin which can make intellJ make sound when compile process is over

young knoll
#

Dang how long is your compile

umbral ridge
#

5 hours

vocal cloud
#

Setup a post task to open an audio file

young knoll
#

Make it play never gonna give you up

sterile token
#

Isnt there any way for forzing writeable book edition without the player having the book? Mainly forcing book writte menu via code

#

I have seen whole 1.8 api and no method exists, dont start saying update version. Just tell me if there or not

young knoll
#

No

#

They need to be holding the book

sterile token
#

right thanks, that what was looking for

#

depending how much data you would have, preferible SQL

#

well depends on your needs

umbral ridge
#

what is mrsql

quaint mantle
#

MySql or mrsql

young knoll
#

The husband of MsSql

umbral ridge
#

lol

#

i actually googled it

#

i love sql

sterile token
#
EntityPlayer entity = (EntityPlayer) player;
entity.openBook()
#

I find by checking NMS packages

young knoll
#

Pretty sure they still need a book

sterile token
young knoll
#

Mhm

inner mulch
#

hello, im currently running 2 servers connected with a proxy, it seems like the quitevent is called after the joinevent and therefore the data loading and unloading doesnt work. (old data is being loaded) Is there any fix to this besides using a runnable and delaying the loading process?

sterile token
inner mulch
#

can you tell me more abou this?

sterile token
#

What you do is instead of loading data when player join each server, you load it once connect to proxy stays in redis.

young knoll
#

Redis is an in memory database that can be accessed by multiple servers

inner mulch
#

so sql bad, redis good?

young knoll
#

*It can also be persistent but yeah

sterile token
#

Redis is not designed by default for being persistent, (IT CAN)

inner mulch
#

oh

#

so i need sql to persist and redis to modify

#

i see

sterile token
#

yeah

inner mulch
#

thats smart

sterile token
#

What you do is having a cache inside redis

#

Because is in memory is so fast

#

I can explaint it if you giveme time

inner mulch
#

so all my prior getting data in memory with hashmaps is useless and i should burn it?

inner mulch
sterile token
#

allright give me time i iwll translate so you perfect understand

inner mulch
#

ok

#

i've now just seen that redis is a nosql database, therefore combining it with mongodb would be smarter, right?

sterile token
#

The first thing to understand is that redis is entirely an in-memory db, i.e. it stores everything temporarily. It is capable of being persistent, but it is not very common to use it for that.

It is almost always used in parallel with a persistent db such as Mongo, Mysql, SqlServer, etc to store all the information permanently.

In case of redis, it has 2 very good functions to take advantage of it, one is the cache system that is basically like creating a HashMap inside Java, it is the same. You indicate a name of the set that would come to be like the table (in SQL), then the key that must be unique for each data (the uuid of the player generally) and finally the data to store.

And its other functionality is a publishing / subscription system, it is a channel where you publish and receive information in real time. It is very useful, to send messages / actions between many servers. For example to create a global /msg, where the player being in lobby can talk with the survival player.

sterile token
inner mulch
sterile token
inner mulch
sterile token
inner mulch
sterile token
#

I worked with redis for 2y

inner mulch
#

oh

#

thats a lot of time

sterile token
inner mulch
#

wait but how do i find stuff in an unsorted db??

sterile token
#

i mean thats not really true

#

It depends the key you are using for each insert

#

i work with Mongo and the data is find really similar, in SQL you indicate the query like SELECT * FROM users WHERE uuid=someUUID and in Mongo, you use a filter, like Filters.eq("uuid", "some-uuid")

#

I dont really sure what you mean by unsorted

inner mulch
#

idk maybe im using the wrong word

#

unstructured database?

#

but this doesnt matter, so you'd recommend combining redis with mongodb as these two are both nosql ?

#

i guess it would be kinda stupid to combine a nosql database with an sql one

sterile token
#

However, what you should know is that SQL and NoSQL are 2 different types of databases. And the main difference between them is that SQL is a relational database that stores information in tables. And you use a query lang for interacting with the db

And mongo stores the information in bson documents, which is basically json data but in binary format. Which means that any type of data can be stored in binary format.

inner mulch
#

okay

sterile token
#

Thats most of theory explaining really vargue and fast

#

Then you can read more in deep

#

What would like to know now?

quaint mantle
#

Hey guys currently having trouble connecting with Redis (Jedis) in my [Practice] plugin. In my [gBasic] plugin which is my network-bridge plugin, connects just fine, but i noticed after just adding Jedis to my [Practice] plugin that it timeouts after a few minutes of idling.

I am using the same code as I am in my [gBasic] plugin, and I am using the same connection credentials. Everything seem's correct.
It's all the same, so I don't know it's breaking.

https://paste.md-5.net/cikalenohu.java (JedisUtil.java) class
This is the class I instantiate in my Core.java (main class).

JedisConnectionException: Failed to connect to any host resolved for DNS name. (followed by Connection timeout connectionException)
https://paste.md-5.net/oyuwesowuk.md

#

If someone could assist me 1 on 1 that'd be great!

#

What should i do guys

#

@anyone

vocal cloud
#

Is your config the same? Is it in the right folder?

minor junco
#

You should debug your values to really verify that. It sounds more like the host or something is wrong (thus unreachable) and after n attempts it just time outs

cinder karma
#

Can somebody point me to a modern tutorial on pathfinding for mobs? I've found a few from 2014/2015, but none of the classes/methods they reference seem to exist anymore...or maybe I'm missing something very obvious?

quaint mantle
#

I mean not that already haven't i will triple-check now, i just don't seem to see anything that would cause such.

wet breach
#

Some tutorials might show you with a mapped version of the jar while others using the unmapped version

#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

vapid grove
#

does protocollib have suppot yet for 1.20.4

#

i cant find info on it at all

river oracle
#

ask in their discord

vapid grove
#

wait they have a discord

river oracle
#

ohh ig they dont' have one

#

make a github issue then

vapid grove
#

oh well guess ill wait til i can use it

quaint mantle
#

Anyone good with redis here?

sterile token
#

Remember to just ask your duded instead of losting time looking for one specialized

valid burrow
undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

quaint mantle
#

Isn't there pricing in AWS based on the RAM and processor power of the servers?

#

I looked at the website but I couldn't understand it.

rare rover
#

is there a formula to calculate the cost if the price goes up every 1.2x each time? I was looking at geometric series but it doesn't seem to work correctly:

val enchantValue = enchant.getInitialCost() * ((1.2.pow(enchantLevel.toDouble()) - 1) / (1.2 - 1)) * i```
#

i got this

#

but looping gives me 206K

proud badge
#

I think you have to download it off of the jenkins?

solid cargo
rare rover
#

i think its 206K

#

i just made a simple program in rust to check if it was right

#

and it wasn't so

solid cargo
#

Looks like you applied the interest formula right?

#

It can be simplified tho

#

A = P(1+r)^t

vapid grove
vapid grove
rare rover
#

tbf i might have done my rust code wrong so it might be right

rare rover
#

i just use a fancy text generator

vapid grove
solid cargo
#

Yeah just use the compound interest formula @rare rover

vapid grove
#

Neat, ill check that out

rare rover
rare rover
quaint mantle
rare rover
quaint mantle
#

ah

#

😄

#

omg

#

sry

vapid grove
#

This is really cool

rare rover
#

haha, no worries xD

cobalt thorn
#

Im trying using a custom command with setblock ~ ~ ~ minecraft:dirt 0 replace {nbt} how can i manage to do it in code without calling the command with the exact result?

proud badge
#

Unless you want me to send you just the .jar file

carmine mica
#

can't know how to do it in code if I don't know wtf the command is @cobalt thorn

#

guessing you can just change that block at the location, but idk what 0 and {nbt} are. those aren't part of the regular minecraft:setblock command

cobalt thorn
#

the command is much longer so that's why i didn't sent the entire command

#

and the command is for 1.12

#

so that's why (0 is blockstate)

vapid grove
white root
#

Hey, can someone point me in the right direction?
in my plugin I need to get the distance between a player and some block periodically. If theyre more than, for instance, 20 blocks from some point, I want to do something

In this (admittedly simplified) example, would I want to use Location#distance(otherLocation) or Location#distanceSquared(otherLocation)? Whats the difference between these and which do I need?
(sorry if this is dumb, maths wasn't my strong suit)

warm mica
#

Right is just left but with the square root taken from it

white root
#

Tysm for the explanation <3

hybrid turret
#

I've written an own ban systen for adding QoL stuff like an executor. I will also add something like a ticket uuid for ban appeals (but that's not the topic).
While writing, I realized that if (for some reason) an admin isn't trustworthy and has access to server files, the executor could be changed, which I... Just don't want. Would it make sense to write an encoder & decoder to encode the username of an executor and if so, is there a good way, except Base64 to implement a text encoder? I feel like Base64 is extremly easy to decode or do I misunderstand Base64?

warm mica
#

Using base64 is just gonna make it more difficult for your admin, but that's pretty much about ot

#

Base64 is basically being used when you want to convert a binary with bytes ranging from 0-255 to a String that is human readable, such as if you want to put it somewhere where binary wouldn't work (e.g. in a json)

hybrid turret
warm mica
hybrid turret
#

I've run out of things to think about so I just do anything now lmao

warm mica
#

Whoever got access to the server could just replace the whole plugin altogether

#

and much much worse

icy beacon
#

If they do, it's on them, not on your plugin

hybrid turret
#

yeah, makes sense tbh

hybrid turret
warm mica
hybrid turret
#

Right, I forgot about that. But that's still missing the name tag

quaint mantle
valid burrow
#

arl

quaint mantle
hybrid turret
#

Scoreboard Teams change name tags? Haven't used scoreboard stuff in a longer time

quaint mantle
hybrid turret
#

Huh, that makes a lot of sense, thank you

wet breach
hybrid turret
#

ohhhhhh

floral drum
#

hi frosty the snowman

lavish vortex
#
    @EventHandler
    public void onPlayerDamage(final EntityDamageByEntityEvent e) {
        if (!(e.getDamager() instanceof Player) || !this.main.isOn()) {
            return;
        }
        final Player p = (Player)e.getDamager();
        for (final PotionEffect effect : p.getActivePotionEffects()) {
            if (effect.getType().equals((Object)PotionEffectType.INCREASE_DAMAGE)) {
                final ItemStack weapon = (p.getItemInHand() != null) ? p.getItemInHand() : new ItemStack(Material.AIR);
                final int sharpnessLevel = weapon.containsEnchantment(Enchantment.DAMAGE_ALL) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_ALL) : 0;
                final int smiteLevel = weapon.containsEnchantment(Enchantment.DAMAGE_UNDEAD) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD) : 0;
                final int baneLevel = weapon.containsEnchantment(Enchantment.DAMAGE_ARTHROPODS) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS) : 0;
                final int strengthLevel = effect.getAmplifier() + 1;
                final int damagePerLevel = this.main.getConfig().getInt("damage-per-level");
                final double totalDamage = e.getDamage();
                final double weaponDamage = (totalDamage - 1.25 * sharpnessLevel - 1.75 * smiteLevel - 1.75 * baneLevel) / (1.0 + 1.3 * strengthLevel) - 1.0;
                final double finalDamage = 1.0 + weaponDamage + 1.25 * sharpnessLevel + 1.75 * smiteLevel + 1.75 * baneLevel + damagePerLevel * strengthLevel;
                e.setDamage(finalDamage);
                break;
            }
        }
    }

I have an error with this code, upon hitting an entity with a sharpness enchant everything work perfectly, but if I hit them with a sword that has both enchant like SMITE and SHARPNESS than the strength potions doens't add up any damage.

wet breach
#

so is it easy to decode? Yes but no. There is a specification on how base64 is supposed to work, but you are free to modify or deviate as well as use any tools at your disposal to implement. Because of this, typically no two encoders or decoders are the exact same unless they follow the exact same standard

#

this is why it is common that a tool that encodes also provides a decoder as well

hybrid turret
hybrid turret
jagged bobcat
wet breach
#

as long as it uses 64bits and provides serialization using printable characters you can pretty much implement however

lavish vortex
wet breach
#

the only downside is, that if your encoder is different then its inherent your decoder be used since no other decoder would really work

hybrid turret
wet breach
#

Many things have specifications, and believe it or not you actually don't need to conform to spec 100%

#

this is only necessary if you want compatibility with everything else

hybrid turret
wet breach
#

but if compatibility is not necessary or needed, implement however you want 😛

hybrid turret
#

My plugin is basically supposed to be a completly closed system to be able to handle pretty much everything on the server

wet breach
#

then yeah, just use your own encoder or decoder in fact I have a class already made you can use

hybrid turret
#

i mean obv not everything lmao

#

but ugwim

wet breach
#

it makes use of snakeyamls encoder/decoder

#

which conveniently is part of spigot 🙂

hybrid turret
#

ooooo

wet breach
#

license is MIT so feel free to use it

hybrid turret
#

thanks

hybrid turret
#

Do I understand correctly that a Multimap is nothing else than a Map<K, List<V>> or Map<K, Set<V>>?

#

Or tbh before I ask shit now, does it even make sense to serialize attributeModifiers of an item's itemMeta if you want to store the item in a json?

icy beacon
#

Anyone's IntelliJ crashing with update 2023.3.2?

shadow night
#

I have not updated IJ in ages lol

icy beacon
#

Nvm I updated Copilot to latest and it doesn't crash anymore

icy beacon
shadow night
icy beacon
#

Well you have a point

valid burrow
#

some memory issue

icy beacon
#

I was updating my ij today and it was lagging so bad during applying patches

#

And then when it booted up and prompted me to download the dictionary for grammar checking, I did

valid burrow
#

i just got used to presing ctrl s after every few lines

icy beacon
#

My pc just stopped responding for like a solid 5 minutes, then disconnected from both monitors, and then took a solid minute to stop lagging

icy beacon
#

Maybe a fresh reinstall would solve this?

valid burrow
#

probably

#

but im lazy

shadow night
icy beacon
valid burrow
#

im in school x)

icy beacon
valid burrow
#

history class

icy beacon
#

Valid

lost matrix
hybrid turret
#

because the details are lost if i don't, no?

lost matrix
#

Which codec are you using? Gson?

hybrid turret
#

As of rn, completly custom lmao

#

StringBuilder xd

lost matrix
#

To serialize to json??

hybrid turret
#

Bc idk why but I can't get gson to work :(

#

?paste

undone axleBOT
hybrid turret
#

.js?

#

what

#

whatever, the code is readable

lost matrix
# hybrid turret Bc idk why but I can't get gson to work :(
    Gson gson = new GsonBuilder().disableHtmlEscaping().create();
    
    // Serializing an ItemStack
    ItemStack itemStack = ...;
    String json = gson.toJson(itemStack.serialize());

    // Deserializing an ItemStack
    Type type = new TypeToken<Map<String, Object>>(){}.getType();
    ItemStack deserialized = ItemStack.deserialize(gson.fromJson(json, type));
hybrid turret
#

wha

hybrid turret
#

I asked like 50 times on this server on how to serialize/deserialize item-stacks and this is the only time i got a straight answer lmao

#

Man, I never worked with JSON in code before, okay? xD

white root
#

Hey, one more quick question, when the server is stopping, will all players be kicked/leave from the server (and their PlayerQuitEvent's be called) before my plugin's onDisable method gets called?
Or is that not something that you can know?

lost matrix
#

Its fine. Just take a dive into Gson. It can serialize a lot.

hybrid turret
#

Damn, I'll use that ig, rip my time lol

white root
hybrid turret
lost matrix
hybrid turret
#

Answering "yes" on and "or" question lol

#

I mean, it makes sense that you meant the first part, but still

lost matrix
#

It was a two part question with the latter being conditional. And i answered the first one which made
the second question obsolete. In my mind it was ok 🤷

#

But im not a native speaker

noble lantern
#

Does minecraft cache player .dat files or load-as-required?

hybrid turret
#

I don't think that's an english only thing (I'm not a native speaker either)

lost matrix
#

Whats the concern?

noble lantern
#

How damaging would it be to rm a player data file during runtime?

#

as long as they are offline

lost matrix
#

Completely fine

noble lantern
#

Awesome thanks 😄

#

Also, long time no see in here congrats on helper : D sure you've had it a while now XD

lost matrix
hybrid turret
#

Nvm I did it. Use a string builder and add the commas and brackets manually

topaz cape
#

yo spigoteers do you know where can i find Steve and Alex default skins (texture and signature)

hybrid turret
lost matrix
#

The proper way would be to register a serializer and then just call

    ItemStack[] array = ...;
    String json = gson.toJson(array);

Want an example?

hybrid turret
#

uhm

#

Kinda yeah

#

bc i feel like i tried that and it didnt work

hybrid turret
#

Probably in the default resource pack, i'm guessing

topaz cape
#

I dont want the png file

#

I just want texture and signature

hybrid turret
#

oh- then i'm no help, sorry

lost matrix
# hybrid turret Kinda yeah
public class ItemStackSerializer implements JsonSerializer<ItemStack>, JsonDeserializer<ItemStack> {

  private final Type mapType = new TypeToken<Map<String, Object>>() {}.getType();

  @Override
  public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) {
    return context.serialize(src.serialize());
  }

  @Override
  public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    return ItemStack.deserialize(context.deserialize(json, this.mapType));
  }

}

Usage:

    Gson gson = new GsonBuilder()
        .disableHtmlEscaping()
        .registerTypeHierarchyAdapter(ItemStack.class, new ItemStackSerializer())
        .create();

    // Serializing an array or List or anything with ItemStacks in it
    ItemStack[] content = ...;
    String json = gson.toJson(content);

    // Deserializing anything in that regard
    ItemStack[] deserialized = gson.fromJson(json, ItemStack[].class);
topaz cape
hybrid spoke
#

but no idea what it was called

noble lantern
lost matrix
# topaz cape anybody

They dont have a texture and signature. They are used by the client as fallback textures and dont need signing.
But you can surely find a random signed skin which simply copied them.

hybrid turret
#

that makes a lot of sense

lost matrix
# hybrid turret that makes a lot of sense

Btw you should use Gson as a top level serializer.
Simply throw the entire object at it, and if something doesnt work, register a serializer.
So just serialize the entire object and write the json String to a file.
Dont tinker with it in String form.

cosmic loom
#

What does extends JavaPLugin do?

umbral ridge
#

🙃

lost matrix
hybrid turret
cosmic loom
umbral ridge
#

btw is there a gson config manager class out there? Do I have to write it myself and spend a whole day at it?

lost matrix
# cosmic loom what does it do?

Spigot will be very confusing if you dont learn the basics of java first.
I would recommend you to start writing some generic java code that can be run in your terminal, and
look at some tutorials first.

noble lantern
lost matrix
umbral ridge
hybrid turret
noble lantern
#

Once you write one, youll never write one again 😛

lost matrix
noble lantern
#

ive been using the same gson class for like 3 years now

valid burrow
noble lantern
#

no

valid burrow
#

yes

noble lantern
#

like that request lol

umbral ridge
noble lantern
#

i know networking programming XD

valid burrow
#

what request

umbral ridge
#

want things to look nice

noble lantern
#

if its even valid, doubt it is

valid burrow
#

why wouldnt it be

#

works literally the same as all other requests

#

whats so special about it

noble lantern
#

cause im like 99% sure if he wants skins he should use the mojang skin server XD there is 100% a API for it

lost matrix
valid burrow
#

but

#

where do you think such an API would get its data

#

do you know the full name of requests?

#

you know theres

#

„api requests“?

hybrid turret
#

wait

#

i won't need it, nvm

noble lantern
lost matrix
noble lantern
#

the REST server the mojang uses to serve skins

valid burrow
#

if it works it works

hybrid turret
#

What does a signed skin mean? What's a signed and what's an unsigned skin?

valid burrow
#

you can have multiple skins saved in your account

#

assigned skin is the one you selected

#

unasigned are the „stored“ ones

noble lantern
lost matrix
#

Notchian clients only display skins which have a valid signature from Mojang.

hybrid turret
twilit creek
#

Hello, small little question, does anyone knows where the implementation of ClientGamePacketListener in the (Remapped) NMS Code is? I'm searching all the day for it because i want to know where for example the handleAddEntity is implemented. Would be nice if anyone can help me please.

eternal night
#

on the client ? confused_panic

#

The ClientGamePacketListener is the thing that handles the packets from the server to the client on the client so like

#

you won't find that implementation in spigot

twilit creek
#

Oh okay, is there an option to see the Clientsided code of Minecraft where this is implemented?

eternal night
#

nothing spigot provides

#

you'll have to look at e.g. fabric

twilit creek
#

I want to understand packets in general from ground, i mean completely. I'm programming since 7 years on smaller things in java primery in the Spigot field and want to go deeper in the code of mc for general purpose to see if i understand it after it better. (Server as also Clientsided)

shadow night