#help-development

1 messages Β· Page 1848 of 1

subtle folio
#

Thanks.

#

Im not too familier with cooldowns, Can someone explain why this isnt working? java cooldown.put(event.getPlayer(), (System.currentTimeMillis() / 1000)); if((cooldown.get(event.getPlayer()) + 1) >= (System.currentTimeMillis() / 1000)){ if (!isUsed(belowLoc.getBlock())) { event.getPlayer().sendMessage("hasnt been used"); event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(1.2)); belowLoc.getBlock().setMetadata("UsedOnce", new org.bukkit.metadata.FixedMetadataValue(Trampotdi.getInstance(), true)); // event.getPlayer().sendMessage(event.getFrom().toString()); // event.getPlayer().sendMessage(event.getTo().toString()); } else { event.getPlayer().sendMessage("has been used"); event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(1.2)); belowLoc.getBlock().setType(Material.AIR); } }

#

the hashmap is defined at the top of the code

cold pawn
subtle folio
#

Nevermind! I might have some brain damage.

cold pawn
#

Heres both methods I tried πŸ˜…

hybrid spoke
# cold pawn

here you are not checking if the entity is a player, you just cast blind. also what is PlayerChatProperties and what returns getGeneralChat? and you are adding player everytime what is unnecessary

#

also unnecessary to first add, and then remove if X is false. just add if X is true

#

and what is distanceFromPlayer?

cold pawn
#

I did actually check if the entities was an instance of a player this is just a past screenshot, PlayerChatProperties just holds the information of which chat a player is currently in, distance from player is the method that reads the defined int from config, which is suppose to be how far should the player be to see the actual message

hybrid spoke
#

also
The set returned is not guaranteed to be mutable and may auto-populate on access. Any listener accessing the returned set should be aware that it may reduce performance for a lazy set implementation. Listeners should be aware that modifying the list may throw UnsupportedOperationException if the event caller provides an unmodifiable set.
from docs

cold pawn
#

and Its a bit messy right now I kinda just butchered everything to try and get this working

hybrid spoke
trim surge
#

Anyone know how to Obtain the following?

block#getID();
block#getData();```
These are currently deprecated ;/
trim surge
#

Version 1.8.9

cold pawn
trim surge
hybrid spoke
hybrid spoke
trim surge
# hybrid spoke for what do you need the type id? just getType
    public static void setBlockInNativeWorld(World world, int x, int y, int z, int blockId, byte data, boolean applyPhysics) {
        net.minecraft.server.v1_8_R3.World nmsWorld = ((CraftWorld) world).getHandle();
        BlockPosition bp = new BlockPosition(x, y, z);
        IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getByCombinedId(blockId + (data << 12));
        nmsWorld.setTypeAndData(bp, ibd, applyPhysics ? 3 : 2);
    }```
#

needs a blockID

hybrid spoke
#

lemme guess, you just copied the method from somewhere and now you are trying to use it

trim surge
hybrid spoke
#

thats a bad practice

#

you should actually understand what you use

trim surge
#

well no shit lol

#

but i need it

#

@ivory sleet Daddy

#

Help me pls ❀️

cold pawn
hybrid spoke
trim surge
#

He taught me to code darling.. He will

hybrid spoke
#

but anyways, using the type id is fine. its deprecated because its a hardcoded value

trim surge
#

he's a close mate.. miss the man tbh

cold pawn
# hybrid spoke so where does it fail

I don't know that's why im asking for help, I tried both methods multiple ways and did a fair bit of debugging but I still can't get it to work πŸ˜…

hybrid spoke
misty current
#

yey i managed to remove commands from the map

#

now my api is reload compatible

cold pawn
fleet imp
#

how can i transform a static var to non-static. or use a non-static var in a static context. or something like that

chrome beacon
#

You can't access a non-static variable without creating an instance

#

As for transforming a static var to non-static just remove the static modifier if possible if not make your own variable and use that

left swift
#

for version 1.18 api do i have to install the craftbukkit and spigot, bukkit separately? I run buildtools as latest and the compiler imports only from spigot api, not from bukkit like Player etc.

tender shard
#

in 1.18, the spigot .jar only contains bootstrap stuff

left swift
#
    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>```yeah
tender shard
#

hmmm that SHOULD work

#

what class are you missing?

left swift
tender shard
#

that is indeed strange

#

please show your dependency section on the right side

#

does it show the bukkit classes there?

left swift
tender shard
#

open the spigotmc thing at the bottom pls

#

then send screenshot again

#

oh also - did you reload your maven config after adding the spigot dependency?

left swift
#

i cant open it

#

but on the left side

#

i have

#

but the craftbukkit

#

i downloaded using java -jar BuildTools.jar --rev latest --compile craftbukkit

sullen marlin
#

there is no reason to compile craftbukkit

left swift
#

I haven't had it before, but I thought it shouldn't be like that, that I install everything separately.

tender shard
#

when filing bug reports on spigot's jira

#

it asks you to also try craftbukkit πŸ˜›

left swift
#

so any ideas?

tender shard
left swift
fleet imp
#

what's considered a non-static context

quasi patrol
#

Is it possible to create a hidden save file, so like a save file that isn't visible to the server owner?

tender shard
quasi patrol
#

Oof.

tender shard
#

the server owner can always see anything if they want to

#

but

#

why would you even need that

#

why would you want to hide files from the owner?

#

are you up to something suspicous? lol

quasi patrol
#

Ofc not lol.

fleet imp
left swift
#

@tender shard with <artifactId>spigot-api</artifactId> works, but i need <artifactId>spigot</artifactId> for nms

quasi patrol
#

Just want to make an alt checker that works with offline players, but don't want the server owner to be able to see the saved ips for privacy?

tender shard
#

try to run buildtools again

#

seems like you got the bootstrapped jar in your repo instead of the "actual" server .jar

tender shard
quasi patrol
#

But now that I think about it, if they know java they could just make their own plugin. .-.

torn shuttle
#

in addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks); is the String name the actual permission?

tender shard
#

IPs are nothing special anyway

torn shuttle
#

use my discount code on nordvpn to transcend this mortal realm of ips

tender shard
#

internet wouldn't work without knowing each other's IPs

#

see? no problem in letting others know your IP

torn shuttle
#

it would work just fine if you spoofed it

#

also just saying you can absolutely fuck with people by targetting their ip

tender shard
#

I highly doubt that

#

only thing anyone could do is start a random DDoS attack

#

but, back to topic:

#

the server owner will always know player's IPs

torn shuttle
#

and a general idea of the geo location

tender shard
#

it's in th elogs anyway

tender shard
torn shuttle
#

not everyone walks around wanted to get doxxed

tender shard
#

and not everyone will start random DDoS attacks

#

@quasi patrol EVERY website you visit, EVERY gameserver you join, etc - they ALL know your IP

torn shuttle
#

sure, but if you become even a z-list personality online you will get people who will actively seek out to mess with you in any way you give them

#

I mean hell I'm no one and even I already got doxxed a few times just because people were bored

wraith apex
fleet imp
#

how do i instantiate a boolean

wraith apex
#
boolean aBool = true;
#

or

#
boolean anotherBool = false;
fleet imp
#

but say i already defined a bool, how do i insantiate one

wraith apex
#

you just make it equal to false or true

#

boolean is a primitive type

#

so you don't use the new keyword

#
boolean isFlying;

// Sets isFlying to true
isFlying = true;

// Sets isFlying to false
isFlying = false;
hybrid spoke
#

new Boolean

wraith apex
tender shard
#

e.g. if it may be nullable or sth

wraith apex
#

Β―_(ツ)_/Β―

#

why does a boolean need to be nullable?

#

why not by default it be false?

tender shard
#

I can give a nice example

hybrid spoke
#

or use the Boolean.TRUE/FALSE

sleek pond
#

If your lazy and want to have 3 states for something

torn shuttle
#

there are no silver bullets for browsing online but in terms of privacy using a vpn is like step 0 of privacy 101

tender shard
#
Boolean isSomePluginInstalled = null;

public void something() {
  if(isSomePluginInstalled == null) {
    checkIfSomePluginIsInstalled(); // This will set the boolean to true or false
  }

  if(isSomePluginInstalled()) {
    doSomething();
  }
}
wraith apex
sleek pond
#

Lmao

wraith apex
#

or just have it check anyway

#

I've sort of come to understand that you can point to something in code or the world and get a true or false value from it

hybrid spoke
#

the null state of your boolean would be the init

tender shard
#

it is null when no check was done yet

#

afterwards it's true or false

wraith apex
#

huh I guess that's a good use case

#

the ability to know if something was checked

tender shard
#

there might be a better way, but yeah that's just a tiny example of why you sometimes want a Boolean to be null πŸ™‚

#

of course I could also just use two booleans instead

#

boolean haveIAlreadyChecked;
boolean isSomePluginInstalled;

#

but I think it's easier this way

fleet imp
wraith apex
tender shard
wraith apex
#

as the way you browse the internet is also collected

wet breach
#

while it is bad practice because not being proper, you could technically use Null as a third state that doesn't use anymore extra resources πŸ˜›

tender shard
wraith apex
#

static = you never intend to create instances of this and every reference of this variable is the same and always will be

tender shard
#

static = it belongs to the class
non-static = it belongs to the INSTANCE

torn shuttle
#

why use values when you can just use different types of null

fleet imp
#

oh ok

wraith apex
wet breach
#

yep

tender shard
#

of course it won't

#

it will stay there

wraith apex
#

Huh, why?

torn shuttle
#

it would be very bad if static got gc'ed lol

tender shard
#

because it's static πŸ˜›

wet breach
wraith apex
#

if I fill a list with million integers and then clear it is that not GCed?

fleet imp
#

then what does Non-static field cannot be referenced from a static context mean

tender shard
#

basic rule:

hybrid spoke
tender shard
#

If ANYTHING has a reference to something, "something" will not get GCed

wet breach
#

wouldn't be proper or good design, but if you had to work against resource constraints that is an acceptable solution @torn shuttle

tender shard
#

I will start a fight now

#

static getters or DI?

wraith apex
tender shard
wraith apex
#

so by clearing a static list, those cleared vars are GC'ed

#

at least I would imagine so

torn shuttle
tender shard
#

lol

tender shard
wet breach
tender shard
#

show your code @fleet imp

fleet imp
torn shuttle
tender shard
#

yes, no problem

#

just show your code

wraith apex
#

static methods can be called with ClassName.MethodName, instance methods can only be called using an instance of the class

torn shuttle
#

theseus' understanding, if the reference is the same but the value becomes different am I still understanding it the same way

tender shard
#

to explain it in one sentence: static things are stuff you can always access, non-static can only be accessed if you have an object / an instance of your class

wet breach
# fleet imp i need u to dumb it down a lot for me

if the method is static and you try to grab a reference of an object or another method and they are also not static, the compiler will yell at you because you can't use non-static stuff in static methods πŸ™‚

tender shard
#

like for example, you have a person

wraith apex
#

I could probably GC a static class by forcing the URLClassLoader to purge it

hexed hatch
#

Does anyone know why FileConfiguration#save(File) might be failing me?

wraith apex
#

if it was dynamically loaded

hexed hatch
#

I'm modifying an instance of a FileConfiguration and I'm trying to save it using that method

tender shard
#

the age and the name of a person are associated with one special person. You can't just do Person.getAge() because the age depends on a specific person. However, we could in theory say that the planet of a person is always the same because we're all from earth, so getPlanet() could be a static method

tender shard
#

I doubt that lol

#

anyway I think that explanation is understandable πŸ™‚

wraith apex
#

I'm a cold heartless bastard

#

:3

#

That's my proof

torn shuttle
#

for whatever reason I just can't get permissions to work and it's really starting to annoy me

tender shard
wraith apex
tender shard
torn shuttle
#

they always evaluate to false

tender shard
wraith apex
tender shard
torn shuttle
#

bukkit

fleet imp
# tender shard show your code <@!825102564931665940>

So, I'm making a plugin with the JDA and this method sends whatever is in a specific channel to the MC chat

public class Main extends JavaPlugin {
    public long PostID = Said "channel" id;
}

public class msgRecive extends ListenerAdapter {
    @Override
    public void onMessageReceived(MessageReceivedEvent event) {
        if(event.getChannel().getIdLong()==Main.PostToMinecraft) {
            Bukkit.broadcastMessage(ChatColor.DARK_PURPLE+event.getAuthor().getAsTag()+" said: "+ChatColor.RESET+ChatColor.BLUE+event.getMessage().getContentRaw());
        }
    }
}
torn shuttle
#

does vault even let you do that?

wraith apex
torn shuttle
#

no

wraith apex
#

well.. that might be why

torn shuttle
#

look at me , I am the permissions plugin now

wraith apex
#

the server does not store the permissions you give to players

torn shuttle
#

I know

wraith apex
#

over restarts

torn shuttle
#

do the impossible see the invisible

wraith apex
wet breach
#

static members are stored in or with the class object at runtime

ivory sleet
#

I mean technically class loading can cause static referents to be unloaded

#

Or well enqueable for gc

tender shard
#

they wanted a basic explanation on what static means

ivory sleet
#

True

wraith apex
#

Spigot has some fancy code for keeping track of plugin classes

ivory sleet
#

It’s not anything reliable regardless

wraith apex
#

when you unload them it will purge them

ivory sleet
#

Like you’d have to rely on ::finalize which has some major flaws

wraith apex
#

so they are no longer referenced

torn shuttle
#

so you're telling me that moving forward I should create all static objects by dynamically loading their classes in and out?

hexed hatch
#

Does anyone know why Fileconfiguration#save(File) is not working for me?

hexed hatch
#

None

tender shard
#

it just doesn'T save?

hexed hatch
#

Just complete failure to save anything I have changed on the file

ivory sleet
#

Do you save it to an existent file

hexed hatch
#

Yes

#

I create the file well beforehand, it exists

tender shard
ivory sleet
#

I guess some code could help us find out about the error of well issue

hexed hatch
#

Nope

tender shard
#

windows can be weird when overwriting opened files

torn shuttle
#

oop is cringe, static oop is the new hotness

wraith apex
#

I looked at spigots code for how it loads plugins and made my own version

#

so I can have a modular plugin

ivory sleet
tender shard
wet breach
tender shard
#

let's go back to italien spaghetti code

wraith apex
#

some people on the youtubes saying oop is dodo and we should all be using procedural

torn shuttle
wraith apex
#

lol

torn shuttle
#

with uh

#

what was it called again

hexed hatch
#
        humanFile = new File(plugin.getDataFolder() + File.separator + "humans.yml");
        if (!humanFile.exists()) {
            try {
                humanFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        humanConfig = YamlConfiguration.loadConfiguration(humanFile);
        humanConfig.createSection("humans");
        try {
            humanConfig.save(humanFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }```
This creates my configuration file. It works as expected, and the "humans" section is created as expected
torn shuttle
#

ECS it was

wraith apex
hexed hatch
#
    void addHuman(Player player) {
        humanConfig.getStringList("humans").add(player.getUniqueId().toString());
        try {
            humanConfig.save(humanFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }```
This is what I'm trying to do
torn shuttle
#

tbf ECS is much faster, just like it is much more of a pain to develop

ivory sleet
hexed hatch
#

I know I must be missing something very simple here, but it will not append the list with the values I'm trying to add

wraith apex
#

ECS?

torn shuttle
#

entity component system

#

it's a whole thing

wraith apex
#

I mean for game development...

#

maybe

hexed hatch
#

I just don't understand why the list is not being updated in the file

torn shuttle
#

yeah that's pretty much what the devs agree to

wet breach
wraith apex
#

ECS sounds like OOP with extra steps...

hexed hatch
#

oh

wet breach
#

try using a set method to set the config value

#

and then save

hexed hatch
#

Oh I see that

torn shuttle
#

still just getting started with it though

left swift
#

I must implement methods but...
How can i make that?

torn shuttle
#

and if you think ecs is weird and annoying you should see what trying to offload processing to the gpu looks like

ivory sleet
left swift
#

I've figured it out before, but that's what still won't implement x() πŸ˜„

ivory sleet
#

Maybe you got a method which already matches the signature but different return type

torn shuttle
#

also just on the topic of unironic oop sucks, the main thing that is usually brought up about it is how you generally can't create a class that is a subclass of two different classes

#

which does really suck tbf

ivory sleet
#

Well multiple inheritance would make Java a lot more complicated including the introduction of a whole new set of problems

#

Like the Diamond problem iirc the name

torn shuttle
#

I understand why it is the way it is, but it doesn't make the issue suck any less

wraith apex
ivory sleet
#

Fair, guess you should move to not java

torn shuttle
#

move? I was born in Java, molded by it

wraith apex
#

lol alright bane

ivory sleet
#

Hmm run //undo maybe

torn shuttle
#

I didn't even look at other programming languages before my spigot plugins were at a few ten thousand downloads

wraith apex
#

do you wear a coffee mask?

ivory sleet
#

Idk it worked on my test server atleast

torn shuttle
#

I also have a cool pit at the java island

ivory sleet
#

Ever travelled to lombok?

torn shuttle
#

every time I see lombok I just think bollocks

trim surge
#

Lombok 🀀

ivory sleet
#

Lol

torn shuttle
#

and I see lombok a lot

ivory sleet
#

No Toby

trim surge
#

Conclure!!!!

#

can i dm you? its important lol

torn shuttle
#

hot

ivory sleet
#

Toby, first it sucks, second it haunts me

trim surge
torn shuttle
#

getter I hardly know her

left swift
mighty sparrow
#

It'll markdown the metbods you need to implement

mighty sparrow
#

You have to write code in it and return the desired types

ivory sleet
#

Implement it manually maybe tusoo

mighty sparrow
#

Yes

left swift
ivory sleet
#

It must be public

left swift
mighty sparrow
#

Read the error message

ivory sleet
#

Make it return void

left swift
#

when it is void

ivory sleet
#

Oh meant boolean oopsie

#

But yes

left swift
ivory sleet
#

Make it void?

torn shuttle
#

my soul is void

ivory sleet
#

Or maybe you’ve run into a compile time dependency mismatch

ivory sleet
torn shuttle
#

I don't want to get high but thanks for offering

ivory sleet
#

And jfc ios why does autocorrect suck

ivory sleet
torn shuttle
#

brah why it no work

ivory sleet
#

Use luckyperms maybe

torn shuttle
#

I can't

ivory sleet
#

Ah that one hurts

torn shuttle
#

oh

#

balls

#

I inverted the permanent check

ivory sleet
torn shuttle
#

yee

#

I messed up

#

ok that now sort of works

slow oyster
#

Is it possible to get a Player instance even if a Player is offline?

mighty sparrow
#

What would you do with this instance @slow oyster

hasty prawn
mighty sparrow
slow oyster
#

Yeah I know, there's just some methods I need to use that use Player. I.e get their Inventory

mighty sparrow
#

Look at above @slow oyster

slow oyster
#

And yes I know about OfflinePlayer etc, it's just some API methods that need a Player instance

torn shuttle
#

well that's lame by jdbc driver doesn't support #getBlob

#

I feel discriminated against

#

this is some form of data structure shaming

young knoll
#

No you cannot have a Player object if the player isn't online

mighty sparrow
#

Thats why you need to create a registered player class like I sent if you looked at it

slow oyster
#

Nah it doesn't matter I needed a Player instance to get their inventory but it makes sense it's not possible to get it when the player is offline

mighty sparrow
#

But the json files are saved on the server

#

You cant get the items from the existing files

slow oyster
#

That's the reason, it was a PR I made but now I'm realising it may need an option for OfflinePlayers too

cold pawn
#

Is it possible that players can’t use command blocks after there skin is changed through packets. Because I change players skin through packets and because of that they cant use command blocks

young knoll
#

Wut

cold pawn
#

I made a system that change players to specific skins, but when there skin is changed they can no longer access a command block

#

I change player skins through packets so I’m wondering if it has something to do with that

young knoll
#

I guess it may tell the client they are no longer op?

#

So they can't open em anymore

cold pawn
#

Oh that’s a problem ok let me try that

buoyant viper
#

ah yes, the client sided quirks of minecraft

#

gotta love how held together by duct tape and string this game is

runic mesa
#

what plugin do i use

#

event*

buoyant viper
#

for what

runic mesa
#

for boat movement

#

on player move doesnt have it

buoyant viper
#

there might be a VehicleMoveEvent or something

mighty sparrow
#

?jd

mighty sparrow
#

Look for the event

#

In the doc

cold pawn
young knoll
#

No idea

#

Are you sure it's caused by the skin change

runic mesa
#

There doesnt seem to be away to get the player in the vehicle tho

mighty sparrow
#

I never played with those methods

#

But braindead like this

#

Look if the player coords match the boat coords

runic mesa
#

thats what i was thinking

young knoll
#

You can get passengers

#

Of the boat

cold pawn
low temple
#

I’m trying to retrieve a clicked inventory and want to store that inventory but the contents don’t update when the item is taken. Like if they take out a block at the index of 8 it will register the inventory before that item was removed. I’ve been creating a thread that waits 1 millisecond then returns the correct inventory. Is there a better way to do this or is the way I did it the only way?

cold pawn
# cold pawn

Sorry if the codes a bit messy I was about to do some cleaning up before this issue sprang up πŸ˜…

cold field
#

Hi guys how fast is it the cloning of the itemMeta? I need to access PDC very often every time with a different persistenDataHolder

hardy swan
#

I think it is a detail meant to be ignored, or you can assume it to be fast.

junior briar
#

why not store pdc as a local variable.

young knoll
#

very often every time with a different persistenDataHolder

hardy swan
#

But I suppose pdc is also cloned with itemmeta right

#

^ Even if you want to access from the same persistent data holder everytime

junior briar
#

sry! i thought u were talking about different PersistentDataType

quaint mantle
#

hello

#

heloooooooo

austere sinew
#

Hi

junior briar
#

check these sources.
but i don't think u can do anything about that.

    @Overridden
    @Override
    public CraftMetaItem clone() {
        try {
            CraftMetaItem clone = (CraftMetaItem) super.clone();
            if (this.lore != null) {
                clone.lore = new ArrayList<String>(this.lore);
            }
            clone.customModelData = this.customModelData;
            clone.blockData = this.blockData;
            if (this.enchantments != null) {
                clone.enchantments = new LinkedHashMap<Enchantment, Integer>(this.enchantments);
            }
            if (this.hasAttributeModifiers()) {
                clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
            }
            clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), DATA_TYPE_REGISTRY);
            clone.hideFlag = this.hideFlag;
            clone.unbreakable = this.unbreakable;
            clone.damage = this.damage;
            clone.version = this.version;
            return clone;
        } catch (CloneNotSupportedException e) {
            throw new Error(e);
        }
    }
cold field
#

Thanks all of you. I think I will benchmark with some milli's to know if it is faster using reflection or the normal method

hardy swan
#

I will not touch reflection unless absolutely required for the task to even be possible.

cold field
#

why?

hardy swan
#

And you can trust that if both ways works O(n) time, reflection is most likely more expensive by a scalar

#

Meaning if you wont use reflection to change one prc

#

You wont use it to change multiple prc too

junior briar
#

i don't think reflection is expensive after java 7 or 8.
oof

mighty sparrow
#

whats reflection

hardy swan
#

Expensive*

#

Oops

young knoll
#

If it's cached it's pretty fast

hardy swan
#

Even if it isnt expensive, it is a bad se practice, increases coupling

#

Probably decreases testability too, if you ever do unit tests anyways

junior briar
#

as the member org.bukkit.inventory.ItemStack.meta doesn't belong to nms, it's fine enough to be accessed with reflection.

young knoll
#

That's just an interface

junior briar
#

org.bukkit.inventory.ItemStack is a class instead of an interface.

hardy swan
young knoll
#

Oh right Itemstack is the weird one

junior briar
#

because when it comes to nms or craftbukkit wrappers, things become complicated.

young knoll
#

NMS names no longer change every version

#

CB still does

junior briar
#

even the package names no longer change, they still don't guarantee their internal structures.

ebon torrent
#

hi, I'm trying to fork a plugin that uses the chat component api, but I can't seem to download the api to include in my source. I went to this website https://www.spigotmc.org/wiki/the-chat-component-api/ , but clicking on "Chat Component API Javadoc" leads me to a broken page with no option to download the api. where should I download it from?

young knoll
#

Its part of spigot

ebon torrent
#

oh right

#

it still doesn't recognise my imports though...

young knoll
#

What is your dependency

ebon torrent
#
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
#

this is what I'm importing, and it can't find the md_5 submodule

young knoll
ebon torrent
#

Ah sorry, what's that in java?

junior briar
#

what interesting is, bukkit uses reflection in its own event executor.
so no need to worry about the efficiency.

EventExecutor executor = new EventExecutor() {
    @Override
    public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException {
        try {
            if (!eventClass.isAssignableFrom(event.getClass())) {
                return;
            }
            // Spigot start
            boolean isAsync = event.isAsynchronous();
            if (!isAsync) timings.startTiming();
            method.invoke(listener, event);
            if (!isAsync) timings.stopTiming();
            // Spigot end
        } catch (InvocationTargetException ex) {
            throw new EventException(ex.getCause());
        } catch (Throwable t) {
            throw new EventException(t);
        }
    }
};
young knoll
#

How are you referencing spigot

#

Is it via jar, maven, gradle, etc

ebon torrent
#

ah

#

yeah, I added a jar dependency

young knoll
#

What jar

ebon torrent
#

I can give you the name sec

young knoll
#

Also what mc version

ebon torrent
#

1.18.1

#

spigot-api-1.18.1-R0.1-20211226.225430-20.jar

#

a blank plugin compiled successfully before in the same environment, so I believe I set it up correctly?

young knoll
#

You can depend on the full jar instead and that should give you the bungee api

ebon torrent
#

hm, I thought I did that? I don't use java that often though, so maybe I overlooked something

#

I do remember that I had to explicitly import JavaPlugin, but I wasn't able to do that with this

ebon torrent
young knoll
#

spigot-api is just the api

#

You want Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar iirc

ebon torrent
#

oh right, what's actually the difference?

#

but yeah, I'll try that, thanks :)

junior briar
#

i'm looking for a simple solution of player request and acception. anybody knows?

young knoll
#

Player request and acception?

junior briar
#

something like invite and accept in chat.

young knoll
#

Probably just a map that stores a UUID -> Request Object

#

The request object would contain the requesters uuid and any other data you need

junior briar
#

whose UUID?

young knoll
#

Like expiry time

#

The targets uuid would be the key

#

Or you could use a bi-map of just two UUIDs if you don't need any other data

junior briar
#

actually i want a bi-map with extra data.

#

but i don't know how.

hardy swan
#

You can create an association class

young knoll
#

You would have to use a custom object with overriden .equals

hardy swan
#

A request class or sorts

junior briar
#

when the inviter send a new request, i'll need to replace the old one with it. so requests need to be associated with both inviters' UUID and targets' UUID.

proven wave
#

There is an error in NPCLib on version 1.7.10, can anyone help me?

#

NPCLib 1.7.10 error

buoyant viper
#

mc 1.7.10??

junior briar
#

u want the link...?

ebon torrent
# ebon torrent but yeah, I'll try that, thanks :)

@young knoll sorry to bother you again, but now it can't recognise org.bukkit? with the first jar, I was able to import both spigot and bukkit but not the chat api, and with the second jar, it isn't able to require bukkit

#

and adding both jars doesn't work because it finds the spigot dependency in both jars...

young knoll
#

That's weird, the shaded one should contain the full API

junior briar
#

just add the jar u running the server with.

young knoll
#

Won't work

#

That's the bootstrap jar

ebon torrent
#

hmm

#

I mean I can try again

#

so to be clear, the shaded jar is supposed to have org.bukkit?

young knoll
#

Yes

#

See this post

#

(First comment)

ebon torrent
#

I see

#

eclipse still tells me that org.bukkit cannot be resolved to a module in module info, so I'm not sure what I'm doing wrong

junior briar
#

for me i use maven to import the jar created by BuildTools.
it's called spigot-1.17.1-R0.1-SNAPSHOT.jar.

young knoll
#

Yes but that is with maven

#

(Although you should use maven or gradle)

junior briar
#

i mean, he will just need to import his spigot-1.18.1-R0.1-SNAPSHOT.jar.

keen obsidian
#

I have a string of data in json format and I wish to send it to the player, however, it does not send (there is no output whatsoever) with Player#sendMessage, Player#sendRawMessage or in fact in Player#spigot#sendMessage even though it is a String, outputs fine to console, no errors - 1.17.1
Example of the string: {"type":"GLASS","name":"Block of Glass"}

ebon torrent
#

I tried both files and I'm not sure if it works?

young knoll
junior briar
keen obsidian
# young knoll Share code
val serialized: String = ItemStackSerializer.serialize(player.inventory.itemInMainHand)
player.sendMessage(serialized) // does not send
player.sendRawMessage(serialized) // does not send
player.sendMessage("Hello") // does send
player.sendRawMessage("Hello") // does send
Bukkit.getLogger().info(serialized) // does send

the serializer I am using: https://gist.github.com/slohth/1472498381b7f4d269af535f68302ff1

Gist

A quick and feature-rich serializer to convert ItemStacks into readable and modifiable Strings via json. - ItemStackSerializer.java

#

this is an example of the logged serialized string

#

it just does not send to the player

karmic bear
#

Hey it's my 1st time writing a plugin and was wondering if any of you would like to revise my code and/or organization in intellij?
I'd love to hear criticism and maybe some helpful tips from more experienced users

quaint mantle
#

gib code

junior briar
karmic bear
quaint mantle
#

verify when

young knoll
#

Verify

quaint mantle
#

!verify

undone axleBOT
#

Usage: !verify <forums username>

young knoll
#

Or upload it to git or whatever

quaint mantle
#

yeah

#

hist

junior briar
#

u might need to try a tellraw generator to create a raw message with correct syntax.

young knoll
#

Regardless of that, sendMessage should work

#

At least, I figure it would

keen obsidian
young knoll
#

Try stripping off the { }

karmic bear
#

i uploaded to dropbox

quaint mantle
#

imagine lul

#

just post codes where you want us to see in gist

#

i dont think anyone would download it just to check lol

karmic bear
#

uh

quaint mantle
karmic bear
#

ill verify my forum account real quick

#

nvm ive been verified

quaint mantle
#

you arent

#

!verify

undone axleBOT
#

Usage: !verify <forums username>

karmic bear
#

!verify SlamaPig

undone axleBOT
#

This account is already verified!

karmic bear
#

alright, seems good to go πŸ‘

keen obsidian
#

Perhaps Player#sendMessage just has an allergy to json format

quaint mantle
#

what are you trying to do first

#

@karmic bear

young knoll
#

Spigot (or minecraft) is probably trying to do something with it

karmic bear
#

well this plugin has no clear directive other than practice, mainly in efficient code and organization

#

I made a class to handle my itemstacks and another class for behaviours but not sure wether to lump them together or not

#

i treated it sorta like if I were creating a mod

keen obsidian
quaint mantle
#

you can just remove it because it is unnecessary

young knoll
#

You create a new ItemBehaviours each time

#

You shouldn't do that if you have no reason to

quaint mantle
#

oh yea

#

put it as a local variable or something

young knoll
#

As you are running on 1.17, you can quickly cast and check in one line

#

if (sender instanceOf Player player) { player.whatEver }

quaint mantle
#

not on minecraft 1.17, if you using java 16+ you can use patterns variables

#

oh yea

#

he is using java 16

young knoll
#

1.17 uses java 16

#

So there is no reason not to use it in your plugins

#
List<String> wandLore = new ArrayList<>();
wandLore.add("Β§cRight Click Anywhere To Create TNT!");

Just call setLore with Arrays.asList()

quaint mantle
#

dont use Β§ lul

#

just translatealternative color

young knoll
#

Or the enum

fleet imp
#

is it possible to change a non-static var to a static var

young knoll
#

Add static to it

quaint mantle
#

put static word

fleet imp
#

i made this dohickey but it still doesnt like it static long channel = nonStaticVAr;

young knoll
#

Well yeah, you can't declare it inline like that

#

You will have to assign it in the constructor or elsewhere

fleet imp
young knoll
#

But at that point, why is it static

fleet imp
#

Non-static method => non-static var = X > static var => static void

young knoll
#

What

fleet imp
#

thats kinda how my program is going

young knoll
#

It sounds to me like you are abusing static

fleet imp
#

bruh idk what im doing

young knoll
#

You really don't need to be using static for much

#

Constants, enums, purely utility methods are some good use cases

fleet imp
#

I'm trying to get a setting from getConfig and that works, but that's not static (and Spigot API made that very clear). I need to use that var in a "static context" but it doesn't let me

eternal oxide
#

You pass an instance of your main class not try to static access the config

#

?di

undone axleBOT
hybrid spoke
#

always bully the disabled

#

he is doing his best ok, leave him alone

junior briar
mighty sparrow
#

lets ping the admin

eternal oxide
#

You pass an instance of your main class to any class constructor where you want to access your config

fleet imp
#

wdym

#

oh

#

yea

eternal oxide
#

?di

undone axleBOT
fleet imp
#

i did that but it still doesnt work

#

this is the err I got Non-static field cannot be referenced from a static contex

eternal oxide
#

yes, because you should not be using static

#

access in a non-static way - Dependency Injection

fleet imp
#

but i need to do that for the method im doing

eternal oxide
#

no you don;t

brave sparrow
#

You cannot elevate a non static field or method to a static one

#

What are you actually trying to do

#

At a higher level

eternal oxide
#

You are trying to access it static because you don;t understand when to actually use static

fleet imp
#

im using the JDA to send messages from a specific channel to the minecraft chat

brave sparrow
#

Right

#

Why does that need a static context

mellow gulch
#

what? i've used JDA and i don't recall it needing static stuff

fleet imp
#

i have it check if the channel's id matches the one in the config file, but somewhere in there it says its static

#

BUT I DONT KNOW WHAT IT MEAAAANS

mellow gulch
#

static means global kinda.
static methods can be thought of as methods that belong to a class itself, and not instances of the class (object)

#

so a static method in a class doesn't have a this, and other such things.

eternal oxide
fleet imp
#

-_-

#

idk

#

i though i was

uneven dock
#

Hey everybody, I'm working on a network and the owner is looking to have something like this go on in chat. This is mineclub. Doing it with mods wouldn't be too difficult for a mod dev I would think but this is accomplished in vanilla. Any idea how they're doing it?

brave sparrow
#

JavaPlugin#getProvidingPlugin or getPlugin will give you a static instance of your plugin @fleet imp

fleet imp
#
public void onMessageReceived(MessageReceivedEvent event) {
    if(event.getChannel().getIdLong()==Main.ChannelID) {
            Bukkit.broadcastMessage(stuff);
    }
}
fleet imp
brave sparrow
#

The plugin has the config file

eternal oxide
#

You get the config via the plugin instance

young knoll
uneven dock
fleet imp
uneven dock
#

Tysm

brave sparrow
fleet imp
brave sparrow
#

No it will return the plugin

#

And you can get the config from that

eternal oxide
#

read teh DI link I gave you. Use DI correctly and you don;t need to getPlugin

olive lance
#

would it be fine to use import static org.bukkit.ChatColor.translateAlternateColorCodes;

eternal oxide
#

no thats a method call. You don;t import methods

olive lance
#

oh weird that it didnt give me any error for it then

#

i didnt test it tho

eternal oxide
buoyant viper
eternal oxide
#

GL?

buoyant viper
#

like opengl

#

or well, lwjgl mostly

eternal oxide
#

example?

buoyant viper
#

oh wait importing specifically a method ok nvm

eternal oxide
#

ok

mighty sparrow
#

ok

brave sparrow
#

You don’t have to import a static method but you can if you want to use it without specifying the class

olive lance
#

im starting a server to test rn

brave sparrow
#

It’ll work

olive lance
#

but i had thought so since i had no error compiling and such

brave sparrow
#

Yeah

#

It’s valid syntax

#

It means you’ll be able to do translateAlternateColorCodes() instead of having to do ChatColor.translateAlternateColorCodes()

#

That’s all

olive lance
#

Yea thats what i was going for

#

all i needed

brave sparrow
#

Yup that’ll do the job then

brave sparrow
#

It’s just statically importing all of them from the Math class instead of specifying one or two

#

It’s the same thing

eternal oxide
#

Yes, I'm wrong

#

I guess I was confused by doing a single method import

brave sparrow
#

Confused the heck out of me when you said they couldn’t do it and then linked an article saying they could, let me tell you

#

πŸ˜‚

eternal oxide
#

In all the years I don' think I've ever seen anyone static import a single method.

dark arrow
#

i need help

young knoll
#

?ask

undone axleBOT
#

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

olive lance
#

is there an api method for comparing and updating keys in resources config vs data folder config

dark arrow
#

i am trying too create method in java for c rafting recipe but since there are many not primitve data types i am getting confused

young knoll
#

?learnjava

undone axleBOT
young knoll
#

If you are confused by anything non-primitive, I highly recommend those links

dark arrow
#

when i went on last link and searched method it gave me awarnign the the link might not be safe

#

nvm it was safe

olive lance
#

From what im reading using saveDefaultConfig and copyDefaults will make sure that new options will get added to the plugins data folder config yeah?

sullen marlin
#

saveDefaultConfig is a dumb copy

quaint mantle
#

hey so im using better rtp plugin and it is taking 100 years for it to teleport you
any way how you can reduce the time that it takes to tp you to a random location

sullen marlin
#

copyDefaults will update from the default

olive lance
#

The docs on copydefaults are confusing i Cant tell if its saying it will overwrite values that were set by the server owner or not

#

just says they will be impossible to distinguish

sullen marlin
#

it wont overwrite

dark arrow
#

         item = new ItemStack(material,1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("Β§4Pro Armour");
        item.setItemMeta(meta);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,5);


        //proSword = item;

        sr = new ShapedRecipe(NamespacedKey.minecraft("pro_armour"),item);
        sr.shape("DDD"
                ,"EAE"
                ,"EDE");

        sr.setIngredient('D',Material.DIAMOND_BLOCK);
        sr.setIngredient('E',Material.EMERALD_BLOCK);
        ItemStack ingredient = new ItemStack(material);
        ingredient.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,4);
        sr.setIngredient('S',new RecipeChoice.ExactChoice(ingredient));

    },

  public static void createProHelmet(){

      Material material1 = Material.DIAMOND_HELMET;
      ItemStack item2 = new ItemStack(material1);
      ShapedRecipe sr2 = new ShapedRecipe(NamespacedKey.minecraft("pro_helmet"),item2);
      diaCraft(material1,sr2,item2);
      Bukkit.getServer().addRecipe(sr2);

    }
dark arrow
tidal skiff
#

is anyone online on 1.18.1 rn that can hop on a server for like 3 seconds?

tidal skiff
#

also //proSword = item; is commented out

tidal skiff
#

alr

dark arrow
#

i only sent the code where i think there is an error

dark arrow
#

oh yeah

#

thx

viscid ember
#

trying to get a player from PlayerDeathEvent and it seems i cant get the player

#

so im curious what i should do

summer scroll
#

getPlayer ?

viscid ember
#

yeah what about it?

#

Player player = e.getPlayer();

young knoll
#

What’s the issue?

viscid ember
#

its not working

#

oh wait

#

do i have to do getEntity()?

young knoll
#

Yes

#

You can see it returns a player

junior briar
#

πŸ€·β€β™‚οΈ

viscid ember
#

sometimes brain = powerful

dark arrow
summer scroll
young knoll
#

I mean

#

There is at least a reason for this one

viscid ember
summer scroll
#

might as well deprecate PlayerDeathEvent and replace it with EntityDeathEvent

young knoll
#

That already exists

#

PlayerDeathEvent is just for convenience

summer scroll
#

ik it exist, not surprised if that event will be deprecated in the future

#

just like the player pickup item event

tidal skiff
#

how do i convert Math.floor(tempTData.timer/3) to a string

#

i know its probably basic java but still

young knoll
#

Double.toString

#

Or Integer.toString, whichever it is

#

Or just append a string to it

lavish hemlock
#

you do String.valueOf(...)

#

appending a string to it has the possible side-effect of instantiating an entire string builder to append the value + the empty string, then returning the built string

#

( this is cuz string appending actually uses builders or dynamic calls when compiled )

young knoll
#

Sure, but I mean if you have actual text to append

lavish hemlock
#

well then sure

tidal skiff
#

so i have this thing that keeps the player in the air by teleporting them every tick and apparently this happens if you do that

young knoll
#

Yeah

#

That’ll happen

#

You can disable it in server.properties

lavish hemlock
#

Minecraft fly checks go brrrr

young knoll
#

Or set a barrier below them or something

flint carbon
#

Does anyone know why this does not do anything?

#
    public void onChat(AsyncPlayerChatEvent e) {
        e.setCancelled(true);
        Player player = e.getPlayer();
        getServer().broadcastMessage("" + ChatColor.valueOf("#eb4034") + player + ":" + ChatColor.AQUA + e.getMessage());
    }```

This is the full code
#

I'm trying to just make a simple chat formatter

young knoll
#

Have you registered it

flint carbon
young knoll
#

Have you registered the class as an event listener

flint carbon
#

i am a beginner, but this should work fine, right? public final class HexColors extends JavaPlugin implements Listener {

young knoll
#

No

#

You need to register the class

#

Via Bukkit.getPluginManager.registerEvents

flint carbon
dark arrow
dark arrow
#

?learnjava

undone axleBOT
olive lance
#

So using saveDefaultconfig as well as copyDefaults is not copying over missing fields

young knoll
#

saveDefaultConfig does nothing if the file already exists

olive lance
#

copyDefaults is still supposed to copy over the missing fields no?

young knoll
#

No idea

#

I honestly know very little about the defaults system

olive lance
#

its confusing

young knoll
#

I believe it only works if you’ve explicitly added defaults

#

Why not just read both files and copy any missing fields

olive lance
#

I was but then i read there was just this magic copyDefaults method to update it

#

But idk not working

#

hold up

young knoll
#

CopyDefaults looks to be a getter

#

Well, the one is

#

The other one that takes a Boolean is a setter

#

Which is very weird naming

olive lance
#

I know there is surely a way to achieve this with 1 method this is something any basic plugin would use

young knoll
#

Well if there is you could be able to find it

#

And if there isn’t you should make an issue/PR

olive lance
#

I think maybe I need to use Plugin.saveConfig after im going to try

#

yep that was it im dumb

young knoll
#

So that works?

olive lance
#

yep

#

like a charm

#

but heres something not working

#
    public void onPearl(ProjectileLaunchEvent e){
        if(!(e.getEntity() instanceof EnderPearl)) return;
        Player p = (Player) e.getEntity().getShooter();
        p.setCooldown(Material.ENDER_PEARL, (ConfigManager.PEARL_COOLDOWN*20));
    }``` also players are the only thing that throws ender pearls right
young knoll
#

Afaik yes

olive lance
#

the cooldown isnt being affected

young knoll
#

Probably need a 1 tick delay

olive lance
#

Yeah wondering if maybe could set priority and that would change it maybe? just wanna avoid that if possible

young knoll
#

No

#

The event runs before the vanilla code regardless of priority

olive lance
#

mm ok

dire ocean
#

Hey, what should be included in the plugin shutdown logic? (onDisable)

quaint mantle
#

nothing

#

if you want to

young knoll
#

Anything you need to do on shutdown

#

Saving data is the usual use case

dire ocean
#

Alrighties, I read somewhere someone was saying that plugins can cause memory leaks so I was wondering if it was related at all

#

Cheers

quaint mantle
#

Hey, I'm making something with Maven, and i have my resources folder setup, it reads .yml, .json, etc.

For some reason, my plugin.yml will not accept the fact that its api-version 1.18:

#

*I've compiled it several times now

mighty sparrow
#

verison

quaint mantle
#

oh god im idiot

#

πŸ’€

formal bear
#

lmao

mighty sparrow
#

HAHAHA

#

dont worry

quaint mantle
#

LMAOO

#

shouldnt it say if thats invalid?

mighty sparrow
#

this is the life of a developer

quaint mantle
dire ocean
#

youd think so

quaint mantle
#

lmfaoooo

#

ok thanks

#

goodbye LOL

mighty sparrow
#

its 3am

#

its ok

young knoll
#

Why should it

mighty sparrow
#

dont feel guilty

young knoll
#

That’s a valid key, it’s just not the key spigot expects

wet breach
# dire ocean Alrighties, I read somewhere someone was saying that plugins can cause memory le...

there is edge cases of this however with those edge cases generally it isn't the responsibility of your plugin to ensure objects related to your plugin are removed. But your plugin could create some kind of object on another plugin and due to that other plugins design have a flaw where your plugin doesn't bother telling it that its shutting down and now that other plugin has inadvertently leaked memory. But as I said in the beginning, in general or principle usually that shouldn't be the responsibility of your plugin to handle.

hot ibex
#

help pls
[02:36:54 WARN]: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'player' at row 1 [02:36:54 WARN]: at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104) [02:36:54 WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) [02:36:54 WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370) [02:36:54 WARN]: at com.vomarek.hideitem.data.database.MySQL.setState(MySQL.java:62) [02:36:54 WARN]: at com.vomarek.hideitem.data.PlayerState.setPlayerState(PlayerState.java:41) [02:36:54 WARN]: at com.vomarek.hideitem.events.EventsClass$1.run(EventsClass.java:90) [02:36:54 WARN]: at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) [02:36:54 WARN]: at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:58) [02:36:54 WAR

quaint mantle
#

guys i have a problem with EntityPlayer skins

#

no skin

young knoll
quaint mantle
young knoll
#

Make the column accept larger data

#

Or make the data smaller

quaint mantle
formal bear
#

how to make switch case from this please im idiot (intellectual diagnosed illness of technology)

mighty sparrow
#

right click on if and click convert to switch statement

quaint mantle
hot ibex
young knoll
#

Idk, depends on your use case

#

Can you store smaller data without that causing issues

#

Or do you need to store bigger data for everything to work

rain ridge
#

Is there a way to update a scoreboard objective for all Players ever joined in the server? I tried looping over Bukkit.getofflineplayers and from OfflinePlayer getplayer but it doesn't work (getplayer returns nulls which is normal) and then getScoreboard...

dire ocean
formal bear
#

why its highlighted?

sullen marlin
#

Ask your ide

viscid ember
#

ay yo what?

quaint mantle
#

not 1 string

sullen marlin
#

Its broadcastMessage isn’t it

quaint mantle
viscid ember
#

yh

young knoll
#

Yeah broadcast is a different method

formal bear
#

thank you very much @quaint mantle @mighty sparrow

viscid ember
#

ape

#

ape monkey

formal bear
viscid ember
#

thank you guys

quaint mantle
#

guys why i cant change skin of an entity player (npc)
i put the value and signature in properties of the game profile
and enable the second layer in datawatcher
but the skins are steve and alex
but other plugins are showing the skin correct

mighty sparrow
#

You need to pay a 150$ license at microsoft inc

#

For it to work

quaint mantle
#

that was very funny

mighty sparrow
#

Lol

quaint mantle
#

that is not funny

#

that is true

#

wha

#

βœ…

#

no seriously

#

what should i do

#

that is true

mighty sparrow
#

I got the same.problem and went on another project

quaint mantle
#

i dont want to make the plugin public or anything

#

did you send the packet to player?

#

i was messing around lol

#

spawn

#

and add_player

mighty sparrow
#

Mb im tired

quaint mantle
#

spawn? dunno

#

metadata

#

i will send these

#

look at other plugin

#

dunno this

#

i think citizens open source?

#

im not good at reading others code

wet breach
quaint mantle
#

what ?

wet breach
#

there is a packet, think its the tablist packet that keeps track of the player skin in regards for other players

#

if you update the skin on the player object, you need to send the tablist packet(still not sure if this this the correct one) to everyone else so their clients update the skin they see

#

otherwise the alternative is for the person whose skin was changed to re-log

quaint mantle
#

what packet

wet breach
#

I told you what I think it is, there is the link above for the protocol specs

#

tablist packet

#

sorry if I am incorrect in remembering which packet it is

quaint mantle
#

PacketPlayOutPlayerInfo ADD_PLAYER ?

#

i send it

#

but REMOVE_PLAYER after it

#

cause i dont want it to be in tablist

#

let me remove it for a sec and test it

formal bear
#

forgor break; πŸ₯Έ

quaint mantle
#

ok i removed remove_player

#

and it worked but

#

what should i do to remove the npc from tablist ?

wet breach
#

at least you have more info then you did previously

#

anyways that tablist packet is used by the clients to know information about the players that join

#

for instance, what skin they have πŸ™‚

quaint mantle
#

but they are in tablist

wet breach
quaint mantle
wet breach
#

the packet just needs to be sent to the clients so that their client updates their info on a player mainly in regards to their skin

quaint mantle
#

does Biome not work anymore...?

quaint mantle
#

??????

#

literally 0 errors?

wet breach
#

and removing them

quaint mantle
#

it worked but some skins are not working i guess wrong value and sign

#

thanks anyways

wet breach
#

Well like I said you have more information to work with now

#

and a better idea where to look

formal bear
quaint mantle
#

no

#

the video i mean

#

not the post itself

tardy delta
#

So in my case, should i use a concurrenthashmap?

ivory sleet
#

Basically it uses some locks to make it thread safe for write operations in regards to the concurrency level you supply to it. What are you doing specifically?

wet breach
#

second, do you need concurrent access to the map?

quaint mantle
#

how should i use RegionAccessor to modify biomes of locations?

#

i've tried new RegionAccessor(), no constructor.. and then i tried a static refrence of it like RegionAccessor.setBiome(my location, biome);

#

also didnt work, couldnt make a static refrence to it

sullen marlin
#

World implements it

#

But your issue is that specific biome was removed or renamed

quaint mantle
#

oh

#

i thought it was a method issue xD

#

thank u

tardy delta
#

And if im ONLY writing async to the map do i need concurrency?

formal bear
#

how to delete lines of lore? i have few items and its adding itself to next lines

ivory sleet
#

Wat

ivory sleet
#

Like it just when some process executed on another thread than some other thread

#

However if that process was to be executed on the "some other thread" then it’d be executed synchronously in respect to that thread

#

But yea let’s say you do write and read from the map from different threads

#

Take the common pool as our backing pool for instance

wet breach
# tardy delta Why not?

well it is generally bad practice to store objects when the object itself is not necessary to be stored. You can store the player object, you just need to ensure when the player leaves the server however you do indeed remove it from the map

ivory sleet
#

Having a ConcurrentHashMap would be crucial unless you go with the Collections::synchronizedMap which is extremely cumbrous

wet breach
#

otherwise lots of bad things happen πŸ˜›

tardy delta
#

It's just a kind of cache instead of querying the db every time

wet breach
#

And then for your cache mechanism, do note that Guava has caching methods too

#

in this instance, probably better to use Guava's methods in conjuction with your DB

#

will probably solve most everything in question XD

ivory sleet
#

I mean a normal ConcurrentMap could work just as good

tardy delta
#

That's just time based

ivory sleet
#

Yeah it’s more for expiring caches

wet breach
ivory sleet
#

Or if you need soft/weak keys/values

wet breach
#

@tardy delta take a look at Guava's methods never hurts to have options πŸ™‚

#

not saying you need to use them, but it could be more ideal

tardy delta
#

Uhh

#

Which things specifically?

wet breach
#

There is a few different methods available, take a look at them all. Not call caches need to keep the objects around all the time you know

ivory sleet
#

Well it has an automatic loading feature if you can supply a cache loader function

wet breach
#

sometimes it is ok to remove the object from memory if it really isn't being used

#

doesn't mean the object can't come back of course

#

just bring it back when its needed πŸ˜„

ivory sleet
tardy delta
#

After the user leaves

ivory sleet
#

Yeah well technically you could just unload and invoke your removal listener when the user disconnects

#

Altho I found it good to keep the user around a little bit after in case it’s one of those spam join-leave users

tardy delta
#

Yea i was querying the user for removal 5 minutes after he leaves but most of the times that was just unnessecary

#

Like they don't come back in that time

ivory sleet
#

Oh I just have a housekeeper/cleaner which I delegate cleanup to

#

Like it could be useful if you wanna create an api as well

tardy delta
#

So i should take a look at guavas cachebuilder

#

Hmm

ivory sleet
#

Not erasing users at disconnect if the user is being used by some api dependent

#

Tho that’s if this plugin of yours is gonna have such an audience

tardy delta
#

Nah

wet breach
# tardy delta After the user leaves

While this is generally acceptable for scaling purposes it starts to become necessary where you start removing objects not in use including player ones until they are needed in which case if you use Guava cache methods will bring back that key/value stuff automatically if its not present in the cache. This is also handy too because you don't need a separate load method to get objects in there, just invoke the cache.

ivory sleet
wet breach
#

as I said I am not saying in what you should or shouldn't use. I am merely giving you options so you can better decide what it is you want