#help-development

1 messages · Page 1917 of 1

wet breach
#

yes well statics are useful regardless of your unit tests 😛

ivory sleet
#

Which of course not everyone does, but I do it so for me it’s not very nice

wet breach
#

sounds like unit tests need to be made better to cope with statics

ivory sleet
#

That’s besides the point

wet breach
#

Well, statics are part of the language, makes no sense to have a test that can't cope with a native function XD

ivory sleet
#

That static is useful is already true

young knoll
#

I use my users as a unit test

ivory sleet
#

But that doesn’t mean every single usage of it is useful and properly implemented

wet breach
#

Anyways, statics are not bad if what is being referenced isn't going to be GC'ed anyways

lofty fern
#

@wet breach do you know a solution. I still can't figure this out

ivory sleet
#

They’re a part of the language but that shouldn’t inherently mean they are compatible with everything

wet breach
#

statics prevent objects from being GC'ed but if the object being referenced was never going to be GC'ed anyways regardless then the usage of static doesn't really matter

ivory sleet
#

That’s also besides the point

tardy delta
#

imagine..

young knoll
#

Lul

ivory sleet
#

It still doesn’t make it easier for us to unit test with static apis

young knoll
#

Just be Bukkit

ivory sleet
#

(Or well apis that provide static methods)

wet breach
#

Well then I don't understand a test that isn't compatible with something unless you just have an odd strict standard of not using statics thus your test not handling it o.O

ivory sleet
#

Because we can’t mock that method (unless you use sth like power mocks)

#

Unit tests is about testing an implementation of a unit

wet breach
#

statics in Java were part of the language long before unit testing was a thing

ivory sleet
#

Therefore you wanna isolate it from other units and components

#

one way to do that is by mocking the dependencies

blazing scarab
#

statics were made for C programmers

ivory sleet
#

Which can’t be done if static is used improperly

blazing scarab
#

So they can move to java without re-learning

#

static is fine for constants and utility methods - anything that does not have state

ivory sleet
#

Yeah static is state is horrible to every degree

blazing scarab
#

Otherwise, thats global variables... 🤮

ivory sleet
#

Like geez, what are you gonna do when you start multithreading your app

#

Okay for singletons maybe fine

#

(Lazy ones)

young knoll
#

I have a static API class that holds an instance of my plugin 😈

ivory sleet
#

☹️

quiet ice
#

Update your depenencies

blazing scarab
#

😡

lofty fern
#

HELLP I keep getting [ERROR] /C:/Users/angel/IdeaProjects/Core.git/src/main/java/network/palace/core/utils/ErrorUtil.java:[50,124] cannot find symbol symbol: method getRankId() location: variable DEVELOPER of type network.palace.core.player.Rank and cannot find symbol

wet breach
quiet ice
lofty fern
#

Yea

young knoll
lofty fern
#

It only happens when using the maven compiler plugin and only that

quiet ice
#

Then make sure that {, }, ;, etc... are set up correct

quaint mantle
#

There is a fucking. Service. Manger

young knoll
#

Oh yeah

#

Kek

quiet ice
#

I personally use a lot of static abuse in one of my projects because I inherited it's mess

#

But I'm slowly cleaning it up, just takes ages to do so since I don't like to break ABI

young knoll
#

Then I’d have to register a bunch of services though

#

Blah

lofty fern
young knoll
quiet ice
lofty fern
quiet ice
#

(why do people use them anyways?)

lofty fern
#

No clue

#

This is an open source plugin I am updating to work again

#
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 214 source files to C:\Users\angel\IdeaProjects\Core.git\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider network.palace.core.plugin.processor.PluginInfoProcessor not found
[INFO] 1 error
[INFO] -------------------------------------------------------------
quiet ice
#

Hm, could you link it to me so I could try to figure out what is happening?

lofty fern
#

Yea, I will send you my version since it has all the updated dependencys

wet breach
quiet ice
#

Because the error message in itself is almost useless to me (which is rare)

#

Hm, so it could just be replaced with spigot's new library feature?

wet breach
#

they forked the project in question

#

so they can literally change the code to instead shade the libs

quiet ice
#

Yeah, I'd get rid of it either way.

wet breach
#

you are not the first to attempt to help but the problem is trying to figure out what annotation processor it is requiring

#

but I had already recommended in just removing the annotation stuff and removing the reflection code

#

But they have stated they don't know how to do that =/

lofty fern
quaint mantle
wet breach
#

so...we are at this circular problem currently

quiet ice
lofty fern
wet breach
# lofty fern I removed the annotation stuff and it errored everything

yes, but we figured out what the annotation stuff was for, and its for the reflection code. Another person already looked at the reflection code and determined it downloaded dependencies and injects them at runtime. So overall what you could do is just remove all that instead and just shade the dependencies at compile time and thus the project doesn't need to do anything of that sort at runtime and shouldn't change the overall functionality of the plugin

quiet ice
#

oh no, lombok

ivory sleet
#

Yikes

quiet ice
#

You are better off aborting your project of yours than working with lombok

lofty fern
#

Do I delete everything related to lombock for it to work?

wet breach
#

you could

quiet ice
#

Or just run delombok

wet breach
#

but ran into issues compiling

#

but they seem to be unwilling to do any modifications to the code

#

to get it to work

#

so we are this circular compiling problem XD

#

well they are anyways

lofty fern
wet breach
#

you need to know how to code

lofty fern
#

Thats the thing. I don't. And everyone I have tried to pay refused

wet breach
#

while you can remove stuff, it doesn't mean some things won't be needing to be slightly changed

#

which requires knowing java coding

quiet ice
#

I could try to update it, but given that it uses lombok I am demotivated to do so

#

Using lombok is the perfect way of getting your project to end up in a graveyard

wet breach
#

maybe @young knoll would like some monies

#

XD

quiet ice
#

I don't have any infrastructure set up to accept any payments (laziness is pain), so money is irrelevant for me heh.

lofty fern
#

The main reason I want this to work is because another plugin I have needs this to work (I thinkk

#

This is the one I need to work

#

which requires a dependencie from core

wet breach
lofty fern
#

Nope it errors

#

Oh compiled

#

nope

#

they said it won't because the stuff was outdated.

#

So I put in to date

#

but now I can't get it to compile

#

I did once

#

but it crashed my server every time

quiet ice
#

Oh and it using mc 1.12.2 is not a good omen either

wet breach
#

lmao

#

anyways it sounds like you should just find a different plugin

lofty fern
#

Not my choice

quiet ice
#

I have already tried updating smaller plugins but those are an extreme pain to get working

lofty fern
#

There is no such plugin that does firework/lazer shows syncronized to open audio MC besides the show plugin above

quiet ice
#

actually, I recall seeing one on this discord

#

Oh, but that is not synchronized to that

wet breach
lofty fern
wet breach
#

yep one of the downsides of running outdated software

young knoll
#

As it should be

wet breach
#

is there a reason you need 1.12 specifically?

lofty fern
#

I just want this stupid show plugin to work

wet breach
#

what if someone could make the plugin for the latest version?

#

there is events you can listen to where you don't need to do this

slim echo
#

Guys, we need help. How to specify the desired potion in code in JSON format, I need for datapack

wet breach
#

couldn't you just use the name of the potion?

lofty fern
young knoll
#

Potions are all named “potion”

#

You need NBT data

wet breach
slim echo
young knoll
#

I’d ask the minecraft commands discord

#

We don’t really do datapacks here

lofty fern
#

?services

undone axleBOT
wet breach
#

or just download a datapack that does something with potions

#

and just look to see how they did it

slim echo
#

Okay, I'll try

quaint mantle
#

?tryit

#

?tryitsee

#

?tryitandsee

#

?tryandsee

undone axleBOT
quaint mantle
#

okay

bitter nymph
#

Hi. I Using Java MC Server Version 1.16.5 (Spigot). But if i using spigot plugin FAWE Version 1.16.5, i got no command proposal in command line prompt. Did you have any idea?

spiral light
#

maybe they did not support it in 1.16.5

bitter nymph
quaint mantle
#

Guys is there a way to change someone's name above their head without packets?
If not, is the "PLAYER_INFO" server packet the correct one that I should be using ?

tardy delta
#

teams?

bitter nymph
#

The installation instruction did not working as described on https://ci.athion.net/job/FastAsyncWorldEdit/. If i start Server (1.16.5) with installed Java Version 17, the server can not start because of crashes. Failure Log (look last line): [mine-hoster Daemon]: ---------- Detected server process in a crashed state! ----------
[mine-hoster Daemon]: Exit code: 0
[mine-hoster Daemon]: Out of memory: false
[mine-hoster Daemon]: Checking server disk space usage, this could take a few seconds...
[mine-hoster Daemon]: Updating process configuration files...
[mine-hoster Daemon]: Ensuring file permissions are set correctly, this could take a few seconds...
container@mh-cloud~ Server markiert als starting...
[mine-hoster Daemon]: Pulling Docker container image, this could take a few minutes to complete...
[mine-hoster Daemon]: Finished pulling Docker container image
Picked up _JAVA_OPTIONS: -Dlog4j2.formatMsgNoLookups=true -Dcom.sun.jndi.rmi.object.trustURLCodebase=false -Dcom.sun.jndi.cosnaming.object.trustURLCodebase=false
openjdk version "17" 2021-09-14
OpenJDK Runtime Environment AdoptOpenJDK-17+20-202105062337 (build 17+20-202105062337)
OpenJDK 64-Bit Server VM AdoptOpenJDK-17+20-202105062337 (build 17+20-202105062337, mixed mode, sharing)
:/home/container$ /usr/lib/jvm/java-17-openjdk/bin/java -Xms128M -Xmx3072M -Dterminal.jline=false -Dterminal.ansi=true -jar spigot-1.16.5.jar
Picked up _JAVA_OPTIONS: -Dlog4j2.formatMsgNoLookups=true -Dcom.sun.jndi.rmi.object.trustURLCodebase=false -Dcom.sun.jndi.cosnaming.object.trustURLCodebase=false
Unsupported Java detected (61.0). Only up to Java 16 is supported.

quaint mantle
#

including color codes

#

Soooo, yes, teams

bitter nymph
# spiral light dont use java 17

But the instructions on Spigot Website shows "Java 17 is required - If you are unsure how to update your Java versions or run several versions alonside".

spiral light
#

for 1.16.5 ?

spiral light
#

try another one

#

cant remeber running my server in 1.16.5 with java 17

bitter nymph
quiet ice
#

1.16.5 does not support J17

#

Use J16 instead

spiral light
#

maybe they did not add this feature there.

bitter nymph
quiet ice
#

Just report this as a bug to their issue reporting site

bitter nymph
subtle folio
#

how would I go abt spawning a armor stand behind a player, i’ve got the like world.spawn stuff but I don’t know how to use vectors or yaw and pitch

glossy venture
#

does anyone know how to call gradle tasks in sub modules sequentially

#

from another task in the root project

#

^ for more info

#

or programatically

#

i dont know what its called

quaint mantle
quiet ice
#

It is however best to find some random repository (or create one) to host the jars

vocal cloud
vocal cloud
quiet ice
#

or use a more traditional approach, but not all people can do that

lavish hemlock
quaint mantle
#

Simply publish the jar to the local maven repo

vocal cloud
#

You can't pull a jar as a maven repo. That's not how maven works.

quiet ice
#

I think I misunderstood everything

#

I understood it as in add the jars in xyz/abc to the maven pom, where you could use the system scope but I'd advise against it as it damages the pom.
But if it is just installing some rando jar to maven local then yeah, that would be the correct approach

vocal cloud
#

Damages the pom? I assume you mean makes it less likely to be sharable but at the end of the day I'm not the boss of what people decide to do. They want to make it difficult to make a project that's easy to work with shrug1

quiet ice
#

Damages the pom as in transitive depends do not work anymore for anyone using the project as a depend

#

I don't fully care about that anyways given I always remove them manually but it is something you may want to know

vocal cloud
#

If you shade it at the end of the day it's not going to matter

quiet ice
#

that is true

analog prairie
#

After the core plugin I made is closed, it will cause other plugins that depend on this plugin to crash. Is there any solution?

quiet ice
#

Emit some kind of event to signal a shutdown I guess

#

But this feels a bit wrong (but hey, I had this issue when I used minestom back in the days, could be that bukkit also has this whack plugin lifecycle)

vocal cloud
#

Make a shutdown event that makes all other plugins shut down. Or have those plugins register to your main one and then when the main shuts down it can also do the same to them

blazing rune
#

How do I use this.bP.a(1, new PathfinderGoalFollowEntity());

#

??

#

I was trynna make a custom mob follow a specific entity

spiral light
#

custom entity but not understanding how you use a pathfinder ?

sage dragon
#

Hey,

Does anyone know how the server sends the permission level to a player?

I want my admins to be able to use F3 + N to switch gamemode, without giving them op

spiral light
#

if there is no permission for that or a method you need to touch nms probably ... if you know how you could check packets

sage dragon
tacit drift
#

Can I retrieve tile entities from another thread?

spiral light
#

not with the api

sleek oar
#

Is it technically doable to make a plugin that forces a player / the console to execute a command before the player logs off the server and is disconnected?

vocal cloud
#

Depends how they leave though and it'll most likely end up being a race condition

lyric oar
#

Hello, is there a way to cancel a task inside the task? I mean like this:

Bukkit.getScheduler().runTaskTimerAsynchronously(getPlugin(), () -> {
    if(condition) {
          //Cancel the task
          return;
        }
}, 0, time);
#

oops it's task timer not task later

opal juniper
frail pivot
#
            public void run() {
                Player[] players = Bukkit.getServer().getOnlinePlayers().toArray(new Player[0]);
                for(int i=0;i<players.length;i++)
                {
                    System.out.println(players[i].getDisplayName()+ " is at " + players[i].getLocation());
                }
            }```
is this correct to send every player's location out to log?
opal juniper
#

but this is a learn java moment

lyric oar
opal juniper
#

there is

#

cancel()

frail pivot
lyric oar
#
Bukkit.getScheduler().runTaskTimerAsynchronously(getPlugin(), new Runnable() {
    @Override
    public void run() {

    }
}, 0, time);

i have something like this

#

but i can't call the cancel method

dry beacon
#

Pretty sure dictionaries in Python are Maps in java

obtuse ferry
#
dict = {"a" : {"a1": 1, "a2": 2},
      "b": {"b1": 3, "b2": 4}
      }

Whats the java version of a python nested dictionary?
I am thinking of a HashMap but I cannot figure out how to set the values without making 400 put statements

lyric oar
#

i see there is a BukkitRunnable and with it i'm able to do this.cancel(); inside the run method, i'll try this

#

i also see it's deprecated to use it so idk if it would be the right way but if it's works then it's fine

dry beacon
wet breach
#

or hashmaps

#

you could even nest an array in a map too

#

doesn't have to be another map

obtuse ferry
wet breach
#
Map<String, Map<String, List>>
Map<String, List>
dry beacon
#

Gonna ask this again, since I got no response; I'm trying to write to a json file using the gson library. To write to a file I'm using a hashmap, I can easily create simple files using the put method for example:

    map.put("name", "John Deo");
    map.put("email", "john.doe@example.com");```
I'm having trouble with creating more complex files like this one though, could anyone give me some advice, example or reference? ```json
{
  "groups": {
    "group1": {
      "owner": "UUID",
      "members": [
        "UUID1",
        "UUID2",
        "UUID3"
      ]

    }
  }
}```
stoic atlas
#

if (!(args[0]))

#

Does this work in java?

spiral light
#

if args[0] is a boolean ^^

stoic atlas
spiral light
#

but its mostly a string in that examle so No

stoic atlas
#

how do i check whether a variable hold a value

dry beacon
#

maybe check if it's null

young knoll
#

args.length

tender shard
undone axleBOT
spiral light
#

well if args[0] is possible it is set (null or the representive obj)

stoic atlas
#
            if (!(args[0])) System.out.println("Error");
            Location x = player.getWorld().getChunkAt(10, 20).getBlock(8,320,8).getLocation();
            player.teleport(x);
        }```
#

does args[0] == null

#

work?

spiral light
#

do args.length first

wet breach
dry beacon
#

^ check for amount of arguments

spiral light
#

if you do args[1000] but the args.length == 0 you have a big problem in your console

dry beacon
tardy delta
#

why are people using equalsIgnoreCase for commands tho

spiral light
#

json is just a little bit more work with syntax if you use it as config

dry beacon
dusk flicker
#

capitalization?

dry beacon
tardy delta
#

or is the command name the text you type after / instead of the cmd name you actually registered?

dusk flicker
#

tbh checking command name is the worst way to do commands either way

spiral light
dry beacon
young knoll
#

json isn't that bad

#

Unless you have a ton of data

spiral light
#

it depends on how big the project is ... json is a bad idea after a lot messages

tardy delta
#

mysql, h2?

young knoll
#

SQLite

dusk flicker
#

mongo ❤️

tardy delta
#

idk what the difference is between sqlite and h2

dusk flicker
#

google it

quaint mantle
#

h2 is faster

tardy delta
#

both embedded iirc

#

h2 💗

quaint mantle
#

mongo is for noobs

dusk flicker
#

mongo is the best

dry beacon
tardy delta
#

if you're learning it for the future, use databases

quaint mantle
#

json is fine and easy, but i'd support both

opal juniper
#

looks like to me lol

dusk flicker
#

yikes lmao

quaint mantle
#

Not using guava tables 🙄

opal juniper
#

seems very inefficient

#

so uh

#

i’m assume this very inner one is an object - so just make a Serialize method

#

which returns a Map<String, Object>

young knoll
opal juniper
#

then shit all group into a list

tardy delta
#

that looks more like yaml

opal juniper
tardy delta
#

but i think json works the same way

dry beacon
#

yeah I think I'm gonna switch to sql haha

opal juniper
warm light
#

Cannot resolve net.md-5:bungeecord-chat:1.16-R0.4
how to fix it?

dry beacon
#

tha nk you though

opal juniper
#

add the repo

#

RRS

obtuse ferry
#

Why is there an error now

#

But if I remove the last line its perfectly fine

warm light
tardy delta
#

what the hell tho

opal juniper
#

well you need the guava repo ig

quaint mantle
tardy delta
#

Map.of with the newer java version doesnt have a fixed size?

quaint mantle
#

How did you achieve this LoL

tardy delta
#

iirc

warm light
quaint mantle
#

What the fucj

obtuse ferry
tardy delta
#

or wait its a map so probably

dusk flicker
#

why not use an enum

obtuse ferry
dusk flicker
#

?learnjava

undone axleBOT
tardy delta
quaint mantle
tardy delta
#

it would work with a list with just varargs but that isnt possible with a map

obtuse ferry
agile sinew
#

how to know what plugin folder name?

quaint mantle
agile sinew
#

What's involved in naming that folder

dusk flicker
#

it's auto

#

It is whatever your plugin name is as defined in the plugin.yml

tardy delta
#

JavaPlugin#getDataFolder

#

what are you trying to do?

dry beacon
#

Does anyone have an idea how would I go about killing all entities in a certain area? (coords)

obtuse ferry
agile sinew
#

I want to read files in Datafolder but idk how to set datafolder's name

dry beacon
dry beacon
quaint mantle
tardy delta
#

you would use the constant's name instead of identifier tho

quaint mantle
#

yess

#

with a runnable?

tardy delta
#

yes

young knoll
#

yes

quaint mantle
#

thanks ill try itt

young knoll
#

You can't do a lot of things right away with the respawn event

quaint mantle
#

yeahh thats what i was figuring

obtuse ferry
#
Map<String, String> items = Map.ofEntries(
    Map.entry("key-1", "value-1"),
    Map.entry("key-2", "value-2"),
    Map.entry("key-3", "value-3"),
    Map.entry("key-4", "value-4"));
#

I've also seen this

tardy delta
#

is your CustomEnchants already an enum?

obtuse ferry
tardy delta
#

i wouldnt make those fields public

#

its ideal to make an enum for it

obtuse ferry
#

I just followed a tutorial and it said it had to be done this way to work with things such as essentials

tardy delta
#

hmm i dont like codedred for a reason

young knoll
#

It is more compatible ootb that way

obtuse ferry
# obtuse ferry

Could I perhaps add to the wrapper some attributes and make some getters for them

young knoll
#

But it isn't supported

obtuse ferry
#

Instead of everyone telling me what not to do how about tell me what to do, constructive criticism please

young knoll
#

I mean

#

I do my enchants that way too

obtuse ferry
#

..

tardy delta
#

i would do ```java
public enum CustomEnchant {
BLADEBEAN("bladebean", "Blade Bean", 2),
SWORDSDANCE("swordsdance", "Swords Dance", 5);

private final String namespace;
private final String name;
private final int maxLevel;

CustomEnchant(String namespace, String name, int maxLevel) {
this.namespace = namespace;
// ...
}

String getNamespace() { /* */ }

String getName() { /* */ }

}

#

however i dont understand an enchantment having a namespace and a name which contains spaces

young knoll
#

gotta use a namespace to register them

tardy delta
#

in the same way make a static method to register them in that enum

#

oh right

#

and Enchantment is not an interface so that would cause problems

obtuse ferry
#

how about I just add
private final ItemStack item; and this.item = item and make a getItem()

#

Why are all the methods in the wrapper overriden

tardy delta
#

dont ask me where codedred got his idea from ._.

young knoll
#

I know exactly where he got it from

tardy delta
young knoll
#

Bukkit

#

(And vanilla)

obtuse ferry
tardy delta
#

i dont like his tutorials because he uses very bad and old techniques

obtuse ferry
#

I could also use ItemStack[] no?

#

Or other types

obtuse ferry
tardy delta
#

then i would have an CustomItem enum tho as it's not the enchantment which decides where to apply itself on

cold pawn
#

Is there a way to set the perspective of a player to an npc? Would it be through a packet or is there a method for this if it’s possible?

young knoll
#

Packets

karmic grove
#

Ive recently comverted a project to maven but when i try load plugin in server it says invlaid plugin.yml does it need to be in a different location when its loaded with maven or somthin

young knoll
#

should be in src/main/resources

karmic grove
#

Ok thanks

tardy delta
#

just a bit single responsibility principe but it wouldn't really matter, its your plugin

mortal hare
#

ok this is my first time using git inside intellij

#

is it possible to create branch from the intellij itself

#

without going into CLI

tardy delta
#

wha- no

obtuse ferry
#

How everything should depend on the primary key and thats it

tardy delta
#

kinda..

obtuse ferry
#

why are these all overriden?

tardy delta
#

because you wrapper extends the abstract enchantment class?

#

unfortunately not an interface, sigh

obtuse ferry
#

Right

mortal hare
#

why enchantments are in object class

#

aren't there like enum classes

tardy delta
#

nah

#

its stupid tho

hardy swan
#

Object is the mother of all classes

#

Enum is a class

young knoll
#

Enchantments used to be an enum iirc

#

Maybe, but spigot is finally moving away from those

tardy delta
#

like they are instantiated wrappers

#

so why not an enum

young knoll
#

Because enums are not expandable

tardy delta
#

yea..

young knoll
#

Same reason most things are moving away from enums

#

Minecraft is becoming increasingly expandable

mortal hare
#

declare enchantments in enums

#

use EnchantmentHolder

#

for storing dynamic data of enchantment

#

particular to the item itself

young knoll
#

Everything should be registries

hardy swan
mortal hare
#

i think by saying that, you mean runtime expandable

tardy delta
#

anyways what is a ProxiedCommandSender again? is that bungee?

mortal hare
#

iirc, yes

young knoll
tender shard
#

any gradle experts here?

#

anyone know how to change the compiler in gradle like I did with maven here? ^^

tender shard
#

right click project -> git -> branches

lyric oar
#

Hello again, i have a list of blocks and i want to sort them. I want that block y from lowest to highest, and i want x and z to be closest to specific number. For the y thing it's okay, but for the x and z i don't know how to proceed. My current code is:

List<Block> sortedBlocks = blockList.stream().sorted(Comparator.comparing(Block::getY)).collect(Collectors.toList());

Does anyone know how to sort this list so that y is lowest to highest and x and z are closest to a certain number?

mortal hare
hardy swan
mortal hare
hardy swan
#

Dun intellij have cli

mortal hare
#

i added remote

#

but its still grayed out

#

for some reason

cold pawn
mortal hare
#

its just doesn't push to github

#

since main branch is missing

hardy swan
#

Show tree

lyric oar
hardy swan
tender shard
#

I love how noone really fully understands gradle lol

modern fox
#
    @EventHandler
    public void onClick(InventoryClickEvent e) {
        if (e.getRawSlot() == 5) {
            System.out.println("Here");
            Player plr = (Player) e.getWhoClicked();
            ItemStack helmet = plr.getInventory().getHelmet().clone();
            ItemStack current = e.getCursor().clone();
            plr.getInventory().setHelmet(current);
            plr.setItemOnCursor(helmet);
        }
    }
``` Why doesn't this work?
glossy venture
#

yeah ive been using it for like half a year and all i know is how to include dependencies and make tasks

tardy delta
#

registered it?

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

wet breach
tardy delta
#

also is the raw slot even 5

modern fox
# tender shard ?notworking

I am trying to make it so I can place a block on my head as a helmet. It doesn't call the event when trying to place it on the head

tender shard
modern fox
#

I debugged it

tender shard
#

you don't have any debug statement to see if the event gets called in that code though

modern fox
#

I had before

#

It calls when I place a helmet but when placing a block it doesn't call cuz it actually doesn't get placed there

glossy venture
#

but i have no idea how to use it

#

or code it

#

or do anything with it

modern fox
#

on the helmet

#

slot

tender shard
#

and it throws a huge console error

#
[16:33:31 INFO]: [Test] [STDOUT] Here
[16:33:31 ERROR]: Could not pass event InventoryClickEvent to Test v1.1.8
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.clone()" because the return value of "org.bukkit.inventory.PlayerInventory.getHelmet()" is null
        at de.jeff_media.test.Test.onClick(Test.java:35) ~[Test-1.1.8.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor18.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:git-Paper-68]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:2817) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:58) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:13) ~[?:?]
        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-68]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1413) ~[paper-1.18.1.jar:git-Paper-68]
        at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[paper-1.18.1.jar:git-Paper-68]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1391) ~[paper-1.18.1.jar:git-Paper-68]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1384) ~[paper-1.18.1.jar:git-Paper-68]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1362) ~[paper-1.18.1.jar:git-Paper-68]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1268) ~[paper-1.18.1.jar:git-Paper-68]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-68]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
tardy delta
#

you cant place a block as helmet by default

modern fox
#

Ik why that doesn't work but I do not get that error

tardy delta
#

you have to get it from somewhere in the inv

glossy venture
#

maybe set the priority to highest

modern fox
#

Just check if it is null

glossy venture
#

and use getCursor() instead of getHelmet() because it obviously is null

#

if it doesnt place into the helmet slot

tender shard
modern fox
#

I'm using both

tardy delta
#

if you try to set a block as helmet, isnt that blocked by vanilla?

modern fox
#

Hmm I am on 1.8 probably makes a difference

tender shard
tender shard
tardy delta
#

oh

hardy swan
#

You can even do that via commands

#

Vanilla commands

tender shard
#

did you by any change try it in creative mode @modern fox ?

#

or did you try in survival?

modern fox
#

Oh yeah

#

Creative

tender shard
#

yeah well

#

creative inv is client sided

modern fox
#

There you go

tender shard
#

no clickevents for that

tardy delta
#

sometimes my knowledge isnt enough 👀

modern fox
#

Thank you

tender shard
#

np 😄

modern fox
#

Lmao

tardy delta
#

bruh

#

better than saying "im not in a server"

tender shard
tardy delta
#

same thing

tender shard
#

also @modern fox

#

you also want to listen to InventoryDragEvent

#

e.g. check this

#

when you move the cursor a bit, it does NOT call clickevent, but only dragevent instead

#

even when you only move the mouse for a 1/20th second on the same slot by accident

tardy delta
#

another pain

#

damn i learned something new

#

that you can provide a method reference instead of passing this and extending an abstact class

hardy swan
#

wdym

tardy delta
hardy swan
#

Huh?

#

Command executor is a functional interface?

tardy delta
#

i thought you had to implement CommandExecutor to make it work

hardy swan
#

ItemMeta

hardy swan
tardy delta
#

not if you pass a method reference with the same signature

hardy swan
tardy delta
#

that orange, npr

hardy swan
#

Ohh

tardy delta
#

kinda fancy

hardy swan
#

Ohh command executor is indeed a functional interface

#

It only has one abstract method lol

#

Ok learnt sth new

agile sinew
#

can I post picture to url here?

hardy swan
#

If you get verified you can even post pictures here

tender shard
tardy delta
#

isnt it url to picture?

#

👀

tardy delta
agile sinew
#

hmm ok

hardy swan
#

Has anyone received their hacktober fest shirt here

maiden briar
#
while (compute) {
                try {
                    Socket socket = serverSocket.accept();
                    Bukkit.getScheduler().runTaskAsynchronously(plugin, new ArenaSocketTask(new InterceptedSocket(socket)));
                } catch (IOException var2) {
                    var2.printStackTrace();
                }
            }

This keeps accepting sockets forever (I have a print statement in ArenaSocketTask)

young knoll
#

Do you ever set compute to false

maiden briar
#

Yes, if the server shuts down

young knoll
#

So until then

#

It will keep adding sockets

hardy swan
#

If the server is down

maiden briar
#

But all sockets have the same port

hardy swan
#

compute is not even there anymore

maiden briar
#

The problem is that it keeps accepting sockets from the same port

#

Then it runs 100+ tasks for the same socket

#

Or is this how it works? I have no idea about socket programming

hardy swan
maiden briar
#

localport

#

Or is that how it works?

#

I will ask my friend how many servers he has on the same socket

hardy swan
#

I think you should getItemMeta after setting type

#

The type of meta depends on type

#

If you get

young knoll
#

No you don't

#

I don't see a getItemMeta call in there

#

Oh you call getItemMeta each time

hardy swan
#

Before setting lore

#

You should settype

#

Then getItemMeta

#

And setlore on that meta

#

Then setItemMeta with that meta

#

Maybe ItemStack silently rejects incompatible meta

tender shard
#

where did you get that ItemMeta from?

tardy delta
#

is it worth overriding both equals and hashcode?

hardy swan
tardy delta
#

i mean if you override equals which does not use hashcode

tender shard
tender shard
tardy delta
#

ah right

tender shard
#

you don't need hashcode but it will be faster if you have a proper hashcode method

#

also lombok or intellij can create that automatically for you

last iris
#

ItemMeta

tardy delta
#

oh i manually overrid it everytime

tender shard
hardy swan
#

Wont it use that default method too

tender shard
quaint mantle
eternal night
#

If only java had like super convenient data only class types now that implement all of that for you

#

Would be record breaking to just define them easily and not care about hashcode or equals

tender shard
tender shard
#

why has noone invented them

eternal night
#

😔😔 java better hurry

tender shard
#

yeah tbh they should have been added a long time.... e.g. in java 14 or sth like that

#

but fr; I'm still on java 8 for most things anyway so I can't use records anyway 😄 I just do Lombok's @ Data

quaint mantle
#

they were added in java 16 only

#

in j14 it was a preview feature

tardy delta
#

if i'm like having 8 fields i would need to check for all of them in equals method

#

if they specify equality

tender shard
tardy delta
#

that looks like

return Objects.equals(getChatProfile(), user.getChatProfile()) && Objects.equals(getStatisticsProfile(), user.getStatisticsProfile()) && Objects.equals(getMembershipProfile(), user.getMembershipProfile());```lol
quaint mantle
#

why using getters 😦

#

is everything here nullable

#

Yegor256 is going to cry

tardy delta
#

idk i clicked on it

queen sequoia
#

Hey guys, does modern versions of Bungeecord support updated versions of Forge, such as 1.16.5? Looking at other proxies, I see they don't support Forge past 1.12.2. It'd be a project-saver if Bungee did!

tender shard
#

which is false by default

#

so just try it

#
forge_support
Default: false
Type: Boolean
Description: Choose if your BungeeCord instance supports Forge clients or not.
sterile token
#

What protocol would you recommend for sending and receiving data?

#

ByteAarray?

tardy delta
#

from what?

sterile token
#

Im thinking about the library I will work

#

For sending and receiving data vía netty

#

I have already thought the protocol

#

But i dont know what use for sending and receiving. Im between ByteArray

quaint mantle
#

i mean, every data you send across internet is byte array

sterile token
#

Ah allright

#

Thanks

#

With DataInputStream can be converted to ByteArray right?

quiet ice
#

Depends

#

But yes, given that it is just an input stream

#

the bigger question is whether it makes any sense to do so

sterile token
#

Cuz

quiet ice
#

For example if you have a byte array that actually represents an array of integers, you should better use DataInputStream's readInt method

sterile token
#

For sending data vía netty I will use a custom protocol. And the method for sending and receiving will be:

receive(String channel, byte[] data)
send(String channel, byte[] data)

quiet ice
sterile token
quiet ice
#

Because it has #readInt, #readUTF, etc. methods

sterile token
#

That why I will use

#

😂

#

Look here you have my method

quiet ice
#

Then any input stream is sufficent

#

As long as it supports #readNBytes, which it should in modern java

sterile token
#

But i wanna read int, string etc

#

Easly

quiet ice
#

Then don't work with byte arrays

sterile token
#

I dont wanna fuck concerting bytes to string to int

quiet ice
#

bytes -> string is easy

sterile token
glossy venture
#

doesnt netty support sending objects

wet breach
sterile token
#

I will check

quiet ice
#

new String(bytes, offset, len, StandardCharsets.UTF_8)

wet breach
#

so it isn't going to make a difference at the core of networking because it will be turned into bytes regardless

#

whether you choose to do it before hand or simply letting the hardware do it

#

better you do it before hand though

sterile token
#

Because i read that netty send data using a ByteBuffer

#

And inside that buffer the Bytes[]

wet breach
#

because all network communications are binary o.O

sterile token
#

Yeja

wet breach
#

So not sure what it is you are trying to ask here, you are not going to send a string as a string of characters without it first getting turned into bytes

sterile token
#

But so i will use ByteArrayInputStrean + DataInputStrean

quiet ice
#

This is useless overhead imo

#

bytebuffer already offers getInt, etc. method

#

not sure how well netty's bytebuffer does it though

sterile token
wet breach
#

depends on what you are wanting to do with the data

sterile token
#

Trying to send data like object

#

Cuz I will do a Packet (serialized class) system

wet breach
#

no, that isn't what I meant, for instance do you need to save the network data to a file for example? If so an input/output stream would become really handy for this

sterile token
#

Frodt

waxen plinth
#

You could serialize to JSON

quiet ice
#

Myeh

waxen plinth
#

(I was summoned because someone said parse)

quiet ice
#

I dislike that overhead

sterile token
#

I will use this system as plugin on both side bungee and spigot. So i can send data all around network

wet breach
#

then just stick with bytebuffers

waxen plinth
#

You can just treat them like commands

quiet ice
#

At that point it is better to go stream -> buffer -> bytes -> stream -> deserializer -> data

waxen plinth
#

Send a command and its arguments separated by spaces

sterile token
waxen plinth
#

And each packet can be terminated by a newline or null

quaint mantle
#

Redis

quiet ice
#

bruh

sterile token
#

Omg no no

waxen plinth
quiet ice
#

we are joking right

waxen plinth
#

He can't use it because everyone involved in the project is a clown

sterile token
#

Yeah hahaha

#

Thanks frodt for that example

#

I will keept it

wet breach
# waxen plinth You could serialize to JSON

I wouldn't even do this, I would just make use of Java's object serialization because then you can deserialize the object and it be useful immediately without converting to anything else

sterile token
#

And thanks to every one who try to help

waxen plinth
#

Ehhhhh

#

Java's native serialization kinda fucking sucks

quiet ice
#

But really, just go the "stream -> deserializer -> data (object)" route

tender shard
waxen plinth
#

It's not very space efficient

#

And it's very very not human readable

sterile token
#

stream -> buffer -> bytes -> stream -> deserializer -> data

wet breach
quiet ice
#

Debugging probably

sterile token
#

why huma redeable if it for sending and receiving data vía Packet class system

quiet ice
#

But that is about it

sterile token
#

🤣

wet breach
quiet ice
#

It can make your life easier as you can spot issues far better than with a tightly packed system

wet breach
#

well debugging I understand

#

but if debugging at the network layer isn't needed then unnecessary for it to be human readable

#

not that it will be because it will just be bytes anyways

#

depending how you capture the data

quiet ice
#

yeah

waxen plinth
#

But again, the data it outputs is much larger than needed

#

You're wasting bandwidth if you use java serialization

#

Isn't it not recommended to use java serialization like, ever?

wet breach
#

how much bytes you really think the object is going to take ?

#

you do know all packets have a minimum size they get padded to regardless?

#

think its like 64 bytes or something

sterile token
#

You then do:

PacketObject packet = Packets.receive(PacketObject.class)

packet#Setters
packet#Getters

wet breach
#

I was close, 60bytes is what it gets padded to

sterile token
wet breach
#

and that is for a TCP packet

sterile token
#

Yeah I will be sending cross network packet using the netty server/Bungee isntance

wet breach
# sterile token I will use ZLib

you can make use of compression if you want, but I would only do so if the data being sent is averaging to be double or quadruple the size of a single packet

quiet ice
sterile token
#

With a custom channel, wrapper, encryption

quiet ice
#

Why not use UDP

wet breach
#

Well it would depend if they need the packets in order or not

#

if ordering isn't necessary I agree UDP is the way to go

sterile token
#

We need order yes

wet breach
#

but also there is no guarantee of the UDP packet of making it to destination and no way for either side to know it did or not

sterile token
#

And udp not always came it can be lost

rich creek
#

Hi, i need some help with this


        LivingEntity Player = e.getEntity();
        
        if (e.getEntity() instanceof Player) {
            EntityDamageEvent DamagedEvent;
            DamageCause cause = Player.getLastDamageCause().getCause();
            
            String causeString = "Causa de daño: " + cause;
            
            if (cause == DamageCause.ENTITY_ATTACK) {
                if (DamagedEvent instanceof EntityDamageByEntityEvent ) {
                    EntityDamageByEntityEvent EDBEvent = (EntityDamageByEntityEvent) DamagedEvent;
                    if(    EDBEvent.getDamager() instanceof LivingEntity) {
                        
                        causeString= "Causa de daño: ("+EDBEvent.getDamager()+")";
                    }
                    
                }
                
                
            }
            
            if(((Player)e.getEntity()).getInventory().getItemInMainHand().getType() == Material.TOTEM_OF_UNDYING || ((Player)e.getEntity()).getInventory().getItemInOffHand().getType() == Material.TOTEM_OF_UNDYING){
            Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&4&l[Sudden Death II] &c"+Player.getName()+" &fha usado un totem | " + causeString));

              for (Player OnlinePlayer : Bukkit.getOnlinePlayers()) {
                  OnlinePlayer.playSound(OnlinePlayer.getLocation(), Sound.ITEM_TOTEM_USE, 10.0F, 1.0F);
                }
            }
        }
        
    }```

I want the name of the Mob that hurt the player to come out
sterile token
#

Frost really thanks!!

stream -> buffer -> bytes -> stream -> deserializer -> data

data -> serializer -> stream -> bytes -> buffer -> stream

#

?

quiet ice
#

I personally use code like


    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        int readableBytes = in.readableBytes();
        if (readableBytes < headerSize) { // Strict size limitation. Any packet smaller than that is most likely not a packet
            return;
        }
        int readerIndex = in.readerIndex();
        int size = in.getInt(readerIndex);
        if (readableBytes < size) { // Packet not yet fully received (Stream-based transport problem)
            return;
        }
        in.readerIndex(4 + readerIndex);
        short packetId = in.readShort();
        long sender = usingSide == Side.SERVER ? in.readLong() : -1;
        byte[] payload = new byte[size - headerSize];
        in.readBytes(payload);
        out.add(new PacketStub(packetId, sender, payload));

to decode packets into stubs, which then are processed to actual objects

sterile token
rich creek
#

?

#

Aaaa

quiet ice
#

@undone axle you good?

sterile token
#

?paste

undone axleBOT
sterile token
#

Press ctrl + s and then copt the link

rich creek
#

Ou

sterile token
#

Righ

#

I will read

rich creek
#

You speak Spanish?, I say it because it says "VERANO" in your nick

sterile token
#

Why classes in Spanish?

#

If want to talk Spanish dm

#

Cuz here you can get banned

tender shard
#

deep in their heart, verano is russian

sterile token
#

Hahaha

#

I was born in San Peters Burgo

#

Germany

quiet ice
#

Oh lord, I already live in the middle of nowhere, but this really must be nowhere

rich creek
sterile token
tender shard
rich creek
#

Not problem, I understand English xd.

sterile token
#

It not allow to speak Spanish

quiet ice
obtuse ferry
#

Why are all of my switch case statements executing?

        String enchantName = args[0];
        boolean success = false;
        switch (enchantName.toLowerCase()) {
            case "swordsdance":
                sendMsg(player, "swordsdance");
                success = ApplyEnchant.applyEnchant(item, (EnchantmentWrapper) CustomEnchants.SWORDSDANCE, level);
            case "dragondance":
                success = ApplyEnchant.applyEnchant(item, (EnchantmentWrapper) CustomEnchants.DRAGONDANCE, level);
            case "iceaspect":
                success = ApplyEnchant.applyEnchant(item, (EnchantmentWrapper) CustomEnchants.ICEASPECT, level);
            case "bomberace":
                success = ApplyEnchant.applyEnchant(item, (EnchantmentWrapper) CustomEnchants.BOMBERACE, level);
            case "wingardiumleviosa":
                success = ApplyEnchant.applyEnchant(item, (EnchantmentWrapper) CustomEnchants.WINGARDIUMLEVIOSA, level);
            case "dash":
                success = ApplyEnchant.applyEnchant(item, (EnchantmentWrapper) CustomEnchants.DASH, level);
            case "sheercold":
                sendMsg(player, "sheercold");
                meta.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED,
                        new AttributeModifier(UUID.randomUUID(), "attackSpeed", additionalSpeed, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND));
                item.setItemMeta(meta);
        }
chrome beacon
#

Because you haven't put break

spiral light
#

break

obtuse ferry
#

I'm confused

#

Does switch case not run whichever case matches the switch?

young knoll
#

It'll also run all the ones after that if you don't break

quiet ice
#

this is called fall-through

obtuse ferry
olive lance
#

how can you stop ie a chest opening but allow for throwing a potion on it? right now im just allowing the interactevent if they are crouching

young knoll
#

Event#setUseInteractedBlock

quiet ice
#

basically your case statements are labels and the JVM will jump to the respecive label based on the object put in the switch statement head. The JVM will keep executing stuff (even going over other labels) until it hits a statement that exists the scope (i. e. break or return)

olive lance
#

@young knoll is there an article or something explaining that one?

young knoll
#

See above

sterile token
#

On spigot java docs you can find info

olive lance
#

this was just not much

#

I think ive got it now though if I set that to Result.DENY then it will do what i would expect

young knoll
#

Oh the thing I mentioned

#

Yes

quiet ice
#

useIteminHand = throw potion
useInteractedBlock = open chest

olive lance
#

Ah ok it is clear now thank you guys

obtuse ferry
#

How can i simplify

        Enchantment enchant = null;
        switch (enchantName.toLowerCase()) {
            case "swordsdance":
                enchant = CustomEnchants.SWORDSDANCE;
                break;
            case "dragondance":
                enchant = CustomEnchants.DRAGONDANCE;
                break;
            case "bladebeam":
                enchant = CustomEnchants.BLADEBEAM;
                break;
            case "spinattack":
                enchant = CustomEnchants.SPINATTACK;
                break;
            case "excalibur":
                enchant = CustomEnchants.EXCALIBUR;
                break;
            case "devilsscythe":
                enchant = CustomEnchants.DEVILSSCYTHE;
                break;
            case "iceaspect":
                enchant = CustomEnchants.ICEASPECT;
                break;
            case "bomberace":
                enchant = CustomEnchants.BOMBERACE;
                break;
            case "wingardiumleviosa":
                enchant = CustomEnchants.WINGARDIUMLEVIOSA;
                break;
            case "dash":
                enchant = CustomEnchants.DASH;
                break;
            case "sheercold":
                enchant = CustomEnchants.SHEERCOLD;
                break;
            case "urbosasfury":
                enchant = CustomEnchants.URBOSASFURY;
                break;
            case "swiftblade":
                enchant = CustomEnchants.SWIFTBLADE;
        }

I feel like im doing the old if "1" then 1 if "2" then 2

spiral light
#

you could make this much easier by saving the enchantments in a map while registering

#

map<yournamespace,enchantment>

#

and then get the enchantment from there

quiet ice
#

Even better: change CustomEnchants to enum and do Enum#valueOf

obtuse ferry
obtuse ferry
#

I cant

#

I'm extending Enchantment

quiet ice
#

I personally use an intermediary enum which is assigned an enchantment

#

But I don't extend Enchantment in my plugin for one reason or another, so don't take my advice for granted

obtuse ferry
#

Right

obtuse ferry
visual tide
#

why does JavaPlugin implement TabExecutor 😐

quiet ice
#

Because that is the default tab executor

obtuse ferry
# spiral light map<yournamespace,enchantment>

I put

private static Map<String, Enchantment> ENCHANT_KEYS;

//in register
if (registered) {
  ENCHANT_KEYS.put(String.valueOf(enchantment.getKey()), enchantment);
}

I got java.lang.NullPointerException: Cannot invoke "java.util.Map.put(Object, Object)" because "me.jameslloyd.sleepyenchants.enchants.CustomEnchants.ENCHANT_KEYS" is null and

#

How do I assign it to an empty map?

spiral light
#

yeah xD

#

?learnjava

undone axleBOT
spiral light
#

your map "ENCHANT_KEYS" will be null if you not set it to an Map ... like HashMap for example

obtuse ferry
#

Guy said use a Map so I did

#

Take it I should use HashMap

spiral light
#

HashMap is the same like Map

#

Map is the interface of an HashMap

#

you should use a Map for this yes

obtuse ferry
#

Why is it saying it may be final when i put later on?

spiral light
#

but you should learn java and understand how maps, list and so on rly works xD

obtuse ferry
#

I'm trying right now

#

I'm used to python which is much simpler

#

Just slap [] wherever you feel

#

Or {} for dict which is what i understand a map to be

tender shard
spiral light
#

yeah python is simpler but gets so confusing after just creating a small program

tender shard
#

python is like duct tape

#

you can use it to repair or get small things done but you wouldn't use it to construct a whole building

ivory sleet
#

well they have the same abstract data structure specification in a sense

obtuse ferry
#

I'm horribly aware, I used it for my computer science programming project for my coursework to make an app and it is shocking. Thats why im learning java, but its a lot easier to learn with something im familiar with - minecraft.

obtuse ferry
obtuse ferry
#

HashMap seems to have worked thank you guys

#

spoke too soon

tender shard
obtuse ferry
#

My command is no longer working and theres no errors 😦

worldly ingot
#

That wasn't a small project either. Had a full on editor window and whatnot, 3D view of the world, etc.

#

I do wish that project kept going though. I don't believe there are any more offline world editors in modern MC (excluding WorldPainter, but I don't think that counts. It didn't do what MCEdit did)

crude estuary
ivory sleet
chrome beacon
#

MCEdit has saved many of my broken modded worlds

worldly ingot
#

Would be a fun attempt to bring that type of project back, I just can't be bothered lol

obtuse ferry
#

😅

worldly ingot
#

Would be better in an OOP language

#

Or at least a far more standard one than Python

#

C#, C++, Java, whatever

young knoll
#

Rip McEdit

mortal hare
#

ik this is not paper related discord server, but i know most of you here use paper or its derived forks here so here's my question:

any ways to import NMS classes into maven project (Intellij IDEA)? I've used java -Dpaperclip.install=true -jar paperclip.jar before to import patched jar into local repository, but it seems it's been removed (at least in 1.18 builds), any ideas?

tender shard
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
            <classifier>remapped-mojang</classifier>
        </dependency>
        <dependency>
            <groupId>io.papermc.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
waxen barn
#

Hi there, I have a question about BungeeCord.
How can I change the forwarded ip? I want to make feature, that users can host their own spigot servers and they can be added to the bungee network, but I don't want to leak ips of my players to them. I would also like to have ip forward to true, so they can still have the same uuid as on the normal server. Is it possible to just change the forwarded ip to some nonsense but keep the online uuid?

quaint mantle
#

Well yres

tender shard
#

you either have ip forwarding enabled

#

or you don't

quaint mantle
#

Just have a Map<String, String>

#

where the key is the nonsense, which corresponds to the actual ip

#

thus hiding the real ip

#

but why tf would you do that

tender shard
#

also where's the problem in knowing the IP

tardy delta
#

users hosting their own server sounds like problems

glad bridge
#

That's basically minehut yeah?

waxen barn
tardy delta
waxen barn
tender shard
#

you either forward their real IP and get real UUIDs, or you don't and don't get real UUIDs

glad bridge
tender shard
#

i dont even know what minehut is lol

glad bridge
#

Free sever hosting

tardy delta
#

minehut is trash

glad bridge
#

I'm fairly sure they're still going

tender shard
#

all free hosters are trash, otherwise they wouldn't be free

quaint mantle
tender shard
#

sure it has but it's about hiding their IP for whatever reason

waxen barn
quaint mantle
#

hmm

tender shard
#

IIRC ip forwarding in bungee is nothing different from normal NATing

#

the server will always either have the real IP address or it has the bungeecord IP

glad bridge
#

They have different tiers of servers

tender shard
#

RIP spigotmc is down

#

aaaand it's back up

tardy delta
#

👀

glad bridge
#

Then it was never down and you're a monkey

tender shard
glad bridge
#

Yes

tender shard
#

no

quiet ice
#

Did bungee-chat adopt lombok lately or am I just stupid?

waxen barn
glad bridge
#

Search your feelings you know it to be true

glad bridge
#

Actually I'm not sure, cause it kinda seems like they did

obtuse ferry
#

Im confused, I casted to String[] and it still says its not the right data type

quiet ice
#

What is T?

obtuse ferry
#

completions

#

thats fine

mortal hare
buoyant viper
#

ask in paper discord

tender shard
obtuse ferry
#

Oh wait ive got it i didnt need to convert anything

quiet ice
#

Right now you are using the desc (Ljava/lang/String;[Ljava/lang/String;)? but the actual desc is (Ljava/lang/String;Ljava/lang/Iterable;T)?

#

Use Arrays#toList() or something

tender shard
obtuse ferry
#

CustomEnchants.getPossibleKeys() is Set<String>

tender shard
#
public static <T extends Collection<? super String>> T copyPartialMatches(@NotNull String token, @NotNull Iterable<String> originals, @NotNull T collection)
quiet ice
#

Hm, that is some intricate usage of generics

tender shard
#

T is is a Collection<? super String>

quiet ice
#

It's not even 8pm and my brain is already halfway towards entirely shutting down

#

Help me

obtuse ferry
#
public class CustomEnchantTabComplete implements TabCompleter {

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {

        final List<String> completions = new ArrayList<String>();

        StringUtil.copyPartialMatches(args[0], CustomEnchants.getPossibleKeys(), completions);

        Collections.sort(completions);

        return completions;
    }
}

This tab complets for args[0] how do i make it for args[1]?

tender shard
latent zephyr
#

Have you solved this problem?

quiet ice
tender shard
#

what's the command you ran exactly?

tardy delta
#

check if the length == 2

#

and return a partial match

obtuse ferry
tender shard
obtuse ferry
tardy delta
#

well success

waxen barn
#

i solved it in some way (i think by using linux terminal or getting the shaded jar, but it didn't obfuscate correctly)

young knoll
quiet ice
#

Ah then,

List<String> completions = new ArrayList<>();
switch (args.length) {
case 0:
    return completions;
case 1:
    complections.addAll(CustomEnchants.getPossibleKeys());
    break;
case 2:
    for (int i = 0; i < 5; i++) {
        complections.add(Integer.toString(i));
    }
    break;
}
Collections.sort(completions);
return StringUtil.copyPartialMatches(args[args.length - 1], complections, new ArrayList<>());

something like that

tardy delta
#

this was also a nice one

quiet ice
obtuse ferry
#

Now i understand how it works too

#

bonus

tardy delta
#

if (args.length == 2) completions = Arrays.asList(1, 2, 3, 4, 5) lol

obtuse ferry
#

why complections.addAll(CustomEnchants.getPossibleKeys());

quiet ice
#

You do the filtering later on

#

Just to reduce duplicate code

#

Shower thought: Does it make sense to code an entire plugin using JASM or would the performance difference be too low?

tardy delta
#

JASM?

quiet ice
#

Basically a bytecode assembler

tardy delta
#

...that accepts a text file...

#

😳

#

ah bytecode yes

quiet ice
#

.java is also a text file

tardy delta
#

didnt see that

wet breach
tardy delta
#

String[] isnt Iteratable

#

just an array

#

char[][] kekw

quiet ice
#

myeh, a String is not a char array

wet breach
#

toArray technically gives Object[] which is not the same as String[] as the Object[] is backed by List and not List<String>

#

therefore you can't merely cast it like they are doing

tardy delta
quiet ice
#

It is more a byte[] wrapper if anything

wary harness
#

Is there any packet from client which will allow me to make check if fake entity is still spwned for them ?

#

or do I need to respawn it again

young knoll
#

I mean

tardy delta
#

"if it is spawned for them" - if that person can see it you mean?

young knoll
#

If they interact with it there will be a packet

wet breach
wary harness
#

so for example I spawn armor stand on top of player but player which is out of range will not get that packet range is lie 40 block or something like that what I tested

tender shard
wary harness
#

but that player which was out of range when armor stand was spawned will not see it

young knoll
#

Or if they kill it

wary harness
#

but I don't want to refresh it

#

for all players again because you got that flicker then

#

like for ones which are still seeing it

#

it will disappear and show again

#

@tender shard@young knoll

wet breach
#

also char and byte are different as well. Byte is a signed primitive and char is unsigned. Byte is 8bits and char is 16bits. Byte has a range of -128 - 127 and char has a range of 0-65535

tardy delta
#

nice

tender shard
young knoll
#

Char is the only thing that’s unsigned isn’t it

tender shard
#

but normally it shouldnt flicker at all if you e.g. send it every 10 seconds

wary harness
#

and I got it hooked on command

tender shard
#

I had never had problems with that stuff disappearing when going out of range

#

I use it for holograms with armorstands and area effect clouds

#

never had any problems with that

quiet ice
tender shard
#

I use this to show fake entities to players:

    @Override
    public void showEntityToPlayer(@NotNull final Object entity, @NotNull final org.bukkit.entity.Player player) {
        PacketUtils.sendPacket(player, new ClientboundAddEntityPacket((Entity) entity));
        PacketUtils.sendPacket(player, new ClientboundSetEntityDataPacket(((Entity)entity).getId(), ((Entity)entity).getEntityData(), true));
    }

It works fine even when players go out of range and then come back

#

Entity = NMS Entity

young knoll
#

Why object

quaint mantle
tender shard
tardy delta
#

wdym byte[]