#help-development

1 messages · Page 2130 of 1

harsh totem
#

If I have a file for a specific command and I set in the main that the executor of that command is that file so it wouldn't matter if I check inside the file if the command is the command I wanted, right?
like now I have a check in the start of the file that checks what command was run but I don't think I need it because the executor is for only one command

crisp steeple
#

don’t use Objects.requireNonNull

midnight shore
#

Hi! How can i get the percentage equal to a max and a number? Like i have max 100 and i have 10 as the inputted number, obviously the percentage it should return is 10 but sadly i don't remember the math formula behind this

crisp steeple
#

that’ll just throw an exception if it is null

kindred valley
#

FDIPOAJDOIASJDOIASJDOIASJHDOIASDHA

trail oriole
#

yes

kindred valley
#

i roared wtf

trail oriole
#

LMAO

chrome beacon
#

TagParser

compact haven
tardy delta
#

PYRAMIDS

#

AAAA

midnight shore
compact haven
#

and you'll need to multiply it by 100 like deotime said if you want it to display as a percentage. mb

midnight shore
compact haven
#

but yeah it's not complicated math lol

midnight shore
#

yeah i've already fixed that but thanks to both

midnight shore
crisp steeple
#
  1. your event might not be registered
  2. use event.getWhoClicked is always going to be a player so dont check it
  3. if the clicked inventory is null itll cause an exception
  4. if the item on the cursor is null itll cause an exception
west orbit
#

possible to make an arrow not hit any entities and just make it phase thru them?

crisp steeple
#

also you're checking the item on the players cursor

#

not the actual item they clicked

tepid ore
#

Is it possible to make a projectile invisible without ProtocoLib, and if so, how?

echo basalt
tepid ore
#

A what sorry? I've never really dealt with packets

echo basalt
#

You aren't the first one

#

I made a basic tutorial on spigot

#

Should help you get to your answer

tepid ore
#

Ok, thank you :>

compact haven
#

about the entity destroy packet specifically, it tells the client that receives it that the entity no longer exists

#

so basically the client forgets about the entity, as if it was killed, logged off, etc

echo basalt
#

spigot will still be aware of it however, and will cause the projectile to still work

tepid ore
#

Ahh, I see. That makes sense

trail oriole
#

I looked on google how to make custom enchants and they told me to do a custom lore, so it would work by checking the lore of the item, and checking if it contains the custom enchantment then doing the effect if true right ?

golden kelp
#

Yes

trail oriole
#

that seems fair, but how do i add it into an enchant table afterward ?

tardy delta
#

in some code there's so much bad stuf that i dont want to respond

river oracle
#

you can make your own enchantment wrapper

trail oriole
#

well I have no idea how to do that

#

how would that work

#

making my own enchants

river oracle
#

Hold up I have a video

#

it goes over how to make your own enchantment wrapper idk how good the guy is at java its been a while since I touched a custom enchant wrapper

river oracle
# trail oriole well I have no idea how to do that

https://www.youtube.com/watch?v=wd1FUOT-BJY I'm not sure how good these guys practices are but I recall this being the video

Learn how to create Custom enchants for Minecraft :)! I will "attempt" to teach y'all how to register custom enchants as Minecraft enchants! Hope y'all enjoy the video :D

----- Support me & more -----

Patreon:
https://www.patreon.com/codedred

Donate to me :)
https://www.paypal.me/CGMax

Join my discord:
https://discord.gg/zMzXSgk

------ Li...

▶ Play video
trail oriole
#

i've seen that video while searching through internet

#

it says 1.15+

#

i'm 1.8.9

river oracle
#

oh lol cope

trail oriole
#

what do i do ethuethoeqjej

river oracle
#

lore your best option

#

no clue how to put in enchant table though

#

have fun

trail oriole
#

thanks lmfao

compact haven
#

you can't

#

the enchantment table is fixed

trail oriole
#

so the only way is to recode entirely the enchant table right ?

#

like hypixel

compact haven
#

and the lang file is what shows the actual enchantment name on the client

#

so the only way would be to have a resource pack that replaces some useless enchantments with what u want

river oracle
#

idk when custom resource packs were introduced but you could prob force a resource pack for that

trail oriole
#

hold up

#

custom enchants with lore and a command to add the custom enchants

#

would that work ?

chrome beacon
#

Yeah

harsh totem
#

why does it say that there is not such thing as SelectionScreen. was the name changed because my tutorial is old?

trail oriole
#

okay thanks a lot yall

river oracle
#

nice

harsh totem
#

oh lol

#

nvm

#

sorry for wasting your time

river oracle
#

following youtube tutorials the greatest evil there can be

#

I've tried you learn nothing lmfao

harsh totem
compact haven
#

to start with they aren't bad

#

but you might get stuck into a tutorial hell

#

where you can't do anything without them

#

or without a support discord

river oracle
#

by the constant learn java harassment I recieved here I stopped asking for help and learned the greatest lesson

#

java

compact haven
#

LMAO

#

I mean it's so true

#

and I'm glad the harrassment ended up helping 🙃

river oracle
#

I learned with spigot API which was extra awful but it kept me interested at least

kindred valley
#

why it does not see my dependency

compact haven
#

well you have spaces in the group id

#

and double check it's a part of maven central

#

yeah find otu what repository that's a part of @kindred valley because that groupId isn't in maven central

trail oriole
#

well you're not checking if the command is equal to the input cmd

kindred valley
harsh totem
trail oriole
#

if(cmd.getName().equalsIgnoreCase("wands"))

compact haven
#

he wouldn't need to do that if he's setting hte comand excecutor

trail oriole
#

really

compact haven
#

that's if you're putting it into onCommand in the plugin class

#

yes really

trail oriole
#

have I been doing that for nothing ?

compact haven
#

yes

harsh totem
trail oriole
#

well me too and i'm still checking it lmfao

harsh totem
#

lol

#

you dont need this

trail oriole
#

how would i open a gui on right click on a custom entity ? (citizen npc)

compact haven
#

does citizens not fire a interact entity event

#

idrk never used it, you could also listen for the packet kekw

crisp steeple
#

believe it has a "NPC" metadata or something

compact haven
#

then yeah just do that

crisp steeple
#

well i think citizens makes it persistent

compact haven
#

nah only if the entity is despawned

crisp steeple
#

the npc metadata stays after server restart

#

like the actual tag

harsh totem
crisp steeple
#

they probably just re-add it on the start

compact haven
#

if the server restarts the entity is respawned to my knowledge so the metadata is set again

crisp steeple
#

yea

trail oriole
#

Am I dumb

crisp steeple
#

dont know

trail oriole
#

they have an entire api on their wiki

harsh totem
compact haven
#

then yes ur dumb go read the wiki

harsh totem
compact haven
#

this me

trail oriole
#

It says I have to use maven

compact haven
#

well except thats a panda and I'm clearly a polar bear

compact haven
#

if you're using gradle that's fine

#

as for needing to use a dependency manager, not really, but do it?

trail oriole
#

i'm using eclipse 😅

compact haven
#

yes.. that's fine lol

#

maven is a dependency manager, you can use it in literally anything

trail oriole
compact haven
#

even notepad++, though there's no native support

#

"or Gradle for experts," well that's rude

trail oriole
#

I have no idea what maven is

#

i just started eclipse and built my plugin

#

Do I need to restart the whole java project to implement maven ?

compact haven
#

no

#

do you have a domain

#

don't make your groupid that nonsense, the tutorial says it's fine but it really isnt

trail oriole
#
        <groupId>net.citizensnpcs</groupId>
        <artifactId>citizens-main</artifactId>
        <version>VERSION</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>```this ?
compact haven
#

if you don't have a domain, make it like me.frenchkiwi or something, or if you plan on having a domain, reverse that so frenchkiwi.com becomes com.frenchkiwi

#

no that part is fine, leave that, we're setting up maven for your project

trail oriole
#

I have some domain names but do I need to create them in cloudflare to use maven ?

compact haven
#

no

#

it's just a standard, the groupid is typically just your reversed domain

harsh totem
#

I get an error null in the console for a command that just returns an Inventory variable and nothing else but I don't understand why.


import com.ytg667.myplugin.items.ItemManager;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

public class Wands implements InventoryHolder {

    private Inventory inv;

    public void wands() {
         inv = Bukkit.createInventory(this, 9, "pick a magical wand");
         init();
    }

    private void init(){
        ItemStack fireWand = ItemManager.fireWand;
        ItemStack dragonWand = ItemManager.dragonWand;
        ItemStack lightningWand = ItemManager.lightningWand;
        inv.addItem(fireWand);
        inv.addItem(dragonWand);
        inv.addItem(lightningWand);
    }



    @NotNull
    @Override
    public Inventory getInventory() {
        return inv;
    }
}
``` this is the Inventory
trail oriole
#

so I can use anything ?

compact haven
#

if you have a domain that you plan on putting a portfolio on or something, reverse that domain and put it there

glossy venture
harsh totem
trail oriole
compact haven
#

there's no link, it's just standard maven convention

#

the idea is to let people know immediately who the project is by

#

for example, my groupid is me.schooltests, because I own schooltests.me

harsh totem
#

this Inventory file is called inside my command which is called in the main file

#

and the plugin.yml

compact haven
#

and that's where my website will be hosted, rn it's just linked to a VPS I use

trail oriole
#

This is the groupID right ?

compact haven
#

yes

harsh totem
#

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class Wands implements CommandExecutor {
    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
        if (!(sender instanceof Player)) {
            System.out.println("You must be player to execute this command!");
            return true;
        }
        Player player = (Player) sender;
        com.ytg667.myplugin.inventories.Wands gui = new com.ytg667.myplugin.inventories.Wands();
        player.openInventory(gui.getInventory());
        player.sendMessage(ChatColor.GREEN + "Please make a selection");


        return true;
    }
}
``` this is the command
trail oriole
#

named it fr.purpleyounoob

#

because I own purpleyounoob.fr

harsh totem
#

wdym

compact haven
#

well do you plan on putting an actual website there for professional use lol

trail oriole
#

Well I plan on making this website a portfolio website with all my random projects on it

compact haven
#

all right, that works then

#

what is the plugin named

trail oriole
#

KiwiPvp

compact haven
#

make the artifactid kiwipvp then

trail oriole
#

It was there already

compact haven
#

was it lowercase

trail oriole
#

no

harsh totem
#

I don't understand what the problem is

trail oriole
#

just made it

#

lowercase

compact haven
#

go into pom.xml

#

oh okay

#

so you didnt hit create yet

trail oriole
#

no

compact haven
#

send a pic of what you're looking at rn

trail oriole
compact haven
#

ight what's the current version of your plugin

trail oriole
#

it's the pre alpha v0

compact haven
#

pre alpha v0

#

okay then

trail oriole
#

lmao

compact haven
#

thsoe settings are fine, just hit create

trail oriole
#

just saying that it's not done yet at all

#

It has no name

#

and no desc

compact haven
#

that's fine

trail oriole
#

but i pressed finished

#

okay I have pom.xml

#

and a target file

#

and a bin file

harsh totem
#

oh so I just need it to return wands() and not inv

compact haven
#

okay now in the pom.xml

#

send th current pom.xml

#

?paste

undone axleBOT
trail oriole
compact haven
#

hello person who lies to himself

#

;-;

harsh totem
#

well it did fix it

#

i just called wands() there instead if returning inv

trail oriole
compact haven
#

give me a sec frenchkiwi

#

what spigot ver u using

trail oriole
#

spigot-1.8.8-R0.1-SNAPSHOT-latest

#

what

#

@eternal night what do you want

#

caught you

#

hehehe

harsh totem
#

so you just put this.inv instead of just inv? how would that make a difference?

eternal night
#

I see a 1.8, I send some 👀

#

easy as that xD

compact haven
#

send me the citizens website you're on @trail oriole

harsh totem
#

so your code is exactly like mine

trail oriole
#
API

Citizens has an extensive API for working with NPCs. Make sure you always are using an up-to-date build of the CitizensAPI to ensure that your plugin works with the latest release of Citizens.

trail oriole
#

1.8 best mc version pvpwise

harsh totem
#

oh

#

I know what a constructor is I just didn't realise because i'm used to hear it in my language

#

not in english

#

@last temple but it does work now

#

and I dont have a constructor

#

import com.ytg667.myplugin.items.ItemManager;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

public class Wands implements InventoryHolder {

    private Inventory inv;

    public Inventory wands() {
         this.inv = Bukkit.createInventory(this, 9, "pick a magical wand");
         init();
         return inv;
    }

    private void init(){
        ItemStack fireWand = ItemManager.fireWand;
        ItemStack dragonWand = ItemManager.dragonWand;
        ItemStack lightningWand = ItemManager.lightningWand;
        this.inv.addItem(fireWand);
        this.inv.addItem(dragonWand);
        this.inv.addItem(lightningWand);
    }



    @NotNull
    @Override
    public Inventory getInventory() {

        return wands();
    }
}
knotty gale
#

does anyone know how to make a plugin using regions?

harsh totem
#

ok

trail oriole
knotty gale
#

like world edit where you use the axe and make a region

trail oriole
#

yes that's worldguard

#

they have an api

compact haven
knotty gale
#

exactly

compact haven
#

will you just do it lol so I can explain

trail oriole
#

i did it

compact haven
#

all right, so basically how maven works, is that you have dependencies

harsh totem
#

@last temple thank you very much and sorry if I annoyed you a little

knotty gale
#

what would the yml be called

#

and I wopuld I store it with like a variable?

compact haven
#

repositories are remote places that you can fetch dependencies from, and Spigot API is on their own repository, and Citizens API is also on their own repository

#

you in that, you have a repository id'ed spigot-repo and citizens-npcs, for the two different dependencies

knotty gale
#

ok

compact haven
#

the scope is provided, meaning it'll be on the class path when the plugin is ran

trail oriole
#

i'm dead confused lmao

compact haven
#

because spigot will load your plugin into the same place with the spigot api & citizens api, so it's all available

#

what part don't you get tho, so I can elaborate on it

trail oriole
#

isn't the spigot api already available from the build path ?

compact haven
#

well that's meant to be removed

#

maven is a complete replacement for whatever you've been doing before

#

how you've been building plugins is far from recommended

trail oriole
#

oh okay

#

so this now is better ?

compact haven
#

100%

trail oriole
#

i have an error

compact haven
#

yikes, what is that error

trail oriole
#

Missing artifact net.citizensnpcs:citizens-main:jar:2.0.29-b2544

compact haven
#

all right, change the b2544 with SNAPSHOT

knotty gale
#

another question. How do I make a scoreboard, that I can change the score of the thing on the board

compact haven
#

see if that works

#

I just hoped the build number was apart of the maven version but ig it's just SNAPSHOT

trail oriole
#

fixed

knotty gale
#

so like if I have "team 1: 0" I could easily change it to "team 1: 1"

compact haven
#

ok neat, remove the spigot jar from the eclipse build path

knotty gale
#

ok

trail oriole
#

why do I have an error though

compact haven
#

what's the error ;-;

trail oriole
#

no idea

#

it displays nowhere else

compact haven
#

go into your plugin class

#

it's probably a source code error

#

look in the entire branch, there's probably that error X somewhere else too

trail oriole
#

no ?

compact haven
#

yikes why are your classes lowercase

trail oriole
#

what

compact haven
#

classes are meant to be named LikeThis not likeThis

trail oriole
#

tf would I make the uppercase

#

oh

#

why

compact haven
#

because it's convention

trail oriole
#

idk started to like this

#

want me to rename them all ?

trail oriole
#

lmao

compact haven
#

oh well wait, your package is fr.frenchkiwi

#

do you own that domain

trail oriole
#

no

arctic moth
#

what am i supposed to do her

compact haven
#

ight then refactor change that to fr.purpleyounoob.kiwipvp

arctic moth
#

to check if its empty

compact haven
#

ideally package & maven groupid are the same

midnight shore
#

Does the Tablist support ChatColor using setPlayerListHeader?

arctic moth
#

oh i can just remove the item != null part

compact haven
#

as for the error, hover over KiwiPvp that shows the error X and see if anything pops up

trail oriole
#

and no nothing pops up

#

is that an error ?

#

idk it's red

#

lmao

brittle lily
#

Can I Increase damage of player without event?

trail oriole
#

i don't think so

harsh totem
#

how do I execute a command from 1 file in another file?

trail oriole
#

well you can execute a command from a player

harsh totem
trail oriole
#

But executed by a player or the console ?

harsh totem
#

oh wait

#

nvm

#

i'll just copy the command itself

trail oriole
#

well

#

player.performCommand()

trail oriole
#

any future api I want to use from plugins, I'd need to add them as dependencies in the maven pom.xml is that it ?

crisp steeple
#

youll need to figure out if an armorstand that doesnt wear armor returns null or air

trail oriole
#

and then it'll just work with the plugin as some sort of other build path dependency thingy

compact haven
#

Yes, but how are you building it @trail oriole

trail oriole
#

exporting

compact haven
#

Exporting what

#

Like show me what u click

#

I use IntelliJ so Idrk how it works on eclipse but want to make sure you’re using maven to build

trail oriole
#

the entire java project, so i'd click on export the file named KiwiPvp

compact haven
#

Right click on KiwiPvp at the start of the project outline and click Run, see if there’s a maven package option

trail oriole
#

run as maven build ?

crisp steeple
trail oriole
compact haven
#

Or anyone who uses eclipse and maven if u could help him run the package goal on eclipse

crisp steeple
#

i got it right the first time and then my brain started going in circles

compact haven
#

Yes run as maven build

#

Try that

harsh totem
#

I don't understand what the problem is. this event doesn't work.

        if (event.getClickedInventory() == null || (!(event.getClickedInventory() instanceof Player)) || event.getCurrentItem() == null) { return; }
        else {
            Player player = (Player) event.getWhoClicked();
            if (event.getCurrentItem().equals(ItemManager.fireWand)){
                player.getInventory().addItem(ItemManager.fireWand);
                player.sendMessage(ChatColor.GOLD + "You now posses the power of fire!");
            } else if (event.getCurrentItem().equals(ItemManager.dragonWand)){
                player.getInventory().addItem(ItemManager.dragonWand);
                player.sendMessage(ChatColor.LIGHT_PURPLE + "You now posses the power of the dragon!");
            } else if (event.getCurrentItem().equals(ItemManager.lightningWand)){
                player.getInventory().addItem(ItemManager.lightningWand);
                player.sendMessage(ChatColor.YELLOW + "You now posses the power of lightning!");
            }
            event.setCancelled(true);
        }
        }```
crisp steeple
trail oriole
#

?paste

undone axleBOT
trail oriole
harsh totem
crisp steeple
#

you kind of did

compact haven
#

ah okay that’s not running the package goal

harsh totem
#

ah

compact haven
#

Ugh

harsh totem
#

0_0 i think im getting dumber

#

its 00:00 for me

compact haven
#

@worldly ingot do you still use eclipse

#

or did u ever, was that someone else

#

maybe it was optic

trail oriole
#

arg this is so complicated

#

i just wanted to use citizen

compact haven
#

No, you need to learn lol

trail oriole
#

well maven and all to use one api

#

all this for nothing much

#

seems complicated to me

compact haven
#

Actually no

worldly ingot
#

I do, yes

compact haven
#

Choco will you tell him how to run maven package with eclipse

#

I’ve got him to setup the maven with eclipse but idk how to build it properly

worldly ingot
#

Right click the project, Run As -> mvn build...

trail oriole
#

well i have an error

compact haven
#

we did that and it failed

trail oriole
worldly ingot
#

(the one with three dots)

compact haven
#

Said it didn’t specify a lifecycle goal (package)

#

oh the three dots

trail oriole
#

i did it

#

same error

worldly ingot
#

Yeah, once you do that it should bring up a wizard

#

In the "goals" text field, put "clean package" or "clean install"

trail oriole
#

?paste

undone axleBOT
tepid ore
#

What Maven import do I require to use CraftPlayer stuff and sheit like that?

trail oriole
#

oh

#

it worked

river oracle
#

?paste

undone axleBOT
trail oriole
#

but is this how you export the maven file or should I continue the old way of exporting

harsh totem
#

i'm trying to check what inventory is opened in an OnClick event and I get this error Non-static method 'getInventory()' cannot be referenced from a static context from this line if (Wands.getInventory().equals(event.getClickedInventory()))

harsh totem
crisp steeple
#

not static

river oracle
crisp steeple
#

(dont)

harsh totem
#

it will not work

#

its a class

crisp steeple
#

Wands.getInventory() isnt static

#

nor should it be

#

you need an instance of "wands"

eternal night
harsh totem
crisp steeple
#

well you need an instance of it

#

do you have one?

harsh totem
#

no

river oracle
eternal night
#

np

crisp steeple
#

kind of an issue

#

do you have an instance of its holder?

river oracle
harsh totem
crisp steeple
#

no

#

the actual inventory of it

#

where are you creating the inventory

harsh totem
#

import com.ytg667.myplugin.items.ItemManager;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

public class Wands implements InventoryHolder {

    private Inventory inv;

    public Wands() {
         this.inv = Bukkit.createInventory(this, 9, "pick a magical wand");
         init();
    }

    private void init(){
        ItemStack fireWand = ItemManager.fireWand;
        ItemStack dragonWand = ItemManager.dragonWand;
        ItemStack lightningWand = ItemManager.lightningWand;
        this.inv.addItem(fireWand);
        this.inv.addItem(dragonWand);
        this.inv.addItem(lightningWand);
    }



    @NotNull
    @Override
    public Inventory getInventory() {
        return inv;
    }
}
eternal night
crisp steeple
#

so where are you instancing this

harsh totem
crisp steeple
#

so save that to a field somewhere

#

and then check if that field is equal to the clicked inv

harsh totem
#

wdym save it to a field

crisp steeple
harsh totem
#

@crisp steeple can I just make this class public instead of private?

crisp steeple
#

what

#

why would it be a private class in the first place

harsh totem
#

i meant

#

the inv

#

the class is public

#

the inv is private

#

    private Inventory inv;```
crisp steeple
#

you already have a getter for it

#

i do not want to be rude but it doesnt really seem like you know what youre doing

#

i would probably look more into static vs non-static

harsh totem
#

Inventory inv = new Wands().getInventory();

#

like that?

#

and then compare to this?

#

@crisp steeple I just didn't understand what you meant im used to working in my language and not english

#

sorry

#

my bad

tepid ore
#

That will work yes

#

But the Inventory.equals() will not work

#

The way Inventory overrides .equals() is super stupid, you need to compare all items or an nbt tag stored in an item or something. Equals won't work

tawny otter
#

Any simple way of removing a certain amount of a item a player is holding?

tepid ore
tawny otter
#

yeah

elfin atlas
#

Hey is there a way to get the short uuid from a player?

crisp steeple
tepid ore
# tawny otter yeah

ItemStack held = p.getInventory().getItem(p.getInventory().getHeldItemSlot());
held.setAmount(held.getAmount() - Whatever);
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), held);

crisp steeple
#

my advice would be

tawny otter
#

Thanks = )

crisp steeple
#

make a listener inside the Wands class that checks if the clicked inventory is equal to this.inv

#

and then go from there

tepid ore
tawny otter
trail oriole
#

you have item.remove

tawny otter
#

righty

tawny otter
#

righty, thanks

undone axleBOT
delicate lynx
#

I believe there is a way to "get highest block"

arctic moth
#

cringe

tawny otter
#

1.18 Chunked Chunks is wack

snow onyx
#

Hi
Does anyone know about weird behaviour when trying to send a ProxiedPlayer a message with an url that contains a "#" character?
The ClickEvent seems to get removed from the message while anything else, like the HoverEvent, remains.

It always works, when trying to use any other url without a "#" character.
Problem is that I need to keep that character included inside the url.

TextComponent translateButton = new TextComponent("§9§lDeepL");
translateButton.setClickEvent(new ClickEvent(
    ClickEvent.Action.OPEN_URL,
    "https://www.deepl.com/en/translator#auto/en/hi"
));
translateButton.setHoverEvent(
    new HoverEvent(
        HoverEvent.Action.SHOW_TEXT,
        new Text("§7Translate")
    )
);
proxiedPlayer.sendMessage(translateButton);
tawny otter
#

Any way I could make Hostile mobs (in my case Creepers) passive while near a certain player?

eternal oxide
#

cancel its target event, unless you want to mess with AI

tawny otter
#

this looks like what I needed, thanks

sullen marlin
#

you can dump the json with ComponentSerializer to check what is being sent to the client

urban kernel
#

how can i use config in spigot

sullen marlin
#

what do you mean

urban kernel
#

i copied plugin.saveDefaultConfig(); but it throws this

#

also hi md_5

sullen marlin
#

you dont have a variable called plugin

#

if this is your main class just remove the plugin. part

#

otherwise, learn java

urban kernel
#

ok

#

yeah this is the main class

river oracle
#

Brih

#

?learnjava

undone axleBOT
quaint mantle
#

is getInventory.getItemInHand == getItemInHand

sullen marlin
#

yes

quaint mantle
#

what's the max size of a stringlist in yml

ivory sleet
#

iirc by yaml specification unlimited, but in java since lists only go to integer max value in terms of size that probably ought to be it

chrome beacon
#

2147483647 I'd assume

trail oriole
#

i've been reading the DI tutorial like 15 times now and i'm still confused on how to use it lmao

ivory sleet
#

Well you need to understand methods, constructors, classes and objects in Java before properly being able to understand dependency injection

#

and those are quite fundamental concepts in Java and generally speaking object orientation

sterile token
trail oriole
#

Well i started learning java with spigot, I believe I made a lot of progress in a week but I don't know the really fundamentals of java

sterile token
#

So its easy to code

trail oriole
#

Like i'm not sure how java works in depth, although the plugin i'm making for my server works well and I'm proud

sterile token
#

But you have to practise aswell

trail oriole
sterile token
#

Yeah

trail oriole
#

I thought spigot would be a great way to practice and stay productive

sterile token
#

Yeah

#

How old are you?

trail oriole
#

17

#

why ?

sterile token
#

Just to know

trail oriole
#

okay ?

sterile token
#

What do you think people?

trail oriole
#

about ?

agile marsh
#

got a vector question

#

what mathetmatical operations go into vector.angle(vector)?

ivory sleet
agile marsh
#

im trying to create a command that knocks people back in relation to their orientation from a source point and am getting weird stuff from the operation that I wasnt expecitng

ivory sleet
#

so this is an intermediate abstraction that abstracts over your SocketChannel implementation?

sterile token
#

That picture is how i will design the nio library

ivory sleet
#

I mean it looks testable at least

#

by that I mean mockable

sterile token
#

Like with my friends we want to get a better idea

ivory sleet
#

myeah I mean personally I wouldnt spend too much time designing

#

start by making a mediocre, intermediate, working-state design

#

then refactor

sterile token
#

Our goal is to design a simple NIO client(s)-server for sending/receiving packet

ivory sleet
#

yes

#

but make it work first

#

dont make the design first

sterile token
#

Yeah

#

Oh ok

ivory sleet
#

its useless if it doesnt work anyway

sterile token
#

Good point

ivory sleet
#

use whatever tools needed to get it to work first and foremost

#

then make the design clean and robust and decoupled and what not

#

good luck :3

sterile token
#

Allright thanks

#

Infact at the moment that design looks okay

#

Thanks that what we want to know

dry forum
#

whats the best way to get the logs directory?

sterile token
ivory sleet
#

isnt just the server directory resolved by logs or sth?

sterile token
dry forum
#

i need to get the /logs directory

#

specificaly latest.log

sterile token
#

If you making a plugin get plugin folder and then do "../"

#

I dont know if it works

dry forum
#

yeah but servers can have different paths

sterile token
dry forum
#

yeah thats the thing idk what relative path would work for this

#

theres .getInstance().getDataFolder().getAbsolutePath() but that doesnt help

sterile token
#

Get relative path from your plugin folder, and then do: "../../logs"

dry forum
#

its not in the same folder as the plugin folder

sterile token
#

Do you know what do "../"?

#

"../" goes one directory back to the current one

dry forum
#

oh

ivory sleet
#

I mean the plugins folder can be located somewhere completely else

dry forum
#

so itd be .getInstance().getDataFolder().getAbsolutePath() + "../../logs"?

sterile token
#

Yeah try

dry forum
#

ok ty

sterile token
#

Maybe doesnt work

#

But we can find a solution

dry forum
#

"../" does nothing it just shows up as "../" when i broacast the path

sterile token
#

Allright

#

So giveme 1 sec

#

I will do a test

ivory sleet
#

ofc

#

its a relative path

#

unless you absolutify it

sterile token
#

Oh

#

Im idiot

#

"../" only works with absolute path?

#

Im confused now

#

😂

#

@dry forum Try this


// One

File file = getServer().getWorldContainer();
sout(file.getPath());

// Two

sout(new File(".").getAbsolutePath())

dry forum
#

well i found a work around if it doesnt work not the best but :p "logs" + File.separator + "latest.log" ill try that 1 sec

sterile token
#

The second one, its the best solution

dry forum
#

1st solutions prints "."

2nd prints "/home/container/."

mortal hare
#

for (InventoryUIElement element : elements) { // NPE WILL NEVER HAPPEN SINCE SUPERCLASS CHECKS IT. IDE PLEASE SHUT UP. love this comment

ivory sleet
#

Jerelfa calling absolutify on it wont do anything

#

well

#

it will turn it into an abs path

#

but it doesnt help in your case

#

Path.of(".").resolve("logs").resolve("latest.log") would be enough tho

worldly ingot
#

Well, I mean, at that point just do Path.of("./logs/latest.log") lmao

mortal hare
#

./ is for relative path right?

ivory sleet
#

mye probably fine in most cases, tho idk how well the of factory method handles (different) path separator chars

#

file format?

#

I mean you could opt for sth similar to how spigot does it (idk if its directly inherited from mojang) but ye

#

I mean for logging, spigot dumps the latest log in a normal text file, and then it compresses log files that aren't the absolute latest

#

or am I misunderstanding your perhaps

ivory flume
#

Question 🙂

#

when writing a command

#

how does the blockpos args get passed

#

one by one in the array? or just one object in the array and I have to parse it

#

im assumming one by one

#

Like, does this work (in onCommand)

#
            int x = Integer.parseInt(args[0]);
            int y = Integer.parseInt(args[1]);
            int z = Integer.parseInt(args[2]);
crisp steeple
#

yes

#

provided that they are actually numbers of course

ivory flume
#

❤️ thank you

sterile token
#

How to group each element of an array by 2 using lambda because the common for (int a; bla bla) looks really ugly?

ivory flume
#

Isn't there a java fasutil class for that

#

BooleanIntImmutablePair

#

or Mutable pair if you want that

#

now, I have another question 🙂

#

is there a way to run a task in milliseconds

ivory sleet
#

technically yes

#

if you schedule a task in lets say a scheduled executor service

#

and then perhaps sync the task on the server thread on execution

ivory flume
#

oh all right, is ther a special way to do that or just a synchronized block

ivory sleet
#

no no synchronized wont help you

#

but like

ivory flume
#

oh not the bukkit scheduler

#

i get it ig thanks

#

i've mostly messed with mods and we don't generally have to mess this much with threads, just simple server/client checks in world class

ivory sleet
#
ScheduledExecutorService service = Exeucutors.newScheduledThreadPool(1,new ThreadFactoryBuilder().setDaemon(true).build());

service.schedule(() -> {
  Bukkit.getScheduler().runTask(plugin,() -> {
    //TODO
  });
},10,TimeUnit.MILLISECONDS);
#

ofc it wont be 100% accurate

#

but thats as accurate as you can get

ivory flume
#

😅 virtual threads where are you

ivory sleet
ivory flume
#

Is there any way you recommend in testing plugins?

ivory sleet
#

testing in terms of ?

ivory flume
#

setup a server in your pc and shoving clients on your pc into it

ivory sleet
#

like unit testing or just a dev environment?

#

oh

ivory flume
#

all local

#

can you do it in dev environment?

#

👀

ivory sleet
#

myeah well there's paperweight userdev

#

altho not for spigot

#

else its pretty simple to write a task for that using gradle

ivory flume
#

my server is using maven sadly 😔

#

i'll convince them to switch eventually

ivory sleet
#

yeah gradle is at its best significantly more configurable w/o 3rd party plugins

sterile token
ivory flume
#

Why not just a map?

civic dagger
#
new BukkitRunnable() {

    @Override
    public void run() {
        coolDownMap.remove(event.getPlayer().getName(), event.getPlayer().getUniqueId());
        event.getPlayer().sendMessage("removed you from cooldown list");
    }
}.runTaskLater(Main.plugin,15L);

can someone please say wtf is wrong with this? it runs coolDownMap.remove instantly when i get a instance of runnable instead of 15 ticks later

crisp steeple
#

and not the sendmessage?

civic dagger
#

exactly

crisp steeple
#

seems like the runnable isnt the cause then

civic dagger
#

it is

#

i have a sout which prints the coolDownMap

noble lantern
#

no errors saying player is null?

civic dagger
#

no

noble lantern
#

what event is that

crisp steeple
#

well it seems pretty unlikely that you have a javaagent or something executing that line specifically for no reason

#

pretty sure the only other alternative is that you arent using the map right

civic dagger
#

if i remove the runnable that sout prints the map with my player inside it

noble lantern
#

tbf

#

why are you running a removal from a map 15 tickets later

sterile token
civic dagger
#

did you even read the mapname?

crisp steeple
noble lantern
#

ah i see mb

#

i prefer checking time in milli's but ig that works

crisp steeple
#

have no other clue what else it could be then

sterile token
noble lantern
#

also

#

doesnt runTaskLater have an option to take in 2 arguments

civic dagger
#

yes im sure

noble lantern
#

a delay and the time to actually run it later

civic dagger
#

the runnable is fine

#

idk really know why

#

it calls sendmessage later

#

so its fine

crisp steeple
#

i think you just have to be removing it or not placing it somewhere else

#

it doesnt make any sense otherwise

civic dagger
#

no i checked that

#

there is no .remove method

crisp steeple
#

if you want to be completely sure just make a method called test1 and test2

#

put the remove from hashmap in test1 and the sendmessage in test2

civic dagger
#

there is another way

crisp steeple
#

then put bukkit.broadcastmessage(system.currenttimemillis) infront of both

#

and see if theyre different

civic dagger
#

print the map after getting a instance

#

and i did it

#

map is empty

crisp steeple
#

what does that prove

civic dagger
#

before i get a instance of runnable there is already a value inside the map

#

and after getting a instance map is empty

crisp steeple
#

i think you should try what i suggested and see what it says

#

dont know exactly what you're doing since you havent sent code but it doesnt seem possible to happen at all with what you're describing

civic dagger
#

wait

#

CURSED

#

now it dosent remove

crisp steeple
#

what

ivory flume
#

how would I set a block inside a command

#

idk how to get a world

noble lantern
civic dagger
#

is this check good?

if(!(coolDownMap.containsValue(event.getPlayer().getUniqueId())))

also its fine right?

coolDownMap.put(event.getPlayer().getName(), event.getPlayer().getUniqueId());
noble lantern
#

player.getLocation().getWorld()

ivory flume
#

oh that has a world reference? nice!

crisp steeple
#

im not sure why you would put their name and their uuid in a map

#

seems pretty redundant

civic dagger
#

name to show the list uuid to check

noble lantern
civic dagger
#

the problem is it removes

#

but too early

#

like instant

crisp steeple
#

can you show the full thing of whats happening

noble lantern
#

you would have to be overwriting the key somewhere or deleting it somewhere else

civic dagger
#

you get a headache if you see it

#

but ok

crisp steeple
#

i still recommend you try what i suggested because the current scenario you're describing is not possible (without very strange javaagents and such)

civic dagger
#

bruh char limit

crisp steeple
#

?paste

undone axleBOT
ivory flume
#

oh wait @noble lantern what if the command is meant to be run in command block

civic dagger
#

xD

noble lantern
late sonnet
civic dagger
#

ignore the souts and sendmessages

#

they're just for debug

ivory flume
#

😔

noble lantern
#

there could possibly be an event that executes when a command block is run

#

google like CommandBlockEvent spigot and something should show up

crisp steeple
#

ok im just gonna have to assume it makes it up to here because i cannot read all of the stuff before that

noble lantern
crisp steeple
noble lantern
#

and check if its block data/state is a CommandBlock from there should be able to tell what command its executing

crisp steeple
#

doesnt seem like 15 to me

civic dagger
#

i changed it to 1

crisp steeple
#

why

civic dagger
#

like 10 seconds before i send the code

#

debug

#

also that if statement is fine

#

and the reason you cant read stuff before that is its some fancy math

crisp steeple
#

or that you didnt use continue statements

#

but anyways

ivory flume
#

I want to keep the command inside the command class for now i think, i'll see other options

crisp steeple
#

it isnt a problem with the runnable for sure

#

we know that much

civic dagger
#

alright im gonna do a legendry thing

noble lantern
crisp steeple
noble lantern
civic dagger
#

that every developer did atleast 1 time when facing a cursed code

#

REWRITE

noble lantern
#
if (!something)
    continue/return;
#

instead of

#

kamehameha style

crisp steeple
#

im not even sure whats going on here

#

why are you sending a message to something that isnt a player

#

i dont think the cows need to know they were frozen by an admin

ivory flume
#

burchard i figured it out.
sender instanceof BlockCommandSender block
and it has it 😄

ivory flume
#

i mean that it has block#getWorld that i can use

civic dagger
#

ik

noble lantern
#

never heard of BlockCommandSender lmfao

civic dagger
#

they supposed to be players

#

but i dont have anyone to test

#

so changed it to !()

ivory flume
#

i googled it and it appeared in a 2012 forum

noble lantern
#

ill have to add that to my api now to handle block command senders damn

crisp steeple
#

ok

ivory flume
#

just ignore them smh

noble lantern
#

no because i have handles

#

eg onPlayerSend onConsoleSend

crisp steeple
#

makes sense i guess

noble lantern
#

now ill need onBlockSend

#

indeed it does

#

tbf i forget command blocks are in the game 80% of the time

ivory flume
#

if you are running a server its a good way to hook into plugins as staff can easily handle them

civic dagger
#

@crisp steeple

#

now i feel its really cursed

#

everything's fine without runnable

crisp steeple
#

well then dont use it

#

problem solved

civic dagger
#

well then the player going to use that wand and his whole chat will be spammed

#

or worse tps drop

crisp steeple
#

seems like everything isnt fine then

#

how about you just remake your cooldown since this clearly isnt working

civic dagger
#

i just did that

#

its working

#

after 1 use of wand you cant use it again

crisp steeple
#

so its fine now

civic dagger
#

now i just have to remove the cooldown

crisp steeple
#

ok then

civic dagger
#

omg

#

bruh

#

you dont believe

#

but the thing hapening is

#

idk actually it just seems cursed again

#

quick question, why event is pink and have a pink underline in intellij?

earnest forum
#

its a keyword

crisp steeple
#

no it isnt

civic dagger
#

i just checked

#

its fine

#

just a warning

earnest forum
#

oh its underline

#

nvm

civic dagger
#

so

earnest forum
#

i thought it was highlighted

civic dagger
#

no

#

so it stops spamming

#

but at the same time allows

#

you cant just hold right click with wand and fill the chat

#

so that little if statement is not doing its job

#

bruh

#

bruh

#

i just got it

#

PlayerInteractEvent is getting called so fast that coolDownMap.put dosent have time to put user inside a map

crisp steeple
#

i dont think thats it my guy

civic dagger
#

99% its that

crisp steeple
#

that is not how threading works

civic dagger
#

well it is almost

crisp steeple
#

its just not

civic dagger
#

you can have multiple of same event running at the same time

earnest forum
#

thats not how that works

civic dagger
#

sooo

#

you're saying if my method take like 5 min to execute completely other events wait in a queue?

crisp steeple
#

yes

#

your server would stop by then

#

but yeah

civic dagger
#

HM

#

so if a event take like 12 second to run then server print a warning message of server not responding ?

earnest forum
#

yea

#

it would say like

crisp steeple
#

believe the timeout is 20 seconds

earnest forum
#

server is .... ticks behind

crisp steeple
#

but pretty much

civic dagger
#

1 last try

#

lemme see

#

alright

#

now more chance of my idea

#

because i put the map.put line on top

#

and now i can only spam 3 times

#

before it was 7

#

lemme see if my method can crash the server

#

ill just put a 20k for-loop

crisp steeple
#

probably wont

civic dagger
#

why?

crisp steeple
#

20k is not a lot in terms of computing

civic dagger
#

then ill make it 200k

#

alright 1m

crisp steeple
#

putting your entire method into it?

civic dagger
#

no

crisp steeple
#

why do you want to crash your server

#

obviously you can with just a while(true)

civic dagger
#

uh i forgot about that one

#

i use while like every 10 years

noble lantern
#

pink underline is when somethings running async doesnt it, while the variable was declared sync

civic dagger
#

i dont think so

#

why should event be sync

crisp steeple
#

why would it not

#

do you know how horrible it would be if events were async

noble lantern
#

theres only a handful that are actually async

crisp steeple
#

well yeah

noble lantern
#

like PlayerAsyncLogin or some shit like that and the CHatAsync one

crisp steeple
#

the ones marked as that obv

civic dagger
#

i mean event parameter

#

not the event itself lol

crisp steeple
#

hover over it and see what it says

civic dagger
#

nothing

#

no error

#

just basic things about the variable

#

like any other one

#

but i guess that stackoverflow one is correct

#

alright

#

successfully crashed my own server

crisp steeple
#

good for you

civic dagger
#

alright i gave up

#

not going to paste another 300 lines from stackoverflow just to make a cooldown for a private plugin

noble lantern
#

why use runnables for cooldowns anyways

civic dagger
#

idk maybe because i dont know anything else?

crisp steeple
#

system.cureenttimemillis

vagrant stratus
#

What would be the best way of handling inventories for configs 🤔
Just serializing them or is there something better 👀

noble lantern
#

check the time milli the user used the thing at then check it against the current milli time when you need to check if theyre in cooldown

civic dagger
#

HM

vagrant stratus
#

Pretty sure I have a cooldown thing actually, I don't feel like going through a lot of code to find it though

crisp steeple
civic dagger
#

hope dosent use too much cpu

crisp steeple
#

works pretty well

dusk flicker
#

if you wanted to store the itemstacks those already are serialized in bukkit

noble lantern
dusk flicker
#

so you dont have to do anything weird

crisp steeple
#

well if you're using yml yeah

#

im just storing them somewhere

civic dagger
vagrant stratus
noble lantern
#

yes, your opening a task for every player who uses that item

vagrant stratus
#

@dusk flicker
would it just be

        FileConfiguration config;
        config.set("a", new ItemStack(Material.STONE));

?

civic dagger
#

good point but that item SHOULD get in cooldown after first use

dusk flicker
#

dont ask me about configs

vagrant stratus
#

oh, rip

#

lol

dusk flicker
#

i will fuck up your entire project more than likely

#

lmao

vagrant stratus
#

RIP

#

erwrijeiowrjioe

civic dagger
#

lmao

vagrant stratus
#

?tryandsee

undone axleBOT
vagrant stratus
#

I'll just do that lol

dusk flicker
#

shit I missed an opportunity to TAS optic

crisp steeple
#
HashMap<UUID, Long> cooldowns = new HashMap<>();
        
// on use
if(System.currentTimeMillis() - cooldowns.getOrDefault(playeruuid, 0L) < cooldowntimemillis) return;
cooldowns.put(playeruuid, System.currentTimeMillis());
#

@civic dagger

vagrant stratus
#

inb4 it breaks lol

vagrant stratus
#

@dusk flicker
a:
==: org.bukkit.inventory.ItemStack
v: 2975
type: STONE

#

seems like it works lol

dusk flicker
#

yeah

civic dagger
#

only work when you spam like 30 times

#

and it blocks like 5 of them

earnest forum
#

whats ur full code

crisp steeple
#

what are you setting the cooldown time to

civic dagger
#

3000

#

tested with 300 too

#

ok

#

exactly every 5 use

#

it block 1

#

better than nothing i guess

crisp steeple
#

can you send the full code

#

i dont think you're doing it correctly

civic dagger
#
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if(event.getItem() != null) {
                if(event.getItem().getItemMeta().equals(PlayerFreezerItemStack.getFreezeWandItemStack().getItemMeta())) {
                    if(System.currentTimeMillis() - coolDownsMap.getOrDefault(event.getPlayer().getUniqueId(), 0L) < 500) {
                        event.getPlayer().sendMessage("cooldowncheck");
                        return;
                    }
                    coolDownsMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis());
                    if(event.getPlayer().hasPermission("playerfreezer.wand")) {
#

its the start

earnest forum
#

serializes inventories to base64 and back

civic dagger
#

after that all is same as before

#

alright

#

fixed it

#

almost

#

at first you can spam like 10 then you can spam 3 each time

earnest forum
#

what exactly isnt working

civic dagger
#

the if statement

earnest forum
#

you have 3 if statements

#

which one

civic dagger
#

if(System.currentTimeMillis() - coolDownsMap.getOrDefault(event.getPlayer().getUniqueId(), 0L) < 500)

earnest forum
#

whats not working about it

civic dagger
#

it blocks it

earnest forum
#

is it not cooling down properly?

civic dagger
#

it blocks it but not completely

#

each time

earnest forum
#

blocks what

civic dagger
#

you can at max use the item 5 times

earnest forum
#

the message

civic dagger
#

wait

#

its like this:

#
you used the item
you used the item
you used the item
you used the item
you used the item
blocked for 500ms
you used the item
you used the item
you used the item
you used the item
you used the item
#

something like this

#

each time you can use the item for multiple times

earnest forum
#

check if the player actually has a cooldown

#

if theyre inside of the map

#

because you're just resetting the cooldown

#

every time they click

civic dagger
#

hm

earnest forum
#
if(coolDownsMap.contains(event.getPlayer().getUniqueId(){
  if(System.currentTimeMillis() - coolDownsMap.getOrDefault(event.getPlayer().getUniqueId(), 0L) < 500) {
    event.getPlayer().sendMessage("cooldowncheck");
   return;
  }
}
civic dagger
#

i put it inside a else

#

lemme test

earnest forum
#

what..?

#

what else

civic dagger
#

inside a else that belongs to the same if statement

earnest forum
#

show the code

civic dagger
#

nothing changed

#

just as expected

earnest forum
#

show the code

civic dagger
#
if(System.currentTimeMillis() - coolDownsMap.getOrDefault(event.getPlayer().getUniqueId(), 0L) < 1000) {
                        event.getPlayer().sendMessage("cooldowncheck");
                        return;
                    } else {
                        coolDownsMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis());
                    }
#

sorry for bad indent, discord...

earnest forum
#

you do realise

#

that code

#

is LITERALLY the exact same code as before

civic dagger
#

yes i do

earnest forum
#

reworded

civic dagger
#

thats why i said "just as expected"

earnest forum
#

ok

#

now add my change

#

check if the player is inside the cooldown map

#

but remember to put the coolDownsMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis()); outside of that

civic dagger
#

replace if(System.currentTimeMillis() - coolDownsMap.getOrDefault(event.getPlayer().getUniqueId(), 0L) < 1000) with your change?

earnest forum
#

no

#

put that above it

quaint mantle
#

no dont

quaint mantle
#

why would he need to check contains

#

thats just an unnecessary query

earnest forum
#

because theyre just resetting the cooldown every click

#

when they spam it

civic dagger
#

yeah because its getOrDefault

#

no its not resseting

#

because if statement blocks it

earnest forum
#

wait im reading this wrong

hard lake
#

a plugin that always spawns in the lobby, if it runs out the server exits
what is the name of the plugin?

#

HELP

#

PLS

#

PLS

#

HELP ME

quaint mantle
#

?kick @hard lake ask normally

undone axleBOT
#

Done. That felt good.

civic dagger
#

wow

quaint mantle
#

what

civic dagger
#

now he have to wait 10 mins lol

quaint mantle
#

no he didnt

#

he rejoind and spammed again

civic dagger
#

so what you say i should do @quaint mantle

#

bruh so that 10 min is for first join