#development

1 messages · Page 10 of 1

dense drift
#

Also, I believe is not a good idea to use Player objects as keys, I would use UUIDs

olive dirge
#
onlinePlayerSaves.put(p, resultSet);
                p.sendMessage(onlinePlayerSaves.toString());
#

I have this on join

#

Then I access it when breaking a block

sterile hinge
#

well, show your code

#

not just a few lines without any context

olive dirge
sterile hinge
#

ffs if you want help, show your code. Full classes, no weird pasting together

olive dirge
sterile hinge
#

are you inserting entries asynchronously?

#

also why are you always creating anonymous classes when using hashmaps?

merry knoll
#

I was going to ask that

#

and if you are using concurrent access

#

use concurrenthashmap

#

instead

edgy lintel
#

Yes use concurrenthashmap

olive dirge
#

uhh im not putting anything into the db yet

#

but let me switch over to concurrent

#

yeah still seem to be getting empty map

merry knoll
#

remove the {} at the end

olive dirge
#

that didnt work

#

nvm i'm dumb, I created two instances

warm steppe
#

d;jdk List#of

uneven lanternBOT
#
static List<E> of()```
Description:

Returns an unmodifiable list containing zero elements. See Unmodifiable Lists for details.

Since:

9

Returns:

an empty List

dense drift
#

Thats a map though

mystic gull
#

Hello, it will cause lags if i check every seconds all players if they are on water ?

merry knoll
#

why use another scheduler

#

check when they move

#

if all you are doing is a basic if statement

#

then it wont affect in a meaningful matter

merry knoll
#

server does not start ticking

#

before all plugins are enabled right?

#

so i could do:
load plugin a
load plugin b that depend on a
load plugin c that depend on a
// do stuff on plugin a once these two are loaded using a delayed task with 1 tick delay

wary smelt
merry knoll
#

no

#

a has a listener integration

#

and needs to fire a socket once all plugins that depend on it pass the references

#

i could do it with a basic timer

#

but that doesnt feel robust, so i am trying to figure out if there is a "server is ready and plugins are fully initialized" event

lyric gyro
#

yeah there's ServerLoadEvent which sounds more appropriate than scheduling a task

merry knoll
#

that works way better, i couldnt see one in javadocs

#

im probably blind

wary smelt
#

mh why is it marked as @Deprecated ?

lyric gyro
#

is it?

#

no it's not

merry knoll
#

not deprecated on 1.18.2 at least

wary smelt
#

wait i was watching the wrong docs

#

it was 1.13

merry knoll
#

is there an equivalent of this in velocity?

#

or do i register listerners on constructor then subscribe on init event

lyric gyro
#

huh?

#

The PIE would be the equivalent

This event is fired by the proxy after plugins have been loaded but before the proxy starts accepting connections.

Not really sure what you mean by that second comment

merry knoll
#

not sure when it calls the constructors though

#

this basically is the issue

#

i am not sure about the load order

#

since if plugin b gets loaded before plugin a then if i register using constructor = no class def exception

lyric gyro
#

The constructor is called whenever it's called but, the plugin class is automatically registered as an event listener (why you can just add a @Subscribe to the PIE)
If you declare the plugin dependency properly, plugin a will always be constructed before plugin b, and by the time PIE is called all plugins will have been created

merry knoll
#

yes, does plugin initializations also happen according to dependency order

#

initialization event fires according to the order, not sure about the plugin instances being created though

#

although must be since, you would run into more issues most likely

lyric gyro
#

It sure as hell should load in the same order; I don't know velocity internals but I presume it eagerly evaluates the entire plugin dependency tree, and then once it's done with that it walks that tree (from "dependent" to "dependee") creating them

#

At least that's what any sane module system would :D

dense galleon
#

Is there some command to check all the tags and other data present in an Itemstack?

merry knoll
#

i cant test from this shitty laptop hence the question here

#

but that word of caution lowkey scared me

lyric gyro
#

It's more about "you can't do everything in the constructor"

lyric gyro
merry knoll
#

self contained code should be fine then and hopefully the constructor creation is sane

dense galleon
#

Sweet

dense drift
#

/data get entity YourName SelectedItem

dark garnet
#

hm, that worked, strange, ty

#
Object blah = getBlah1();
if (check) blah.doBlah2();```if `check` is false, is `blah` still parsed? *basically, are variables parsed before being used?*
#

also, how can i keep a chunk loaded with a specific item in it? im spawning an item, so if there's a way to keep a chunk loaded by location or something thats fine

merry knoll
#

a variable is effectively just a pointer

#

and yes from the point you create it, it will start pointing at whatever you assign it to

merry knoll
#

then cancel it

#

by checking through location

hoary scarab
#

Whats the entity parameter in PlayerFishEvent?
PlayerFishEvent(Player player, Entity entity, FishHook hookEntity, PlayerFishEvent.State state)

dark garnet
hushed badge
merry knoll
#

getBlah1 - check if true - blah2 - if false stop

#

is what will that do

hoary scarab
hoary scarab
merry knoll
#

apparently it can still be an item as well

#

@hoary scarab

#

are you creating your own entity fish event?

#

yes, so it changes over the events time

#

rather over the state

#

according to the last variable

hoary scarab
#

Just creating a new event so my listener can run instead of me trying to match methods to events.

dark garnet
merry knoll
#

yes

#

if getBlah1 does not do anything

#

and just returns an object reference

#

then performance impant is non-existant

#

its o(1)

#

but if you are calculating something, its probably better to do it inside the if

#

if its not necessary

dark garnet
#

ok

#

ty

sterile hinge
#

don't try to micro-optimize code by doing stuff like that though

lyric gyro
#

optimise for readability thinksmart

dark garnet
#

but some stuff i have is stupidly inefficient/performance-heavy cause i cant be bothered to fix it rolf

dense galleon
#

Any reason why when creating a new lore and setting it with meta.lore(list<Component>), it makes the whole lore italic?

#

Even though i havent made it italic anywhere

merry knoll
dark garnet
dense galleon
merry knoll
#

for just getting a reference sure

dense drift
#

Vanilla behavior that's removed by spigot for strings

dense galleon
#

At the beginning where

merry knoll
#

but with calculations sure

dense galleon
#

I don't use ChatColors anymore

#

I use NamedTextColor and TextDecorator

hushed badge
#

for Components, u need to set the TextDecorations to false i believe

dense drift
#

Append each line to an empty component with italic false is what I do

dark garnet
dense galleon
dark garnet
sterile hinge
dense galleon
merry knoll
dense drift
#

Components is what minecraft uses for years

dense galleon
dense drift
#

Not Adventure directly, but yeah

#

If you rename an item in vanilla, it will be italic

dark garnet
# merry knoll ^

like for events, i usually put all the event.getBlah() stuff at the beginning cause that just makes sense

merry knoll
#

yeah, but thats just a reference

dense drift
#

Spigot disable the italic for strings, that's why you have never seen it

dense galleon
#

Ahh

#

It's not strings as it is text components

merry knoll
#

but if you need to pull data from sql and thats what the "get" does

#

then thats a bad idea

dense drift
#

Yes, Adventure works just like vanilla does

dense galleon
#

That's... very inconvenient

dark garnet
dense drift
#

No no, append the line to an empty component with italic false

dense drift
lyric gyro
#

that's minecraft for ya

dense galleon
#

First line of the lore?

dense drift
#

Each

#

Component.empty().decorate(ITALIC, false).append(line)

dense galleon
#

oh god

viral moth
#

you can just have a static component that you always append to

merry knoll
dark garnet
dense galleon
#

Why not after

viral moth
lyric gyro
viral moth
#

just that the parent component has it set to false

dense galleon
#

I think i am better off making a util method to do this for me automatically

dense drift
#

Removing it from the line itself will remove italic set manually

merry knoll
viral moth
merry knoll
#

cuz in normal usage, you have it in a continuation

#

or through a callback and never really directly

viral moth
#

you'd have to define it yourself obv but its pretty straight forward

dense drift
#

Or, you know, shovel it in your parse method or whatever

dense galleon
dense drift
#

Start*

#

But yeah, is a small thing anyways, and something that could also be a thing on spigot but someone decided to remove it for some reason

viral moth
#

the best part about components is that ItemStack#displayName() and ItemStack#itemMeta().displayName() return different components 🥲

dense drift
#

Yeah, I believe the first method does extra checks to return the name depending on client's language if the item doesn't have a custom name set

#

While the second just returns what was set in the ItemMeta

viral moth
#

even if it does it returns the name in []

lyric gyro
#

it returns the name with brackets + hover event for the item

#

no checks

dense drift
#

Oh it also has a hover? Mhm

lyric gyro
#

yea

dense drift
#

Nice, nice

hard wigeon
#

I'm making an API that gets shaded into a given plugin, and should support whatever (non-legacy) version of spigot that plugin is built on.
How do I allow it to accept things like materials from a higher version than the API was compiled on?

#

eg. if you compile against 1.19 you should be able to use Skulk blocks

#

but if you compile against 1.18 you shouldn't

#

(this is in a method within the API that accepts Materials)

lyric gyro
#

wouldn't it just take a Material and that's it?

dense drift
#

^^

#

The enum is different based on the version that's used

hard wigeon
#

but what version of spigot do I depend on

#

in the API

lyric gyro
#

doesn't matter

hard wigeon
#

oh, does it use the version depended on in the main project over the one I do?

dense drift
#

The highest you need I guess

hard wigeon
#

I just worried it would be trying to accept a 1.18 material, while being given a 1.19 one

#

thanks 🙂

lyric gyro
#

the api version you depend on doesn't matter

#

all you care about is taking a Material

#

your plugin doesn't hard-code the available Materials during compilation

hard wigeon
#

I mean the compilation of the API vs the compilation of the plugin

hard wigeon
#

since the project now has 2 versions of spigot it depends on

#

one within the API that's lower

#

and a higher one within the plugin

lyric gyro
#

i'm still not sure what the concern is

dense drift
#

The api is not different from a plugin that supports multiple versions

#

No matter the version you still use Material#getMaterial for example

lyric gyro
#

unless you need to use e.g. Material.SKULK directly inside the api/plugin then it doesn't matter

hard wigeon
#

alright. Just wanted to check if there would be compile errors

warm steppe
hard wigeon
#

using Material.SCULK hardcoded into the plugin, even though it depends on a higher version of spigot than the API, which does not know about Material.SCULK

dense drift
warm steppe
#

<reset> ...

lyric gyro
#

no

#

<!i>, reset does not work like you think it does

hard wigeon
#

Itemstacks are wrapped in a dumb component

lyric gyro
hard wigeon
#

okay, cool

#

so that should make it allow newer blocks?

#

that the API was not compiled to know about

#

I guess as long as it's not shaded it's fine

#

thanks Emily

merry knoll
#

all you care about is that on the version that your plugin is running on

dense drift
#

You can probably get around that with adding some versions checks, but depends on the use case I guess

merry knoll
#

package and class structure is the same

#

aka Material exists

hard wigeon
#

I was just worrying that Maven/Gradle would be a pain with the 2 versions of spigot API in one project really

merry knoll
#

internals dont matter since its dynamic depending on whats being loaded on the server

#

use the highest version and avoid using any materials directly in the api

#

then you should be fine

hard wigeon
#

but if I'm hard coding a 1.19 only material, it has to accept 1.19 materials everywhere

#

that's all

dense drift
#

What are you trying to do with skulk, Fred?

hard wigeon
#

but yes, I think I get it now

#

I'm making a plugin manager thing for a few of my plugins to link them together
and it will add a GUI to manage the plugins

#

all in one spot

#

and the icon for atleast one of my plugins is skulk related

dense drift
#

Add a fallback material maybe? Or use skulls

hard wigeon
#

But I don't need a fallback, since the plugin is 1.19 only

merry knoll
#

i would fill the gui from the plugins

#

rather than filling them from the api

#

to avoid this whole issue

hard wigeon
#

It unfortunately can't really be

#

without a lot of reflection

merry knoll
#

cant put it as dependency?

dense drift
hard wigeon
#

nope

#

just loaded ones

#

idc about unloaded ones, atleast at the moment

#

though that is a cool idea actually

#

but I can filter it out to only that version and below

dense drift
#

Material pluginXIcon = ServerVersion.is_1_19 ? Material.SKULK : Material.PAPER;

merry knoll
#

again why not have the plugins register their own icon

#

as they are loading

hard wigeon
#

well they are registering it

#

but with the API

merry knoll
#

api doesnt need to know whats being registered

hard wigeon
#

it will work now though, I get that

merry knoll
#

just needs the item / material

hard wigeon
#

my only worry was that

ApiThatOnlySupports118.setIcon(Material.119Material)

would be an issue

lyric gyro
#

no

merry knoll
#

it wont be

hard wigeon
#

right, I get that now lol

merry knoll
#

your api takes Material

lyric gyro
#

it just takes a Material, any material

hard wigeon
#

Just wanted to verify

merry knoll
#

it would only pose an issue

#

if you try to load your 1.19 plugin on 1.18

#

but thats an issue regardless

hard wigeon
#

api-version: 1.19

lyric gyro
#

yeah but that's on the plugin itself, not really to do with the api

merry knoll
#

your api just uses bukkit api for the material

#

and thats already dynamic depending on the version of the server

hard wigeon
#

my worry was compile-time, not runtime

#

but yes, ty

merry knoll
#

you are not compiling the dependency into the plugin so, it is runtime

hard wigeon
#

yeah I am

#

it's getting shaded

merry knoll
#

api is, not bukkit

hard wigeon
#

right right

#

yes

dense galleon
#

How can I play the "health regen" animation the hearts have when regenerating naturally?

#

Ahh got it

#

Gotta do sendHealthUpdate()

dense galleon
#

How do I prevent zombies from converting into drowneds?

merry knoll
#

creatureSpawnEvent

#

then check reason

#

@dense galleon

dense galleon
#

actually EntityTransformEvent is better

#

Is there any way to change the base damage a tool does when swung?

dense drift
#

Attributes probably

dense galleon
#

Didn't know they also worked for items

dense drift
#

d;fields attribute

uneven lanternBOT
#
Fields:
org.bukkit.attribute.Attribute%GENERIC_ATTACK_KNOCKBACK
org.bukkit.attribute.Attribute%GENERIC_MOVEMENT_SPEED
org.bukkit.attribute.Attribute%GENERIC_ATTACK_DAMAGE
org.bukkit.attribute.Attribute%GENERIC_ARMOR
org.bukkit.attribute.Attribute%HORSE_JUMP_STRENGTH
org.bukkit.attribute.Attribute%GENERIC_FOLLOW_RANGE
org.bukkit.attribute.Attribute%GENERIC_LUCK
org.bukkit.attribute.Attribute%GENERIC_MAX_HEALTH
org.bukkit.attribute.Attribute%GENERIC_KNOCKBACK_RESISTANCE
org.bukkit.attribute.Attribute%GENERIC_ATTACK_SPEED
org.bukkit.attribute.Attribute%GENERIC_FLYING_SPEED
org.bukkit.attribute.Attribute%GENERIC_ARMOR_TOUGHNESS
org.bukkit.attribute.Attribute%ZOMBIE_SPAWN_REINFORCEMENTS```
dense drift
#

d;Itemmeta#addattributemodifier

uneven lanternBOT
#
boolean addAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier)
throws NullPointerException, IllegalArgumentException, NullPointerException```
Description:

Add an Attribute and it's Modifier. AttributeModifiers can now support EquipmentSlots. If not set, the AttributeModifier will be active in ALL slots.
Two AttributeModifiers that have the same UUID cannot exist on the same Attribute.

Returns:

true if the Attribute and AttributeModifier were successfully added

Parameters:

attribute - the Attribute to modify
modifier - the AttributeModifier specifying the modification

Throws:

NullPointerException - if AttributeModifier is null
IllegalArgumentException - if AttributeModifier already exists
NullPointerException - if Attribute is null

lone saddle
#
Caused by: java.lang.ClassNotFoundException: me.filoghost.holographicdisplays.api.HolographicDisplaysAPI
``` anyone got any idea why its giving me it? I'm using the newest HolographicDisplay Plugin and also the newest version of the API for the 3.0.0 HolographicDisplays Plugin
dusky harness
#

?paste

neat pierBOT
#
FAQ Answer:

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

lone saddle
broken elbow
#

if you do, make sure you are not shading the API inside your plugin

lone saddle
#

Like i said, yes i have it installed

#

what you mean by shading the API

broken elbow
#

are you using maven or gradle?

lone saddle
#

maven, but im using the newest JAR since the 3.0.0 api isn't there with maven yet

broken elbow
#

ok. in your pom, what is the scope of HD? is it provided?

broken elbow
# lone saddle what you mean by shading the API

Shading dependencies is the process of including and renaming dependencies (thus relocating the classes & rewriting affected bytecode & resources) to create a private copy that you bundle alongside your own code.

#

better than I Could've ever said it

lone saddle
broken elbow
#

how do you use it tho? using your IDE's dependency manager?

lone saddle
#

added the jar to Libraries

broken elbow
#

anyways. there's an easy way to check if this is the case or not. Use either a tool like JDGui or just an archive manager like WinRAR to navigate thru the packages and see if by any chance the HD packages are there

lone saddle
#

in my plugin

broken elbow
#

can you send a full startup log of your server and possibly the plugin jar here as well?

broken elbow
#

you said you use the 3.0.0 development builds?

lone saddle
#

ye beta1

#

the plugin holographic displays

broken elbow
lone saddle
#

works fine on my server

broken elbow
#

seems like the beta api is located in the beta package

#

and not in the API package

lone saddle
#

means what can i do?

#

nvm i did fix it

#

using the HD Plugin as API now and it works as it should

west socket
#

Anyone have an idea as to why this SQL query is failing?

private static void createBoosterTable() throws SQLException {
        System.out.println(connection);

        String query = "CREATE NEW TABLE IF NOT EXISTS BOOSTERS" +
                " (ref_name VARCHAR(255) PRIMARY KEY, " +
                "time INTEGER)";

        Statement stmt = connection.createStatement();
        stmt.execute(query);
    }```
#

When this one works perfectly fine

private static void createAuctionTable() throws SQLException {
        String query = "CREATE TABLE IF NOT EXISTS AUCTION" + "(index     INTEGER PRIMARY KEY," +
                "item       INTEGER," +
                "itemdata   INTEGER," +
                "start         BIGINT(255)," +
                "bids         MEDIUMTEXT)";

        Statement stmt = connection.createStatement();
        stmt.execute(query);
    }```
west socket
#

Oh my god I’m so brain dead

#

I went over that like 20 times

#

And didn’t see that

merry knoll
#

happens when you do sql too much in one day

olive dirge
#

basecomponent is depraciated, what should we use for 1.18+?

icy shadow
#

adventure

olive dirge
#

Is there an easier way to show item in hand using adventure?

#

Trying to figure out how to use HoverEvent<HoverEvent.ShowItem>

lyric gyro
#

player.sendMessage(itemStack.displayName())

olive dirge
#

Sorry I meant I want to show like the hover, with a component in chat of the whole item

lyric gyro
#

player.sendMessage(Component.text("hi").hoverEvent(itemStack))

wintry grove
#

wait you can do that

lyric gyro
#

yes

wintry grove
#

didn't know

lyric gyro
#

now you do

olive dirge
#

that made things a lot easier wow

#

for displayName(), how do I have it as a string, it's a Component rn

lyric gyro
#

why do you need it as a string?

olive dirge
#

I wanna do Component.text(displayName)

lyric gyro
#

right....

#

it already is a component

olive dirge
lyric gyro
#

Component.text gives you a Component

#

ItemStack#displayName already is a Component

#

You already have what you want

olive dirge
#

oh im dumb got it

lyric gyro
#

lmao

olive dirge
#

itemHand.displayName().hoverEvent(itemHand)

lyric gyro
#

ItemStack#displayName will already have the hover event added

#

It's whatever vanilla shows in, e.g. the feedback for /give

olive dirge
#

This adventure update is pretty dope

lyric gyro
#

i guess vanilla doesn't show the lore for /give thonk

#

oh no it returns whatever shows when you kill someone with a renamed or enchanted item and such

#

yeah, not /give

olive dirge
#

whats the best way going about editing asyncChatEvent.message()

#

I wanna replace a text with a new component

hard wigeon
#

can I use a bukkitschedule with a timestamp to exexute?

#

to prevent lag from making a given schedule run longer

weary galleon
#

why can't I upload pics?

neat pierBOT
weary galleon
#

the server is stuck here and won't start

hard wigeon
weary galleon
#

ty

olive dirge
#

can I not save two collections to a db async?

#

both functions "run" but the playerData isn't getting saved

#
    public void saveMasteryData(MasteryData p, String pid) {
        Bukkit.getScheduler().runTaskAsynchronously(DrugCore.getInstance(), new Runnable() {
            @Override
            public void run() {
                String playerJson = DrugCore.gson.toJson(p);
                collection.updateOne(Filters.eq("uuid",pid), Updates.set("data",playerJson));
            }
        });
    }

    public void savePlayerData(PlayerData p, String pid) {
        Bukkit.getScheduler().runTaskAsynchronously(DrugCore.getInstance(), new Runnable() {
            @Override
            public void run() {
                String playerJson = DrugCore.gson.toJson(p);
                collection.updateOne(Filters.eq("uuid",pid), Updates.set("data",playerJson));
            }
        });
    }
#

PlayerData isn't null either, the collection just isnt getting populated

merry knoll
#

what is the best way to eliminate race condition with databases that happen when a player switches server?

#

server a - player quits - data gets saved - server b - player joins - data loaded

#

connection happens first then the old server disconnects

#

resulting in old data being loaded due to this can't just lock the row in the database

#

and no, can't save when changes happen or load with a set delay

sharp cove
#

Someone that knows anything about Laravel?

olive dirge
#

so the they both have different collection names and both JSONs are not null, can't figure out why playerData won't save into the DB

sterile hinge
#

why do you even need two methods that do the same

dense drift
#

Or, hmm, can you add a few seconds delay before save and on join, check if the player is coming from a server and request the data directly from that server, save the data on the new server and cancel the save task from the old server?
Leave server A
Add task to save later the data on server A
Join server B
Request the data from server A
Save the data on server B
Cancel the save task from server A

merry knoll
#

the issue is that

dense drift
#

?

merry knoll
#

to transfer data you need to use plugin messaging

#

and that requires a player on the server

dense drift
#

Yeah but there's other ways to do this

merry knoll
# dense drift ?

I'm wondering since it connects first to the second server then disconnects

#

maybe there is a window in between to transfer data

#

otherwise I think distributing from a bungee plugin is probably the safest

broken elbow
#

when was the chat component api added to spigot? 1.13?

dense drift
#

Bungee components you mean?

broken elbow
#

yeah

dense drift
#

Nah I think it exists even on 1.8 + bungee is not version specific, you can use latest for 1.8 for example

broken elbow
#

wait. does it not come inside the spigot jar?

dense drift
#

d;1.8 Player$Spigot#sendMessage

uneven lanternBOT
#
public void sendMessage(net.md_5.bungee.api.chat.BaseComponent component)```
Description:

Sends the component to the player

Parameters:

component - the components to send

dense drift
#

I think it does, but you need to define a repo for it, idk

#

Why do you need to use that shit?

broken elbow
#

I don't know if I actually need it.

#

I was looking for a way to send a json message in spigot that would work from 1.12.2 to 1.19.2

dense drift
#

Adventure

broken elbow
#

but looking at it, doesn't even seem like they have a way to translate that

dense drift
broken elbow
dusky harness
#

Yes

dense drift
#

Yes

#

Gson

merry knoll
#

shadowing adventure

broken elbow
#

nice. they don't use a special serialization right? strings that would be send with /tellraw would work with it just fine?

dense drift
#

And id say we should promote some [mini] action instead of [json]

merry knoll
#

legit decreased my lifespan

dusky harness
#

?

dense drift
#

Try to generate a json on the webui

broken elbow
dense drift
#

Promote not replace!

#

Json is a pain to use lol

dusky harness
broken elbow
#

ok. and who said we will promote JSON lol?

merry knoll
#

I just serialize using data classes in kotlin

broken elbow
#

we ain't even doing that now

merry knoll
#

and don't bother honestly

dense drift
#

Ok blitz

graceful hedge
#

Hiberna… PES_Blush

charred ravine
#

Hmm when I loop through a item lore with
for (String s : item.getItemMeta.getLore()) {

if (s.contains("whatever-is-in-lore") {
// code
}
}
it only can get the first line otherwise code wont run, anyone have any idea why?

#

I tried also creating the list first but albeit still wont work

spiral prairie
#

Code?

lyric gyro
#

code

high edge
#

Smh

charred ravine
#

I have literally isolated that specific code on a test plugin and it wont loop through the arraylist's string but when i return the list as string it displays all the items lore

#

???

#

@EventHandler
public void onPlayerAttack(EntityDamageByEntityEvent event) {

    if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
        Player player = (Player) event.getDamager();
        Player victim = (Player) event.getEntity();
        ItemStack getItemInHand = player.getItemInHand();

        //Check for Perun's Wrath//
        if (getItemInHand.hasItemMeta()) {
            if (getItemInHand.getItemMeta().hasLore()) {


                for (String s : ((Player) event.getDamager()).getItemInHand().getItemMeta().getLore()) {
                    if (s.contains("per diamond piece")) {
                        player.sendMessage("true");
                    }
                }
hoary scarab
charred ravine
#

nothing

#

however if i just use it to send the list as string to player it sends the whole lore like it should

#

i honeslty dont why it only takes the first line

broken elbow
#

to see if it doesn't loop thru all lines like you said?

charred ravine
#

let me see

#

it does

broken elbow
#

well then the loop works

hoary scarab
#

Show screen shots. Lore and output.

charred ravine
#

ahhh

#

figured it out

#

why do I need to include the color code symbol

#

lol

#

pretty odd but with the symbol in it works

broken elbow
#

bcz those are also characters in the string

#

they're only hidden for the user by the minecraft client

#

but they exist within the string itself

charred ravine
#

yeah only just figured that lol

#

I thought translateColorCodes removed the symbol in the list

#

after also translating '&' or whatever

#

anyway thanks for the help gotta learn java more lol

keen panther
#

hey I'm making some slashcommands, and wondering do I need to make the slash commands in the interaction.guild deployment and the index? i have tried to make a custom command but hasn't worked.

olive dirge
#

anyone know how to turn mongodb driver messages when starting up?

#
        Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
        mongoLogger.setLevel(Level.WARNING);
#

I've used this and it still seems to spam console

dark garnet
#

can someone send a link to a tutorial on vectors pls
idk which one is the best to read

sterile hinge
#

what are you looking for?

dense galleon
#

For some weird reason my entity does not have a killer when fetched in a EntityDamageByEntityEvent

#

Though I damage it with mob.damage(damage, shooter);

#

Shooter is not null, neither is mob

sterile hinge
#

killer != damager

dense galleon
#

Even with this though

#
                mob.damage(damage, shooter);
                mob.setKiller(shooter);```
#

It still says it's null

#

Actually even event.getDamager() says it's null?

#

Even if the method documentation says @NotNull

sterile hinge
#

might be a bug shrug_animated

#

depending on where you call that method, it might clash with other functionality

dense galleon
#

It gets called when using a weapon which throws a ray out

#

the method checks for entities near the ray, and then damages any that are hit by it

#

Could dealing the damage in a BukkitRunnable have something to do with it?

#

Or

#

or nothing idk

#

this is weird

nimble vale
#

wait let me check this i have done the exact same thing recently

#

and had that problem at a certain point

nimble vale
#

is that possible

#

i kinda have the same code over here and no problems with it

dense galleon
nimble vale
#

whatever hmm

#

server is running paper right

dense galleon
#

yeahh

nimble vale
#

did you tried that exact code in outside of the event

dense galleon
#

outside where?

nimble vale
#

so you said that it may be related with the entitydamageevent

dense galleon
#

Right after I set the killer yeah i checked and it's not null

nimble vale
#

you can just test it out

nimble vale
#

right?

dense galleon
#

I'll check with a interact at event

#

Yeah when right clicking the killer is not null

#

Only in the EntityDamageByEntityEvent

nimble vale
#

alright thats a progress i guess

dense galleon
#

Yeah

nimble vale
#

are you testing it with any plugins?

#

maybe some other plugins may be playing with the setKiller in that event

#

so you can change your events priority

dusky harness
#

although I haven't looked at the messages below your question yet

nimble vale
#

its likely

dusky harness
#

(so that bukkit doesn't have to set the killer to the previous killer again)

nimble vale
#

i think it does thonking

icy shadow
#

:nostatic:

lyric gyro
#

god fucking christ i hate bukkit with a passion

dense galleon
#

Hmm what then ffs

nimble vale
#

i am not really sure tho

#

i can't find fucking anything when searching something in this code

#

its like a maze

dense galleon
#

Even in the EntityDeathEvent it's null

nimble vale
dark garnet
#

this is happening to me again with 1.10.0 -> 1.10.1 :(

dusky harness
#

had this issue before

#

you have to set the cache thing to disabled

#

1 sec

#
        outputs.upToDateWhen { false }
dark garnet
#

where?

dusky harness
#
    processResources {
        outputs.upToDateWhen { false }
        expand("pluginVersion" to project.version)
    }
```this is what I use for ex
#

alternatively you can clean on every build 🥴

#

(not recommended)

dark garnet
lyric gyro
#

or do it the proper way

dusky harness
#

👀

lyric gyro
#
processResources {
  inputs.property("version", project.version)
  expand(...)
}
dusky harness
#

like ```kt
processResources {
inputs.property("pluginVersion", project.version)
expand("pluginVersion" to project.version)
}

lyric gyro
#

yea

dusky harness
#

what does inputs.property do?

lyric gyro
#

declares a task input, helps gradle know when a task is up to date or not e.g. if an input changes value

dusky harness
#

ah

#

interesting

#

but shouldn't it know from expand?

lyric gyro
#

not really

#

that's for the specific task action itself when it runs

#

not the property's generic inputs

#

like it can not run at all if none of the inputs have changed

dusky harness
#

Ohh I see

dark garnet
lyric gyro
#

show your build.gradle pretty please

lyric gyro
#

in an onInventoryClick event, can you not track when players click on armor slots in gamemode creative?

#

cause i want to track when a player clicks on the armor slot in both gmc and gms

#

don't even bother with creative mode

#

lots of the player's own inventory stuff is purely client-sided

#

so there is no way to track when a player clicks on their head slot in creative with a non armor item?

#

i don't really know for sure about specific scenarios but you're gonna spend more time banging your head on the wall than successfully tracking stuff

olive dirge
#

how do I remove italics for itemName

olive dirge
#

I tried setting the ItemStack.color() to white

proud pebble
olive dirge
#

ye im using components

#

how would I remove the style

proud pebble
olive dirge
#

dont think that works

dusky harness
#

not decorate

#

oh im 22 minutes late

#

sorry for ping 🥲

olive dirge
#

that worked, thanks

#

it runs when a player quits

#
public void saveData(MasteryData m, PlayerData p, String pid) {
        Bukkit.getScheduler().runTaskAsynchronously(DrugCore.getInstance(), new Runnable() {
            @Override
            public void run() {
                String playerJson = DrugCore.gson.toJson(m);
                collection.updateOne(Filters.eq("uuid",pid), Updates.set("masteryData",playerJson));

                playerJson = DrugCore.gson.toJson(p);
                collection.updateOne(Filters.eq("uuid",pid), Updates.set("playerData",playerJson));
            }
        });
    }
#

I run this

dusky harness
dark garnet
#

o shoot right

dusky harness
#

is this a plugin or a program?

#

since if it's a plugin you don't need the application plugin

#

and put expand outside of filesMatching

#

no

#

inputs.property outside of filesMatching

#

whoops

olive dirge
#

the bukkit scheduler

dark garnet
olive dirge
#

ye

dark garnet
#

i assume it has something to do with DrugCore.getInstance(), but im not sure what

#

what is DrugCore?

olive dirge
#

my main class

dark garnet
#

hm

#

maybe put DrugCore.getInstance() into a try and set the catch to ClassNotFoundException, then print stack trace (and a debug msg) if exception occurs. just to confirm thats what is causing the issue

#

i tried googling it a bit, and all i found was issues regarding getting the main classes of other plugins, and that the person was trying to get them before the plugin enabled or something. but i dont think that would be the case here considering its happening when a player leaves, and not on plugin start

olive dirge
#

its sometimes only

#

not all the time

dark garnet
#

does it only happen to some players? like does it only happen to you?

olive dirge
#

im the only one relogging

dark garnet
#

yeah im not rly sure whats going on, sry

dark garnet
#

also the version thing worked, thx

dark garnet
dark garnet
#

this is what i have rn:

stand.setVelocity(stand.getLocation().subtract(locationB).toVector().normalize().multiply(1));```but when the velocity is set, the armor stand just doesnt move
#

ohhh i think i figured it out, i was setting the stand's gravity off

#

which ig messed with the velocity

#

so now the armor stand is moving, but its not moving in the correct direction

dark garnet
#

figured it out, but now how do i keep it so that it doesnt fall to the ground (since setting no gravity wont work)?

lyric gyro
#

or idk maybe make it ride another armor stand without gravity

#

No idea if that would work

dark garnet
#

i think i might just be able to set the velocity's vector's Y to 0 using Vector#setY

dark garnet
#

i also need to figure out how to make it so the armor stand can go thru blocks

dark garnet
#

im trying to eject all passengers from an armor stand, but it just isnt working

#
stand.eject();
stand.getPassengers().forEach(entity -> Bukkit.broadcastMessage(entity.getName()));```2nd line is for debugging, every time it sends my username when it shouldnt send anything
i also tried doing `stand.getPassengers().forEach(entity -> stand.removePassenger(entity));` but that didnt work either
sterile hinge
#

what does eject return?

olive dirge
#
Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
        mongoLogger.setLevel(Level.WARNING);

why doesnt this prevent the spam from mongo from showing up

dense drift
#

d;Player#eject

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

Eject any passenger.

Returns:

True if there was a passenger.

dusky harness
#

Spigot doesn't look in Java main class

#

So even with application plugin u can remove the main class line in the build gradle

hoary scarab
#

Has String.split(String) always included the string used in the method in the array?

String example = "a | b";
String[] array = example.split(" | ")
ConsoleOutput.debug("Array Size: "+array.lenght);
Arrays.asList(array).forEach(arg -> ConsoleOutput.debug(arg));
```Outputs
> 3
> a
>  |
> b
icy shadow
#

wdym

#

"a b c".split(" ") should be {"a", "b", "c"}

hoary scarab
icy shadow
#

that's because split uses a regex and | is a special character in regex

hoary scarab
#

Might be an issue with java17

icy shadow
#

i can assure you it's always functioned like that

hoary scarab
icy shadow
#

np

charred ravine
#

hey is there a way to check on EntityDamageEvent if the damage is caused by the plugin?

#

Nevermind figured it out by setting a damageCause of Magic

icy shadow
#

inb4 a witch breaks your plugin

#

i would set a metadata key on the entity instead

stuck canopy
#

help

#

what am I doing wrong here

icy shadow
#

dunno

stuck canopy
icy shadow
#

whats the problem?

stuck canopy
#

and I used %scoreboard_location%

#

and it didnt work

icy shadow
#

that is not how papi works

stuck canopy
#

then how so

icy shadow
#

strings in java are immutable so setPlaceholders returns a new string with the placeholders set

#

it doesnt do any magic

stuck canopy
#

and what do I have to do to make it work?

icy shadow
#

use the returned string rather than "%blah%"

stuck canopy
#

what

proud pebble
#

did the api for creating an expansion change since the last time i used it cus afaik its public String onRequest(OfflinePlayer player, String params) {

stuck canopy
#

I can see 2 methods in the wiki

#

onPlaceholderRequest(Player, String)

#

theres this one as well

proud pebble
#

or atleast thats what i followed and it works like a charm

#

btw you did register the expansion in your main class's on enable right?

stuck canopy
#

    @Override
    public void onEnable() {
        // Plugin startup logic
        getServer().getPluginManager().registerEvents(new LocationEvent(), this);
        new LocationPlaceholder().register();

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }
}```
proud pebble
#

and in your plugin.yml your depending on placeholderapi right?

stuck canopy
stuck canopy
#
version: '${project.version}'
main: me.none030.crypsisplaceholders.CrypsisPlaceholders
api-version: 1.19
depend: [PlaceholderAPI, WorldGuard]```
#

im using the placeholder on SimpleScore plugin

proud pebble
#

according to With a Plugin (Internal Class) it uses onRequest rather then onPlaceholderREquest

#

the only time onplaceholderrequest is shown to be used is by the relational placeholders

#

try switching to onrequest and see if it starts working

stuck canopy
#

oh

#

aight let me try that

shell moon
#

If I spawn using packets an armorstand, and set it as passenger or a player and set me as passenger of the armorstand

#

we will see it as we are mounting, what would others see? (people who joined the world or the server or didnt recieve the spawn packet)

#

would i look like "mounting" the armorstand which is mounting the player?

stuck canopy
#

still doesnt work

dark garnet
#

is there another way to generate -all when using gradle b?

proud pebble
lyric gyro
proud pebble
#

so in the if identifier equals, have it return something like an empty string

lyric gyro
#

or run gradlew sJ instead lol

proud pebble
#

if the return statement on line 39 still doesnt work then its gotta be something else

keen panther
#

hey any one know where i can find support on coding a bot/

proud pebble
#

a bot for what?

shell moon
#

Probably here, just ask

proud pebble
#

actually yes, someone here might know a solution to your problem

keen panther
# proud pebble a bot for what?

so I'm creating a discord server bot and am struggling on slash commands, https://discordjs.guide/creating-your-bot/creating-commands.html#resulting-code so I've created the initial ping commands, ping, server and user, but struggling to add in my own, do I need to add the command to index.js, interaction.guild and deployment-commands.js for this to work? also on the next section called command handling, im struggling to get the new commands like avatar, kick and beep to respond atall, i even resulted to coping the code, to rule out any mistakes. maybe im missing a file or something but im just stumped. here is the section im on now https://github.com/discordjs/guide/tree/main/code-samples/creating-your-bot/command-handling/commands

stuck canopy
#

I typed the wrong world name

keen panther
charred ravine
#

why in the world does it prematurely kill the player at 5 hearts when I do this:

if (victim.getHealth() - event.getFinalDamage() <= 0) {
event.setCancelled(true);
victim.setHealth(victim.getMaxHealth();
victim.teleport(victim.getWorld().getSpawnLocation();

The code cancels the death screen however testing it it does it too quick at 4-5 hearts

#

disabled all other event handlers etc and same result

shell moon
lyric gyro
#

can i

#

hide particles for everyone?

#

only for one specific effect though

#

night vision

shell moon
#

i guess with packets you can

#

kinda weird, why?

lyric gyro
shell moon
#

yeah

#

i mean, why hide it for everyone except the player?

lyric gyro
#

i want to hide it from everyone

dark garnet
shell moon
lyric gyro
#

actually

#

explain

shell moon
#

how are you adding the effect?

lyric gyro
#

that gives you night vision

#

and removes it from you

#

when you send the command a second time

#

also how do I create a toggle on/off command, ik how to make regular commands but not commands that turn off and turn on

lyric gyro
dark garnet
lyric gyro
#

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public final class Nvod extends JavaPlugin {

    @Override
    public void onEnable() {
        // Plugin startup logic

    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        if(command.getName().equalsIgnoreCase("nv")){

            if(sender instanceof Player){
                Player playerWhoToggled = (Player) sender;
                playerWhoToggled.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 2147483647, 1, false, false));
                playerWhoToggled.sendMessage(ChatColor.GREEN + "Visão noturna ativada.");
            }

        }


        return true;

    }

    }

``` have a look
dark garnet
#
if (playerHasNightVision) {
    playerRemoveNightVision;
    return true;
}

playerAddNightVision
return true;```
lyric gyro
#

thats it?

dark garnet
#

yes

lyric gyro
#

do I have to put this below the if statement that gives nv?

dark garnet
#

wdym

lyric gyro
#

the if statement

#

is giving night vision

#

nvm

merry knoll
#

you just check by hasPermission like normal

#

you dont need to hook up to luckperms specifically

lyric gyro
dark garnet
lyric gyro
#

yeah i know

#

thats the idea

merry knoll
#

thats what it does already

lyric gyro
#

but this won't work

merry knoll
#

is returns the part that confuses you?

lyric gyro
#

no

#

the thing is

merry knoll
#

its pseudo code

#

so you cant copy paste obviously

#

playerHasNightVision etc

#

you need to replace with stuff that does that exactly

lyric gyro
#

of course

#

and

dark garnet
lyric gyro
#

we are not calling object 'playerWhoToggled'

#

which doesnt make any sense

dark garnet
merry knoll
#
if (playerHasNightVision) { // Check if the player has night vision
    playerRemoveNightVision; // Since they have it, remove it
    return true; // Stop the code
}
// They dont have it, since the case where they have it is above
playerAddNightVision // Give them night vision
return true; // stop code

lyric gyro
#

but does playerHasNightVision exist?

merry knoll
#

nope

dark garnet
merry knoll
#

you need to write it yourself

#

you gotta write a method

#

that returns true or false

dark garnet
merry knoll
#

depending on if they have it or not

dark garnet
#

nvm there is Player#hasPotionEffect

merry knoll
#

thats even easier then

lyric gyro
#

so in this case, playerHasNightVision is the method that I wrote

#

got it

merry knoll
#

all the player stuff there

#

you need to replace

#

with actual code

dark garnet
lyric gyro
#

okay

dark garnet
#
if (check if player has night vision) {
    remove night vision
    return true;
}

add night vision
return true;```
lyric gyro
#

thats only the easier part of the plugin btw

#

ill have to do something way more complicated later

#

that i dont even know

#

if its possible

dark garnet
lyric gyro
#

basically

#

this plugin is for a minigames server

#

which has a lot of minigames

#

most minigames will have this nv thing

#

but theres this one minigame

#

where its like dead by daylight

#

and it doesnt make sense

#

if the people escaping from the killer have night vision

#

so my friend asked to make this plugin work

#

only in specific worlds

#

because the minigames are built on different worlds of course

#

@dark garnet

#

what do I do now

#

It's saying that hasPotionEffect cant be referenced from a static context

merry knoll
#

you need to use it on player instance

lyric gyro
#

Mk

lyric gyro
#

Nested if statement?

merry knoll
#

no

#

dont use static access

#

use it on command sender

#

cast to player

lyric gyro
#

OH

#

I GET IT

#

thanks

#

was using player instead of playerWhoToggled

#

also this object name is horrible

#

no reason to be that long

#

but who cares

lyric gyro
#

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public final class Nvod extends JavaPlugin {

    @Override
    public void onEnable() {
        // Plugin startup logic

    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        if(command.getName().equalsIgnoreCase("nv")){

            if(sender instanceof Player){
                Player playerWhoToggled = (Player) sender;
                playerWhoToggled.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 2147483647, 1, false, false));
                playerWhoToggled.sendMessage(ChatColor.GREEN + "Visão noturna ativada.");

                if(playerWhoToggled.hasPotionEffect(PotionEffectType.NIGHT_VISION)){
                    playerWhoToggled.remove();
                }

            }



        }


        return true;

    }

    }

merry knoll
#

if(command.getName().equalsIgnoreCase("nv") this part is not needed

#

if you register your executor properly

#

and no that wont work

lyric gyro
#

i think that's the only way I can do it for now

lyric gyro
merry knoll
#

read the code

#

then write what it does

#

step by step atm

lyric gyro
#

well

#

ignoring the fact

#

that I havent set anything up on onEnable

merry knoll
#

just the command part

lyric gyro
#

the only thing wrong that I can think off

merry knoll
#

what happens when a command is received

merry knoll
lyric gyro
#

ok

merry knoll
#

write what it does in your mind

#

step by step

lyric gyro
#

first it gets if the command was sent or not

#

if it was sent, then get who sent it

#

and set night vision without particles, amplifier of 1

#

duration infinite

#

and send a nice message in chat

merry knoll
#

then?

lyric gyro
#

then

#

if the player

#

already has night vision

#

remove from him

#

except

merry knoll
#

does he already have it atm?

#

or rather can he ever not have it

lyric gyro
#

wdym

merry knoll
#

you give him the effect

#

THEN check if he has it or not

lyric gyro
#

oh

merry knoll
#

which is always true

lyric gyro
#

so the issue is

#

the if statement is in the wrong placew

merry knoll
#

you gotta check first

#

if they have it remove

lyric gyro
#

also

merry knoll
#

else give

lyric gyro
#

will that remove part work?

merry knoll
#

no

lyric gyro
#

yeah

#

i thought so

merry knoll
#

you need to check the exact method

#

for removing potion effects

#

google something like

#

spigot remove potion effect java

#

(or learn to use javadocs so you dont need to depend on forums)

proud pebble
lyric gyro
#
                    playerWhoToggled.removePotionEffect(PotionEffectType.NIGHT_VISION);
                }```
#

if that was what I was doing wrong

#

then it will work ig

keen panther
merry knoll
#

you found the correct method ye4s

lyric gyro
#

how do I check if he doesn't have the potion effect

#

do I only put else at the end of the if statement?

#

or else if

proud pebble
lyric gyro
# proud pebble do exactly the same thing but put a ! at the front
                    playerWhoToggled.removePotionEffect(PotionEffectType.NIGHT_VISION);
                    playerWhoToggled.sendMessage(ChatColor.RED + "Visão noturna desativada.");
                }

                playerWhoToggled.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 2147483647, 1, false, false));
                playerWhoToggled.sendMessage(ChatColor.GREEN + "Visão noturna ativada!");```
#

have a look at this

#

thats how it is now

#

i know its wrong

proud pebble
#

your removing the potion effect, then readding it?

lyric gyro
#

i said

#

i know its wrong

#

thats what im trying to patch

proud pebble
#
if (haspotion) {
    removepotion
    sendmessage disabled
} else {
    addpotion
    sendmessage enabled
}
#

also id replace the number with Integer.maxvalue()

lyric gyro
proud pebble
lyric gyro
#

the duration you mean

#

yeah i set it to the limit of an integer because they said on the forums that if you did that, the effect would last forever

proud pebble
#

yes, means you dont have to write out integer maxvalue every time you wanna use it

#

also it wouldnt last forever, but basically forever

lyric gyro
#

it would last for around 60 years or something like that

#

also

#

will it make the code run faster?

#

because it isn't writing out 2 billion and shit

#

but just max value

lyric gyro
# proud pebble ``` if (haspotion) { removepotion sendmessage disabled } else { addp...

this correct mah guy? ```if(command.getName().equalsIgnoreCase("nv")){

        if(sender instanceof Player){
            Player playerWhoToggled = (Player) sender;

            if(playerWhoToggled.hasPotionEffect(PotionEffectType.NIGHT_VISION)){
                playerWhoToggled.removePotionEffect(PotionEffectType.NIGHT_VISION);
                playerWhoToggled.sendMessage(ChatColor.RED + "Visão noturna desativada.");
            }else{
                playerWhoToggled.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 2147483647, 1, false, false));
                playerWhoToggled.sendMessage(ChatColor.GREEN + "Visão noturna ativada!");
            }```
#

why is discord text formatting stupid today

merry knoll
#

yep quite correct

lyric gyro
#

@merry knoll btw

#

teach me how to implement executors correctly

proud pebble
#

what a weird way to do your commandexecutor class

lyric gyro
#

yeah

#

ik

merry knoll
#

you want it as its own class

#

ideally

lyric gyro
#

thats the only way i can do it for now though

proud pebble
#

the spigotmc forums has a tiny section of creating a command

lyric gyro
#

the only thing left to do is add onEnable method and register the command

proud pebble
#

add the command to your plugin.yml, register the command in your onenable method in your main class and create a class that implements commandexecutor

lyric gyro
#

cant believe im actually going somewhere with java

#

a few weeks ago i was like "the fuck is a variable"

#

now im here

proud pebble
#

should tell you everything you need to know to make a command and register it and stuff like that

lyric gyro
#

what do I put in onEnable? @proud pebble

#

Im not very good at this part yet

proud pebble
#

scroll down

stuck canopy
proud pebble
#

it says how to register the command

proud pebble
lyric gyro
#

@proud pebble

#

this.getCommand("kit").setExecutor(new CommandKit());

proud pebble
lyric gyro
#

what would be this

#

command kit part

#

im slow

#

explain it to me

merry knoll
#

thats your own class

lyric gyro
#

ah

merry knoll
#

that extends commandExecutor

proud pebble
#

getCommand() requires the command string, in this case it would be "nv"

#

the set executor is your command class, the class has to implement commandExecutor

lyric gyro
#

ill have to do that ig

merry knoll
#

once you have it up proper

#

it will only send the one that you register

#

as in this.getCommand("kit").setExecutor(new CommandKit());

proud pebble
#

writting everything in your main class is the best way to have a mess of a plugin

merry knoll
#

you will only get the command kit

#

so the first part of your code checking if its nv

#

is not needed

#

if its set up properly

proud pebble
#

so for each command you will need a seperate command class

#

i usually call them all Command<CommandName> so like CommandAnvil for example

lyric gyro
#

the ide is asking me to make the class that implements command executor abstract

#

do i have to

#

?

proud pebble
#

no

lyric gyro
#

Class 'Nvod' must either be declared abstract or implement abstract method 'onCommand(CommandSender, Command, String, String[])' in 'CommandExecutor'

merry knoll
#

it needs to have the methods

#

alt enter on it

#

then choose implement members

lyric gyro
#

ah

#

ok

#

implemented em

proud pebble
#

when you hover

merry knoll
#

then move your command logic

#

into that implemented method

#

then you gucci

lyric gyro
#

now i just need to paste the code i wrote here right?

merry knoll
#

remove the first if though

#

since thats always true now

lyric gyro
#

yeah of course

merry knoll
#

and you are done

proud pebble
#

make sure to return true

#

at the end

#

will stop it from sending the message "/nv" every time you send the command

lyric gyro
#

I think im done

#

ill send the code here

merry knoll
#

register it

#

on your on enable

#

if you didnt already

#

and put it on your plugin.yml

lyric gyro
#

so you guys can spot any errors that that I haven't seen k?

proud pebble
#

well if there are errors, more then likely it would spit them out before compile

lyric gyro
#

anything unneeded

#

or something like that

#

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public final class NvodMain extends JavaPlugin {

    @Override
    public void onEnable() {
        this.getCommand("nv").setExecutor(new Nvod());
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        return true;

    }

    }

#

thats the main class

proud pebble
#

you can drop the on command

lyric gyro
#

already tried to

#

it gives me an error

proud pebble
#

since its not needed in the main class anyore

lyric gyro
#

oh wait

#

yeah done

#

anything else?

merry knoll
#

thats legit it