#help-development

1 messages · Page 834 of 1

glad prawn
#

I think it's ok with few lines of code

lost matrix
#

I think he did it because his IDE suggested it and he should def create a concrete impl to learn it 🙂

quaint mantle
lost matrix
quaint mantle
#

try to load soundlistener class if successful it'll proceed if not it'll catch block and it'll throw a runtimeException

#

though doesn't it make sense to run it on the main class cause my main class is a listener

lost matrix
#

This code doesnt make sense to run anywhere...
It is a highly specifc tool used for reflections and triggering classloader initialization.
Nothing you should worry about for at least another year of coding.

quaint mantle
#

oh xd sorry again being a newbie has its fall downs ;-;

lost matrix
#

Create a new class
Let it implement Listener
Create a new instance of that class
Register that instance in your onEnable

Pls create a Listener instance and come back when you got that done 🙂

#

And make yourself familiar with the difference of a class and an instance of a class

quaint mantle
minor junco
#
  1. you reallocate the same instance within itself
  2. you register your events within the PlayerJoinEvent
#

remove line 17 & 26, go in your Main where your onEnable is and put Bukkit.getPluginManager().registerEvents(new SoundListener(), this); within the enable method. I'd recommend having a look over Java basics too!

quaint mantle
#

ohhhh sorry then i really struggle understanding sometimes so this really helps since its super clear

minor junco
#

i understand, we all started at some point

#

and no worries you'll get behind all of this with enough time

river oracle
minor junco
river oracle
#

truly a mess

minor junco
#

it kinda is yeah

river oracle
#

though it works for now

#

less nesting is always better for the stack

minor junco
#

idk what this is supposed to represent but if it's not something configurable just put everything in one line, no?

river oracle
minor junco
#

oh ive just seen you meant syntax tree

river oracle
#

like syntax of a language

#

I forget what its called

#

I don't work with this stuff a lot

minor junco
#

the process is called tokenization

river oracle
#

ahhh yes

minor junco
#

so its tokens you're saving from your syntax

river oracle
#

yeppers

minor junco
#

what do you need this for?

#

if I may ask

dry forum
quaint mantle
#

Guys

minor junco
quaint mantle
#

Should I be separating my plugins?

river oracle
# minor junco if I may ask

well I'm making a MiniMessage clone that supports BungeeChat. Regex kinda falls off once you get more complex

#

I tried attempting this with regex and it was hell

#

so i looked up many things and decided maybe I should go for lexical analysis

minor junco
#

alright, well if this syntax tree is not meant to be configurable, just put everything in one line no?

river oracle
brisk estuary
#

hey, I have moved a class that implements PersistentDataType from a package to another one. The thing is that I used this pdt to store info in items and I have a machine that checks the item's pdc for this specific info. The problem is that this machine is not able to recognise old items because of the package (it looks for the pdt, which is in a new package, and finds the old pdt from the old package). I've managed to fix it by having 2 PDTs, one in the new package and one in the old package. Then in the new PDT I check in the fromPrimitive method wether it's the new or the old pdt.

@Nonnull
    @Override
    public List<MerchantRecipe> fromPrimitive(@Nonnull byte[] bytes, @Nonnull PersistentDataAdapterContext context) {
        if (bytes.length == 0) {
            return new ArrayList<>();
        }

        List<MerchantRecipe> merchantRecipes = new ArrayList<>();

        try (ObjectInputStream objectStream = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
            int recipeCount = objectStream.readInt();
            for (int i = 0; i < recipeCount; i++) {
                Object object = objectStream.readObject();
                MerchantRecipe recipe;
                if (object instanceof SerializableMerchantRecipe smr) {
                    recipe = smr.toMerchantRecipe(context);
                } else {
                    SlimeFrame.getInstance().getLogger().warning("Old MerchantRecipeList serialization detected");
                    me.voper.slimeframe.slimefun.datatypes.MerchantRecipeListDataType.SerializableMerchantRecipe smr = (me.voper.slimeframe.slimefun.datatypes.MerchantRecipeListDataType.SerializableMerchantRecipe) object;
                    recipe = smr.toMerchantRecipe(context);
                }
                merchantRecipes.add(recipe);
            }
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }

        return merchantRecipes;
    }
#

But now I also need to convert every item that has the old PDT to the new one, but I don't know how to check if an item has the old PDT given its ItemMeta. Does anybody know how I can do that?

river oracle
minor junco
#

ah okay

river oracle
#

in reality its just a class with 4 fields

    private final BaseNode parent;
    private final Token token;
    private final NodeType type;
    private final String source;
    private final List<BaseNode> children;
#

but when working on it if its visualized its much easier to see where shit breaks

minor junco
#

yeah igy

#

but i mean

#

if it works and only is to debug

#

who cares if it looks messy

river oracle
river oracle
#

you'll have to manually check for the old class too

#

but considering you used serializables and I'm assuming you didn't use proper Serialization versioning that data may be as good as lost from what I know on the topic matter

brisk estuary
#

The old class is the same class, the only difference is that it is in another package

brisk estuary
river oracle
#

doesn't matter if you didn't do proper Serialization ID etc

river oracle
#

like

#

why

#

there must be a good reason to serialize an entire RECIPE

#

oh wait that's a MerchantRecipe god I got tricked

brisk estuary
#

xd

river oracle
#

I thought that said something else

#

idk a ton about java serialization but you may be fucked

#

have you tried moving it back to the old package

#

if you don't provide a proper serialization version too when you change that class its possible to lose old data

#

excerpt from https://www.baeldung.com/java-serialization section 3.2 under section 3 Caveats of Serialization

The JVM associates a version (long) number with each serializable class. We use it to verify that the saved and loaded objects have the same attributes, and thus are compatible on serialization.

Most IDEs can generate this number automatically, and it’s based on the class name, attributes, and associated access modifiers. Any changes result in a different number, and can cause an InvalidClassException.

If a serializable class doesn’t declare a serialVersionUID, the JVM will generate one automatically at run-time. However, it’s highly recommended that each class declares its serialVersionUID, as the generated one is compiler dependent and thus may result in unexpected InvalidClassExceptions.
#

this is not to say to use NMS internals use NBT to store everything in bytes

#

than parse those bytes from the PDC

brisk estuary
#

alright, thanks

rapid trout
#

I want to create a NPC, for this I want to use an library, I tried NPC-lib but it doesn't permit do depalce the NPC, I want to make the NPC able to go forward

echo basalt
#

ZNpcs seems to be a trending one

#

Worst case you might try citizens' new packet npc system

quaint mantle
#

What's a desginer pattern that takes in an object and returns the same object but modified

#

public interface CustomItemIdentifier {

labelItem(ItemStack customItem, String referenceName);

}

Maybe like this

echo basalt
#

Uh

#

Function?

#

or UnaryOperator

quaint mantle
#

it just applies a NamespacedKey into an item

echo basalt
#
UnaryOperator<Integer> operator = (value) -> value + 1;
int two = operator.apply(1);
#

type deal

#

you might want a builder pattern

quaint mantle
#

I'm at the stage where I want to start making features for my custom items (the implementation) but I want the custom items to be labeled using pdc

#

and I also want it to all be loosely coupled

#

but idk how to approach this

waxen plinth
#

functional interfaces / lambdas are definitely the way to go, I agree

#

they allow you to very easily express side effects and then store them for later

echo basalt
#

I'd probably make some sort of pdc system on your item builder

#

And use uh

#

Maps n interfaces

quaint mantle
#

So

#

I made a rough layout

#

Idk it's kinda all over the place

waxen plinth
#

some of these feel like they could be abstract classes

#

like CustomCharacterInformation

#

is there any reason for ArmorContainer to be anything but a wrapper for an ItemStack[4]?

#

or what will T be

#

I guess custom item type

quaint mantle
#

yeah

waxen plinth
#

so a wrapper for a T[4]

quaint mantle
#

could be

waxen plinth
#

don't build abstractions for things that really don't need to be abstracted over

#

providing an overridable method for getting the armor contents that could be dynamically computed would be more than enough, I think

echo basalt
#
public interface MyCustomItem {
  String getIdentifier();
}
public interface MyCustomItemProvider {
  MyCustomItem provide(MyPlugin plugin, ConfigurationSection config);
} 
public class MyItemRegistry {

  private final Map<String, MyCustomItemProvider> providers = new ConcurrentHashMap<>();
  private final MyPlugin plugin;

  public MyItemRegistry(MyPlugin plugin) {
    this.plugin = plugin;
    registerDefaults();
  }

  public void register(String name, MyCustomItemProvider provider) {
    this.providers.put(name, provider);
  } 

  public MyCustomItem provide(String name, ConfigurationSection section) { // Hook this to where you scan your config
    MyCustomItemProvider provider = this.providers.get(name);

    if(provider == null) {
      return null;
    }

    return provider.provide(this.plugin, section);
  }

  private void registerDefaults() {
    register("hero-boots", MyHeroBoots::new);
    register("hero-leggings", MyHeroLeggings::new);
  }
}

🤔

waxen plinth
#

yeah that's a good pattern if they're config dependent

echo basalt
#

That's how I usually do configurable custom items

waxen plinth
#

I would sometimes do stupid shit to avoid needing to manually register them

echo basalt
#

That's hacky

#

Just manually register them

#

Don't hide code flow

echo basalt
#

hacky

waxen plinth
#

😎

#

the things I'd do to get a crumb of abstraction in java

echo basalt
#

I used to work at a server that took that to the extreme and it wasn't fun to learn

#

you'd just pray for things to register themselves

waxen plinth
#

it's a delicate system

echo basalt
#

And it'd add 100 hours of onboarding, development and management time to save ~5 seconds a couple times

#

All while hiding code flow and making sure you have no control over when things get registered or work

waxen plinth
#

yeah I mean in all honesty it really wasn't worth it, but I did it because I would literally always forget to register my new classes and have to redeploy and reload twice

echo basalt
#

Our way to disable a command was just to comment out the entire class and pray it works

waxen plinth
#

lol

#

I ended up building a lot of very broad and abstract tooling to optimize away basically every little slowdown, and that was one of them

#

I really just wanted to move as fast as possible and it did sometime cause me to cut corners

echo basalt
#

thing is those tools end up being a lot slower than just doing stuff manually

waxen plinth
#

definitely not lol

echo basalt
#

An example is our ORM system

waxen plinth
#

some of them saved me countless hours

echo basalt
#

We used reflections to serialize all player data and stick it in our database

waxen plinth
#

just have to pick the right tools for the job and make sure they're capable of doing what you need

echo basalt
#

Which meant a solid 200 hours writing the system to be resilient

waxen plinth
#

ouch

echo basalt
#

And another 2 hours for each project just adapting the data structure to work with the ORM

waxen plinth
#

any reason to not use an existing one?

echo basalt
#

because the ORM really didn't like generics or interfaces

echo basalt
quaint mantle
#

What's orm

waxen plinth
#

object relational mapping

echo basalt
#

shove an object in a database

waxen plinth
#

a strategy for automatically converting objects into database rows

echo basalt
#

Like sure it's cool and works like magic

waxen plinth
#

tbh I think you might as well use an object or document database if that's what you want

echo basalt
#

For my skyblock system I just took the abstraction approach

#

And made abstract classes for everything

waxen plinth
#

sql is extremely rigid and seems largely incompatible with the "wave a magic wand" approach of ORM

quaint mantle
waxen plinth
#

I've come to really dislike OOP design

quaint mantle
waxen plinth
#

hi conclure

ivory sleet
#

hello

waxen plinth
#

everything needs to be a strict hierarchy and there can be no exceptions to the rules you lay out

ivory sleet
#

I mean traditional oop is goofy

waxen plinth
#

a class is like 3 concepts rolleed into one

ivory sleet
#

But if you modernize it, pretty decent stuff

waxen plinth
#
  • no sum type 🤮
quaint mantle
#

I still like OOP over (forgot what the other was)

waxen plinth
#

functional?

quaint mantle
#

Yes

waxen plinth
#

imperative?

quaint mantle
#

Functional

waxen plinth
#

functional is nice but I feel like it's best interspersed with imperative

quaint mantle
#

I don't know what imperative is

waxen plinth
#

plain old "code code"

ivory sleet
#

Object oriented

waxen plinth
#

just write the code that does stuff, straight-up

quaint mantle
#

Like js?

ivory sleet
#

Imperative means we tell the machine what to do

waxen plinth
#

instructions, function calls, statements

quaint mantle
#

Or more like assembly?

waxen plinth
#

assembly is one example of imperative code

ivory sleet
#

as opposed to declarative (functional) where we rather describe things with expressions what will happen

waxen plinth
#

I find functional amazing for smaller tasks

ivory sleet
#

I find a mix to be the best

waxen plinth
#

and algebraic type systems elegant for weaving everything together at larger scale

#

it's so simple and so powerful

echo basalt
#

It'd be interesting to make an abstract class to filter stuff

#

TBH at work we just made a listener for each custom item

#

And did the manual checks as it was like

#

5 lines

waxen plinth
#

I designed an enchant system that was pretty cool

#

it let you abstractly define "triggers" and define behavior with them

#

might be a bit tough to reproduce fully tbh but I think it worked really well

#

this was a rewrite so ofc it was much nicer after that

quaint mantle
#

For each check

echo basalt
#

Pretty much

ivory sleet
#

But anyway, traditional oop sucks, however if you take a little bit of lambda calculus, little bit of type theory, and little bit of data oriented programming it becomes nice

waxen plinth
quaint mantle
#

maybe I'm rly over thinking this

waxen plinth
#

even if you don't want to go as deep into it as this does

echo basalt
#

You can just make methods to get an item from an event

quaint mantle
#

legit the only character I've made is the flash 💀

waxen plinth
#

you could do something similar

quaint mantle
#

And I've been on this for a month

echo basalt
#

and a method to check if the item tag matches

quaint mantle
#

The thing is tho

ivory sleet
#

Boxbeam, how do you know my previous name to be conclure? Just curious :>

quaint mantle
#

That just seems so like

#

violating the dry

echo basalt
#

boxbeam is redempt silly

waxen plinth
ivory sleet
#

Oh

echo basalt
#

yeah just figured that part out

#

was like "who tf is this rando"

waxen plinth
#

you could use a similar approach

#

don't have to copy the design outright, but the approach of triggers and handlers split up into specific items/matchers worked really well

ivory sleet
echo basalt
#

Reminds me of the uh

ivory sleet
#

You see

echo basalt
#

my quests system

#

except I didn't abstract it THAT much

waxen plinth
#

I mean look how simple it made it to create an enchantment in the end, you could basically just write "here's what it is, and here's what it does" in very simple terms

ivory sleet
#

DRY is good, but all principles should not be taken literally, just try to get the idea of them and apply whats useful to u

quaint mantle
#
public class TheFlashBoots implements CustomItem { 
  
     private final PermanentPotionEffectManager potionEffectManager; 
  
     public TheFlashBoots() { 
         this.potionEffectManager = new PermanentPotionEffectManager(CharacterWarPlugin.getInstance()); 
     } 
  
     @Override 
     public @NotNull ItemStack getItem() { 
         return new CustomItemBuilder(Material.LEATHER_BOOTS, "the_flash_boots") 
                 .setName("<yellow>The Flash's Boots") 
                 .setLore("<gray>Grants <yellow>Speed V <gray>when equipped.") 
                 .setColor(Color.YELLOW) 
                 .build(); 
     } 
  
     @Override 
     public void onArmorEquip(PlayerArmorChangeEvent event) { 
         this.potionEffectManager.applyEffectLoop(event.getPlayer().getUniqueId(), PotionEffectType.SPEED, 4); 
     } 
  
     @Override 
     public void onArmorUnEquip(PlayerArmorChangeEvent event) { 
         this.potionEffectManager.removeEffectLoop(event.getPlayer().getUniqueId(), PotionEffectType.SPEED); 
     } 
  
     @Override 
     public void onPlayerLeave(PlayerQuitEvent event) { 
         this.potionEffectManager.removeEffectLoop(event.getPlayer().getUniqueId(), PotionEffectType.SPEED); 
     } 
 }```
waxen plinth
#

how are the events passed through?

quaint mantle
#

listeners

#

that I inject a item repository into

#

and so it's basically I get the PDC once

waxen plinth
#

so do you mean these are all like default methods that do nothing

echo basalt
#

I'd probably use the eventbus system I made for this

quaint mantle
#

yeah

waxen plinth
#

and when the associated event happens with this item

echo basalt
#

Sure it means manually registering stuff

waxen plinth
#

it passes it through to the custom item class?

quaint mantle
#
public interface CustomItemListener extends Listener { 
  
     default void onDamagedWhileWearing(EntityDamageEvent event) {} 
     default void onDamagedWhileHolding(EntityDamageEvent event) {} 
  
     default void onDamagedByPlayerWhileWearing(EntityDamageByEntityEvent event, DamageEventInfo info) {} 
     default void onDamagedByPlayerWhileHolding(EntityDamageByEntityEvent event, DamageEventInfo info) {} 
  
     default void onAttackPlayerWhileWearing(EntityDamageByEntityEvent event, DamageEventInfo info) {} 
     default void onAttackPlayerWhileHolding(EntityDamageByEntityEvent event, DamageEventInfo info) {} 
  
     default void onArmorEquip(PlayerArmorChangeEvent event) {} 
     default void onArmorUnEquip(PlayerArmorChangeEvent event) {} 
  
     /*** Not reference name specific.*/ 
     default void onPlayerLeave(PlayerQuitEvent event) {} 
  
     default void onInteractWhileHolding(PlayerInteractEvent event) {} 
  
 }```
quaint mantle
waxen plinth
#

ah...

echo basalt
#

Or if you want to be picky just a Map<Class<? extends Event>, Consumer<? extends Event>> getListeners()

waxen plinth
#

but extending Listener, does that mean the events are being passed directly from the spigot event bus?

quaint mantle
#

no

#

That's if like

#

There's an unsupported even

#

event

waxen plinth
#

right, that's always the issue

#

that's the limitation of that approach

#

you have this special set of "supported triggers" carved out

echo basalt
#
@Override
public Map<Class<? extends Event>, Consumer<? extends Event>> getListeners() {
  return Map.of(
    PlayerJoinEvent.class, this::handlePlayerJoin,
    PlayerQuitEvent.class, this::handlePlayerQuit
  );

this is hideous think3d

quaint mantle
#

which I am ok with tho

waxen plinth
#

and if you want something special, you end up having to write the checks yourself

waxen plinth
quaint mantle
#

and how does that support every trigger?

waxen plinth
#

because a trigger can react to anything, even custom events

echo basalt
#

sumn like this

waxen plinth
#

all it does is register a listener to a specific kind of event and say "I can tell you the items 'associated' with this event"

#

that's it

echo basalt
#

Just add a void registerEvents(EventBus bus) method to your interface of use that constructor interface thing

waxen plinth
#

and then the manager will look at those items, figure out what enchants are on it, see if any of those have triggers registered to the event, and call their handlers if they do

quaint mantle
#

yeah but like

waxen plinth
#

so all you need to do to make a trigger for something is be able to retrive the items and player from the event

quaint mantle
#

How does the manager do that with an unsupported event

echo basalt
#

Basically you just adapt to bukkit's event bus

#

and use interfaces and listeners and maps rather than hardcoding your event types

#

For example, by using that EventBus util I referred

#
@Override
public void registerEvents(EventBus bus) {
  bus.subscribe(EntityDamageByEntityEvent.class, this::handleEntityDamage);
} 

type deal

#

Just have an event bus in your registry and call that method when your thing gets registered

waxen plinth
#

it gets passed the event class

#

and it can then register a listener for that class

#

so yeah

#

EventListener is a helper class that registers listeners from lambdas

quaint mantle
#

I have no idea what's happening

#

but lets say bucket releases a new event

#

like

#

PlayerDamagedByZombie (unrealistic)

#

how would you like

#

manage this new event

waxen plinth
#

getEvents() returns a Map<Class<? extends Event>, Function<Event, EventItems>>

ivory sleet
#

You have to manually add it, or well u could scan classes at runtime

waxen plinth
#

yeah it knows the event classs at runtime

#

the trigger specifies it

#

and it maps it to a lambda that can take that event and get the EventItems from it, which is just a wrapper for any items used or changed in the event

#

which also captures the player

quaint mantle
#

bruh

waxen plinth
#

so then it can register a new listener to that event class

quaint mantle
#

yeah I'm clueless rn

young knoll
#

Just make your own skript

#

Easy

waxen plinth
#

lol

quaint mantle
#

Top notch configuration

young knoll
#

I mean

#

Name a plugin more configurable than skript

quaint mantle
#

command blocks

#

not even a plugin

#

needed

waxen plinth
#

they're probably both turing complete

quaint mantle
#

Bro I used to think hypixel was running a bunch of command blocks

waxen plinth
#

and ATMs are run by tiny men who hand out the money

quaint mantle
#

💀

young knoll
#

Are you telling me the aren’t!

quaint mantle
#

@waxen plinth so when should I use abstract classes

#

because I originally had an abstract class for the CustomCharacter class

#

Got yelled at

#

So I turned it into a regular class

waxen plinth
#

CustomCharacter does not sound like it should be a regular class

#

what would an instantiation of that base class represent?

young knoll
#

A custom character

#

Duh

quaint mantle
#

lol

waxen plinth
#

but overriding nothing, so what would it specify?

#

just armor or something?

quaint mantle
waxen plinth
#

is there no behavior without a default impl

#

and I mean an obvious default

dreamy ridge
#

why do i get this error
Caused by: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: ./world/stats/?4?lOfficer.json at sun.nio.fs.UnixPath.encode(UnixPath.java:121) ~[?:?]
This error occurs when i use § colouring ONLY on my real server. When im using gradle run server task the error does not occur

carmine mica
#

you are setting the gameprofile name to have invalid characters, the section char in this case

#

also offline mode

dreamy ridge
#

im using offline mode, and gameprofile names are allowed to have colourcodes no? why would it only error on my real server not gradle run task if thats the case

carmine mica
#

🤷 idk why its only happening sometimes, but that is what is causing that exception

#

people usually change the gameprofile name that is sent to clients, not the actual one stored on the server if you are wanting to add legacy color codes to it

dreamy ridge
#

arent gameprofiles already pretty much client side? since im not really telling the server that a gameprofile/player exists

carmine mica
#

no. each player has a gameprofile on the server

#

you can try just deleting that file and see what happens

hoary spire
#

org.bukkit.plugin.InvalidDescriptionException: Plugin description file is empty or not properly structured. Is nullbut should be a map.

main: com.therobokedi.main
name: testplugin
version: 0.0.1
author: TheROBOKEDi
commands: 
  testcmd: 
    description: test command
    default: true```
dreamy ridge
carmine mica
#

oh wait, show the whole stacktrace

#

its probably erroring just trying to create the Path object to see if the file exists

dreamy ridge
#

e

#

discord wont let me upload text as files :/

cyan void
#

is there a place for where i can see all the deprecated functions and what to use instead?

i need it for this:

Player player = event.getPlayer();
player.getItemInHand();
#

'getItemInHand()' is deprecated

round finch
#

For newer versions it is either main hand or offhand

short raptor
#

Is there a way to cancel a knockback impulse without cancelling existing velocity? If I just set their velocity to vector 000 then his movement from before getting hit is gone as well

cyan void
inner mulch
inner mulch
inner mulch
#

or just cancel it

short raptor
#

Oh awesome thanks!

inner mulch
#

remember to check if the entities are players too, unless you want to cancel all the knockback on the server

inner mulch
#

Oh there has to be a spigot one too

short raptor
#

You made me think, I can probably just get player's velocity in the damage event, and then subtract the difference 1 tick later when his knockback gets applied

#

Because Right now I am doing this Bukkit.getScheduler().runTaskLater(main, () -> victim.setVelocity(new Vector()), 0); I think I wouldnt need to change it much

inner mulch
#

That would work

short raptor
#

I will try it

inner mulch
#

Okay i will see if spigot has an event

#

I couldnt find one

short raptor
#

Yeah I don't think it exists for spigot :(

inner mulch
#

I guess either paper or the damageevent method

cyan void
inner mulch
#

i dont know

inner mulch
upper hazel
#

what event exists in bukkit api when triggering a tag name change in anvil

remote swallow
cyan void
inner mulch
#

Is there an event being called for when a player's shield is broken?

eternal oxide
#

break item

#

sorry item break

inner mulch
eternal oxide
#

have you looked to see if PlayerItemBreakEvent fires when the shield breaks?

grim ice
#

Do you guys think I can use shutdown hooks

#

to save cached data to my database?

eternal oxide
#

um, probably difficult as your plugin is instanced by Spigot

grim ice
#

well im not making a spigot plugin :P

eternal oxide
#

by the time any shutdown hook fires your plugin will already have been disposed of

grim ice
#

its a discord bot in java

#

I don't think the framework im using interferes with how shutdown hooks work, so this is a general java question

wet breach
#

not sure how large your cache of data is

grim ice
#

not that large

#

just user balances and inventories..etc

wet breach
#

however you could make use of memory mapped files to store it for the next start up. Memory mapped files are separate memory space from the java process and if something happens the OS ensures it gets saved 🙂

#

in this manner you don't have to worry about holding up a shutdown

#

as well as if it just shutsdown unexpectedly

grim ice
#

i see

#

ill look into that

astral pilot
#

how do i check if the mob spawn location is safe before spawning the mob

hazy parrot
#

or just periodically save your data

#

i wouldn't trust shutdown hooks

grim ice
rotund ravine
#

Periodic plus shutdown hook 👌🏻

grim ice
#

but it still doesnt gurantee

hazy parrot
#

it pretty much does

rotund ravine
#

Then

#

Save on each change

lost matrix
astral pilot
lost matrix
#

Check if blocks are at their location 🙂

quaint mantle
#

im getting this error in my project, i recently switched pc's so the path to my project changed
every time i reload maven i get this error: (im trying to use nms 1.20.2)


Try to run Maven import with -U flag (force update snapshots)

i tried following the link and searched for org/spigotmc/spigot, but the only version contained in spigot was 1.8.8
here's my full pom.xml, apparently the spigot dependency is the error:
https://pastebin.com/PuHcFGM7

lost matrix
#

Also running paper-api + nms spigot is wild...
Either use spigots nms approach or papers. But dont mix them.

opal juniper
#

yeah ^ they are very different

quaint mantle
#

i believe they are quite the same
also NMS worked perfectly a few days ago (with paper), the error only appeared after I switched pc's

rotund ravine
#

Yes

#

Build the jar with buildtools

quaint mantle
#

What does build tools actually do

#

cause I'm confused

rotund ravine
#

Takes the mojang jar

#

Decompiles it

quaint mantle
#

which one

rotund ravine
#

Patches the code with magic

#

And compiles it again

rotund ravine
quaint mantle
#

nah like where does it get it

rotund ravine
#

From mojang

chrome beacon
#

^^

inner mulch
#

is there an event for when a player throws a trident

inner mulch
#

:(

proud badge
lost matrix
proud badge
#

Chatgpt is 2022 and 1.13 was released in 2018

lost matrix
proud badge
#

Rip

inner mulch
lost matrix
inner mulch
#

okay

#

i will try to

lost matrix
#

But depends on your purpose

wet breach
#

?jd

undone axleBOT
inner mulch
#

yes i could find anything

wet breach
#

?jd-s

undone axleBOT
inner mulch
wet breach
#

this lets you see all events that are possible

inner mulch
#

okay

dry forum
#
            Location blockLocation = block.getLocation();
            Material material = block.getType();```

i have a 3x3 of green wool between those 2 points, and the material is returning LEGACY_WOOL, why is it not GREEN_WOOL
lost matrix
dry forum
#

ah k thanks

short raptor
inner mulch
quaint mantle
#

i meant running buildtools*

#

nevermind i solved it

clear elm
#

whats not working here?

#
import java.awt.Point;
import java.util.Scanner;

public class Snake {
    public static void main(String[] args) {
        Point spielerposition = new Point(10, 9);
        Point schlangePosition = new Point(30, 2);
        Point goldPosition = new Point(6, 6);
        Point tuerPosition = new Point(2, 5);
        boolean weiter = true;

        while (weiter) {
            for (int y = 0; y < 10; y++) {
                for (int x = 0; x < 40; x++) {
                    Point p = new Point(x, y);
                    if (p.equals(spielerposition))
                        System.out.print("P");
                    else if (p.equals(schlangePosition))
                        System.out.print("S");
                    else if (p.equals(goldPosition))
                        System.out.print("G");
                    else if (p.equals(tuerPosition))
                        System.out.print("T");
                    else
                        System.out.print(".");
                }
                System.out.println();
            }
            
            bewegespieler(spielerposition);
            bewegeSchlange(schlangePosition, spielerposition);
        }
    }

    private static void bewegeSchlange(Point schlangePosition, Point spielerposition) {
        if (spielerposition.x < schlangePosition.x)
            schlangePosition.x--;
        else if (spielerposition.x > schlangePosition.x) {
            schlangePosition.x++;
            if (spielerposition.x < schlangePosition.x)
                schlangePosition.x--;
            else if (spielerposition.x > schlangePosition.x) {
                schlangePosition.x++;
            }
        }

        private static void bewegespieler (Point spielerposition) {
            Scanner scan = new Scanner(System.in);
            String input = scan.next();
            if (input.equals("w")) {
                if (spielerposition.y > 0)
                    spielerposition.y--;
            } else if (input.equals("s")) {
                if (spielerposition.y < 9)
                    spielerposition.y++;
            } else if (input.equals("a")) {
                if (spielerposition.x > 0)
                    spielerposition.x--;
            } else if (input.equals("d")) {
                if (spielerposition.x < 39)
                    spielerposition.x++;
            }
        }
    }
}```
#

bewegespieler method is not working

proud badge
#

Why use a scanner in a minecraft plugin

#

And a main void

clear elm
#

its not mc plugin just normla jva

#

java

proud badge
#

well this isnt a normal java help server

clear elm
#

i tought some1 can help anyways

lost matrix
clear elm
#

nothing happens error the "bewegespielr method dont works"

#

is there an java help dc?

viral temple
clear elm
#

ok

viral temple
viral temple
clear elm
#

how to learn makng plugins?

hoary spire
#

org.bukkit.plugin.InvalidDescriptionException: Plugin description file is empty or not properly structured. Is nullbut should be a map.

main: com.therobokedi.main
name: testplugin
version: 0.0.1
author: TheROBOKEDi
commands: 
  testcmd: 
    description: test command
    default: true```
rotund ravine
#

default?

#

Ah i see

#

Try passing it through a yaml linter

clear elm
#

what is OOP?

hoary spire
candid rapids
#

I'm making Minecraft Spigot Plugin, and I have a question about event priorities. I made a plug-in that pays coins at a certain probability when destroying blocks, but I use it with a plug-in called WorldGuard, so when you destroy a block in a protected area by WorldGuard, the block is not destroyed, only coins are given and copied. Is there a way to solve this? Below is the code of the plug-in I made.

package io.github.lucystudio.drop.event

import io.github.lucystudio.drop.Main
import org.bukkit.Material
import org.bukkit.block.Block
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.inventory.ItemStack
import java.util.Random

class OnBreak: Listener {

    private fun hasItemDropped(block: Block): Boolean {
        val drops = block.drops
        return drops.isNotEmpty()
    }

    @EventHandler(priority = EventPriority.MONITOR)
    fun onBreak(event: BlockBreakEvent) {
        if (Main.instance.config.getBoolean("enabled")) {
            val block = event.block
            val isFullyGrown = block.blockData.asString.contains("age=7")
            if (block.type == Material.WHEAT || block.type == Material.CARROTS || block.type == Material.POTATOES) {
                if (isFullyGrown && hasItemDropped(block)) {
                    var random: Random?
                    random = Random()
                    random.setSeed(System.currentTimeMillis())
                    var randomNumber: Int = random.nextInt(100)

//                    println(randomNumber)
//                    println(Main.instance.config.getInt("percent"))

                    if (randomNumber < Main.instance.config.getInt("percent")) {
                        val item = Main.instance.config.getItemStack("item") ?: ItemStack(Material.DIAMOND, 1)
                        event.player.inventory.addItem(item)
                        if (Main.instance.config.getString("messages.get_coin") != "false") {
                            event.player.sendMessage(Main.instance.config.getString("messages.prefix").toString() + " " + Main.instance.config.getString("messages.get_coin"))
                        }
                    }
                }
            } else if (block.type == Material.BEETROOTS) {
                val isFullyGrownThree = block.blockData.asString.contains("age=3")
                if (isFullyGrownThree && hasItemDropped(block)) {
                    val random = Random()
                    val randomNumber = random.nextInt(100)

                    if (randomNumber < Main.instance.config.getInt("percent")) {
                        val item = Main.instance.config.getItemStack("item") ?: ItemStack(Material.DIAMOND, 1)
                        event.player.inventory.addItem(item)
                        if (Main.instance.config.getString("messages.get_coin") != "false") {
                            event.player.sendMessage(Main.instance.config.getString("messages.prefix").toString() + " " + Main.instance.config.getString("messages.get_coin"))
                        }
                    }
                }
            }
        }
    }
}
hoary spire
candid rapids
proud badge
#
        List<String> materialList = config.getStringList("noAlertMaterials");

        // Convert the list of material names to an array of Material objects
        GriefAlert3.nonAlertBlocks = new Material[materialList.size()];
        for (int i = 0; i < materialList.size(); i++) {
            GriefAlert3.nonAlertBlocks[i] = Material.matchMaterial(materialList.get(i));
        }

        List<String> placementAlertMaterialList = config.getStringList("placementAlerts");

        // Convert the list of material names to an array of Material objects
        GriefAlert3.placementAlertBlocks = new Material[placementAlertMaterialList.size()];
        for (int i = 0; i < placementAlertMaterialList.size(); i++) {  // Fix here
            GriefAlert3.placementAlertBlocks[i] = Material.matchMaterial(placementAlertMaterialList.get(i));
        }
    }``` For some reason the materialList always gives a nullpointerexception, despite it being in the config.yml
rotund ravine
rotund ravine
#

Also check inside your jar

proud badge
#
  - ACACIA_SAPLING
  - BIRCH_SAPLING
  - DARK_OAK_SAPLING
  - JUNGLE_SAPLING
  - OAK_SAPLING
  - SPRUCE_SAPLING
  - ACACIA_LEAVES
  - BIRCH_LEAVES
  - DARK_OAK_LEAVES
  - JUNGLE_LEAVES
  - OAK_LEAVES
  - SPRUCE_LEAVES
  - GRASS
  - DIRT
  - MYCELIUM
  - PODZOL
  - COARSE_DIRT
  - TALL_GRASS
  - FERN
  - DANDELION
  - POPPY
  - BLUE_ORCHID
  - ALLIUM
  - AZURE_BLUET
  - RED_TULIP
  - ORANGE_TULIP
  - WHITE_TULIP
  - PINK_TULIP
  - OXEYE_DAISY
  - SUNFLOWER
  - LILAC
  - ROSE_BUSH
  - PEONY
  - MELON
  - PUMPKIN
  - VINE
  - WATER_LILY
  - WHEAT
  - CARROTS
  - POTATOES
  - BEETROOTS
  - MELON_STEM
  - PUMPKIN_STEM
  - NETHER_WART
  - COCOA
  - SUGAR_CANE
  - BAMBOO```
#

Interestingly it works when the server starts

#

But not when the config is reloaded

#
    private final GriefAlert3 plugin;

    // Constructor that takes the main plugin instance as a parameter
    public ReloadCommand(GriefAlert3 plugin) {
        // Use the plugin instance to get the configuration
        this.plugin = plugin;
        config = plugin.getConfig();

        // Now you can use this.config to access the configuration
    }```
rotund ravine
#

Check inside hour jar @hoary spire

rotund ravine
proud badge
#

heres the full class

chrome beacon
#

you never actually reload the config... also why is it static

umbral ridge
#

hey I clicked some exclude option in intellij ide by accident for player object, how can i get it back?

astral pilot
#

is there a way to get mob size

proud badge
chrome beacon
#

?di

undone axleBOT
chrome beacon
#

^^

astral pilot
#

well is there a way tho to check if a spawn is a safe location

rotund ravine
proud badge
#

How could I run the reloadConfig() method in a seperate class then?

quaint mantle
#

Hello! I have a problem with ProtocolLib. I'm trying to add a fake player to the tab list and then add it to a scoreboard team.
My issue is, that I cannot add it to a team. The team exists, I also checked for outgoing packets, that are sent by the server, and the format looks exactly the same.
I'm using MC 1.19.4 and the latest version of ProtocolLib.

ProtocolManager protocolManager = Main.getManager();

        PacketContainer playerInfoPacket = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);

        playerInfoPacket.getPlayerInfoActions().write(0, EnumSet.of(
                EnumWrappers.PlayerInfoAction.ADD_PLAYER,
                EnumWrappers.PlayerInfoAction.UPDATE_LISTED,
                EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
                EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
                EnumWrappers.PlayerInfoAction.UPDATE_LATENCY
        ));
        playerInfoPacket.getPlayerInfoDataLists().write(1, List.of(
                new PlayerInfoData(
                        new WrappedGameProfile(UUID.randomUUID(), FRENSOR),
                        0,
                        EnumWrappers.NativeGameMode.CREATIVE,
                        WrappedChatComponent.fromText(FRENSOR)
                )
        ));

        protocolManager.sendServerPacket(player, playerInfoPacket);

        PacketContainer teamUpdatePacket = protocolManager.createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
        teamUpdatePacket.getModifier().write(0, 3);
        teamUpdatePacket.getModifier().write(1, "1mod");
        teamUpdatePacket.getModifier().write(2, List.of(FRENSOR));
        teamUpdatePacket.getModifier().write(3, Optional.empty());

        protocolManager.sendServerPacket(player, teamUpdatePacket);
#

I'm not receiving any errors.

orchid trout
hoary spire
orchid trout
#

?learnjava

undone axleBOT
proud badge
#

What is the best way to save persistent data? (In my case a few HashMaps which contain custom objects)

shadow night
#

Depends on what you are doing I'd say

proud badge
#

I just said, few hashmaps with custom objects

tall dragon
#

that doest say that much

shadow night
#

Well, are you trying to save it into some entity? Is it some data you need globally on the whole server?

proud badge
#

Globally on the server. It's an alert system for staff thats tied to an index

umbral ridge
#

what index

hoary spire
tall dragon
#

yea

#

type stuff

proud badge
#

Numerical

#

1-1000

tall dragon
#

in plugin.yml xd

hoary spire
proud badge
#

I think I'll use SQLite maybe, I'll learn it

umbral ridge
hoary spire
#

src/main/resources/plugin.yml

hazy parrot
proud badge
#

Integer, Object

hazy parrot
#

Why not just List

tall dragon
#

yea so why not a list

proud badge
#

oh yeah

#

i forgor

green plaza
#

Any plugin that fixes shulker box exploits?

chrome beacon
#

anyways this is the wrong place to ask

hoary spire
#

After build, plugin.yml is empty (in jar)

#

How can i fix this?

pulsar monolith
#

How can I sort players in the player list by their rank? For example 1. Owner, 2. Supporter, 3. Normal Player. I tried using teams but it is still being sorted alphabetically

eternal oxide
#

use teams setting the prefix to adjust ordering

#

use invisible color codes to sort

orchid trout
#

it returns null and causes an exception, what do i do?

hazy parrot
#

It would be helpful if you provide a little bit more context

quaint mantle
#

Stack trace?

inner mulch
#

why is player#dropItem() a bool?

clear elm
#

How to learn spigotapi

hazy parrot
undone axleBOT
inner mulch
hazy parrot
#

Returns:
True if item was dropped successfully

clear elm
#

?spigotapi

#

?learn spigot

#

?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 usernames, global display names, and server...
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.

clear elm
#

?commands

astral pilot
#

how do i find a surface for mobs to spawn in (getHighestBlock doesn't seem to be feasible as it can cause mobs to spawn on rooftops)

rotund ravine
#

Chronny

#

Just iterate spaces urself

#

For loops exist

patent quarry
#

Hello everyone, Is there a way to know :

  • when a falling block entity is killed (for exmple sand on a torch) ?
  • or that an item spawned is from a falling block that has been destroyed ?
chrome beacon
#

You can try the EntityDeathEvent or EntityDropItemEvent

hoary spire
#

JanTuck

hoary spire
atomic niche
#

What are some examples of plugins that use XMaterial for materialID support?

tall dragon
atomic niche
#

Have any specific example that is reasonably well coded?

tall dragon
#

not sure what ur asking. ur tryna find out how XMaterial works?

atomic niche
#

Not really, I just want to see something to use as a reference integration.

#

(I recall we had trouble integrating it for some reason or another in the past; want to see how someone else has done it before trying again)

tall dragon
#

well there is really not alot to it

#

i assume you would use this with a config

#

you get an xmaterial like you would with any enum. using valueof

#

then to get the Material, call parseMaterial

#

thats pretty much it

ivory sleet
#

^

tall dragon
#

😂

rotund ravine
#

Thank you

hoary spire
#

JanTuck

hoary spire
serene sigil
#

how to create a plugin folder for my plugin after load?

#

yknow the datafolder

quaint mantle
#

if (!plugin.getDataFolder().exists()) plugin.getDataFolder().mkdir()

serene sigil
#

thx

quaint mantle
#

Forgot semi

serene sigil
#

also i get this exception:

#

java.lang.IllegalArgumentException: Unsupported class file major version 65

serene sigil
quaint mantle
#

Update the maven plugin(s)

#

to latest

serene sigil
#

in pom.xml?

quaint mantle
#

yeah

serene sigil
#

what? the spigot dep?

quaint mantle
#

Nope <build> <plugins> ... </plugins> </build>

mint plover
#

Hello does someone has the Java Doc of spigot 1.20.0 to 1.20.4 ? Thanks in advance !

serene sigil
#

i dont have any maven plugins

#

i only added the spigot dep

hazy parrot
#

You are compiling with newer version of java

#

But using older to run it

serene sigil
#

oh

#

so i should downgrade the compilation version?

hazy parrot
#

Downgrade version for compilation or use new version to run it

eternal oxide
#

source/target version

undone axleBOT
mint plover
remote swallow
#

they're all the same except added methods

mint plover
#

Between these version there was some new features like the TrialSpawner that doesn't exist in Spigot 1.20.0 to 1.20.3

young knoll
#

Correct

#

Because the block only exists in 1.20.3+ experimental datapack

remote swallow
#

old docs arent hosted anywhere offical by spigot and helpchat dont seem to have them so the best you have is checking dates, updating or running buildtools with the --generate-docs flag and check the jars

hoary spire
#

EpicEbic

remote swallow
#

thats my name

hoary spire
#

(in jar)

remote swallow
#

does it have content in ur ide

hoary spire
#

yea

#

plugin.yml is filled

eternal oxide
#

?paste your pom

undone axleBOT
hoary spire
#

ok

eternal oxide
#

src/main/resources is definatelky the location of the plugin.yml you checked is not empty in your project?

hoary spire
#

yea

eternal oxide
#

drop your jar in here

#

you may have to verify

hoary spire
#

Me can send it in dm?

eternal oxide
#

I don't do dms

echo basalt
#

Just verify

hoary spire
#

im verified but me cant send file

eternal oxide
#

type !verify <yournickonspigotforum>

remote swallow
#

leave and rejoin

eternal oxide
#

or ^if truly verified

twin venture
#

Hello , after day's of thinking idecided to use mongodb to store cosmetics data , kits data , and after that i can use it on all servers connected to mongodb

#

but i get a bug ..

#

this is the loadOrSave method :

eternal oxide
#

uh, plugin.txt ?

hoary spire
#

oh

#

im edited it for read easily

#

wait 2s

remote swallow
#

show how ur compiling

eternal oxide
#

ok, close everything you have open which could be messing with yoru build. close all zip programs, text editors

#

run mvn clean package

hoary spire
hoary spire
#

It is being built now. This is the first time I've had this problem. It's weird.

quaint mantle
#

How do you shade something on gradle?

hoary spire
chrome beacon
remote swallow
hoary spire
#

shadowJar

quaint mantle
#

okay let me see if i can figure it out now! thanks!

#

Sorry, im (semi) new to java, and the intelij IDE. how do i change the version of gradle I want a project to use?

#

I need to go from 7.3.3 to 8.x.x

ivory sleet
#

there is this folder

#

its called gradlew I think or just gradle

#

u go in the properties file in that folder and change the version

quaint mantle
#

gradle-wrapper.properties?

chrome beacon
#

You can also just run gradle wrapper --gradle-version 8.5

#

Will update it for you

quaint mantle
#

I dont think i have gradle in my bin

chrome beacon
#

You can use gradlew

dim shore
#

how do i actually send worldguard checks? (I have little to no idea what im doing)

    private void veinMine(Block originBlock, Material material, Player player, int lvl, ItemStack itemStack) {
        RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
        Queue<Block> blocksToCheck = new LinkedList<>();
        Set<Block> visitedBlocks = new HashSet<>();
        int maxSpreading = lvl * 8;

        blocksToCheck.add(originBlock);
        visitedBlocks.add(originBlock);

        boolean creativeMode = player.getGameMode() == GameMode.CREATIVE;
        while ((!blocksToCheck.isEmpty()) &&
                (creativeMode || (itemStack.getDurability() < itemStack.getType().getMaxDurability() && maxSpreading > 0))) {
            Block currentBlock = blocksToCheck.poll();

            if (!creativeMode) {
                itemStack.setDurability((short) (itemStack.getDurability() + 1));
                maxSpreading--;
            }

            if (currentBlock.getType() == originBlock.getType()) {
                for (Block relativeBlock : getAdjacentBlocks(currentBlock, lvl)) {
                    if (!visitedBlocks.contains(relativeBlock) && relativeBlock.getType() == material) {
                        visitedBlocks.add(relativeBlock);
                        if (query.testState(BukkitAdapter.adapt(relativeBlock.getLocation()), WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD)) {
                            relativeBlock.breakNaturally();
                        }
                        blocksToCheck.add(relativeBlock);
                    }
                }
            }
        }
    }

quaint mantle
#

its not setup

#

/in my bin

ivory sleet
remote swallow
#

your project should have a gradlew

chrome beacon
#

Every gradle project should contain a gradlew and gradlew.bat file

remote swallow
#

if not you need to run gradle init

#

it should exist enough to run that from intellij

chrome beacon
#

so just ./gradlew wrapper --gradle-version 8.5 --distribution-type all

#

assuming cwd is project

quaint mantle
#

in the project dir?

chrome beacon
#

yes

quaint mantle
#
At line:1 char:1```
#

yeah

#

did I set something up wrong?

remote swallow
#

is it using powershell or cmd

quaint mantle
#

oh

#

thats powershell

chrome beacon
#

yeah add .bat if you're on windows

#

so gradlew.bat

remote swallow
#

gradlew.bat should work iirc

quaint mantle
#

still no

#

i needa be in cmd?

chrome beacon
#

remove ./

quaint mantle
#

I did

chrome beacon
#

oh well

#

use CMD

#

Powershell being a pain as always

ivory sleet
#

Yeah its pretty dumb

quaint mantle
#

says not recognized still

#

wth

#

thats so weird

ivory sleet
#

well in worst case just change the props file

quaint mantle
#

alright

#

8.5.0?

chrome beacon
#

8.5

quaint mantle
#

alright

chrome beacon
ivory sleet
#

Yeah sadly it doesn’t update those

remote swallow
#

you can run gradle init to get it to update them

#

found that out a few months ago

quaint mantle
#

._.

#

about that

remote swallow
#

do you use intellij?

quaint mantle
#

yeah

remote swallow
#

on the right side of your screen should be a gradle tab

#

open that

#

open the project, go into tasks then setup

#

well build setup

#

then double click init

quaint mantle
#

alright

#

all this and it still is not fixed my error 😔

remote swallow
#

?paste the error

undone axleBOT
quaint mantle
#
[13:44:25 ERROR]: Error occurred while enabling RPG v0.0.1-SNAPSHOT (Is it up to date?)
java.lang.NoClassDefFoundError: com/mongodb/client/MongoClients
        at me.tls.rpg.common.RPG.onEnable(RPG.java:22) ~[RPG-0.0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:190) ~[paper-1.20.4.jar:git-Paper-330]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.4.jar:git-Paper-330]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugin(CraftServer.java:637) ~[paper-1.20.4.jar:git-Paper-330]
        at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugins(CraftServer.java:548) ~[paper-1.20.4.jar:git-Paper-330]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:274) ~[paper-1.20.4.jar:git-Paper-330]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1132) ~[paper-1.20.4.jar:git-Paper-330]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321) ~[paper-1.20.4.jar:git-Paper-330]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException: com.mongodb.client.MongoClients
        at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:197) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:164) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
        ... 11 more
remote swallow
#

open the link, paste, save then send but now send ur build.gradle

ivory sleet
#

And well… relocate probably:>

echo basalt
#

Imagine relocating

#

Just use the bukkit library loader

quaint mantle
#
plugins {
    id 'com.github.johnrengelman.shadow' version '8.1.1'
    id 'java'
}

group = 'me.tls'
version = '0.0.1-SNAPSHOT'

repositories {
    mavenCentral()
    maven {
        name = "papermc-repo"
        url = "https://repo.papermc.io/repository/maven-public/"
    }
    maven {
        name = "sonatype"
        url = "https://oss.sonatype.org/content/groups/public/"
    }
}

jar {
    destinationDirectory.set(file("$rootDir/../../Servers/Paper-1.20/plugins"))
}

dependencies {
    compileOnly "io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT"
    compileOnly 'org.mongodb:mongodb-driver-sync:4.9.0'
    // Implement later ????
    compileOnly 'redis.clients:jedis:5.0.0'
}

def targetJavaVersion = 17
java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}

tasks.withType(JavaCompile).configureEach {
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release = targetJavaVersion
    }
}

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}
ivory sleet
#

Or that yea

versed moss
#

I'm not sure if i am being stupid or something, but what im trying to do is make a plugin which when you leave the server, it spawns a zombie, saying "offline" and when you join, it kills the zombie, However when the player leaves the server, it works fine, the zombie spawns, but when they join, the zombie does not die? does can anyone help me, here is my code:

//Player join snippet
@EventHandler
public void playerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    Entity ent = linkedPlayer.get(player);
    deleteNPC(ent);
}
//spawn NPC snippet
public void spawnNPC(Player player, Location location) {
    Entity npc = Bukkit.getWorld(player.getWorld().getName()).spawnEntity(location,EntityType.ZOMBIE);
    npc.setMetadata("CustomNPC",new FixedMetadataValue(plugin,player));
    Zombie zombieNPC = (Zombie) npc;
    zombieNPC.setAI(false);
    zombieNPC.setCustomName(ChatColor.translateAlternateColorCodes('&',"&7&lOffline &r&7"+player.getName()));
    zombieNPC.setCustomNameVisible(true);
    linkedPlayer.put(player.getName(),npc);
    linkedPlayer_flip.put(npc,player.getName());
}
//Leave snippet
@EventHandler
public void playerLeave(PlayerQuitEvent event) {
    Player player = event.getPlayer();
    Location location = player.getLocation();
    ItemStack[] playerInventoryContents = player.getInventory().getContents();
    inventoryHashMap.put(player.getName(), playerInventoryContents);
    linkedPlayer.remove(player.getName());
    linkedPlayer_flip.remove(linkedPlayer.get(player.getName()));
    spawnNPC(player, location);
}
//Delete NPC Snippet
public void deleteNPC(Entity ent) {
    if(ent.hasMetadata("CustomNPC")){
        if(ent instanceof Zombie){
            Zombie ZombieNPC = (Zombie) ent;
            ZombieNPC.setHealth(0.0);
        }
    }
}
echo basalt
#

?paste for big blocks pls

undone axleBOT
quaint mantle
#

Oop my bad

echo basalt
#

Both of you

remote swallow
#

this should be implementation "org.mongo...."

echo basalt
#

Yeah for things you want to shade change it to implementation

versed moss
#

I'm not sure if i am being stupid or something, but what im trying to do is make a plugin which when you leave the server, it spawns a zombie, saying "offline" and when you join, it kills the zombie, However when the player leaves the server, it works fine, the zombie spawns, but when they join, the zombie does not die? does can anyone help me, here is my code:
https://paste.md-5.net/judizoyude.cs

quaint mantle
#

ok now let me try

versed moss
#

ill try that one second

quaint mantle
#

still the same error

echo basalt
#

Just gradlew build?

quaint mantle
#

Yeah i think

echo basalt
#

Run the shadowJar task instead

quaint mantle
#

ok

#

then build?

echo basalt
#

Just look for it

#

shadowJar builds it for you

quaint mantle
#

or just that

#

ok

#

still same error

remote swallow
versed moss
#

Same thing happend, However, i bug checked it, and for some reason in the HashMap "linkedPlayer", it says that the NPC is null?

echo basalt
remote swallow
#

idk

echo basalt
orchid trout
#

i want to check if the uuid is null in the database, but it throws an exception

echo basalt
#

goddamn it's a busy day today

versed moss
steel swan
#

Hey ! i have this plugin that can use to generate a world
First, the world is created as an only roofed forest, but there are huge patches of water, any way to prevent that?

orchid trout
proud badge
#

what would be something like a HashMap but it can have multiple return values? Like HashMap x list, in my case I insert a username and I want to get returned a list of specific numbers that I can add

echo basalt
echo basalt
#

You're facing an NPE

echo basalt
#

I'd make a wrapper class for the list though

orchid trout
proud badge
#

hmm how could I add a value to that hashmap

orchid trout
echo basalt
#

map.computeIfAbsent(key, (irrelevant) -> new ArrayList<>()).add(...)

quaint mantle
#

OK IT WORKS NOW

#

thanks

#

also how can i change it to build the jar right to my plugins folder?

versed moss
hazy parrot
#

There is also MultiMap, not sure if it's included with spigot tho

minor junco
#

Build -> All Artifcats

echo basalt
#

You're passing the player onJoin

#

and passing the player name onQuit

#

Just think about what you're doing for a second

quaint mantle
#

even using the shadowJar?

echo basalt
#

There is a way to set a build dir on shadowjar but it was annoying iirc

versed moss
echo basalt
quaint mantle
#
shadowJar {
   archiveBaseName.set('shadow')
   archiveClassifier.set('')
   archiveVersion.set('')
}
#

just this?

sterile flicker
#

please help isOnGround is not working as expected [18:47:19 INFO]: [SumeruRTP] 222
[18:47:19 INFO]: [SumeruRTP] 333 the code first teleports and then checks if the player is on the surface, but it returns true even though I have already taken off. I need that when a player falls to the surface, he is deprived of a bow that helps him land, but the bow disappears immediately as soon as the player prescribes / rtp and falls from the sky. I'm making an rtp plugin and I want the /rtp command to display a menu with a choice of two teleportation methods. the usual one and the other one with which the problem arose. The expected behavior of 2 ways of teleportation (clicking on the golden block) is that the player will be teleported high in the sky and will fall, it is desirable that he looks down and falls more slowly and is given a bow for teleportation (I have already done this) and as soon as the player falls and is on the surface, remove this bow from his inventor code: https://pastebin.com/UzVj5K2K

quaint mantle
#

perfect thank you

versed moss
#

do i delete them 2 lines then?

echo basalt
#

facepalm learnjava moment

echo basalt
proud badge
#

responsibleAlerts.computeIfAbsent(player.getName(), (irrelevant) -> new ArrayList<>()).add(alerts.size() - 1);
How I understand, is this will add a new integer alerts.size()-1 in my case, to the list assosiated with the hashmap? And if it doesnt exist yet it will make a new one

echo basalt
#

Pretty much

#

Try and see!

proud badge
#

Ok

sterile flicker
versed moss
young knoll
#

supplyIfAbsent when?

ivory sleet
#

What would that do? lol

echo basalt
young knoll
#

Use a supplier rather than a function

sterile flicker
echo basalt
#

even though the key generic type is a String

ivory sleet
#

there is putIfAbsent iirc

versed moss
#

OH MY GOD

#

I AM SO DUMB

echo basalt
versed moss
#

LOLOLOLOL

ivory sleet
#

but yeah supplyIfAbsent could be nice to lazily populate

echo basalt
versed moss
#

Sorry i have been staring at the same piece of code for about an hour lol

echo basalt
#

Unless you put a shared collection but that'd be immutable

sterile flicker
versed moss
echo basalt
#

I swear projects keep disappearing from my Open Recent tab

young knoll
#

Essentially
map.supplyIfAbsent(key, ArrayList::new).add(0)
rather than
map.computeIfAbsent(key, k -> new ArrayList<>()).add(0)

#

Look at all those saved bytes

leaden imp
#

so me and my friend are wanting to code a spigot plugin for 1.20.4 for making custom gui menus but dont know where to start does anyone have any tips tricks or videos they can send to help us learn

inner mulch
#

7smile7 modern approach to guis

#

a really good ressource

steel swan
#

Anyone has any idea how to generate a waterless world

quaint mantle
ivory sleet
#

Yeah coll its not too dumb of an idea, looks beneficial if you have some heavy resource object

inner mulch
#

do not use yt tuts some of them show a way taht you shouldnt use

#

like comparing titles and stuff

sterile flicker
leaden imp
quaint mantle
#

with a resource pack

inner mulch
#

no he wants api i think to create modern gui's

quaint mantle
#

ah

#

my b

undone axleBOT
inner mulch
#

his request has nothing to do with java bro

young knoll
#

"Yeah coll its not too dumb of an idea"
Dang that's the nicest thing Conclure has ever said to me

#

:p

echo basalt
# sterile flicker is there an example of this?
BoundingBox box = player.getBoundingBox();
Location picked = ...;
Vector direction = new Vector(0, -1, 0);

RayTraceResult result = box.rayTrace(picked.toVector(), direction, direction.length());

if(result == null) {
  // unsafe
  return;
}

Block hitBlock = result.getHitBlock();
...
echo basalt
orchid trout
#

i just figured he doesnt know anything

#

because of how he asked the question

hazy parrot
#

Lol??

orchid trout
#

shpould have probably asked if he did first sorry

quaint mantle
#

yo guys

#

just read about pre mature optimization

#

and lowkey

inner mulch
#

ok

echo basalt
#

btw your issue is that your rs.getString(1) returns null

ivory sleet
quaint mantle
#

i think i gotta stop with all this project structure stuff

echo basalt
#

lmao

echo basalt
#

have you called resultset.next()

#

I don't think so

remote swallow
orchid trout
quaint mantle
#

yeah planning for the future was mentioned

#

in premature

echo basalt
#

Just call it and check your variables

leaden imp
# orchid trout ?learnjava

i know some javascript im more of command block coding been doing that for 7 years just started learning data packs and plug in this year

orchid trout
#

my database is empty

remote swallow
#

javascript will not help in java

echo basalt
#

Do null checks and stuff

remote swallow
#

nor will datapcks or command blocks

leaden imp
#

i know

echo basalt
#

If there is no entry getString will obviously return null thumbsup

leaden imp
#

its a diffrent type of coding

echo basalt
#

We should start opening threads for issues there are always like 2-3 people needing help

echo basalt
#

return a null profile or create one on the spot

versed moss
leaden imp
versed moss
#

alr bet

orchid trout
young knoll
remote swallow
#

choco says no

young knoll
#

Choco eats glue

remote swallow
#

@worldly ingot stop having a gf and get in here we should get to trial a forum channel for like month and see how it goes

steel swan
#

Anyone has any idea how to generate a waterless world please? ive tried everything

echo basalt
hazy parrot
#

Imo forums on discord are for some reason unorganised af

echo basalt
#

They are

#

I'd still recommend opening a thread if there are multiple people asking for help

#

Just to make communication easier

#

it's annoying having to juggle between like 3 people and making sure everyone understands what message is directed to who

steel swan
remote swallow
#

a forum channel would make it more obvious to see new threads

#

bc you like just dont notice them

#

ever

young knoll
#

idk I think they are farily organized

ivory sleet
echo basalt
#

help-development-thread when

remote swallow
#

coll ur a canada

#

find choco

young knoll
echo basalt
#

conclube can you actually pin the start of my good habits message instead of the middle of it

#

I'd rather people see the basics first

ivory sleet
#

wait did I pin the wrong one?

echo basalt
#

you pinned like the middle of it

ivory sleet
#

Im such a troll lol

remote swallow
#

in think theres like 4 messages

ivory sleet
#

Will fix

remote swallow
#

pins **Conclube **pinned a message

#

i was close

ivory sleet
#

lol

young knoll
#

You can change terrain height with a datapack

#

Or you can write an entire custom generator 👀

#

Or try a plugin like Terra

steel swan
young knoll
#

don't think so

waxen plinth
#

I think data packs might be able to make tweaks instead of needing to rewrite everything

echo basalt
#

You can unpin the second one

ivory sleet
#

Did it alr

waxen plinth
#

there's a short list of capabilities that always felt missing from spigot

#

worldgen tweaks was one

echo basalt
#

don't think you did

steel swan
waxen plinth
#

entity behavior was another

#

well it's basically the only option you've got

ivory sleet
#

Wait I pinned multiple middle parts

waxen plinth
#

I don't think plugins can directly change the biome distribution

echo basalt
#

there's literally just 1 start and end

ivory sleet
#

What the fuck was I on when pinning those

young knoll
#

worldgen is a PITA

#

Because of course

#

Registries

remote swallow
#

worldgen is bread

echo basalt
#

It's just a cleverly split message :)

#

and you unpinned it all

#

great job

waxen plinth
#

that looks like a good pin

ivory sleet
waxen plinth
#

lots of good style advice

remote swallow
#

is this gonna be pinned backwards

waxen plinth
#

though I do disagree with the variable names one

steel swan
waxen plinth
#

events called e and players called p is fine imo

ivory sleet
#

Ugh idk, discord on phone is laggy

remote swallow
#

no

#

they are not descript at all

waxen plinth
#

for extremely obvious, common types I really do not mind abbreviating

young knoll
waxen plinth
#

because p just means "the player"

remote swallow
#

not everywhere

steel swan
waxen plinth
#

just like how n is often used for "a number"

echo basalt
#

it can also mean packet

ivory sleet
young knoll
#

Or pufferfish

waxen plinth
#

ok then I'd always type out packet and only abbreviate player

remote swallow
#

or potato

young knoll
echo basalt
#

int x, y, z, i and n can be fine

ivory sleet
#

or well, what’ve been taught enterprise wise

echo basalt
#

I'd still use x, y, z, index and number

waxen plinth
#

I usually use e in my event handlers and p in lambdas that take players

echo basalt
#

That's a you problem

ivory sleet
#

Yeah totally fine

waxen plinth
#

e in event handlers is one I will never change because you reference the event so many times in the handler

echo basalt
#

Well, not really

waxen plinth
#

but in command methods I always do Player sender or CommandSender sender

echo basalt
#

You reference it at the top when getting all the variables you need

waxen plinth
#

I don't make variables to hold fields of the event

echo basalt
waxen plinth
#

I just make repeated get calls, usually

ivory sleet
#

Id say for smaller event handler methods, using e can be fine

echo basalt
#

yeah that's a problem

waxen plinth
ivory sleet
#

But larger ones, event is prob better

lost matrix
waxen plinth
#

the type of the sender depends on if it's a player-only command or not

#

I will always defend event e and single-letter lambda parameters, but everywhere else I tend to type out the full name

echo basalt
waxen plinth
#

like what?

#

nearly all event fields are stored and not computed

echo basalt
#

Yeah that might be applicable for events but for data belonging to players or inventories, no

waxen plinth
#

if I reference a value like 3+ times I'll probably pull it out, but for 2-3 I often just make another get call

echo basalt
#

For example calling Inventory#getHolder returns a new copy in all vanilla implementations

#

and this copies the entire tile entity and all its contents

waxen plinth
#

what? lmao

#

that's funny