#help-development

1 messages · Page 1847 of 1

tidal skiff
#

still does it

young knoll
#

When patching I just run CB

tender shard
#

but can't you just use the main jar anyway?

tender shard
tidal skiff
#

havent tried yet let me see

azure phoenix
young knoll
#

I think you can compile it back to spigot using buildtools with --dont-update

#

(After committing your changes)

tender shard
#

normally you DO NOT want to run buildtools but just compile spigot using maven

tidal skiff
#

it seems to work fine with the heart particle but it has an animation so i wonder if its just a set animation for the particle

#

theres some extra data for the function im gonna try set to 0

tender shard
young knoll
#

Yes, the extra int controls speed on the fire particle

#

Or float, whatever it is

tidal skiff
#

ok i fixed it by setting the extra int to 0

#

alr ty

tender shard
#

:3

azure phoenix
#

do u know why just mvn clean install doesn't work anymore?

tender shard
young knoll
#

¯_(ツ)_/¯

azure phoenix
#

no errors

tender shard
#

and where's the problem?

young knoll
#

Probably because of the bootstrap stuff

azure phoenix
#

this happens when I run

young knoll
#

Which file

#

There should be several

azure phoenix
#

the one without bootstrap or remapping

young knoll
#

You need to run the bootstrap one

azure phoenix
#

I see

#

thanks :P

tender shard
#

mvn creates this file:

#

spigot-1.18.1-R0.1-SNAPSHOT-bootstrap.jar

#

it should run fine

#

inside SPigot/Spigot-Server/

azure phoenix
#

👍

dark arrow
#
       ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("ProSword"),new ItemStack(Material.DIAMOND_SWORD));
       sr.shape("DDD"
               ,"DSD"
               ,"DDD");
       sr.setIngredient('D',Material.DIAMOND);
       sr.setIngredient('S',Material.DIAMOND_SWORD);
   }
#

i have tried that code now but it does not work and does not show any error also

young knoll
#

Well yeah, you need to add the recipe separately at startup

#

And then validate the ingredients using the event

dark arrow
#

ohh

analog prairie
#

i have some coding problem

#

Why I can not use chinese in kick message?

tender shard
#

you should not create a new crafting recipe in every PrepareItemCraftEvent

#

as Coll said: create the recipe ONCE on startup

#

buuuut

#

I already said:

#

this won't work

#

and also wtf

#

you use a minecraft namespaced namespacedkey

#

you should use your plugin instead

tender shard
young knoll
#

You would create a recipe with just the bare items at startup

tender shard
#

any error message?

young knoll
#

And then validate they have the data you want in the event

#

The bare recipe is just so the prepare craft event actually triggers

tender shard
#

well

#

the prepare event always gets called

#

even if no recipe matches

young knoll
#

Really?

#

Huh

tender shard
#

if always gets called when the matrix is changed, yes

#

let me double check, but im 99% sure

analog prairie
tender shard
# young knoll Really?

my intellij doesn't want to open lol. but yeah I'm 99.9% sure because I'm using it in one of my plugins

analog prairie
#
event.getPlayer().kickPlayer(("雲端\nReason for ban >> "+jsonObject.get("response").getAsJsonObject().get("reason").getAsString()));
tender shard
young knoll
#

I don’t think that’s the client

dark arrow
young knoll
#

Looks like you need to change the encoding in your IDE

tender shard
#

is that message appearing on compiling, or only when you run the code?

analog prairie
young knoll
#

You can also use Unicode escapes in strings

#

Like so \u0048

tender shard
#

that's a zero!

young knoll
#

The client should have textures for all the Chinese characters

#

I would think anyway

analog prairie
young knoll
analog prairie
# young knoll Like so `\u0048`

event.getPlayer().kickPlayer(("\u96f2\u7aef\u9632\u8b77\u7cfb\u7d71\nReason for ban >> "+jsonObject.get("response").getAsJsonObject().get("reason").getAsString()));

#

Is this right?

mellow gulch
#

does yml support utf8? might be worth trying to put the messages in a yml file so you don't need to escape every single character

#

and this solution (assuming yml does support utf8) would let you keep your sources ansi also

young knoll
#

It does if you save it as such

mellow gulch
#

(and would also make your plugin easily convertible to whatever language instead of hard coding the messages as chinese)

dark arrow
#

i think i found how to make custom r ecipes

#

how will i give the item a colored name

#

using setDisplayName

young knoll
#

ChatColor

dark arrow
#

is ti work for setDisplayName also?

#

i found this site

mellow gulch
#

it should, and afaik you can just use the reset color to remove the italics on custom named items

dark arrow
#

ok

mellow gulch
#

your link was missing a few

#

lol nvm, i just didn't scroll down enough like an idiot

dark arrow
#

can i use font tag and color tag together?

buoyant viper
#

format and color? yeah

mellow gulch
#

what does fint mean? the format ones? yeah

dark arrow
#

*font

#

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;

public class itemManager {
    public static ItemStack proSword;

    public static void init(){

    }
    public static void createProSword(){
        ItemStack item = new ItemStack(Material.DIAMOND_SWORD,1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("§4Pro Sword");
        meta.addEnchant(Enchantment.DAMAGE_ALL,5,false);
        item.setItemMeta(meta);

        proSword = item;

        ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("pro_sword"),item);
        sr.shape("DDD"
                ,"DSD"
                ,"DDD");
        sr.setIngredient('D',Material.DIAMOND);
        sr.setIngredient('S',Material.DIAMOND_SWORD);
        Bukkit.getServer().addRecipe(sr);
    }
}
```This Time I did it in the class with everything said but again its not working 😦
#
    public void onEnable() {
      
        itemManager.init();


    }
eternal oxide
#

your init method calls nothing

dark arrow
#

beuh i am so dumb

#

lets go

#

its working

#

thx to everyone who helped me making is

#

tysm

#

😄

tidal skiff
#

hey all, i have kind of a weird problem:

im making a trap plugin and im trying to make a trap that encapsulates the victim in a 3x3 invisible wall that only theyre affected by and blah blah blah i have all that stuff down but i have a class for timed events and a class for the trap itself. before when i made an explosion trap it was pretty simple, the victim steps on the trap and it passes a location and a timer to the timed event class and after the timer drops to 0 then an explosion is created at the location, but this one is kind of weird. I need to pass 3 objects, a location, an int for the timer, and a player, but i havent found a way to do it. i used a hash map for the explosion trap but you obv cant fit 3 values into a hash map

#

im gonna try put a hash map inside a hash map wish me luck kekw

ivory sleet
#

I mean encapsulate the data with a class

#

If you’re on newer versions, you can even use a record

tidal skiff
#

lmfao i put a hash map in a hash map boys

dark arrow
#

bro i have completed the code to get shaprneed 5 dia sword after doing a specific recipe

#

now how will i make it so that it gives sharpness 6 or more then it

ivory sleet
#

as said you should encapsulate said data in a new class and pass that type to the V type parameter

dark arrow
#

if i do using addenchants it just removes the enchants

dark arrow
#

any solutions for that?

ivory sleet
#

Use addUnsafeEnchantments iirc

tidal skiff
ivory sleet
#

Something with unsafe

tidal skiff
#

in the item meta

#

im prob wrong

dark arrow
dark arrow
#

when i add that

#

is just removes all the enchants

#

if i add shapness 5 then it add but if its sharpness 6 nothing happens

dark arrow
ivory sleet
#

Check the link I sent

dark arrow
#

ok

#

how will i use it?

#

i cant type addunsafeenchants

analog prairie
#

I can add unicode to kick message

ivory sleet
analog prairie
#
String msg= MessageFormat.format("\u96f2\u7aef\u9632\u8b77\u7cfb\u7d71\nReason for ban >> {0}",jsonObject.get("response").getAsJsonObject().get("reason"));
ivory sleet
#

Yeah although you need to make sure your compiler compiles with UTF-8 encoding or smtng

analog prairie
#
[16:21:05] [defaultEventLoopGroup-5-1/INFO]: [Geyser-Spigot] whes1015 從 Java 伺服器中斷連線,原因為 雲端防護系統
Reason for ban >> "\\u5916\\u639b"
ivory sleet
#

That’s due to gson

#

Which escapes the \

analog prairie
#

the problem is my unicode is \u5916\u639b

ivory sleet
#

Or whatever Json lib u use

analog prairie
#

It always display \ \u5916\ \u639b

ivory sleet
#

As said

#

It escapes the \

analog prairie
#
System.out.println(jsonObject.get("response").getAsJsonObject().get("reason"));
#
[16:21:04] [Server thread/INFO]: "\\u5916\\u639b"
ivory sleet
#

Try to append .replace("\\\\","\\")

analog prairie
#

So is Gson's problem?

dark arrow
#

can i add using itemstack?

ivory sleet
#

Might be

ivory sleet
dark arrow
#

ok

#

not working

ivory sleet
#

Send the code and never say not working, specify what does not work and what the wanted result is rather

dark arrow
#

sorry for not specifying

ivory sleet
#

No worries but just for any future references:)

dark arrow
#

        ItemStack item = new ItemStack(Material.DIAMOND_SWORD,1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("§4Pro Sword");
        item.addUnsafeEnchantment(Enchantment.DAMAGE_ALL,6);
        item.setItemMeta(meta);

        proSword = item;

        ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("pro_sword"),item);
        sr.shape("DDD"
                ,"DSD"
                ,"DDD");

        sr.setIngredient('D',Material.DIAMOND);
        sr.setIngredient('S',Material.DIAMOND_SWORD);
        Bukkit.getServer().addRecipe(sr);
}
    ```
analog prairie
dark arrow
ivory sleet
ivory sleet
#

It’s probably a bit weird to understand why that matters right now but ItemMeta is actually not a part of the ItemStack

analog prairie
#
[16:32:33] [Server thread/INFO]: whes1015 lost connection: 雲端防護系統
Reason for ban >> \u5916\u639b
ivory sleet
#

👍

ivory sleet
#

But how does your json look

#

Chances are you can read your json with utf8 encoding and get it to work that way

#

@analog prairie

#

So if you could share the code where you read the json file would be amazing

dark arrow
#

also how to make it so that they could only give shapneed 5 di amond sword for recipe and not any other diamond sword?

ivory sleet
#

ItemStack ingredient = …;
sr.setIngredient('T',new RecipeChoice.ExactChoice(ingredient));

ivory sleet
#

iirc

#

Ah right I’ll have myself a look

analog prairie
analog prairie
tidal skiff
#

so do constructors not work in spigot or am i just fucking stupid

ivory sleet
#

They work

tidal skiff
#
public class TData {

    public static Location location;
    public static int timer;

    public TData(){}
    public TData(Location location_, int timer_){
        location = location_;
        timer = timer_;
    }
}

this is probably the simplest constructor ever but when i make a new TData object and try and use it like

ivory sleet
#

Remove static

tidal skiff
#

i need static

ivory sleet
#

No you don’t lol

tidal skiff
#

oh wait nvm

#

either way it doesnt work without them anyway

ivory sleet
#

Static globalifies the variables

#

It does

tidal skiff
#

wait nvm tf

#

ive tried without static???

#

this is rigged

#

anyway ty

tidal skiff
lavish hemlock
#

don't do this (Location location_, int timer_)

#

_ is no longer valid in identifier names

tidal skiff
#

alr

#

why not tho

#

why arent they valid i mean

lavish hemlock
#

I'm not sure, I think it's because they're used as keywords in later versions

sacred mountain
#

does org.bukkit.particle; not exist i cant import it

lavish hemlock
#

keywords are stuff like public and static btw

#

ye Java is jank sometimes

lavish hemlock
#

You should remove static.

tidal skiff
#

yeah i did

ivory sleet
#

Yeah they removed the possibility of using $ in variable names iirc

ivory sleet
#

Ye sadge

lavish hemlock
#

:(

sacred mountain
lavish hemlock
#

In Java, there's a very common way to define properties, which are getters and setters

#

Essentially, instead of allowing people to directly access your fields, you use methods to retrieve and set the value of the field

#

This is mainly to prevent binary incompatibilities as I understand it?

#

example:

#
private final String name;

...

public String getName() {
    return name;
}
#

If we were to refactor the above code to be conventional.

#
public class TData {
    private /* final */ Location location;
    private /* final */ int timer;

    public TData() {
        // this.location = <default here>;
        // this.timer = <default here>;
    }

    public TData(Location location, int timer) {
        this.location = location;
        this.timer = timer;
    }

    // Your getters here.

    // If you didn't uncomment the above code, then your setters would also be here.
}
#

Note: This is conventional, but not pretty. Java is not meant to be pretty.

quaint mantle
#

anybody cane help my with towny plugin'

lavish hemlock
#

If you want a pretty language, go look at Kotlin 😉

lavish hemlock
undone axleBOT
#

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

dark arrow
ivory sleet
#

That was just a sample code

#

You need to understand it and apply what I did just a little bit different

dark arrow
#

is it possible to make my new item with all those enchants and put it in ingredent?

ivory sleet
#

Think so

dark arrow
#

ok

#

ok

#

it worked

#

thx onceagain

sacred mountain
dark arrow
#

i was typing the wrong spelling xD

ivory sleet
#

You can’t import a package

sacred mountain
#

huh

ivory sleet
#

you could use org.bukkit.particle.*; tho that’s a bit slower

#

Ideally just import the class

sacred mountain
#

ok

ivory sleet
#

Well then that’s not a valid package

#

you know classes are case sensitive in terms of name

#

Actually a lot of stuff is in programming generically speaking

onyx fjord
#

Which spigot API version are you using @sacred mountain

sacred mountain
#

tried that didnt work

sacred mountain
onyx fjord
#

Smh

sacred mountain
#

for referenced libraries

ivory sleet
sacred mountain
#

o

#

ok

onyx fjord
#

I guess that might be the reason

sacred mountain
#

i'm literally just tryna fix some stuff from another plugin, im not a great dev at all

#

idk whats wrong with ti

onyx fjord
#

@ivory sleet did 1.8 even have particle API?

sacred mountain
#

that will be a rip if it didnt

onyx fjord
#

Good reason to update

sacred mountain
#

well i cant really do that rn

#

is there any way to get a particle api in 1.8

#

like an external

ivory sleet
onyx fjord
sacred mountain
#

its just this one class that im trying to fix without removing it

#

should i bother downloading particle api plugins and using those

ivory sleet
#

Yeah better than committing yourself to nms

onyx fjord
dark arrow
#

the maximum limit of enchants using commands is 32767 so unsafe enchants have the limit ?

ivory sleet
#

In newer versions 255

dark arrow
#

ohk

trim crystal
#

Hey, how do I use NMS to show a block as "cracked"?

ivory sleet
#

Step 0: you use the api

trim crystal
#

done

#

btw I'm on 1.18

trim crystal
#

ty

onyx fjord
#

Yoo

#

I didn't know that it's a thing

#

I thought it's a protocollib thing

ivory sleet
#

🥲

cold field
#

Hi Conclure just to know, have you already any tips?

ivory sleet
#

Oh yeah link that thing

cold field
summer scroll
#

Can you remove the minecraft:paper and NBT lore?

tidal skiff
#

what was that text file thing that you could save data to like strings and ints and shit

#

i forgot what it was called

#

but i need to use it lol

spiral light
analog prairie
#

Can I display color on console?

tacit drift
royal vale
#

Gets the brand of the currently connected server. May be null if the server hasn't yet sent brand information. Server brand information is sent over the {@code MC|Brand} plugin channel, and is used to identify modded servers in crash reports.

How do I change the server brand (which packet/plugin channel)?

tacit drift
royal vale
#

Or just the f3 brand

tacit drift
#

The F3 brand is the server brand i think

wet breach
#

which, unless you have a mod that changes it or have a custom client, it is by default Vanilla

#

don't have the client loaded but I am sure someone can check really quick

#

if it says anything other then Vanilla on a spigot server, then we know its not from the client 🙂

nocturne sinew
#

difference between clients and launchers

tidal skiff
#

anyone know why getConfig().set("Traps.ExplosiveTraps", null); isnt working? im trying to reset the entire path

#

nvm i figured it out

#

anyway

#

anyone know how to iterate through a config like this:

Traps:
  ExplosiveTraps:
    '1':
      Location:
        ==: Vector
        x: 26.0
        y: 66.0
        z: 100.0
      PlacedBy: f780f203-cf11-4416-9e07-9ec21b37e476
    '2':
      Location:
        ==: Vector
        x: 30.0
        y: 67.0
        z: 109.0
      PlacedBy: f780f203-cf11-4416-9e07-9ec21b37e476

and get the vector values and uuids?

#

back into a hashmap i mean

#

or at least get the length of all the '1' '2' so i can iterate through the config directly

spiral light
#

You can save the length of this in the config while setting it too...

summer scroll
tidal skiff
#

lol didnt think about that

tacit drift
#

ofc you can't change the client brand

spiral light
#

You can change the server brand in F3 but it is sended in the moment the player joins ... So you need to catch the packet there and modify it

sage dragon
#

I wonder if it is possible to check where an arrow hit a player?

onyx fjord
spiral light
sage dragon
spiral light
#

Not that easy and not accurate all the time but it is possible

tidal skiff
#

does getOfflinePlayer work even if the player is online

#

i get that it says offline player

#

but i just need to know so i can get the uuid

sage dragon
tidal skiff
#

alr ty

sacred mountain
#

anyone know anything about effectlib

#

im having trouble doing some stuff

#

i dont know where to add parameters into the code after reading the wiki

tidal skiff
#

anyone know why UUID tempID = Bukkit.getOfflinePlayer(getConfig().getString("Traps.ExplosiveTraps." + iter + ".PlacedBy")).getUniqueId(); isn't working? the error says that its returning null even though it shouldnt be, i can literally see it there in the config

sage dragon
tidal skiff
#

i do but if u try set tempid directly as the string in there it rejects it

sage dragon
#

Did you try UUID.fromString, or did you just put a string there?

tidal skiff
#

i just put the string there

sage dragon
#

If you use Bukkit.getOfflinePlayer with a string, it's assuming you entered a name, not a uuid

tidal skiff
#

whats fromstring

tidal skiff
#

thats not sarcastic

#

it looks sarcastic

sage dragon
sage dragon
tidal skiff
#

OMG IT FINALLY WORKS

#

holy crap if i'd known the from string function existed

#

tysm

sage dragon
#

You're welcome

tidal skiff
#

is anyone on mc 1.18.1 rn? i need u to hop on the server so i can test smth itll be like 2 seconds

trim crystal
#

send me

trim crystal
quaint mantle
#

Hello! I am trying to disable the fact that a tripwire gets powered when you step into it.

#

I looked at the spigot source in buildtools and here is what I found (it's from CraftBukkit):

#
        // CraftBukkit start - Call interact even when triggering connected tripwire
        if (flag != flag1 && flag1 && (Boolean)iblockdata.get(ATTACHED)) {
            org.bukkit.World bworld = world.getWorld();
            org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
            org.bukkit.block.Block block = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
            boolean allowed = false;

            // If all of the events are cancelled block the tripwire trigger, else allow
            for (Object object : list) {
                if (object != null) {
                    org.bukkit.event.Cancellable cancellable;

                    if (object instanceof EntityHuman) {
                        cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
                    } else if (object instanceof Entity) {
                        cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
                        manager.callEvent((EntityInteractEvent) cancellable);
                    } else {
                        continue;
                    }

                    if (!cancellable.isCancelled()) {
                        allowed = true;
                        break;
                    }
                }
            }

            if (!allowed) {
                return;
            }
        }
        // CraftBukkit end
#

As you can see, cancelling PlayerInteractEvent and EntityInteractEvent should be enough

#
    @EventHandler
    public void tripwireEvent1(PlayerInteractEvent event) {
        event.setCancelled(true);
        Logs.logInfo("triggered 1");
    }

    @EventHandler
    public void tripwireEvent2(EntityInteractEvent event) {
        event.setCancelled(true);
        Logs.logInfo("triggered 2");
    }
#

Unfortunately, this code doesn't seem to work: event is not triggered when I step into a string (it is if I click on it of course)

#

Any idea why?

trim crystal
#

I'm not sure never dealt with this but I can only give what I think can be the solution.

Try saving the entity the player is interacting with and save it as a tripwire, after that change the tripwire's state

quaint mantle
#

What entity are you talking about?

#

I am trying to understand why the event is not triggered

trim crystal
#
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
        Player p = e.getPlayer();
        if (e.getAction() == Action.PHYSICAL) {
            if (e.getClickedBlock().getType() == Material.TRIPWIRE) {
                p.sendMessage("you hit a trap!");
            }
        }
    }
#

I think you can change it to any entity as well

quaint mantle
#

This won't help, as I said it is not triggered

trim crystal
#

dumb question but, did you register the listener?

quaint mantle
trim crystal
#

Happens to me a lot that's why I'm asking

#

PlayerInteractEntityEvent try using this event maybe

quaint mantle
#

This event is not triggered according to the code I sent

quaint mantle
#

Tripwires are not entities

trim crystal
summer scroll
#

Does someone know what is the probable cause here? So I make armor stand follow player's head movement, and suddenly the armor stand stops following player's head movement when player is riding something.

quaint mantle
#

do you know where I could report this issue to spigot team?

trim crystal
trim crystal
#

Does mining fatigue -1 let's the player hand animation move the same speed without actually breaking the block?
in 1.8 it used to work but I'm now using 1.18

summer scroll
trim crystal
#

The head's angle changes to the horse's head angle but the armor stand stays according to the player's head angle before you get on the horse

summer scroll
trim crystal
#

I actually asking because I tried maybe it doesn't work anymore and maybe I did something wrong..

#
    public void addSlowDig(Player player, int duration) {
        player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, duration, -1, false, false), true);
    }

that function gives the player the mining fatigue and I do receive mining fatigue ingame

tardy delta
#

what are you trying to do?

tidal skiff
#

how do i set the realm of a Location object

#

like nether end etc

young knoll
#

setWorld

tidal skiff
#

how do i get the nether world

#

object

tardy delta
#

Bukkit.getWorlds().get(1) iirc

tidal skiff
#

thought so, y

#

ty*

tardy delta
#

index 0 is overworld, 1 is nether and 2 is end, rest is custom worlds

tidal skiff
#

how do i get the world index of a block

#

i think it might be in the location property

young knoll
#

Block.getWorld

#

?jd

tardy delta
#

would it be a good idea to start the hikari connection pool when i need a connecion, not when the plugin starts up?

summer scroll
quaint mantle
#

hello i have a question about wiki.vg

#

it shows protocol specifiactions and stuff about 1.18

#

but i want info about release 1.9.4

tardy delta
#

is the if check unneccesary?

summer scroll
#

yes, you don't need the length check

tardy delta
#

oki

lavish hemlock
#

when iterating, you don't need to check length

spiral light
lavish hemlock
cold field
#

When is the itemMeta of an ItemStack null?

trim crystal
#

Hey, how can I put the equivalent to mining fatigue -1 of 1.8 in 1.18?
I want the player to move the hand like he is mining but won't actually damage the block, I know I can cancel block damage event but on the client side he will break the block..

tardy delta
#

cancel the block break?

#

well that will still show the block breaking

trim crystal
#

In 1.8 I could give the player mining fatigue -1 and the hand would move the same speed but he won't damage any block.. I think they removed that in 1.18

spiral light
#

In 1.18 you can send block damage to 0 all the time

trim crystal
#

with the player.sendBlockDamage(location, 0f);?

#

currently I'm using this but to change the animation, I'll send you the code, 1 sec

#
    private ArrayList<CustomBlock> blocks;

    @Override
    public void onEnable() {
        this.blocks = new ArrayList<CustomBlock>();
        getServer().getPluginManager().registerEvents(this, this);
    }

    private CustomBlock exists(Location location){
        for(CustomBlock block : blocks){
            if(block.location.equals(location)) return block;
        }
        return null;
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event){
        Location location = event.getClickedBlock().getLocation();
        CustomBlock block = exists(location);

        if(block != null){
            block.incermentDamage(event.getPlayer(), 0.05f);
        }else{
            blocks.add(new CustomBlock(location, 0f));
        }
    }

Main ^^

public class CustomBlock {

    public float dmg;
    public Location location;

    public CustomBlock(Location location, float dmg){
        this.location = location;
        this.dmg = dmg;
    }

    public void incermentDamage(Player player, float damage){
        this.dmg += damage;
        if(dmg < 1f) {
            player.sendBlockDamage(location, dmg);
        }
        else
            player.sendBlockDamage(location, 0f);
    }

CustomBlock^^^

#

This is just a test so I don't care if the main and the listener are the same class

#

So with this code if I cancel the interact event the block would break and then it would cancel the break, but on client side it would show the crack animation going all the way

#

I know I can send the block crack animation through NMS but I couldn't find how..

spiral light
#

Playerinterscct gets called just once

#

Playerinterscct event*

#

You will need to check if the player clicks something else and if not send no block DMG all the time

#

Also mining fatigue 255 will slow down the break animation ?

trim crystal
#

I'll try the mining fatigue 255, but I didn't understood what you said about the playerInteractEvent, currently I'm testing a perfect situation where the player doesn't click anything else, when I long left click the block will break like in vanilla minecraft but since the server cancelled the event the block won't disappear, I don't want the block to even break on client side.

ivory sleet
#

@cold field anyways the code is better

#

You could still extract the data transfers themselves from the manager logic

trim crystal
trim crystal
ivory sleet
#

Empee

trim crystal
#

I saw people use protocolLib for sending packets, is it better than NMS?

spiral light
#

Yes

trim crystal
#

And where can I find the full api?

spiral light
#

Google ?

#

Send Block change will easy work if you just know how

cold field
cold field
#

He was reviewing my code. I've made a lib that expose brigadier compatible from 1.8.8 to 1.17.1

peak granite
#

can a final HashMap be updated

hybrid spoke
#

yes

late sonnet
peak granite
#

oh

#

so the elements can be updated

#

thanks

trim crystal
#
    @EventHandler
    public void onInteract(PlayerInteractEvent event){
        Location location = event.getClickedBlock().getLocation();

        PacketContainer fakeExplosion = protocolManager.createPacket(PacketType.Play.Server.EXPLOSION);

        fakeExplosion.getDoubles()
                .write(0, location.getX())
                .write(1, location.getY())
                .write(2, location.getY());
        fakeExplosion.getFloat().write(0, 10f);

        try{
            protocolManager.sendServerPacket(event.getPlayer(), fakeExplosion);
        }catch (InvocationTargetException e){
            throw  new RuntimeException("Cannot send packet " + fakeExplosion, e);
        }

    }

anyone knows why it doesn't create an "explosion"?

chrome beacon
trim crystal
#

just testing protocollib

#

Learning*

dusty sphinx
#

how can i place a player head and set it's owner?

        Bukkit.getScheduler().runTask(BlockRegen.getInstance(), () -> {
            block.setType(regenerateInto);
            if (block.getState() instanceof final Skull skullState) {
                skullState.setOwningPlayer(Bukkit.getOfflinePlayer(preset.getOwnerUuid()));
            }
        });```
i put this together but it doesnt work (regenerateInto = Material.PLAYER_HEAD)
chrome beacon
dusty sphinx
#

ah

#

thanks ill try it

spiral light
#

not just update... setBlockState and then update maybe ?

eternal oxide
#

No just state.update()

#

Applies it back to the Block the state came from

dusty sphinx
#

update works

#

dope

#

thanks

wet breach
#

however caveat, I will only review it for 1.17+

#

only because I am not a fan of developing for older versions, however just because I am not a fan of it, doesn't mean I should punish/critique harsher on others for doing so even if I would prefer if the majority of devs would stop supporting outdated versions

#

if your repo is setup in a way that makes it easy to review code for differing MC versions I will only critique on the code for 1.17 🙂

#

Just letting you know ahead of time so that when I give you my review it isn't confusing XD

tardy delta
#

should i load users from the db in the pre login event or just on join?

tardy delta
grim ice
#

right?

tardy delta
#

yea looks weird

grim ice
#

not really

grim ice
#

as far as i remember

#

ive seen smth like this in a forum or smth

tardy delta
#

yea was just asking

dark arrow
#

hey i wanted to ask that i was working on crafting recipe but i have to make similar crafting recipe for 5 to 6 items so is there any way to do it faster rather than typing the whole code again and again

#

???????

grim ice
#

just use a method

#

to create the recipe

#

pass in the things that are different from each item to another in the params

dark arrow
#

is it possible that i make a varialbe 'x' thne use it every where in the method then i replace teh x with the string of the item?

grim ice
#

u mean like

#

x as a param?

#

then just method(x);

#

btw u shouldnt name variables 1 letters

dark arrow
#

ok

grim ice
#

1s i need this for a friend

#

?learnjava

undone axleBOT
wet breach
#

if I remember right, in the pre-login phase you can do all the stuff you want to and have a fairly long time to do so before connection gets dropped

#

and if for some reason the DB stuff isn't able to get fetched for whatever reason you can just terminate the connection

#

if you did this in the on Join phase, it has the potential of causing the server to lag, and because we already passed some protocol connection stuff, you have a shorter time to do stuff before the server automatically terminates the connection

#

and if the DB server stuff couldn't be fetched, they could potentially be stuck waiting on the connection to terminate

cold field
# wet breach I will review it later if that is ok

Ok get it. The problem is that I've used reflection to make it compatible with older version. I really wanted to avoid using reflection for 1.17 (Thanks to nms repackaging) the problem is that some classes has been compiled with java version 16+ and I can't compile the lib with java 8

wet breach
#

sometimes it is just necessary

#

reflection that is

cold field
#

Ok, thanks I really appreciate it

golden turret
#

anybody

trim crystal
#

I'm asking again, anyone know what's the equivalent of 1.8 mining fatigue -1 on 1.18?

#

I want to make it so that the hand animation moves the same as if the player doesn't has a mining fatigue but at the same time that the player doesn't damage the block on client side

sage patio
#

Hi, I have a problem with PlayerInteractEntityEvent
These is my code

public void onInteract(PlayerInteractEntityEvent event) {

        if (!(event.getRightClicked() instanceof Player)) {
            return;
        }

        Player player = event.getPlayer();
        Player target = (Player) event.getRightClicked();

        if (player.getItemInHand().getType().equals(Material.BLAZE_ROD)) {
            if (player.hasPermission("gtautils.cuff")) {
                if (Main.cuffs.contains(target)) {
                    Main.cuffs.remove(target);
                    player.chat("/uncuff " + target.getName());
                } else {
                    Main.cuffs.add(target);
                    player.chat("/cuff " + target.getName());
                }
            } else {
                player.getItemInHand().setType(Material.AIR);
                player.sendMessage(Utils.getColorizedConfig("noPermission"));
            }
        }

    }

      // I have a HashSet of Player in my Main class too

Problem is when I Right click on anyone, plugin runs both if and else codes.

golden turret
#

the event is called twice

#

see event.getHand

sage patio
#

Thanks

mellow gulch
sage patio
mellow gulch
#

the event has a getItem() which returns the itemstack in the hand, regardless of which hand it was

mellow gulch
# trim crystal 😔

wish i could help, i don't remember anything about 1.8, it was quite a long time ago

trim crystal
#

Do you know maybe how I can make sure that the hand moves normally (when you mine) but you don't damage the block, trying to figure it out with protocol lib but I'm not even sure if it'll do the job lol

mellow gulch
sage patio
golden turret
#

*PlayerInteractEntityEvent

trim crystal
mellow gulch
golden turret
#

use

#

PlayerInteractAtEntityEvent

spiral light
sage patio
golden turret
#

the getHand

tardy delta
#

cuffs.remove(target) will return a boolean whether or not it can be removed or not

sage patio
#

thanks

tardy delta
#

dont try to remove two times

#

it will check if it contains and remove it

trim crystal
#

Can anyone help me understand protocol lib? I'm reading the wiki and having a bit of a issue understanding

hybrid spoke
spiral light
#

the mining speed penalty ?

#

you cant

#

unless you add some speed / break the block before it should break with calculations ...

trim crystal
tardy delta
#

i'm having a player field somewhere in a class that extends bukkitrunnable, when the user leaves the server the runnable will be cancelled, will it be able to be gc'd?

hybrid spoke
#

manipulate packets

tardy delta
spiral light
tardy delta
#

also because its an inner class

hybrid spoke
#

doesnt matter

#

inner classes are like normal ones just.. inner.

tardy delta
#

and that outer class instance is stored in a map

trim crystal
#

I see, so for example if the wiki shows "Packet ID 0x09" it doesn't really concerns me right?

tardy delta
#

until the player leaves

#

so it was a bit weird

hybrid spoke
#

inner class just means that it belongs to the scope of the outer class

tardy delta
#

yea i know

#

i think that helped me

sage patio
tardy delta
#

dont make fields public tho

hybrid spoke
spiral light
sage patio
tardy delta
#

you dont want to expose them

spiral light
hybrid spoke
#

check if the hand is of OFF_HAND and return if so

trim crystal
#

https://prnt.sc/24o9pun
In protocollib if I have this packet, to change the ID I do:
packet.getIntegers().write(0, 1)
and to change the stage I do:
packet.getBytes.write(0, (byte) 1)
or did I understood in incorrectly, because if I didn't then how do I change the location?

Lightshot

Captured with Lightshot

hybrid spoke
#

having public fields in such a context breaks the concept of OOP kinda

trim crystal
tardy delta
#

packets are a pain

spiral light
#

its a nice to have

sage patio
hybrid spoke
#

bad metaphor but the point should be clear

spiral light
tardy delta
#

i'm always thinking if you really want to use something as obj.myfield make it like a method so you can call obj.field()

hybrid spoke
tardy delta
#

but yea i'm doing strange things sometimes

delicate cargo
#

2 things:

  1. how can i create a particle effect?
  2. how can i raycast?
spiral light
trim crystal
#

yep, thanks a lot!

spiral light
delicate cargo
#

perfect, tysm!

tardy delta
#

World#spawnParticle

#

you might need a loop and some maths for really an effect

delicate cargo
#

whats the spigot docs cmd?

hybrid spoke
#

?jd

delicate cargo
#

?jd World#spawnParticle

delicate cargo
#

oh

dark arrow
#

how will i use methind in plugin java cuz i am creating similar crafting recipies so i dont want to reapeat a code so much?

tardy delta
#

uhm

dark arrow
#

?jd

dark arrow
#

?jd method

tardy delta
#

?learnjava

undone axleBOT
trim crystal
#
@EventHandler
    public void onInteract(PlayerInteractEvent event){
        Location location = event.getClickedBlock().getLocation();
        for(int x = -2; x < 3; x++){
            for (int z = -2; z < 3; z++){
                PacketContainer blockBreak = protocolManager.createPacket(PacketType.Play.Client.BLOCK_DIG);

                blockBreak.getBytes().write(0, (byte) 5);
                blockBreak.getIntegers().write(0, x + z);
                blockBreak.getDoubles().
                        write(0, location.getX() + x).
                        write(1, location.getY()).
                        write(2, location.getZ() + z);

                try{
                    protocolManager.sendServerPacket(event.getPlayer(), blockBreak);
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                }
            }
        }
    }

I tried something pretty simple, but it says that the error is in line
blockBreak.getBytes().write(0, (byte) 5);
here is the document for this packet: https://wiki.vg/Protocol#Block_Break_Animation
or maybe I am using the incorrect packet

dark arrow
tardy delta
#

just create a method

#
dark arrow
chrome beacon
#

It's the same

buoyant viper
#

isnt there a method to send the player block break in bukkit?

tardy delta
#

just create a method that does some stuff and call it

buoyant viper
#

like sendBlockBreak or sendBlockDamage

dark arrow
#

i am making a code so that if i add diamond blocks around the diamond armour and it should give the armour with prot5 and that part is working but how will make into method thats the problem

#

cuz as far as i know we can put variable in method

#

and armour is a defined funtion

tardy delta
#

Player#sendBlockDamage?

patent horizon
#

where do gradle builds get output to?
maven usually outputs it in a target folder in the project

trim crystal
#

I'm suffering lol

#

been trying to figure this out all day

dark arrow
#

instead of ItemStack item = new ItemStack(Material.DIAMOND_HELMET)

#

what should i w rite in teh mothod

#

so that i could replace the called method with the armour i need

buoyant viper
#

maybe its BLOCK_BREAK_ANIMATION? @trim crystal

#

that matches up with the 0x09 packet id

trim crystal
tardy delta
trim crystal
buoyant viper
#

rip

#

i think u were also sending a client packet from the server so

#

lol

#

or trying to

trim crystal
#

oh lmao, I'm pretty new to this XD

buoyant viper
#

on phone cant see that

trim crystal
#

oh lol, I have this line as well: [ProtocolLib] Loaded class RPrison.rprison.Rprison from Rprison v1.0-SNAPSHOT which is not a depend, softdepend or loadbefore of this plugin.

dark arrow
trim crystal
# buoyant viper on phone cant see that

Caused by: com.comphenix.protocol.reflect.FieldAccessException: No field with type byte exists in class PacketPlayOutBlockBreakAnimation.
This is the main error here

buoyant viper
#

uhh

#

maybe try writing in the order of packet fields on wiki? idk

so write the int, then the location(x3 doubles, or int depending on how it wants loc?), and then the byte

#

never used protocollib either so shots in the dark rn

trim crystal
#

lmao let's see if that works

#

nope, didn't change a thing

buoyant viper
#

rip

trim crystal
#

yep XD

hexed hatch
#

will Entity#remove function even if the entity is not in a loaded chunk?

tall dragon
#

which will not happen in an unloaded chunk

tardy delta
#

is the String::replace to prevent SQL injection?

String statement = "SELECT * FROM playerdata WHERE player_id='{id}'";
            pStatement = connection.prepareStatement(statement.replace("{id}", uuid + ""));```
trim crystal
candid galleon
tardy delta
#

tell me how to do then

#

its not my code tho

grim ice
#

just

#

learn java

#

okay

#

u wouldnt need to waste time for such a simple task if u knew java

#

private void nameThisWhatever(Material material) {}

#

actually replace void with the class name

#

was it shaped recipe

#

or smth

#

wait nvm

trim crystal
#

Is there anyone here that knows how to use protocollib?

chrome beacon
#

Yeah

tardy delta
#

how would i save a list of channels (strings) in a database?

#

i was thinking of saving it as one string with a delimiter

#

i could make a new table with channels and inner join it with the users, goes kinda brrr

tardy delta
#

does this looks clean lol

public User getUser(UUID uuid) {
        return userCache.values().stream().filter(u -> uuid.equals(u.getUuid())).findFirst().orElseGet(() -> {
            String sql = "SELECT * FROM playerdata WHERE uuid='" + uuid + "'";
            try (Connection conn = Database.getInstance().getDatasource().getConnection();
                 PreparedStatement ps = conn.prepareStatement(sql)) {
                ResultSet rs = ps.executeQuery();
                if (rs.next()) {

                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return null;
        });
    }
#

userCache is a map<uuid, user> tho

sudden raft
#

even if uuid is UUID, i would recommend using PreparedStatement#setString instead of concatenating

tardy delta
#

oh uh lets assume its better

sudden raft
#

also userCache.values().stream().filter(u -> uuid.equals(u.getUuid())).findFirst() time complexity is O(n) (linear)

#

instead, you could use uuid as key

tardy delta
#

so like this and then replace it
String sql = "SELECT * FROM playerdata WHERE uuid='?'";

#

xd i was trying to do some stream stuff

#

ah i can remove the ' '

#

also whats the best way to save a players playtime to a db? rn im saving an int with the total minutes they have played since they joined?

peak granite
#

if i have a home list in a player data file like this:
Homes:
HomeName:
Location: ....
AnotherHomeName:
Location: ....
how do i get the amount of homes, when i do getStringList(Homes).size() it returns 0

tardy delta
#

its not a list

#

a stringlist == ```yaml
key:

  • 'value1'
  • 'value2'```
#

do getConfiurationSection("homes").getKeys(false).size()

hexed hatch
#

is there no api for leashing entities to fenceposts?

#

I can get the leashholder entity

#

but I can't do anything with the api equivilent to this: /summon pig ~ ~ ~ {Leashed:1b,Leash:{X:32,Y:32,Z:32}}

grim ice
tardy delta
#

also is it possible to return in a HashMap::forEach?

#

doesnt work so i guess no

#

Map.Entry goes brr

buoyant viper
#

lambda expressions do have their caveats

tardy delta
#

true

formal bear
#

ik its about java not exactly spigot, but how to make timeout, like 1 second after

peak granite
#

runtasklater

tardy delta
#

isnt that a responsability for the fence or the leash itself?

spiral light
#

playerConnection now is "a" or smth like this

buoyant viper
#

sounds like a remap issue

spiral light
#

i think he does not use the mojang remappings ...

tardy delta
#

efficiency is something else i guess xd

brave sparrow
#

Since userCache is a map you should just do userCache.get(uuid)

#

The whole point of a hashmap is the key based access

tardy delta
#

BRRUUHHHHH

#

im stupid

brave sparrow
#

Otherwise you could just be using a list

tardy delta
#

did i just....

#

do this..

#

bruhh its because it was an arraylist first and i didnt change it

sudden raft
#

you could also use computeIfAbsent

brave sparrow
#

The .get() is the main reason to use a hashmap, it gives you amortized constant time access by key

#

You wouldn’t want to use computeIfAbsent here

sudden raft
#

return userCache.computeIfAbsent(uuid, k -> {
// execute query to database
return user;
});

#

my english is broken

tardy delta
#

yea i understand 😄

#

sometimes i'm just doing suck stupid things

brave sparrow
#

Are you synchronizing access to userCache

#

Or how are you maintaining thread safety

tardy delta
#

i'm not using it on multiple threads

brave sparrow
#

You’re doing database calls on the main thread??

tardy delta
#

yea i was planning to do it async

brave sparrow
#

You have to do it async

tardy delta
#

still implementing db stuff

sudden raft
#

I think using a ConcurrentHashMap is enough to make it threadsafe

#

at least in this case

brave sparrow
#

I mean, using a sledgehammer to kill a fly

digital rain
#

hey why is the default player inventorytype crafting instead of player, ig its intended but its a bit weirdly described on hub.spigot

brave sparrow
#

But yeah lol

wet breach
brave sparrow
#

There’s performance trade offs to using concurrent hashmap

tardy delta
#

i'm storing an <uuid, user> where user is a player wrapper

wet breach
brave sparrow
brave sparrow
wet breach
#

what I mean is while there is trade offs with ConcurrentHashMap, most of the time you are going to see performance boosts

#

not the the other way around unless you are stuffing a crap ton of data into it

young knoll
#

IIRC you only need to use the concurrent one if you are modifying it from multiple threads

#

Reading is fine

wet breach
quaint mantle
#

Reading can cause a write operation as well

brave sparrow
#

No it can’t

#

If there’s a write associated with your read then it isn’t a read

#

However

#

You do have to worry about synchronization when reading from multiple threads if there are writes happening

#

And in this case there would be writes happening

quaint mantle
#

thats a myth; reading is not always thread safe. If you read and write at the same time, it will cause cme

brave sparrow
wet breach
brave sparrow
#

I’m not disputing that it will work

#

It’s just unnecessary

#

And there’s also memory overhead to think about if you don’t configure it with an appropriate concurrency level for your use case

formal bear
#

why is it highlighted?

hexed hatch
#

anyone know if there's an event for cancelling spectating an entity?

brave sparrow
peak granite
#

when i do config.set("Homes", null); it doesn't truly set Homes value to null in config like Homes: {} how can i make it actually set

#

it just skips

brave sparrow
brave sparrow
hexed hatch
#

Which is absolutely sickening to me

#

but it does work

brave sparrow
#

Lol

#

Hacky solutions always make my soul hurt but they get the job done

flat belfry
#

damn alex from mp

#

Do you just handle java

buoyant viper
#

whats java

brave sparrow
#

Technically I do both but my main focus is Java

#

I don’t think this is the right channel for that though lol

wet breach
#

sure, you could think about it and what not, but better to design and getting it working first then to sit there and think about which API method in Java is more optimal to use

brave sparrow
#

Just jumping into something without thinking it through is how you make a mess and accumulate a massive amount of technical debt very quickly

wet breach
#

you end up in just a dev cycle if you attempt that

#

and never release 🙂

brave sparrow
#

There’s a difference between not designing every component before you start and not designing anything before you start lol

#

This is a simple thing to think about

naive jolt
#

Hey, is there a work around to getting access(in another class) to this player, in the event

public void DamageEntity(EntityDamageByEntityEvent event) throws IOException {
       if(event.getDamager() instanceof Player) {
           Player damager = (Player) event.getDamager();

       flagCount.get(damager.getName());```
#

the damager var

fleet imp
#

I'm referencing getConfig() in an interface that doesn't have a static modifier. It gives me a problem: Non-static field 'config' cannot be referenced from a static contex

brave sparrow
wet breach
# brave sparrow This is a simple thing to think about

well we obviously have differing opinions. I am of one that will answer your questions and tell if you something will work and what not, however not really my job to inform and teach nuances of the Java API which is where you seem more concerned with 🙂

#

You don't become a good developer by not making mistakes

brave sparrow
#

You can make mistakes, or you can get some wisdom from somebody who has already made the mistake and can teach you the lesson directly

#

The end result is the same

delicate cargo
#

how can i shift a location forwards>

brave sparrow
delicate cargo
#

i mean on 1 dir

brave sparrow
brave sparrow
delicate cargo
#

so like shift forwards relative to player rot

trim crystal
wet breach
# brave sparrow The end result is the same

not quite, unless the mistake is going to kill someone or harm someone I agree, however you tend to remember better by being allowed to do something wrong and learning from your own mistake as opposed to someone else's mistake and never understanding why fully the other way is bad in some way

fleet imp
trim crystal
delicate cargo
wet breach
#

but like I said we obviously have differing opinions which that is ok

brave sparrow
wet breach
#

and not necessarily need to debate our differences XD

buoyant viper
#

his issue iirc was not having the right fields for BlockBreakAnimation

trim crystal
brave sparrow
delicate cargo
#

im just seeing loc.add(vec)

#

aka add a vectors coords to a loc

brave sparrow
#

Correct

#

A vector is a direction

delicate cargo
#

oh

#

oh damn i understand it now

#

its not rotational values

trim crystal
naive jolt
delicate cargo
#

but instead the shift needed for moving forward

brave sparrow
#

If you just want to use the player’s direction there’s methods for that

brave sparrow
naive jolt
#

yes

#

it is

brave sparrow
#

So are you just trying to show them their own flags?

young shell
#
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] HCurrencyAPI-1.0-SNAPSHOT.jar, Hubcore-1.0-SNAPSHOT.jar define 1 overlapping resource: 
[WARNING]   - plugin.yml
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
``` How can I fix this
brave sparrow
young shell
brave sparrow
trim crystal
buoyant viper
#

gradle, on the other hand, flips its sh!t over something like duplicate files

#

or at least it did for me

naive jolt
#

so I need to supply the Player

#

but then the player is in that Event

#

as a local variable

brave sparrow
#

The player is the sender of the command

formal bear
#

Name of the plugin: should be main class? Which "name"

brave sparrow
#

There’s VarInt, Position and byte

#

So those are the fields you have to set

buoyant viper
#

wouldnt position be 3 doubles tho?

brave sparrow
#

It would

buoyant viper
#

or maybe 3 ints if its picky

brave sparrow
#

But you can’t just set position to 3 doubles

trim crystal
#

How can I get to the position? as I saw there are only:
getDoubles();
getFloats();
getIntegers();
getBytes();
didn't see anything to position so I could write on..

brave sparrow
#

I’m not super familiar with the protocol lib methods but according to your error that is the issue

#

Maybe see what Position is made up of

brave sparrow
brave sparrow
#

The command doesn’t need to reference the event

trim crystal
fleet imp
naive jolt
#

/flags another player

buoyant viper
naive jolt
# brave sparrow The player is in the command itself as the sender, the event has a variable and ...

Here's the code

if (sender instanceof Player p){
            HashMap<String, Integer> flagCount = damage.getflagCount();
           if(p.hasPermission("HyperCheat.checkFlags")){
               if (args.length == 0){

                   p.sendMessage(flagCount.get(damage.getPlayername) + " is the amount of flags" + p.getDisplayName() + " has.");
               }else{
                   Player target = Bukkit.getPlayerExact(args[0]);
                   if (target instanceof Player){
                       p.sendMessage(flagCount.toString() + " is the amount of flags" + target.getDisplayName() + " has.");
                   }
               }

           }else{
               p.sendMessage(ChatColor.RED + "You do not have the required permissions(HyperCheat.checkFlags) to use this command");
           }

        }```
wet breach
#

unlike in game where you are used to xyz, it is in the packet as xzy @trim crystal

brave sparrow
#

Still not the event

wet breach
#

26 bits for x and 26 bits for z, y having only 12 bits

naive jolt
wet breach
#

((x & 0x3FFFFFF) << 38) | ((z & 0x3FFFFFF) << 12) | (y & 0xFFF)
from wiki.vg they give you an example to encode it properly

brave sparrow
#

The player in the event is totally irrelevant to the player in the command

naive jolt
#

Okay let me explain a bit more

brave sparrow
#

Even if it’s the same player

formal bear
brave sparrow
wet breach
#

?di

undone axleBOT
trim crystal
trim crystal
naive jolt
brave sparrow
wet breach
trim crystal
#

❤️

wet breach
#

how protocolLib does stuff isn't the same from the wiki.vg

#

so you need to refer to their API stuff

#

ProtocolLib attempts to make it easier instead of messing with stuff like I was showing for example

buoyant viper
#

just wasnt sure what the position field was for protocollib

brave sparrow
buoyant viper
#

but that byte field might yell at u since that spigot page showed int

wet breach
#

I didn't realize protocolLib was being used here otherwise I wouldn't have bothered referencing wiki.vg stuff XD

buoyant viper
#

his original message showed protocollib code lol

fleet imp
wet breach
buoyant viper
#

yea it was uhh

brave sparrow
#

@fleet imp you’re providing too much implementation for a Java interface

#

All the interface really includes is method signatures

#

The implementation comes from implementing classes

fleet imp
#

how to i convert a string to int or bool

spiral light
#

Integer.parse###

#

same for bool

loud vessel
fleet imp
#

thx

lyric grove
#

Hi, im getting a npe although i dont see why i am

#

as i made sure i set it if absent

buoyant viper
#

is actions null?

lyric grove
buoyant viper
#

thats just a class

#

i mean the actions field

lyric grove
#

i set the action as a new linked list so yeah

buoyant viper
#

still not what i'm talking about

#

this.actions

#

the field, actions

loud vessel
# lyric grove no

Output this.actions to the console to understand that it is not null

buoyant viper
#

is that null?

lyric grove
#

oh no i save it on disable and load it onenable

brave sparrow
#

Is an exception being thrown in your loadActions()?

#

If so actions would never be assigned

lyric grove
#

there isnt any exeption

#

and actions are being assigned, idk why its giving me a npe when i try to access them

#

(i store it using json)

brave sparrow
#

Is there any more to the error?

lyric grove
#

I dont think so

brave sparrow
#

Ok, can we see the whole getFromUUID with line numbers?

lyric grove
brave sparrow
#

Right before line 55 can you throw in a system print outputting this.actions

lyric grove
buoyant viper
#

can you add a System.out.println("" + actions) before calling the return in getFromUUID

lyric grove
#

ok

buoyant viper
#

or like an

if (actions == null) System.out.println("uhoh");

young shell
#

shouldn't Javaplugin#saveDefaultConfig() create a Folder with the plugin name and the config file inside?

brave sparrow
#

If you’ve set up config defaults it should

young shell
#

So if the config File is inside the resources folder right?

tardy delta
#

yes

lyric grove
#

oh what? actions is null

#

well rip, i did something wrong

olive lance
#

How did you guys deal with PayPal asking for purchase receipts when you accept payment for good and services? When you didn’t purchase anything

buoyant viper
#

sounds like that wasnt an email from paypal then

olive lance
#

I sold a plugin on spigot and they want purchase receipts for verification cause they think I’m reselling or something

#

PayPal sucks fr

cold pawn
#

I’m making a chat plug-in we’re it gets the players around a player and sends the message that the player sends only to them. Practically Proximity chat. I’ve tried using the distance method in the players location and the getNearbyEntities Method but they don’t seem to work. It doesn’t give me any errors in console it just doesn’t get the players around that specific player. Any other way I can do this? 😅

hasty prawn
#

Entity#getNearbyEntities

young knoll
#

Nah

hasty prawn
#

And then filter to Players

#

It works

young knoll
#

You probably want to use distanceSquared for something like this

cold pawn
#

Didn’t work

hasty prawn
hasty prawn
hybrid spoke
young knoll
#

Nothing, but when you want a big radius and only players its probably more efficient to loop over all players in that world

hasty prawn
#

Proximity Chat usually isn't that large of a radius

#

Guess it depends on what you define as a large radius

young knoll
#

Like, 50

hybrid spoke
#

looping over the players will be more performant

hasty prawn
#

Yeah that's pretty big for prox chat

cold pawn
#

And I clear the recipients list before

hybrid spoke
#

so you are doing smth wrong

hasty prawn
#

^

#

When you're back at your computer send code

young knoll
#

We can’t really so much without the code

cold pawn
#

Ok then I’ll do that in a bit 😅

fleet imp
#

how do i send text to chat with a plugin

young knoll
#

To one player? All players?

fleet imp
#

all

young knoll
#

Bukkit.broadcastMessage

lyric grove
# lyric grove

anyone know why actions would be null even when im loading it?

young knoll
#

If logfileroot already exists you don’t load anything

buoyant viper
#

^

lyric grove
#

omg thank you so much i hope this works

wide flicker
#

Anyone know how to force a plugin to use a dependency packed with it instead of the version packaged with the server? (Gson version used is about 5 years out of date; trying to use the latest version, but it seems to be sticking with the server provided copy...)

young knoll
#

Shade and relocate it and it should be used

vocal cloud
#

Yeah if you shade it it will use internal dependencies.

young knoll
#

Relocate is the important part

wide flicker
#

Gotcha, I'll look into it. Thanks!

subtle folio
#

Im using a PlayerMoveEvent for a trampoline thing im making. I want to make a block then when stepped on, breaks. I currently do this with metadata as such java if (!isUsed(belowLoc.getBlock())) { event.getPlayer().sendMessage("hasnt been used"); event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(1.2)); belowLoc.getBlock().setMetadata("UsedOnce", new org.bukkit.metadata.FixedMetadataValue(Trampotdi.getInstance(), true)); } else { event.getPlayer().sendMessage("has been used"); event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(1.2)); belowLoc.getBlock().setType(Material.AIR); }

#

In chat I see both hasnt been used and has been used

#

the block instantly deletes, any idea how to fix?

#

the isUsed function if youre curious public boolean isUsed(Block b) { List<MetadataValue> metaDataValues = b.getMetadata("UsedOnce"); for (MetadataValue value : metaDataValues) { return value.asBoolean(); } return false; }

young knoll
#

The event gets called a lot

harsh idol
# subtle folio In chat I see both hasnt been used and has been used

Make sure the event isn't triggered twice or more by adding a cooldown for exemple. With your code, the PlayerMoveEventwill be triggered multiple times
(When the player velocity is updated, the player move again, triggering the event, that make the player move again, etc.)

young knoll
#

So it’s getting called twice when the player steps on it

subtle folio
#

Yeah, im seeing that I put the from and to methods location's to strings. I guess a cooldown is nessasry