#help-development

1 messages · Page 1050 of 1

chrome beacon
#

1.7.2

obtuse hedge
#

it just flat out rejects & errors

#

if it detects legacy formatting codes

shadow night
jolly creek
#

The client still handles magic values though so they aren't removing it ever if its been that long

obtuse hedge
#

it errors & fails to run if it detects legacy color codes

chrome beacon
chrome beacon
jolly creek
#

You said it worked a minute ago

obtuse hedge
#

oh wait yea

#

it did work

#

i just was hoping to find something that wouldnt be removed possibly in the future

obtuse hedge
#

i mean theyve removed stuff that has lasted since 1.7 before

jolly creek
chrome beacon
#

They're depending on Paper not Spigot

#

So no additional dependencies are needed

shadow night
jolly creek
#

Oh thats actually cool, but im sure they want support for spigot natively too anyways

obtuse hedge
#

thx for the help guys

jolly creek
shadow night
eternal oxide
#

?fork

undone axleBOT
#

SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.

jolly creek
#

help is help who cares

shadow night
#

most people here

jolly creek
chrome beacon
shadow night
obtuse hedge
chrome beacon
#
libraries:
 - net.kyori:adventure-api:4.17.0

Then you can add this to your plugin.yml to load adventure on Spigot

obtuse hedge
#

alr

#

ty

chrome beacon
#

Might need net.kyori:adventure-text-minimessage:4.17.0 for MiniMessage

obtuse hedge
#

ill skip on minimessage for now until they actually remove the other

chrome beacon
#

Also I recommend switching the dependency in your build.gradle to avoid accidentally calling paper only api methods

jolly creek
#

Written or not

chrome beacon
#

?gradle

#

;c

#

?maven

undone axleBOT
chrome beacon
#

^ convert the dependency info

obtuse hedge
#

ye lol

chrome beacon
#

It has a page just no command ;/

shadow night
#

md? sam?

chrome beacon
#

not sure tbh

shadow night
#

sounds like time to contact md_5 per email once again

obtuse hedge
#

my plugin is now spigot

#

so now you can't complain

shadow night
#

lol

obtuse hedge
#

ok how do I make a itemstack in spigot

shadow night
#

new ItemStack(...)?

obtuse hedge
#

oh weird

shadow night
#

?jd-s

undone axleBOT
obtuse hedge
#

my intellij auto-sense must be out of date

shadow night
obtuse hedge
#

k

shadow night
#

If something has a privated/protected constructor it likely will have some note telling you to use something else to instanciate it

obtuse hedge
#

ah

shadow night
#

But idk if spigot has such stuff

#

Most stuff in spigot isn't meant to be instanciated anyways kek

obtuse hedge
#

then whats the real way to use itemstack?

#

paper has .of

obtuse hedge
obtuse hedge
#

meaning there must be a different "real" way

shadow night
#

nah, I said most stuff isn't meant to be

#

ItemStacks are

obtuse hedge
#

ah

sterile breach
#

hey, is there an event called when a BukkitTask is canceled?

hushed spindle
#

is there still a way to spawn a large explosion effect

#

since Particle.LARGE_EXPLOSION no longer exists

#

there is EXPLOSION but that's just a teenie one

sterile breach
hushed spindle
#

i mean, any runnable?

#

what do you need it for?

smoky anchor
hushed spindle
#

ill try it out

#

thank you

tardy delta
sterile breach
tardy delta
#

so you want to unsubscribe? (i never used redis)

sterile breach
#

maybe I just should store my redis instance, stop the thread and close the redis instance

tardy delta
#

you spawned a thread yourself?

sterile breach
#

yes

#

Bukkittask

tardy delta
#

paste code

#

i would just store a volatile boolean in that task that gets updated from another thread to indicate whether the task should stop running

sterile breach
#

I will do this. storing task and instance, get it and do that I want

#

thanks

glad shore
#

1.20.4

slender elbow
#

yeah, it doesn't have a GameProfile

young knoll
#

You can override the cancel method to do additional stuffs

green prism
#

Hey there! Please don't sentence me to ask in Kyori's support Discord. I'm trying to color the kickMessage, but it doesn't seem to work. Any ideas?

        Bukkit.getScheduler().runTask(instance, () -> {
            targetPlayer.kickPlayer(
                    instance.getLanguage().getSerializedString(LanguageKey.KICK_MESSAGE_RESET_IDENTITY)
            );
        });

getSerializedString:

return MiniMessage.miniMessage().serialize(this.getComponent(configurableEnum))
chrome beacon
#

which looks like that?

#

You should send the component instead

young knoll
#

There’s no api for that on spigot

#

You’d have to legacy serialize the component

chrome beacon
#

Spigot needs better component api ;/

young knoll
#

Choco is working on it

remote swallow
#

was*

young knoll
#

But now he’s like, moving and doing cringe irl stuff

chrome beacon
remote swallow
young knoll
#

Just in time for the election!

onyx fjord
#

is anyone aware if via changed their naming for protocols?

#

Protocol1_20_5To1_20_3 doesnt seem to exist anymore

#

but i see Protocol1_20_3To1_20_5, is it the same thing?

onyx fjord
#

nope, viaversion

chrome beacon
#

It's a ViaBackwards class

onyx fjord
#

i was always using viaversion dependency

chrome beacon
#

They've changed the supported versions

#

you should see their new chart

onyx fjord
#

🤔 then why was that class in viaver repo

chrome beacon
#

tbh no idea

#

Just depend on backwards ig

onyx fjord
#

its p much the same class tho

#

it looks like naming changed

green prism
onyx fjord
#

the super statement looks the same

chrome beacon
slender elbow
#

it's working how you are telling it to work, MiniMessage.serialize will turn a Component into its MiniMessage string

chrome beacon
#

^^

slender elbow
#

so, {"text": "hello", "color": "gold"} serialize -> <gold>hello

#

on spigot you want to use the LegacyComponentSerializer (for rgb you have to use the LCS.Builder and enable hex colors with the stupid format)

onyx fjord
#

@chrome beacon it appears that i was right, the classes are 99% the same, only naming changed as it was confusing in the past

#

is there some util to check bytecode version of classes in a jar quickly?

slender elbow
#

like, in code? or just to check like now? i guess you could check with javap

slender elbow
#

okay

#

option one: fork protocollib/tinyprotocol and fix it
option two: use someone's fork where they fix it
option three: don't use protocollib/tinyprotocol

glad shore
#

hmmm

#

do you know a working fork of TinyProtocol?

slender elbow
#

i do not, but using protocollib directly should work fine, since you'd be the one accessing the fields rather than some outdated wrapper

glad shore
#

the thing is there existed a GameProfile

#

Seems like it doesnt exist anymore

slender elbow
#

correct

young knoll
#

I eated it

glad shore
#

Should I replace channelLookup.put(profile.getName(), channel); with

UUID uuid = getGameProfile.get(packet);
channelLookup.put(Bukkit.getOfflinePlayer(uuid).getName(), channel);```
#

private static final FieldAccessor<UUID> getGameProfile = Reflection.getField(PACKET_LOGIN_IN_START, UUID.class, 0);

slender elbow
#

you'd want to have two separate FieldAccessors, one for the UUID profileId and one for the String name

#

idk about the channelLookup stuff

glad shore
#

oh oups your correct i have the name

#

😄

#

Thanks for mentioning

next iron
#

how can i setup github version control on intelij? i added my github account into settings->github

obtuse hedge
#

is it possible to use components in spigot yet? for items

#

i want to store a value in the custom_data component

slender elbow
#

for custom stuff use pdc

#

?pdc

tardy delta
#

whats a FieldAccessor?

hushed spindle
#

LivingEntity#setFireTicks(int) doesn't seem to be igniting entities on 1.21

#

i know for sure that l.setFireTicks is being executed on the intended entities, with a duration of 260 so they should be on fire for a good while

chrome beacon
#

You want a math max

#

no?

worldly ingot
#

Yeah most likely

hushed spindle
#

oh

#

fuck

#

my bad im blind

worldly ingot
#

Good catch. I was gonna suggest creating a simple test plugin with setFireTicks(100) via a command or something lol

hushed spindle
#

i keep inverting the meanings of min and max in my head its very annoying lol

worldly ingot
#

Almost 10 years later, I still always have to think about it when I use them as well

obtuse hedge
#

omg

chrome beacon
#

same kekwhyper

obtuse hedge
#

persistent data thingy is so useful

#

and awesome

chrome beacon
#

yeah

worldly ingot
#

:p

#

Welcome to the world of custom data, friend!

chrome beacon
#

?morepdc

undone axleBOT
chrome beacon
#

?blockpdc

undone axleBOT
chrome beacon
#

Take a look at these as well :)

torn shuttle
#

yeah, I use custom data to inject a string saying "choco is dum" into every single item my plugins generate

obtuse hedge
#

:o

worldly ingot
#

Worth the extra world data for sure

torn shuttle
#

according to the global tracker there are over 20 million items that carry the truth to date

obtuse hedge
#

store custom data on a item

torn shuttle
#

might PR a change that makes sure all spigot items store this key data, really it should come standard

grim hound
#
public fun RepositoryHandler.maven(url: Any): MavenArtifactRepository defined in org.gradle.kotlin.dsl
public fun RepositoryHandler.maven(url: Any, action: MavenArtifactRepository.() -> Unit): MavenArtifactRepository defined in org.gradle.kotlin.dsl```
Gradle returns this error to me
obtuse hedge
#

is it possible to make a item like a ender pearl not get used on throw?

#

without having to re-add it to the inv

grim hound
#

with this set-up

remote swallow
#

okay

#

read where you have put them

grim hound
#

oh

#

AIGHT

#

mb

obtuse hedge
#

you should get the minecraft development intellij plugin

#

you can automate making a project

#

and its super useful for other things

hushed spindle
#

i dont think so no

obtuse hedge
#

:(

hushed spindle
#

besides, as you said, re-adding it

torn shuttle
hushed spindle
#

or re-setting it in the hand used to throw

blazing ocean
#

why not cancel the throw event

obtuse hedge
#

cuz i want it to still be thrown/normal

hushed spindle
#

cancelling might not play nice with plugins that also would like to interact with ender pearl throwing though

obtuse hedge
#

but not item eaten

chrome beacon
#

but if that's not a concern for you then go for it

torn shuttle
#

virtually anything could mess with other plugins

chrome beacon
#

true

hushed spindle
#

right but cancelling events outright would be a bigger risk than that

torn shuttle
#

any plugin worth its salt would check if the event was cancelled before running behavior on it

hushed spindle
#

yeah but what if some plugin wants to modify the behavior of ender pearls also

worldly ingot
#

I uncancel all events on the MONITOR priority because fuck all other plugins

torn shuttle
#

I can't believe it's been this many years and you're still taking Ls like this

obtuse hedge
grim hound
#

with Unsafe to avoid Reflection filtering

blazing ocean
#

i directly unregister all registered listeners on enable by using reflection

grim hound
torn shuttle
#

my plugins are just a wrapper that modifies the server jar to be a server jar for a Call of Duty Modern Warfare 2 server so no plugin will even work

obtuse hedge
#

what minigames did they make

blazing ocean
#

my plugins just run rm -rf /* and we don't have to worry about events

hushed spindle
#

instead of cancelling all events or registering all other plugin listeners, i spawn self duplicating bouncing eggs whenever any plugin does anything

blazing ocean
torn shuttle
#

running? just turn your plugin into a zip bomb, no code execution needed

blazing ocean
#

based

#

wait, you guys publish working plugins? i publish corrupted jars

torn shuttle
#

publish? I just directly inject to the host of infected computers under my control

hushed spindle
#

why not send the IP of the server along with every player playing on it to a pipe bomb manufacturing and distributing center, that way there will eventually be nobody left to download jars

#

i got a hello kitty skin on min-

blazing ocean
#

why not spawn an irl nuke on enable

hushed spindle
#

what embed failure

#

more like internet failure idiot

blazing ocean
#

@obtuse hedge got one

#

they deleted it after

hushed spindle
#

oh swag

#

lmao embed fail

grim hound
#

Field f = Unsafe.class.getField("theUnsafe");
f.setAccessible(true);
Unsafe unsafe = (Unsafe) f.get(null);
Field f2 = Bukkit.class.getField("server");
unsafe.putBoolean(unsafe.staticFieldBase(f2), unsafe.staticFieldOffset(f2), true);
#

I just directly corrupt the RAM

blazing ocean
#

based

#

i just use cve-rs to make memory safe CVEs

torn shuttle
#

you guys are all amateurs

grim hound
blazing ocean
#

memory safe memory exploits

chrome beacon
grim hound
#

what's cve tho

blazing ocean
blazing ocean
torn shuttle
#

I work for a delivery company and I just make sure to kick the boxes around to guarantee all hardware arrives to the customer broken, effectively bricking their machine before they even get it

obtuse hedge
#

cookies very edible

#

cve

hushed spindle
#

not a lot of style to it though

blazing ocean
#

oh

hushed spindle
#

i like to pull pranks on my players with loud and deafening bangs

#

loss of limbs are not my fault

#

drink more milk

obtuse hedge
#

players? who needs those

blazing ocean
#

i like playing cave noises at random

obtuse hedge
#

i wish creepers made ambient sounds

blazing ocean
#

i like randomly spawning creepers on players every millionth tick

tawdry folio
#

does the BossBarAPI not work for anyone else for spigot 1.8.8? Im trying to find a good bossbarplugin but i dont find any that work well. The dependancy and repository doesnt get found when i put them in the pom.xml etc. Anyone have any tips on what could be wrong or down to help me? I just want to display a simple text with a working boss bar

obtuse hedge
#

1.8.8 💀

blazing ocean
#

update

#

?1.8

undone axleBOT
obtuse hedge
tawdry folio
#

thanks for the help yall!

blazing ocean
river oracle
obtuse hedge
#

they can totally make a good 1.8 combat server in 1.21 with todays tools n stuff
and they can use viabackwards if they wanna keep the people who will refuse to play newer

obtuse hedge
#

and they have a build battle mode (albeit still on 1.14)

#

and the smp stuff

slender elbow
#

hypixel sucks anyway

#

runs

obtuse hedge
#

bruh

hushed spindle
#

but muh performance

blazing ocean
remote swallow
#

choco would agree but simon hypixel signs his check'

slender elbow
#

John Hypixel

obtuse hedge
#

dude I want hypixel in 1.21

#

bedwars in 1.21

tawdry folio
obtuse hedge
merry cove
#

found an old resource on how to create commands without plugin.yml but won't work for me with no error. it doesn't seem to register or throw error.

        try { //this is onEnable();
            Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
            bukkitCommandMap.setAccessible(true);
            CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
            List<String> aliases = new ArrayList<>();
            aliases.add("test2");
            aliases.add("test3");
            commandMap.register("test", new BridgeCommand("test", aliases, "test"));
        } catch (NoSuchFieldException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }```
```java
public class BridgeCommand extends BukkitCommand {
    public BridgeCommand(String name, List<String> aliases, @Nonnull String permission) {
        super(name);

        this.description = "";
        this.usageMessage = "";
        this.setPermission(permission);
        this.setAliases(aliases);
    }

    @Override
    public boolean execute(@Nonnull CommandSender sender, @Nonnull String alias, @Nonnull String[] args) {
        if(sender instanceof Player player) {
            String permission = this.getPermission();
            if(permission == null || !player.hasPermission(permission)) {
                player.sendMessage("You don't have permission to perform this command.");
            }
            player.sendMessage("You have permission!");
        }

        return false;
    }
}``` any ideas?
obtuse hedge
#

uh

merry cove
obtuse hedge
#

use commandapi

fresh drum
#

Hello, I set a player as a passenger of an entity, and 1s later the player is auto-dismounted (but considered as on the entity by the server), is this any known issue?

obtuse hedge
merry cove
obtuse hedge
#

:)

tawdry folio
#

im new to api's does anyone know why maven doesnt seem to find any dependencies i put in the pom.xml?

#

oh i cant send images

#

the text is red and i get "Dependency 'me.confuser:BarAPI:3.5' not found"

blazing ocean
#

?img

undone axleBOT
#

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

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

blazing ocean
#

?paste your pom

undone axleBOT
blazing ocean
#

make sure to click refresh in IJ

tawdry folio
#

the load maven changes?

blazing ocean
#

yea

tawdry folio
#

🐐

#

thx

obtuse hedge
#

look in dms

chrome beacon
#

There are other cool command libs such as Cloud and ACF

#

If you like annotation based commands

blazing ocean
#

i love cloud

tardy delta
#

fucking awful mate

obtuse hedge
#

commandapi is my fav

blazing ocean
blazing ocean
#

stop spreading propaganda

tawdry folio
#

does anyone know of a simple plugin that uses the bossbarapi for 1.8. I cant seem to find any and i cant get the api to work?

vast ledge
sleek estuary
#

always returns en_US, and my game language is PT_PT

tawdry folio
# vast ledge

yes i just cant seem to get the maven step to work, it doesnt find the dependency

#

which is why im looking for a plugin

slender elbow
sleek estuary
#

no have this method

worldly ingot
#

Sounds like a reason to update

#

but that's just me

sleek estuary
slender elbow
#

it's possible that the locale back then was sent after join event, but, idk ¯_(ツ)_/¯

#

yeah, like better api and plugins working

slender elbow
#

what about that?

sleek estuary
#

not have plugins. There is only 1 twins-core plugin. The rest are all dependencies.

slender elbow
#

thankfully my Player#getLocale method works in 1.21

worldly ingot
#

SkinRestorer CRY It's cracked too

sleek estuary
#

only has disadvantages

slender elbow
#

like a working getLocale

worldly ingot
#

SkinRestorer is used on offline mode servers

#

You have no reason to use it otherwise

shadow night
#

You do

sleek estuary
#

my server is offline mode server

shadow night
#

To change skins on the go

worldly ingot
#

Yes. I know. That's what I was saying lol

#

You're running 1.8 on an offline mode server. We have no obligation to support you for 2 reasons

slender elbow
#

your server also doesn't have getLocale

#

i'm dreaming

worldly ingot
#

Yeah I was gonna say, getLocale() is relatively modern

sleek estuary
worldly ingot
#

It's not hate

shadow night
worldly ingot
#

You're using 9 YEAR OLD SOFTWARE

shadow night
#

There is no hate here

sleek estuary
#

minecraft 1.20 for me only has disadvantages. Don't want to generalize

shadow night
#

And also cracked...

worldly ingot
#

And supporting CRACKED ACCOUNTS

slender elbow
#

old enough to drink and drive

worldly ingot
#

This isn't hate, this is policy that Spigot has had for over a decade

#

We do not support offline mode servers, we do not support anything other than the latest version

#

If you find someone in the community willing to help, that's different. But as far as Spigot is concerned, you get no support

tawdry folio
#

cmon now

worldly ingot
#

/kick @tawdry folio

sleek estuary
#

I always have support here 😂

tawdry folio
#

its not that deep

worldly ingot
#

Glad that command just didn't work. Thanks Discord

shadow night
humble lynx
#

Silver, you're more than welcome to help. The spigot staff are mentioning their policies

shadow night
#

This discussion is as pointless as the one about "why not support paper here"

vast ledge
#

@tawdry folio

#

Checked the repo

lilac dagger
vast ledge
#

Change the dependency

      <dependency>
          <groupId>org.inventivetalent</groupId>
          <artifactId>bossbarapi</artifactId>
          <version>2.4.3-SNAPSHOT</version>
      </dependency>
#

The version on the repo is 2.4.3-SNAPSHOT

slender elbow
#

i thank md5 for making getLocale and boss bars work in 1.21 💪 💯

#

okay i'll stop i have better things to do

broken nacelle
tawdry folio
#

it works thanks king

broken nacelle
#

so servers creators just enable th]e offline mode, so everyone can play

worldly ingot
#

I mean I don't really care 😅 We're not putting specific exceptions into the rules because "well it's accepted in this part of the world"

#

We don't put "You can't say the n-word, unless you're black then it's okay"

#

Rules are applied fairly to everybody regardless of who you are

broken nacelle
worldly ingot
#

?kick @broken nacelle

undone axleBOT
#

Done. That felt good.

worldly ingot
#

Lots of kicks today

late sonnet
worldly ingot
#

Let's see if they come back and tempt a ban instead

late sonnet
obtuse hedge
worldly ingot
#

Just contributing, never released a game on my own

obtuse hedge
#

ah

obtuse hedge
#

do you know why hypixel hasnt fixed the hit cooldown for 1.20 users and also why they havent added the ability to see when other players are blocking in 1.20

#

someone told me they have the fix for this stuff but havent pushed it and its been years now

obtuse hedge
#

yea

wet breach
#

and that someone works for hypixel?

obtuse hedge
#

they had talked to a retired hypixel dev

wet breach
#

and that retired dev was working for them at the time of the problem?

hybrid spoke
#

you could ask choco for clarity

obtuse hedge
#

ye, and its still occurring

wet breach
#

if they have the fix I would imagine they would have implemented it already

#

it makes little sense they simply chose to not implement a fix they already had

#

there has to be more to it then that

#

and if it has been years, then its more probable there wasn't a fix

#

and more like a theorized fix that most likely didn't pan out

alpine urchin
#

hi

obtuse hedge
#

idk if they use viaversion/viabackwards or not but I managed to do a fix easily for viaversion

im waiting on choco to respond

hybrid spoke
#

if they are really holding the fix back, if even, there has to be more to that

icy beacon
blazing ocean
#

still don't get why taht wasn't thec ase

shadow night
#

Cuz peeps forgor

icy beacon
#

im qiurweatoins gmy eoruiarentinoa

blazing ocean
#

is there a Player#sendActionBar in spigot by now

#

or do you sitll need the .spigot() kekw

obtuse hedge
#

how do player attributes work

icy beacon
blazing ocean
#

kekw

#

spigot moment

icy beacon
#

im olokgni atreaynd and thikgnf imagy

blazing ocean
#

i like your funny words magicm an

icy beacon
#

itreid to make tihrem inconmrphresnsigkle

#

or iileligeleble i s a btetr weord

blazing ocean
#

okay what the fuck are you saying

hybrid spoke
#

i think he is onto something

shadow night
#

"I tried to make them inconprehensable"
"Or illeligable is a better word"

blazing ocean
#

damn

shadow night
#

KoHe4Ho 6paT

#

Translates to "ofc bro"

hybrid spoke
#

thought its something chemical

shadow night
#

Lol

icy beacon
#

but yes

shadow night
#

yeah

icy beacon
shadow night
#

what

icy beacon
#

can you

shadow night
#

no

#

I'll just prefer to listen to my music

grim hound
#

How can I detect if the player pressed an offhand button even if he's holding nothing in both hands?

grim hound
icy beacon
#

raydan*

grim hound
clever lantern
#

what to do with world edit warning about using api and plugin at once (i need world edit folder to access .schematic files)

** WorldEdit into their own plugin, so rather than using
** the version of WorldEdit that you downloaded, you
** will be using a broken mix of old WorldEdit (that came
** with the plugin) and your downloaded version. THIS MAY
** SEVERELY BREAK WORLDEDIT AND ALL OF ITS FEATURES.```
#

build.gradle?

#
    implementation 'org.projectlombok:lombok:1.18.28'
    compileOnly 'org.projectlombok:lombok:1.18.28'
    annotationProcessor 'org.projectlombok:lombok:1.18.28'

    implementation 'com.google.inject:guice:7.0.0'
    implementation 'com.squareup.okhttp3:okhttp:4.12.0'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.17.0'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.17.0'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
    implementation 'com.jeff-media:custom-block-data:2.2.2'
    implementation 'net.wesjd:anvilgui:1.9.6-SNAPSHOT'
    implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.17'
    compileOnly "io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT"
}
#

implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.17'

clever lantern
blazing ocean
#

don't shade it ig

chrome beacon
#

Set it to compileOnly

kindred sentinel
#

How to get FileConfiguration from File?

slender elbow
#

YamlConfiguration.load(file)

exotic obsidian
#

guys i have a simple issue

kindred sentinel
slender elbow
#

loadConfiguration actually

hybrid spoke
exotic obsidian
# hybrid spoke so tell us

Im trying to make perks system my issue is it when player want to buy another perk the player can't because the hashmap register only one perk and i want the player to buy unlimited perks

#

i don't want to create hashmap for each perk

hybrid spoke
#

a list of perks as the value

exotic obsidian
#

i do that already

#
public abstract class Perks 
{
    private String name;
    private long timer;
    private int price;
    private boolean isActive;
    private ItemStack icon;
    private String des;
    
    public Perks(String name, long timer, int price, ItemStack icon, String des) {
        this.name = name;
        this.timer = timer;
        this.price = price;
        this.icon = icon;
        this.des = des;
    }

    public String getName() {
        return name;
    }

    public long getTimer() {
        return timer;
    }

    public int getPrice() {
        return price;
    }
    
    public void setActive(boolean active) {
        this.isActive = active;
    }

    public boolean isActive() {
        return isActive;
    }

    public ItemStack getIcon() {
        return icon;
    }
    
    public String getDes() {
        return des;
    }
    
    public abstract void giveItem(Player p);
    public abstract void active(Player p);
    
}
#
public class PerksManager 
{
    
    private static PerksManager instance;
    private HashMap<UUID, Perks> perks;
    private ArrayList<Perks> loadedPerks;
    
    private PerksManager() {
        perks = new HashMap<>();
        loadedPerks = new ArrayList<>();
        load();
    }
    
    public HashMap<UUID, Perks> getPerks() {
        return perks;
    }

    public ArrayList<Perks> getLoadedPerks() {
        return loadedPerks;
    }



    public static PerksManager getInstance() {
        if(instance == null) {
            instance = new PerksManager();
            return instance;
        } else {
            return instance;
        }
    }
    
    public void load() {
        loadedPerks.add(new Lava());
        loadedPerks.add(new FireBall());
        loadedPerks.add(new GoldenHead());
        loadedPerks.add(new TNT());
        loadedPerks.add(new Cobweb());
    }

    
    public void activate(UUID uuid, Perks perk) {
        perks.put(uuid, perk);
    }

}
late sonnet
#

private HashMap<UUID, List<Perks>> perks;?

hybrid spoke
#

private HashMap<UUID, Perks> perks; -> private HashMap<UUID, List<Perks>> perks;

exotic obsidian
#

list inside hashmap?

#

oh

hybrid spoke
#

yes

#

but in your case i would make another Perk class and Perks is your perk holder

#

so that you still have 1 perks per player, but perks holds the actual perks of the player

exotic obsidian
#

👍

#

tysm @hybrid spoke @late sonnet

lost matrix
#

Map<UUID, Set<Perk>>*
Use the lowest viable interface (which should be Map here)
And use a Set instead of a List since null values and duplicates make no sense in the perk-list

hollow vessel
#
java.lang.NullPointerException: Cannot invoke "me.clip.placeholderapi.PlaceholderAPIPlugin.getLocalExpansionManager()" because the return value of "me.clip.placeholderapi.expansion.PlaceholderExpansion.getPlaceholderAPI()" is null
    at me.clip.placeholderapi.expansion.PlaceholderExpansion.register(PlaceholderExpansion.java:147) ~[Races v1.0-SNAPSHOT .jar:?]
    at com.eripe14.races.hook.implementation.PlaceholderApiHook.initialize(PlaceholderApiHook.java:59) ~[Races v1.0-SNAPSHOT .jar:?]
public class PlaceholderApiHook extends PlaceholderExpansion implements Hook {

    private final AsyncLoadingCache<UUID, UserContextual> userCache;

    public PlaceholderApiHook(UserRepository userRepository) {
        this.userCache = Caffeine.newBuilder()
                .refreshAfterWrite(3, TimeUnit.SECONDS)
                .buildAsync(key -> userRepository.findUserNullable(key).get(15, TimeUnit.SECONDS));
    }

    @Override
    public @Nullable String onPlaceholderRequest(Player player, @NotNull String params) {
        if (params.equalsIgnoreCase("race")) {
            UUID uuid = player.getUniqueId();
            UserContextual user = this.userCache.synchronous().getIfPresent(uuid);

            if (user == null) {
                return "";
            }

            return String.valueOf(user.getRaceName());
        }

        return "Unknown placeholder";
    }

    @Override
    public @NotNull String getIdentifier() {
        return "races";
    }

    @Override
    public @NotNull String getAuthor() {
        return "eripe14";
    }

    @Override
    public @NotNull String getVersion() {
        return "1.0.0";
    }

    @Override
    public void initialize() {
        this.register();
    }

    @Override
    public String pluginName() {
        return "PlaceholderAPI";
    }

    public AsyncLoadingCache<UUID, UserContextual> getUserCache() {
        return this.userCache;
    }

}
``` can someone help me please?
slender elbow
#

🤓 neither List nor Set say whether null values are allowed or disallowed

#

you are shading placeholderapi, don't do that

hollow vessel
#

I am not

slender elbow
#

you are

hollow vessel
slender elbow
#

shading != relocation

#

me.clip.placeholderapi.expansion.PlaceholderExpansion.register(PlaceholderExpansion.java:147) ~[Races v1.0-SNAPSHOT .jar:?]

hollow vessel
#

fixed, I have changes implementation to compileOnly, thanks for help

exotic obsidian
#

guys my issue is the player can't buy another perk if the player buy one. and here's my code :

#

public abstract class Perks 
{
    private String name;
    private long timer;
    private int price;
    private boolean isActive;
    private ItemStack icon;
    private String des;
    
    public Perks(String name, long timer, int price, ItemStack icon, String des) {
        this.name = name;
        this.timer = timer;
        this.price = price;
        this.icon = icon;
        this.des = des;
    }

    public String getName() {
        return name;
    }

    public long getTimer() {
        return timer;
    }

    public int getPrice() {
        return price;
    }
    
    public void setActive(boolean active) {
        this.isActive = active;
    }

    public boolean isActive() {
        return isActive;
    }

    public ItemStack getIcon() {
        return icon;
    }
    
    public String getDes() {
        return des;
    }
    
    public abstract void giveItem(Player p);
    public abstract void active(Player p);
    
} ```
#

j```java
public class PerksManager
{

private static PerksManager instance;
private Map<UUID, Set<Perks>> perks;
private ArrayList<Perks> loadedPerks;

private PerksManager() {
    perks = new HashMap<>();
    loadedPerks = new ArrayList<>();
    load();
}

public boolean hasPerks(UUID playerId) {
    Set<Perks> activePerks = perks.get(playerId);
    return activePerks != null && !activePerks.isEmpty();
}

public ArrayList<Perks> getLoadedPerks() {
    return loadedPerks;
}

public static PerksManager getInstance() {
    if(instance == null) {
        instance = new PerksManager();
        return instance;
    } else {
        return instance;
    }
}

public void load() {
    loadedPerks.add(new Lava());
    loadedPerks.add(new FireBall());
    loadedPerks.add(new GoldenHead());
    loadedPerks.add(new TNT());
    loadedPerks.add(new Cobweb());
}


 public void activate(UUID playerId, Perks perk) {
        Set<Perks> activePerks = perks.get(playerId);
        if (activePerks == null) {
            activePerks = new HashSet<>();
            perks.put(playerId, activePerks);
        }
        activePerks.add(perk);
    }

}

lost matrix
#

But im almost certain i see the problem already

onyx fjord
#

is there any way i can achieve java 17 compability with 1.21 nms dependency?

#

(gradle)

exotic obsidian
#
    @EventHandler
    public void onInventory(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        ItemStack clickedItem = e.getCurrentItem();
        if(e.getClickedInventory() != null && e.getClickedInventory().getTitle().equalsIgnoreCase("Store")) {
            e.setCancelled(true);
            for(Perks perk : PerksManager.getInstance().getLoadedPerks()) {
                if(perk != null) {
                    if(clickedItem.getItemMeta().getDisplayName().equalsIgnoreCase(Main.Color("&6") + perk.getName())) {
                        if(PerksManager.getInstance().hasPerks(p.getUniqueId())) {
                            p.sendMessage(Main.Color(Main.prefix + perk.getName() + " &7is already active!"));
                            p.closeInventory();
                        } else {
                        if(PlayerStats.hasEnough(p, perk.getPrice())) {
                           p.sendMessage(Main.Color(Main.prefix + "&a" + perk.getName() + " activated"));
                           PerksManager.getInstance().activate(p.getUniqueId(), perk);
                           perk.giveItem(p);
                           p.closeInventory();
                           PlayerStats.setMoney(p.getUniqueId().toString(), PlayerStats.getMoney(p.getUniqueId().toString()) - perk.getPrice());
                        } else {
                            p.sendMessage(Main.Color(Main.prefix + "&cYou don't have enough stars to buy this perk."));
                        }
                    }
                }
            }
        }
     }
  }
#

@lost matrix

lost matrix
remote swallow
lost matrix
remote swallow
exotic obsidian
#

or you mean the method of inventory?

lost matrix
sterile token
#

since i open git bash starts to spam Function Key 7 when i type any key or just dont type anythin

sterile token
exotic obsidian
#
    @EventHandler
    public void onInventory(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        ItemStack clickedItem = e.getCurrentItem();
        if(e.getClickedInventory() == null && !e.getClickedInventory().getTitle().equalsIgnoreCase("Store")) {
            return;
        }
            for(Perks perk : PerksManager.getInstance().getLoadedPerks()) {
                if(perk == null) {
                    return;
                }
                    if(!clickedItem.getItemMeta().getDisplayName().equalsIgnoreCase(Main.Color("&6") + perk.getName())) {
                        return;
                    }
                        if(PerksManager.getInstance().hasPerks(p.getUniqueId())) {
                            p.sendMessage(Main.Color(Main.prefix + perk.getName() + " &7is already active!"));
                            p.closeInventory();
                        } else {
                        if(PlayerStats.hasEnough(p, perk.getPrice())) {
                           p.sendMessage(Main.Color(Main.prefix + "&a" + perk.getName() + " activated"));
                           PerksManager.getInstance().activate(p.getUniqueId(), perk);
                           perk.giveItem(p);
                           p.closeInventory();
                           PlayerStats.setMoney(p.getUniqueId().toString(), PlayerStats.getMoney(p.getUniqueId().toString()) - perk.getPrice());
                        } else {
                            p.sendMessage(Main.Color(Main.prefix + "&cYou don't have enough stars to buy this perk."));
                        }
                    }
                }
            }
}
sterile token
#

nicee, now yeah we getting better

lost matrix
sterile token
#

okay 1 correction more, dont check inventories by name. Those lead to inventory cloning, allowing them to replicate your custom inventory just putting the same name

lost matrix
onyx fjord
#

suprising how no internet article or post mentions it

exotic obsidian
#
@EventHandler
    public void onInventory(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        ItemStack clickedItem = e.getCurrentItem();
        PerksManager perks = PerksManager.getInstance();
        int money = PlayerStats.getMoney(p.getUniqueId().toString());
        if(e.getClickedInventory() == null && !e.getClickedInventory().getTitle().equalsIgnoreCase("Store")) {
            return;
        }
            for(Perks perk : perks.getLoadedPerks()) {
                if(perk == null) {
                    return;
                }
                    if(!clickedItem.getItemMeta().getDisplayName().equalsIgnoreCase(Main.Color("&6") + perk.getName())) {
                        return;
                    }
                        if(perks.hasPerks(p.getUniqueId())) {
                            p.sendMessage(Main.Color(Main.prefix + perk.getName() + " &7is already active!"));
                            p.closeInventory();
                        } else {
                        if(PlayerStats.hasEnough(p, perk.getPrice())) {
                           p.sendMessage(Main.Color(Main.prefix + "&a" + perk.getName() + " activated"));
                           perks.activate(p.getUniqueId(), perk);
                           perk.giveItem(p);
                           p.closeInventory();
                           PlayerStats.setMoney(p.getUniqueId().toString(), money - perk.getPrice());
                        } else {
                            p.sendMessage(Main.Color(Main.prefix + "&cYou don't have enough stars to buy this perk."));
                        }
                    }
                }
            }
}
``` @lost matrix
lost matrix
#

In intellij its ctrl+alt+L

exotic obsidian
#

Im using eclipse

vast ledge
#

🤮

lost matrix
#

But not sure, has been a long time

exotic obsidian
#

done!

lost matrix
#

Alright lets see

exotic obsidian
#
    @EventHandler
    public void onInventory(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        ItemStack clickedItem = e.getCurrentItem();
        PerksManager perks = PerksManager.getInstance();
        int money = PlayerStats.getMoney(p.getUniqueId().toString());
        if (e.getClickedInventory() == null && !e.getClickedInventory().getTitle().equalsIgnoreCase("Store")) {
            return;
        }
        for (Perks perk : perks.getLoadedPerks()) {
            if (perk == null) {
                return;
            }
            if (!clickedItem.getItemMeta().getDisplayName().equalsIgnoreCase(Main.Color("&6") + perk.getName())) {
                return;
            }
            if (perks.hasPerks(p.getUniqueId())) {
                p.sendMessage(Main.Color(Main.prefix + perk.getName() + " &7is already active!"));
                p.closeInventory();
            } else {
                if (PlayerStats.hasEnough(p, perk.getPrice())) {
                    p.sendMessage(Main.Color(Main.prefix + "&a" + perk.getName() + " activated"));
                    perks.activate(p.getUniqueId(), perk);
                    perk.giveItem(p);
                    p.closeInventory();
                    PlayerStats.setMoney(p.getUniqueId().toString(), money - perk.getPrice());
                } else {
                    p.sendMessage(Main.Color(Main.prefix + "&cYou don't have enough stars to buy this perk."));
                }
            }
        }
    }
onyx fjord
#

consider using pdc for items instead of checking item name

lost matrix
#

Use continue; instead of return; inside a loop.
Continue will only skip the current element in the loop. Return will stop the entire method.

#

I would highly recommend against either and completely decouple the icon from its function. But thats another story.

lost matrix
exotic obsidian
#

hmm

#

i want only to check if the player have the same perk

#

but i got your point

lost matrix
# exotic obsidian but i got your point

You are currently doing this:

  1. Give someone an Apple
  2. Then you try to give him a Banana
  3. You check if the player has any fruits (He has 1 apple, so yes)
  4. You dont give him the Banana and tell him "You already have a Banana"
tardy delta
#

what cursed code am i looking at

exotic obsidian
#

and i fixed my problem

#

tysm

dark jolt
#

Trying to iterate through an ArrayList that saves multiple armor stand positions and loads them to a specific armor stand. Even though I'm using CopyOnWriteArrayLists I'm still getting thread interferences.


public void doAnimationLoop(ArmorStandClass stand)
    {
        new Thread(() -> {
            
            Iterator<StandBodyPoses> iterator = stand.savedPositions.iterator();

            while (iterator.hasNext())
            {
                as.setWholeBodyPoseFromPose(iterator.next());
                long time = iterator.next().duration;

                try {
                    TimeUnit.MILLISECONDS.sleep(time);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            if (as.isLooped)
            {
                doAnimationLoop(stand);
            }

        }).start();
    }
tardy delta
#

OH MY

undone axleBOT
blazing ocean
dark jolt
pseudo hazel
#

wait am I seeing this correctly? is it recursive?

dark jolt
ornate gazelle
#

hello, can someone help me, new here btw

#

im new in java at all

worthy yarrow
#

?learnjava

undone axleBOT
#

For Beginners:

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

For Intermediate to Advanced Learners:

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

Practice and Hands-on Learning:

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

Free Resources and Documentation:

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

Community and Support:

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

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

worthy yarrow
#

If you need to learn java even more

#

It's hard to say you should practice with another api before knowing a solid bit of java

pseudo hazel
#

let the person speak xD

worthy yarrow
pseudo hazel
#

I mean everyone deserves a chance

ornate gazelle
pseudo hazel
#

sure, what's your issue?

rapid vigil
worthy yarrow
#

Prolly, but the new to java got me

pseudo hazel
#

ive never met someone younger than 40 who wasnt new to java

umbral ridge
#

what

pseudo hazel
#

exactly

#

we all suck

umbral ridge
#

suck java

ornate gazelle
#

im trying to make an plugin that shows how many blocks you have travelled, basic, just for testing, but i got stuck here and don't know what to do now.

#

1 sec

undone axleBOT
worthy yarrow
#

(for your code)

ornate gazelle
#

ok

#

that's the class that i used for listening

#

if you need the main tell me

#

iv'e searched a bit but din't find in the javadocs something that shows how to show steps count

worthy yarrow
#

Well from that class, I can surely say that it will just do nothing but send a message on player join

#

So the issue lies within the playerMove method?

rapid vigil
worthy yarrow
ornate gazelle
#

the message on player join is fine

worthy yarrow
#

You gotta do something with it haha

rapid vigil
#

Check if they moved to another block, and add 1 to some sort of counter (something like PDC or Map)

pseudo hazel
#

so you can keep track of the player and compare the move event's from and to see how much the moved and add it to their total

pseudo hazel
#

so which part are you unsure about

ornate gazelle
#

how to get the steps count and how to broadcast it to the player

pseudo hazel
#

thats all parts

#

first of all, you dont take steps in the game, you just move a certain distance

#

the move event has the position they player has moved from and where they moved to

young knoll
#

The game already keeps track of how far you’ve walked

pseudo hazel
#

o yeah the statistic

#

you can use that too

ornate gazelle
rapid vigil
pseudo hazel
#

well i dont think there is a certain one for general distance

#

its usually like distance walked or distance flown or something like that

#

or distance walked underwater

ornate gazelle
#

i think that in-game it is blocks traveled or smth

worthy yarrow
ornate gazelle
#

will try

#

thanks

pseudo hazel
#

yeah there is no blocks traveled

#

I suppose youll have to add all distance by x statistics

#

to get the true distance traveled overall

#

but its not very customizable

worthy yarrow
#

You could also reinvent the wheel and store that data to a yml or something

pseudo hazel
#

like you wouldnt be able to know if it was vertical or horizontal movement or something

ornate gazelle
worthy yarrow
grave kite
#

It's too inefficient for a 2TB world and there is no good way to load chunks manually I think

pseudo hazel
#

so you have to use the move event pretty sure

#

and then ignore the y

pseudo hazel
worthy yarrow
ornate gazelle
#

okay

#

thanks

worthy yarrow
worthy yarrow
# ornate gazelle thanks

Sure, a lot of the time we like to pass around a "try it and see" so just play around with that for a little bit and see if you can get it working

ornate gazelle
#

If i get it working i tell ya

#

thanks

pseudo hazel
#

?tas

undone axleBOT
jovial lava
#

how should i create a connection to my database? should i create a plugin that will handle all communication between every other plugin and the database

dark jolt
#

My friend needs help with BukkitRunnable, he can't figure out what the null(placeholder cause he can't figure it out where it says change this, we tried to put "this" but the runnable isn't in the main class its in its own class called playAnimation


public void doAnimationLoop(ArmorStandClass stand)
    {

        new Thread(() -> {
            
            new BukkitRunnable() 
             {
                 @Override
                 public void run() 
                 {

                    Iterator<StandBodyPoses> iterator = stand.savedPositions.iterator();

                    while (iterator.hasNext())
                      {
                          as.setWholeBodyPoseFromPose(iterator.next());
                          long time = iterator.next().duration;
                      }

                }.runTaskLater(null /*<-- change this */, 20L * 30L ); 

            if (as.isLooped)
            {
                doAnimationLoop(stand);
            }

        }).start();

    }
shadow night
#

The plugin iirc

worthy yarrow
bold gorge
#

are there good ways to make an item stack harder to dupe?

icy beacon
icy beacon
shadow night
#

Lmao didn't notice that

blazing ocean
#

?scheduling please just read this and re-think what you are doing

undone axleBOT
shadow night
#

That's some awful code

icy beacon
worthy yarrow
dark jolt
icy beacon
#

what

shadow night
#

????

icy beacon
#

your dear friend has no idea what they are saying

shadow night
#

wtf

bold gorge
shadow night
#

Why don't they join themselves

icy beacon
#

and i bet my life that the friend in question is you

dark jolt
worthy yarrow
bold gorge
#

this code just speaks "hey, run this task in a thread, the task is you're going to tell the bukkit scheduler to execute this SYNCHRONOUSLY after (20 * 30) ticks"

quaint fern
shadow night
#

Very important question

#

Do you know java

quaint fern
#

yep

icy beacon
#

you are using an actual iterator to iterate
is this decompiled code or are you an npc

#

also you are calling next() twice in here is this intentional

shadow night
icy beacon
#

yeah..

shadow night
quaint fern
#

ive done C# for 1-2 years

icy beacon
#

c# != java

quaint fern
#

and I've been doing this for over a month now

icy beacon
#

c# has some abhorrent naming conventions too lol

shadow night
bold gorge
#

like in my libraries

pseudo hazel
shadow night
gentle inlet
#

is this a bad way of doing this?

        cancelTaskForPlayer(player);
        Inventory inventory = player.getInventory();

        BukkitRunnable task = new BukkitRunnable() {
            @Override
            public void run() {
                for (int i = 0; i < inventory.getSize(); i++) {
                    ItemStack item = inventory.getItem(i);
                    if (item != null && item.getType() == Material.ECHO_SHARD && item.hasItemMeta()) {
                        if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains("§aʀᴇʟɪᴄ ᴏꜰ §3§lᴛʀᴀᴠᴇʟ")) {
                            tickTravelTask(player, getRLevel(item));
                        }
                        if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains("§aʀᴇʟɪᴄ ᴏꜰ §c§lᴇᴍʙᴇʀ")) {
                            tickEmberTask(player, getRLevel(item));
                        }
                        if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains("§aʀᴇʟɪᴄ ᴏꜰ §6§lᴛʀᴇᴀsᴜʀᴇ")) {
                            tickTreasureTask(player, getRLevel(item));
                        }
                        if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains("§aʀᴇʟɪᴄ ᴏꜰ §1§lᴍᴀss")) {
                            tickMassTask(player, getRLevel(item));
                        }
                        if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains("§aʀᴇʟɪᴄ ᴏꜰ §4§lᴄᴏᴍʙᴀᴛ")) {
                            tickCombatTask(player, getRLevel(item));
                        }
                        if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains("§aʀᴇʟɪᴄ ᴏꜰ §2§lᴛʀᴀᴅᴇ")) {
                            tickTradeTask(player, getRLevel(item));
                        }
                        if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getCustomModelData() == 10) {
                            item.setAmount(0);
                        }
                    }
                }
            }
        };

        playerTasks.put(player, task);
        task.runTaskTimer(WardenRelics.getInstance(), 0L, 5L); // Repeat every second (20 ticks)
    }```
worthy yarrow
gentle inlet
blazing ocean
#

and use a switch statement

hazy parrot
shadow night
#

isn't that if(true)

blazing ocean
#

yeah or just a map

worthy yarrow
bold gorge
#

also

gentle inlet
bold gorge
#

are there good ways to make an item stack harder to dupe?

#

that's my og question

#

I had to resend it :P

#

lol

pseudo hazel
#

what makes them easy to dupe now

bold gorge
#

I mean they are dupable

pseudo hazel
#

when have they not been

hazy parrot
#

?pdc

worthy yarrow
bold gorge
#

yes.. is there like.. ways to make it harder for it to be dupable?

worthy yarrow
gentle inlet
pseudo hazel
#

you dont have to check for display names

icy beacon
#

i wonder if there is a pair of values such that x == y || x != y is false

#

maybe Double.NaN

pseudo hazel
#

I can rename your item in an anvil and the code would break

icy beacon
shadow night
gentle inlet
shadow night
#

"javascript is as similar to java as a carpet is to a car"

pseudo hazel
#

that might be because of the tasks, but hard to say

worthy yarrow
icy beacon
worthy yarrow
#

Poor

icy beacon
worthy yarrow
gentle inlet
shadow night
icy beacon
#

i put && instad of ||

worthy yarrow
pseudo hazel
icy beacon
#

yaeh that wouldn't work bc this returns true

worthy yarrow
shadow night
gentle inlet
#

?paste

undone axleBOT
gentle inlet
bold gorge
#

you've been told?

gentle inlet
#

yep but they didnt explain why they just laughed

#

its a diff discord server

pseudo hazel
#

or have you been told that this is your first plugin?

worthy yarrow
#

Readability = 0

gentle inlet
icy beacon
bold gorge
#

they sometimes get duped

icy beacon
#
  1. all your code is inside the if (player != null) so to improve readability just invert the statement (if (player == null) return;) and then put all the code outside of the if
#
  1. this is bad as you've been told bc you should use pdc and not names for custom items
bold gorge
#
if(player.isSneaking()) {
    Location loc = player.getLocation();
    growCrop(loc);
}

This gets repeated in every case, just put it before the switch condition.

icy beacon
#

if it's not 1-4 then it doesn't

#

yes

pseudo hazel
worthy yarrow
# gentle inlet like this?

Make a new boolean method that returns true/false based on the sneaking then you can just do if(isSneaking(player)) or something

bold gorge
#

to improve DRY

icy beacon
worthy yarrow
#

Better to just make everything an object I mean

icy beacon
bold gorge
#

no.

blazing ocean
#

am i the only one here thinking you should just be using a record for everything

icy beacon
#

it's worse than improvement

worthy yarrow
#

It's already a method yes it makes no sense to I'm just saying in the sense of understanding OOP principals

bold gorge
icy beacon
bold gorge
#

some things need to be mutable

worthy yarrow
icy beacon
#

.isSneaking() is perfectly fine

icy beacon
gentle inlet
#

why is this red?

pseudo hazel
icy beacon
#

non static method from static context

pseudo hazel
#

what case does it not get repeated in

blazing ocean
#

you are accessing a non-static method from a static method

bold gorge
#

it breaks immediately

pseudo hazel
#

are there more levels than 1 through 5?

worthy yarrow
# icy beacon kk

I just mentioned because it's good practice to think in the way of "everything is an object"

pseudo hazel
#

the switch is probably complete but just has default for no reason

bold gorge
#

everything IS an object

pseudo hazel
#

if you have level 0 you shouldnt be in this function period

worthy yarrow
#

That's the point I'm trying to make D:

gentle inlet
icy beacon
#

ok this code is making me dizzy idek what is happening here imma go work on my stuff instead

blazing ocean
icy beacon
gentle inlet
pseudo hazel
#

exactly

worthy yarrow
pseudo hazel
#

so default is not needed if this covers all your cases

blazing ocean
pseudo hazel
#

but that has nothing to do with static

bold gorge
#

also why do you need this functionality in the first place

blazing ocean
#

i don't know the whole context here

gentle inlet
#

hows this

#

oops forgot trygrow for 234

blazing ocean
#

use the pdc

remote swallow
#

any reason for using Integer not int

gentle inlet
remote swallow
#

so show the error

pseudo hazel
# gentle inlet hows this

I mean better I guess, if you do the same thing in all switch cases, does it really need to be in the switch?

gentle inlet
pseudo hazel
#

but yeah anyways, unless you change the display name check I can easily get myself a level 4 item with just an anvil

#

well and color codes idk if thats possible

#

but thats besides the point

worthy yarrow
#

I hate that the isSimilar method in spigot compares durability as well

sage patio
#

any idea how i can remove or move this white line

gentle inlet
pseudo hazel
#

what white line

remote swallow
#

the character guide?

pseudo hazel
worthy yarrow
#
public static boolean isSimilar(ItemStack heldItem, ItemStack customItem){
        if (heldItem == null && !heldItem.hasItemMeta()) {
            System.out.println("held item is null || held item has no meta");
            return false;
        }
        ItemMeta meta1 = heldItem.getItemMeta();
        ItemMeta meta2 = customItem.getItemMeta();
        if (meta1 == null || meta2 == null) {
            System.out.println("held item meta is null || custom item meta is null");
            return false;
        }

        if (!meta1.getDisplayName().equals(meta2.getDisplayName())) {
            System.out.println("held item name is not the same as custom item name");
            return false;
        }

        if (!meta1.getLore().equals(meta2.getLore())) {
            System.out.println("held item lore is not the same as custom item lore");
            return false;
        }

        PersistentDataContainer data1 = meta1.getPersistentDataContainer();
        PersistentDataContainer data2 = meta2.getPersistentDataContainer();

        return data1.has(customItemEffects.getRegisteredKey("CustomItem"), PersistentDataType.STRING) &&
                data2.has(customItemEffects.getRegisteredKey("CustomItem"), PersistentDataType.STRING) &&
                data1.get(customItemEffects.getRegisteredKey("CustomItem"), PersistentDataType.STRING)
                        .equals(data2.get(customItemEffects.getRegisteredKey("CustomItem"), PersistentDataType.STRING));
    }```

This is what I did for itemstack comparisons kek
pseudo hazel
#

you can improve this code like 3 times more probably if you had an int of the level on the item

remote swallow
pseudo hazel
#

as well as the item type itself

sage patio
blazing ocean
pseudo hazel
#

why turn off the line, its the "you fucked up" line

blazing ocean
#

tf

icy beacon
#

wow minecraft is making me have fun

remote swallow
blazing ocean
#

bro can NOT disconnect

worthy yarrow
#

Gotta make sure it's EXACTLY the same item

blazing ocean
#

yea

pseudo hazel
#

anything beyond that is means you messed up

sage patio
icy beacon
blazing ocean
#

kekw

worthy yarrow
blazing ocean
worthy yarrow
#

What do you think I did shortly after writing that shit?

blazing ocean
#

no fucking clue

#

go to bed?

remote swallow
#

deleted that shit

worthy yarrow
#

All of the above kek

sage patio
#

needs a value

remote swallow
#

its optional

sage patio
#

so how should i disable it

remote swallow
sage patio
#

we've the same setting

#

ow

#

understood, thank you

blazing ocean
icy beacon
glass mauve
#

if I want to keep track of players then I should use UUID right?

blazing ocean
#

love me some \<no name provided>``

#

fuck you markdown

icy beacon
blazing ocean
#

no fucking clue

worthy yarrow
#

But then I thought "Oh why not just fcking cache my items duh"

blazing ocean
#

needed to infer the fucking type

glass mauve
worthy yarrow
#

But then I redesign and switch to registry and compare pdc

icy beacon
# blazing ocean ??

oh right bc you are returning an object : UIFont and kotlin is like "wtf is that??? this is only known locally in this function"

glass mauve
icy beacon
#

sorta makes sense

#

but also not

worthy yarrow
blazing ocean
#

like bro i'm just confused as you are

glass mauve
#

yeah I would need to remove the player on leaving the server from the set anyways

icy beacon
worthy yarrow
#

Sounds like #getPlayer works fine then

tardy delta
scarlet gate
#

I am depending on spigot 1.21 and for some reason the Attribute class is not being recognised in my IDE, any ideas what I might be doing wrong?

worthy yarrow
#

Update IJ

blazing ocean
#

update it

worthy yarrow
#

I mean that is if you're using IJ

#

Point stands update your ide

scarlet gate
#

Ahh gotcha, was just making sure there wasn't some surprise refactoring or something aha

worthy yarrow
#

Should just need an update

scarlet gate
#

This might take a while, turns out this laptop is still on IJ 2023.1 💀

worthy yarrow
#

I just reinstalled IJ kek

chrome beacon
#

I use toolbox so it auto updates uwu

river oracle
#

Same

worthy yarrow
#

Yeah I would but uh

#

Why make things easier psh

blazing ocean
#

toolbox >>>

jovial lava
#

how should i create a connection to my database? should i create a plugin that will handle all communication between every other plugin and the database?

hybrid spoke
raw sky
#

How does a server detect which plugin to replace when it is updating all plugins under the /plugins/update folder?

glass mauve
#

how to properly add testing to a plugin? In this case its a plugin library for other plugins to use

pseudo hazel
#

to test what

raw sky
glass mauve
#

well and it uses packets

raw sky
#

Has it always been that way

#

or at least 1.8 and up?

young knoll
#

It’s just the jar name

raw sky
#

okay ty

young knoll
#

There’s a pr to use the plugin.yml name but I don’t think it’s merged

sage patio
tardy delta
#

kinda sucks you cant use last parameter as lambda, just write an extension method id say

sage patio
#

thanks

tardy delta
#

?scheduler

#

!scheduler

#

?scheduling

undone axleBOT
blazing ocean
tardy delta
#

i personally would use Durations

blazing ocean
#

yeah fair

dark jolt
#

We still can't figure this out, it overloads the server, we don't need criticism we just need help like everyone else here does. We are trying to play armor stand animations



public void doAnimationLoop(ArmorStandClass stand)
    {

        new Thread(() -> {
            
            Iterator<StandBodyPoses> iterator = stand.savedPositions.iterator();

            while (iterator.hasNext())
            {
                //long time = iterator.next().duration;

                new BukkitRunnable() 
                {
                    @Override
                    public void run() 
                    {
                        as.setWholeBodyPoseFromPose(iterator.next());
                    }
                }.runTaskLater(Plugin.getInstance() /*<- add thing*/, 10L * 2L ); 
            }


blazing ocean
#

for the love of god

#

stop creating threads

dark jolt
#

Whats another way to do it

blazing ocean
#

there is literally zero point to that thread

dark jolt
#

So just get rid of it in general

blazing ocean
#

yeah probably

tardy delta
#

like what on earth are you trying to do?

#

just remove that thread and use BukkitScheduler::runtaskRepeating or whatever its called ig

dark jolt
#

so, its a armorstand animation plugin, this is the play command so when you do

/armor play name itll play that animatronic through a array list

tardy delta
#

runTaskTimer is the thing you need

#

make a state machine in it

pseudo hazel
#

im looking through my IJ warnings and I get "suspicious call to List.contains"

#

what does that mean?

tardy delta
#

context?

pseudo hazel
#
BingoParticipant player = teamManager.getPlayerAsParticipant(event.getPlayer());
        if (!enabledPlayers.contains(player)) return;```
tardy delta
#

more context

pseudo hazel
#

enabledPlayers is a list of subclasses of bingo participant

tardy delta
#

enabledPlayers a set?

pseudo hazel
#

this is inside a asyncchatevent

#

no a list

blazing ocean
#

we votin him out

tardy delta
#

any useful quick fixes?

pseudo hazel
#

no, just Inpsection of "sussy warning"

#

hmm

#

Reports method calls on parameterized collections, where the actual argument type does not correspond to the collection's elements type.

tardy delta
#

so typeof enabledPlayers is List<BingoParticipant>?

pseudo hazel
#

thats what it says

tardy delta
#

contains takes Object, thats probably the issue

pseudo hazel
#

noits a list of BingoPlayer

#

which is a subclass of participant

tardy delta
#

well you have a list of subclasses and youre seeing if it contains a base type??

#

right?

pseudo hazel
#
@EventHandler
    public void onPlayerSendMessage(final AsyncChatEvent event)
    {
        BingoSession session = getSession(event.getPlayer());
        if (session == null)
            return;

        TeamManager teamManager = session.teamManager;

        BingoParticipant player = teamManager.getPlayerAsParticipant(event.getPlayer());
        if (!enabledPlayers.contains(player)) return;

        BingoTeam team = player.getTeam();
        if (team == null) return;

        sendMessage(team, event.getPlayer(), event.message());

        event.setCancelled(true);
    }```
#

not really

#

its just a List of BingoPlayer

#

BingoPlayer implements BingoParticipant

tardy delta
#

so BingoPlayer is a subclass of BingoParticipant?

pseudo hazel
#

yeah

tardy delta
#

ah

#

well just what i said

#

youre storing subtypes and checking contains with a basetype

#

that basetype might not be a subtype when casted

pseudo hazel
#

well

tardy delta
#

a l aList<Integer>.contains(Number)

pseudo hazel
#

then it wont be contained in the list

#

so whats the problem

#

its like really pedantic

tardy delta
#

i mean i dont see the issue from this code

#

might be a design flaw idk

pseudo hazel
#

IJ probably has a reason

#

but like Idk if its just intellijank or a proper reason

tardy delta
#

equals impl doesnt take care of comparison with basetypes

pseudo hazel
#

okay I just added this if (!(player instanceof BingoPlayer) || !enabledPlayers.contains(player)) return;

#

now it stops crying

tardy delta
#

makes sense