#help-development

1 messages ยท Page 175 of 1

wary topaz
#

you think I dont get that?

fluid river
#

what is the problem then

dense crow
#

lol

fluid river
#

....

wary topaz
#

its not giving me an error to help me debug this shit

dense crow
#

somebody can tell me how i can request a players UUID, when he never played before? wanna do a sort of own whitelist not based on the minecraft one

wary topaz
#

Bukkit.getOfflinePlayer (name).getUniqueId

dense crow
fluid river
#

do it by nickname

#

ez solution

wary topaz
#

Use a string in the name

fluid river
#

does it really return null tho

#

it's deprecated + it's notnull

dense crow
#

huh weird

fluid river
#

notnull too

dense crow
#

my server is in online mode, normally it should work wtf

fluid river
wary topaz
#

i had to remove if (!(sender instanceof Player)) {

remote swallow
#

!(sender instanceof player p)

wary topaz
#

true

#

but no

fluid river
#

in yml file or with flag

remote swallow
#

!(sender instancefof Player) will go through if they arent a player

#

oh wait i just realised what its doing

#

dont mind me

fluid river
#

even tho you don't get debug messages, why do you use weird old constructions

#

which are replaced in newer java versions

wary topaz
#

wdym

fluid river
#

switch (usage) {
case "spectator":
case "sp":
case "4":
target.setGameMode(GameMode.SPECTATOR);
gamemode = "SPECTATOR";
break;

wary topaz
#

are you saying I should use if?

fluid river
#
case "spectator", "sp", "4" -> {
    target.setGameMode(GameMode.SPECTATOR);
    gamemode = "SPECTATOR";
}```
#

ya know

#

no break needed

wary topaz
#

ohhh you measn that

#

good point

#

I might do that

fluid river
#

if (!(sender instanceof Player)) { why not using pattern matching?

wary topaz
#

wdym

fluid river
#

and why do you guys use that still

#

it's basically can only be null if you manually edited plugin.yml in jar file

fluid river
# wary topaz wdym
if (!(sender instanceof Player player)) {
    sender.sendMessage("omg you are console");
    return false;
}
// now you are free to use player variable anywhere in the method
#

tho half of this can be wrapped with Enum

wary topaz
#

but idont need to use player as I have Sender

fluid river
#

what if you want to set your own gamemode with these commands

wary topaz
#

wdym

fluid river
#

not for another player but to yourself

wary topaz
#

/gmc

fluid river
#

you can't set it to sender

#

only to player

wary topaz
#

oh yeah

#

thats true

#

thats why it errored!

fluid river
#

>>> asking for help not for a lesson ๐Ÿ™‚

wary topaz
#

yeah yeah but what about the target

#

it doesnt have arg 1 so ill have to fix that

fluid river
#

add aliases please

#

don't check for label

dense crow
#

is it normal that the bukkit dont make any web request with that offlinePlayer method?

fluid river
#

hardcoded UUID generator i guess

buoyant viper
#

couldve sworn i looked at the server code for getting an OfflinePlayer and found out it was a Lookup

#

might have to look again ig

fluid river
#

a lot of spaghetti

dense crow
fluid river
#
public Gamemode(Main plugin) {
    this.plugin = plugin;
    plugin.getCommand("gamemode").setExecutor(this);
    plugin.getCommand("gmc").setExecutor(this);
    plugin.getCommand("gma").setExecutor(this);
    plugin.getCommand("gms").setExecutor(this);
    plugin.getCommand("gmsp").setExecutor(this);
}```
at least i refactored constructor
oblique wigeon
wet breach
#

still around?

fluid river
oblique wigeon
fluid river
#

gmc can't have gamemode creative alias

#

as far as i remember

oblique wigeon
fluid river
#

bro

#

you can't do that

#
gmc:
  aliases: [gamemode creative, creative]```
oblique wigeon
fluid river
#

so what the heck are you talking about then

#

he has 5 different commands

#

gmc gma gms gmsp

#

which can't basically have any other aliases

#

i mean they can but not defined here

oblique wigeon
fluid river
#

and gamemode which has gm alias only

fluid river
oblique wigeon
fluid river
#

so you would need to do like label check

oblique wigeon
#

so no

fluid river
#

which is extremely cringe

#

if you use /gma you get adventure

#

and /gmc gives creative

oblique wigeon
#

also why would you need /gamemode creative as an alias

fluid river
#

cuz gmc is shortcut to gamemode creative

oblique wigeon
#

that's already a default mc command

fluid river
#

true btw

#

not to me

#

not my code

#

blame author for redefining gamemode command

#

i guess i know why

#

he wants colored messages on /gamemode

oblique wigeon
fluid river
#

this one i sent doesn't tho

#

these are all different commands

#

you basically do cmd.getName()

kindred valley
#

Hello

oblique wigeon
#

they all have the same executor object

fluid river
#

well you do cmd.getName() check now

#

not label

#

tho same

#

but still

oblique wigeon
fluid river
#

that's why i never execute all commands in one CommandExecutor

#

doesn't cmd.getName() for gm return parent command tho

#

if gm is an alias to gamemode in plugin.yml

#

never checked this

#

and never watched the sources of Command class

oblique wigeon
#

here's my solution:

class AdvCmd {
 .. GamemodeCommand.adv()
}

class CreCmd{
 .. GamemodeCommand.cre()
}

class SrvCmd{
 .. GamemodeCommand.srv()
}

class SpecCmd{
 .. GamemodeCommand.spec()
}

class GamemodeCommand {
 .. switch(args[0]){
      case "spec":
        spec
      etc ...
  public static boolean adv(){
    // set to adv mode
  }
  etc...
}```
#

you can always condense it and put them into the same class, but imo it's unnecessary

fluid river
#

so each command would have own executor class in your solution?

oblique wigeon
#

another optimization you can do is just to have a single static function that takes in a string that represents a gamemode

#

and then calling that instead of doing the independent logic on each one

fluid river
#

Basically have an Enum with ()

#

tho not the best solution

oblique wigeon
#

tf lmao

#

lol what was that

fluid river
#

i mean refering to one guy here

#

who suggests enums a lot

#

everytime possible

oblique wigeon
fluid river
#

forgotthename

#

i mean i have one executor for each command

#

cuz they easily eat command aliases

#

other solutions for me are garbage from the beginning

#

hard to refactor

#

hard to read

#

lazy asses think it's a good idea to have all of them in one class

#

and leave with 200 lines of unnecessary code after that

oblique wigeon
#

its ok im gonna go spend 10 hours reinventing the wheel

fluid river
#

good luck

#

โค๏ธ

#

the only thing i do with a shame is writing multiple EventHandlers in one class

earnest socket
fluid river
#

hehe some good shit coming

#

a lot of code tho

#

not an easy task to get where your problem starts

wet breach
#

so first recommendation

#

don't use star imports

#

you should import only the things that are actually needed, not too big of a deal. Second, I think it might be with the runnables if you are experiencing any lag in regards to your plugin. And if not that, possibly the dynmap stuff since dynmap isn't exactly resource friendly

#

also, for comparing the doors

#

instead of using a string you can actually use this

#

there is a door type category that applies to all the doors so you don't need to use a contains

earnest socket
#

which didn't lag

#

also my runnables don't run very often

#

my save runnable runs only every 20 mins

earnest socket
#

I didn't compare doors anywhere

wet breach
earnest socket
#

oh you mean thta

#

do I check if the block is an instance of Door?

wet breach
#

believe block data has a getType

earnest socket
wet breach
#

then its just getType == Type.door

#

block data

earnest socket
#

oh wait

#

Didn't know about Type.

wet breach
#

part of BlockData ๐Ÿ™‚

earnest socket
#

there is no type

earnest socket
#

doesn't work

wet breach
#

or you can use Openable

#

then that gets doors and fence doors ๐Ÿ™‚

#

which you should be able to do an instance check with that

#

instead of a ==

earnest socket
#

yeah doesn't work either

wet breach
#

you need to get BlockData

#

check if the blockdata is an istance of openable

earnest socket
#

ok that worked

wet breach
#

unfortunately can't do that with seeds I don't think lol

earnest socket
#

I tried removing org.bukkit.* from the imports

#

it just readded it

#

automatically

wet breach
#

need to change your IDE settings

#

anyways as far as the lag goes, I don't really see anything specific that stands out, other then just possibly being dynmap stuff. Even if it comes from factions doesn't necessarily mean it is optimal because it does come from that

#

Java VisualVM is a profiler you could use to profile

#

also, if you go the heapdump route to look at that

#

then just be warned that heapdumps are the same size as the amount of ram you allocated to the server

#

so if you allocated 10GB and then took a heapdump, it will be a 10GB file

earnest socket
#

I did make a heap dump and put it into visualVM

#

still trying to understand how to use it though

fluid river
#

you can do

#

Tag.DOOR.isTagged(material)

#

if you want to check if block is a door

earnest socket
#

I found what was causing most of the lag

#

I think it's my getClaimedChunks method in the Nation object

#

I am using another method to turn a chunk into a string and back because when a Chunk is unloaded it then returns null

wet breach
#

why are you turning a chunk into a string?

earnest socket
wet breach
#

ok but that doesn't answer why turning it to a string

earnest socket
#

I am saving it into a string so I can save it into memory

wet breach
#

just use chunk coords

earnest socket
#

and then use world.getChunk() to get it back

earnest socket
wet breach
#

As long as you have the x and z, you can always load a chunk

earnest socket
#

I also need the world

#

that's why I turn it into a string like "world,x,z"

#

and then I use getChunkAt

#

wait

#

I have an idea

#

not sure if it'll work better

#

factions uses it's own object for chunks

#

that stores the world x and z positions

#

would that be faster than using strings?

wet breach
#

Well you could just use serialization

#

so just use a custom object that implements serializable

#

and then you can just straight save the object

earnest socket
#

So basically what I suggested right?

wet breach
#

no need to convert it to a string and then you can load the object again by deserializing it

wet breach
earnest socket
#

how do I exactly implement serializable. I mean just implements serializable shouldn't work right?

#

do I have to make a certain method

wet breach
#

for a class to be serializable it needs to implement serializable

earnest socket
#

yes I did that

wet breach
#

it needs to have a long UUID constant in the class

earnest socket
#

for the world field in my object

#

should I use World

#

UUID

#

or string for the name

#

I suppose world can be removed from memory

#

making it return null

wet breach
#

generally it is better to use UUID's because world names can be changed, but not their UUID's however the name should be fine because most people don't generally make it a habit of changing their world names

earnest socket
#

is any faster than the other

wet breach
#

no, both are the same as both are loaded at server startup

#

server, loads all the worlds the server has at startup and loads all the information into memory so doesn't really matter

earnest socket
#

no I mean like is getting the world from a name or UUID faster

wet breach
#

I just told you world information is loaded at server startup, therefore when using those methods it just fetching the data that is already loaded in memory

earnest socket
#

not sure but maybe comparing a string is slower than a UUID

wet breach
#

so no neither one is faster or slower then the other

earnest socket
#

ok

wet breach
#

now, if you are doing comparison checks though

#

it is generally faster to check object equality then it is string comparisons

brave goblet
#

Is it ok to make listener classes with parameters?

wet breach
#

sure

remote swallow
#

what type or parameters

brave goblet
#

and pass that instance to my listener

remote swallow
#

yeah thats fine

wet breach
#

the only thing is, when you go to register your listener

#

you need to be able to feed those types your listener requires

remote swallow
#

best to pass ``this` in and have methods to get that

wet breach
#

well you have to create the listener class object when registering your listeners

#

therefore if your listener requires parameters

#

you need to be able to pass in the parameters you specified

brave goblet
#
Ranking ranking = new Ranking(economy);
getServer().getPluginManager().registerEvents(ranking, this);
getCommand("rank").setExecutor(ranking);
#

this is how i registered it

remote swallow
#

isnt it a lot easier to just follow vaults docts and have getEconomy in main class and just pass this in then this.plugin.getEconomy

wet breach
#

in most cases vault isn't required

#

people think if they are providing an economy, that they need to implement vault but don't realize that for people to use vault with their economy, vault actually needs to implement their economy not the other way around

#

unless vault changed since I last looked at it, but I think it is still at version 1.7

#

if you are trying to provide api for your own economy, you could just directly do so

#

no need for vault

brave goblet
wet breach
#

ah ok, that is a valid use case then ๐Ÿ™‚

brave goblet
#

Same result in the end right? and i don't have any other get methods from the main class

brave goblet
wet breach
#

not sure if it is, because this would refer to your plugin

brave goblet
#

ok nvm

wet breach
#

not the plugin that holds the economy

brave goblet
#

eg

#
        return econ;
    }```
#

ok nvm

#

how do i even find this.plugin

remote swallow
#

there is more than likely a better way but this is the best i know


public class MyClassName implements Listener {
  private final MainClassName plugin;

  public MyClassName(MainClassName plugin) this.plugin = plugin;
}
wet breach
#

public class EconListener implements Listener {
    Plugin plugin;  //<---- this.plugin refers here

    public EconListener(Plugin plugin) {
        this.plugin = plugin;
    }
}
brave goblet
#

AH ok make sense thanks

remote swallow
#

this.plugin.getEconomy or plugin.getEconomy work

brazen hollow
remote swallow
#

?paste ur pom

undone axleBOT
brazen hollow
earnest socket
#

For whatever reason this returns a ClassCastException. Does anyone know why?

#

All I do
new TerraChunk(chunk)

#

and it says I am casting the chunk

chrome beacon
#

Doesn't look like you're casting in that code

earnest socket
#

ik

chrome beacon
#

Make sure the plugin jar is up to date so it matches the code

earnest socket
#

that's why I am confused

#

I did

tall dragon
earnest socket
#

wait actually I didn't

#

I put the plugin in the root of my server

#

not in the plugins folder

tall dragon
#

lmfao

earnest socket
#

I am stupid

brazen hollow
#

lol

manic furnace
#

I try to sent a fake Chat msg with the ClientboundPlayerChatPacket but im stuck. One of the needed Parameters is the SignedMessageBody, takes a ChatMessageCotant, an Instant, salt and LastSeenMessages. What is salt and how can I get it? And how can I get the LastMessagesSeen?

chrome beacon
#

Send a system message

#

So not send a fake message from a player

manic furnace
#

I just want to see if it is possible with packets

chrome beacon
#

Don't

manic furnace
#

Why

chrome beacon
#

Chat reporting

#

It is also the reason why you need all of those params

manic furnace
#

Oh shit ok

#

That makes sense

#

What รญs the simplest thing you can do with nms? I just want to test my ReflectionUtils

chrome beacon
#

You can spawn a mob

manic furnace
#

Ok thanks

orchid portal
#

Help, how to change the color of the chat? I tried like this: Bukkit.getServer().broadcastMessage("&l[&d&lDS&f&l]"); However, this comes out:

manic furnace
molten hearth
rigid bone
#

Is there any pugin that changes player's skin depending on his tag?

brave goblet
#

I have a problem when i add vault api to my plugin all later versions of minecraft items break using Material.

#

eg honey block and deepslate

#

I am using version 1.7

remote swallow
#

1.7 isnt supported

brave goblet
molten hearth
#

average 1.7 logic

brave goblet
#

1.8 doesn't even exist ๐Ÿ’€

visual tide
tender shard
#

yeah

#

1.8 should have been dead the moment 1.9 got released

brave goblet
#

๐Ÿ’€

tender shard
#

idk why minecraft is the only game where people use 8 year old versions and consider this okay

brave goblet
#

also PLAY_ONE_MINUTE is counted in ticks correct?

tender shard
brave goblet
#

yup just double checking

#

so to get from ticks to milliseconds you / 50 or *

#

because one tick happens every 0.05 seconds

young knoll
#
  • 50
#

1 tick is 50ms

brave goblet
#

Ok cool cool then from milliseconds to seconds u / 1000

summer agate
#

Hello, I'm working on a plugin and am trying to diagnose the cause of lag. I think a profiler is the best way to go. I've managed to run a profiler on the whole server, but I'd like to run one on just my plugin. Is that possible?

rough drift
#

go to plugins -> yourplugin and you'll see the causes of lag there

summer agate
#

Oh yes I just forgot that existed haha

wet breach
rough drift
wet breach
#

profiler they should be able to isolate methods specific to their plugin

#

or even class objects

rough drift
#

oh yeah

summer agate
#

Thanks a bunch

white root
#

The issue that im having is that I cant figure out how to tell if the player is actually putting the item on their head or not, since event.result seems to always be ALLOW and event.isCancelled is always false, even if when a player on a non-modified client clicks on an armor slot with an item in their cursor, and the item does not get placed. Any suggestions?

brazen hollow
#

Can't you get the slot the player is trying to move the item to?

drowsy helm
#

Do a 1 tick delay and see if the item was set

tardy delta
#

whats uwu girl doing there

#

im not laughing

brazen hollow
#

I am

toxic sage
#

Does anyone know what I am doing wrong? He tries to teleport the NPC to the player's locations, but he teleports to the spawn of the world

    public static void run(Player player){
        ServerPlayer cPlayer = ((CraftPlayer) player).getHandle();
        GameProfile gProfile = new GameProfile(UUID.randomUUID(), player.getName());
        ServerPlayer npc = new ServerPlayer(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld)player.getWorld()).getHandle(),
                gProfile, null);
        Location loc = player.getLocation();
        npc.teleportTo(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
        cPlayer.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
        cPlayer.connection.send(new ClientboundAddPlayerPacket(npc));
    }
opal bone
#

Hey guys question

I have a plugin that adds a possibility to place water in the nether
but when i try to waterlog a block it still evaporates the water.
Even tho i set it to waterlogged
placing normal water does work

    public void onWaterPlace(@Nonnull PlayerInteractEvent event) {
        final Player player = event.getPlayer();
        final Block clickedBlock = event.getClickedBlock();
        if (event.getClickedBlock() != null
            && event.getItem() != null
            && clickedBlock != null
            && WorldUtils.inNether(player.getWorld())
            && player.getInventory().getItemInMainHand().getType() == Material.WATER_BUCKET
            && Purification.getValue(clickedBlock.getChunk()) >= Purification.PLACE_WATER
        ) {
            event.setCancelled(true);

            if (clickedBlock.getBlockData() instanceof Waterlogged block
                && !block.isWaterlogged()
                && !player.isSneaking()
            ) {
                block.setWaterlogged(true);
            } else if (clickedBlock.getRelative(event.getBlockFace()).isEmpty()) {
                clickedBlock.getRelative(event.getBlockFace()).setType(Material.WATER);
            }

            if (player.getGameMode() != GameMode.CREATIVE) {
                event.getItem().setType(Material.BUCKET);
            }
        }```
tardy delta
#

uhh i forgot but how do i do this?

#

my class cant be generic

drowsy helm
drowsy helm
tardy delta
#

mhh stackoverflow stated that its not possible and that i have to use wildcards and internal casting

toxic sage
drowsy helm
#

ClientboundTeleportEntityPacket

spring cypress
#

Hi so im using spigot to make a minecraft server on my raspberry pi 3 b and ive run into an erros reading Error: unable to access jarfile /home/emdeboss/minecraft/spigot-1.15.2.jar nogui i have no clue how to fix can anyone else know?

drowsy helm
#

And ClientboundRotateHeadPacket

drowsy helm
#

Nogui shouldnt be part of that error

tardy delta
#

hmm i like the syntax

drowsy helm
#

Ou thats nice

#

Not async tho id assume

tardy delta
#

its a pain implementing

#

still doing so

manic furnace
#

In NMS, do the craftbukkit or net.minecraft.server imports change cause of the version?

spring cypress
#

java -Xms512M -Xmx1008M -jar /home/emdeboss/minecraft/spigot-1.15.2.jar nogui @buoobuoo

manic furnace
drowsy helm
#

Just nms

#

But craftbukkit names can change sometimes

opal bone
manic furnace
#

When I print out the name of the package entityplayer is in, it say net.minecraft.server.level without an version

drowsy helm
#

Yeah needs the hyphens

spring cypress
drowsy helm
#

If itโ€™s on a cli os you dont need the nogui bit anyway

opal bone
tardy delta
#

why this not working smh

spring cypress
drowsy helm
#

Afraid not sorry

manic furnace
opal bone
#

are you on linux egg?

opal bone
spring cypress
#

no im using a raspbery pi

tardy delta
opal bone
#

yea okay so you are on linux mind doing ls /home/emdeboss/minecraft/

spring cypress
#

what?

#

ahh ok thx

drowsy helm
#

What os are you using

#

On the pi

spring cypress
#

raspian i think

opal bone
#

i assume raspbian

tardy delta
#

no ubuntu server :(

drowsy helm
spring cypress
#

alr i did the command

opal bone
#

send the output

drowsy helm
#

Dont thi k the intial <T> is necessary

tardy delta
#

unexpected <T>

#

iirc

#

wait

spring cypress
#

apache-maven-3.6.0 BuildData BuildTools.jat BuildTools.log.txt Bukkit CraftBukkit spigot.jar work

tardy delta
#

unexpected token ye

drowsy helm
#

Thats your issue

opal bone
#

okay change java -Xms512M -Xmx1008M -jar /home/emdeboss/minecraft/spigot-1.15.2.jar nogui to java -Xms512M -Xmx1008M -jar /home/emdeboss/minecraft/spigot.jar --nogui

drowsy helm
#

Youโ€™re trying to gwt spigot-1.15.2 or whatever

#

Not spigot.jar

spring cypress
#

ok

#

now i get an error saying

#

invalid or corrupt jar file

#

then the /home and all of that

tardy delta
#

became even worser

opal bone
#

it seems like your spigot jar is corrupt then

spring cypress
#

how can i fix it?

tardy delta
#

hope my stuff makes any sense

drowsy helm
#

Looks fine to me

#

Resolver.apply throws an exception right

tardy delta
#

ye

#

the fact that it compiles doesnt mean it makes sense lol

drowsy helm
#

Should just use reflection to apply;)

tardy delta
#

mye i was thinking about that too but ive never used reflections and im trying to make my stuff as fast as possible

round finch
#

with java how would I load a jar API from a spefic folder?

tardy delta
#

UrlClassLoader?

round finch
#

inside my program

tardy delta
#

ah static block not allowed in an interface lol

drowsy helm
#

Make it all abstract class

#

Ez fix

tardy delta
#

fuck it

#

need nested query support

molten hearth
#

so I'm spawning an Armor Stand to show the amount of damage dealt by the player every time a player whacks an entity, is there any way to prevent the player from hitting the armor stand when they attack the entity thats behind the armor stand

drowsy helm
#

I do the same thing and have never had issues with hitboxes

#

If you want to go above and beyond, have a class for each armorstand which contains a parent (the mob) and when the armorstand is hit transfer the damage to the mob

molten hearth
#

hmm I guess that works lol sounds so hacky ty

tardy delta
#

should be smth like this

#

Connector will probably be a static var

round finch
tardy delta
#

google

round finch
#

bruh

#

didn't find much

#

i did google search before asking

#

clearly i'm too autistic to give a good question for google or there isn't much to find?

#

@tardy delta

molten hearth
#

bing

grand pebble
#

Yahoo

round finch
molten hearth
#

are you referring to something like URLClassLoader

round finch
#

Getting a jar file from a folder in my program

molten hearth
#

uhm

round finch
#

inside the program

molten hearth
#

ooh

#

you mean in your resources?

round finch
#

sorry brain confusion

I mean I want to get a jar from some spefic folder load class from the chosen jar into my own program

molten hearth
#
URLClassLoader child = new URLClassLoader(
        new URL[] {myJar.toURI().toURL()},
        this.getClass().getClassLoader()
);``` you can set `myJar` to be whatever jar you're trying to load
#

if this is what you're trying to do

round finch
#

isn't URL for websites?

molten hearth
#

I have no idea why they called it URLClassLoader

#

actually its because you give it an URL

#

but a file path can be an URL

round finch
#

pain

#

i wanted this for a plugin

#

to load random apis

#

:)

molten hearth
#

you can do like java URL myJarURL = new File("path/to/my.jar").toURI().toURL(); URLClassLoader child = new URLClassLoader( myJarUrl, this.getClass().getClassLoader() );

round finch
#

this is very fancy

#

๐Ÿ˜„

tardy delta
#

an url is a universal resource locator so not only for sites and whatever

#

i was confused too

glossy venture
#

URI is even more confusing right

tardy delta
#

whats an uri even

molten hearth
#

an URLI

glossy venture
#

universal resource identifier

#

lmao

#

cant even locate the resource

#

bozo

tardy delta
#

kinda stupid that the ide cannot infer that sneakyThrow will neverr return normally even with a contract

glossy venture
round finch
#

i learn something "new" yesterday with path "./myFolder/"

molten hearth
tardy delta
#

lol

molten hearth
#

dis might help too

tardy delta
#

i broke ij

#

foudn old code

#

that time when i decided to write a linkedlist impl :/

molten hearth
#

alright boys I am once again back with my maths skill

#

how does one implement a % of something happening? I guess my best bet is if I have 50% then I convert it to 0.5 then uh maybe I generate a random number between 0 and 1 and if its <= 0.5 then I return true else I return false?

tardy delta
#

Random::nextInt == percentage / 100?

molten hearth
#

holy shit that sounds

#

useful

#

one sec

tardy delta
#

like that will be 0.1, 0.3

molten hearth
#

ima make tea and reflect on that one

tardy delta
#

fuck java

#

idk never used

eternal oxide
#

No point in most cases

molten hearth
#

unless im doing cryptography or smth why should I care about that? (genuine question)

eternal oxide
#

If I'm generating a random to generate some loot there is zero point in using SecureRandom

molten hearth
#

personally im using this as a crit chance %

drowsy helm
#

Elaborate

molten hearth
#

so I guess players could carefully commit mafs to calculate when they'll definitely crit? kind of overkill imo if they want sure

eternal oxide
sterile token
#

I would like to see how you Implement it

molten hearth
#

ah well they'll either crit or not crit

#

thats all they see

eternal oxide
#

impossible, unless they have server access and can trace every single generated random

crimson terrace
eternal oxide
#

Yep

drowsy helm
#

I dont think ANY player would care to go to that level of pain-in-the-assery to do that

#

Either way tjats not the wnd of the world

young knoll
#

Arenโ€™t randoms seeded by the system time when created with no set seed

eternal oxide
#

of course you do, you have to be able to know every random which was generated to be able to predict teh next random

drowsy helm
#

Encryption and cryptography are probably the only proper usecase for them

young knoll
#

So youโ€™d need the exact system time the random was created

serene sigil
#

can some 1 help me with this?

why doesnt this work?? (the item doesnt show up)

molten hearth
#

well

#

copilot recommends me this code lol

tardy delta
molten hearth
#

except I cant use nextInt from a static conext

#

good times

floral drum
molten hearth
#

ikr

floral drum
#

that's why I don't pay for it

tardy delta
#

got it for free lol

young knoll
#

ThreadlocalRandom.current

floral drum
#

Fuck you

crimson terrace
tardy delta
#

no fuck you

floral drum
#

only if you're 18

crimson terrace
#

fuck all of us?

tardy delta
#

i am 18

floral drum
#

pog

eternal oxide
#

No you can't as not all randoms are generated for you

sterile token
tardy delta
#

copilot copying my old code

eternal oxide
#

To predict you have to see every random which is generated to monitor teh patern

tardy delta
floral drum
tardy delta
#

basically

serene sigil
tardy delta
#

its another ij window lol

molten hearth
eternal oxide
#

Randoms do follow a sequence, BUT if you only see one random every now and then, predicting becomes impossible

#

even then these are random generated in a plugin to determin crits. You will never actually see the random result, only a true/false so impossible to predict

floral drum
#

LOL

molten hearth
#

๐Ÿ’€

serene sigil
#

damn

#

nice

molten hearth
#

bro really wanted those free 5 iron ingots

floral drum
#

hahaha

molten hearth
#

๐Ÿ’€

floral drum
#

guessing you had to make sure no-one used the casino whilst you were trying to obtain the sequence?

molten hearth
#

bro really wanted those minecraft vbucks to irl trade

sterile token
floral drum
#

oh

molten hearth
#

I'd say skill issue

young knoll
#

โ€œI can crack random number generation in a casino pluginโ€ฆ with the source codeโ€

floral drum
serene sigil
molten hearth
floral drum
#

nah fam I'm chillin

serene sigil
#

JUST PLZZ

echo basalt
#

y'all acting like kids

serene sigil
#

ye

floral drum
#

F

serene sigil
#

no, the item just doesnt show up... the gui does

young knoll
#

Isnโ€™t slot 2 the output

#

Game probably overrides it immediately since there is nothing in the input

sterile token
#

Fourteen I was trying to do something like:

void test() throws Exception;

Executor executor = Executors.newScheduledExecutor();

executor.submit(test()).catch(ex -> sout(ex.getMessage())) ;

serene sigil
tardy delta
sterile token
#

Bloat?

tardy delta
#

all my exception handling is basically rethrowing the exception so the delegate can handle it

sterile token
#

Im really fucked to have to do try-catch un executor

tardy delta
#

i had a Result<T, E extends Exception> before

serene sigil
#

i tried casting but it gave classcastexeption

sterile token
#

I dont know why the fuck you cannot pass a method throwing a checked exceptions

#

๐Ÿ˜ก

serene sigil
sterile token
#

?

#

I mean I always confused checked exception with uncheked

serene sigil
#

jk lol

sterile token
#

Checked exceptions are the one throwing right?

white root
#

Ok, can someone tell me im not crazy?
This almost feels like a spigot bug, but im probably just doing something wrong

This code here kotlin @EventHandler fun onInventoryClickEvent(event: InventoryClickEvent) { val slot = event.slot val cursor = event.cursor val current = event.currentItem println("slot: $slot, cursor: $cursor, current: $current") } outputs this for some reason????```verilog
[08:37:10 INFO]: slot: 17, cursor: ItemStack{GOLDEN_HELMET x 1}, current: ItemStack{DIRT x 1}
[08:37:10 INFO]: slot: 17, cursor: ItemStack{GOLDEN_HELMET x 1}, current: ItemStack{AIR x 0}
[08:37:10 INFO]: slot: 17, cursor: ItemStack{AIR x 0}, current: ItemStack{GOLDEN_HELMET x 1}


It seems that when in creative mode, it correctly identifies the event.slot as 39, but when in survival mode it always says slot 17, and even goes as far as saying that event.currentItem is the item that is actually in slot 17, instead of what is in the helmet slot (39)
serene sigil
#

oh shitlin

#

alr

sterile token
#

Kotlin ๐Ÿคข

white root
#

It has the same affect as java, just a better format (imo)

#

Idk java, only kotlin

serene sigil
tardy delta
#

checked ones are the one that the ide knows of and that you need to surround with a try catch

sterile token
#

Fourten so what exception is this

#

void test() throws Exception

undone axleBOT
tardy delta
tardy delta
#

cuz it doesnt extends RuntimeException

sterile token
#

Ok

tardy delta
#

btw isnt there a oneliner to create a file if it does not yet exist?

severe night
#

why this is happening? someone know?

tardy delta
#

mwoa 3 lines

serene sigil
molten hearth
#

new File(databasePath.normalize().toString()).createNewFile();

sterile token
#

Fourteen what do you recommend to be able to pass method with checked exceptions thru an executor

molten hearth
#

it should make the file if it doesnt exist and ignore it if it exists

serene sigil
#

help...

eternal oxide
# serene sigil help...

Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.inventory.CraftInventoryCustom cannot be cast to class org.bukkit.inventory.SmithingInventory (org.bukkit.craftbukkit.v1_19_R1.inventory.CraftInventoryCustom and org.bukkit.inventory.SmithingInventory are in unnamed module of loader java.net.URLClassLoader @3b764bce)

serene sigil
#

ik

#

but why?

eternal oxide
#

you shoudl not be casting at all

serene sigil
#

ye but the item doesnt appear

eternal oxide
#

remove the cast and then tell us what happens

serene sigil
#

basically the gui opens but without the sword...

eternal oxide
#

surely a smithign inventory has slots 0 and 1 with a result in 2

serene sigil
#

it has

jaunty crag
#

what is the packet to make a chest appear opened

serene sigil
#

i tried changing from 0-3 but 3 gave me an exception, so it registers the slots

#

but not the item

eternal oxide
#

0-2 is correct

#

smithign doesn;t have 3

serene sigil
#

exactly

eternal oxide
#

what are you trying to do? It looks like you are tryign to open a smithing inventory with ONLY a result

brazen hollow
serene sigil
#

basically i have a server with custom crafting recipies, one of them is if u put an iron sword + diamond in a smithingtable it will give u a diamond sword. And im trying to make a "tutorial" where a gui opens and shows everyone how to craft it

manic furnace
#

Im a bit confused about reflections, because the imports in my case from 1.19.2 are net.minecraft.server instead of net.minecraft.server.v1_19_2

white root
eternal oxide
#

You can;t set the result slot without anything else (I don;t believe)

serene sigil
#

wdym?

eternal oxide
#

you need something in slot 0 and 1 to be able to put something in slot 2

#

ie you can;t have a result without an input

serene sigil
#

oh okay

#

im gonna try

tardy delta
#

lets see if it works

white root
# white root Ok, can someone tell me im not crazy? This almost feels like a spigot bug, but i...

So I scraped together enough stackOverflow to translate my code to java, ill repost this here

Ok, can someone tell me im not crazy?
This almost feels like a spigot bug, but im probably just doing something wrong

This code here java @EventHandler public final void onInventoryClickEvent(@NotNull InventoryClickEvent event) { int slot = event.getSlot(); ItemStack cursor = event.getCursor(); ItemStack current = event.getCurrentItem(); System.out.println("slot: " + slot + ", cursor: " + cursor + ", current: " + current); } outputs this for some reason????```verilog
[08:37:10 INFO]: slot: 17, cursor: ItemStack{GOLDEN_HELMET x 1}, current: ItemStack{DIRT x 1}
[08:37:10 INFO]: slot: 17, cursor: ItemStack{GOLDEN_HELMET x 1}, current: ItemStack{AIR x 0}
[08:37:10 INFO]: slot: 17, cursor: ItemStack{AIR x 0}, current: ItemStack{GOLDEN_HELMET x 1}


It seems that when in creative mode, it correctly identifies the event.slot as 39, but when in survival mode it always says slot 17, and even goes as far as saying that event.currentItem is the item that is actually in slot 17, instead of what is in the helmet slot (39)
tardy delta
#

show your project structure

tardy delta
#

why is your main class class in a main folder tho

serene sigil
#

bruh md_5 plz fix smithing table

brisk estuary
#

Hi, does anybody here work with MongoDB? I followed all the instructions from https://www.spigotmc.org/wiki/using-mongodb/ but I'm getting an error when I try to connect to Mongo -> java.lang.NoClassDefFoundError: com/mongodb/client/MongoClients

brisk estuary
tardy delta
eternal oxide
tardy delta
#

might abstract away sql strings tho

toxic sage
#

is it possible to detect the click of a lying NPC? I use the ProtocolLib plugin and when I click on a standing (or floating) NPC, he sends me a message, but completely ignores the sleeping NPC...

        ProtocolManager manager = ProtocolLibrary.getProtocolManager();
        manager.addPacketListener(new PacketAdapter(this, PacketType.Play.Client.USE_ENTITY) {
            @Override
            public void onPacketReceiving(PacketEvent event) {
                PacketContainer pack = event.getPacket();
                int enId = pack.getIntegers().read(0);
                event.getPlayer().sendMessage(enId+"");
            }
        });
tardy delta
#

tutorial for what?

eternal oxide
#

we should have a...

#

?tutorial

#

but we don;t

untold jewel
#

Is it possible to make Entities with custom pathfindergoals without nms_

#

like pets

eternal oxide
#

no

#

Goals requires nms

tardy delta
#

just google

eternal oxide
#

which ide?

tardy delta
#

dont say eclipse

eternal oxide
trim creek
jaunty crag
#

how can i initialize a Team without applying it to a scoreboard?

tardy delta
#

๐ŸŒ

trim creek
tardy delta
#

im very angry now

trim creek
#

Vรรรรรรรรรรรรรรรรรรร

#

๐Ÿ˜ญ

echo basalt
eternal oxide
#

I love Eclipse. they even improved module handling so I'm a happy camper

trim creek
echo basalt
#

UniversityPlugin, ZombiesPlugin etc

manic furnace
#

Ok now my head goes completely nuts
Why use all version below 1.17 import net.minecraft.server.v<VERSION>.EntityPig for example
and all above import net.minecraft.world.entity.animal.EntityPig

tardy delta
#

assuming gender hmm

manic furnace
echo basalt
#

Yeh

tardy delta
#

hmm might use reflections to map pojos to db tables but i saw what happened with gson

manic furnace
#

Im beginning to understand why almost everybody hates nms for multiple version compatibility

eternal oxide
#

modules makes it simple

jaunty crag
#

do i need to have a scoreboard to make a team

echo basalt
tardy delta
#

ah lol

tardy delta
eternal oxide
#

pff

#

sheep

tardy delta
#

netbeans

echo basalt
#

ms-paint-ide

eternal oxide
#

real men use Eclipse

tardy delta
#

legends use notepad

#

ig im not a legend

molten hearth
#

legends use nano because vim is for nerds

lost matrix
tardy delta
#

code seems to become like rust

warm light
#

Is it possible to rename a inv?

lost matrix
molten hearth
#

is it bad practice to have a hashmap in a hashmap

lost matrix
glossy venture
#

unless it has to be performant

molten hearth
#

so I should just make a class with a getter to the hashmap?

glossy venture
#

nah if you only need the hashmap just put a hashmap

#

dont make another clas

lost matrix
glossy venture
#

s

glossy venture
#

to wrap it

molten hearth
#

I have an enum called SkillType which has stuff like SkillType.WOODCUTTING, SkillType.FISHING and I need it to map to a value for a level, so eg <SkillType.FISHING, 5> and I need to map this collection of values to the player UUID

#

so I have HashMap<UUID, HashMap<SkillType, Integer>> not sure if I could do it a different way

glossy venture
#

for that make a centralized player data class

#

for if you want to add more stats

lost matrix
#

ill explain it

glossy venture
# lost matrix ill explain it

i think i know what youre going to say
"you can expand it, and its a principle for manageable code" but if you only need the hash map and no other shit theres no point in making another class, it will basically just be a wrapper

tardy delta
#

oh wait

glossy venture
tardy delta
#

what i have is

glossy venture
#

maybe even a player data class

tardy delta
#

was he talking about keeping track of progress or computing the xp needed to level up a skill?

#

lol

glossy venture
#

how to store skill levels per player

#

in a hash map

lost matrix
glossy venture
#

i dont care about principles as long as it saves me coding time and execution time

#

unless you need more data

#

just use the structure

lost matrix
glossy venture
#

instead of a wrapper doing the same thing

molten hearth
#

uh and why would I do that instead of directly just having it in one line?

fresh timber
#

what is the range of ports I can use for my mc servers, or is there none?

lost matrix
glossy venture
lost matrix
glossy venture
#

so imo it wouldnt be worth it

lost matrix
# glossy venture well if youre certain you just need that data writing a wrapper class definitely...

Not in the long run. Imagine if he later wants entities to also have skills. Then instead of just adding another Map<UUID, SkillHolder> you
need to basically copy paste the entire class and make sure the functionality doesnt contain anything player specific.
Its all about modularity. Making something "work quickly" will create huge problems if you want to modify or expand
the code at any point. There is no excuse to ever ignore those principles. Otherwise you are not writing an application
but a simple script in which case you are better off using Python or something similar.

echo basalt
#

I learned to never nest maps because I ended up having to change the data structure and it took me like 2 hours to replace all of it

lost matrix
#

Its always worth it. "The only way to go fast is to go well." - Bob Martin
This is crucial in software development

echo basalt
#

7smile7 what's your stance on extending collections for the sake of utility ๐Ÿ‘€

lost matrix
echo basalt
#

hm

#

๐Ÿค”

lost matrix
#

The responsibility to manage the data lays with the enclosing class

lost matrix
lost matrix
# echo basalt ๐Ÿค”

This looks like you abused a LinkedList to achieve a Composite pattern now that i look at it closer

echo basalt
#

you make it seem like I'm going to jail for class abuse

#

but sure I was thinking on using an internal list or something

#

I do need a node chain structure regardless, would make more sense than an arraylist

#

a tree not so much as I have no "go forward" button

lost matrix
wary topaz
sterile token
#

Nested switch

lost matrix
wary topaz
#

I dont see what you mean.

lost matrix
#

Also:

                if (sender instanceof Player player) {
                    Player target = Bukkit.getPlayer(player);
                } else {

This makes no sense whatsoever. Here sender and target will always be the same person

wary topaz
#

it checks if the args are 0 first though.

lost matrix
wary topaz
#

So what can I do?

lost matrix
#

Learn the basics of java i guess?

#

You need to define "target" in a higher scope

#

Your target variable is defined and then deleted right away without seeing any usage currently

wary topaz
#

Alr I fixed it

golden turret
#

Guys

#

I am having a problem with my collision here

#

basically clone the repository and run it yourself

#

open the index.html

lost matrix
#

Delete that post pls

golden turret
#

and click anywhere in the screen to add circles

golden turret
lost matrix
#

There are too many "can you try out my application" scams

golden turret
#

a

#

fair

#

then

#

just look at the code

lost matrix
#

Already on it

golden turret
#

basically

#

when I add some circles

#

everythign works fine

#

they collide and do the physics

#

but when I add a lot of circles

quaint mantle
#

hi how can i make my vault economy math expression to look like this 2k instead of 2000 and also how can i capitalize letters on placeholders?

golden turret
#

the heaviest of them starts to teleport

brazen hollow
#

What maven command do I use to build my plugin?

golden turret
#

let me record to show it

lost matrix
#

"Object" is a pretty questionable name. Use Body or RigidBody for physics based objects

golden turret
#

alright

#

uploading video

lost matrix
wary topaz
#

if (target = Player) {
target.sendMessage("ยงeยงlYour gamemode has been set to ยงaยงl" + gamemode);
return true;
}


Expression expected

wary topaz
#

Dang forgot thanks

lost matrix
#

Also this makes no sense

#

so probably instanceof

wary topaz
#

No, i set target to player earlier so its fine

brazen hollow
#

๐Ÿค”

lost matrix
#

What exactly should not happen?

#

Ah i see

golden turret
#

the bigger ball starting to teleport

#

when I add multiple balls

#

the bigger ball has a mass of 50000000000

#

and the others balls has a mass of 1

lost matrix
#

Is there a reason why you only calculate the gravitational force for the heaviest object?

golden turret
#

when I remove this the physics simply stops to work

#

and also, I dont know how to use it for all objects

lost matrix
#

Every object with mass in a space has gravitational force. So even your desk is currently pulling your toilet to itself and vice versa.
For a correct n-body simulation you need to calculate the force of each object towards each other object.

golden turret
#

that is what happens when I apply the gravitational force for all objects

#

basically, the physics works only for the first added ball

#

and stops working on all balls if I add more

#

no errors on console

lost matrix
#

Why is gravitationalForce not a vector?

warm token
#

Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaLeatherArmor cannot be cast to class org.bukkit.entity.Damageable (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaLeatherArmor and org.bukkit.entity.Damageable are in unnamed module of loader 'app')

lost matrix
#

there are two

warm token
#

dsaodkadosdjids

lost matrix
#

acceleration += force.divide.. should do the trick actually

golden turret
lost matrix
golden turret
#

and then here I transform it to a vector

lost matrix
#

Anyways you only apply the last acceleration instead of the resulting overlayed acceleration

golden turret
#

hm

#

and how can i fix it

golden turret
#

so it should look like this, right?

lost matrix
#

Or you create a force vector, overlay all forces and only set the acceleration at the end

#

I would rather go with the technically correct way of creating a final force vector which
is the result of adding all force vectors and then setting the acceleration once

sterile token
sterile token
#

Weird

golden turret
#

yes

lost matrix
# golden turret like I just sent?

This would get out of hand very quickly. So no.
Create one vector before the loop and add all force vectors on it.
Afterwards you set the acceleration to finalForce / mass

golden turret
#

just for a base, I stole the code from here https://github.com/JVictorDias/CanhaoDeNewton/blob/main/src/main.cpp, which is described here https://www.youtube.com/watch?v=evcnQajrR6E
it is in portuguese btw

โœ… - Aprenda programaรงรฃo na Alura, estudando com 10% de desconto em: www.alura.com.br/promocao/universoprogramado

Olรก!! Seja muito bem vindo(a) ao Universo Programado!

Neste vรญdeo vocรช verรก como simular a gravidade em um computador e com ela reproduzir o experimento do Canhรฃo de Newton! Neste vรญdeo abordaremos conceitos fรญsicos como posiรงรฃo, ...

โ–ถ Play video
warm light
#

I have a custom inv. and I want to get that inv in InventoryCloseEvent so if I check it like this,

if e.getInventory().equals(MyCustomInv){
...
}

will it check if the event inventory is exactly my custom inv or it will check the inv type/ inv name or something else?

sterile token
lost matrix
#

Use a Set<Inventory>. When you open the custom inv -> add it to the Set. When its being closed -> remove it from the Set.
Then on click and close you can simply check if the Set contains the inv.

lost matrix
sterile token
#

That could help you

quiet ice
sterile token
#

hahaha i mean i dont copied that from yours

#

I used to use that before i ask you for help

#

Where is the thread

#

I cannot find it

lost matrix
lost matrix
#

Yes

sterile token
#

Because inventory doesnt keep the player uuid

#

๐Ÿง

lost matrix
#

But the event does

civic wind
golden turret
lost matrix
sterile token
#

Wizard

#

Dont tell u use vscode for java

#

I will kill u

lost matrix
golden turret
lost matrix
#

This makes more sense

lost matrix
sterile token
#

Where is the thread :D

#

I need to looks your code

golden turret
sterile token
#

I need the thread where you sent the code

#

I mean i never left the thread

#

weird

#

fucked discord

quiet ice
lost matrix
quiet ice
sterile token
#

why null?

#

I mean why holder is set to null?

#

What should be holder so

#

I never understand why its there if no oe use it

quiet ice
#

It's just there for the sake of being there

sterile token
quiet ice
#

InventoryHolder is a hack

golden turret
sterile token
#

Im still thinking how to track custom inventories during event when i have a map<String, Menu>

#

name

#

No no

#

Unique name

#

Let find a example from Ilussion impl

#

but that string is no the menu name

#

๐Ÿง

golden turret
sterile token
#

why discord doesnt display the nfucked picture

#

Fucked discord

#

๐Ÿ˜ก

#

what

#

are u trolling

#

Im being serious bruh

#

I dont have coding problems

#

I have LOGIC problems that is not the same as CODING

#

Indeed

#

you talk really closed enlighs

golden turret
# lost matrix looks better

Problem here. I was testing with only 2 types of circles: 1 with 50000000 of mass and another with 1 of mass. I added one more type with 10 of mass and its speed is very slow now

sterile token
#

Also take care that is not my code

#

I know he has a Map<String, Menu> that is simple

#

Lmao intellij is weird

#

displaying errors when everything is correct

#

๐Ÿ˜‚

#

Its a library

glad prawn
#

your import does not have ;

sterile token
#

If i create a new instance every time the menus will always be null

sterile token
#

NewInstanceMenuHandler == HavingMenusEmpty

#

How would i relationate the menus with player

#

static is cringe

#

it also makes you more unprofesional

#

Arent nested map really bad?

#

I dont think so

#

I dont know wy you are trolling me

#

If im being serious

#

I will make a chain obj for that

#

Doesnt this coding skills look great

#

Yeah

fluid river
#

good evening comrades

#

where are newbies

#

show me please

sterile token
#

Hey sotp it

fluid river
#

hehe i know

sterile token
#

I dont wanna blame u

#

Because i will get banned

#

Conclure just have given 1 oportunity more next one im banned

#

He is really kind

fluid river
#

what happended

#

so you got nearly banned

echo basalt
fluid river
#

imlllusion unblock me

echo basalt
quaint mantle
#

hi how can i make my vault economy math expression to look like this 2k instead of 2000 and also how can i capitalize letters on placeholders?

fluid river
#

string.toUpperCase()

string.replace()

#

hi geol

quiet ice
#

Alternatively you'd have to make the SI unit conversion yourself

quiet ice
fluid river
#

he probably uses PAPI vault placeholders i guess

pastel relic
#

don't know where to post this but why are my images not showing up?

fluid river
#

so he would need to manually work with string

pastel relic
#

yes.

fluid river
#

then just a website bug

pastel relic
#

I tested the images and they work on other websites.

fluid river
#

spigotmc loves to erase my pictures

#

Sometimes

#

wait day or two

quaint mantle
fluid river
#

they gonna reappear

#

send the link btw

pastel relic
fluid river
#

it's just a spigotmc thing

quiet ice
#

You shouldn't use any text within images anyways