#help-development

1 messages ยท Page 157 of 1

echo basalt
#

Sometimes I feel like catching a train just to come for your kneecaps

drowsy helm
#

imlukas be careful you can get banned for reaction spam

sullen wharf
#

oof

#

alright

#

i'll stop

echo basalt
#

Sadge

torn shuttle
#

and then make lines of code that are 100x longer

echo basalt
#

Big muscles big code

#

No pain no gain

torn shuttle
#

I'm making one heck of a meme rn

#

they'll remember me for this one

echo basalt
#

Your entire life is a meme

#

I'll remember you for sure

torn shuttle
#

thanks I'll remember me too

echo basalt
#

Bruh

torn shuttle
#

I really need to make this more resilient, I have the weirdest silent issues

echo basalt
#

I wonder why

torn shuttle
#

code gremlins and people cursing my code under their breath

#

I just need to make sure I re-salt all the doorways and windows so the bad vibes can't get in

echo basalt
torn shuttle
#

they hate us cuz they anus

torn shuttle
#

where my vape nation bros at

drowsy helm
true perch
#

I'm trying to learn Generics in java. Here's an example of something I am working with:
java 1 public class GenericClass<T>{ 2 private final ArrayList<T> list = new ArrayList<>(); 3 public GenericClass() { 4 } 5 public void addObject(T object) { 6 this.list.add(object); 7 } 8 public int getResult() { 9 int result = 0; 10 for (T index : this.list) { 11 result += index.getValue(); 12 } 13 return result; 14 } 15 16 } Line 11 doesn't work because the .getValue() method is found in the Class I intend to pass in through the diamond brackets <>. How can I call that method in a situation like this?

true perch
tranquil dome
#

I tried setting an entity's velocity to Vector(0, 0, 0) when I pull it with a fishing rod, but it does not stop the entity from getting pulled towards me. What should I do to stop the entity from moving to me?

tall dragon
#

yea how the heck did u get the numbers before the lines

#

did you aadd those manually?

#

~~```java
1
2 test
3

#

ah yes

#

@quaint mantle

#

uhhh

#

the second ~~ are wrong

true perch
#

This is purely an example I'm using to learn, I have no application intentions with this other than learning.

zealous osprey
#

That's very cool

true perch
#

getResult is just an example of a method being run by a certain type

#

not found in the generic class

echo granite
#

flatMap

ivory sleet
#

<T extends I>

#

then the type can at worst be erased to I

#

Well assuming I::getIndex exists

true perch
ivory sleet
#

Another way is ofc to have something like getResult(ToIntFunction<T>)

#

(Without restricting T)

#

however the operand function does the mapping

tranquil dome
#

How can I stop entities from being pulled with a fishing rod? I already listen to when the entity is being pulled, but I just can't manage to stop the entity from moving towards me

#

nvm

#

I can cancel the event and it won't do it

#

Actually no, that also prevents the rod from being pulled back

#

Is there a way to manually retract the rod for a player?

eternal oxide
#

setHookedEntity(null)

torn shuttle
#

set to null, the breakfast of champions

coral oyster
#

hi all, I'm trying to use a scheduled task but I can't seem to access variables declared in the class that the task is in in the runnable?
here is my task:

              Bukkit.getScheduler().runTaskLater(Main.getPlugin(Main.class) ,
                        new Runnable() {
                            @Override
                            public void run(){
                                player.setLevel(((vel_x + vel_y) / 2) * 999);
                                player.sendMessage("Player speed: " + ((vel_x + vel_y) / 2) * 999);
                            }}, 20);
            };

and intellij linter:

eternal oxide
#

Correct, they have to be effectively final or Atomic

coral oyster
#

but i want to change them in the task, i cant have them as constants

ivory sleet
#

just effectively final/final

#

Not atomic necessarily

eternal oxide
#

looks to me like you only want to calculate not reassign

ivory sleet
#

You can use a singleton array

coral oyster
ivory sleet
#

int[1]

#

Yes but effectively final is not the same as final

#

Effectively final usually means that the explicit variable used is non reassignable, but the content of the data the variable points towards is mutable

coral oyster
#

i think i get you, ill play around for a bit and see if i get it to work

ivory sleet
#

Myeah

tranquil dome
# eternal oxide setHookedEntity(null)

This method doesn't exist in 1.8 sadly. I tried removing the fishhook entity. This worked, but afterwards I couldn't cast my rod anymore. Do you have another solution?

eternal oxide
#

is vel_x the x velocity of your player?

coral oyster
#

yes

eternal oxide
#

then just read it from teh player

#

Player is already final

coral oyster
eternal oxide
#

its going to be wildly inaccurate as it ignores z

coral oyster
#

because the player is in a boat, I want to get the speed of the boat which wont be changing on the y axis

eternal oxide
#

Using Player#hetVelocity().length() would be simpler

#

but your code uses Y not Z

coral oyster
molten hearth
#

Bro missed xyz day

coral oyster
#

im used to 3D printers where z is up

crude charm
#

Why is a "a" being added to the start of the name?

            String input = event.getCurrentItem().getItemMeta().getDisplayName();

            int i = input.indexOf(' ');
            String name = input.substring(1, i);

            try {
                event.getWhoClicked().sendMessage(ChatColor.GREEN + "Teleported you to " + name);
                event.getWhoClicked().teleport(Bukkit.getPlayerExact(name).getLocation());
            } catch (Exception e) {
                ((Player) event.getWhoClicked()).sendMessage(ChatColor.RED + "Could not find a player with the name " + name);
                e.printStackTrace();
            }
coral oyster
eternal oxide
#

also boats can move up and down so best to not ignore Y

echo basalt
#

mf sent a screenshot that didn't have anything to do with chat

drowsy helm
#

i can count a total of 4 "a"s in that screenshot and none are at the start of anything

young knoll
#

A

remote swallow
river oracle
#

A

visual citrus
#

how to immue player knockback?

mighty pier
crude charm
# drowsy helm where?

When it prints the can not teleport error message is say "aZoiBox" or "a8" or whatever

#

it adds an a

mighty pier
#

lmao

#

color code

young knoll
#

Yep

#

You are substringing from 1

#

Color codes are 2 characters

crude charm
#

Oh

#

thanks

young knoll
#

You should just use ChatColor.stripColor

crude charm
wind tulip
#

Hey, can someone give me an example of a string you'd put in Material#createBlockData?

#

I want to set a block's data from a dictionary, like for example "half=top" and so on

wary harness
#

Any suggestion for good inventorylib

quiet ice
wary harness
remote swallow
#

looking it, it should work on most

sterile token
#

Hi im on programming classes bored

#

Could someone recommend a good for loader for java 1.8

crude charm
#

Why is my dummy taking dmg when I hit it?

@EventHandler
public void onPvP(EntityDamageByEntityEvent event) {
    event.setCancelled(true);
sterile token
#

I will use it to load a remote controller done on Java on the computer. Because they permissions are okay. But java has root permissions

#

๐Ÿคก

sterile token
crude charm
sterile token
#

I mean could be another plugin overriding the event

sterile token
#

๐Ÿ’ช

crude charm
quiet ice
#

OpenTTD and mindustry are the only two Games I Play at school

sterile token
#

They are really clown because how the fuck they will give all privileges for java when you know that from java you can do dirty things too

quiet ice
#

I want to say however: If you indend to do anything harmful - DO NOT DO IT

#

You would regret it. Circumventing Security at Schools are No laughing matter

sterile token
#

I mean I just will give a try of what I can do I wont leak data

#

Just talk with the director and told that they have security problems

#

I would do it as one of those ethical hackers

#

๐Ÿ˜‚ ๐Ÿ˜‚

tardy delta
sterile token
#

Do

#

I need a java loader please

#

๐Ÿ˜ก

tardy delta
#

a what?

sterile token
#

A loader for java

#

Fourteen

untold jewel
#

I like https://github.com/SamJakob/SpiGUI this api. Its easy to use and has alot of cool features. One problem is that it has an item hardcoded which I cannot remove. I've tried to set the slot to air, or another item but wont work. Anyone who knows how to remove it or maybe has a better API? Let me know

GitHub

A comprehensive GUI API for Spigot with pages support. - GitHub - SamJakob/SpiGUI: A comprehensive GUI API for Spigot with pages support.

sterile token
#

My school pcs are in land red but they are protected for executing programs. But what about java its has root privileges!!

tardy delta
#

didnt understand half of that sentence but anyways what youre studying?

sterile token
#

So im looking for a java loader to inject a native jar which do what ever I need

tardy delta
#

no idea wth a java loader is

sterile token
#

Im basically trying to test my school security

tardy delta
#

ah yes

sterile token
#

Java loader is a java program that load and execute a jar in the JVM

remote swallow
#

if it doesnt have a jvm already installed and you dont have admin perms, i doubt you can inject something into a jar file to run jar files

sterile token
#

Epic

#

Im doing that

#

The JVM has root privileges

#

I mean the computer itself is well protected but not as 100%

remote swallow
#

does the computer have java/jvm installed

sterile token
#

So that why im looking for a java loader

#

Yes it has

#

Im planning to make a java code which load a custom jar hided and then execute native methods from a DLL

#

๐Ÿค”

chrome beacon
crude charm
#

I've been patient

#

๐Ÿ˜ฆ

sterile token
#

You are not playing anyone

crude charm
sterile token
#

If you need support wait patientlly and if you dont want to your message get lost open a Thread

crude charm
#

HELP ME

sterile token
#

I dont know why its so diff to do that

tardy delta
#

new Thread(this::askHelp)

untold jewel
#

Inventory API GUI APi

smoky oak
#

how do i do a String <-> integer map (both directions) ?

agile anvil
#

Do you mean Integer (or char) array instead of integer map ?

#

Or what is your data structure ?

smoky oak
#

im asking generally how to make a map that links the objects on both sides to each other

agile anvil
#

Ohhh

#

This is not possible

chrome beacon
#

Guava has a bimap

agile anvil
#

Because the map is not made to have unique values

smoky oak
#

collection then

agile anvil
#

You'll have to use another structure like bimaps

smoky oak
#

thatd do it thanks

sterile token
#

Or use Map<String, Integer> names and Map<Integer, String> ids

#

๐Ÿ˜‚

hasty obsidian
#

how do I check if a player has a potion effect

undone axleBOT
hasty obsidian
#

like has any potion effect, because hasPotionEffect() requires a potioneffecttype

#

dont I need to check if a player has a potion effect?

tardy delta
#

ยฏ_(ใƒ„)_/ยฏ

#

can i use the return value of this and assume pos hasnt incremented?

#

looks like pos is incremented after value has been returned

chrome beacon
#

++pos

#

^ that's increment and use

#

pos++ is use then increment

tardy delta
#

i was thinking how jvm would be able to do stuff in that method if control was already given to another method

#

anyways

wary harness
#

NoClassDefFoundError: net/minecraft/network/protocol/game/PacketPlayInUseEntity

#

people getting kicked with this error?

#

When they join they get kicked

chrome beacon
#

Looks like it can't find that packet

remote swallow
#

could be a via version thing

chrome beacon
#

Or their plugin

crude charm
#

hi

sterile token
#

?hi

crude charm
#

?dontsayhello

sterile token
#

?nohi

#

?no Hello

#

I dont remember

#

Haha

#

There was a cmd

crude charm
#

Can u plz help

#

in my thread

#

its been over an hour

sterile token
#

What do you need

crude charm
#

check the thread

chrome beacon
#

?nohello

undone axleBOT
crude charm
#

do you see it?

sterile token
#

No

#

I cannot find the Thread

chrome beacon
#

There it is

tardy delta
#

new Thread(this::helpMe)

#

atleast smth that works

golden turret
#

hey guys is there a way to create empty objects?

#

like

quiet ice
#

new Object();?

vocal cloud
golden turret
#
Object myEmptyObject = SomeClassForThat.createEmpty(MyCoolObject.class);

Class<?> clazz = myEmptyObject.getClass();
Field field = clazz.getDeclaredField("test");
field.setAccessible(true);
field.set(myEmptyObject, "value");```
quiet ice
#

Or do you mean sun.misc.Unsafe#allocateInstance?

eternal night
#

I mean usually you want to get a specific constructor

quiet ice
#

Oh you probably mean allocateInstance then

eternal night
#

and call newInstance on it

#

allocateInstance gets pretty funny

quiet ice
#

You can call the constructor later on anyways

golden turret
quiet ice
#

Yeah, it's a feature-complete object

#

You won't run any constructors though

#

So all fields are guaranteed to be either null, 0 or false

torn shuttle
#

dust options are proof that god is dead and java killed him

hasty prawn
#

How so KEKW

torn shuttle
#

the constructor is a nightmare and I never remember how to do it

#

there's more than just redstone that can be colorable right?

#

fireworks and music notes should work as well?

tardy delta
#

i miss the c++ style of defaults params :(

torn shuttle
#

I miss sleeping

#
if (particle.equals(Particle.REDSTONE) || particle.equals(Particle.FIREWORKS_SPARK) || particle.equals(Particle.NOTE))
                location.getWorld().spawnParticle(particle, location, amount, x, y, z, speed,
                        new Particle.DustOptions(Color.fromRGB(red, green, blue), 1));

data should be class java.lang.Void got class org.bukkit.Particle$DustOptions
was this not the constructor?

hasty prawn
torn shuttle
#

bruh

#

oh

#

wait are fireworks just redstone particles and the spark is the trail?

hasty prawn
#

Note and Fireworks don't take any object apparently

tardy delta
#

FireworkMeta

hasty prawn
#

Yeah I think fireworks spark is just the white trail it leaves behind

#

Which doesn't have a color

torn shuttle
#

firework meta?

hasty prawn
#

FireworkMeta is for making actual fireworks

tardy delta
#

sets the color and stuff

torn shuttle
#

and notes?

tardy delta
#

what notes

torn shuttle
#

literal notes

#

the ones from jukeboxes

tardy delta
#

ah

hasty prawn
#

Looks like it's based on a 0 count with speed for some reason?

torn shuttle
#

is it still illegal to murder people?

hasty prawn
#

I believe so yes

torn shuttle
#

ah

hasty prawn
#

You could probably punch your monitor though that'd be fine

torn shuttle
#

why would I punch the monitor, it knows how to do rgb without summoning Cthulhu

#

ah except you need to add colors not as rgb but individual elements

#

for the fireworks

#

meh

#

wait actually not this won't work

#

I am spawning the particle not the firework, is it not possible to do this via the api then?

lunar forge
#
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.0.1-jre.jar:?]
        at org.bukkit.craftbukkit.v1_18_R2.block.CraftCreatureSpawner.setMinSpawnDelay(CraftCreatureSpawner.java:65) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3498-Spigot-b081915-10ba1be]
        at me.waterbroodje.customspawnerplugin.listeners.BlockSpawnListener.onBlockSpawn(BlockSpawnListener.java:24) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        ... 23 more```

```java
    @EventHandler
    public void onBlockSpawn(BlockPlaceEvent e) {
        NamespacedKey key = new NamespacedKey(CustomSpawnerPlugin.getInstance(), "spawner");
        PersistentDataContainer data = e.getItemInHand().getItemMeta(). getPersistentDataContainer();
        //.get(key, PersistentDataType.STRING);
        if (data.has(key, PersistentDataType.STRING)) {
            CreatureSpawner spawner = (CreatureSpawner) e.getBlockPlaced().getState();
            spawner.getPersistentDataContainer().set(key, PersistentDataType.STRING, data.get(key, PersistentDataType.STRING));
            spawner.setSpawnedType(EntityType.COW);
            spawner.setMinSpawnDelay(2000);
            spawner.setMaxSpawnDelay(8000);
            spawner.update();
        }
    }``` What did I do wrong lol
tardy delta
#

cache key and use pdc::getOrDefault

lunar forge
#

But I was trying to change the spawn delay and then this happend

tardy delta
#

that error message doesnt make much sense

sterile token
#

Why are you reinventing weed when it already exists! Just use it

gaunt relic
#

Hello, is there an easy way to get the drops of an entity? For example EntityType.ZOMBIE drops rotten flesh, is there a method that tells me that?

sterile token
#

LMAO

sterile token
tardy delta
#

stop reinventing weed pls

gaunt relic
#

It's because I want to do something else with the items, it's going to be some sort of fuel for the mob spawner, and I need to validate the item when someone clicks on a spawner

#

I guess I'm going to have to store all drop items on a map with the entity types

torn shuttle
#

the hell is a dust_transition

sterile token
undone axleBOT
sterile token
#

That is your best friend

hasty prawn
#

Set the maximum first

torn shuttle
lunar forge
#

Thank you

quaint mantle
#

why isn't the block setting to bedrock?

#
if (mineMaterials.contains(mat)) {
            var random = new Random();
            var amount = random.nextDouble(getAmount(mat));
            e.getBlock().setType(Material.BEDROCK);


            new BukkitRunnable() {
                @Override
                public void run() {
                    e.getBlock().setType(mat);
                }
            }.runTaskLater(CharmGenz.plugin, 50L);
            return;
        }```
#

it does get set back to the material

#

but doesn't get set to bedrock

torn shuttle
#

what in-game feature has transitioning particle colors?

gaunt relic
tardy delta
#

heeheehaw

hasty prawn
quaint mantle
#

and gets set back to the original material type

#

but doesn't set to bedrock

#

for some unknown reason

torn shuttle
#

my god you need 40/20 vision to spot the particles on this one

hasty prawn
torn shuttle
#

huh

#

not a gif

#

I didn't know mc added tentacles

quaint mantle
#

thanks

torn shuttle
#

finally they'll be able to get into the japanese market

quaint mantle
#

also

#

is there a better way of doing this

#

since im using 2 bukkit runnables

#
if (mineMaterials.contains(mat)) {
            var random = new Random();
            var amount = random.nextDouble(getAmount(mat));
            new BukkitRunnable() {
                @Override
                public void run() {
                    e.getBlock().setType(Material.BEDROCK);
                }
            }.runTaskLater(CharmGenz.plugin, 1L);

            Bukkit.broadcastMessage(String.valueOf(amount));

            new BukkitRunnable() {
                @Override
                public void run() {
                    e.getBlock().setType(mat);
                }
            }.runTaskLater(CharmGenz.plugin, 50L);
            return;
        }```
#

i mean, i could use 1

#

and just set a var every tick

#

suggestions, thoughts?

stoic vigil
#

how to give items a colorful lore?

ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setLore(<what comes here to make it colorful?>);
zealous osprey
#

Write some text with the color codes ig?

hasty prawn
#

Because since you weren't canceling, you're setting the type and then the block is being broken anyways, which is why it wasn't setting.

quaint mantle
#

okay, let me try

hasty prawn
torn shuttle
quaint mantle
#
            e.setCancelled(true);
            e.getBlock().setType(Material.BEDROCK);
            e.setCancelled(false);```
hasty prawn
#

No you have to keep it cancelled

quaint mantle
#

ah, makes sense

#

okay

solid cargo
#

do yall think that a server looping thru main hands of 30-40 players would cause lag?

hasty prawn
#

Nope

solid cargo
#

every tick

hasty prawn
#

Yeah, should be fine

#

The server is calculating AI for every entity every tick, so doing something like that is negligible in comparison

solid cargo
#

ic

#

yo but if a player is seen with an exploitable item (chests with nbt lmao) should i clear all inventory or the hand item?

eternal oxide
#

How is the player going to get a chest like that?

solid cargo
#

i think (im on mac rn) it was ctrl + middle click

eternal oxide
#

Thats creative mode

solid cargo
#

yes

#

the game is gonna be set in gmc

eternal oxide
#

You have near zero control over creative

solid cargo
#

yes but players can "ban" others by giving the item

eternal oxide
#

Don;t allow players to have creative

#

you are entering into a whole world of hurt for yourself

solid cargo
#

BUT WE NEED TO

#

its a building championship

eternal oxide
#

I highly doubt that

chrome beacon
#

Time to use Protocollib to remove all NBT from items

eternal oxide
#

they don;t need creative to build, you just have to be good at coding to simulate it

solid cargo
#

you asking me to make a "creative" menu on survival?

eternal oxide
#

yes

solid cargo
#

hah, try to explain it to people who play mc for first time

eternal oxide
#

Then limit all yoru creative to a single world

#

wipe inventories when they join/leave the world

solid cargo
#

WorldChangeEvent?

#

some like that?

eternal oxide
#

yes

tardy delta
#

me watching rust documentation to write java hmmyes

solid cargo
#

will this also cancel observers??

civic wind
#

Not sure why as it should just work to whatevers set in the config?...

orchid portal
#

Help plzz, you need to make sure that another block appears in the place of the previous block, I tried it as it is on the screen, it doesn't work, but there is a message, what should I do?

#

Sorry for broke english)

floral drum
tardy delta
#

how would i call a class that holds a char array to iterate over and a current position and is able to build numbers from those chars?

#

called it a StringReader first but might do CharBuf or smth

tardy delta
#

world might be null too

orchid portal
tardy delta
#

youre changing the material

orchid portal
tardy delta
#

if it wasnt obsidian before you wont notice it being changed

orchid portal
tardy delta
tardy delta
orchid portal
#

ahhh, got it, thanks

tardy delta
#

dang it

#

as usual im eating comma positions

floral drum
tardy delta
#

hi babe

#

๐Ÿ’€

#

the hell happened with discord, why is this so fucking big

floral drum
#

What the fuck

hasty prawn
#

You can change the size of it

#

Or atleast the horizontal size Thonk

floral drum
#

๐Ÿ˜ญ

tardy delta
#

can only make it bigger smh

#

hehe i better call my class CharEater

floral drum
#

wtf

tardy delta
#

its wasting chars lol

floral drum
#

oh

tardy delta
#

looks a bit better already

#

only bloat asf

floral drum
#

uwu

tardy delta
#

also unoptimized asf

floral drum
#

oh

#

L

tardy delta
charred blaze
#

When I keep mouse on bukkit event it says javadoc could not be found. How can I add spigotmc javadocs in eclipse?

tardy delta
#

OWHH now i figured out why copilot was doing pos--

#

it was trying to debloat my code smh

tardy delta
#

just use ij lol

charred blaze
tardy delta
#

brr

#

even my phone has more ram

charred blaze
#

MEHH

patent fox
#

how can i check if entity is dropped item?

worldly ingot
#

You have a 32 bit computer? PandaSpooky

#

Are you using Maven, Greened?

charred blaze
charred blaze
#

What am I doing wrong rn?

patent fox
tardy delta
#

kinda made it work

worldly ingot
#

I've always found Eclipse's artifact Javadoc tool to be inadequate. I could never get it to work, personally

#

Using Maven resolves the issue just fine because Javadocs are auto downloaded as artifacts, but I could never do it via the classpath

#

I don't think Bukkit's Javadocs generate a package-list file so I believe that's why it's failing

charred blaze
#

so...

charred blaze
tardy delta
#

why not use vscode if youonly have 4gigs ram?

#

lol

charred blaze
#

but

tardy delta
#

just use notepad

charred blaze
#

i have lot of projects on eclpse

charred blaze
tardy delta
#

lemme guess.. no?

charred blaze
#

how can i fix that on ECLIPSE?

tardy delta
#

idk

#

that seems kinda slow tho

#

never look at how Math.pow is implemented lmao

#

i thought it was 400 lines

#

ah 250

charred blaze
tardy delta
#

close mc lmfao

charred blaze
tardy delta
#

is server running on ya pc too?

charred blaze
tardy delta
#

good

charred blaze
#

where are the javadocs in this jar?

tardy delta
#

i believe they arent included

charred blaze
#

i fixed it with replacing https with http but still its not working

#

Note: This element has no attached source and the Javadoc could not be found in the attached Javadoc.

#

aaaaaaaa

#

i get it

#

maybe this url gives me other minecraft version's javadocs right?

patent fox
#

how can i check if entity is dropped item?

crimson terrace
#

thats the solution

tardy delta
#

isnt that Item class?

crimson terrace
#

entity instanceof Item or whatever

tardy delta
#

^^

patent fox
#

yes i dont know the class name

crimson terrace
#

lemme check

#

there we go

charred blaze
crimson terrace
#

๐Ÿ™‚

#

theyre useful when you can read

#

which means most of the time I ignore them

charred blaze
patent fox
#

thanks

crimson terrace
#

XD

crimson terrace
crimson terrace
#

I cant help you with that

eternal oxide
#

With Eclipse you should not be setting javadocs manually

charred blaze
#

Unknown javadoc format for Player {key=Lorg/bukkit/entity/Player;} [in Player.class [in org.bukkit.entity [in C:\Users\topic\OneDrive\Desktop\files\dato\server\jars\spigot-1.12.2.jar]]]

#

error log

eternal oxide
#

Probably because you are in OneDrive. Never a good thing

charred blaze
eternal oxide
#

don;t do it on your desktop

charred blaze
#

the desktop folder is in only onedrive folder as far as i know

hasty prawn
#

I do all my stuff off OneDrive ๐Ÿ˜„

#

Except BuildTools because it cries

charred blaze
hasty prawn
#

I dunno it just works

#

All my projects are in the OneDrive folder and IntelliJ seems to handle it just fine

hasty prawn
#

Why not

jade grove
# hasty prawn Why not

theres a 50/50 chance that you lose the data inside your onedrive regardless if you login to your microsoft account after factory resetting

young knoll
#

Fuck onedrive

hasty prawn
jade grove
#

happened to me b4 and i wanted to kill myself

#

then again, it was just porn

hasty prawn
#

I don't really plan on Factory resetting anyways

#

But good to know I suppose.

echo basalt
#

Onedrive stinky

#

Just use google drive

#

The desktop app syncs your folder and gives you a virtual network disk that lets you use files from other computers directly

stoic vigil
#

intelliJ says that ShapedReceipt is deprecated, but whats the newer version of it? or can i just ignore it?

chrome beacon
#

Javadoc should tell you

stoic vigil
#

oke thy i'll look there

#

ah so the new is just with a key?

young knoll
#

Mhm

opal juniper
#

what have i done wrong

young knoll
#

Integer[]

#

Although I would just use int[]

opal juniper
#

huh i didnt know that was how that worked

#

thanks

stoic vigil
#

how to get the "plugin" in a seperat class? NamespacedKey key = new NamespacedKey(<???>, "emerald_sword");

young knoll
#

?di

undone axleBOT
stoic vigil
#

ah thx โค๏ธ

#

is it normal that a custom receipt isn't shown in the receipt book? or do i need to do smth that it appears there?

#

ah oke, so how to unlock if the user has a specific item in his inventory?

young knoll
#

Vanilla does it through hidden advancements

stoic vigil
#

is it possible to make it a default, that the receipt is unlocked for every player?

lost matrix
hoary quartz
#

hey guys, this is my first time ever programming a plugin but for some reason when I put the version in the dependency part, it say's that it's not found

#

I've literally just copy and past the code in the spigot maven topic

lost matrix
hoary quartz
#

this has appered

#

how there is errors if it's a new project lol

lost matrix
#

Tha fk? Did you install maven on your pc?

chrome beacon
#

Intellij comes with maven bundled

hoary quartz
lost matrix
#

Change the maven home dir in your maven settings and select a maven bundle (v3)

stoic vigil
#

how to read a namespaced key out of the plugin? like i created one at the receipt and now need it to give the player the receipt

hoary quartz
quaint mantle
#

Does bukkit runnables lag the server once theres a decent amount

#

Or when does it start to lag the server

lost matrix
hoary quartz
#

because I've following a tutorial and the guy it's using the jdk 1.8, i've just notice this now

lost matrix
quaint mantle
#

True ig

stoic vigil
lost matrix
# quaint mantle True ig

Managing runnables is quite painfull. I usually just create one runnable and add tasks to it to work on.
Then add another runnable for other types of tasks.

lost matrix
floral drum
#

I've been diagnosed with habba ๐Ÿ˜ญ

lost matrix
floral drum
#

habba good day ;3

#

oh

#

OH SHIT

#

LMAO

hoary quartz
#

for some reason

stoic vigil
subtle folio
#

How can I store a list of objects in json with gson?

lost matrix
subtle folio
#

I only know how to store one object,

lost matrix
#

A list is an object

subtle folio
#

I can just toss in the list?

#

but what about reading

#

List.class?

lost matrix
#

You need a TypeToken for that. One moment ill show an example

subtle folio
#

Kk

lost matrix
#
    List<String> inputList = List.of("Foo", "Baz");
    Gson gson = new GsonBuilder().disableHtmlEscaping().create();
    String json = gson.toJson(inputList);
    Type token = new TypeToken<List<String>>(){}.getType();
    List<String> outputList = gson.fromJson(json, token);

But you should generally not have a need to manually serialize collections like that.

subtle folio
#

I see

#

very peculiar

#
    String json = gson.toJson(inputList);``` This part is writing?
#

and the below is reading

lost matrix
#

Yes

subtle folio
#

Thank you 7

quaint mantle
#

How much can 500MB store?

#

As in documents on mongo

subtle folio
#

oh

#

nvm

quaint mantle
#

๐Ÿคฏ

subtle folio
#

was confused by the question at first XD

quaint mantle
#

Im planning on storing around 100-200k documents with around 20 variables in each. Im guessing I'll be totally fine. But im just going to make sure

hasty prawn
#

I mean you can probably get a rough calculation if you know how much space each variable uses.

vocal cloud
#

Just store 1 document and make 200k of them

quiet ice
#

500 MB is huge amounts of storage if spent wisely

quaint mantle
#

I think we good

#

Around 40 bytes per 20 characters in a variable

#

So just 40 * (10 * 150000)

#

Which is 60M bytes aka 60MB

#

Around 833K variables give or take since some will cost more storage than others

#

I think im good xD

mossy gazelle
#

Hey so trying to make a code that places blocks behind an arrow, but the blocks just gets placed inside of the arrow and then it stops. Looking for something that can delay the block placement

hasty prawn
#

?scheduling

undone axleBOT
mossy gazelle
#

Dude

#

I hate that scheduling thing

hasty prawn
#

It's pretty easy, what are you having issues with?

river oracle
#

can someone walk me through how to module your project with maven I don't really get how it works i kept getting errors last time trying to do it. I'm trying to submodule my project because of NMS versions

quaint mantle
#

how would i change the location of the compile jar in maven?

mossy gazelle
#

I think I figured it out, but dose this work??

#

public void BlockBow(EntityShootBowEvent s) {
new BukkitRunnable() {
@Override
public void run() {
Entity arrow = s.getEntity();
if(arrow instanceof Arrow) {
Location loc = arrow.getLocation();
if(loc.getBlock().getType() == Material.AIR) {
loc.getBlock().setType(Material.GOLD_BLOCK);
}runTaskLater(plugin, 30);
}
}
}.runTaskTimer(plugin, 0, 0);
}

#

With the runtasklater?

#

@hasty prawn

#

Sorry if its not allowed to ping

hasty prawn
#

You would need another BukkitRunnable if you want to schedule 2 tasks like that.

fluid river
mossy gazelle
#

Dude am so dumb

#

Can I use it inside an schedule task?

fluid river
#

e.getProjectile() returns the arrow

mossy gazelle
#

Thanks

#

So this wont work?
public class tutevents implements Listener {

Main plugin;
public tutevents(Main plugin) {
    this.plugin = plugin;
}
@EventHandler
public void BlockBow(EntityShootBowEvent s) {
    new BukkitRunnable() {
        @Override
        public void run() {
            Entity arrow = s.getProjectile();
            if(arrow instanceof Arrow) {
                Location loc = arrow.getLocation();
                new BukkitRunnable() {
                if(loc.getBlock().getType() == Material.AIR) {
                    loc.getBlock().setType(Material.GOLD_BLOCK);
                }
                }.runTaskLater(plugin, 33);
            }
        }
    }.runTaskTimer(plugin, 0, 0);
}

}

#

I think I got it

#

Honesly thought schedule was so hard

fluid river
#

and you messed it up

mossy gazelle
#

Noonononon

#

Fixed it

fluid river
#

still messed up

mossy gazelle
#

Added the public void again

#

@EventHandler
public void BlockBow(EntityShootBowEvent s) {
new BukkitRunnable() {
@Override
public void run() {
Entity arrow = s.getProjectile();
if(arrow instanceof Arrow) {
Location loc = arrow.getLocation();
new BukkitRunnable() {
@Override
public void run() {
if(loc.getBlock().getType() == Material.AIR) {
loc.getBlock().setType(Material.GOLD_BLOCK);
}
}
}.runTaskLater(plugin, 5);
}
}
}.runTaskTimer(plugin, 0, 0);
}
}

#

Actually kinda works

#

But getting lower fps for a wierd reason

eternal oxide
#

every tick you are scheduling a new runnable to run in 5 ticks time

fluid river
#
@EventHandler
public void BlockBow(EntityShootBowEvent s) {
    Entity entity = s.getProjectile();
    if (!(entity instanceof Arrow arrow)) return;
    new BukkitRunnable() {
        public void run() {
            if (arrow.isInBlock()) this.cancel();
            else {
                Location loc = arrow.getLocation().clone().subtract(loc.getDirection().normalize());
                if (loc.getBlock().getType() == Material.AIR)
                    loc.getBlock().setType(Material.GOLD_BLOCK);
            }
        }
   }.runTaskTimer(plugin, 1L, 1L);
}```
eternal oxide
#

he needs it every tick

#

he's creating a trail of blocks everywhere the arrows goes

#

yep

#

you also need to cancel the timer when the arrow dies

mossy gazelle
#

Should I just add remove arrow or something?

#

or dosent that work?

#

Ah okay that makes sense

#

Thank you so much guys

#

Feel like I have learned so much

fluid river
#

you could learn this days ago if used my

#

FREE JAVA LESSONS

checkmybio

mossy gazelle
#

It just says Free java lessons

fluid river
fluid river
mossy gazelle
#

Soooo how do I get them?

fluid river
#

basiaclly

#

dm me

mossy gazelle
#

xD

fluid river
#

it's 1:56 for me

mossy gazelle
#

Its 1 am

#

Got school and work tomorrow xD

fluid river
#

so after sleep

mossy gazelle
#

Yeah sure

fluid river
#

we could do smth

mossy gazelle
#

But one last thing

#

Getting error on if (arrow.isInBlock()) this.cancel();

#

isinblock

fluid river
#

yeah i forgot to cast it

#

changed

mossy gazelle
#

if (((AbstractArrow) arrow).isInBlock()) this.cancel();

fluid river
#

no

mossy gazelle
#

Like that?

#

if (((Arrow) arrow).isInBlock()) this.cancel();

fluid river
#

that's just Arrow class

#

i changed it different way

#

use it instead

#

so you don't do class cast everytime

mossy gazelle
#

Okay

#

But think I gotta get sleep now, thanks again btw

torn oyster
#

what would be the best way to store player cosmetics (with different categories) and what they select

#

mysql

fluid river
#

?

#

there is no best way

torn oyster
#

a good way then

fluid river
#

if you have many values just don't use yaml

#

cuz if file size gets too big YamlConfiguration.loadConfiguration() goes brrt

#

and dies

#

If you want to have 2 columns(player, cosmeticId) just use a small sql table then

#

or use a lot of small yml files for each player(see no real need in this)

torn oyster
#

can you store an array in there?

#

oh wait i could store a string

#

that is like

#

cosmeticID,cosmeticID,cosmeticID,cosmeticID,cosmeticID

#

etc

#

and do string.split(",") or something

#

and then a mysql thing of all cosmetics

#

or yaml file actually

#

to store what item the cosmetic is

lost matrix
#

Create a table for cosmetics with owner ids

|     ID    |      owner     |       cosmetic     |
___________________________________________________
|     01    |    DDA4-UI33   |        Wings-A     |
|     02    |    DDA4-UI33   |      Walk Trail    |
|     03    |    KN9K-F099   |        Wings-A     |

This is the correct relational approach

torn oyster
#

oh?

#

but i would have thought that each cosmetic type would have its own id

#

rather than who owns it

fluid river
#

the string.split methods sound fun too xD

torn oyster
#

and their id

#

like each item has its own id, rather than each instance of a player owning an item

fluid river
torn oyster
#

what's the pros and cons of each?

torn oyster
quaint mantle
#

how would i fix this?

#

Exception in thread "cluster-ClusterId{value='6336287dfe350b564eed7153', description='null'}-ac-itkzscn-shard-00-00.gdgktnz.mongodb.net:27017" java.lang.IllegalStateException: zip file closed

fluid river
#

well for string split you need to get value from db

#

if does not exist store a new one

#

if extists add new value to the string you got and store it again

quaint mantle
#

and this

lost matrix
#

You have a "one to many" relation. So if you use a relational database and not a document one like mongodb then
the correct way is a separate table with one entry for each cosmetic with its owner.

quaint mantle
#

com.mongodb.MongoQueryException: Query failed with error code 8000 with name 'AtlasError' and error message 'user is not allowed to do action [find] on [database.collection]' on server ac-itkzscn-shard-00-02.gdgktnz.mongodb.net:27017

#

because mongo is being weird

fluid river
#

guy got zip file error

quaint mantle
fluid river
#

based

quaint mantle
#

it should anyawys

lost matrix
#

And dont reload. The message even tells you that it causes bugs.

fluid river
#

well basically don't leave your connections opened and so on

quaint mantle
#

because mongo is being gay

#

but how do i fix that second error

#

credentials are correct

#

i triple checked

fluid river
#

drinking vodka

#

eating pelmeni

#

not using mongo

#

russians only use 1ะก

lost matrix
# quaint mantle because mongo is being gay

This can happen if you have a user that only has permission to a certain database but you do not include this in your connection string. E.g. the connection string atlas will recommend is
mongodb+srv://:@productive.abcd.mongodb.net/?retryWrites=true&w=majority

but if your user only has access to the database "my-database" the connection string should look like this
mongodb+srv://:@productive.abcd.mongodb.net/my-database?retryWrites=true&w=majority

quaint mantle
#

i fixed it

#

we good

#

thanks

#

also, im wanting to make a collection per server

#

how would i do that?

#

i could do the server name

#

but if they change it, it'll break

lost matrix
#

The plugin users should manage their own databases

quaint mantle
#

alr

stuck flax
#

Would HumanEntity.getInventory().getItemInMainHand() be null if no item is held or an item with Material.AIR, and does the same got for .getEquipment().getHelmet()?

torn oyster
#

how would I prevent arrow pickup?

stuck flax
#

I figured it out, it's Material.AIR

strong parcel
#

Right now I am working on an item that you activate and deactivate by right-clicking and delete by dropping. Also, if the item is active, it should not be dropped. I am running into an issue though because apparently the PlayerInteractEvent gets fired when you drop an item while looking at air. This means that if the item is active it will stop the item from dropping, but it will also deactivate the item. The DropItemEvent fires first, so what I am thinking is to time stamp the DropItemEvent, put the timestamp into a hashmap, and cancel the PlayerInteractEvent if it is within a fraction of a second of the drop event. Is that the best way to do it though, or is there a better way to solve the issue?

kind hatch
grave lagoon
#

can someone help me modify the loot table of a player and natural chests

#

to buff it

#

like the luck effect but actually does something

quick zenith
#

For PlayerChangedMainHandEvent how do i get the old item?

alpine narwhal
quick zenith
#

oh

alpine narwhal
#

The event you're looking for should be InventoryInteractEvent

quick zenith
#

isnt that for like clicking on the inventory?

alpine narwhal
#

That includes their own inventory.

quick zenith
#

ok leme try

hasty prawn
#

You sure they're not looking for PlayerSwapHandItemsEvent?

#

I.e, when they put something in their offhand

alpine narwhal
#

How did I miss that in the docs ๐Ÿ˜ข

hasty prawn
#

Lol, it happens

torn oyster
#

how does hypixel do their first person view thing?

#

where you can look into the eyes of other players as spectator?

hybrid spoke
torn oyster
alpine narwhal
#

Player#setSpectatorTarget

torn oyster
#

i can't get one either

#

it's a relatively small feature

torn oyster
#

as i was saying, it's a relatively small feature so nobody really makes video on it

mighty pier
#

put the player in spectator

torn oyster
#

no

mighty pier
#

cringe

torn oyster
#

i use my own spectator system bruh

mighty pier
#

cringe

alpine narwhal
#

Well, then idk what to tell you.

torn oyster
#

no

#

i have my reasoning

mighty pier
#

every second teleport player

#

boom

torn oyster
#

they will see the other one

#

the player

#

tho

alpine narwhal
#

hide them?

mighty pier
#

are you stupid

torn oyster
hybrid spoke
#

we cant help you without knowing what you mean

torn oyster
#

oh my god i'll get a video

mighty pier
#

ik what you mean

alpine narwhal
#

Bro is pressed ๐Ÿ˜ญ

mighty pier
#

it just teleports the player im pretty sure

#

what other way is there

torn oyster
#

this is some random person i clicked on

#

when i died

alpine narwhal
#

Yea, thats spectator mode.

torn oyster
#

no

#

it's not

#

u have a hotbar and a character

#

a hot bar with items

#

oh wait

#

actually

#

i think they put u in spectator mode

#

that's smart

alpine narwhal
#

no shit

torn oyster
#

and then take u out of it

#

to do normal spectating

#

normal spectating: flying around in survival mode with invis and stuff
first person spectating: spectator mode

#

but how would i keep track of when they exit the first person view?

alpine narwhal
#

They use Sneaking

torn oyster
#

ye

#

isn't that vanilla too?

#

u sneak to exit?

alpine narwhal
#

iirc

torn oyster
#

is there a packet i would listen for?

alpine narwhal
#

An event yes.

torn oyster
young vale
#

i need a plugin to whitelist players from discord

torn oyster
#

?services

undone axleBOT
torn shuttle
#

so there def. no way to spawn the beams from guardians via the api right

#

I guess other than spawning an invisible guardian for these purposes

crimson terrace
quaint mantle
#

yeah

chrome beacon
torn shuttle
#

I am having some pretty hardcore code rot issues

chrome beacon
#

ow

torn shuttle
#

I was abusing static back in 2017 (tbf it made sense back then) and now it has come back to haunt me

chrome beacon
#

I just rewrite everything

torn shuttle
#

I mean

#

sort of halfway through doing that as is

#

what I really need to do is either make some of the core classes cloneable or completely tear it down and rebuild it so they can generate objects I can use

#

these do some pretty expensive parsing operations and at the scale this needs to run I do not want to redo that every time

#

yeah think I'll just split the parsing to its own thing and use the parsed data for instantiation

#

I can already tell this is not going to be fun

crimson terrace
chrome beacon
#

Maintain what's that. I'm stuck in my rewrite cycle

crimson terrace
#

XD

torn shuttle
#

I used to keep track of my rewrites

#

I don't do that anymore

chrome beacon
#

I've rewritten my forge mod 3 times now

#

I'm wondering if I should start over again

crimson terrace
#

having learned about separation of concerns and constructor injection, aswell as composition over inheritance I do think its pretty good code for like 1 year of experience XD

torn shuttle
#

fast forward two years, turns out you didn't know anything about inheritance and are rewriting the project to use it way more

crimson terrace
#

except when you dont actually have any reason to use it

#

interfaces, yes. abstract classes, barely

torn shuttle
#

that just makes my prophecy sound way more sound

crimson terrace
#

why tho

chrome beacon
#

Abstract classes have their use

crimson terrace
#

obviously

#

didnt say never to use them

torn shuttle
#

half the battle is discovering how they can be used more efficiently

crimson terrace
#

welp, I hope I can at least refactor my code instead of rewriting it all

#

not even half way done and its like 2k lines already

torn shuttle
crimson terrace
#

old code was like 10k, the one before that was 15k

#

doing the same stuff with less code is good

echo basalt
#

Magma flexing inefficiency

torn shuttle
crimson terrace
#

we are

echo basalt
#

Mans in denial

torn shuttle
#

jealousy intensifies

crimson terrace
#

but is the total with or without empty lines?

#

and comments

echo basalt
#

What comments

torn shuttle
#

it's 55482 of code

#

2780 comments because comments are for cowards

shadow zinc
#

any way I can optimize this code, it finds the subcommands by looking at the first arg, finding the commands, getting the annotations and matching the arg

#
    public static Class<? extends Command> getSubcommand(Class<? extends Command> root, CommandBuilder commandBuilder, String[] args) {
        if (args.length > 1) {
            ArrayList<Command> commands = commandBuilder.getCommands();
            ArrayDeque<String> argStack = new ArrayDeque<>(Arrays.asList(args));
            Iterator<String> value = argStack.iterator();
            Class<? extends Command> previousCommand = root;
            while (value.hasNext()) {
                String currentArg = value.next();
                Class<? extends Command>[] annotatedSubcommands = CommandUtils.getSubcommands(previousCommand);
                if (annotatedSubcommands!=null) {
                    for (Class<? extends Command> subcommand : annotatedSubcommands) {
                        if (subcommand.getName().equalsIgnoreCase(currentArg)) {
                            previousCommand = subcommand;
                        }
                    }
                }
            }
            return previousCommand;
        }
        return null;
    }```
torn shuttle
#

let me tell you

#

I am now splitting it up so I can precache the parsing

echo basalt
#

Sounds like my original plan but with changes

torn shuttle
#

and I'm approaching it with all the finesse of a man with a chainsaw and about 5 minutes before they get to clock out

echo basalt
#

Sometimes I want to have good nights of sleep and then you ping me with some code

echo basalt
#

This is exactly what I wanted to avoid

#

That if check on the default param because you couldn't bother making an empty block of code

#

It's gonna be a long day today I can feel it

pseudo hazel
#

the if check is pointless

echo basalt
#

No he has a feature he didn't implement and needs it

#

But it makes me want to shriek

torn shuttle
#

you're both wrong

#

it actually runs on the penultimate line lol

pseudo hazel
#

?

#

well thats true

#

but it will fail silently if the type isnt a run script

torn shuttle
#

it's an action that just runs the additional scripts, and every action does that as well if any exist

pseudo hazel
#

then I probably messed up my switch syntax then

torn shuttle
#

I just didn't want console telling people the action was jacked up when it's just not meant to do anything

#

presumably @echo basalt prefers this far worse solution

#

which actually I should be able to delete now

#

I think

#

wait no never mind I can't

shadow zinc
torn shuttle
#

I mean not really

#

anyone who has ever done complex stuff with mc materials has probably written switch statements 3-5x the size of this one

pseudo hazel
#

not that bad

shadow zinc
#

its nearly as many cases of beer I got in the back

pseudo hazel
#

this is what switches are meant to do after all

torn shuttle
#

I've seen switch statements go over 500 lines

#

I've even refactored a few

shadow zinc
#

just think you could some register and handle thing

#

register cases in a class and then handle them elsewhere, might be neater

pseudo hazel
#

whats the difference

#

you are just spreading out the work that needs to be done

torn shuttle
#

it takes more time and ultimately you write more

#

and makes it harder to find what you're looking for

#

what's not to like

crimson terrace
#

but if you need to change something specific you know where to find it

torn shuttle
#

good luck remembering the name of every variable lol

pseudo hazel
#

well if you need to change something here you just edit the switch

shadow zinc
#

I just think it would be a bit more solid and if you eventually end up with 500 cases, its gonna be a lot easier to manage

torn shuttle
#

some of the people in here have a straight up otherworldly definition of "easier"

shadow zinc
#

future proof then

torn shuttle
#

how is that future proof

pseudo hazel
#

how is 500 classes more future proof compared to a 500 case switch

torn shuttle
#

would you rather have 2000 classes or 2000 lines in a switch statement

shadow zinc
#

I never said have 2000 classes lol

torn shuttle
#

then you have failed to future proof

pseudo hazel
#

then what did you mean exactly?

crimson terrace
shadow zinc
#

something like this

crimson terrace
#

breaking them up into a few classes each with a switch to handle those specific cases would be good

shadow zinc
#

so instead of a switch, I register each version and its handled elsewhere

torn shuttle
#

oh so I get to still write a line per entry but also I have to manage that entry elsewhere on top of that?

crimson terrace
#

just imagine that comes to 500 lines of switch

shadow zinc
#

kinda, I made a builder, registered each "condition" and then I use a manager that matches each condition and runs the appropriate code

crimson terrace
#

and instead of going through all 500 of them you go through 5 lines and check what you need to edit

#

and then you only have 100 lines instead of 500 which you need to get through. and edit or change

shadow zinc
#

I mean you do you, I'm just giving you some advice so you don't cry yourself asleep when you have 500 conditions/cases

torn shuttle
pseudo hazel
#

I prefer something like a big switch over a conplicated builder/manager

torn shuttle
#

you are exponentially adding lines and complexity to something that is currently 1 line, 2 if you include the bit where I have to register the field

crimson terrace
#

at this point I assume that the code we dont see isnt actually complex

pseudo hazel
#

in a case where each result would be 1 lone of code, making it more complicated than a switch just doesnt make much sense imo

#

this switch could already be compressed a bit if you grouped cases with the same outcome

torn shuttle
pseudo hazel
#

like all parseInteger cases etc

pseudo hazel
shadow zinc
pseudo hazel
#

why

#

also that has nothing to do with java in particular

crimson terrace
pseudo hazel
#

i dont want to complicate code for the sake of making it more complicated

torn shuttle
#

all values are assigned to their own variables

pseudo hazel
#

yeah u right, I wasnt looking at it correctly

crimson terrace
#

youre reading values from config?

torn shuttle
#

mostly yes

crimson terrace
#

that makes a little more sense then

#

not sure if its possible in your case but I use ConfigurationSerializable for my plugins

pseudo hazel
#

I see, it would be ridiculous to create a complicated structure to read some files

shadow zinc
#

File reading is fine I guess, especially if that scale will stay constant.

torn shuttle
#

I also don't understand why so many people don't just ask what the final scope of the system is

#

I'm already nearly done with all the actions I'll ever want to add

#

it's 17 lines right now, it might be 30 by the time all is said and done

#

30 cases is nothing on a switch statement

crimson terrace
#

wasnt looking at it properly, I was thinking that you had a specific method for each case, which isnt so. if there was a specific implementation for each case a class to handle it or something would be good

harsh totem
#

The problem was that the picture didn't exist because it was deleted

pseudo hazel
crimson terrace
#

just grouping them roughly would help out, not 1 class per function but one class per like 5 or so

pseudo hazel
shadow zinc
#

at least they are using a switch statement and not if statements

ivory sleet
#

The classic agreement is that a class must only have one major reason to change (formally known as single responsibility principle)

Then we have that a function must only do one thing, which is defined as when you cannot extract another function from your given function

However there are some contentions against these classic principles

crimson terrace
pseudo hazel
#

usually

shadow zinc
#

at least thats my philosophy

ivory sleet
#

Well if the code hinders you from being able to properly extend, modify, debug or test it then the code must be poorly written to some degree

#

Needless to say, switch statements/expressions are convenient but they are sometimes seen as evil

crimson terrace
pseudo hazel
#

for no reason other than looking repetitive

ivory sleet
#

For one, switches tend to do more than one thing

shadow zinc
#

switch statements give me Vietnam flashbacks

crimson terrace
#

a switch is just a concise chain of command

ivory sleet
#

Also switches sometimes imply your class is a dependency magnet which is usually something you do want to evade if possible

shadow zinc
#

this is one two occurrences of me using switch statements in my code

ivory sleet
#

Myeah thatโ€™s probably more fine

#

Although pretty useless

#

We have TimeUnit to convert between time units

pseudo hazel
#

i also use switches in my Command classes

ivory sleet
#

Mhhheh, might be fine

shadow zinc
#

stackoverflow told me to use spring

ivory sleet
#

Lol

pseudo hazel
#

why not

#

it works for me

#

i just switch on the arg to get the command

shadow zinc
#

hell na

#

thats going to far

pseudo hazel
#

noone ever taught me another way

ivory sleet
#

It works

shadow zinc
#

please

pseudo hazel
#

wdym

pseudo hazel
#

i wont make a class for every single command argument if thats what you mean

ivory sleet
#

But mapping arguments is usually a better design choice overall

pseudo hazel
#

then teach me something better

shadow zinc
#

use a command manager or make one

ivory sleet
#

For all literal sequences you have a sub command class

#

And then arguments are just arguments

#

Parse as per usual

pseudo hazel
#

most command executions are not more than 5 lines, including player checks

ivory sleet
#

/somecommand epic dodo 4
epic dodo - literal/subcommand identifier
4 - argument
somecommand - main command

pseudo hazel
#

yeah I dont see the benefit of this

#

this will just add like 8 more classes to my code for not much reason

shadow zinc
# pseudo hazel then teach me something better

This might help you understand it as well https://www.youtube.com/watch?v=WyFN_jTS4nU

In this episode, I show you how to make a Command Manager for your Spigot plugin to easily manage sub-commands. This will make your life much easier, trust me. I will apply this concept to the Quarter Master plugin, next episode. #Spigot #MinecraftPluginDevelopment

Code: https://gitlab.com/kinglydeveloper/command-manager-spigot

โญ Kite is a fre...

โ–ถ Play video
ivory sleet
#

^ especially if your command class does a lot of different things

shadow zinc