#help-development

1 messages · Page 2070 of 1

tender shard
#

a right click with an enderpearl? you can detect that

viral crag
#

there are many ways, reliably only client side

tender shard
#

a right click with nothing in your hand? no you can't detect that

halcyon mica
#

Well

#

Back to NMS I guess

tender shard
#

Also the vanilla client doesn't send a packet on right clicking air without an item in their hand

timid parrot
#

not playerinteract entitydamagebyentityevent

halcyon mica
#

I simply don't believe that, let me doublecheck

timid parrot
#

@EventHandler

    public void onSnowballHit(EntityDamageByEntityEvent e) {
        if ((e.getDamager() instanceof Snowball))
            if ((e.getEntity() instanceof Player)) {
                double damage = 0.01;
                e.setDamage(damage);
                Projectile projectile = (Projectile) e.getEntity();

                Player attacked = (Player) e.getEntity();
                ProjectileSource ps = ((Snowball) e.getDamager()).getShooter();

                if (!(ps instanceof Player)) {
                    return;
                }

                Player shooter = (Player) ps;
                ArrayList<java.lang.String> lore = new ArrayList<>();
                lore.add("This balls can freeze a player");

                    if (projectile instanceof Snowball) {
                        if (shooter.getInventory().getItemInMainHand().getItemMeta().getLore().equals(lore)) {
                            attacked.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 20, true));
                            attacked.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, 100, true));

                        }
                    }

            }
    } this code doesnt work
tender shard
midnight shore
tender shard
#

this code doesnt work

viral crag
#

are snowballs entities?

tender shard
#

of course

#

they are projectiles

viral crag
#

interesting

tender shard
#

what else would they be? 😄

granite owl
#
public class SimpleCommandMap implements CommandMap {
    protected final Map<String, Command> knownCommands = new HashMap<String, Command>();
#

why cant i get the knownCommands field with reflection

tender shard
#

SimpleCommandMap.class.getDeclaredField("knownCommands")

viral crag
tender shard
#

no problem at all

eternal needle
granite owl
#

but

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.

granite owl
#
SimpleCommandMap commandMap = ((CraftServer) Bukkit.getServer()).getCommandMap();
        //commandMap.clearCommands();
        //commandMap.getCommand("op").unregister(commandMap);
        
        try {
            final Field f = commandMap.getClass().getDeclaredField("knownCommands");
            f.setAccessible(true);
            @SuppressWarnings("unchecked")
            Map<String, Command> cmds = (Map<String, Command>) f.get(commandMap);
            cmds.remove("op");
            f.set(commandMap, cmds);
        } catch (Exception e) {
            e.printStackTrace();
        }
#

[19:56:23] [Async Chat Thread - #3/WARN]: java.lang.NoSuchFieldException: knownCommands

tender shard
#

you used getClass() instead of class

#

getClass() probably returns a CraftCommandMap or similar

#

use the code I sent and it will work 100% fine

granite owl
#

hmm

tender shard
#

e.g.

#

Player.class -> Player

#

somePlayer.getClass() -> CraftPlayer

granite owl
#

but i want to get the field

#

from the instance

tender shard
#

I know

granite owl
#

so just

#

SimpleCommandMap.class

#

worked

#

why

tender shard
#
Field field = SimpleCommandMap.getDeclaredField("commandMap");
Map<String,Command> commands = field.get(Bukkit.getServer().getCommandMap());
granite owl
#

i really dont understand why it worked now

tender shard
#

you're new to reflection, right?

granite owl
#

yes

#

but like

#

i didnt pass an instance

#

only the class itself

tender shard
#

then it's a static field

granite owl
#

how can i access an instances member

tender shard
#

I will explain later, I have to go grocery shopping now

#

google difference between "getField" and "getDeclaredField"

#

it'll probably answer your question

granite owl
#

kk ty

#

well it works now

tender shard
#

I gotta go now, will be back in 30-40 mins

granite owl
#

so

#

finally time to work it out

#

and make it look good

#

teye 😄

torn shuttle
#

quick q, there's no way through the api to get a full list of blocks in radius for an explosion event right? only the ones that blew up?

viral crag
#

not really, that's more coreprotect/prism stuff

#

you would need to know what was there before the explosion and deal with moving materials

torn shuttle
#

argh give me a break

#

does minecraft actually raycast explosion damage?

#

what a weird way of doing things

#

why not just do a volume?

ancient plank
#

minecraft explosions are weird in general

torn shuttle
#

oh

#

because stuff behind protected areas doesn't blow up huh

ancient plank
#

after a certain set size the only thing that increases in an explosion is the length of the shockwaves

torn shuttle
#

ok so to reimplement explosions I'd have to listen to the explosion, cancel it, raycast my own explosion vectors, come up with my own math for block resistance and then ship that in my own explosion event huh

ancient plank
#

mhm

torn shuttle
#

and I guess also my own math for attenuation

crisp steeple
#

isn’t there just an event though for when a block gets exploded?

torn shuttle
#

the raycasting part sounds exceptionally inefficient

ancient plank
#

painfully annoyed that after like 64 explosion size it just does this

torn shuttle
#

yeah

#

I know

#

how about I just invent my own new method called volumetric stepping

#

I just go through all the adjacent blocks and kill progression when it would no longer explode

#

each block carries its own vector, and the explosion propagates to the direction pointed towards; that should work

ancient plank
#

math

hasty prawn
#

that's a lot of large words

torn shuttle
#

I mean really this is basically how real explosions work, I'm basically describing a wave

viral crag
#

water and lava wouldnt really move

#

and falling materials shift place

torn shuttle
#

water an lava just need increased attenuation values

#

I don't really care about falling blocks here tbh

#

this is for the context of explosions in boss fights

#

I'm not modifying tnt or anything like that

ancient plank
#

I suck at math so I spent like 2 hours searching for a formula and then a java implementation of a formula for my nether corruption plugin

#

to make it prefer points closer to the center when the diameter is big

hasty prawn
#

Searching for formulas is the worst

viral crag
#

thats what matlab or maple are for

hasty prawn
#

You end up with a Wikipedia page written by 18 different rocket scientists or something and none of it makes any sense

#

There's more Greek letters than English ones

ancient plank
#

I kept ending up with 2d implementations and trying to make it work in a 3d implementation and failing and going back to google

#

was really difficult to get weighted points that prefer being closer to the center of a sphere

mint mesa
#

how can I make a quartz slab in 1.8?

crisp steeple
#

setData()?

mint mesa
#

I cant seem to find the data online tho

#

plus it seems to be deprecated anyway

crisp steeple
#

it’s just the damage value

#

well yeah

#

i think the non deprecated one is with getBlockState and then setdata

mint mesa
#

is there anyway to see which data value the quartz slab is?

#

also how do I change the slab from the top half to the bottom half of a block?

#

havent seen that anywhere either

crisp steeple
#

pretty sure it’s in getblockstate as well

crisp steeple
timid parrot
#

the item just doesnt work

crisp steeple
#

the damage value is on the item

crisp steeple
#

pretty sure the .equals() method on lists compares the reference

tender shard
tender shard
crisp steeple
#

maybe not then

#

still a bad idea though and possibly the reason

tender shard
#

I've used assertEquals in my PDC library a shit ton of times during testing

#

at least hashmaps, hashsets, arraylists, linkedlists etc all compare the contents

crisp steeple
#

yeah not that but just in general

#

if you make a typo or something just by one space it won’t work

tender shard
#

identifying items by its lore is a shitty idea, I agree

#

for that, PDC should ALWAYS be used

mint mesa
#

now its just in the wrong area

ancient plank
#

1.8 moment

mint mesa
#

indeed

ancient plank
#

doing block rotations on 1.16.5 isn't fun, can't imagine doing it in 1.8

granite owl
#

i wonder

#

if i register a custom plugin command /op

#

do i override the vanilla in the knownCommands map?

crisp steeple
mint mesa
#

I gotta do this for all 26 letters of the alphabet too

tender shard
crisp steeple
#

1.8 block data is really annoying

granite owl
#

@tender shard is this the correct way to apply it on start? xD

tender shard
#

everything below 1.13 is bullshit 😄

mint mesa
#

the exact same code...

#

different type

tender shard
#

for everything

granite owl
#
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { Ranks.disableVanillaOp(); } });
ancient plank
#

if you make a custom /op it'll do "pluginname:op" and "minecraft:op"

granite owl
#

hm

mint mesa
#

nvm it isnt the same :)

real palm
granite owl
#

im as far as to remove the vanilla commands from the knownCommands map

#

but i also need to create my custom implementation

exotic jetty
#

i dont know if anny of you ever played skyblock but i wanna make it so there is a sing where you can write something on and it will get turend into a string. how would i do this?

ancient plank
#

sign

crisp steeple
#

sign

exotic jetty
#

lol sorry

crisp steeple
#

there’s an event for it pretty sure

#

either that or with packets

tender shard
#

SignChangeEvent exists

#

but you can also send the "sign gui" to a palyer

#

using API

crisp steeple
#

yeah that method works for making sign input

exotic jetty
#

thanks

crisp steeple
#

the only thing is that you have to get the response with packets

#

and there’s a lot of bugs with it

tender shard
#

won't it call a SignChangeEvent?

#

I'll try it quickly

crisp steeple
#

so it would be a client sided sign

tender shard
#

true but you could just create one at an arbitrary place

granite owl
#

xD

crisp steeple
#

yeah that’s what some people do

#

but then there’s bugs with that like block deletion

#

and the fact anyone could just come along that sign and change it

exotic jetty
#

so what line of code would i use to open a sign

crisp steeple
tender shard
# granite owl its still difficult

the main idea is this:
getDeclaredField returns any field from exactly that class. if you call it on Player, you can get ALL private, etc fields that are declared in Player. However, in 99% of cases you have a CraftPlayer and not a player

exotic jetty
#

so i want people to give a name for the a shop by clicking a sign in gui

granite owl
#

hm

tender shard
#

imagine this:

A.class has a private field "something" and a public field "publicSomething"
B.class extends A.class and has a private field "someThingElse"

You can get the public "publicSomething" from both class A and B using getField
But you can only get either "something" using getDeclaredField on class A, or get field "somethingElse" usig getDeclaredField on class B

granite owl
#

xD

tender shard
#

so basically: getField returns an ACCESSIBLE field no matter if it's from exactly this class or a super class.
getDeclaredField returns ANY field but it has to be defined directly in this class

granite owl
#

hmm

tender shard
#

so if you wanna access private fields, always use SomeClass.class instead of someObjectThatYouThinkBelongsToClass.getClass()

granite owl
#

kk

tender shard
#

because the object might as well belong to a subclass

crisp steeple
granite owl
#

right

#

so

graceful oak
#

When saving data like a currency to files is it better to save to a yml file or should I make a json formatted file? Really looking for the most efficient and commonly used way that it is done.

granite owl
#

Field cmdsField = SimpleCommandMap.class.getDeclaredField("knownCommands"); get the field of that class

granite owl
#

(Map<String, Command>) cmdsField.get(commandMap); ```txt
get the specified class of the target instance

crisp steeple
crisp steeple
#

it’s your choice really on whichever you find better

graceful oak
#

alright thanks

tender shard
#

yaml and json is pretty much the same

exotic jetty
granite owl
tender shard
#

yaml is more readable so if you want admins to be able to edit it, use yaml, otherwise use json

#

but for currency stuff I'd much rather use a DB

#

since it probably changes very often

crisp steeple
granite owl
#

well this is how far i am ```java
public static void disableVanillaOp()
{
try
{
Field mapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
mapField.setAccessible(true);
SimpleCommandMap commandMap = (SimpleCommandMap) mapField.get(Bukkit.getServer());

        Field cmdsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
        cmdsField.setAccessible(true);
        @SuppressWarnings("unchecked")
        Map<String, Command> cmds = (Map<String, Command>) cmdsField.get(commandMap);
        
        cmds.remove("minecraft:op");
        //cmds.remove("op");
        cmds.remove("minecraft:deop");
        //cmds.remove("deop");
        cmdsField.set(commandMap, cmds);
        
        mapField.setAccessible(false);
        mapField.setAccessible(false);
    } 
    catch (Exception e) 
    {
        e.printStackTrace();
    }
}
crisp steeple
#

a way to create the sign could just be sendBlockChange and then use the openSign method

tender shard
granite owl
#

and ik its still buggy

crisp steeple
#

i would probably recommend searching a tutorial on how to read incoming packets

tender shard
#

I just found out that I use the commandmap myself in my lib

granite owl
#

i thought its prob a good idea to restore the protection

tender shard
#

I totally forgot about that

granite owl
#

xD

graceful oak
# tender shard but for currency stuff I'd much rather use a DB

The way im doing it right now is that when server starts the amount that have goes into a hash map then when server stops it gets saved to file with a DB would I be able to just live update from player to DB and call from it instead of doing the hash map? or is it sill a good idea to use the hash map?

tender shard
tender shard
#

they'll be upset then

exotic jetty
granite owl
crisp steeple
#

sendBlockChange is client side

granite owl
#

cause u can cause a memory violation otherwise

exotic jetty
crisp steeple
exotic jetty
#

yes

crisp steeple
#

i’ve seen a few on youtube

graceful oak
#

Now would calling directly from a DB be slow or would it be more efficient than loading the map every time

crisp steeple
#

in terms of efficiency probably the map

#

but you should probably save it to db every few minutes or so so players don’t lose all their progress if the server dies

graceful oak
#

yeah thats what I figured thanks for the help!

sage merlin
#

for some reason the first if statement fails when i try to click the item again. So when i click a item twice it disappears and then the first if statement is never true therefore i can't choose the item

tender shard
#

in case anyone wants to crash the JVM, here you go

tender shard
quasi patrol
#
        if (AmogusSkinner.list.contains(event.getEntity())) {
            Player player = event.getEntity();;
            event.setDeathMessage("");
            event.setKeepInventory(true);
            AmogusSkinner.list.remove(player);
            player.spigot().respawn();
        }
    }``` it still drops their items but keeps their inventory, so basically duping. Also it isn't respawning them.
sage merlin
granite owl
#

the commands

#
cmds.replace("minecraft:op", new OpCommand("op"));
            cmds.replace("op", new OpCommand("op"));
            cmds.replace("minecraft:deop", new VersionCommand("version"));
            cmds.replace("deop", new VersionCommand("version"));
            cmdsField.set(commandMap, cmds);
#

and then ive created a new vanilla command inheriting BukkitCommand like the /reload command does

#

and hooked it to the op command

#

wont work for autocompletion of other commands but suffices to re-route the execution of that command completly

crisp steeple
#

not a great solution though

#

you would be better off just checking entitydamageevent check if the applied damage is less than 0, then teleporting them

#

would also fix the inventory dupe problem

tender shard
granite owl
#

so @tender shard after a long road ive managed to override the /op command xD

#

ive replaced the BukkitCommand with custom written ones instead of deleting the key

#

and used the ReloadCommand class as temple

#

also ty for your patience xD

#

despite me nagging xD

tender shard
#

np lol

kindred valley
#

WHAT IS ? ON JAVA

crisp steeple
#

Either a generic wildcard or used in ternary operator

kindred valley
crisp steeple
#

i don’t think that’s a word

kindred valley
crisp steeple
#

google dot com > java generics

kindred valley
#

i have never seen this before

#

i mean i saw but never worked on it

tender shard
#

String asd = true ? "asd" : "not-asd";

#

asd is "asd" now

#

if true would be false, then asd would be "not-asd"

#

it's basically the short form of

String asd;
if(true) asd = "asd";
else asd = "not-asd";
normal isle
#

i am new to tis

#

this

#

i have 0 experience

viral crag
#

...

tardy flame
#

Imagine

#

Why would you even need it?

#

Like-

#

Eh

#

Too complicated

#

And food lage

#

Too late

tender shard
#

to save what player e.g. owns an entity

tardy flame
#

Just save owner's uuid

tender shard
#

Player owner = entity.getPersistentDataContainer(key, DataType.PLAYER);

tardy flame
#

And retrieve player from it

#

._.

tender shard
left swift
#

Heyo! How can I deploy my plugin to vps after building using intellij?

somber hull
#

Could you not do that originally 😳

tender shard
somber hull
#

Oh

tender shard
#

of course a player implements PersistentDataHolder

somber hull
#

I thought you meant

tender shard
#

no that's not what I meant 🙂

somber hull
#

Like storing data into a player

tender shard
#

of course that is builtin 😄

somber hull
#

Lol

tardy flame
somber hull
#

Yea why don’t you just save the players uuid

#

And then grab a player via uuid when needed

tender shard
viral crag
#

offlineplayer always exists even if they dont

tender shard
tardy flame
tender shard
tardy flame
#

If a player is offline, how can it be saved..

tender shard
#

then you can retrieve it when the player is offline

fleet bone
#

hi does anyone know how to make ur own custom ip for free using spigot

tender shard
#

also player was just an example, I know it's not very useful to store a player in a PDC

tardy flame
#

Yeah

tender shard
#

but what about stuff like... string arrays? itemstacks? HashMap<Integer,ItemStack>?

tardy flame
#

It has more sense

#

Also wouldn't storing a player make a memory leak?

tender shard
#

I just used player as example because I was told to "pdc myself" 😄

tardy flame
#

Object storing itself?

tender shard
#

it only stores what bukkit serializes it to

tardy flame
#

Hmm

#

Okay

tender shard
#

(which is basically only the name lmao)

#

but it still allows you to get a player object

#

even when the player is not online

tardy flame
#

Idk ask this pdc guy

tender shard
viral crag
#

do you know if your keyboard is dvorak or asdf?

tender shard
#

you basically just have to do

myEntity.getPersistentDataContainer().set(someKey, DataType.ITEM_STACK, theItemStackYouWantToStore);
#

to store an itemstack inside an entity

#

that's all you need to store it

normal isle
#

wait this is a only 1 line of code?

tender shard
#

no

#

well

#

yes

#

to store an itemstack, yes

#

to achieve everything you want to do, obviously no

#

your whole plugin would likely be about 20-30 lines of code in total

#

unless you wanna serialize the itemstack yourself

#

then it'd be about 50-60 lines

normal isle
#

ok

#

what are the basics liens i need to know

tardy flame
#

Read java docs

#

uWu

ivory sleet
tender shard
#

?learnjava

undone axleBOT
normal isle
#

ok

tender shard
#

it simply stores the name lmao

normal isle
#

if i need a little help with the code can you help me?

ivory sleet
#

I wasnt talking about yours tho

tender shard
#

I'm just confused as to how bukkit can create a player object by just the name if they are not online

tardy flame
#

I didn't ping you mate

#

Go away

ivory sleet
#

No need to be rude here

viral crag
tender shard
tardy flame
#

Ahhhh

tender shard
#

Player, no

tardy flame
#

So rude

#

😩

#

Players are saved locally in one of world files

viral crag
tardy flame
#

That's why you can get them

tender shard
ivory sleet
# tardy flame So rude

Literally, if you don't care about what someone says just ignore it, don't be a douche prompting them with meaningless messages

tardy flame
#

Why would you need a player object if they are offline

#

That's a real problem tho

ivory sleet
#

You're not saving the player object

#

you're just saving data from it

viral crag
#

I imagine Mojang (or MS) has something in mind similar to Discord's (note that Conclure is not online)

tender shard
#

their location...

#

the list is long

tardy flame
#

Eh

#

I mean

ivory sleet
tardy flame
#

You could do everything that In a queue whenever this player joins

tender shard
tardy flame
#

Then you would have to just store what you need

tender shard
tardy flame
#

I think we are just creating problems from not existential problem

tardy flame
tender shard
#

but about serializing the player

tardy flame
#

Hi 2 hex

viral crag
#

has an idea for 2Hex a Serializing Killer :P

tardy flame
#

D:

grim ice
#

hi

grim ice
#

wats dat

viral crag
#

I am going to go with erasing mfnalex's player serialization

ivory sleet
#

myeah, mfnalex I can see it being most useful if you wanna sync blobs of player data between different nodes, then your pdc type pretty much cut out all the work for it

tender shard
ivory sleet
#

it does

tender shard
#

I only included it because Player implements ConfigurationSerializable

ivory sleet
#

of course depends on to what extent

tender shard
#

I have never tried whether it actually returns anything useful 😄

patent relic
#
public static void setup(){
        file = new File(Bukkit.getServer().getPluginManager().getPlugin("CoordinatePlugin").getDataFolder(),"coords.yml");```
ivory sleet
#

but lets say you want to sync the player between two faction servers

patent relic
#

why am i getting Method invocation 'getDataFolder' may produce 'NullPointerException'

tender shard
#

I just haven't ever tried if it actually works

ivory sleet
#

now idk exactly how precise Player::serialize is

#

like what data is included

sage merlin
ivory sleet
#

but theres potential to say the very least

tender shard
ivory sleet
#

oh

ivory sleet
#

thats tragic

tender shard
#

I'll have to try it tomorrow

patent relic
tender shard
#

maybe it does return a proper player object

#

I am not sure

ivory sleet
#

yeye keep me informed

tender shard
chrome beacon
tender shard
ivory sleet
#

🙏

patent relic
#
if(Bukkit.getServer().getPluginManager().getPlugin("CoordinatePlugin") != null){
            file = new File(Bukkit.getServer().getPluginManager().getPlugin("CoordinatePlugin").getDataFolder(),"coords.yml");
        }```
#

the error still shows inside the if statement

chrome beacon
#

It doesn't know that it won't be null the second time you call the method

patent relic
#

i was trying to follow a tutorial on custom files, and he didnt get the error that i got

chrome beacon
#

It's not an error it's a warning

#

You can ignore it if you want

#

Eitherway I recommend learning some Java basics before starting with Spigot development

#

?learnjava

undone axleBOT
patent relic
#

im just confused on saving/reloading data for spigot

#

i already have my plugin finished

young fractal
#

?help

undone axleBOT
#
CafeBabe Help Menu
*Red V3*
**__Admin:__**

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

names Show previous names and nicknames of a member.
userinfo Show information about a member.

**__ModLog:__**

listcases List cases for the specified member.
reason Specify a reason for a modlog case.

**__Permissions:__**

permissions Command permission management tools.

young fractal
#

?learn

hushed spindle
#

small question about EntityShootBowEvent

if (event.shouldConsumeItem()){ 
    double saveChance = 0.5;
    if (Utils.getRandom().nextDouble() < saveChance) {
        event.setConsumeItem(false);
        arrow.setPickupStatus(AbstractArrow.PickupStatus.CREATIVE_ONLY);
    }
 }

When shooting the arrow the item gets consumed, but the arrow also becomes not possible to pick up. no other event.setConsumeItem() occurs anywhere after in my code so the change is not being un-done, how does this work?

viral crag
#

not aware that you can pick up non-dropped arrows

hushed spindle
#

yeah you can pick arrows up when shooting them with a non-infinity bow

viral crag
#

that must be specific to java then

hushed spindle
#

this isnt a bedrock feature?

tall dragon
viral crag
#

not that ive ever had happen

#

they hit target/block and despawn

hushed spindle
#

anyway, strangely this only occurs when shooting with a normal bow, im implementing custom arrows and i made it so these arrows will still be consumed when shot by an infinity bow. this works, and the isConsumed property is now true and it still passes the if check in this code block, but now arrows shot from a normal bow aren't able to be picked up while also being consumed

viral crag
#
Previously shot arrows
Arrows shot by players can generally be picked up.

Arrows cannot be picked up if:

It is shot by a creative mode player.
It is shot by any mob able to shoot arrows, such as skeletons, strays, pillagers, or piglins. This includes mobs that do not shoot arrows in normal gameplay, such as illusioners and bow-wielding wither skeletons.
It is shot with an Infinity-enchanted bow.
It is one of the two extra arrows shot with a Multishot-enchanted crossbow.
hushed spindle
#

its not the pickup status im worried about, i just want these arrows to not be consumed when the random check passes

left swift
#

Heyo! How can I deploy my plugin to vps after building using intellij?

left swift
#

I mean automatically. I want to test my plugins on my hosted server

viral crag
#

write a script to upload it - alternatively you could use the debug setup

hushed spindle
#

i dont think im being clear enough.
i have custom arrows that use the Material.ARROW type, and i want them to be consumed by infinity and also be pick-uppable. This works

i also have a "chance to not spend an arrow when shooting" stat that overrides this, where the arrow becomes not pick-uppable and the item is not consumed

for infinity bows this works fine, saved arrows aren't consumed and spent arrows are, saved arrows become impossible to pick up while with spent arrows this is still possible
for normal bows saved arrows are still consumed while also impossible to pick up, spent arrows are still able to be picked up

vocal cloud
#

Show code lol

hushed spindle
#
AbstractArrow arrow = (AbstractArrow) event.getProjectile();
if (arrow is custom){
    event.setConsumeItem(true);
    arrow.setDamage(custom damage);
}

if (event.shouldConsumeItem()){
    double saveChance = arbitary chance to save ammo;
    if (Utils.getRandom().nextDouble() < saveChance) {
        event.setConsumeItem(false);
        arrow.setPickupStatus(AbstractArrow.PickupStatus.CREATIVE_ONLY);
    }
}
#

i mean its moreso confusing that the pickup status is updated but the consume item status seemingly isn't

#

because i cant pick up the arrow but it's still being consumed

viral crag
#

how can you consume or unconsume an arrow after you have already initiated using it?

hushed spindle
#

what do you mean?

#

this is within an event listener

viral crag
#

you said you were using the shoot bow event

hushed spindle
#

yeah

viral crag
#

the arrow has already been allocated and assigned

hushed spindle
#

events happen before the actual thing happens in game and changing the properties of the event changes the outcome of what happens in the game

viral crag
#

no

#

events happen durring their event name

hushed spindle
#

how would that explain what im experiencing though

#

i have 4 test cases, no infinity normal arrows, infinity normal arrows, no infinity custom arrows, and infinity custom arrows

#

all except infinity custom arrows are working

#

oh dude

#

what the fuck lmao

#

its a visual glitch

#

the arrows arent being consumed they just look like they are

viral crag
#

the client is confused

hushed spindle
#

when i click the item in my inventory it gets updated to its intended amount

viral crag
#

I should really finish my bow code i guess, however I use the projectile event

noble lantern
hushed spindle
#

im not editing any items, just letting the vanilla game/spigot handle item consumption

#

but im not

#

is updateInventory() an expensive method or is it allright to call on an EntityShootBowEvent

noble lantern
#

It shouldnt be an issue IMO iirc its just a client sided update

#

basically the server tells client to refresh inventory

#

just make sure the entity == Player that way you not calling it on skeletons per say

hushed spindle
#

mhm already asserted that

noble lantern
#

Sounds good, try calling updateInventory and see if that fixes the visual bug

hushed spindle
#

thanks for the help fellas, good to keep in mind that it'll only appear your code is broken

noble lantern
#

I didnt read the whole issue, but i figured that could possibly be the issue here :p

hushed spindle
#

do you reckon this could be a bug worth reporting to spigot because it feels like a minecraft issue

noble lantern
#

I do not beileve do, especially if updateInventory fixes it

onyx fjord
#

I would blame mojang if so

noble lantern
#

^

hushed spindle
#

figured as much

onyx fjord
#

Search on Jira maybe it's known

hushed spindle
#

updateInventory() did work

#

looks good now

noble lantern
#

awesome, its just likely due to how MC handles the clients updating inventories

onyx fjord
#

Visual bugs with Inventory are so fucking common

noble lantern
#

just had one last night myself lmao

#

was rather annoying

onyx fjord
#

Yk what's funny, team of 5 people can fix 40 Minecraft bugs in a week

#

In spare time

hushed spindle
#

i feel like thats because companies force their programmers to work a specific way thats very very slow but more healthy for the program

onyx fjord
#

Healthy?

#

It's a mess

hushed spindle
#

yeah idfk man

#

maybe they lazy

#

maybe they set their priorities wrong

noble lantern
#

i bet MC's source code is a total hell hole

hushed spindle
#

oh it is

onyx fjord
#

I believe in competence of programmers, if someone fails it's usually supervisors

#

Programmer only does what he is told

onyx fjord
hushed spindle
#

its like they wrote it in moon runes

onyx fjord
#

You will find stuff like minimum loading time of 2 seconds hard coded

noble lantern
#

oh god

onyx fjord
#

Even NASA pc must wait 2 seconds, no exceptions

noble lantern
#

Thread.sleep(2);

#

ez

onyx fjord
#

Also changing language reloads all textures I believe

#

;)

hushed spindle
#

fantastic

#

but yeah they may be setting their priorities wrong or focussing too much on content rather than the overall health of the game

noble lantern
#

havent tried that one yet

hushed spindle
#

but they cant change too much because spaghetti garbage

noble lantern
onyx fjord
crisp steeple
#

can’t forget all of ghost items/blocks

noble lantern
#

cancelling blocks burning in lava

hushed spindle
#

i mean it makes sense, java edition doesnt make them their bank

#

but still bedrock is somehow littered with bugs

noble lantern
hushed spindle
#

honestly not even worth using bedrock edition

noble lantern
#

thats been a bug ever since MC was created

hushed spindle
#

is realms that profitable?

#

hiring a server is so much cheaper and more flexible

#

cant do shit with realms

noble lantern
#

PrEDownLOaDeD MaPs

#

oH YeAh

crisp steeple
hushed spindle
#

fair enough

noble lantern
#

realms server customizability is aids

hushed spindle
#

good for kids i guess

noble lantern
#

no spigot allowed

crisp steeple
#

there’s a few fun realm maps but that’s it

noble lantern
#

^ was just typing that

#

But if you wanna customize even just basic server properties good luck

#

gamerules sure but any configs or whatnots goodluck

hushed spindle
#

yea nothing

#

can you even add datapacks to realms

crisp steeple
#

also realms just don’t work half the time

#

my friend bought one and tried to invite me and it just

#

didn’t show up for me

noble lantern
#

im prolly wrong though

hushed spindle
#

id hope so

noble lantern
#

yessir

hushed spindle
#

datapacks is like the one form of "modding" acknowledged by mojang, would hope you could add datapacks

mint mesa
#

looked around on the spigot docs, there doesn't seem to be any way to put a slab on the lower half rather than the upper half, or vice versa, is there?

crisp steeple
#

i have no clue why people create data packs they’re so annoying to make

mint mesa
#

i asked here earlier, and told its in the getState, but couldnt find a way to change it

noble lantern
hushed spindle
#

Block#setBlockState

#

?

#

man if you've seen terralith or nullscape its so insanely good

mint mesa
mint mesa
#

trying to make an A

noble lantern
#

check if state == that

mint mesa
#

the stairs are fine

noble lantern
#

TOP and BOTTOM are options with Slab#setType(thatDocAbove)

mint mesa
noble lantern
#

you need to cast getState to a Slab with a isntanceof check

mint mesa
#

huh

noble lantern
#

and then use the Slab instance you have and setType to Slab.Type.TOP

#

sec

#

ill write a example

#

if (b.getState() instanceof Slab) {
    final Slab slab = ((Slab) b.getState);
    slab.setType(Slab.Type.TOP);
}
mint mesa
#

i got a lot more letters to go after this :(

noble lantern
#

No, the state

#

BlockData isnt useful here

noble lantern
mint mesa
#

I did

#

thank you

noble lantern
#

Because its something that isnt changed, its just my style of code

#

if you wanted to

#

you could do this:

crisp steeple
noble lantern
#
if (b.getState() instanceof Slab slab) {
    slab.setType(Slab.Type.TOP);
}
#

but thats only for JDK 16 iirc

grim ice
noble lantern
#

ah 14

mint mesa
#

ah shit

#

Im using java 8

noble lantern
#

thats only for my second example

mint mesa
#

setType doesnt exist as well

#

:p

noble lantern
#

first example can be used for 8

#

can you show your code?

mint mesa
noble lantern
#

or Stairs

#

not Step

mint mesa
#

Slab doesnt exist

#

Step is slab

noble lantern
#

and you dont set Material

#

^

mint mesa
#

yea..

noble lantern
#

NMS/Reflection it is

mint mesa
#

ah

#

fun fun fun

crisp steeple
#

i am pretty sure setData will work…

noble lantern
#

yeah for this youll need to use Data

crisp steeple
#

plugins in 1.8 are pain

mint mesa
crisp steeple
#

no pdc

crisp steeple
mint mesa
crisp steeple
#

pretty sure you can just f3 and look at it

noble lantern
#

its aids ever done Anvils on that version

#

it gives me nightmares

mint mesa
noble lantern
#

i cant remember

mint mesa
#

it doesnt

noble lantern
#

you can use the /data command and fire out the byte value from there

#

oof

#

sec imma google this

#

not much i could find

mint mesa
#

hmm

#

how can I set it to 7:10

#

I dont think that works :p

crisp steeple
#

honestly just mess around with the byte value close to the one on the item until it works

noble lantern
#

^

crisp steeple
#

should only be -2 or +2 away

mint mesa
#

ah!

#

I have found it

noble lantern
mint mesa
#

Step mystep = (Step) bs2.getData();

#

mystep.setInverted(true);

noble lantern
#

1.8 api be like

mint mesa
#

fr

#

quick "upper slab" search on spigot forums

#

and simple fix

#

now lucky me can go onto "B"

hushed spindle
# grim ice arent they just command blocks but worse

depends, with datapacks you can directly alter the world generation or loot table json files already present. This doesnt actively run anything so in this aspect I think datapacks are more efficient than plugins typically are, but when it comes to adding new content to the game datapacks essentially boil down to command scripts that constantly run so they're just similar to those "single command block creations" that were hip a while ago condensed to a datapack rather than a world structure

noble lantern
#

My turn:

So this is rather a tricky question but I want to know if this is possible with packets/reflection/NMS

Say you have a Custom enchantment that will extend/implement the Enchantment class and register the enchant via reflection to the Enchantment map, and you want to apply this enchantment to a EnchantTable to be able to apply this enchantment in a "vanilla feel"

I've done my fair share of research, and notice that the client handles previewing enchantments differently on the enchantment table as well as applying this said enchantment

Now for applying the actual enchantment, this is rather easy as we can just cancel the event and apply our own result item

My main issue will just be having the enchantment show its name on the enchantment table

TLDR: Can you change enchantment names previews in the enchantment tables (The 3 enchantments on the side) with your own Enchantment class extending the vanilla Enchantment class

hushed spindle
#

you cant

#

because enchantment names are something that are translated by the client to whatever language the client has selected

#

you cant make custom enchantments exactly like how vanilla ones work, you can only get quite close to it

#

i made a plugin like that, it needs some maintenance but it still works

mint mesa
#

May I introduce... A

hushed spindle
#

its called enchantssquared if you're interested in looking

noble lantern
hushed spindle
#

getName() doesnt actually return the name visible on the item

#

its basically just an internal tag

noble lantern
hushed spindle
#

also wasnt getname deprecated because the enchantments are now keyed

#

no that also isnt possible

#

i think i put the github in the page itself rather than on the top

noble lantern
#

ah yes found it

#

If im unable to set the names for previews though then its likely ill just create my own GUI

hasty prawn
#

I have an enchantment API that can add enchantments in the table.

hushed spindle
#

i really dont think thats possible lol

hasty prawn
#

They'll never be displayed, but they can be added as secondary enchantments.

noble lantern
#

ahh dang

hasty prawn
#

You can't display them without a resource pack afaik

hushed spindle
#

yeah thats exactly what they want

hasty prawn
#

Maybe not even with that.

noble lantern
#

Yeah i know how to do everything else, its just getting them to display in enchantment tables

#

Alrighty so then creating a custom GUI would be best way of handling this then i presume

hasty prawn
#

Probably yeah

noble lantern
#

big sadness

#

Thanks guys 🙂

hushed spindle
#

having to make a custom gui for it sucks because then it doesnt feel like vanilla any more

#

its pain

noble lantern
#

Yeah thats why i didnt want to make a custom gui for it, it really sucks minecraft is so limiting in the stupidest of ways lmao

#

Anvils are a similar way, with handling things on the client side lmao

hasty prawn
#

I mean it makes sense tbh

#

Because of languages

hushed spindle
#

anvils fucking suck to work with

noble lantern
#

Yeah indeed it does make sense, just wish there was a way to simply "override" these

noble lantern
hushed spindle
#

why must a PrepareAnvilEvent fire several times depending on which item slot was clicked

#

why

noble lantern
#

Anytime someone tells me they have a bug with anvils, or I have to create something for anvils i just know imma be working on it all day

hushed spindle
#

and for some reason each of those events is different so one event overrides the other

noble lantern
#

dont forget it being called randomly for no reason even though you didnt do anything

or when typing in the bar it also fires the event

#

spamming events goes brrrrt

hushed spindle
#

you know what funny also

#

my anvil shit would bug the fuck out if you clicked an anvil slot in a specific way

#

like on the corner of a slot and it just wouldnt work

#

and if you wanna try to get your custom anvil stuff to cost exp good luck with that because its only gonna work half the time

#

why? Only god knows why

#

im getting regular bug reports from my users saying stuff gone wrong with the anvil and im just like not again

noble lantern
#

i had someone yesterday come with a bug for anvils as they were using geyser/floodgate

#

luckily

#

geyser/floodgate anvils are already bugged on theyre end

#

so I didnt have to do anything for that bop

#

working with anvils on 1.8 is even more aids as they dont have PrepareAnvilEvent

hushed spindle
#

amazing

#

i actually gotta make a gui specifically so bugrock people can even combine enchantments

#

awesooome

west oxide
#

hey so am geting this error
Caused by: java.lang.NullPointerException: Cannot invoke "online.shakiz.kprac.arenaManager.ArenaManager.worldIsUed(org.bukkit.World)" because "this.arenaManager" is null

this is where the error is :


        onGoingSetups = new LinkedHashMap<>();

        arenaManager = plugin.getArenaManager();

        Bukkit.getServer().getPluginManager().registerEvents(this,plugin);

    }

    public void addSetup(Player player){

        if (!onGoingSetups.containsKey(player.getUniqueId())){
            if (!arenaManager.worldIsUed(player.getWorld())){
                onGoingSetups.put(player.getUniqueId(),new ArenaSetup(player.getWorld(),player));
            }else{
                player.sendMessage(Utils.CC("You cannot do this as the world is already used on a different arena or setup."));
            }
        }else{
            player.sendMessage(Utils.CC("&cYou cannot do this,as you already have an existing ongoing Setup"));
        }

    }```
and my onEnable:
```private ArenaManager arenaManager;

    @Override
    public void onEnable() {

        ConfigManager.setupConfig(this);

        this.arenaManager = new ArenaManager(this);

        getCommand("setup").setExecutor(new SetupCommands(this));

        Bukkit.getServer().getPluginManager().registerEvents(new ArenaListeners(this), this);

    }```

i am convinced after all the time i spent looking at this to fix it that if theres an issue its not on my code ;-; (ik it is but yeah)
hushed spindle
#

it looks like you didnt call SetupManager yet

west oxide
#
 public ArenaManager(KPrac plugin){

        setupManager = new SetupManager(plugin);

        arenas = new LinkedHashMap<>();
        profileManagers = new LinkedHashMap<>();

    }```
hushed spindle
#

arenaManager = plugin.getArenaManager() within your setupmanager method

#

setupmanager doesnt seem to be called yet so it is null

#

oh its a constructor nvm

west oxide
# hushed spindle setupmanager doesnt seem to be called yet so it is null

i ran this command and got the error


                    if (!arenaManager.isInGame(player.getUniqueId())) {

                        World world = null;
                        if (args.length == 1) {
                            world = player.getWorld();
                        }
                        if (args.length == 2) {
                            world = Bukkit.getWorld(args[1]);
                        }
                        if (world == null) {
                            player.sendMessage(Utils.CC("&cCouldn't find this world."));
                        } else {

                            if (setupManager.worldIsUsed(world)) {

                                //get the player back to continue setup.

                            } else {
                                setupManager.addSetup(world, player);
                            }

                        }

                    }
                }```
#

i got the same error on other projects and i cant find it there aswell in the same way

#

:<

hushed spindle
#

how is arenamanager instantiated in your command class

west oxide
hushed spindle
#

If arenamamager is null there should be an error the moment you start your server

#

do you see any

west oxide
#

nope

#

i dont think its related

#

its even before the plugin is enabling

hushed spindle
#

its a bit late for me to help rn sorry

#

i cant see an issue right off the bat

west oxide
west oxide
idle loom
#

How do I check if arg 0 is a player or if its a string

west oxide
#

or getPlayer

vocal cloud
idle loom
#

yeah

#

I tested that

#

it didnt

west oxide
vocal cloud
#

Maybe read the docs

idle loom
#

arg0 isnt gonna be player so like it cant get offline player

#

cause

#

it isnt

#

player

vocal cloud
idle loom
#

and

#

not null

west oxide
#

oh f

idle loom
#

anyway

west oxide
idle loom
#

help 😭

west oxide
#

wait what are you trying to achieve ?

idle loom
#

if(arg0) is a player
then like do thing
else if isnt a player then like
also do things

vocal cloud
#

Player player = Bukkit#getPlayer()
if player != null: dosomething
else dosomethingelse

west oxide
vocal cloud
#

Firstly worldIsUed should be worldIsUsed?

#

Do you have this on github. Your code is really hard to follow

#

getArenaManager is returning the instance and not null?

vocal cloud
#

You sure?

#

Try logging it

vocal cloud
#

Log after it's set and log in the get

west oxide
#

import online.shakiz.kprac.arenaManager.ArenaManager;
import online.shakiz.kprac.arenaManager.setup.SetupCommands;
import online.shakiz.kprac.listener.ArenaListeners;
import online.shakiz.kprac.utils.ConfigManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;


public final class KPrac extends JavaPlugin {

    private ArenaManager arenaManager;

    @Override
    public void onEnable() {

        ConfigManager.setupConfig(this);

        this.arenaManager = new ArenaManager(this);

        getCommand("setup").setExecutor(new SetupCommands(this));

        Bukkit.getServer().getPluginManager().registerEvents(new ArenaListeners(this), this);

    }

    @Override
    public void onDisable() {


    }
    public ArenaManager getArenaManager() {return this.arenaManager;}
}
vocal cloud
#

Well your error says otherwise no?

west oxide
#

ok am logging it

#
java.lang.NullPointerException: Cannot invoke "Object.toString()" because "this.arenaManager" is null
        at online.shakiz.kprac.KPrac.getArenaManager(KPrac.java:35) ~[?:?]
        at online.shakiz.kprac.arenaManager.setup.SetupManager.<init>(SetupManager.java:26) ~[?:?]
        at online.shakiz.kprac.arenaManager.ArenaManager.<init>(ArenaManager.java:26) ~[?:?]
        at online.shakiz.kprac.KPrac.onEnable(KPrac.java:20) ~[?:?]```
vocal cloud
#

Not tostring

west oxide
#

okay

vocal cloud
#

Place it after you initialize it in your methods and in your getter

west oxide
#
[23:16:18 INFO]: [KPrac] is null: null
[23:16:18 INFO]: [KPrac] is null: null
[23:16:18 INFO]: [KPrac] is null: online.shakiz.kprac.arenaManager.ArenaManager@2a470628
[23:16:18 INFO]: [KPrac] is null: online.shakiz.kprac.arenaManager.ArenaManager@2a470628
[23:16:18 INFO]: [KPrac] is null: online.shakiz.kprac.arenaManager.ArenaManager@2a470628```
#

uhhh

crisp steeple
#

where are you putting them

west oxide
#
    public void onEnable() {

        ConfigManager.setupConfig(this);

        this.arenaManager = new ArenaManager(this);

        getLogger().info("init: " +  arenaManager);

        getCommand("setup").setExecutor(new SetupCommands(this));

        Bukkit.getServer().getPluginManager().registerEvents(new ArenaListeners(this), this);

    }

    @Override
    public void onDisable() {


    }
    public ArenaManager getArenaManager() {
        getLogger().info("getter: " +  arenaManager);
        return this.arenaManager;
    }```
#

        onGoingSetups = new LinkedHashMap<>();

        arenaManager = plugin.getArenaManager();

        plugin.getLogger().info("setupManager: " +  arenaManager);

        Bukkit.getServer().getPluginManager().registerEvents(this,plugin);

    }```
young fractal
#

quick question, how is it possible for me to create a permission node from in game. like if i were to do /permission create permission
how could i register that permission in plugin.yml

west oxide
#
[23:19:20 INFO]: [KPrac] setupManager: null
[23:19:20 INFO]: [KPrac] init: online.shakiz.kprac.arenaManager.ArenaManager@661476dd
[23:19:20 INFO]: [KPrac] getter: online.shakiz.kprac.arenaManager.ArenaManager@661476dd
[23:19:20 INFO]: [KPrac] getter: online.shakiz.kprac.arenaManager.ArenaManager@661476dd```
ivory sleet
#

When is your setup manager initialized

west oxide
ivory sleet
#

Oh ofc it’s gonna be null

west oxide
#

oh

#

kinda makes sense already now that you said it

ivory sleet
#

Idk if you figured it out

#

Ye

#

Well one way is to ascend setup manager such that it’s in KPrac.java

#

Another way would be to pass your ArenaManager directly

west oxide
#

after arenaManager

ivory sleet
#

Alr

noble lantern
#

passing through constructors though is mwah

ivory sleet
#

?

west oxide
west oxide
#

like is it good or messy

#

i tried myself to make it good oop code

ivory sleet
#

It’s a bit under average but on the better side in terms of just a spigot plugin

quaint mantle
#

in conclusion your code doesnt look good

#

better than mine when i first started tho

ivory sleet
#

Like there are good things about your code, but some parts could be designed better imho

west oxide
#

i dont understand how to make it better and am trying to figure it out

ivory sleet
#

Well first of all you don’t have particularly much code there

#

So it’s hard to give a thorough and justified assessment

west oxide
#

oh yeah i understand

#

well thank you conclure you are the best || i still remember when you taught me to use constructors||

ivory sleet
#

But for instance passing your KPrac to every other class is violating your abstraction hierarchy and is arguably causing bit much coupling in terms of design merely

Oh yeah that was a while ago, you’ve definitely become a lot better since last :3

west oxide
#

also thanks

ivory sleet
#

Nah

#

That’d be unnecessary static which is even more insane of an idea

west oxide
#

then how can i pass it trough

ivory sleet
#

But for instance let me give you an example

#
class PluginDerivative extends JavaPlugin{
  Dependency dependency;
  SomeManager someManager;
  OtherManager otherManager;

  @Override void onEnable(){
    this.dependency = new Dependency();
    this.someManager = new SomeManager(dependency);
    this.otherManager = new OtherManager(this);
  }

  Dependency dependency(){
    return this.dependency;
  }
}
class SomeManager {
  final Dependency dep;
  SomeManager(Dependency dep){
    this.dep = dep;
  }
}
class OtherManager{
  final PluginDerivative pl;
  OtherManager(PluginDerivative pl){
    this.pl = pl;
  }

  void doStuff(){
    //USAGE of Dependency
    this.pl.dependency() //for instance 
  }
}```
#

Here

#

SomeManager is more proper than OtherManager

#

As you can see, Dependency is directly injected/passed

#

And yes wrote it on phone

vocal cloud
#

Dear God

river oracle
#

you legend

west oxide
vocal cloud
#

People complain about static abuse but in reality the real abuse was the friends we made along the way

noble lantern
ivory sleet
#

But SomeManager is better because:

  • It explicates all dependencies
  • It makes the real dependencies loosely coupled
  • however it may lead to longer constructors, although there are strategies for how to deal with that such as static factory methods, context objects etc
noble lantern
#

Question:

Anyone here good with knowing how licensing works for things?

Say I have something that has a MIT license, lets say TinkersConstruct mod

Would I be able to lets say, port tinkers to a MC Plugin using they're textures but not they're source code itself?

ivory sleet
#

If a license is stated for the textural assets specifically then you might have to abide by that, else I believe it goes under the same license the code is put under? No?

west oxide
#

ill try using that instead of passing the main instance

#

i actually somewhat understand why that

ivory sleet
#

Lol yeah, well I mean something you definitely wanna understand before the arguments I made is specifically SOLID and OO principles

#

And then you probably wanna learn the design patterns

#

Yeah Shakiz

noble lantern
ivory sleet
#

sadly Bukkit sometimes require you to pass the plugin instance

#

Take BukkitRunnable#runTask for instance

#

or NamespacedKey

noble lantern
#

oh wait

#

neat

ivory sleet
#

Ah

noble lantern
west oxide
river oracle
#

having issues while compiling my plugin anyone ever see this before lol I tried searching for a bit couldn't find anything. I'm probably just stupid, but the MojoExecutionException is too vague. When I looked it up all I could find was people using JRE instead of JDK, but I made sure I do indeed have the JDK installed
Error: https://paste.md-5.net/acecojecez.sql
Pom: https://paste.md-5.net/fopoqimizi.xml

ivory sleet
#

If you really wanna be object oriented here you could create a middle abstraction level component which encapsulates a said plugin instance and delegates it (but let’s talk about that another time lol)

west oxide
#

yeah i gotta sleep

#

ty conclure again

ivory sleet
#

Sleep tight :3

ivory sleet
noble lantern
#

Cannot invoke "String.endsWith(String)" because "pattern" is null

river oracle
noble lantern
#

oh interesting

river oracle
#

also nothings tripping sonar lint either

ivory sleet
#

Have you tried invalidating caches and rebooting your ide?

vocal cloud
#

People should upload their code to github for help YanSigh

river oracle
ivory sleet
#

Mye, like based on the error it looks like someone put a "bad" string but I don’t really touch maven that often so not my field of expertise

river oracle
#

this is pain lol

ivory sleet
#

Understandable 🥲

#

gradle

river oracle
#

gradle seems harder to learn than maven

ivory sleet
#

A pretty bullshit argument imo, and then given the advantage once learnt I’d say it’s worth it

river oracle
#

whats gradle got over maven besides less verbosity

ivory sleet
#

Faster in subprojects, you basically code the buildscript (as opposed to maven where it’s just a bunch of tags) given that you program/code it, gradle can offer an api without the usage of external plugins

#

Then of course you got a ton of plugins in case you don’t wanna lay down focus on writing and automating tasks by yourself :3

#

Of course one disadvantage is how every project uses a different version of the gradle wrapper because it’s updated just so often, and then it’s less established in spigot

#

Myeah it’s also quite unopinionated so people tend to structure things differently which can be a disadvantage as you’ll have to learn every project’s structure from the beginning (assuming you’re trying to understand an open source that uses gradle)

idle loom
#

This command is sending an error to console and I'm honestly not sure why
The command sets your, or someone elses gamemode to survival when ran

public class customGMS implements CommandExecutor {
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player player = (Player) sender;
            if(!player.hasPermission("srmod.gamemode")) {
                player.sendMessage(ChatColor.BLUE + "Permissions> " + ChatColor.GRAY + "You do not have permission to do this.");
                return true;
            }
            Player target = Bukkit.getPlayer(args[0]);
            if(args.length == 0) {
                player.setGameMode(GameMode.SURVIVAL);
                player.sendMessage(ChatColor.BLUE + "Gamemode> " + ChatColor.GRAY + "You set your gamemode to Survival");
                return true;
            } else if (args.length == 1) {
                player.setGameMode(GameMode.SURVIVAL);
                player.sendMessage(ChatColor.BLUE + "Gamemode> " + ChatColor.GRAY + "Set " + ChatColor.GRAY + target.getName() + ChatColor.GRAY + "'s gamemode to Survival");
                target.sendMessage(ChatColor.BLUE + "Gamemode> " + ChatColor.GRAY + "Your game mode was set to Survival.");
                return true;
            }
            return true;
    }

}```

Error: https://www.toptal.com/developers/hastebin/ijucowiyum.properties
ivory sleet
#

Player target = Bukkit.getPlayer(args[0])

#

You check the arguments length after this line

#

And so you don’t really check whether args[0] actually is within bounds

#

As the check (args.length == 0)comes after the attempted array access of index 0

woeful crescent
#

Now that World.spawnFallingBlock() is deprecated, what's the best way to spawn a falling block with a specified texture?

pliant oyster
idle loom
pliant oyster
#

yeah i'm typing

#

for the else if part

#

are you trying to set the targets gamemode or the senders?

#

lemmie just retype that for you

idle loom
#

ooh

#

yeah that code there has some issues I fixed

#

with variables

#

like when you're supposed to set someone elses gamemode it sets yours

#

I fixed that

pliant oyster
#
public class customGMS implements CommandExecutor {
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

            Player player = (Player) sender;

            if(!player.hasPermission("srmod.gamemode")) {

                player.sendMessage(ChatColor.BLUE + "Permissions> " + ChatColor.GRAY + "You do not have permission to do this.");
                return true;

            }

            if(args.length == 0) {

                player.setGameMode(GameMode.SURVIVAL);
                player.sendMessage(ChatColor.BLUE + "Gamemode> " + ChatColor.GRAY + "You set your gamemode to Survival");
                return true;

            } else if (args.length > 0) {

                String playerName = String.valueof(args[0]);
                Player target = Bukkit.getPlayer(playerName);

                target.setGameMode(GameMode.SURVIVAL);
                target.sendMessage(ChatColor.BLUE + "Gamemode> " + ChatColor.GRAY + "Set " + ChatColor.GRAY + target.getName() + ChatColor.GRAY + "'s gamemode to Survival");
                target.sendMessage(ChatColor.BLUE + "Gamemode> " + ChatColor.GRAY + "Your game mode was set to Survival.");
                return true;
            }
            return true;
    }

}```
#

Idk if you have to create the string playerName but that's what I usually do for command args

#

I spaced it out a bit for u

ivory sleet
#

🥄

pliant oyster
#

@idle loom

pliant oyster
#

that's how ppl learn

ivory sleet
#

No not really

pliant oyster
#

I have to use code in a thingy first before I have any idea what it does

#

lol

ivory sleet
#

Mye well I’d say the colossal issue with spoonfeeding is the fact that you can continue without knowing the actual solution

#

It does not enforce you to understand the solution put simply

pliant oyster
ivory sleet
#

But if you’re dedicated then ye perhaps spoonfeeding might just be fine

pliant oyster
ivory sleet
#

Ye lol maybe

pliant oyster
pliant oyster
ivory sleet
pliant oyster
#

uhhh

#

a low iq human being

idle loom
#

damn

#

I'm a bleb then

#

D:

ivory sleet
#

Oh then I’m a bleb as well pepesipspin

pliant oyster
#

ayy

#

oh shit

#

forgot need to use my nitro

#

it's ending soon

ivory sleet
#

🥲

pliant oyster
#

NOOO

#

IT ENDED

#

nvm

ivory sleet
#

Lol

vocal cloud
noble lantern
#

Whats the best way to handle adding in custom blocks to a plugin?

I know for the block to retexture you would use a resource pack, and most of the time i hear lots of good things for Mushroom blocks, but this would only make it so you could add in 15 different blocks according to this screenshot

but even then it doesnt seem like youd be able to do that many because you would just have a resource pack that has different texture for the stem, cap, and pore (So in reality only 3 different blocks) unless im wrong about this (I saw some spigot post somewhere that you can have 120 different texture with mushroom blocks? Ill try to find the spigot post)

Dont want to use armor stands + heads method, just seems kind of uhm, broken lmao

I know of another method, but its as weird as the armor stands one, which would be making the block covered in item frames and then retexturing a item with CMD that's inside that item frame (Probably a map?)

echo basalt
#

Last option is janky and you'd need to recode a lot of stuff

#

It's decent for adventure maps

#

But not survival

#

Mushroom stems and pores are decent

noble lantern
#

Yeah tbh most methods are real janky, which im fine with im just trying to find a method that would be the "least jank" if you get what im saying

And yeah any way this is done ide need to add a bunch of handling and prevent any unwanted actions which im well aware of and ready to do, just not sure the best way to handle actually handling the texturing of items

noble lantern
hasty prawn
#

Noteblocks are another good option

noble lantern
#

Yep i heard stuff about noteblocks too, was considering that as well

#

How many different blocks could you squeeze out of both of them? As i dont really see a very clear answer for this

If the mushroom blocks textures are all individuals then thats 15 blocks itself, but if mushroom blocks are handled dynamically (Stem, Spore, and cap are textured at runtime) then that would mean im only able to handle 3 different textures at one time, and i assume the same would be similar with noteblocks

hasty prawn
#

Well, Noteblocks have a ton. There's 16 instruments, each have 25 notes, and can either be powered on or off. 16 * 25 *2 = 800 lol

#

Could calculate mushroom blocks the same way, but I'm going to just assume that the 120 calculation was probably correct, or atleast close to it.

noble lantern
#

oh wow 800 definatly does seem a lot better than 3, 15 or 120 lmao

Only issue is im not entirely sure how this would be handled out when creating the pack i would assume you would edit the ,json to point to a different texture than the original but looking through the default json files for blocks i dont see that many configurable options :c

#

oh neat

#

youtube vid for noteblocks

hasty prawn
#

Perfect lol

noble lantern
#

wait hold up

#

this video is smart

#

it uses monster spawners, and you set the spawner type to armor stand that is wearing a custom textures item

#

and scale it up with the json files of the texture pack o.O

noble lantern
#

okay yeah im definatly trying that that seems so cool

#

There should be a java.version variable in your maven file, or gradle file

And set the java version to lower in your intellij as well (if your using that)

#

?

#

You cant do that

#

If you want to support down to java 8, youll need to compile with java 8 (To my knowledge)

#

you could create 2 seperate java versions for your plugin, but that would mean maintaining 2 different plugin source's

#

Thats why i dont really like to create plugins for anything lower than ~1.14, its just too big a hassle, handling different nms, handling different java versions, handling differences in spigot api with version checks

granite beacon
#

Is there a way to check when a dropped item is moved?

#

EntityMoveEvent only applies to living entities

hexed hatch
#

It’s a good trick to use sporadically though, though it is to be noted when you’re looking at them from a distance, they look like spawners

#

There’s one good, real block to use that is mineable with a pickaxe and can’t be obtained in survival: the petrified oak slab variants

#

It only has 3 variants, a bottom slab, top slab, and double slab

noble lantern
hexed hatch
#

If it’s only a couple per chunk I doubt it

#

I’m talking about if players grab a shit ton of it and build houses out of it

noble lantern
hexed hatch
#

Only three, and it’s a top slab, bottom slab, and full block

#

It’s not a lot to work with, but I like to dedicate those to blocks I want to use en masse

noble lantern
#

The main issue is im going to need about 20ish different blocks to be added

#

and possibly more

#

So im just trying to find the most efficient way to add this many blocks without any over complicated methods and no clunkyness like with armor stands and item frames

hexed hatch
#

Noteblocks are the way to go I’d say, but bear in mind that they will be mineable by axe

noble lantern
#

Indeed, i assume though you can just make an API check (ie check if block is custom ore/block) and for said ores that are spawned and allow to be mineable with pickaxes faster and make mining speed slower with axes?

I havent really touched on that part of the api yet but i assume this is something thats probably possible

hexed hatch
#

The mushroom variants aren’t a terrible option either

#

But

#

It’s finicky as all hell

#

Because when a mushroom block is next to another block, it changes states

noble lantern
#

ohhh you know what good point

#

Forgot about that

hexed hatch
#

There’s no clear api path for adjusting it, it takes some work and there may be desync for players with low pings

#

All in all, adding blocks to a spigot server is a fun experience

noble lantern
#

Yeah i know either way custom blocks get implemented things are going to be finicky, im fine with the actual mining process being a little out of sync

hexed hatch
#

I once added an entire dimension to my server made of blocks not found in any of the other worlds

#

It was pretty desolate

noble lantern
#

im trying the spawner way out now, but i need to import NMS to access CraftCreatureSpawner but for some reason gradle isnt liking to import that nms jar lmfao

radiant cipher
#

Anyone know if theres a way to power a block requiring redstone to activate