#help-development

1 messages · Page 2159 of 1

granite owl
#

why did ppl always say this wouldnt exist duh

#

RecipeChoice.ExactChoice

#

is what makes custom items fully functional

#

cause it checks for nbt values matching

eternal oxide
#

There have been changes to Furnace/recipe over time but The only thing I know you can;t do through recipes is require x amount of an item

granite owl
#

btw the dust pile are emeralds

granite owl
#

to require > 1 quantity in a matrix slot

patent horizon
#
    private final Map<String, Integer> npcDialogues = new HashMap<>();

    public Map<String, Integer> getNpcDialogues() {
        return this.npcDialogues;
    }``` i have this map in a playerdata accessing class, but whenever i try to use the following method, i get this error message
```[20:12:00 ERROR]: Could not pass event PlayerInteractEntityEvent to PlexPvP v${version}
java.lang.NullPointerException: Cannot invoke "java.util.Map.getOrDefault(Object, Object)" because the return value of "net.plexpvp.core.data.instanceTargets.PlayerData.getNpcDialogues()" is null
    at net.plexpvp.core.npc.NpcListener.onNpcClick(NpcListener.java:38) ~[PlexPvP-1.0-SNAPSHOT.jar:?]```
eternal oxide
#

impossible, unless you are doing some crazy ass reflection or something

patent horizon
#

¯_(ツ)_/¯

eternal oxide
#

or you are trying to use it in a static code block... possibly

patent horizon
#

nothing in the class is static

#

nor the class it's being called from

sacred mountain
#

the code runs, as the printlns have run, except the entity doesnt get teleported

fossil lily
#

How can I damage my item?

#

I can't cast the meta to Damagable

eternal oxide
daring lark
#

how to set player balance with vault api?

sacred mountain
#

with the teleport message working

eternal oxide
crisp steeple
fossil lily
#

I get an error when casting it do "Damagable"

sacred mountain
#

so it ran all of that in under a tick? ok

patent horizon
eternal oxide
fossil lily
eternal oxide
#

Sorry I don;t do 1.8

crisp steeple
#

if you’re on 1.8 i believe you can just do .setDurability or setDamage

crisp steeple
#

i don’t really have a clue how you’re getting that error

fossil lily
crisp steeple
fossil lily
#

oh wait

#

it might be

eternal oxide
# sacred mountain

Yes, but if the entity isn't actually in the world yet it can;t be teleported

lethal python
#

my playerinteractentityevents aren't firing when i right click an invisible armorstand how do i solve this

granite owl
#

@eternal oxide lmao u can override vanilla recipes

#

crafting

patent horizon
#

why is it conventional to use getters and setters instead of just editing values directly?

eternal oxide
granite owl
#

means can set the vanilla recipes to explicit vanilla item only

lethal python
#

wowowo

#

what are they under

lethal python
#

i'm not trying to equip it with anything

sacred mountain
lethal python
#

it's set as marker and everything

#

does this fire even if i'm not equipping anything

#

right click with fist

granite owl
#

any help on how i can get a Recipe instances namespacedkey?

eternal oxide
granite owl
#

if i have a Recipe instance*

eternal oxide
sacred mountain
#

well it wasnt

#

it spawns and just does nothing

#

and then the server crashes

eternal oxide
#

server crash sounds more like you are getting stuck in a loop

sacred mountain
#

its a 'server stopped from 10 seconds'

eternal oxide
#

Then your code is never exiting and locking up the server

sacred mountain
#

could you read the paste

#

so you can see why

eternal oxide
#

link it again

granite owl
#

Bukkit.removeRecipe(new NamespacedKey("minecraft", "emerald_block")); found, any help on how to get a "plugin" instance to the vanilla minecraft namespace?

sacred mountain
#

while (!targetEntity.getNearbyEntities(0.5D, 0.5D, 0.5D).contains(z)) {
//
continue;
}

this is where it's getting stuck, but it should not be getting stuck as the target should be teleporting

#

so idk

eternal oxide
#

oh of course it is

sacred mountain
#

basically, the target doesnt move, making the zombie not move either and then the server is stuck in a loop

eternal oxide
#

its entering that loop and never exiting

#

nothing on the server can change while its in that while loop

sacred mountain
#

but its while condition tho

#

oh

#

why doesnt the getnearbyentities work as a condition

eternal oxide
#

it does, but its still in yoru code every time it repeats

#

nothing on the server has changed

#

its a single Thread

#

while in yoru code, no other code is running

sacred mountain
#

oh

#

so uh

#

how do i do that

#

while the zombie isnt close enough from the target, just wait

#

waiting isnt a very good thing in code but thats what i need rn

eternal oxide
#

you use a repeating task to check

sacred mountain
#

right ok so just a runnable

eternal oxide
#

yep

wet breach
#

or threads

sacred mountain
#

im legit stupid ok thanks

#

so in the repeating task its just delay 0L and interval 1L, check for nearby entities and when the condition is true i can just cancel();

#

right

eternal oxide
#

unless you grew up with single core Processors its easy to be confused with Threads

sterile token
#

Hi its possible to register a codec for mongo?

#

Because im getting exception when having saving my custom data

#

Its telling me that ClaimType no tiene un codec

eternal oxide
#

read the reply to that thread about creating codecs

#

It sounds like you are trying to save an object that mongo doesn;t not know how to handle

quaint mantle
#
@EventHandler
    public void onDiamondBreak(BlockBreakEvent event) {
        Block blockBroken = event.getBlock();

        if (blockBroken.getType() != Material.DIAMOND_ORE || blockBroken.getType() != Material.DEEPSLATE_DIAMOND_ORE) {
            Bukkit.getLogger().info("Broke a non-diamond block!");
            return;
        }

        Bukkit.getLogger().info("Diamond Ore broken!");
    }

I am fairly certain that Diamond Ore broken! should be getting logged in the console but it does not

patent horizon
#

how do i make these safe

lethal python
#

so PlayerArmorStandManipulateEvent doesn't trigger when u aren't changing its armor

#

so how do i check when player right click invisible marker armorstand

patent horizon
#

why arent you just using EntityInteractEvent

lethal python
#

because it doesn't work

patent horizon
#

you can lookup the click type and entity

#

wdym doesnt work

lethal python
#

w8

eternal night
#

marker armorstands have no hitbox

#

players cannot interact with them

patent horizon
#

interesting

lethal python
#

how can i make invisible immovable immortal armorstand

#

without it being marker

#

:v

patent horizon
#

nbt

eternal night
#

just a non-marker and make it invulnearable ?

lethal python
#

does invulnerable make it resistant to pistons also

eternal oxide
patent horizon
#

yeah you dont even need nbt, there should be methods for invisible, immortal, and gravity

eternal oxide
#

You will never see diamond ore broken

eternal night
#

dunno if no gravity prevents piston movements

quaint mantle
#

oh wait yeah

patent horizon
#

how can i check if a entity/item contains persistentdata without triggering npe if it doesn't?

#

i dont wanna flood console with try/except messages either

#

since it could come up negative a lot

eternal night
#

null check it

#

get(NamespacedKey, INTEGER) returns an Integer

#

not an int

#

you are auto unboxing it

#

which may lead to a null pointer

patent horizon
#

getString(heldItem, new NamespacedKey(PlexPvP.get(), "fishing_rod")) == null

eternal night
#

Well please save the value

#

and then compare it

#

but yes

patent horizon
#

i think the problem is i'm comparing what was returned from the method instead of comparing before returning

eternal night
#

what

#

what does getString do

patent horizon
#

returns the persistentdata in the form of a string

#

supplied with an item/entity and a key

eternal night
#

the PersistentDataType.STRING would work fine here

#

your issue is just auto unboxing

patent horizon
#
    public static String getString(Entity entity, NamespacedKey key) {
        return entity.getPersistentDataContainer().get(key, PersistentDataType.STRING);
    }```
eternal night
#

yea that works tho

#

nothing there will break yet

#

if the returned value is null

#

your issue is with your integer implementation

patent horizon
#

well i havent used the integer one yet

#

so the npe isnt coming from there

#

i'll fix it in advance tho

eternal night
#

what NPE are you getting

patent horizon
#
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.getPersistentDataContainer()" because the return value of "org.bukkit.inventory.ItemStack.getItemMeta()" is null
    at net.plexpvp.core.util.PersistentData.getString(PersistentData.java:23) ~[PlexPvP-1.0-SNAPSHOT.jar:?]
    at net.plexpvp.core.npc.FishermanNPC.open(FishermanNPC.java:25) ~[PlexPvP-1.0-SNAPSHOT.jar:?]
    at net.plexpvp.core.npc.NpcListener.onNpcClick(NpcListener.java:48) ~[PlexPvP-1.0-SNAPSHOT.jar:?]```
eternal night
#

well that was not the method you linked then

#

that just fails because you supply an item without item meta

#

like air

patent horizon
#

this is my condition tho

#

if (heldItem.getType() != Material.AIR || getString(heldItem, new NamespacedKey(PlexPvP.get(), "fishing_rod")) == null) {

#

oh wait

#

...

eternal night
#

lol

patent horizon
#

but im tryna do like if the player is holding air or an item that doesn't contain the required data

#

would i just slap some parenthesis in the second one

lethal python
#

so there's no immovable flag for armorstands

#

marker is the only way

#

how can i do a raycast

patent horizon
lethal python
#

i will try that now but i thought armorstands dind't have ai

patent horizon
#

well they cant move, but AI also includes being pushed by a piston and whatnot

#

oh nvmd

#

noai mobs can still get pushed

#

uhhh

#

what if you just tried some good ol' packets

lethal python
#

yea it still moves

#

this is like my first plugin

#

i don't know what NMS is or what packets are

#

i see all this stuff being thrown around

#

i had to get someone to help me with a dependency today

#

i haven't worked with maven before

eternal night
#

you could try a marker armorstand and the actual one riding it 🤔

#

passengers should not be pushed

lethal python
#

:V 🧠

#

how do i do

#

spawn armorstand then can i do like

#

.setRider?

#

is that a thing?

eternal night
#

addPassenger

#

but yea

lethal python
#

awesome is that easy

#

cool cool i will do that

patent horizon
eternal night
#

lets hope that works 😅

#

Well

patent horizon
#

would end up above or below it

eternal night
#

a little above

#

it is a marker

#

that should be rendered basically at the same height

patent horizon
#

there's a way to interact with armorstand packets

eternal night
#

mate if they just started

patent horizon
#

ik so because i have a packet hologram leaderboard thing on my server that's rotatable

eternal night
#

packets will not work

patent horizon
#

oh

#

they just started

#

heh

dusk flicker
#

have any of yall messed with TAB's weird custom event system before? Waiting on TABs support but might as well ask here.

patent horizon
#

is tab supposed to be an acronym for something other than the playerlist ingame?

dusk flicker
#

its the actual plugin name lmao

patent horizon
#

oh

dusk flicker
lethal python
#

so i could put an armorstand with a helmet on, make it a marker, but then make some invisible noai mob ride it, and i check for right clicks on that mob

eternal night
#

I guess

#

could also just spawn the marker with nothing

lethal python
#

how far up do passenger mobs sit

eternal night
#

and then the non marker with stuff

#

with a marker it shouldn't sit very high

lethal python
#

nonono i've already made a resource pack with the item displaying on an armorstands head

misty current
#

how can I make structures registered in the structuremanager persist through restarts? do I have to save the files myself?

eternal night
#

yes

#

The structure manager does not even save vanilla ones by default

#

you have to save them in the structure block and actively load them back in

sterile token
misty current
#

or that you can make them persist

eternal night
#

The StructureManager has a saveStructure method

lethal python
#

is .setMetaData just a way of storing miscellanious info inside a mob

#

like could i make my own flag and set it to true for a zombie

humble tulip
#

Won't u use persistent data container?

lethal python
#

wot

humble tulip
#

To set data for entities

lethal python
#

im a noob at spigot idk the full api yet

#

is that part of spigot

humble tulip
#

Yes

#

You do Entity#getPersistentDataContainer

wet breach
humble tulip
#

And you cna look at the link to see the methods of the pdc

tardy delta
#

?pdc

lethal python
#

thank you

patent horizon
#
                                var item = new ItemBuilder(Material.FISHING_ROD)
                                        .name(localize(player, "item.fishing.rod.name", playerResolver))
                                        .lore(localizeList(player, "item.fishing.rod.lore"))
                                        .build();
                                setString(item, new NamespacedKey(PlexPvP.get(), "fishing_rod"), "true");
                                player.getInventory().addItem(item);``` would anyone know why the persistent data isnt actually being applied to the fishing rod that's given to the player?
#
    public static void setString(ItemStack item, NamespacedKey key, String value) {
        item.getItemMeta().getPersistentDataContainer().set(key, PersistentDataType.STRING, value);
    }```
tardy delta
#

i guess we need to see the impl for the ItemBuilder class tho

patent horizon
eternal night
#

item meta is a clone

tardy delta
#

ah nvm

patent horizon
eternal night
#

it clones itself

#

mutating it does nothing unless you feed the instance back

#

using setItemMeta

eternal oxide
#

apply the meta back on teh item, after you set it

patent horizon
#

the meta being the persistent data?

eternal night
#

the entire item meta

#

getItemMeta returns the cloned item meta

eternal oxide
#

ItemMeta you get from getItemMeta()

humble tulip
#

get the item meta

#

modify it

eternal night
#

its pdc is hence obviously also the clone

humble tulip
#

and then set it back

patent horizon
#

so basically

eternal night
#

no

#

you need to store it

#

getItemMeta returns a new instance

#

calling it again just creates another new instance

humble tulip
#

?di

undone axleBOT
humble tulip
#

@lethal python

#

^

patent horizon
#

wait

#

why is this hurting my brain

#

i understand what u mean

humble tulip
#

ItemMeta meta = item.getItemMeta

#

meta.modify();

#

item.setItemMeta(meta);

patent horizon
#

ah ok

#

ye

lethal coral
#

what's the difference

drowsy helm
#

one cann be picked up iirc

tardy delta
#

first one ye

reef mantle
#

Player inventory is unaffected. What am I doing wrong here?

eternal oxide
#

I don't think you need to update the inventory

reef mantle
#

doesn't do anything with or without that line

eternal oxide
#

then make sure the code is even running

fossil lily
#

Is there a packet im not seeing that is sent when a player gets a new item? (Not pickup)

reef mantle
eternal oxide
#

I've no idea what you mean by 0

reef mantle
#

here's the actual setup of my code, updateInventory commented out for now

#

and here's the debug output

#

item stack (11 carrots) is not decremented. The event is clearly firing twice (!?) and bailing out on the first run, when it shows the correct amount

eternal oxide
#

ok, line 61, you are returning before you reduce the amount if its a golden carrot

#

the other 0 is the offhand trigger

#

both 0

reef mantle
#

that's it. its supposed to be a !=

worldly ingot
#

getItem() returns a mirror iirc btw

#

So you shouldn’t have to setItem()

#

Of course you can do it for the sake of clarity, and I might even be wrong ;p

dense geyser
#

how would I go about changing the type of a material of a placed block in 1.8? so for example, oak stairs to birch stairs. Everything in MaterialData to do with changing the typeid seems to be deprecated

river oracle
#

did you look why its depricated?

#

1.8 is so old it could just be depricated because of 1.9

#

if your using 1.8 don't even worry about deprication the API is so old do you really expect for it to be updated anyways

final cypress
#

I'd like to make a plugin to let players maintain individual builds in a world separate from the overworld - new to spigot API and have been reading docs, seen methods for loading chunks from a created world, but is there general information somewhere about what specifically it means to load chunks? Want to make sure I handle loading/unloading properly

golden turret
#

how can i listen for the ChunkLoadEvent of the default world

humble tulip
#

Check if the loaded chunk is in the defualt world

golden turret
#

when the world is firstly loaded, spigot already loads the chunks before my plugin even loads

#

basically, im deserializing a location from a config and it is giving me "unknown world" if i set load: STARTUP

#

and also i want to listen to every chunk load event to do something

humble tulip
#

Can't u just get all the loaded chunks after startup

#

Like onEnable

#

And do whatever u want?

patent horizon
#

tryna add a new object to a json config. which one of these do i put in place for a map?

humble tulip
#

Think it is a jsonobject

patent horizon
#

alr

lethal python
#

how do i check if a playerinteractentityevent was a right click

#

wait nvm

reef mantle
#

yes

minor vapor
#

o.o

#

never seen that before

quaint mantle
#

hideous

sharp flare
#

intelliJ all the way

fallow isle
#

I'm trying to create this runnable, but for some reason its not running at all. the debug messages "pre worked" and "zipline has been created" is sent, but nothing in the runnable. no stacktraces as well, anyone knows why?

minor vapor
#

BukkitRunnable is deprecated, you should use Bukkit#getScheduler()#scheduleSyncRepeatingTask()

fallow isle
#

ah thanks, i'll look into it!

minor vapor
#

np

lethal python
#

has anyone here used anvilgui

#

this one

#

I have this code in a PlayerInteractEntityEvent listener:

AnvilGUI gui = new AnvilGUI.Builder()
        .title("Does this work")
        .open(event.getPlayer());

This is the error when the event happens:
https://pastebin.com/zjWyyH3L

#

it's supposed to render an anvil gui

#

i've tried running .plugin(this.plugin) on it and that didn't help either

quaint mantle
#

hello, who can help me with doing rectangular world border?

fallow isle
minor vapor
#

debug outside of the for loop inside of your task to make sure it's running

fallow isle
#

oh god why didnt i think of that, let me try that 🤦

#

yep thats it... thanks LMAO

#

dammit 3 hours of sleep really isn't enough

minor vapor
#

I hear ya, I regret working last night when tired

minor vapor
full sorrel
#

So say I have another Java program, (Discord Bot) is it possible to use Spigot API as a Listener and get server information, I keep reading that it has to be a plugin

#

Any help would be appreciated

lethal python
#

@humble tulip

humble tulip
#

?

lethal python
#

oh i didn't reply

lethal python
#

i have the pastebin for ithere

#

and explanation

waxen plinth
#

Or a plugin that communicates with a discord bot

#

You can't easily make a program that runs separately from the server and still interfaces with it otherwise though

full sorrel
#

I was seeing that first option, Idk why I could not find that answer before.

#

I would prefer the 2nd option myself, I am going to look into that route.

waxen plinth
#

It's far more painful

humble tulip
#

yeah^

full sorrel
#

Oh rip

humble tulip
#

is this plugin ur making for the public?

#

or yourself?

full sorrel
#

No, private server.

#

The bot is even exclusive to the discord server.

humble tulip
#

and what kinda data u wanna send back and forth?

full sorrel
#

Mostly, auto whitelisting, would be neat to have chat synced up but not required.

humble tulip
#

honestly the first option is the best

#

but you can use sockets

#

make the discord bot the server and all the mc servers clients

frosty geyser
#

When i try detecting a player removing an item from a armor slot InventoryClickEvent doesn't fire, is there a different Event i can call that focuses to the main Player's Inventory? (using spigot 1.18.2)

full sorrel
humble tulip
humble tulip
#

just a regular click?

frosty geyser
#

yep

humble tulip
#

maybe an if statement is wrong somewhere then

#

can we see your code?

frosty geyser
#
    public void onBannerRemoved(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        final ItemStack clickedItem = e.getCurrentItem();
        if (clickedItem == null || clickedItem.getType().isAir()) return;
        String playerGroup = getGroup(p); // group would be like Plains
        String getKing = getKing(playerGroup); // My IGN
        String playerName = p.getDisplayName(); // My IGN again
        boolean isPlayerAKing = playerName.equals(getKing); // A Workaround for checking due to it skipping over it
        p.sendMessage(isPlayerAKing + "");
        if (!isPlayerAKing) return;
        if(e.getSlotType() == InventoryType.SlotType.ARMOR) {
            p.sendMessage("Slot Is In Armor");
            if(e.getCursor().getType() == getKingBanner(playerGroup)) {
                p.sendMessage("Item Is Banner");
                e.setCancelled(true);
            }
        }
    }```
#

trying to detect when a player tries to remove a banner from their head doesn't register it which is pretty odd, been looking around for 2 hours now and haven't really found a way around it

humble tulip
#

have you put any debug statements at the top to make sure the event is fired?

frosty geyser
#

i have which was this:

        p.sendMessage(isPlayerAKing + "");```
which would return true or false and it would only detect it in Inventories that were Chests but not the normal player inventory
modest shard
#

is there a way to execute a vanilla command from code

humble tulip
#

probably Bukkit.getConsoleSender and run the command using that?

modest shard
#

or if there is a way to make a listener detect whether a player right clicks an item such as a special stick, and to obtain the location of the player and the direction the player is facing?

humble tulip
#

yes there is

modest shard
#

ive never dealt with right clicking any item, cuold u point me in the right direction?

humble tulip
#

playerinteractevent

modest shard
#

how to check if its right click

#

or for the item?

humble tulip
#

i just tested that it does

#

something you're doing is wrong

modest shard
#

this is my item btw

#

would i have to copy past this into the listener to check fo the item?

humble tulip
#

why is that a static method

#

no

#

save an instance of the stick in your listener class

frosty geyser
# full sorrel So say I have another Java program, (Discord Bot) is it possible to use Spigot A...

tbh its not too hard to do, all i did was make the bot in a class called DiscordStuff which extends the ListenerAdapter and an variable JDA jda; then made an public DiscordStuff(Main main) { startBot(); this.jda.addEventListener(this); }
so then the Main plugin class can run the bot then a function to start the Bot so it will actually be active

    try {
      this.jda = JDABuilder.createDefault(this.token).build();
    } catch (LoginException e) {
      e.printStackTrace();
    } 
  }```
afterwards  i did whatever i needed to do in that class, if you wanted to make listeners to PlayerJoinEvent or anything then implement Listener to the class add a `public MainClass plugin;` then in the DiscordStuff(MainClass main) add in `plugin = main;` and a `plugin.getServer().getPluginManager().registerEvents(this, (Plugin)this.plugin);` to register the events to actually work.
humble tulip
#

and check if ItemStack#isSimilar(ItemStack)

modest shard
#

#?

#

what does isSimilar check?

humble tulip
#

if the itemstack is the same in all aspects but the amount

modest shard
#

ah

humble tulip
#

if u wanna compare amount use the equals method

modest shard
#

i think isSimilar seems fine for this purpose

frosty geyser
#

then in the main plugin class i just extended JavaPlugin and made an onEnable this called new DiscordStuff(this); which made it so the bot was being hosted on the server itself and still received data

humble tulip
#

make sure you call jda methods on a separate thread cuz it can lag your server

modest shard
#

this look righ so far?

#

*right

humble tulip
#

LOL

#

?wiki

undone axleBOT
modest shard
#

wiki for me?

humble tulip
#

this for u

modest shard
#

ok ty

humble tulip
#

yes it's right but if you need to ask if that's right, you need to look around a bit more

full sorrel
humble tulip
#

supersand then sockets are your way to go

frosty geyser
#

i know a janky way for it

modest shard
#

cant find more detailed stuff on event api

frosty geyser
#

if you would like to know it

full sorrel
#

Yeah I was looking into sockets

#

sure I'm down for suggestions

#

I'm mostly in the research phase rn.

humble tulip
humble tulip
#

what more detailed stuff do u want?

modest shard
#

it doesnt have anything on more specific events

humble tulip
#

?jd

modest shard
#

liek how to get info form the evnts

modest shard
#

💀 i better get searching

humble tulip
#

find the events there

frosty geyser
#

alright so have 2 discord bots, 1 in the plugin, 1 for the main. now have a discord server that both bots will be in that will communicate data between each of them and just have checks if a message comes in from the other server from that one bot to then do a certain thing with the data included into it

#

its not the best way to do it, but it works

#

sockets would be the way to go but if you want an easy way for it then that would be it

full sorrel
#

I did think of that, but I quickly turned it down.

modest shard
#

is there a way to "round" directions a player is facing to strictly NWSE

frosty geyser
#

makes sense

modest shard
#

without too much math

full sorrel
#

Thanks though guys, appreciate the time trying to help me.

frosty geyser
#

i did it so a javascript bot could communicate with a jda bot

humble tulip
#

maybe

modest shard
#

yes ty to peoples helping me

#

i think i could do it maybe if i knew how the direction facing stuff works

#

let me get the interaction thing down first

final cypress
humble tulip
#

fk discord spoils it

modest shard
#

lol

#

ty tho

#

yea im not about to figure out what the heck yaw is and how it works

final cypress
#

You can disable embed previews with <> around the link

modest shard
#

i feel deprived without nitro

#

😭

frosty geyser
#

buy nitro again then

modest shard
#

i won the nitro from a giveawa

#

lol

#

how to summon a primed tnt? i alr know how to summon a mob, but is it different for primed tnt

#

oh its TNTPrimed

#

is ther smth wrong with this? or is this not how you are supposed to summon tnt

#

o wait im oncrack

#

wait no

#

even after i changed null to TNTPrimed

#

anyone?

#

😭

frosty geyser
#

TNTPrimed t = (TNTPrimed) w.spawnEntity(p.getLocation(), EntityType.PRIMED_TNT); ?

modest shard
#

TNTPrimed t = (TNTPrimed) w.spawnEntity(p.getLocation(), EntityType.PRIMED_TNT);

frosty geyser
#

shows no errors for me

modest shard
#

yea currently that

frosty geyser
#

maybe change it to something else

modest shard
#

did i forget to import smth

frosty geyser
#

i only needed to import import org.bukkit.entity.TNTPrimed;

modest shard
#

that should work then

#

._\

lethal python
#

guys i saw a server where they had this chest menu where you could click buttons, but the buttons didn't have the white highlight when you hover over an item

#

i thought they were using a custom font texture but i'm using a custom font texture rn and the items in the container are rendering on top of the text ·_ .

modest shard
#

???

#

why in this channel?

lethal python
#

because it's a development question

#

people in here have probably made custom guis before

#

i want to know what technique is used to make that specific gui

modest shard
#

pictures pls

lethal python
#

i will have 2 find a server with it again

modest shard
#

well idk what ur talking abt 💀

#

i figured it out

#

bruh moment

coarse shadow
#

can we access jigsaw block's gui through spigot?

modest shard
#

is there some way to make an itemstack into a Material that i can add to a recipe

#

nvm i figured it out

coarse shadow
wet breach
#

should be able to, BlockData contains the data of said block

coarse shadow
#

but does parameters on that method change depending on different blocks?

#

cuz data of a chest and a jigsaw is different

wet breach
#

not sure, will have to play around with it. Those API methods have inherited methods too

#

I haven't messed with jigsaws but those are the only API things I managed to find in relation to them

coarse shadow
#

got it ty

sacred mountain
#

not too familiar with itemstack deserialization and serialization, can you serialize to a custom yml manager? Or does it need to spigot fileconfiguration for yml

opal juniper
sacred mountain
crimson terrace
#

Did you serialize an itemstack to get that section?

#

If so you should be able to deserialize it back into an itemstack

sacred mountain
#

Hm, could you first tell me the difference between single keys, configurationsections, and how to use them? Like what do i put in them

#

not too sure how to serialize to file

sharp flare
#

I think spigot has a resource page for that

#

might worth googling

latent pelican
#

Hi I want to implement a stop clock that can be called with a certain command and measures the time it takes a player from one coordinate to another?
How can I do that?

sharp flare
#

you can try a runnable which runs every second and cancel it when the player has reached the coords or location

#

there are other ways but thats what came to my mind

crimson terrace
#

you should probably measure the time with system millis

#

its more exact that way

quaint berry
#

So uhhhh

#

Why is this happening?

#

I forgot how to fix it

wet breach
quaint berry
#

The AuraMain is the main class but there is extra stuff connected

#

Why?

quaint berry
#

Due to 2 voids?

wet breach
#

that is just showing you member methods

#

which is the two void methods you specified

quaint berry
#

Oh

#

I'm an idiot

#

I don't need to specify a main class due to it being in the plugin.yml....

quaint berry
#

I do have one more issue that would help me

#

I have this

#

This is my YML

#

How would I get the chosen player?

#

like /command exampleaccount

eternal oxide
#

if (args.length > 0)
Player player = Bukkit.getPlayer(args[0]);
if (player != null)

knotty oxide
#

Anyone knows how to get this MariaDBV Source

fossil lintel
#

How are you building your project?

#

You could add it to the library section of your plugin.yml

buoyant viper
#

does FileConfiguration#get return List<Object> for types such as Byte, Float, and Character?

#

im running into a type-mismatch for those 3 types with it trying to set a fields value with reflections

worn tundra
#

Do you have a code snippet to show?

buoyant viper
#
wf.trySet(fileConfiguration.get(wf.getPath()));```
`wf` is my "WrappedField" object (https://paste.md-5.net/vexewuxacu.java), `fileConfiguration.get` is the get method in FileConfiguration (duh), and `wf.getPath()` is the path to the key (ie. `getConfig().getByteList("this.is.a.path")`
#

the 3 types are commented out rn so that it doesnt error out my smp for now

#

ik reflections is usually a can of worms not worth opening but this seems so simple that i cant grasp what would be going wrong

astral shard
#

yo i have a quick question, is spigot like a java library for minecraft or what exactly is spigot?

buoyant viper
buoyant viper
astral shard
#

and what does it extend? it just simplifies working with the api because it has classes for certain elements and stuff?

buoyant viper
#

it adds some stuff, cba to remember what tho

earnest forum
#

simply put

astral shard
#

is there a place where I can find all of this stuff

earnest forum
#

it has an api which you can program and make plugins to do all sorts of stuff

buoyant viper
eternal oxide
#

It is an API for interacting with the Minecraft Server.

buoyant viper
astral shard
#

okay I get it now

#

thanks yall

earnest forum
#

with a vanilla minecraft server jar you dont get a plugins folder (i dont think)

#

i dont think ive ever actually used one

astral shard
#

you think there's a c++ version of spigot since it is an API and not part of the actual minecraft server, therefor not having to be java?

earnest forum
#

no

#

it has to be java

eternal oxide
#

There was one I believe, but it was never finished

earnest forum
#

its an expansion on the java minecraft version

buoyant viper
#

itd have to be a full port of the java edition server methinks

eternal oxide
#

was it glowstone? or some other

buoyant viper
#

glowstone is java

#

its just the server written from scratch

eternal oxide
#

perhaps I'm thinking of a full server rewrite

earnest forum
#

u mod something in the language its coded in

#

unless they have an inbuilt modding thing

eternal oxide
#

being the same language is not a requirement of an api/mod

astral shard
#

right that makes sense

buoyant viper
#

ppl have made plenty of injectable mods made in C++

earnest forum
#

yes but usually u do

#

code in the same language

restive tangle
#

I'm wondering how I should implement special abilities for my kits. I was thinking an enum for allowed events such as EventType.DEATH or EventType.KILL, a description which will be displayed and a consumer that takes player so I can actually implement the effect.

@RequiredArgsConstructor
class KitAbility implements Listener {
  @Getter private final EventType calledOn;
  @Getter private final String description;
  private final Consumer<Player> effect;

  @EventHandler
  public void event() { // this is the problem
    
  }
}

How do I map these enums to certain event classes so I can register them using something like.

@EventHandler
public void event(Event e) {
  if (!(e instance of calledOn.getEvent().class event) return
}

Or

public void event(calledOn.getEvent().class event) {
  effect.accept(event.getPlayer);
}

If not, is there a better way?

earnest forum
#

you could make your own event that has a field which is the enum

#

instead of creating different events

restive tangle
#

What? I don't quite understand, I was thinking EventType would be something like

@RequiredArgsConstructor
enum EventType {
  DEATH(PlayerDeathEvent.class),
  KILL(PlayerDeathEvent.class)

  @Getter private final Class<E extends EntityEvent> event;
}
earnest forum
#

so how would you listen to that?

restive tangle
#

I don't know, that's why I am here

earnest forum
#

enums dont really work like that

#

i suggest you make your own event/method that runs on the PlayerDeathEvent

#

explain what ur trying to do again?

restive tangle
#

Special abilities for kits

earnest forum
#

how?

#

when someone dies?

restive tangle
#

You kill some effect takes place, you die some effect takes place and so on

earnest forum
#

ah

#

in your player death

#

even t

#

make a method that makes your effect once a certain condition is reached

#

something like

#
public void runEffect(EffectType type){
    if (type == ..) {
      //do so and so
    }
}
#

run this on your player death event

restive tangle
#

Kits will have different effects and these effects could be triggered on different events

#

Or the same one

earnest forum
#

run this same method whenever you need to

#

sorry for this haphazard explanation im playing a video game rn i just didnt want to leave u hanging

bleak oak
#

Hello, I just discovered that since 1.17 API and NMS have been changed but I don't understand something

#

I imported the spigot remapped etc but why netty is not in?

#

How can I get it?

quaint mantle
#
new BukkitRunnable(){
            public void run(){
                if(!giant.isDead()){
                    if(giant.getTarget() == null){
                        for(Entity entity : giant.getNearbyEntities(10, 10,10));
                        if(entity instanceof Player){
                            Player player = (Player) entity;
                            giant.setTarget(player);

                        }
                    }
                }```
I keep getting this error "Cannot resolve symbol 'entity'
how 2 fix dis?
buoyant viper
#

its not in the loop

latent pelican
#

How can I make my Time.System.Millis stop when a player reached certain coordinates ( a certain tile)?

earnest forum
#

you cant

#

that continuously runs

#

you would have to pause the entire server

latent pelican
#

Yeah but how can I store that millis time

earnest forum
#

set it to a variable

latent pelican
#

Of course I know

#

But is it like (if player.getLocation() == new Location(1, -60, 1) { time = ...

#

??

earnest forum
#

what are you even trying to do?

#

give me some context

quaint mantle
#

?

earnest forum
#

yes

#

the if isnt nested inside the for

eternal oxide
#

You have a ; after your for loop instead of a {

earnest forum
#

theres also not enough }

#

your opening too much and not closing them

#

unless ur leaving out some code at the bottom

quaint mantle
#

!paste

#

a

earnest forum
#

?paste

undone axleBOT
quaint mantle
#

here is the entire code

earnest forum
#

yeah change the ; after your for into a {

#

and then add another } after the end of the if

quaint mantle
#

which line?

earnest forum
#

41

quaint mantle
#

is dis correct?

#

also will the auto spawn thing work

#
 @EventHandler
    public void onSpawn(EntitySpawnEvent event){
        if (!(event.getEntity() instanceof Animals))
            return;
        if (!(event.getLocation().getBlock().isLiquid()))
            return;
        if ((int) (Math.random() * 10) == 1) {
            event.setCancelled(true);

            Bukkit.broadcastMessage("" + event.getLocation());

        }
    }


}```
earnest forum
#

cant help rn im playin a game

#

ask some1 else

quaint mantle
#

and why do I keep thinking that ur pfp is that linus tech tips guy

earnest forum
#

but that for thing should work

#

its superwog

quaint mantle
#

hf

earnest forum
#

ty

latent pelican
earnest forum
#

yea that should work then

latent pelican
#

Ok but somehow my if condition isnt working ingame

#

If I want to store timemillis when he reached for example the coordinates (1.0, -60, 1.0)

#

How would my If statement look like

earnest forum
#

make sure to use getBlockX

#

because that uses whole numbers

#

getX is a double

#

its like

#

5.3334

#

if ur in the middle

eternal oxide
#

just use Location#getBlock and compare

latent pelican
#

if (p.getLocation() == new Location(p.getWorld(), 1.0, -60.0, 10.0))

earnest forum
#
if(player.getLocation().getBlock().equals(new Location(x,y,z).getBlock())
#

use blocks

#

because the player's location uses a double as coordinates so it will never be equal to your target

latent pelican
#

Ahhh makes sense

#

I try it out

earnest forum
#

1.5, 1.5, 1.5 is not the same as 1,1,1 even if you're standing on top of the same block

restive tangle
# restive tangle I'm wondering how I should implement special abilities for my kits. I was thinki...

Could I use generics instead?

@RequiredArgsConstructor
class Ability<E extends EntityEvent> implements Listener {
  @Getter private final String name, description;
  private final Consumer<Player> effect;

  @EventHandler
  public void event(E event) {
    if(!(event.getEntity() instanceof Player player)) return;
  
    effect.accept(player);
  }
}  

One problem, if in my abstract kit class I put

private Ability<EntityEvent> special;

And in a derived class I put

special = new Ability<PlayerDeathEvent> ("", "",...);

Would the event register PlayerDeathEvent or EntityEvent?

earnest forum
#

EntityEvent

#

it should cast player death event to entity event

restive tangle
#

Well that's a shame

earnest forum
#

you can just do private Ability<? extends EntityEvent> special;

restive tangle
#

Oh, I forgot about that one. Thanks

latent pelican
#

If the block I stand on has the y coordinate -61

#

my location is still -60 right?

eternal oxide
#

don't compare teh block under you

latent pelican
#

I didnt do that

earnest forum
#

yes it is

#

ur y level is the bottom half of your body

latent pelican
#

`
if (p.getLocation().getBlock() == new Location(p.getWorld(), 1.0, -60.0, 10.0).getBlock())

earnest forum
#

not ==

#

.equals()

eternal oxide
#

== "should" work as there is only ever a single instance of each Block, but equals() is teh correct method to use

earnest forum
#

yes its good practice

#

try printing the player coordfs

latent pelican
#

Still isnt working ( is there something wrong in my code)?

#

`
long timeMillis_start = System.currentTimeMillis();

        if (p.getLocation().getBlock().equals(new Location(p.getWorld(), 1.0, -60.0, 10.0).getBlock())) {
            long timeMillis_end = System.currentTimeMillis();
            long timeSeconds = TimeUnit.MILLISECONDS.toSeconds(timeMillis_end-timeMillis_start);
            p.sendMessage("Time: " + timeSeconds);
        }

`

tardy delta
#

You're comparing a block with a location

latent pelican
#

Ok so what to do

earnest forum
#

nah

#

hes grabbing the block from it

#

at the end

#

from the target location

latent pelican
#

So what des that mean for the code

earnest forum
#

that should be working

tardy delta
#

Ah wait

restive tangle
#
    // whether effect should take place on killer
    // only applies to PlayerDeathEvent
    private final boolean killer; 

    @EventHandler
    public void event(E event) { // wack
        if(!(event instanceof Player player)) return;
        
        if(event instanceof PlayerDeathEvent) {
            player = killer ? player.getKiller() : player;
        }
        
        effect.accept(player);
    }

A jank fix to target victim or attacker in PlayerDeathEvent

latent pelican
#

What do I have to do

earnest forum
#

should be

#

try print both blocks

#

send them as message to player

latent pelican
#

`
public class TimeKeeperCommand implements CommandExecutor {

public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]) {
    if (sender instanceof Player) {
        Player p = (Player) sender;
        p.sendMessage(ChatColor.GREEN + "Time started! Go! Go! Go!");

        long timeMillis_start = System.currentTimeMillis();

        if ((p.getLocation().getBlock()).equals(new Location(p.getWorld(), 1.0, -60.0, 10.0).getBlock())) {
            long timeMillis_end = System.currentTimeMillis();
            long timeSeconds = TimeUnit.MILLISECONDS.toSeconds(timeMillis_end-timeMillis_start);
            p.sendMessage("Time: " + timeSeconds);
        }
    }
    return true;
}

}
`

#

Whole code?

#

Where can I implement the print

earnest forum
#

before the check

#

where you check if the blocks are the same

#

just print the block as a tostringm

#
p.sendMessage(p.getLocation().getBlock()+"");
p.sendMessage(new Location(p.getWorld(), 1.0, -60.0, 10.0).getBlock()+"");
#

you might have to individually compare the x,y,z

restive tangle
#

Why not?

earnest forum
#

are you sure the event is firing

loud grove
#

Hello

#

Legit or fake

restive tangle
rough drift
eternal oxide
#

the code/command will not wait for you to reach the destination block

#

Your code will only work if you are stood at teh location when you use the command

#

You need to use the Scheduler to start a repeating task to listen for the player reaching the destination

granite owl
#

hope to get some help about something prob simple but i didnt find much on the internet neither the documentation nor the forums. so

#

i have a fully functional custom item and id like to now inject it into the namespaced map that the /give command utilizes so i can /give my custom items

#

and if possible also the map that the creative mode inventory is using

eternal oxide
#

register the recipe and it shoudl appear in all menus

granite owl
#

registered the recipe

#

works fine like ive said yesterday

#

but its not under gie

#

give

#

those are different maps

#

i suspect itll be somewhat similar to

#
try
        {
            Field mapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
            mapField.setAccessible(true);
            SimpleCommandMap commandMap = (SimpleCommandMap) mapField.get(Bukkit.getServer());
            
            Field cmdsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
            cmdsField.setAccessible(true);
            @SuppressWarnings("unchecked")
            Map<String, Command> cmds = (Map<String, Command>) cmdsField.get(commandMap);
            
            Command opCmd = new OpCommand("minecraft:op");
            Command deopCmd = new DeopCommand("minecraft:deop");
            
            cmds.replace("minecraft:op", opCmd);
            cmds.replace("op", opCmd);
            cmds.replace("minecraft:deop", deopCmd);
            cmds.replace("deop", deopCmd);
            cmdsField.set(commandMap, cmds);
            
            mapField.setAccessible(false);
            cmdsField.setAccessible(false);
        } 
        catch (Exception e) 
        {
            e.printStackTrace();
        }
```this
ivory sleet
#

Don’t need to use setAccessible(false) after

#

That will only affect the AccessibleObject instance you invoke it on

granite owl
granite owl
humble tulip
#

Think he's telling yo u to make your own command

granite owl
#

the command was not what ive been asking for

#

i want to inject custom items into the namespaced map

#

of the /give command

#

and hes saying that its redundant to set fields inaccessible

ivory sleet
#

Ya, at least for your purpose

granite owl
#

still need help with adding items to the /give list

#

xD

#

also trying to set an items max stack size but ive been reading trough the servers source files and apparently its impossible because stack sizes are derrived from materials which use final fields so even if i could do it i would override the vanilla items stack size too

#

and this is the same in both the bukkit api and nms methods

crisp steeple
#

well it’s not impossible

#

friend of mine changed the stack size of items just by forking spigot

#

keep in mind you’ll have to update the players inventory a lot in order for jt to look okay client side

granite owl
#

its not a big issue i can either use wooden swords as dummy item or add a PDC uuid value to it to make them non-stacking

#

problem is rather to keep track of the UUIDs

#

in an efficient manner

eternal oxide
#

just use random. Odds of having a collision which would allow stacking is near zero

granite owl
eternal oxide
#

true

granite owl
#

if i start to utilize uuids

#

i can also implement it in an anti cheat to detect dupes

#

however then punishing someone who got the near zero chance

#

is a nono

#

i just wonder why its so hard to make the stack size a member of the item meta

#

because its clearly not

#

its just that no one bothers to update that deprecated system from 12 years ago

eternal oxide
#

?contribute

granite owl
#

haha u serious?

#

even IF i was to write that system

#

chances are going near zero that its even being considered i believe

#

xD

eternal oxide
#

Yep

granite owl
#

yep serious or yep near zero

eternal oxide
#

near zero

granite owl
#

then im not gonna bother with a contribution

#

my time is too valuable to go to waste

#

even tho some might argue about that here xD

eternal night
#

I mean it will not get accepted anyway

#

The server would have to actively maintain the non vanilla item stack limit as the client doesn’t allow their modifications

granite owl
#

yea nah its cool its just gonna be anoying cause i have to write a couple of system

#

to utilize wooden swords as dummy objects

#

without breaking vanilla mechanics

#

like when ive found that the api does support crafting with custom items and not only materials it solved so much work, even though everyone here said recipes take materials only which is wrong

ivory sleet
#

Everyone?

granite owl
#

anyways back to the roots to find a solution to inject custom items into the give command map first

granite owl
#

but thats not true u can wrap itemstacks like this

ivory sleet
#

I mean the api supports custom items

granite owl
#
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(plugin, "recipe_diamond_dust"), item.getItemStack());
        recipe.shape("AAA", "AAA", "AAA");
        recipe.setIngredient('A', new RecipeChoice.ExactChoice(new ItemStack(Material.COAL_BLOCK)));
        Bukkit.addRecipe(recipe);
ivory sleet
#

Yes exactly

eternal night
#

Exact choices have their issues with the recipe book

#

But that’s on mojang

granite owl
#

thats what ive found when diving trough the servers source files

#

no one ever told me about that existing

ivory sleet
#

Ugh weird, I guess you shouldn’t listen to everyone here btw

eternal night
#

Then you must have been pretty unlucky with the support here xd

granite owl
ivory sleet
#

Because that exact choice api has existed for quite some time now

granite owl
#

well ive found it on my own by chance looking for something else trough the decompiled bukkit api

#

and then seeing exact choices being like

#

wait.. thats a thing?

#

xD

eternal oxide
#

It was probably a generic reply from people as most enquiries along those lines are related to multiple items (stack sizes) in crafting

granite owl
#

my custom items derrive from emeralds

#

so what ive done to set the vanilla recipe explicit

#
//Emerald Block Vanilla Override
        Bukkit.removeRecipe(new NamespacedKey("minecraft", "emerald_block"));
        ShapedRecipe recipe_emerald_block = new ShapedRecipe(new NamespacedKey("minecraft", "emerald_block"), new ItemStack(Material.EMERALD_BLOCK, 1));    
        recipe_emerald_block.shape("EEE", "EEE", "EEE");
        recipe_emerald_block.setIngredient('E', new RecipeChoice.ExactChoice(new ItemStack(Material.EMERALD)));
        Bukkit.addRecipe(recipe_emerald_block);
#

works totally fine

#

now no custom items can be used for the vanilla recipe

#

only thing is renamed emeralds cant be used either but tbh, not my problem xD

#

i mean whos renaming emeralds

granite owl
#

😛

eternal oxide
#

No clue. I've never played with the give command

restive tangle
#

How would I add special abilities into my kits? I tried making a class which would accept a consumer but two events of the same type cannot exist so that was a flop

quaint mantle
#

does anyone have any resources as to where i could learn the minecraft and spigot api?

chrome beacon
#

Do you know Java?

quaint mantle
#

Yes, i learned java, I'd also like to know where i could find the terms accociated with some of the actions

#

let me refraise that

#

you know like if you were to say "passing an instance"

eternal oxide
#

?di

undone axleBOT
quaint mantle
#

thanks, but what i'm looking for is a dictionary or something of the sort that tells you what stuff like that means, (i know dependency injection)

#

i know java, i just need to know the fancy words and stuff so i can actually be helped here

eternal oxide
#

Di is literally passing an instance/reference

quaint mantle
#

i know

restive tangle
#

It's called Google

eternal oxide
#

I doubt there is a dictionary like that. Make mistakes, people will correct you and you learn

quaint mantle
#

ok

#

thanks

eternal oxide
#

People love to correct mistakes 🙂

restive tangle
kindred valley
#
@EventHandler
    public void onInteract(PlayerInteractEvent e) {
        Block block = e.getClickedBlock();
        BlockState state = block.getState();
        if(state instanceof TileState) {
            e.getPlayer().sendMessage("b");
            if(((TileState) state).getPersistentDataContainer().has(Keys.ironConverterKey, PersistentDataType.STRING)) {
                e.getPlayer().sendMessage("a");
            }
        }
    }
```Hello, I'm checking if a block has specified persistent data type but it always returns false.
#

But actually block has a PersistentDataType

#
public class IronConverter {
    private static ItemStack ironConverter = new ItemStack(Material.CHEST);
    public static ItemStack setupIronConverter(String a, String text) {
        ItemMeta meta = ironConverter.getItemMeta();
        PersistentDataContainer ironConverterContainer = meta.getPersistentDataContainer();
        ironConverterContainer.set(Keys.ironConverterKey, PersistentDataType.STRING, a);
        meta.setDisplayName(text);
        ironConverter.setItemMeta(meta);
        return ironConverter;
    }
}
eternal night
#

I mean how do you set the value

#

Item PDCs are not auto copied to block pdcs when placed

kindred valley
eternal night
#

Yes

reef lagoon
#

how do i check for when the server stops

kindred valley
reef lagoon
#

yeah but it doesn't let me execute stuff

river oracle
#

It definitely let's you execute stuff

reef lagoon
#

wait no, it did, but it executed it 5 times

#

I need to do smth only once

river oracle
#

Are you sure it executed 5 times

#

Are you sure it's not a logic error?

restive tangle
#

When someone kills a person, they get strength and such

humble tulip
#

Well u can add methods to your kit class

#

Like onDie

#

OnAplly

#

That take a player

#

And call those methods from a listener

#

Are the kits configurable or are they coded in?

restive tangle
#

Yeah I know, but the specials will have a name and description to display

#

They are coded.

restive tangle
#

Should I create a seperate data class that stores that data?

humble tulip
#

Create an abilitykit interface with those methods

river oracle
#

Simple data class should work yea make sure you have an interface for easy storage

humble tulip
#

getName

#

get Description

#

And all the ability methods

restive tangle
#

How would interface make it easier for storage?

river oracle
#

Lists

#

Maps

#

Queues

#

Arrays

#

Uhmmm

humble tulip
#

I'm confused

river oracle
#

He's asking how using an interface would make the data easier to store lmao

humble tulip
#

What data do u need to store about kit description?

#

You wanna make it configurable?

restive tangle
#

I have a Custom kit abstract class that the kits derive from

humble tulip
#

Returns a clone i beleive

river oracle
humble tulip
river oracle
#

Eh who knows maybe guis and such

#

I always like to store String names for ease of access for that type of stuff

restive tangle
#

To display them in the shop and selector.

humble tulip
bleak oak
#

Does anyone know how to have netty in spigot 1.18?

restive tangle
#

Those are GUIs

#
@Data
class KitAbility {
  private final String name, description;
}
abstract class CustomKit {
  private KitAbility ability = new KitAbility("NONE", "No special");

  public void onDeath(Player player) {

  }

  public void onKill(Player player) {

  }
}
#

I still don't understand why KitAbility being an interface would help

kindred valley
cold field
#

Heya guys does anyone have any idea on how to prevent the player from moving an item when he is in creative mode?

kindred valley
#
@EventHandler
    public void onBlockPlace (BlockPlaceEvent e) {
        Block block = e.getBlockPlaced();
        Player p = e.getPlayer();
        if(block.getState() instanceof TileState) {
            p.sendMessage("tilestate");
            if(block.getType() == Material.CHEST){
                p.sendMessage("CHEST");
                if(p.getInventory().getItemInMainHand().isSimilar(IronConverter.getIronConverter())) {
                    p.sendMessage("getmethodu");
                    ((TileState) block.getState()).getPersistentDataContainer().set(Keys.ironConverterKey, PersistentDataType.STRING, "ironconverter");
                    block.getState().update();
                }
            }
        }
    }
restive tangle
eternal night
#

states are snapshots @kindred valley

#

similar to ItemMeta

#

you need to store the result of getState

fallow violet
#

?paste

undone axleBOT
fallow violet
desert tinsel
#

what is that error: Error occurred while enabling BowSpleef v1.0-SNAPSHOT (Is it up to date?) java.lang.IllegalArgumentException: Plugin already initialized!?

fallow violet
flint coyote
#

Do you use the same name for the main class of different plugins? That might also cause this issue. Although I'm not entirely sure about that

desert tinsel
kindred valley
#

?paste

undone axleBOT
fallow violet
desert tinsel
#

i do not have any plugin with the same name

fallow violet
#

i had the error months ago because i copied a plugin and just changed the code. Maybe thats your case

#

i got the mistake

chrome beacon
fallow violet
humble tulip
#

Make it an interface

#

Not a class

restive tangle
humble tulip
#

Do all kitd have abilities?

restive tangle
#

No

kindred valley
eternal night
#

you call update on the variable

kindred valley
#

i fixed

eternal night
#

wat

kindred valley
#

yes i get it

eternal night
#

oh

desert tinsel
#

i changed the name for main class

eternal night
#

oh yea the code you linked was wrong

humble tulip
#

Well make an AbilityKit abstract class that extends kit

eternal night
#

glad you fixed it yourself

desert tinsel
#

and it still doesn't work

humble tulip
#

And add the methods specific to abilities there

restive tangle
#

Could you tell me why an interface would be better here?

humble tulip
#

I didn't say interface for data storage

fallow violet
humble tulip
#

I'm just talking about kits

desert tinsel
knotty meteor
#

How can i add 1 in config if player jumps once?

fallow violet
desert tinsel
#

nope

fallow violet
#

mmh

desert tinsel
#

i will try to delete all plugins

fallow violet
#

can you send the complete error?

#

?paste

undone axleBOT
restive tangle
#

CustomKit has a constructor.

desert tinsel
restive tangle
fallow violet
#

can you send the Main class?

#

wait

eternal night
#

your JoinCommand is the culprit

#

it is calling new Main() somewhere

#

in its constructor to be precise

fallow violet
#

agree

humble tulip
#

@restive tangle ??????

#

I'm confused as to what u want

#

Jjst extend kit and call it abilitykit

#

Add some abstract methods such as getAbilityName

#

And applyAbility

#

Or whatever

latent pelican
#

Hi, how can I break out of an Repeating Task with Scheduler if my if statement has occured?

eternal night
#

You can cancel it if you have a reference to its bukkit task

latent pelican
#

What does that mean

eternal night
#

the runTaskTimer method has an overload that takes a consumer

reef lagoon
# river oracle It definitely let's you execute stuff
public void onDisable() {
        EmbedBuilder builder2 = new EmbedBuilder()
                .setAuthor(
                        "Server Status"
                );

        builder2.setDescription("The server stopped! :red_circle:");
        builder2.setColor(Color.RED);
        if (jda != null) jda.shutdownNow();
        if (chatChannel == null) return;
    }``` this didn't send anything
river oracle
#

@Override moment

eternal night
#

e.g.

runTaskTimer(plugin, task -> {
  if(somethingBadStopTask) { task.cancel(); return; }

  doOtherSTuffHereEveryTickOnMainThread
}, 0, 0)
river oracle
#

But who am i

eternal night
#

I mean

#

am I missing something or are you just not sending the embedBuilder

#

lol

latent pelican
#

`
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
if ((p.getLocation().getBlock()).equals(new Location(p.getWorld(), 1.0, -60.0, 10.0).getBlock())) {
long timeMillis_end = System.currentTimeMillis();
long timeSeconds = TimeUnit.MILLISECONDS.toSeconds(timeMillis_end-timeMillis_start);
p.sendMessage("Time: " + timeSeconds + "Seconds");

        }
        }, 0, 5);

`

river oracle
#

Who knows

eternal night
#

scheduleSyncRepeatingTask is the same as runTaskTimer

latent pelican
#

Thats my curent code, I am using Schedulesyncrepeatingtask, not tasktimer

eternal night
#

just that instead of bukkit runnable you can use a consumer<BukkitTask>

#

they are passing a runnable

#

not a bukkit task

#

there is no this.cancel() in a runnable

fallow violet
#

oh im sorry

latent pelican
#

So what would that mean for my code

eternal night
#

you replace scheduleSyncRepeatingTask with runTaskTimer

#

and then () -> with task ->

#

now you can call task.cancel() inside the lambda

reef lagoon
eternal night
#

@Override does not matter btw

#

you should add it

#

but your method would still override its parent method even without the annotation

river oracle
#

Oh ASakashrug I just use it didn't know you didn't need it

eternal night
#

I mean you should

reef lagoon
#

Why is it not doing anything then

#

vars are set

eternal night
#

never a reason to not do it and skipping it for sure is bad practice

#

are you sending it now ...