#help-development

1 messages · Page 73 of 1

charred blaze
#

please?

rough basin
#

Can OnclickEvent and BlockPlaceEvent.setCanceled be used at the same time?
I have to execute the code without being placed when I right-click on LANTERN.

eternal oxide
#

If you want to set a value for muted you need it as a field in the class not a local variable

charred blaze
#

i know its weird

#

field?

eternal oxide
#

however you can;t get the value of muted until its been set, and you won;t know when that happens

#

why are you not simply checkign litebans for muted when they try to talk?

tardy delta
#

ah yes

charred blaze
charred blaze
eternal oxide
#

yes, why use a runnable? it should be memory persistent data from litebans.

charred blaze
eternal oxide
#

ah

charred blaze
tardy delta
#

lets create a cache lol

eternal oxide
#

are you checkign litebans every time they talk?

#

I don;t know litebans, does it have a mute setting?

charred blaze
#

everytime they talk, place signs, make books, join with nicknames, rename items

#

xd

quasi flint
#

i would adive

#

to cache that

#

and invalidate it every 5 min

#

and then reget it

shadow zinc
#

💵

quasi flint
#

just a runnable

#

that resets the field

distant wave
#

how can i update placeholder?

quasi flint
#

every 5 orso so munties

quasi flint
distant wave
# quasi flint could u be more specific?

i have placeholder in sidebar scoreboard (its smth like: Purse: %myplugin_coins%), if i die all my coins are divided by 2, but placeholder says still same value

agile anvil
#

Is it you who code the scoreboard?

distant wave
#

yes

#

wanna see the code?

tardy delta
#

anyone knows how to properly create a commandcontext in acf?

quasi flint
distant wave
quasi flint
#

i dont know

#

where u use placeholder api there

#

oh there u use it

distant wave
#

can i somehow update that placeholder

quasi flint
#

maybe with

#

objective.setScore();

#

if thats a thing

#

is it a thing?

distant wave
#

it is but thats not what i want

agile anvil
#

When the player dies, or at regular interval just call PlaceholderAPI.setPlace.... again

#

So you'll have to figure out how to update your scoreboard

tardy delta
#

ah managed acf to work

quasi flint
#

i would just

#

resend after death

#

to update it

distant wave
#

cool i figured out it

#

thanks

shadow zinc
#

Is an empty inventory slot null or air?

zealous osprey
#

null if you use Itemstack[]

shadow zinc
#

🆒 🌭

naive bolt
#

how can i make the public void createPlayer(Player player, Town town){ town to json?

#

i tried to use ```java
Gson gson = new Gson();
String j = gson.toJson(town);
plugin.getLogger().info(j);

tardy delta
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

naive bolt
#

the error is [10:08:21 ERROR]: Could not pass event TownAddResidentEvent to TownyMySQL v1.0 java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @5332f755

#

I want to make town into json or a string

tardy delta
#

?paste town fields

undone axleBOT
naive bolt
#

full stack trace ^

tardy delta
#

town having location?

#

gson doesnt know what to do with the locations WeakReference<World>

#

so write a typeadapter

naive bolt
naive bolt
#

basically im trying to store the whole town information in a sql database

tardy delta
#

uhh i hope youre not storing json into a database?

naive bolt
#

whats so bad with that

quasi flint
#

inefficient

#

as fuck

tardy delta
#

just create a storage implementation for a database

naive bolt
#

im not reading it again from the plugin its so i can just get town information on a discord bot

#

its not going to be constantly read

quasi flint
#

still

#

fucking huge

#

database gonna be big

naive bolt
#

maybe i just use independant things like name residents etc

tardy delta
#

and you gotta save your stuff in a very big varchar

#

which is not the point of a database

quasi flint
#

1 big varchar = bad

tardy delta
#

that town object is huge lmao

quiet ice
#

Say the people using yaml for flatfile storage

tardy delta
#

i'd create a townsettings class

quasi flint
#

if so where so i can punish myself

quiet ice
#

You certainly did at the very least

#

Everyone did that

young knoll
#

Pfft

#

I use images

quiet ice
#

that is too efficent if done right

vast raven
#

I'm having problems using CorpsReborn API, like getting the inventory on a corpse, if the event is cancelled, it will return null.

shadow zinc
#

How do is I make plugin ok

upper vale
shadow zinc
#

hmm

#

and what is a spigot

#

how much does it cost

iron glade
#

Is there a difference between #getServer()#getPluginManager() and Bukkit#getPluginManager() ?

tardy delta
#

no

#

Bukkit class delegates a Server object

iron glade
#

okay

echo granite
#

Hey, I'm trying to only include 1 class(XMaterial) during maven-shade-plugin, but the final jar is tiny... what am I doing wrong?

<filters>
    <filter>
        <artifact>*:*</artifact>
            <excludes>
                <exclude>com/cryptomorin/xseries/*</exclude>
            </excludes>

            <includes>
                <include>com/cryptomorin/xseries/XMaterial*</include>
            </includes>
    </filter>
</filters>
echo granite
eternal oxide
#
CompletableFuture.runAsync(...).thenRun( this runs on the original calling thread? );```
agile anvil
#

Yes

noble forge
tardy delta
#

is there a reason there is no PersistentDataType.BOOLEAN?

#

or are we supposed to use a byte?

eternal oxide
#

yes (byte) 1

#

Thanks

tardy delta
#

hmm would work ig, only forgot the set the meta back on the item

#

also wondering if ItemStack::hasItemMeta is the same as checking if the meta is notnull

#

ij doesnt seem to understand that

slate mortar
#

it looks like it validates it, and most likely returns false if it's null

dense pine
tardy delta
#

alr thanks

#

your map does not contains the entry you want

slate mortar
quaint mantle
#

Hello can someone help me with some Plot Plugin for Version 1.17?

slate mortar
#

or the entry specifically is set to null... afaik thats also possible

dense pine
#

but every player after joining gets assigned to hashmaps

dense pine
young knoll
#

getItemMeta will create it if it doesn’t exist

slate mortar
#

first

#

store their uuid's, not the entire player object

tardy delta
#

i can just check if the meta is notnull then 👍

slate mortar
#

second: which line does the error come from

dense pine
slate mortar
#

that doesnt help a single bit

#

i can't see what you have in line 92

dense pine
#

ive linked pastebin ;-;

slate mortar
#

in a class called aWelcome

tardy delta
dense pine
slate mortar
#

that code gives me a small but kinda dense headache ngl

dense pine
#

also when i reload the plugin while im on the server hashmaps seem to be okay

slate mortar
# dense pine

can you paste this as text? either in paste or here, idc

#

dont wanna write it all out by myself

dense pine
#

ive sent pastebin with my original message

tardy delta
#

that looks like the code i wrote nearly two years ago 👀

#

why dont you just have a map with the players uuid and an object that holds those three values instead of three maps

slate mortar
#

i honestly don't evne know what you're trying to achieve in the end

young knoll
#

What does it mean for a headache to be dense

quaint mantle
#

hey, I am trying to use Json to save custum data for a spigot plugin, I have some json knowledge however I have no clue how I can use java plugins to work with json

slate mortar
#

i have no idea

#

but it definitely is DENSE

tardy delta
slate mortar
#

if i'm not completely dumb

#

and i am

#
    public void test(PlayerJoinEvent e) {
        if (e.getPlayer().hasPlayedBefore()) {
            Bukkit.getOnlinePlayers().forEach(p -> {
                hasWelcomed.put(p, false);
            });
        }
        isNew.put(e.getPlayer(), !e.getPlayer().hasPlayedBefore());
        timeLeft.put(e.getPlayer(), getConfig().getInt("time", 0));
        hasWelcomed.put(e.getPlayer(), e.getPlayer().hasPlayedBefore());
        if (e.getPlayer().hasPlayedBefore()) return;
        e.getPlayer().sendTitle("§cWitaj na serwerze, §f" + e.getPlayer().getName() + " §c❤", "§7Życzymy miłej rozgrywki!", 20, 60, 20);
        e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_SPAWN, 1.0F, 1.0F);
    }```

this should be like exactly the same
#

correct me if i'm wrong

#

i'm tired af

rough basin
#

How to remove "Decoration Blocks"

slate mortar
#

you don't

#

it's rendered by the client

#

hardcoded for stuff like Tools, Food etc

drowsy helm
young knoll
#

^

rough basin
#

Thanks

quaint mantle
tardy delta
#

i mean why not using the builtin config file then?

dense pine
shadow zinc
#

Anyone know of or has some open source code that uses the luckperms api, I want to have a look at it to get a sense of how to integrate my plugin with luckperms, and yes I have read the docs and getting started, just want inspiration

distant wave
#

can i cancel sync repeating task

slate mortar
#

the question is.. why do you need like 20 hashmaps for that

drowsy helm
#

if its a bukkit runnable it's just cancel()

agile anvil
tardy delta
#

just google the lp wiki

shadow zinc
young knoll
#

Hook vault

distant wave
shadow zinc
#

😉

drowsy helm
tardy delta
#

that was my cat on my keyboard

shadow zinc
#

I'll hook your mum

shadow zinc
drowsy helm
#

or atleast it barely worked when i did it, a year or two ago

tardy delta
#

i hooked into luckperms in order to get the prefix of a group and change groups

dense pine
young knoll
#

Can’t say I’ve had any issues

#

Your dev is

shadow zinc
#

screw vault, anyone know of a project?

young knoll
#

Something…

dense pine
#

xD

slate mortar
#

i mean

#

maybe i'm really dumb

#

but why do you need a hashmap at all?

shadow zinc
#

🙏

slate mortar
#

if you just want to interact with the player(s) once

dense pine
#

hm?

young knoll
#

You need a Map<UUID, Pair<Boolean, Pair<Integer, Boolean>>>

quaint mantle
slate mortar
#

why tf does he need a map? what is the need of storing the player

quaint mantle
#

I am making a clan plugin

slate mortar
onyx fjord
#

whos he

slate mortar
young knoll
slate mortar
#

i don't even know what it means lol

shadow zinc
#

DID YOU JUST ASSUME X GENDER

dense pine
#

you did too mate

agile anvil
tardy delta
shadow zinc
#

I'll use x for gender of individual

quaint mantle
onyx fjord
tardy delta
#

check the docs for config files

shadow zinc
#

definitely not satire

quaint mantle
slate mortar
tardy delta
#

lol

slate mortar
#

i can't guess everything

#

i'm sorry

shadow zinc
#

😶

young knoll
#

I try to go with they

dense pine
#

Okay so how do it without hasmaps

tardy delta
#
BukkitWiki

The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...

dense pine
#

like i need to somehow store if player is new, if they welcomed already

quaint mantle
#
List<Bla> list = new ArrayList<>(){
  public final Bla test = add(new Bla());
};```
Erm why can't I access test here (using list.test)? it's public right?
I want to use this to create a list of elements for looping, but also be able to access individual items
**I know add doesn't return the item added, just for explanation**
onyx fjord
slate mortar
#

why do you need to store if the player is new?
that's what Player#hasPlayedBefore is for

onyx fjord
#

you can also count players since plugin was installed, by just adding uuids to array

shadow zinc
#

Anywho, whats the best way to get the instance of an api, such as handling the plugin not being enabled, different mc api versions etc

dense pine
#

okay thats a good idea and how about timer? Is there any sense to have an individual timer for each player? Or just one global timer that is triggered by joining of new player?

quaint mantle
tardy delta
#

i think he means in the config file

young knoll
#

Ah

#

Honestly an int is probably easier, just add 1 when a new player joins

agile anvil
quaint mantle
agile anvil
#

Isn't your code totally in red ?

quaint mantle
#

Wdym? xd

sterile token
#

Hi, Is there any alternative for YamlConfiguration but for Bungeecord api?

sterile token
quaint mantle
sterile token
quaint mantle
sterile token
#

Oh ok

#

Sorry mate

#

I thought you didnt know java

#

As you explain it

quaint mantle
#

I am bad at explaining for sure

#

Don't worry

#

xD

sterile token
#

Timar the problem is that you are using a prvate acess modified

#

Which doesnt allow using a method/field from an external. Class

#

Sorry but im on cellphone and i type prettt bad

#

I also not native english speaker i native Spanish speaker

quaint mantle
#

oh, Intellij told me that so I made it private.
It seems I have to add the generics to the constructor for it to work

tardy delta
#

he wants the item signature no?

sterile token
#

So he wasnt allowed to

quaint mantle
sterile token
#

And the problem was that he is using.a.Private access modifier instead of a public

#

Shity corrector

#

Lmao

quaint mantle
#

xD Thanks, it worked

quaint mantle
#

Hm another question, should I use a singleton for my managers, or instantiate in plugin class?

shadow zinc
#

don't do a singleton

quaint mantle
#

What is the problem with a singleton?

shadow zinc
#

answer in there

distant wave
#

yooo im here again, why this doesnt spawn the armor stand

quaint mantle
distant wave
shadow zinc
#

🙏

tardy delta
#

registered it?

shadow zinc
#

Any idea how to use the luckperms api to get the permission node of a command, yes I am reading the docs still

chrome beacon
shadow zinc
glossy venture
#

can i disable the extensive logging of every mf thread mongodb does

#

its spamming the console

shadow zinc
chrome beacon
#

and none do for sub arguments and such

shadow zinc
#

If I can hook into that then my problem is solved

chrome beacon
#

Then you need to run all commands

shadow zinc
#

It depends

chrome beacon
#

and what about per user perms

shadow zinc
#

Its only for commands, shouldn't that be irrelevant?

dense pine
#

How to stop a running task?

#

like there is a timer for 30 seconds and for example i want to stop it with a command whenever i want

#

Bukkit.getScheduler().runTaskLater(this, () -> rewardAvailable = false, time * 20L);

young knoll
#

Store the result of that isn’t a variable

#

And then do YourVariable.cancel

shadow zinc
hushed pawn
#

i want to add some stuff to nms classes there is any guides how to do that? I think it called patching isntit

young knoll
#

You basically need to make a custom spigot fork

hushed pawn
#

I found this, but im not sure if i can directly edit nms classes

eternal night
#

Forking spigot just always looks so fun

hushed pawn
#

I still don't really understand relationship in between spigot and bukkit

split lake
#

wasnt spigot just a fork of bukkit or sum

eternal night
#

Yea spigot is a fork of Bukkit but Bukkit is dead

#

Spigot, for whatever reason, still has a repo called Bukkit and craftbukkit that it maintains

#

And then applies spigot patched on top of those repos

split lake
#

damn

quasi flint
#

so

#

years old code

shadow zinc
#

🤨

eternal night
#

Some may say that

sacred mountain
#

years old code, if good code, no need to replace

rough basin
#

How to make Blue firework particle?

tardy delta
#

there is fireworkmeta afaik

rough basin
#

thanks

charred blaze
#

i lookd into litebans api and i want to first check if player is banned and if not ban him but there is one problem

    @Override
    public void run() {
        boolean banned = Database.get().isPlayerBanned(uuid, ip);
    }
}.runTaskAsynchronously(plugin);

new BukkitRunnable() {
    @Override
    public void run() {
        if (!banned) {
            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "example");
         {
    }
}.runTask(plugin);```
how can i get variable "banned" in another runnable?
shadow zinc
#

Why is this not running?

#
public class TabFunctionality implements Listener {
    @EventHandler
    public void onPlayerTab(PlayerCommandSendEvent e) {
        Bukkit.broadcastMessage("PlayerCommandSendEvent");
        for (String commandString : e.getCommands()) {
            Command command = Bukkit.getServer().getPluginCommand(commandString);
            Bukkit.broadcastMessage(commandString);
            if (command != null) {
                Bukkit.broadcastMessage(PermissionCheck.getPermission(command));
                if (!e.getPlayer().hasPermission(PermissionCheck.getPermission(command))) {
                    e.getCommands().remove(commandString);
                }
            }
        }
    }
}```
#

I've registered the listener but for the life of me I can't figure out why it doesn't work

charred blaze
#

idk but im using this PlayerCommandPreprocessEvent

grave charm
#

^ use that and cancel the event

shadow zinc
#

oof alright

grave charm
charred blaze
#

reason of why im getting boolean Asynchronously is that litebans throws exception if you do that on main thread

#

second runnable is that you need to run tasks as runnable or it will throw exception

charred blaze
chrome beacon
charred blaze
#

i just want to get "banned" variable

charred blaze
#

wait

agile anvil
#

You can use CompletableFuture task

tardy delta
#

why dont you cache stuff

chrome beacon
tardy delta
#

ew

agile anvil
grave charm
#

banned is only defined in the first scope, you need to declare it outside of the scope of the first runnable if you want to access it in another one

agile anvil
charred blaze
tardy delta
#

just use a cf or execute all your stuff async and go back to the main thread when the bool is found

#

why do people instantiate bukkitrunnables too :/

charred blaze
# charred blaze

The method runTask(Plugin, BukkitRunnable) in the type BukkitScheduler is not applicable for the arguments (new BukkitRunnable(){}, BukkitRunnable)

charred blaze
tardy delta
#

instead of creating the scheduler

chrome beacon
charred blaze
chrome beacon
tardy delta
#

all that nesting stuff looks weird

chrome beacon
#

Yeah it looks messy but if done right it works

chrome beacon
#

Do it just like you did the first time

#

Just move it in to the other one

tardy delta
#

scheduler looks much cleaner in my eyes

charred blaze
#

first time?

#

wdym

tardy delta
#

that code hurts my eyes

charred blaze
charred blaze
chrome beacon
#

?scheduling

undone axleBOT
chrome beacon
#

Choose one way of calling the scheduler don't try to mix two

tardy delta
#

also you need ::replace instead of ::replaceAll

chrome beacon
#

^

tardy delta
#

replaceall works with regex

#

replace just does what it says, replace the string

quasi flint
#

Regex slow

#

Isn't it

young knoll
#

Terrible naming

agile anvil
#

No

tardy delta
#

ye

young knoll
#

Should have been replaceRegex or something

agile anvil
#

Of course if you need to replace a char it's slower, but it's actually the most optimized string searching

charred blaze
agile anvil
#

Well, except some special cases

chrome beacon
charred blaze
chrome beacon
#

That's all

#

Don't change it

charred blaze
chrome beacon
#

Yeah that's what you're supposed to do

#

and that's what you didn't do

tardy delta
#

uhh whats actually the problem

quasi flint
#

Professional ignoring

chrome beacon
charred blaze
#

so

#

you are saying that

#

to move second runnable

#

in first one right?

chrome beacon
#

Yes

charred blaze
#

so like this?
new BukkitRunnable() { @Override public void run() { boolean banned = Database.get().isPlayerBanned(uuid, ip); new BukkitRunnable() { @Override public void run() { if (!banned) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "example"); { } }.runTask(this); } }.runTaskAsynchronously(this);

chrome beacon
#

Yes

tardy delta
#

this is it basically?

#

damn that looks ugly

#

kinda stupid that PersistentDataContainer::remove doesnt return a boolean

chrome beacon
#

PR time

tardy delta
#

never done that lol

eternal night
#

I don't think you can do that anyway

#

You'd break ABI

#

Or actually

tardy delta
#

whats abi?

eternal night
#

Application binary interface

tardy delta
#

hmm yes

young knoll
#

Spigot doesn’t like changes that effect existing plugins

#

No idea if changing the return type would break old jars

charred blaze
tardy delta
#

lmao just removed it

#

overtype it

#

not too much work

rough basin
#

how to modify block of Particle.BLOCK_CRACK

flat ravine
#

Hi! Do you know how to add heads in Deluxe Menus?

tardy delta
#

lets just do it like that then

charred blaze
#

says this

tardy delta
#

uhh put smt between the brackets ig

charred blaze
grave charm
#

you need to pass an instance of the plugin as well, not just the class

tardy delta
#

i dont see any errors lol

charred blaze
#

screened it

#

and

#

errors dissapeared

#

WAT

agile anvil
#

We're wizards

#

that is why

charred blaze
#

@agile anvil

#

can you stop that spell please

chrome beacon
#

Probably missing a }

agile anvil
#

am I watching eclipse?

chrome beacon
#

Yes

agile anvil
#

That's why there are so much bad spells around

charred blaze
charred blaze
#

i just saved it now

#

and errors dissapeared

chrome beacon
#

Eclipse moment 🗿

agile anvil
# chrome beacon Probably missing a }

^ (I hated that IDE because of this, you can't learn from your errors cause you can't understand where they're from... So when I began programming that was a pain)

charred blaze
#

;-;

agile anvil
dusk flicker
#

not really an emoji

charred blaze
#

i heard that looping all players in skript was laggy

#

will this be laggy too?

#

for example on 100 players

agile anvil
#

Well, it's not free in term of performance. But if you need to reach all players at once, there is always a time you have to loop them all

#

In that case it's not laggy if it's just some times

#

But to broadcast a message use Bukkit#broadcastMessage

#

instead

charred blaze
#

is there any other way to send message to all players online with permission "example"?

charred blaze
agile anvil
#

Loop all of them and send if they have permission

young knoll
#

Bukkit.broadcast

charred blaze
#

isnt that laggy?

sterile token
#

Does Bungeecord api have any alternative for the YamlConfiguration from Spigot????

charred blaze
sterile token
#

Oh which

charred blaze
#

same?

sterile token
#

I want the class name which i should extends

young knoll
#

Bukkit.broadcast goes to all players with the specified permission

#

One line

shadow zinc
#

hot

charred blaze
#

as i remember

sterile token
#

That why but thanks Greened!

agile anvil
sterile token
#

Oh ok

#

Because im trying to find the bungeecord file magnament class which you use it for loading files and doing CRUD operations (Create, Read, Update and Delete)

echo basalt
charred blaze
echo basalt
#

Only computationally-expensive code will hinder your server's performance

#

And usually in massive amounts

#

or

#

Any code that intentionally "lags" / slows down execution

#

Such as Thread#sleep

minor garnet
#
        BlockPosition blockPos = new BlockPosition(loc.getBlock().getX(), loc.getBlock().getY(), loc.getBlock().getZ());
        PacketPlayInBlockPlace packet;
        packet = new PacketPlayInBlockPlace(blockPos, -1, stack, -1, -1, -1);
        
        EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
        entityPlayer.playerConnection.a(packet);
    }```

does anyone know that the player is not being updated to draw an bow?
echo basalt
#

unless

#

It's run on a separate thread

echo basalt
#

You can't really do that

minor garnet
#

wdym

echo basalt
#

PlayIn means Client -> Server

#

You can't really do the other way around

#

In the worst case, you disconnect the client

#

in the best case, nothing happens

minor garnet
#

how can i make the player draw the bow then?

echo basalt
#

You can't

minor garnet
#

i mean

echo basalt
#

You can send packets to all other players saying that that player in specific is drawing a bow

minor garnet
#

make player x look like he's pulling a bow for other players

echo basalt
#

That's a different packet

minor garnet
#

what exactily

sterile token
echo basalt
#

might be metadata honestly

agile anvil
minor garnet
echo basalt
#

Yeah metadata

agile anvil
sterile token
agile anvil
restive mango
#

Anyone know how to get an entitytype ID?

echo basalt
#

Entity status is more for sound effects

echo basalt
restive mango
#

I'm also working on packets and I'm just trying to get entity type IDs

minor garnet
#

someone of these values ​​what would be maybe to pull a bow

sterile token
restive mango
#

for the Spawn Entity packet

#

Type VarInt The type of the entity (see "type" field of the list of Mob types).

echo basalt
#

private static final int ARMORSTAND_ENTITY_TYPE_ID = Registry.ENTITY_TYPE.getId(EntityType.ARMOR_STAND); // EntityType.ARMOR_STAND.getTypeId() apparently spawns a ghast??

echo basalt
#

according to the NMS packet impl

#

So if you're using ProtocolLib, you skip that

#

Check around this area for how to convert formats to protocollib

restive mango
#

wat

#

I'm using ProtocolLib, but I need the entity type.

#

How would it know what to show the player, otherwise?

echo basalt
#

Or this for a more basic explanation

misty ingot
#

anyone know some good tutorials for plugin development? I already know the basics about java and plugin dev and also database/config stuff but I am looking to learn higher level stuff now

echo basalt
#

It reflects the nms fields on the packet class

agile anvil
# minor garnet someone of these values ​​what would be maybe to pull a bow

From Comphoenix: " indirectly, by telling it a player has right-clicked on an item, or directly by sending a play animation packet.

Unfortunately, like a lot of places in the protocol and for little good reason, it's the former. The server sends an ENTITY_METADATA (40) packet setting the 4th bit in the flag metadata that indicates the player referenced in the packet is performing a right-click action. When the player releases the bow, a new packet is sent to clear this bit."

echo basalt
#

Wiki.vg reflects the serialize method for the packet

echo basalt
#

I learned a lot from making a gta plugin

#

Messed with npcs, luckperms, storing player data, schedulers and all

misty ingot
#

Thats exactly what I am doing as of right now but I fee like theres a ton of features I am missing out on

echo basalt
#

Then come up with challenges that force you to mess with those features

sterile token
agile anvil
echo basalt
#

If you don't know how to do NMS mobs with custom pathfinders, focus on making a plugin that changes mob AI

misty ingot
#

thanks for the help guys 🙂

echo basalt
#

If you don't know how to mess with the scoreboard api, make a tab plugin

#

type deal

misty ingot
#

deal

minor garnet
restive mango
#
public static void spawnEntity (Player player, Entity entity, String i) {
        WrapperPlayServerSpawnEntityLiving packet = new WrapperPlayServerSpawnEntityLiving();
        packet.setEntityID(entity.getEntityId());
        packet.setType(EntityType.valueOf(i));
        packet.setUniqueId(entity.getUniqueId());
        packet.setX(entity.getLocation().getX());
        packet.setY(entity.getLocation().getY());
        packet.setZ(entity.getLocation().getZ());
        packet.setYaw(entity.getLocation().getYaw());
        packet.setPitch(entity.getLocation().getPitch());
        packet.sendPacket(player);
    }

Specifically, it's this: packet.setType(EntityType.valueOf(i)); which confuses me. I've been trying to figure out ways to make one entity look like another entity, but this doesn't seem to work.

#

@echo basalt

echo basalt
#

Okay so you just want a bootleg libsdisguise

restive mango
#

Like it appears to be the incorrect entity, I give it the string ZOMBIE and it looks like an ocelot.

#

Kinda!

echo basalt
#

¯_(ツ)_/¯

restive mango
#

I mean I want to know how to do this for other purposes too, like later on I might want to summon phantom entities and whatnot

echo basalt
#

did discord image upload die again

minor garnet
echo basalt
restive mango
#

can you show me where they get ARMORSTAND_ENTITY_TYPE_ID from?

#

That's what I need!

restive mango
#

oh... eh? But Registry doesn't have that method....

echo basalt
#

Uhh

#

IRegistry.Z or something

#

it's nms

restive mango
#

oh fuck

echo basalt
#

what can I tell you

#

You can do some funny stuff

#

Or mess with reflections

#

For example, using reflections to loop through IRegistry

#

get the registry that returns entitytype

#

finding the method that returns int from entitytype

#

and calling it

#

then calling it for each entity type and tossing it on a map

tardy delta
#

hmm and that works too

restive mango
#

Hm

agile anvil
sacred basin
agile anvil
#

Action bar is the bar just above the hotbar, chat is chat and system idk

tardy delta
#

?tryit

young knoll
#

System is from not a player

tardy delta
#

dang i love this elytra texture

restive mango
#

@echo basalt solved it, but I do have a follow-up stupid question

#

int entitytypeID = IRegistry.ENTITY_TYPE.a(EntityTypes.ARROW);

#

etc.

#

How do I get the EntityTypes enum thing from a string? Like getting EntityTypes.ARROW from the string 'ARROW'?

echo basalt
#

you might have to use reflections

#

EntityTypes is not an enum

restive mango
#

nvm

#

o

#

shit

#

well hang on let me see if this other thing works

#

omfg

#

there must be an easier way to do this

agile anvil
#

Create a map 🤡

restive mango
#

nooo

#

I don't want to write it all out by hand...

#

if this takes more than 30 minutes i might though

agile anvil
#

When you're engineer, you're lazy. And I already see me copy paste all the variables, and use some cool Regex Find-Replace to create a map lmaoo

supple elk
#

I'm making a boat "step-up" effect where if a boat runs into a 1-high wall it goes over it (velocity needs to be conserved). The number is the speed of the boat each second. The runnable is created when the boat approaches the wall. For some reason the velocity sometimes suddenly drops off a few ticks after it approaches the wall, as can be seen in the screenshot. If anyone has any ideas as to why this happens it would be appreciated

restive mango
#

got it

#

So

supple elk
restive mango
#
public static void spawnEntity (Player player, Entity entity, String str) {
        WrapperPlayServerSpawnEntityLiving packet = new WrapperPlayServerSpawnEntityLiving();
        packet.setEntityID(entity.getEntityId());
        int entitytypeID =  IRegistry.ENTITY_TYPE.a(EntityTypes.a(str).get());
        packet.setType(EntityType.fromId(entitytypeID));
        packet.setUniqueId(entity.getUniqueId());
        packet.setX(entity.getLocation().getX());
        packet.setY(entity.getLocation().getY());
        packet.setZ(entity.getLocation().getZ());
        packet.setYaw(entity.getLocation().getYaw());
        packet.setPitch(entity.getLocation().getPitch());
        packet.sendPacket(player);
    }
#

For anyone who wants to know

supple elk
restive mango
#

this is the code to use

#

to make an entity (entity) look like any other entity, with the entitytype defined by a string (str)

warm galleon
#

whats going on? My events arent being called and the class is empty

torn shuttle
#

Quick q: If I load a chunk as a plugin with no players in it, does that instantly start some sort of timer as to when the chunk should unload?

agile anvil
charred blaze
#

when im doing e.setCancelled(true); in signchangeevent sign is not dissapearing why?

#

text is appearing also

warm galleon
agile anvil
#

To cancel the placement of the sign, it's block place event

#

To remove text, change the text of the event to nothing

warm galleon
#

whats funny, is that my main class doesnt seem to have been used either, i remeber in my other projects intellij marks my main class as used/instantiated as well

#

but mine is grayed out for this on

#

e

agile anvil
warm galleon
#

ill copy over the entire classes

agile anvil
#

?paste it

undone axleBOT
warm galleon
#

religiously i must use hastebin

chrome beacon
chrome beacon
warm galleon
#

i did refactor my code names and classes a while ago and im not sure if i updated that

warm galleon
#

yeah the onenable is being called

chrome beacon
#

How are you checking that your listener is being called

warm galleon
warm galleon
agile anvil
#

Put this.playerStore = new PlayerStore(); in onEnable

#

Your constructor is never called

misty ingot
#

how do I make the comments stay in a config.yml file? when the plugin loads up and creates the folder with the file in it, I can see the fields but not the comments I put in there

warm galleon
#

oh i thought they always get called by the server

#

thats why its final

misty ingot
warm galleon
young knoll
#

Comments should stay in modern spigot

charred blaze
#

how to delete it?

warm galleon
#

also why is listener class empty and not used by anything other than my class

eternal night
#

its a marker interface

#

alternative would be for you to pass objects to registerEvents

chrome beacon
eternal night
#

which is just meh

warm galleon
#

ill try runing the plugin again tho

#

ill add a sout call to see

chrome beacon
#

You've told Intellij that @EventHandler means that it's used

#

It doesn't matter for the compiled project

warm galleon
#

oh

reef brook
#

how can i make the third argument of a command red?

warm galleon
#

wait 3rd

#

args[2]

#

or whatever u named ur string[]

#

from the command executor thing

reef brook
#

my command has only 2 arguments and I want it to be red when you put more than 2 (like the commands of many plugins)

young knoll
reef brook
#

in the tab completion i mean

chrome beacon
#

Make a custom tab completer

reef brook
#

i use the onTabComplete but i didn't find how to make args red

young knoll
#

You can’t iirc

#

You need brigadier or a framework that uses it

ivory sleet
#

Yeap

charred blaze
#

how to get player's swapped item?

young knoll
#

Swapped?

quasi pond
sinful rapids
#

Code

blocco.setTypeIdAndData(175, (byte) 3, false);

Only half of the plant comes out, how do I put the whole plant out?

chrome beacon
#

ew legacy code

young knoll
#

Gotta change the block above it too

chrome beacon
quasi pond
chrome beacon
#

There are two spaces before everything

quasi pond
quasi pond
sterile token
quasi pond
#

but it doesn't works for me

sterile token
#

Plugin.yml command name and api registrarion thru spigot

#

Is the same name

#

Like the command name is the same in the plugin.yml and in the api registration

#

Something else is happening

#

Do you have any decompiling tool? Like Luyten or JD-Gui
So then you can decompile the jar and see if everything is okay

#

I also do that when i have that type of problems

quasi pond
#

Yes I have JD Gui

#

Ok thx I will see that

sterile token
#

If not should be something related to registraion thru plugin.yml or api

#

Also something not related, but are u french?

quasi pond
#

Yes

sterile token
#

Oh i have figured it

#

haha

quasi pond
#

My english is very bad lol

sterile token
#

That gui should be useful for you to check

quasi pond
#

Oh ok

sterile token
#

Im really sure that we are missing something

quasi pond
#

name: CasinoMoney version: '1.0-SNAPSHOT' main: fr.pr11dev.casinomoney.CasinoMoney authors: [ pr11dev ]

In JD-Gui I see that on plugin.yml

quasi pond
charred blaze
#

how to get player's swap item?

dim palm
#

how can i send a hoverable message?

charred blaze
charred blaze
#

i mean

#

how to get item in another hand?

chrome beacon
chrome beacon
charred blaze
#

k

charred blaze
#

i onlysee these

chrome beacon
#

PlayerInventory is not a Player

#

It's the inventory

river oracle
#

I thought getItemInHand was deprecated in favor of getItemInMainHand

chrome beacon
#

They are probably depending on an old version

river oracle
#

what version?

charred blaze
#

p is not playerinventory

#

wdym

river oracle
#

p#getInventory lmao

#

p#getInventory -> PlayerInventory

#

PlayerInventory#getItemInMainHand
PlayerInventory#getItemInOffHand

charred blaze
#

i dont see any offhand

river oracle
#

there is no off hand prior to 1.9

charred blaze
#

ah

#

i was on 1.8

river oracle
#

find that improbably

#

I don't think you replaced your 1.8 api

#

also if your switching to 1.12 might as well make the jump to 1.18.2 or 1.19.2

charred blaze
#

error now

river oracle
#

don't reccomend the latter due to bugs latest stable I'm aware of is 1.18.2

charred blaze
river oracle
#

speeks for itself

supple elk
#

is onDisable called on a reload? From my testing it's not. Is there anything else I can use?

supple elk
#

.>

river oracle
#

good way to cause memory leaks and other issues

charred blaze
#

what to place instead of material?

river oracle
undone axleBOT
river oracle
#

you should know how to compare 2 things

#

before coding with spigot

sterile token
# dim palm how can i send a hoverable message?
public class Message {

    private String message;
    private final List<TextComponent> messages = new ArrayList<>();

    public Message message(String text) {
        this.message = Chat.style(text);
        this.messages.add(new TextComponent(this.message));
        return this;
    }

    public Message hover(String text, String hover) {
        this.message = Chat.style(text);
        TextComponent component = new TextComponent(Chat.style(this.message));
        component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Chat.style(hover)).create()));
        this.messages.add(component);
        return this;
    }

    public Message open(String text, String hover, String url) {
        this.message = Chat.style(text);
        TextComponent component = new TextComponent(Chat.style(this.message));
        component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Chat.style(hover)).create()));
        component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
        this.messages.add(component);
        return this;
    }

    public Message execute(String text, String hover, String command) {
        this.message = Chat.style(text);
        TextComponent component = new TextComponent(Chat.style(this.message));
        component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Chat.style(hover)).create()));
        component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
        this.messages.add(component);
        return this;
    }

    public void sendComponent(Player player) { player.spigot().sendMessage(this.messages.toArray(new TextComponent[0])); }
}
supple elk
charred blaze
#

🙂

supple elk
charred blaze
#

[20:45:24 WARN]: [Chat] Plugin Chat v1.0 generated an exception while executing task 22
java.lang.IllegalStateException: Asynchronous entity add!

#

what?

eternal night
#

something is adding entities off the main thread

charred blaze
#

it points on this line

eternal night
#

Yes

charred blaze
#

is block entity?

eternal night
#

no but what happens when you break a block naturally

charred blaze
#

it breaks

#

xd

eternal night
#

and drops an item

charred blaze
#

a

eternal night
#

beyond that

charred blaze
#

how to break without dropping item?

chrome beacon
#

Also don't modify the world async

charred blaze
#

then?

eternal night
#

even breaking the block is not supported off main thread

#

yea

charred blaze
chrome beacon
#

Do it sync

eternal night
#

don't interact with anything in the minecraft world off main thread unless specifically specified to be safe

#

^

charred blaze
eternal night
#

push a new runTask onto the scheduler

charred blaze
#

ah ok

#

Bukkit.getScheduler().runTask(this, () -> {
e.getBlock().breakNaturally();
});

#

like dis yuh?

eternal night
#

👍

charred blaze
#

k

sterile token
#

Wondering to learn this: If im not wrong block when you are breaking, placing, and etc, they are managed async or sync?

charred blaze
#

you are not what?

#

wrong block?

#

wdym

sterile token
#

okay

#

Because logic told me tha tthey should be managed async

#

So then you dont have problems like ticks, lag, etc

charred blaze
#

mhm

sterile token
#

Im not sure

#

I just wondering to learn

charred blaze
sterile token
#

Because if you thought, many players breaking, placing block, dropping, etc all at the same time? That should take all resources i suppouse

sterile token
charred blaze
#

its because of my england

#

:DDD

#

english

sterile token
#

Na dont worry is okay, im also a spanish native speaker so my english is even worst

#

😂

quaint mantle
#

minecraft runs on 1 thread

sterile token
#

Oh that the problem

#

I always forget that shity mc is not multi threaded

quaint mantle
#

yes, minecraft isn't designed to be multi threaded

#

but you can make it work

#

with tasks that run next tick

sterile token
#

ok and something else, if its designed to run sync, how does it execute async things?

quaint mantle
#

minecraft doesn't do anything async

sterile token
quaint mantle
#

ah, that is handled by bukkit / spigot

agile anvil
sterile token
#

😬

agile anvil
#

I'm French that's maybe the pb

quaint mantle
#

oh no I get it

charred blaze
#

why is this bugged? p.getInventory().setItemInOffHand(null);

quaint mantle
#

Move code that doesn't need to interact sync to a thread

sterile token
#

Can u explain it in english-english timar - HAHAH

quaint mantle
#

but yes that is handled by spigot itself

quaint mantle
sterile token
charred blaze
#

when i have editable book in second hand

#

and edit it

#

it is edited

#

BUT

#

when i drop it

#

and get it

#

then

#

it is old text in there

#

non edited

#
  • item not deleted when edited
tardy delta
#

those are 11 lines my man

quaint mantle
#

xD

#

setItemInOffHand item argument is nullable

charred blaze
#

ig?

quaint mantle
#

can you maybe show some code ?

charred blaze
#

uh wait

#

i understand why it does like that

quaint mantle
#

it seems as though the old ItemStack is getting dropped, and only then the item gets edited

charred blaze
#

if (p.getInventory().getItemInOffHand() == new ItemStack(Material.BOOK_AND_QUILL)) {

#

why isnt this check working?

quaint mantle
#

because

#

these are two different item stacks

charred blaze
#

how to check if its book and quill

quaint mantle
#

you need to check against itemStack.getType()

#

itemStack.getType() == Material.BOOK_AND_QUILL

agile anvil
#

ItemStack represent the item itself, you can have two pens but they aren't the same, even if they're the same type. As timar said, you're looking to check for types

charred blaze
#

uh right

charred blaze
#

bruh

quaint mantle
#

It is not smart to start learning Java with Spigot, that's why.

#

not saying you are doing that

charred blaze
tardy delta
#

yes

charred blaze
quaint mantle
#

No, rather:
First Java tutorial:
Two instances of the same class are not necessarily the same.

river oracle
#

its part of coding

charred blaze
river oracle
#

?jd

tardy delta
#

its part of learning the api

river oracle
#

learn how to use the java docs as well mate

charred blaze
#

hte?

#

wdym

quaint mantle
#

hte = the

pseudo sierra
#

Is there a way to make hostile mobs deal more damage?

quaint mantle
#

you can add a damage attribute modifier

pseudo sierra
#

@quaint mantle yes i want to do that but I want to make it so every mob that spawns has it

quaint mantle
#

listen to the spawn event and give the mob an attribute

#

you cannot edit base mob values

#

pretty sure

quaint mantle
#

except if FourteenBrush proves me wrong again (^^)

#

nvm xD

dim palm
#

how can i create a method that sets a random block on X location

tardy delta
#

have some collection that contains all the materials that are blocks, or stream then when needed and use a random to set the block type to blocks.get(random.nextInt(material.size()))

#

if i understand your question correctly

dim palm
#

😨

tardy delta
#

uhh ye smth like that

#

or Arrays.stream(Material.values()).filter(Material::isBlock).collect(Collectors.toList())

nocturne crystal
#

hello i'm using nms but is all obfuscated, how can i see the methods name?

sterile token
tardy delta
#

bruh fkin discord keeps saying upload failed

#

lemme try this

#

bruh wth is this

sterile token
#

?

#

Oh there is bug with that i have discovered

sterile token
#

When you are trying to upload a file which is inside a zipped or rar file, discord fail with that issue also
@tardy delta

tardy delta
#

reload command moment

#

ah stuff got corrupted

sterile token
# tardy delta

Is something weird because while mc is not multi threaded, netty does it

#

HAha

tardy delta
#

always fun when it happens in native code

#

think it was sqlite

#

hmm wondering if i use completable futures in my onDisable, the server will wait for them to complete before shutting down the server?

#

ig not

tardy delta
#

bruh store some of those variables

#

instead of new Random you can use Random r = ThreadLocalRandom.curren()

#

am i seeing Material.getMaterial(int) or whats happening there?

dim palm
#

😨

tardy delta
#

you need to get a material from that collection by getting a random index

crisp steeple
#

i don’t think there are that many materials

tardy delta
#

and then asking the collection ::get(index) or use an array or smth

#

how does that compile?

#

might be me getting blind too

#

@dim palm just have a static List<Material> field

#

which you intialize with that stream method i told you

tardy delta
#

yes

#

and later on you set the block type to materials.get(random.nextInt(materials.size()))

dim palm
#

thanks

charred blaze
#

hey, so i have command cooldown system like this:


import java.util.HashMap;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import net.md_5.bungee.api.ChatColor;

public class Rtp extends JavaPlugin {
    static HashMap<Player, Long> commanddelay = new HashMap<>();
    @Override
    public void onEnable() {
        saveDefaultConfig();
    }

    @Override
    public void onDisable() {}

    @SuppressWarnings("deprecation")
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player p = (Player)sender;
        if (label.equalsIgnoreCase("rtp"))
            if (!commanddelay.containsKey(p)) {
                commanddelay.put(p, Long.valueOf(System.currentTimeMillis()));
                
            } else if (System.currentTimeMillis() - ((Long)commanddelay.get(p)).longValue() >= TimeUnit.MINUTES.toMillis(5)) {
                commanddelay.remove(p);

            } else {
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou need to wait &6" + TimeUnit.MILLISECONDS.toMinutes(commanddelay.get(p)-System.currentTimeMillis()+TimeUnit.MINUTES.toMillis(5)) + "&c minutes before RTPing again!"));
            }
        return false;
    }
}```
But problem is that when player executes command and it has cooldown and he cant execute it again  because of cooldown, if he leaves the server and rejoins he can run that command again
#

i cannot understand why

lost matrix
charred blaze
#

"uuid is more flexible"

#

xd

river oracle
sinful rapids
charred blaze
#

why using names would cause bugs/

compact glen
#
@EventHandler
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
  System.out.println("Test");
  Block furnaceBlock = event.getBlock();
  ItemStack smelting = event.getResult();
  System.out.println(smelting.getItemMeta().getDisplayName());
  if (smelting.getItemMeta().getDisplayName() == ChatColor.GOLD + "Boom") {
    World w = furnaceBlock.getWorld();
    w.createExplosion(furnaceBlock.getLocation(), 5, true);
  }
}

does anyone know why doesnt work? it doesnt even print "Test" in the console

river oracle
#

so it only makes sense to use a UUID in every case

charred blaze
river oracle
#

🤦‍♂️ I'm done with you nvm

charred blaze
#

if account name will change wouldnt uuid will change too?

river oracle
#

unless you are using offline mode

charred blaze
#

i got the point

river oracle
#

in that case cope nerd

compact glen
#

god damn

#

thats hot

#

i mean what

river oracle
#

it took you a long time to type that lmao

charred blaze
compact glen
#

skill issue

charred blaze
#

aaaaaa

#

wait ;d

chrome beacon
#

?learnjava moment

undone axleBOT
charred blaze
#

how to check if player has typed message since he joined?

chrome beacon
#

Save the user to a list

#

when they first type

#

then check if they are in the list

compact glen
#

what if i dont want to

#

what if i want to spoonfeed

#

jk jk

#

well anyway it should print "Test" to the console but it doesnt

#

the event just doesnt execute

river oracle
#

damn thats crazy

compact glen
#

frfr

river oracle
#

on god never seen that before mate

chrome beacon
#

Sounds like you didn't register the listener

river oracle
#

+1 ^ mans

compact glen
#

oh wait