#help-development

1 messages · Page 984 of 1

rough ibex
#

anyway

#

show your pom

real ridge
buoyant viper
#

LMAOOOOOOOOOO

#

i dont know HOW but i am going to use the term "uniboob" in a sentence one day

rough ibex
#

hm

#

is the project JRE set for 21

real ridge
#

I think so

buoyant viper
#

maybe specialsource doesnt support 21 yet?

#

doesnt sound right tho

#

i almost feel like this plugin can be de-NMS'd

#

intellij wtf do u mean 😭

#

how do u know the dependency but refuse to say its there

#

1.20.6 ?!?!!

#

oh it like bugged out or something bc i ran it for 1.20.5 but 1.20.6 is the actual vers i guess

#

suddenly realizing im too stupid for nms

#

the bare minimum should be running --remapped and then adding the spigot dependency right?!

echo saddle
#

how do i get rid of that annoying chat toast in the upper right everytime i load the client?

buoyant viper
#

forgot to add the code for ALL of these 💀

echo saddle
#

egads

#

so, this new component stuff is a bloody nightmare

#

for example, if you create an itemstack with various flags and lore and such, then give it to a player and then read the itemstack back and try to compare to the original it fails

#

it fails because default values are not in the actual item as far as I can tell

buoyant viper
#

@real ridge is it required that the Gender enum needs the Component and SoundEvent code?

#

(ive been de-NMSing/rewriting the gender plugin for the last hour)

#

a PR is almost ready except for the Gender enum

plucky rock
#

does any1 know how you would go about getting the server's local time

echo saddle
#

just need to get the system time in java, right?

quaint mantle
native nexus
plucky rock
#

yea

#

i got it

plucky rock
quaint mantle
echo saddle
#

Well, i'm stumped. If I create an ItemStack with various flags, and then give that ItemStack to a player, then read that ItemStack back and compare to the original, they will not match

#

Or at least that's what I think is going on

quaint mantle
#

What are you trying to achieve?

#

You could do data containers

sullen marlin
echo saddle
#

Just updating an economy plugin that has custom currency items that are created from information in a config file, then giving them to a user, then when they are read back for deposit, they don't match

#

This is what I'm seeing...

#


item ItemStack{DEAD_BUSH x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"text":"","extra":[{"text":"Gold Coin","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"yellow","bold":false}]}, lore=[{"text":"","extra":[{"text":"This is worth ","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"white","bold":false},{"text":"100x ","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"yellow","bold":false},{"text":"the base currency","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"white","bold":false}]}, {"text":"","extra":[{"text":"Earn more coins from jobs, quests or trading!","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"blue","bold":false}]}], custom-model-data=4, enchants={DURABILITY=10, KNOCKBACK=0}, ItemFlags=[HIDE_ENCHANTS, HIDE_ATTRIBUTES, HIDE_UNBREAKABLE, HIDE_DESTROYS, HIDE_PLACED_ON, HIDE_ADDITIONAL_TOOLTIP]}}: ItemStack{DEAD_BUSH x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"text":"","extra":[{"text":"Gold Coin","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"yellow","bold":false}]}, lore=[{"text":"","extra":[{"text":"This is worth ","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"white","bold":false},{"text":"100x ","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"yellow","bold":false},{"text":"the base currency","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"white","bold":false}]}, {"text":"","extra":[{"text":"Earn more coins from jobs, quests or trading!","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"blue","bold":false}]}], custom-model-data=4, enchants={DURABILITY=10, KNOCKBACK=0}, ItemFlags=[HIDE_ENCHANTS, HIDE_ATTRIBUTES, HIDE_UNBREAKABLE, HIDE_DESTROYS, HIDE_PLACED_ON, HIDE_ADDITIONAL_TOOLTIP]}}```
#

At the bottom, getting all the additional flags that are default I think

#

so they don't match

#

not even with isSimilar

#

Is my presumption correct that the changes are just the default flags?

#

maybe someone else can confirm.

quaint mantle
#

Flags are different ig

echo saddle
#

my understanding is that defaults are different

#

SlicedLime said something about it in the video, I'll have to go watch it again

quaint mantle
#

Just use persistent data container for ez fix

echo saddle
#

well, I could just make a custom serialized id and place it in the itemstack pdc and then check for that to determine if it is a matching currency to allow to deposit...

#

but itemstack matching not working worries me more

sullen marlin
echo saddle
#

I guess we can't assume anymore that an item's itemstack will not be changed from when it is created.

#

I will look into it, time permitting, got to sleep soon and work tomorrow

#

also getting some weird behavior with minecraft:lore and minecraft:custom_name showing up under components under block_entity_data. Not sure if that's my code just failing on this new release or what.

plucky rock
#

is there anything bad in having the same uuid when creating diffrent attribute modifiers?

#

i havent noticed anything bad but i just want to verify

buoyant viper
#

when working directly with Netty, does it need to be shaded?

#

should be a no, right? since the it should be in the classpath when running the server?

#

abt to have a fairly big PR if this works duke @real ridge

nova notch
#

there really is a mod for everything huh

quaint mantle
gilded forge
#

Dependency hasnt updated?

#

Could not resolve all files for configuration ':compileClasspath'.
Could not find org.spigotmcspigot1.20.6-R0.1-SNAPSHOT.

dawn flower
#

how would i create a fake entity for a player and make the player ride that fake entity without being able to dismount

gilded forge
#

I can run with spigot 1.20.5

#

but spigot 1.20.6 is not

remote swallow
#

it should be out on bt

#

one sec

gilded forge
#

ty

remote swallow
#

check your using java 21 for bt, 1.20.6 should be available for it

tender shard
#

however you should use PDC to detect custom items

#

instead of just checking equals(...)

cobalt peak
#

Someone have or know how to do a plugin that recreate the maze of minecraft 1.21 and the wind chard??

#

If you know pls mention me 😄

mellow edge
#

does anyone know what the 2. parameter (boolean) does?
public PacketPlayOutWorldParticles(EnumParticle var1, boolean var2, float var3, float var4, float var5, float var6, float var7, float var8, float var9, int var10, int... var11)

mellow edge
#

I'm in 1.8

#

but still

#

I got the asnwer

polar forge
#

Hey Guys

dawn flower
#
PacketContainer packet = manager.createPacket(PacketType.Play.Server.SPAWN_ENTITY);
packet.getModifier().write(0, entityId)
  .write(1, UUID.randomUUID())
  .write(2, bukkitEntityType.getTypeId())
  .write(3, location.getX())
  .write(4, location.getY())
  .write(5, location.getZ())
  .write(6, location.getPitch())
  .write(7, location.getYaw())
  .write(8, location.getYaw())
  .write(9, null)
  .write(10, 0)
  .write(11, 0)
  .write(12, 0);```
this aint no work
jagged bobcat
#

Umm..? Context?

dawn flower
#

should be self explanatory

#

im trying to spawn a fake entity to the player

jagged bobcat
#

Try sending the packet

dawn flower
#

i sent it

#

nothing happened

#
[11:22:52 ERROR]: #!#! Stack trace:
[11:22:52 ERROR]: #!#! java.lang.IllegalStateException: Unable to set value of field private final net.minecraft.world.entity.EntityTypes net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity.e
[11:22:52 ERROR]: #!#!     at ProtocolLib.jar//com.comphenix.protocol.reflect.accessors.DefaultFieldAccessor.set(DefaultFieldAccessor.java:44)
[11:22:52 ERROR]: #!#!     at ProtocolLib.jar//com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:358)
[11:22:52 ERROR]: #!#!     at ProtocolLib.jar//com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:321)```
polar forge
#

So I was making a ban plugin, and I wanted to store every ban in a yml file, with banner and reason for the ban. It must work even if the player is offline (bans them anyway). I also added that if a player sends the command /banreason <player> it gets the reason out of that yml file. But I’m getting some problems with this yml file I can’t make it work nor generate it in a folder with the bans. Can anyone please look at my code? Thanks guys. https://paste.md-5.net/yajedumapi.java

dawn flower
#

btw dont kick the player on join, use join results

drowsy helm
#

use UUID

dawn flower
#

and use uuid like buoobuoo said

polar forge
#

Or what

dawn flower
#

and is that 2 plugins inside 1 plugin

drowsy helm
#

lol didnt even see that

polar forge
drowsy helm
#

use uuid instead of target.getName()

#

no it's not

dawn flower
#

no its 2 lmfao

drowsy helm
#

you're using 2 JavaPlugins, which is incorrect

#

BanPlugin class should just be standalone command handler

#

no point in it being a JavaPlugin

dawn flower
#

you should implement CommandExecutor for commands not javaplugin

#

why does javaplugin even have onCommand

polar forge
dawn flower
#

make BanPlugin implement CommandExecutor not extend JavaPlugin

ivory gale
#

And register your PlayerJoin listener on the onEnable() method, not on his own constructor (or at least call it somewhere)

dawn flower
polar forge
#

Method does not override method from its superclass

dawn flower
#

wait im confused

#

did you make Permissions class the main class rather than the actual main class

polar forge
#

No BanPlugon was the original main class

drowsy helm
#
        getCommand("banplayer").setExecutor(new BanPlugin(this));
        getCommand("banreason").setExecutor(new BanPlugin(this));```
dawn flower
#

that looks like a command to me

dawn flower
drowsy helm
#

you're only ever supposed to have 1 instance of JavaPlugin

polar forge
#

Ive followed a tutorial online

drowsy helm
#

from who

#

they needa be fired

polar forge
#

From someone on yt

drowsy helm
#

your PErmissions class should be your main class

polar forge
#

But, guys, I now made Permissions the main class

dawn flower
#
    private Permissions plugin;
    public BanPlugin(Permissions plugin) {
        this.plugin = plugin;
    }```
this doesnt look like BanPlugin is the main class
ivory gale
polar forge
#

What should I do now

dawn flower
#

also ur using bukkit's banning system

#

which is already tracked

#

you need to implement ur own banning system

polar forge
dawn flower
#

its abit complicated for temporary bans

#

but for perm bans just make a set

polar forge
#

Yea my server uses only perma bans

#

So it’s not an issue

dawn flower
#
private Set<UUID> permBanned = new HashSet<>();

public void onLogin(PlayerLoginEvent e) {
  if (permBanned.contains(e.getPlayer().getUniqueId())) {
    e.setKickMessage("&cYou're perm banned!");
    e.setResult(PlayerLoginEvent.Result.KICK_OTHER);
  }
}```
#

something like this should work

#

for temporary bans u have to either make a task that countdowns every second (laggy and doesn't countdown when the server is offline) or either store the time the ban will be gone and subtract the current time with that and if the output is 0 or lower then that guy should be unbanned

polar forge
dawn flower
#

not all the code, some code can be used like the ones in the command but you should replace the ban system with that

#

and to ban someone you do permBanned.add(target.getUniqueId());

and to unban u just do the opposite by doing remove

polar forge
#

What should I remove? I’m sorry if I’m asking too much but I really can’t resolve it

dawn flower
#
private Map<UUID, Long> tempBanned = new HashMap<>();

public void onLogin(PlayerLoginEvent e) {
  if (tempBanned.containsKey(e.getPlayer().getUniqueId())) {
    long difference = tempBanned.get(e.getPlayer().getUniqueId()) - System.currentTimeMillis()
    if (difference > 0) {
      e.setKickMessage("&cYou're temp banned for " + difference + " milliseconds!");
      e.setResult(PlayerLoginEvent.Result.KICK_OTHER);
    }
  }
}```
this is how a tempban would work
dawn flower
#

yeah i cant clean the code, its too messy

#

you're prob gonna have to rewrite it with a proper tutorial

#

look at plugins like advancedbans' source code to get an idea of how you're going to do it

polar forge
#

True

#

Too messy

#

I’ll rewrite it

dawn flower
#

how do i make a player ride a fake entity

#

that was if he didnt want temp bans

polar forge
#

Im only making it perma, no temp bans

#

I started over 😭

dawn flower
#

how do i spawn a entity with a saddle through protocollib

dawn flower
#
private List<WrappedWatchableObject> saddledMetadata(org.bukkit.entity.EntityType entityType) {
        WrappedDataWatcher metadata = new WrappedDataWatcher();
        if (entityType == org.bukkit.entity.EntityType.HORSE) {
            metadata.setObject(
                    new WrappedDataWatcher.WrappedDataWatcherObject(
                            17,
                            WrappedDataWatcher.Registry.get(Byte.class)),
                    (byte) 0x04
            );
        } else if (entityType == org.bukkit.entity.EntityType.PIG) {
            metadata.setObject(
                    new WrappedDataWatcher.WrappedDataWatcherObject(
                            17,
                            WrappedDataWatcher.Registry.get(Boolean.class)),
                    true
            );
        } else if (entityType == org.bukkit.entity.EntityType.STRIDER) {
            metadata.setObject(
                    new WrappedDataWatcher.WrappedDataWatcherObject(
                            19,
                            WrappedDataWatcher.Registry.get(Boolean.class)),
                    true
            );
        } else if (entityType == org.bukkit.entity.EntityType.LLAMA) {
            metadata.setObject(
                    new WrappedDataWatcher.WrappedDataWatcherObject(
                            20,
                            WrappedDataWatcher.Registry.get(Integer.class)),
                    14
            );
        }
        return metadata.getWatchableObjects();
    }


packet = manager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
            packet.getWatchableCollectionModifier().write(0, saddledMetadata(bukkitEntityType));
            for (Player player : players) {
                manager.sendServerPacket(player, packet);
            }```



this throws this exception: https://paste.md-5.net/otojucowor.bash
icy beacon
#

gosh

#

?paste for code walls PLEASE

undone axleBOT
dawn flower
wise rock
#

Hello! Anyone has any idea if there is a way to inject a custom DataFixer into the internal code?

dawn flower
#

i don't think it's possible without modifying spigot

ivory sleet
wise rock
#
Schema schema = DataFixers.getDataFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion()));
TaggedChoice.TaggedChoiceType<?> choice = schema.findChoiceType(References.ITEM_STACK);

This is my current code, no idea how to go further

undone axleBOT
dawn flower
#

what slot is the saddle for horse is?

sullen marlin
dawn flower
#

it's for a fake horse using protocollib

sullen marlin
#

you can do per-player entities using Entity#setVisibleByDefault and Player#showEntity

dawn flower
#

no like, i want the entity to not exist server-side as well

#

so if the server suddenly crashes these entities dont just exist

sullen marlin
#

add Entity#setPersistent(false) then

dawn flower
#

oh

#

that kills the entity on restarts?

quaint mantle
#

They are just not serialized on stop

dawn flower
#

doesnt that do the same thing..

ivory sleet
#

@wise rock well I think for starters u prob wna reflect into DFU right? and add ur fixed to the globalList and fixerVersions

you may also want to "recompute" the rules map

(maybe there is a more sophisticated way to deal w it but yea)

eternal oxide
#

not the same

dawn flower
#

either way the entity wont exist when the server restarts

quaint mantle
#

Why serialize an entity that you will kill on start???

dawn flower
#

anyways is there a method to make the entity die when the player leave as well without listeners?

sullen marlin
#

yes

#

Entity#setPersistent(false)

dawn flower
#

?

sullen marlin
#

that's the method

#

?jd-s

undone axleBOT
dawn flower
#

i want to link the entity with a player so when that player leaves the entity dies

sullen marlin
eternal oxide
#

if it doesn;t persist its never saved, so anythign that causes the chunk to unload results in teh entity going poof.

dawn flower
#

idk

sullen marlin
quaint mantle
#

Linked to all players or per player?

dawn flower
quaint mantle
dawn flower
#

also sorry if i'm annoying

sullen marlin
#

Entity#setPersistent(false)

dawn flower
#

oh wait im dumb

eternal oxide
#

viewing players not in range = entity goes poof

quaint mantle
#

PlayerQuitEvent, get the entry of the player and remove the entity, then remove the entry on the map

#

If you want the entity to be removed when the chunk unloads, just setPersistent(false) (I think this is how persistent works)

dawn flower
#

aight

real ridge
buoyant viper
wise rock
# sullen marlin ?xy

I used to write a custom NBT tag "itemsadder" into the root of the ItemStacks.
I want to move the "itemsadder" tag into the "custom_data" since now the root NBT doesn't exists anymore in items.
To do so I had the idea to code a custom DataFixer to let the game handle that, because I doubt there is any other way to intercept items loading and fix that data.

#

Surely this is not available in the API

wise rock
eternal oxide
slender elbow
#

that's like, the whole point of it

wise rock
#

nvm, seems Minecraft is already doing that under the hood, I will have to test: ItemStackComponentizationFix

slender elbow
#

yep

wise rock
#

good news then, thanks a ton

dawn flower
#

Entity#setPersistent(false) doesn't kill the entity if the chunk is unloaded

slender elbow
#

if the chunk is unloaded, so is the entity

#

unless you mean when the chunk is unloaded

#

it isn't killed, no, just removed

#

see EntityRemoveEvent and its Cause

dawn flower
#

so there isnt a way to kill the entity when the chunk is unloaded?

sullen marlin
#

What do you mean kill

dawn flower
#

poof the entity

sullen marlin
#

An entity with setPersistent false will never come back

#

So yes, it go "poof"

dawn flower
#

it comes back for me

#

im not talking abt server restarts, the entity is gone when the server restarts but if i leave (the chunk unloads) and i try to do Entity#remove, it doesn't remove it and setPersistent(false) doest delete it

slender elbow
#

when are you doing setPersistent(false)?

dawn flower
#

when spawning

#

oh wait

#

i got it to work!!11

dawn flower
eternal oxide
#

That jerky is just the client predicting the movement and being reset by the server

dawn flower
#

can i make the horse not go inside

#

i dont want the player turning into a horse

eternal oxide
#

probably disconnect the player from the horse and read steerage packets for it

dawn flower
#

ok

dawn flower
#

what if i just teleport the vehicle to the past location..

dawn flower
#

oh wait u cant cuz it dismounts u, rip

coarse spade
#

Does anyone know how to make text copy-able in chat by clikcing it? I noticed this functionality in the driveBackupV2 pluigin where I could click on the verification code and it would copy it to clipboard, and I want to replicate this functionality in the broadcast coordinates plugin, but I have no idea how it works, I could not find anything.

#

<gold><click:copy_to_clipboard:'<link-code>'><link-code></click></gold>

young knoll
#

Components

mighty gazelle
#

how I can get the speak from the player that joins the server?

lilac dagger
#

components should do it

#

it's a click event feature

buoyant viper
#

ComponentBuilder my beloved

dawn flower
#

whats a good way to teleport an entity with its passengers?

tired star
#

im doing this pvp damage tracker plugin, but im having problems with registering potion damage. everything else seems to work but i cant seem to get the potion thrower's UUID. I need for my calculations. here are some methods I've tried https://paste.md-5.net/aluyegaxoh.java

#

it always goes to the else part that I left there just for my debugging reasons

#

can anyone help with this?

valid burrow
dawn flower
#

u cant tp a passenger nor a vehicle

valid burrow
#

yea u can? 😭 its just an entity

dawn flower
#

u cant 💀

#

u can call the method but it does nothing

shadow night
#

You can't teleport entities with passengers iirc

dawn flower
#

aka a vehicle

valid burrow
#

disbound him then tp

#

and remount

dawn flower
#

the thing is im stopping players from dismounting, ur supposed to be stuck on it.. FOREVER

#

i can kill the entity then respawn antoher one

valid burrow
#

so? Theres million workarounds how you can make your code ignore the dismount for that fraction of time

dawn flower
#

like?

valid burrow
#

like u could give the player some data and on dismount check if they have that data and then ignore

dawn flower
#

good point

valid burrow
#

or you could cache the player in a list and ignore cached players

dawn flower
#

or make a set of uuids to ignore

valid burrow
#

or or or

valid burrow
dawn flower
#

yeah ik

valid burrow
#

but why uuids?

#

just use the player object

#

uuids require way more resources

dawn flower
#

so it doesnt fuck up if the player leaves in that same tick

#

somehow

valid burrow
#

u can just use a try catch

dawn flower
#

genius

valid burrow
#

using uuids is way slower as you need to convert it

#

also

#

offline player object exists

dawn flower
#

👏

valid burrow
#

which u can cast to online player as soon as u need it

dawn flower
#

i wouldnt even need online player object?

valid burrow
#

u can do offlinePlayer.getPlayer

#

will return null if they are offline

#

iirc

#

or throw exception

#

i was hesitant with try catch too when i started with spigot but

#

after a year

#

i realized they are actually very useful

dawn flower
#

#bot-commands

mighty gazelle
#

how I can get the lang from the player that joins the server?

dawn flower
#

the what?

shadow night
#

Wasn't there a way to get their locale

valid burrow
valid burrow
dawn flower
#

that is?

valid burrow
#

and the way to get their local is ip

valid burrow
shadow night
valid burrow
#

there is no way to retrieve what language someone set in their client

valid burrow
shadow night
#

Hmm

#

Still sounds like they want to know the locale

valid burrow
#

well as i said that can be retrieved through IP

shadow night
#

What about

grizzled mason
#

That always return "en_US" 😦

shadow night
#

Oof

valid burrow
grim hound
slender elbow
#

en being the language, us/ca being the localization of it

#

it's called locale because it's localized

#

unless you're telling me de_de isn't german

#

i'd be shocked

acoustic pendant
#

Should i make my own way of pasting schematics or just use world edit?

young knoll
#

Up to you

#

One requires NMS

acoustic pendant
young knoll
#

Parsing them does

acoustic pendant
#

oh

young knoll
#

Well, you could use something like JNBT but you'd still need NMS to handle block entities

acoustic pendant
#

then world edit is probably the way i guess

lilac vector
#

i'm prolly overestimating the performance impact but like how negligable is smth like this
(pseudocode)

fn cacl_level(total_exp: int, levels: List<int>) -> int {
  for (index, level_req) in levels {
    if total_exp < level_rew {
      return index;
    }
  }
}```
running for every player every 10ish ticks (not in the same tick)
#

levels is relatively small about 1000 max

inner mulch
lilac vector
#

and then calculate the level on demand

#

that's the cleanest solution, the next step is to add caching

inner mulch
#

No need to store every 10 ticks

blazing ocean
blazing ocean
chrome beacon
#

it returns what the client language is set to

#

and it does work fine

blazing ocean
#

🤷‍♂️

slender elbow
#

it works fine if you have the client properly configured in your client lol

#

it will also work as long as you aren't using a shitty client that doesn't send that info

#

something something badlion

#

it certainly works with the vanilla client if you change your locale

novel meteor
#
  <repositories>
      <repository>
          <id>spigotmc-repo</id>
          <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
      </repository>

      <repository>
          <id>sonatype</id>
          <url>https://oss.sonatype.org/content/groups/public/</url>
      </repository>
      <repository>
          <id>sk89q-repo</id>
          <url>https://maven.enginehub.org/repo/</url>
      </repository>
  </repositories>

  <dependencies>
      <dependency>
          <groupId>org.spigotmc</groupId>
          <artifactId>spigot-api</artifactId>
          <version>1.20.4-R0.1-SNAPSHOT</version>
          <scope>provided</scope>
      </dependency>
      <dependency>
          <groupId>org.bukkit</groupId>
          <artifactId>bukkit</artifactId>
          <version>1</version>
          <scope>provided</scope>
      </dependency>
      <dependency>
          <groupId>com.sk89q.worldguard</groupId>
          <artifactId>worldguard-bukkit</artifactId>
          <version>7.0.0</version> <!-- Replace with your WorldGuard version -->
          <scope>provided</scope>
      </dependency>
  </dependencies>
</project>
warm mica
novel meteor
#

Can anyone help me figure out how to get the worldguard API, I have tried to follow the docs for it but can't get it to work

slender elbow
warm mica
slender elbow
#

unless you're using a shitty client that isn't vanilla :D but that isn't a Minecraft issue, that's a shitty client issue

novel meteor
#

I know the bukkit dependency doesn't work either, because I can't seem to find the correct version of it for 1.20.4 which is the mc version im on, but the worldguard only seems to show up when the bukkit dependency is there, even though it cant find the bukkit version correctly

warm mica
river oracle
#

?paste

undone axleBOT
novel meteor
novel meteor
#

I restarted my IDE, and now the actual thing for worldguard shows up but not the correct version even though ive double checked on the worldguard site and this is the version to use for 1.20.4

river oracle
#

Ignoring the fact your java version is unsatisfactory for spigot 1.20.4 looks fine

#

Se3ms like intellij being weird

#

Try compiling from the command line with maven

#

If it works it's intellij invalidate your caches

grizzled mason
novel meteor
faint swift
#

When sending a lot of packets should I use a runTaskLaterAsynchronously, to ensure that the client receives packets one at time?

#

Some people in forum told that they were getting kicked out of the server without a runTaskLaterAsync, so the packet would be send after some time

toxic galleon
#

Hello, i am trying to get into plugin development with spigot and wanted to get the .jar-file by building it with the build tool (.exe) but ran into a missing dependency error with maven. Does anyone know how to fix this?

chrome beacon
#

looks like it cached a failure to download a dependency

#

Normally you'd use the -U flag to force it to check again

#

but it might be a bit trickier with BuildTools

#

You can delete the cached org.apache.maven.plugins:maven-compiler-plugin from your local .m2 repo

toxic galleon
#

sorry, I don't really know a lot about maven. Wher can I find this .m2 repo?

quaint mantle
#

C:\Users%username%

toxic galleon
#

shoul I just delete that and run again?

quaint mantle
#

Sure

toxic galleon
#

it seems to have worked this time. I passed the section that didn't work. Thank you very much!

#

Next error:

[INFO] Reactor Summary:
[INFO] 
[INFO] Spigot-API 1.20.4-R0.1-SNAPSHOT .................... SUCCESS [ 21.406 s]
[INFO] Spigot-Parent dev-SNAPSHOT ......................... SUCCESS [  0.011 s]
[INFO] Spigot 1.20.4-R0.1-SNAPSHOT ........................ FAILURE [ 47.095 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:08 min
[INFO] Finished at: 2024-04-30T18:27:19+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.md-5:specialsource-maven-plugin:2.0.2:remap (remap-members) on project spigot: Error creating remapped jar: The following artifacts could not be resolved: org.spigotmc:minecraft-server:csrg:maps-spigot-members:1.20.4-R0.1-SNAPSHOT (absent): Could not find artifact org.spigotmc:minecraft-server:csrg:maps-spigot-members:1.20.4-R0.1-SNAPSHOT in minecraft-libraries (https://libraries.minecraft.net/) -> [Help 1]```
polar forge
#

Hey guys

#

Just a question, they told me to use getUniqueId to ban players instead of using target and players

#

How would I do that?

#

I want to ban online and offline players

#

Doesn’t matter

quaint mantle
#

?

polar forge
#

Maybe lemme rephrase it with more context

#

I’m making a ban plugin, and those banned players must be stored in a .txt file where if I want to check, I could just do /banreason and get the reason for the ban, or do /isplayerbanned and see if the player is effectively banned. So I started over writing the plugin I already made bc it was too messy

#

They told me to use getUniqueId instead of Player player = blah blah blah

#

How would I do it?

quaint mantle
#

Wait, that's wrong

polar forge
quaint mantle
#

Give me a minute

grim hound
#

does anyone here know how to use ByteBuddy?

chrome beacon
#

?ask

undone axleBOT
#

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

grim hound
chrome beacon
#

Most likely

#

This discord has 14k members

quaint mantle
#

I'm guessing this could work

#

Pretty new to this myself

polar forge
grim hound
chrome beacon
grim hound
#

I might be using the class loader

#

I think I see it now

quaint mantle
grim hound
#

don't know how to solve it exactly tho, let's see

quaint mantle
#
Player playerlol = Bukkit.getPlayer(args[0]);
if (playerlol != null) {
    UUID playerUUID = playerlol.getUniqueId();
} else {
// Player is offline
}```
#
 Player playerlol = Bukkit.getPlayer(args[0]);
        if(playerlol != null) {
            playerlol.getUniqueId();
        } else {
            //
        }```
This should work
polar forge
#

I’ll write the code now, if I understood correctly

quaint mantle
#

What exactly are you trying to do?

#

Could we discuss about this in DMs?

polar forge
#

Sure

toxic galleon
quaint mantle
#

Give me a minute, I'll be with you

quaint mantle
toxic galleon
#

I did and it solved the first error I sent, but then this popped up

lilac vector
#

is the player PDC decent enough for data storage?

#

Or should I prefer to opt for custom db

eternal oxide
#

depends on the data

lilac vector
#

Hm?

eternal oxide
#

It depends on what data you want to store and when you need to access it.

lilac vector
#

well the data is stuff like custom player statistics and level etc

#

i'd onyl need ot access it when the player joins the serber

eternal oxide
#

level and statistics already exist. You are creating more?

lilac vector
#

yh

#

it's for custom stuff

#

like keeping track of custom mob kills

eternal oxide
#

then so long as you don;t need it when they are offline, PDC is fine

lilac vector
#

you can't read pdc when the player is off?

eternal oxide
#

no

lilac vector
#

oh shoot

#

ic

toxic galleon
shadow night
eternal oxide
#

You could also turn MC into a space simulator, technically.

shadow night
#

Yeah lol

#

Good idea, I'll write it down

orchid hinge
#

when getting something from config is the second argument the default?

icy beacon
#

Yes, generally

orchid hinge
#

alright

orchid hinge
#

was just asking cuz the names arent exactly explenatory

echo basalt
#

get(String path, Object default)

grim hound
#

Does anyone know what signature I could use?

#

it's ByteBuddy for context

astral jackal
#

Why can't I increase the render distance when I have the paper spigot engine installed? I tried to do it in server propeties, but it doesn't work, and when I change it in the spigot files, after restarting the server, the low render distance setting returns.

remote swallow
#

stop the server, modify settings then start

shadow night
#

PaperSpigot hasn't been a thing for ages

astral jackal
#

but when I restart the server, all the settings I changed return to their initial state and I have a small render distance again

valid burrow
#

change them while its stopped

#

but also yh

astral jackal
#

it doesnt help

valid burrow
#

dont use paper spigot

astral jackal
valid burrow
#

not paper spigot

#

PaperSpigot is outdated and was never good in the first place

remote swallow
#

paper spigot is paper mc

valid burrow
remote swallow
#

no it literally is

valid burrow
#

they changed their name

#

to papermc

#

they arent called paper spigot no more

remote swallow
#

yeah but people knew them from 2012 so still use the oldname

valid burrow
#

people used paper in 2012

#

tragic

quiet ice
#

PaperSpigot is 1.8 paper, afterwards it's just papermc

valid burrow
#

thank you for saying the same thing a third time

quiet ice
#

Well it's still the correct name to referr to 1.8 paper if you need to

grim hound
#

what the fuck

#

is up with bytebuddy

#

I've tested every single syntax

#

and this mfo still says "nah"

quiet ice
#

ByteBuddys strength is its Javaagent

grim hound
#

None of [public static void shadow.systems.interception.AlixEventInterceptor$Interceptor.intercept(java.lang.Object[],java.lang.reflect.Method,java.lang.Object)] allows for delegation from public void net.minecraft.server.players.PlayerList.a(net.minecraft.network.NetworkManager,net.minecraft.server.level.EntityPlayer)

#

like the fuck you mean

quiet ice
#

Where does you plugin need to run on?

grim hound
#

wdym

quiet ice
#

what I'm going after is to suggest the use of ignite or similar bytecode manipulation frameworks

slender elbow
#

no, he is making a regular spigot plugin

#

which lmao

grim hound
slender elbow
#

never used it

grim hound
#

mmm'

dry hazel
#

the question would be what is the xy

#

what are you trying to accomplish with bb

grim hound
quiet ice
#

In that case, what I'd try is to generate a bog standard proxy class via ASM like (this one is for the bukkit unsafe, which is an interface, but the same would apply to all other classes) https://github.com/Geolykt/EnchantmentsPlus/blob/4xx/src/main/java/de/geolykt/enchantments_plus/compatibility/hackloader/Hackloader.java#L83-L180

The idea is that you delegate all public and protected methods to the real implementation and intercept the method you wish to intercept.
The only issue would be package-protected methods though

grim hound
#

and I don't understand anything

#

in the code you just showed me

#

so it's not much of a help

quiet ice
grim hound
#

what would you change?

dry hazel
quiet ice
#

The idea is to generate a class of following layout

class ProxyClass extends ProxiedClass {
  public ProxiedClass x;

  @Override
  public void methodA() {
    x.methodA(); 
  }

  public void interceptMethod() {
    if(!InterceptHandler.handleIntercept()) {
      x.interceptMethod();
    }
  }  
}
grim hound
quiet ice
#

the most important bit is that you don't copy over the internal state of the object but rather forward to the object

grim hound
#

you can spout whatever

#

I still have no idea how to implement that with ASM, ByteBuddy, whatever

#

I don't have any experience using those

#

and the documentation doesn't help

quiet ice
#

I'll try to write some psuedocode then

tranquil glen
#

I have a question guys

#

When making a field inside of a class, is it protected by default?

#

or is it public/private

quiet ice
#

it's package-protected, so neither

grim hound
#

it's package-private

tranquil glen
#

yes

#

i thought package-private was the same as protected

#

what's the difference?

grim hound
#

can access protected

tranquil glen
#

ohhh

quiet ice
#

Yes. package-protected means only accessible in package

grim hound
#

but only classes in the same package

#

can access package private

tranquil glen
#

okay, so if i were to make a new object that inherets it in a different package, it wouldn't be able to access it?

grim hound
#

so package private is less visible

tranquil glen
#

okay cool

#

thank you guys

grim hound
#

👍

chrome beacon
tranquil glen
#

that's super helpful

quiet ice
#

note that nested/inner classes still have access even with private

tranquil glen
#

okay, i figured so

#

can i have an example of a use-case for it?

#

where package-private would be better suited than protected

quiet ice
#

mostly only classes where inheritance isn't a thing anyways

tranquil glen
#

okay, so i'd probably rarely ever have to think about it then

quiet ice
#

However when you talk about usecases then there are only usecases for public but none for other visibility modifiers, so be a bit careful with that train of thought

#

the idea is usually to go with the least access necessary

tranquil glen
#

okay, that makes sense

#

then just use access/modifier methods as necessary

analog mantle
#

How can i see how many downloads a spigotmc resource has?

icy beacon
analog mantle
#

Thanks

nova quail
#

Hello! I have made a plugin where player can spit like llama when he writes /spit. I have also made a GUI where player can choose any additional particle that will spawn with spit to create more effects. I have created SQLite Database which collects info about player's choice. But now when I choose anything in GUI it just gives error's or just choosing "hearts" particles even if I choose anything else. Can somebody help please with database. I had before all data saves in config, but when I moved to database I have this problems.

My code: https://paste.md-5.net/xocijiciyi.java
My errors: https://paste.md-5.net/akofehasem.sql

quiet ice
quiet ice
#

I friggn love ASM. Best invention since sliced bread

grim hound
#

I have no idea how to use it

worthy yarrow
#

Damn ASM became a concept 22 years ago...

grim hound
#

and this is the method

#

(in some versions they don't have the third argument, it's weird)

grim hound
quiet ice
#

My idea and your idea are completely different. What you are intending for is to copy the internal state of the object. While I would proper wrapping the object

trim quest
#

what is the difference between JavaPlugin#saveResource, YamlConfiguration#save

grim hound
#

but because I don't know how I settled on this

chrome beacon
worthy yarrow
#

Could the first be applied to a yaml config? (Not that you would just curious)

trim quest
#

i have custom yml file inside of my src/main/resources folder and im trying to save it to the plugin folder but i guess i made a mistake

public File reloadFile() {
        File file = new File(plugin.getDataFolder(), "custom-heads.yml"); // Initialize the file here
        YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
        try {
            Reader defConfigStream = new InputStreamReader(plugin.getResource("custom-heads.yml"), "UTF8");
            if (defConfigStream != null) {
                YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
                config.setDefaults(defConfig);
                saveFile(config, file);
                return file;
            }
            plugin.getLogger().severe("Failed to reload file: "+"config reader is not defined");
            return null;
        } catch (UnsupportedEncodingException e) {
            plugin.getLogger().severe("Failed to reload file: " + e.getMessage());
            e.printStackTrace();
        }
        return null;
    }

    // tested
    private void saveFile(FileConfiguration fileConfig, File file) {
        if (fileConfig == null || file == null) {
            plugin.getServer().broadcast(ChatColor.RED + "Failed to save file!", "OP");
            return;
        }
        try {
            fileConfig.save(file);
        } catch (IOException e) {
            plugin.getLogger().severe("Failed to save file: " + e.getMessage());
        }
    }
#

maybe im trying to getting resources is which is not defined in java code

#
[21:29:48] [Server thread/ERROR]: Error occurred while enabling MileniumCraft v1.0 (Is it up to date?)
java.lang.NullPointerException: null
        at java.io.Reader.<init>(Reader.java:167) ~[?:?]
        at org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.<init>(InputStreamReader.java:95) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
        at me.erano.com.skull.SkullService.reloadFile(SkullService.java:157) ~[?:?]
        at me.erano.com.skull.SkullService.<init>(SkullService.java:38) ~[?:?]
        at me.erano.com.Plugin.registerServices(Plugin.java:40) ~[?:?]
        at me.erano.com.Plugin.onEnable(Plugin.java:27) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~
        at 
soft spire
#

What is the best ide for Minecraft development? IntelliJ Idea or Eclipse?

eternal night
#

a loaded question KEKW

#

(its IntelliJ)

worthy yarrow
#

IntelliJ, however, an ide is an ide and tbf you only need a notepad to code

soft spire
#

Okay good because that's what I'm using now

worthy yarrow
#

If you use eclipse, you should just hope you know what you're doing 😄

soft spire
#

Can eclipse gifs blind you kekw

icy beacon
#

it's SUBJECTIVE don't even start this discussion yall

grim hound
#

it's better

trim quest
#

nah closing ide for switching project is boring

soft spire
icy beacon
#

this ain't going anywhere

#

bye

worthy yarrow
#

Has anyone got ideas for plugins

#

I'm stuck

grim hound
#

epic items

#

custom mobs

#

but no levels

grim hound
#

maybe even custom generating structures

worthy yarrow
#

I want to do something with a leveling system of sorts

grim hound
#

just do skills

#

and like item ranks

#

I've been thinking about it for a long time

worthy yarrow
#

Levels are fun tho

#

Hmmm

icy beacon
#

make them fun and interesting and fun and

worthy yarrow
#

annnnnd stuff right?

icy beacon
#

and stuff and

#

basically make them not as boring and predictable as they are now

worthy yarrow
#

Some sort of pseudo factions system with a couple twists would be cool

icy beacon
#

i've had the idea of making a raids plugin for a while but never got my hands on it

#

maybe you could do something incredible with this idea

#

i'm talking about village raids btw just in case

worthy yarrow
#

Hmm

#

Well towny already has siegewar but that's pvp, in terms of village raids... what about a fallout style raid where when started, there's an underground vault where you have to go through and clear out enemies, get loot, etc... so in a way it's like a dungeons system

icy beacon
#

in my mind I had something with custom mobs, pathfinding, rewards, etc

#

your idea also sounds cool

worthy yarrow
#

I just know dungeons are kinda hot right now

icy beacon
#

you can build on both of these

polar forge
#

Hi

polar forge
#

Guys could anyone help me? So I’m making a ban plugin, I already made one but I am now implementing/isplayerbanned and /banreason <player> with file txt where these info can be stored and retrieved, I had to delete all my code for this

#

So I’m starting over

#

Someone here suggested me to be able to ban offline and online players, it’s better to use getUniqueId

#

Instead of using Player player = blah blah blah

trim quest
#

java.lang.NullPointerException: null
at org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2146) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils.copy(IOUtils.java:2102) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2123) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils.copy(IOUtils.java:2078) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at me.erano.com.SkullService.loadDefaultFile(SkullService.java:164) ~[?:?]
at me.erano.com.SkullService.<init>(SkullService.java:40) ~[?:?]

public File loadDefaultFile() {
        File file = new File(plugin.getDataFolder()+ File.separator + "custom-heads.yml");
        YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
        if(!file.exists()) {
            saveFile(config, file);
        }
        try {
            InputStream in = plugin.getResource("custom-heads.yml");
            OutputStream out = new FileOutputStream(file);
            IOUtils.copy(in,out);
            out.close();
        }catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (IOException e) {
            e.printStackTrace();
        }
        return file;
        
    }
// tested
    private void saveFile(FileConfiguration fileConfig, File file) {
        if (fileConfig == null || file == null) {
            plugin.getServer().broadcast(ChatColor.RED + "Failed to save file!", "OP");
            return;
        }
        try {
            fileConfig.save(file);
        } catch (IOException e) {
            plugin.getLogger().severe("Failed to save file: " + e.getMessage());
        }
    }
fringe yew
#

when you use .getString() on a config file does it cache at all?

polar forge
#

That’s my question

eternal oxide
#

OfflinePlayer#ban

trim quest
#

anyone can help me

#

i have issue about Spigots Configuration API

fringe yew
polar forge
#

So it must also check if it’s a real username

eternal oxide
#

if you get an offline player by UUID and they do not exist it wil;l have an empty name

#

well I believe it will be null not empty

trim quest
fringe yew
#

thanks

lament tree
#

getString() reads the config file

polar forge
trim quest
#

so

eternal oxide
#

an offline player will always have a UUID

polar forge
#

And what if that offline username doesn’t exist

eternal oxide
#

get an offline player by a uuid who does not exist and they will have a null name

trim quest
#

Embedded resource cannot be found error xD

trim quest
#

there is method named by saveResource on JavaPlugin but its cant read files which is located in src/main/resources

eternal oxide
#

even edited its wrong

polar forge
#

I don’t get it

trail coral
#

can anyone help me with reflection?

im making a custom items plugin and all the items are in seperate classes in one big package. whenever theres a detected use of an item, i have to check if its a custom item. for that i have tk loop thru every file, get their namespacedkey variables and check if the used item matches. so idk how to loop thru the files and idek if thats the most efficient way of doing this

tender shard
#

which version are you on?

eternal oxide
#

Havign a class per item is not a good design

trail coral
#

and if it does do the thing its supposed to do

tender shard
#

you can load the list of keys into a List or Set or whatever in onEnable

trail coral
eternal oxide
#

put all yoru items in a Map using the NamespacedKey, then theres no looping

trail coral
tender shard
#

or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to...

trail coral
#

i just created a CustomItem abstract class

#

that the classes extend

tender shard
#

that's bulllshit

trail coral
#

and loop thru all classes that extend that class

eternal oxide
#

terrible design

tender shard
#

yeah that won't work

trail coral
#

bro

#

whats the best design

tender shard
eternal oxide
#

theres much more flexible and useable design

trail coral
#

CustomItem@is my own class

tender shard
trail coral
#

BRO

#

I GET THAT

#

but to know which item it is

#

i have to check which item PDC it matches with

eternal oxide
#

a Map

tender shard
#

you check which tag it has

trail coral
#

so thats why i need to loop thru the items and get their pdcs

tender shard
#

yes

still ridge
#

hello, what is the difference between AttributeModifier.Operation.ADD_NUMBER and AttributeModifier.Operation.ADD_SCALAR ? (and it's possible to have an explanation of AttributeModifier.Operation.MUTIPLY_SCALAR_1 ?)

eternal oxide
#

if you are checking the item they used you only have ONE item to check

trail coral
eternal oxide
#

not if they are in a Map

tender shard
trail coral
#

but thats way too much work tho

eternal oxide
#

you jut Map#get(key)

#

your way it crazy work and bad design

trail coral
#

so whats the best design if i dont make seperate classes for each item

#

then its gets clustered up

#

cause i have like 20 itsms

tender shard
#

PDC dude, I already told you 12 times

trail coral
#

which its own everything

eternal oxide
#

only 20?

trail coral
eternal oxide
#

PDC

trail coral
#

are you fucking with me

#

im using pdc

#

already

tender shard
#

no

trail coral
#

god damn

#

i have classes

eternal oxide
#

no, you are just not listenign to anyone

tender shard
#

but apparently you're using it wrong

trail coral
#

that have the items' itemstacks

eternal oxide
#

throw them away

trail coral
#

and shit

#

and ehat function theyre doing

eternal oxide
#

your classes are rubbish

trail coral
#

okay so how do i sort them

#

cause thats the cleanest way i can think of

#

when i do it in 1 class the code gets flustered up

eternal oxide
#

create an item builder

trail coral
#

or clustered

trail coral
#

thats also kind of what CUSTOMITEM class is since all items have different functions i didnt know how to make a general builder

#

so i made an abstract class with functions like getItem() getFunction() etc

dawn flower
#

how would i make specific players not see someone else's armor

trail coral
#

idk nms

mortal hare
#

wtf

#

😂

trail coral
#

how do i make an item builder @eternal oxide

eternal oxide
#

add in a PDC tag and you are done

dawn flower
#

an item builder is really not that useful if you don't have custom items

#

unless u want quick items like gui items but that's usually 2 lines and mostly constants like frame which is a black stained glass pane named " "

trail coral
dawn flower
#

ah

dapper flower
#

Does this task run every 20 seconds?

new Task().runTaskTimer(this, 0L, 20L * 20L);
#

or is the max i can put 20L in the period parameter

trail coral
#

no it runs every tick

dapper flower
#

i wasnt to execute smth every 20s

dawn flower
#

that does indeed run every 20 seconds

trail coral
#

oh i didnt see the * 20

dapper flower
#

ok nice

trail coral
#

is there a way to make scheduled events

dapper flower
#

ty

trail coral
#

like i want something to happen every 6PM EST on sunday

#

how do i make that work for example

acoustic pendant
#

Why is Bukkit.getWorlds just retarning me "world" when other worlds are created?

eternal oxide
#

Don;t use the Bukkit scheduler

trail coral
#

yeah

dawn flower
#

tasks arent the way to do that

trail coral
#

i know

#

but whats the correct way

dawn flower
#

actually.. you can use a task for that

trail coral
#

no because what if the server resets

dawn flower
#

a task that runs every second and checks if the current time is 6PM EST

trail coral
#

isnt that unnecessary? i thought there were better ways

dapper flower
#

can't he get the time and calculate when to run the task and then use runLater() ?

trail coral
eternal oxide
dapper flower
#

i mean it gets calculated o nstart

acoustic pendant
#

so it is efficcient

eternal oxide
#

don;t rely on ticks for acurate timing

dapper flower
#

true what if tps is like 9tps

dawn flower
#

but then if the server neevr restarts for 2 days then it only triggers once

dapper flower
#

on trigger you can recalculate too

#

well still half assed

dawn flower
#

oto much calculations

dapper flower
#

literally 2

dawn flower
#

what if u run it for 100 years

trail coral
#

i think the stack overflow page elgar sent is cool but it needs some tweeks in thid case

dapper flower
#

why would yo uneed to run it for 100y XD

dawn flower
#

what if its a nasa server

#

that comuniminiucates with whatever the fuck theyre sending to space

#

that always gets lost

eternal oxide
#

Use the ScheduledExecutorService

dawn flower
#

what in the...

#

it doesnt even have a constructor?

dawn flower
#

wait you can do that with spigot

#

that's sick

young knoll
#

Player#sendEquipmentChange

dawn flower
young knoll
#

You can use the armor equip event library to detect armor changes

dawn flower
#

flippin genius

dawn flower
#

wouldnt cancelling PacketType.Play.Server.ENTITY_EQUIPMENT be easier tho since i wouldnt have to do all that loops and that many event listening

trail coral
#

@eternal oxide I implemented the itembuilder, now how should i organize the seperate items? isnt it better to make classes dedicated to each item?

eternal oxide
#

no

trail coral
#

so how else

#

i dont mean listener classes btw

#

nust like if i have a poison sword a new class like poisonsword.class

#

and so on

#

but thats just the same as before i still need reflection that way

eternal oxide
#

you add a PDC tag, or set of tags to indicate what type of custom weapon it is

trim quest
#

GUYS

#

I FINALLY

#

SOLVED

eternal oxide
#

you create a key for that item

trail coral
eternal oxide
#

store teh item against the key

trail coral
#

i alr use pdc

trim quest
#

solution is :

public File loadDefaultFile() {
        File file = new File(plugin.getDataFolder(), "custom-heads.yml");
        YamlConfiguration config = YamlConfiguration
                .loadConfiguration(new InputStreamReader(plugin.getResource("custom-heads.yml")));
        saveFile(config, file);
        return file;
    }

    // tested
    private void saveFile(FileConfiguration fileConfig, File file) {
        if (fileConfig == null || file == null) {
            plugin.getServer().broadcast(ChatColor.RED + "Failed to save file!", "OP");
            return;
        }
        try {
            fileConfig.save(file);
        } catch (IOException e) {
            plugin.getLogger().severe("Failed to save file: " + e.getMessage());
        }
    }
#

i was understood FileConfiguration is wrong

eternal oxide
#

when someone uses an item, you pull the PDC data, fetch the item from your map and action whatever you need to action

trail coral
#

so i make 1 class where i build each item and add it to a map according to its key

#

and then check that whenever i need to

eternal oxide
#

yes

trail coral
#

thank you

eternal oxide
#

the key itself indicates what item it is, the data you store under that key tells you what functions the item has

trail coral
#

the item

eternal oxide
#

if it were me, I'd make a module system. Where each module performs a specific function. Be it poison, sweeping attacks etc

trail coral
ivory sleet
eternal oxide
#

much easier

trail coral
#

dude theres just one thing i dont understand

#

each item has its own function right

#

so whenever i get which item it is

#

i still have to perform whatever the action it is

#

so here do i store the code for that function

eternal oxide
#

yes, the modules do that

#

you create a poison module

#

a sweep attack module

#

whatever functions you want these items to have

trail coral
#

hm

#

can you help me with the logic for that?

#

like okay i get which modules that item has but then how do i perform the code for that?

eternal oxide
#

then when you pull the value stored in the PDC for that item you find what it needs to do

trail coral
#

different classes for each module and a doAction() or something in each class?

eternal oxide
#

if you stored it as a simple string like "a,b" you read it and know it has to perform a and b functions

#

yes

trail coral
#

so ill create a new package called modules

#

and create classes for each modules

eternal oxide
#

yep

trail coral
#

where ill store all the info including the actions it needs to do

#

and then what

#

i detect which modukes an item has with pdc

#

and then how do i get the actions

#

do i make a module builder for modules aswell?

eternal oxide
#

when you read the PDC string from the item, you invoke the doAction(...) method of the modules it says to use

#

no

#

one module per action

trail coral
#

no?

eternal oxide
#

no

trail coral
#

or do i just add the classes and keys to a map

eternal oxide
#

you add them to a Map

trail coral
#

so ill keep the itembuilder

#

and add a module feature or whatever

#

so i can specify which modules it has

#

snd in detection

#

i dont check for an item

#

i check for modules

#

with pdc

#

and then get the method from the modules' class

#

and perform whatever

eternal oxide
#

yep, you get the modules from the map based upon the PDC value

trail coral
#

that makes so much more sense man

#

thank you

dawn flower
trail coral
#

why is static bad?

eternal oxide
#

you don;t care much about the items themselves, only what they do

trail coral
#

i still have to care about them lowkey because i need to give the items to players with commands or crafting recipes whatever it may be

eternal oxide
#

if you have 100 different actions and you create 1000 items which implement different combinations of those actions. you would have 1000 classes

#

if you only care about the actions, you have 100 always

#

it also makes it simple to move your items into a config so you can create new ones without having to distribute a new jar

dawn flower
#

wouldn't this work?

public class ArmorItems implements ItemType {
  private static void Map<String, ItemStack> armor = new HashMap<>();
  
  @Override
  public static void registerItem(String id, ItemStack item) {
    armor.put(id, item.clone());
  }
  
  @Override
  public static ItemStack getItem(String id) {
    return armor.getOrDefault(id, new ItemStack(Material.AIR));
  }
}```
(itemtype is a custom interface)
trail coral
#

elgar do i store a modules hash map of
class<?> handler, String moduleName?

dawn flower
#

or make a big ass constructor that registers all armor

eternal oxide
trail coral
#

okay thanks and since ill be creating new classes for each module, and i have to register it to a hashmap

echo basalt
#

Also you can't inherit static methods

trail coral
#

to register it to a hashmap the code first has to get executed so how am i gonna execute that code

#

of each class

#

if you know what i mean

eternal oxide
#

you can store an actual instance in the map

echo basalt
#

Well

#

If you're creating an object you have context of it

#

You can register it after fully initializing

#

Wherever you initialize

eternal oxide
#

map.put("poison", new Poison())

trail coral
#

oh alright

#

thanks

eternal oxide
#

a base class of Actions, so Poison extends Actions

trail coral
#

ill try that and get back to you if i have some issues but its 1am and ill probably log off in like 40 mins lmao

trail coral
#

and also

#

im storing the hashmap in a seperate class

#

thats correct right?

eternal oxide
#

you cna store it anywhere thats appropriate

trail coral
#

like a ModulesList class that has the map with all the getters setters etc

eternal oxide
#

yep

trail coral
#

and also a Module class that poison extends

#

?

eternal oxide
#

yep

trail coral
#

what would that module class have tho, like getAction# is one whats another

eternal oxide
#

have a base class which all your Modules extend

trail coral
#

getName#

#

and then what lmao

eternal oxide
#

you could even make it an interface for a cleaner look

trail coral
#

but interface doesnt have like mandatory overrides right

#

you can choose to override something

remote swallow
#

if you add default its optional

#

without its not

trail coral
#

wdym

remote swallow
#

public interface wow {

    String omgwow(); // this is a required method

    String woah() default { // this is not required
        return "sus";
    }
}```
trail coral
#

oh thanks

#

how do i implement levels? like level 1 enchant level 2 enchant because I cant really store that in that hashmap

eternal oxide
#

that would be item specific

#

so thats data you store in the PDC and pass to yrou Module as required

trail coral
#

so new Poison(Integer EnchantLevel)

#

something like that?

eternal oxide
#

yep

trail coral
#

but what do i add to the hashmap then because i cant add an enchant level that would mean adding a new module for each level

eternal oxide
#

however you'd probably just pass the pdc data/item into the module and let teh module pull that info

dawn flower
#

how do i listen for when a player becomes visible or invisible

eternal oxide
#

In your module you do the different power depending on level

trail coral
#

okay so I created a Module interface, a ModulesList class and a poison class that implements module

#

now i add it to the modules list

#

and then do some listener stuff

#

i still didnt get how to do the levels but whatever lmao

#

i think its too late rn my brain is shut off

tranquil glen
#

wait

#

oh nvm im thinking of abstract classes

#

wait

#

idk, i have enough trouble with interface vs abstract class

young knoll
#

You can only extend one abstract class, but you can implement multiple interfaces

#

Also no instance variables in interfaces

tranquil glen
#

i get that, but why not just use interfaces and never use abstract classes if its that simple?

young knoll
#

Well then you can’t enforce a certain constructor for example

tranquil glen
#

(not trying to sound argumentative, just curious)

young knoll
#

Interfaces also don’t have those

tranquil glen
#

ohh okay yeah i didnt think of that

young knoll
#

I have a somewhat particular requirement
I need a random number between two bounds, both inclusive, with a specific number of decimal points

#

And I can’t think of a clean way to do it

brave ice
#

hello, where is situated the class concerning hit and block in spigot 1.8.8 please ? Thanks

tranquil glen
warm mica
young knoll
#

lol, preferably not doing a ton of math

#

Or weird stuff to truncate decimal places

tranquil glen
#

maybe something with BigDecimal and RoundingMode?

young knoll
#

Mmm, could work but creating a BigDecimal object doesn’t seem ideal

brave ice
glass raven
#

hello, is it possible to edit a offline player’s inventory?

vast ledge
#

offlinePlayer#getPlayer()#getInventory()

#

jsut make sure the player exists before accessing that

young knoll
#

That won’t work if they aren’t online

vast ledge
#

You should still be able to access there playerdata tho

ivory sleet
vast ledge
ivory sleet
#

If thats not too unclean

glass raven
#

how can i make the inventory update once player gets online?

vast ledge
#

You should just be able to encode your changes and write them to the file, which should update it automatically

young knoll
#

Just gotta make sure the decimal can be 0-1 instead of 0-.99999

vast ledge
#

Skill 💯

young knoll
#

I think I can just do nextDouble(1 + double min value)

#

Ah wait you said gen the decimal as an int too and then divide

#

Yah that’s smort

remote swallow