#help-development

1 messages · Page 132 of 1

rotund pond
#

Aaah no, I just needed the link of a topic saying why getInstance is a bad practice for JavaPlugin
A friend asked me this link and I couldn't find it

And I'm asking it in #help-development because it's about development obviously

odd wedge
#

Why do people blindly hate on singletons

odd wedge
#

Not always bad

delicate lynx
#

dependency injection is used everyone in other projects, that's why I like to use it instead

twilit roost
#

yep works now
thx

tender shard
#

di

delicate lynx
#

it's a standard that major companies use

tender shard
#

?di

undone axleBOT
odd wedge
fluid river
#

static import version doesn't require getter)

#

so it's smaller

rotund pond
fluid river
#
private static MainClass instance;

public void onEnable() {
    instance = this;
}```

```java
import static me.cringedeveloper.cringeplugin.MainClass.instance;

public class Cringe implements Listener {
    @EventHandler
    public void onCringe(PlayerCringeEvent event) {
        instance.getServer().broadcastMessage(event.getCringe());
    }
}```
thorny marsh
#

Hey i am trying to sendSignChange if the sign is playced but the sign dont change his content why

naive bolt
#

i cant seem to find how to play sound ghast Affectionate Scream

#

does anyone know

mellow pebble
#

when i try to save my config with this

#

it removes everything

undone axleBOT
fluid river
#

no what

#

I know right

#

answering different thing

twilit roost
mellow pebble
#

could you paste it ?paste

vocal pine
#

?paste

undone axleBOT
vocal pine
#

sry i needed it myself too lol

mellow pebble
#

yessir

vocal pine
#

feel like im missing something obvious but i've looked at it over & over

kindred valley
#

Whats the problem

vocal pine
#

just doesn't fire when i break a block

#

can't work out why

worldly ingot
#

final all the things

green prism
#

Unsupported class file major version 60
(While shading the plugin)
Help me? I've already tried to switch from java 16 to 17.

kindred valley
#

In event

hasty prawn
#

^

#

@vocal pine I assume it doesn't print "Event firing"?

vocal pine
#

nope

tender shard
#

probably you gotta upgrade your maven shade plugin

hasty prawn
#

Well your event code seems right so perhaps maybe your plugin isn't being loaded?

tender shard
green prism
kindred valley
#

Prolly no difference

tender shard
green prism
#

hm

tender shard
#

that's only one line

green prism
#

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>

hasty prawn
#

That doesn't matter afaik

kindred valley
tender shard
vocal pine
#

ah

undone axleBOT
vocal pine
#

ye i needed the specific mcmmo instance (i thought; at least)

hasty prawn
#

Do /plugins and see if yours shows up sudura.

#

And that its green

vocal pine
#

it does not

kindred valley
#

Not me

green prism
kindred valley
#

Send console

green prism
#

what do you use?

hasty prawn
vocal pine
#

Sorry i was writing smth to print in onEnabled didnt know theres an easier way

tender shard
vocal pine
#
version: 1.0
author: Euronite, sudura
main: games.tress.cropdrops.Cropdrops
api-version: 1.19
depend: [mcMMO]
#

author part right

kindred valley
#

This is not main class

hasty prawn
#

Could be that yeah

kindred valley
#

Isnot your main class XPCrops?

vocal pine
#

oh ye

#

😐

hasty prawn
#

Also true

vocal pine
#

sorry guys

#

i changed name of it cus person wanted me to push it as update to theirs

#

i just missed it here

hasty prawn
#

Also put [] around the authors though

vocal pine
#

yeah lmao

#

oops

#

thank u sorry it was smth so stupid

#

totally blanked on the fact id changed it

green prism
mellow pebble
#

yeah i did now it works perfectly

#

yeah i did it

#

no worries

#

ty for help ❤️

lethal knoll
#

With the ConfigurationSerialization ,is there any possible way to exclude a certain property from being serialized into the config file, but still have it present in the memory?

eternal oxide
#

if its your own object, yes

lethal knoll
#

The use case is the following, I store (Doors). And the existence of hte door is in the config file.

#

But there is no need to keep track in the file if this door is also open or not

#

However when fetching it I would still need to have that value

lethal knoll
eternal oxide
#

Simply ommit that field when you serialize

lethal knoll
#

But then when reading from the Configuration object, it will no longer exist

#

and It sounds silly to keep track of it in a seperate map

eternal oxide
#

correct. you'd have to set a default when you deserialize

lethal knoll
#

but if that is the only solution

#

But I don't want it to become serialized

#

I just want to store keep track of the open/close state in the memory, not the file

eternal oxide
#

thats pointless

lethal knoll
#

Well that is the goal , I don't know if you are familair with services and repositories, but my respository is interacting with the data storage (config) and stores it. So when reading data, it fetches it from there again

#

so maybe I have to write everything to a map only

#

If that is the only option :/

#

I have a class door, that door has a location and block data. and all of that needs to be kept upon restart

#

But the actual state of the door, is also important, only not for after a restart

hasty prawn
#

Yeah but what you're saying doesn't really make sense, you say you don't want to keep the open/close state persistently but then you need it when creating the Door object?

lethal knoll
#

Assuming a door is closed by default

#

And assuming upon onEnable*, I will close all doors

eternal oxide
#

Then do exactly as I said

hasty prawn
#

^

lethal knoll
#

I'm sorry but I'm not following what you said then

hasty prawn
#

Just set the state as false

#

Don't store it, and when you deserialize from the config just set that state to closed

eternal oxide
#

You exclude the field in your serialize method

#

and set a default when you deserialize

lethal knoll
#

Okay i see why you say it, but it's important that when I update somewhere that my door is closed, and when I fetch again by id the same door, it should know it's closed or open. Sorry for making it complicated

#

I just don't need it in my config file itself

#

but on runtime, that's where I need it

#

and that is also when I store it

hasty prawn
#

Oh, don't return it from the config every single time

eternal oxide
#

at runtime its a door

lethal knoll
hasty prawn
#

Yeah you'd have a list or map in memory that'd you'd check first, if it's not in there then get it from the config and then add it to that list/map

lethal knoll
#

ah that makes alot of sense, but when storing, I guess it would be a good idea to then also store it in the config correct?

#

both config and memory*

eternal oxide
#

if you don;t care about the open/close state at startup why do you need to know it at runtime?

lethal knoll
#

Because when somebody closes a door, then I need to be able to fetch that closed or open state

#

I just don't need that value in the config

#

Because upon restart, it will always be false

#

But I think I know what to do

midnight shore
#

why is this wrong?

static ingot
# midnight shore why is this wrong?

You need to define the generic parameter before the return type of your method

public <T extends Weapon> void registerWeapon(String name, Class<T> weaponClass) {
    registeredWeapons.put(name, weaponClass);
}```
midnight shore
#

i made it like this and i don't get any error is this ok?

static ingot
#

the red underline appears to be an error though 🤨

#

whatever parameterized types you're using for your registeredWeapons map doesn't support classes extending from Weapon as a value

midnight shore
#

i was concerned about the class thing

static ingot
#

Ah. Then yeah, I suppose you don't need a generic type at all, lol

worldly ingot
#

No need for the generic there. Wildcard is fine ;p

quaint mantle
#

aloha everyone
I am currently structuring my API and would love to hear some feedback, opinions and improvements
I am asking first, to make sure people don't get angry at me stealing their time looking at something they don't actually want to look at, is that ok?

#

actually I can make a thread and ask there, then I don't spam this channel with a big file

tender shard
twilit roost
#

in IntelliJ when I create Comment using /** */ and install the package
It doesn't appear anywhere in the docs

quiet ice
#

Which docs?

twilit roost
#

first pic is API
second is in another plugin:
no comment visible + not even when hovering on the method

twilit roost
quiet ice
#

Oh the package docs need to be in a file called package-info.java

tender shard
#

they are talking about the normal javadoc comments theya dded to the methods

twilit roost
#

and it will result in something like this?

quiet ice
#

Well I'll just blame IJ there because clearly it is at fault there

tender shard
#

you have to "attach the javadocs" to your .jar or with an execution in the javadoc plugin

quiet ice
#

Or just export the source

twilit roost
#

I dont understand maven at all
so thats why im asking

quiet ice
#

Eclipse generates javadocs from the source even if the javadocs are not present, so it is easier to just export the source jars without bothering with the javadocs themselves

tender shard
quiet ice
#

Alternatively

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
grim ice
#

oh dear god

#

i havent seen maven in so long

#

god gradle ticks me off

#

but im forced to use it for forge

#

🤷🏻‍♂️

quiet ice
#

As someone that is writing his own maven resolver, maven is an absolute pain

grim ice
#

Well that isn't the casual usage

quiet ice
#

WHY the hell does the dependencyManagement block exist and why does the import scope exist

#

Maven version ranges are also absolute pain

grim ice
#

everything is painful

eternal night
#

🤔

quiet ice
#

4.0.0 is not included in the range of [3.0.0,4.0.0), so is 4.0.0-final or 4.0.0.0, but 4.0.0-alpha is included in the range.

#

It does make sense yes, but it also introduces a dilemma because people writing such ranges absolutely don't expect this behaviour

tender shard
#

doesnt that mean that 4.0.0 and 3.0.0 are included in [3.0.0,4.0.0]?

quiet ice
#

Yes

#

4.0.0-final is funnily enough also included in [3.0.0,4.0.0], which even fewer people expect

tender shard
#

that makes perfect sense, versions with an "identifier" are always older than versions without

quiet ice
#

Actually 4.0.0-final and 4 and 4.0.0 have the same age

#

Only 4.0.0-sp is more recent

#
        // Based on examples provided by https://maven.apache.org/pom.html#Version_Order_Specification
        assertFalse(isNewer("1.0-rc", "1.0-cr"));
        assertFalse(isNewer("1.0-cr", "1.0-rc"));
        assertFalse(isNewer("1.0-ga", "1.0.ga"));
        assertFalse(isNewer("1.0.ga", "1.0-ga"));
        assertFalse(isNewer("1-1.foo-bar1baz-.1", "1-1.foo-bar-1-baz-0.1"));
        assertFalse(isNewer("1-1.foo-bar-1-baz-0.1", "1-1.foo-bar1baz-.1"));

        assertFalse(isNewer("1", "1.1"));
        assertFalse(isNewer("1-snapshot", "1"));
        assertFalse(isNewer("1", "1-sp"));

Being only a part of all the unittests I had to make

#

And then there is

        assertTrue(isNewer("3.3.0-I20070605-0010", "3.3.0"));
        assertFalse(isNewer("3.3.0", "3.3.0-I20070605-0010"));

where actually the opposite was documented. But whatever

tender shard
#

first they say "all versions with a qualifier are older than the same version", then it goes to tell how this is not true, lol

#

oh no wait

#

actually it says what I said, something with "final" should always be older than just 4.0.0

quiet ice
#

Are you on the oracle site? That one is absolute bullshit.

tender shard
#

yeah I couldnt find a better source

quiet ice
tender shard
#

oh yeah those say otherwise

atomic violet
#

anybody know where i can find the help page for scoreboard methods? im trying to find it but all im finding are custom scoreboard plugins

#

nvm got it

fervent gate
#

Is there a way to see how long the player has been online for?

#

Like how long since they joined?

river oracle
#

You could check the playtime statistic

#

Iirc that's a thing

#

It'll be like player#getStatistic or something along those lines

fervent gate
#

Found something that might be useful, thanks

delicate obsidian
#

It is possible to make a custom mob (nbt edited mob) spawn naturally without replacing a random existing mob?

fluid river
#

own conditional spawn systme

ornate patio
#

Is it possible to make music discs in a jukebox play on loop

#

or actually better question

#

is there a way to detect if a music disc is finished playing

#

or are the music discs just one fat sound effect

#

I noticed that there is a JukeBox#isPlaying() method but I need something like an event for when a jukebox finishes playing

upbeat wren
#

anyone know a away to select 2 players inside a array without select yourself?

quaint mantle
#

for loop and an if statement?

kind hatch
#

Then do your random search for two people.

upbeat wren
#

but he need be inside the array too

#

i think

fluid river
#

??

kind hatch
#

I mean, if you don't want to include yourself in the results. The best way is to just remove yourself from the results in the first place.

upbeat wren
#

it's because it a matchmaker

#

and when paring i pick a random player in array

#

oh i understand now

#

i will remove on results

#

so in theory this will work?

   Random rand = new Random();
   List<Integer> newList = new ArrayList<>();
   for (int i = 0; i < totalItems; i++) {
        int randomIndex = rand.nextInt(list.size());
        newList.add(list.get(randomIndex));
        list.remove(randomIndex);
   }
   return newList;
hazy parrot
#

can you explain what you are trying to do

#

because if totalItems is size of list List, newList will always be same as list

fresh timber
#

hey, I just was making a /suicide cmd and I made this code that has a hashmap and is used for confirmation. What I did was create the hashmap which its keys are a UUID and value is a boolean. So, I made code where it has an if statement asking if the key pUUID (A variable I have set up for the player's UUID) is null and if it is to put in the key pUUID true so it would not be null. then I sent a message explaining the confirmation and made a delayed task for 10 seconds to remove pUUID key and value from the hashmap so they would. Then there is an else statement killing the player and telling them they got killed just so they know 😉 I did this so they would have to type /suicide twice for a confirmation. For some reason, every time I run it, it just does what it would do as if it were null in the if statement. I am very new to spigot development and it would be nice to know what I did wrong. Here is my code:

public class Suicide implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String [] args) {
        if (!(sender instanceof Player)) {
            Message.send(sender, "&cOnly players can use this command!");
            return true;
        }

        Player player = (Player) sender;
        UUID pUUID = player.getUniqueId();
        HashMap<UUID, Boolean> suicide = new HashMap<UUID, Boolean>();
        if (suicide.get(pUUID) == null) {
            suicide.put(pUUID, true);
            Message.send(sender, "&fAre you sure? You will die and loose all of your items! If you want to suicide, type &c/suicide&f again. &8(This expires in 10 seconds!)");
            new DelayedTasks(() -> {
                suicide.remove(pUUID);
            }, 10 * 20);
        } else {
            player.setHealth(0);
            Message.send(sender, "&c&lYou have been killed!");
        }

        return true;
    }
}
#

oop

#

lemme edit that

kind hatch
#

You're creating a map in the command. You need to have that map outside of your method.

fresh timber
#

ah ok

#

so like this?

HashMap<UUID, Boolean> suicide = new HashMap<UUID, Boolean>();
public class Suicide implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String [] args) {
        if (!(sender instanceof Player)) {
            Message.send(sender, "&cOnly players can use this command!");
            return true;
        }

        Player player = (Player) sender;
        UUID pUUID = player.getUniqueId();
        if (suicide.get(pUUID) == null) {
            suicide.put(pUUID, true);
            Message.send(sender, "&fAre you sure? You will die and loose all of your items! If you want to suicide, type &c/suicide&f again. &8(This expires in 10 seconds!)");
            new DelayedTasks(() -> {
                suicide.remove(pUUID);
            }, 10 * 20);
        } else {
            player.setHealth(0);
            Message.send(sender, "&c&lYou have been killed!");
        }

        return true;
    }
}
hazy parrot
#

that is outside of class

fresh timber
#

oh ;-; so before the @Override?

kind hatch
#

Technically, it can be anywhere outside of a method, but for readability people put variables like that at the top of the class.

fresh timber
#

mm ok thx for the help :)

fallow valley
#

Hi I'm trying to ban words like "hell" but this raises the issue of such things like "hello" also get banned.

#
 public List bannedWords = config.getList("banned_words");
    @EventHandler
    public void chatMessage(AsyncPlayerChatEvent event){
        /* Getting our variables ready */

        Player player = event.getPlayer();
        String message = event.getMessage();

        /* We need to get each item in the list and check if any of them are in the message! */
        for (Object item : bannedWords){
            if(message.contains(item.toString())){
                System.out.println("BANNED < DEBUG");
            }

        }
hasty prawn
#

Profanity filtering is not at all an easy task, you'll probably have to do some research on some algorithms that people have tried.

fallow valley
#

config is yml and looks like:

  - hell
  - crap
#

oh damn

hasty prawn
#

Or, if you just want to have a basic one, split the message by spaces and check if any of the words are in the list.

fallow valley
#

yeah I thought I could add like if(message.contains(item.toString() + " ")){ but that doesn't work if it's only the word byitself

fallow valley
hasty prawn
#

Well that's pretty complicated to really get right afaik, might do some research and see what others have done in the past.

fallow valley
#

right ok

fallow valley
lost matrix
#

This has by far the best performance but is a bit trickier to implement than just a contains.

worldly ingot
#

and still has false positives. For the example above, "prickle" would flag you

#

Nobody has perfected word filters

lost matrix
#

Yes true

#

There are some apis which use neuronal networks for really good filtering.
But those are mostly rate limited unless you pay.

#

*And you have the overhead for your rest calls.

worldly ingot
#

At the end of the day, all you need is some simple filtering because inevitably someone will find a way around yours, but hopefully by that time, you'll have punished them accordingly

fresh timber
#

This is a terrible method, but what I do for chat filters on my server is I replace all of the bad words in the message with *s for the letters then say for the most common words like lets say grass I would change that to 3 asterisk thingies in red (&c) then I would do if the message contains gr&c(3 asterisks), replace that with grass. This only works for the most common words that you put in but after a few days of finding words that were blocked, I never had a problem again with that unless you send a not common word

quaint mantle
#

<this is a terrible method>

fresh timber
#

lmao

#

it works if u are only using the plugin for ur server ig

#

uh so I'm trying to make a /spawn command and on it I want them to wait for 5 seconds without moving, like almost every plugin out there and I have a hashmap I am using but it wont let me use it in a different java class... does it need to be outside of the class I am mainly using it in to access it everywhere? or what do I need to do?

#

bcus it wont let me put it outside of the class

lost matrix
#

Can you already disable the nsa/stasi-style surveillance? Because if not then ill just let microsoft do the cleansing.

lost matrix
kind hatch
fresh timber
#

whats this mean "dependency injected (through the constructor)
to other classes"

lost matrix
# fresh timber uh so I'm trying to make a /spawn command and on it I want them to wait for 5 se...
public class TeleportManager {
  
  private final Map<UUID, Location> waitingPlayerMap = new HashMap<>();
  
  public boolean isWaiting(UUID playerId) {
    return waitingPlayerMap.containsKey(playerId);
  }

  public void setWaiting(UUID playerId, Location targetLocation) {
    waitingPlayerMap.put(playerId, targetLocation);
  }
  
  public Location removeWaiting(UUID playerId) {
    return waitingPlayerMap.remove(playerId);
  }
  
}

Example for the manager class

lost matrix
fresh timber
#

so... where do I create the hashmap?

iron glade
#

?learnjava

undone axleBOT
fresh timber
#

just forgot stuff lol

tranquil stump
#

how do I force a command to be run like /pluginname:commandname instead of /commandname

fresh timber
#

prob shoulda used the info I got from solo learn while I learned it cus I never used it the whole time and just forgot cus I never used it ;-;

lost matrix
lost matrix
tranquil stump
#

I see that the plugin Gringotts you need to type gringotts: before the command so I was wondering how to do that for mine

#

like in the auto complete all the commands come up with /gringotts:

iron glade
#

Custom tabcomplete maybe

fresh timber
# lost matrix

ohh... that took me a long time to get but so I'm making a new class with the hashmap and making variables in it that are public to remove and add stuff to it? Did I get it right or no?

tranquil stump
fresh timber
#

bro ur so unhelpful

iron glade
#

Not only related to your current problem tbh

lost matrix
fresh timber
#

uh ok

lost matrix
# fresh timber uh ok

And remember: This class should only have one instance and not a single more. Because if you create a new instance
then this instance will have a new map which is completely unknown to everyone else that has a different instance.

echo basalt
#

This one is fine

#

basically if it sounds bad, it's detected as a "bad word"

#

guy designed this for a TTS bot

arctic moth
#

im bored someone give me some ideas on how to make the most toxic annoying plugin

echo basalt
#

fast enough

#

chat events are async regardless

lost matrix
#

There are apis out there that have an average of 100ms response time for this.
Phonetic filtering is probably the wrong approach for text that will never be heard.

worldly ingot
#

I don't think there's an event for that

#

Nor can one be implemented

#

Jukeboxes just... play

quaint mantle
#

ElgarL, did you by any chance made one of the first cracked launchers?
I remember back in the day before I had the chance to buy it, there was this launcher named "Minecraft Launcher by anjocaido"

arctic moth
#

how do you check if a chunk is in simulation distance

#

no Chunk#isSimulated() or anything of the sort

arctic moth
quaint mantle
#

btw Choco, had the pr's related to the bucket events been merged?

worldly ingot
#

I don't follow. Which PR?

#

Oh the handedness? No not yet

ornate patio
#

perhaps detect when a player right clicks a jukebox, then set an interval that will constantly check if the jukebox is playing

#

and if its not restart the music

quaint mantle
#

I see, I'm so happy about them.
Thank you again for the contribution.

By the way, how may I contribute to the API?
I mean, what are the rules while contributing to the API.
Are we supposed to use mojang mappings to guide ourselves?
How may I contribute to the API?

worldly ingot
#

First and foremost,

#

?cla

undone axleBOT
fresh timber
# lost matrix

on here why do you put public Location and what is it like is it from org.bukkit or is it a java thing?

worldly ingot
#

Beyond that, you can work directly out of BuildTools. Fork the Bukkit and CraftBukkit repos on the stash, make a branch, make changes in the Bukkit and CraftBukkit folders, then commit and PR

worldly ingot
#

The README of each project has details on expectations

arctic moth
quaint mantle
#

oh

arctic moth
#

also use the dead thread

lost matrix
arctic moth
fresh timber
#

yea but when I put it in my IDE it gives me error

#

what do I import to make it work?

lost matrix
#

bukkit

fresh timber
#

oh ok

#

I thought that was for a location in a world

#

;-;

#

k thx for the help :)\

lost matrix
fresh timber
#

...

#

uh

#

then why does it help u access it from outside the class

lost matrix
#

The "public" does

fresh timber
#

o

#

ok

#

so

#

what is Location for

#

is it cus ur teleporting someone?

#

in ur code

#

tbh im just confused why all of ur variables have different uh prefixes in the manager bcus they are all editing the hashmap

lost matrix
#

I dont see how this correlates at all...

fresh timber
#

;-;

lost matrix
#

And those are not variables

delicate lynx
#

"in the manager"

fresh timber
#

oh yea constructors why do those all have different prefixes like the first one is public boolean and the second is public void and the third is public location

iron glade
#

boolean returns true or false

fresh timber
#

yea

iron glade
#

void returns nothing and just "does" stuff

delicate lynx
#

because you specify what you want your constructors to do

iron glade
#

and Location is the returned object in the last method

fresh timber
#

bro I give up

iron glade
#

?learnjava

undone axleBOT
iron glade
#

moment

fresh timber
#

im not doing that again

#

took me like 2 months

#

learned nothing

iron glade
#

I see

lost matrix
#

Please. You will suffer for months and not get anything done if you continue like this.
Learn the bare minimum of java before jumping into spigot

iron glade
#

^

fresh timber
#

welp everything every tells me to learn with like sololearn didnt work

iron glade
#

Learning java basics is honestly not that difficult

fresh timber
#

so I'll try here

vocal cloud
#

If you can't learn from a structured platform what makes you think you can learn from us Thonk

next plume
# fallow valley Hi I'm trying to ban words like "hell" but this raises the issue of such things ...

I use a 9 year old version of PwnFilter that I updated for 1.19. It uses regular expressions. There's a compiled .jar file and a comprehensive set of rules.
https://github.com/Bobcat00/PwnFilter

GitHub

PwnFilter is a JAVA Plugin for Bukkit, a multiplayer server API for the game Minecraft. Pwnfilter implements Regular Expressions created in a user defined "rules.txt" as an in-gam...

fresh timber
#

bcus I already have learned a lot from u

iron glade
fresh timber
#

uh ok

fallow valley
#

hey doods I'm tryna get the amount of caps in a string but what confuses me is when compiling I get an issue

#

my code is this:

int amount = 0;
for (char letter : message){
  if (Character.isUpperCase(letter)){
    amount =+ 1;

  }
}
iron glade
#

And what's the issue?

fallow valley
#

getting to that lol

iron glade
#

initialize amount with 0

vocal cloud
#

Uh amount isnt set?

#

Learn java moment 2 electric boogaloo sadge

fallow valley
#

(from above)

String message = event.getMessage();
iron glade
#

did you initialize amount in your code?

#

or was it like int amount;

fallow valley
#

wdym?

iron glade
#

you just edited the message

fallow valley
#

int has a value of 0

#

the error is for-each not applicable to expression type

#

in refrence to line: for (char letter : message){

iron glade
#

message.toCharArray() or smth maybe

worldly ingot
#

Strings are not iterable

vocal cloud
#

I wish google had an API so you could easily make a bot to google things for people.

worldly ingot
#

Yeah, toCharArray() it

fallow valley
#

crap I have no brain.

#

tysm fellas

iron glade
#

are "unset" ints actually initialized to 0? if yes I didn't know that lol

fallow valley
#

sorry brainfart. Was programming in python yesterday

iron glade
#

that's what I thought so far

iron glade
fallow valley
iron glade
#

ah gotcha, I was talking about before u edited the message and it just said int amount

#

which, as I thought so far, should be null and not 0

fallow valley
#

yeah it did say int amount = 0; in my code. I didn't copy everything i only copied what was relevant, musta got rid of that.

iron glade
#

aight

#

kinda irritated for a second haha

#

Though, a google search says ints are initialized to 0

vocal cloud
#

Good practice to set it anyways

iron glade
#

that's what I've been doing

iron glade
fallow valley
#

ohh really?

#

idk why I thought it was null then

iron glade
#

dw I was thinking that too

hazy parrot
#

Unless it's local var

worldly ingot
#

int can't be null

#

primitives, can't be null

hazy parrot
#

But will result compile error

fallow valley
ornate patio
#

does anyone have a code example of a static helper class for a plugin

#

for example Lib's Disguise is a plugin but if you add it as a maven dependency it uses a bunch of fancy static classes to interact with the plugin

#

i need to know how to create something like that where users cant mess with my plugin (as in hide it from autocomplete) but can use the API freely

#

i know i asked this question before but never really got a satsifying answer

lost matrix
#

Do what spigot does.
Define your API by using a bunch of interfaces.
Implement the API in your plugin and let the user only depend on your api.
This way the implementation is not visible for the user.

#

But thats probably overkill.
Just create a static facade pattern.

ornate patio
ornate patio
ornate patio
#

i wanna make my plugin look as professional as possible

ornate patio
#

I get the whole creating interfaces and implementing part

#

but how would I create a static facade class in the API to actually interact with the plugin itself?

#

I would use Bukkit's plugin manager to get the plugin, but don't I need to cast the plugin to my own one that subclasses Plugin in order to actually do stuff with it? If I need to cast it, then my API will need to depend on my plugin

worldly ingot
#
public final class MyAPIClass {

    private static MyAPIInterface api;

    private MyAPIClass() { } // Private because it shouldn't be instantiated

    public static void setAPI(MyAPIInterface api) {
        MyAPIClass.api = api;
    }

    public static MyAPIInterface getAPI() {
        return api;
    }

}```
#

That would be in your API. Then in your plugin all you would have to do is call MyAPIClass.setAPI(new MyAPIImplementation())

#

That's basically what Bukkit does. That's what the Bukkit class is. It has a setServer(Server) method that it calls in CraftServer's constructor

#

You could make use of the services API too, but imo that's a backwards use of it

ornate patio
#

okay got it

#

I'll save this for later

#

thanks so much 🙏

worldly ingot
#

Vault is the prime example of how it's meant to be used

#

A service is something you expect other plugins to implement so that your own plugin can use it

#

Or at least in the case of Vault, allow other plugins to use as well

rigid drum
#

Ok and if you make an API

#

nothing is wrong with someone else implementing it

#

OCP and all

nimble hill
#

Whats the best way to check if a player is able to build in an area? (checking the ifCanceled() is not a possibility)

BlockCanBuildEvent can = new BlockCanBuildEvent(p.getWorld().getBlockAt(p.getLocation()), p, Material.AIR.createBlockData(), false);
        Bukkit.getServer().getPluginManager().callEvent(can);

        if (!can.isBuildable()) {
            return false;
        }

But i feel that there is probably a better way of doing this. And the only information im allowed here is the location of the player.
Anyone have any other ideas of alternative ways of doing this?

eternal oxide
#

you should probably alos check the cancelled state

#

Not sure isBuildable checks that

nimble hill
#

Im checking the canbuild state elsewhere on the actual event

#

This check is me checking if they have permission to build to use a skill

eternal oxide
#

I'd generally use the block place event over canBui;ld

nimble hill
#

I mean dont they work the same in terms of viability?

eternal oxide
#

they do, kinda. But BlockCanBuild is fairly new. I'm not sure many protection plugins listen to it

worldly ingot
#

Nah, BlockCanBuildEvent has been around since 2011

nimble hill
#

BlockCanBuild is 1.18+ iirc
so, it should be enough time. But yea overall is what im doing fine for Checking of they have build perms at their location?

eternal oxide
#

I'd have to dig in the internals to see if a protection plugin not listening to this event would even trigger a false response

nimble hill
#

Thats why im asking, are there better alternatives?

eternal oxide
worldly ingot
#

tbqh, it's such an underused event, I'd be shocked if any plugin is using it

eternal oxide
#

If not, I know some protection plugins will not return false.

nimble hill
eternal oxide
#

Yep thats my thoughts. I'd actually not even heard of this event until it was mentioned here, and I've written protection plugins 🙂

nimble hill
#

Ive used it in React a while back with no real issues

#

But im trying to see if my "old habbits Die Hard" is going to continue

eternal oxide
#

So the answer is, if its a modern updated protecton plugin that listens to this event you are good.
Older protection plugins its unknown, you'd have to test

nimble hill
#

Or if there are better ways

nimble hill
#

Mmm, ill stick with this for now until i get a report, but im glad that im not off my rocker

#

Thanks @eternal oxide / @worldly ingot for your insight.
Take care yall 🙂

torn shuttle
#

Programming with multiple lines is for losers, check out my one line statement

case NEARBY_PLAYERS -> eliteEntity.getLocation().getWorld().getNearbyEntities(eliteEntity.getLocation(), range, range, range, (entity -> entity.getType() == EntityType.PLAYER)).forEach(entity -> entity.teleport(finalLocation));

echo basalt
#

ew

torn shuttle
#

haters

nimble hill
#

Hold my beer

torn shuttle
#

get with the new hotness

#

it's actually worse than you think

            switch (target) {
                case ALL_PLAYERS -> Bukkit.getOnlinePlayers().forEach(player -> player.teleport(finalLocation));
                case WORLD_PLAYERS ->
                        eliteEntity.getLocation().getWorld().getPlayers().forEach(player -> player.teleport(finalLocation));
                case NEARBY_PLAYERS ->
                        eliteEntity.getLocation().getWorld().getNearbyEntities(eliteEntity.getLocation(), range, range, range, (entity -> entity.getType() == EntityType.PLAYER)).forEach(entity -> entity.teleport(finalLocation));

            }
nimble hill
#
RegisterAdvancement(AdaptAdvancement.builder().icon(Material.COOKED_BEEF) .key("challenge_eat_100") .title("So much to eat!").description("Eat over 100 Items!").frame(AdvancementDisplay.AdvancementFrame.CHALLENGE).visibility(AdvancementVisibility.PARENT_GRANTED).child(AdaptAdvancement.builder().icon(Material.COOKED_BEEF).key("challenge_eat_1000").title("Unquenchable Hunger!").description("Eat over 1,000 Items!") .frame(AdvancementDisplay.AdvancementFrame.CHALLENGE).visibility(AdvancementVisibility.PARENT_GRANTED) .build()).build());```
torn shuttle
#

aw hell yeah

nimble hill
#

I can do better hold up

torn shuttle
#

I think you can fit a couple more builders and builds on there

nimble hill
#

Same

#

I have like a 30 line one lolol

#

Its almost as bad as doing an If without the {}'s

nimble hill
eternal oxide
#

very unreadable

echo basalt
#
public enum SearchContextType {

  ALL_PLAYERS((context) -> {
    return Bukkit.getOnlinePlayers();
  },

  WORLD_PLAYERS((context) -> {
    Entity entity = context.getEntity();
    return entity.getWorld().getPlayers();
  }),

  NEARBY_PLAYERS((context) -> {
    Entity entity = context.getEntity();
    double range = context.getRange();

    Set<Player> set = new HashSet<>();
    for(Entity target : entity.getNearbyEntities(range, range, range) {
      if(target instanceof Player player) {
        set.add(player);
      }
    }
  };

  private final Function<SearchContext, Collection<Player>> function;

  SearchContextType(Function<SearchContext, Collection<Player>> function) {
    this.function = function;
  }

  public Collection<Player> fetch(Entity entity) {
    return fetch(entity, 0);
  }

  public Collection<Player> fetch(Entity entity, double range) {
    return function.apply(new SearchContext(entity, range));
  }
}
#
@Data
@AllArgsConstructor
public class SearchContext {
  private final Entity entity;
  private final double range; // can be 0
}
heavy swan
#

How do I make a post in the spigot forum?

torn shuttle
echo basalt
#

it makes your code seem fancy

#

it's just more organized ig

#

just like placeholder code

#

you make individual code blocks whenever you declare your actions instead of in the big method that needs the result

#

bonus points if you get paid hourly

torn shuttle
#

no joke your version seems way more confusing to me

echo basalt
#

It's more overengineered

#

but each enum declaration has its own implementation of how it fetches the players from a given context

#

the context is a data object

torn shuttle
#

but why

echo basalt
#

so the entity, the range, etc

#

it makes adding new types a bit easier

torn shuttle
#

considering I already covered all the cases I wanted this doesn't seem like a better solution

echo basalt
#

Instead of having to add to the enum, then locate the method, you just make the method inside the enum

#

it also prevents big ass blocks of code

torn shuttle
#

also a bit easier assumes new entries follow the format you imposed

echo basalt
#

a bit how placeholderapi code is often split up into functions for bigger plugins

#

you can modify the context object to fit your standards

#

maybe make a context builder

#

with default values

#
Collection<Player> collection = type.fetch(
  SearchContext.builder()
  .range(20)
  .avoidIf((player) -> player.getGameMode() != SURVIVAL)
  .build(entity)
);
#

would be the end game result lol

#

sure it's a lot more abstracted but the end result ends up cleaner

torn shuttle
#

you have a very weird concept of clean

echo basalt
#

lol

#

bAsiCallY

torn shuttle
#

it's diametrically opposed to mine

echo basalt
#

The idea is that the method shouldn't handle multiple cases

#

instead, it calls the handler of the selected case in specific

torn shuttle
#

that isn't cleaner so much as it is more fastidious

echo basalt
#

the end result is the same, but it's better managed

torn shuttle
#

I feel like your concept of better management is very subjective

echo basalt
#

Okay uhhhhh

#

Think of PAPI expansion code

#

it has a String onPlaceholderRequest(Player, String)

#

would you put like 25 ifs in there

#

or just make it fetch the value from a Map<String, Function<Player, String>>

torn shuttle
#

if there's 3 cases? yes I would put 3 ifs

#

code exists in a context

#

you don't bring in a nuclear bomb to unjam a door

echo basalt
torn shuttle
#

yeah, but if my first approach is always the most fastidious one I would still be writing the first release of my first plugin

echo basalt
#

this is what I consider awful

torn shuttle
#

and yet it has become the industry standard in our little world, because it actually exists and works

echo basalt
#

I guess it's a speed vs quality thing

#

But honestly I'm obsessed with being fastidicious

#

don't judge me for googling the meaning

torn shuttle
#

well you're not obsessed with spelling that correctly that's for sure

echo basalt
#

I don't care about spelling, it's a word I learned like 5 minutes ago

#

at 5:30am

torn shuttle
#

also if you think this chunk of code is bad you're weep tears to see what I'm currently working on

echo basalt
#

I remember that one livestream I saw

torn shuttle
#

but hey, it will be out tomorrow and people will probably really like it

echo basalt
#

and how the code was barely readable because I was watching a 4k stream at 1080p

torn shuttle
#

yeah still streaming

kindred valley
#

Hey

#

What is the logic of arenapvp

chrome beacon
#

?

kindred valley
#

I mean

#

Whats the logic of teleporting different maps

#

How can they do that

chrome beacon
#

If game start
Find map
Teleport player

#

?

kindred valley
#

But

#

Wouldnt have to be like 1000 maps

#

Everytime they queue they will teleport a new world

chrome beacon
#

Why would you send them to a new world???

proper notch
#

Lots of servers just have them in the same world separated by 1k blocks or smthing so u cant see other arenas.
Some servers have systems to use the same arena for multiple fights at the same time by preventing you from seeing other players not in your fight.
IDK if this is that popular any more, but I know some used to paste them in on-demand using FAWE.

chrome beacon
#

^

kindred valley
#

Actually yes it can be created by world edit

echo basalt
#

You could allow fake blocks but stuff like lava would need to be emulated

rough drift
#

block instanceof Chest is returning false, even though the block is a chest 100% as I can see it with my very own two eyes, and the print statement also prints that it is a chest

#

org.bukkit.block.Chest

#

yes it's that

#

the other one doesn't even have an inventory

#

Yeah the other doesn't hold inv

kindred valley
green prism
#

Hello!
I'm doing an interactive furnace inventory, tried this util created in a few minutes.... It works correctly but I can't set slot 3... How can I do it?

Util: https://paste.md-5.net/wivebuvozu.java

How am I using it?

    @Override
    public boolean onCommand(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String label, @NotNull String[] args) {
        FurnaceUtil furnaceUtil = new FurnaceUtil("test");
        furnaceUtil.addElement(1, new ItemStack(Material.STRING));
        furnaceUtil.addElement(2, new ItemStack(Material.GOLD_INGOT));
        furnaceUtil.addElement(3, new ItemStack(Material.DIRT));
        furnaceUtil.build();
        furnaceUtil.show((Player) sender);
        return false;
    }```
#

ouch, maybe it starts from 0

#

works

#

thank you guys

hollow belfry
#

How to update bedrock version in geyser crossplay

chrome beacon
#

Update Geyser

green prism
# chrome beacon also use <#741875845089722499>
    public void setOnClickListener(InventoryClickEvent event) {
        if(event.getClickedInventory() == null) {
            return;
        }

        if(event.getClickedInventory().getHolder() == null) {
            return;
        }

        if(!(event.getClickedInventory().getHolder() instanceof GUIHolder)) {
            return;
        }

        
    
    }```

olive, excuse me a question.
How do I consume the event that the player (myself in the other class lmao) passed to me?
chrome beacon
#

You just call that method from the listener?

green prism
chrome beacon
#

Ah you want the consumer interface

green prism
#

wat

#

hmu

#

hum

chrome beacon
#

addElement(int pos, ItemStack stack, Consumer<InventoryClickEvent> onClick)

chrome beacon
#

When calling that method you can give onClick as a lambda function like the screenshot shows

green prism
#

how can I accept it?

#

should I create a new inventoryclickevent?

chrome beacon
#

No use the one from the event listener

green prism
chrome beacon
#

Don't accept it there

#

Accept it when the event happens

green prism
chrome beacon
#

Yeah accept it in the event listener

#

So you have the InventoryClickEvent

#

You can store that consumer in a field

green prism
#

AHHH

#

got it

#

thank you

hybrid spoke
#

anyone wanna make a 50x20 block kraken out of armorstands

hybrid spoke
green prism
#

I've finished

hybrid spoke
#

show me

green prism
#

here you are

hybrid spoke
#

thats not 50x20

green prism
#

1920x1080 pixel

#

that's it

molten hearth
#

Even better

hybrid spoke
#

we'll try something more simple

#

what about a giant 70x10 knight

#

now animate it

green prism
#

ahaha I will end up banned

hybrid spoke
#

how so

green prism
#

u've just rescued a baby panda

hybrid spoke
green prism
#

How to prevent the inventory from closing with the resourcepack download/request in 1.16.5?

green prism
#

thats the matter

green prism
# chrome beacon Wdym?

That I wanted to make this plug-in public, so, I don't know whether in a server they have resourcepack or not...
I want to prevent it from closing the inventory at onjoin

chrome beacon
#

Use that event to reopen your inventory after the resourcepack screen

charred blaze
#

im trying to listen on handshake packet with protocollib, but it says PacketType.Handshake cannot resolved to a variable

vital sandal
#

this ?

charred blaze
vital sandal
#

handshake ?

#

when we can shake hand in minecraft ?

charred blaze
#

handshake doesnt mean handshake

#

It's like motd refresh in server list (as i know)

#

ping*

vital sandal
#

is it possible to cancel screen shake when we use setHealth() ?

eternal oxide
#

setHealth does not shake the screem

kindred valley
eternal oxide
#

Spigot setHealth does not give adrenaline

kindred valley
kindred valley
vital sandal
eternal oxide
#

?stash

undone axleBOT
kindred valley
#

I dont get it Elgar

eternal oxide
#

There is no adrenalin applied when a player is healed.

kindred valley
#

But it gives an screen effect

kindred valley
#

Troll

eternal oxide
#

that is the CB code to heal, which calls java public void setHealth(float f) { this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); }

#

all that does is then send a packet to inform the client to set the health

charred blaze
#

I want to make the server appear offline from the real IP Address, yes it appears offline with this code, but it also denies connections from bungee. But I want them to join. How do I fix that?

vital sandal
#

Or may be it is setscaledHp

smoky oak
#

which to use, and why?

for(String name : structSection.getKeys(false)){
  ConfigurationSection targetSection = structSection.getConfigurationSection(name);
}
``````java
ConfigurationSection targetSection;
for(String name : structSection.getKeys(false)){
   targetSection = structSection.getConfigurationSection(name);
}
eternal oxide
#

neither

#

you are just looping sections so no need for any temp variable

smoky oak
#

can u iterate sections directly then

eternal oxide
#

yes

smoky oak
#

some sort of iterator?

#

wait

#

theres no iterator or stream

#

how do i do it

rotund pond
#

With a lambda expression

smoky oak
#

u sure about that

rotund pond
#

Depending on what you need

#

What are you trying to do ?

smoky oak
#

i have a data object im comparing to a configurationSection. Said sections are different from each other. I'm trying to find the corresponding section.
basically this in complex:

for every Section do:
  get Section.id
  compare section.id with data object
  return section if it matches, otherwise continue
return null
rotund pond
#

Mh

#

Maybe you could trying something like this:

structSection.getKeys(false).forEach(structName -> {
String sectionId = structSection.getString(structName + ".id");
...
}

Sorry if it's weird, I'm on a smartphone

eternal oxide
#
        getConfig().getValues(true).forEach((key, value) -> {
            
            if (value instanceof ConfigurationSection) {  }
        });```
smoky oak
#

u sure that shouldnt be false instead

rotund pond
#

Another way 👍

eternal oxide
#

would probably work

smoky oak
#

im about 99% sure ill get a npe or something if i keep that true

eternal oxide
#

you walk all contents not just the root

rotund pond
smoky oak
#

why would i want to do that? I'm doing a specific path

#

its a config not a heap

eternal oxide
#

from your question it looked like you wanted an anonymous method to parse

smoky oak
#

well i have a specific structure, and i want to find the section the comparison object matches with
just blindly fishing for it wouldnt work

#

hence me changing that true to a false

#

or are the keys the absolute path

#

wait even if they are I'd have to do string manip on them, like cutting away the last part

#

iterating over the top level seems safer

smoky oak
eternal oxide
#

Explain exactly what you are trying to do

smoky oak
#

Find and return the configurationSection / key to that configurationSection (either works) that matches the data object passed to the method as a comparison object

eternal oxide
#

um not so easy

#

is the object already serialized in Map form?

smoky oak
#

no, I'm unaware how to do that. It would make things easier thats for sure

#

also

#

the passed data object might have additional values not present in the configuration, its supposed to ignore those

#

but it also means i cant do equals() on the config map and serialized map would i have it

eternal oxide
#

You are not going to be able to simply search the config for that item. you need some kind of indexing

smoky oak
#

yea so what im trying to do atm basically is

public static ConfigSection findSection(dataObject cmp, FileConfiguration cfg){
  for(String key : cfg.getKeys(false)){
    ConfigurationSection checkSection = cfg.getConfigurationSection(key+"."+items);
    if(compare(checkSection, cmp)) return cfg.getConfigurationSection(key);
  }
  return null;
}
//compare not implemented
quasi flint
#

exclude the ip adress of the bungee

#

if u can get the ip adress from where the packet comes

eternal oxide
#

Why are you trying to find an item in your config?

smoky oak
#

no, because that's the part of the section that identifies it. I need the section above that

quasi flint
#

thats for sure

#

but from the first packet

#

meeeeh

smoky oak
#

maybe u remember this atrocity

#

ArrayList<ArrayList<ArrayList<ItemStack>>>

eternal oxide
#

Just have your dataObject implement ConfigurationSerializable (and register)

#

you can control which Fields it stores in its Serialize method.

#

you can also then compare objects to find matches, like how ItemsStack.isSimilar() works

#

If your item implements CS it can then be easily put in and read from the config

smoky oak
#

i think in this instance its simpler to write the comparision instead of making a dedicated data class. I am using that list purely for the identification, and am also only using non-unique items (enchanted, lore etc make it return false), and im not storing the items

#

still, its something that might come in useful later

green prism
# eternal oxide If your item implements CS it can then be easily put in and read from the config

Hello ElgarL 🙂
Im trying to create a furnace that allow an item to be selected. Precisely I wanted to make on the left (Fuel and Combustion Side) two arrows and on the right the item that changes when the arrows are clicked following a list.
In your opinion, how do I update the inventory after changing item on the right?
Should I recreate and open the inv?

I created this class as Util:
https://paste.md-5.net/otagoqipup.java

peak wharf
#

Hi how can i give a id for a inventory, i save the contents in a hashmap with de inventory name, its give some Issues...

peak wharf
#

Hmm

rocky pond
#

Hey, does anybody know how to do this? As you can see, when I hover over the player list, I see some customisable text. I don't really have a code for now, I started by creating a ServerListPingEvent but thats about it

lost matrix
rocky pond
lost matrix
#

The server responds with a simple json message.
This part is responsible for the text which is displayed.
You can set this by using something like ProtocolLib to
alter the packet before its being sent out.

#

^ Link for more infos

quaint mantle
#

Hi i have having an issue with one my plugins. The plugin is developed in koltin. Can anyone help me if they have spare time 😢

eternal night
#

What is the specific issue here ?

#

generally, just post the concrete issue and hope that someone can help you

#

don't damange mobs off your main thread

#

the server thread ?

#

you are spinning up a async task somewhere

#

in that task you damage entities

#

which is not supported

#

by not damaging them in an async task

#

either make the entire task sync

#

or create a new sync task to damage hem

#

mhm ?

#

Well that is fine

#

but scheduleAsyncRepeatingTask

#

means the repeating task is async

#

there should be a similar method without the async

#

np 👍

vital sandal
#

Is there a betterway to load player stats in a hashmap without a runnable for every players?

eternal night
#

what do you mean runnable o.O

smoky oak
vital sandal
#

Just slower i think

smoky oak
#

wdym not effective

#

it just has to work

#

wont take longer than a few ms anyways

vital sandal
#

Yeh ofc but that isnt any difference than a runnable for each

smoky oak
#

actually

#

the overhead is much smaller

#

also runnables still get processed on the main thread anyways iirc so this is actually faster

vital sandal
#

I can split runables on each thread and core so not a problem

#

Why would i need to load an offline player ?

#

Huh?

green prism
#

how to remove that book in a fake furnace inventory?

vital sandal
#

You cant 😄

smoky oak
#

iiirc u cant since its a client thing

green prism
#

bruh

#

it is ugly as fk

smoky oak
#

play 1.12 then

green prism
#

1.7 is way better

#

1.4 even more

smoky oak
#

i like 1.6.4 tbh

#

has some nice modpacks

boreal seal
#

i think i messed up somewhere

#

lol

#

why it says binary

#

like i told you plugin something tottaly different

#

monkey plugin monkey plugin

green prism
#

how the fuck is possible that a char means 99

tardy delta
#

??

boreal seal
#

char isnt 99

#

char is like A
or B

#

...

tardy delta
#

char has an int value

green prism
boreal seal
#

fix ur

#

click event

#

first

tardy delta
#

'1' - '0' == 1

boreal seal
#

and use interact event instead

#

monkey

green prism
#

what changes between the two?

boreal seal
#

its better for performance

green prism
#

huh

boreal seal
#

trust me

#

i use 1.8

green prism
#

oaky

boreal seal
#

dont listen to those monkies who use 1.12

green prism
#

i use 1.19

#

btw

boreal seal
#

still use interact event

ivory sleet
#

Are you trolling?

boreal seal
#

Conclure no

#

interact event > click event

green prism
#

Conclure, what is the best in your opinion?

ivory sleet
#

You cant even use InventoryInteractEvent

#

Since it doesnt have a HandlerList instance

green prism
#

thank you

boreal seal
#

oh shit

#

didnt notice

#

kacper my man how r u

onyx fjord
#

is anyone aware how i can filter out strings from log4j logs?

#

lets say LOL UWU gets logged but i wanna filter UWU so only LOL gets printed

ivory sleet
#

One way is to append log filters or sth

onyx fjord
#

btw must be in code

#

no xml configs

ivory sleet
#

Myeah, I think its possible to append a filter in code

#

Tho I dont have any pseudo code for it

#

But I used to do it when unit testing

green prism
#

            @Override
            public Result filter(LogEvent event) {

                if (event.getMessage().getFormattedMessage().toLowerCase().contains("lol")) {
                    return Result.DENY;

                }
                return Result.NEUTRAL;
            }
        });```
onyx fjord
#

i dont want to stop the message fully tho

#

just remove the filtered part

ivory sleet
#

Theres probably a way to do that as well with that callback method

onyx fjord
abstract sleet
#

does that LogEvent allow you to modify the message?

onyx fjord
#

nope

#

stackoverflow suggests reflection

#

but it says old versions need reflection

tardy delta
#

siuuu my parser believes 1+(1+1) is 22

chrome beacon
#

ouch

green prism
chrome beacon
#

with?

ivory sleet
#

@onyx fjord

#

Add an appender not filter

#

And iirc you might be able to cast to MutableLogEvent

onyx fjord
#

do you have an example of how to do it?

green prism
# chrome beacon with?

You know the FurnaceGUI from earlier?
FurnaceGui (Util): https://paste.md-5.net/kociwedijo.java
FurnaceElement (Object): https://paste.md-5.net/oduzokadep.java

Well, I wanted to make it change right the age and make it dynamic....
I have no idea how I can make it bring the new value when it updates

AtomicInteger actualAge = new AtomicInteger(ConfigLoader.min_age);
                    furnaceGui.addElement(new FurnaceElement(actionElement.getIntPos(), true, actionElement.getStack(), click -> {
                        personUtil.getPerson(click.getWhoClicked().getUniqueId()).setAge(actualAge.get());
                        click.getWhoClicked().sendMessage(ConfigLoader.message_ageConfirmed);
                        inventoryManager.openNextInventory((Player) click.getWhoClicked(), plugin, personUtil, postProcessCommands, customConfigsInit);
                    }, FormatUtils.color(actionElement.getDisplayname().replace("%actualage%", String.valueOf(actualAge))), FormatUtils.loreListToSingleString(actionElement.getLore()).replace( "%actualage%", String.valueOf(actualAge))));```
#

look at the event listener

tardy delta
#

lol FormatUtils.loreListToSingleString

green prism
#

ik

#

I guess olivo has given up xD

chrome beacon
#

I have no idea what the problem is?

#

The placeholder thing?

green prism
#
 public FurnaceElement(int location, boolean dynamic, ItemStack stack, Consumer<InventoryClickEvent> clickEvent, String... text) {```
chrome beacon
#

So the placeholder is the problem

green prism
#

ye

chrome beacon
#

Your code will only work once since you replace (and thus remove the placeholder)

#

so the next time it should update it can't find the placeholder

green prism
tardy delta
#

college gotta be fucking kiddin me

#

who even uses bluej

onyx fjord
#

?

chrome beacon
#

BlueJ 💀

onyx fjord
#

OH LOL

#

yk

#

they told us to use some 90s C++ ide

green prism
#

IntelliJ 🌮

onyx fjord
#

just use whatever u want

chrome beacon
#

We used Netbeans 😎

tardy delta
#

i saw my profs code 💀

hasty prawn
#

I didn't even know BlueJ existed

onyx fjord
#

same

tardy delta
#

looks horrible

green prism
chrome beacon
#

You can store the original lore and displayname

onyx fjord
#

what else you need

hasty prawn
# chrome beacon We used Netbeans 😎

My professor used Netbeans and everyone in class used IntelliJ, which he had never used. You can imagine how many issues kids had and he had literally no idea how to fix them.

tardy delta
#

looks horrible

onyx fjord
#

we switched to codeblocks

tardy delta
#

i saw ij on the taskbar on my profs pc, why not use it then :/

green prism
hasty prawn
chrome beacon
#

You pass it as a param

tardy delta
onyx fjord
#

is the thingy saying client message has wrong timestamp new?

tardy delta
#

and a bunch of javafx stuff too

#

first thing i see is a damn singleton

chrome beacon
onyx fjord
#

Is the client/server system time unsynchronized?

#

do you know which packet that is?

green prism
chrome beacon
#

Timestamp is included in the chat messages

tardy delta
chrome beacon
green prism
chrome beacon
#

Have you thought about just using that lib?

#

Instead of making your own

green prism
#

bad luk

chrome beacon
#

Time to fork

green prism
#

Just thinking about having to download the whole code and duplicate it in the proj to change that InventoryType.Furnace...

#

makes me lazy ahah

chrome beacon
#

You know it's less work then rewriting the entire thing

green prism
onyx fjord
#

pull request?

#

what are minecraft and bukkit logger names

tepid ore
#

I have this code for a void world chunk generator in my plugin: https://paste.helpch.at/ekovirisah.java. However, I want to support 1.17+ version to be used and some of the methods from 1.18+ does not exist in 1.17. How would I go about doing this?

tardy delta
#

how tf is that 54 lol

hasty prawn
#

wtf LOL

tardy delta
#

i fucked up few minutes ago by clearing token buffer by calling parse recursive lol

hasty prawn
#

Maybe it just appended the complete sum and (2+2) together?

tardy delta
#

might have happened ye

#

mye actually im not breaking loop when i encounter () and parse parenthesis

hasty prawn
#

Does yours have a panic attack if you give it negative numbers

tardy delta
#

should be skipping (internal expression).length tokens ig

#

no? negative numbers work fine

hasty prawn
#

That's good

tardy delta
hasty prawn
#

I only ask because differentiating between a negative and a subtraction operator

#

is something

tardy delta
#

ah my way to distinguish

hasty prawn
#

Well the math is wrong but it took them atleast

hasty prawn
#

I guess

tardy delta
#

ill probably switch to an indexed loop instead of looping over input.toCharArray

hasty prawn
#

Should switch to RPN peepoGiggles

tardy delta
#

ah this not working lol

onyx fjord
#

can i add column number in ij?

#

like somewhere in editor

#

to have an idea where to break line

#

nvm

#

its in right bottom

tardy delta
#

lol

#

hmm might do smth like this to dintinguish between a syntax exception and a recursive call to parse cuz parse clears the token buffer which i dont want when recursing

#

i miss the c++ style of default parameters tho :(

hasty prawn
#

What is hasPanicked? Lol

tardy delta
#

indicates whether the prev expression failed

#

cuz normally at the end of my parse method, i clear the buffer and return the calculation

#

if i throw an exception earlier then the buffer isnt clear and next expression will be fucked up

hybrid spoke
#

can u make it swear if it panicked

hasty prawn
#

I second this idea

hasty prawn
tardy delta
#

mye just thought that too lmao

#

instead of doing this bs

#

my tokens should be a static field then smh

hasty prawn
#

I would've thought you make a new Expression for each one

tardy delta
#

actually i should have a local tokenlist variable cuz recursive parsing fucks up with the main expression then tokens

#

nah

#

probably should be creating some kind of expression obj

charred blaze
tardy delta
#

time to look at how crunch does it lol

#

@hasty prawn this feels hacky

hasty prawn
#

Nah just do it when you throw that error

#

Not in the error itself

tardy delta
#

that are a lot of places lol

hasty prawn
#

Make a method for it then? PauseChamp

tardy delta
#

for what lol

hasty prawn
#

For throwing the error and clearing the tokens

tardy delta
#

ah smh

hasty prawn
#
private void error(String message) {
  ExpressionParser.resetState();
  throw new InputMismatchException(message);
}

i guess

tardy delta
hasty prawn
#

yeah

boreal seal
#

im trying to save an object that i created

#

why this is the output

hasty prawn
#

Did you put @EventHandler above it

boreal seal
#

sec ill send some code

#

why satic

#

its an event

#

static*

tardy delta
#

satan

hasty prawn
#

Also true, shouldn't be static

boreal seal
#
public class RTPLoc{

    private int count;

    private int x;

    private int y;

    private int z;

    private World world;



    public RTPLoc(Player player,int count) {
        this.x = player.getLocation().getBlockX();
        this.y = player.getLocation().getBlockY();
        this.z = player.getLocation().getBlockZ();
        this.count = count;
        this.world = player.getWorld();
    }

    //methods to get vaules later.
    public int getx() {
        return x;
    }
    public int gety() {
        return y;
    }
    public int getz() {
        return z;
    }
    public int getcount() { return count; }
    public World getworld() { return world; }
}
#

my data class

#

so why the output is like this?

#

i dont want use minecraft Location

#

its too heavy to load up.

hasty prawn
#

You have to make it ConfigurationSerializable

boreal seal
#

i'm not very familiar with yaml concept

#

i use mysql usually

#

ill go to docs

hasty prawn
#

Implement that and add one of the deserialization methods it says

boreal seal
#

yeah i see

#

didnt really get it

#

but ill make it toString

#

didnt really understand what they meant there

noble crown
#

hi, can i remove player's resourcepack (server)?

dire marsh
noble crown