#help-development

1 messages Β· Page 1487 of 1

sharp bough
#

is this true?
4 Answers. Is there a theoretical limit for the number of key entries that can be stored in a HashMap or does it purely depend on the heapmemory available ? Looking at the documentation of that class, I would say that the theoretical limit is Integer. MAX_VALUE (231-1 = 2147483647) elements

#

to the question
is there a limit of how many keys a hashmap can have?

#

cuz thats 2.1B keys

dense goblet
#

if I addItem() to a full inventory, will it drop on the ground?

dense goblet
#

is there a built-in way to handle that

sharp bough
#

you want to drop it?

dense goblet
#

yes

sharp bough
#

spawn the item in the location of the player

dense goblet
#

I need to know if its full or not

sharp bough
#

where item = itemstack that could not be added

sharp bough
#

smth like that

#

Inventory.firstEmpty()

dense goblet
#

hm that wont work for stacking items

sharp bough
#

try
Inventory.firstEmpty()
catch exception
spawn item

sharp bough
dense goblet
#

if I have 1 wood in every slot and want to add 1 wood, it will not find an empty slot for it to go

#

even tho it should stack with the other woods

#

there is first(ItemStack) though maybe thats correct

weak mauve
#

any solutions?

dense goblet
#

actually no docs say its an exact match hm

sharp bough
#

first()

#

Returns the first slot in the inventory containing an ItemStack with the given stack.

#

firstEmpty()
Returns the first empty Slot.

#

ig you could use that

dense goblet
#

yea neither of them will work for me unfortunately

sharp bough
#

what are you trying to do

dense goblet
#

I will have to iterate it manually and do my own stackable test

#

I want to add an item to a storage block or drop on the ground if it doesnt fit

sharp bough
#

storage block?

#

so its not a player?

granite stirrup
dense goblet
#

like a chest etc

quaint mantle
#

addItem returns a HashMap<Integer, ItemStack> containing the items that could not be added

quaint mantle
dense goblet
#

ohhh useful

#

ty fefo

granite stirrup
#

Does it not

quaint mantle
granite stirrup
#

I thought it does

dense goblet
#

what does the integer represent?

#

oh addItem takes many items so ig its just the index

granite stirrup
#

Index I think

quaint mantle
#

mhm

granite stirrup
#

Or id

dense goblet
#

no more IDs πŸ™‚

quaint mantle
granite stirrup
#

IDs still exist lol

quaint mantle
#

they don't

dense goblet
#

yea you get the reference so index is kinda redundant

quaint mantle
#

well not numeric IDs

dense goblet
#

IDs only exist for world saving etc

quaint mantle
#

namespaced keys

granite stirrup
#

But I looked into material class and it referred blocks and items with IDs

quaint mantle
#

that's a bukkit thing

#

vanilla does not use them anymore

#

they are non-existent

#

are you depending on the spigot api or the bukkit api?

#

depend on spigot api

#

?

#

are you using maven/gradle or just stuffing the jars into ij?

#

yeah i strongly suggest you learn how to use maven or gradle, manage dependencies, build your applications/libraries, shade (bundle) libraries, publish to repos, and automate a billion other things (you don't necessarily have to do all of these, but the primary use you'll give them is manage dependencies such as spigot-api and other libraries)
ig this will suffice since a lot of people find maven easier to learn before gradle https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/

granite stirrup
#

Try maven see if it works then

#

If maven works which it probs will then the way u are adding Ur spigot API jar must be wrong

quaint mantle
cold tartan
#

i cant figure out why this doesn't work, what i want to happen is for an item that is unbreakable to not be able to be moved, but the events aren't even called at all (the prints dont work).

    @EventHandler
    public void onMoveItem(InventoryMoveItemEvent event) {
        if (event.getItem().getItemMeta().isUnbreakable()) event.setCancelled(true);
        System.out.println("1");
    }

    @EventHandler
    public void onPickupItem(InventoryPickupItemEvent event) {
        if (event.getItem().getItemStack().getItemMeta().isUnbreakable()) event.setCancelled(true);
        System.out.println("2");
    }

    @EventHandler
    public void onDragItem(InventoryDragEvent event) {
        if (event.getCursor().getItemMeta().isUnbreakable()) event.setCancelled(true);
        System.out.println("3");
    }
granite stirrup
#

Ur buildpath must be wrong but use maven

#

Just get maven omg

near swan
#

it's going to work with maven or gradle

granite stirrup
#

Maven is easier

near swan
#

the bungee chat api is a transitive dep of spigot api

#

a proper build tool will resolve it for you

granite stirrup
#

And also u can get the latest jar of 1.16.3

#

Without having to use buildtools or anything

#

Or getting it online by urself

#

Bro please

#

Use maven

granite stirrup
#

Oh wait misread

granite stirrup
cold tartan
#

hmmmmm, dang

quaint mantle
#

did.. you register the listener?

cold tartan
#

yeah

quaint mantle
#

i mean the sole fact that "the events aren't even called at all" tells me the listener is not being registered either

cold tartan
#

i mean other events in the same class do work

#

wait

#

does it work for the player inventory?

#

or just for like chest inventories?

quaint mantle
#

should work for the player inv too

cold tartan
#

hmmmmmmmmm

quaint mantle
#

do you also have an InventoryClickEvent listener..?

cold tartan
#

wdym?

#

like a duplicate class?

#

*method

quaint mantle
#

duplicate?

#

InventoryMoveItemEvent is not for clicking items around

cold tartan
#

oh is it not?

quaint mantle
#

no

cold tartan
#

i just want to detect when an item is changed from its slot

#

i mean none of them are being called

quaint mantle
#

there are half a million events regarding inventories

#

add a handler for InventoryClickEvent, then test it

cold tartan
#

hmmmmmm

#

this doesnt work either:

@EventHandler
    public void onInventoryInteract(InventoryInteractEvent event) {
        System.out.println("1");
    }
quaint mantle
#

keep in mind there are two items involved in that event, cursor and current

#

because InventoryInteractEvent is in and of itself not an event that is called

cold tartan
#

wdym

quaint mantle
#

sub-classes of it are

cold tartan
#

oh so its like Entity to LivingEntity

quaint mantle
#

e.g. InventoryClickEvent extends InventoryInteractEvent, you can listen to InventoryClickEvent, you can't listen to InventoryInteractEvent

cold tartan
#

ok

quaint mantle
#

you can only listen to events that have a HandlerList

#

and sub-classes of them

#

InventoryClickEvent has a HandlerList, InventoryInteractEvent does not

cold tartan
#

ok, lemme test this out

#

oh sweet

#

this is perfect

#

it works

sharp bough
#

is there some api to handle hoppers and their data like item transfering, the amount of items, name of inv etc

granite stirrup
#

Don't think so

vagrant stratus
#

does the jar contain said plugin.yml?

#

Check the compiled jar

#

Thought so

sharp bough
#

why does event.getsource.getcontents return the itemstack with amount - 1? in inv move item event, single items are null and itemstacks are the amount - 1

granite stirrup
#

U haven't got a plugin.yml

#

Put it in src/main/resources

vagrant stratus
#

Could probably be cleaned up but this is what i use @high prawn It'll fix your issue

#

oop, forgot to remove the ```'s

granite stirrup
#

Is it in src/main/resources/

vagrant stratus
#

It's possible they're just not including it in the maven build process

#

which the above does πŸ‘€

granite stirrup
#

I don't in the pom

#

It works fine

vagrant stratus
#

Not explicitly, i mean like you're not using a plugin or something that takes it into account πŸ‘€

#

unless things are different πŸ€”

#

πŸ€·β€β™‚οΈ

granite stirrup
#

I think that tutorial thinks u know basic maven

vagrant stratus
#

^

granite stirrup
#

It probs is for beginners but u probs need to know where to put Ur files in maven

#

Np πŸ‘

#

Lol

#

It should work

#

Cuz anything from the chat stuff work for ne

vale cradle
#

Does anybody know what exactly happens when I add an item to an inventory? Because I try to get the item at the index I just added it and its not equal != at the item I just added

dusty herald
# vale cradle

I would try comparing ItemStacks another way, like ItemStack#isSimilar(ItemStack)

vale cradle
#

I need the exact item ;p

dusty herald
#

This method is the same as equals, but does not consider stack size (amount).

vale cradle
#

I'd just like to know what happens underground, so I'd have a better idea of what to do next

vale cradle
#

==

quaint mantle
#

use .equals()

#

item stacks are cloned left right and center when adding and getting them from inventories

vale cradle
#

EXACT

dusty herald
#

then use .equals if you don't care about stack size

#

.equals is exact..?

#

what are you on about

quaint mantle
#

because of that

vale cradle
#

I see

dusty herald
#

just use .equals if you don't care about the item stack size, it will only return true if the item is the same as the one you're comparing against

quaint mantle
vale cradle
#

I'm just limit testing the items to see if there's a way to implement a sort of metadata to them

quaint mantle
#

you should use PDC to identify the uniqueness of your items

vale cradle
#

I don't want to store primitives or those stuff

#

I'm looking further

#

Like, attaching Consumers, Suppliers, Functions or Executors

#

Those kind of functional stuff

quaint mantle
#

mate this isn't haskell

vale cradle
#

And I wouldn't like to use serializable functions ;p

vale cradle
#

I'm pretty near actually

quaint mantle
#

what do consumers and executors have to do with itemstack equality..?

dusty herald
#

you don't want to use serializable things?

vale cradle
#

The fact that won't be applied to another item with the same qualities

dusty herald
#

😦 what did they ever do to you

quaint mantle
#

if you want to identify an "EXACT" itemstack, you tag it with PDC

#

then check for the tag

#

if it's there, it's THE item

vale cradle
#

For example, I'd be able to abstract the Item metadata with IdentityMaps

vale cradle
#

Might work

quaint mantle
#

sure

#

nobody tell tommy that itemstacks are serializable

vale cradle
#

I know they are

vagrant stratus
#

you just did though

quaint mantle
#

add the UUID to the PDC as a String, then check if it's there, get it etc

young knoll
#

Or make a custom pdc type for UUIDs that saves the most and least significant bits

#

I assume that’s a bit smaller

vale cradle
#

I use NBT Api ;p

quaint mantle
#

yeah ig an array of the two longs will be better

ivory glacier
#

How can I convert a TextComponent to string?

#

I want to do an equality check

quaint mantle
#

toPlainText

somber hull
#
    public ChestGui createGui() {
        ChestGui gui = new ChestGui(3, "Navigator");

        gui.setOnGlobalClick(event -> event.setCancelled(true));

        OutlinePane background = new OutlinePane(0, 0, 9, 3, Priority.LOWEST);
        background.addItem(new GuiItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
        background.setRepeat(true);

        gui.addPane(background);

        OutlinePane navigationPane = new OutlinePane(3, 1, 3, 1);

        ItemStack shop = new ItemStack(Material.CHEST);
        ItemMeta shopMeta = shop.getItemMeta();
        shopMeta.setDisplayName("Shop");
        shop.setItemMeta(shopMeta);

        navigationPane.addItem(new GuiItem(shop, event -> {
            // navigate to the shop
        }));

        ItemStack beacon = new ItemStack(Material.BEACON);
        ItemMeta beaconMeta = beacon.getItemMeta();
        beaconMeta.setDisplayName("Spawn");
        beacon.setItemMeta(beaconMeta);

        navigationPane.addItem(new GuiItem(beacon, event -> {
            // navigate to spawn
        }));

        ItemStack bed = new ItemStack(Material.RED_BED);
        ItemMeta bedMeta = bed.getItemMeta();
        bedMeta.setDisplayName("Home");
        bed.setItemMeta(bedMeta);

        navigationPane.addItem(new GuiItem(bed, event -> {
        }));

        gui.addPane(navigationPane);

        return gui;

    }

I am using inventory framework. Should i be running this every time someone executes the admin gui command? or is there a way to create it, and then give it to a person later

#

It just creates a gui

#

createGui().show(plr);

#

im running this everytime they run the gui command

quaint mantle
#

I mean you can create it once in a field and then call show as needed

somber hull
#

Would that be better, or not that big of a deal?

quaint mantle
#

better sure

somber hull
#

alright

#

thanks

vagrant stratus
#

Field definitely, you're not calling all of that code each time iirc

mint frigate
#

how do i start development on plugin are there any good tutorial videos you would recommend?

somber hull
#

he does a lot of shit things

#

like bad practices

#

but hes the best tutorials i have found

#

Just ask questions here, and people will make fun of you for making mistakes. But hey, thats how you learn

vagrant stratus
#

I'd do a series myself, rn isn't the best time though qwq

somber hull
#

@mint frigate

#

a LOT of bad practices, but its as basic as your gonna get

quaint mantle
#

a LOT of bad practices
yyep, that's what I've heard as well lol

#

never seen any of their vids tho

mint frigate
#

thnx

vagrant stratus
#

looking actually πŸ˜‚

quaint mantle
#

I personally suggest the official Bukkit fandom

somber hull
#

Yea but theres no video tutorials

#

right

quaint mantle
#

videos are meh

somber hull
#

well

#

some people learn different ways

quaint mantle
#

they tend to take a shit ton of effort and outdate pretty quickly

somber hull
#

i fucking hate reading

quaint mantle
somber hull
#

meh

#

doesnt mean i dont do it

#

i just hate doing it

#

im reading a big fat java book rn

#

i hate it

vagrant stratus
somber hull
#

dude, i am still pretty new to spigot development

#

but i would love to help someone who doesnt know anything

#

lol

#

most of the time when i go onto forums, or here. Its questions i would ask, not beginner stuff

#

oh no, you guys are typing for a long time

quaint mantle
#

sad reality is that, way more often than not, "i want to learn spigot" means "i know jack about java", because if you do understand how to make programs in java (not necessarily proficient, but you are sure you know your stuff) then "learning spigot" is not really that hard other than for a few odd ends here and there

somber hull
#

sad reality is that, way more often than not, "i want to learn spigot" means "i know jack about java"
this was me

#

but yea

vagrant stratus
# somber hull https://www.youtube.com/watch?v=r4W4drYdb4Q

Looking at the first 3 episodes, there's not really anything "bad" per se, however there could be some improvements
e.g. in Ep3 It would be better done this way

if(!isNum(args[0])){
    player.sendMessage(ChatColor.RED + "Usage: /launch <number-value>");
    return true;
}
player.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Zooooom!");
player.setVelocity(player.getLocation().getDirection().multiply(Integer.parseInt(args[0])).setY(2));
quaint mantle
#

I'm all in for learning Spigot as you learn Java, but learning spigot without knowing how to Java is a horrible idea

vagrant stratus
#

The way it's done isn't bad but it could still be improved

somber hull
#

yea i knew nothing, didnt know what an API was, didnt know what an IDE was. Didnt know litterally anything about java lol

#

But i bought a java book, and asked dumb questions here

#

and boom im smart now

quaint mantle
#

I started on spigot w/ little to no knowledge on Java (coming from C++, somewhat similar, very different nonetheless, but I did have previous knowledge about OOP in general) and my arrogant, self-confident ass made the worst code to ever exist :^)

somber hull
#

lol, i think we all did (am currently for me)

vagrant stratus
#

I'm sure my code could be improved massively as well tbh πŸ‘€

somber hull
#

can i send you one of my classes, and you guys just ridicule me for whatever is bad

#

?paste

queen dragonBOT
somber hull
#

its a command one

vagrant stratus
#

Don't need the else statement

somber hull
#

i thought so, (pretty sure i got that from codedred)

vagrant stratus
#
if (!(sender instanceof Player)) {
            sender.sendMessage("Only Players can access this command!");
            return true;
        } else {

This one

somber hull
#

oh

vagrant stratus
#

That's not needed

somber hull
#

right

#

because of the return

quaint mantle
#

why tf did i use to name my command handler "CommanderKeen" πŸ˜‚

somber hull
#

lol

vagrant stratus
#

Formatting the code would of been nice too πŸ‘€

somber hull
#

i did lol

#

eclipse you can do ctrl+shift+f

#

?

vagrant stratus
#

-<

somber hull
#

looks fine on my end lol

somber hull
#

aight, i gotta go design a gui

#

unless you wanna help

vagrant stratus
#

Can't really see anything else wrong with the code, and fuck gui's

somber hull
#

lol

#

by design a gui, i mean make it look nice

#

im using an easy gui creator

#

basically

#

Inventory Framework

dense goblet
quaint mantle
#

full error?

dense goblet
somber hull
#

woah

dense goblet
eternal oxide
#

VanillaUtils.java:95

#

Which line is this?

dense goblet
#

cant paste images sorry

#
result.add(CastingUtils.confidentCast(bukkitStream.readObject())); //read serialisable (size times)
vagrant stratus
#

Was about to say, could of just sent the line as text πŸ˜›

somber hull
#

is there a reason not to use color.TranslateAlternateColorCodes

dense goblet
#

yea but then the rest of the context is gone

eternal oxide
#

Break up the line and see what is null. Is it the object?

dense goblet
#

yea its readObject()

quaint mantle
#

the only thing null in here is w/e Bukkit is trying to read though, deep inside readObject

dense goblet
#

but that should just be whatever was written by bukkit in serialiseToBytes

quaint mantle
#

it's literally commented with NPE lmao

eternal oxide
#

Do all the objects you are saving correctly implement ConfigurationSerializable, and they are registered?

dense goblet
#

all the elements I pass to the serialisation function just do this:

    @Override
    public Map<String, Object> serialize() {
        return stack.serialize();
    }

is this the problem?

#

oh I had no clue we had to register them lol

eternal oxide
#

Yep, have to register the classes.

somber hull
#

ChatColor.translateAltern...*

dense goblet
eternal night
#

I mean, the world has slowly been moving away from the legacy strings but if you wanna just use strings translateAlternateColorCodes is fine

quaint mantle
#

components pog

somber hull
#

Alright

quaint mantle
vale cradle
quaint mantle
vale cradle
#

+1

dense goblet
#

ye I mean registerClass still needs to be called somewhere, and ideally each class would register itself but idk if there's a smart way to make that happen

vagrant stratus
somber hull
#

Hex is poggers

vagrant stratus
#

B

somber hull
#

idk how to use it in mc tho

dusty herald
#

with magic

eternal oxide
somber hull
#

alright i need opinions

vagrant stratus
# somber hull idk how to use it in mc tho

private static int SERVER_VERSION = -1;

public static int getVersion() {
if (SERVER_VERSION != -1) {
return SERVER_VERSION;
}
SERVER_VERSION = Integer.parseInt(Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]
.replace("1_", "").replaceAll("_R\d", "").replaceAll("v", ""));
return SERVER_VERSION;
}

public static String colorize(String string) {
if (getVersion() >= 16) {
Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
for (Matcher matcher = pattern.matcher(string); matcher.find(); matcher = pattern.matcher(string)) {
String color = string.substring(matcher.start(), matcher.end());
string = string.replace(color, net.md_5.bungee.api.ChatColor.of(color) + "");
}
string = ChatColor.translateAlternateColorCodes('&', string);
return string;
}
return ChatColor.translateAlternateColorCodes('&', string);
}

quaint mantle
#

yeeeeeeeee

dense goblet
#

hm that feels kinda hacky, maybe I should use a different serialiser

somber hull
#

wow

#

ok

quaint mantle
somber hull
#

hmmm

#

ChatColor.Magic isnt working

dense goblet
#

always weary of using static but if it doesnt break stuff then sure πŸ™‚

#

is all static code executed before main runs?

#

or the first time the class gets referenced

somber hull
#

is this look good?

#

uh

quaint mantle
somber hull
#

i sent a imgur link

#

A

#

its multiple photos

quaint mantle
somber hull
quaint mantle
#

and it won't attach the embed

somber hull
#

oh

#

thank you

#

<😳>

#

wait

quaint mantle
#

\😳

somber hull
#

i did that right

#

...

#

howe

quaint mantle
#

\😳

somber hull
#

right

#

im dumb

#

\😳

#

does look good?

#

im gonna make the NBT ITEMS look obfuscated

#

with the .magic

#

its just not working rn

#

i think i put it out of order

quaint mantle
#

is this like an in-game gui builder?

somber hull
#

no

#

its a settings changer

dense goblet
#

is it loot crates

somber hull
#

so you dont have to use the config

somber hull
dense goblet
#

good lol

somber hull
quaint mantle
#

ig it's good lol

vagrant stratus
#

loot crates when?

#

Want stone tools? Pay $20

somber hull
#

im not changing it

#

eyyyy

#

made it work

#

ill probably make that not bold

dense goblet
#

ayy got recipes working in my multiblocks, thanks for the help πŸ™‚

granite stirrup
#

Should I sleep

eternal oxide
#

You can sleep when you are dead

granite stirrup
#

Oh

#

Its 7:28 rn

#

I already feel dead tired

eternal oxide
#

UK then

granite stirrup
#

Ye

wide aspen
#

which one is easier to set up bungeecord or velocity?

granite stirrup
#

?8ball should I sleep

queen dragonBOT
#

Yes

granite stirrup
#

I think they all setup the same tho?

wide aspen
#

aight

granite stirrup
#

Um btw little tip if Ur having more than 2k players u probs should have multiple bungees and hook them up to together

#

To balance the load

#

I tested 1 waterful bungee and used 2k fake players and the bungee crashed

#

XD

#

It had 10gb ram to

#

Well my friend tested

#

And it was his bungee lol

outer crane
#

it only crashed at 2k?

granite stirrup
#

Ye

outer crane
#

dang thats bad

#

ive seen proxies handle that easily at like 2gb of ram

granite stirrup
#

I mean normal bungeecoord does worse

granite stirrup
#

Or multiple

#

Lol

outer crane
#

one

#

velocity

granite stirrup
#

Lol

#

I mean the users where like fake players and all but also they where joining pretty fast probs that's why it crashed

outer crane
#

ig that could be a cause

granite stirrup
#

It was like atleast 1 player per like 2 ticks

outer crane
#

alright that makes sense in that case

#

but

#

does bungee have ticks?

#

or just are you using that to measure

granite stirrup
#

Ticks is a time in mc lol

outer crane
#

alright ur just using that as a measurment

granite stirrup
#

Every like 0.1 seconds I think a new fake player was like joining

#

Cuz 1 MC tick in seconds is 0.05 seconds

eternal oxide
#

1 tick = 1/20th of a second

granite stirrup
#

Ye

outer crane
#

yeah ik n stuff

granite stirrup
#

Online it says 0.05

#

(n*(1/20)) < calculates ticks in seconds n = ticks

#

I think that's how u do it

#

Lol

opal juniper
#

Assuming it is running at 20tps

granite stirrup
#

Eh

#

I mean

#

Yeah I guess but technically it converts ticks to seconds

#

It isn't meant to accurately give it in seconds depending on tps

outer crane
#

servers ideally should be at 20tps, this equation assumes the ideal

granite stirrup
#

Will this work (ticks*(1/20)+(20-tps)))? To get ticks to seconds by tps

#

Probs not

#

XD

lucid bane
#

why 12.2 spigot playerDeathEvent doesnt have getKiller?

granite stirrup
#

event.getEntity().getKiller()? Or
event.getPlayer().getKiller()?

lucid bane
#

??

vagrant stratus
#

That's how you get the people who killed the player

lucid bane
#

what does getPlayer() return?

granite stirrup
#

Yeah I think in newer version they added .getKiller to the event I think but in older version u have to do this

granite stirrup
lucid bane
#

I cant understand why player instance has getKiller() sry

granite stirrup
#

It does

granite stirrup
#

That's why they have a getKiller

#

Actually its livingentity that has it but player extends livingentity so it inherets getKiller

lucid bane
#

oh

granite stirrup
#

It returns a player XD

#

My phone is lagging

#

Oof it sent my message 3 times

#

XD

lucid bane
#

thx

dusty herald
#

why can't there be a fucking castable trapchest

#

😭

bitter briar
#

When will version 1.17 come out for spigot is it the same day as vanilla?

vagrant stratus
#

?eta

queen dragonBOT
#

There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.

vagrant stratus
#

?1.17

queen dragonBOT
#

There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.

granite stirrup
queen dragonBOT
#

There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.

dusty herald
#

πŸ™‚

burnt current
#

Hey! I would like to know if there is a certain item somewhere in the player's inventory. I know that this can be done somehow with inventory.contents, but I don't know how exactly I could apply this. Can anyone help me with this by chance

eternal oxide
#

getContents().contains

#

or Inventory#contains

burnt current
#

so i don't need a For loop? i just need to enter this line?

#

how would the line have to look exactly then? I would write the following: player.getInventory().getContents().contains
and where would I have to specify the item that is being searched for?

granite stirrup
#

if it exists or not

burnt current
#

how do you mean that?

#

so I would like to query if a player has 4 iron bars in inventory but don't know how to do that

granite stirrup
#

u have to do java if (player.getInventory().getContents().contains(itemstack)) { ur code }

burnt current
#

when I do this I get the error for contains:
cannot resolve method 'contains' in 'Itemstack'

granite stirrup
#

i dont mean put itemstack

#

i mean replace it with a valid itemstack

burnt current
#

I have done that. I have written in there Material.IRON_BARS

granite stirrup
#

oh wait try changing it to new ItemStack(Material.IRON_BARS)

#

?

quaint mantle
#

what a disaster this is

granite stirrup
#

idk

solemn glade
#

i like coding

wispy fossil
quaint mantle
#

just reading this channel

wispy fossil
#

lol what specifically i just got here

burnt current
quaint mantle
#

this guy that somehow doesn't seem to understand the inventory contains bit

granite stirrup
#

i never really messed with checking inventory contents

#

i dont do inventory stuff

wispy fossil
#

lmao people are new let em learn
aint calling it a "disaster" gonna help

burnt current
quaint mantle
#
if(e.getPlayer().getInventory().contains(Material.DIRT)){
  dude has dirt

}```
#

@burnt current

burnt current
#

ok i will try

#

oh I just see, I already saved a player as a variable: Player player = (Player) event.getWhoClicked();
I pass the variable event at the beginning of the method as InventoryClickEvent.

granite stirrup
#

Β―_(ツ)_/Β―

quaint mantle
#

then just use player.getInventory()...

#

just basic java really

burnt current
#

ok now it seems to work. I thought you needed getContents for that but apparently you don't need that after all.

#

and then how could I still check if the player has at least 4 iron bars in the inventory in that case?

grave rune
#

Question:
Can I use TextComponent in Minecraft 1.8? I have the problem that the function "player.spigot().sendMessage(myTextComponent)" does not seem to exist in Minecraft 1.8.

quaint mantle
sullen marlin
#

yes, textcomponents existed then

#

make sure you have spigot-api as your jar

burnt current
quaint mantle
#

spigot check if player has x amount of y

sullen marlin
#

'spigot inventory contains at least item' second result gives the exact method for me

burnt current
#

Ok thanks for your help

sullen marlin
#

as does first

quaint mantle
#

yeah I don't see why you wouldn't look it up before asking here

candid galleon
#

πŸ‘€

grave rune
# sullen marlin make sure you have spigot-api as your jar

Just to be sure:

If I understood you correctly, the spigot API should be included in my jar. Wouldn't this mean that the plugin will be very large in terms of memory? So from a few kbs to several MB? Or have I misunderstood something there?

sullen marlin
#

no I mean check your IDE is referring to spigot-api

candid galleon
#

spigot-api as your jar is for the IDE

#

you don't compile it with the jar, the plugin uses the server's jar at runtime

sullen marlin
#

the method you want existed as far back as 1.7

granite stirrup
#

wtf are u using a server jar for a plugin u have to use the spigot-api jar

#

lol

#

oh man ```default ClassName() {

}``` isnt a allowed ;-;
candid galleon
#

default is for interfaces

granite stirrup
#

ik

candid galleon
#

:?

quaint mantle
#

?:

candid galleon
#

what would a default class be then

granite stirrup
#

i wanted to see if i can have a constructor in a interface

#

lol

eternal night
#

πŸ‘€

candid galleon
#

ah

#

you could use an abstract class instead

#

though im sure you know that

granite stirrup
#

i do

covert bluff
#

I restored IntelliJ idea's settings to its default, but then all my recent projects tab were wiped out, i tried opening them and it ended up like this

#

nvm i cant send pics here

ivory sleet
#

Verify fingerguns

vagrant stratus
#

or don't, just won't be able to self the pics

covert bluff
#

help!

#

i restored intellij's idea's settings to defaulted options!! but then all my recent projects were wiped out!!!!! i tried opening them in my plugisn folder and it ends up like this !!!

#

it is saying no symbol for kitselector etc.e tc. !!

#

but when i crete spigot plugin using inecraft devleopment plugon it works fine

daring sierra
#

a bit too red but very cool ngl

shy wolf
#

hello!, can whitelist msg have multi lines?

cold tartan
#

you would probably have to remake the whitelist command if you wanted that

#

as far as i know

shy wolf
#

oof

cold tartan
#

i mean not remake it

#

but make a seperate command

#

wait no

#

i guess you could use the onCommand event

#

then send messages w/ that

shy wolf
#

is ther a finishd plugin?

cold tartan
#

idk

shy wolf
#

oof

#

and how to make a custom placehoder in holo?

quaint mantle
shy wolf
#

ok ty

dusk flicker
#

That formst will cause errors if someone posts a %

#

And also follow naming conventions for vars please

#

Image about it with a link to that thread

quaint mantle
#

is there a way to set pathfinder goals in spigot? or is it only NMS

granite stirrup
#

yes but u cant change it if they already have one

#

atleast i dont think so

granite stirrup
quaint mantle
#

thanks

hollow arch
#

Heyo - Seem like if I hit one of my hotbar keys like 1 to put items into an inventory such as atest, the InventoryMoveItemEvent doesn't get fired

eternal oxide
#

InventoryClickEvent

hollow arch
#

Yeah, there I also do ```java
if (e.getClickedInventory() != null && e.getClickedInventory().getType() == InventoryType.PLAYER) {
e.setCancelled(true);
return;
}

eternal oxide
#

check the InventoryAction in the click event

hollow arch
#

Doesn't get fired

#

Ah wait

cold tartan
#

Could someone help me with potions. The potion that this gives just doesn't have levitation:

public static ItemStack leviPot = new ItemStack(Material.POTION, 1);

public static void init() {
  leviPot = setLeviPot(leviPot);
}

public static ItemStack setLeviPot(ItemStack i) {
  PotionMeta m = (PotionMeta) i.getItemMeta();
  m.addCustomEffect(new PotionEffect(PotionEffectType.LEVITATION, 200, 4), true);
  return i;
}
#

oh wait

#

shoot

#

forgot to set item meta

#

srry

ivory sleet
#

πŸ₯΄

woeful crescent
#

Also, does anyone know how to immediately summon a firework explosion

late void
#

i wanted to know if there was a way to amplify slime block bounce each time

#

is it possible even with spigot?

rugged topaz
#
        org.bukkit.scoreboard.Scoreboard score = p.getScoreboard();
        Objective health = score.getObjective("showhealth") == null ? score.registerNewObjective("showhealth", "health") : score.getObjective("showhealth");
        if (health.getDisplaySlot() != DisplaySlot.BELOW_NAME) health.setDisplaySlot(DisplaySlot.BELOW_NAME);
        health.setDisplayName(replaceChatColors("&c❀"));

        p.setScoreboard(score);

is there a solution to this also applying the health effect to NPC's (of those with metadata 'NPC' if that helps)?

#

it's not meant to, it's only supposed to apply it to players\

eternal oxide
#

Have you tried adding the NPC's to a different scoreboard?

#

If that doesn;t do it then it likely can;t be done as NPCs are just fake players

granite stirrup
rugged topaz
#

so i'm not sure if i can control that

rugged topaz
#

so i just feel dumb

#

for still having this issue

rugged topaz
#

bc i don't wanna use another plugin

granite stirrup
#

yes

#

why?

granite stirrup
#

lol

woeful crescent
rugged topaz
#

welp!

eternal oxide
slim kernel
#

If I cancel the task of a scheduler does it immediately stop or finish everything till it is at the bottom again and stops there then?

quaint mantle
#

Hi there! Metadata won't clear. What I should do to fix it

p.removeMetadata("camouflageCD", plugin);
            p.sendMessage("===========");
            p.sendMessage(p.getMetadata("camouflageCD").get(0).asBoolean() + "");
            p.sendMessage(p.getMetadata("camouflageCD") + "");
            p.sendMessage(!Utils.hasMetadata(p, "camouflageCD")+ "");
            p.sendMessage(Utils.hasMetadata(p, "camouflageCD")+ "");
red apex
#

Anybody know how can i disable going left and right?

torn shuttle
quaint mantle
torn shuttle
#

I still don't know if those are 100% accurate

#

these things are documented in a weird way

quaint mantle
#

well you could compare the movement against the player's yaw

#

trigonometry :)))))

vale magnet
#

we broke up with my friend and we will transfer the plugins we bought to a different account can anyone help me about this please

sage swift
#

no

torn shuttle
#

friendship ended with friend, now other friend is my new friend

quaint mantle
quaint mantle
torn shuttle
#

$5 says there is an entity.hasMetadata already

quaint mantle
#

k so?

#

why don't you use that instead

#

removeMetadata doesn't works

#

not in Utils.hasMetadata() problem

#

why are you relying on the super unreliable toString implementation that can not even do what you expect

#

why don't you just, y'know, use Entity#hasMetadata

#

as you are supposed to

torn shuttle
#

using the API? we don't do that around these parts

quaint mantle
#

then why don't you use it

#

as you are supposed to

quaint mantle
#

why do you insist that it doesn't work when getMetadata returns false

#

how are you so certain

#

plugins have been using this metadata API for literally ages, I really doubt it's broken

#

if (p.hasMetadata("camouflageCD")) returns true

#
p.removeMetadata("camouflageCD", plugin);
        if (p.hasMetadata("camouflageCD")) {
            p.sendMessage(String.valueOf(p.getMetadata("camouflageCD")));
            return;
        }
#

is there a method to figure out if the player is riding a horse?

#

I can't find it

quaint mantle
#

thanks

#

@quaint mantle what version are you running?

wraith mauve
#

i have some problem in sethome and it say only admin can sethome is there any good plugin that i can use?

quaint mantle
#

what do you plan on doing exactly?

sage swift
#

en pee see when

quaint mantle
#

can you share the rest of the code?

lyric grove
#

i get this error

sage swift
#

implements Listener, not extends Event lol

#

extends Event is for when you make an event of your own

lyric grove
#

oh xd

sage swift
#

you shouldnt need to cast the class to Listener if it's done correctly

outer crane
#

How do you guys debug stuff? I find that adding a new print to the plugin then recompiling, etc is a bit annoying, is there like a debugger for spigot or smthn?

lyric grove
sage swift
#

that's extends

lyric grove
#

oh lmao

sage swift
#

not what i said to do :)

quaint mantle
hybrid spoke
outer crane
#

thats some 10000iq thinking there

vagrant stratus
quaint mantle
hybrid spoke
vagrant stratus
quaint mantle
vagrant stratus
#

If you don't do anything about it then you can say you didn't know

hybrid spoke
#

oh yeah and ask people here to fix it

#

5head

quaint mantle
outer crane
quaint mantle
#

what do you mean "store custom stats"? can't you do it in a List or a Map or something?

quaint mantle
# outer crane How do you guys debug stuff? I find that adding a new print to the plugin then r...

well you can attach a jvm debugger to the running java instance if you really want to have a deep look into things (field/variable values, current stack frame, etc), but keep in mind you'd need to crank up the watchdog time or whatever in spigot.yml so it doesn't kill the server if you're paused on a breakpoint hhhhhhhh
idk how old these are but
https://www.spigotmc.org/wiki/intellij-debug-your-plugin/
https://www.spigotmc.org/wiki/eclipse-debug-your-plugin/

#

what kind of stats, why do you need a player for this

fickle helm
quaint mantle
#

the Bukkit API isn't really meant to be extended with the exception of commands and events

vagrant stratus
#
public class CustomPlayer {

   private Player player;

   public CustomPlayer(Player player){
     this.player = player;
   }
   
   public Player getPlayer(){
       return player;
   }
}

._.

quaint mantle
#

good ol' composition

hybrid spoke
vagrant stratus
hybrid spoke
#

UUID

quaint mantle
#

WeakReference tho

chrome beacon
#

I mean storing the player is fine just make sure you weak refrence it

vagrant stratus
#

True, the getPlayer would then have to be changed to a Bukkit method then.
I'm assuming @quaint mantle here is gonna use said field as well, don't wanna be calling getPlayer all the time

untold rover
#

Hey we are using Packets to remove players from the tablist, we implemented a fix which adds the player back for a duration of 30 ticks when sending the named_entity_spawn packet to the player, it works fine BUT most of the times the players are steves or alex's is there a way to fix that?

storm monolith
#

how can I stop a parrot from randomly flying? I tried to override its pathgoal but without success.

vital wadi
#

hey i need a plaguin to add /shop 1.16.1

#

Bisect hosting

storm monolith
red apex
#

how do i change entity speed?

slim kernel
#

If I cancel the task of a scheduler does it immediately stop or finish everything till it is at the bottom again and stops there then?

vital wadi
#

i need help here

quaint mantle
#

cancelling a task tells the scheduler to not run it again, it doesn't exit the function

slim kernel
#

okay thank you and a other question: is it normal that my PlayerInteractEvent gets called 2 times everytime?

quaint mantle
slim kernel
#

yes

quaint mantle
#

mhm

#

once for each hand

slim kernel
#
if (event.getHand().equals(EquipmentSlot.HAND)) {

But I did this already

#

how can I prevent it from being called 2 times?

quaint mantle
#

well uh... what's the rest of the code?

quaint mantle
#

people, sharing code helps us help you πŸ‘

slim kernel
quaint mantle
#

Use a paste site please

#

!paste

#

smh

slim kernel
#

okay

#

like github

quaint mantle
#

I wonder if they will ever plan on adding the file preview thing on mobile too

slim kernel
tardy delta
#

why not putting two times HashMap?

slim kernel
#

ping me then pls thank you

daring sierra
#

emily talking here?

#

how is this

quaint mantle
quaint mantle
tardy delta
#

oh

quaint mantle
slim kernel
#

oh okay thank you alot

fleet wigeon
#

.ETA

daring sierra
queen dragonBOT
#

There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.

coral sparrow
#
if (player.getBrain.contains("anything")){
    player.graduate;
   }
shut field
coral sparrow
granite stirrup
#

im tired

shut field
red apex
coral sparrow
shut field
#

I had to do LivingEntity

red apex
quaint mantle
#

Neato

red apex
#

How can i change nbt tag to spawn horse with saddle

shut field
young knoll
#

πŸ₯„

shut field
#

apparently you might need it to be set tamed first

red apex
#

and how do i do that? 😢

shut field
#

horse.setTamed(true);

red apex
#

thanks

young knoll
#

The javadocs will tell you all of this

shut field
#

or you can just look it up

#

There is already a forum that did that exact thing-> on spawn equip saddle on horse

young knoll
#

That’s what the javadocs are for

shut field
young knoll
#

You look things up

shut field
young knoll
#

On the javadocs

sacred crest
#

does anyone know how to change the render distance for just the nether? could i make a plugin to do that or would i have to run the nether on a seperate bungeecord server

young knoll
#

I would use something like view distance tweaks

#

It’s a nice plugin to have in general

wraith rapids
#

or use paper

#

i think spigot.yml lets you change the view distance on a per-world basis as well

vernal basalt
#

ok so i made an api which works but im looking at it and want to make a full rewrite of it

#

before i would log everything so when the player logged off i could still check things like armor and health

#

now im just going to check the nbt

#

does the nbt update all the time though?

granite stirrup
#

does anyone know the code for clearing the java console that works for all oses?

vernal basalt
#

like would i need to check if the player is online and only check the nbt in order to get a live stat

loud swift
#

Hey guys, I'm new to async programming and have run into a dilema, maybe you can help me:

  • On chunk load, I Asynchronously load information pertaining some blocks into a memory map.

  • I also have a block break event listener, that gets & uses information from that memory map.

  • How can i make sure the asynchronous task for the chunk is done before getting/using that information inside the block break listener?

Should i keep a list of unfinished chunks, add to that on chunk load, and remove with a callback when the info loading is done?

wraith rapids
#

instead of holding a Map<Key, Data> as your "memory map"

#

hold a Map<Key, CompletableFuture<Data>>

dense remnant
#

Hello! I am currently writing on a minecraft plugin that connects a discord bot to the server.

I am trying to add a json file for easy configs but it gets overwritten on every reload/restart.

My onEnable calls this:

config = new Config(new File("plugins/ntstreakyDiscord/ranks.json"));

and this is the Config class:

wraith rapids
#

when the chunk loads, you create a new completable future, and put it in the map

#

you then fire the logic that will get the actual data, that is, complete the completable future, on a different thread

#

when you need to access this data, first get the future

#

map.get(key)

#

then, on the future, call future.get()

#

if the future is complete, the data is returned immediately

dense remnant
#
public class Config {

    private File file;
    private JSONObject json;
    private JSONParser parser = new JSONParser();
    private HashMap<String, Object> defaults = new HashMap<String, Object>();

    public Config(File file) {
        this.file = file;
        reload();
    }

    @SuppressWarnings("unchecked")
    public void reload() {
        try {

            if (!file.exists()) {
                PrintWriter pw = new PrintWriter(file, "UTF-8");
                pw.print("{");
                pw.print("}");
                pw.flush();
                pw.close();
            }
            json = (JSONObject) parser.parse(new InputStreamReader(new FileInputStream(file), "UTF-8"));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

  




wraith rapids
#

if the future is not yet complete, the data will be returned when the future is completed

dense remnant
#
  @SuppressWarnings("unchecked")
    public boolean save() {
        try {
            JSONObject toSave = new JSONObject();

            for (String s : defaults.keySet()) {
                Object o = defaults.get(s);
                if (o instanceof String) {
                    toSave.put(s, getString(s));
                } else if (o instanceof Double) {
                    toSave.put(s, getDouble(s));
                } else if (o instanceof Integer) {
                    toSave.put(s, getInteger(s));
                } else if (o instanceof JSONObject) {
                    toSave.put(s, getObject(s));
                } else if (o instanceof JSONArray) {
                    toSave.put(s, getArray(s));
                }
            }

            TreeMap<String, Object> treeMap = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
            treeMap.putAll(toSave);

            Gson g = new GsonBuilder().setPrettyPrinting().create();
            String prettyJsonString = g.toJson(treeMap);

            FileWriter fw = new FileWriter(file);
            fw.write(prettyJsonString);
            fw.flush();
            fw.close();

            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
    public void addRankRole(String rolename, String roleid, String permission){
        JSONObject obj = new JSONObject();
        obj.put("Role_ID",roleid);
        obj.put("Permission",permission);
        defaults.put(rolename,obj);
        save();
        getRanks();
    }

    public String getRawData(String key) {
        return json.containsKey(key) ? json.get(key).toString()
                : (defaults.containsKey(key) ? defaults.get(key).toString() : key);
    }

    public String getString(String key) {
        return ChatColor.translateAlternateColorCodes('&', getRawData(key));
    }


  


dense remnant
#
  public boolean getBoolean(String key) {
        return Boolean.valueOf(getRawData(key));
    }

    public double getDouble(String key) {
        try {
            return Double.parseDouble(getRawData(key));
        } catch (Exception ex) {
        }
        return -1;
    }

    public double getInteger(String key) {
        try {
            return Integer.parseInt(getRawData(key));
        } catch (Exception ex) {
        }
        return -1;
    }

    public JSONObject getObject(String key) {
        return json.containsKey(key) ? (JSONObject) json.get(key)
                : (defaults.containsKey(key) ? (JSONObject) defaults.get(key) : new JSONObject());
    }

    public JSONArray getArray(String key) {
        return json.containsKey(key) ? (JSONArray) json.get(key)
                : (defaults.containsKey(key) ? (JSONArray) defaults.get(key) : new JSONArray());
    }


    public Object[] getRanks(){
        return json.keySet().toArray();
    }

}
dense remnant
loud swift
#

Awesome, i think i got it @wraith rapids

wraith rapids
#

which means that the main thread will be blocking on this method until the data is ready

opal juniper
dense remnant
#

I read that I would need to do it in another way

loud swift
#

Yeah, but that pretty much can't be prevented

wraith rapids
#

which is undesirable, but there's not really any way around it

loud swift
#

if you need the data you need the data

opal juniper
#

Just include it in the jar

loud swift
#

right

dense remnant
#

Okay thanks, I will try after I ate

loud swift
#

Thanks a lot that really helped

wraith rapids
#

next time don't spam the fuck out of the channel

#

use a pastebin

dense remnant
#

Okay thanks

dense remnant
quaint mantle
#

How to remove players from online players?

loud swift
#

Kick the player?

quaint mantle
#

Nope, vanish

loud swift
#

You probably need to send a packet

#

simulating that you kicked the player

wraith rapids
#

Player::hidePlayer

loud swift
#

oh lol thats way simpler

quaint mantle
#

Hideplayer is oudated

#

Or not?

wraith rapids
#

might be paper only, dunno

chilly summit
#

Hey guys, I know this is the SpigotMC server, but since they're so similar to Spigot plugins, would it be okay to ask for help on a BungeeCord plugin? If not, where should I ask?

loud swift
#

Maybe entity.setVisible(false)?

quaint mantle
#

Okay, thanks

wraith rapids
#

bungee is developed by the same people pretty much

opal juniper
wraith rapids
#

see the channel description

chilly summit
#

Ah didn't see that

#

okay then

#

Here's my main class, it does print that onEnable ran when I start my BungeeCord server, but when I kick myself, it prints nothing. Is there something I'm doing wrong?

package net.GlitchedBlox.GlitchedBloxBungeeCore;

import java.util.concurrent.TimeUnit;

import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ServerKickEvent;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;

public class Main extends Plugin {
    private Main plugin;
    @Override
    public void onEnable() {
        this.plugin = this;
        System.out.println("onEnable ran!");
    }
    @EventHandler
    public void onKick(final ServerKickEvent event) {
        System.out.println("Player kicked!");
        final ProxiedPlayer p = event.getPlayer();
        if (event.getPlayer().getServer() != null) {
            System.out.println("Player in server!");
            if (!event.getPlayer().getServer().getInfo().getName().equalsIgnoreCase("hub")) {
                System.out.println("Player not in hub!");
                event.setCancelled(true);
                plugin.getProxy().getScheduler().schedule(plugin, new Runnable() {
                    @Override
                    public void run() {
                        System.out.println("Player moving code called!");
                        p.connect(plugin.getProxy().getServerInfo("hub"));
                        p.sendMessage(new TextComponent(ChatColor.AQUA + "Oh no! You've been kicked from " + ChatColor.GOLD + event.getKickedFrom() + ChatColor.AQUA + " for " + ChatColor.DARK_RED + event.getKickReasonComponent() + ChatColor.AQUA + "!"));
                    }
                }, 1l, TimeUnit.MICROSECONDS);
            }
        }
    }
}
wraith rapids
#

i don't know how the bungee event bus works, but on bukkit you'd have to have your class implement Listener, and register it with the plugin manager

chilly summit
#

hmm let me check if adding "implements Listener" fixes it

#

totally forgot about that

#

Nope

#

doesn't do anything.

#

Still doesn't say "Player kicked!"

wraith rapids
#

google "event listener bungeecord tutorial"

loud swift
sharp bough
#

how could i manage hoppers? for example set the amount of items moving unsing the move item event or set the destination to another location or hopper

#

some API

#

or premade methods

loud swift
sharp bough
#

its called itemMovementEvent

loud swift
#

There you go, use that one πŸ™‚

#

You probably have to get the target container, cancel the event

sharp bough
#

yes, i already tried but it doesnt really thave that many things to use

loud swift
#

and then change the inventory of that container

sharp bough
#

theres no such thing as setDestination or a way to set the amount of items moving to X in that location

loud swift
sharp bough
#

so the only way would be to cancel the event

#

take the item moving

#

take the item stack in the hopper

#

remove it

#

and add it to another location

#

but theres a bunch of problems with that logic

#

i already tried and its not ment to do that

#

so for example doing that i takes the amount - 1

#

i assume its becausue theres already 1 moving

#

so if you only have 1 it returns null

#

unless theres another one of those

#

so i was wondering how do people do plugins using this

wraith rapids
#

InventoryMoveItemEvent::setItem

sharp bough
#

like this one

dense remnant
# opal juniper Yep

What should I take as path?
using "plugins/ntstreakyDiscord/ranks.json" doesnt work
The embedded resource 'plugins/ntstreakyDiscord/ranks.json' cannot be found in plugins\ntstreakyDiscord-1.0-shaded.jar

sharp bough
wraith rapids
#

you should use the path it is at

#

if the file in your jar is at /mystuff/myfile.txt, then use mystuff/myfile.txt

dense remnant
#

Uhh but the file is not inside my jar

coral sparrow
#

isnt it inside resourcess or smt?

dense remnant
opal juniper
wraith rapids
#

either include it in the jar and extract it, or write to disc programmatically

chilly summit
#

assuming my Listener is in my main class

wraith rapids
#

this, this

chilly summit
#

Actually it would be

getProxy().getPluginManager().registerListener(this, this);

right?

wraith rapids
#

if you are running this in the main class and your event handlers are on the main class, then this, this

chilly summit
#

oh you said what I was thinking lol

loud swift
#

one this is your plugin instance the other one the event listener

#

You should really separate your plugin in classes though

#

specially if you are new to programming

#

otherwise you won't understand what you are doing

#

and debugging and code changes will be a nightmare

dense remnant
#

Well it didnt change anything for me.. yes I wrote it to disk programmatically but after reload it is getting overwritten like before

wraith rapids
#

well, if don't overwrite it if it's already there

dense remnant
weary summit
#

Why is my git appearing as "Buildtools"? How to revert this?

#

(sorry, I don't understand much about git) (and if that's offtopic pls tell me)

chrome beacon
#

Yeah that happens you will have to login again

opal juniper
#

How do i 'get' the main thread in order to call an event

chrome beacon
#

BukkitRunnable

opal juniper
#

Oke

chilly summit
# loud swift You should really separate your plugin in classes though

It works! Thank you!

And to this note, I'm not new to plugin development or java, I just have never made a listener. I only didn't separate it because I literally have 35 lines of code, just putting a player in the lobby when they are kicked from another server with a few other cases. I have my main plugins on my Spigot servers super separated, each command even has it's own class.

wraith rapids
#

don't use a bukkit runnable for that

#

use the bukkit scheduler

#

less overhead, more readable, doesn't shit up your project with anonymous local classes

opal juniper
#

yeye, thats what i am doing ^^

chilly summit
#

I'd like to get the bungee API kick reason, but

event.getKickReason()

is depreciated, and

event.getKickReasonComponent()

doesn't have a method to get the kick reason. How should I get it?

#

I can't find any other funtions

wraith rapids
#

one returns a string

#

the other returns a component

#

a component is just a fancy string with formatting and shit

chilly summit
#

Yes, but I don't know how to get the string from the component.

wraith rapids
#

toString or use the legacy/plaintext serializer

chilly summit
#

would I just be able to use .toString()

#

got why do I keep typing the same thing people say right after them

wraith rapids
#

i don't know how toString is implemented

#

but you could try it

quaint mantle
#

it'll probably do something like TextComponent[blah blah]

chilly summit
#

yeah

quaint mantle
#

you should use BaseComponent#toPlainText to get the contents

chilly summit
#

okay

chilly summit
ivory sleet
#

Fefo helpful cojo

quaint mantle
#

Fefo
sadge

shy wolf
#

help plzzzzzzzzzzz

#

i have a loc meneger i have multi loc's

#

and some of the loc's world are null

#

how to make it not null

shy wolf
shy wolf
dense remnant
#

Okay I fixed my Json Bug I think

ivory sleet
dense remnant
#

Now I have another Problem...

Config conf = Main.getInstance().config;
        conf.reload();
        String[] ranks = objectToStringArray(conf.getRanks());
        System.out.println("hi");
        ResultSet rs = sendStatement("SELECT * FROM DiscordTable");
        System.out.println(ranks.length);
        for (int i = 0; i < ranks.length; i++) {
            System.out.println(i);
            JSONObject ob = conf.getObject(ranks[i]);
            System.out.println(ranks[i]);
            try {
                System.out.println(ob.get("Permission").toString()+"\n"+rs.getString(1));
                if(Bukkit.getServer().getPlayer(rs.getString(1)).hasPermission(ob.get("Permission").toString()));
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }

This Code should throw 14 times println if the ranks.length is 4 right?

[20:24:29 INFO]: hi [20:24:29 INFO]: 4 [20:24:29 INFO]: 0 [20:24:29 INFO]: Discord.RSS [20:24:29 INFO]: rss e0a683b3-10f7-4190-b48a-2cb4cb6b0631
But it only executes the for loop once...

shy wolf
#

i need helpeeeeeeppppppppppppppppp

chilly summit
#

I'm trying to help you

shy wolf
#

ok

chilly summit
#

why doesn't it extend or implement anything?

shy wolf
#

what

chilly summit
#

oh nvm

#

I thought it was a command sorry

shy wolf
#

it's ok

tardy delta
#

what does this do?

return Utils.color(Main.getConfiguration().getString("messages.no-permission"));
chilly summit
shy wolf
#
                    Location event = LocationManeger.getLocation("event");
                    player.teleport(event);```
#

this is how i get loc

ivory sleet
chilly summit
tardy delta
#

but that .getString() what does that do?

#

where does it gets it from?

dense remnant
chilly summit
#

The configuration file

chilly summit
ivory sleet
tardy delta
#

ow yea a see

dense remnant
chilly summit
dense remnant
#

Yes I know

chilly summit
ivory sleet
#

myeah

shy wolf
#

help?

ivory sleet
#

What was the issue bud?

shy wolf
chilly summit
#

I can't figure out without all of your classes, I don't even know what code the error is coming from

shy wolf
#

sooo

#

what class do u need?*

ivory sleet
#

Your call Bukkit#getWorld returns null precisely due to no world with the given name being present

quaint mantle
#

that's a weird path tho...

shy wolf
#

lobby-name-world: TrestiaMap
event-name-world: TrestiaMap

quaint mantle
#

you should be able to simple config.set(path, location) and config.getLocation(path)

quaint mantle
chilly summit
#

The path shouldn't have the colon in it

#

oh my gosh