#help-development

1 messages Β· Page 1468 of 1

vale cradle
#

No, create your own connection pool is pretty hard, I just have all what I need to do those dirty job async and not bother my main thread

wet breach
#

creating your own connection pool isn't hard at all, what is hard is keeping it optimal and not over bloated or keeping the speed up whatever your requirements are πŸ˜‰

vale cradle
#

^^

vestal dome
#

I have this code...

#

and get this?

#

I'm not in the server btw

vale cradle
#

Is better use a library for that

#

For doing async tasks, executors and all those stuffs, is not so hard

#

And performance is not affected at all if you know what you're doing

#

No need a library for that

wet breach
#

the server will keep the spawn that is set loaded @vestal dome not sure if its possible to have a world loaded without atleast having a single chunk loaded lol

vestal dome
#

Hey good point.

vale cradle
#

Sadly mc can't be made totally async because is not totally thread safe

twilit rivet
#

how does one check if (args.length == 0) {}, as everytime I try it says "this statement is always false"

wet breach
#

@vale cradle no game is completely async anyways. At some point even with async you need to synchronize somewhere at some point πŸ˜‰

vale cradle
#

I mean, comparing to web world xD

#

Async libraries in those cases are godlike

#

In minecraft, having a good simple implementation should be enough

wet breach
#

well web world stuff is different

ripe marlin
#

I ended up getting it a week ago thanks for recommending it is so helpful

#

It would’ve taken me like a month to get on my feet the way the course taught me

wraith rapids
#

@vestal dome use the async chunk api

#

and don't use the console sender for logging

#

use your plugin's logger

#

if you want to do stuff with chunks that are normally unloaded, add a plugin ticket to keep them loaded

#

instead of repeatedly loading and then unloading them

vale cradle
vestal dome
#

This is me just testing.

#

there's NO POINT.

#

further more, What the hell do you mean by "async chunk api"?

wraith rapids
#

well if you ever do it for realsies, do it properly

sharp badge
#

How would I go about creating a constructor without creating a new instance of that class?

vestal dome
#

That is not gonna be in a public version

#

that IS LITERALLY

#

FOR TESTING PURPOSES

#

u kidding?

#

are you really gonna argue over such stupid reason?

wraith rapids
#

well again, if you ever do it for realsies, do it properly

proper notch
vestal dome
#

how to get someone pissed.

#

NOW answer me,ok thx bay

wraith rapids
#

i don't think you're understanding what i'm saying

vestal dome
#

lmfao

#

I ask what is async chunk api.

wraith rapids
#

google it or whatever

vestal dome
#

is this a joke?=

wraith rapids
#

you are overreacting

vestal dome
#

no u

sharp badge
# proper notch wdym? what are you actually trying to achieve?

My apologies if it's a bit vague, I have a class called InterestTask which has a decrementing time variable that decrements once per second using a bukkit runnable. I am trying to access this class from my main so I can update a config value on server disable. However, from my tests, the only way I can get this to work is from the following code:

InterestTask interestTask = new InterestTask(this);

But I would like to be able to access this without creating a new instance of the class

wraith rapids
#

basically, if you ever do this not as a "test" but rather for real, you should do it properly

#

i'm giving you advice on how to do it properly

vestal dome
#

It is not done for any good reason

#

it is for testing purposes.

wraith rapids
#

i'm not telling you to do it right this instant

vestal dome
#

AS i said.

wraith rapids
#

i'm telling you that if you do it for real at some point, you should do it properly

proper notch
vestal dome
#

alright, I'll accept, thank you, now explain it

wraith rapids
#

async chunk api was added by paper and lets you load chunks asynchronously

vestal dome
#

not using paper btw

wraith rapids
#

you posted a paper timings report earlier

vestal dome
#

someone who was reporting the bug to me..

#

don't assume it.

#

move on

wraith rapids
#

so the people who use your plugin are using paper

#

shade in paperlib and they'll be 300% more satisfied

vestal dome
wraith rapids
#

you'll still retain spigot compatibility and you don't need to make large changes to your code

vestal dome
#

not ok with your answer tho

#

what is the point?

wraith rapids
#

what answer are you even talking about

sharp badge
vestal dome
#

I'm just CHECKING if the chunk is "loaded".......

#

how can it be that hard?

#

I said the problem is that it is not correct.

#

I'm not even close to this chunk

wraith rapids
#

why are you being so fucking touchy about this

vestal dome
#

I'm done

#

fuck that

wraith rapids
#

do you not engrish well?

#

communicating with you is a pain

proper notch
sharp badge
vestal dome
#

I'M SORRY WHAT?

vestal dome
#

My question is why the hell is the chunk LOADED when I'm not even close to it

proper notch
#

You need to storage that instance as a variable in your class so you can reference it later

vestal dome
#

simple right?

wraith rapids
#

anyway, isLoaded is isLoaded

#

it doesn't lie

#

if it returns true, it's loaded

#

the reason could be anything really

#

a nether portal, spawn chunks, a plugin ticket...

vestal dome
#

I restarted the server and it's still loaded.

sharp badge
proper notch
wraith rapids
#

each instance of a class has its own fields

#

if you create a new instance, then the value will obviously "reset"

proper notch
#

Create a variable in your class, on enable set that variable to what you want.

wraith rapids
#

as you just created a new instance

#

and that instance's fields now hold the default values

proper notch
#

On disable, use that variable you assigned the instance to.

vestal dome
#

right there..

#

restarted the server.

#

and it's loaded?

wraith rapids
#

yes, well, like i said

#

it could be any number of things

vestal dome
#

it is NOT a spawn chunk

#

and I'm not even close to the chunk in the first place.

#

not even gonna join the server.

wraith rapids
#

dunno, not really your problem though is it

vestal dome
#

another time...

#

Didn't join the server, says it's loaded....

vestal dome
#

hf

vale cradle
#

Isn't it a Spawn Chunk?

wraith rapids
#

probably a spawn chunk

vale cradle
#

ya

wraith rapids
#

i know you're saying it's not a spawn chunk

#

but it's still probably a spawn chunk

vale cradle
#

But

pliant copper
#

what’s the protocollib packet type for actionbar

vestal dome
#

I used /setworldspawn

vale cradle
#

There is not the coordinates of the chunk

vestal dome
#

on a complete opposite side..

wraith rapids
#

chat

vale cradle
#

I guess the spawn chunks still the same

pliant copper
vestal dome
#

fine I'll go to 1M, 1M

vale cradle
#

That's not the point

wraith rapids
#

you might also be calling something like getBlock or whatever on the chunk and that loads it, idk

vestal dome
#

Then what is the point?

wraith rapids
#

listen to chunk load events if you want to make sure

vale cradle
#

Always, chunks need to be loaded

#

In a default world

vestal dome
wraith rapids
#

anything that accesses the world in any way will load the related chunk, f.e Block::getType

#

make sure you're not calling anything like that before testing if it's loaded

vale cradle
#

those are the spawn chunks, and if I remember correctly (don't trust me so much), the spawn chunks are the same even if you change the spawn point

vestal dome
#

Unless using new Location() loads the chunkj

#

which is stupid af, let me tell ya

sage swift
#

can you tell me

vale cradle
#

Other plugins?

vestal dome
#

no other plugin....

vale cradle
#

Check entities inside the loaded plugin

vestal dome
#

would this load a chunk tho?

sharp badge
vale cradle
#

maybe there is an entity that prevents the chunk to be unloaded

vestal dome
#

the world has no entities...

#

I would say..

#

and even if there is

#

they don't have anything that prevents them from despawning.

wraith rapids
#

listen to chunk load events and check when it gets loaded

proper notch
wraith rapids
#

if the event doesn't fire, it's a spawn chunk

vestal dome
#

good time to use my api

#

anddddddddddddddd

#

right on the spot

#

but how the f

wraith rapids
#

now, print a stack trace

vale cradle
vestal dome
#

well gonna mod api 1s

wraith rapids
#

if this was paper and you were an end user, you would be instructed to enable sync load monitoring and check the related logfile

#

it records the stack traces of all sync chunk load requests

#

the issue is then fixed either by removing the plugin or finding an alternative that doesn't cause sync chunk loads

vestal dome
#

yup....

#

it's with the removal of the machine if air

#

nice πŸ™‚

wraith rapids
#

aside from entities, it's usually the first thing that is checked in a timings report

#

yeah, Block::getType loads the chunk

#

ignore the machine entirely if the chunk is unloaded

vestal dome
#

Change my mind πŸ™‚

#

lmfao

wraith rapids
#

basically this is going to be loading every chunk every tick or however often this runs that has a machine in it

#

which is why your paper friend was seeing this using fucking +200% tick time

vale cradle
#

And if you want to work with worlds and stuff, I'd recommend you to use paper

#

I think you won't like to load unloaded chunks just for everything

wraith rapids
#

spigot doesn't even delay chunk unloads like paper does I don't think, so the chunk will literally unload the same tick just to get loaded again the next tick

#

omega 🀑

wet breach
#

there is a chunk cache. Chunks don't unload immediately in the event they are needed again

wraith rapids
#

they're not flushed to disk no, but it still takes time to load and unload them

wet breach
#

if the chunk isn't re-loaded in a given time frame it will unload completely

vale cradle
#

ChunkSnapshot?

shrewd furnace
#

im working on a plugin atm and im not having any errors but im getting a warning message... the plugin compiles and exports correctly with no errors but when I run it on my server nothing happens ;( Do you know how I can correct the "warning" message: Class 'Main' is never used

wet breach
#

I am assuming the warning comes from the compiler?

shrewd furnace
#

yup

#

god this is going to be the easiest fix and im going to look super dumb lol

#

idk why its giving me that warning though

wet breach
#

first, you shouldn't name any of your classes main

#

second, the compiler isn't wrong

shrewd furnace
#

aha

#

lol okay

wet breach
#

odds are you didn't extend JavaPlugin

#

?paste

queen dragonBOT
shrewd furnace
#

public class main extends.....

wet breach
#

show us some code so we can see what you are doing wrong

wraith rapids
#

the warning is fine

wet breach
#

not here

shrewd furnace
#

oh

wet breach
#

at the link provided

wraith rapids
#

the IDE just doesn't know that the bukkit server is going to reflectively go and grab your main class and instantiate it

#

so it doesn't see any uses for it

#

and as such warns you for an unused class

#

get the mcdev plugin for intellij or whatever to get rid of the warning

shrewd furnace
wraith rapids
#

or just ignore the warning

#

lots of warnings end up just getting ignored

shrewd furnace
#

its a super simple plugin to enable a texturepack with a command and i had it working before although after making some very small changes and recompiling its just not even getting "executed?" by the server

wraith rapids
#

does the server say something about it when you try to load it in

#

paste logs or something

shrewd furnace
#

I should probably look at the pog

#

*LOG

wraith rapids
#

that's the first thing to do yes

twilit rivet
#

Anyone have an idea why this isn't being liked

wraith rapids
#

target might be null

sage swift
#

there is a case where it's null? lol

wet breach
#

@sage swift its more of a case that it could be null

sage swift
#

command block executes command

#

boom

#

server expload!

wet breach
#

@twilit rivet you should check that target isn't null. The only way it isn't null, is if the check where you set it, gets ran, but if it doesn't run, target will be null

shrewd furnace
#

OOOH

#

this looks promising

wraith rapids
#

don't check for instanceof consolesender

#

check for !(instanceof player)

shrewd furnace
wraith rapids
#

there are a myriad of different command senders

wet breach
#

@wraith rapids they do

wraith rapids
#

Cannot find main class `me.freddie.badplugin.BadPlugin'

shrewd furnace
#

lol

wet breach
#

they just check at the beginning if its the console and state command doesn't work from the console

#

look further down and they check if its a player

wraith rapids
#

yes, but they should not be checking for a console command sender

#

they should be checking for a not player command sender

wet breach
#

they should if they don't want to allow the console to run the command

wraith rapids
#

they only want a player to use the command

#

they don't have any special case for a Creeper executing the command

sage swift
#

one day

wet breach
#

lol

wraith rapids
#

the if else is pretty spaghetti anyway

#

all commandsenders are permissible, so you should first get the hasPermission check out of the way

#

you shouldn't hardcode the op check either, as the end user may not want an op to have this permission

#

instead, you should declare the permission with a permission default of OP

shrewd furnace
#

ack wtf... how do i "use" a class?

wraith rapids
#

why are you asking that

#

are you trying to solve the main class not found issue

#

because that has nothing to do with using a class

shrewd furnace
#

yes?

wraith rapids
#

what is your main class called

shrewd furnace
#

thats the error its sending

shrewd furnace
wraith rapids
#

what is the package called that your main class is in

shrewd furnace
#

OMG

wraith rapids
#

now what do you have written in your plugin.yml for main

shrewd furnace
#

NOooooOooo πŸ˜‚ 😭

wet breach
#

you named your main class as main, but you put in the plugin.yml that your main class is me.freddie.badplugin.BadPlugin

wraith rapids
#

the main property in plugin.yml must be the path to your main class

shrewd furnace
#

it should be main.freddie.....

wraith rapids
#

if your main class is called Main, and is in package com.mydomain.myplugin, then main should be "com.mydomain.myplugin.Main"

wet breach
#

but you put me.freddie.badplugin.BadPlugin in the plugin.yml that is where the server picks up to find your main class

vale cradle
#

If you want to, just suppress the warning

#

@SupressWarning("unused")

shrewd furnace
wraith rapids
#

if that is where your main class is in, yes

shrewd furnace
#

oh

#

i see

#

very cool NNYaKNpGms0eUVpiSdHx, thank you very much

wraith rapids
#

that little bit of text is how the server finds your main class

vale cradle
shrewd furnace
#

right...

wet breach
#

only if you are on linux which most people have their servers running on linux @vale cradle

wraith rapids
#

i AM LINUX

shrewd furnace
#

linux cringe ngl

vale cradle
vale cradle
wet breach
#

linux is far better then windows

vale cradle
#

You're not prepared enough, sorry

wraith rapids
#

obligatory templeos reference

wet breach
#

lol

quaint mantle
#

🀚 😏 😏 βœ‹

#

😏 🀝 😏

granite stirrup
#

um im getting errors

sage swift
#

good

granite stirrup
#

lol

#
java.lang.RuntimeException: Unable to access address of buffer
        at io.netty.channel.epoll.Native.read(Native Method) ~[server.jar:git-Spigot-db6de12-18fbb24]
        at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.doReadBytes(EpollSocketChannel.java:678) [server.jar:git-Spigot-db6de12-18fbb24]
        at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.epollInReady(EpollSocketChannel.java:714) [server.jar:git-Spigot-db6de12-18fbb24]
        at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe$3.run(EpollSocketChannel.java:755) [server.jar:git-Spigot-db6de12-18fbb24]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) [server.jar:git-Spigot-db6de12-18fbb24]
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:268) [server.jar:git-Spigot-db6de12-18fbb24]
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [server.jar:git-Spigot-db6de12-18fbb24]
        at java.base/java.lang.Thread.run(Thread.java:834) [?:?]``` it prints this like 1000 times and then crashes
#

and idk what it means ;-;

#

its probs to due that its 1.8.8 but most of the plugins on here dont support above 1.10 and i dont want to go updating every single one that is 1.10+

sullen marlin
#

1.8 doesnt support whatever java version you are using

granite stirrup
sullen marlin
#

because spoiler alert, that java version didn't exist 6 years ago when 1.8 was released

wet breach
#

are you using viaversion? @granite stirrup

granite stirrup
wet breach
#

It is either going to be that or something involved with that, or what md_5 said

granite stirrup
#

i think its cuz were running on java 11 but idk if we can change that

wet breach
#

I have never experienced that problem and I use java 14 currently, haven't upgraded to 16 yet

granite stirrup
#

its a 1.8.8 server lmao

wet breach
#

but I also don't use spigot 1.8

#

So, that could be your issue as well

granite stirrup
#

well i cant upgrade since most the plugins dont support 1.10+

#

and i dont want to go through all the plugins

#

to update them

wet breach
#

that isn't our problem πŸ™‚

#

you are free to use outdated software, but you are going to have to live with whatever problems that brings with it or deal with it anyways πŸ˜‰

granite stirrup
#

yeah but its not a choice to upgrade if i dont have plugins that support 1.12.2 or 1.16.5

wet breach
#

it is your choice

sage swift
#

your solution is pretty clear, is it not?

wet breach
#

you just simply don't want to put the work in required to maintain updated stuff

#

in either case what Gecko said

granite stirrup
sage swift
#

use a compatible java version like md_5 said

granite stirrup
#

i dont know if u can change the java version on the host

wet breach
#

sounds like you need a better hosting provider

granite stirrup
#

anyway i cant check since i dont own the server i only have access to files and stuff

wet breach
#

Well you got the answers to your problem. Just because you don't like the answers doesn't mean they are not the solutions. What you choose to do or how you go about it is up to you lol

granite stirrup
wet breach
#

seems like you are going to have fun then. πŸ˜‰

sullen marlin
#

you can try disabling native transport in server.properties, but really you need to downgrade your java version as I'm not sure what other issues there may be

vestal dome
#

So I want to place a wall depending on where the player is looking at ...

#

is there a simple way to make this?

sullen marlin
#

Player.getTargetBlock

#

and then just make a wall

vestal dome
#

uhhh

granite stirrup
#

i disabled native transport and now its not crashing or displaying that error 1000 times

vestal dome
#

is it really this simple...

#

sus

#

but what if I have to put some type of data int he blocks?

#

then how do I do it?

#

for example, wool color

#

because of 1.12 or 1.8

young knoll
#

Ew

#

Use MaterialData? I think it was

late cliff
#

When I run the command, I get this in the console:

Caused by: com.comphenix.protocol.reflect.FieldAccessException: No field with type net.minecraft.server.v1_16_R3.ItemStack exists in class PacketPlayOutEntityEquipment.
    at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:365) ~[?:?]
    at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:345) ~[?:?]
    at testplugin.TestPlugin.sendPacket(TestPlugin.java:44) ~[?:?]
    at testplugin.TestPlugin.onCommand(TestPlugin.java:27) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot.jar:3084-Spigot-9fb885e-afa0678]
    ... 19 more
#

What is going on here? this is kind of wack yo

#

More importantly: How do you interpret that wiki entry?

sullen marlin
#

go look at the protocollib packet wrappers

late cliff
#

???

sullen marlin
#

ya

drowsy helm
#

some wiki vg packets arent updated with 1.16 stuff, i just decompile and check the constructor

late cliff
#

How do I get that on the classpath? is it a jar I download?

#

wait

#

Yeah, because I can't access WrapperPlayServerEntityEquipment in eclipse

#

nevermind I just had to read for 20 seconds:
You can use PacketWrapper as a dependency if you wish, although it is highly recommended that plugin authors simply copy and paste the classes they need into their project. T

#

alright thank you sir

#

WOW this repo is fucking cash

#

good deal

late cliff
#

wtf

#
Caused by: com.comphenix.protocol.reflect.FieldAccessException: No field with type net.minecraft.server.v1_16_R3.ItemStack exists in class PacketPlayOutEntityEquipment.
    at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:365) ~[?:?]
    at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:345) ~[?:?]
    at testplugin.WrapperPlayServerEntityEquipment.setItem(WrapperPlayServerEntityEquipment.java:90) ~[?:?]
    at testplugin.TestPlugin.sendPacket(TestPlugin.java:46) ~[?:?]
    at testplugin.TestPlugin.onCommand(TestPlugin.java:27) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot.jar:3084-Spigot-9fb885e-afa0678]
    ... 19 more
sullen marlin
#

hmm idk then

#

is your protocollib up to date

late cliff
#

yes

#

it is

sullen marlin
#

try asking them I guess

late cliff
#

fack

sullen marlin
#

in 1.16 the actual type is a List<Pair<EnumItemSlot, ItemStack>>

#

idk if there's a way to get that in protocollib

quartz anchor
#

is there is a way to convert textcomponent to json string?

late dove
#

How do I get the book enchantment? From objects I can get it, but from books I can’t do it!

sullen marlin
#

ComponentSerializer

#

and look at the meta

warm galleon
#

EntityEnderCrystal enderCrystal = new EntityEnderCrystal(((CraftWorld) loc.getWorld()).getHandle());

        enderCrystal.setPosition(loc.getX(), loc.getY(), loc.getZ());

but i dont see anything

#
@EventHandler
    public void onSnowballThrow(ProjectileHitEvent e){
        if (e.getEntity() instanceof Snowball) {
            Snowball projectile = (Snowball) e.getEntity();
            Location loc = e.getEntity().getLocation();
            EntityEnderCrystal enderCrystal = new EntityEnderCrystal(((CraftWorld) loc.getWorld()).getHandle());

            enderCrystal.setPosition(loc.getX(), loc.getY(), loc.getZ());
            if (projectile.getShooter() instanceof Player) {
                Player player = (Player) projectile.getShooter();
                player.sendMessage(ChatColor.GOLD + "You spawned in an " + ChatColor.DARK_PURPLE + "End Crystal" + ChatColor.GOLD + "!");
            }
        }
    }```
#

java code ^

sullen marlin
#

why are you using nms for this

warm galleon
#

end crystals are still entities

warm galleon
#

1.9 they made it an item

sullen marlin
#

spawnEntity has existed for a hell of a long time before 1.8.9

warm galleon
#

damn

sullen marlin
#

like did you honestly think spigot had no api to spawn an entity

warm galleon
#

like titles, bossbars, actionbars, etc

sullen marlin
#

you've been able to spawn an entity since probably beta 1.2

quartz anchor
#

there is bossbars api i think

sullen marlin
#

like seriously bro

warm galleon
sullen marlin
#

bossbars didnt exist till 1.9

#

and guess what, there was a bossbar api added in 1.9

warm galleon
#

for end cristal

sullen marlin
warm galleon
#

ahh

#

ender crystal

#

ive been trying end crystal

late cliff
warm galleon
#

ayyy thanks now i have a endercrystal-shooting snowball for my crystalpvp server lmao

sullen marlin
#

@late cliff the packet would be PacketPlayOutEntityEquipment that you have to send

late cliff
#

Yeah, I sent that

#

in some other code

#

let me try again

warm galleon
sullen marlin
#

no idea

late cliff
sullen marlin
#

the entity id

late cliff
#

got it

wet breach
#

do you use worldguard @warm galleon ?

#

if so, there is some settings in there relating to explosions

late cliff
#
void sendPacket(Player holder, Player observer) {
        ItemStack testItem = new ItemStack(Material.DIAMOND_CHESTPLATE);

        List<Pair<EnumItemSlot, net.minecraft.server.v1_16_R3.ItemStack>> pairs =
                Arrays.asList(new Pair<>(EnumItemSlot.CHEST, CraftItemStack.asNMSCopy(testItem)));
        
        PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(holder.getEntityId(), pairs);
        
        CraftPlayer craftHolder = (CraftPlayer) holder;
        
        craftHolder.getHandle().playerConnection.sendPacket(packet);
    }

>here we go
here we go
>here we go
here we go

warm galleon
late cliff
#

it didnt work πŸ˜”

#

WAIT WTF

#

IT WORKED

warm galleon
#

lol

wet breach
#

probably had to wait for an update packet of some sort

late cliff
#

interesting

wet breach
#

there is multiple packets relating to entities

late cliff
#

fun fact: In creative mode, if you click on the chestplate while it is in your chest slot, it becomes an item

#

Obviously not in survival mode though

young knoll
#

We don’t talk about creative mode

late cliff
#

If I specify api-version to be 1.16, will it stop using LEGACY_* materials?

#

I think its fucking it up

quaint mantle
#

yea

late cliff
#

alright that worked

#

Now I need to figure out these "update packets"

#

I am basically trying to make color cycling armor

#

Would that be too packet-intensive?

young knoll
#

Probably not

late cliff
late dove
#

What's the best way to store item enchantments in the database?

young knoll
#

Considering doing it fully server side sends the packets anyway

wet breach
late cliff
#

I see, thanks

wet breach
#

basically after you send the entity equipment packet, just send that packet. will make the client update the entity faster

late cliff
#

I will send it only if the player isnt moving

#

since that might mess up the smoothness of the movement on the observer's end

wet breach
#

that packet is sent even if the entity doesn't move

small dust
#

i just created two npcs{znpcs plugin} with the skins of wallibear r purpled , today when i logged into the server their skins were showing as steve and even if i am trying to load another npc with another skins they are sometimes loading as stev

late cliff
#

Is there a way to interrupt these packets with NMS? Whenever an enemy hits the player, the armor blips with the actual underlying armor

#

in my case its an iron chestplate disguised as a diamond chestplate

young knoll
#

Protocol lib has packet listeners

late cliff
#

yeah but

#

earlier in chat I have been having trouble with that

young knoll
#

But it may be the client doing it, which you can’t really stop

late cliff
#

I dont think so, these "blips" can be cancelled (I know I can with protocollib in THEORY, but protocollib is being a bitch)

#

I even used the wrapper repo

#

and errors everywhere

#

Up down left right

#

in my pants

#

under my hat

#

they are just everywhere, flooding my console

#

so I am gonna stick with NMS i guess

wet breach
#

why do you want to update the entities equipment with packets instead of just changing the equipment on said entity?

young knoll
#

In modern versions you can modify the armor values of an item, so you can have leather armor be just a strong as diamond

#

If that’s what you want

wet breach
#

you can create your own listener, just need to inject your handler into the network

late cliff
young knoll
#

I guess the problem would be durability, why hasn’t Mojang made that an attribute yet

late cliff
#

I dont want it to interfere with the vanilla grind if you know what im saying

young knoll
#

I have no idea what you are saying

late cliff
#

like

#

the GRIND bro

wet breach
#

@young knoll they don't want to interfere with the normal drops

late cliff
#

its every day bro

#

^

young knoll
#

I mean, you could solve that with a listener

wet breach
#

yep

late cliff
#

wdym

#

like an event listener?

wet breach
#

just keep track of the equipment the entity originally had, then when it dies, instead of dropping your items you used to make it look better

#

just drop the original items

#

or just use the loot table

late cliff
#

HMMMMM

#

I dont know, I feel like there are too many "leaks" that free items could "seep" through

wet breach
#

what you are wanting is completely doable with just the API and no need to go with packets or NMS

young knoll
#

Nobody has made a plugin that turns all armor into dyeable leather

#

I know what I’m doing tomorrow

late cliff
#

But which events should I look out for?

wet breach
#

lol

late cliff
#

I have to catch EVERY event that could possible get the armor piece out

#

idk man, I like the idea but

young knoll
#

From a mob?

late cliff
#

from a player

#

well I know entity death event yes

#

hmmm

#

inventory move item event?

#

that one as well

young knoll
#

InventoryClickEvent

#

Move item is for hoppers

late cliff
#

yeah when they pick it up

#

yeah

#

on their cursor ja

late cliff
#

so IDK, I dont want to miss any events

#

if I do, I have to roll back the world because otherwise it's "vanilla virginity" would have been lost

#

and the worst case scenario is not knowing IF it's precious vanilla virginity has been lost

#

or WHEN

wet breach
#

you don't have to worry about hoppers

late cliff
#

so I wouldnt know how far to roll it back

wet breach
#

as long as you cancel the event for item drops, the hopper won't grab them πŸ˜‰

late cliff
#

basically, I need every event that could possibly remove an item from any EquipmentSlot

#

including hands, because I will have it do custom-shields

#

custom shields, and have diamond/netherite swords look like fancy gold swords

wet breach
#

well, you only have like 3 events to work with. Really only have 1 event where the items drop and that is when the entity dies

late cliff
#

hmmm, for hands, I would have to consider the event where the player scrolls in their hotbar

#

or swaps offhand

wet breach
#

why?

late cliff
#

becuase when they hold their netherite sword, it will become a gold sword aesthetically

#

if they scroll to another slot in their hotbar, it must go back to a netherite sword

#

this is kind of tricky

#

ahhhhh

wet breach
#

so....why not just give them a custom gold sword?

late cliff
#

because

#

vanilla bro

wet breach
#

this way when it gets dropped, you know it should be a netherite one

late cliff
#

hmm

wet breach
#

then you don't have to worry about constantly modifying stuff in player inventories

#

only have to worry about it on item drop instead

late cliff
#

so you mean

#

hmm

wet breach
#

just add custom data to the gold sword is what I am saying, doing so makes it not the same as a normal gold sword

late cliff
#

what if I want a sword to be disguised as a bow? I never mentioned this, but this plugin will allow players to pick any item they want

young knoll
#

So wait

#

You want them to look different when held, but only when held

#

Why

#

How is it less vanilla if they look different all the time

late cliff
#

its a FEELING man

#

I cant describe it, but it doesnt seem right, something is off, like the boogey man is going to rekt my sword and explosion my world

#

ignore that

#

its late, I need to go to bed

young knoll
late cliff
#

nah its okay

#

inventory is fine

#

but, I would have to change attribute modifiers of the sword and what not

#

players base deal 1 attack damage with an attack speed of 4

#

So the EVENTS would be 3 of them?

  • Drop item event
  • shift click into chest/inventory event
  • ???
wet breach
#

itemmetadata exists πŸ˜‰

late cliff
#

yeah persistentdata

#

I will use that

#

I am just trying to figure out which instances an item will leave their inventory

wet breach
#

why do you need to worry about inventory events?

late cliff
#

basically all the times where an item could leave the player's inventory

#

also

#

if the player configures their SWORD to look like a BOW, they could shoot with it

#

hmmmmmmm

#

I will sit on this idea

#

I am going to bed

digital plinth
#

is there a way to disable ppl from getting illegal items in their saved hotbar while in creative mode?

cinder thistle
#

Also imagine being unverified

keen kelp
#

how do I prevent players from taking GUI items out

sage swift
#

event.setCancelled(true)

keen kelp
#

oh that's right lmao me is no brian

quaint mantle
#

How to change this? (I can edit spigot)

eternal oxide
#

photoshop or paint

quaint mantle
#

version 1.9 btw

eternal oxide
#

MainListener.java:140 incorrect inventory size

#

Caused by: java.lang.IllegalArgumentException: Invalid inventory size; expected 36 or less

quaint mantle
#

ik bcz i cant remove the armor and offhand item

#

bcz the fucking 1.9 bug gets even the armor and offhand making it 41 and not 36

eternal oxide
#

um, you are looping over your armorContents and setting the whole contents every time

quaint mantle
#

wait what?

#

im looping only the armorcontents only

eternal oxide
#

oh no use of {}

#

makes more sense

quaint mantle
#

yea

tardy delta
#

bruh plugin wasnt working bcs i forgot a !

eternal oxide
#

You content.getContents().length will always return 41 as empty spaces will be AIR or null

quaint mantle
#

oh so how do i fix that?

eternal oxide
#

you strip null or AIR from teh beginning of the array

quaint mantle
#

strip?

#

thats what?

eternal oxide
#

use substring

quaint mantle
#

like on the?

eternal oxide
#

teh returned array

tardy delta
#

uhh
Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_16_R3.command.ColouredConsoleSender cannot be cast to org.bukkit.entity.Player

final Player p = (Player) sender;

does give me error when trying to execute from console

eternal oxide
#

the array will alwasy be 41 long, so just suibstring and ignore the armor slots

eternal oxide
quaint mantle
#

w8 how can i remove smth from ItemStack[]?

tardy delta
#

and now i cant resolve p

#

wauw

#

there we go again

eternal oxide
eternal night
#
if (!(sender instanceOf Player)) {
  sender.sendMessage(Component.text("This command is only for players!")));
  return true;
}
final Player player = (Player) sender;
#

basically like that

tardy delta
#

oh i initialised the player p just under the onCommand

eternal night
#

Yea you don't wanna do that

late dove
#

How do I get items in the shulker box? To save them later!

eternal night
#

exactly how you'd get the contents of a chest

tardy delta
#

how can i check if the item in mainhand is null?

#

i have this but it says its always false

summer scroll
#

Does someone know why Chest keep being opened If there's no one views the chests?

#

I opened the chest using code.

quaint mantle
tardy delta
#

like this?

#

if (p.getInventory().getItemInMainHand().getType() != Material.AIR) return true;

quaint mantle
#

yea

#

well maybe ==

keen kelp
#

is it impossible to include Item meta in a crafting recipe?

sullen marlin
#

as ingredients for shaped recipes, yes, see RecipeChoice.ExactChoice

sage swift
#

RecipeChoice.E

#

ok

sullen marlin
#

as results for all recipes, yes

#

otherwise, no

keen kelp
#

I know recipe result can have ItemMeta

#

but it's possible for ingredient yes?

sullen marlin
#

yes, for shaped recipes

keen kelp
#

so you mean it's possible for unshaped?

sullen marlin
#

no, its only possible for shaped recipes

keen kelp
#

to have itemMeta?

sullen marlin
#

yes

keen kelp
#

can I have some resources

sullen marlin
#

new ShapedRecipe(...).setIngredient('#', new RecipeChoice.ExactChoice(item))

tardy delta
#

so does someone knows how to cancel when the players isnt holding something in his mainhand?

sullen marlin
#

cancel what?

#

if (p.getInventory().getItemInMainHand() == null) return true;

tardy delta
#

it says that its always true

dusty herald
#

that cannot be true

#

show code bc it soudns like ur fucking something up

tardy delta
#
if (cmd.getName().equalsIgnoreCase("store")) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("the console cannot run this command!");
                return true;
            }
            final Player p = (Player) sender;
                if(args.length > 0) {
                    StringBuilder message = new StringBuilder();
                    for(String arg : args) {
                        message.append(arg + " ");
                    }
                    if (p.getInventory().getItemInMainHand() != null) return true;
                    ItemStack itemStack = p.getInventory().getItemInMainHand();
                    ItemMeta itemMeta = itemStack.getItemMeta();
                    PersistentDataContainer container = itemMeta.getPersistentDataContainer();
                    if(container.has(new NamespacedKey(MagmaBuildNetwork.getPlugin(), "MBN"), PersistentDataType.STRING)) {
                        p.sendMessage(ChatColor.GREEN + "There is already a message stored inside this item!");
                        p.sendMessage(ChatColor.GREEN + "Message: " + ChatColor.GREEN + container.get(new NamespacedKey(MagmaBuildNetwork.getPlugin(), "MBN"), PersistentDataType.STRING));
                    }
                    else {
                        container.set(new NamespacedKey(MagmaBuildNetwork.getPlugin(), "MBN"), PersistentDataType.STRING, message.toString());
                        itemStack.setItemMeta(itemMeta);
                        p.sendMessage(ChatColor.GREEN + "Message stored!");
                    }
                } else {
                    p.sendMessage(ChatColor.RED + "You need to provide a message to store!");
                }
            }
eternal night
#

why do you return true if the item is actually not null

#

xD

tardy delta
#

ow

#

when i change it to == null it says always false

#

here we go again

eternal night
#

if the item in hand is never null you are good

dusty herald
#

wtfa re you doing lmao

eternal night
#

just means that it will return an ItemStack(Material.AIR) when the player holds nothing

dusty herald
#

STATIC

tardy delta
#

so i have to check if the type != Material.AIR?

dusty herald
#

i smell STATIC

#

nah it'll be null

#

can't getType of a null

eternal night
#

I think you wanna check the item meta for null

#

jochyoua fam

dusty herald
#

unless u can then 🀷

eternal night
#

it is annotated with @NotNull

#

it isn't going to be null

dusty herald
#

then how the fuck does it throw an NPE

tardy delta
#

well i just want to check if the player's holding an item

eternal night
#

if the item is AIR the item meta would be null

#

so you'd wanna null check that

dusty herald
#

wtf

eternal night
#

what

wet breach
#

if there is a valid item, itemMeta won't be null. Can't get metadata of something that is null

eternal night
#

it can definitely be null

dusty herald
#

they're checking the ItemStack code πŸ˜‚

#

inspect element

eternal oxide
#

AIR is a valid item but has no ItemMeta

eternal night
#
@Override
    public ItemMeta getItemMeta(Material material) {
        Validate.notNull(material, "Material cannot be null");
        return getItemMeta(material, null);
    }

    private ItemMeta getItemMeta(Material material, CraftMetaItem meta) {
        material = CraftLegacy.fromLegacy(material); // This may be called from legacy item stacks, try to get the right material
        switch (material) {
        case AIR:
            return null;
#

like

dusty herald
#

so would checking if it's not null be useless?

eternal night
#

it can definitely be null

dusty herald
#

like the actual itemstack

eternal night
#

yeah idk where you got your javadocs from

#

but this is latest

drowsy helm
#

theres a method for hasItemMeta

eternal night
#

it is definitely nullable

drowsy helm
#

so yes can be

dusty herald
eternal night
#

oh

#

i guess you are on an old version

dusty herald
#

i

#

inspected the element

#

changed it from nullable to notnull

eternal night
#

oh

dusty herald
#

are you o k

eternal night
#

idk, my brain didn't really think of something as stupid as that

dusty herald
#

welcome to my world

#

tiem to sleep

eternal night
#

probably best

drowsy helm
#

according to 1.18 docs

tardy delta
#

so how can i fix it? :))

eternal night
#

you null check the item meta

wet breach
#

just like you did for checking the item

drowsy helm
#

hasItemMeta

eternal night
#

or that

wet breach
#

either way works

dusty herald
tardy delta
#

if (p.getInventory().getItemInMainHand().hasItemMeta()) return true;

dusty herald
#

uhhhh

eternal night
#

fuck off xD

dusty herald
#

question

#

is flamecord bad

tardy delta
#

oh

eternal night
#

and no fourteen you'd wanna save the item meta as you are using it later

#

so like

#
final ItemStack inHand = player.getInventory().getItemInMainHand();
final ItemMeta inHandMeta = inHand.getItemMeta();
if (inHandMeta == null) {
  // PLayer does not have an item in hand
} else {
  // Player has item
}
drowsy helm
#

assumes that item in hand is not null

eternal night
#

which it never is

tardy delta
#

and to cancel the command its just return true right?

drowsy helm
#

yes

tardy delta
#

i assume this will work

if (cmd.getName().equalsIgnoreCase("store")) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("the console cannot run this command!");
                return true;
            }
            final Player p = (Player) sender;
                if(args.length > 0) {
                    StringBuilder message = new StringBuilder();
                    for(String arg : args) {
                        message.append(arg + " ");
                    }
                    final ItemStack itemStack = p.getInventory().getItemInMainHand();
                    final ItemMeta itemMeta = itemStack.getItemMeta();
                    if (itemMeta == null) {
                        return true;
                    } else {
                        // Player has item
                        PersistentDataContainer container = itemMeta.getPersistentDataContainer();
                        if(container.has(new NamespacedKey(MagmaBuildNetwork.getPlugin(), "MBN"), PersistentDataType.STRING)) {
                            p.sendMessage(ChatColor.GREEN + "There is already a message stored inside this item!");
                            p.sendMessage(ChatColor.GREEN + "Message: " + ChatColor.GREEN + container.get(new NamespacedKey(MagmaBuildNetwork.getPlugin(), "MBN"), PersistentDataType.STRING));
                        }
                        else {
                            container.set(new NamespacedKey(MagmaBuildNetwork.getPlugin(), "MBN"), PersistentDataType.STRING, message.toString());
                            itemStack.setItemMeta(itemMeta);
                            p.sendMessage(ChatColor.GREEN + "Message stored!");
                        }
                    }
                } else {
                    p.sendMessage(ChatColor.RED + "You need to provide a message to store!");
                }
            }
#

lets try

drowsy helm
#

yep

#

could clean it up a bit, try avoid using so many nested if statements

#

just do early returns

tardy delta
#

yea i have some coding spaghetti

sturdy hearth
#

How do I make a config that looks like this:```yml
players:

  • 6334d54b-1b2a-4ab1-813f-c85610b972a7:
    level: 10
    xp: 50
  • 6334d54b-1b2a-4ab1-813f-c85610b972a8:
    level: 5
    xp: 6
summer scroll
sturdy hearth
summer scroll
#

cuz it's a configuration section

sturdy hearth
#

And I want a list

#

I know it's possible with some YAML parsers

summer scroll
#

why?

sturdy hearth
sturdy hearth
summer scroll
#

you can do that using configuration section too

#

i'll give you an example

#
for(String uuid : config.getConfigurationSection("players").getKeys(false))){
  int level = config.getInt("players." + uuid + ".level");
  int xp = config.getInt("players." + uuid + ".xp");
}
sturdy hearth
summer scroll
#

no problem.

keen kelp
tardy delta
#

?paste

queen dragonBOT
tardy delta
#

can someone take a look at my lock method how to fix the classcastexception?

eternal oxide
#

line 11 shoudl be || not &&

keen kelp
#

Hey elgarl

tardy delta
#

and yesterday they said me it has to be && :/

eternal oxide
#

only if you want to exit if BOTH are false

keen kelp
#

Im trying to have an Item ingredient in a shaped recipe to have ItemMeta

#

and MD_5 said it's .setIngredient('#', new RecipeChoice().ExactChoice(ItemStack));

#

but it gets underlined

eternal oxide
tardy delta
#

i have this error when trying to cast aCraftEnchantingTable to Lockable

#

so putting || would solve it?

eternal oxide
#

because its not lockable

#

changing to || woudl mean enchanting tables would not allow yoru code to run as they are not Lockabale

keen kelp
#

new RecipeChoice()

eternal oxide
#

you should be using new RecipeChoice.ExactChoice(ItemStack)

#

if you are and its underlining, hover over it and see what the error says

keen kelp
#

oh

#

no brackets?

eternal oxide
#

no

keen kelp
#

k

tardy delta
#

ow bruh i can still break it

eternal oxide
#

Your test code in BlockBreak is bad then

#

you need to cancel the event if its locked

tardy delta
#

i havent test code in block break πŸ˜‚

eternal oxide
#

That would be why then πŸ™‚

tardy delta
#

xd

#

so in fact it would be the same code as the eventHandler except its for blockbreak and not for interact?

eternal oxide
#

pretty much yes

quaint mantle
#

just a question is this bad? or

eternal oxide
#

make a method the returns a boolean and accepts a block

#

add a <?>

tardy delta
#

and now players can override a lock by putting a lock on the same block again ._.

quaint mantle
#

ty

tardy delta
#

so i have to check if the block not already has a lock and then i can put one

eternal oxide
#

yes

quaint mantle
#

just to understand what would happen if i didnt add <?>?

#

and what happens when i add it

eternal oxide
#

nothign much, it woudl just warn

quaint mantle
#

okay thank you

abstract spindle
#

Hey Guys is there an an alternative to the Material.LEGACY_STATIONARY_WATER , because it is @deprecated and I don`t find an alternative ?

dire marsh
#

yes

#

Material.WATER

tardy delta
# eternal oxide yes

something like this?

if (container.has(key, PersistentDataType.STRING)) return; // cannot override existing lock
        if (MagmaBuildNetwork.getPlayersWantingLock().remove(event.getPlayer().getUniqueId())) {

            event.setCancelled(true);
            container.set(key, PersistentDataType.STRING, p.getUniqueId().toString());
            blockState.update(); //apply the lock!
            p.sendMessage(ChatColor.DARK_GREEN + "Locked!");
...
abstract spindle
# dire marsh yes

Okay, but now there is the Problem, that a player canΒ΄t click a Block with the Material.WATER. So the by the PlayerInteractEvent the event.getClickedBlock() will never have the Material.WATER

dire marsh
#

send your code

abstract spindle
#

So I tried to work around the problem

dire marsh
#

please use == to compare enums

#

and debug your if statements

crude hound
#

Hi, I'am still in my problem, can you help me to get, remove and add tags to entity?

#

(in 1.8.9)

tardy delta
#

how can i get the block who is broken in the blockBreakEvent?

#

just event.getBlock()?

eternal oxide
#

yes

tardy delta
#

okay

tardy delta
# eternal oxide you need to cancel the event if its locked

like this?

@EventHandler
    public void onBlockBreak(BlockBreakEvent event) {

        Block block = event.getBlock();
        Player p = event.getPlayer();
        NamespacedKey key = new NamespacedKey(plugin, "MBN");

        BlockState blockState = block.getState();
        if (!(blockState instanceof TileState) || (!(blockState instanceof Lockable))) return;

        TileState tileState = (TileState) blockState;

        PersistentDataContainer container = tileState.getPersistentDataContainer();

        if (container.has(key, PersistentDataType.STRING)) event.setCancelled(true);
    }
#

maybe remove some unneccesary parts but yea

abstract spindle
#

I would writ it so but, yes so can get the block

@EventHandler
    public void onBlockBreak(BlockBreakEvent event) {

        Block block = event.getBlock();
        Player p = event.getPlayer();
        NamespacedKey key = new NamespacedKey(plugin, "MBN");

        BlockState blockState = block.getState();
        if (blockState instanceof TileState || blockState instanceof Lockable){

        TileState tileState = (TileState) blockState;

        PersistentDataContainer container = tileState.getPersistentDataContainer();

        if (container.has(key, PersistentDataType.STRING)) event.setCancelled(true);
        }
    }
tardy delta
#

oh thats pretty the same thing

#

oh wait there s something more

#

i havent checked if the uuid stored is the same as that from the owner

abstract spindle
#

only the fact that you dont`t have an return statement that is unnecessary

eternal oxide
#

I would create some helper methods.

boolean isLockable(BlockState state)
boolean isLocked(BlockState state, @Nullable Player player)
boolean setLock(BlockState state, @NutNull Player player)```
abstract vortex
#

need help in bungeecord server

#

listeners:

  • query_port: 25577
    motd: '&1Another Bungee server'
    tab_list: GLOBAL_PING
    query_enabled: false
    proxy_protocol: false
    forced_hosts:
    pvp.md-5.net: pvp
    ping_passthrough: false
    priorities:
    • lobby
      bind_local_address: true
      host: 0.0.0.0:28409
      max_players: 4000
      tab_size: 100
      force_default_server: false
      remote_ping_cache: -1
      network_compression_threshold: 256
      permissions:
      default:
    • bungeecord.command.server
    • bungeecord.command.list
      admin:
    • bungeecord.command.alert
    • bungeecord.command.end
    • bungeecord.command.ip
    • bungeecord.command.reload
      log_pings: true
      connection_throttle_limit: 3
      server_connect_timeout: 5000
      timeout: 30000
      stats: ceb0560d-f953-43a8-a6f2-1ea0188f3892
      player_limit: 4000
      ip_forward: true
      groups:
      md_5:
    • admin
      remote_ping_timeout: 5000
      connection_throttle: 4000
      log_commands: false
      prevent_proxy_connections: false
      online_mode: false
      forge_support: false
      disabled_commands:
  • disabledcommandhere
    servers:
    lobby:
    motd: '&1Just another BungeeCord - Forced Host'
    address: us3.falix.gg:28409
    restricted: false
    hub:
    motd: '&1Just another BungeeCord - Forced Host'
    address: de10.falix.gg:28803
    restricted: false
drowsy helm
#

jesus

abstract vortex
#

bungee config

drowsy helm
#

this is help dev not bungee

eternal oxide
#

?paste not spam

queen dragonBOT
abstract vortex
#

where i can get that

eternal oxide
quaint mantle
#

Hi
I am trying to create a file and save us data only that I always make this error:

        at cryptomanager.cryptomanager.Main.<init>(Main.java:12) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_51]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_51]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_51]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_51]
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_51]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[server.jar:git-Spigot-37d799b-3eb7236]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[server.jar:git-Spigot-37d799b-3eb7236]
        ... 8 more```
Code: 

public class WalletWriter {
String path;
public WalletWriter(String path){
this.path = path;
}
public void write(String user, int money,int crypto) throws IOException {
File wallets = new File("wallets.txt");
if (!wallets.exists()){
try {
wallets.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}

    FileWriter myWriter = new FileWriter("wallets.txt");
    myWriter.write(user+" "+money+" "+crypto);
    System.out.println("[CryptoManager] Wallet Writed...");
    myWriter.close();
    System.out.println("[CryptoManager] Wallet Closed...");
}
Please help me
tardy delta
#

i did the check part like this

String lock = container.get(key, PersistentDataType.STRING);
        if (lock != null && !lock.equalsIgnoreCase(p.getUniqueId().toString())) {
            event.getPlayer().sendMessage(ChatColor.RED + "You cannot break this!");
        }
#

else: you can break it..

eternal oxide
#

See above for my recommended methods you should write

keen kelp
#

how do I hide Enchatments

#

like the hide flag thing

quaint mantle
quaint mantle
eternal oxide
#

then plugin is null

tardy delta
#

for some reason when i set a lock i cant open it either

eternal oxide
#

you need to check for a lock and if its not yours cancel the opening event.

crude hound
quaint mantle
eternal oxide
#

plugin is null

quaint mantle
#

how i change it?

eternal oxide
#

you can;t initialize fields in the class where you depend on values like plugin which are not set until onEnable

quaint mantle
#

plugin is :public static Main plugin;

#

and in onEnable: plugin = this;

eternal oxide
#

MY statement still stands

#

onEnable runs long AFTER class instancing

#

you should not be trying to access getDataFolder() in your class instance

#

initialize it in your onEnable after you set your plugin reference.

#
public WalletWriter myWriter;

public void onEnable() {
    this.plugin  = this;
    myWriter = new WalletWriter(this.getDataFolder() + "wallets.txt");```
quaint mantle
#

Thanks

tardy delta
#

what does that ~ do?
List<String> arguments = new ArrayList<String>();

eternal oxide
#

?

tardy delta
#

ow

#

copied the wrong one

eternal oxide
#

Its private so only accessible from inside that class, but its static so there can only ever be one instance

tardy delta
#

i mean the ~ here what does it do?

#

copying does not work πŸ™„

eternal oxide
#

no matter how many copies of that class are created at runtime they will all share the same arguments

#

oh

tardy delta
#

xd

eternal oxide
#

I have never in my life used it

#

I've never even seen it used

#

where is this from?

wraith rapids
#

that is intellij collapsing the type parameters

eternal oxide
#

oh

wraith rapids
#

if you click on it it'll expand to the actual params

eternal oxide
#

stupid intelij

wraith rapids
#

the ~ is there to differentiate it from the diamond notation shit

crude hound
#

I found a solution but I have another problem while trying to load this line : java NBTInjector.inject(); because I have this error :

wraith rapids
#

can you paste the error on a paste site

crude hound
#

k

wraith rapids
#

i don't feel like downloading a txt file

crude hound
#

(Im in 1.8.9)

wraith rapids
#

look into what SpawnEntityCustomNbtInjectorTest.java:27 is doing ig

#

i don't use 1.8 so I can't help you beyond that

#

maybe ask your community of fellow 1.8 plebians

#

there are quite a few of them here

#

although in a typical 1.8'er fashion they never answer anyone's questions, only ask their own

crude hound
#

I early checked but this is a test maked by the api I'm actually using and it failed that's my question

wraith rapids
#

yeah you need to open it up and look at it to figure out why it failed

#

since the failure message isn't exactly descriptive

#

i'll start compiling a list of 1.8 people that i'll ping whenever a 1.8 guy has a question

#

i'll foster a community out of you fucks yet

#

so you can piss off to your own discord

covert bluff
#

What is the difference between using the player's username as comparison or to find and using the player's UUID as comparison or to find? How?

chrome beacon
#

UUIDs can't change

#

Player names can change and there are also rare cases of two accounts with the same name

covert bluff
#

i see, thanks

#

but would it matter if the server was offline mode anyway

#

or should i still use uuid for good practice

chrome beacon
#

Yeah if the server is offline mode it doesn't matter

#

UUID will change with the username

covert bluff
#

thanks

chrome beacon
#

But please don't make offline mode servers ;/

covert bluff
#

i actually wouldn't, trust me, but most of my friends have the pirated version of minecraft

#

and i have no one to test my plugins with

wraith rapids
#

you should still use UUIDs even if the server is in offline mode

#

relying on UUIDs allows you to for example easily implement username changes

#

simply substitute the joining player's UUID with a different one, and all of their data is swapped

#

f.e if playerA with uuidA changes their username to playerB, this would also change their offline mode UUID to uuidB

#

however you can easily switch the uuid back to uuidA

#

which allows them to retain all of their data despite the username change

#

plus keying data by UUID is the standard, anyway

quaint mantle
#

how can i make smth like that player cant damage any entity?

tardy delta
#

?paste

queen dragonBOT
quaint mantle
#

like how can i get smth like entity.getDamager

maiden briar
#

Cancel PlayerDamageEntityEvent

quaint mantle
#

ohh ty i thought it was smth like entitydamage

maiden briar
#

Or EntityDamageByEntityEvent is better, check if entity is a player

quaint mantle
#

okay

tardy delta
quaint mantle
#

could you try debugging the lock what does it say?

maiden briar
#

What is MagmaBuildNetwork.getPlayersWantingLock()?

quaint mantle
#

prob hashmap

#

or some list

tardy delta
#

yea a list with the users who wants a lock on their container

maiden briar
#

Then you mean replace it with contains?

tardy delta
#

look when i do /lock set the player is added to the list

if (cmd.getName().equalsIgnoreCase("lock")) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("the console cannot run this command!");
                return true;
            }
            final Player p = (Player) sender;
            if (args.length == 1) {
                if (args[0].equalsIgnoreCase("set")) {
                    MagmaBuildNetwork.getPlayersWantingLock().add(p.getUniqueId());
                    sender.sendMessage(ChatColor.DARK_GREEN + "Right click a block to lock it!\nOr type /lock cancel to cancel");

quaint mantle
tardy delta
#

uhh never done debugging

quaint mantle
#

System.out.println(lock);

tardy delta
#

oh

eternal oxide
tardy delta
#

owh i understand

#

how do i fix then that i can cannot override an existing lock?

#

so another player cannot 'claim' your locked chest?

maiden briar
#

Map<Player, Lock> , check if player contains with the lock

#

I would recommend set the location, because it is always different

wraith rapids
#

no

#

check if the tile has the tag

#

if it has the tag, it's locked

eternal oxide
#
String lock = container.get(key, PersistentDataType.STRING;
if (lock != null) { // Has a lock so test.
    if (!lock.equalsIgnoreCase(p.getUniqueId().toString())) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "You cannot open this!");
        return;
    }
} else { //no lock
    if (MagmaBuildNetwork.getPlayersWantingLock().remove(event.getPlayer().getUniqueId())) {

        event.setCancelled(true);
        container.set(key, PersistentDataType.STRING, p.getUniqueId().toString());
        blockState.update(); // apply the lock!
        p.sendMessage(ChatColor.DARK_GREEN + "Locked!");
    }
}```
tardy delta
#

what does those 2 first lines do?

wraith rapids
#

they confuse you

#

because they introduce you to concepts you're not ready for and aren't necessary here

eternal oxide
#

retrieves teh UUID lock if it exists, else null

wraith rapids
#
String lock = container.get(key, PersistentDataType.STRING);
if (lock != null) {
#

functionally identical to this

tardy delta
#

so then i have to check if the lock is equal to the players uuid

eternal oxide
#

the above code does that

wraith rapids
#

if the container is locked
if the player is trying to lock something
if the container is locked by the player
"you have already locked this container"
else
"someone else has already locked this container"
else
"you cannot open this, this is locked"
else
if the player is trying to lock something
lock the container
else
open the container

eternal oxide
#

updated code to include adding the lock

young knoll
#

πŸ₯„

tardy delta
#

is this a begin?

wraith rapids
#

illegible spaghetti

tardy delta
#

._.

#

i think it works

wraith rapids
#

it's still illegible spaghetti

tardy delta
#

tested it with my alt and he cant open/break it

wraith rapids
#

you should clean it up a bit

tardy delta
#

yea i know i dont know how πŸ™„

wraith rapids
#

lines 18 through 21 are horror

#

other than that it's fine

#

but on line 18 you have an if clause that splits on a newline without a {} block

#

and on line 19 you have another if clause that does the same

#

you should combine them into a single if clause and use {} if you can't fit it on a single line

#

and you will want an empty line after them before line 21 because otherwise it looks like an illegible blob

tardy delta
wraith rapids
#

you still have a 2 nested ifs that could be a single if with a &&

#

and the first if doesn't have a {} block but splits to a new line

eternal oxide
#

and move line 8 to the very top

wraith rapids
#

and don't create a new namespaced key each time this runs

#

and be more liberal with empty lines

#

right now you have all the way from line 18 to line 35 without a single break

tardy delta
#

does that namespace key matters?

young knoll
#

Is lockable even used

wraith rapids
#

not really

eternal oxide
#

create a field for the NamespacedKey so its only created once when the class is

tardy delta
#

so a private field and then a getter for it?

eternal oxide
#

no need for getter, just private

wraith rapids
#

no need for a getter since it's in the same class

tardy delta
#

oki

wraith rapids
#

or more specifically, on the same object

#

but oop is probably still hebrew for you

tardy delta
#

can i delete lockable?

#

probably

past vapor
#

ite so im trying to import the BetterRTP api, i think ive done it successfully however when i attempt to build my plugin this happens:

#

i cant put an image :I

wraith rapids
#

inb4 you imported it as an artifact with your ide instead of with maven or gradle or whatever you're using to build

quaint mantle
#

you need to verify btw for images

wraith rapids
#

upload the image somewhere else and then link it here

past vapor
#

How do i import it with raven

vocal mirage
#

Hi !
I was looking at plugin messaging system between Spigot and Bungee, and I just wanted to know if there is a way to get all connected players on Bungeeserver with a special perm, and send them a message, from a Spigot plugin ?

Thanks,

quaint mantle
#

could you show how you imported it?

wraith rapids
#

you need to add its dependency information to your pom.xml

#

show your pom.xml and link to the github of the api or whatever

past vapor
#

Howd i do that, im new to maven

wraith rapids
#

open up the file

#

take a screenshot

#

and then send it

#

the file is at the root of your project directory

quaint mantle
#

btw @wraith rapids do you know how to save resource under other name? Server#getResource

past vapor
#

Do i just add

<dependency>
            <groupId>org.bukkit</groupId>
            <artifactId>bukkit</artifactId>
            <version>1.15.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
#

but replace that with the information for the api

wraith rapids
#

no, that is for bukkit

#

well yeah

quaint mantle
#

yes

past vapor
#

ite

#

ill try

wraith rapids
#

write the inputstream down to disk

quaint mantle
#

okay

past vapor
#

I have no clue what the format would be to this

wraith rapids
#

link the api or lib or whatever

#

i'll show you how to do it

quaint mantle
#

you dont have an repository

past vapor
#

thats a dependancy

wraith rapids
#

open up their pom

#

on lines 7 through 10 you will find the information you need

#
    <groupId>me.SuperRonanCraft</groupId>
    <artifactId>BetterRTP</artifactId>
    <packaging>jar</packaging>
    <version>3.1.0-4</version>
quaint mantle
past vapor
#

got it

wraith rapids
#

yeah you'll have to build it locally

past vapor
#

i added that to my pom.xml

wraith rapids
#

since they don't deploy it to an online repository

past vapor
#

and it doesnt like it

chrome beacon
#

You can use JitPack