#development

1 messages · Page 140 of 1

echo briar
#

how would i go about setting that up?

#

like looping it to check once the command is run?

winged pebble
#

One way you could do it is instead of referencing a sword field, call a getSword() method that dynamically builds it from the config

#

That way it would always check the config

echo briar
winged pebble
#

Just make it a method inside that class

echo briar
#

ah okay

echo briar
winged pebble
#

np 👍

tender thicket
#

can someone help me with setting up an internal debug server?

#

with intellij

winged pebble
#

What issue are you having?

tender thicket
#

uhm i think actually i figured it out?

#

@winged pebble so like

#

how do i get the changes to automatically apply inside the debug environment

#

it states

#

Building your project will inject the changes to the server

#

but building my project did no such thing

winged pebble
#

What are you following?

tender thicket
#

Spigot

#

Does paper not support swapping?

#

I figured it would be the same but i suppose not

limber hedge
#
List<Integer> distances = Arrays.asList();

distances.add((int) b.getLocation().distanceSquared(player.getLocation()));

Why isnt this being added into the array?

warm steppe
#

Because it's a list

limber hedge
#

So how would I add it in? 😮

high edge
#

List<Integer> distances = new ArrayList<>();

distances.add();

winged pebble
#

Arrays.asList() is immutable, no?

#

Or is that just the other ones that return immutable lists

sterile hinge
#

no, it returns a list wrapper around the the array

#

means you can do everything with it what you can do with the array too

#

and changes to the array are visible in the list and vice versa

winged pebble
#

It does say it returns a fixed size list

#

Which leads me to believe you can't add or remove from it

sterile hinge
#

yes, just like arrays

turbid jewel
#
final ProcessBuilder processBuilder = new ProcessBuilder(command.split("\\s"))
                .directory(sourceFolder);

Procress process = processBuilder.start();

Does anyone know if it's possble to bind some sort of Shutdownhook that gets called once this specific procress is stopped/destoryed?

sterile hinge
#

d; Process#onExit

uneven lanternBOT
#
public CompletableFuture<Process> onExit()```
Description:

Returns a CompletableFuture<Process> for the termination of the Process. The CompletableFuture provides the ability to trigger dependent functions or actions that may be run synchronously or asynchronously upon process termination. When the process has terminated the CompletableFuture is completed regardless of the exit status of the process.

Calling onExit().get() waits for the process to terminate and returns the Process. The future can be used to check if the process is done or to wait for it to terminate. Cancelling the CompletableFuture does not affect the Process.

Processes returned from...

This description has been shortened as it was too long.

Since:

9

Returns:

a new CompletableFuture<Process> for the Process

turbid jewel
#

@sterile hinge Thanks, appreciate it

cobalt sun
#

Hey

#

I have a mate who wants to host a minecraft server with crossplay

#

He uses realms but realms is shitty

#

And he claims there's no way to host your own server and allow crossplay

#

But I really don't believe that

#

Like he wants to play on PC with his mates on ps and xbox

woven hull
cobalt sun
#

Ah yes

#

Thanks

trail burrow
#

is it possible to allow players to create a alias to a command?

high edge
#

doubtful

trail burrow
#

I know I can collect the list of alias save to a config and at bootup load that config, just not should how to add to the command as a alias

craggy zealot
#

anyone know the issue to this?

#

[08:31:30 WARN]: java.sql.SQLSyntaxErrorException: 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 '),PLAYER VARCHAR(100),UUID VARCHAR(100))' at line 1

#

?

opal maple
#

validate your sql syntax through online tools like eversql

woven hull
opal maple
#

you mean sql syntax is correct?

craggy zealot
#

yes

#

i assume

opal maple
#

ok wait

craggy zealot
#

im just as confused

opal maple
#

no it's invalid syntax

craggy zealot
#

how is that

#

how is it invalid

opal maple
#

no length to DOUBLE type

#

that's invalid line

craggy zealot
#

?

#

so what should i do

opal maple
#

just edit like this

#

if you want to set size to DOUBLE, you have to do that like DOUBLE(5,0)

#

like DECIMAL

craggy zealot
#

so

#

100.0

opal maple
#

that would be (3,0)

#

(3,1)

craggy zealot
#

why are you using

#

,

opal maple
#

ah wrong this is the desc from mariadb document

#

M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits allowed by the hardware. A double-precision floating-point number is accurate to approximately 15 decimal places.

#

(M,D)

limber hedge
#

I've got this issue:

UUID playerUUID = (UUID) config.get("players." + player.getUniqueId());```

The second part is the data type Object and cannot be cast to UUID, how would one convert it to a UUID format?
craggy zealot
#

just use

#

UUID.fromString()

opal maple
#

I think your original size in sql was 100 so, I think you don't have to specify size

craggy zealot
#

im done my Mysql api

#

you can set

#

ints, doubles, strings, and uuids

#

🙂

#

just a test class

limber hedge
craggy zealot
#

let me see your config

limber hedge
#
java.lang.ClassCastException: class org.bukkit.configuration.MemorySection cannot be cast to class java.lang.String (org.bukkit.configuration.MemorySection is in unnamed module of loader java.net.URLClassLoader @5c29bfd; java.lang.String is in module java.base of loader 'bootstrap')```
#
    public static boolean doesPlayerExisit(Player player){ //Checks if player is in data.yml
        String playerStringUUID = (String) config.get("players." + player.getUniqueId());
        UUID playerUUID = UUID.fromString(playerStringUUID);
        if (playerUUID == null) {
            return false;
        }else {
            return true;
        }
    }```
craggy zealot
#

what

#

your config file

limber hedge
#
players:
  6b7b95b0-85b5-30cf-b997-271790f60040:
    currentXP: 0
    currentLevel: 0
craggy zealot
#

give me a sec

broken elbow
#

ugh. it tells you what the problem is.

#

you can't just cast it to a string.

limber hedge
#

It cannot be cast

craggy zealot
#

cant you just

limber hedge
#

But its the data type object so I can cast it to anything

#

Question is how to have it in UUID format

broken elbow
#

you do understand that config.get("players." + player.getUniqueId()); will return yml currentXP: 0 currentLevel: 0

#

not the uuid right?

#

if you want to check if there is data for that uuid inside the gui, use config.contains(player.getUniqueId().toString())

craggy zealot
#

if config.coinains something

#

in player.getUUID

broken elbow
#

d;spigot YamlConfiguration#contains

uneven lanternBOT
#
boolean contains(@NotNull String path)
throws IllegalArgumentException```
Description:

Checks if this ConfigurationSection contains the given path.

If the value for the requested path does not exist but a default value has been specified, this will return true.

Parameters:

path - Path to check for existence.

Throws:

IllegalArgumentException - Thrown when path is null.

Returns:

True if this section contains the requested path, either via default or being set.

limber hedge
#

Thanks

craggy zealot
#

okay i have a issue with my rounds system

#

i have 4 rounds

#

but when i finish round 2

#
java.lang.IndexOutOfBoundsException: Index 3 out of bounds for length 3```
#

but i orginized them

#
            for (GameRound gameRound : Main.getRounds()) {
                if (i == gameRound.getRound()) {
                    rounds.add(Main.getRounds().get(i));
                    Main.getRounds().get(i).setGame(this);
                }
            }```
opal maple
#

you're using outer for loop for just to get index?

#

use index variable or ArrayList.indexOf() instead.

craggy zealot
#

dwym

#

because

#

i have round 1

#

2 3 4

#

and i need them to be

#

1,2,3,4

#

i have a list of all the game rounds

opal maple
#

in Main.getRounds()?

craggy zealot
#
        super(round name: "Round 3", round: 3, new MobSpawn(new Testombe(), 1), new MobSpawn(new Testeliten(), 1));
        setAmountOfMobsNeeded(2);
    }```
#

thats the game round class what it looks like

#

and this is the next round

#
        System.out.println(game.getRounds().size());
        GameRound newGameRound = game.getRounds().get(getRound() + 1);
        newGameRound.onStart();
        game.setRoundIn(newGameRound);
    }```
opal maple
#

did you check the size of Main.getRounds() and index 'i' inside of for loops
just print them to console
that error you pasted is literally index outbound error

craggy zealot
#

lets go thru this

#

so there are 4 rounds

#

and it prints the size as 3

#

becuase 0,1,2,3

#

4

#

so when im on round 2

#

and try to go into round 3 it says out of bounds?

opal maple
#

that's why you should check that thru debug... because there's no prob you're saying

craggy zealot
#

let me print i

opal maple
#

yup

craggy zealot
#

hmh

#
[09:45:55 INFO]: [Zombies] [STDOUT] §c2
[09:45:55 INFO]: [Zombies] [STDOUT] §c3```
#

there are 4 rounds thoo

#

the math aint mathing up

#
            try {
                GameRound round = (GameRound) clazz.getDeclaredConstructor().newInstance();
                getRounds().add(round);
            } catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
                e.printStackTrace();
            }
        }```
#

public static List<GameRound> rounds = new ArrayList<>();

#

im not no mathmaticisan but if 4 + 0 = 4

opal maple
#

I can't help you til can't see the entire code. But according to the error message it is clear that your're trying to access index '3' of list which size is 3.

craggy zealot
#

so how do i get the next round of the list?

opal maple
#

don't you have currentRound in class?

craggy zealot
opal maple
#

I don't think you can do that without knowing which round is runnning

craggy zealot
#

getRound() is just the round int

#

lets say im in round 1

#

then getRound() = 1

#

so to go to the neext round i do +1

opal maple
#

ah you have current round

craggy zealot
#
for (int i = 0; i < Main.getRounds().size(); i++) {
            for (GameRound gameRound : Main.getRounds()) {
                if (i == gameRound.getRound()) {
                    rounds.add(Main.getRounds().get(i));
                    Main.getRounds().get(i).setGame(this);
                }
            }
        }```
#

so turns out

#

this only goes to round 3

#

thats the only way i found to orginize them

#

idk what to do to fix it

craggy zealot
iron karma
#

how i can make a lib?

#

i mean

#

add the repository in pom.xml and can access its methods

icy shadow
#

You need to publish it to some maven repository

#

There's maven central and jitpack which are both free and easy enough, or you can self host with something like reposlite

torn heart
#

so i'm trying to spawn a villager with a certain location rn with this: ```java
Location loc = new Location(Bukkit.getWorld("world"), -1.5, 114, 12.5);
loc.setYaw(45);
loc.setPitch(45);
Villager perks = (Villager) Bukkit.getWorld("world").spawnEntity(loc, EntityType.VILLAGER);

    perks.setAge(9999999);
    perks.setProfession(Villager.Profession.PRIEST);
    net.minecraft.server.v1_8_R1.Entity nmsEntity = ((CraftEntity) perks).getHandle();

    NBTTagCompound tag = nmsEntity.getNBTTag();
    if (tag == null) {
        tag = new NBTTagCompound();
    }
    nmsEntity.c(tag);
    tag.setInt("NoAI", 1);
    nmsEntity.f(tag);
    
    perksVillager = ((CraftEntity) perks).getHandle();
sharp cove
#

Why isn't this possible with C# 😦

<a class="btn btn-secondary" href="@xmlMethods.changeStyle();" role="button">Verander style</a>```
#

Everything would be so much easier 💔

torn heart
sharp cove
#

Oh sorry

#

Is this java only?

dusty frost
#

they only do javascript, and not in the href

icy shadow
icy shadow
dusty frost
#

isn't it a templating engine?

#

didn't think it had a runtime a la JS

dense drift
dusty frost
#

sounds like you didn't put your redis connection details in correctly

#

a timeout means that it tried a few times to connect to the server and couldn't

torn heart
#

so i'm trying to spawn a villager with a certain location rn with this: ```java
Location loc = new Location(Bukkit.getWorld("world"), -1.5, 114, 12.5);
loc.setYaw(45);
loc.setPitch(45);
Villager perks = (Villager) Bukkit.getWorld("world").spawnEntity(loc, EntityType.VILLAGER);

    perks.setAge(9999999);
    perks.setProfession(Villager.Profession.PRIEST);
    net.minecraft.server.v1_8_R1.Entity nmsEntity = ((CraftEntity) perks).getHandle();

    NBTTagCompound tag = nmsEntity.getNBTTag();
    if (tag == null) {
        tag = new NBTTagCompound();
    }
    nmsEntity.c(tag);
    tag.setInt("NoAI", 1);
    nmsEntity.f(tag);
    
    perksVillager = ((CraftEntity) perks).getHandle();
sharp cove
sharp cove
winged pebble
#

Unless I'm missing something, browsers don't know to interpret c#

craggy zealot
#

does anyone know how to organize a list of rounds?

#

right now it only goes from 1,2,3 then doesnt add 4

#
List<Integer> ints = new ArrayList<>();
        for(GameRound gameRound : Main.getRounds()){
            ints.add(gameRound.getRound());
        }
        Collections.sort(ints);
        for(int i : ints) {
            for(GameRound gameRound : Main.getRounds()) {
                if(i == gameRound.getRound()) {
                    rounds.add(gameRound);
                    gameRound.setGame(this);
                    System.out.println(ChatColor.GREEN + gameRound.getMessage());
                }
            }
        }```
icy shadow
#

d;Collections#sort

uneven lanternBOT
#
public static void sort(List list, Comparator c)
throws UnsupportedOperationException, ClassCastException, IllegalArgumentException```
Description:

Sorts the specified list according to the order induced by the specified comparator. All elements in the list must be mutually comparable using the specified comparator (that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the list).

This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

The specified list must be modifiable, but need not be resizable.

Parameters:

list - the list to be sorted.
c - the comparator to determine the order of the list. A null value indicates that the elements' natural ordering should be used.

Throws:

UnsupportedOperationException - if the specified list's list-iterator does not support the set operation.
ClassCastException - if the list contains elements that are not mutually comparable using the specified comparator.
IllegalArgumentException - (optional) if the comparator is found to violate the Comparator contract

icy shadow
#

just use this lol

#

sort(rounds, Comparator.comparingInt(GameRound::getRound))

craggy zealot
#

OHHH

#

holy shit

icy shadow
#

by sorting the list by the round number

craggy zealot
#

i thouight that shit only worked for a list on numbers

icy shadow
#

thats why u use the second parameter

#

normally it only does (more specifically, any Comparable type)

shell moon
#

did 1.19 break stuff related to actionbar and chat?

hoary scarab
shell moon
#

I have a plugin to send staffchat messages with #

hoary scarab
#

If you read above I actually had so many issues with it lol

shell moon
#

it now sends on actionbar xdd

hoary scarab
#

Do you use packets for the action bar or do you use the API?

Anything over 1.9 I use
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(text));

shell moon
#

i mean, i'm, using a plugin for staffchat that sends message in chat

#

but i just connected with 1.19 and it sends it on actionbar insteadd xd

shell moon
hoary scarab
limber anvil
#

I'm using intelliJ

floral beacon
#

Hello there

so i want to make bungeecord (waterfall) plugin that will get strings from the list with "target-usernames" and it'll compare to player that left the server (bungee's PlayerDisconnectEvent)

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerDisconnect(PlayerDisconnectEvent ev) {
        ProxiedPlayer p = ev.getPlayer();

        for (String u : plugin.getConfig().getStringList("usernames")) {
            if (p.getName() == u)
                ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), plugin.getConfig().getString("command").replaceAll("%username%", p.getName()));
        }
    }

this is what i got, although this do execute command that targets player that disconnected, but it doesn't target player i enter in usernames list, it does this to ANY player that leaves proxy server

my config.yml

command: "ban %username%"

usernames:
- "TheJoshua"
dusty frost
#

Use .equals to compare Strings, not ==

floral beacon
dusty frost
#

yes

floral beacon
#

will test now

dusty frost
#

though you should also probably be working with UUIDs, not usernames, as usernames can change

floral beacon
#

weird enough, it still does ban any player that leaves the proxy server...

#

even though p.getName() is not at all the same as string from list (of usernames)

#

and i checked that by broadcasting current string while in for loop

floral beacon
#

Worked, thanks @dusty frost !

dusty frost
floral beacon
#

is there a way to execute bungeecord command while no player is online?

river solstice
#

Hey. Odd issue here.

Is there a way to completely cancel all clicks/packets from being sent to the server?
I don't want specific players to be able to click and so they won't be flagged by anti-cheat for excessive clicks per second

hoary scarab
sleek kraken
#

im using NoteBlockAPI and im getting the error ""package com.xxmicloxx.NoteBlockAPI.model does not exist""

#

can anyone help @here

#

also yes the file is there in my external libraries

torn heart
#

does anyone know how to spawn a villager facing a certain direction

balmy wing
#

Anyone knows how to add multiple version support in our own Minecraft plugin? I'm still a beginner and that's why I'm asking about it.

sleek kraken
balmy wing
#

Hmm, it'll work?

#

Alright done, I'll try.

winged pebble
#

If you need to use nms across multiple versions, people often create modules for each version

limber anvil
#

how tf do you add lore to an item? It requires a component to do so, idk how to construct one

high edge
#

Component#text

limber anvil
#
ItemStack item = new ItemStack((Material) config.get(node+".material"), 1);
ItemMeta im = item.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("hi");
im.setLore(lore);```
#

setLore is deprecated & that is the only thing I can find

limber anvil
# high edge Component#text

I understand it needs a text component but idk how to make 1 bc the one I'm using kicks back a syntax error

high edge
#

You add the component which you get by passing your string to Component.text

limber anvil
#

can you show me some example code? nothing I'm trying is working

lyric gyro
#
Component.text(“Hi”)
#

Kinda like that.

limber anvil
#

ok I get that

#

but look at my code

#
ItemStack item = new ItemStack((Material) config.get(node+".material"), 1);
ItemMeta im = item.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("hi");
im.lore() = Component.text("hi");```
lyric gyro
#

You’re not setting the item meta

high edge
#

Read the error, it'll make things clearer

limber anvil
#

it needs a list of components

#

sigh

icy shadow
#

so change it to a list of Components

limber anvil
#

im.lore().add(Component.text("hi"));

#

this works

winged pebble
#

Unless lore() returns null

#

Then you've got an NPE

limber anvil
#

NPE?

winged pebble
#

NullPointerException

limber anvil
#

ah

#

I've been avoiding most NPE's.. oof

winged pebble
#

This is what you need basically```java
List<Component> lore = new ArrayList<>();
lore.add(Componet.text("hi"));
meta.lore(lore);

limber anvil
#

that or if you add to the lore aka meta.lore().add(component) it'll make a new index

broken elbow
#

yeah you just need to make sure it hasLore() first

limber anvil
#

ooh right gotcha

broken elbow
#

also just using meta.lore().add(component) won't work. it won't update the lore. you have to do meta.lore(meta.lore().add(component)) or something like that

limber anvil
#

weird

#

welp I got it now 😒 😂

limber anvil
#

ok so my goal is to get the caught entity that is on the end of my fishing hook, & to change it to a custom item.. I'm not sure that it is working

#
    @EventHandler
    public void onFish(PlayerFishEvent event){
        if(event.getState().name().contains("CAUGHT")) {
            String category = pickFish();

            Item entity = (Item) event.getCaught();
            if (entity != null)
                entity.setItemStack(createItem(category));
        }
    }```
#
    public ItemStack createItem(String node){
        ItemStack item = new ItemStack((Material) config.get(node+".material"), 1);
        ItemMeta im = item.getItemMeta();
        im.displayName(Component.text(node+".displayName"));
        List<Component> lore = new ArrayList<>();
        for(String line : config.getConfigurationSection("lore").getKeys(false)){
            lore.add(Component.text(line));
        }
        im.lore(lore);
        if(config.get(node+".enchantment") != null){
            im.addEnchant((Enchantment) config.get(node+".enchantment"), config.getInt(node+".level"), true);
        }
        item.setItemMeta(im);
        return item;
    }```
#

ok so getCaught is like if I were to hook a player, it would return the player & not the actual fish that I get

#

I think?

#

not sure anymore

winged pebble
#

You want them to fish, and instead of getting a fish for example, you want them to get something else?

limber anvil
#

yeah I want them to get fish but my own custom fish

winged pebble
#

CAUGHT_ENTITY is when they hook a player or mob

#

CAUGHT_FISH is from fishing normally

#

So just check CAUGHT_FISH instead of both

limber anvil
#

wdym?

winged pebble
#

You don't want to check if the state is CAUGHT_ENTITY

limber anvil
#

the state of getting a fish will return like CAUGHT_FISH

winged pebble
#

You only want to check CAUGHT_FISH

#

Right

limber anvil
#

yeah

#

but..

winged pebble
#

But currently, you're checking both CAUGHT_ENTITY and CAUGHT_FISH

limber anvil
#

I'm trying to actually get the (ENTITY) of the fish that gets pulled in when I retract the hook

winged pebble
#

Right, but your logic is off right now

limber anvil
#

yeah I got that part

winged pebble
#

But the rest should be fine

limber anvil
#

so the event.getCaught() is returning null

stuck hearth
#

d; spigot PlayerFishEvent

uneven lanternBOT
#
public class PlayerFishEvent
extends PlayerEvent
implements Cancellable```
PlayerFishEvent has 1 all implementations, 10 methods, 1 implementations, and  1 extensions.
Description:

Thrown when a player is fishing

stuck hearth
#

Entity caught by the player, Entity if fishing, and null if bobber has gotten stuck in the ground or nothing has been caught

winged pebble
#

I assumed CAUGHT_FISH meant they had an item on the hook

stuck hearth
#

Should

limber anvil
#

omg I'm dumb..

#

the issue wasn't even in my fish catching method.. it was in the pickFish method

#
    public String pickFish(){
        double rnd = Math.random() * maxWeight;
        for(String fish : config.getConfigurationSection("item").getKeys(false)){ //<--------------- it needs to be items & not item.. sigh
            double choice_weight = config.getConfigurationSection("item."+fish).getDouble("chance");
            if(rnd < choice_weight){
                return "item."+fish;
            }
            rnd-= choice_weight;
        }
        return ""; //will never reach here
    }```
limber anvil
#

so the issue is

ItemStack item = new ItemStack((Material) config.get(node+".material"), 1);```
#

can't convert string to material

#

how do I get a material from a config?

#

nvm material.getmaterial

limber anvil
#

I got everything working btw

marble nimbus
#

preferably it should work without using Processes

proud pebble
#

also since when is ItemMeta#setLore() deprecated?

#

or is it just paper that deprecated it

winged pebble
#

It's just paper

lyric gyro
#

valueOf must be an exact match, the others will check for things like legacy plugin compatibility, are case insensitive, will turn some characters like - or into an underscore etc

#

though realistically, the registry should be used

shell moon
#

HikariConfig#addDataSourceProperty(key,value)
requires value as string? or it can be other types?
I mean, for example, with "useSSL", it needs to be "true" as string or true as boolean (from config.yml)

proud pebble
#

valueOf worked fine

lyric gyro
#

yeah because exceptions are fucking garbage

proud pebble
#

actually looking back, you are unable to add to a Set<Material> if that string was parsed with Material#getMaterial() but worked just fine as Material#valueOf(), was the weirdest bug ever because sysout would return the same object, or atleast felt like they were the same

#

i didnt do them at the same time ofcourse

#

weirdchamp tbh

tight junco
#

pretty sure its just a boolean

#

but i do SSL in jdbc url

shell moon
#

Then question would be, can be any of them? boolean or string?

brittle thunder
#

"true"

shell moon
#

but question was: can it be a boolean too?

hikariConfig.addDataSourceProperty("useSSL",true)
or it must be a String always and boolean is not supported

high edge
#

Just make it "true"

shell moon
#

what about other options

#

they must be "200" "20.55" and so on as string?

high edge
#

I mean if all it allows is strings, then yes

shell moon
topaz gust
#

does anybody know where LivingEntity#getKiller() get it's data from and how to manipulate it? (not using paperspigot 😢)

high edge
#

EntityDamageEvent or some shit?

thorn cape
#

Hey so I am sending the PacketPlayOutPlayerInfo packet to client and setting them to sepctator so their name shows up in tab as greyed out. But this will make it so the player cannot use their hotbar and it will set their flyspeed and such. How would I fix this (eg. revert them to survival abilities and still keep the tab changes)?

dense drift
#

Send the packet to all players except themselves? 🤔

marble nimbus
#

when I have a file named something.log how can I (if the file exists) compress that delete it and create a new one all from within Java? similar to how minecraft does it with the log files

icy shadow
#

if file exists
compress it
delete it
etc

marble nimbus
#

okay okay, now hear me out

#

how do I compress it xD

#

I only found solution where people use Processes to use zip commands in Linux

#

but that's eww

pulsar ferry
marble nimbus
#

wow its that simple oof fanks matt

pulsar ferry
#

Smh Johni

raw crest
#

my ult discord forgot which email it was on can i get lil help to figure which one?

sleek kraken
#

does anyone here know how to use NoteBlockAPI im having an error

warm steppe
#

What is your error?

marble nimbus
thorn cape
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.

trail burrow
#

in 1.19 is there a way to tell if zombie was natural spawned or from a spawner?

dusky harness
trail burrow
#

THANKS, I will look into that

wintry grove
#

how do you exactly go about setting up a tab completer for a command registered with the command map

dusky harness
#

Since can't you just override the tabComplete method of Command?

wintry grove
#

because I plan on expanding it a lot

wide token
#

Hello! With the help of DeluxeMenu, I have an exchange of goods on my server (iron for gold, etc.). At night, for a couple of hours, people can freely exchange goods, even if there are none in their inventory. Dup. How can this be resolved? The latest version of the plugin is on Java 11

#

'gold_ingot':
material: gold_ingot
amount: 16
slot: 2
lore:
- '&7Обмен железа на золото'
- ''
- '&7- Левый клик: обменять &b18 &bзолота &7за &a1 железный блок'
- '&7- Левый клик+шифт: обменять &b144 золотых слитков &7за &a8 железных блоков'
- '&7- Левый клик: обменять &b32 железа &7за &a16 золота'
right_click_requirement:
requirements:
has_item:
type: has item
material: 'gold_ingot'
amount: 16
deny_commands:
- '[message] &cВ вашем инвентаре отсутствует 16 ед. данного товара.'
right_click_commands:
- '[console] clear %player_name% gold_ingot 16'
- '[console] give %player_name% iron_ingot 32'
- '[message] &aВы обменяли золото на железо'
left_click_requirement:
requirements:
has_item:
type: has item
material: iron_block
amount: 32
deny_commands:
- '[message] &cВ вашем инвентаре отсутствует 1 железный блок.'
left_click_commands:
- '[console] clear %player_name% iron_block 1'
- '[console] give %player_name% gold_ingot 18'
- '[message] &aВы обменяли железо на золото'
shift_left_click_requirement:
requirements:
has_item:
type: has item
material: iron_block
amount: 128
deny_commands:
- '[message] &cВ вашем инвентаре отсутствуют 8 железных блоков.'
shift_left_click_commands:
- '[console] clear %player_name% iron_block 8'
- '[console] give %player_name% gold_ingot 144'
- '[message] &aВы обменяли железо на золото'
This is an example of my code

warm steppe
#

Тебе нужна проверка эсть ли у игрока железо или золото

#

Из за этого игроки и могут просто обменивать ресурсы

#

@wide token

wide token
#

так она есть)

#

в коде же это указано

#

проблема в том, что ночью в 11-12 часов

#

внезапно она отключается

#

и игроки могут спокойно обменивать товары, даже без нужных предметов

#

я ума не приложу как это вообще возможно

warm steppe
#

Ааа да, эсть проверка. Не заметил). странная фигня

wide token
#

очень

warm steppe
#

У тебя случайно нет двух таких менюшек?

wide token
#

в каком плане? Несколько меню от DeluxeMenu?

warm steppe
#

Да

wide token
#

есть

#

много

#

8 меню сделано

warm steppe
#

Ну, типа где можно обменивать ресурсы

wide token
#

есть с продажей за деньги

#

и с обменом тоже

#

есть

warm steppe
#

А ну это тогда не то

wide token
#

есть, есть

#

вспомнил

#

книги за золото

warm steppe
#

Я думал есть два одинаковых мену и одна сломанная

hoary scarab
warm steppe
neat pierBOT
#
FAQ Answer:
» Give the helpers some details
» Ask suitable questions
» Be polite
» Wait

Source

dense drift
#

@wide token » Wait

pulsar ferry
#

Also wrong channel

loud sorrel
#

So i work w kids and im making a plugin to play amongus in minecraft for them. one of the tasks needs to spawn an armor stand only visible to that player using packets. heres my code, ignore the debug stuff and other fluff. the stand doesnt spawn, anyone know why? btw, the participants class extends player

marble cradle
#

Hey guys, having some issues with velocity right now

stuck hearth
#

That sucks

marble cradle
#

People are able to run commands while offline

#

And it's throwing some errors

#

Let me get a paste

#

?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

marble cradle
#

Commands are freezing the chat thread

icy shadow
#

How tf do u run a command while offline

shell moon
#

INFO java.util.concurrent.CompletionException: java.lang.IllegalStateException: Not connected to server!

#

lol

marble cradle
#

That's the problem

#

It freezes the main thread and still processes when the person is offline

icy shadow
#

But how does that happen in the first place

#

Anyway this sounds more like a velocity bug than anything else

marble cradle
#

Yeah, we reported it but it's the only instance of this happening

#

The server got hard ddosed (1500+ connections per second) yesterday and that's what started it

loud sorrel
#

16.3

loud sorrel
#

yes and its not null

hoary scarab
#

Try sending the data packet as well.

loud sorrel
#

? as a debug u mean?

#

it prints both the armor stand and packet

#

sry for the wierd pic format im at school

hoary scarab
#
private ArmorStand armorStand;

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));
}
loud sorrel
#

sorry but do i change w my code from this? im still learning packets

hoary scarab
loud sorrel
#

ah ok

#

what else other than teleport

hoary scarab
loud sorrel
#

entityarmorstand doesnt have those methods

#

and theres no synchedentitydata

hoary scarab
loud sorrel
#

ooh ok ty

proud pebble
#

doesnt 1.16.3 have mojang mapped

#

wouldnt suprise me

hoary scarab
proud pebble
#

according to screamingsandles 1.14.4+ has mojang mappings

hoary scarab
#

1.17 is when spigot did mojang mapped and had a remapping plugin for maven.

loud sorrel
#

ok ill be able to try it like 10-15 mins thsm

#

maven ❤️

pulsar ferry
loud sorrel
#

it spawned 😄 tysm!

hoary scarab
#

np

stuck hearth
#

Happy to help

proud pebble
lyric gyro
#

in the paper/spigot environment, yes they're useless

#

well, were :^)

proud pebble
#

i see.

wintry grove
dark garnet
#

how can i "summon" a warden's sonic boom? what even is it, an entity???

torn heart
#

i'm tryna set a material rn in spigot 1.8.9 but a lot of stuff just isn't showing up. anyone know why?

proud pebble
torn heart
#

spider eye

#

an item stack takes a material and an amount

proud pebble
#

SPIDER_EYE should show up

#

Material.SPIDER_EYE does show up in the material enum for 1.8.8

wintry grove
#

it does exist in the javadocs at least

daring sky
# dark garnet how can i "summon" a warden's sonic boom? what even is it, an entity???

You can, but just a heads up theres a lot of things to "summon" : go here to look up the documentation https://hub.spigotmc.org/javadocs/bukkit/ : in the search bar type in "sonic" to pull up the list. From whats available you can grab the particle effects, sounds and damage event. With those you could likely mock the sonic boom event. Unfortunately, the actual attack isnt a projectile that can be used for simplicity.

chilly oyster
#

im trying to add placeholders to a plugin and have this code which i based off the wiki but they dont seem to be ingme even though papi says the plugin was registered and shows up in /papi list is there something im missing?
https://bin.birdflop.com/merewikosu.java

high edge
#

what's the placeholder you're trying

chilly oyster
#

ive tried %karma% and %wins% as well as %deaths%

#

they all only return the string again

high edge
#

You need to put the expansion identifier in there as well, so %sabotage_<placeholder>%

chilly oyster
#

yep i guess that would do it Facepalm

pulsar ferry
winged crescent
#

any thoughts on transferring files/ a whole world from one server to another linked by bungee

#

maybe ftp?

wet fox
#

Is there a way to detect if a player has opened it own inventory (1.16+)
Currently I have tried

Listening for InventoryOpenEvent (seems to be client side)
Checking every tick if the player has an open inventory. This somewhat works but it also closes the chat and leave screen (if I can solved that, it would work but I could not find any ways to do so
Checking for Achievement.OPEN_INVENTORY (no longer supported in 1.16)
Listening for PacketType.Play.Client.CLIENT_COMMAND packet (did not fire at all)

icy shadow
#

I don't think so, until they click something it's entirely client sided

mystic gull
#
 Constructor<?> destroyConstructor = Objects.requireNonNull(destroyClass).getConstructor(int.class);
#

Hello why I receive this error java.lang.NoSuchMethodException: net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy.<init>(int)

#

Here is the packet parameter public PacketPlayOutEntityDestroy(int... var1)

high edge
#

NoSuchMethodException

mystic gull
#

yes getConstructror throw this error because he dont recognize the constructor but as you can see on the last code it should work ?

stuck canopy
#

    import org.bukkit.Material;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityPickupItemEvent;
    import org.bukkit.inventory.ItemStack;

    import static testingplugins.testingplugins.Items.oak_log;

    public class Events implements Listener {

        @EventHandler
        public void onPickup(EntityPickupItemEvent e) {

            if (e.getItem().getItemStack().equals(new ItemStack(Material.OAK_LOG))) {
                e.getItem().setItemStack(oak_log);

            }
        }
    }```
#

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

public class Items {
    public static ItemStack oak_log;

    public static void init() {
        createItems();
    }
    public static void createItems() {
        ItemStack item = new ItemStack(Material.OAK_LOG);
        ItemMeta meta = item.getItemMeta();
        List<String> lore = new ArrayList<>();
        lore.add("§f§lCOMMON");
        meta.setLore(lore);
        item.setItemMeta(meta);
        oak_log = item;
    }
}
#

help

#

It only works with a 1 amount of oak log

#

how can I make it work when I pickup a stack of the oak log

icy shadow
#

use isSimilar instead of equals

stuck canopy
#

oh

#

it worked thanksss

stuck canopy
#

tho im trying to get a better way

#

    import org.bukkit.Material;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityPickupItemEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;

    import java.util.ArrayList;
    import java.util.List;


    public class Events implements Listener {

        @EventHandler
        public void onPickup(EntityPickupItemEvent e) {

            List<String> lore = new ArrayList<>();
            lore.add("§f§lCOMMON");

            if (e.getItem().getItemStack().isSimilar(new ItemStack(Material.OAK_LOG))) {
                e.getItem().getItemStack().getItemMeta().setLore(lore);

            }
        }
    }```
#

I ended up with this

#

and idk why this isnt working

hoary scarab
stuck canopy
#

    @Override
    public void onEnable() {

        getServer().getPluginManager().registerEvents(new Events(), this);
        getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Plugin has been enabled");
        // Plugin startup logic

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
        getServer().getConsoleSender().sendMessage(ChatColor.RED + "Plugin has been disabled");
    }
}```
stuck canopy
#

wait

#

is it not?

hoary scarab
stuck canopy
#

there are no errors tho

#

and how can I add debug?

hoary scarab
# stuck canopy and how can I add debug?
public void onPickup(EntityPickupItemEvent e) {
    if(!(e instanceof Player p)) return;
    p.sendMessage("your text");
}

Bukkit.broadcastMessage("your text");
Bukkit.getPlayer("your name").sendMessage("your text")
Bukkit.getLogger().info("your text")
<Main>.getLogger().info("your text")
System.out.println("your text")

stuck canopy
#

its going to print that in the console and going to broadcast in chat?

#

but what

#

how is it going to know the error

#

or is it to check if the plugin is actually working or not

hoary scarab
#

Its not checking for a specific error its showing; 1 that the code is running, 2 what ever info you add in the text such as the item, type, entity etc...

stuck canopy
#

I see

#

ok now I have no idea why it isnt working

dark garnet
#

and how would i use EntityDamageEvent.DamageCause? could i not just do 10 damage to the player?

daring sky
wintry grove
#

second I mean that when you do tab when typing a command suggestions appear right?

#

thats the tab completion

#

I want to set those results when using my commands

#

but tabComplete from commandMap its for doing tab complete

#

not setting the results

lyric gyro
#

what do you think "doing tab complete" vs "setting the results" each means?

wintry grove
#

uhh well

#

what the name says lmao

#

I mean I think that it does so because of the result it gives

dense drift
high edge
#

:pog:

wintry grove
lyric gyro
#

you "set the results" when you are "doing tab complete"

#

you return the list of completions in that method

#

that is literally what the method is for

#

client notifies server "I'm typing this command, please give me suggestions", server calls your command tabComplete, command returns list of suggestions, server sends that to client

dark garnet
#

how does chat preview work? is it anything similar to tab complete?

pulsar ferry
#

I'm assuming it functions in a similar way

dark garnet
#

is it some sort of event?

pulsar ferry
#

I don't think the API supports it yet

dark garnet
#

aw dang

#

is using a 3rd-party api the only way mojang intended it to be used?

#

or is there like a way to set it in-game

pulsar ferry
#

Idk exactly how mojang wants it on vanilla server
But spigot/paper will add api for it soon

pulsar ferry
#

Tbh i don't even know if you can customize the chat on the vanilla server thonk

pulsar ferry
lyric gyro
#

you can now with data packs fingerguns

pulsar ferry
#

Oh true I sometimes forget that exists lol

wintry grove
#

I guess so

marble cradle
#

Having some issues with velocity:
So basically this server I admin on is having some major issues with velocity where basically they are getting attacked (have been being attacked for 3 days straight). Whenever someone sends chat or commands, it completely blocks the main thread for like 30 seconds. Does anyone know how to fix this/stop the attack?

wintry grove
#

thats what I thought lmfao

#

so the tabComplete I do it on the command?

lyric gyro
#

???

#

tabComplete is for tab completions
you press tab, and you get completions

wintry grove
#

yes but where do I send those possible completions lmao

#

because

#

it returns those

#

right?

#

or am I stupid

lyric gyro
#

check the whole method signature

#

what does it return?

pulsar ferry
#

You're supposed to return a list of strings in the tab complete method, those are the completions

wintry grove
#

a list

#

alright my question is where do I put that tab complete method?

lyric gyro
#

a list, yes, a list containing possible completions, matches

#

you don't call it

wintry grove
#

in the command overriding the Command one?

lyric gyro
#

the server calls it

lyric gyro
#

it calls tabComplete on the corresponding command

wintry grove
#

alright

#

thank you

marble cradle
stuck canopy
#

import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

import static me.none030.itemrarity.Items.LoreVariable.*;

public class ItemRarityEvents implements Listener {

    @EventHandler
    public void onPickup(EntityPickupItemEvent e) {

        if (e.getItem().getItemStack().getItemMeta().getLore().isEmpty()) {
            e.getItem().getItemStack().setItemMeta(itemLore.getItemMeta());
        }
    }
}
#

why does this not work

high edge
#

uh what

stuck canopy
#

im trying to get every vanilla items

#

and then change their lore

hoary scarab
stuck canopy
#

no errors

hoary scarab
stuck canopy
#

do you want the full code?

hoary scarab
#

Yes

stuck canopy
#

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

public class LoreVariable {
    public static ItemStack itemLore;

    public static void init() {
        createItems();
    }

    public static void createItems() {
        ItemStack item = new ItemStack(Material.OAK_LOG);
        ItemMeta meta = item.getItemMeta();
        List<String> lore = new ArrayList<>();
        lore.add("§f§lCOMMON");
        meta.setLore(lore);
        item.setItemMeta(meta);
        itemLore = item;
    }
}
#

import me.none030.itemrarity.Events.ItemRarityEvents;
import me.none030.itemrarity.Items.LoreVariable;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;

public final class ItemRarity extends JavaPlugin {

    @Override
    public void onEnable() {

        getServer().getPluginManager().registerEvents(new ItemRarityEvents(), this);
        LoreVariable.init();
        getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Plugin has been enabled");
        // Plugin startup logic

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
        getServer().getConsoleSender().sendMessage(ChatColor.RED + "Plugin has been disabled");
    }
}
stuck canopy
#

im just using it's meta data

hoary scarab
#

Does the plugin actually start?

stuck canopy
#

yes

wintry grove
hoary scarab
#

So add debug code to the event and check if it's even running.

stuck canopy
#

oh wait

#

got an error

#

when I got slain by a zombie

hoary scarab
#

... and the error?

stuck canopy
hoary scarab
#

Txt please

stuck canopy
#

its too big

polar island
#

Your array is empty at some point

stuck canopy
#

which

polar island
#

Oh the getlore function is.returning null

#

Because the item didn't have any lore

stuck canopy
#

and if its empty it adds a lore

#

thats what im trying to do

polar island
#

Well isEmpty isn't gonna work because your passing in null not a empty list

pulsar ferry
stuck canopy
#

oh

#

okay

polar island
#

Or rather check if it's null. Not if the list is empty

dark garnet
polar island
#

Why what

dark garnet
#

why is it always false

polar island
#

Oh because you need to separate the 2 statments

icy shadow
#

because ia is false apparently

#

According to that second screenshot

dark garnet
lyric gyro
#

BANANA

#

Eminem can make orange rhyme with you, did you know?

polar island
#

What is itemadderinsalled

dark garnet
polar island
#

No ik that

icy shadow
#

Can you show the full code

polar island
#

But what does the itemAdderInstalled function do

icy shadow
dark garnet
#

its used in other parts of my plugin and its been true (when itemsadder is installed ofc)

dark garnet
# icy shadow Can you show the full code

DamageManager.java:```java
private final boolean ia = Main.itemsAdderInstalled();

/**
 * Damage reduction for helmet
 *
 * @return  The amount of damage reduction
 */
private double helmet() {
    if (inv.getHelmet() == null) return 0.0;

    final Material material = inv.getHelmet().getType();
    // problem code v
    if (ia && inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack()) return 0.16;
    if (material == Material.DIAMOND_HELMET || material == Material.NETHERITE_HELMET) return 0.12;
    if (material == Material.GOLDEN_HELMET || material == Material.CHAINMAIL_HELMET || material == Material.IRON_HELMET || material == Material.TURTLE_HELMET) return 0.08;
    if (material == Material.LEATHER_HELMET) return 0.04;

    return 0.0;
}````Main.java`:```java
/**
 * Checks if ItemsAdder is installed
 *
 * @return  {@code true} if ItemsAdder is installed, {@code false} otherwise
 */
public static boolean itemsAdderInstalled() {
    return Bukkit.getPluginManager().getPlugin("ItemsAdder") != null;
}```
polar island
#

Yea

dark garnet
polar island
#

Yea

#

I would check individually

dark garnet
#

yeah that gets rid of the error but it doesnt make sense why it wouldnt work the other way

polar island
#

Well && is funky in java

icy shadow
#

no it's not lol

dark garnet
#

when i use context actions to merge it gives me what i had before

icy shadow
#

yeah because it doesn't matter

dark garnet
#

yea thats what i had thought

icy shadow
#

If ia is false then it doesn't matter which you do

icy shadow
dark garnet
icy shadow
#

yes

dark garnet
#

alright good, i was having problems with getPlugin != null related to itemsadder not enabling

#

if i click Remove 'if' statement extracting side effects:

if (ia) {
    inv.getHelmet();
    CustomStack.getInstance("vanadium_helmet").getItemStack();
}```
#

ok intellij says this is ok:


    /**
     * Damage reduction for helmet
     *
     * @return  The amount of damage reduction
     */
    private double helmet() {
        if (inv.getHelmet() == null) return 0.0;

        final Material material = inv.getHelmet().getType();

        // problem code v
        if (inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack()) return 0.16;
        if (ia && inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack()) return 0.16;
        // problem code ^

        if (material == Material.DIAMOND_HELMET || material == Material.NETHERITE_HELMET) return 0.12;
        if (material == Material.GOLDEN_HELMET || material == Material.CHAINMAIL_HELMET || material == Material.IRON_HELMET || material == Material.TURTLE_HELMET) return 0.08;
        if (material == Material.LEATHER_HELMET) return 0.04;

        return 0.0;
    }```
stuck hearth
#

+😳

#

I don't think that can succeed

#

ia && iv.getHelmet() shouldn't even be possible I don't think

stuck hearth
#

Well I don't know what ia is, but I don't think inv.gethelmet returns a bool

dark garnet
dark garnet
#

if i put ia after inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack() it works fine...

#
if (inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack() && ia) return 0.16;```
#

why bruh

stuck hearth
#

Yeah that makes sense

#

Order of operations of sorts

#

If you really want ia first use parenthese

dark garnet
#

i tried

stuck hearth
#

ia && (#getHelmet == Itemstack)

dark garnet
#

yea thats what i did

#

still screams at me

stuck hearth
#

for what?

dark garnet
#

Operand #1 of and-chain is false

#

Condition 'ia && (inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack())' is always 'false'

stuck hearth
#

Then ia always returns false

dark garnet
#

it doesnt tho

#
public static boolean itemsAdderInstalled() {
    return Bukkit.getPluginManager().isPluginEnabled("ItemsAdder");
}```
#

i use it in other parts of the plugin too

stuck hearth
#

So are you saying (#getHelmet == Itemstack) && ia works correctly though?

dark garnet
#

but i need to check for ia before the other thing

stuck hearth
#

That's some goofy shit

dark garnet
stuck hearth
#

@dark garnet
This is a really stupid suggestion, but try single & instead of double

sterile hinge
#

== on ItemStacks sounds sus

dark garnet
dark garnet
#

Correct this "&" to "&&" and extract the right operand to a variable if it should always be evaluated.

stuck hearth
#

Oh interesting

dark garnet
#
final boolean custom = inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack();
if (ia && custom) return 0.16;```
stuck hearth
#

Anyway, I think that's your solution

dark garnet
#

but...

#

that wont work

#

since i have to check for ia before doing any customstack stuff

#

imma just do this:

if (ia) if (inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack()) return 0.16;```
sterile hinge
#

That’s equivalent to &&

dark garnet
#

and && should be fine but intellij says no

sterile hinge
#

If IntelliJ says no, there’s a reason for that

#

I think there’s an option to trace back where a value comes from

dark garnet
sterile hinge
#

If the dataflow analysis found a TOP value somewhere, you can trace it back

#

And if it tells you that something is false, then it found a TOP value somewhere

dark garnet
#

TOP?

sterile hinge
#

An unambiguous value that can have exactly one state

dark garnet
#

imma try using this for now:

if (ia) {
    final CustomStack custom = CustomStack.getInstance("vanadium_helmet");
    if (custom != null && inv.getHelmet() == custom.getItemStack()) return 0.16;
}```
shell moon
#

IridiumColorAPI can't have more than 1 step colors and bold, strike, underline, etc right?

iron karma
#

vault have a booster?

dense drift
iron karma
#

how i can create a head with custom value?

marble nimbus
#

how can I make Module A of my Gradle Multi-Module Project be dependent on Module B and wait for that to finish Build first

marble nimbus
#

I have this in my Submodule

tasks.register("copyCreator") {
    dependsOn("shadowJar")
    copy {
        from("build/libs/PebbleConfigCreator-all.jar")
        to("src/main/resources/PebbleConfigCreator.jar")
    }
}``` But the Problem is, I get this: 
```Could not determine the dependencies of task ':shadowJar'.
> Could not create task ':PebbleConfigCreator:copyCreator'.
   > baseDir may not be null or empty string. basedir='null'```
dense drift
#
    task<Copy>("copyJarToServer") {
        from(shadowJar)
        into("./server/plugins")
    }

This is what I use to move the jar to the plugins folder

#

@marble nimbus

#

Ah, to depend on the execution of a task of another module, you have to use dependsOn(module:task). It will invoke module:task and then your task

marble nimbus
#

yea I managed to do it, thanks alot

#

does ShadowJar exclude jars from the resource Folder?

keen locust
#

Hello good afternoon! How can I show my items in quantity in the gui menu? Tried: quantity: 10 more didn't work?

    material: LIGHT_BLUE_STAINED_GLASS_PANE
    quantity: 10
    slot: 20
    priority: 1
    update: true
    hide_attributes:  true
    display_name: '&aEXPANDIR 10'```
proud pebble
hard wigeon
#

Is there an easy way to access a relocated class?

#

so like cast a class that could be any package to the original class's package, and work with it from there

stuck canopy
#

import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scheduler.BukkitTask;

public class SkillsStats implements Listener {


    @EventHandler
    public static void onJoin(PlayerJoinEvent e) {
        int mana;
        mana = 100;
        int health;
        health = (int)e.getPlayer().getHealth();
        String message = health + "     " + mana;
        String name = e.getPlayer().getName();
        Player player = Bukkit.getPlayer(name);
        player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
    }
}
#

how can I repeat this task

#

I want to create a permanent action bar

pulsar ferry
#

Search for Bukkit scheduler

high edge
#

have a runnable, also ew

dark garnet
#

why is no sound being played when i use Sound.ENTITY_WARDEN_SONIC_BOOM?

#

i tested with another sound and it works

#

player.getWorld().playSound(player.getLocation(), Sound.ENTITY_WARDEN_SONIC_BOOM, 1, 1);

#

ping me if u reply

dark garnet
stuck hearth
dark garnet
#

and when trying to play it, nothing is played, and nothing in subtitles either

stuck canopy
#

how can I get the player name here

#

    Skills plugin;

    public SkillsStats(Skills plugin) {
        this.plugin = plugin;
    }

    public int mana = 100;

    String name = Bukkit.getName();
    public int health = (int)Bukkit.getPlayer(name).getHealth();

    @Override
    public void run() {
        String message = health + "     " + mana;

        Player player = Bukkit.getPlayer(name);
        player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
    }
}```
#

as this doesnt work

spiral prairie
#

Bukkit.getName()?

high edge
#

:what:

#

You need to pass in the players

spiral prairie
#

^^

hard wigeon
#

With reflection, how does one cast an instance of a class (eg. com.package.testclass) to a relocated version of the same class (eg. net.example.testclass), since the original instance could have any package, but I need to work with it like it's an instance of net.example.testclass, since it's the same class (atleast, in terms of duck typing)

lyric gyro
#

you don't

#

they are completely different classes with different signatures

#

that's like saying "Oh, LuckPerms API has a UserManager class, why can't I use my class also named UserManager that's in my package instead of that one?", they're different classes that happen to be named the same and have the same methods, but they're still different, you can't cast one to the other

hard wigeon
#

or do I need to manually call methods via reflection?

#

because that sounds terrible lol

icy shadow
#

java aint a dynamic language

#

so yeah i think that's your only option

hard wigeon
#

yeah yeah I know

#

okay

icy shadow
#

or some cursed classgen stuff

hard wigeon
#

I definitely know what classgen is

icy shadow
#

programmatic class generation

hard wigeon
#

well I got that, I meant like how to use it

icy shadow
#

idk

hard wigeon
#

it was in the name lol

icy shadow
#

you asked

hard wigeon
#

but I'll just use reflection

stuck hearth
#

Mixin moment

lyric gyro
#

well mixin needs runtime support (and that kind of thing is not exactly something that is done out of the box either)

#

you could pull off some hacky whacky compile-time crap

icy shadow
#

joe mama needs runtime support

dusty frost
#

i want runtime support for my life

robust flower
#

how to partially shade dependencies on a library (w/ Gradle)?

stuck hearth
#

Wym partially shade?

robust flower
#

Shade some dependencies while others are inherited transitively

stuck hearth
#

Exclude those deps

robust flower
#

but will they still be inherited transitively?

stuck hearth
#

Uhh probably not, now that I think about it

#

I'd have to check shadow documentation

robust flower
#

bcz what I'm trying to accomplish is to remove some of my transitive dependencies from the guy that is shading my library, some of which could be a burden to manage or bcz of conflicts, you know

#

I know that there are many libraries that do this, I just don't know how they do this

lyric gyro
#

shadow has explicit include/exclude dependency merging

#

something something documentation

robust flower
#

but how do I publish the shadowed jar instead of the normal one (with java-library plugin)?

wheat carbon
#

if it’s for public use don’t

lyric gyro
#

why would you want to publish shaded jars? ultimately it's up to the end library user which distribution method to use, forcing it in a way they may not be interested in is not a nice thing to do

robust flower
#

I have my reasons to shade some dependencies in a library

lyric gyro
#

why

robust flower
#

stupid dependencies like this: "org.checkerframework:checker-qual:3.21.4"

lyric gyro
#

what about it

wheat carbon
#

secret you’re stopping people from excluding those libraries if they need to

lyric gyro
#

and you're stopping them from other kind of dependency resolution stuff, like version management

wheat carbon
#

it’s really important in public libs that you don’t shade anything in the deployed jar

robust flower
wheat carbon
#

why?

robust flower
#

most of the dependencies will be exposed to the consumer and I'll let them choose what they want to do, but not with all of them

lyric gyro
#

what does that solve

robust flower
lyric gyro
#

what is the underlying problem? checker-qual is just annotations ultimately tho

#

why does your lib require relocations that's like really bad lol

wheat carbon
#

relocating its dependencies emily

lyric gyro
#

hm?

robust flower
lyric gyro
#

🤨

wheat carbon
#

deploying a shaded jar will only do the opposite

#

that’s a major inconvenience

robust flower
#

what is the problem of shading annotations?

#

they are small, and are already implementation so the consumers never directly depended upon them

lyric gyro
#

well annotations like jetbrains' and checker-qual have no effect at runtime whatsoever (they are not even loaded at runtime so including them in the final runtime jar is pointless), it's compile-time checks (if there is a processor present.. in reality it's IDE support tho)

#

i mean in the case of those kinds of annotations use compileOnly if you don't plan on exposing them to consumers and it's only for your own build process

#

but by shading stuff you don't even give them option to choose at all

dusty frost
#

this man really be relocating jetbrains annotations

robust flower
#

I know its possible bcz I already saw many big names doing that, I just wanted to know how 😢

lyric gyro
#

if you don't want them to get the classes, don't publish shaded jars because that will actually let them use the classes, since they are part of your artifact, not transitive anymore

robust flower
#

there are ways around that, like shading stuff only on already transitive parts of your lib

lyric gyro
#

wat

#

the second you shade something, it no longer becomes transitive, it is embedded into your artifact and it is something you ship with your jar, it is not transitive

robust flower
#

i can't win against these arguments, but I noneless still want to learn how to do what I've explained

lyric gyro
#

Dependencies in the api configuration won't be shaded because they are, well, considered api contract and are exposed "properly" (i.e. as different dependencies in the dependency graph)
Dependencies in the implementation and runtimeOnly configurations are shaded and not "exposed" in the dependency graph (though the actual classes will be exposed once they are inside your jar file); ShadowJar adds a shadow configuration that has the "original" behaviour of implementation (part of the runtime classpath, not shaded in, not exposed in the dependency graph to consumers)

#

Should also note that with gradle you can strictly require a specific version of a dependency, so if a consumer tries to use another version, build will fail (ideally with a provided reason you put in too)

stark solstice
#

Hello o/
i want to make an api for my server so i can use it on my website/discord server
i have seen many peopl use like
api.servername.com/rank/playername or something like that
if anyone knows how or have a video tutorial it would help me a lot
Thanks.

flat anchor
dusky harness
#

¯_(ツ)_/¯

dusky harness
#

With Paperweight, how do I exclude a dependency (specifically adventure in this case as I'm using an older version of Paper while requiring a new version of adventure)?
exclude(group = "net.kyori") doesn't work 😕:

paperDevBundle("1.17.1-R0.1-SNAPSHOT") {
   exclude(group = "net.kyori")
}
```but when running `gradle dependencies` I see this: ```
\--- io.papermc.paper:paper-server:1.17.1-R0.1-SNAPSHOT
   ...
   +--- io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT
   ...
   |    +--- net.kyori:adventure-bom:4.9.3

🤔

dense drift
#

Your own version should have priority I believe

dusky harness
#

since I will also be relocating adventure

dense drift
#

You wont

dusky harness
#

how come?

#

like player.sendMessage

#

in other projects I created an extension function

dense drift
#

That is not adventure, that is paper api

dusky harness
#

then creating my own extension function for sendMessage

dense drift
#

Well, then use spigot ??

dusky harness
#

I'll prob just use regular paper api without paperweight

#

going to see if that works

dense drift
#

Also, your extension will be shadowed by the actual method

dusky harness
#

since it'd convert to something like BukkitFunctionsKt.sendMessage

dense drift
#

Are you sure about that?

iron karma
#
public String getChannelNameByPlayer(Player player) {
        for (ChatChannel channel : channels.values()) {
            if (channel.getPlayerList().contains(player.getUniqueId())) return;
        }
    }```
how i can return the name of the channel?
#

i mean

#

is there any way to get the key of a map having the value?

icy shadow
#

not without linear searching

#

or use a BiMap

iron karma
#

what

#

i dont understand xd

iron karma
icy shadow
#

yes

iron karma
iron karma
# icy shadow yes

When you initialize the class, it implements all the methods of the class, is it necessary?

icy shadow
#

nooonononono

#

use an implementation like HashBimap

iron karma
#

dont exists xd

iron karma
#

it gives me this error

#

UnknownFormatConversionException

#

in setFormat()

#

this is my setFormat

#
e.setFormat(translate(plugin.getChatConfig().getString("CHAT-FORMAT"))
                    .replace("{player-name}", "%s")
                    .replace("{message}", "%s"));```
icy shadow
#

thats not how setFormat works

#

d;spigot AsyncPlayerChatEvent#setFormat

uneven lanternBOT
#
public void setFormat(@NotNull String format)
throws IllegalFormatException, NullPointerException```
Description:

Sets the format to use to display this chat message.

When this event finishes execution, the first format parameter is the Player.getDisplayName() and the second parameter is getMessage()

Parameters:

format - String.format(String, Object...) compatible format string

Throws:

IllegalFormatException - if the underlying API throws the exception
NullPointerException - if format is null

icy shadow
#

actually yeah it kinda is lol

#

whats the full error

iron karma
#
e.setFormat(translate(PlaceholderAPI.setPlaceholders(player, plugin.getChatConfig().getString("CHAT-FORMAT"))
                    .replace("{player-name}", "%s")
                    .replace("{message}", "%s")
                    .replace("%", "%%")));```
#

but now shows the format without placeholders

stuck canopy
#

import com.connorlinfoot.actionbarapi.ActionBarAPI;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

public class SkillsStats implements Listener {

    @EventHandler
    public void onJoin(PlayerJoinEvent e) {

        int health = (int)e.getPlayer().getHealth();
        char heart = '\u2661';
        int mana = 100;

        String message = "§c" + health + "/" + maxHealth + heart + "   " + "§b" + mana + "/" + maxMana;
        ActionBarAPI.sendActionBar(e.getPlayer(), message, 100000);
    }


    public int maxMana = 100;
    public int maxHealth = 100;

}```
#

why is this not working

#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>me.none030.actionbarapi</groupId>
            <artifactId>actionbarapi</artifactId>
            <scope>system</scope>
            <version>1.5.4</version>
            <systemPath>D:/ActionBarAPI-1.5.4.jar</systemPath>
        </dependency>
    </dependencies>```
dense drift
#

try to avoid local jars, at least install them to your local repository

stuck canopy
#

Figured out that actionbarapi doesnt work in 1.18

sterile hinge
#

why would you even need it

dense drift
#

Use adventure @stuck canopy

viral moth
#

could you not just do player.sendActionBar(Component.text(""));

#

might be paper only, not 100% sure

dense drift
#

Yes, thats adventure

stuck canopy
#

Im trying to create a permanent action bar

lyric gyro
#

scheduler.runTaskTimer(sendActionBar, 1, 1)

viral moth
#

that prob your best bet ^

#

also realistically it doesnt matter but you should be able to do it async

iron karma
#

for some reason it returns false being that the player is in the list

lyric gyro
#

packets are queued sync anyway, the only thing that will happen async is adding it to the queue

iron karma
#
public boolean isInChannel(Player player) {
        for (ChatChannel channel : channels.values()) {
            if (channel.getPlayerList().contains(player.getUniqueId())) {
                System.out.println("yes");
                return true;
            }
        }

        System.out.println("no");
        return false;
    }```
viral moth
#

what is a ChatChannel?

#

is that your class?

iron karma
#

a class i created xd

iron karma
viral moth
#

assuming its kinda like a staff chat/clan chat thing? so only certain people are included in the conversation, just assuming

iron karma
#

yep

#

they are channels, with a command a player can create a channel to talk xd

viral moth
#

idk how many channels there will be but if there will be a lot it might be good to have a map that is player -> list of channels they are on/channel they are in if they can only be in one

#

just to avoid looping, not too big of a thing but it might also make your code simpler

stuck canopy
lyric gyro
#

the same way you would define the player for the "ActionBarAPI"

stuck canopy
#

I defined it in a PlayerJoinEvent

stuck canopy
lyric gyro
viral moth
dense drift
stark solstice
stuck canopy
#

finally I was able to make it work

dark garnet
#

how can i get all the children keys of a key in a yml file?
ping if reply

hoary scarab
gloomy geode
#
            try {
                file.createNewFile();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }```

Im currently trying to create a config.yml if there isn't one on start up but all it does is throw except
#

anyone have a good way of doing it?

lyric gyro
#

well.. what does the exception say?

#

if it's telling you something is wrong, maybe paying attention to what it says might be important

gloomy geode
dark garnet
gloomy geode
dark garnet
lyric gyro
#

does the parent folder of the file exist?

gloomy geode
#

config.yml

#

File file = new File("Discord/config.yml");

#

does this create the parent folder

dark garnet
gloomy geode
#

dam im dumb

dark garnet
#

Also I’m pretty sure that puts it in the root directory

#

You should use Bukkit.getPluginDirectory() or something, I can’t recall what it is exactly, Emily can probably tell u

gloomy geode
#

I'm a newbie so

#

would the plugin directory be the one i create

#

cause it currently creates nothing

lyric gyro
#

in your main plugin class you'd have something like this

File dataFolder = getDataFolder();
File config = new File(dataFolder, "config.yml");
dataFolder.mkdirs();
config.createNewFile();
gloomy geode
#

oh i think i got it

#

before

#
            folder.mkdir();
            getLogger().info("Creating new directory for Discord");
        } else {
            getLogger().info("Found your directory!");
            if(!file.exists()){
                try {
                    file.createNewFile();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }```
#
    File file = new File(folder + File.separator + "config.yml");```
#

is my folder variable wrong?

lyric gyro
#

getDataFolder already returns the plugin's own folder inside the plugins dir

gloomy geode
lyric gyro
#

that would make it plugins/<plugin name>/Discord

gloomy geode
#

ohhh gotcha lemme change it

gloomy geode
gloomy geode
#

one more problem emily xD

#

My javaplugin isn't extending to classes

#

other one

#

String link = getConfig().getString("Link"); this getConfig() is throwing an error because i need java plugin to be in that class also

hoary scarab
#
Path-1:
    Path-1-Sub-1:
        Sub-Sub-2: -1
Path-2
    Path-2-Sub-1:
        Sub-Sub-2: 1

getConfigurationSection("Path-1").getKeys(true) will return ["Path-1-Sub-1", "Sub-Sub-1"]

getConfigurationSection("Path-2").getKeys(false) will return ["Path-2-Sub-1"]

#

Hopefully that answers your question.

viral moth
gloomy geode
# viral moth huh

I have a main class with javaplugin extends and I need it in another class

viral moth
#

ok

#

you need to work on your wording a little bit

#

but

#

in your main class make a private static <your main class> instance = null

#

in the on enable method make it equal this

#

and create a getter

#

then just use the getter

#

does that make enough sense?

gloomy geode
#
            return instance;
        }```
viral moth
#

I'm on mobile so it's hard to explain

#

ok

gloomy geode
#
        public Disc(Discord instance) {
            plugin = instance;
        }```
viral moth
#

no

gloomy geode
#

and i thought this might work in my class

viral moth
#

what the...

gloomy geode
#

wait

#
        Discord plugin;
        public Disc(Discord instance) {
            plugin = instance;
        }
#

didn't work tho for my getConfig so def wrong

viral moth
#

it's very wrong

#

no offense

gloomy geode
#

my main is Discord and class is Disc

#

none taken, started today

viral moth
#

why 2 separate classes?

#

discord and disc?

gloomy geode
#

disc is my command

viral moth
#

I'd suggest naming it disccommand

#

anyways

#

let me find qn example rq

gloomy geode
#

would it be easier to move the command just to the main file

viral moth
#

no

#

structure your code just name things as clearly as possible lol

#
    public static Main getMain() { 
         return main; 
     } 
     private static Main main; 
  
  
     @Override 
     public void onEnable() { 
         main = this;
#

hopefully that is clear enough

#

I'd call it instance rather than main, that's just old code I had on github

gloomy geode
#

yeah i have that already

viral moth
#

ok

#

so where ever you need a java plugin just do Discord.getInstance()

#

and that should work fine

gloomy geode
#
private static Discord getInstance() {
            return instance;
        }
#

i had this at the end

viral moth
#

so what's the issue

gloomy geode
#

i just needed it public

viral moth
#

oh

#

lol

gloomy geode
#

im dumb