#help-development

1 messages ยท Page 944 of 1

torn shuttle
#

yes

#

many ways

lost matrix
#

There are quite a few better approaches

flint warren
#

any of them?

torn shuttle
#

to be clear if you know to get a class by string then the class already existed

#

if that is the case there is no reason you can't get that via other means

#

like just having an enum that describes your different classes and checking if the input matches an enum

#

then just redirecting to that class

lost matrix
flint warren
#

thank you both

#

imma look into it more in depth

torn shuttle
#

I'd say you can go read my pseudo-scripting language for elitemobs but it may be too much

#

but basically it's a whole scripting language that does not use any kind of reflections, the only reflections I use are to initialize complex config file structures

#

(well, at least directly in that codebase)

tall dragon
torn shuttle
#

ayy got the suggestions system working

#

hm I think I might be able to streamline it a bit more

#

but I'll do that later

shut field
#

is BSON a efficient way to save data?

#

I want to save a long list of Locations and I don't want it to take up a huge amount of space

eternal oxide
#

no flat file storage is efficient data storage unless you encode it yourself.

shut field
#

hundreds probably

lost matrix
#

-.-

#

Then use whatever.

#

Doesnt matter.

#

I was prepared for like millions

eternal oxide
#

explain what you are doing and we can probably suggest a better way

shut field
#

farming palnts

eternal oxide
#

tells me nothing

lost matrix
#

Use the PersistentDataContainer of the chunk they are in.
Listen to ChunkLoadEvent and ChunkUnloadEvent to load/save the plants from PDC back into memory.

eternal oxide
#

just storing plant locations is not the right way to do it

wintry lynx
#

Soooo. Smoll question. Is there a way to know a food items value and saturation? There's no FoodMeta.

shut field
#

I usually only think about persistent data with entities

eternal night
wintry lynx
#

But so is most meta stuff

eternal night
#

Fair too KEKW

lost matrix
wintry lynx
#

Can't wait to recode everything. uwu

eternal night
#

hmm

#

2 weeks till pre release COPIUM

lost matrix
eternal night
#

cannot wait for the item_name component to confuse the shit out of every one

eternal oxide
#

might be a nice time to drop all old support

wintry lynx
lost matrix
#

Oh yeah. With adventure it will be a treat. bungee components, nbt tag components, item components, text components.

remote swallow
#

has mojank been in contact with payper eyes_sus

lost matrix
lilac dagger
#

lol

remote swallow
#

remove all the french

#

make sure to delete the root of them too

eternal oxide
shut field
#

is chunk#getX in the center of the chunk or a corner

eternal oxide
#

corner

lost matrix
eternal oxide
#

kinda. If you use it for anythign it will translate to a corner

lost matrix
#

I think ElgarL is thinking about Locations? Maybe?

eternal oxide
#

in relation to, yes

lost matrix
#

Ah i see what you mean.

#

If you convert it from chunk into world space

shut field
#

thanks, both

#

make smuch more sense, yeah

lost matrix
#

Relative block coords within a chunk (from the top)

#

Chunk coordinates in the chunk grid

flint oak
#

hello i am using gpt to code some minigame with my friends. the code working except the sponge walking thing. the game is not reacting to the walking in the sponge can you guys help me

flint oak
eternal oxide
#

yes/no

flint oak
#

i dont know what need to do

tall dragon
dark arrow
#

anyone watched alan becker

#

??

shadow night
dark arrow
# shadow night Why

they made a fun minecraft video about block staff , I wanted to make a plugin from it

cinder abyss
#

Hello, what is the sound commonly used when there is an error?
It sounds like a teleportation sound I don't know how to name it
I searched on the minecraft wiki but didn't find him

echo basalt
#

villager no

cinder abyss
#

Not a sound from a living thing

#

It's like a teleportation sound

echo basalt
#

there's also enderman teleport but low pitch

cinder abyss
#

I think Hypixel use it when you don't have enough money to buy something in bedwars

cinder abyss
dark arrow
cinder abyss
#

Should I start a bedwars game to listen to it? Lol

dark arrow
dark arrow
subtle otter
#

yo can any1 help me i tried to make a item event and it messed up my commands and command event + the item its self,is there any1 who can help

chrome beacon
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

chrome beacon
#

No one can help you if you don't provide any information

tall dragon
#

personally i take a module based approach and i make sure everything is decoupled nicely. e.g most modules should work on itself so you can turn any module on / off on the fly

echo basalt
#

Modular approach + modular design on your utilities and stuff

#

So for example on my skyblock core my database stuff is de-coupled

#

Each "module" can make its own database off the common code

grim hound
#

yo, how can I shade a jar into my own jar and add my own package prefix to avoid class loading conflict?

#

I don't use maven

tall dragon
#

well what do you use

grim hound
#

IntelliJ artifacts

tall dragon
#

pretty sure its impossible with that

grim hound
#

oh

#

brah

tall dragon
#

u need either maven or gradle

#

or some other build system

grim hound
#

I heard better things about gradle

subtle otter
tall dragon
subtle otter
tall dragon
#

so if you never used a build system before i recommend starting with maven.

grim hound
#

literally

#

built a plugin 2 times with it

subtle otter
#

continue to use maven for abit longer

grim hound
#

long ago

tall dragon
#

theres plenty of documentation on how to shade using maven so

eternal oxide
#

Spigot is based around the Maven build system. If you use Spigot, use Maven

tender shard
#

you can use both

eternal oxide
tender shard
#

maven is much easier and gradle is much more flexible

grim hound
#

What kind of logic is that?

#

I'll learn how to use gradle

#

and I'll be able to keep using it

#

rather than learning the slow-building maven

eternal oxide
#

perfect logic?! Use the simplest system.

tall dragon
#

slow? xD

eternal oxide
#

Maven is not slow.

tall dragon
#

u will still be waiting for gradle to index when im already done testing

eternal oxide
#

Especially not when compiling plugins for Spigot.

subtle otter
#

yo can any1 help me out im coding a custom sword thats based material is a iron sword,theres currently no recipe but theres a command and a event but when i coded the item event it stopped me being able to spawn the sword with commmand and when i got it to work for like 5 min the item event(the event it to shoot fireballs on right click) wouldnt work im pretty sure its down to the registory of the item even,command and the item itself

tender shard
#

people who claim that maven is slow haven't properly setup their multi-module project

grim hound
subtle otter
#

heres some code for the item event: public class ZorroEvents extends JavaPlugin implements Listener {

@EventHandler
public void interact(PlayerInteractEvent event) {
 Action eventAction = event.getAction();
 Player player = event.getPlayer();



 if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK) {
     if (player.getItemInHand().getType().equals(ItemManager.zorrosword.getItemMeta())) {
         player.launchProjectile(SmallFireball.class).setVelocity(player.getLocation().getDirection().multiply(1));
     }
 }
    }
tall dragon
#

my friend uses gradle and had to wait 54 minutes

#

cuz his codebase is massive

eternal oxide
#

My "friend" can fly too.

subtle otter
#

yes and my maven builds usually only take up to 5 min

echo basalt
grim hound
#

fuends

#

๐Ÿ‘

tall dragon
subtle otter
#

can any1 help me with my code?

tall dragon
#

he works at jartex

echo basalt
#

ew jartex

#

cracked network

tall dragon
#

;ddd

echo basalt
#

half of it is just public plugins too fym

tender shard
#

This is Gradle. It can do anything if you plug in enough stuff, but it's pretty complicated to learn how to properly use it.

#

this is maven. if you just wanna play some music, it's straight forward

tall dragon
#

i currently have a project with about 18k lines source code with multiple modules & shading. & it builds in 10 seconds

#

good enough

echo basalt
subtle otter
echo basalt
#

6 second build

tender shard
undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

grim hound
echo basalt
#

gradle

grim hound
#

see

#

am using gradle

tall dragon
#

i mean. 4 seconds

#

that doesnt make up for the headache of setting up gradle for me

echo basalt
#

you'll go far by knowing the basics

#

if I need to shade shit I just copy things across

tall dragon
#

but people that have more brain cells than room temperature unlike me might do it faster

tall dragon
echo basalt
#

few secs

tall dragon
#

whenever i fork a gradle project it always seems to take so long

tropic knoll
#

The IDEA minecraft dev plugin will auto setup the only gradle things you need.

tender shard
#

yes sure, but only once

tender shard
deep herald
#
[18:59:57 WARN]: java.lang.NoSuchFieldException: modifiers
[18:59:57 WARN]:        at java.base/java.lang.Class.getDeclaredField(Class.java:2610)
[18:59:57 WARN]:        at hApi 1.0.jar//net.hyperiongames.hapi.command.HyperionCommandHandler.swapCommandMap(HyperionCommandHandler.java:149)
[18:59:57 WARN]:        at hApi 1.0.jar//net.hyperiongames.hapi.command.HyperionCommandHandler$1.run(HyperionCommandHandler.java:51)
[18:59:57 WARN]:        at org.bukkit.craftbukkit.v1_20_R2.scheduler.CraftTask.run(CraftTask.java:101)
[18:59:57 WARN]:        at org.bukkit.craftbukkit.v1_20_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[18:59:57 WARN]:        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1470)
[18:59:57 WARN]:        at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:446)
[18:59:57 WARN]:        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1379)
[18:59:57 WARN]:        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1156)
[18:59:57 WARN]:        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315)
[18:59:57 WARN]:        at java.base/java.lang.Thread.run(Thread.java:840)```anyone know why im getting an error for modifiers?
remote swallow
#

Field.class.getDeclaredField

#

are you sure thats the right class

lilac dagger
#

what's -17?

deep herald
#

hi

lilac dagger
#

as epic said, that can't be the right class

shadow night
deep herald
#

hold on

lilac dagger
#

field class get declared for sure

deep herald
grim hound
#

yeah, why would you need to use reflection on a Field class?

#

also, java won't allow it

tender shard
deep herald
#

17

eternal oxide
#

trying to get around Reflection using "modifiers" no longer works

deep herald
#

what do i do then

eternal oxide
#

what are you tryign to access?

deep herald
#

modifiers

#

look

eternal oxide
#

just teh command map?

deep herald
#

its my owqn cmd map

eternal oxide
#

err

lilac dagger
#

i have a way to access the command map and it doesn't require any of this

#

are you sure you need it?

eternal oxide
#

it looks liek he's tryign to replace the whole command map

chrome beacon
#

Yeah ^^

deep herald
#

bc im pro

#

(joke)

chrome beacon
#

Why are you trying to replace the entire command map though ๐Ÿ’€

deep herald
#

custom

chrome beacon
#

._.

remote swallow
#

you will remove every single other command

deep herald
#

ok

lilac dagger
#

just remove all the map's entries

eternal oxide
#

if you do that you are also wiping out all bukkit/other plugin commands

deep herald
#

it wont

lilac dagger
#

^

deep herald
#

ive used it b4

remote swallow
deep herald
#

on old vers

#

1.8

eternal oxide
#

Ok, explain WHY you are trying to remove all commands

remote swallow
#

okay so, a command map is a map

if you change the variable of a map everything in that old map no longer exists
you need to add to the existing command map

subtle otter
#

public final class ZorroSMP extends JavaPlugin {

@Override
public void onEnable() {

    getLogger().info("plugin has been enabled");

    ItemManager.init();

    Objects.requireNonNull(getCommand("zorrosword")).setExecutor(new Zorrocommands());

    Bukkit.getPluginManager().registerEvents(new ZorroEvents(), this);

}

@Override
public void onDisable() {

getLogger().info("plugin has been enabled");

}

}

public class Zorrocommands implements CommandExecutor {

@Override
public boolean onCommand(@NotNull CommandSender sender,@NotNull Command cmd,@NotNull String label, String[] args) {
   if (!(sender instanceof Player)) {
       sender.sendMessage("only players can use that commmand");
       return true;
   }
 Player player = (Player) sender;
   if (cmd.getName().equalsIgnoreCase("zorrosword")) {
       player.getInventory().addItem(ItemManager.zorrosword);
   }
    return true;
}

}

public class ItemManager {

public static ItemStack zorrosword;


public static void init() {
    createzorrosword();




}

private static void createzorrosword() {
ItemStack item = new ItemStack(Material.IRON_SWORD, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("ยง6Zorro's lost sword");
List<String> lore = new ArrayList<>();
lore.add("ยง7This sword is a relic of");
lore.add("ยง7A ancient beast");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK, 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
zorrosword = item;

}

}

any1 able to help?

tall dragon
#

?codeblock

undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
tall dragon
#

plez

remote swallow
#

also

#

?paste

undone axleBOT
subtle otter
#

public class ZorroEvents extends JavaPlugin implements Listener {

@EventHandler
public void interact(PlayerInteractEvent event) {
 Action eventAction = event.getAction();
 Player player = event.getPlayer();



 if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK) {
     if (player.getItemInHand().getType().equals(ItemManager.zorrosword.getItemMeta())) {
         player.launchProjectile(SmallFireball.class).setVelocity(player.getLocation().getDirection().multiply(1));
     }
 }
    }
chrome beacon
#

Just use the paste if it's a large class

#

code blocks are useful for small snippets

deep herald
remote swallow
#

not making ur own

deep herald
#

ok

chrome beacon
#

Your plugin should only contain one JavaPlugin class

subtle otter
#

ohhhhh

chrome beacon
#

which is the "main" class

subtle otter
#

okay so what do i put instead

deep herald
supple topaz
#

what is the best way to store variables

chrome beacon
subtle otter
deep herald
#

fr

chrome beacon
eternal oxide
#

Got to start somewhere

supple topaz
deep herald
chrome beacon
#

?di

undone axleBOT
eternal oxide
chrome beacon
supple topaz
eternal oxide
#

answer Olivo as there are other ways depending on what data

supple topaz
#

like ammo or on/off state

eternal oxide
#

then pdc

chrome beacon
#

^^

#

?pdc

chrome beacon
#

?blockpdc

undone axleBOT
chrome beacon
#

^^ if it's a block

#

(and not a tile entity)

deep herald
#

ok @tender shard i was told that it doesnt delete all the cmds

supple topaz
subtle otter
subtle otter
#

public class ZorroEvents implements Listener {

@EventHandler
public void interact(PlayerInteractEvent event) {
 Action eventAction = event.getAction();
 Player player = event.getPlayer();



 if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK) {
     if (player.getItemInHand().getType().equals(ItemManager.zorrosword)) {
         player.launchProjectile(SmallFireball.class).setVelocity(player.getLocation().getDirection().multiply(1));
     }
 }
    }




}

public final class ZorroSMP extends JavaPlugin {

@Override
public void onEnable() {

    getLogger().info("plugin has been enabled");

    ItemManager.init();

    Objects.requireNonNull(getCommand("zorrosword")).setExecutor(new Zorrocommands());

    Bukkit.getPluginManager().registerEvents(new ZorroEvents(), this);

} 

item event isnt working any1 know how to fix?

#

any1?

chrome beacon
#

?paste

undone axleBOT
chrome beacon
#

^^ put your code in a paste so you don't flood the chat

#

though looking at the earlier code a Material isn't an ItemStack so it won't work

#

Your IDE should be warning you about this

#

also follow naming conventions

#

?conventions

supple topaz
chrome beacon
#

ouch

#

it happens

subtle otter
#

If yk how

chrome beacon
#

Attach a PDC tag that you can use to identify your sword

#

?pdc

coral flower
#

Hey guys, I try to extend from the Zombie class and the IDE tells me I should implement it. But all the tutorials online tells me to extend. What is the right way to make a custom zombie?

cinder abyss
#

Hello, I want to cover 1.9-1.20.4, but in 1.13, Sound.ENTITY_ENDERMAN_TELEPORT is Sound.ENTITY_ENDERM -> E <- N_TELEPORT, how can I support both? I already have a method to detect if it's below 1.13

wide coyote
#

valueOf and try-catch

cinder abyss
#

try catch ?

#

why?

#

I've done that:java Versioning.isPost13() ? Sound.valueOf(Sound.class, "ENTITY_ENDERMAN_TELEPORT") : Sound.valueOf(Sound.class, "ENTITY_ENDERMEN_TELEPORT")

wide coyote
#

dude you already got the answer

#

why did you ask how to detect if under 1.13

cinder abyss
#

my code is good?

wide coyote
#

yes

cinder abyss
#

okay thanks

wide coyote
#

idk your isPost13 method but if it works, it works

cinder abyss
#

I asked because I didn't made something before that

tardy delta
#

why am i seeing the same thing twice

cinder abyss
eternal oxide
cinder abyss
#

exactly

tardy delta
#

they changed the name?

cinder abyss
cinder abyss
tardy delta
#

smh

cinder abyss
#

from men to man

real imp
#

Hello , i don't know how to setup the server , can someone help me?

chrome beacon
meager wolf
#

so im using a sign to get player input, im sending the player fake packets of a fake sign block near them, and then making them open it and then getting what they wrote, however, this doesnt work when players are above build height and under bedrock, is it possible to make something similar while making it work everywhere ?

deep herald
#
[18:44:20] [Server thread/WARN]:     at java.base/java.lang.Class.getDeclaredField(Unknown Source)
[18:44:20] [Server thread/WARN]:     at hApi-1.0.jar//net.hyperiongames.hapi.command.HyperionCommandHandler.swapCommandMap(HyperionCommandHandler.java:153)
[18:44:20] [Server thread/WARN]:     at hApi-1.0.jar//net.hyperiongames.hapi.command.HyperionCommandHandler$1.run(HyperionCommandHandler.java:51)
[18:44:20] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_20_R2.scheduler.CraftTask.run(CraftTask.java:101)
[18:44:20] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_20_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[18:44:20] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1470)
[18:44:20] [Server thread/WARN]:     at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:446)
[18:44:20] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1379)
[18:44:20] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1156)
[18:44:20] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315)
[18:44:20] [Server thread/WARN]:     at java.base/java.lang.Thread.run(Unknown Source)```still getting this from my plugin that I was talking abt earlier
remote swallow
#

explain why you need to access the Field class

deep herald
#
        Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
        commandMapField.setAccessible(true);
        Object oldCommandMap = commandMapField.get(Bukkit.getServer());
        HyperionCommandMap newCommandMap = new HyperionCommandMap(Bukkit.getServer());
        Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
        knownCommandsField.setAccessible(true);
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        modifiersField.setInt(knownCommandsField, knownCommandsField.getModifiers() & -17);
        knownCommandsField.set(newCommandMap, knownCommandsField.get(oldCommandMap));
        commandMapField.set(Bukkit.getServer(), newCommandMap);
    }```
blazing ocean
#

explain why

deep herald
#

read?

earnest lark
#

be nice?

lilac dagger
#

i think you should just clear the Map

#

and fill it with what you want to have

valid burrow
lilac dagger
#

instead of this modifier manipulation

deep herald
#

uh

lilac dagger
#

it's just the easiest way, i'm doing it

deep herald
#

can u show how?

lilac dagger
#

i mean it's a little different to what you're doing but alright

#

and as you can see i have the internal map

deep herald
#

thatsd what im trying to do

lilac dagger
#

then you don't need the modifiers

deep herald
#

i actually have it

lilac dagger
#

i feel like you're struggling with reflections a bit

deep herald
#

ye

lilac dagger
#

delete everything under knownCommandsField set accesible

#

and do this

deep herald
#

huh

#

oh

#

wait

#

its not even being used

#

for anything

#

accept for that

lilac dagger
#

knownCommands = knownCommandsField.get(commandMap = (CommandMap) server.getClass().getMethod("getCommandMap").invoke(server));

#

and you can cast

#

my cached field allows me to hide the cast

deep herald
#

thats what i hgave so far

#

but lemme put ur stuff in

#

also thats below

lilac dagger
#

you don't need anything below

#

you don't have to set anything

#

just read

sullen marlin
#

?xy

undone axleBOT
deep herald
lilac dagger
#

ye

deep herald
#

cast?

lilac dagger
#

yup

deep herald
#

alr

#

so that?

lilac dagger
#

so this is it, now you have access to the map

#

from here you can operate on the map as you please

deep herald
#

wdym

#

my brain

lilac dagger
#

from what i remember you said you wanted to remove all commands and add yours

deep herald
#

no

lilac dagger
#

you can do so by knownCommands.clear();

deep herald
#

i wanna keep the bukkit cmds

#

but add mine

#

to this

acoustic shuttle
#

int requiredAmount = 50 if i = 10; how do I make this work I want to set requiredAmount to a certain number depending on the number of i

#

i can do it in two lines

#

but how do i do it in one line?

lilac dagger
#

oh then you can just do
knownCommands.put("command", command); for (String alias : aliases) { knownCommands.putIfAbsent(alias, command); }

#

@deep herald

echo basalt
lilac dagger
#

oh and also command.register(commandMap)

acoustic shuttle
deep herald
#

all im doing is swapping the cmd map with mine?

echo basalt
lilac dagger
#

so there's no need to swap anything

#

you can just use what we extracted

lilac dagger
deep herald
#

wait

#

is modifiers even a thing

#

in new vers?

echo basalt
echo basalt
deep herald
#

how do i un hidden the hidden of hiddens

echo basalt
#

it's a little ugly but

echo basalt
deep herald
#

how bro

lilac dagger
#

but are you trying to use the modifier to change the final?

echo basalt
#

unsafe o_o

#

Bro wants to replace the entire command map

#

Last time I did that I did use unsafe

deep herald
#

it works on 1.8 and 1.7 fine so why cant i here

lilac dagger
#

but it sounds like you'd break some plugin somewhere

deep herald
#

W

#

love that

echo basalt
lilac dagger
#

pog

#

mine

deep herald
lilac dagger
echo basalt
#

This is acceptable imo

lilac dagger
#

you can try, it can't hurt

deep herald
#

gamer

echo basalt
#

ew

#

not using phases wtf

lilac dagger
#

it is a different system, it is cool ๐Ÿ˜„

deep herald
#

bro imma legit set my project to java 8 just to do this ๐Ÿ˜ญ

remote swallow
#

why are you so set on 100% replacing command map

echo basalt
#

Only reason to inject in a custom command map is to listen to forced commands through dispatchCommand

#

everything else is achievable through the API

fallen lily
deep herald
#

i need it like that

lilac dagger
#

even then, i think it's much easier to just wrap every command and listen that way

acoustic shuttle
# remote swallow i == 10 ? itIs10: itIsntTen
            int requiredAmount = 0;
            var o = i == 10 ? requiredAmount : 50;
            o = i == 11 ? requiredAmount : 100;
            o = i == 12 ? requiredAmount : 250;
            o = i == 13 ? requiredAmount : 500;
            o = i == 14 ? requiredAmount : 750;
            o = i == 15 ? requiredAmount : 1000;
            o = i == 16 ? requiredAmount : 2500;```
I have this but requiredAmount keeps getting set to 0
fallen lily
#

Java language version

acoustic shuttle
fallen lily
fallen lily
#

That is disgraceful

echo basalt
#

you can prob make that shorter with an array

fallen lily
#

Absoloutely absurd

#

And appaling

#

To say the least

acoustic shuttle
deep herald
fallen lily
#

Wait nvm

echo basalt
#
int min = 9; // 9 = 0, 10 = 50
int[] array = {0, 50, 100, 250, 500, 750, 1000, 2500};

// clamp i between [0, arraylength]
int index = Math.max(i - min);
index = Math.min(index, array.length);

int value = array[index]
fallen lily
#

god old lookup table

echo basalt
#

hell yeah

deep herald
echo basalt
#

Or you can use a map

echo basalt
#

Problem with a map is that if your entry is above the max bound it returns null

#

Unless you use a navigablemap

fallen lily
# acoustic shuttle okay ty

just so you can appreciate Kotlin; hereโ€™s a Kotlin implementation of your code:

val o = when (i) {
10 -> 50
11 -> 100
12 -> 250
13 -> 500
14 -> 750
15 -> 1000
16 -> 2500
else -> throw IllegalArgumentException()
}

#

The else can early return from the method, provide a default value or throw an exception

fallen lily
#

Once you get comfortable with Java I would recommend trying Kotlin honestly it really is the swiss army knife of the JVM

ivory sleet
echo basalt
#
return switch(value) {
  case 10: 50
  case 11: 100
  case 12: 250
  default: -1
}
#

sumn like this

fallen lily
#

not as bad as I remember it haha

#

Back in java 8 days you had to allocate the return on the stack, modify it, break from the case & return at the end

#

essentially you end up with (3 * cases) + 2 lines

remote swallow
echo basalt
#

yield p sure

fallen lily
#

or if youโ€™re a monster you can brace the break and setting return value and narrow it down to cases + 2

echo basalt
#

is only for braces

wary harness
#

Hey is it possible to get instance of entity projectile like arrow or xpbottle which is lanuched with BlockDispenseEvent

slow granite
#

hey guys, need help here

subtle otter
slow granite
#

i dont know why

#

eclipse dont recognize spigot lib

#

i already imported it

subtle otter
#

Are U using inteliji idea

slow granite
#

eclipse

subtle otter
#

Okay well U need a plugin.yml

#

Dnt see it there and you need it

young knoll
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

subtle otter
#

Show me what the plugin.yml looks like

subtle otter
#

I need to import spigot API into ur folder

subtle otter
slow granite
subtle otter
#

Nope emm I can't show U rn but in like 30 min I can

kind hatch
#

The main spigot-1.18**.jar** is now a bootstrap jar which contains all libraries.
You cannot directly depend on this jar.

slow granite
#

but im using the 1.8.8 version

remote swallow
#

?1.8

undone axleBOT
subtle otter
slow granite
slow granite
kind hatch
slow granite
#

i dont know what im doing wrong

subtle otter
#

@echo basalt yo help him out ur good at coding

rough ibex
#

1.8 oh god

subtle otter
slow granite
#

like, eclipse seems to be recognizing the jar file

echo basalt
#

Sounds like I have fans

slow granite
#

when I use the shortcut

subtle otter
slow granite
#

it auto create

echo basalt
#

I'd like to start by saying I drank a couple hours ago so I might write some spaghetto code

#

But what's up?

remote swallow
echo basalt
#

check my github and do a pr

subtle otter
#

Put the code
@Override
Public static void OnEnable

remote swallow
#

no static

subtle otter
#

In the Curley brackets

#

Oops

#

No static

#

I'm still kinda new but I'm learning

slow granite
subtle otter
#

@slow granite

slow granite
#

didn't work

echo basalt
#

Given you're using eclipse gradle is icky uh

#

Let's start by making a new, maven project

#

You're missing the spigot dependency and the bootstrap jar doesn't let you import it directly

remote swallow
#

@young knoll ur gradle eclipse nerd

remote swallow
subtle otter
#

Hhahhahah lol

young knoll
#

I just make the gradle project outside eclipse

subtle otter
young knoll
#

Then import > existing gradle project

kind hatch
#

oof

#

Might as well just use the other IDE at that point

subtle otter
#

Oof indeed .gradel = confusion

slow granite
#

@echo basalt

#

should i migrate to intellij idea?

echo basalt
#

Ideally

slow granite
#

ok, gonna do this and try

subtle otter
slow granite
#

thx a lot guys

#

ok

#

s2

#

have a good night

subtle otter
echo basalt
#

I use it

#

but it's not great

#

and triples your ram usage

subtle otter
#

Really?

#

I find it very useful tho

#

Like it has everything U need in 1 plugin it allows code alot quicker

echo basalt
#

It's just a template

#

and some custom inspections

remote swallow
subtle otter
#

Exactly for new coders that's helpful BC we do what we're really doing,I'm new and I've been learning java for about 4-5 days and I've coded a custom mod while working on my plugin

#

The mod works completely fine it's the fing plugin that's confusing me I'll figure it out eventually

young knoll
remote swallow
young knoll
#

Thatโ€™s just me not installing a Kotlin extension

remote swallow
#

no it happened on groovy too

young knoll
#

Well it looks fine in notepad++

#

GitHub must render tabs differently

remote swallow
#

no it happens when i read it in ij

young knoll
#

Well then notepad++ must render them differently

echo basalt
#

@wraith dragon BTW I added code to the minigame demo wiki

#

hm where is my simple scoreboard thing

wraith dragon
#

wait ill go check it out rn

#

yo there are a lot of changes for the phase side but no changes for player states and tasks

#

good stuff dude

echo basalt
#

I kinda nuked the player state stuff

#

I really can't bother

#

I just use kits for it now :)

#

And have each game do its own state tracking

#

There's also map code on the demo

#

And I did make the split between "map templates" (have access to the config and expose it) and "instanced maps" (have access to their map template, as well as positional context)

flint warren
#

any idea on why this triggers when i put on armor using right click?

@EventHandler
public void onClick(PlayerInteractEvent event){
  if(event.getHand() == EquipmentSlot.OFF_HAND) return;

  if (event.getAction() == Action.LEFT_CLICK_AIR){
     System.out.println("This somehow triggers when I equip a helmet??");
  }
}
echo basalt
#

?playerinteract

#

bot pls

#

?interact

#

whatever

flint warren
#

what

echo basalt
#

Basically the event fires for each hand

flint warren
#

yeah i know i've fixed that

#

1 sec

#

that code is not full

echo basalt
#

If that's your exact code add more debug

#

Print out every variable in the event, along with the player's inventory

#

That's the only way to come up with conclusive evidence

wraith dragon
echo basalt
#

Well yeah but they're error prone

wraith dragon
flint warren
#
System.out.println(event.getAction().toString());

prints LEFT_CLICK_AIR
when i RIGHT CLICK a helmet to put it on

#

i mean it makes no sense

echo basalt
#

Applying multiple states can cause problems

rough ibex
#

I sure hope those quotes aren't there

echo basalt
#

I usually just have a "spectator kit"

echo basalt
#

Print out the hand, item in the hand, all of it

#

What player did it

#

Look for patterns

wraith dragon
echo basalt
#

You could still use a player state system but they'd need to be game-specific

wraith dragon
echo basalt
#

For example I have 2 game modes at this network

young knoll
#

Pretty sure equipping armor with right click causes the swing hand animation

echo basalt
#

One's a skywars clone

young knoll
#

Which then fires a left click event

echo basalt
#

And the other is like a fall guys type of thing

#

The spectator state is completely different

#

As one has to disable movement checks

#

And the other has to disable combat

wraith dragon
#

Oh I see, so like if they would NOT be game-specific, and there were two spectator states

#

conflict

echo basalt
#

Well if they were not game specific let's say you had a spectator state

#

And like a uh

#

"hunter" state

#

One wipes your inventory and gives you a sword

#

One wipes your inventory and gives you a compass

#

Then you'd need a system to only be in one state at a time

#

But some games require multiple states

#

Like being a hunter but also a wizard or something

flint warren
wraith dragon
#

But arent kits similar? They give you items and potioneffects, but you can give multiple kits to someone

echo basalt
#

The difference is that the custom logic isn't bound to the kit

#

And kits are configurable

#

They're a lot more raw

#

And it gives you, the developer, all the power to handle custom logic

#

For example

public void makeBomber(Player player) {
  giveKit(player, TNTTagConstants.BOMBER_KIT);
  makeGlowing(player);
  registerTeam(player, bomberTeam);
}

public void makeGlowing(Player player) {
  // Some other thing
}
coral flower
#

I try to implement a Custom Zombie like this: ```java
public class CustomZombie extends Zombie {
public CustomZombie() {
super(EntityType.ZOMBIE, Bukkit.getWorld("roguelike"));
}
}

But my ide wants me to implement instead of extend. But all tutorials online are using extend
echo basalt
#

It's basically a structure that prevents wonky state behavior by reworking everything and removing states

echo basalt
#

Not the bukkit Zombie interface

coral flower
#

is it default or do I need to download it?

echo basalt
#

?nms

coral flower
#

thx!

hazy cypress
#

Hi, I need help making it so players canโ€™t shift click from an inventory menu. I already have a setCancelled event but players can still shift click. Can anyone help?

agile anvil
#

Which event have you cancelled?

hazy cypress
wraith dragon
#

Interesting, I will test it later, thanks for the W minigame strucutr

coarse finch
#

i have in my config a section that is ```yaml
punishments:

triggers:
  TOXICITY: ">=0.9"
  SEVERE_TOXICITY: ">=0.9"

# Do we require all triggers to be met, or just one?
required_triggers: 1

# Actions to take when the triggers are met
# Placeholders:
# %player% - the player who sent the message
# %message% - the message that was sent
# %score% - the scoring of the message

actions:
  remove_message: true
  send: "&cYour message was removed because it was toxic."
  notify: "&cMessage by %player% was removed because it was toxic. Score: %score% - Message: %message%"
  • triggers:
    SPAM: ">=0.9"
    required_triggers: all
    actions:
    remove_message: true
    send: "&cYour message was removed because it was spam."
    notify: "&cMessage by %player% was removed because it was spam. Score: %score% - Message: %message%"
    command: "mute {player} 1h"```and i cant figure out how i would iterate over every node
rotund ravine
undone axleBOT
#

Itโ€™s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

coarse finch
hazy cypress
forest moss
#

hello, im trying to do a command which causes the minerals to cook instantly, so idk why my code burn only the coal and not the minerals, anyone can help me?
@EventHandler
public void onFurnaceBurn(FurnaceBurnEvent event) {
if (autoSmeltEnabled && event.getBlock().getState() instanceof Furnace) {
Furnace furnace = (Furnace) event.getBlock().getState();
ItemStack input = furnace.getInventory().getSmelting();
if (input != null) {
event.setBurnTime(1);
}
}
}

@EventHandler
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
    if (autoSmeltEnabled && event.getBlock().getState() instanceof Furnace) {
        Furnace furnace = (Furnace) event.getBlock().getState();
        ItemStack input = furnace.getInventory().getSmelting();
        ItemStack result = event.getResult();

        if (input != null && result != null && result.getType() != Material.AIR) {
            Material inputType = input.getType();

            if (inputType == Material.IRON_ORE) {
                result.setType(Material.IRON_INGOT);
            } else if (inputType == Material.GOLD_ORE) {
                result.setType(Material.GOLD_INGOT);
            } else if (inputType == Material.ANCIENT_DEBRIS) {
                result.setType(Material.NETHERITE_INGOT);
            }

            furnace.getInventory().setResult(result);
        }
    }
}

}

hybrid spoke
subtle otter
#

Yo any know how to help,trying to create a namespace key = new namespace key(),idk what to put in the brackets

eternal oxide
#

(pluginInstance, "keyname")

subtle otter
eternal oxide
#

show code

subtle otter
#

Can I DM U

eternal oxide
#

no

#

?paste

undone axleBOT
subtle otter
eternal oxide
#

pluginInstance has to be YOUR plugin instance

#

is this method in your main plugin class?

subtle otter
#

Nope

eternal oxide
#

you need to pass a plugin instance to it, or create yoru keys elsewhere that has access to your plugin instance

subtle otter
#

I'm new to this elaborate ๐Ÿ™ƒ

eternal oxide
#

You are going to find it difficult as it's private static

#

?di

undone axleBOT
subtle otter
#

Shud I change it to public

eternal oxide
#

or you could use teh String, String constructor

#

not as safe, but useable

#

like new NamespacedKey("MyPluginName", "key")

#

all lower case

subtle otter
#

I have that and there's a red line underneath

#

Keeps coming up as a red line underneath

eternal oxide
#

hover over and see what the error is

subtle otter
rough ibex
#

You should really pass in the plugin instance

subtle otter
#

Tf is the plugin instance

eternal oxide
#

you have no instance for ZorroSMP

rough ibex
#

plugin instance is the instance of your plugin.

eternal oxide
#

just use "zorrosmp" instead of ZorroSMP

subtle otter
#

tried that it comes up red

eternal oxide
#

""

subtle otter
#

Oh

eternal oxide
#

you are just typing words. it's a String so needs " "

rough ibex
#

I hate to say it but

#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programmingโ€”great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! ๐ŸŽ‰

rough ibex
#

You really should know some Java basics.

subtle otter
#

Thanks

rough ibex
#

such as objects

subtle otter
#

Aot

#

Appreciate it

#

Imma go through all these

eternal oxide
#

Learnign takes time. just keep going steady

subtle otter
#

Yes ik I've been doing yt tutorials and getting nowhere

rough ibex
#

Use the resources that work for you

#

youtube tutorials may not work

subtle otter
#

Yes I realised that ๐Ÿ˜ญ๐Ÿ˜ญ

eternal oxide
#

zorrosword is not a material

subtle otter
#

does this look right for me to be able to shoot a fireball out og my custom item with right click

subtle otter
#

bc thats y i added namespacekey

eternal oxide
#

yeah, but you never did anythign with the key

#

you created it but didn;t put it anywhere

subtle otter
#

oh...

eternal oxide
#

You should have put it in the PDC

subtle otter
#

?pdc

eternal oxide
subtle otter
#

getting more problems

rough ibex
#

and the error is

#

also ... isn't valid

subtle otter
#

mat.PI

eternal oxide
#

Math. not math. but you don;t need that

subtle otter
#

thats one problem i believe i solved the rest

rough ibex
#

PI is just an example

eternal oxide
#

you could put an INTEGER, 1

subtle otter
#

when i add the integer 1 it turns red

eternal oxide
#

it really doesn't matter what you put as you only need to check the key exists in the PDC later

#

you don;t actually need to check its value

subtle otter
#

does this look right bc imm not getting any errors

eternal oxide
#

looks fine

#

err no

#

you get the PDC but do nothing with it

rough ibex
#

you get the PDC but don't do anything

#

you aren't assigning it to anything

eternal oxide
#

you deleted the .set(...

subtle otter
#

when i add the set it goes red

#

okay imma just go lean java

rough ibex
#

You should really learn what you're doing

#

yeah

#

'it goes red' you should understand why

subtle otter
#

yeah sound like a better idea than relying on ya;;

eternal oxide
#

.set(key, PersistentDataType.INTEGER, 1);

subtle otter
#

okay thanks

#

@rough ibex can u send the link for learning java please

rough ibex
#

Scroll up

wet breach
#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programmingโ€”great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! ๐ŸŽ‰

acoustic shuttle
#

how would I go about doing this as it isn't working

String uuid = event.getPlayer().getUniqueId();```
I want to set the uuid var to the player's uuid when they join 

```js
public class PlayerJoinListener implements Listener {

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event){

        String uuid = event.getPlayer().getUniqueId();

    }
}```
echo basalt
#

Well

#

Is a unique id a string?

acoustic shuttle
#

uh idk

echo basalt
#

What does your IDE tell you

acoustic shuttle
#

tbh I don't think im even doing it right

eternal oxide
#

delete the String keyword and see what your IDE says

acoustic shuttle
#

UUID uuid = event.getPlayer().getUniqueId();
ah so this would get their uuid?

rough ibex
#

yes

acoustic shuttle
#

alright I'm having trouble and I'm really trying but I can't seem to figure out how to create a yml file in my plugin folder in a playerdata folder which I'm aware probably isn't efficient I'm just learning right now so I'm trying to learn how to create them

sullen marlin
#
BukkitWiki

The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...

eternal oxide
#

?configs

undone axleBOT
acoustic shuttle
#

ohh tysm

paper crest
#

When i cancel PlayerDropItemEvent and when I use PlayerInteractEvent and I click Q (drop item attempt) is calling action LEFT_CLICK_AIR.

sullen marlin
#

because the event fires when the left hand swings on air, which is what happens when you drop an item

acoustic shuttle
#

FileConfiguration data = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "player_data" + File.separator + "data.yml"));
how would I make get data folder work it's not working rn what do I need to return in the metohd?

sullen marlin
#

what's the issue you're facing

sullen marlin
sullen marlin
#

I dont think there is a way to fix it because the client is swinging the hand

paper crest
#

I want to disallow Q from left click items.

#

So I want to trigger only with left click not with Q.

#

I think I can cache the item on drop.

valid burrow
#

what

paper crest
idle loom
#

How do you get an enchantment by a string?
Because Enchantment.getByName and .getByKey are both deprecated and I'm not sure what it means by getting it via the Registry

sullen marlin
#

Registry.ENCHANTMENT.match

idle loom
#

thank you

acoustic shuttle
sullen marlin
#

plugin.getDataFolder().mkdirs() before maybe

upper hazel
#

can I format string to textComponent and back while maintaining color integrity (I need it for holograms)?

acoustic shuttle
#

like this?

sullen marlin
#

yeah

acoustic shuttle
sullen marlin
#

well it wont generate anything, that code loads the file

#

what are you trying to do

acoustic shuttle
#

right now I'm just trying to create a yml file for everyone who joins the server so I can save data to it later

#

ik its not the best idea if they join and never play again

#

but it's just learning right now

sullen marlin
#

the file will be created when its saved with .save

acoustic shuttle
sullen marlin
#

when you want to save the file

#

data.save..... read the link that was sent

ocean hollow
#

Can I use packages to make the item look different on F5?

lost matrix
ocean hollow
gleaming grove
quartz anchor
#

i think i encountered a bug or something. setting the PublicBukkitValues.<whatever that is> to empty list ([]) and then trying to get the list of data containers from plugin throws The found tag instance (NBTTagList) cannot store List

quartz anchor
lost matrix
# ocean hollow

The F5 key will show you the view other players have of you.
So if you want to change the items model for this, it will be changed for everyone.

ocean hollow
#

other players see a crossbow, if I send a package to the player himself, saying that he has a different item, then what will happen?

lost matrix
#

That works. But its not changing your own view in 3rd person. Only the perceptions other have of you.

sullen marlin
#

?jira

undone axleBOT
quartz anchor
#

i got bad gateway when opening jira

sullen marlin
#

Rip

icy beacon
#

same btw

#

is it down

sullen marlin
#

gonna up the ram, newer versions are heavier it seems

supple topaz
#

is it possible to completely remove the displayname of an item so it doesn't show up when you hover over it?
"" or null just give it its normal name and "ยงr" shows a small text box when hovering over the item

topaz cape
#

unreleased 1.9.X is fire though

lilac dagger
#

not that i know of

slate surge
icy beacon
#

What is the problem?

slate surge
#

when i am opped i can place blocks in all areas but when i am not opped i can not

icy beacon
#

Is this your plugin or are you administrating?

slate surge
#

my plugin

icy beacon
#

Then you made it that way. Not sure what the question is

#

?nocode

undone axleBOT
#

Itโ€™s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

slate surge
#

no no

#

my block place event is this```java
@EventHandler()
public void onBlockPlace(BlockPlaceEvent event)
{
if (event.getBlockPlaced().getLocation().getY() > 100 && !(event.getPlayer().getGameMode() == GameMode.CREATIVE))
{
event.setCancelled(true);
event.getPlayer().sendMessage("You are only allowed to placed blocks as high as 100 on Y axis!");
return;
}
if (event.getBlockPlaced().getType() == Material.TNT)
{
event.getBlockPlaced().setType(Material.AIR); // Remove the TNT block
event.getBlockPlaced().getWorld().spawn(event.getBlockPlaced().getLocation(), TNTPrimed.class); // Spawn ignited TNT
return;
}
if (event.getPlayer().getGameMode() == GameMode.SURVIVAL)
{
Location location = event.getBlock().getLocation();
gameSession.addPlacedBlocks(location);
}

}```
#

and i dont have any plugin like world edit or world guard

icy beacon
#

Are you sure you don't have any other BlockPlaceEvent in your plugin?
Also if there are any other plugins on the server that your plugin can work without, remove them and try again.
If the problem persists, go through every BlockPlaceEvent you have, find every event.setCancelled(true) and place some debug statement before it and see which one gets called

slate surge
#

nope i do have a interact event? will that interfear with it?

icy beacon
# slate surge my block place event is this```java @EventHandler() public void onBlockPlace...

Also it'd be good for readability to cache these variables

@EventHandler()
    public void onBlockPlace(BlockPlaceEvent event)
    {
        Block block = event.getBlockPlaced();
        Player player = event.getPlayer();
        if (block.getLocation().getY() > 100 && !(player.getGameMode() == GameMode.CREATIVE))
        {
            event.setCancelled(true);
            player.sendMessage("You are only allowed to placed blocks as high as 100 on Y axis!");
            return;
        }
        if (block.getType() == Material.TNT)
        {
            block.setType(Material.AIR); // Remove the TNT block
            block.getWorld().spawn(block.getLocation(), TNTPrimed.class); // Spawn ignited TNT
            return;
        }
        if (player.getGameMode() == GameMode.SURVIVAL)
        {
            Location location = event.getBlock().getLocation();
            gameSession.addPlacedBlocks(location);
        }

    }

And maybe even cache block.getLocation

icy beacon
slate surge
#
@EventHandler
    public void onPlayerInteract(PlayerInteractEvent event)
    {
        Player player = event.getPlayer();
        if (event.getAction().toString().contains("RIGHT_CLICK") && event.getItem() != null)
        {
            if (isFireball(event.getItem()))
            {
                Vector direction = player.getLocation().getDirection();
                player.launchProjectile(Fireball.class, direction);
                if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
                {
                    return;
                }
                event.setCancelled(true);
                ItemStack fireballItem = event.getItem();
                int amount = fireballItem.getAmount();
                if (amount > 1)
                {
                    fireballItem.setAmount(amount - 1);
                } else
                {
                    player.getInventory().remove(fireballItem);
                }
            }
        }
    }

    private boolean isFireball(ItemStack item)
    {
        if (item == null || item.getType() != Material.FIREBALL)
        {
            return false;
        }
        Material material = item.getType();
        return material == Material.FIREBALL;
    }```
slate surge
icy beacon
#

Do you have any other plugins on the server?

#

It also could be spawn protection actually, what are the coordinates of the place you were at?

#

If spawn-protection in your server.properties is not 0, try setting it to 0

slate surge
#

its around 0 0

#

wait let me try disabling spawn prot

slate surge
icy beacon
#

Set it to 0 and see

#

Line 37

slate surge
#

lol i am blond

icy beacon
#

Happens

slate surge
#

works!

#

tysm

icy beacon
#

GG

slate surge
#

also how to use Location to set a block as bed?

alpine urchin
#

since it has two parts

#

@slate surge

#

to get the block of the location do

Block block = location.getBlock();
slate surge
#

umm

alpine urchin
#

what

#

you want me to spoonfeed you even more

icy beacon
#

Is there a way to prevent feeding/sitting animals? This simply doesn't work (rmbing sits/feeds the animal)
Yes, the listener is registered and the debug message is printed

  @EventHandler
  fun onInteract(event: PlayerInteractAtEntityEvent) {
    // Disallow sitting & feeding wolves
    if (event.rightClicked !is Wolf) return
    println("YOU INTERACTED WITH WOLF!?!?!?!")
    event.isCancelled = true
  }
slate surge
#

u using kotlin? @icy beacon

icy beacon
#

Yes

alpine urchin
#

after setting canceled to false, you can just unsit them:

 if (!(w.isSitting())) {
    w.setSitting(false);
}```
#

@icy beacon

icy beacon
#

Sitting is fine, I'm more concerned about feeding

#

I'd have to fetch the player's hand and give it back a tick later

#

This feels hacky

slate surge
icy beacon
#

Surely there's a way

icy beacon
slate surge
icy beacon
#

Dude please

alpine urchin
icy beacon
#

I've scoured some forums

slate surge
#

more

icy beacon
#

People have struggled with this same problem and did some hacky shit

slate surge
#

pls

icy beacon
#

I'm not gonna be consulting gpt about this lmao

acoustic shuttle
#
        YamlConfiguration playerData = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "player_data.yml"));
        playerData.save("player_data.yml");

why isn't this generating the file?

slate surge
#

which api? spigot or bungee?

alpine urchin
# slate surge yes
//Converts the location to a block as you asked for
Block bedFoot = location.getBlock();
//Accesses the second part block, since a bed is two blocks.
Block bedHead = bedFoot.getBlock().getRelative(BlockFace.SOUTH);
//Set both to material block
bedFoot.setType(Material.BED_BLOCK);
bedHead.setType(Material.BED_BLOCK);```
icy beacon
ivory sleet
#

so u're basically loading the file into memory and then saving it back from memory to file directly?

slender elbow
#

and this is why ai won't replace programmers

lilac dagger
#

because the bed can be facing any of the main cardinals

alpine urchin
#

yes, but he said he wants to do this based on a location

#

but yes its better to work with an event

slate surge
#

@acoustic shuttle the way i create config shit

public void loadConfig()
    {
        // Load the configuration file
        File configFile = new File(getDataFolder(), "config.yml");
        if (!configFile.exists())
        {
            
            saveResource("config.yml", false);
            getLogger().info("config.yml not found, creating new one.");
        }
    }```
upper hazel
#

how some tab plugins bypass the maximum length of 16 characters along with color encoding

#

and what are the best pockets to use for tab

orchid hinge
#

there sure as hell isnt one for me

upper hazel
#

or are they edited separately

orchid hinge
#

this dont look like 16 characters to me

#

wait ill check my coding changing it

upper hazel
#

oh...

orchid hinge
#

yeah i just use Player.setPlayerListName()

upper hazel
upper hazel
orchid hinge
#

works for me

upper hazel
#

setPlayerName worked only in chat as long as I remember

orchid hinge
orchid hinge
#

setPlayerListName is for tab

upper hazel
#

I've already struggled with the packages...

orchid hinge
#

my entire tab name changing is this ```java
public void updatePlayerListName(Player p) {
Rank playerRank = CrystalCore.getInstance().rankManager.getPlayerRank(p);

    String playerName = p.getName();
    if (nicknames.containsKey(p)) {
        playerName = nicknames.get(p);
    }

    String newPlayerName = playerRank.getPrefix() + " " + playerName;

    if (CrystalCore.getInstance().vanishManager.isVanished(p)) {
        newPlayerName = newPlayerName + " &6[Vanished]";
    }

    p.setPlayerListName(Core.color(newPlayerName));
}```
#

and 99% of that code is to work with the rest of my plugin

upper hazel
#

thank you you saved so much time

orchid hinge
#

only relevant part of that code is p.setPlayerListName(Core.color(newPlayerName));

slate surge
#

why this works for one player and not the other?

for (Player player : Bukkit.getServer().getOnlinePlayers())
        {
            sendPlayerToServer(player, "practice_lobby");
        }
        Bukkit.getServer().shutdown();
public static void sendPlayerToServer(Player player, String server)
    {
        ByteArrayOutputStream b = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(b);

        try
        {
            out.writeUTF("Connect");
            out.writeUTF(server);
        } catch (IOException e)
        {
            e.printStackTrace();
        }
        player.sendPluginMessage(getPlugin(), "BungeeCord", b.toByteArray());
    }
orchid hinge
#

if it works first try it probablt doesnt work in production

slate surge
agile anvil
hazy parrot
ocean hollow
#

Is there a method that will only play the sound to one player?

lost matrix
ocean hollow
#

and what are the arguments?

ocean hollow
lost matrix
#

I feel like an AI assistant searching for data in javadocs...

chrome beacon
#

Same ;/

eternal night
#

how do I send a particle to a player

lost matrix
eternal night
#

COPIUM 7smile7GPT pls generate code examples that work 100%

#

Maybe we just need spigot GPT

#

Actually, isn't discord working on like, user installed apps?

worthy star
#

how can i export my codes to another project with intellij? if this is the right channel

lost matrix
# eternal night Maybe we just need spigot GPT

Honestly, with the new LLMs that have a 2M input vector and context size, you could literally give it the entirety of Spigot, Craftbukkit and SpigotAPI + javadocs
and it would be able to write code for you.

lost matrix
native nexus
#

If thatโ€™s what you want and not learn anything

lost matrix
worthy star
#

no no

undone axleBOT
worthy star
#

hi

#

so

#

i always get this error whenever i execute my command
Command code
Commands Manager code

#

would appericate it if someone helps me :)

ivory sleet
lost matrix
#

@eternal night ETA?

eternal night
#

this is a secret project

hazy parrot
worthy star
#

int id = (Objects.requireNonNull(config.getConfigurationSection("warnings")).getKeys(false).size()) + 1; this

#

1 sec

hazy parrot
#

Check that

worthy star
#

it worked thx

#

but

#

i have a return false if args length != required args
and `usage: '/warn [player] [reason]'

#

in plugin.yml
but it sends error if i don't set args instead of usage

#

i tried to make another test cmd with usage and required args and it worked

eternal oxide
#

WarnCmd.java:19

#

check length of array before trying to use

worthy star
#

ty

abstract iron
#

Hey sorry if this is a bit of a newbie question here but how do I check what the Language level of the project default is in intelliJ if anyone can assist?

lilac dagger
#

click the 3 dashes in the up left corner and project structure

#

you'll see there the language level

#

however i'm not sure if it'll show the same as with maven, so you might wanna consider relying on the maven one instead

abstract iron
lilac dagger
#

i usually specify it in maven

abstract iron
#

ah alright appriecate the help

upper hazel
lilac dagger
#

i see something about Component.text();

surreal wind
#

guys im trying to make a system where i have custom items that i can acces from every class but i dont know how to do that, do i make a class and a getter for every item?

lilac dagger
#

have a common class offer you access

surreal wind
#

what is a common class

lilac dagger
#

you can put it in a manager and that manager be used to inject into your classes that need it

surreal wind
#

is there a youtube tutorial on this cause im confused

lost matrix
surreal wind
lost matrix
#

With configurable i meant through a config file by the plugin user

surreal wind
#

no

lilac dagger
#

with a itemstack builder

surreal wind
#

so i creathe a method which makes an itemstack then where do i store the itemstack

lilac dagger
#

a manager

lost matrix
lilac dagger
#

or a factory

surreal wind
#

i need to store it somewhere

#

like for a recipe or when i right click

lost matrix
#

Why do you need to "resuse" it?