#help-development

1 messages Β· Page 1712 of 1

digital rain
#

worked before i added the inputable feature in game

#

basically before the command was /advancedenchant, iand i added the whole args thing so that i can input values into there

#

so im guessing that the int or char isnt getting converted from string

#

just not sure

solid cargo
#

why doesnt the effect play

#

like, i changed the effect to another and it worked

#

but VILLAGER_PLANT_GROW doesnt work

tardy delta
#

a villager who is planting weed

solid cargo
#

its for a join effect

#

i need that green emerald particle

digital rain
solid cargo
#

oh looks like i used playEffect instead of spawnParticle. im dumb :D

digital rain
#

oh

#

lol

#

i still cant find that particle on the list

solid cargo
#

player.spawnParticle(Particle.DRAGON_BREATH, player.getLocation(), 1) this straight up aint working. also no errors

kind coral
#

Questions

worldly ingot
#

ItemMeta#getLore() can return null if the item doesn't have lore

#
List<String> lore = meta.getLore();
if (lore == null) {
    lore = new ArrayList<>();
}

lore.add("whatever");
meta.setLore(lore);```
digital rain
#

why did it work before tho

worldly ingot
#

The item you had before probably had lore

digital rain
#

oh bc i defined lore before makes sense

#

oh yeah well very much thanks Choco

regal lake
#

How i get all exp points of a player ? (exp and levels converted as exp)

halcyon mica
#

So I made a plugin with the new mojmapped names for nms and shit

#

Is it normal that paper fails to load it then?

tardy delta
#

is there a way to detect another half of a chest next to another and both parts are connected?

tardy delta
#

well i found a post

#

checking if the inventory is instanceof DoubleChestInventory or something

#

and then i need to get the location

eternal oxide
#

DoubleChest has getLeftSide() and getRightSide()

worldly ingot
kindred tusk
#

Hello, if I create a spigot plugin for 1.7.10 will it be available for 1.16 ?

ivory sleet
#

depends

#

but there's a big chance stuff might break in between

kindred tusk
#

I just want to send requests to a minecraft server to be able to perform commands from a website (my plugin will just make the link)

opal juniper
#

uh

#

how would the server know who to send requests to

young knoll
#

I assume it just runs them as console

#

Like DiscordSRV

kindred tusk
quaint mantle
#

what event would be used to detect when a player is at a certain location (x,y,z)

young knoll
#

PlayerMoveEvent

quaint mantle
#

ok thx

solid cargo
#

cant seem to get args.length >= 0 to work

#

it says arrayoutofboundsexception

#

have even tried catching the error

#

it still goes through

solar sable
#

the Material is showing me the error and the error is "Parameter is not a subclass of org.bukkit.event.Event "

young knoll
#

Because it's not an event, but you have the @EventHandler annotation

solar sable
#

ooh

#

my bad

#

how can i not see that

#

im blind

#

there you go, its fixed

#

thank you for fixing my eyes lol

tacit drift
#

πŸ‘“

solar sable
#

i mean i do have eye problems so

#

and ear problems

#

anyways

quaint mantle
#

how do i go about getting the coordinates? tried #getBlockAt

    public void darlandiaTimeChange(PlayerMoveEvent e) {
        if (e.getPlayer().getLocation() == coordinatesOfLocation) {

        }
clever dawn
#

Is there a clean way I can use hex colors in a team prefix using just the API?

timid kestrel
#

Quick q, why can gradle find org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT, but not org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT? Even both files literally exist right next to eachother in the repo?

ivory sleet
timid kestrel
ivory sleet
#

oh

#

yeah weird

#

it should work perfectly fine

#

what does the gradle error say

#

the stacktrace ofc

timid kestrel
timid kestrel
#

It's weird cos it works fine in VS Code, but it's being odd about it in IntelliJ

ivory sleet
#

okay then

#

restart and invalidate caches

#

intellij is kinda dodo sometimes lol

timid kestrel
#

Neither the repo or restart sorts it

ivory sleet
#

try deleting the .idea folder

#

and .gradle folder

#

then ofc restart and invalidate again

timid kestrel
#

fails, when you say invalidate, is there anything I should be clicking?

ivory sleet
#

File -> Invalidate Caches... -> Restart and Invalidate

#

or smtng

#

Use English, thanks

#

show time?

clever dawn
timid kestrel
ivory sleet
#

Idk what bossbar show time is rly lol

ivory sleet
timid kestrel
#

It's a brand new project too

ivory sleet
timid kestrel
ivory sleet
#

also

#

what Java version do u use

#

and gradle version

timid kestrel
ivory sleet
#

alr

#

anyways try the dep I mentioned above

timid kestrel
#

yeah, same error, could not find

ivory sleet
#

what gradle version are you on

timid kestrel
#

Trying to find it

ivory sleet
#

gradle/gradle-wrapper.properties

timid kestrel
#

ah, 7.1

ivory sleet
#

oh

#

hmm

timid kestrel
#

same as my VS code setup lol

#

how odd

ivory sleet
#

try
org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT:20210929.090115-75

timid kestrel
#

could not find

ivory sleet
#

exact same error?

#

or slightly different?

timid kestrel
#

yup

#

same error

ivory sleet
#

cant be

#

send it regardless

timid kestrel
ivory sleet
#

no

#

org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT:20210929.090115-75

#

try that one

#

not org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT-20210929.090115-75

timid kestrel
#

fails too

#

just re-created the project again to make sure it wasn't a 1 off (as it's a fresh install) - exact same issue

timid kestrel
#

oh lord

ivory sleet
#

?

timid kestrel
#

I'm out of my depth here with the mess that is gradle lol

ivory sleet
#

Yeah

#

this issue of yours is quite a peculiar one I must say

#

We even tried specifiying snapshot version

timid kestrel
#

Yea, I think it's something outside of the build.gradle file, something system based perhaps

ivory sleet
#

yeah

#

hmm you could contact the gradle devs about it

#

Or maybe ask somewhere else where people are more knowledgeable about it lol

#

anyways best of luck

timid kestrel
#

IntelliJ downloads and manages its own version of gradle right?

ivory sleet
#

Sorta yeah

timid kestrel
#

Well, it looks like I've actually somehow managed to download the jar file locally, stored in c:\users\user\.m2 (ofc, .m2 is a good name and place to hide this...)

Switching to Maven made all my issues go away, basically. Gradle seems abit crap.
Also ty for your time / help @ivory sleet !

ivory sleet
#

ah

torn oyster
#

are there any good ways to make custom soundtracks

main dew
#

How find leaks memory?

ancient plank
#

yes

cosmic spear
#

Hey guys good Bungeecord login plugin?

#

Need it

burnt apex
#

how to get the time the player spent on his server, what is the event of the Statistics object please?

sullen marlin
quaint mantle
#

ItemFrame frame = (ItemFrame) entity;

sullen marlin
#

Just look at the list, should be obvious

burnt apex
#

what is "iirc" pls ?

hasty prawn
#

PLAY_ONE_MINUTE is play time

ancient plank
#

if i recall correctly

burnt apex
#

Oh okok thanks

hasty prawn
#

And I think it's in ticks not minutes, it's named wrong

ancient plank
#

its PLAY_ONE_MINUTE but it doesn't return a minute iirc, some other timeunit

#

yes ticks

burnt apex
#

ticks okok i will try to transform ticks into a second/mns/hours/day

quaint mantle
#

@sullen marlin we need namespace pdc, so if the plugin is removed all pdc is removed from the player

#

or plugin pdc

#

is that how it works? or is it just nbt

sullen marlin
#

It's stored per plugin, but it's not removed if the plugin disappears

young knoll
#

You could probably write a plugin to do that

#

If you really wanted to

quaint mantle
#

it does

quaint mantle
#

whats entity

#

show where you get it

#

Hover over entity

#

i mean the entity variable

#

What does it say

vagrant stratus
#

Anyone know if & and hex are supported in console?

hasty prawn
#

You didn't define entity

quaint mantle
#

Well there is no entity in a PlayerInteractEvent

#

So you’ll need to define it

#
if (enabled.contains(e.getPlayer()));

what is this

#

Test what the player is doing

vagrant stratus
#

also you'd be better off putting large chunks of text in ?paste

#

?paste

undone axleBOT
young knoll
quaint mantle
#

not sure for hex

#

try it

vagrant stratus
young knoll
#

cast where

quaint mantle
#
private final ComandSender sender = Bukkit.getConsoleCommandSender();

// sender has chatcolor support
vagrant stratus
#
  public void sendMessage(CommandSender sender, String message) {
    if(sender instanceof Player player){
      player.sendMessage(colorize(getPrefix() + message));
      return;
    }
    sender.sendMessage(message);
  }
young knoll
#

Yeah you shouldn't have to cast

#

Any sender should work

ancient plank
vagrant stratus
#

dumb af question, but i haven't touched spigot in ages 🀣

quaint mantle
#

works on malware detection for spigot

vagrant stratus
quaint mantle
#

jk

vagrant stratus
young knoll
#

Pretty much

vagrant stratus
#

πŸ‘

quaint mantle
#

java with spigot

vagrant stratus
#

but not actually using spigot code lol

young knoll
#

No idea what happens with command blocks

vagrant stratus
#

Fuck command blocks

young knoll
#

What is your goal

#

Are you clicking an item frame in the world, or holding one?

vagrant stratus
#

@quaint mantle I do plan on getting back into actual spigot coding though, as one can tell from my basic question πŸ˜‚

#

If it helps I do remember most things lol

young knoll
#

Use PlayerInteractEntityEvent

#

Then you have access to the player and the clicked entity

vagrant stratus
young knoll
#

The heck you running the game on, a Ti85?

vagrant stratus
#

i3-2120, but it still takes a fair bit for everything to start πŸ‘€

#

8 GB of ram

young knoll
#

I only use like

vagrant stratus
#

I think you've seen my specs lol

young knoll
#

1 for my test server and 2 for the client

vagrant stratus
#

:3

quaint mantle
#

Also try using UUIDs when handling lists of Players.. As the player Object changes frequently whereas the UUID Doesn’t

young knoll
#

The player object changes on reconnect

woeful crescent
#

Are the PlayerQuitEvent and PlayerTeleportEvent events called before or after they play out ingame? I want to know if I'll be able to catch a player's open inventory and call InventoryCloseEvent before it closes. (1.8 doesn't call InventoryCloseEvent very well, so I plan to make a patcher)

young knoll
#

Can you cancel the teleport event

barren nacelle
#

`import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;

public class BlockListener implements Listener {

@EventHandler
public void onPlaced(BlockPlaceEvent e) {

    if (e.getBlockPlaced().getType() == (Material.TNT_MINECART)) {
        e.setCancelled(true);
    }
    if (e.getBlockPlaced().getType() == (Material.TNT)) {
        e.setCancelled(true);
        e.getPlayer().getWorld().setPVP(false);
    }
}

}` Hi! So I was making a quick plugin to stop tnt from being placed Does anyone know why it wasn't working

young knoll
#

TNT minecarts are not blocks

#

The TNT part looks fine though

barren nacelle
barren nacelle
young knoll
#

Is it registered

barren nacelle
#

Ok

#

Imma try again

#

Is there something wrong with my main?

#

It seem fine to me

young knoll
#

Looks alright

unkempt peak
#

Lol that sysout though

vast shale
unkempt peak
paper viper
#

dont name your class main

unkempt peak
#

I would reccomend always putting listeners in another class

unkempt peak
barren nacelle
paper viper
#

check out my thread

unkempt peak
paper viper
#

oh

unkempt peak
#

It's called Main

paper viper
#

Just choose a different name

unkempt peak
#

?

#

Why?

paper viper
#

Read my post

unkempt peak
#

Main is the standard

paper viper
#

No it is absolutely not

ivory sleet
#

Not for plugin names

barren nacelle
#

Then what should I write

paper viper
#

Your plugin name

#

directly

#

Main is vague, doesn't say much, and also your plugin isnt a standalone application either

barren nacelle
#

Also a heads up I can delete the plugin while the server's running

unkempt peak
#

Oh I do that sometimes idk why it really matters though

paper viper
ivory sleet
#

Some good names are
WorldGuardPlugin, LuckPermsPlugin or maybe GriefPreventionEntryPoint

unkempt peak
#

....no

#

That's 100x worse

paper viper
#

Yeah lol

barren nacelle
paper viper
#

I mean, you should always shut your server off first, but for windows you cant

#

but i think for unix you can

#

well

#

some

barren nacelle
#

I don't really care if the server gets corrupted

young knoll
#

You can swap it on windows

#

But not delete

paper viper
#

its not that, the OS just will simply not allow you to delete it

#

lol

ancient plank
#

I name my plugins by inputting keywords into google translate with a random language then taking the phonetics for it

barren nacelle
#

When the server is running nothing is using it for some reason so I can delete it

ancient plank
#

like Konchina, which was my last commission, or my current Molynsi (iirc)

barren nacelle
young knoll
#

But the SEO

barren nacelle
#

It seems much easier

paper viper
barren nacelle
ivory sleet
#

Yea

#

But decompiling is effort

barren nacelle
#

Ok

paper viper
#

dude

#

Git exists

#

Github also exists

barren nacelle
#

Ok

paper viper
#

They are there for a reason

#

for viewing code

#

and also organizing work

ancient plank
#

?paste

undone axleBOT
barren nacelle
#

Wait what

#

Oh sorry

ancient plank
#

use a paste for larger code snippets

paper viper
#

use an EnumSet instead

#

check if enumset contains the placed block

barren nacelle
#

Ohhh

#

Ok

paper viper
#

Ok, I really hate to say this. But you probably gotta learn some java basics and stuff first

#

at least the basics

#

like classes and stuff

barren nacelle
ivory sleet
#

PulseBeat_02 Java series on yt!

ancient plank
#

I gotta do some learning πŸ˜” gotta do smth with enums

paper viper
#

Nah

#

lmao

ivory sleet
paper viper
ivory sleet
#

Yea

barren nacelle
ivory sleet
#

Man it gives us so much more power

barren nacelle
barren nacelle
paper viper
ivory sleet
#

Only cursed thing is the keyword non-sealed

ancient plank
#

do the command

paper viper
#

dont watch it

ancient plank
#

?java

ivory sleet
#

?learnjava

undone axleBOT
paper viper
ivory sleet
#

Yeah lol

paper viper
#

Bruh

#

i wished they would add like package specific visibility modifiers too

barren nacelle
#

Time to do some reading

paper viper
#

cause protected aint enough

ancient plank
#

I gotta make some custom "Classes" i.e. like how mmos have "Knights" and whatnot, been sitting here the past 10 minutes thinking about the best way to go about it

ivory sleet
#

Assume class Vehicle is sealed
Then class Car which extends Vehicle must be declared sealed, non-sealed or final iirc

paper viper
#

Yea

barren nacelle
#

Luckily I have speechify

paper viper
#

Dont

#

this isnt english class

#

you wont benefit from the dude speaking

young knoll
#

Why do we need non-sealed though

#

Can't it just be declared normally, it would imply the same thing

ivory sleet
#

Oh it’s in case you wanna extend a sealed derivative

#

Like where new derivatives of that derivative may be loaded during runtime

#

As sealed thing is kinda checked at compile time c

barren nacelle
ancient plank
#

the only time I've used enums is to store discord webhooks πŸ€” I think

paper viper
#

just use them for constants

#

and "modes"

young knoll
#

Yeah I use one for namespaced keys

#

Although it's a bit weird since you need to call setup() on it

paper viper
#

wdym setup()

ivory sleet
#

Enum singleton 😏

young knoll
ancient plank
#

plguinKey

#

classic, I always do that

young knoll
#

Shh

paper viper
#

i prefer using JavaPlugin.getPlugin since you use static with static and it avoids the unnecessary method call

#

or I just define it directly and just do it inside the constructor

young knoll
#

Hmm, fair

ivory sleet
#

AbstractPluginNameSpacedKeyFactoryImpl snooze

ancient plank
#

stop

ivory sleet
#

😦

#

setInvisible(true);

ancient plank
#

clikck

ivory sleet
#

iirc

ancient plank
#

πŸ‘ I like the inclusion of the entire class just to ask how to make an item frame invisible /s

paper viper
#

sure

silk tusk
#

Where do find the api jar for spigot? I downloaded it before so that I could have nice documentation in my ide, but I can't find it now.

paper viper
#

just add it using maven/gradle

#

unless you are using NMS or adding jars manually

ancient plank
#

en em ess

paper viper
#

lol

silk tusk
#

I am unfortunately using nms. I tried to avoid it but I keep finding just one obscure thing that doesn't work without it

paper viper
#

NMS is not documented

silk tusk
#

yeah I know

paper viper
#

and also you can only use JARs for NMS

#

oops i meant

#

not only JARs

#

you can run buildtools

#

and use that too, and remove the -api part

ancient plank
#

just set visible back to true

paper viper
#

(preferable option)

#

not really lol. No need to use .equals on enums

ancient plank
#

vomiting rn

#

abysmal spacing

vague oracle
#

player.getItemOnCursor is null and as said don't use .equals for enums

sleek parrot
#

command /spawn:
trigger:
set {Spawn::%player%} to 5
send "Please don't move"
while {Spawn::%player%} is not 0:
wait a seconds
subtract 1 from {Spawn::%player%}
{Spawn::%player%} is 0
teleport player to {spawn}

on any move:
if {Spawn::%player%} is set:
delete {Spawn::%player%}
send "You moved..."

#

it says error at "on any move"

ancient plank
sleek parrot
#

k

ancient plank
#

I think that's their discord πŸ€”

#

there's like 4 communities for it apparently

young knoll
#

No

#

Why would the player be holding an item on their cursor while right clicking an entity?

snow ember
young knoll
#

Also frame will always be null

#

Because you explicitly set it to null

ancient plank
#

cursed

snow ember
#

At the start you should probably put: if (e.getItemOnCursor() == null) return;

young knoll
#

That isn't what they want

#
  1. e is the event, and does not have a getItemOnCursor
#
  1. getItemOnCursor gets the item the player is holding when in an inventory, not what is in their hand
ancient plank
#

I think we should get an explanation from them on what exactly they want to happen

young knoll
#

Wait, PlayerInteractEntityEvent does not have a getItem or getItemInHand or anything

#

Gross

ancient plank
#

well ye because there aren't any interactions where right clicking an entity fwith a specific item does anything in vanilla mc

#

just getplayer then their inv then item in main hand/off hand

young knoll
#

Still annoying that the convivence method does not exist

#
ItemStack item;

if (event.getHand() == EquipmentSlot.HAND) {
    item = event.getPlayer().getEquipment().getItemInMainHand();
} else {
    item = event.getPlayer().getEquipment().getItemInOffHand();
}
#

Look at all those lines, terrible

ancient plank
#

yeah but it doesn't make sense to add lines to the underlying event code for "convenience" when it isn't applicable for most use cases

#

imo

young knoll
#

Tell that to BlockPlaceEvent#getBlockPlaced

ancient plank
#

what about it

young knoll
#

It only exists for connivence :p

ancient plank
#

how is that?

young knoll
#

It’s the same as getBlock

#

Technically it’s for clarity, but close enough

#

Also there are some vanilla entity interactions based on held item

snow ember
young knoll
#

Not enough streams

snow ember
#

@quaint mantle What are you trying to achieve here?

#

Minecraft version?

#

Okay well think through it. We need to detect when a player right clicks, which is PlayerInteractEvent. Then we need to see if the interaction is a right click, and if the thing right clicked is an itemframe. Then, get the itemframe, and then invert its invisibility.

#

actually @ancient plank or @young knoll do itemframes count as blocks? Because PlayerInteractEvent only supports block and air clicks :/

#

Maybe check if you interact with a living entity

ancient plank
#

na

#

they're entities

snow ember
#

yea thats what I thought

spare marsh
#

Quick question

snow ember
#

Ooooh

#

EntityInteractEvent

#

Might work

spare marsh
#

So I found this on spigot

private static final Pattern HEX_PATTERN = Pattern.compile("&(#\\w{6})");

    public static String colorize(String message) {
        Matcher matcher = HEX_PATTERN.matcher(ChatColor.translateAlternateColorCodes('&', message));
        StringBuffer buffer = new StringBuffer();

        while (matcher.find()) {
            matcher.appendReplacement(buffer, net.md_5.bungee.api.ChatColor.of(matcher.group(1)).toString());
        }

        return matcher.appendTail(buffer).toString();
    }```
young knoll
#

PlayerInteractEntityEvent

#

Which is what they are already using

ancient plank
#

PlayerInteractAtEntityEvent should be used, over playerinteractentityevent

spare marsh
ancient plank
snow ember
#
    @EventHandler
    public void onItemFrameClick(EntityInteractEvent e) {
        if (e.getEntity().getType() == EntityType.ITEM_FRAME) {
            ItemFrame frame = (ItemFrame) e.getEntity();
            frame.setVisible(!frame.isVisible());
        }
    }
``` This should work if e.getEntity returns the entity interacted
ancient plank
#

unless I can't read

young knoll
#

See that’s always confused me

#

Because PlayerInteractEntity is the parent class of PlayerInteractAtEntity

snow ember
#

:/

young knoll
#

But it says (this), so I have no idea

snow ember
#

You should really figure this out on your own though. I honestly shouldn'tve spoonfed you

ancient plank
#

idk anymore

snow ember
#

Learning logic is more important than knowledge of Java or the Spigot API imo.

spare marsh
#
  public String translateHexColorCodes(String startTag, String endTag, String message)
    {
        final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
        Matcher matcher = hexPattern.matcher(message);
        StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
        while (matcher.find())
        {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, COLOR_CHAR + "x"
                    + COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
                    + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
                    + COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
                    );
        }
        return matcher.appendTail(buffer).toString();
    }``` 

What would be a proper way to call this method?
ancient plank
#

googling is a skill πŸ‘

hasty prawn
#

Are you still trying to make item frames invisible? Thonk

#

Dang lmao

young knoll
#

Spigot hasn’t changed much since 1.11?

hasty prawn
#

PlayerInteractEntityEvent -> Cast to ItemFrame -> ItemFrame#setVisible

#

done

young knoll
#

Don’t forget to check before you cast

hasty prawn
#

Yes yes ofc

young knoll
#

Use that sick new inline casting

hasty prawn
#

I just figured that was implied

spare marsh
#

Can I get some help? 😦

hasty prawn
#

Pattern variables PeepoHappy

young knoll
#

Is that the name? I never remember official terms

ancient plank
hasty prawn
#

Yeah I think it is

hasty prawn
young knoll
#

^

ancient plank
#

oh

#

that's wild

young knoll
#

Very useful

hasty prawn
#

Indeed

ancient plank
#

what version is that

young knoll
#

15 I think?

hasty prawn
#

No idea but 17 has it and that's all that matters KEKW

young knoll
#

So does 16

#

Which is what mc uses

ancient plank
#

ic ic

hasty prawn
#

That's what I meant whoops

#

I only found out about it because IntelliJ called me a dumbass for not using it

ancient plank
#

lol

young knoll
#

It’s probably my favourite new feature

#

And like

#

1 of the 3 new features from java 9+ I’ve used so far

hasty prawn
#

What are the other 2

young knoll
#

Using method arguments in a try with resources

ancient plank
#

might upgrade the java version my current project uses, so I can use method arguments in try-with-resources

vital yacht
ancient plank
#

would make my SQL code cleaner

young knoll
#

?paste

undone axleBOT
young knoll
ancient plank
#

i just call them lambda switches lol

hasty prawn
#

Oh yeah those are nice

#

What's this method arguments in try with resources Thonk

vital yacht
#

Yeah

young knoll
#

You can use arguments passed to a method in the try with resources block

#

Something like

ancient plank
snow ember
vital yacht
#

Do you mean a regular try-with-resources statement?

young knoll
#

No

ancient plank
#

?paste

undone axleBOT
wild reef
#

Hey quick question. So I want to use a TextComponent to send a message which is clickable.
But I could only find ways to execute like specific server commands but nothing you can code yourself like this:

TextComponent recieverMessage = new TextComponent("Test message");
recieverMessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, ""));

But I want something like this:

recieverMessage.setClickEvent(new ClickEvent(ACTIONX, () -> System.out.println("Something")));
ancient plank
#

this

vital yacht
#
try (final Connection connection = getConnection) {

} catch (final Exception exception) {

}
#

That ^?

young knoll
#

That’s just the normal one

ancient plank
#

look at my paste

hasty prawn
#

So it's basically just, make these things, then do this?

young knoll
#

Let me write an example

ancient plank
hasty prawn
#

Yeah that's what I'm looking at

vital yacht
#

What's the difference?

snow ember
#

wait nvm cant do it in 11

young knoll
snow ember
#

is there any way to use java generics with static methods?

vital yacht
ancient plank
#

In this example, the try-with-resources statement contains two declarations that are separated by a semicolon: ZipFile and BufferedWriter. When the block of code that directly follows it terminates, either normally or because of an exception, the close methods of the BufferedWriter and ZipFile objects are automatically called in this order.

young knoll
#

No because the object isn’t created inside the try statement

vital yacht
#

That's what a try-with-resources is though right?

#

Also isn't it Autocloseable, or am I wrong?

wild reef
snow ember
#

would something like this be possible?

vital yacht
#

You can't have a constructor with a class that extends JavaPlugin

ancient plank
#

grrr I wish oracle docs had a dark mode

snow ember
#

Because generics are only applicable to the instance of the class

#

so it cant be static

young knoll
snow ember
#

but i need it to be static haha

vital yacht
#

Why would you need to do that?

snow ember
#

Im trying to be lazy

#

basically

#

and save lines of code

#

so the CorePlugin

vital yacht
snow ember
#

I would extend when making a plugin

#

oh nvm

#

ur not asking me :/

vital yacht
#

No I am

snow ember
#

Oyh

#

so basically

#

use generic

#

for the instance of the class

#

for example

#

public class Plugin extends CorePlugin<Plugin>

#

would automatically generate and instance grabber

#

for

#

the class Plugin

#

but it'd have to be static

vital yacht
#

Use dependency injection

young knoll
#

You could always use a framework to inject the plugin instance

vital yacht
#

That would get rid of this whole issue

snow ember
young knoll
#

If you don’t feel like writing the few extra lines to use di

vital yacht
#

?di

undone axleBOT
young knoll
#

?di

undone axleBOT
young knoll
#

Heh

snow ember
#

alright htanks

#

also md 5 really needs a dark mode for spigot

#

my eyes are burning

vital yacht
#

I think donators get it

young knoll
#

There is one for donors iirc

snow ember
#

That's cruel but ig

young knoll
#

There are probably browser plugins that let you define your own css for it

snow ember
#

Can someone just explain di to me

#

I'm not staring at this wiki with my eyes burning for 10 mins

vital yacht
#

You pass around an instance of your plugin instead of using a static instance

#

For example, say you had a listener class

class Something implements Listener
// add field for Plugin, pass plugin instance in class constructor

Or use a DI framework

young knoll
#

Essentially you pass your plugin instance to the constructor of a class

#

So that class can then access it

snow ember
#

okay

#

this is confusing me

#

OH I GET IT

#

Yeah but

young knoll
#

Note to self, add shift-right click to toggle item frame visibility to my plugin :p

snow ember
#

Okay 1 I already do that a bunch

#

2

#

I'm too lazy to make a constructor for every class, then pass it from my main class

#

Because

#

I jsut wanna use Plugin.getPrefix(), etc. in peace

#

:/

young knoll
#

You can auto generate a constructor if you just define the final field

snow ember
#

This is paining me

snow ember
#

but

#

thats one extra line

#

I can't afford

young knoll
#

Β―_(ツ)_/Β―

snow ember
#

And
I still have to

vital yacht
snow ember
#

pass it from my main class

#

Not for that instance

vital yacht
#

Use a DI framework like Guice if you don't want to pass around an instance

snow ember
#

Thats literally the only time I use static

vital yacht
#

Still static abuse

snow ember
#

It's not abuse if you do it once: /

vital yacht
#

Yes it is

snow ember
#

Who wants to type Plugin.getPlugin().getPrefix()?

vital yacht
#

Plugin.getPlugin is the static abuse

snow ember
#

Your brain is static

vital yacht
#

My brain is dynamic

snow ember
#

Prove it

vital yacht
#

No

snow ember
#

Actually i'd rather not see an autopsy of your brain

#

alright thank you.

#

its 10 pm

#

why would I wanna do that?

vital yacht
#

To learn and code better?

snow ember
#

I'm not refusing lol

#

I still might do DI

#

I'm just arguing why I think I shouldn't do it

#

yea do you wanna do that for every class you use your main class with?

vital yacht
young knoll
#

To be fair with spigot it’s more about building a good habit

snow ember
#

Kay maybe i'm just lazy but I don't like repeating myself a lot

young knoll
#

The plugin class is a singleton anyway, so a static getter isn’t the worst

vital yacht
#

Why are you casting a string to Object lol

snow ember
#

Lol? did I jsut see that

#

Hes casting a FileConfiguration to an object?

#

okay just do

young knoll
#

Yes

snow ember
#

getConfig().getString("Discord")

#

no object casting or anything

vital yacht
#

Oh wait

#

I thought he was casting the string, not the config lol

snow ember
#

Lo

#

getString isn't a method from the Object class anyways

#

Also why this.getConfig()? Just use getConfig()

vital yacht
#

Is it decompiled or something?

#

Do you know what casting is?

snow ember
#

then... why are you casting a config to an object?

#

I know you've probably heard this a lot, but maybe just take a one hour course on basic java?

#

so you don't forget

#

and OOP

vital yacht
#

That applies to you too Exortions

elder kettle
#

Hello, does anyone know or know of a plugin that allows chests to automatically sort items? preferably compatible from 1.12 onwards or 1.12

snow ember
#

and java?

vital yacht
snow ember
#

I know a ton of people that do it?

#

Why DI every class you have?

#

also doesn't mean its the worst way of doing it

#

there isn't anything fundimentally wrong with it, it just might not be the most efficient

snow ember
#

Yeah

#

I kind of can

vital yacht
#

And what do you mean by efficient

snow ember
#

I mean

vital yacht
snow ember
#

are you saying DI is more efficient?

snow ember
#

that's literally all I need to say

#

Lol

hasty prawn
#

Are we talking about Dependency Injection vs Singleton :o

vital yacht
#

Let me show you an example of something that works than

#

?paste

snow ember
#

Kind of yeah

undone axleBOT
snow ember
hasty prawn
#

I brought up points earlier with this and no one answered PepeHands

#

.

snow ember
#

Okay and your point is>

vital yacht
#

Always listen to Conclure

snow ember
#
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");
sendMessage(" ");


for (int i = 0; i < 50; i++) {
  sendMessage(" ");
}
#

this actually

#

proves that DI is worse

vital yacht
#

How?

#

The first is something that works

#

The second is something that is better

snow ember
#

Because the multiple sendMessages is basically you constructing every class u wanna DI with

#

the for loop is basically the singleton

vital yacht
#

No?

snow ember
#

:/

hasty prawn
snow ember
#

Yeah

vital yacht
snow ember
#

There isn't any point really not to use a singleton

#

DI takes up an extra 2+ lines per class

hasty prawn
#

I mean, he probably is right about this. But until I see some pretty clear reasoning behind using DI over it, there's no reason to make the hard switch.

snow ember
#

singleton is three lines forever

vital yacht
snow ember
#

yep

hasty prawn
#

Not forever, you have to access it still.

snow ember
#

public static Plugin getPlugin() {
return instance;
}

hasty prawn
#

Well and define instance LULW

snow ember
#

5 lines then

vital yacht
#

Then you end up doing Plugin#getSomeObject#getSomethingElse#doSomething Everywhere

snow ember
#

Not true

#

u need an object

#

Object o = Plugin#getObject()

#

o.

#

o#whatever

#

o#toString

hasty prawn
vital yacht
#

No

snow ember
#

You actually do

vital yacht
#

You can instantiate everything in the constructor

hasty prawn
#

I agree that DI is fantastic in a lot of cases, just not for the plugin class case.

snow ember
#

Yea

#

just use the 5 lines of static?

#

The plugin doesn't break without DI

hasty prawn
# vital yacht No

How is passing the Plugin instance any different from a static Getter? You're getting the same object. You still have to call Plugin#getSomeObject#getSomethingElse#doSomething regardless of the method

snow ember
#

Exactly

#

and if ur not using getter and using di

#

its

#

plugin#getSomeObject#getSomethingElse#doSomething as well

#

just lowercase plugin this time :)

#

yeah but

#

then

#

if u use static

#

its getPlugin#whatEver

#

?

#

so same thing

hasty prawn
#

Yeah kinda

vital yacht
#

Sorry should have been Plugin.getInstance.getSomeObject.getSomethingElse.doSomething

snow ember
#

Also im pretty sure DI will slow load time of plugin by a few ms

vital yacht
#

What

snow ember
#

ur constructing every class

#

passing in an instance

vital yacht
#

Can you test that

snow ember
#

Maybe later

vital yacht
#

Please show me the results

snow ember
#

Ik

#

But that doesn't mean its better than singleton lol

hasty prawn
# vital yacht Sorry should have been `Plugin.getInstance.getSomeObject.getSomethingElse.doSome...

Sure, but that's going to be negligible. Also, with DI you run into this issue

For example, if you're instantiating a class within another class, that's instantiated within another class, etc etc, you'd have to pass y our plugin instance across every single one of the classes, JUST so you can use it in the one you're trying to get to, regardless of whether the first 2 classes actually use the plugin instance or not. It seems like that would be far more complicated than just "oh, I need my plugin instance for this class. Main.getInstance() done."

snow ember
#

Alright at this point ima just stop arguing. Let's all mutually agree that they both work, and everyone has preferences

snow ember
#

my point

#

i've been arguing the entire time

hasty prawn
#

And it's just uglier IMO to be constantly forced to pass around an object, even if it's completely unnecessary to what you're doing.

vital yacht
hasty prawn
floral bison
#

use a di framework

#

ez

young knoll
#

DI is a better practice

#

But in terms of the spigot plugin instance, it doesn’t really matter

ashen flicker
#

Well I mean I feel like a certain advantage to passing an instance around is instance control. Like you’re basically saying β€œI only want these classes to have access” so if it’s an api the user of it can’t just do β€œmain.getinstance” and access everything

vital yacht
#

Also Bukkit provides a method to get an instance of the class

hasty prawn
#

It definitely is extremely situational, yeah.

I'm more specifically talking about the Main plugin instance. IMO DI just doesn't make a ton of sense in that case. In most other cases, yes, I agree DI is better.

vital yacht
#

If you really don’t want to do DI

ashen flicker
#

Standing for dependency injection?

toxic lava
#

Is there a yet a simple way of sending text to a players actionbar (without another api, would be the best)? I mean, actionbar has been a thing since 1.8 but i cant seem to find anything official in the docs

vital yacht
toxic lava
ashen flicker
#

Can’t you just use a singleton pattern and use DI? The only thing you’d be not doing is having a static instance of main

vast shale
young knoll
#

It tells you what is null

vast shale
#

How would I add a feature to return false if its zero... I thought it'd be easy but im struggling

#

in the method linked above

young knoll
#

If what is 0

sharp storm
#

could someone make a simple plugin for me

vast shale
#

I think something is wrong with the "this.main.battle"

sharp storm
#

actually maybe not

vast shale
#

Just calling functions like

main.battle.startBattle(players, npcs)
``` returns the same null error
upper tendon
#

How come this doesn't register my command??

young knoll
#

Is that onCommand method in the main class

young knoll
vast shale
#

I can't figure out why its null though... I'm just trying to call a method in another class

upper tendon
vast shale
#

I declare in it the static main in the main class public BattleMenu battle;

young knoll
#

That is just declaring it

#

You haven’t set it to anything

upper tendon
#

How does one do that....

#

I'm very new and I'm following a tutorial to just learn the basics, and the person I'm watching has nothing else

vast shale
#

What would I even set it to though?

young knoll
#

An instance of BattleMenu

upper tendon
young knoll
#

As for the command that all looks fine

#

Make sure your exported jar has the right plugin.yml

vast shale
#

Public main class

upper tendon
young knoll
#

Does the /die command show up when trying to tab complete

upper tendon
vast shale
#

I'm getting that the constructor is undefined....

upper tendon
#

What does your battle class look like

#

also dont put the "args" in there, that was just a placeholder if you had any arguments for it

vast shale
#

How do you mean?

#

In terms of what my battle class looks like

upper tendon
#

I mean BattleMenu sorry

#

like whats the code

#

also remove the args I put in there

vast shale
#

It's prettu core, basically the core of the plugin. Did you want to see any part specifically

#

*pretty long

upper tendon
#

Remove the "args"

tacit drift
#

@upper tendon did you set executor for "die"?

tacit drift
upper tendon
upper tendon
#

sorry πŸ˜”

tacit drift
#

in your onEnable method

young knoll
#

You don’t have to set executor if it’s your main class

vast shale
#

I have the method public BattleMenu(Main mn, DataManager data) { main = mn; battles = new HashMap<>(); earnedXp = new HashMap<>(); countdowns = new HashMap<>(); lured = new HashMap<>(); traps = new HashMap<>(); dead = new ArrayList<>(); this.data = data; } So I think I must pass both main and data

upper tendon
#

yeah

#

that's your constructor, so you need to pass those in

vast shale
#

Can I create the instance in this public BattleMenu method?

young knoll
#

You should instantiate those maps and lists inline

upper tendon
#

doesn't have to

vast shale
#

I can't put it elsewhere because I need to pass the data parameter

#

Not sure what inlining is

upper tendon
#

create the instance where you were trying to create it before

#

where you're actually using it

vast shale
#

I'm trying to use it in the battlemenu class

#

Should I make the instance in the method I'm calling battle in?

solid cargo
#

why this aint working?

young knoll
#

Define not working

#

Also you don’t need the array, just pass 3 strings

solid cargo
#

oh you saying that to wesbag?

vast shale
#

Not

#

*No

upper tendon
young knoll
#

No idea why it’s not being registered

#

Have you fully restarted the server

solid cargo
#

who me?

#

no i have just reloaded it

young knoll
#

I need to use replies more

solid cargo
#

true

young knoll
solid cargo
#

ah

#

uh

#

i try to craft it in game

#

and it doesnt show me anything

young knoll
#

Did you call bukkit.addRecipe

solid cargo
#

yes

#

this right?

upper tendon
young knoll
solid cargo
#

but... it doesnt

#

will try restarting it

young knoll
#

Again I always recommend a full restart instead of /reload to make sure

solid cargo
#

ok

#

it threw me an error

#

its easy to fix tho

young knoll
#

Also you won’t get a sharpness 6 book from that

#

You have to get the meta and cast it

upper tendon
#

Ok @young knoll im so sorry im an idiot lol. I deleted my main class and then made a new one in its place but called it something else - didn't even check the log once πŸ€¦β€β™‚οΈ sorry

solid cargo
#

it doesnt let me upload

#

but i did get a book from crafting it

young knoll
#

It won’t work in an anvil

solid cargo
#

it doesnt let me apply it tho

#

yeah

young knoll
#

Get the meta, cast it, used the linked method, and set the meta

lost matrix
#

Enchanted books have a different type of meta

solid cargo
#

so i did this..

#

but its red :(

#

wait dont tell anythingh

#

oh fixed it

#

the sword only maxes out to sharp 5 tho

young knoll
#

The anvil might cap enchantments

#

You’d have to use the PrepareItemAnvil event to get around that

solid cargo
#

ugh

#

is it a lot of code?

young knoll
#

Shouldn’t be

#

Just get the item in slot 2 and manually add the stored enchants to the output

solid cargo
#

ah ok

#

I am 🀏 close asking for a spoonfeed

young knoll
#

?services

undone axleBOT
sharp storm
#

k

solar sable
#

is there a way to detect when a player is standing on everything?

torn oyster
#

why whenever i do SqlUtil.getConnection().close();

#

on disable

#

it has a chance for the plugin not to disable

#

and i have to kill the server

#

its so annoying

#

also the plugin disables before the world saves

ivory sleet
#

I have not a single clue where you call it and what that actually is

#

Is it a Connection?

torn oyster
#

yep

ivory sleet
#

Depending on what you’re doing, a static singleton, or the JavaPlugin’s static way of getting a plugin instance may take even more time

#

They have different purposes

#

How is one better if they have different use cases?

#

Yeah I am just curious as to why

torn oyster
steep comet
#

How should we write E2E tests for MC plugins? Any tips, any tools? πŸ€”

main dew
#

How find leaks memory?

solar sable
#

how to give a player an item ?

hasty jackal
#

easiest would probably just to attach a profiler and look for classes that have "too many" instances, however many or few that may be. then is figuring out why they don't get gc'd

solar sable
#
@EventHandler
    public static void onPlayerMove(PlayerMoveEvent e) {
        Player player = e.getPlayer();
        int x = player.getLocation().getBlockX();
        int y = player.getLocation().getBlockY();
        int z = player.getLocation().getBlockZ();

        Material block = player.getWorld().getBlockAt(x, y - 1, z).getType();
        if (block != Material.AIR) {
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9WalkDetector > &fYou are walking on " + block.name());
        }
    }
``` it seems that if i just stand on the block and move my camera, it will non stop sending the message, so is there any way for me to only detect when its on the y level and not x and z?
lost matrix
solar sable
#

well i want it to detect when i am standing on the block but only once

#

because if i move my camera it will send the message saying i am standing on the block

#

i dont want that

#

i want it to only detect when i am on the block and not when i move my camera

lost matrix
#

Do you constantly want to check the block or only detect if the player enters a block for the first time

solar sable
#

detect if the player enters a block

#

i want it like "player stand on a grass block and then a message pops up saying the player is standing on grass block and then when the player moves to another block it detects that one" but i dont want it to send the message when i move my camera

lost matrix
#

I think this performs decently.

  private final Map<UUID, Material> playerMaterials = new HashMap<>();

  @EventHandler
  private void onMove(final PlayerMoveEvent event) {
    final Player player = event.getPlayer();
    final Material playerMaterial = this.playerMaterials.get(player.getUniqueId());
    if (playerMaterial == null) {
      return;
    }
    final Location from = event.getFrom();
    final Location to = event.getTo();
    final int fromX = from.getBlockX();
    final int fromY = from.getBlockY();
    final int fromZ = from.getBlockZ();
    final int toX = to.getBlockX();
    final int toY = to.getBlockY();
    final int toZ = to.getBlockZ();

    if (fromX == toX && fromY == toY && fromZ == toZ) {
      return;
    }

    final Block below = to.getBlock().getRelative(BlockFace.DOWN);
    final Material belowMaterial = below.getType();

    if (belowMaterial != playerMaterial) {
      return;
    }

    player.sendMessage("You have found your block!");
    this.playerMaterials.remove(player.getUniqueId());
  }
solar sable
#

okie ill try it

#

i hope it is exactly what i want

#

oh why does it say "to.getBlockX();" might produce null?

lost matrix
#

Ah. Because in spigot the target location could be null.

solar sable
#

aah

#

so do i just ignore this?

lost matrix
#
    final Location to = event.getTo();

    if (to == null) {
      return;
    }

    final int fromX = from.getBlockX();

Just insert this

solar sable
#

ah okay

main dew
#

But how height is so low or so height?

solar sable
main dew
#

πŸ˜…

solar sable
#

what are you trying to say lol

lost matrix
main dew
#

what if the block is below or above the maximum build height?

lost matrix
#

Ah

solar sable
#

well it will not detect anything i guess

vernal pier
#

Pretty sure it’s air

lost matrix
#

Doesnt matter.

solar sable
#

@lost matrix idk why but now it just doesnt say anything

lost matrix
solar sable
#

ah

quaint mantle
#

@ivory sleet hire me 4 discord helper ❀️

ivory sleet
#

Apps closed atm 😦

solar sable
quaint mantle
#

It’s been fixed @solar sable

solar sable
#

ik

quaint mantle
#

Then why the uh

#

Okay nvm

ivory sleet
#

Toby, if you're more active, then maybe

quaint mantle
solar sable
#

im an organised person and i mostly organise my class and stuff but seeing that he chooses his Main as a listener just makes me mad lol πŸ˜†

quaint mantle
#

Also I’m in Self Isolation right now.. Family tested positive

solar sable
quaint mantle
solar sable
#

lol k

#

ik*

quaint mantle
#

But people who Call stuff Main do have some issues

#

I won’t lie

solar sable
#

call stuff main?

#

wdym

ivory sleet
#

ah, well you currently have around 200 messages Toby

quaint mantle
ivory sleet
#

in this discord that is

quaint mantle
solar sable
#

i have 587 messages....what

#

i joined like this week .-.

quaint mantle
#

Oh Conclure

#

I took an IQ test

ivory sleet
#

Dont check how many I got lol

ivory sleet
quaint mantle
#

I’m Above average 😎

ivory sleet
#

lol big brain

solar sable
#

sheeesh

quaint mantle
#

πŸ˜‚πŸ€£

solar sable
#

is it free? if its free imma take one hehehehe

quaint mantle
#

It’s free yessir

#

Take any online

solar sable
#

gimme the link to the one you took lol

quaint mantle
#

Conclure

#

As You’re my Uncle

ivory sleet
#

Ye

#

uh

quaint mantle
#

You want to help me with a big project?

ivory sleet
#

what is it specifically

quaint mantle
#

Command Framework 😩

ivory sleet
#

use mine 🀑

quaint mantle
#

Oh no

#

Show me it

quaint mantle
#

Any example of it in use?

ivory sleet
#

uh

quaint mantle
#

Like a command class

ivory sleet
#

I'll implement a command very soon

#

yea

#

rn its just abstraction

quaint mantle
#

Ohhh okay

#

I mean.. I like the annotations in command frame works