#help-development

1 messages ยท Page 2295 of 1

noble lantern
#

you can just check if the constructor argument is a subclass of JavaPlugin if you like

#

and then provide your plugins instance

#

i just prefer to check for my own class subclass because my plugin extends BurchAPI

#

if you want just rip that whole class

#

and replace invokeClass with your DI needs

sterile token
#

I cannot use DI

#

Because i dont know if people will use Di with which class

#

That the main issue

#

๐Ÿ˜ฌ

#

I wont know if people ill use constructors on command class for example, maybe yes maybe not

noble lantern
#

and store theyre JavaPlugin class instance as a generic

sterile token
#

More things lmao

noble lantern
#

look at my code

#

constructors are ALWAYS in java

#

unless privated/protected

#

thats why you catch invocation errors

#

and then tell the API user that theyre methods need to be public

#

but by default java provides a public constructor with no args

sterile token
#

But what if they add some randoms args that i dont know then i cannot initialize

noble lantern
#

then you ignore those ones

#

and tell them constructors can only have DI arguments

sterile token
#

๐Ÿ˜‚

noble lantern
#

just dont register the command?

#

and it never gets called

#

throw a error message into console

#

"CommandXYZ will not be loaded due to a invalid command constructor"

#

then continue in your loading loop

#

typically you wont need more than your plugins instance in a command

#

most people who know java make getters in the main class like instance.getPlayerDataService()

#

passing any other args to a command constructor doesnt rly make sense

Since @Command sets everything about the command you need

sterile token
#

too much things for a simple deal

noble lantern
#

well overall this kind of thing isnt simple, but not overly complex either

sterile token
#

I ill just do them to save a Map<Command, Class>

noble lantern
#

just a lot of boilerplate is all

#

thats fine

sterile token
#

So them i force to pass the class instance ith args already

noble lantern
#

saves a lot of overhead when getting classes and stuff

#

how about something better

#

if your annotations are set at runtime retention

sterile token
#

Yep the Command class has runtime rentetion

#

๐Ÿ˜‚

noble lantern
#

make users extend a Command class, and then make them pass a instance to registerCommand() in your command class handler

#

and you dont need to handle anything besides annotations

#

all object in java have getClass()

#

use that to get the annotations

#

and you wont need to worry about the constructor then

sterile token
#

So them just do something like:

CommandAPi#register(class implementing CommandData)

noble lantern
#

yep!

#

tbf its not needed

sterile token
#

tbf?

noble lantern
#

well kinda maybe

#

not sure entire

#

to be fair

sterile token
#

oh ok

noble lantern
#

i just use it so its easier to store in a list

#

cause theylle all be instances of each other

#

My user extend ApiCommand

sterile token
#

I also want something diff

noble lantern
#

that way i can shove theyre command class into the command map

#

without any special processing

sterile token
#

Because i want to each class contains many commands (each boolean method + annotated with @Command = new command)

  • Burch
noble lantern
#

ohhh

#

interesting okay

#

so like each method is a boolean annotated with @Command

#

in that case u dont need the extension

last swift
#

I'm modifying the vanilla knockback and damage, but I'm having issues with calculating the damage of armor and whatnot. The final damage doesn't seem to calculate for armor, so how can I work around this and calculate it properly?

// Works, but doesn't account for armor
double damageFinal = event.getFinalDamage();
Bukkit.getScheduler().runTask(app, () -> {
  double health = player.getHealth() - damageFinal;
  if (health < 0.0) {
    health = 0.1;
  }
  player.setHealth(health);
});

// Everything below works properly
Combat.sendDamageAnim(event.getDamager(), player); // Sends the animation packet                    
Combat.applyKnockback(player, damager, 0); // Applies custom knockback
noble lantern
#

just scan theyre JavaObject.getClass() methods for the annotated methods and your chillin

#

and it can be any class that way

sterile token
noble lantern
#
registerCommand(new MyCommandDoesntMatterWhatItExtends(arg1, arg2, arg2));

public void registerCommand(Object obj) {
    obj.getClass(); // run through its methods here to search for annotated methods
}
noble lantern
#

just make sure you annotations have runtime retention or you wont be able to use them

I think IDE already warns you for that tho

sterile token
#

Burch do you have kotlin experience?

noble lantern
#

Use Damagable @last swift

noble lantern
sterile token
#

Oh sorry for being ass-hole but i having some more issues :/

noble lantern
#

your not xD

sterile token
#

I have a protection plugin with next modules: core, 1.19 and 1.12

#

And im thinking i will face flags issue

#

๐Ÿ˜ฌ

noble lantern
#

I have 0 idea how to do maven modules

Might be a question for smile or conclure

sterile token
#

No no

noble lantern
#

oh okay

sterile token
#

There no isue with that

noble lantern
#

wym by flag issues then?

sterile token
#

Because some flags are version dependent i think, something like animas protection flag and mobs

#

I call flags to special atribbutes that allow/disallow something

noble lantern
#

ohh

#

do they not have like a getSomething(String) method?

#

like with Material.getMaterial?

sterile token
#

I keep a track of a List<Flag> on my core claim object

noble lantern
#

Flag

sterile token
#

But i dont know how to that flags i mention before (animals and mobs protection) because they are version dependent

noble lantern
#

or is it FLags

sterile token
#

Flag is an enum

noble lantern
#

I dont see any bukkit Flag classes

sterile token
#

No no

#

Flag is a custom clas

#

๐Ÿ˜‚

noble lantern
#

What does it store?

sterile token
#

My bad i didnt explain you

sterile token
#

Which contains all flags

noble lantern
#

better yet, how do you get the anims and stuff?

#

WHats the code for that

#

i need need the object names of how you get the animation ids and stuff

sterile token
#

Yeah that my question, because the flags that are not version dependent like command protections are created inside the core module

noble lantern
#

Like is there AnimationSomething.SWING_ARM?

#

cause idk how your getitng all this stuff

sterile token
noble lantern
#

I just need the class name

#

is all

#

like a code snippet of how you play animations etc

sterile token
#

As animals and mobs are diff in 1.12 and 1.19 what do i need to do? Listen to special flag on each plugin module or in the core?

noble lantern
#

i just wanna see the methods of the class

sterile token
#

Do i explain?

noble lantern
#

im just trying to figure out

#

how your using the flag enums...

sterile token
#

Oh let me use translator so its better

noble lantern
#

like the code your using

#

i just need the code your using that enum class in cause idk what your doing

sterile token
noble lantern
#

are these stored into PDT?

sterile token
#

PDT?

#

On Claim object i keep track of flag in a List<Flag>

noble lantern
#

So if this is your plugin why would it be version dependent?

sterile token
#

And then on the core i listen to block place, delete and command, check if flag is enabled and allow/disallow the action

sterile token
#

Because on 1.19 are not the same mobs that 1.12

noble lantern
#

ohh

#

EntityTypes?

sterile token
#

Yes

noble lantern
#

Ohhhh

#

sec

sterile token
#

That why

#

Im asking if need to listen to flags on the core or each plugin module

#

๐Ÿ˜‚

noble lantern
sterile token
#

A friend told me to code the full project on 1 module but using spigot api 1.13 but im not sure. So them i created 3 modules core (common things), plugin 1.12 and plugin 1.19

noble lantern
#

I would personally never develop 3 seperate code bases

sterile token
#

But would work what my friend said?

#

Because let say if i code the plugin in that way then some mobs and animals doesnt exists so i will have issues related to flags

#

๐Ÿค”

noble lantern
#

no because your plugin compiles to one jar and it can only depend on one version

That way just sounds like youll be making 3 forks of your plugin, and youll need to release a new resource page for each one

noble lantern
#

always try to use string getters

sterile token
#

He?

#

I dont understand that

#

Im not harcoding anything...

noble lantern
#

your Flag class wont be an issue its the entity types that will

sterile token
#

I still didnt code the mobs and animals flags

noble lantern
#

then in that case

sterile token
#

what u suggest

noble lantern
#

it will be version safe

#

for any version that has EntityType class + that method (valueOf is a default java enum method)

#

i would wrap it tho

sterile token
#

Im not mainly understanding :/

#

Sorry bro

jade roost
#

how do i make a custom ban message so it doesnt be the default message

package no;

import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;

public class BanListener implements Listener {

    @EventHandler
    public void onPlayerJoin(PlayerLoginEvent e) {
        Player player = e.getPlayer();
        if(player.isBanned()) {
            player.kickPlayer(ChatColor.translateAlternateColorCodes('&', "&cno"));
        }
    }
}
noble lantern
#
public EntityType getType(String type) {
    try {
        return EntityType.valuedOf(type);
    } catch (IllegalArgumentException | NullPointerException ignored) {
        return null;
    }
}

    if (getType("HUSK") == null) {
        Bukkit.getLogger().info("Please use a version that supports husks!");
    }
sterile token
#

I know what you mean

noble lantern
#

:))

jade roost
#

e

jade roost
#

i wonder what kind of big brain move i did there

#

XD

noble lantern
#

Does that not already change the kick message?

#

If not, use AsyncPlayerPreLoginEvent

#

(You should use that anyways)

jade roost
#

k now i am gonna go to the docs

noble lantern
#

kicking in this event should set the message

#

or disallowing cause thats how that events used

jade roost
#

ik

#

ok and i dont know how to use AsyncPlayerPreLoginEvent

#

e yes

#

uh

#

how do i get players name

#

cuz

#

i am stupid

#

;-;

noble lantern
#

just get slot 0 and check its meta data

jade roost
#

brb

noble lantern
jade roost
#

yea nvm

noble lantern
#

?paste use this

undone axleBOT
river oracle
#

?paste

undone axleBOT
river oracle
#

use this

#

?paste

undone axleBOT
unkempt peak
#

Put it in a paste

noble lantern
#

You are checking if a player name is test

#

not an item name

jade roost
river oracle
#

hmmm is the player an item now?

river oracle
#

use their uuid instead Player#getUniquieID

noble lantern
#

if (player instanceof ItemStack stack) {}

river oracle
jade roost
noble lantern
#

oh true true

#

that way u dont get exceptions

river oracle
#

yep

noble lantern
#

and bugs and stuff

noble lantern
#

sec

jade roost
#

listen

#

i started java

#

like

#

2 days ago

#

i am noob

river oracle
#

spare him don't do it ๐Ÿ˜ญ

noble lantern
#

Better idea:

  1. Learn more java

  2. Take the UUID, pass it to OfflinePlayer then getName() of that player

#

BanList seems to be handlred horribly

#

like excuse me?

#

we ban off names spigot?

#

spigot?

river oracle
#

i wish I could PR to change that xD

noble lantern
#

ikr

#

now i remember why i stored bans myself when i did it

noble lantern
river oracle
#

yes I gotch you gimme a second

noble lantern
#

it does support IP's

#

if you get the IP list you can search via ip

#

but no uuid tf

#

prolly because bans.json is so aids

river oracle
#
@EventHandler
// I was just spoonfed like a baby :)
public void onSpoonFeed(SpoonfeedEvent event){
  event.setCancelled(true);
}
noble lantern
#

you forgot @EventHandler

river oracle
#

mb

noble lantern
#

pooog

#

it should work

#

its on line 1 therefore it cancels the item in the first item slot

river oracle
#

SpoonfeedEvent is an alternative

noble lantern
#

So does anyone have a real question

#

sigh

jade roost
river oracle
river oracle
#

@ivory sleet wanna help this guy for us :)

noble lantern
#

ty

#

mf made me delete everything i was typing

noble lantern
#

so you need to use OfflinePlayer

jade roost
#

oh

#

OH

noble lantern
#

Bukkit.getOfflinePlayer(uuid)

#

and use the name provided from that

noble lantern
#

i need ideas on some dickhead things he can do

river oracle
#

not sure if this is possible but a fine idea

noble lantern
#

its hard to get away from him

#

he does this thing called creepy teleport

gleaming grove
noble lantern
#

where he teleports offset 20 blocks then darts at you 5x speed

#

@quaint mantle

#

pls help

noble lantern
#

i could make a tecture pack ngl

#

omg

#

thank you jacek

quaint mantle
#

?ban @pastel copper

undone axleBOT
#

Done. That felt good.

noble lantern
#

Whats an un-used sound in MC anyone know?

river oracle
noble lantern
#

big pog

gleaming grove
#

you dont need to override voice

noble lantern
#

no you just replace a sound in the game

#

in the texture pack

#

and then play that sound to client

gleaming grove
#

but you can add brand new sound in texturepack

noble lantern
#

can you call it in spigot?

#

IIRC spigot uses Sound enum to play sounds

gleaming grove
#

ye

#

I give you example code in priv

noble lantern
#

unless theres another method idk about

#

kk

gleaming grove
#

ok i;ve sended it

noble lantern
#

alright codes added now to just find leeroy jenkins audio

#

perfect

#

time to test kek

worldly ingot
#

Creative variable names

noble lantern
#

indeed, he does do that too

#

only issue it that youtube vid didnt covnert to ogg properly

#

oh my god

#

this gonna be hilarious

#

pathfinding fucked up at the start but still funny

buoyant viper
noble lantern
#

can you imagine hearing that ever time you clicked a button

#

"LEEROOOYYY JENKIINNS"

noble lantern
buoyant viper
#

goes to change settings

#

speeds through menus

#

LEEEEROOOYYYY- LEEEROOOYYYY- LEERROOOOOOYYY JENNKKKIIINNNNSSS

noble lantern
#

im gonna have waaay to much fun with these sounds

#

im gonna make leeroy a fucking menace

gleaming grove
#

XD

noble lantern
#

i wish he didnt go all bobbly tho

#

YES

gleaming grove
#

i;m waiting for better skin

noble lantern
noble lantern
glossy scroll
#

i need a little bit of help figure out OutputStreams

#
                try (FileOutputStream fos = new FileOutputStream(file);
                     ByteArrayOutputStream bos = new ByteArrayOutputStream();
                     ObjectOutputStream oos = new ObjectOutputStream(bos)) {

                    room.serialize(oos, getWorld());
                    oos.flush();
                    byte[] bytes = bos.toByteArray();
                    bos.flush();
}```
#

what would be the purpose of flushing the ByteArrayOutputStream

#

actually it seems to be nothing

#

because flush doesn't do anything in the superclass

#

and ByteArray... doesnt override flush

#

so my question has been answered

noble lantern
#

the purpose of flush() is to remove everything in the current buffer

#

its good if your re-using a output stream and want to make sure nothings on the buffer before doing your next thing

#

but if your using it once you can just close it iirc

i like to flush then close tho

glossy scroll
#

yes thank you

#

@noble lantern also reset() to continue using the stream?

noble lantern
#

i just re-initialize it ngl

#

prolly not the best way, i assume reset() is propor but i dont use streams long enough for that

#

i just open them for file writing and then close, or for a quick rest request

glossy scroll
#

yea its just that rn it's in a try-clause thing

#

(forgot the right name for it)

#

so theyre effectively final

noble lantern
#

cause you can have nonfinals on try/catch

#

but in lambdas, when setting variables using = they need to be effectively final, or an AtomicReferance

#

i try to avoid situations like this where i can

#

cause i dont like either options

#

sometimes you cant though

ornate patio
#

How would i create a pagination command using this method though

#

i have a couple questions ima just wait for 7smile7

drowsy helm
#

damn 7smile has a whole ass command

ornate patio
noble lantern
drowsy helm
#

what a show off

river oracle
#

He's better than you stay mad

noble lantern
#

Question this is gonna be VERY stupid but I'm desperate because my workaround is total aids

My IDE alerts me "task" might not have been initialized, however it will 100% will always be initialized by then as this timer has ran multiple times by now

How can i mark this as unsafe, or override this method somehow?

drowsy helm
noble lantern
#

yall can just block me ik most stupid question

river oracle
#

Shut up idiot stupid head

echo basalt
drowsy helm
#

yeah was just gonna say

noble lantern
#

BukkitRunnables allow that?

echo basalt
#

you can call cancel() directly

drowsy helm
#

yeah you can cancel internally

noble lantern
#

ohh

#

okay ty

#

my solution was aids lmao

#

the lock is for something else

echo basalt
#

I have a scheduler utility that's just a fancy wrapper to bukkit's scheduler

#

it's stupid as shit

noble lantern
#

yeah i might do the same thing

#

i have a runTask(Runnable, delay) method in my main inherited class

#

but thats it lmfao

echo basalt
#

the code internally just calls the bukkit method after wrapping it around like 8 different classes

noble lantern
#

oh thats a smart one though ngl

#

i would prefer an empty constructor cause im too lazy to get my plugins instance xD

drowsy helm
#

ou ive never seen someone do it like that

#

thats pretty cool

echo basalt
#

I can then do stuff like

task.onCancel(() -> {
  ...
});
noble lantern
#

ohhh functional intefaces

drowsy helm
#

can .run also take lambda?

noble lantern
#

mmmm

echo basalt
#

also if you call every(...) it returns a modiified ScheduledTask thing that allows me to set a duration

echo basalt
noble lantern
#

callbacks in java fun

echo basalt
#
new ScheduleBuilder(plugin)
  .every(1).seconds()
  .run(() -> { 
    Bukkit.broadcastMessage("tick");
  })
  .during(5).minutes()
  .async()
  .onCancel(() -> {
    Bukkit.broadcastMessage("cancelled");
  })
  .start();
noble lantern
#

placeBlockasNpc(loc, Material.DIRT, () -> { // executes after completions });

#

im working on a wrapper class rn actually to build my callback functions like that

#

cause rn my code be looking like

echo basalt
#

completablefuture poor man edition

noble lantern
#

nono

noble lantern
#

it IS a completable future

#

well kinda

#

the function executes async

#

call back to main thread for callback function

echo basalt
#

my man

noble lantern
#

efficient asf too

echo basalt
noble lantern
#

whats that?

#

yeah be careful with that style tho

#

cause youll end up like:

echo basalt
#

it like

#

loads houses from a database

#

and pastes it to a world

#

loading the world

noble lantern
#

kamehameha code

echo basalt
#

that's small

noble lantern
#

i think its ugly imo

#

i wanna do

echo basalt
#

not much I can do about it

noble lantern
#

someTask()
.andThen(anotherTask()
.andThen(() -> {
}));

echo basalt
noble lantern
#

im going to make a builder similar to this

echo basalt
#

that's the method for pasting a house / island

#

๐Ÿคก

#

I only had to rewrite it like 4 times

noble lantern
#

thats not bad though for schematic pasting

echo basalt
#

oh it doesn't paste the schematic

noble lantern
#

oh

echo basalt
#

it just fetches, does some checks

#

unloads and loads when needed

noble lantern
#

ahh

echo basalt
#

it then calls one of the two methods (one for pasting handlers that want a loaded world, the other for unloaded world)

noble lantern
#

illusion have you met leeroy yet?

echo basalt
echo basalt
noble lantern
#

is that for a skyblock plugin?

noble lantern
echo basalt
echo basalt
#

Which then pastes the island :)

#

I've done bigger blobs of code for fake blocks

#

and pasting fake blocks from schematics

#

using multi-block-change packets (one per chunk section)

#

and making a shitty WE api for fake blocks

#

that just has a set method

#

The code for saving islands is actually like a third of the size

#

but 2x as janky

#

because paper decided to be a special little snowflake and save worlds async with no way to know when the worlds are actually saved

#

WorldSaveEvent triggers at the start of the save instead of once the buffers are all flushed

#

so I made an intentional configurable delay

#

๐Ÿคก

#

But if I unload the world as soon as the buffers are all flushed the world may still corrupt

#

so there's another delay on top

noble lantern
echo basalt
#

Fake blocks are for another project

#

where I run like 25 minigame instances at once in a single world

#

because the map doesn't change much

#

The fake blocks are just doors that you can unlock to access other areas of the map

#

So I just set those blocks to air and send fake blocks for the doors

#

unlocking will just sent a premade empty area packet

#

:)

#

But my stupid ass decided to optimize the shit out of it to only use one packet per chunk section, regardless of how many doors or blocks were there

#

And then make it all load out of a schematic

#

I mean it's like 400 lines total

#

And another 100 lines to make sure you can click on those blocks

#

and not just break and bug them out

#

I also made sure to optimize the heck out of it by hashing every single aspect of the block's location

#

AKA making a chunk system

#

For quicker lookup times

tight locust
#

I made a plugin that when a player right clicks a sculk shrieker with a nether star it summons the wither, but when the warden is summoned, the console gets spammed with errors.

Here is my code:
package me.guedosha.summonwarden;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

public final class Summonwarden extends JavaPlugin implements Listener {

@Override
public void onEnable() {
    getServer().getPluginManager().registerEvents(this, this);
}

@EventHandler
public void onDemandSummon(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Block b = event.getClickedBlock();
    Action action = event.getAction();
    ItemStack item = event.getItem();

    if (action == Action.RIGHT_CLICK_BLOCK && b.getType() == Material.SCULK_SHRIEKER && item.getType() == Material.NETHER_STAR) {
        player.getWorld().spawnEntity(b.getLocation(), EntityType.WARDEN);
    }
}

@Override
public void onDisable() {
    // Plugin shutdown logic
}

}

and here is the console error:

noble lantern
#

ahh i see i always wondered uses for fake blocks

#

always seen ppl using em

#

sorry for slow responses working on leeroy

tight locust
echo basalt
#

like a cave entrance you can blow up in an rpg

#

without making a whole world for that

#

I made a whole client-sided tutorial with fake blocks and entities

#

where you had fake menus you could click on

tight locust
# tight locust I made a plugin that when a player right clicks a sculk shrieker with a nether s...

ERROR Could not pass event PlayerInteractEvent to Summonwarden v0.1
20.07 22:25:19 [Server] INFO java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "item" is null
20.07 22:25:19 [Server] INFO at me.guedosha.summonwarden.Summonwarden.onDemandSummon(Summonwarden.java:30) ~[summonwarden-0.1.jar:?]
20.07 22:25:19 [Server] INFO at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1.execute(Unknown Source) ~[?:?]
20.07 22:25:19 [Server] INFO at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
20.07 22:25:19 [Server] INFO at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:git-Purpur-1662]
20.07 22:25:19 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
20.07 22:25:19 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:666) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
20.07 22:25:19 [Server] INFO at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:544) ~[purpur-1.19.jar:git-Purpur-1662]

dim palm
#

Hello, how can i send a action bar for the player 15 times for 15 seconds

#

but i need to the actionbar update

echo basalt
#

or the block is null

echo basalt
#

You need to handle that type of stuff instead of just pasting a block of text and expecting us to spoonfeed you

noble lantern
#

the cursed method comment should say 40 tho

vagrant stratus
#
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
    target = Bukkit.getPlayer(UUID.fromString(args[0]));
    if (target == null) {// Handle null target}
}

Is there a better way of handling this?

#

I could just not do the second check, but you never know lol

noble lantern
#

?paste

undone axleBOT
noble lantern
#

oommmfffgggg

#

i hate pasting code man

#

so FUCKING annoying

#

@vagrant stratus

#

UUID throws that exception if invalid one is provided

#

i prolly fucked the ternary up maybe

#

i did

#

reverse the last 2 parts of ut

#

uuid first then string

vagrant stratus
#

I keep forgetting ?: is a thing ๐Ÿ˜‚

noble lantern
#

i did too and i was looking at that like hmm

#

and it popped into my mind

#

i 100% never use them in my own code

carmine nacelle
#

Anyone versed in ProtocolLib? I used to have this working before updating and such (and decompiling my src from before, might have screwed it)

noble lantern
#

why are you decompiling your src

#

sounds sus

vagrant stratus
#

I'll most likely use them within my Anti-Malware more when I rewrite lol

carmine nacelle
#

โœจ windows corrupted and i didnt have a backup anywhere โœจ

vagrant stratus
#

github ๐Ÿ˜„

noble lantern
#

^^

carmine nacelle
#

well yeah i know that now.

noble lantern
#

your decompiled source is likely fucked to shit with the variable names and other things

#

unless you compiled with the original jar

#

that one has your pom and stuff still in it

#

so if you can manage to find that jar ๐Ÿ‘Œ

carmine nacelle
#

I already fixed all of it except this part

#

ive spent the past week unfucking it

#

now im to this point

echo basalt
#

What you need?

carmine nacelle
#

getting this error

#
        this.protocolManager.addPacketListener(new PacketAdapter(this.cadiaBees, ListenerPriority.NORMAL, PacketType.Play.Client.CHAT){

            public void onPacketReceiving(PacketEvent event) {
                PacketContainer packet = event.getPacket();
                Player player = event.getPlayer();

                CustomHive customHive = cadiaBees.hiveGUI.getPlayerInteractingHive(player);
                PersistentDataContainer container = cadiaBees.hiveManager.getBlockForHive(customHive);

                if (container != null && cadiaBees.hiveManager.getPlayerNamingHiveTask(player) != null) {
                    event.setCancelled(true);
                    String newName = packet.getStrings().read(0);
                    if (newName.equalsIgnoreCase("cancel")) {
                        player.sendTitle(ChatColor.YELLOW + "Hive-Naming Cancelled", "", 20, 40, 40);
                        player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
                        cadiaBees.hiveManager.getPlayerNamingHiveTask(player).cancel();
                        cadiaBees.hiveManager.removePlayerNamingHiveTask(player);
                        return;
                    }
                    if (newName.length() > 35) {
                        player.sendMessage(ChatColor.RED + "The max length for a hive name is " + ChatColor.GRAY + "25" + ChatColor.RED + " characters!");
                        player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
                        return;
                    }
                    cadiaBees.hivePDCManager.setHiveName(container, ChatColor.translateAlternateColorCodes('&', newName));
                    player.sendTitle(ChatColor.translateAlternateColorCodes('&', newName), ChatColor.GRAY + "Hive successfully renamed!.", 20, 40, 40);
                    player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_YES, 1.0f, 1.0f);
                    cadiaBees.hiveHoloManager.getHolosForHive(customHive).get(0).getHoloLines().set(0, ChatColor.translateAlternateColorCodes('&', newName));
                    for (Player allPlayers : Bukkit.getOnlinePlayers()) {
                        cadiaBees.cadiaCore.hologramManager.refreshHolo(allPlayers, cadiaBees.hiveHoloManager.getHolosForHive(customHive).get(0));
                    }
                    cadiaBees.hiveManager.getPlayerNamingHiveTask(player).cancel();
                    cadiaBees.hiveManager.removePlayerNamingHiveTask(player);
                    cadiaBees.hiveGUI.removePlayerInteractingHive(player);
                }
            }
        });

listener

gleaming grove
#

How to trigger command in server for a player?

noble lantern
#

CommandSender inherits Player iirc

#

or visa versa

echo basalt
#

what's HivePDCManager#93

#

blockIsPlayerHive

gleaming grove
#

thx

carmine nacelle
# echo basalt Packets are being read async
    public boolean blockIsPlayerHive(Block hiveBlock) {
        Beehive playerHive = (Beehive) hiveBlock.getState();

        if(playerHive.getPersistentDataContainer() == null) return false;
        NamespacedKey hiveCustomKey = new NamespacedKey(cadiaBees, "custom-hive");

        if(playerHive.getPersistentDataContainer().has(hiveCustomKey, PersistentDataType.INTEGER)) {
            return true;
        }

        return false;
    }
echo basalt
#

yeah naw

#

you're checking blockstates async

carmine nacelle
#

F

#

isnt there a function to run them sync

earnest forum
#

BukkitScheduler#runTask

echo basalt
#

you can just use the scheduler for that

#

but that would kill packet cancelling

carmine nacelle
#

I thought there was a lambda thing

echo basalt
#

regardless why aren't you using a chat event for this kind of stuff?

carmine nacelle
#

they dont need to be cancelled so its fine

echo basalt
#

you literally cancel the packet event

earnest forum
#

pass in a lambda in the runTask

carmine nacelle
#

well if I cant cancel it from sending the message thats an issue

#

idk why i have this in a packet listener tbh..

carmine nacelle
#

holy shit i got it

#

well..cant cancel i need to

noble lantern
#

(if thats your issue)

#

i see yada mentioned that too

noble lantern
carmine nacelle
#

WOOOO GOT IT

#

LES GO

#

thanks guys i didnt know it was a sync/async issue

bold solstice
#

Anyone knows how to detonate a firework instantly?

noble lantern
#

hmm

#

sec

#

You have a Projectile instance right?

#

detonate()

#

wait

#

sorry

#

sec

#

i assume you tried that?

#

or not yet

bold solstice
#

yea I did

#

it used to work

noble lantern
#

yeah figured

bold solstice
#

now it stopped for some reason

noble lantern
#

yeah i cant find any methods for actually setting the fuse time hmmm

#

PrimedTNT has setFuseTicks

#

maybe theres another type for firework or something

#

lemme find

#

damn

#

why is that so complicated lmfao

bold solstice
#

yea xD

noble lantern
bold solstice
#

Ive looked up in some forums and they said i need to delay the fuse in a few ticks so it will do, I delayed in 10 ticks and it still didn't work

noble lantern
#

Sounds like its gonna need some seriously tricky packet trickery, or fake fireworks

Or we need 7smile7 or choco

#

7smile offline rn tho

bold solstice
#

I dont know how to use packets xD

#

I only used the regular bukkit api

gleaming grove
#

Does somebody know if resoucepack could be download from public FTP with this code?

#

event.getPlayer().setTexturePack(settings.getFtpTexturesURL());

noble lantern
#

just as long as the url returns the direct file

#

eg with dropbox, you have to change the end of the link to dl=1 that way the url returns the file

#

not sure how exactly it needs to be returned tho

gleaming grove
#

sounds promising

midnight patrol
#

anyone have a link to the namespacekey of vanilla recipes? including smelting recipes

small current
#

i done this

#

does this look like instant ?

hybrid spoke
hybrid spoke
noble lantern
#

HAHAHA

#

to give credit on the guy i sent

#

that is a rather weird thing to do cause you cant edit the fuse time

tender shard
#

someone might have an answer and now people just find a closed thread on google without any answer and no way to reply

#

so useless

hardy swan
#

noob question, can there be Block above build limit?

#

ok yes it should be

#

thanks

small current
#

โ€i copied this multiversion setUnbreakable from spigot forums, will this work ?

loud junco
#

ItemMeta already has a setUnbreakable tho, or?

noble lantern
#

not on older versions iirc

loud junco
#

Found that itemmeta.spigot().setUnbreakable() exists on lower versions, probably wont exists on newer, maybe set the durability to Integer.MAX_VALUE

#

not sure if that code sent would work, best thing is to try it ๐Ÿ‘

noble lantern
#

man maven is the most

#

stupidest fucking shit ever

#

god why do people use this pile of shit

#

the repos are literally harded as https

ivory sleet
#

Yep maven bad (:

noble lantern
#

like you cant even access these urls with http

#

and mavens saying theyre http...

#

invalidated caches... added a mirror to settings.xml...

#

none of it worked whytho

#

Is there any fix for this?

round eagle
#

is there a way to allow players from a certain server (not a proxy) to join another server?

for example, players can join server1 through server2, but they cannot directly join server1

context: i have a waiting lobby which is a bungee instance. the waiting lobby is not a proxy (again). they should go from the proxy to server1, and the from there to server2

ivory sleet
#

Yeah

#

You can write a proxy plugin that manages it

noble lantern
#

if it used a older version from the repo it redirected as http.... so you need the LATEST....

round eagle
#

wouldnt that be sketchy

#

someone could manipulate or abuse the response

ivory sleet
#

Wait wat

#

abuse the response?

pliant plover
#

Is there any way of putting Multiple Locations into world.dropItem(); Because every Time I fire the Command, the Server Crashes when it gets to the point of dropping items

earnest forum
#

?learnjava

undone axleBOT
charred blaze
#

java.lang.ExceptionInInitializerError: null
at MultyBot.SQLUtils.<clinit>(SQLUtils.java:14) ~[?:?]

earnest forum
#
 b[0] = false;
``` is not valid java code
hybrid spoke
charred blaze
hybrid spoke
#

because it hasnt been initialized first?

charred blaze
#

how to initialize it first?

hybrid spoke
#

you cant in this context. you will have to set your variable afterwards

#

your constructor only gets called if you create a new instance of that class. your static variables are initialized once the class has been loaded. because of that it doesn't know the plugin var yet

earnest forum
#

it is not wrong

#

that is correct

#

because it is static

#

you use ClassName.b = false

vale ember
#

i wonder how is it supposed to run if the runnable part is outside of any method/constructor/initializer?

tall dragon
#

yea how does that even work

earnest forum
#

.runTaskLater(plugin, 20 * 5);

#

at the end of the runnable initialize

#

its the same as doing BukkitScheduler.runTaskLater(runnable)

#

no

#

i mean

#

thats what you should be using

#

if you have a class named TestClass and it has a public static boolean b you use TestClass.b to access it

#

u should learn java

#

?learnjava

undone axleBOT
earnest forum
#

you don't have a good enough understanding to be programming with spigot

#

not a good idea

#

well in this server we help with spigot

#

not java

#

i just had to explain a very basic concept to you

charred blaze
earnest forum
#

its expected that you have atleast a basic understanding of java's syntax

native gale
#

Hello

agile anvil
#

(Not sure it's the thing you are looking bu found it Quickly on the doc on my phone)

native gale
#

Sorry, I sent a wrong version of API I am working with

#

Lemme sec

#

Here

agile anvil
native gale
#

Idk about that, I need the name of the advancement, not just the key

agile anvil
#

Two options :

  • create a namespace id converter (so you have to save all the name and put them next to a key)
  • maybe there is a translation file containing all of this
mental nymph
#

how to hide a C418 - mellohi lore on disc?

agile anvil
agile anvil
tardy delta
#

Set it in the constructor

#

Why making a field static if you set it in the constructor tho

charred blaze
tardy delta
#

Set the URL field in the constructot

charred blaze
proven ocean
#

Hey hey, does anybody know what meta to use for changing the sound of a goat horn? Or in general how to change the instrument of a goat horn

charred blaze
charred blaze
maiden thicket
proven ocean
maiden thicket
#

initialize url in the constructor

noble forge
proven ocean
#

is it possible with the spigot api?

noble forge
#

yeah lol

charred blaze
#

how

proven ocean
#

what's the method called ๐Ÿ‘‰ ๐Ÿ‘ˆ

maiden thicket
charred blaze
#

what do you call "initialize"

proven ocean
supple elk
#

How does the nether work? I have multiple world folders for the plugin I'm making. Each one has it's own nether right?

#

There's the event 'PlayerChangeWorldEvent', which triggers on a change between any world. I'd like to detect when a player changes between world folders

#

how would I do that?

noble forge
#

theres no goat horn meta

#

how could md_5 forget the goat horn

supple elk
#

I've already found my answer ๐Ÿคฆโ€โ™‚๏ธ

proven ocean
#

I saw there were already some threads from june...

charred blaze
#

isnt it already initialized?

vale ember
#

it's initialized statically

noble forge
#

bruh

noble forge
#

how is it so hard to add this

#

there are some wip pr's already

vale ember
noble forge
#

otherwise just use nms

#

or a library

charred blaze
vale ember
lost matrix
lost matrix
quaint mantle
#

How can I check if item is named?

lost matrix
charred blaze
#

how to use plugin.getDataFolder() in my url variable?

quaint mantle
#

Ok thanks

maiden thicket
charred blaze
lost matrix
maiden thicket
#

replace everything

#

with an ; after url

#

and then in your constructor

#

initialize it

charred blaze
#

whaat

lost matrix
# charred blaze whaat

Make it not static.
Just write your plugin without the static keyword.
This will help your understand what static does.

supple elk
#

What happens if you unload a world when a player is in it?

eternal oxide
#

NEVER use static, unless someone who knows how to write Java tells you to

charred blaze
lost matrix
supple elk
#

mk

charred blaze
eternal oxide
#

I thought it just failed to unload the world, but I may be wrong

charred blaze
#

remove final from plugin?

lost matrix
charred blaze
lost matrix
charred blaze
#

a

lost matrix
#

Using a database before understanding java is just bound to cause problems and increases your development time immensely.

hot wolf
#

I made an economy plugin and I require some data from thata database in another plugin. What is the best way to make an api? Are there any guides or docs you can recommend for that? Because I need a BalanceChange event which I can access from the other plugin and I have to be able to read the balance of a player.

lost matrix
hot wolf
#

but is there a doc or smth you could recommend? I think I'll be able to figure it out from there

lost matrix
eternal oxide
#

Events are not hard to design and subscrib to

hot wolf
lost matrix
#
  • Dont forget the static handler list
hot wolf
tardy delta
#

Don't forget to implement cancellable ig

hot wolf
hot wolf
#

๐Ÿง

#

lol

eternal oxide
#

7-8 years ago I wrote that code ๐Ÿ™‚

grim ice
#
  • why the heck are you using eclipse
lost matrix
hot wolf
lost matrix
#

Always forget how long elgarl is around here already

eternal oxide
#

I use Eclipse. I love it amd thats why I use it

hot wolf
#

hm

hot wolf
eternal oxide
#

Yeah I tried IJ but I actually didn't like it.

#

That was a like 5 or so years ago

grim ice
#

im not a fan of modern ui and stuff but honestly eclipse is too much

#

it hurts my eyes

hot wolf
eternal oxide
#

Only two issues I have with Eclipse.

  1. You can;t resize the toolbar, so icons are really small on large monitors.
  2. Nested Modules are treated as separate projects.
tardy delta
#

my eyes dont want to work today :(

quaint mantle
#

I ment like how do I check if item is named with an anvil or if it just has its vanilla name

#

boolean isVanillaName = meta.getDisplayName().equals("");

#

That works but is it a good way tho?

supple elk
#

Advantages/Disadvantages of these approaches?

tardy delta
#

no need for a click method ig

supple elk
#

they both have click methods don't they?

tardy delta
#

actually the constructor way looks cleaner to me

hybrid spoke
#

are all these errors

#

or is this your theme

tardy delta
#

looks like theme

#

lmfao

quaint mantle
#

Weird theme

tardy delta
#

no u

supple elk
#

it's a pog theme

#

underlining is for errors

tardy delta
#

this theme looks hot but its only for vscode :(

hybrid spoke
#

just use the mario plugin

tardy delta
#

whas that

hybrid spoke
#

super mario theme in intellij

supple elk
hybrid spoke
#

with sounds

noble forge
#

Is there a better way of iterating through all players in a world to get the closest one to a particular position, other than using Bukkit.getOnlinePlayers()?

hybrid spoke
#

blocks

#

entities i believe

#

every key you hit makes a sound

tardy delta
#

World#getOnlinePlayers

hybrid spoke
#

enter is a kabooom

#

and you have chill mario background music

tardy delta
#

sounds horrible

hybrid spoke
#

sounds great

lost matrix
tardy delta
#

huh

noble forge
#

but is that better than manually iterating?

#

thanks for all the answers btw, wow

glossy venture
lost matrix
tardy delta
#

is a thing

glossy venture
#

except yellow variables

tardy delta
noble forge
#

I only have spigot as a dependency

lost matrix
tardy delta
#

nobody listening to me smh

lost matrix
tardy delta
#

๐Ÿ‘‰๐Ÿ‘ˆ

#

dunno what happened with my eyes

noble forge
tardy delta
#

everything looks blurred

lost matrix
# noble forge

I would always prefer api methods over self written ones and then
hope that the underlying implementation is decent.

tardy delta
#

spigot api lol

noble forge
#

oo

tardy delta
#

can someone verify if am still alive?

noble forge
#

not really

noble forge
#

it looks cleaner

#

so ill use that

lost matrix
noble forge
#

there is tho

lost matrix
noble forge
#

o wait

#

I might have misphrased a bit

#

I just wanted to get the nearby players within a certain radius to a point

#

I can just use

lost matrix
#

Oh. Thats a completely different task. Then def use this method.

tardy delta
#

oh thats a method too

noble forge
#

I mean not completely different

lost matrix
noble forge
#

but where the heck does it come from

#

my only dependency is spigot and nms

lost matrix
noble forge
#

how

lost matrix
#

You have it on your classpath

noble forge
#

huh

#

weird?

lost matrix
#

Are you using maven or gradle?

noble forge
#

maven

#

o wait

lost matrix
#

And you didnt add any jars manually?

noble forge
#

it seems like someone added paper as a dependency

#

oop

lost matrix
#

I see

noble forge
#

if its available i might as well use it

#

otherwise I would manually iterate through the players

lost matrix
noble forge
#

I think it depends on how many entities are nearby too

#

if the nearby entities is more than the total amount of players it would be better to iterate through all players instead right?

tardy delta
#

Player.class.isInstance :(((

noble forge
#

lol

#

instanceof

noble lantern
#

no way isInstance is a thing

tardy delta
#

method references :((((

hardy swan
#

are leaves transparent

hardy swan
lost matrix
tardy delta
#

Class#isInstance

#

why not

#

well ye instanceof works too

lost matrix
#

Oh you mean for the Predicate

tardy delta
#

yep

lost matrix
#

Yes you could also use Player.class::isInstance

tardy delta
hardy swan
#

fastest way to check if block is leave

tardy delta
#

Tag.LEAVES.isTagged(material)

hardy swan
#

That

#

's very sick

#

ty

tardy delta
#

not sure if thats the fastest but its one line ๐Ÿ˜

#

ij just crashed by looking at that method smh

noble lantern
#

Any maven wizards?

How can i take an entire package from my plugin, and treat it as provided? Eg not compiling the files into my jar file, but still allow compiling

hardy swan
#

wdym, you want to expose certain "APIs" from your plugin?

noble lantern
#

me?

tardy delta
#

no that chicken crossing the road

noble lantern
#

if it's me, I need to do it because when importing citizensapi NMS methods they're remapped oddly, but in their source code they're not

So i take their classes and manually hard fork them into my jar only copying classes I need

These classes shouldn't be hard compiled in, they should be as provided but I'm unable to do it via maven repo due to the remappings

Hence why i want the files removed and treated as "provided"

#

doubt its possible

#

but worth asking

tardy delta
#

no its not you

hardy swan
#

try play around it and see jar contents

limber owl
#

hello, so i have3 servers (in theory) and on one server is my minigame and the other is lobby, 3rd is bungee, how do I make that players user /play in lobby and it joins them to the game

limber owl
tardy delta
#

pluginmessaging stuff?

proven ocean
glad prawn
#

Can you tell me, I use the default config file, I add a few things and use reloadConfig. But no data is changed.

proven ocean
#

How can create a Item which has a translatable name? For instance I'm creating a potion with an effect, but I want it's name to be "Potion of Strength" (-> translatable). Because I create it via plugin it's name is "uncraftable potion".

upper vale
glad prawn
eternal oxide
#

You must be saving before you reload which overwrites the manual edits

proven ocean
tall dragon
eternal oxide
#

you want to animate teh chest opening? or you actually want to open it for someone?

proven ocean
noble forge
#

o my bad

#

replied to the wrong message

proven ocean
#

I have this: "item.minecraft.potion.effect.night_vision" and I want this : "Potion of Night Vision" (for every language)

noble forge
#

o wait

#

localized name is not what youre looking for

#

translatable components is what youre looking for I believe

proven ocean
#

I believe so too

#

but how do I put this component ON the item?

#

that's what I'm looking for

#

I believe NMS is the way to go, but I'm clueless how to start

glad prawn
eternal oxide
#

you can;t just be reloading

#

I do this often in many of my plugins so I know it works exactly as it should

upper vale
glad prawn
#

Just save?

proven ocean
#

why should he save if he wants his manual changes to apply?

upper vale
#

,?

eternal oxide
#

He's trying to load in manual changes he made to teh config.yml

upper vale
#

Because heโ€™s making changes by code

upper vale
#

Reloading just gets data from the file again

eternal oxide
#

yes

upper vale
#

Which wouldnโ€™t work becuase the manual changes havenโ€™t been saved yet

eternal oxide
#

Which is why I'm telling him he must be doing something else as well as reload

#

No his MANUAL changes are with a text editor, NOT via code

upper vale
#

Yeah bad wording there mb

eternal oxide
#

I get it wrong often too ๐Ÿ™‚

noble forge
#

Only thread that I found

#

Spigot do be lacking a lot

noble forge
proven ocean
#

Why is vanilla minecraft easier than spigot in terms of custom items / names

glad prawn
proven ocean
lost matrix
noble forge
#

custom items in vanilla are even easier lol

proven ocean
lost matrix
#

Sure but you have to look up every single attribute and you have no type safety.
And proper custom items are straight up impossible in vanilla.

eternal oxide
proven ocean
eternal oxide
#

This is why FileConfiguration config = this.getConfig();

#

you are caching the config

proven ocean
glad prawn
#

saveConfig or not when I reloadConfig gives the same result.

eternal oxide
#

yes

proven ocean
#

ok then maybe ElgarL is right

eternal oxide
#

all of your reference is to your local config variable

proven ocean
#

there are a few things

eternal oxide
#

if you reload and want it in your config you need to (after reload) config = this.getConfig();

proven ocean
#

for instance " List<String> msg = config.getStringList("msg");" is only updated on the beginning. If you reload the config this list won't change

#
 case "reload":
                    if (!sender.hasPermission("be.reload")) return true;
                    reloadConfig();
                    for (String s : this.getConfig().getStringList("msg")) System.out.println(s);
                    break;

try this

tardy delta
lost matrix
# glad prawn Ok. Thanks.

For reloads you should always have a single reload method that makes sure all of your components are reloaded properly.
And your command only calls this method.

For configs: Always load your configs when the server starts.
Dont use FileConfigurations for configs on runtime.
When you reload you simply load all configs into your data classes again and call all needed component initializer.

proven ocean
#
            net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
            NBTTagCompound tag = nmsItemStack.v();
            tag.a("translate", new TranslatableComponent(potionType.getNameLocation() + potionEffectType.getKey().getKey()).getTranslate());
            nmsItemStack.b(tag);

            itemStack = CraftItemStack.asBukkitCopy(nmsItemStack);
            meta = (PotionMeta) itemStack.getItemMeta();
#

that TranslatableComponent doesn't even make sense LMAO

lost matrix