#help-development

1 messages · Page 1413 of 1

dense goblet
#

I think a normal for loop would be easier

near crypt
#

@bright yoke but this does not work it expects a ;

bright yoke
#

huh?

near crypt
#

oh ik

#

okay it works

#

sry

#

😄

bright yoke
#

so in that loop, just teleport that someone

dense goblet
#
FileInputStream in = new FileInputStream(file);
ObjectInputStream objIn = new ObjectInputStream(in);

result.blocks = (Map<LocCoordinate, CustomBlock>)objIn.readObject();

intellij says im casting from Object to Map<LocCoordinate, CustomBlock> and highlights it yellow, is that normal with deserialising?

bright yoke
# near crypt okay it works
if (event.getCurrentItem().getType() == Material.BEDROCK) {
    Player target = (Player) event.getWhoClicked();
    Collection<Player> players = Bukkit.getOnlinePlayers();
    Location location = target.getLocation();

    for (Player someone : players) {
        someone.sendMessage("§f" + target.getName() + "§a hat dich zu ihm teleportiert");
        someone.teleport(location);
    }

    target.sendMessage("§aAlle Spieler wurden zu dir teleportiert");
    target.closeInventory();
}
``` so it'd end up something like this
#

idk that language, im just guessing thats the right text

bright yoke
#

but yes generally with deserializing that usually pops up

dense goblet
#

how do you suggest serialising

#

I want to be space efficient where possible

bright yoke
#

yea ObjectInputStream is not going to be efficient in terms of space and speed

dense goblet
#

is it not just a bytestream?

bright yoke
#

i'd make my own serialize/deserialize methods

#

nah there's lots of metadata and it uses reflection, which is pretty slow in java

near crypt
#

i have figured it out before you sent me this but thx 😄

dense goblet
#

oh wow that sucks

#

hm

bright yoke
#

so uh

dense goblet
#

the problem is I need to serialise ItemMeta

#

it can be serialised into Map<String, Object>

eternal oxide
#

ItemStatcs are already serializable

dense goblet
#

how would I do that?

#

to convert it to a byte array for example

eternal oxide
#

you can just call serialize but it depends on how you are going to store teh data

dense goblet
#

yeah serialise gives Map<String, Object>, how do I turn that into a bytestream? I assume all the values should be serialisable (even if its not explicitly stated) but I don't know how to serialise an Object

#

aa this can be useful

eternal oxide
#

look at the link

bright yoke
#
public static void write(File file, Map<LocCoordinate, CustomBlock> map) throws IOException {
    try (DataOutputStream out = new DataOutputStream(new FileOutputStream(file))) {
        out.writeInt(map.size());

        for (Map.Entry<LocCoordinate, CustomBlock> entry : map.entrySet()) {
            LocCoordinate coordinate = entry.getKey();
            CustomBlock block = entry.getValue();

            // Handle serializing these
            out.writeInt(coordinate.getX());
            out.writeInt(coordinate.getY());
            out.writeInt(coordinate.getZ());
            block.write(out);
        }
    }
}

public static Map<LocCoordinate, CustomBlock> read(File file) throws IOException {
    try (DataInputStream in = new DataInputStream(new FileInputStream(file))) {
        Map<LocCoordinate, CustomBlock> map = new HashMap<>();
        int size = map.size();

        for (int i = 0; i < size; i++) {
            LocCoordinate coordinate = new LocCoordinate(in.readInt(), in.readInt(), in.readInt());
            CustomBlock block = CustomBlock.read(in);
            map.put(coordinate, block);
        }

        return map;
    }
}
#

i havent touched bukkit in years, i forgot how itemstacks were serialized

dense goblet
#

is there a difference between using BukkitObjectOutputStream and DataOutputStream?

bright yoke
#

ah BukkitObjectInputStream

#

well yes

#

BukkitObjectInputStream will try to use the bukkit config serializers before defaulting to default java

bright yoke
dense goblet
#

I think for those I can use what Elgar linked 🙂

bright yoke
#

remember that ObjectInputStream is generally worse at everything

dense goblet
#

since it looks like BukkitObjectOutputStream.writeObject(ItemStack) works

#

and I guess same for ItemMeta

#

since its contained within a stack anyway

bright yoke
#

i would create a BukkitObjectOutputStream just for serializing an itemstack but continue using the data streams for everything else

dense goblet
#

okay, I'll give it a go, thanks both of you!

eternal oxide
#

Location is serializable the same way. ItemMeta will be serialized with the ItemStack

dense goblet
#

im using a local location which is just 2 bytes and a short, plus the CustomBlock only stores an ItemMeta with no need for a stack, so it should be even easier 🙂

eternal oxide
#

You can make your custom classes seralizable by bukkit

dense goblet
#

so if I pass one into BukkitObjectOutputStream that's how it serialises it?

eternal oxide
#

yes

dense goblet
#

sweet

#

is it worth using GZIP to compress chunk data or is the cpu overhead not worth it

visual tide
#

if i do player.getInventory() or player.getEquipment() with perworldinventory will i get the inventory or equipment of the world the player is currently in?

stone sinew
#

Its their current inventory inventories don't affect that.

visual tide
#

so the one if the world they're in atm

stone sinew
#

Yes

visual tide
#

ok thanks!

torn oyster
#

what should i extend if im making a custom player class

#

oh wow thats a lot of people typing

chrome beacon
#

CraftPlayer but why don't do that

ivory sleet
#

Probably wrap it instead? I mean kotlin on the flip side has some features such that you wouldn’t need to wrap it.

torn oyster
#

whats wrong with making a custom player class

ivory sleet
#

The api is not made extendable, especially for CraftPlayer

#

I mean we have certain interfaces which are extendable but yeah

chrome beacon
#

Yeah it's not designed to be implemented on your own

#

Better to just store a player reference

torn oyster
#

true

#

thanks

quaint mantle
eternal oxide
#

Caused by: java.lang.NoSuchFieldError: NOTE_BASS
TutorialListener.java:21

quaint mantle
#

oh welp

#

ty lol

dense goblet
#

hmm does ChunkLoadedEvent not get called on spawn chunks?

eternal oxide
#
    @EventHandler
    public void onItemHeld(PlayerItemHeldEvent event){

        Player player = event.getPlayer();
        int slot = event.getNewSlot();

        if(player.getInventory().getItem(slot) != null && player.getInventory().getItem(slot).getType() == Material.STICK) {
            // code here
        }
    }```
eternal oxide
dense goblet
eternal oxide
#

not unless those chunks get unloaded

dense goblet
#

so I guess I need to manually call it for chunks loaded at world start

eternal oxide
#

What are you trying to do?

dense goblet
#

read back from the file we wrote to

#

when a chunk is loaded, its appropriate file is read and it loads custom block data into memory

#

it works really well except for spawn chunks after restart

eternal oxide
#

What do you do with this custom block data?

dense goblet
#

implement blocks with custom functionality

eternal oxide
#

custom look or?

dense goblet
#

nope

#

they can just run custom code

#

I guess you could do custom look with armour stands tho

#

but that would be laggy

eternal oxide
#

are these blocks passive unless interacted with?

dense goblet
#

so far yes but I plan to add ticking blocks too (for machines etc)

#

right now just testing that they can persistently store custom data and that is working well

#

i.e. if I have a block of silver with a randomly-assigned "quality" tag of 0.8, it does not re-roll the quality every time I mine it and put it back down

eternal oxide
#

You can simply check after your plugin has loaded getWorld().getLoadedChunks()

dense goblet
#

sounds like that'll work, ty 🙂

quaint mantle
#

After I learn Java will I still need to watch Youtube tutorials on how to make plugins?

dense goblet
quaint mantle
#

What forums posts?

dense goblet
#

didnt watch any videos, they tend to be not too concise in my experience

ivory sleet
#

If you know java then you don’t need YouTube frankly

dense goblet
#

hmm seems like WorldLoadEvent isn't getting called at startup

#

my plugin might be being enabled after the world is loaded

ivory sleet
#

Register the listener onLoad

dense goblet
#

instead of onEnable?

ivory sleet
#

Yeah

dense goblet
#

im getting this error:

#

[12:27:51] [Server thread/ERROR]: Plugin attempted to register kaktusz.kaktuszlogistics.world.WorldEventsListener@70e5599e while not enabled initializing KaktuszLogistics v1.0 (Is it up to date?)
org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register kaktusz.kaktuszlogistics.world.WorldEventsListener@70e5599e while not enabled

#

ohh I need to change the yml right

eternal oxide
dense goblet
#

ayy that works ty!

limpid veldt
#

How do I get the effects of a potion itemstack? like if I have a lingering pot or a regular potion, how can I get a list of the effect objects

#

looked at the Deprecated Potion class but it did not work with lingering pots

#

tried PotionMeta potionMeta = (PotionMeta) item.getItemMeta(); and potionMeta.getCustomEffects but it always had nothing in it

#

suggestions?

#

all the spigot/bukkit forums posts are like 2017/2018

#

also looking for a way to get the potion effect of tipped arrows too but ill leave that for another day

sullen marlin
#

look at the other methods in PotionMeta

#

customeffects is not what youre after

spring river
#

Hello, GameProfile modifications are reset when i'm reconnecting please ?

lilac dagger
#

you have to do the modifications again upon reconnection

spring river
#

Ok, thanks ! 😄

limpid veldt
#
potionMeta.getBasePotionData().getType(). //stuff here//```
#

suggestions?

coral sparrow
#

Hello, how do i reopen a inventory after it is closed by a player

eternal oxide
#

InventoryCloseEvent

coral sparrow
coral sparrow
eternal oxide
#

no

coral sparrow
#

huh

#

oh

quaint mantle
#

hey spigot people! can you gimme particleparm example?

PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(**Here**, (float) (loc.getX() + x), (float) (loc.getY() + y), (float) (loc.getZ() + z), 0, 0, 0, 0, 1); 
``` How to use particleparm?

```public <T extends ParticleParam> PacketPlayOutWorldParticles(T var0, boolean var1, double var2, double var4, double var6, float var8, float var9, float var10, float var11, int var12)``` It's method of packetplayoutworldparticles
#

T var0

#

btw, I know how to use generic type in java

ivory sleet
#

Looks like the particle type or smtng no?

sullen marlin
#

There is no reason to use packets for particles, use the damn api

stiff topaz
#

Cannot resolve symbol 'senderName'

opal sluice
#

You need to instantiate the String out the if statements

hybrid spoke
#
String senderName;
if(asdka) {senderName = ""} else { senderName = ""}
getConfig()....
hybrid spoke
eternal oxide
#

return true from your onCommand

mellow zephyr
#

hi i made a spigot forge server and its crashing

eternal oxide
wraith rapids
#

hi i made a spigot forge server and its crashing
and nobody was surprised

quaint mantle
quaint mantle
young knoll
#

Locate it?

quaint mantle
#

yaa

#

the damn api has no locat

#

.spawnParticle(Particle.BARRIER, 5)

stiff topaz
#

How would I detect something like /mycommand -p (args) <--

young knoll
#

The API has locations?

maiden thicket
maiden thicket
maiden thicket
#

oops nvm hes faster

#

lol

young knoll
#

It has a ton of overloads

quaint mantle
# maiden thicket wdym ?

The Damn API: .getLocation().getWorld().spawnParticle(Particle.CLOUD, dropBait.getLocation(), 5);

And packet:
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(**How to do**, true, (float) (loc.getX() + x), (float) (loc.getY() + y), (float) (loc.getZ() + z), 0, 0, 0, 0, 1);

young knoll
#

The API has a ton of overloads

#

I don’t see what your issue is

maiden thicket
#

whats the difference

#

what

#

u dont need packets for particles

#

the api provides a bunch of ways to spawn them already

quaint mantle
solemn shoal
#

[SpigotAV] Loaded class net.thearcanebrony.spigotav.Main from SpigotAV v1.0 which is not a depend, softdepend or loadbefore of this plugin.

#

something seems off there

maiden thicket
quaint mantle
#

the spawnParticle has

maiden thicket
#

huh?

#

locate?

quaint mantle
#

Particle type, particle location, particle amount

#

and

maiden thicket
#

ur spawning it at a location

#

just use that location

quaint mantle
#

wait

maiden thicket
quaint mantle
young knoll
#

No you don’t

maiden thicket
#

the helix particle can be done with api

#

ive used that exact same guide

quaint mantle
#

spawnParticle ?

maiden thicket
#

with the api

#

yes

quaint mantle
#

Hmmmmm

#

how did you do?

solemn shoal
#

hm my server hangs on plugin load

mellow zephyr
#

hey im back

solemn shoal
#

can anyone help me figure it out?

mellow zephyr
#

and i deleted the mod

solemn shoal
#

ill post code in a sec

mellow zephyr
#

and its still crashes

wraith rapids
#

still the wrong channel

severe folio
mellow zephyr
#

wait what

#

damint

#

sorry

solemn shoal
#

wrong server too? lol

wraith rapids
#

it's forge bukkit or something

#

it crashing comes as a surprise to no-one

quaint mantle
#

Why is the ServerClients green and the other class is blue?

solemn shoal
#

also 1.7.10

solemn shoal
#

blue means uncommitted

quaint mantle
#

ohh okay

solemn shoal
#

hm

wraith rapids
#

if it's hanging on something, just take a jstack and see where it is

solemn shoal
#

how can i take a jstack?

wraith rapids
#

with jstack

solemn shoal
#

how?

quaint mantle
#

i have problem with my main class? i cant import it in all classes? it says not found or smth like that but it exists

solemn shoal
#

huh..

wraith rapids
#

have you tried importing it

solemn shoal
#

yikes jstack lol

quaint mantle
#

i did

wraith rapids
#

it's not listed as an import in your screenshot

quaint mantle
#

i click import class nothing happened

crude charm
wraith rapids
#

import it manually i guess

solemn shoal
#

its stuck on String.Replace?

wraith rapids
#

it's probably repeatedly doing string.replace

quaint mantle
wraith rapids
#

try restarting the ide

#

it's 2021 but developers are retarded and can't make caches work properly

severe folio
solemn shoal
#

i think i found it lol

#

its me trying to replace colors

#

looking for prefix ~# but never actually replacing the prefix itself

quaint mantle
#

ty

solemn shoal
#

still hung

#

tfw i dont get what im doign wrong

wraith rapids
#

use Matcher

solemn shoal
#

?

wraith rapids
#

doing that manually is inefficient and dumb

solemn shoal
#

never heard of Matcher

wraith rapids
#

like the core class of java standard libraries when it comes to working with regular expressions and strings

solemn shoal
#

ah

#

~#[0-F]{6}

#

regex 100

severe folio
#

my hex pattern is different but idk if its the best

#

this is mine

private static final Pattern HEX_PATTERN = Pattern.compile("&#([A-Fa-f0-9]{6})");
wraith rapids
#

depending on the assumptions one makes about character ranges, either works

severe folio
#

fair

solemn shoal
#

how can i correctly use Matcher?

wraith rapids
#

0-F might prove to have some issues if there are unexpected characters between 9 and A

solemn shoal
#

right

#

also didnt use a group

wraith rapids
#

you read the dox and then you invoke the right methods in the right order

solemn shoal
#

(~#[0-9A-F]{6})

wraith rapids
#

it's much easier to use on java9

solemn shoal
#

this would be better no?

wraith rapids
#

yes

solemn shoal
#

also note to self, dont try to instantiate Matcher

wraith rapids
#

yes, most of the regex related shit in java uses factory methods

solemn shoal
#

i was hoping this'd work but no, cant instantiate Matcher: java new Matcher(Pattern.compile("~#[0-F]{6}"), text).replaceAll(matchResult -> new RGBColor(matchResult.group().substring(2)).getAnsiColor());

wraith rapids
#

pattern.matcher

#

or match

#

i don't remember

#

and don't re-compile your pattern every time

#

precompute it and reuse the compiled pattern

#

also, instead of doing group().substring

#

define a group that only includes the characters you want

#

~#([0-F]{6})

solemn shoal
#

ah

wraith rapids
#

then just grab group(1)

spring river
#

Hello, it's possible to detect if a **Player **instance is the correct instance of the Player (not an old instance saved before re-connection of the player) please ?

wraith rapids
#

player.isOnline would return false for such an instance probably

solemn shoal
spring river
#

No :/

solemn shoal
#

yeah that seems to match pretty well

eternal oxide
#

Don;t store Player object. Store UUID and get teh player as required

wraith rapids
#

but you never really want a situation to happen where you have stale player instances

#

always key stuff by either UUID or name and if you do hold onto player instances, evict and discard them on disconnect

spring river
#

Thanks for your help and your time ! Have a nice day

solemn shoal
#

what'd be the correct way to it with java 8?

wraith rapids
#

you can't use the lambda thing

solemn shoal
#

seems to work fine?

wraith rapids
#

in java 8

#

so you would have to like create a string builder and manually pipe substrings of the original string into it with your replacements in between

solemn shoal
#

oh wait nvm

#

im compiling for java 11

wraith rapids
#

yeah that'll blow up on 8

solemn shoal
#

yeah

severe folio
wraith rapids
#

it is yes

#

but in java 8 most of the standard library methods don't accept them as parameters yet

solemn shoal
#

but it wasnt added everywhere at once lol

severe folio
#

oh right i get that

wraith rapids
#

f.e the replaceall thing that takes a lambda for Matcher was introduced in 9

severe folio
#

fair enough, i didnt know that

wraith rapids
#

before that you needed a while matcher.hasNext loop and manually juggling the substrings around

solemn shoal
#

how can i iterate over all matches in a string?

proven sierra
#

without the substringing

solemn shoal
#

no i mean, with java 11

wraith rapids
#

wut

solemn shoal
#

if i have this in a single string im passing it

wraith rapids
#

replaceAll replaces all instances of the found pattern

#

meaning your lambda is called for each found instance

#

it's not exactly iteration, but your code does run for each match

solemn shoal
#

oh its for each full match, not for every group

#

i see

wraith rapids
#

find the keyword and then take all of the args after it

solemn shoal
#

org.bukkit.plugin.InvalidPluginException: java.lang.IndexOutOfBoundsException: No group 1

wraith rapids
#

maybe the first group is 0

#

although generally with regex the 0th group describes the entire match

#

i don't remember how java handles it, see the dox

solemn shoal
#

oh like, its not couting ~# as a group?

wraith rapids
#

~# is not a group

#

it's not wrapped in ()

solemn shoal
#

ah

vast phoenix
#

Hey I have an issue some classes sometimes don't of my custom plugins it's really weird, I don't ever reload, I always restart.

Caused by: java.lang.NoClassDefFoundError: nl/blackminetopia/minetopia/modules/player/gui/AdminToolGUI
        at nl.blackminetopia.minetopia.modules.player.commands.AdminToolCommand.execute(AdminToolCommand.java:52) ~[?:?]
        at nl.blackminetopia.minetopia.util.interfaces.CommandHandler$1.execute(CommandHandler.java:93) ~[?:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:152) ~[patched_1.12.2.jar:git-Paper-1618]
        ... 14 more
#

When I decompile the jar the class is really there I just think this is really weird.

severe folio
#

are you using Eclipse

vast phoenix
#

Nope I'm IntelliJ

chrome beacon
#

Is it in the right package

vast phoenix
#

Yes it is but the weird part is

#

when I restart my server it sometimes is gone or it just stays the same

#

after a few restarts it's gone I just really don't get it anymore

#

have been trying this out for weeks

wraith rapids
#

classloading is hard

vast phoenix
#

what could be the issue?

eternal oxide
#

is it your plugin you are accessing or a separate plugin?

vast phoenix
#

my plugin

eternal oxide
#

all the classes are in your one plugin?

vast phoenix
#

the only classes that have this exception thrown are my own classes

#

yes

wraith rapids
#

super difficult to try and diagnose classloading issues remotely

#

it could be that the class blew up while it was being initialized

#

make sure there are no static blocks or something that could explode in that class or the classes it refers to

eternal oxide
#

Usually due to instancing classes at creation

vast phoenix
#

Should I just send my class here I can show you

wraith rapids
#

and make sure no other plugin is trying to access this class

eternal oxide
#

?paste

queen dragonBOT
vast phoenix
#

just the class that is throwing this exception

vast quest
#

how can I get the players cps

eternal oxide
#

the class thats throwing the error and the class that is missing.

wraith rapids
#

are you trying to rank 1.8 players in proficiency

vast phoenix
#

this is a old class tho

#

I use just one static method

#

to open a custom gui

lyric vigil
#

Hey im looking to join a project. DM me if you are a new community looking to get off your feet.

wraith rapids
#

write me a crates plugin

#

i'll send you feet pictures

eternal oxide
vast phoenix
#

uh

#

A lot

#

all the sub menus import it

#

and one Listener class

#

this is that Listener class

eternal oxide
#

show your AdminToolCommand.java

vast phoenix
#

Ok

sick portal
#

Hello everyone, for storing IDs and relations in a database, would you recommend using the player UUID as a primary key ? (premium only)

#

Or would you rather create a generated and ID and associate the player UUID ?

wraith rapids
#

you should use their horoscope as the primary key

solemn shoal
#

not sure what went wrong here

eternal oxide
#

Well, your code is quite a spiders nest. My best guess is something in your command handler/AdmintoolGUI is not being released onDisable.

sick portal
wraith rapids
#

they probably won't

#

if they did, every server would be massively fucked

#

and you would have bigger issues than just your plugin database

minor garnet
#

guys, I’m going to repeat a problem that I was yesterday, but I don’t have time to solve

sick portal
#

I suggest you use a paste tool

minor garnet
sick portal
minor garnet
#

ConnectionSQL.loadAll().stream().forEach(e -> LootManager.loot.add(e)); this can my problem ?

ivory sleet
#

Feels unnecessary to stream if the higher order function after that just is forEach and btw method reference is possible there if I’m not wrong?

minor garnet
#

yes i know of it

eternal oxide
minor garnet
#

I was doing some tests

vast quest
#

How can I get the cps of the playert

minor garnet
#
    public static void spawnLoot(Location local, ItemStack item) {
#line 67        ArmorStand armor = local.getWorld().spawn(local, ArmorStand.class);
        
    }```
chrome beacon
vast quest
#

how

#

Interact event?

minor garnet
#

I debugged and saw that the location was not null and neither the item stack

#

i don't know if because I gave a for each to add everything to the hash, and when I use the runnable it may be that I haven't loaded all the data

young knoll
#

The interact event would work

#

If you want to be fancy you would listen for the packets

chrome beacon
#

^^

hybrid spoke
solemn shoal
hybrid spoke
solemn shoal
#

does anyone have an idea why all of my text is dark gray?

vast quest
young knoll
#

Persist it somewhere

#

Like a database

vast quest
#

how

wraith rapids
#

what is the raw string result

chrome beacon
vast quest
#

I know how to store a varuable but not how to store a varuable after a restart

solemn shoal
#

config

young knoll
hybrid spoke
chrome beacon
#

Ah you want persistant data storage

young knoll
#

Ideally don’t persist in yml

solemn shoal
hybrid spoke
#

one of my plugins fully concentrates on the CPS of a player^^

solemn shoal
#

im storing based on current tick, and averaging the last 20 ticks

wraith rapids
#

use a rolling average

solemn shoal
#

?

#

anyways

#

my colors dont work and i hate it

wraith rapids
#

what is the raw string output

solemn shoal
#

its using ansi color

wraith rapids
#

yes but what is the raw string output

solemn shoal
wraith rapids
#

and what is the raw string input

solemn shoal
#

i should probably log that..

#

one second

#

this is the colors it instantiates:

#

my color test seems to work fine

rotund pond
#

Wow nice one

solemn shoal
#

wait lemme run 0-255 instead of 0-128

#

oh

rotund pond
#

Just, what's the point of that ?

hybrid spoke
solemn shoal
#

testing my color system

rotund pond
#

Okok 👍

stiff topaz
#

In my code Prefix is defined in a for statement. How can I use it outside of the for statement

                    for(String arg : args) {
                        if (arg.contains("-p")) {
                            Bukkit.broadcastMessage(ChatColor.RED + arg);
                            Prefix = arg.replace("-p", "");
                            Bukkit.broadcastMessage(ChatColor.BLUE + Prefix);
                        }
                        if (arg.contains("-s")) {
                            Bukkit.broadcastMessage(ChatColor.RED + arg);
                            Suffix = arg.replace("-s", "");
                            Bukkit.broadcastMessage(ChatColor.BLUE + Suffix);
                        }
                    }
                    // Send Broadcast
                    Bukkit.broadcastMessage(Prefix + messageToBroacast + Suffix); // I want to use Prefix here !

solemn shoal
#

something seems odd here

#

yikes file too big

hybrid spoke
solemn shoal
#

how can i have an unsigned byte?

hybrid spoke
solemn shoal
#

fair

stiff topaz
solemn shoal
#

just doesnt make sense in my head to represent the 3 color channels als integers

stiff topaz
#

The blue text is from the if statement

solemn shoal
#

as in like, a waste of memory lol

stiff topaz
#

The red is not

#

Ill put the code

wraith rapids
#

just perform your math operations on the byte after you've cast it to int and masked with & 0xFF

#

and then trim back to byte

solemn shoal
#

bruh

#

making everything an int fixed all my issues lol

hybrid spoke
solemn shoal
wraith rapids
#

that said you don't need to do that for + operations, and for - operations only if your unsigned byte is the right hand operand

stiff topaz
#
                    String Prefix;
                    String Suffix;
                    Prefix = getConfig().getString("Prefix");
                    Prefix = ChatColor.translateAlternateColorCodes('&', Prefix);
                    Suffix = getConfig().getString("Suffix").replace("%sender%", senderName);
                    Suffix = ChatColor.translateAlternateColorCodes('&', Suffix);

                    // Custom Pre/Suffix
                    for(String arg : args) {
                        if (arg.contains("-p")) {
                            Bukkit.broadcastMessage(ChatColor.RED + arg);
                            Prefix = arg.replace("-p", "");
                            Bukkit.broadcastMessage(ChatColor.BLUE + Prefix);
                        }
                        if (arg.contains("-s")) {
                            Bukkit.broadcastMessage(ChatColor.RED + arg);
                            Suffix = arg.replace("-s", "");
                            Bukkit.broadcastMessage(ChatColor.BLUE + Suffix);
                        }
                    }
                    // Send Broadcast
                    Bukkit.broadcastMessage(Prefix + messageToBroacast + Suffix);```
solemn shoal
#

its actually working now lol

#

tho it seems to be ignoring a digit

hybrid spoke
young knoll
#

Isn’t a short between a byte and int in terms of size

#

16 bits I assume?

solemn shoal
#

no idea

wraith rapids
#

yes

solemn shoal
#

i think so

wraith rapids
#

same size as char

#

but char is unsigned, short is signed

limpid veldt
wraith rapids
#

yatopia

solemn shoal
#

@limpid veldt ^

hybrid spoke
#

thanks now i have an epileptical attack

limpid veldt
#

running yatopia o_o

#

f

wraith rapids
#

die

solemn shoal
#

yes yatopia

#

its what i had lying around so /shrug

limpid veldt
#

the purpur devs have stepped into the room with bats

solemn shoal
#

afaik theres purpr devs in their discord lol

stiff topaz
minor garnet
#
    @EventHandler
    public void PlayerInteractEvent(final PlayerInteractEvent event) {
        if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            final Player player = event.getPlayer();
            final Location eye = player.getEyeLocation();
            final Vector direction = eye.getDirection().multiply(10);
            final Location ping = FinalCatch(eye, direction).add(0,  -1.5, 0); 
            getClosest(ping, 0.5).ifPresent(e -> Bukkit.broadcastMessage(e.toString()));
            ping.getWorld().spawnParticle(Particle.END_ROD, ping.add(0, 1.5, 0), 0, 0, 0, 0);
        }
    }```
stiff topaz
solemn shoal
#

pretty colors

minor garnet
#

in the execution of this code is it possible that it is called twice?

wraith rapids
#

yes

#

interact event is called twice

stiff topaz
wraith rapids
#

once for each hand

stiff topaz
#

This obviously shouldnt look like that

wraith rapids
#

first for the main hand, then for the off hand

#

iirc that's the order

minor garnet
#

how do i get it to run once

wraith rapids
#

you ignore the second run

minor garnet
#

but how ?

hybrid spoke
#

check the hand

wraith rapids
#

with logic

minor garnet
#

checking a hand ?

limpid veldt
#
pos1
method();
goto pos1;
solemn shoal
#

oh..

ivory sleet
#

Plugman 🎈

solemn shoal
#

i know lol

#

im too lazy to restart the server

ivory sleet
#

Tbf same

summer scroll
#

all of plugins installed on test server has javaassist warning or something.

#

why's that?

solemn shoal
#

because theyre all malware

#

lol

#

but yes, i intentionally installed malware on my server

summer scroll
#

really?

solemn shoal
#

yep

summer scroll
#

so my server have a malware right now

solemn shoal
#

not your server lol

#

these are just plugins submitted from the yatopia discord

summer scroll
#

i mean the mc plugin yeah

#

but it doesn't change anything in-game.

#

i don't see any effects

solemn shoal
#

well yeah

#

the malware i have installed is just a backdoor

ivory sleet
#

SpaceDash which one is the malplugin?

solemn shoal
#

?

#

how do you mean malplugin?

ivory sleet
#

Malware plugin

#

If that’s more clear

solemn shoal
#

anything aside SpigotAV

#

thats installed on my test server

ivory sleet
#

Oh thought there was one plugin which injected the rafael stuff into other plugins

solemn shoal
#

oh it does it on its own

#

but not on windows

ivory sleet
#

Ah

viscid oasis
#

Does anyone know how can I remove NPC from tablist?

#

My code to initialize NPC packets:

#
            connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
            connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw * 256 / 360)));```
quaint mantle
#

how do i get the cpu load and usage in bungee?

hybrid spoke
quaint mantle
#

idk

hybrid spoke
timber crescent
#

how would i do something every 10 kills

quaint mantle
#

ty

hybrid spoke
quaint mantle
timber crescent
quaint mantle
#

show the kill counter

timber crescent
#

it adds every time you get a kill to a mongodb document

hybrid spoke
quaint mantle
#

okay and whats the problem?

#

ty

proper notch
hybrid spoke
#

or just store the kill count local, add it every 10th kill to your mongodb, reset it and do your thing

lusty cipher
#

Would you guys say it is a bad idea to send any OP user a ingame message if the plugin is outdated everytime they join?

wraith rapids
#

depend on permissions

#

and add a config setting to turn it off

#

other than that it's fine

lusty cipher
#

ok thanks, cause theres a bunch of servers using quite outdated versions so yeah

limpid veldt
#

How do I get the effects/strength/duration a potion has from an itemstack?
The Potion class was deprecated and does not work for lingering pots

wraith rapids
#

that's just a symptom of quite a few servers being run by tards

limpid veldt
# solemn shoal

also why on earth would you install malware on your server

solemn shoal
#

because spigotav

#

lol

#

im working on an antivirus so i need test samples

limpid veldt
lusty cipher
#

add a seperate permission or just check if the user has op permissions

eternal oxide
#

leave your update messages in the logs. Its annoying to be harassed.

lusty cipher
#

That's what I thought too. However a) admins don't look at logs too carefully and b) a config setting to turn it on/off should be quite ok, no?

eternal oxide
#

If they don;t look at the logs they should not be running a server

lusty cipher
#

🤷‍♂️
Mind telling that to 80% of all the servers that run my plugin and use a version that is 3 months old? lol

#

Eh I'll just leave the setting off as default in the config, if anyone wants it they can turn it on I guess

eternal oxide
#

If they are using a 3 month old version, it works for them. They don;t need harassing

#

Notify in teh logs so they see it when they decide to update

limpid veldt
quaint mantle
#

how do i get max storage of spigot server?

wraith rapids
#

the same way you would get the max storage of any environment

#

it's a system/environment property, not something specific to the minecraft server application or spigot

quaint mantle
#

oh okay

#

just check world.getnearbyentites.isempty

#

bcz if if remember its list

torn shuttle
#

anyone happen to know if scraping data from the spigot website is against spigot TOS? I'd like to collect data to get some basic dl trends but not if it is against the rules

#

not site-wide, just for my projects

lusty cipher
torn shuttle
#

oh that does look good

#

thanks

#

I assume getting that is fine

lusty cipher
#

yeah using that is fine and has download data aswell

#

And scraping data from the website is most likely against tos lol

torn shuttle
#

yeah all I want to know is the daily dl rate

main dew
#

How use FernFlower Decompiler?

limpid veldt
#

intellij has it built in

#

easy way:

  • rename the .jar to a .zip extension
  • navigate to the .class file and double click it
  • intellij does the rest
main dew
limpid veldt
#

its close enough for most things

quaint mantle
#

or use luyten or jd-gui

limpid veldt
#

occasionally converts foreach into Iterators and while loops but apart from that its great for stealing source code fixing dead plugins

torn shuttle
#

gaze upon my class name and despair EnderDragonPotionBombardmentConfig

limpid veldt
#

long ass class name

wraith rapids
#

still better than VillagePlace

limpid veldt
torn shuttle
#

EnderThing1

#

EnderThing2

#

..

quaint mantle
#

yes

fickle helm
#

does anyone know if there an API to query what these values are set to in spigot.yml?

  attribute:
    maxHealth:
      max: 2048.0
    movementSpeed:
      max: 2048.0
    attackDamage:
      max: 2048.0```
limpid veldt
#

which one is better

quaint mantle
#

i use luyten mostly

wary harness
#

So need suggestion I am making tools need specific list of enchants to execute code
what would be the best way if tool has all enchant which are on white list

#

just for loop

#

and if one is false brake loop and return

torn shuttle
wary harness
#

or is there any better way to compare

#

to list

torn shuttle
#

np, it's one of the first lines in my plugin which I just happened to have open

#

also have code to change it if you want it

fickle helm
#

that's ok, I just needed to know the value. Until today I thought it was a hard-coded value and I had my plugin never allow more than 2048 max health to prevent an exception

torn shuttle
#

it's not hard coded and a lot of people run with values under it

#

I bump it up to 10mil

rotund pond
#

Hello !

I'm trying to make a class that allows you to redo some small spigot features on the configurations (like the SaveDefaultConfig () method).

Do you have any idea how I will be able to check if the configuration sections in the plugin match those in the plugin file?

torn shuttle
#

as in scan for changes?

rotund pond
#

not really
I just want to be able to add non-existing section configurations to avoid getting a "nullpointerexception" when I add configuration options

#

something like

wraith rapids
#

use defaults

rotund pond
#

defaults ?

wraith rapids
#

configurations have defaults

torn shuttle
#

yeah defaults are a key feature for these

wraith rapids
#

if a value is absent in the user-provided file, the default value is used

#

the defaults are loaded from the config.yml you bundle in your jar

torn shuttle
#

you can also save defaults pretty decently

wraith rapids
#

you can also manually set defaults with the methods on ConfigurationSection

torn shuttle
#

it will write to file if it doesn't exist but will use existing values if it does

wraith rapids
#

just keep in mind that saving configs in any way will nuke all comments

rotund pond
#

So I have to do something like this ?

torn shuttle
#

hm

wraith rapids
#

load the bundled resource as a yaml configuration

#

there is a method to bulk-set defaults from an existing configuration section

#

use that to apply all of the contents of your bundled messages.yml as defaults

torn shuttle
quaint mantle
#

yes

wraith rapids
#

load the bundled resource as a configuration, then load the user-provided file on disk as a configuration

#

then apply the contents of the former as defaults to the latter

rotund pond
wraith rapids
#

that's basically what bukkit does with config.yml under the hood

rotund pond
#

xD

#

Gonna read this, thank you so much !

torn shuttle
#

sure

#

not claiming it's perfect but it works really well for me and my need to create hundreds of config files

#

that wasn't a joke

rotund pond
#

Nice thank you ^^

#

Yeah I understand, but the beginning of your sentence was funny

torn shuttle
#

I just counted, my production server has 660 config files for my one plugin

wraith rapids
#

add 6 more

torn shuttle
#

devilish

rotund pond
torn shuttle
#

it's a boss plugin and each boss has a config file

rotund pond
#

Aaaaaah

torn shuttle
#

and each piece of custom loot has a config file

rotund pond
#

ok now i understand xD

#

Another question, I know how to edit a file from the plugin folder, but how I can edit a file from the plugin himself ?
For example, let's say I want to do a playerdata in the plugin itself (like essentials). How to get this file and then edit it?
I don't understand what method i should use

torn shuttle
#

it's not as bad as it used to be since now they work based off of blueprints and no longer require 1 file per individual mob since they can put multiple locations on a single file

#

which is good because there's thousands of them now

rotund pond
torn shuttle
#

it's not that great

#

but I figured it could help you

quaint mantle
#

lemme try

rotund pond
torn shuttle
#

be careful about which file saver you use, only defaults will erase any non-default values and custom values will let you use whatever is on the file

quaint mantle
#

oh yeah i know why

#

bcz when you try to do it checks for players too

lusty cipher
#

how can I get the item that is being dropped in BlockBreakEvent?

torn shuttle
#

are you close to yourself

#

iterate through the result

#

compare the entity to the player

wraith rapids
#

pass it a Predicate that doesn't accept players

torn shuttle
#

for (Entity entity : player.getNearbyEntities(player.getLocation(), 5, 5, 5){if (player.equals(entity)) {...}}

#

think that should probably work

eternal night
#

player.getWorld().getNearbyEntities(player.getLocation(), 5, 5, 5, e -> !player.equals(e)) probably works better

#

following NNY's suggestion

rotund pond
wraith rapids
#

or for (Entity entity : player.getNearbyEntities(player.getLocation(), 5, 5, 5, (e) -> !(e instanceof Player)) {...}

#

the former only discounts the player

#

the latter discounts all players

lusty cipher
wraith rapids
#

cool

rotund pond
quaint mantle
torn shuttle
#

pretty sure entities can't be null there

quaint mantle
#

oh sorry all is a player

torn shuttle
#

allPlayers I guess

#

oh wait couldn't be that

quaint mantle
#

with what

torn shuttle
#

mind you if you are scanning for the lack of entities none of these are what you want to do lol

#

also keep in mind dropped items are entities

#

and armor stands and stuff

wraith rapids
#

probably want to instanceof livingentity if you don't want stuff like items or paintings

#

that said armorstands are fucking living entities for some reason

rotund pond
#

Another question, I know how to edit a file from the plugin folder, but how I can edit a file from the plugin himself ?
For example, let's say I want to do a playerdata in the plugin itself (like essentials). How to get this file and then edit it?
I don't understand what method i should use

wraith rapids
#

YamlConfiguration.loadFromFile(File file) or something

rotund pond
wraith rapids
#

define inside the plugin

#

in the plugin jar? no

rotund pond
torn shuttle
#
boolean hotSinglesInYourArea = false;
for (Entity entity : player.getNearbyEntities(player.getLocation(), 5, 5, 5){
if (entity.equals(player)
continue;
if (entity instanceof LivingEntity){
hotSinglesInYourArea = true;
break;
}
if (hotSinglesInYourArea){
awooga();
}
}
wraith rapids
#

you don't want to be reading and writing into your plugin jar at runtime

#

the whole thing will explode

rotund pond
#

oh

wraith rapids
#

essentials doesn't store its things in the jar

#

it's all in the plugin directory

rotund pond
#

How does Essentials work then?
There was a time when they stored everything inside the plugin I think

eternal oxide
#

no

wraith rapids
#

player.getWorld().getNearbyEntities(player.getLocation(), 5, 5, 5, e -> !player.equals(e)).isEmpty()

torn shuttle
#

wait, that's illegal

wraith rapids
#

yes

#

just keep in mind that it will return false if there is literally anything

#

including but not limited to paintings, invisible armor stands, area of effect clouds, xp orbs and more

torn shuttle
#

lightning

#

very very frightning

dense goblet
#

Is there some utility to damage an item without having to re-code all the unbreaking logic etc?

sharp bough
#

is there way of checking the depth of getKeys true?

#

i dont know the player id and i cant get it

#

i do know tho the format

#

so its always this

#
    playerID:
        '1': 5
        '4': 12
    OtherPlayerId:
        '2': 6
        '2': 10```
#

theres activeBeds . a player id wich i dont know . 1 , 2,3, etc the amount of beds the player has

wraith rapids
#

what are you doing

sharp bough
#

so if depth of the key is 2 (wich means that its activeBeds(0),playerID(1).num(2)) then edit it

wraith rapids
#

what

sharp bough
#

wich i cant get

wraith rapids
#

literally what are you saying

sharp bough
#

cuz its the id of the player and i need to edit all players in the config file

sharp bough
wraith rapids
#

iterate over all of the keys

sharp bough
#

i have activeBeds wich have playersID and each player has X amount of numbers

wraith rapids
#

getKeys(true) is like entirely useless unless you want to print the contents of the config to console or something

#

if you want to iterate over all of the players in your config, go to the ConfigurationSection that contains them, and call getKeys(false)

#

each of the returned keys will point to a ConfigurationSection that holds whatever you've put in it

torn shuttle
#

boy this is probably not a good way of doing this lol

#

it looks like you should know what the ids are so you can just do a get for the value and see if it's null

quaint mantle
#

how do i change spigot messages like bungee has the messages.properties file?

lusty cipher
#

can I get the item from BlockBreakEvent or will I have to spawn it myself

dense goblet
#

you should use e.getBlockState @lusty cipher

lusty cipher
#

that has literally nothing to do with my question

dense goblet
#

what is your question?

#

you did not specify which item

#

there are multiple items involved

lusty cipher
#

There's only one item (type) that is being dropped. The other thing is called a block

dense goblet
#

there is:
the item being dropped
the item corresponding to the block itself
the item in the player's hand

quaint mantle
#

Is there a way to set a scoreboard in a specific area? I already did the scoreboard, I only need the area stuff

torn shuttle
#

assign the scoreboard when they enter, remove it when they leave

quaint mantle
#

I know but I want to set the Area in the Scoteboard. As example: Area: Auction House

eternal oxide
lusty cipher
#

But I guess the answer is: I'll have to spawn the items myself

lusty cipher
wraith rapids
#

drops in bukkit are fucked

torn shuttle
sharp bough
#
                    for(String Key : String.valueOf(Objects.requireNonNull(Main.get().getConfig().getConfigurationSection("activeBeds")).getKeys(false))){
                        
                    }```
why did this work yesterday and not today?
lusty cipher
#

I need the block state, which is an air block in the other event

dense goblet
#

spnda if you want help you should consider showing some basic respect to those you're asking to help you

sharp bough
#

since when i cant use foreach in strings

wraith rapids
#

what

eternal oxide
torn shuttle
wraith rapids
#

again, literally what

torn shuttle
#

not asking for support for featherboard or smth

quaint mantle
wraith rapids
#

you are calling String.valueOf on a Set

#

or a List

#

or whatever

#

and then trying to iterate over that String as if it were a Set or a List

#

String.valueOf makes things into strings

#

you can't iterate over a String

torn shuttle
# quaint mantle No lol my own

well first you'll have to define a bunch of regions, then it's as simple as checking where the player is when they get the board and making sure that you construct it with the adequate string for the location

wraith rapids
#

a String is not a Collection, it's not Iterable

quaint mantle
torn shuttle
#

that's really up to you

quaint mantle
#

I mean I can’t just go block by block

#

That takes too long

torn shuttle
#

if we're talking the easiest possible way do something like xMax xMin zMax zMin populate it with numbers and then check if the player's location is contained within that

wraith rapids
#

or depend on WorldGuard

lusty cipher
dense goblet
#

to minimise how many areas you iterate through

eternal oxide
wraith rapids
#

depends on how many areas you have

quaint mantle
young knoll
#

It says it will be the state before the block is destroyed

lusty cipher
wraith rapids
#

lol

young knoll
#

Gets the BlockState of the block involved in this event before it was broken.

wraith rapids
#

what are you even arguing about

lusty cipher
#

It was AIR when I printed it

#

🤷‍♂️

eternal oxide
#

The Block is already broken as this event is called, so #getBlock() will be AIR in most cases. Use #getBlockState() for more Information about the broken block.

wraith rapids
#

are you sure you didn't call e.getBlock().getState

dense goblet
#

just store a sparse list of AABBs, then iterate over them and check if player coords are within the bounds

wraith rapids
#

if you can find a decent resource or a guide on worldguard without having a fucking aneurysm, you could maybe just depend on worldguard

#

saves you the effort of managing the configuration and defining of regions

#

and lets end users use a familiar way to define them

timber crescent
eternal night
#

looks like an incomplete stacktrace. Anything past this ?

timber crescent
#

nope just that

quaint mantle
#

try like removing some code and try to see which thing causes it

eternal oxide
eternal night
#

you wanna look for something along the lines of caused by Exception after that stacktrace

#

maybe check further up the log, some loggers tend to shorten these if configured incorrectly

wraith rapids
#

doing db queries on inventory click event

eternal night
#

who knows, maybe it is cached :>

timber crescent
#

oh its that Caused by: java.lang.NullPointerException at cc.solarpvp.solarkitpvp.mongodb.MongoDB.getLevel(MongoDB.java:157) ~[?:?] at cc.solarpvp.solarkitpvp.SolarKitPvP.loadEmeraldKit(SolarKitPvP.java:100) ~[?:?] at cc.solarpvp.solarkitpvp.event.MenuListener.onClick(MenuListener.java:29) ~[?:?] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[?:?] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-Spigot-db6de12-18fbb24] ... 15 more

timber crescent
eternal night
#

👀

wraith rapids
#

yes

quaint mantle
#

whats on line 157 in MongoDB.java

wraith rapids
#

db queries are potentially very slow

vernal basalt
#

how can i get the location of a player who isn't on

wraith rapids
#

why am I getting a NPE in a line# that is in a fucking javadoc comment

timber crescent
#

thats the whole method public int getDeaths(String uuid) { Document document = new Document("UUID", uuid); Document found = getPlayerInfo().find(document).first(); if(found != null) { Document var1 = new Document("UUID", uuid); return var1.getInteger("deaths"); } return 0; }

quaint mantle
#

and what is the 157 line

timber crescent
#

its the return var1.getInteger

quaint mantle
#

and does the "deaths" exist in mongodb collection?

timber crescent
#

ill check i might of named it something else

#

i never made it lmao

quaint mantle
#

xd

#

thats why you gettin npe

raw swallow
#

is there a way to make custom mob animal tamer?

wraith rapids
#

a what

raw swallow
deft sedge
#

?paste

queen dragonBOT
near crypt
#

how can i send a player a message when the player clicks a specific head?

raw swallow
#

can anyone help me?

quaint mantle
near crypt
#

but how to check for the head?

#

for the specific head? by the name or what?

#

@quaint mantle

quaint mantle
#

get its itemstack check its material if its skull and then get the item meta convert it into skullmeta and get the owning player and then check if the owning player is the name u want

wraith rapids
#

depends on your definition of "specific"

#

texture? owner? location?

near crypt
#

texture

#

not the owner this is the Porblem

#

problem

#

how can i check the texture? @wraith rapids

wraith rapids
#

get it from the skull

#

and compare

near crypt
#

how from the skull?

wraith rapids
#

you can get it from like the gameprofile or something

#

i don't remember how you do it on spigot

#

easier on paper

near crypt
#

okay

quaint mantle
near crypt
#

thx 😄

main dew
#

I try decompile .jar use FernFlower decompilator. Who can help me?

dense goblet
#

I added item damage logic myself but the item does not automatically break when its durability falls to 0

#

instead if goes negative

#

is there a way to call the item break event

quaint mantle
#

you could just remove the item ig

dense goblet
#

yeah I could do that, play the sound and do the particles

quaint mantle
#

yeah

dense goblet
#

thought there might be an inbuilt way

#

how do I get the correct location for particles?

wraith rapids
#

i'm sure there is a way to call that properly

dense goblet
#

looking on google gives me nothing :/

#

i can take a look at forge source

past glen
#

so I have a custom item called the wither sword, to craft it you need 2 nether stars and a netherite sword, how can I make the custom item have the same enchantments as whatever sword was used to craft it?

eternal oxide
#

you copy them in the CraftItemEvent

wraith rapids
#

the way how it'd be implemented internally would be through the ComplexRecipe or whatever that was called

past glen
#

k

wraith rapids
#

but that's not intended for implementation by plugins

#

so you just need to hack around it

past glen
#

k

#

so could I copy the enchantments from the og sword onto the crafted sword?

wraith rapids
#

in the event, yes

raw swallow
chrome beacon
raw swallow
chrome beacon
#

Don't cast your mob to entity

#

That doesn't work

raw swallow
#

And how i set my mob animal tamer?

chrome beacon
#

You cast your mob to the entity type it is and then set the owner

quaint mantle
#

Hi my plugin cant reach too messages? they are just blank but theyre not null?

chrome beacon
quaint mantle
#

the result is l: xd: false

raw swallow
quaint mantle
#

the l should be whats inside the config but its blank

#

its bungeecord btw

chrome beacon
#

They cannot be tamed

raw swallow
#

I try to tame an horse with a custom mob skeleton

chrome beacon
#

Yeah that would be why

#

Only players can tame mobs

raw swallow
#

And there is a way to male mobs tame horse?

river spear
#

If I place gravel now why doesn't it stay in the air?

@EventHandler
  public void onPhysics(BlockPhysicsEvent event ) {
         event.setCancelled(true);
       
  }```
eternal oxide
#

Try watching the EntityChangeBlockEvent instead

quaint mantle
#
        for (UUID member : sgPlayer.getParty().getMembers()) {
            OfflinePlayer memberPlayer = Bukkit.getOfflinePlayer(member);
            if (memberPlayer.isOnline()) {
                Bukkit.getPlayer(member).sendMessage(ChatColor.BLUE + "bababooey");
            }
        }```
#

is this a good way of doing things?

eternal oxide
#

you can just memberPlayer.getPlayer()

quaint mantle
#

oh, didn't know that.

#

because Bukkit.getPlayer(uuid) will return null if the player isn't online right

loud swift
#

and if you are doing that check for every message it seems a bit inefficient

#

maybe cache the online members for each party or something

quaint mantle
#

It's a partychat command

wraith rapids
#

getOfflinePlayer can make a network request to mojang api to figure out the name and stuff of that player

#

which can take a long time

loud swift
#

I'd hold a map <PartyUUID, Set<Player>> and on message get the right set and send the message to everyone

wraith rapids
#

ideally each Party object would have a Set of online players in a field somewhere

quaint mantle
#

but that'll go to shit when the player logs off right

wraith rapids
#

you'd maintain them with the join/quit events

loud swift
#

no, because on login and logout you just update the map

eternal oxide
#

its a UUID lookup for OfflinePlayer. That shoudl not perform a Mojang lookup

wraith rapids
#

iirc there's a line on the dox that says it can ring up mojang api

#

otherwise it won't know the offlineplayer's name

quaint mantle
#

I thought it only rings up that api call when the player has never logged in

ivory sleet
#

Yeah thats correct nny

wraith rapids
#

paper has a getOfflinePlayerIfCached method which doesn't do that call

eternal oxide
#

Only if you lookup by name

wraith rapids
#

but it will return null if the uuid-name isn't cached

eternal oxide
#

a lookup by UUID is only local

ivory sleet
#

I mean getOfflinePlayer(UUID) never calls it but getOfflinePlayer(String) may make the request because to both methods an offline player for every name/uuid will exist

eternal oxide
#

It will always return an OfflinePlayer but the name will be null if its unknown

quaint mantle
#

right now this is what I've got for the command itself

#
    public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
        Player p = (Player) sender;
        if (args.length == 0) {
            p.sendMessage(ChatColor.RED + "Invalid message. /pc <message>");
            return true;
        }
        BlitzSGPlayer sgPlayer = BlitzSG.getInstance().getBlitzSGPlayerManager().getBsgPlayer(p.getUniqueId());
        if (sgPlayer.getParty() == null) {
            p.sendMessage(ChatColor.RED + "You're not part of a party.");
            return true;
        }
        for (UUID member : sgPlayer.getParty().getMembers()) {
            OfflinePlayer memberPlayer = Bukkit.getOfflinePlayer(member);
            if (memberPlayer.isOnline()) {
                memberPlayer.getPlayer().sendMessage(ChatColor.BLUE + "Party > " + sgPlayer.getRank(true).getPrefix() + p.getName() + (sgPlayer.getRank(true).getPrefix().equalsIgnoreCase(ChatColor.GRAY + "") ? ChatColor.GRAY + ": " : ChatColor.WHITE + ": ") + joined(args).replaceAll("%", "%%"));
            }
        }
        return true;
    }```
#

The caching thing will probably also work but oh well

eternal oxide
#

Thats fine as you are using UUIDs, but I'd move the definition OfflinePlayer memberPlayer out of the for loop

quaint mantle
#

How would I get the player object then

#

OfflinePlayer in this case

eternal oxide
#

I'd also construct the message once and send it each time.

quaint mantle
#

Yep I just did that

#

but how would I retrieve the OfflinePlayer from the UUID without Bukkit.getOfflinePlayer

eternal oxide
#

you use Bukkit.getOfflinePlayer(UUID)

#

It won;lt query Mojang and you will always get an Object back

#

your test for isOnline is all you need

raw swallow
#

how i can set a player automatically ride an horse ?

quaint mantle
#

but that's what i'm doing right now isn't it

eternal oxide
#

yes

#

Its fine

quaint mantle
#

oh

#

yeah you said you'd move the definition of it outside of the for loop

#

so I thought you were suggesting another way of doing this

eternal oxide
#

yes, define it before so you are just assigning a value each iteration

#

defined in the loop you are creating a new instance every iteration

quaint mantle
#

Yeah that's what it's supposed to do, it's assigning the iterated value

eternal oxide
#

define before for loop with OfflinePlayer memberPlayer;

quaint mantle
#

Ohhh.

eternal oxide
#

in the loop you do memberPlayer = Bukkit.getOffline

quaint mantle
#

Right right

#

Is that even an improvement?

#

nevermind, you're 100% right.

#

thanks Elgar

tame iron
#

there is a task to translate the name of the subject into another language. Is there any way to do this using the game if I initially get the name in the form of a string?

sharp bough
#

whats a fancy way of setting a gui size based on a number? like if the number is 4 then the gui size set to 9, but if the number is 23 then the gui size has to be 27

#

i dont wanna do if else etc

eternal oxide
#

Math

glass sparrow
#

idk if that will work

#

but something like that

eternal oxide
sharp bough
#

haha nice

empty roost
#

I saw that, XP bar and hotbar differently sending by server, or whatever you call it. Then is it possible to use XP bar in creative mode?

young knoll
#

I assume the client just skips rendering it

#

So probably not without a mod

empty roost
#

I don't think so, I saw a thread in SpigotMC but I couldn't find it

#

but easiest example is on Hypixel. there are previews for cosmetics, when you preview them, it puts you to first person spectator mode and then your inventory goes. after you leave the preview mode, firstly your xp bar comes and then your hotbar/heart/food bar comes.

main dew
#

How can I lock the head with a specific texture on creative?

sage swift
#

what

main dew
#

I want block skull with name "Raymano"

chrome beacon
#

Cast item meta to SkullMeta and set the owner

#

oh wait it's a block?

#

or just the item?

main dew
#

yea but how block add this to inventory