#development

1 messages · Page 135 of 1

wraith scarab
#

i debug

#

i don't found the error i just use another method

#
        if (item_meta.getDisplayName().equals("§6Core Chest")) {
            Player player = (Player) e.getWhoClicked();
            Inventory inventory = Bukkit.createInventory(null,
                    plugin.core_upgrade.getConfig().getInt(player_clan_name + ".chest_upgrade.level") * 9
                    , "§6Core Chest");
            UUID player_uuid = e.getWhoClicked().getUniqueId();
            Clan player_clan = plugin.get_simple_clans().getClanManager().getClanByPlayerUniqueId(player_uuid);
            clan_inventory.put(player_clan, inventory);
            FileConfiguration core_upgrade_file = plugin.core_upgrade.getConfig();
            if(core_upgrade_file.contains(player_clan_name + ".chest_upgrade.content")) {
                Set<String> inventory_content_list = Objects.requireNonNull(core_upgrade_file.getConfigurationSection(
                        player_clan_name + ".chest_upgrade.content")).getKeys(true);
                for (String path : inventory_content_list) {
                    clan_inventory.get(player_clan).setItem(Integer.parseInt(path), core_upgrade_file.getItemStack(player_clan_name + ".chest_upgrade.content." + path));
                }
            }
            player.openInventory(clan_inventory.get(player_clan));
        }
    }
    @EventHandler
    public void on_inventory_close(InventoryCloseEvent e){
        if(!e.getView().getTitle().equalsIgnoreCase("§6Core Chest")) {return;}
        FileConfiguration core_upgrade_file = plugin.core_upgrade.getConfig();
        String player_clan_name = Objects.requireNonNull(function.get_player_clan(e.getPlayer().getName()).getClan()).getName();
        int slot = 0;
        for(ItemStack item : e.getInventory().getContents()) {
            core_upgrade_file.set(player_clan_name + ".chest_upgrade.content."+slot, item);
            slot++;
        }
        plugin.core_upgrade.saveConfig();
    }
#

here the code if anyone need

#

i just do a another section for every item

#

i use get kkey with a condiguartion section

broken elbow
#

can you put java after the 3 ` its not much but might make this more readable

#

also one thing I have to recommend is naming conventions. everything here is just named with_this_naming_whatever and it makes it even harder for us to keep track of stuff.

#

also I hope you're aware Objects.requireNonNull would just throw if the argument is null. it doesn't get out silently

#

anyways these are just observations not related to your problem I had to make. currently debugging something on my own so someone else might be able to help with more stuff.

wraith scarab
broken elbow
#

its a warning not an error.

#

you could have a null check instead of that.

broken elbow
#

well clearly something in here can be null function.get_player_clan(e.getPlayer().getName()).getClan(). so you should instead check if that is null before. java if (whatever == null) // do something since its null

wraith scarab
#

okay thx

broken elbow
#

what?

warm steppe
#

u forgot brackets

broken elbow
#

not exactly?

warm steppe
#

u forgot

broken elbow
#

I think you are mistaking

warm steppe
#

stop trolling

winged pebble
#

This is perfectly valid```java
if (whatever == null) something.do();

broken elbow
#

I think you should stop trolling or move to #off-topic ...

#

you're just spamming this channel for no reason

neon wren
#

@wraith scarab is that your exact code? it makes no sense.

#

As I don't think Objects.requireNonNull() returns a getName() which your code java String player_clan_name = Objects.requireNonNull(function.get_player_clan(e.getPlayer().getName()).getClan()).getName();
Shows it should.

broken elbow
#

it returns T

winged pebble
#

It's also basically pointless in that context

broken elbow
#

it will basically return what you give it

#

if its not null

#

so it is valid. its just useless for the most part

#

so I'm assuming this function.get_player_clan(e.getPlayer().getName()).getClan() returns a Clan or whatever which has a name

neon wren
#

I see, I usually never touch it so that'd make sense

#

Thought possibly the IDE had a error, or the user doesn't like the red alerts to be shown.

broken elbow
#

well its not even red. its yellow by default. at least in intellij.

rigid mountain
#

Question, So im making custom enchants, and i figured instead of creating each enchant I could make one class and load them from config. So i have a CustomEnchant.java class like so: https://paste.helpch.at/sateqowofu.java

and then I have a CustomEnchantManager.java which will handle all of the enchant loading and such, but my question is can i create a new instance of CustomEnchant.java each time to create a new enchantment?

Like;

CustomEnchant test1 = new CustomEnchant(0, "Test1", 3, 1, EnchantmentTarget.ARMOR);
CustomEnchant test2 = new CustomEnchant(0, "Test2", 2, 1, EnchantmentTarget.WEAPON);
CustomEnchant test3 = new CustomEnchant(0, "Test3", 4, 1, EnchantmentTarget.ARMOR_HEAD);```
cinder forum
#

Hi, I'm working w Vault and want to do something when balance or permission primary group is changed, is possible to do this using Vault API? 🤔

dense drift
#

you can create an wrapper for vault and register it with a higher priority, look at "vault events"

craggy zealot
#

im using protocolLib and i have this issue and i dont know how to fix it

#
[14:21:45 ERROR]: Could not pass event PlayerJoinEvent to Zombies v1.0
com.comphenix.protocol.reflect.FieldAccessException: Field index out of bounds. (Index: 1, Size: 1)
        at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:373) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:349) ~[ProtocolLib.jar:?]
        at me.TahaCheji.utils.Nametag.<init>(Nametag.java:23) ~[MafanaZombies.jar:?]
        at me.TahaCheji.events.PlayerJoin.onJoin(PlayerJoin.java:36) ~[MafanaZombies.jar:?]```
#

the code is this

#
        this.packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
        String name = UUID.randomUUID().toString().replace("-", "").substring(0, 12);
        this.packet.getIntegers().write(1, 0);
        this.packet.getStrings().write(0, name);
        this.packet.getChatComponents().write(0, WrappedChatComponent.fromText(player.toString()));
        this.packet.getSpecificModifier(Collection.class).write(0, Collections.singletonList(player.getName()));
    }

    public Nametag setPrefix(String prefix) {
        this.packet.getChatComponents().write(1, WrappedChatComponent.fromText(ChatColor.translateAlternateColorCodes('&', prefix) + " "));
        return this;
    }```
dense drift
#

I guess you meant getIntegers().write(0, 0);@craggy zealot

craggy zealot
#

let me try that

dense drift
#

Are you trying to create a team?

craggy zealot
#

fake team

#

for nametags and tab names

#
com.comphenix.protocol.reflect.FieldAccessException: No field with type net.minecraft.network.chat.IChatBaseComponent exists in class PacketPlayOutScoreboardTeam.
        at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:369) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:349) ~[ProtocolLib.jar:?]
        at me.TahaCheji.utils.Nametag.<init>(Nametag.java:24) ~[MafanaZombies.jar:?]```
#

this.packet.getChatComponents().write(0, WrappedChatComponent.fromText(player.toString()));

dense drift
#

What version are you on?

craggy zealot
#

1.18.2

#

i dont know how to use packets

#

do i looked up online

dense drift
craggy zealot
#

you want me to use that?

dense drift
#

that's the documentation for packets, but your packet should have a ChatBaseComponent field, hmm

#

try getBytes().write(0, (byte) 0); for Mode create team

craggy zealot
#

where does it create the team

dense drift
#

the packet has a Mode field, and each value represents an action

#

0 to create a team, 1 to delete it, etc.

craggy zealot
#

fieldIndex

#

?

dense drift
#

this is what the index is for

#

index 0 to set the team display name, index 1 to set its prefix and index 2 to set its suffix

#

same thing applies for all fields

#

in your case, index 0 for byes is the Mode field, and you set it to 0 (getBytes(0, 0)) to use the Mode create team

craggy zealot
#

i wanted to use a api

#

but i cant find any that work

finite monolith
#

Anyone have an idea how to fix my issue?

#

I made a discord way back when. Signed out to make a second went to log back in. It was an old forgotten email

#

Now I'm forced to make a new one. And want to re link my same ps4 account to my current email

#

I'm not sure if I can re link without knowing the old account info. And bc of privacy I cant even get the email address to go through the recovery options to reset the password. Much less remember the email or that password

lyric gyro
#

what

#

@finite monolith uh you should contact discord support, this is a Minecraft and programming help server

#

?not-discord

neat pierBOT
#
FAQ Answer:

Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.

queen plank
#

I want to prevent an item from being burned. I have this code, but it does not work.

@EventHandler
public void onItemIncinerate(EntityCombustEvent event) {
if(event.getEntity() instanceof Item)
  event.setCancelled(true);
}

@EventHandler
public void onItemIncinerate(EntityDamageEvent event) {
if ((event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK
    || event.getCause() == DamageCause.LAVA) && event.getEntity() instanceof Item)
  event.setCancelled(true);
}```
The events are registered.
broken elbow
#

try walking over where the item was. I know when I last tried this, the item would just become invisible but I could still pick it up and it would show back.

queen plank
#

Wow

#

That was it

#

Thanks

#

🙂

buoyant haven
#

Need to know:

The loadPlayer function calls every time when somebody joins.

Code:

https://haste.jazzkuh.com/acamehasuw.java

Problem:

Now he make's every time somebody join's a new row in the table, but i want that everyone person have 1 row, not more

lyric gyro
#

how did you create the table?

#

you probably want the uuid column to be the primary key (or was it unique? i'm not particularly well-versed with sql)

buoyant haven
buoyant haven
queen plank
#

Is there a way to make an item immune to lava just like netherite items? I currently just replace the current item with a new one, but the item is super twitchy.

dense drift
#

Cancelling the event should should be enough

queen plank
#

Yeah, but the item goes invisible

#

Does it have something to do with optifine?

dusky harness
queen plank
#

I guess, but then I can blame that if don't manage to fix it lol

wintry grove
#

I think there is some sort of attribute?

#

or NBT

lyric gyro
#

there is a field you can change in the item type so it's as natural as netherite but, that won't be in the client data and the client will still de-render it

queen plank
#

No point in changing it then. Guess I'll keep it as I have it now. Thanks though

#

One more thing, does anyone know the default values for the pick up sound?

#

I can't for the life of me find them

#

I'm trying to tweak pitch and volume but it just sounds weird

surreal lynx
#

1, 1?

queen plank
#

Nope, I've tried 1,1 0,0 and the other obv ones. But all seems odd

lyric gyro
#

0.2F, (this.random.nextFloat() - this.random.nextFloat()) * 1.4F + 2.0F

#

fixed volume, random (high) pitch

rigid mountain
#

https://paste.helpch.at/cihocumata.shell

So im making a configureable custom enchants. Each enchant has a type and an effect. Basically the type is the condition for it to run. So for example the BOW type requires a player to shoot a player. I have this part handled inside an EntityDamageByEntityEvent which i do some shit to get down to where a player shoots a player. Thats beyond the point. I also have a Effect which is what happens when said condition is filled. The effects are what i sent above ^. So say this enchant has a type or BOW and an effect or MESSAGE:You have been shot! or the enchant has the same type, but the effect HEAL. Basically i need to differentiate between all of the types, so should i create a long ass if statement inside a function? So like a function runEvent(String s) which takes in MESSAGE:You have been shot! and if some substring ordeal == MESSAGE send a message? Or is there a better way Not sure if this makes any sense so feel free to ask questions lmao.

Please ping me abt to gts will reply in morning.

craggy zealot
#

okay im still having issues with packets and name changing

#

anyone know another api?

dusky harness
craggy zealot
#

no like a name changer api?

dusky harness
#

oh idk 🤷

#

if its not a public plugin then you can use TAB and PAPI ¯_(ツ)_/¯

proud pebble
#

and what do you want to change them to

craggy zealot
#

i fixed that i just used teams does anyone know how to orgnize a list?

#

i have a list of rounds that i wanna go from 0 to 1 to 3 to ect...

#

and there added into a list randomly they all have a id of 1 or 0 or 3 or 2

#

and i wanna go from smallest to biggest this is what i already have but it doesnt work

#
                if (i == Main.getRounds().get(i).getRound()) {
                    rounds.add(Main.getRounds().get(i));
                    Main.getRounds().get(i).setGame(this);
                }```
#

like im trying to sort them from highest to lowest

leaden sinew
#

Collections.sort

rigid mountain
broken elbow
#

you could just use an already existent action library and just add your own actions to it.

rigid mountain
#

Ah, I didnt think abt that thank you 🙂

solemn ocean
#

Guys im making an RPG like and I'm a newbie tbh, so as player levels he gets also more health, do you think theres a way to do this without the main healthbar or can I use it? Im scared of the scaling of health at high levels at a certain point, how would you handle that?

spice rover
#

public class WildBoar extends EntityPig {
    
    public WildBoar(Location loc) {
        super(EntityTypes.PIG, ((CraftWorld) loc.getWorld()).getHandle());
        this.setPosition(loc.getX(), loc.getY(), loc.getZ());

        this.setHealth(20.0f);
        this.setCustomName(new ChatComponentText(ChatColor.YELLOW + "Wild Boar"));
        this.setCustomNameVisible(true);

    }

    @Override
    public void initPathfinder() {
        this.targetSelector.a(0, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
        this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false));
        this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true));
        this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityTurtle.class, 10, true, false, EntityTurtle.bo));

        this.getAttributeMap().b().add(new AttributeModifiable(GenericAttributes.ATTACK_DAMAGE, (a) -> a.setValue(1.0)));
        this.getAttributeMap().b().add(new AttributeModifiable(GenericAttributes.FOLLOW_RANGE, (a) -> a.setValue(1.0)));
    }

}``` what am i doing wrong? the pig stands still and doesnt do anything
craggy zealot
leaden sinew
lyric gyro
#

You can't set the health to anything above 20 iirc so you just do that with effects

craggy zealot
#

like this is a round

#


    public RoundOne() {
        super("Round 1", 1, new MobSpawn(new Testombe(), 3), new MobSpawn(new Testeliten(), 1));
    }

    @Override
    public boolean whileIn() {
        System.out.println(2);
        return true;
    }
}```
#

and this is the gameround class i need to use the int round to go from 0 to 1 to 2 to 3 to 4

#
public abstract class GameRound {

    private final String message;
    private Zombies game;
    private final int round;
    private int amountOfMobsNeeded;
    private List<Entity> mobKilled = new ArrayList<>();
    public List<MobSpawn> mobsToSpawn = new ArrayList<>();


    public GameRound(String message, int round, MobSpawn... mobSpawns) {
        this.message = message;
        this.round = round;
        this.mobsToSpawn = Arrays.asList(mobSpawns);
    }```
solemn ocean
lyric gyro
#

You can change the amount of hearts

solemn ocean
#

Yeah but at somepoint when people will get 10k health how do I scale it for people with 100 health?

#

Its better to make a custom healthbar

lyric gyro
#

Yes

solemn ocean
#

Idk why but this seems not to work, Do I do something wrong?

                    player.getAddress().toString(),
                    ChatColor.BOLD + "" + ChatColor.RED + "You got banned too many times!\n" + "You got banned PERMANENTLY!",
                    null,
                    null);```

I see that my ip is the same but the port changes, is that the issue? Or it's only because im in local? Do I have to substring it to take only before the port? Or maybe it takes also the / before the ip?
warm steppe
#

also check litebans

#

😉

lyric gyro
#

You probably don’t want them to get more than 20 or 30 hearts, anything above will just be too broken

#

If you want to have stronger enemies, you give your players better gear that protects them from it, don’t increase their health any more

winged pebble
#

Can't you change the scaling? So that the amount of hearts is always the same buts each hearts hp value is different per player?

solemn ocean
lyric gyro
winged pebble
lyric gyro
#

Hey,
Im trying to make a Particle Gun that shoots particles but idk how to calculate the Direction and stuff to spawn the Particles

#

this is what ive got so far:

    @EventHandler
    public void onShoot(PlayerInteractEvent event) {
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
            Player p = event.getPlayer();
            if (p.getItemInHand().getType() == Material.NETHERITE_HOE) {
                Vector direction = p.getEyeLocation().getDirection();
                Particle.DustOptions options = new Particle.DustOptions(Color.GRAY, 1);
                p.spawnParticle(Particle.REDSTONE, p.getEyeLocation(), 50, 0,0,0, options);
            }
        }
    }
worn jasper
#

uh sooo I store gens in a json file where the keys are like: world::XCoord::YCoord::ZCoord and then a base64 serialized string which is the gen.
But somehow, recently I found out that it is breaking some gens and turning them into normal blocks but the weirder part is that it has a pattern.
This also only happens when the json file has a big size.

#

Let me know if you need anything that might be helpful, either info or classes, etc.

surreal lynx
#

Is there a way to fork a repository without forking it?

I still need to pull upstream changes occasionally, but github doesn't let you private forks

dense drift
#

If you have access to a private repository and the owner permits forking, you can fork the repository to your personal account or any organization on GitHub Team where you have repository creation permissions. You cannot fork a private repository to an organization using GitHub Free. For more information, see "GitHub's products."

broken elbow
#

you misunderstood smh

#

he wants to fork a repo then make that fork be private

#

wait what? you don't need pro to create private repos?

dense drift
#

Hm, strange, I thought you need pro. Thats nice then

wintry grove
#

oh wait but you want to do pull request

#

thats a problem

lyric gyro
#

pull upstream changes, not make pull requests

surreal lynx
#

^

lyric gyro
#

but yeah that's pretty much it, clone locally and push to private repo

wintry grove
#

my bad

winged pebble
lyric gyro
#

how do I get the target block the player is looking at?

#

(like any distance)

#

._.

#

sorry

uneven lanternBOT
#
@NotNull
Block getTargetBlock(@Nullable Set transparent, int maxDistance)```
Description:

Gets the block that the living entity has targeted.

This method considers all blocks as 1x1x1 in size. To take exact block collision shapes into account, see getTargetBlockExact(int, FluidCollisionMode).

Parameters:

transparent - Set containing all transparent block Materials (set to null for only air)
maxDistance - this is the maximum distance to scan (may be limited by server by at least 100 blocks, no less)

Returns:

block that the living entity has targeted

lyric gyro
#

huh

#

shit

#

tysm

vale fractal
#

I am trying to make a plugin that allows players to have custom pickaxe enchants, one of those will be able to break 5x5 layer of blocks with the pickaxe and I want it to be compatible with the AutoSell plugin, I am using this method to break the blocks but it's not working sadly with the auto sell. Any help with it?

#
        if (block.getType() == Material.BEDROCK) return;
        ItemStack[] items = block.getDrops(item).toArray(ItemStack[]::new);
        HashMap<Integer, ItemStack> restItems = player.getInventory().addItem(items);
        block.setType(Material.AIR);
        for (ItemStack itemStack : restItems.values()){
            player.getWorld().dropItem(player.getLocation(), itemStack);
        }
    }```
broken elbow
vale fractal
neat pierBOT
#
FAQ Answer:

Here you can find the API to hook into Clip's plugin AutoSell, which was made by vk2gpz - https://www.spigotmc.org/resources/62935/
Please do not contact Clip for help with this particular resource.

vale fractal
#

Alright thank you

broken elbow
#

and actually clip might just have an api on his maven repo

vale fractal
#

Alright 👍

quiet spindle
pine flax
#

i'm making a score board and i'm having trouble adding entries to it. i'm expecting 500 entries but i end up with 7 because the Set is rejecting entries https://paste.gg/p/anonymous/679512cec12f4649a214d405f773e277

so far i've tried:

  • overriding Entry 's equals
  • converting Entry to a class and overriding its equals
  • making entries not final and setting it to newEntries

i'm sure the copy Set has 500 entries and the queryResult Map gets 300 entries from the sql. any ideas would be appreciated

Fixed it, it was rejecting entries when Entry’s compareTo returned 0

broken elbow
#

but now I realise the map updates based on how you look. I thought you just want the part at the bottom. lol

#

that's probably just a lot of calculation. taking every block that's at the surface and painting based on a color you chose

#

since it doesn't look like that map even has shadows which normal maps take into account if i remember correctly

wintry grove
lyric gyro
#

did you try seeing things with a debugger?

wintry grove
#

yes

#

nothing weird

lyric gyro
#

so it worked

#

what did you try to do with it?

dusky harness
#

since i see that u set R to 5.0 in GameScreen

#

so are you saying that it prints 0.0 in line 16?

#

idk

#

¯_(ツ)_/¯

wintry grove
#

if I print on that class it prints 5.0f

#

which is ok

dusky harness
#

soo

wintry grove
#

but if I print on the window class it prints 0.0f

#

the default value

dusky harness
#

wheres ur print?

wintry grove
#

removed

#

but it was on line 135

#

window class

lyric gyro
#

what did you try doing when looking with the debugger

dusky harness
#

then in setR just put ```java
new RuntimeException("HashCode: " + hashCode()).printStackTrace();

#

or use debugger but idk how debugger works 🤷

#

so

#

¯_(ツ)_/¯

wintry grove
#

it doesnt change the values

lyric gyro
#

so it has a completely different instance of the Window class presumably

wintry grove
#

apparently

lyric gyro
#

why is the Window constructor public if it's also a singleton

wintry grove
#

just stupid me being well stupid

lyric gyro
#

well

#

make it private

#

and watch your issue disappear

dusky harness
#

wait a minute

#

-_-

lyric gyro
#

mhm

wintry grove
#

I have always had a suspicion with that method

#

but didnt know what was the problem

lyric gyro
#

you're literally creating a brand new instance

#

completely unrelated to the static one

#

that's why "nothing" gets changed, it is changed but in the new instance you create

wintry grove
#

thought so

#

finally

#

me being an idiot caused me pain

#

fair ig

#

tysm

lyric gyro
round cliff
#

Hey !

How can I parse a placeholder in my java plugin ?

I'm using PAPI on my plugin and I wan't to parse some placeholders to use the return values

Thank you very much 😄

lyric gyro
#

what's the fancy command to show java docs

#

;d

#

uhhhh

#

nvm

wheat carbon
#

don't even have papi indexed lol

lyric gyro
round cliff
lyric gyro
#

np, let us know if you have issues

dense drift
round cliff
# lyric gyro np, let us know if you have issues

Yes I have a small issue

Sometimes when I change the data of my player (I use luckperms and the luckperms PAPI) my placeholder is blank

This is my code to show the placeholder

Bukkit.broadcastMessage("    §f → " + PlaceholderAPI.setPlaceholders(player, "%luckperms_next_group_on_track_skygrades%"));
#

And this is the same when I want to parse the placeholder
/papi parse Teyir %luckperms_next_group_on_track_skygrades%

lyric gyro
#

then your placeholder doesn't work

#

but your code is right

round cliff
#

My placeholder work x)

#

It's work sometimes

#

But not all the time

lyric gyro
#

well then your code will also work sometimes x)

round cliff
#

Yes this is very strange

#

:x

lyric gyro
#

you can maybe add a check in your code

#

to see if it returns ""

#

and if it does replace it with something

round cliff
#

Yes

#

But if I have nothing to return all my code is broken :x

lyric gyro
#

No?

round cliff
#

Yes, bc the bukkit message is just a log test

lyric gyro
#

Ahhhh

#

Well maybe consider using something directly linked to your plugin instead of going through placeholders

#

whats stopping you from using the luckperms api?

round cliff
#

(I'm not JAVA dev, I'm php, C++,C# and nodejs dev)

This is my biggest java plugin and I have some difficulties with the luckperms api

#

If you want an example, this is how I can get the user Highest rank in a track

    public static String getHighestOnTrack(Player player){
        LuckPerms luckPerms = LuckPermsProvider.get();

        Set<String> groups = Collections.singleton(luckPerms.getPlayerAdapter(Player.class).getUser(player).getNodes(NodeType.INHERITANCE).stream()
                .map(InheritanceNode::getGroupName)
                .map(n -> luckPerms.getGroupManager().getGroup(n))
                .filter(Objects::nonNull)
                .max(Comparator.comparingInt(g -> g.getWeight().orElse(0)))
                .map(Group::getName)
                .orElse(""));

        return groups.toString().replace("[", "").replace("]", "").toLowerCase();
    }

But I can't replicate the placeholder %luckperms_next_group_on_track_skygrades%

solemn ocean
#

Guys do you know if ita possible to create a custom entity class with custom behaviours and ai? so that i can check if I killed that type example Entity.SHARK only with plugins no datapacks or mods

loud sorrel
#

so u probably could do it w a resource pack and extending entity. if u look at my github linked in my profile and look at KatCore, look at how I extended Player to CustomPlayer. You could do the same with Entity (I have, its just not uploaded)

#

@solemn ocean

dense drift
round cliff
# dense drift Well, it doesnt look like you are getting the groups from a specific track

This is my new function

    public static String getNextOnTrack(Player player){
        LuckPerms luckPerms = LuckPermsProvider.get();
        @Nullable Track track = luckPerms.getTrackManager().getTrack("skygrades");

        luckPerms.getUserManager().loadUser(player.getUniqueId());

        if (track == null || track.getGroups().size() <= 1) {
            return "track == null";
        }

        List<Group> groups = luckPerms.getPlayerAdapter(Player.class).getUser(player).getNodes(NodeType.INHERITANCE).stream()
                .filter(n -> track.containsGroup(n.getGroupName()))
                .distinct()
                .map(n -> luckPerms.getGroupManager().getGroup(n.getGroupName()))
                .collect(Collectors.toList());

        if (groups.size() != 1) {
            return "size != 1";
        }


        return Strings.nullToEmpty(track.getNext(groups.get(0)));
    }

But I have a lot of problems bc if I remove the group.size() check I have an out of bound and if I keep the check I have always my return

broken elbow
#

well that means the stream is returning an empty list.

#

so your groups is basically an empty list.

round cliff
#

Okey thx

#

And how can I fix that ?

broken elbow
#

well I mean it just means that there are no groups meeting your conditions.

#

you'll probably have to debug that stream

#

instead of a stream maybe use a for loop or something and just debug everything you can

round cliff
#

Okey thank you, I'm sorry I have a lot of problem with the Luckperms API

#

And the API is not very documented

broken elbow
round cliff
#

Yes I have read 3 times the api wiki x)

#

And the java docs

broken elbow
#

line 4 in your method

round cliff
#

Yes ?

#

And why

broken elbow
#

because your Player is online

#

since Player represnents an online playert

#

so that means luckperms already has the user loaded

round cliff
#

Ah yes, this is just a small test *

#

I forgot to remove this line

#

But I don't understand why, I have some issues with this placeholder

#

(I have an empty return)

broken elbow
#

is this their placeholder? or is this yours?

round cliff
#

Luckperms placeholder

broken elbow
#

but do you have a group set to yourself on that track?

#

bcz that's what the placeholder returns

round cliff
#

Yes sire

broken elbow
#

not with /lp addparent

#

btw

#

I believe you have to use the promote command

round cliff
broken elbow
#

otherwise it won't count it

round cliff
#

Ok okey

#

I allways /lp user Teyir parent add GROUP

broken elbow
#

yeah. that might be a problem

#

try /lp user Teyir promote skygrades

round cliff
#

Oh thank you very much

#

I love you ❤️

broken elbow
#

it works?

round cliff
#

(with honor obviously)

#

Yes

broken elbow
#

nice

#

yw

round cliff
#

I don't have out of bound

#

You are very helpful, thank you very much

hard wigeon
#

How does one check for when a player falls on the ground?

#

the player damage event won't fire since they might not have fallen far enough

#

and Player#isOnGround is depricated iirc

#

and I'm out of other ideas

broken elbow
#

is it?

#

d;spigot Entity#isONGround

uneven lanternBOT
#
boolean isOnGround()```
Description:

Returns true if the entity is supported by a block. This value is a state updated by the server and is not recalculated unless the entity moves.

Returns:

True if entity is on ground.

broken elbow
#

no its not

lyric gyro
#

on Entity it isn't, on Player it is

broken elbow
#

oh.

#

how does that work?

lyric gyro
#

how does what work?

#
interface Player extends Entity {
  @Override
  @Deprecated
  boolean isOnGround();
}
#

that's how it works

hard wigeon
#

because the player one is very glitchy compared to the entity one

#

since client side

broken elbow
#

yes. I know emily

#

smh my head. you should've know I Know by the way I asked the question

#

/s

hard wigeon
#

so any clue how to detect when someone lands on a block?

lyric gyro
#

check for playermove? ¯_(ツ)_/¯

hard wigeon
lyric gyro
#

y coord has changed and player is on ground I suppose?

#

I mean if you're moving vertically, and you are on the ground, then you weren't before that

hard wigeon
broken elbow
#

make your own method to check I guess?

lyric gyro
#

isOnGround..?

hard wigeon
# lyric gyro isOnGround..?

remember the fact that player#isOnGround is deprecated because it relies on the client, and it super janky supposedly

lyric gyro
#

yes, and so is PlayerMoveEvent

#

it's called in the movement packet, which is also what determines if the player is on ground

hard wigeon
#

ah, so just rely on it?

#

cool

lyric gyro
#

do you have any other options?

hard wigeon
lyric gyro
#

Well, when you're on the ground your vertical velocity isn't 0 either lol

barren ore
#

Just check if players Y cords changed..

neon wren
#

ground level is not equal @barren ore? why would you check if a player's Y cord has changed.

barren ore
#

Oh wait I read that wrong

#

Check if player has a block underneath them on movement

#

If block is air their not on the ground

#

You can still use #isOnGround if it’s depracted

#

It will only cause issues if it gets removed in newer versions

winged pebble
neon wren
#

Found the thread, I was looking for. This should be beneficial to you @hard wigeon

broken elbow
#

like there's many checks you need to make

barren ore
#

Well obv your going to have to do a lot of checks

neon wren
#

Although this is outdated, it may fail on a slab (post from 2017)

barren ore
#

If it’s not implemented into spigot or whatever he is using already

#

He will have to make his own method

#

Checking it

#

U can also check using y by seeing if players Y cords went down by X amount and then check if when player finally lands so his Y cords will stay the same

#

If he doesn’t want it to be fired if player steps down off 1 block if Y changed by -1 then don’t fire any event

#

And check for how much has the players Y went down by 🤷‍♂️

night cobalt
#

im trying to solve a sql syntax exception and i havent been able to find the issue for hours, can anyone see what is wrong with this query?

DROP PROCEDURE IF EXISTS addColumnToTable; 
CREATE PROCEDURE addColumnToTable() 
BEGIN 
  IF (NOT EXISTS( 
    SELECT NULL
      FROM INFORMATION_SCHEMA.COLUMNS
      WHERE table_name = 'tableName'
      AND table_schema = DATABASE()
      AND column_name = 'test') )
  THEN 
    (ALTER TABLE BANKS_PROFILES ADD COLUMN test SMALLINT DEFAULT 0;)
  END IF
END; 
CALL addColumnToTable();

with the following error
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 9
in this case I'm using mariaDB, of which i know a much simpler query is available, but i want to be able to do this in MySQL too for accessibility

#

supposedly the issue is in the ALTER TABLE line but i cant tell whats wrong with it

warm wing
#

hi

how do i get the name of a player in an event?

dusky harness
warm wing
#

is there any way to insert a variable into a string?

broken elbow
#

insert in what way?

#

add it in the middle of the string? or replace a specific character/substring

warm wing
#

lets say I have:

dog = 5
print ("(dog) is after 4")
broken elbow
#

so if your string already contains (dog) you can use replace.

int dog = 5;
String str = "(dog) is after 4";
System.out.println(str.replace("(dog)", dog.toString()));```
dusky harness
#

¯_(ツ)_/¯

warm wing
#

so it thinks that the variable would be an attribute

dusky harness
#

yes you can do Bukkit.broadcastMessage(dog + "is after 4")

dense drift
#

If you want to format messages for instance, MessageFormatter exists

warm wing
warm wing
#

does anybody know a good delay statement i could use?

#

wait() & .sleep all stop the server for the given amount of delay

dusky harness
warm wing
#
       new BukkitRunnable() {
                @Override
                public void run() {

                    p.spawnParticle(Particle.FLASH, xInt, yInt, zInt, 1, 0, 15, 0);
                }
            }
            .runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
#

how come i cant find symbol of plugin?

neon wren
neat pierBOT
solemn ocean
#

Are template strings a thing in java or only in javascript?? I mean the
Hello ${variable_name} !

#

I cant use the backtick in discord tho it formats it

dense drift
#

No, java doesnt have string interpolation or patterns

#

You can use String#format

night ice
tight junco
#

yes

solemn ocean
#

Does anyone know modelengine? If I can implement it in my plugin??

tight junco
#

kotlin has it though PES_EvilRondo

#

google is incredible

solemn ocean
#

Ye i searched but i saw in a server they said you cant implement it so i asked here to know if it was true, im not good at api understanding still, im a newbie hahahah

tight junco
#

from what i can see you can import it very easily with maven/gradle

night cobalt
tight junco
#

you asked a whole once

upper jasper
#

no javadocs etc

warm wing
#

if (timer == 0 ) p.getWorld().playSound((xInt, yInt+10, zInt), Sound.ENTITY_GENERIC_EXPLODE, 1, 1);

#

for some reason the xInt, yInt+10, zInt is giving me errors

#

anybody knoi why

warm wing
#

even without () doesnt work

hoary scarab
#

What error is it giving you?

warm wing
#

cannot resolve

hoary scarab
#

Needs a location not coords

warm wing
#

any way i can use coords with a location

hoary scarab
#

new Location(<world>, x, y, z)

warm wing
#

ty ❤️ ill try it out

solemn ocean
#

Guys i saw the persistent data storage class, is it good for custom stats saving of players like level, totalKills etc... or its better to use custom yml config files?

warm wing
#
                    if((timer == 0) && (all.getLocation().getBlockX() > (xInt+10)) && (all.getLocation().getBlockX() < (xInt-10))){
                            if((all.getLocation().getBlockZ() > (zInt+10)) && (all.getLocation().getBlockZ() < (zInt-10))){
                            p.setFireTicks(20);
                            p.damage(1000);
                            }
                    }
#

using this to check if a player is in a square area when timer == 0

#

for some reason it doesnt work at all

#

if anybody knows pls lmk as i try to rsolve this

hoary scarab
tropic glen
#

Guys, I was creating a plug-in of banknotes and I was looking for a way to recognize them since you can make them by default and infinite from the config. Do you have any ideas? I was thinking about saving the PersistentDataContainer String in the item of the note but thinking about it, maybe generating a lot of banknotes would be a small problem with this?

dense drift
#

d;spigot boundingbox

uneven lanternBOT
#
public class BoundingBox
extends Object
implements Cloneable, ConfigurationSerializable```
BoundingBox has 2 all implementations, 34 methods, 2 implementations, and  1 extensions.
Description:

A mutable axis aligned bounding box (AABB).

This basically represents a rectangular box (specified by minimum and maximum corners) that can for example be used to describe the position and extents of an object (such as an entity, block, or rectangular region) in 3D space. Its edges and faces are parallel to the axes of the cartesian coordinate system.

The bounding box may be degenerate (one or more sides having the length 0).

Because bounding boxes are mutable, storing them long term may be dangerous if they get modified later. If you want to keep around a bounding box, it may be wise to call clone() in order to get a copy.

gritty thistle
#

i was wondering if its possible to make a web based shop in which you would buy with ingame currency? and how it would be done

dark garnet
sterile hinge
#

your code is incomplete

dense drift
dark garnet
sterile hinge
#

well you removed the important parts

dark garnet
sterile hinge
#

the calling code

sterile hinge
#

well you're creating new instances every time

dark garnet
#

but all of the map stuff is in the same class so shouldnt it not matter?

sterile hinge
#

instances matter

dark garnet
dark garnet
#

i think i fixed it, ty!

hard wigeon
#

With protocollib is it possible to create a WrappedDataWatcher with an entity I created? (so not a real entity)?

#
        glowPacket.getBytes()
                .write(0, (byte) 0x40);

does not seem to make my entity glow

dusky harness
#

and if you're on 1.9+ (i think its 1.9?), you have to do setObject(WrappedDataWatcherObject(0, Registry.get(Byte.class)), (byte) 0x40)

#

i think

hard wigeon
#

I tried something similar to that with no success, let me try again

#

gotta recreate special xray in spigot, this is a pain

#

ah I had a small piece different

#

let me see

hard wigeon
#

no dice, still no glow

dusky harness
#

can u show more of the code?

hard wigeon
#
        PacketContainer glowPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);

        WrappedDataWatcher watcher = new WrappedDataWatcher();
        WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Byte.class);

        watcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, serializer), (byte) 0x40);
        glowPacket.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());

        glowPacket.getIntegers()
                .write(0, entityId);
        try {
            protocolManager.sendServerPacket(player, glowPacket);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
dusky harness
#

hmm

hard wigeon
#

primatives don't have classes though...

#

oh you deleted

#

smh

#

and the entity spawned for it is right above

#

it's an invisible shulker if it helps

dusky harness
#

try doing byte.class

#

¯_(ツ)_/¯

#

i dont think it'll work though

#

but worth a shot

hard wigeon
#

lets see

#

it compiles

#

probably auto boxing? I'm unsure

#

yeah, no difference

dusky harness
#

byte.class != Byte.class

#

at least it doesn't print the same things

dusky harness
#

¯_(ツ)_/¯

hard wigeon
#

positive, let me send the whole thing

dusky harness
#

only thing i had different was that I used ProtocolLibrary.getProtocolManager().createPacket but I don't think it makes a difference

hard wigeon
#

the invis entity is created

#

but no outline

dusky harness
#

what version?

hard wigeon
#

1.18.2

#

only the latest

#

oh wait

#

I missed something with lowercase byte

#
java.lang.IllegalArgumentException: No serializer found for byte
#

even better

dusky harness
#

ye use Byte then

hard wigeon
#

so I'm confused

lyric gyro
#

wiki.vg does not reflect the packet object structure

hard wigeon
#

oh wait

hoary scarab
#

Don't you have to get the data watcher directly from the entity?

hard wigeon
#

now it has an outline

#

but it's also visible

hard wigeon
dusky harness
lyric gyro
#

wiki.vg shows the actual data that is sent through the network and how you should be (de)serializing stuff

dusky harness
hard wigeon
dusky harness
#

or it should

dusky harness
hoary scarab
hoary scarab
dusky harness
#

packet side entity

hard wigeon
dusky harness
#

math?

hard wigeon
#

yeah, adding to hexadecimal numbers

dusky harness
#

oh

#

i'd recommend keeping it with |

#

clearer

#

¯_(ツ)_/¯

hard wigeon
#

you're no fun smh

#

fine

hoary scarab
hard wigeon
#

how?

dusky harness
hard wigeon
#

there is no class for that entity

#

it's solely an ID

hoary scarab
#

SynchedEntityData syncedData = armorStand.getEntityData();

hard wigeon
#

now I just need to implement all the logic for highlighting and unhighlighting blocks

broken elbow
#

that's cool

hard wigeon
#

yeah I'm happy

#

this is good non-destructive xray

#

because the alternative that works on 1.18 is replacing all blocks with barriers client-side

dusky harness
#

wait what is SynchedEntityData

hoary scarab
dusky harness
#

if he makes an instance of it, it'll place it in the world

#

instead of being packet side

hard wigeon
#

^^ all I have is an ID of the entity

hoary scarab
dusky harness
#

yes if he makes an instance of that, it'll be placed in the world

hoary scarab
dusky harness
#

im pretty sure they are

hard wigeon
#

not always, but in this case I specifically do not want one

#

I want it entirely packet side

dusky harness
#

although nms I don't think sends the packet

#

so players won't see it

#

so it's partially packet side ig

lyric gyro
#

No entity exist in any world until you add them to it

hoary scarab
#

sigh

Message Moved...

#

dkim ^^^

hard wigeon
#

right, and I don't want that

#

I just want to send packets

#

to tell the client there is a shulker

#

which I'm doing

#

successfully

hoary scarab
#

Yes but dkim thinks it spawns an entity.

hard wigeon
#

ah

dusky harness
#

at least i thought it did since I remember testing it a while ago
idk anymore 🤷
maybe ill experiment with it again sometime later

hoary scarab
#
private void spawnStand(Location loc, String customName, Player player, ArmorStand stand) {
    if(stand == null) {
        ServerLevel level = ((CraftWorld) loc.getWorld()).getHandle();
        ArmorStand nmsStand = new ArmorStand(EntityType.ARMOR_STAND, level);

        nmsStand.absMoveTo(loc.getX(), loc.getY(), loc.getZ());
        nmsStand.setNoBasePlate(false);
        nmsStand.setNoGravity(false);
        nmsStand.setInvisible(true);
        nmsStand.setInvulnerable(true);
            
        nmsStand.setCustomName(CraftChatMessage.fromStringOrNull(StringsUtil.get().colorize(customName)));
        nmsStand.setCustomNameVisible(true);
            
        this.armorStand = nmsStand;
    }else {
        this.armorStand = stand;
    }
        
    SynchedEntityData syncedData = armorStand.getEntityData();
    List<Packet<?>> packets = Arrays.asList(
                new ClientboundAddEntityPacket(armorStand),
                new ClientboundTeleportEntityPacket(armorStand),
                new ClientboundSetEntityDataPacket(armorStand.getId(), syncedData, true));
        
    ServerPlayerConnection playerConnection = ((CraftPlayer) player).getHandle().connection;
    packets.forEach(packet -> playerConnection.send(packet));
}
``` Full method.
hard wigeon
#

d;map#remove

uneven lanternBOT
#
V remove(Object key)
throws UnsupportedOperationException, ClassCastException, NullPointerException```
Description:

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Parameters:

key - key whose mapping is to be removed from the map

Throws:

UnsupportedOperationException - if the remove operation is not supported by this map
ClassCastException - if the key is of an inappropriate type for this map (optional)
NullPointerException - if the specified key is null and this map does not permit null keys (optional)

Returns:

the previous value associated with key, or null if there was no mapping for key.

hard wigeon
#

my one cast to byte seems fine

lyric gyro
#

code?

hard wigeon
#

oh oops

#

thought I attached it

#

mb

#

okay, apparently nevermind

#

I think I got it

#

it was my cast, it was just on the wrong part of the byte

#

wierd

hard wigeon
#

why might my shulker be entirely invis?

#

it doesn't show it's head or anything

#

even without setting it to invis

#

it's wierd, it's kind of like the client knows something is there, but doesn't know to render it at all

lyric gyro
#

Hey,
Im trying to use the Citizens-API in 1.18.2.

I added the dependency to the pom.xml. When I build my Artifact it and reload the Server it says :

Caused by: java.lang.NoClassDefFoundError: net/citizensnpcs/api/CitizensAPI
        at de.claascode.casino.commands.SpawnNPC.onCommand(SpawnNPC.java:22) ~[Casino.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        ... 21 more
Caused by: java.lang.ClassNotFoundException: net.citizensnpcs.api.CitizensAPI
        at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:151) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
        at de.claascode.casino.commands.SpawnNPC.onCommand(SpawnNPC.java:22) ~[Casino.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        ... 21 more

The Code i used:

                NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "ClaasCode");
                npc.spawn(player.getLocation());
#

do I need to have Citizens on the Server? or do I need to replace the <repository> <id> from "everything" to something else?

broken elbow
#

yes you do need to have citizens on the server

lyric gyro
#

oh lol xD

#

there isnt a way to avoid needing Citizens on my Server?

jade wave
#

No p

#

Nop*

wintry grove
#

I dont think so

#

maybe you could shadow it

#

but because of how it is made you cant

winged pebble
round sail
#

i mean you could shade it in kek

#

include the citizens jar in your jar

stuck hearth
#

You could, but you shouldn't

lyric gyro
#

you could but that doesn't mean it's going to work lol

stuck hearth
#

Shade in the implementation too

#

Because we're nuts out here

night ice
#

Use an Npc library if u dont want to use citizens as a plugin

carmine spindle
#

can you have diffrent left click command for people in diffrent groups?

carmine spindle
#

i am using luckyperm groups

night ice
#

You are talking about deluxe menus?

carmine spindle
#

yes

night ice
carmine spindle
#

i have it so that i have a gui thank ranks people up but i want the items to do somthing else when a staff memeber uses the rank up sytstem

worn jasper
#

var lastLogin = pdc.get(new NamespacedKey(plugin, "LastLogin"), PersistentDataType.LONG); this is literally line 67 in OfflineRewardsTask.java

#

I am quite confused at this moment lol

sterile hinge
#

sounds like your code doesn't match the running plugin

worn jasper
#

well, I can assure you, it's that lol

worn jasper
#

Since, the line it's printing doesn't make any sense.

sterile hinge
#

well there must be a call to FlatFile#remove at line 67 in OfflineRewardsTask

#

and it isn't an error, it's just a stacktrace

worn jasper
#

wth

#

okay

night ice
#

Could you provide the code for OfflineRewardsTask?

worn jasper
#

ye sure

#

1s

night ice
#

according to the paste, this is your 67th line

totalMoney += amount * sellPrice * multiplier;

But this doesn't do any I/O Operations rather an arithmetic operation, so is there something changed in between the og stacktrace and the code?

worn jasper
#

those also count

#

xd

lyric gyro
#

Well, he didn't really forget anything

night ice
#

I have no way of knowing your imports or how much line it should cost, so you should have posted those...

lyric gyro
#

you just didn't include them in your paste lol

night ice
#

Also are you using SimplixStorage?

#

FlatFiles is used by SimplixStorage, so there is no way a pdc#get() operation involves calling something from SimplixLibrary... So most prolly the lines might have changed....

#

The error isn't from what you say...

worn jasper
#

Wth, I will recheck and yes my bad, didn’t send the importats.

warm steppe
#

Bukkit.getOfflinePlayer(name).getPlayer().geUniqueId();

lyric gyro
#

only works if player logged in in last 30 days

warm steppe
#

no

#

at least works for me

night ice
#

it will work, if the player has logged into the server once

lyric gyro
#

.-.

#

if not i would need to use Mojang's API right

night ice
warm steppe
#

it will just work

#

it cant not run

lyric gyro
#

I mean if the player never was on Server

#

it cant get the uuid

#

so i would need to get it other way

night ice
#

then you would need to get it externally

prisma briar
#

What's the best way to check If player collided with a block?

warm steppe
#

get player location

#

get block from player location

#

check block face

prisma briar
#

Basically I have a skill which will launch player on a whatever direction and I want it when player bump into a block, it will deactivate the skill, right now I only have a timer to set that the skill is completed.

solemn ocean
#

To store for example "currentMana" or "currentHealth" on a player that persists even on logout, (config files are not good for like custom health system: players have up to 10k health since its a scaling rpg and each time they get damage i dont like updating a config file for current health), do you think the best way is to use PersistentDataContainers? Like setting a NamespacedKey for "currentMana" and lower it when he uses spells etc so its binded to a specific player?? What would you do?

prisma briar
#

So you don't need to deal with configs

solemn ocean
#

Im just scared of losses of data

#

like if I remove by mistake the plugin, like I update it and it doesnt load for a bug, would all the data be lost?

prisma briar
#

Probably yes

#

Maybe have a backup or something with config or whatever.

solemn ocean
#

Yeah I might just save the data onPlayerLeave in config and load onPlayerJoin PDC if not found, so on runtime I use PDC and backup on configFiles, maybe later Database

prisma briar
solemn ocean
#

nope

#

writing everytime in file someone uses spells or gets damage seems too much thats the reason

prisma briar
#

You only write to the config on player leave or server stops, I think that's the better option.

solemn ocean
#

yeah

#

serverstops works also on crash right?

prisma briar
#

Not sure

solemn ocean
#

mmm gottta check that out

#

ty

night ice
#

Its safe to have a task that can save all the cached player data every 5 mins or 10 mins

worn jasper
#

I wanted to use streams but I am not that familiar with them and have no idea how I could do this

night ice
#

Just from a quick look, instead of looping through all the keys and getting values of each key again …you can use a map iterator

#

Also specifying the variable type would be a lot better in case of readability…

night ice
worn jasper
worn jasper
#

code wise

#

does it change a lot performance wise?

sudden sand
#

Do someone know how to display a player the red screen of the worldborder for 1.18 ?

quaint skiff
#

Hi, I wanted to create a /gm command with a GUI and it works for myself but when i want to set the gamemode of someone else inside the GUI it says it didn´t find the target (boolean hasTarget is false) but after i send the command it tells me if it finds the target and if the boolean is true. When I click on something it still says hasTarget is false. (https://paste.helpch.at/okexizepuk.java)

dense drift
#

Does anybody know how to modify the permissions of a faction on FactionsUUID?

jade wave
rigid mountain
bitter grove
rigid mountain
#

Question, this is not Spigot related, just Java in general. So im taking my Java MTA and im stuck at this how to consume an instance of your own class. What exactly does this mean? Im not sure what all the formal jargin is to all this lol.

lyric gyro
#

ngl i have no clue what that means

winged pebble
#

Yeah it's very ambiguous

#

I typically take consume to mean use or interact with, so it seems like a weird question

#

Just put Consumer<MyClass> 😂

lyric gyro
#

Hello

dark garnet
#

why is this returning 0:

YamlConfiguration.loadConfiguration(new File(new File(configFolder, "data"), "slots.yml")).getInt("e907083e-5db6-41fc-9e32-5c4d99a08712.locks")```psuedo: `data.getInt("e907083e-5db6-41fc-9e32-5c4d99a08712.locks")`

`slots.yml`: ```yml
e907083e-5db6-41fc-9e32-5c4d99a08712:
  locks: '100'```*ping if reply*
winged pebble
#

Make sure it's loading the file properly

echo briar
dark garnet
winged pebble
#

int can't be null

#

null for int is 0

#

primitives can't be null

echo briar
lyric gyro
#

Can we see the code for it?

#

All the error is saying is you can’t use getConfig on your plugin variable in the EnablePvPEvent class because it’s null.

lyric gyro
#

Most likely thought it was a string though

warm steppe
#

integer is just a blank number without any " or '

echo briar
echo briar
#

Pretz aka pretxels is my spigot name. It’s what I usually use for my projects

lyric gyro
#

With spring boot im trying to update a value through a POST request, however when printing the body of the request it tells me like MyObject(valueOne= "value", valueTwo="value") It is as a HttpEntity at the moment, should the body not be in JSON form?

lyric gyro
#

It’s trying to translate the color codes there but it can’t find it

#

So it becomes “null” since it doesn’t exist, that’s where the “Cannot translate null text” comes from

#

Just make sure it’s in the config file and you should be good

echo briar
#

Yup it’s there

topaz elm
solemn ocean
#

if I deal damage to a armorstand it doesnt destroy right? like this ((Damageable) entity).damage(60, player);

#

I didnt like to check if the entity was an armorstand or whatever entity that has no health value, I would like it to work, I know there's entity.remove() but I think it doesnt call the EntityDeathEvent tho, and I need that

hoary scarab
worn jasper
#

specifically the generateDrops() method

#

already did some stuff some people here previously suggested, didn't seem to help a lot.

broken elbow
#

Bukkit#getPlayer will return null if the player is not online

#

you need a null check instead

#

the way you store these generators might be something you want to improve tho. it seems like you just store the generators and each have an owner but maybe you just want to have the owner and put all generators under their uuid? so instead of going thru each generator, getting the player every time, just get it once and then loop thru all that player's generator?

worn jasper
#

Would this maybe fix the issue?

broken elbow
#

tbh with you, I have no clue xD

leaden sinew
#

And if possible split up the drops into different ticks if there are a lot.

worn jasper
worn jasper
leaden sinew
worn jasper
broken elbow
#

yeah. that would most likely error out if it was async

#

bcz item drops are new entities

#

and spigot doesn't like you to work with entities async

worn jasper
#

bruh

iron palm
worn jasper
#

just noticed

broken elbow
#

yeah. but just changing it, won't fix your problem

#

it will just throw errors

worn jasper
#

eh

broken elbow
#

you might want to generate the drops and return them back and then drop them sync

worn jasper
#

wait what?

broken elbow
#

so make generateDrops return a map of location, itemstack

worn jasper
#

how would that even work?

#

in the sense of

#

I execute it async

#

but how would I get the values of what it returns and execute that sync

#

I am confused in that part

#

never did anything similar

broken elbow
#

that's a good question. xD

worn jasper
#

bruh

hoary scarab
#

You can create itemstacks async just not drop items async

worn jasper
#

I have no clue how I would even start with it

hoary scarab
#
public void generateItems() {
    Map<Location, List<ItemStack>) generatedItems = new Hashmap<>();
        Bukkit.getScheduler().runTaskAsynchronously(<JavaPlugin>, () -> {
        //generate items
        generatedItems.put(location, list<itemstack>);

        Bukkit.getScheduler().runTask(<JavaPlugin>, () -> //spawn items using map);
    });
}
#

God that was a bitch to type on phone. I hate auto correct

#

Almost every char changed like 3+times

solemn ocean
#

Does anyone know which is the maven dependency for NMS 1.18.1 snapshot?

worn jasper
#

ye, understand it now, I was mainly confused on how the structure would look like

hoary scarab
#

What I wrote I basically how you could do it but there are better ways.

Structure wise just generate the locations and itemstacks async and switch to sync and spawn said items at the locations.

broken elbow
echo briar
broken elbow
#

Main.plugin.getConfig().getString("deactivation.deactivation-countdown" + x[0]) is returning null

#

or is null

echo briar
#

Hmm okay

#

Any idea of why it would return null?

broken elbow
#

d;spigot ConfigurationSection#getString

uneven lanternBOT
#
@Nullable
String getString(@NotNull String path)```
Description:

Gets the requested String by path.

If the String does not exist but a default value has been specified, this will return the default value. If the String does not exist and no default value was specified, this will return null.

Parameters:

path - Path of the String to get.

Returns:

Requested String.

broken elbow
#

If the String does not exist and no default value was specified, this will return null.

worn jasper
#

or am I wrong?

#

I would have to check if it finished

hoary scarab
#

And the async task schedules the sync task so it will run after the async task anyways

worn jasper
worn jasper
#

or wait no, I just read it wrong

#

my bad

hoary scarab
#

👍

jolly garden
#

Hey how can I change Skin of a Player so everyone see it? my Code don´t work

lyric gyro
#

how can I detect if a player is looking at another player?

lyric gyro
#

can you help me figure out what "plugin.target" etc

formal crane
#

Do i need to shade for hikaricp?

lyric gyro
#

or can I somehow check if a particle hits a Player or shit?

broken elbow
#

you can check the x and z of the particle

#

and compare it to the player

broken elbow
lyric gyro
#

wait

#

how

broken elbow
#

how what?

#

there's a BoundingBox#contains method

lyric gyro
#

and then the Vector is the Location of the Particle?

broken elbow
#

no. there's a contain method that takes in 3 doubles

#

x, y, z

lyric gyro
#

tysm

dark garnet
formal crane
#

i am back with a other hikaricp problem, so basicly i am trying to store an int on the uuid of the player (in the database) so
i have this class: PlayerModel.java(https://paste.razerstorm.be/axifayuhug.java) this class is where i add the integer to the database
the problem i have is that after using the addGrindCoins method more then 10 times my server freezes and crashes

this is the code in the listener that triggers the method in PlayerModel.java:

PlayerModal playerModal = plugin.getModalManager().getCustomPlayer(player.getUniqueId());
playerModal.addGrindCoins(5);
player.sendMessage("Je hebt nu " + playerModal.getGrindCoins() + " grindcoins!");```
broken elbow
#

well usually you want to not do that. database requests can be pretty expensive. instead cache the data and save it every 5 minutes or so

formal crane
#

but a database should be able to handle this right?

broken elbow
#

I mean it handles it but your server doesn't

formal crane
#

but it always crashes after 10 times

#

thats just weird

#

i just did it 5 times and waited like 10 - 20minutes and did it 5 times again and it crashed (even after waiting so long)

lyric gyro
#

Hey since I kinda suck at Math can someone help me
When I use player.getTargerBlock to get the Location the player is looking at it gets a Location of the block wich is always smth like this 5.5 5 5. Is there a way to get the exact Location where the Player is looking at? With max distance ofc

broken elbow
#

try that one maybe?

#

nvm. that also gets a block lol. not a location

#

no idea what the exact is for then

lyric gyro
#

weird

#

i think I really would need to calculate the Location based on yaw and pitch, then go foward etc

#

There's LivingEntity#rayTraceBlocks

#

but im not able to do that since Math = hard

#

you can get the location from the result

lyric gyro
#

is there a way to get the Location even if its air tho

#

like now I need to aim at an Block within the MaxDistance

#

mm I don't think so

#

I mean

#

"can you", yes you can

#

not with that method tho

#

maybe with normal rayTrace tho

#

uh is there even a "normal" rayTrace?

broken elbow
#

nah

#

not in spigot's api at least

lyric gyro
#

there actually is player.getWorld().rayTrace()

#

im trying that rn but it doesnt seem to do the Job

#

I GOT IT

#
Location end = player.getWorld().rayTrace(player.getEyeLocation(), player.getEyeLocation().getDirection(), 15, FluidCollisionMode.NEVER, true, 5, null).getHitPosition().toLocation(player.getWorld());
vernal quail
#

Question: How to spawn block break particle like naturally?

i tested with spawnParticle method
it's looks like not natural block break animation (particle not spread like vanilla)
but Origin Realms is

Here is my test (with vanilla command for now)
https://youtu.be/RX92GThYIVM

i think Origin Realms server is using BlockDamageEvent to trigger player is start digging custom block
and put SLOW_DIGGING potion effect for 255 w/Packet to bypass slow arm swinging when apply potion effect (for prevent player digging block by natural)
and play block cracking stage to block, and make it break when block cracking stage is done

this my opinion that make me ask that question
because i don't think Origin Realms server make player break custom block with normal method

https://youtu.be/I0PxqtETnDc

surreal lynx
vernal quail
surreal lynx
#

Thats odd, my blocks have particles

vernal quail
solemn ocean
#

Anyone that used ModelEngine's api and knows why doing

        modeledEntity.getNametagHandler().setCustomName("head", ChatColor.BOLD + "" + ChatColor.YELLOW + entityName + " " + ChatColor.RED + CombatManager.getCurrentHealth(mob) + "❤");
        System.out.println(modeledEntity.getNametagHandler().getCustomName("head"));```
returns null on the sout and so doesnt show the custom name above the entity?
rigid mountain
#

Question, so im trying to add the guids plugin to my maven to use the api but im getting this error: Could not find artifact dev.triumphteam:triumph-gui:pom:3.0.3 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)

pulsar ferry
#

Update to 3.1.2

rigid mountain
#

im trying to use 3.5.6.0

#

wouldnt that be downgrade?

pulsar ferry
#

What

#

Where did you see that version?

rigid mountain
#
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>glares-repo</id>
            <url>https://repo.glaremasters.me/repository/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>me.glaremasters</groupId>
            <artifactId>guilds</artifactId>
            <version>3.5.6.0</version>
        </dependency>
    </dependencies>```
broken elbow
rigid mountain
#

^

pulsar ferry
#

Ah I see, transitive thing, because the error is not coming from there

#

Glare will probably need to bump gui version and release another version of guilds

rigid mountain
#

So should i try a different version of Guilds?

pulsar ferry
#

If that's the latest then I don't think any will work

rigid mountain
#

Thats not the latest i dont think

pulsar ferry
#

Actually 3.5.6.4-SNAPSHOT has the right gui version

rigid mountain
#

The POM for co.aikar:acf-paper:jar:0.5.1-SNAPSHOT is missing, no dependency information available

#

thats the error i get now

pulsar ferry
#

Glare why are you making all this transitive ugh

rigid mountain
#

-_-

pulsar ferry
#

Add

<repository>
  <id>aikar</id>
  <url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
rigid mountain
#

That fixed it thank you 🙂

pulsar ferry
pulsar ferry
rigid mountain
wintry grove
#

I want to get funny

#

can you register commands using brigadier on bukkit?

lyric gyro
#

"yes"

wintry grove
#

and do they work?

#

stupid question

#

meant to say is it worth it?

pulsar ferry
#

"yes"

lyric gyro
#

I mean

#

it's as worth as you make it be

#

if you really love using brig and absolutely thrive when using it, then sure

stuck hearth
#

Blessed that Sponge uses brigader tbh

thorn cape
#

If my project used spigot instead of spigot-api how would I make it so jitpack would be able to compile that jar? Or is there a better place to host my libraries?

pulsar ferry
#

You can't use JitPack with spigot since there is no public repo for it

thorn cape
dusky harness
#

so it'll just error out bc of the craftbukkit/nms code

#

so I think that you'd have to either use reflection or use maven central

thorn cape
dusky harness
#

¯_(ツ)_/¯

thorn cape
dusky harness
#

ok this tutorial isn't perfect since maven central takes a bit of time to setup and I didn't feel like going to every little process, but better than nothing
I hope

if you want to do maven central:
sign up: https://issues.sonatype.org/secure/Signup!default.jspa
apply: https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134

  • summary can just be group id, same with description (since it's required)
  • group id is, again, group id (ex: io.github.dkim19375 - com.github is replaced with io.github)
  • project url, a project that you'll upload to sonatype, im assuming its so that they know you're not botting or anything, you only have to include 1 project
#
  • scm url, also known as source control management - if you use github i just did https://github.com/username/project.git and they accepted
  • username is your jira username for sonatype
  • already synced to central: no
    then within a few minutes you'll get a reply which will ask you to verify ownership, for github they just make you create a repository with your ticket name (took 3 minutes for me)
    then you reply saying that you did it, then you'll have to publish an artifact, then tell them that you published it so that they can enable syncing (took 6 minutes for me)

btw once you got accepted, you have to upload your pub key:

open cmd prompt and if you type gpg or gpg2 does respond?
with something other than ```
'gpg' is not recognized as an internal or external command,
operable program or batch file.


If it doesn't, then install this: <https://sourceforge.net/p/gpgosx/docu/Download/>

then run `gpg --full-generate-key` to generate a key, with 4096 bit RSA if it asks you to choose

Then do do `gpg --list-keys --keyid-format=long` to view the key you just made, then to export it to a file, run: `gpg --export --armor KEYIDBLAHBLAHBLAHBLAHBLAHBLAHBLAH > key.pgp` (this is our public key) - make sure to *not* include `rsa4096/` 
Then publish it on https://keyserver.ubuntu.com/#submitKey and/or https://keys.openpgp.org/upload (make sure it says `PUBLIC` at the top - you don't want to upload your secret key!)

Now run `gpg --list-secret-keys` and export the secret key: `gpg --export --armor KEYIDBLAHBLAHBLAHBLAHBLAH > seckey.gpg` - don't share this

Once you've gotten that, go to `%USERPROFILE%\.gradle\gradle.properties` and here's what I have: ```properties
mavenUsername=dkim19375 - from sonatype
mavenPassword=from sonatype

signing.keyId=last 8 chars of key id
signing.password=password of key
signing.secretKeyRingFile=seckey.gpg

SIGNING_KEY=last 16 chars of key id
SIGNING_PASSWORD=password of key
#

ok sorry for text wall mods

#

but

#
#

<reserved for future so that i dont spam this again if i need to edit>

#

🤷

#

made this a while ago so hopefully its helpful

#

haven't looked at this in a while

thorn cape
#

alright lol I'll figure it out

lyric gyro
#

ok

hard wigeon
#

What's the best way to get which item was used to throw which throwable entity?

#

eg. What item was used to throw a snowball

#

or egg

#

or enderpearl

#

so I can read the data once it's been thrown

#

and add something to the entities data

#

and in turn do something when it lands

lyric gyro
#

Paper has PlayerLaunchProjectileEvent which has all that info (player, projectile and item stack)
though I don't know if for arrows it returns the bow or the arrow item, but for an arrow projectile there's AbstractArrow#getItemStack or something like that idk

hoary scarab
#

Spigot has that too doesn't it? If not its just ProjectileLaunchEvent

#

Yeah its just ProjectileLaunchEvent

upper jasper
river solstice
#

Hey, uh, why am I getting this?

processResources {
    eachFile {
        if (file.name.endsWith(".yml")) {
            expand version: version
        }
    }
}
lyric gyro
#

give*

hoary scarab
lyric gyro
#

that's not a guarantee tho

#

e.g. i have a single special ender pearl that I shoot

hoary scarab
#

Check both hands 😉

lyric gyro
#

no

#

wont when

#

work*

hoary scarab
#

You can test for enderpearls lol

lyric gyro
#

not if it's a single item you hold

hoary scarab
lyric gyro
#

lol how

hoary scarab
#

You can test what item was used.

lyric gyro
#

you literally can't check because the single item you had already got consumed

hoary scarab
lyric gyro
#

bows sure, every other throwable, not so much

hoary scarab
hoary scarab
#

@lyric gyro

@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) {
    Projectile projectile = (Projectile) event.getEntity();
    if(!(projectile.getShooter() instanceof Player shooter)) return;
        
    ItemStack item = shooter.getInventory().getItemInMainHand();
    if(item == null) item = shooter.getInventory().getItemInOffHand();
    ConsoleOutput.debug("Item: "+(item == null ? "null" : item.toString()));
}

[DEBUG] Item: ItemStack{SNOWBALL x 5}
[DEBUG] Item: ItemStack{SNOWBALL x 4}
[DEBUG] Item: ItemStack{SNOWBALL x 3}
[DEBUG] Item: ItemStack{SNOWBALL x 2}
[DEBUG] Item: ItemStack{SNOWBALL x 1}

fair prawn
#
Map<Listener, CustomItemDefinedMgr<?>> swapped = customItemTypeMap.entrySet().stream()
                .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));```
This java code has no error.
```kotlin
val swapped = customItemTypeMap.entries.stream()
            .collect(Collectors.toMap(Map.Entry::value, Map.Entry::key))```
But this kotlin code has an error on both Map.Entry saying "2 type arguments expected for interface Entry<out K, out V"
Why is it?
icy shadow
#

you have to do Map.Entry<K, V>::blah, it's a bit of a pain

#

however a more idiomatic way of doing this in kotlin would be customItemTypeMap.entries.associate { it.value to it.key}

lyric gyro
#

BiMap moment

deft cairn
#
package commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Commands implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) { return true; }
        Player player = (Player) sender;

    if(command.getName().equalsIgnoreCase("commandthing")) {
    //stuff
}
        return true;
    }```

"equalsIgnoreCase" doesn't work. Anyone know why?
fiery pollen
#

Did you actually register it in the onEnable() method?

#

@deft cairn

deft cairn
#

Forgot to, one second

fiery pollen
#

and then you wouldn't even need to check if it equals commandthing

feral cedar
#

Anyone able to help me compile PlotSquared V6? I get an Unresolved refernece: grgit even though I have import org.ajoberstar.grgit.Grgit imported in the build.gradle.kts

fiery pollen
#

Haven't you watched a tutorial or something before starting to code?

deft cairn
#

i did

#

i'm following a tutorial.

night ice
mossy rover
#

how do i make an endpoint request to a website and put the result in a placeholder?

feral cedar
rigid mountain
#

Question, so im trying to use the Guilds API, but im getting this error not too sure why

stuck hearth
#

If api is null I would assume your either not calling it correctly or it hasn't initialized for some reason

rigid mountain
#

i do GuildsAPI api = Guilds.getApi();

#

not sure how id initilize it

lyric gyro
#

make sure you (soft)depend on guilds and that you call getApi during/after onEnable, rather than putting that in a field directly

rigid mountain
#

ok

lyric gyro
#

like you can put it in a field, but do that in onEnable

rigid mountain
#

When i softdepend, im still getting the same error

#

SHould i only do that in my main class?

lyric gyro
#

Can you send your listener class and your main class?

#

?paste

neat pierBOT
#
FAQ Answer:

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