#help-development

1 messages · Page 1886 of 1

dense heath
#

Alrighty! Just booted up my drive with all my tools, I'll make quick work of this

hushed stirrup
#

Persistent Data Container?

eternal oxide
#

?pdc

lean gull
#

is there a way to make a lot of if statements cleaner?

eternal oxide
#

switch statements and early return

lean gull
#

what's that

eternal oxide
#

it all depends on yoru if requirements.

spiral light
eternal oxide
#

If possible a Switch statement is much cleaner, The early return is exit out as soon as possible if you know you can

#

Lastly, if you are reusing the same test over and over in different places, don't, use variables

dense heath
#

Where should I send it?

#

Ah, actually, here

#

?paste

undone axleBOT
dense heath
#

If you'd like, you can go ahead and reverse dump that from your terminal

glossy venture
#
List<PermissionTree> trees = getGroups()
        .stream()
        .map(PermissionGroup::getPermissions)
        .collect(Collectors.toList());
trees.sort(PermissionSorters.GROUP_TREES_BY_WEIGHT);
``` will this be extremely slow?
glossy venture
#

it maps, collects and sorts it

lean gull
#

how do i know if my code can be laggy? im afraid of making something that will be ok when i test it but when more players will come on when i release the server, it will be laggy

eternal oxide
#

experience

lean gull
#

what's benchmark

dense heath
lean gull
#

idk how to do that

quaint mantle
#

How can I change a block to Air with its Location, World#setBlock wants a BlockData, whats that

quaint mantle
#

than ku

quaint mantle
#

Can u add custom potion effects through Spigot?

#

yes

#

How?

#

To a potion item? or to an entity

#

Entity

spiral light
quaint mantle
#

Like a effect called Dappaness

quaint mantle
#

Yea

#

Well I guess you could create the effects, but idk about the status effect

#

dont think so

#

Aight

#

thanks for ur help

spiral light
#

i dont think the player would see it

quaint mantle
#

How can I get the player who is trying to craft an item from CraftItemEvent

tender shard
#

getWhoClicked

#

@quaint mantle

quaint mantle
#

OO

#

make sure to cast tho

tender shard
#

yeah and also check if the HumanEntity is instanceof Player. Player currently is the only known thing that implements HumanEntity, but other plugins might add some weird other implementations, and also in the future other HumanEntities could be added

#

Is anyone here familiar with MockBukkit?

cold field
tender shard
quaint mantle
#

Which event is fired when players wishper

tender shard
quaint mantle
#

Whisper

#

typo 😅

tender shard
#

wisper?

#

ah

vague swallow
#

you mean when he does /msg?

tender shard
#

whisper yes

vague swallow
#

or /tell?

cold field
quaint mantle
#

Yea

#

/w

tender shard
blazing rune
#

Hello can I talk here?

quaint mantle
#

#general my friend

tender shard
#

so there is no event

vague swallow
#

I think it's the same event for all the executed commands

quaint mantle
#

I mean there is something called /tell

blazing rune
#

Anyway...

#

Is there a way to change player's chat prefixes

quaint mantle
#

Yes

blazing rune
#

Well

vague swallow
#

@tender shard What event gets fired if someone executes a command?

quaint mantle
#

So, what u can do is listen to the chat and then cancel that event and send a custom message

blazing rune
#

Ok how do I explain this

quaint mantle
#

no, i guess, unless you do what this guy said

tender shard
#

change the format in that event

blazing rune
#

I know that but

quaint mantle
#

oh

#

yea

vague swallow
#

@quaint mantle So try to use a PlayerCommandPreprocessEvent

blazing rune
#

I'm trynna make like to prefixes

#

1 for non-ops and for ops

tender shard
#

use the event I sent above, then do sth like
event.setFormat("[YourPrefix] %s: %s")

#

first %s is the name, second %s is the msg

blazing rune
#

I do this: e.setFormat(ChatColor.RED + "" + ChatColor.BOLD + "ADMIN " + ChatColor.WHITE + e.getFormat());

blazing rune
quaint mantle
tender shard
#

however you have to take namespaces into account

quaint mantle
#

it doesnt have a method for that ig

tender shard
#

it could also be /minecraft:tell

quaint mantle
#

oo

#

sorry

blazing rune
#

Ok the server is taking its time to restart

#

Give it a few mins

vague swallow
tender shard
#

use the placeholders

#

%s %s

blazing rune
#

@EventHandler
public void playerChat(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
e.setFormat(ChatColor.GRAY + "" + ChatColor.BOLD + "MEMBER " + ChatColor.GRAY + e.getFormat());
if (p.isOp()) {
e.setFormat(ChatColor.RED + "" + ChatColor.BOLD + "ADMIN " + ChatColor.WHITE + e.getFormat());
}
}

tender shard
#

it expects something that can be run through String.format

blazing rune
#

This is my code

#

I'm sure you can point out the problems

tender shard
#

that looks correct except that you double the format for OPs

tender shard
#
public void onChat(AsyncPlayerChatEvent event) {
        String prefix = "MEMBER";
        if(event.getPlayer().isOp()) {
            prefix = "ADMIN";
        }
        event.setFormat(prefix + " %s > %s");
    }
#

that results in
MEMBER mfnalex > my messsage
and

ADMIN someoneelse > other message```
blazing rune
#

I'll send you the screenshot

tender shard
#

this is the screenshot @blazing rune sent

quaint mantle
#

use to make a nice cool box

tender shard
#

and it's exactly as I said

blazing rune
quaint mantle
blazing rune
tender shard
#

You first change the format and you set the format again adding to the old format

quaint mantle
#

but we do 😦

blazing rune
#

:/

blazing rune
tender shard
blazing rune
tender shard
#

did you understand why your code duplicated the prefix?

vague swallow
#
    public void onChat(AsyncPlayerChatEvent e) {
        Player p = e.getPlayer();
        if(p.isOp()){
            e.setFormat("§4§l(Admin) §f" + p.getDisplayName() + " > " + e.getMessage());
        } else e.setFormat("§7§l(Member) §f" + p.getDisplayName() + " > " + e.getMessage());
    }
tender shard
#

the format expects a string to be used with String.format

#

it's not needed to manually insert the player name and message

#

that's what the %s placeholders are for

vague swallow
#

yeah that's just what I did when I did it some months ago

#

but ty

tender shard
#

also it would be way easier to simply save the prefix in a variable, then use that to change the format instead of duplicating the p.getDisplayname + " > " + e.getMessage() part 🙂

blazing rune
#

Is it better to use the chatcolor or §

tender shard
#

ChatColor

#

but

vague swallow
#

What you like the most

tender shard
#

if you want to make it configurable

#

you should use &c color codes, and run them through ChatColor.translateAlternateColorCodes

#

because it might happen that the § character will change someday

tender shard
#

if you want it configurable, use &c codes. If not, you can either hardcode &c codes or use ChatColor.RED

blazing rune
jolly acorn
#

Hey can i dm someone? Since theres a error in my console i dont know and i already deleted ranksigns plugin.

jolly acorn
#

@blazing rune ima dm

blazing rune
#

Ok

jolly acorn
tender shard
undone axleBOT
#

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

tender shard
jolly acorn
#

This thing is showing up on me console idk what it means

#

And iam freaking out

jolly acorn
jolly acorn
#

Bro iam literally shaking idk what this means and iam very worried

tender shard
#

please do not DM me with stuff that belongs here

jolly acorn
#

K i cant semd pics here

tender shard
#

here's the error they DMed me

jolly acorn
#

Okay thanks

tender shard
#

resend the full error as text

#

?paste

undone axleBOT
jolly acorn
tender shard
#

is RankSigns your plugin?

jolly acorn
#

I already deleted it

tender shard
#

I mean - did you code that plugin?

#

because if not, this is the wrong channel, this channel is about coding your own plugins. if it's not your plugin, you should head to #help-server and/or contact the author of that plugin

jolly acorn
#

I didnt code it

#

I didnt do nothing

#

I just downloaded it

#

And troed it and it dodnt work

#

So k deleted it

#

And the author doesnt have discord

#

Ima check the supporr

spiral light
#

again here with 3rd party plugin help ^^ i see you dont understand it probably

jolly acorn
#

I iam in help server but the chat seems inactive

#

Amd again they dont have discord or any support

#

See

#

I didnt code or anything

tender shard
#

this

#

channel

#

is for coding your plugins

minor fox
#

Are there any libraries for asynchronous chunk loading?

tender shard
#

yes

#

PaperLib

#

(when using spigot, it uses synced chunk loading though. It only uses async loading when you're on paper or a paper fork)

#

@minor fox

minor fox
shrewd solstice
#

how can i give a knockback effect on every entity in front of me???? 1.16.5

#

or damage

minor fox
#

is spigot 1.18 able to run on a 1.17 server

frosty tinsel
tender shard
#

if you run spigot 1.18 it's a 1.18 server

#

do you mean whether you can upgrade from 1.17 to 1.18?

#

if so: yes

minor fox
#

no the api

tender shard
#

ah okay

#

if you do not use api methods added in 1.18 it runs fine on 1.17

hardy swan
# minor fox no the api

as long as the package names and method names are the same and present in runtime, it doesn't matter where those come from

blazing rune
#

Hello I have a question, how do I add permissions to players without a permission plugin?

tender shard
tender shard
#

you can also check my permission plugins source code ^^

#

it's extremely simple

shrewd solstice
#

guys?

#

is there a way to detect blocks between 2 position im in 1.16.5

tender shard
#

blocks between 2 poisionts?

shrewd solstice
#

yes

tender shard
#

like everything between 0,0,0 and 100,100,100?

#

you can just loop over the coordinates inside your area

shrewd solstice
#

like every block between my position and 8 block in front of me

tender shard
#

Player#getLineOfSight

shrewd solstice
#

?

tender shard
#

?

#

that's the method you are looking for

wide imp
#

can anyone help me figure out why configuration comments are duplicating on restart

#

choco said something about this but i havent been able to find anymore information about it

tender shard
#

your own plugin?

wide imp
#

yes

tender shard
#

show your code to save the config pls

olive lance
#

Comments in yaml is recent?

#

I thought you could always comment

wide imp
#

and the config file grows exponentially

tender shard
wide imp
tender shard
quiet ice
#

btw commented configs are done by default now

wide imp
#

from what i can see mcmmo had the same

hybrid spoke
#

thats just the how. we need the where

wide imp
#

i saw something in mcmmo discord about snakeyml changing in the recent updates?

vague swallow
#

Is there a way to make ghost players without a team?

wide imp
tender shard
#

what are ghost players?

vague swallow
#

like if the player is transparent

hardy swan
#

spectator?

vague swallow
#

nooo

tender shard
#

you could use packets

vague swallow
#

if seeFriendlyInvisibles is true in a team then your invisible teammates are transparent

hybrid spoke
#

5Head make them invisible and give them glowing

vague swallow
hybrid spoke
#

its not really what you wanna achieve

#

but it goes in that direction

vague swallow
#

I want to see the skin, because I want to make holograms

#

like in star wars

hybrid spoke
#

then not

hardy swan
#

oh you are thinking of translucent

hybrid spoke
#

this would just outline the player and make the rest invisible

hardy swan
#

not transparent

#

i think just the head is possible cuz that's what spectator mode is, never seen anyone did a full body ghost

vague swallow
vague swallow
hybrid spoke
#

seems like its clientside

vague swallow
#

no it's not, I sadly can't upload screenshots here

tender shard
#

send a packet to the client that the player is spectator and that you have this "friendly team" thingy

tender shard
hardy swan
#

oh wait now i think of it i did see a full body ghost before

#

when i played block hunt haha

hybrid spoke
#

same in real life

#

oh

hardy swan
#

oh

#

_>

hybrid spoke
#

but actually never saw that before

#

other than in spectator

quaint mantle
#

um so i made a lifesteal smp server with spigot on aternos for 1.18.1 then it says U need spigot and i cant go in the server

hybrid spoke
hardy swan
#

confusing in so many levels

tender shard
#

aternos should be illegal anyway

#

worst hoster ever

quaint mantle
#

no

hardy swan
#

free tho

hybrid spoke
#

its okay for a free one

#

but i would not give them any money

hardy swan
#

is realms good?

jagged thicket
#

NO

tender shard
#

realms suck

jagged thicket
#

aternos better tbh

#

realms so bad

hardy swan
#

can you even develop for realms servers

#

what kind of api do they run on if so

proud basin
#

I don’t think so

#

just because you don’t get access to any of the files

tender shard
#

it's vanilla

hardy swan
#

wow that really suck

#

actually suck wtf

#

even aternos is better

quaint mantle
#

no

eternal oxide
#

yes

#

I think

#

I never had any issues reading async

#

you can;t write though

hybrid spoke
#

depends on the version

tender shard
#

if the chunk is unloaded, you're gonna be fucked

#

if it's loaded there's a good chance reading will work

hybrid spoke
#

it will 1.8>

tender shard
#

who still uses 1.8 shouldn'T be allowed to ask here anything anyway 😛

hybrid spoke
#

really depends on the usecase

#

i still have to use 1.8 since my plugins support it

tender shard
#

I dropped support for everything below 1.16 a few months ago and it was the best decision I ever made

#

(besides drinking jägermeister)

hardy swan
#

almost no one runs on 1.15 or 1.14

#

almost because i cant be sure lol

quaint mantle
hybrid spoke
hybrid spoke
#

at least 1.14

hardy swan
#

i heard 1.15 has shit performance too

quaint mantle
#

pff

ashen vessel
#

Trying to add the mongodb java driver to pom.xml. However it just says depency not found

quaint mantle
#

1.18 didnt went too far

hybrid spoke
#

1.15 is okay

hybrid spoke
ashen vessel
#

?paste

undone axleBOT
ashen vessel
hardy swan
#

is there a fixed timing spigotmc updates its api

hybrid spoke
hardy swan
#

yea that one and the Xeroblahblah api

hybrid spoke
#

3 hours +-

hardy swan
hardy swan
spiral light
tender shard
#

no

#

of course not

#

I love my jäger

spiral light
#

wtf xD nice

hybrid spoke
#

how did that picture came so fast

tender shard
#

mobile phones exist lol

hardy swan
#

he drinking rn

hybrid spoke
tender shard
#

because I'm cold af

spiral light
tender shard
#

nah I don't like it when it's cold lol

#

I drink it at room temperature

hybrid spoke
#

ew

spiral light
#

its burning at room temp. ^^

tender shard
#

nah

#

a nice warm jäger

hybrid spoke
ashen vessel
#

Yep

hybrid spoke
#

did you try to invalidate your caches/restart/force download

tender shard
#

run mvn clean package -U and then send the FULL maven log pls

ashen vessel
hybrid spoke
#

what ide do you use

ashen vessel
#

Intellij

ashen vessel
hybrid spoke
#

File > Invalidate Caches

visual tide
tender shard
#

why not

hybrid spoke
#

just install maven xD

spiral light
#

only shit performance if your pc / server is bad ^^

visual tide
#

not installed 😐

ashen vessel
#

Lol

hybrid spoke
#

otherwise intellij provides quick commands you can use even without maven

tender shard
visual tide
ashen vessel
#

Because Im a shit java developer that doesnt no fuck all what hes doing

#

🙂

ashen vessel
tender shard
#

oh shit

#

it doesnt show the GUI

hybrid spoke
#

ugh, default design

tender shard
#

when you click on the "m" button

#

you can enter "mvn clean install -U"

tender shard
hardy swan
#

ok hear me out

#

mvn archetype::generate

ashen vessel
#

Ok it works now

ashen vessel
#

Still get a maven shaded thing caution message but idrc. It builds successfully

tender shard
tender shard
#

I'd always think something's wrong lol

undone axleBOT
ashen vessel
tender shard
ashen vessel
#

Idk how to exclude META-INF

hybrid spoke
#

once also had colored icons

tender shard
#
    <plugins>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.2.4</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <artifactSet>
                <includes>
                  <include>de.jeff_media:JeffLib-*</include>
                </includes>
              </artifactSet>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/**</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <createDependencyReducedPom>true</createDependencyReducedPom>
          <createSourcesJar>true</createSourcesJar>
        </configuration>
      </plugin>
hybrid spoke
#

but they are gone somehow

tender shard
#

important thing is the <filter> part with the META-INF thing

hardy swan
#

<createDependencyReducedPom>true</createDependencyReducedPom>?

#

nvm

tender shard
#

you only need this:

#
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/**</exclude>
                  </excludes>
                </filter>
              </filters>
hardy swan
#

i don't need nothing

ashen vessel
#

Ok thanks

quiet ice
#

What does ** do again? Only match files in the folder or does it also do it recursively?

tender shard
hybrid spoke
#

its so monotone and boring

tender shard
#

it's about the content

hybrid spoke
#

i get hyped by mine

tender shard
#

I wouldn't even notice if the colors were different, I don't look at them

hybrid spoke
#

so change it for us all

tender shard
#

okay send a file to import

granite beacon
#

Question, it seems like when using getResource() and then Files.copy my file is growing in size and getting corrupted.
It's happening even after no other section of code access the file/directory.

Files.copy(getResource("region.slime"), Paths.get(mapFolder.getAbsolutePath() + "\\region.slime"), StandardCopyOption.REPLACE_EXISTING);

Top is the copy using that bit of code and bottom is the resource folder.

hardy swan
#

best colors

hybrid spoke
#

so we can look without being bored at your screens

tender shard
hybrid spoke
tender shard
#

I looked through the most popular 20 themes in the plugin section and they all looked a 12 year old created them

quiet ice
#

Just go with the eclipse theme

tender shard
quiet ice
#

It is a theme after all

tender shard
#

I am glad I uninstalled eclipse 1.5 years ago

#

never looked back

#

Idea truly is superior

hybrid spoke
#

most important plugin still is pokemon progress

granite beacon
#

Eclipse < IJ

tender shard
#

eclipse is like the weird old drunk uncle of intellij

hardy swan
#

netbeans grandpa

mellow edge
#

which event I must use to detect when someone steps on wheat and try to break it

quiet ice
#

I don't really understand why people switch IDEs, it is such a pain to get comfy with one

tender shard
# mellow edge which event I must use to detect when someone steps on wheat and try to break it
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onTrampleCrops(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        if(event.getAction() != Action.PHYSICAL) return;
        if(!main.getConfig().getBoolean(Config.LEATHER_PREVENTS_TRAMPLING)) return;
        if(event.getClickedBlock() == null || event.getClickedBlock().getType() != Material.FARMLAND) return;
        double chance = 0;
        for(ItemStack item : player.getInventory().getArmorContents()) {
            if(item==null) continue;
            if(item.getType().name().startsWith("LEATHER_")) chance += 0.25;
            if(main.getConfig().getBoolean(Config.ONLY_REQUIRE_BOOTS) && item.getType() == Material.LEATHER_BOOTS) {
                chance = 1.0;
                break;
            }
        }
        if(random.nextDouble(0,1) < chance) {
            event.setCancelled(true);
        }
    }
#

TL;DR InteractEvent, Action.PHYSICAL

mellow edge
#

so the same as pressure plate

#

thanks!

tender shard
#

np

quiet ice
granite beacon
#

I'll give it a go

tender shard
granite beacon
tender shard
#

where do you want to save it?

#

is mapFolder inside the world folder?

granite beacon
#

/maps/

#

no, it's in the main server folder

tender shard
#

oh okay nvm then

worldly ingot
#

saveResource() will save it in the same directory you have it in your local project

tender shard
#

yeah but they need it in server root/maps/

worldly ingot
#

relative to your plugin's dir

#

Yeah then you have to save it with getResource() ;p

tender shard
#

yes 🙂 I'd just copy bukkits saveResource code and adjust it lol

worldly ingot
#

There is getResourceAsStream() though iirc

tender shard
#

yes

granite beacon
#

that works too lol

worldly ingot
#

Can then write the bytes to an arbitrary file

tender shard
#
    public void saveResource(@NotNull String resourcePath, boolean replace) {
        if (resourcePath != null && !resourcePath.equals("")) {
            resourcePath = resourcePath.replace('\\', '/');
            InputStream in = this.getResource(resourcePath);
            if (in == null) {
                throw new IllegalArgumentException("The embedded resource '" + resourcePath + "' cannot be found in " + this.file);
            } else {
                File outFile = new File(this.dataFolder, resourcePath);
                int lastIndex = resourcePath.lastIndexOf(47);
                File outDir = new File(this.dataFolder, resourcePath.substring(0, lastIndex >= 0 ? lastIndex : 0));
                if (!outDir.exists()) {
                    outDir.mkdirs();
                }

                try {
                    if (outFile.exists() && !replace) {
                        this.logger.log(Level.WARNING, "Could not save " + outFile.getName() + " to " + outFile + " because " + outFile.getName() + " already exists.");
                    } else {
                        OutputStream out = new FileOutputStream(outFile);
                        byte[] buf = new byte[1024];

                        int len;
                        while((len = in.read(buf)) > 0) {
                            out.write(buf, 0, len);
                        }

                        out.close();
                        in.close();
                    }
                } catch (IOException var10) {
                    this.logger.log(Level.SEVERE, "Could not save " + outFile.getName() + " to " + outFile, var10);
                }

            }
        } else {
            throw new IllegalArgumentException("ResourcePath cannot be null or empty");
        }
    }
#

that's the builtin saveResource method 😄

quiet ice
#
                        byte[] buf = new byte[1024];

                        int len;
                        while((len = in.read(buf)) > 0) {
                            out.write(buf, 0, len);
                        }

                        out.close();
                        in.close();

I'd rather use Java 10's in.transferTo(out); and also use try-with-resources instead of these few lines which are just a memory drain

#

You can tell that this method was written when Java 8 (perhaps even Java 7) wasn't a thing. Nowadays we have a lot more things that are vastly superior to this

quaint mantle
#

and md_5 just not having much time to reformat and rewrites those codes

quiet ice
#

And I am too lazy PRing stuff to spigot.

quaint mantle
#

spigot could be not that big if someone do it

#

like a massive 2mb rewrite?

tender shard
granite beacon
#

Could it be because of how java is packaging the file?

quiet ice
#

Then just delete the file beforehand honestly

#

Make sure the append modifier is not set

lean bone
#

Could anyone help me with this?

quiet ice
#

Or just don't save if the file is already present

granite beacon
quiet ice
#

Then why would it grow in size?

granite beacon
#

I don't know

quiet ice
#

Actually, what do you expect to happen in the first place?

granite beacon
#

I want to save a file from my resource folder to a folder

quiet ice
#

That the file is some kind of virtual link to the jar entry or do you expect a hard copy (which will require some space on the file system)?

hardy swan
#

you can change file's name after

granite beacon
quiet ice
#

Ah, you mean that the file is actually not stored as it should be

granite beacon
#

Correct

#

It's growing in size and corrupting

quiet ice
#

What happens if you use mvn clean package instead of mvn package to build the jar?

hollow beacon
#

isnt the initial resource folder read only

#

i just started reading, which file is corrupting?

granite beacon
#

region.slime

quiet ice
#

Hm, and the resource is inflated even in the jar?

granite beacon
quiet ice
#

(i. e. unzip the jar and check the file sizes)

granite beacon
#

let me see

#

how can I check the size with jd gui?

quiet ice
#

Just unzip the jar

hollow beacon
#

just open it as a zip -ninja'd

quiet ice
#

If not, some whacky JVM or Classloader stuff is going on.
If yes, maven is being strange (I have seen it inflating jar entries in the past, but only on class files as of now)

hollow beacon
#

i guess u just disable filtering

granite beacon
#

I am so confused as to how I open this jar lol

hollow beacon
#

right click

#

and open with winrar

#

or change the .jar to .zio

#

and then double click it

granite beacon
#

step one get winrar got it

hollow beacon
#

thats it, if its open with winrar you should see the files

granite beacon
#

Size has gone up on compile

#

nice

hollow beacon
#

try disabling filters

granite beacon
#

so

#
<nonFilteredFileExtensions>      <nonFilteredFileExtension>slime</nonFilteredFileExtension>
</nonFilteredFileExtensions>
#

?

quiet ice
#

Likely

hollow beacon
#

yep

granite beacon
#

here we go, fingers crossed

#

So

#

It's not compiling now

hollow beacon
#

show your pom

#

?iin

#

?bin

#

!bin

#

idk

granite beacon
#

no worries lol

eternal oxide
#

?paste

undone axleBOT
hollow beacon
#

thanks.

granite beacon
hollow beacon
#

whats the error?

granite beacon
#

if only I knew

royal vale
#

How to translate hex codes to color codes?

granite beacon
tender shard
#

ff0000 -> &x&f&f&0&0&0&0

#

and then run it through translateAlternateColorCodes

granite beacon
#

Oh wait he meant in game

#

I'm dumb

tender shard
#

idk 😄

#

I assumed it's for configurable messages

hollow beacon
granite beacon
#

Would it be a bad idea to just

<resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
        </resources>
hollow beacon
#

try running mvn package -X

#

for debugging

granite beacon
#

and just dump that in a paste?

hollow beacon
#

sure

granite beacon
#

it seems to be an issue when it attempts to filter a zip

hollow beacon
#

show me

granite beacon
#

I deleted all zips and now it compiled

hollow beacon
#

coolsies

granite beacon
#

weird

hollow beacon
#

also add zip to your nonFilteredFileExtension then

granite beacon
#

I was just about to do that

#

works

#

thanks man ❤️

hollow beacon
#

lovely

#

you're welcome

royal vale
#

For this:
&#017fc6&lO&#1299d1&lr&#23b2dd&le&#33cce8&lo&#44e5f4&lM&#55ffff&lC

tender shard
#

no hashtag

hollow beacon
#
public String translateHexColorCodes(String message) {
        //Sourced from this post by imDaniX: https://github.com/SpigotMC/BungeeCord/pull/2883#issuecomment-653955600
        Matcher matcher = HEX_PATTERN.matcher(message);
        StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
        while (matcher.find()) {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, COLOR_CHAR + "x"
                    + COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
                    + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
                    + COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
            );
        }
        return matcher.appendTail(buffer).toString();
    }
royal vale
#

I've tried with &x&0&1&7&f&c&6

#

Returns orange to

tender shard
#

you have to turn ff0000 into &x &f &f &0 &0 &0 &0

royal vale
#

Cuz last one is &6

tender shard
#

without the spaces

royal vale
# tender shard without the spaces
public static String color(String string) {
        final Pattern hexPattern = Pattern.compile("&#([A-Fa-f0-9]{6})");
        Matcher matcher = hexPattern.matcher(string);
        StringBuilder buffer = new StringBuilder(string.length() + 4 * 8);
        while (matcher.find()) {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, "&x&" 
                    + group.charAt(0)
                    + "&" + group.charAt(1)
                    + "&" + group.charAt(2)
                    + "&" + group.charAt(3)
                    + "&" + group.charAt(4)
                    + "&" + group.charAt(5)
            );
        }
        return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
    }
#

It looks like an bungee api issue

#

&x&0&1&7&f&c&6 translates to orange

tardy delta
#

should i separate my database and cache implementation?

tender shard
#

try to hardcode &x&f&f&0&0&0&0

#

see if it shows a solid red

royal vale
tender shard
#

it does work fine for me in bungee

royal vale
#

I literally put &x&0&1&7&f&c&6 in the config

tender shard
#

and you ran that through chatcolor.translate... ?

royal vale
#

So it just translated via chatcolor

#

Yes

tender shard
#

where did you use it? in the chat? actionbar? ... ?

royal vale
#

I'm on 1.17

#

Server ping

#

Worked before

#

Now it doesn't

tender shard
#

what did you change since it doesn't work anymore?

royal vale
#

Using bungee api 1.18

#

Didn't change anything about the code itself

#

Except

#

StringBuffer

#

to StringBuilder

tender shard
#

can you show your full server ping code?

royal vale
#
} else {
    serverPing.setDescriptionComponent(new TextComponent(NetworkTools.color(String.join("\n", Configs.config.getStringList("modules.motd.message")))));
}
#
e.setResponse(serverPing);
#
public class ProxyPingListener implements Listener {

    @EventHandler
    public void onProxyPing(ProxyPingEvent e) {
tender shard
#

I have this:

    @EventHandler
    public void onPing(ProxyPingEvent event) {
        if(!config.getBoolean("enabled")) return;
        ServerPing ping = event.getResponse();
        ping.setPlayers(new ServerPing.Players(config.getInt("max-players"), ProxyServer.getInstance().getOnlineCount(),ping.getPlayers().getSample()));
        String motd = config.getString("motd");
        if(motd == null || motd.length()==0) return;
        motd = motd.replace("%countdown%", getCountdown());
        BaseComponent[] components = TextComponent.fromLegacyText(TinyTextUtils.format(motd));
        BaseComponent component = components[0];
        for(int i = 1; i < components.length; i++) {
            component.addExtra(components[i]);
        }
        ping.setDescriptionComponent(component);
        if(favicon != null) {
            ping.setFavicon(Favicon.create(favicon));
        }
        event.setResponse(ping);
    }

So the text is translated by TinyTextUtils.format, which looks like this:

```java
#

whoops

trail bough
#

java [java]

tender shard
#

wait I'll just upload the whole thing to github

royal vale
#

I used java 8 before

tender shard
#

doesnt change anything

royal vale
#
public static String color(String string) {
        final Pattern hexPattern = Pattern.compile("&#([A-Fa-f0-9]{6})");
        Matcher matcher = hexPattern.matcher(string);
        StringBuffer buffer = new StringBuffer(string.length() + 4 * 8);
        while (matcher.find()) {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, ChatColor.COLOR_CHAR + "x"
                    + ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1)
                    + ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3)
                    + ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5)
            );
        }
        return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
    }

^ Old

public static String color(String string) {
        final Pattern hexPattern = Pattern.compile("&#([A-Fa-f0-9]{6})");
        Matcher matcher = hexPattern.matcher(string);
        StringBuilder buffer = new StringBuilder(string.length() + 4 * 8);
        while (matcher.find()) {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, "&x&"
                    + group.charAt(0)
                    + "&" + group.charAt(1)
                    + "&" + group.charAt(2)
                    + "&" + group.charAt(3)
                    + "&" + group.charAt(4)
                    + "&" + group.charAt(5)
            );
        }
        return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
    }

New

hollow beacon
#

remove the chatcolor translatething

royal vale
#

Why??

tender shard
hollow beacon
#

iirc it gets handled by bungee itself if its that format?

royal vale
#

The translate is so normal color codes translate to

hollow beacon
#

hmm

tender shard
hollow beacon
#

can you remove it and try

translateAlternateColorCodes("&", color(message));

#

so essentialy removing it from the method

#
public static final Pattern HEX_PATTERN = Pattern.compile("&#(\\w{5}[0-9a-f])");

public String translateHexCodes (String textToTranslate) {

        Matcher matcher = HEX_PATTERN.matcher(textToTranslate);
        StringBuffer buffer = new StringBuffer();

        while(matcher.find()) {
            matcher.appendReplacement(buffer, ChatColor.of("#" + matcher.group(1)).toString());
        }

        return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());

    }
tender shard
#

seems like your color() method does stupid stuff

hollow beacon
#

your regex is fucked

tender shard
#

print out the whole translated string to console WITHOUT running it rhough translateAlternateColorCodes

#

you did something wrong with the regex, yes

#

you shouldnt use ChatColor.of to translate it

hollow beacon
#
public String translateHexColorCodes(String startTag, String endTag, String message)
    {
        final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
        Matcher matcher = hexPattern.matcher(message);
        StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
        while (matcher.find())
        {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, COLOR_CHAR + "x"
                    + COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
                    + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
                    + COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
                    );
        }
        return matcher.appendTail(buffer).toString();
    }
``` this has the most positive ratings on spigot
tender shard
#

you should simply manually turn ff0000 into &x&f&f&0&0&0&0

#

it will 100% work fine then

royal vale
#

But even §x§0§1§7§f§c§6O makes orange

tender shard
#

yes sure you must not use §

royal vale
#

I know

#

I just used it in the config

#

And it still shows orange

#

...

hollow beacon
#

try my code

#

has the most ratngs on spigot

#

lol

royal vale
hollow beacon
#

you need a starter for it

#

so a start char

crimson verge
#

i never had issues with ChatColor.of() so ._.

tender shard
#
    @EventHandler
    public void onPing(ProxyPingEvent event) {
        if(!config.getBoolean("enabled")) return;
        ServerPing ping = event.getResponse();
   
        BaseComponent[] components = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',"&x&f&f&0&0&0&0TEST TEST TEST"));
        BaseComponent component = components[0];
        for(int i = 1; i < components.length; i++) {
            component.addExtra(components[i]);
        }
        ping.setDescriptionComponent(component);
        if(favicon != null) {
            ping.setFavicon(Favicon.create(favicon));
        }
        event.setResponse(ping);
    }

This will 100% give you red solid text

royal vale
stone sinew
#
public String colorize(String s) { return hexColor(ChatColor.translateAlternateColorCodes('&', s)); }
public String removeColor(String s) { return s.replace("§", "&"); }
    
private Pattern hexPattern = Pattern.compile("#([A-Fa-f0-9]){6}");
public String hexColor(String s) {
    if(s == null) return s;
    if(s.isEmpty()) return s;

    Matcher matcher = hexPattern.matcher(s);
    while(matcher.find()) {
        String color = s.substring(matcher.start(), matcher.end());
        s = s.replace(color, String.valueOf(ChatColor.of(color)));
        matcher = hexPattern.matcher(s);
    }
        
    return s;
}
```Here are my text color methods.
crimson verge
hollow beacon
royal vale
hollow beacon
#

hashtag

crimson verge
#

could be why

#

some 3rd part clients dont accept hex codes

royal vale
#

But like

#

it worked before

crimson verge
#

oh than maybe lunar dos

#

does*

tender shard
hasty prawn
#

Lunar also seemingly randomly breaks

stone sinew
hasty prawn
#

So it could still definitely be Lunar

crimson verge
#

lmfao

tender shard
crimson verge
#

dessie youre great

tender shard
#

what does the java version have to do with this

stone sinew
royal vale
#

That's what it used to do

tender shard
#

it doesn't make sense because the translation method simply isn't correct

#

I wasn't talking about any java version things

stone sinew
#

Makes sense to me too.

tender shard
#

oh sorry I quoted the wrong code

hasty prawn
#

Yeah my HEX color conversion is effectively the same as Yappery's

#

And I'm fairly certain it works Thonk

tender shard
#

https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/data/HexColor.java here's my hexcolor class and here's my textutils class to translate them and it works without any problems on all 1.16+ versions, both with spigot and bungeecord https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/TextUtils.java

GitHub

Contribute to JEFF-Media-GbR/JeffLib development by creating an account on GitHub.

GitHub

Contribute to JEFF-Media-GbR/JeffLib development by creating an account on GitHub.

crimson verge
#

also would still recommend testing on vanilla mc client if able uwu

hasty prawn
#

^^

tender shard
#

I'd suggest to print out the text before and after running it rhough translateAlternate..... to console

royal vale
#

Other servers have hex color codes

#

In their motd

#

Im so confused

tender shard
#

your translation method is broken, I've said that 10 times already

royal vale
#

it worked before!?!?

#

Lemme change it to yours

hollow beacon
#

welcome to programming

crimson verge
#

^ lmfao

#

sometimes shit just breaks for no good reason

#

gotta roll with the punches

tender shard
#

actually it doesn't 😄

hollow beacon
#

yeah it does

tender shard
#

if stuff breaks for you with no apparent reason, something MUST have changed

hollow beacon
#

i rolled out an app, worked all good. then the ios developers took a look at it and it just didn't work at all

tender shard
#

if the same code runs with the same input, it produces the same result

ancient plank
#

uwu

crimson verge
shrewd solstice
#

is there a way to give knockback to the mob im looking at?

crimson verge
#

is there a way, probably. is it gonna create a lag machine? also probably lmfao

#

i cant imagine a way to do that without a ton of lag

hasty prawn
#

Depends on how often you're checking

tender shard
#

I doubt that checking who a player looks at every tick will cause any lag

#

unless you check it in a distance of 10,000 blocks

crimson verge
#

LMAO fair

tender shard
#

every hostile mob basically checks its line of sight every tick

hasty prawn
#

I doubt they need to check every tick anyways

ancient plank
#

I wrote some pretty inefficient stuff recently

tender shard
#

true, just wanted to say it wouldn't really create a "lag machine" 🙂

ancient plank
#

good fun

hasty prawn
#

Applying knockback every tick is gonna make the mob, well not be there anymore KEKW

hasty prawn
tender shard
#

I'd check every tick if you're looking at an entity, and if yes, do a cooldown of 1 second or so when you've applied knockback to that mob

ashen vessel
#

?paste

undone axleBOT
ancient plank
hasty prawn
#

Awesome

ashen vessel
#

Ok so im trying to open a db connection and also access it from across classes. I am very noob with java so I can use it but not do anything I actually wanna do so I need help. https://paste.md-5.net/qalumafafu.java

tender shard
#

I can use it but not do anything I actually wanna do so I need help.
what?

ashen vessel
#

I have a very hard to understanding 100% how java works. Thats all

hollow beacon
tender shard
#

wrong reply? 😛

hollow beacon
#

whoops

royal vale
#

@tender shard used ur method

#

Still didnt work :(

hollow beacon
tender shard
# royal vale

print out the text BEFORE and AFTER you ran it it through translateAlternateColorCodes

royal vale
#

I did

hollow beacon
#

yeah

tender shard
hollow beacon
#

thats what i did for my xray plugin anyways

#

if you do it alot just make a thread

#

all good

#

let me chck

#

for (int x = 0; x <= 15; x++) {
for (int y = 0; y <= 255; y++) {
for (int z = 0; z <= 15; z++) {

minor fox
#

What is the recommended way of adding NMS to your project using paper?

tender shard
#

to get NMS, run buildtools --remapped, then add spigot as dependency

royal vale
hollow beacon
tender shard
hollow beacon
#

read some websites and you'll be good to go

tender shard
#

how do you generate that text

hollow beacon
#

he forgot the starting character

#

exactly like i said

tender shard
#

that's not the only problem

hollow beacon
#

your starting character is #

tender shard
#

ff0000 -> &x&f&f&0&0&0&0

ashen vessel
tender shard
ashen vessel
#

Just nvm ill do some reading

tender shard
#

sorry but that sentence is cursed lol

hollow beacon
#

lol

tender shard
#

noone can understand it

ashen vessel
#

Lmao I just realized that

royal vale
#

Just # instead of &#

ashen vessel
#

but its completely ignored by the public method on the bottom

tender shard
#

and you want to print "TEST"

hollow beacon
tender shard
#

then you should pass EXACTLY this to translateAlternateChatColor:

#

&x&f&f&0&0&0&0TEST

#

so basically: add a & in front of every char of your hex color, and in front of the whole color, add &x

#

#000000 -> &x&0&0&0&0&0&0
#FFFFFF -> &x&f&f&f&f&f&f

#

etc

ancient plank
#

someone should make a thread

ashen vessel
hasty prawn
#

I vote alex

tender shard
#

yeah pls open a thread for the hex color thing

#

hex colors

hollow beacon
#

the line you circeled is the initializer

#

oh i see

#

remove the first MongoClient

#

so

#

mongoClient = MongoClients.create();

#

that way it uses the public variable

tender shard
#

tbh @ashen vessel

#

?learnjava

undone axleBOT
tender shard
#

no offense but this is not a spigot related question, it's about basic concepts of java

#

you must know about variable scopes etc

shadow night
ashen vessel
#

Ik i just figured you guys would have the answer, Ill go over to the java discord (if there is one)

hollow beacon
#

i gave you the answer

hollow beacon
ashen vessel
#

Ik

#

I try that, but then it cant resolve that variable

shadow night
hollow beacon
shadow night
hollow beacon
hollow beacon
proud basin
#

isn't it getSchedulers?

ashen vessel
#

Ok so I know I wasnt going crazy

shadow night
proud basin
#

clear your cache

hollow beacon
#

try any other method

#

and that

ancient plank
#

:)

hollow beacon
#

in intellij try

file -> restart and invalidate caches

ashen vessel
ancient plank
#

xd

proud basin
#

bro

#

it literally says the issue

ashen vessel
#

Ik

ancient plank
#

just learn some java man

#

this is a very basic java issue

shadow night
proud basin
#

what spigot version is that

shadow night
tender shard
#

oh wait

#

I know your problem

#

you use that outside of any method etc, right?

#

show your full class pls

ancient plank
#

jeff media is big brain

proud basin
#

who?

tender shard
#

me

#

lulz

proud basin
#

ur mfnalex

tender shard
#

jeff media is my c0mp4niii

proud basin
#

that's what they all say...

ancient plank
#

problem solved ez

tender shard
#

yeah

#

that's what I suspected

vocal cloud
#

What happened to the zoom in on the logo. I was hoping for a meme where it enlarges slowly

proud basin
#

maybe the spigot server logo?

quiet ice
#

that never had a zoom to begin with

tender shard
#

nah it just gets filled up with md5's special sauce

#

i.e. water

vocal cloud
halcyon mica
#

How can I get a item type from a identifier?

#

i.e. a "minecraft:whatever" string

tender shard
tender shard
vocal cloud
#

yeahhhh

halcyon mica
#

You know, a valid material to initialize a item stack

trail bough
tender shard
#

valid materials are always minecraft:something

#

Material.valueOf("DIRT") for example

halcyon mica
#

That is not accepting a resource location though

tender shard
#

there are no custom blocks in spigot

#

they simply don't exist

#

what do you want to do anyway?

halcyon mica
#

it's fine, I'll just use the nms item registry

tender shard
#

that will not change anything

#

there simply are no custom items when you don't use client and server mods

#

period

worn tundra
#

Which you can overcome, by using resource packs.

tender shard
#

no

#

it's still vanilla items

#

it's still minecraft:note_block

worn tundra
#

Both for custom items and custom blocks, the latter requiring to sacrifice a few blocks with blockstates.

tender shard
#

just with custom textures for certain blockstates

#

yeah

#

it's still internally only minecraft:whatever blocks

worn tundra
#

For custom items you can do up to 2 billion textures per material

#

Yeah, of course. You don't really need it to be anything else.

worn tundra
tender shard
#

:3

#

I had that idea in a dream lol

#

ahaha

#

only took them 1.5 years

worn tundra
#

Premium plugin btw

tender shard
#

😄

#

unfortunately many paid plugins have way slower support than free ones

#

because most free devs care about ratings, while paid authors care mostly about income >.<

halcyon mica
#
        private ItemStack parseStack(JsonObject obj) throws JsonParseException {
            Item type = IRegistry.ITEM.getOptional(MinecraftKey.a(obj.get("type").getAsString())).orElseThrow(() -> new JsonParseException("Unable to parse item entry! Invalid Item Type: " + obj.get("type").getAsString()));
            net.minecraft.server.v1_16_R3.ItemStack item = new net.minecraft.server.v1_16_R3.ItemStack(type, obj.get("count").getAsInt());
            if(obj.has("nbt")) {
                try {
                    JsonElement e = obj.get("nbt");
                    String tag = e.isJsonObject() ? Cow.GSON.toJson(e) : e.getAsString();
                    item.setTag(new MojangsonParser(new StringReader(tag)).f());
                } catch(CommandSyntaxException ex) {
                    throw new JsonParseException("Unable to parse item entry! Invalid NBT data!", ex);
                }
            }
            return CraftItemStack.asBukkitCopy(item);
        }```NMS is really not hard to use when you have experience in client modding
#

I'd argue it's even easier to use

#

The only annoying part is the constant need to convert between nms and spigot/bukkit objects

hasty prawn
#

Easier to use is definitely a stretch

halcyon mica
#

Its subjective, I suppose

#

I have much less issues dealing with the actual minecraft systems than the abstracted bukkit versions of them

hasty prawn
#

I guess, but Spigot is fully documented so I would say it's WAY easier to learn how Spigot works than it is how NMS does.

halcyon mica
#

So is vanilla though

#

It's just that this documentation is not found within the spigot community, but the modding one

hasty prawn
#

The server side is documented?

halcyon mica
#

Mhm

hasty prawn
halcyon mica
#

Much more than the client stuff actually

#

Because rendering is a black magic barely anyone dares to touch

ancient plank
#

modding makes me wanna commit war crimes

hasty prawn
#

My issue with modding was that nothing was documented

halcyon mica
#

You must have used forge

hasty prawn
#

Yep.

#

Fabric is more documented I suppose?

ancient plank
#

fabric is way easier than forge

halcyon mica
#

Yep

hasty prawn
#

I haven't tried in a while so

halcyon mica
#

It also has proper mappings

trail bough
#

Fabric is better than forge but has less compatability with other mods [since most use forge] and visa versa

halcyon mica
#

Open source ones, which can be distributed freely

#

See yarn

#

And even have parameter names, unlike the official mojang ones

ancient plank
#

I mostly use fabric for client side stuff since y'know its easy as fk to do that with it

halcyon mica
#

I don't like to do "x is better than y" for anything, but except existing mod compatibitly, forge has nothing above fabric

hasty prawn
#

Sure it does! It's... faster to type...

#

and...

#

yep.

halcyon mica
#

Proxies make me shiver

hasty prawn
#

The only reason I still use Forge over Fabric is because of 1.8.9

maiden briar
#

public String onPlaceholderRequest(Player player, String params) this method is from PlaceholderAPI. I cannot change it. However, I'd like to asynchronously replace the placeholders, because I am getting data from my database

hasty prawn
#

If servers are gonna support it, might as well us it.

halcyon mica
#

I mean

#

Legacy fabric exists

thorny python
maiden briar
#

Ok time to change my methods then....

thorny python
#

you may consider add cache or something about db

maiden briar
#

Yes, but other servers can also update the values

#

So I wanna stay up to date

thorny python
#

uh that's tricky

#

unless you get notified when it get updated

maiden briar
#

Exactly, don't know that

thorny python
#

bungee have way to distribute message across servers iirc

maiden briar
#

I know, but it also might be on another bungee instance

thorny python
#

uh

trail bough
#

how do i get a user's uuid? i can't find it in the docs thru a quick search [though i'm dumb so yh]

#

Nevermind

#

it's probably getUniqueID

#

yup

thorny python
#

create a queue in some common communication channel and keep attempt consuming message in async task

#

complicate tho

maiden briar
#

Yes, if that problem could be solved

#

Let's build in a synchronised exception then

thorny python
#

hm personally I dont really go for extremely high performance, lazy to do async even in db xd

maiden briar
#

xD

thorny python
#

is there a efficient way to map user given item stack to a String?

#

so e.g. user can set current holding item stack to a particular name

#

and for any other item stack coming in the future, I can map stack to its name which defined by user (if exists)

#

currently I have to iterate over all saved (ItemStack, String) pairs until I find the first one return true in isSimilar()

thorny python
#

um is ItemStack comparable?

warm mica
#

isSimilar is already mostly efficient, actually

quiet ice
#

with what would you compare itemstacks with?

warm mica
#

You could use a tree/hash map with the materials at the key, meaning that you wouldn't have to iterate them all

thorny python
#

compare itemstack with itemstack

quiet ice
thorny python
#

ya map material first seems relatively good way

quiet ice
#

On what would you sort the stacks though?

thorny python
#

I am reading the link from ElgarL

warm mica
thorny python
#

which suggest using TreeMap

quiet ice
#

I'd not use Treemap

#

Unless it is String -> Itemstack, otherwise no, makes no sense whatsoever

thorny python
#

treemap need keys to be comparable iirc

visual tide
#

what would be the best way to get the time until the next hour divisible by 6 (so 00,06,12,18)?

thorny python
#

wdym 'time'

#

a integer of remaining seconds?

visual tide
#

well yes

quiet ice
#

Based on which clock?

visual tide
#

a set timezone

thorny python
#

do some math on System.currentTimeMillis() I guess

quiet ice
#

You'd be insane if you were to do that

thorny python
#

uh why?

warm mica
quiet ice
#

If anything, use Clock#millis instead of System#currentTimeMillis

thorny python
#

oh timezone thing

#

I still using currentTimeMillis for many timestamp environments

quiet ice
#

I have come to love DateTimeFormatterBuilder

thorny python
#

xd I work around time for some internal functions which no show to the user so it probably easier to use currentTimeMillis

somber hull
#

WHen is the proper time to use something asyncronouslyt?

thorny python
#

when process is slow and you dont need feedback immediately

somber hull
#

Got it

vocal cloud
#

When you have no race conditions as well

quiet ice
#

@visual tide

        Clock c = Clock.systemUTC();
        LocalTime time = LocalTime.now(c);
        int currently = time.getHour();
        int remainingHours = 6 - currently % 6;

something along this line

tulip owl
#

Just cloned InteractiveBooks (https://github.com/Leonardo-DGS/InteractiveBooks) and it won't build or sync in IntelliJ (trying to add a feature), any ideas? That link just leads to a 404.

Could not find spigot-api-1.18-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT:20211201.040401-5).
Searched in the following locations:
    https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18-R0.1-SNAPSHOT/spigot-api-1.18-R0.1-20211201.040401-5.jar

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
trail bough
tulip owl
#

yep, the build.gradle has the spigot API in it

trail bough
#

Try the solution it's reccomending? no clue, sorry

tulip owl
#

oh wait, it might need JDK 8

trail bough
#

Is it 1.18.1?

tulip owl
#

yea

trail bough
#

It should be JDK 17

tulip owl
#

but it says J1.8 in build.gradle

trail bough
#

oh

#

huh