#help-development

1 messages · Page 653 of 1

unkempt peak
#

If you want you can dm me the plugin source on github and I can investagate it better and see if I can figure it out @sage dragon

sage dragon
#

I just figured it out 😅

It's really simple...

Just add a delay between closing the shulker and re-opening the chest.

Seems like 1 Tick is enough

#

Thanks for your help 😅

unkempt peak
#

np, sorry I wasn't very useful lol

simple schooner
#

damn it involves NMS, I probably wanna learn the fundamentals of java first before tackling with NMS

unkempt peak
simple schooner
#

what but they used it in an example I found in the forums

formal bear
#

Event is causing server to crash, seems to spam, listener registered only once, anyone?

    @EventHandler
    public void onPlayerSleep(PlayerBedLeaveEvent event) {
        World world = Bukkit.getWorld("world");
        if (world == null) return;
        event.getPlayer().sendMessage("Time: " + world.getTime());
    }
simple schooner
shadow night
#

this is a thing

formal bear
#

Ik, this is not the problem tho

shadow night
#

last time I used PlayerBedLeaveEvent it worked fine

lost matrix
shadow night
#

yep

#

and you can also change the name of the main world which will fuck up thigns

unkempt peak
#

Wouldn't it just throw an npe tho?

shadow night
#

ig

#

but you don't want a npe

unkempt peak
#

Right, but that doesn't really explain the spam

lost matrix
#

It wouldnt cause an npe

unkempt peak
#

Well yeah it this case it would just return

lost matrix
#

Im suspecting that there is a recursive trigger of this event somewhere else

unkempt peak
#

Which means it can't be the problem because the code below it is running

#

Yeah the problem can't be with the code they showed

formal bear
#

Hm weird, i've just restarted the server and now it's working as it should 🤔

#

Nevermind, thanks for help

lost matrix
#

Dont tell me you used /reload

unkempt peak
#

Again, something else is causing it

formal bear
simple schooner
#

uhm what

lost matrix
#

you called player.toString() instead of getName()

simple schooner
#

o

#

damn

unkempt peak
#

Also cancel the chat event or other players can see that

formal bear
unkempt peak
#

Just teleport them after they leave bed

formal bear
#

It's causing to loop

unkempt peak
#

Wdym?

#

show your whole event listener

formal bear
#
    @EventHandler
    public void onPlayerSleep(PlayerBedLeaveEvent event) {
        Player player = event.getPlayer();
        World world = player.getWorld();
        player.sendMessage("Time: " + world.getTime());
        player.teleport(new Location(world, 0.0, 87.0, 0.0));
    }
}```
unkempt peak
#

Why are you hard coding the location

shadow night
#

I have the same question

formal bear
#

Just for testing

#

Wdym

#

I can set it with injected config no difference with the functioning

unkempt peak
#

Ok, explain what the goal is here

#

why are you doing this

formal bear
#

I want to teleport player when he leaves the bed.

unkempt peak
#

Why?

lost matrix
formal bear
formal bear
shadow night
unkempt peak
#

fr

tall dragon
shadow night
#

depression be like

#

I remember I had a plugin where for each certain action I would create a timer for x amount of time, which means there would be a shit ton of timers running each tick

icy beacon
#

funny thing is that i've read the docs before but completely forgot about it

tall dragon
#

yeaa thats another one

tall dragon
#

at least its documented for that one

unkempt peak
#

When the solution is right in front of your face but your just blind

#

I swear programmer blindness is a real thing

zealous osprey
unkempt peak
#

Yeah just maybe

simple schooner
#

how do I hide yaml files from the server's files

icy beacon
#

yeah

unkempt peak
#

Why would you want to do that

zealous osprey
zealous osprey
unkempt peak
#

I mean sure you can just put the file somewhere else

zealous osprey
#

Yeah, for example in the .jar itself using the resource dir

simple schooner
unkempt peak
#

Wait what players? how would they have access to the file

simple schooner
#

uhm not players

zealous osprey
simple schooner
#

I meant those who have access to the servers files

icy beacon
#

just name the file something scary like ".data" or "DONOTTOUCH"

#

a competent admin will be able to open the jar archive and edit the files if necessary

#

it takes 0 effort

unkempt peak
#

There's no real reason to hide files from admins, the server data folder exists for a reason

zealous osprey
simple schooner
#

okay

unkempt peak
#

Also yeah just serialize to a dat

tall dragon
#

good luck deciphering

zealous osprey
unkempt peak
#

You literally just make the object serializable and write it directly to .dat

#

Without needing to write serializing logic for yml or json

#

Just store the raw data if it doesn't need to be edited outside of run time anyways

#

just implement Serializable and write the ObjectInputStream to a .dat file

tall dragon
#

probably ObjectOutputStream but sure

unkempt peak
#

Yeah lol

silent steeple
#

any config apis

fluid river
#

?learnjava

undone axleBOT
fluid river
#

that's for me

quaint mantle
unkempt peak
quaint mantle
unkempt peak
#

Fair enough

short raptor
#

Any way to detect and setCancelled on a warden doing a sonic boom attack?>

unkempt peak
short raptor
#

Alr

unkempt peak
quaint mantle
#

Unless theres a sonic boom attack event

unkempt peak
#

Don't just immedeatly resort to nms

#

that should be last resort

quaint mantle
#

I dont fw new api

#

my bad

unkempt peak
#

Just use the damage cause

unkempt peak
quaint mantle
#

It doesn't implement Cancellable?

fluid river
#

as you can see

#

but probably it's subs do implement it

quaint mantle
#

EntityEvent doesn't

#

Event doesn't

#

Object surely doesn't

spare hazel
#

how can i ceate a TabCompletor. i know how to set it to a command but idk how to create it

unkempt peak
#

SONIC_BOOM is right in the docs for EntityDamageEvent

fluid river
#

class implements TabCompleter

#

ez

spare hazel
fluid river
shadow night
fluid river
#

you will have method onTabComplete()

#

in your command class

#

after you implement TabCompleter

spare hazel
#

in my command class?

#

not a seperate command?

#

class i mean

fluid river
#

and then in main you would need getCommand("cringe").setTabCompleter(yourCommandClass);

#

yes

unkempt peak
# spare hazel no how to actually create the tabcompletor

Learn how to add tab completer to your commands! Super fast and easy :)

~ Sorry I missed last week, been super sick. More videos coming soon once I'm fully healed :D
CodedRed.setHealth(20.0);

------ Links ------

Download Eclipse: https://www.eclipse.org/downloads/packages/release/2019-03/r/eclipse-ide-java-developers

Download Spigot: htt...

▶ Play video
fluid river
#

implements CommandExecutor, TabCompleter

spare hazel
#

alr

#

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return HypixelCustomItems.getPlugin().getItems().keySet().stream().toList();
}

like this?

fluid river
#

sure

spare hazel
#

alr thanks

unkempt peak
#

Well that would return the same list for any arg

#

You might want to check which arg your tab completing unless it's irrelevant

unkempt peak
#

Yeah that's a bit wierd

hazy parrot
#

Just return new ArrayList<>(set)

unkempt peak
spare hazel
hazy parrot
spare hazel
hazy parrot
#

You are making new stream instance and then still iterating over it to accumulate it into list

unkempt peak
#

It's simply unnecessary

hazy parrot
#

When you can just directly make it

spare hazel
#

ok alr

#

return new ArrayList<>(HypixelCustomItems.getPlugin().getItems().keySet());

#

like this?

unkempt peak
#

Yep

#

Also use code blocks when sharing code please

#

Or paste if it's big

spare hazel
#

and another question:
if i setup interfaces in my plugin for each class and then provide the plugin in my other plugin, will i beable to use all the methods from the 1st plugin?

smoky oak
#

thats not what interfaces are for

#

tldr you can use all public methods

unkempt peak
#

Yeah as long as the class and method is public you just need to get the plugin and add depends in your yml

alpine urchin
#

since the other implements it

smoky oak
#

you can have plugins depend on each other given two caveats

alpine urchin
#

for the functions to work, you need to instantiate it which according to your code is in the second plugin

smoky oak
#
  1. you don't define hard dependencies
  2. you don't use the other plugin's methods before load is complete
#

you then can use bukkit methods to obtain the plugin instances

#

not a good idea tho lol

unkempt peak
#

Yeah unless you didn't make them it's kinda pointless

spare hazel
smoky oak
#

wym

alpine urchin
#

its one jar

#

well

#

at the end when you run it

#

its one jar

spare hazel
alpine urchin
#

not spigot-api.jar and spigot-impl.jar

smoky oak
#

well yes

alpine urchin
#

bukkit is interfaces

smoky oak
#

the spigot api is just a list of shit

#

not the actual code

alpine urchin
#

craftbukkit implements it

smoky oak
#

it tells your IDE 'this method exists'

spare hazel
#

and in spigot everything implements the things in spigot-api

smoky oak
#

so that you can compile

smoky oak
#

if you run buildtools with --generate-source youll see what i mean

spare hazel
#

wait so bukkit has a class org.bukkit.CraftPlayer that Implements EntityPlayer(org.bukkit.EntityPlayer)
and in bukkit api theres an interface at org.bukkit.EntityPlayer just to make the ide think theres an actual meethod at that position?

alpine urchin
#

you got it kinda wrong

#

but Player is a bukkit class

#

with your api methods

#

CraftPlayer implements it

#

bukkit is the api

spare hazel
#

so bukkit is just the api and craftbukkit is the actual code executor?

alpine urchin
#

yes

fluid river
#

yes

#

and spigot is api above bukkit

alpine urchin
#

craftbukkit mainly uses nms which is mojangs code to implement bukkit

spare hazel
fluid river
#

and paper is kinda spigot but with some features

alpine urchin
#

you cannot access

#

craftbukkit

#

you cant just do new CraftPlayer inside bukkit

#

they can’t depend on each other

#

its a one way thing

spare hazel
alpine urchin
#

we added some functions

#

including the com

drowsy helm
#

Spigot just bukkit but orange

alpine urchin
#

ps me

#

so im offended

unkempt peak
#

And paper is just spigot but white

alpine urchin
#

tf

shadow night
simple schooner
#

Is it okay to store an arraylist inside an hashmap thats inside another hashmap

alpine urchin
#

?xy

undone axleBOT
shadow night
#

what the heck

alpine urchin
#

if you tell us the context of the situation we can advise you a better solution

shadow night
#

List<HashMap<HashMap>>

unkempt peak
#

What in the fuck are you trying to do my dude

#

lmao

simple schooner
spare hazel
simple schooner
#

wait actually nvm I'll just fuck around and find out

unkempt peak
#

Great idea

simple schooner
#

but is this performant though

unkempt peak
#

Fr tho what led you to that abomination

shadow night
unkempt peak
simple schooner
#

I don't know, I don't have any other solutions in mind

unkempt peak
#

Tell us the problem

#

?xy

undone axleBOT
simple schooner
#

nah I'm scared to get humiliated, I'll just fuck around and find out

unkempt peak
#

Mate if you want help you gotta give us something to work with

simple schooner
unkempt peak
#

If your really that self conscious dm me lol

simple schooner
#

why am I even doing this

#

😭

unkempt peak
#

You good man?

simple schooner
#

I dont know why I'm storing this in a hashmap

hazy parrot
#

You probably want to explain what u want to do

#

Because you probably don't need that much nested collections

simple schooner
#

I might need a database for this wait nvm

tender shard
#

damn, I should have changed one more file

simple schooner
#

thats alot of files lol

zealous osprey
tender shard
#

no

#

gitignore is fine

#

it's 99 actual class files that have changed

zealous osprey
#

oh wow

tender shard
#

main reason for all the file changes is that I changed the main class name lol

zealous osprey
#

XD

#

ah yes, when everything "updates" cause you gotta change an import statement

ivory sleet
#

Ouch

tender shard
#

how to make intellij stop claiming that "%%__USER__%%".startsWith("%") is always true

ivory sleet
#

//noinspection ConstantConditions

#

iirc

tender shard
ivory sleet
#

without the s I think?

tender shard
#

no :/

#

but it's not important, I like this funny workaround

ivory sleet
#

Aww hmm well u can add the appropriate inspection exemption by alt + enter othewise (and then click one of the bottom thingies)

#

yeah

tender shard
#

its only purpose is to print "AngelChest" or "AngelChest Plus" anyway

ivory sleet
#

Yea

#

I got that also when using blossom

tender shard
#

blossom?

eternal night
#

blossom party

ivory sleet
#

Yeaa blossom, epic stuff

eternal night
#

A Gradle plugin to perform source code token replacements in Java-based projects

#

just don't name the org it is under in the spigot discord monkaCross

tender shard
#

i wonder how spigotmc's .jar injection stuff works

#

it somehow "transforms" .jar files on the fly when you download any paid plugin

lilac dagger
#

java assist maybe?

onyx fjord
#

doesnt javaassist work at runtime

lilac dagger
#

then i guess not

onyx fjord
#

how do i rotate player in vehicle without dismounting?

chrome beacon
upper hazel
#

I made a plugin to change the basic attributes of the player, but due to bugs they stacked and in the end I demolished this plugin from the server and the effects remained

smoky oak
upper hazel
#

what do

onyx fjord
chrome beacon
#

I don't think it will

smoky oak
zealous osprey
#

I think they are talking about the player head block?

smoky oak
#

pretty sure a head cant ride a vehicle

shadow night
#

But it can be on an entity

sterile breach
#

good morning. In my command I find myself doing a lot of if eles to check the arguments (if there are 0 args, if there are 1, 2 etc...) it makes me recopy a lot of code and I was wondering if this was a bad thing?

smoky oak
#

if-else is done sequentially, so it's slower than switch for large amounts of if-elses. if you have the same code often you should probably put it in a function

#

but since it's in a command it should be fine

zealous osprey
#

I would recommend using a command framework, such as ACF; Search "acf spigot" and you'll find it.
It makes creating and maintaining commands much simpler.

sterile breach
zealous osprey
#

I find switch are less readable than if-else in most cases. However they have their place, especially when you want smth different to happen with different enums or such.
It's not "bad"; However many if-else statements are unreadable aswell, especially when they are nested.

#

Try not to nest if statements if possible, but rather use "guard clauses" or create a function which contains the logic then

quaint mantle
#

anyone know why the color shit isnt working

and also when i type a command and then a console message happens, it disregards the command

zealous osprey
#

Also the other point Moterius made, with putting the logic in a completely, probably static, function is good; ASLONG as the code is exactly the same.
Too often have I tried aswell to make one function fit all my needs, don't do that, it'll get messy real quick

zealous osprey
quaint mantle
#

what console supports it?

#

because it supports colors here

zealous osprey
#

I think there's a function to check that using sender#canSendColor or smth like that

zealous osprey
quaint mantle
zealous osprey
sterile breach
zealous osprey
#

then leave it

quaint mantle
zealous osprey
#

patience

ocean hollow
#

why line on the first screen can give null?

zealous osprey
#

do you mean the line:
Particle.valueOf(...)?

ocean hollow
#

yeah

sterile breach
#

exist an event when a block got breaked by explosion?

zealous osprey
#

Cause if the name for that enum doesn't exist in the enum, it'll throw an exception and return null

ocean hollow
#

that exists

#

config has the same name

zealous osprey
#

But java can't garuantee that it is the same, if the name is not specified within the byte/src code

sterile breach
#

I need to know when a block is broken. No matter how. Excepted block break event. What other reasons/events could there be?

zealous osprey
#

There might be smth like BlockChangeEvent and then check if the new state is of type Material.AIR?

lunar wigeon
#

there is no event BlockChangeEvent

#

basically, BlockBreakEvent 🙂

desert tinsel
#

How to create a shared inventory with multiple players, that can be updated in real time, like if I use the same instance of an Inventory for all players does it work, or I need to use events etc?

#

bassically I want a command /inv that opens that shared inventory

lunar wigeon
#

just create 1 inventory object and open it for the players

desert tinsel
#

would it update each time someone changes an item?

lunar wigeon
#

yes

desert tinsel
#

okie, thanks

smoky oak
#

BlockBurnEvent
BlockExplodeEvent (may be the tnt, may be the blown up block)
BlockFadeEvent
LeavesDecayEvent
SpongeAbsorbEvent

plus all player stuff @sterile breach

zealous osprey
smoky oak
#

the inventory should be a reference

#

this isnt feasilble for player inventories, but easily done with extra inventories

lunar wigeon
zealous osprey
lunar wigeon
#

it does

zealous osprey
#

neat

lunar wigeon
#

its same inventory object

#

so why wouldn't it?

#

just test it yourself if you dont believe

zealous osprey
#

Cause I'm not sure if Inventory updates after changing stuff with it

lunar wigeon
#

it doesesses

quiet ice
#

Can affirm

zealous osprey
#

Damn, that's cool. I didn't think it would send the updates.
That makes stuff like that very easy

haughty pewter
#

hey, how i could make only 1 nether portal in world ? and disable ability for other players to create one?

smoky oak
#

you just make a nether portal, and listen for the events that would create or destroy one, and cancel all those events

haughty pewter
#

could you make one for me? im not good at this 😅

smoky oak
#

I ran buildtools with --generate-docs
org.spigotmc:spigot-api:jar:javadoc:1.20.1-R0.1-SNAPSHOT was not found in https://jitpack.io

#

did something change?

quaint mantle
#

How do i put knockback on a stick? java.lang.IllegalArgumentException: Specified enchantment cannot be applied to this itemstack

smoky oak
#

you should be able to tell the stick it has the knockback enchantment, maybe you're trying to apply it to the wrong thing

quaint mantle
#

im doing it like this ```ItemStack stick = new ItemStack(Material.STICK);
stick.addEnchantment(Enchantment.KNOCKBACK, 2);

   p.getInventory().addItem(stick);```
zinc moat
#

Does anyone know how to make a 1.19.4 plugin to the following versions 1.20 1.18 1.17

smoky oak
#

can someone please post me a working project xml file with the javadoc and source code pulled from .m2? For some reason it's noto working for me

spare hazel
#
 @Override
    public void onBlockBreak(BlockBreakEvent e){
        if(e.getBlock().getWorld() != HypixelCustomItems.getPlugin().getServer().getWorlds().get(0)){
            for(int x = 0; x < 3; x++){
                for(int y = 0; y < 3; y++){
                    for(int z = 0; z < 3; z++){
                        if(allowedBlocks.contains(e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(x+1, y+1, z+1)).getType())) {
                            e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(x + 1, y + 1, z + 1)).setType(Material.AIR);
                        }
                    }
                }
            }
        }
    }

will this replace the blocks in a 3x3x3 area if the world isnt the main world and the block type is in the list of allowed block types?

sterile breach
smoky oak
#

im not guaranteeing anything, but that's what i think is more or less everything that can remove a block

zinc moat
#

Does anyone know how to make a 1.19 plugin to the following versions 1.20 1.18 1.17

smoky oak
#

viaversion

#

unless it relies on nms u probs can just recompile it for those versions

zinc moat
zinc moat
smoky oak
#

allows new clients onto old servers

zinc moat
#

isnt that player only

smoky oak
#

thers a reverse of that too

#

but it glitches if you go over that version that changed world height

zinc moat
fluid river
#

stop comparing worlds with !=

#

you have .equals for that

#

or you can compare their names

#

with .equals also

smoky oak
#

Hm this is interesting. Seems like it isnt building the javadocs. Anyone know why?
java -jar BuildTools.jar --generate-source --generate-docs --rev 1.20.1 --remapped

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Spigot-API 1.20.1-R0.1-SNAPSHOT .................... SUCCESS [ 13.127 s]
[INFO] Spigot-Parent dev-SNAPSHOT ......................... SUCCESS [  0.010 s]
[INFO] Spigot 1.20.1-R0.1-SNAPSHOT ........................ SUCCESS [ 37.505 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  50.723 s
[INFO] Finished at: 2023-08-03T16:22:29+02:00
[INFO] ------------------------------------------------------------------------
Picked up _JAVA_OPTIONS: -Djdk.net.URLClassPath.disableClassPathURLCheck=true
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.spigotmc:spigot-api >-----------------------
[INFO] Building Spigot-API 1.20.1-R0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------```
ocean hollow
#

How can I find out if a player's inventory is open?

fluid river
#

player.getInventoryView() ig

#

idk if it returns null when inv is closed tho

ocean hollow
#

oh, getOpenInventory()

#

so what does that mean? with what i need to check player inventory if he has inventory closed?

#

null?

#

it writes me "always false"

ocean hollow
#

what is "internal crafting view"?

chrome beacon
#

The one in the player inventory

ocean hollow
#

what is the name of the inventory in which there are 9 slots

river oracle
#

hotbar, Dispenser, Dropper

dawn plover
#

class org.bukkit.craftbukkit.v1_20_R1.inventory.CraftInventoryCustom cannot be cast to class org.bukkit.inventory.AnvilInventory

with var inventory: Inventory = Bukkit.createInventory(null, InventoryType.ANVIL)
and val anvilInventory : AnvilInventory = inventory as AnvilInventory (here is where the error happens)

this is really weird, because its an anvilInventory...

slender elbow
#

createInventory always creates that "custom inventory", not the real type

dawn plover
#

O_O

slender elbow
#

you'll have to work with the indexes for inputs/result

#

not that the anvil is too complicated anyway, 3 slots

dawn plover
#

i mainly use the the anvil for its typing function, is there any selution for? otherwise i dont need it anyway

eternal night
#

uwu ?

slender elbow
slender elbow
#

i mean you can still use that

river oracle
dawn plover
#

NMS? is that an api?

slender elbow
#

"work properly"?

river oracle
#

I mean that'd be the main reason to really use that inventory virtually I can think of

river oracle
dawn plover
#

oh wait ,yea, netMinecraftServer
welp, i guess i am not implementing any text ediding then lol

river oracle
#

I don't like its api that much, but idk what else exists

clear panther
#

Efficiency in minecraft: regular enchant lores
MD_5 Efficiency: DIG SPEED

fluid river
#

surewhynot

zinc moat
#

does anyone know how to make a command that gets an interger insted of a string

zinc moat
#

no

#

like

#

./flyspeed 2

#

for example

clear panther
#

tbh idrk how to do that

zinc moat
#

oh ok thats fine

clear panther
#

cause i use loop for stuff lol

zinc moat
#

ight

inner mulch
zinc moat
#
    @Override
    public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
        if (sender instanceof Player){
            Player p = (Player) sender;
            if (p.hasPermission("be.flyspeed")){

                if (args.length == 0){
                    p.sendMessage(ChatColor.RED + "Please provide the speed");
                    p.sendMessage(ChatColor.GREEN + "Example: /flyspeed 2");
                }else {
                    p.setFlySpeed(flyint);
                    p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Flying enabled");

                }
            }
        }
        return true;
    }
#

im trying to make a ./flyspeed command

#

i need to get an interger arg insted of a string arg

inner mulch
#

no parseint works too

#

what exactly doesnt work here?

#

it seems fine imo

zinc moat
#

org.bukkit.command.CommandException: Unhandled exception executing command 'flyspeed' in plugin BoxEssentials v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

#

it gave me a null

inner mulch
#

you entered /flyspeed 1, right?

zinc moat
#

yeah

zinc moat
inner mulch
#

i mean it said flying enabled, which is after setting flyspeed

#

so

#

you should be faster?

zinc moat
#

i did ./flyspeed 1

#

it gave me no error

#

i did ./flyspeed 2

#

it gave me an error

rotund ravine
#

Just parse the string

inner mulch
#

where is flyint defined?

#

i think this is the problem

zinc moat
#

i used to have

#

this

inner mulch
#

String flystring = args[0]

#

args = arguments that the player give

#

s

zinc moat
#

String flystring = flySpeed[0]
int flyint = Integer.parceInt(flystring) ;

chrome beacon
#

Missing ; and a typo

inner mulch
#

but in your oncommand it says args

zinc moat
inner mulch
#

is your flyspeed defined to be the args ?

zinc moat
#

i got this error

chrome beacon
zinc moat
#

ty ill try compiling it

#

ok

#

so

#

flyspeed 1 works flyspeed 2 doesnt

#

org.bukkit.command.CommandException: Unhandled exception executing command 'flyspeed' in plugin BoxEssentials v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

inner mulch
#

can you just send the full code?

#

without missing parts

zinc moat
#
    @Override
    public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
        if (sender instanceof Player){
            Player p = (Player) sender;
            if (p.hasPermission("be.flyspeed")){

                if (args.length == 0){
                    p.sendMessage(ChatColor.RED + "Please provide the speed");
                    p.sendMessage(ChatColor.GREEN + "Example: /flyspeed 2");
                }else {
                    String flystring = args[0];
                    int flyint = Integer.parseInt(flystring);

                    p.setFlySpeed(flyint);
                    p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Sucsesfully setted flyspeed.");

                }
            }
        }
        return true;
    }
#

sure

#

here it is

smoky oak
#

well since the error says unhandled, we dont know exactly what it is

#

wheres line 47

zinc moat
#

theres no line 47

smoky oak
#

this says the erro is in line 47

zinc moat
#

it only goes up to 32

smoky oak
#

wait you somehow broke bukkit

zinc moat
#

LOL

inner mulch
#

i used your code and it works fine

zinc moat
#

like are u able todo ./flyspeed 2?

inner mulch
#

remember that flyspeed 1 is the maximumg and you need to differ with 0.1 0.2

#

setting it to 1 is the max

zinc moat
#

bro

#

nahh

inner mulch
#

it works in my game

#

perfectly

zinc moat
#

so\

#

uh

#

that error

#

is when i do ./flyspeed 2

#

im dumb mb

inner mulch
#

you cant set it to 2

smoky oak
#

so the line that causes the error is sender.sendMessage(line);
line here is something from config

zinc moat
smoky oak
#

well if you set a point before it it shouldnt be counted as a command

smoky oak
#

theres no reason for you to get an error

zinc moat
#

uhh

inner mulch
zinc moat
#

@inner mulch try ./flyspeed 0.2

inner mulch
#

...

#

int wont work with 0.2

zinc moat
#

alright

inner mulch
#

i said it in the same exact message

zinc moat
#

im new tho

#

idk how to switch cases

inner mulch
#

switch is something like an if sentence but it switches corresponding to the value

zinc moat
#

ok

inner mulch
#

switch (flyint) {
case 1:
player.setflyspeed(0.1F)
break;
}

#

and so on

chrome beacon
#

but why though 💀

#

Just divide by 10??

inner mulch
#

because he wants to

#

why not

#

there are many approaches

zinc moat
chrome beacon
#

?learnjava

undone axleBOT
zinc moat
inner mulch
#

case 2:
blabla
break;

#

case 3:
blbl
break;

chrome beacon
zinc moat
inner mulch
zinc moat
#

ahh ok

zinc moat
inner mulch
#

dont forget to break;

zinc moat
#

ik

inner mulch
#

breaking the case is very important

chrome beacon
#

?spoon Just this

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

inner mulch
#

yes but its not spoonfeeding

#

i told him about switch cases

#

and the next time he has a problem he will hopefully use them

chrome beacon
#

I guess you volunteer to be a Java teacher then

zinc moat
chrome beacon
#

because they will ask for help with other basic Java things

#

instead of following the Java tutorials first

inner mulch
#

I prefer to learn like this as well, I do something that I want and once I have a problem I google or if that doesnt help ask here

#

im not watching 10 hours of tuts

#

i will start and ask once a problem occurs

smoky oak
#

asking here doesnt guarantee answers

#

wacht ill demonstrate

#

is there a non-backtracking regex for 'only numbers' and is it faster than try/catch around the java number parser?

smoky oak
#

see

#

case in point

inner mulch
#

did you wait your lifetime for this?

smoky oak
#

not really no

inner mulch
#

you send these messages like you copied them

#

i feel like you waited for the perfect moment

smoky oak
#

i prewrote that one like ten minutes ago and didnt want to interrupt

#

no deeper reason lol

inner mulch
#

ok xd

zinc moat
#

this would work?

inner mulch
#

its not loading

zinc moat
#
                        case 10:
                            p.setFlySpeed(1F);
                            p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Sucsesfully setted flyspeed.");
                            break;
#

this would work right?

inner mulch
#

try it :)

zinc moat
#

alright

#

compiling

inner mulch
#

I would recommend that you use intelliJ, its the most newbie friendly program in my opinion

inner mulch
#

hmm i guess yours looks different

zinc moat
inner mulch
#

a few minutes ago you had a problem with "parceInt" intelliJ wouldnt let that slide

#

i guess

#

but why wasnt there anything that told you its incorrect

#

why did it even compile?

chrome beacon
#

Eclipse can compile invalid code

zinc moat
#

i dont know java well but i can read and this aint looking good

chrome beacon
#

just throws an error when that code runs instead

inner mulch
#

Olivo, do you know how I can get if a crop is fully grown?

zinc moat
#

Ty for helping

inner mulch
#

np

zinc moat
#

it works

inner mulch
#

have fun with lightspeed flying

zinc moat
#
  • the message
mellow pebble
#

is someone good in math here ?

smoky oak
#

eeeeh kinda

#

y

zinc moat
#

inf money glitch

look for someone making plugins for money, then u list ur service for $2.50 more then the other guy then u hire him to make the idea ur customer wants u give the plugin to the customer boom free money

mellow pebble
zinc moat
smoky oak
#

maybe

#

whats it about

mellow pebble
#

well i need one picture which is 100x100 to be in center of my screen on x axis and slightly upwards then middle of screen on y axis .. so i need to calculate position of that image (x and y coordinates) to be exactly placed as mentioned before in middle of x axis and slightly upward on y axis like 200px higher than middle of y axis

mellow pebble
zinc moat
#

i barley know how fractions work so

mellow pebble
#

lets say this circle is picture and where it has to be placed

#

and it has to be in that position all the time even if display size is changed

shadow night
#

Isn't that like anchor points or some shit like that?

mellow pebble
#

i can for example get current display size and just divide by 2 and that is middle of x axis

#

but y axis is bit complicated

#

and im not sure how to fix that

#

@eternal oxide might know he is good at math but he is not online

zinc moat
#

any booster perks?

flint coyote
#

pink name

zinc moat
flint coyote
#

i'd say worth it. I just won't pay for nitro lol

zinc moat
#

i didnt pay for it

#

i tried to buy it and itt went thru

#

i looked at my bank account nothing got charged

#

next day still nothing charged

#

so i just got free nitro

flint coyote
#

sounds good

zinc moat
#

ikr

fluid river
smoky oak
#

regex backtracks to satisfy it's conditions

smoky oak
# mellow pebble

pretty sure you just need to multiply a double that gives percentual screen height (like 0.3, since screens usually start counting at the start) with the screen height for your y value

#

or well 0.7 if you start counting at the bottom

fluid river
zinc moat
#

all commands in my spigot plugin 🙂

fluid river
chrome beacon
#

It replaced the entire invalid method with a throw statement

fluid river
#

it just throws 99 errors

#

when you try to compile

#

try catch on parse is probably faster anyways

inner mulch
#

How do i get if a crop is fully grown?

fluid river
#

Ageable

inner mulch
#
    public void test (BlockBreakEvent event) {
        Block block = event.getBlock();
        Ageable ageable = (Ageable) block.getBlockData();
        if (ageable.isAdult()) {
            event.getPlayer().sendMessage("gfg");
        }
    }```
I did this, but it doesnt work
cursive glen
#

so I'm encountering a bit of a problem after coming back to plugin development

#

and I am unable to add my jars to the build path in my ide to make a plugin

fluid river
#

is it a correct ageable

cursive glen
#

I did a bit of research and it seems like now the jars contain many other folders

inner mulch
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

fluid river
#

?jd-s

undone axleBOT
fluid river
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

fluid river
#

there is getAge() and getMaxAge()

#

compare them

mellow pebble
inner mulch
smoky oak
#

you need to add the circle diameter

#

youre placing it's top left corner

fluid river
#

bruh just use your eyes to look at javadocs

#

yourself

inner mulch
#

im using paper

#

i should probably go to the paper server

fluid river
#

and???

mellow pebble
inner mulch
#

Its not THERE

fluid river
#

Ageable is part of bukkit api

smoky oak
#

well its screen height * percent value - 1/2 image height

fluid river
#

not paper

inner mulch
fluid river
#

show your import

#

Ageable

inner mulch
#

its non existent

fluid river
#

???????

#

just scroll up to the beginning of your class

inner mulch
#

i fixxed it

#

thank you

fluid river
#

how

#

i'm just curious

vital sandal
#

how can I get ping response of a server with bungeecord plugin?
I need to get this

inner mulch
#

i didnt even know that was a thing

fluid river
#

i literally just told you

#

wrong import

inner mulch
#

BRO you asked

cursive glen
#

so guys

#

if you didnt know

#

discord is currently shitting itself

#

and also

#

I actually managed to get the thing working

#

somehow

#

through just trying stuff in the ide

#

so thanks guys

vital sandal
fluid river
#

yeah

#

half of the messages just disappear

#

ping is also rly high

smoky oak
#

none of that happened to me toeday

inner mulch
#

Hello, is there a way to get all the pieces of cugarcane if i break the bottom part?

smoky oak
#

yea simple

#

just iterate upwards until you hit not sugercane

inner mulch
#

ok

#

got it

ocean hollow
#

how to load ItemStack[] from config

#

it gives me null

last abyss
#

Hi, someone know when i make color code on the display name the name of the player doesn't change on the top of his head ?

smoky oak
#

tab and player name are different things

#

i dont know the name of what you need to change tho

#

its probably referenced in the player class tho

cursive glen
#

how to send multiple clickable messages in a single message?

smoky oak
#

what do you set it to @last abyss

last abyss
smoky oak
#

yea i think you need to show the relevant code her

last abyss
#

the "relevant code" ?

smoky oak
#

yea how you're setting the name

last abyss
#

but i can only set the display name and the playerlist name or i just don't see it

smoky oak
#

there might be some update weirdness

#

i remember that there was some changes with inventory where it only updated if you called a specific update method

#

does the name change if you relog?

#

with the account whose name was changed

granite olive
#

I'm trying to have my plugin execute a /spreadplayers command with a specific set of players and if I have read the spigot source code of their extension of the vanilla command correctly then my implementation should work:

        String command = String.format(
                "spreadplayers %f %f %d %d %s",
                map.getWorld().getSpawnLocation().getX(),
                map.getWorld().getSpawnLocation().getZ(),
                map.rtpDistanceFromPlayers,
                map.rtpRadius,
                respectTeams ? "true" : "false"
        );

        for (Player player : players) {
            command += " " + player.getName();
        }

        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
    }```
It sadly does not work because I get the following error in the console when I try to run this with 2 (or more) players: `Incorrect argument for command ... player1 player2<--[HERE]` (where player1 and player2 are the names of whichever players I test it with), what am I doing wrong?
last abyss
#

nop

smoky oak
#

hm maybe google can help you but im out of ideas

smoky oak
#

mitght be a config problem, might be a problem in your command code

granite olive
#

but I wouldnt know how to specify another version

smoky oak
#

whats the exact error

cursive glen
#

does anyone know how to use componentbuilder or textcomponents to send multiple clickable messages to a player?

chrome beacon
granite olive
#

theres nothing more than the small snippet I sent above where it throws an error as soon as there is more than 1 player (like it would if it were the vanilla command)

obsidian fulcrum
#

heyyy soo i got an problem with my server world spawn when i use /setworldspawn it set my world spawn but if I spawn it on that pre-marked spot just back to the lobby
any ideas how to fix it?

obsidian fulcrum
#

:?

cursive glen
#

this is the snippet they provided

#
BaseComponent[] component =
    new ComponentBuilder("Hello ").color(ChatColor.RED)
        .append("world").color(ChatColor.DARK_RED).bold(true)
        .append("!").color(ChatColor.RED).create();
granite olive
smoky oak
#

no i thought it was an issue in the command code

chrome beacon
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

smoky oak
#

but if its spigot commands youre using its probably not

cursive glen
smoky oak
#

heres a really dumb idea that might work
call the SpreadPlayersCommand::execute method directly

cursive glen
#

I guess I'm just not doing it right bcs copying the snippet in works

granite olive
smoky oak
#

that just means unsupported

#

theres probs a comment for a new one

sterile breach
#

Hi, how i can do a confirmation gui? I use a callback ?

quaint mantle
#

Does async catcher catch player.inventory.addItem

alpine urchin
granite olive
smoky oak
#

SpreadPlayersCommand.execute(Bukkit.getConsoleSender(), "spreadplayers", array_of_arguments)

ocean hollow
#

why is the armorstand not removed after the server is turned off? it's not null, it just stays on shutdown

granite olive
#

It cannot resolve the symbol 'SpreadPlayersCommand' even when I have import org.bukkit.command.defaults.*;

smoky oak
#

yea im out of ideas

granite olive
#

no worries, thanks for the help though at least I know I'm not missing something obvious

chrome beacon
ocean hollow
#

does this event only work on shutdown?

carmine mica
#

Doesn’t exist anymore

granite olive
#

was it replaced with something newer?

#

any code I find was committed 2013 or so

carmine mica
#

No. The vanilla command exists on the server. You can’t access it’s logic with the API

#

If you wanna make your own command, just make your own

#

Doesn’t matter what else is on the server

flint coyote
#

I can't run that command ingame either. Unless I only specify one player argument

granite olive
#

hm okay I guess I'll do that then, thanks for the info

carmine mica
flint coyote
#

yes. He tried to do player1 player2 which is not an entity selector

granite olive
#

creating a custom entity selector is not possible, right? Because if I had a way to pass my list of players as that to the execution of the vanilla command it would be perfect

#

I guess I could tp all the players to the world first and then could do all the players in the world

flint coyote
#

You could add the same scoreboard objective to all of them and then use that as a selector

granite olive
#

oh good idea, they have a scoreboard set already anyway

quaint mantle
#

what would be the best way to randomly select a block inside of a chunk that is surrounded by blocks?

zealous osprey
#

Select a random block in the chunk, if it isn't surrounded, try again?

Or you could try to figure out a density distribution and then use some fancy probability math to select a block and then test if it's surrounded by blocks

quaint mantle
#

mm true

zealous osprey
#

but that won't work if the plugin can be used on maps with custom maps or such, cause you have to prepare the density map beforehand. or make one by selecting random chunks when the server loads

haughty pewter
#

is there a way to add all block types in all variants easyer? so i dont have write like that
STONE: [PICKAXE]
DIRT: [SHOVEL]
LOG: [AXE]
GRASS_BLOCK: [SHOVEL]

sharp kayak
#

Is there any way to cancel the advancement completed broadcast of a player?

smoky oak
haughty pewter
#

woud it be possible to make by id?

#

bcs there to much blocks to write down :D

smoky oak
#

Block:isPreferredTool(ItemStack tool)

#

gives u a boolean

shadow night
#

why are my effects not showing when I join the server? I have 3 infinite effects. Such as invisibility and saturation work, but jump boost does not. Removing those effects manually per /effect clear player effect removes them saying the effect is removed successfully. This is very confusing and breaks jump boost, why and how do I solve that?

smoky oak
#

effects can be applied invisible

#

it requires op or plugin access

shadow night
#

but jump boost does not work

#

the effect exists until I rejoin

smoky oak
#

ah you meant that

#

idk how rejoining interaccts with effects sorry

shadow night
#

even temporary effects don't appear

#

huh this is weird

#

this definitely shouldn't work like that

#

this seems to be due to some plugin I had in my plugins

#

and it is not the plugin I'm testing currently

#

no way

#

if that is it

#

okay it was not viaversion

#

and there are two plugins left that can just not possibly do it

#

bro what

#

how

#

skinsrestorer it was

#

this is what happens when your friends play cracked

smoky oak
#

theres a reason i be like 'no warranty except: this will work with my other plugins'

shadow night
#

I have just one question

#

how

#

how could SKINSRESTORER break EFFECTS

#

and this is what was stopping me from developing my plugin

#

SKINSRESTORE

#

lmao what

smoky oak
#

cracked servers show aled/steve skins by default

#

afaik skinrestorer messes with packets

#

so thats probably the issue

shadow night
#

packetry = packet fuckery

#

I bet packetry is like mixins in modding world

haughty pewter
chrome beacon
#

or?

haughty pewter
#

i want make a plugin that allows to break blocks whit specific tools

#

stone whit pickaxe dirt whit showel

smoky oak
#

oh thats simple

#

BlockBreakEvent

haughty pewter
#

yes for u its simple :)

smoky oak
#

no literally

#

that event has the block broken and the player that did it and iirc the tool too

#

just check that and drop the block if applicable

quaint mantle
#

Hi im using this for a kbffa plugin but if i hit someone off it works but if they then jump off after respawning it still counts as a kill, therfor an unlimited kill glitch

lilac dagger
#

reset it then

spare hazel
#

How can i execute commands as the server?

remote swallow
#

Bukkit.dispatchCommand(Bukkit.getConsoleCommandSender() iirc

lilac dagger
#

you beat me to it

small iron
#

How to set Command prefix? like:

  • /gm menu
  • /gm create ...

for something like /menusetting okay I can understand.

red otter
#

Hello, how i can create a ShapedRecipe and set the Amount of the Ingredient Item?

tender shard
#

if you wanna have recipes with different stack sizes, you have to listen to PrepareCraftItemEvent or however it's called, then set the result manually

#

but the recipe book will not properly work for that

red otter
#

okay and give it a other method to create a custom recipe

spare hazel
#
if(e.getBlock().getWorld() != HypixelCustomItems.getPlugin().getServer().getWorlds().get(0)){
            for(int x = 0; x < 3; x++){
                for(int y = 0; y < 3; y++){
                    for(int z = 0; z < 3; z++){
                        if(allowedBlocks.contains(e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(x+1, y+1, z+1)).getType())) {
                            e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(x + 1, y, z + 1)).setType(Material.AIR);
                        }
                    }
                }
            }
        }

this piece of code doesnt replace a 3x3x3 chunk of blocks. does anyone know the problem?

tender shard
#

you are comparing worlds using ==

#

you should be using equals

#

also why are you using such a complicated way to get the relative block

#

and you shouldnt use variable names such as "e"

spare hazel
#

lemme do those things

north nova
tender shard
#
if(event.getBlock().getWorld().equals(Bukkit.getWorlds().get(0)) {
  for(...) {
    for(...) {
      for(...) {
        Block relative = event.getBlock().getRelative(x+1, y+1, z+1);
        if(allowedBlocks.contains(relative.getType()) {
          relative.setType(Material.AIR);
        }
    }
tender shard
north nova
#

but why add xyz +1

tender shard
#

yeah the math is pretty bad

north nova
#

this seems completely unnecesary but who knows what he's trying to do

lilac dagger
#

Shouldn't it go from - radius to radius?

tender shard
#

usually you should also take the direction into account

lilac dagger
#

For a true 3x3 pickaxe?

north nova
#

yea

north nova
#

x = -1; x < 1; x++

#

if he would use it like hes using it

#

i think

spare hazel
#
@Override
    public void onBlockBreak(BlockBreakEvent e){
        Block block = e.getBlock();
        if(!block.getWorld().equals(HypixelCustomItems.getPlugin().getServer().getWorlds().get(0))){
            for(int x = 0; x < 3; x++){
                for(int y = 0; y < 3; y++){
                    for(int z = 0; z < 3; z++){
                        if(allowedBlocks.contains(block.getWorld().getBlockAt(block.getLocation().add(x+1, y+1, z+1)).getType())) {
                            block.getWorld().getBlockAt(block.getLocation().add(x - 1, y, z - 1)).setType(Material.AIR);
                        }
                    }
                }
            }
        }
    }

i believe this is better

tender shard
#

usually you do something like

offsetX = 0;
offsetZ = 0;
if(player is looking north) offsetX = 1;
else if(player is looking south) offsetX = -1;
else if(west) offsetZ = 1;
else if(north) offsetZ = -1;

x = blockX + offsetX;
z = blockX + offsetZ;
for(int x = -radius; x <= radius; x++)
small iron
spare hazel
#

im sure worldedit has a superpickaxe or something lemme check their source code

remote swallow
#

their superpick is just really fast

north nova
#

@spare hazel what is that code supposed to do?

remote swallow
#

they dont add a 3x3 pic

#

is it actually 3x3 or is it 3x1

spare hazel
north nova
#

wtf

remote swallow
#

go look at slimefuns explosive pic and modify it

spare hazel
#
package com.amirparsa.hypixelcustomitems.Items;

import com.amirparsa.hypixelcustomitems.CustomItem;
import com.amirparsa.hypixelcustomitems.HypixelCustomItems;
import com.amirparsa.hypixelcustomitems.Rarity;
import com.amirparsa.hypixelcustomitems.Stat;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockBreakEvent;

import java.util.ArrayList;

public class ChunkMiner extends CustomItem {

    private ArrayList<Material> allowedBlocks = new ArrayList<>();

    {
        setId("CHUNCK_MINER");
        setMaterial(Material.GOLDEN_SHOVEL);
        setName("Chunk Miner");
        setRarity(Rarity.RARE);
        setAdditionalLore("Breaks A 3x3 Area Of Blocks");

        addStat(Stat.SPEED, 100);

        allowedBlocks.add(Material.DIRT);
        allowedBlocks.add(Material.DIRT_PATH);
        allowedBlocks.add(Material.COARSE_DIRT);
        allowedBlocks.add(Material.GRASS_BLOCK);
        allowedBlocks.add(Material.PODZOL);
    }

    @Override
    public void onBlockBreak(BlockBreakEvent e){
        Block block = e.getBlock();
        if(!block.getWorld().equals(HypixelCustomItems.getPlugin().getServer().getWorlds().get(0))){
            for(int x = 0; x < 3; x++){
                for(int y = 0; y < 3; y++){
                    for(int z = 0; z < 3; z++){
                        if(allowedBlocks.contains(block.getWorld().getBlockAt(block.getLocation().add(x+1, y+1, z+1)).getType())) {
                            block.getWorld().getBlockAt(block.getLocation().add(x - 1, y, z - 1)).setType(Material.AIR);
                        }
                    }
                }
            }
        }
    }
}

remote swallow
#

and get how they do it

tender shard
#

why don't you just use a temp variable for the block in the loop

#

instead of doing this weird getBlockAt twice

north nova
#

i love when people haven't heard of dependency injection

#

isn't static abuse cool

remote swallow
#

there isnt even a need for a plugin instance either

north nova
#

Bukkit.getServer()

#

yea

remote swallow
#

you dont even need the getserver

tender shard
#

that code also doesn't take the player's looking direction into account, as I already said

remote swallow
#

getWorlds is a method on Bukkit

#

no

#

Bukkit.getWorlds

north nova
#

it doesn't need direction if it's just 3x3

spare hazel
#

ok

spare hazel
north nova
#

yeah

remote swallow
#
private List<Block> findBlocks(@Nonnull Block b) {
        List<Block> blocks = new ArrayList<>(26);

        for (int x = -1; x <= 1; x++) {
            for (int y = -1; y <= 1; y++) {
                for (int z = -1; z <= 1; z++) {
                    // We can skip the center block since that will break as usual
                    if (x == 0 && y == 0 && z == 0) {
                        continue;
                    }

                    blocks.add(b.getRelative(x, y, z));
                }
            }
        }

        return blocks;
    }
#

slimefuns code for this isnt too bad tbh

north nova
#
    void onBlockBreak(BlockBreakEvent event) {
        final Block block = event.getBlock();
        final World world = block.getWorld();
        if (world.getUID().equals(Bukkit.getWorlds().get(0).getUID())) {
            return;
        }

        final BlockData blockData = Bukkit.createBlockData(Material.AIR);
        
        for (int x = -1; x < 1; x++) {
            for (int y = -1; y < 1; y++) {
                for (int z = -1; z < 1; z++) {
                    Location offsetLocation = block.getLocation().add(x, y, z);
                    world.setBlockData(offsetLocation, blockData);
                }
            }
        }
    }``` here @spare hazel
#

lol

sleek wren
#

import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Random;

public class SpawnBreak extends JavaPlugin implements Listener {

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

@SuppressWarnings("unlikely-arg-type")
@EventHandler
public void onBreak(BlockBreakEvent event) {
    Block block = event.getBlock();
    if (block.getType() == Material.SPAWNER) {
        int GG = new Random().nextInt(100);
        if (GG >= 90) {
            block.breakNaturally();
        } else {
            event.setCancelled(true);
        }
    }
}

}

north nova
#

dont do that

remote swallow
#

why are you putting it in 1 class

#

that is just wrong

#

giving be huge chatgpt vibes tbh

north nova
#

use ThreadLocalRandom.current().nextInt(100) instead of new Random on every block break

#

no, you can't

#

because then the chance generated once will always be the same

#

huh?

remote swallow
#

doubt its the issue

#

but debug ur code

north nova
#

what even is the problem you're having with that code?

#

did you register the event...?

#

how?

remote swallow
#

why are you casting it

#

that shouldnt need to be ever casted

north nova
#

so man has a variable for plugin manager

spare hazel
remote swallow
#

iirc breakNaturally wont break bedrock

#

no, once again. DEBUG UR CODE

vast ledge
#

public class name implements Listener

#

Then why you cast (Listener)

remote swallow
#

debug ur code

#

so im gonna guess you dont know what it means, and dont want to ask. Add sysouts and see whats actually happening

north nova
#
    private ArrayList<Material> allowedBlocks = List.of(Material.DIRT, Material.DIRT_PATH, etcetc);

    {
        setId("CHUNCK_MINER");
        setMaterial(Material.GOLDEN_SHOVEL);
        setName("Chunk Miner");
        setRarity(Rarity.RARE);
        setAdditionalLore("Breaks A 3x3 Area Of Blocks");

        addStat(Stat.SPEED, 100);
    }

    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
        final Block block = event.getBlock();
        final World world = block.getWorld();
        if (world.getUID().equals(Bukkit.getWorlds().get(0).getUID())) {
            return;
        }

        final BlockData blockData = Bukkit.createBlockData(Material.AIR);
        
        for (int x = -1; x < 1; x++) {
            for (int y = -1; y < 1; y++) {
                for (int z = -1; z < 1; z++) {
                    Location offsetLocation = block.getLocation().add(x, y, z);
                    final Material material = offsetLocation.getBlock().getType();
                    if(!allowedMaterials.contains(material)) {
                      continue;
                    }
                    world.setBlockData(offsetLocation, blockData);
                }
            }
        }
    }

#

wtf is this code tho

#
        setId("CHUNCK_MINER");
        setMaterial(Material.GOLDEN_SHOVEL);
        setName("Chunk Miner");
        setRarity(Rarity.RARE);
        setAdditionalLore("Breaks A 3x3 Area Of Blocks");

        addStat(Stat.SPEED, 100);
    }
``` why are u doing this
remote swallow
#

just hurts

#

and for it to be a hypixel knock off

spare hazel
north nova
#

okay

#

but why are you doing that

remote swallow
#

that is the wrong way to handle that

north nova
#

why not have a constructor?

#

use lombok

remote swallow
#

most of that should be a super call in the constructor

north nova
#

have an abstract item class and have a builder(toBuilder = true)

#

and just use the builder

remote swallow
#

why have a builder

#

just call a super

north nova
#

cleaner

remote swallow
#

i mean, not really here

north nova
#

depends on his use and how "modular" this plugin is supposed to be

remote swallow
#

you should use builder if each item didnt get its own class

spare hazel
#

this works for me
and its readable

north nova
#
  • lombok is cool
north nova
#

the code u initially sent is bad

remote swallow
#

lombok is cool, just depends how you use it

north nova
#

bro lombok is amazing

remote swallow
#

if you use it correctly yeah

north nova
#

ah i can't send pictures

remote swallow
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

north nova
#

!verify

undone axleBOT
#

Usage: !verify <forums username>

north nova
#

oh fuck off

spare hazel
# north nova depends on his use and how "modular" this plugin is supposed to be

SPOILER: Its Not

if(rightClickAbility != null && rightClickAbilityDesc != null){
            lore.add("");
            lore.add(ChatColor.GOLD + "Item Ability: " + rightClickAbility + ChatColor.YELLOW + "" + ChatColor.BOLD + " RIGHT CLICK");
            lore.add(rightClickAbilityDesc);
        }

        if(blockBreakAbility != null && blockBreakAbilityDesc != null){
            lore.add("");
            lore.add(ChatColor.GOLD + "Item Ability: " + blockBreakAbility + ChatColor.YELLOW + "" + ChatColor.BOLD + " BREAK BLOCK");
            lore.add(blockBreakAbilityDesc);
        }
remote swallow
#

no spigot account?

#

smh

#

fuck me

north nova
#

i got one but the username is from the 15 year old version of me

north nova
#

what is this

#

😭

spare hazel
north nova
#

i wont question it

#

u do ur thing

#

lol

tender shard
north nova
#

!verify noobdog2013

undone axleBOT
#

A private message has been sent to your SpigotMC.org account for verification!

tender shard
remote swallow
tender shard
#

it's not like making it 3 blocks wide would make any difference

#

you just change one line

north nova
tender shard
#

instead of doing * offset you do * offset * radius

north nova
#

its actually rocket science

#

:\

spare hazel
remote swallow
#

its not my code

#

i just used stuff i had found online

north nova
#

add the Heavy Diamond Hoe and let us know 🗣️ 🗣️

icy beacon
#

"I will steal your code!!!"
"it's not even my code lol"

remote swallow
#

literally

icy beacon
#

every based programmer

north nova
#

if you think about it