#help-development

1 messages ยท Page 2080 of 1

wet breach
#

linux already supports GUI redirect

spiral aurora
#

how does one make it such that a villager gets infected at any difficulty
this is my current code now:

public class VillagerInfectEvent implements Listener {
    @EventHandler
    public void onInfected(EntityDeathEvent ed){
        LivingEntity e = ed.getEntity();
        if(e instanceof Villager){
            Villager vill = (Villager)e;
            EntityDamageEvent entityDamageEvent = vill.getLastDamageCause();
            if(entityDamageEvent == null) return;
            if(entityDamageEvent.getCause().equals(ENTITY_ATTACK)){
                //what do i do here
            }
        }
    }
}```
wet breach
#

so do most SSH applications

#

putty supports it, I just don't use putty for it

spiral aurora
worldly ingot
#

Don't think there's API for that at the moment, but Villager#zombify() is being PR'd at the moment

noble lantern
#

your welcome choco!

wet breach
noble lantern
#

you can merge now ๐Ÿ™‚

wet breach
#

since that is what the code does

tender shard
noble lantern
#

oh yes

tender shard
#

public void zombify();

noble lantern
#

lemme contact the bukkit devs directly

tender shard
#

here you go

noble lantern
#

oh hell yeah

#

there we go choco

#

were all set

worldly ingot
wet breach
noble lantern
#

jsut change type and worry about it later

tender shard
#

exactly

wet breach
#

technically not on the bukkit dev team anymore, but I don't think people at this point care about the technicalities anymore ๐Ÿ˜›

noble lantern
#

wait

#

you were a bukkit dev

worldly ingot
noble lantern
#

sheeesh

worldly ingot
#

He's old

wet breach
#

Yeah I was a bukkit Dev staff member ๐Ÿ˜„

noble lantern
#

damn right he is

spiral aurora
noble lantern
#

he could be my dad almost

wet breach
#

assuming zombie villagers have trades, been a while since I messed with them

worldly ingot
#

You'd have to keep track of it because there's no API for setting the villager data of a zombie

#

(hence the #zombify() API being added)

wet breach
#

so probably

tender shard
wet breach
#

not sure why you thought that, like I idk how many times I tell people my age lmao

tender shard
#

does zombify "exchange" an existing entity into a zombie thing, or does it create a new entity?

wet breach
#

technically creates a new entity

#

since both are not the same internally

tender shard
#

yeah but I mean

wet breach
#

even the internal code kills the previous entity

tender shard
#

if I do this:

Villager frostalf = Bukkit.getEntity(...);
frostalf.zombify();
// is frostalf now still a valid reference to the now zombified frostalf?
wet breach
#

oh I see

#

yeah it should still be valid

#

unless they screwed it up for it

tender shard
#

are you sure? because this means that the frostalf object changed it's class

wet breach
#

but technically it should keep that reference

#

Well, most entities can be reduced to just entity class

crimson terrace
#

does zombify() return anything?

tender shard
#

that's the question ๐Ÿ˜„

worldly ingot
#

The zombified entity

tender shard
#

ah ok

crimson terrace
#

well then thats that XD

tender shard
#

so it indeed replaces it by returning a new entity

wet breach
#

makes sense that is the easier way

#

without hacking many things

tender shard
#

btw did you people know about the light block?

worldly ingot
#

It's a new entity

crimson terrace
tender shard
#

there's now a block called "Light" that is invisible (like barrier blocks) and that you can walk through (so basically like air) but you can set a custom light level between 0 and 15 for it

#

ITS SO AWESOME

wet breach
#

we can now cause epileptic seizures more easily now

#

oh wait, don't think that is the purpose of it

tender shard
#

lol my bf created a "garbage tower"

wet breach
#

as if the tower garbage made a difference

tender shard
wet breach
#

@noble lantern you should benchmark those math utils you have now

#

be interesting to see how much more efficient they are over the traditional methods

tender shard
#
public interface MathUtils {
  int add(int a, int b);
}
wet breach
#

I don't mean in terms of writing them out efficient

#

meant in execution wise

#

the addition one might be a bit harder to benchmark

#

because I mean its pretty efficient in java as it is XD

tender shard
#

everyone watch out

#

!True is going to ask a question

wet breach
#

we almost have a complete window typing

regal lake
#

I have a strange behavior, for me it seems the saturation of the food is maybe broken on spigot.
The wiki (https://minecraft.fandom.com/wiki/Hunger#Food_level_and_saturation_level_restoration) says a bread gives you 6 saturation points.
I tested it with the following code, but it gives me different saturations (5, 2.5, 3.75, ...) for the bread.

@EventHandler
    public void playerItemConsumeEvent(PlayerItemConsumeEvent event) {
        ItemStack itemStack = event.getItem();
        Material material = itemStack.getType();
        if (!material.isEdible()) {
            return;
        }

        Player player = event.getPlayer();
        float beforeSaturation = player.getSaturation();
        Bukkit.getScheduler().runTaskLater(this.main, () -> {
            float newSaturation = player.getSaturation();
            float saturationDiff = newSaturation - beforeSaturation;

            Bukkit.broadcastMessage("gained saturation: " + saturationDiff);
        }, 1L);
    }
wet breach
#

have you checked your spigot.yml?

sage dragon
regal lake
tender shard
tender shard
wet breach
#

I am pretty sure the test isn't designed properly

regal lake
wet breach
#

you can get the players saturation before they eat, and after they eat. You wouldn't test it before the event completes though at least not that event. You need to know what their points were before and then need to wait till the event completes to then see what is after

regal lake
#

wtf o.O

wet breach
#

as expected ๐Ÿ™‚

tender shard
#

I always tp'ed myself 10 blocks up to lose some health, until I lost hunger level, then ate a bread

#

it was always 6

outer loom
lavish hemlock
#

EssentialsX

tender shard
outer loom
#

ok thx

wet breach
#

did you use the same code @tender shard or did you alter it?

lavish hemlock
#

It's surprising to hear somebody doesn't know what Essentials is

wet breach
#

interesting

tender shard
#

I only changed this.main to this

wet breach
#

probably the reason they are having issues lol

tender shard
#

lol

wet breach
#

anyways food items are not broken in spigot

#

whatever you are doing is causing it to do something different @regal lake

regal lake
#

I try to figure out what happens here ๐Ÿค”

tender shard
#

you got any other plugins?

#

oooor

#

maybe

#

your saturation was already almost full when you ate

#

so it hit the limit

regal lake
#

No, i always set the saturation to 0 with the hunger effect

tender shard
#

oh ok

#

then I have no idea tbh

wet breach
#

maybe that is where it is going wrong for you in regards to your test

regal lake
#

I will setup a fresh spigot server without any other plugins and add one ofter the other

wet breach
#

but more curiously not sure what gave you the inclination you needed to test the saturation levels to begin with

regal lake
#

I want to increased the gained saturation, that was the reason why i saw that the gained saturation changed ๐Ÿ˜›

wet breach
#

ah ok

noble lantern
#

who

#

pinged

noble lantern
#

but when i do use them i will ๐Ÿ˜›

noble lantern
wet breach
lavish hemlock
#

cock

noble lantern
#

oh sorry i mispelled flashlight

tender shard
tender shard
wet breach
#

chicken

cursive loom
#

Hello seameone know how I can't but a sign on front face of a chest when I put him ?
I have try that but didn't work

                if (b.getBlockData() instanceof Chest) {
                    Chest chest = (Chest) b.getBlockData();
                    BlockFace face = chest.getFacing();
                    BlockState sign = b.getRelative(face).getState();

                    sign.setType(Material.OAK_WALL_SIGN);
                    ((Directional)sign).setFacing(face);
                    sign.update();
                }
opal juniper
#

you need a wall sign iirc

quick plank
#

How can i get the UUID of a player that is offline?
I am saving the playtime in seconds to a file every time a player logs out and i want to be able to get the playtime of that player when offline.
This is what my .yml file looks like ```yaml
users:
UUID-HERE:
playtime: 48242

This is what i'm using in my code to get the "targeted player" `Player targetPlayer = Bukkit.getPlayer(args[0]);`
But if the player is offline it is just returning null...
opal juniper
#

Bukkit.getOfflinePlayer

quick plank
#

Yes, i have read about that... But i still need to get the UUID

#

And how should i do that?

opal juniper
#

it returns an OfflinePlayer, which you can call getUniqueId()

wet breach
cursive loom
opal juniper
#

if i remember correctly

crimson terrace
wet breach
crimson terrace
#

๐Ÿ˜›

wet breach
#

we want to know what is iirc

wet breach
#

so fun fact since I had a bit of fun with some math earlier

noble lantern
#

lets us stream

#

in vc

wet breach
#

There is no well defined function for the perimeter of an ellipse

opal juniper
#

huh

quick plank
opal juniper
#

yes

wet breach
#

in other words, you can only approximate the perimeter of an ellipse

quick plank
#

'getOfflinePlayer(java.lang.String)' is deprecated

#

...

opal juniper
#

rtfm

#
Deprecated.
Persistent storage of users should be by UUID as names are no longer unique past a single session.
wet breach
#

because the player is offline

#

anyways, is deprecated for the reasons it states in the javadocs, however that doesn't mean your server magically updated the record of the player name so it is still valid in some cases to use the player name to fetch the UUID of the player if they are offline. The exception of this is if there is no record on your server, it will contact mojang API to get the UUID instead ๐Ÿ™‚

#

I really need to start my own teaching channel lmao

#

or a channel that has these weird facts that no one really thinks abouts

drowsy harness
#

can i ask a question about packets / nms here?

quick plank
#

I still don't get it...
I know about the deprecated stuff but i just can't get other stuff to work...

wet breach
wet breach
quick plank
#

Yes, i'm just gonna try something

drowsy harness
#

spawning an itemframe with packet f***s the rotation

#

Is there some additional packet I need to send?

wet breach
#

the best place to go in regards to looking up packet stuff as its really the only place that has it the most documented

drowsy harness
#

excuse me for being dumb, packets not my thing, but how am i using the wrong values, when im supplying the data watcher of an existing entity?

quick plank
#

It's kinda messy

wet breach
#

ok

#

so you can fix this

quick plank
#

But i think it is working...

wet breach
#
                Player targetPlayer = Bukkit.getPlayer(args[0]);
    
                UUID ofPlayer = Bukkit.getOfflinePlayer(args[0]).getUniqueId();

So this needs to be fixed

#

this is how its going to get fixed

#
OfflinePlayer offPlayer = Bukkit.gettOfflinePlayer(args[0]);
UUID playerUUID = offPlayer.getUniqueId();
#

if you need to that Offline player to be a player Object because maybe they are online? (for future reference)

#

you can do this

if (offPlayer.isOnline()) {
    Player player = (Player)offplayer;
}
//or we can also do this since you got the UUID
Player player = Bukkit.getPlayer(playerUUID);
mellow edge
#

why does that code only detect fly hacks and not speed hacks? : ```java
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
if (!e.getPlayer().hasPotionEffect(PotionEffectType.SPEED)) {
if (e.getFrom().distance(e.getTo()) > 4.317) {
//code
}

wet breach
#

but for your usage you want to use offlineplayer because your code actually doesn't require there to be a Player object and also there is a possibility they can be offline so because of that we can just use offlineplayer and save the time for null checking ๐Ÿ™‚

wet breach
#

I think what you would need to do is possibly add to the meta that it is attached to a block?

quick plank
#

Alright, so then i won't need to to do if (targetPlayer == null)?

wet breach
#

exactly ๐Ÿ™‚

quick plank
#

Alright, i'm gonna try and see if i can get it to work properly

#

Thanks for the help!

drowsy harness
wet breach
wet breach
# drowsy harness so i'm not really expecting an answer because you said you're not the best to as...
       {
                    EntityPlayer nmsplayer = ((CraftPlayer) p).getHandle();
                    EntityItemFrame itemframe = new EntityItemFrame(nmsplayer.world);
                    itemframe.setLocation(e.getValue().getX(), e.getValue().getY(), e.getValue().getBlockZ(), 0, 0);
                    itemframe.setItem(CraftItemStack.asNMSCopy(getMap(e.getKey())));
                    nmsplayer.playerConnection.sendPacket(new PacketPlayOutSpawnEntity(itemframe, 71));
                    nmsplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(itemframe.getId(), itemframe.getDataWatcher(), false));
                }

this is how an itemframe packet should look

#

this specific code sets the itemframe to have a map in it

quick plank
wet breach
#

OfflinePlayer doesn't require the player to be online, and even if the player is online it is still fine

quick plank
#

Hmm okay, but am i doing this correct? Player targetPlayer = Bukkit.getPlayer(playerUUID);

wet breach
#

you only need the Player object if what you are doing requires there to be an online player, such as sending the player in question a message for example which you don't do

drowsy harness
wet breach
quick plank
#

Alright

drowsy harness
#

setting false in the meta packet, doesn't display the item in my tests

wet breach
#

I will leave it to someone else more suited to help ๐Ÿ™‚

#

hopefully someone who is, is online or will be online soon lol

drowsy harness
#

alright, well thank you ig

quick plank
#

And this i should just leave like this?

wet breach
#

yeah its fine

#

just because it is deprecated doesn't mean can't be used, it is just important you understand why it is deprecated

quick plank
#

Yeah, but if someone would change their name... what would happen? Do they just need to log in again before it can be used?

wet breach
#

if someone changes their name, but hasn't re-joined your server

#

you will still get the correct UUID

quick plank
#

Ohh okay

wet breach
#

however, if say you know their name but haven't joined yet

#

and lets say they changed it and didn't tell you

#

now the server is going to contact Mojang API since they hadn't joined your server

#

and fetch the UUID for that name, which could be someone else, since that player changed their name and that isn't their name anymore

quick plank
#

Yeah alright

wet breach
#

for your purposes of how you are using it, it is fine

quick plank
#

๐Ÿ‘

#

Thanks a lot for the help!

#

I have been trying to figure this out for like 2 days now

wet breach
#

well that is part of the learning process

#

and not everyone learns at the same pace ๐Ÿ™‚

quick plank
#

Yep ๐Ÿ™‚

tender shard
#

I'm a genius, change my mind

public class HookHandler {

    private static final boolean worldBorderApiInstalled;

    static {
        worldBorderApiInstalled = Bukkit.getPluginManager().getPlugin("WorldBorderAPI") != null;
    }

    public static boolean isInsideWorldBorder(Location loc, Player player) {
        if(!worldBorderApiInstalled) return true;
        try {
            return WorldBorderApiHook.isWithinWorldWorder(loc, player);
        } catch (Throwable throwable) {
            return true;
        }
    }

}
mellow edge
#

what does player.getVelocety(); do

warm dust
#

Its better to do events private ?

slim kernel
#

Why cant I use 1.18.2 there?

warm dust
#

It will work with 1.18.1

#

I do the same

worldly ingot
slim kernel
warm dust
#

I do my plugin in 1.18.1 spigot in a server of 1.18.2

burnt current
#

Hey, short question: I try to programm, that mobs (for example two zombies or one zombie and one skeleton) fight against each other. Someone said i should use living entities for that and i saw that there is a attack() method for living entities. But i have the problem that idk how to work with living entities. Does maybe someone have an tutorial for working with living enties?

drowsy harness
tardy delta
#

check the permission yourself

arctic moth
#

for whatever reason, doing CreatureSpawnEvent doesnt trigger for stuff like golems and withers

#

any ideas what should be used>

#

?

delicate lynx
#

it should, can you show the code section?

tardy delta
#

ye i just read a post on the forum and t indeed should

#

did you register the event?

arctic moth
#

yes

#

if i summon it, it works, but if i build it it doesnt

#

those buffs apply to every mob, but i have some health-specific things in the wither that require the buff to be there on the wither

tardy delta
#

@EventHandler(ignoreCancelled= true) is something

#

better readability

arctic moth
#

oh

tardy delta
#

also if else if else if instead of if if if

#

or even a switch :p

quaint mantle
#

Dont create a random object every time just have one main object in your class

arctic moth
#

ive always wondered why they have an object for random

#

instead of just a function

tardy delta
#

ThreadLocalRandom.current() also returns a random

#

which is bound to the current thread or something

arctic moth
#

oh

#

anyways, why isnt the event triggering when the wither spawns

#

maybe attributes cant be added until it explodes?

quaint mantle
#

how do you know the event doesnt trigger?

arctic moth
#

idk maybe it does

quaint mantle
#

put a debug line to check for sure

tardy delta
#

add a sysout

arctic moth
quaint mantle
#

yea whatever floats your boat

#

all the same

tardy delta
#

@noble lantern knows everything about whats the best way to log

#

:)

noble lantern
#

Bukkit.broadcastMessage()

tardy delta
#

xd

noble lantern
#

ez

exotic jetty
#
PacketContainer packet53 = protocolManager.createPacket(53);
            packet53.getIntegers().write(0, x).write(1, y).write(2, z).write(3, 63).write(4, 0);
            packets.add(packet53);

            PacketContainer packet130 = protocolManager.createPacket(130);
            packet130.getIntegers().write(0, x).write(1, y).write(2, z);
            packet130.getStringArrays().write(0, defaultText);
            packets.add(packet130);
        }

        PacketContainer packet133 = protocolManager.createPacket(133);
        packet133.getIntegers().write(0, 0).write(1, x).write(2, y).write(3, z);
        packets.add(packet133);

        if (defaultText != null) {
            PacketContainer packet53 = protocolManager.createPacket(53);
            packet53.getIntegers().write(0, x).write(1, y).write(2, z).write(3, 7).write(4, 0);
            packets.add(packet53);
        }

so im trying to make some sign gui but the source is kinda old. here i get errors by the numbers. are these diffrent in newer versions? im using protecollin

arctic moth
#

yes it gets triggered

#

@tardy delta

#

but no buffs

tardy delta
#

did you add a sysout at the end of the code?

arctic moth
#

yes

tardy delta
#

so it fully executed

arctic moth
#

my guess is buffs reset when it fully spawns

#

after chargeup

#

any idea how many ticks the chargeup is?

summer scroll
#

Have you tried to add a delay? Like 1-3 tick

arctic moth
#

yes

#

its the chargeup thingy i think that breaks it

#

cuz summoning it works and it doesnt have the chargeup time

noble lantern
#

whats the code again

#

reply to it

arctic moth
tardy delta
noble lantern
#

ty

arctic moth
#

sad whered the embed go

noble lantern
#

wait why CreatureSpawnEvent

arctic moth
#

wither spawn

#

and literally every other spawn

noble lantern
#

EntitySpawnEvent might make it work

#

idk how the 2 events itneract

arctic moth
#

it works in creaturespawnevent

noble lantern
#

one might get called before/after the other

arctic moth
#

just the buffs dont get added

tardy delta
#

is there an entityspawnevent? there isnt iirc

noble lantern
arctic moth
#

also i dont wanna give the buffs to every entity

#

like items

summer scroll
#

there is

arctic moth
#

or crystals

noble lantern
tardy delta
#

ah ye i see

quaint mantle
#

i dont think he needs entity spawn event

noble lantern
#

your trying to add leviation?

quaint mantle
#

his event runs every time

arctic moth
drowsy harness
#

Packet Question...

So, what could be the reason for this behavior?
I'm trying to hide and show a certain entity, in this case, we're using a item frame. Every other entity works as expected, but an issue arises when item frames are being used.

summer scroll
#

CreatureSpawnEvent extends EntitySpawnEvent

quaint mantle
#

omg

arctic moth
#

thats only for phantoms

noble lantern
#

or the attributes

arctic moth
#

attributes

tardy delta
#

whats the difference lol

drowsy harness
#

Image 2 to post above ^^

quaint mantle
#

creature is a creature

#

entity is every entity in the game

summer scroll
#

i think it's the same

tardy delta
#

and what does creature mean then?

quaint mantle
#

a living entity

#

thats not a player

arctic moth
#

wait what would happen if i did smth stupid like nuking the world on Event

echo basalt
sterile token
#

How do they register placeholders that are updated on an event?

quaint mantle
#

entity spawn event includes all entities like arrows and stuff

arctic moth
#

ye

#

i dont want that

quaint mantle
#

creature spawn event is for creatures

arctic moth
#

i just want creatures

quaint mantle
#

your event is fine, its just the delay issue

arctic moth
#

ye i think the game creates a new wither or smth after it explodes

drowsy harness
arctic moth
#

so it resets all the nbt

quaint mantle
#

for wither exclusively

#

theoretically that should only trigger when he first spawns so sounds to me like the best way to solve your problem

echo basalt
summer scroll
echo basalt
#

which is odd, but only exists because you can attach them to all block faces simultaneously

#

The item rotation itself is part of the datawatcher

sterile token
#

Lmao i losted my message

#

How do they register placeholders that are updated on an event? Thanks

quaint mantle
#

make the placeholder pull from a variable

#

update the variable on an event

drowsy harness
sterile token
quaint mantle
#

sometimes the best solution is the simplest

echo basalt
quick plank
#

How can player.getLocation().getWorld().getName() produce "NullPointerException"?

quaint mantle
#

player is null

tardy delta
#

player null?

#

got ninja'd lol

quaint mantle
#

lmao

tardy delta
#

๐Ÿค 

quaint mantle
#

im just watching youtube sitting on this channel

tardy delta
#

im just deleting a folder for 15 minutes now

quick plank
#

Uhhm

tardy delta
#

show code

quaint mantle
#

was about to type that roll

chrome beacon
#

?paste

undone axleBOT
tardy delta
#

hahah get ninja'd

quick plank
tardy delta
#

private is something lol

quick plank
#

?

tardy delta
#

private Main plugin

quaint mantle
#

lmao

tardy delta
#

player isnt null

#

is the world null in the quit event or something?

quaint mantle
#

hold up

#

hes doing

#

Main.getPlugin

#

instead of plugin.

#

idk if it will matter cuz idk what Main looks like

quick plank
#

Let me try

quaint mantle
#

but also you should prob have shown the nullpointerexception too

tardy delta
#

ah lol

quaint mantle
#

tho i guess it doesnt matter since u said what line it was so nvm

#

but yea pretty sure its cuz you create a Main plugin variable and dont even use it lol

tardy delta
#

that isnt throwing a npe

quaint mantle
#

yea idk

quick plank
#

It says Method 'getWorld' is annotated as 'nullable'

mighty pier
#

im trying to use vault api and when i start my plugin it says Disabled due to no Vault dependency found!

#

i want to use economy

chrome beacon
#

Show your code

#

Also make sure Vault is installed

mighty pier
#

it is

eternal oxide
#

you need an economy plugin too

mighty pier
#

i want to use essentials

#

do i need like essentialseco or something?

#

omg nvm

minor garnet
#

why sometimes yaw get negative?

        final Location eye = player.getLocation();
        final float yaw = 0 - eye.getYaw();```
the problem, and that usually the number stays positive, but ends up becoming negative, and that makes the numbers flip, from 0 360 ending up being 360 to 0
eternal oxide
#

0 - eye.getYaw()?

minor garnet
#

its because is gedtting negative values

#

i want invert it for more easy to manipulate

eternal oxide
#

a yaw will always be 0 to 360

#

only pitch goes negative

minor garnet
#

is getting negative

#
final Location eye = player.getLocation();
final float yaw = eye.getYaw();```
eternal oxide
#

also try using getEyeLocation() not get Location()

minor garnet
#

I use 0 - to transform from negative to positive, but sometimes it becomes positive and negative

eternal oxide
#

eye location is where you are looking

#

location is where yoru body is facing

minor garnet
eternal oxide
#

Should be impossible. docs say 0 to 360

minor garnet
#
final Location eye = player.getEyeLocation();
final float yaw = eye.getYaw();
//final float yaw = 0 - eye.getYaw();
actionBarMessage(player, "yaw: " + yaw);```
eternal oxide
#

No clue, theoretically impossible.

#

7-8 years back I seem to remember MC rotated the world by 90 degrees so the sun went east/west

exotic jetty
#

Im working on SignGUI over 10 hours and everything i find is outdated or doesnt work. I basicly want to make it so you have a shop and you can set the title of that shop by clicking on a button and a sign will pop up where you can type something in and then make it so the title will be what the players shop name will; be what he typed in the sign. Does annyone have any expiriences with this or wants to help me with this? you can dm me.

smoky oak
#

how do you escape a for loop? break?

restive tangle
#

Alright, I have a question. If I want to make an API for my plugin, I would create a class and create the needed methods for it. If I wanted to create another plugin that depends on the first plugins methods, would I add it as a dependency and then if I call the method would it work?

public class FirstPluginAPI {
  public FirstPluginAPI() {
    // stuff
  }

  public boolean linkedAccount(Player player){
    // stuff 2
  }
}

Second plugin :

maven,
<dependenies>
  <dependency>
    // all the things 
  <dependency>
<dependencies>
public class SecondPluginCommand implements CommandExecutor {
  @Override
  public boolean onCommand(.....) {
    Main.firstPluginAPI.linkedAccount((Player) sender);
  }
}
ivory sleet
#

myes

#

usually your api should just be a set of interfaces

smoky oak
#

remember to declare your scope right tho

#

if it's provided you need to add the api as plugin to the server

#

i think

ivory sleet
#

yes

#

thats correct

mighty pier
# mighty pier

when i add the test-economy command to plugin.yml then the plugin breaks

ivory sleet
#

how does it break?

restive tangle
mighty pier
#

it just says invalid plugin.yml

#

and doesnt show up in /pl

restive tangle
ivory sleet
#

lets take a look at spigot for instance

#

the api mostly consist of interfaces

smoky oak
ivory sleet
#

then we have underlying classes that implement them

#

for instance Player -> CraftPlayer

#

and the CraftPlayer on its own adapts EntityPlayer or the nms Player instance (altho we as api consumers know nothing about that)

restive tangle
#

So would it be

public interface APIInterface {
  public boolean linked(Player player);
}

And I would make a class that implements this interface and add functionality?

ivory sleet
#

mye

#

consider to use a more useful name, such as isLinked

#

or if it does something perhaps linkTo

restive tangle
#

Would the class need to have the same name as the interface?

ivory sleet
#

nah

#

class DodoEpicConclureism implements APIInterface {

}

#

that'd work

#

altho questionable class name of the implementation class

#

but ye

restive tangle
#

So then I'd override the functions right? Thanks

ivory sleet
#

yup

granite owl
#

is there a way to alterate the permission token in this event PlayerCommandPreprocessEvent for players? Say, usually player has no permission to execute given command but this time its decided that he can

ivory sleet
ivory sleet
#

or well

#

technically you could change the permission for the underlying command instance

granite owl
#

how

mighty pier
ivory sleet
#

but in theory that wont work well

ivory sleet
undone axleBOT
granite owl
#

ik a command contains a token who sent the command and if he has permission or not

ivory sleet
#

yes

granite owl
#

alternatively i could also cancel the event and create a new command instance in which he has permission

ivory sleet
#

but then you need to take into account the fact that plugins may not use the permission system bukkit offers

granite owl
#

and now dont yell at me xD

mighty pier
granite owl
#

and write my own

ivory sleet
#

for instance setExecutor((sender,cmd,label,args) -> { if (sender.hasPermission("some.perm") { return true; } throw new RuntimeException(); })

#

@mighty pier send ur plugin.yml

#

?paste

undone axleBOT
mighty pier
#
version: '${project.version}'
main: me.frandma.disabler.Disabler
api-version: 1.18
authors: [ Frandma ]
description: Custom plugin for Disabler.
commands:
  test-economy:
    permission-message: e
    permission: *```
ivory sleet
#

'*'

granite owl
#

hm

mighty pier
#

opmfg

#

i understand

ivory sleet
#

also make sure you use the right encoding

#

ye

mighty pier
#

api version

#

eeereee

ivory sleet
#

ah

mighty pier
#

its supposed to be 1.8.8

granite owl
#

im pmuch done writing a permission system which is using the scoreboard teams as its base, disabled the team and scoreboard command and execute logic via that xD

ivory sleet
#

that too

granite owl
#

that wont cause trouble because i dont intend to use other ppls plugins

lapis widget
mighty pier
#

yes

restive tangle
#

Assuming Dodo, right?

ivory sleet
#

yes

smoky oak
#
Location original_loc = new Location(world, 0,0,0);
func(original_loc);

...
func(Location loc){
  loc.add(1,1,1);
}

after calling the function, is original_loc still pointing to 0,0,0 ?

ivory sleet
#

but I sincerely hope that wasnt the name of your class

restive tangle
#

I'm not making anything right now lmao

ivory sleet
#

oh right

restive tangle
#

Why is it better to use an interface then?

ivory sleet
#

well then in addition you usually use services manager to provide the api instance from one plugin to another

#

well because when using an interface your design becomes considerably more robust

#

I mean in practice, when 2 plugins communicate there is no inherit need for an interface

#

but it really helps

restive tangle
#

Alright thanks, I'll look into the service manager

ivory sleet
#

especially when you want to provide a functionality of your service to the world

#

ye

smoky oak
ivory sleet
#

and in theory, you decouple your api layer from your business logic, you properly invert your dependencies and your api becomes mockable

#

@restive tangle

ivory sleet
#

it'd be 1,1,1

smoky oak
#

you know that your answers conflict here right?

ivory sleet
#
    @NotNull
    public Location add(double x, double y, double z) {
        this.x += x;
        this.y += y;
        this.z += z;
        return this;
    }
#

perhaps this is enough then

smoky oak
#

urgh conclure im calling a method with origin_loc as argument and in taht method the argument gets changed. WHat im asking is if the location used as argument outside the method changes due to this

eternal oxide
#

Yes, unless you clone

smoky oak
#

k noted

#

clone it is

ivory sleet
#

^since add mutates the data of your location object

smoky oak
#

would calling loc = loc.clone() inside the method work?

ivory sleet
#

yes but it'd be useless

#

unless you return it (or do sth else in that function Ig)

smoky oak
#

no i need to mutate the location inside the method for the purpose of the method but the location passed as argument cannot change as a result of this

#

it needs to continue pointing towards the same location

mighty pier
#

still no work

smoky oak
#

so doing loc = loc.clone() inside the method would reassign loc to a new Location object thats a copy of the passed argument, correct?

ivory sleet
#

yes

smoky oak
#

ok thanks

mighty pier
#

plugin still brokie

ivory sleet
#

yes

#

you need to surround the asterisk with single quotes

#

(or double ones)

mighty pier
#

permission-message: "e"

#

like that

#

?

ivory sleet
#

the one under that

#

the * (aka asterisk)

mighty pier
#

ok

#

thank

ivory sleet
#

nw

mighty pier
#

i did it like that before and it worked

#

without the quotes

ivory sleet
#

my a bit weird

#

well, the error shouts at you due to the asterisk

mighty pier
#

k

desert musk
#

**how do you make valid, working enchanted books as an itemstack? **@ me with an answer

frank frigate
#

Hello, my code here isn't working, I have reviewed a lot of resources and can't figure out why it doesn't work.

        plugin = this;
        NamespacedKey glowkey = (new NamespacedKey(this, "glow"));

        this.getServer().getPluginManager().registerEvents(glow, this );
        ItemStack glowitem = new ItemStack(Material.BOOK, 1);
        ItemMeta glowmeta = glowitem.getItemMeta();
        PersistentDataContainer glowdata = glowmeta.getPersistentDataContainer();
        glowmeta.setDisplayName("ยงd");
        glowdata.set(glowkey, PersistentDataType.STRING, "glow");
        glowitem.setItemMeta(glowmeta);
        NamespacedKey glowrecipekey = new NamespacedKey(this, "glowrecipekey");
        ShapedRecipe glowrecipe = new ShapedRecipe(glowrecipekey, glowitem);
        glowrecipe.shape("EEE", "ECE", "EEE");
        glowrecipe.setIngredient('E', Material.GOLD_BLOCK);
        glowrecipe.setIngredient('W', Material.GLOW_BERRIES);
        glowrecipe.setIngredient('G', Material.GOLDEN_CARROT);
        glowrecipe.setIngredient('C', Material.BOOK);
        Bukkit.addRecipe(glowrecipe);
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.

frank frigate
#

the recipe doesn't work, 0 console errors

#

like i put it into crafting table, and the recipe does not exist

eternal oxide
#

did you teach it to the player?

frank frigate
#

?

frank frigate
#

I put the items in

#

and it doesn't show up with the item

granite owl
#
Bukkit.getServer().dispatchCommand(...); returns a bool
``` what exactly does its return value represent?
drowsy harness
#

returns false if no target is found

undone axleBOT
drowsy ledge
#

How can I unban a banned player?

granite owl
#

tried didnt find the doc for that

lusty forum
#

neeeed help

granite owl
drowsy harness
drowsy harness
brave sparrow
granite owl
#

aight ty

drowsy harness
#

ye depends on which plugin ofc

lusty forum
#

Hey guys, I want to create an inventory with player heads. In the middle should be the numbers from 1-5. On top and bottom should be player heads with which you can make the numbers "higher" and "deeper". Can somebody help with this?

drowsy harness
#

but default is pardon i think

drowsy ledge
#

thx

granite owl
#

okay so whats the easiest way to bypass a command instances op check

drowsy harness
lusty forum
#

What should I search?

drowsy harness
lusty forum
#

And how can I put custom heads in a GUI?

desert musk
granite owl
#

ive written my own permissions system, and i need a way to override the op check esp for the vanilla commands

drowsy harness
granite owl
#

so non op ranks can execute certain commands

#

as if they had op

drowsy harness
# lusty forum Yes exactly

alright:

  • in your inventory class, load up the default values in the inventory (1-5 or whatever you want), then set a variable for your current number.

  • create a config where you can save all the heads, or whatever you want to do to get the texture of the head.
    the config could maybe look something like this:

        - "headtexture" # head 1
        - "headtexture" # head 2
  these values saves the texture of the head with the one on it, two on it, etc.

- if the player clicks on the top heads or bottom heads (check in inventoryclicklistener), you update the heads in the inventory with the texture
   of the head in the next index of your config list

if you don't understand i'll provide some code examples later :p

drowsy harness
lusty forum
#

Can somebody help my with config file?

young shell
#

is there a Method to check if a Inventory contains all Itemstacks of a Collection?

lusty forum
#

*arraylist

young shell
#

yeah I'm currently doing java Arrays.stream(user.getPlayer().getInventory().getStorageContents()).toList().contains(getItems())but a containsAll Method would be quite handy

#

Why

#

If I need to check for more than 1 item thats the most readable Solution

wet breach
#

you could just do a contains on getStorageContents since that returns an array already

wet breach
young shell
#

Array don't have a contains method

#

Only Collections have

lusty forum
wet breach
#
for(ItemStack items : user.getPlayer().getInventory().getStorageContents()) {
    for(ItemStack items2 : getItems()) {
        if(items.equals(items2)) {
            //do something here
        }
    }
}

very readable and easy to understand, and not very difficult or super inefficient ๐Ÿ™‚

young shell
#

Why would have a pyramid of doom thats 6 lines long if I can do it one more readable one

wet breach
#

pyramid of doom?

#

not sure what that means

young shell
wet breach
#

your style of writing is up to you

#

has nothing to do with how it compiles

#

you want to write the entire thing on one single line

#

then go for it ๐Ÿ™‚

#

still compiles the same

young shell
#

I asked if there was a containsAll Method. I still haven't gotten an answer for that

wet breach
#

no

#

but, hey its your project your code so it don't matter to us if its inefficient just we like to be nice and point such things out from time to time to people when its not obvious to them ๐Ÿ™‚

young shell
wet breach
#

if you say so

#

I am not going to argue ๐Ÿ™‚

#

you could probably find people who ask this question on the forums and find some examples. Regarding how to stop tab completion and what not and how to stop brigadier from doing its thing. But like it doesn't matter to hide commands though if they don't have permission to run them anyways

#

ok?

#

more of a reason they shouldn't do things then if they find that ๐Ÿ™‚

#

if you think your server will be more secure because you obscure something, then you are mistaken

#

as long as the plugins you use respect permissions and you setup permissions appropriately, even if they discover a plugin command

#

doesn't mean they will be able to use it

#

and as for your example it is a poor one even if it is just an example. Everyone already knows about vanish and that literally almost every server uses it or has their own version of it lol

#

I have worked for a large network before, they are not around anymore but we never bothered to hide commands at all

#

we didn't even bother to hide plugins we used as well

#

most of them were custom anyways ๐Ÿ™‚

#

there is a permission to prevent usage of pl

#

it isn't that the custom plugins didn't have commands

#

they didn't register a bunch of commands

#

also aliasing is a thing

#

you can alias a command to include parameters to a single alias command ๐Ÿ˜‰

#

and even register such in code too

#

no

#

as in, it has its own permission nodes and is sane in its checking if a player has whatever permission required

#

instead of going by if you are opped or not opped type deal lol

#

we never had issues is all I am saying and as far as I am aware no one who had permissions granted to them were able to run commands they were not allowed

#

yeah they could see the command exists, but that was it, most of the time they had no clue what it even does XD

#

you could just demonstrate it for them ๐Ÿ˜›

#

well sure, but if you have a decent community

#

generally whenever someone question it some random in the community answers it for you ๐Ÿ™‚

#

not like telling them what it does, exposes the specifics of it lol

#

we had anti-cheat related command stuff where we can enable reporting on any player we chose ๐Ÿ˜›

#

or visually turn on stats in our chat

#

telling them and even showing them what it looks like, doesn't reveal how those stats or anti-cheat reporting stuff gets its information or how it looks at the information XD

#

but it helps the loyal ones know you have cool tools and then they start doing your job for you sometimes lol

#

which is awesome to have ๐Ÿ™‚

smoky oak
#
key1:
  key2: value
  - "list_1"
  - "list_2"

does calling config.getStringList("key1") return a collection of {"list_1", "list_2"}?

sharp nacelle
#

Hi guys!

granite owl
#

do more potential command senders but Player, CommandBlock and ConsoleSender exist?
any other instances that can perform commands?

sharp nacelle
#

How can I check the side of the clicked block? I try it:

            if (blockFace == null) return;
            Location targetLocation = null;
            if (blockFace.equals(BlockFace.UP)) {
                targetLocation = new Location(player.getWorld(), block.getX(), block.getY()+1, block.getZ());```
but it doesent worked.
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.

ornate heart
unkempt peak
lusty forum
#

yes they count

ornate heart
#

ooo that's alot

unkempt peak
#

Why are you appending the bold symbol to every char?

#

You only need it at the begging of the string unless you reset formatting

mighty pier
#
                    if (item == null || item.getType() == Material.AIR) continue;
                    player.getWorld().dropItemNaturally(player.getLocation(), item);
                }``` items dont drop
lethal zealot
#

I'm not sure how I use <Player>.getAdvancementProgress(), is there any guide about it?

lusty forum
desert musk
#

I'm editing a YAML value in my plugin which "works" but the actual value in the file doesn't seem to change and when i restart it wasn't affected at all.

arctic moth
#

anyone know how to add custom loot tables to structures

unkempt peak
desert musk
#

tysm

#

lol

unkempt peak
#

Np lol it's easy to forget

silver needle
#

do you guys use final for local variables or method parameters, why or why not?

chrome beacon
#

No because I'm lazy

tardy delta
#

no

#

because it makes no sense

timid parrot
#

how can i get the loc of the area where a snowball lands

quaint mantle
#

projectilehitevent

timid parrot
#

i know which event

quaint mantle
#

then get the projectile

#

and get its location

timid parrot
#

but how i create the box

quaint mantle
#

wdym

#

like a radius?

timid parrot
#

yeah

#

like a radius or area

quaint mantle
#

of entities or blocks

tardy delta
#

maths

timid parrot
#

a custom radius of the snowball loc

quaint mantle
#

containing entities or blocks?

#

or just

#

in general

#

i mean just like

timid parrot
#

just block s

#

so i want to summon lots of anvils in the radius when the snowball lands

quaint mantle
#

jesus i suck at math

#

yeah i cant help u

#

i forgor the formula

#

@tender shard

drowsy harness
# timid parrot so i want to summon lots of anvils in the radius when the snowball lands
    public void onProjectileHit(ProjectileHitEvent event) {
        ProjectileSource shooter = event.getEntity().getShooter();

        Entity entity = event.getEntity();
        if (entity instanceof Snowball) {
            Iterator<Block> iterator = new BlockIterator(entity.getWorld(),
                    entity.getLocation().toVector(),
                    entity.getVelocity().normalize(), 0, 4);

            while (iterator.hasNext()) {
                Block block = iterator.next();
         
            }
        }
    }```
then just spawn anvils around `block.getLocation();`
silver needle
#

Final keyword for local variables or parameters

glass mauve
#

I need help with toPrimitive, I dont know what to do here

quaint mantle
glass mauve
#

yea, but I dont know how to do that

quaint mantle
#

why not store it as a string then use JSON to serialize it

tardy delta
#

bytearrayoutputstream

#

alex' pdc thing is saving stuff in byte arrays iirc and thats what hes using

quaint mantle
smoky oak
#

is there a way to extract the only value from a HashSet of guaranteed size 1 without using the same for(Object o : set) loop one uses for multi-entry HashSets

quaint mantle
#

whut

tardy delta
#

to get the element out of the set when the size is 1

quaint mantle
#

just do the loop

tardy delta
#

just for loop is the thing

smoky oak
#

ok

tardy delta
#

god ninja'd again

quaint mantle
#

hehe

tardy delta
#

lmao i really cant type in the dark

quaint mantle
#

tupe

#

tuple!?

tardy delta
#

tuple

#

got ninjad again

quaint mantle
#

we love tuples

tardy delta
#

yes but not here

#

๐ŸŽƒ

quaint mantle
#
fn balls() -> (usize, usize) {
    (5, 10)
}
#
def balls() -> tuple[int, int]:
    return 5, 10
tardy delta
#

meh

jagged thicket
#

deez are some good names

tardy delta
#

i dont like that you cant write short methods shorter

#

like fn deez_nuts() => (1, 2)

smoky oak
#

just to verify but .equals() on hashMaps with the same set of key-> value mappings and the same key& value types results in true correct?

quaint mantle
tardy delta
#

mye but its still not a method

opal juniper
tardy delta
#

im trying to find mt keyboard ๐Ÿคฃ

opal juniper
#

should get that checked out

tardy delta
quaint mantle
#

didnt even notice that

#

thanks

#
record Tuple<T, Z>(T t, Z z) {}

// somewhere
Tuple<Integer, Integer> balls() {
    return new Tuple(5, 10);
}
tardy delta
#

tuple in java when

#

lets go to bed now

opal juniper
smoky oak
#
Provided: HashSet<HashSet<Item>>```
Why is this an issue?
#

isnt everything an object

echo basalt
#

cant you cast it

smoky oak
#

probably

quaint mantle
#

cool

smoky oak
#

there a simple way to get al corners of a BoundingBox?

sharp bough
#

how can a command be null? when i try to write this.getCommand("test").setExecutor(new testManager()); it recommends that i replace it with Objects.requireNonNull(this.getCommand("test")).setExecutor(new testManager()); why is that?

golden turret
#

how can i convert a string like ยงxยง0ยง0ยงfยงfยง8ยง0TEXT to a minecraft chat component with colors?

echo basalt
#

don't forget to translate it

#

you can then get its json through ComponentSerializer

echo basalt
echo basalt
echo basalt
golden turret
#

wait

#

i just needed the fromLegacyText

#

thanks

echo basalt
#

hm okay

#

Have fun

quaint mantle
#

How to set the head skin by id?

smoky oak
# echo basalt

you recon it'd be faster do to arrays of min7max three times and iterate over them or to just do it manually?

echo basalt
#

premature optimizaiton ยฏ_(ใƒ„)_/ยฏ

smoky oak
#

ima do the latter one then since its more readable

frail gale
#

does someone know why BlockDropItemEvent doesn't work for chests?

smoky oak
#

iirc its because its the nbt dropped and not the block itself

#

assuming you mean the items inside

frail gale
#

yeah the items inside

quaint mantle
#

How to set the head skin by id?

frail gale
#

you mean the head texture?

unkempt peak
frail gale
#

yep if not search it on google there are a ton of posts about this

quaint mantle
quaint mantle
granite owl
#

i think i could use some help on this. ```txt

  1. Player is not op
  2. Player executes /gamemode creative
  3. I now want to alternate the command that will be parsed so that the player has op permission for this one and only this time
  4. So the player for this single one command is being treated as if op, but is not actually an op
golden turret
#

you can do anything with coding

unkempt peak
granite owl
frail gale
# quaint mantle I found something about GameProfile in Google, but I don't have it

what version of spigot you're using and what IDE? if you're using Eclipse and you're using the spigot API by the Build Path then you need to go inside your server folder and find a folder called bundler open it then open libraries and import everything from this folder to your Build Path and then you're gonna have the GameProfiles class

granite owl
#

first of the messages then aint sent to the player who actually executed the command to say inform him of incorrect args

#

also since the sender is a console he MUST specify a target

unkempt peak
granite owl
granite owl
#

and i dont want to use the permissions.yml

#

writing own implementations is like hardcoding in this case

chilly haven
#

Yall

granite owl
#

because i want them to use the default command

#

not a special one

chilly haven
#

Where do i grt help if my acc got stolen

hasty prawn
#

Mojang's support, they'll ask for your TID.

sterile token
unkempt peak
#

Ok.. well i have no idea why you want to do it the hard way

chilly haven
#

Dpigot acc

unkempt peak
sterile token
granite owl
#

ik that ppl will call me out on it again sooo

#

im using the scoreboard teams to check for permissions

sterile token
#

I dont understand why you doing like that

#

What the fuck

#

๐Ÿ˜ณ

unkempt peak
#

But spigot has permissions built in...

#

??

sterile token
#

Spigot contains a class called PermissionAttachment

unkempt peak
#

why would you ever need to over complicate something like that?? whatever your doing you need to rethink it because there is no reason for that

sterile token
#

I dotn even understand why he is doing in that way and what is his goal

unkempt peak
#

Please explain the goal of your project and why in the world you need such a work around

granite owl
#

so theres the bashing xD

#

ive built a permission system which revolves around mc teams instead of spigots permission system

#

whats wrong about that

unkempt peak
granite owl
#

the redundant call to retrieve the teams instance?

#

ppl here suggested to iterate trough offline players instead of using an indexed map

#

ive split the op system

#

in full access

#

and limited access

#

by severing the system into teams

#

removed the /team and /scoreboard command from the command map using reflection

#

overriden the /op /deop to fit my needs

#

and wrote a /rank system to modularly create new ranks based on teams

unkempt peak
#

What is the purpose of this teams based permission system over spigots built in permissions?

granite owl
#

now im at the point to create a permission system for the softcoded ranks which will be stored using serialization

granite owl
#

u give players access

#

not groups

#

my system gives a usergroup access

#

and if that group gets deleted so do all priviledges for everyone from that team

#

so, can you help me or not?

unkempt peak
#

Thats what permission plugins and group manager plugins or for

granite owl
#

yea

#

i dont use other ppls plugins

#

ive written a system which directly binds permissions to ranks

#

hardcoded the full access admin, limited access admin and default user group

#

and softcoded other ranks

unkempt peak
#

I get if you want to make your own but there is no reason for not using normal permissions you can simply set group members permissions to the group permissions

granite owl
#

and overriden mcs vanilla methods via reflection accessing

#

its already finished and working

#

i only need to bypass admin checks for special groups not having admin power

#

but being able to access certain admin commands

unkempt peak
#

Ok well clearly i can't change your mind and I don't understand your project so you will have to ask someone else

granite owl
#

the question wasnt about how to work with teams or such

#

the question was how to access a pending command, and modify its value as to if the sender has had op at the time of sending the command

#

im sorry if i sound rude but so far ive only been called out for doing things the way i did, without the intention of providing help which happens all too often if u dont ask standard questions

unkempt peak
granite owl
#

i think ive figured a way

#

im going to send it as consolesender

#

reparse the command on preprocessing so its always in the right format

tardy bay
granite owl
#

say guy tries to execute /gamemode creative someoneElse

#

itll be reparsed to /gamemode creative ownName

#

and then send feedback to the executor of what has been executed

granite owl
#

throw them all out, put em in one by one

#

and then trial & error

#

til u get the answer

#

oh @unkempt peak this ^ right there is the answer as to why i dont use existing permission plugins

cursive loom
#

Hey do you konw how I can get the front face of a chest when I put him for put a sign on itt ?

granite owl
#

get the instance of ur chest block

#

somewhere u can retrieve the info of its rotation

cursive loom
#

Yes I have try but I don"t find it

granite owl
#

BlockFace
getFace(Block block)
Gets the face relation of this block compared to the given block.

#

something like that

quaint mantle
#

Hi guys,

How do I make it so on maven <build></build> only the .jar file gets placed in the directory given?

cursive loom
#

Hey do you konw how I can get the front face of a chest when I put him for put a sign on it ?

I have try that but that didn't work

                if (b.getBlockData() instanceof Chest) {
                    Chest chest = (Chest) b.getBlockData();
                    BlockFace face = chest.getFacing();
                    BlockState sign = b.getRelative(face).getState();

                    sign.setType(Material.OAK_WALL_SIGN);
                    ((Directional)sign).setFacing(face);
                    sign.update();
                }
frank frigate
#

so I'm getting this error ```
java.lang.NullPointerException: Cannot read field "glowkey" because "me.nrgking.imbuements.ImbuementsMain.glow" is null
at me.nrgking.imbuements.Imbuements.Glow.<init>(Glow.java:25) ~[?:?]
at me.nrgking.imbuements.ImbuementsMain.onEnable(ImbuementsMain.java:27) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:517) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3468-Spigot-ffceeae-d53c4fb]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:431) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3468-Spigot-ffceeae-d53c4fb]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3468-Spigot-ffceeae-d53c4fb]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3468-Spigot-ffceeae-d53c4fb]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:263) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3468-Spigot-ffceeae-d53c4fb]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1007) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3468-Spigot-ffceeae-d53c4fb]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3468-Spigot-ffceeae-d53c4fb]
at java.lang.Thread.run(Thread.java:833) [?:?]

#

my main class is:


    private static ImbuementsMain plugin;

    public static Glow glow;

    @Override
    public void onEnable() {
        plugin = this;
        NamespacedKey glowkey = (new NamespacedKey(this, "glow"));

        this.getServer().getPluginManager().registerEvents(new Glow(), this );
        ItemStack glowitem = new ItemStack(Material.BOOK, 1);
        ItemMeta glowmeta = glowitem.getItemMeta();
        PersistentDataContainer glowdata = glowmeta.getPersistentDataContainer();
        glowmeta.setDisplayName("ยงdGlowing Spellbook");
        glowdata.set(glowkey, PersistentDataType.STRING, "glow");
        glowitem.setItemMeta(glowmeta);
        NamespacedKey glowrecipekey = new NamespacedKey(this, "glowrecipekey");
        ShapedRecipe glowrecipe = new ShapedRecipe(glowrecipekey, glowitem);
        glowrecipe.shape("EEE", "ECE", "EEE");
        glowrecipe.setIngredient('E', Material.GOLD_BLOCK);
        glowrecipe.setIngredient('W', Material.GLOW_BERRIES);
        glowrecipe.setIngredient('G', Material.GOLDEN_CARROT);
        glowrecipe.setIngredient('C', Material.BOOK);
        Bukkit.addRecipe(glowrecipe);


    }

    public static ImbuementsMain getPlugin(){
        return plugin;
    }
#

my other class is ```java
NamespacedKey glowkey = ImbuementsMain.glow.glowkey;

@EventHandler
public void GlowHit(EntityDamageByEntityEvent e) {
    if (e.getDamager() instanceof Player) {
        Player player = (Player) e.getDamager();
        if (e.getEntity() instanceof Player); {
            LivingEntity victim = (LivingEntity) e.getEntity();

            ItemStack item = player.getEquipment().getItemInMainHand();

            PersistentDataContainer data = item.getItemMeta().getPersistentDataContainer();


            if (data.has(glowkey, PersistentDataType.STRING)) {
                victim.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 600, 1));
            }
        }
    }
}

@EventHandler
public void GlowInteract(EntityInteractEvent e) {
    if (e.getEntity() instanceof Player) {
        Player player = (Player) e.getEntity();
            ItemStack item = player.getEquipment().getItemInMainHand();
            ItemMeta meta = item.getItemMeta();
            PersistentDataContainer data = meta.getPersistentDataContainer();

            ItemStack item2 = player.getEquipment().getItemInOffHand();
            PersistentDataContainer data2 = item2.getItemMeta().getPersistentDataContainer();

            if (data2.has(glowkey, PersistentDataType.STRING) && item.equals(Material.DIAMOND_SWORD)) {
                data.set(glowkey, PersistentDataType.STRING, "glow");

                item.setItemMeta(meta);

                player.sendMessage(ChatColor.LIGHT_PURPLE + "Your weapon glows with an ethereal light.");
            }
    }
}
delicate lynx
#

you never set glow

granite owl
#

is it possible to add pdc data to scoreboard teams?

eternal night
#

No

celest lichen
half leaf
#

hey so i just started using spigot and i have a basic knowledge about java, anyways so i was trying to make a cooldown for my "FeedCommand", but i was getting this error!

#

Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because the return value of "java.util.HashMap.get(Object)" is null at me.cqveman.learning_everything.commands.FeedCommand.onCommand(FeedCommand.java:32) ~[?:?]

#

my code:

#

`package me.cqveman.learning_everything.commands;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.HashMap;
import java.util.UUID;

public class FeedCommand implements CommandExecutor {

private final HashMap<UUID, Long> cooldown;

public FeedCommand() {
    this.cooldown = new HashMap<>();
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof Player) {
        Player p = (Player) sender;

        if (!this.cooldown.containsKey(p.getUniqueId()) && p.getFoodLevel() < 20) {
            this.cooldown.put(p.getUniqueId(), System.currentTimeMillis());
            p.setFoodLevel(20);
            p.sendMessage(ChatColor.YELLOW + "Stop eating you that much you dump fat.");

        } else {
            long timeElapsed = System.currentTimeMillis() - cooldown.get(p.getUniqueId());

            if (timeElapsed >= 10000) {
                this.cooldown.put(p.getUniqueId(), System.currentTimeMillis());
                p.setFoodLevel(20);
                p.sendMessage(ChatColor.YELLOW + "Stop eating you that much you dump fat.");
            } else {
                p.sendMessage(ChatColor.GRAY + "You're already too fat! Wait for another " + (10000 / 1000 - timeElapsed) + " seconds!");
            }
        }
    }
    return true;
}

}
`

#

plz help

#

also if i didnt provide enough info plz tell me!

chrome beacon
#

Your hashmap doesn't contain the value

half leaf
#

wym

#

it does

#

private final HashMap<UUID, Long> cooldown;

#

there

#

or do u mean smthing else?

#

im a beginner so plz explain

chrome beacon
#

Basically the error is saying that you're calling longValue on null, which doesn't work

#

This is caused by you trying to use a cooldown time from the hashmap but it doesn't exist

half leaf
#

and the solution?

#

agian im a beginner

chrome beacon
#

Check if map containd value before using the value

quick plank
#

I have coordinates stored in a file. How can i make it so that the coordinates only have 2 decimals instead of 14?

#

Also how can i do it with yaw and pitch?

waxen plinth
#

DecimalFormat

#

Actually I think String.format("%.2f", numberHere) would also work

#

Yea it does

arctic elm
#

Hello, I'm trying to use Hibernate-jpa inside my plugin, can you guys have any ideas why ?

quaint mantle
#

Okay so for example, essentials has a thing that stores the spawn location somewhere in the ram, or something idk if it's actually what it does..
My question now is, how do they do it and what is that method called?

quick plank
#

It stores it in a .yml file

quaint mantle
#

Ahhh okay, thanks!

quick plank
#

No worries, feel free to dm me if you need help. I am working on the same thing right now

west glacier
#

Hey i just started using spigot since 2 days and I have made an announcement in the chat when a player breaks a block, but now I would like to add a time in which that message is not sent because if he breaks the block several times it appears all the time in the chat as an announcement, can someone help me?

west glacier
#

i try it using runTaskTimer

#

nop

west glacier
noble lantern
#

you want to have a HashMap of UUID's that are players that you recently sent messages too with a integer value of the last time you sent the message to

Run through the HashMap every 20 ticks and decrement value by 1 (This is lightweight your just doing simple math) and when value is 0 remove UUID and value from the HashMap

From then its just a simple if hashMap.get(thatPlayersUuid) == null { handleStuffAndAddToHashMap(); }

#

or look into how WorldGuard does theyre message delays

quaint mantle
noble lantern
#

this is one way to add delay in between messages so its not sending the message every block break

west glacier
#

okay

#

and where i can put the time i want???

#

hashMap.get(thatPlayersUuid) == null { handleStuffAndAddToHashMap(); }

#

i want 3 min with out sending this message

noble lantern
#

you have a runTaskLater in your class's constructor that runs every 20 tickets (1 second) and it just checks values of the hashmap

You just need to add values to hashmap when you send the message and from there the runTaskLater handles this all

#

i can maybe get some type of example spun up

#

one second

west glacier
#

thx ๐Ÿ™‚

#

im so noob at this

#

I started yesterday watching videos to learn something

noble lantern
#
public class HandleDelayedMessage {

    public final HashMap<UUID, Integer> playersInCooldown;

    public HandleDelayedMessage(YourPlugin plugin) {
        this.playersInCooldown = new HashMap<>(); // initalize hashmap
        new BukkitRunnable() {
            @Override
            public void run() {
                this.playersInCooldown.forEach((K, V) -> { // loop throughall keys and value in the hashmap
                    V--; // decrement seconds value by one
                    if (v <= 0) this.playersInCooldown.remove(K); // if seconds less than or equal to 0, remove player from cooldown
                });
            }
        }.runTaskLater(plugin, 20L); // 20 = 1 seconds ie 20 ticks 
    }

    public void addToCooldown(final Player player, final int seconds) {
        this.playersInCooldown.putIfAbsent(player.getUniqueId(), seconds); // add player to the hashmap with a second cooldown, putIfAbset should be used to prevent duplicates, you can add ifInCooldown check as well if this method doesnt work for some reason, and just return if that methods true
    }

    public boolean isInCooldown(final Player player) {
        return this.playersInCooldown.get(player.getUniqueId()) != null; // null check if player's uuid is inside the HashMap
    }
}
#

i added comments

#

to explain everything

#

please make sure you read them

#

also do note theres prolly some syntax stuff wrong as i wrote this in discord

#

its pretty simple but hard to explain without showing code

west glacier
#

Thank you so much

noble lantern
#

essentially you create a instance of this class onEnable and create a getter for it in your main class

#

theres likely better ways to handle it, but this is really lightweight and easy to understand

west glacier
#

i will try it

#

but i use bukkit if I import from java its okey??

noble lantern
#

huh?

#

ie import Bukkit?

#

Either way your gonna import Bukkit for runnables

west glacier
#

okay

noble lantern
#

either in the form of BukkitRunnable or Bukkit for Bukkit.getSchedular() or whatever that method name is

#

you can change to getSchedular() if you like

west glacier
#

yes

noble lantern
#

no real difference though as to my knowledge performance-wise, just in looks

west glacier
#

i change hashmap for this?

noble lantern
#

negative that HashMap is necessary

west glacier
#

aaa

noble lantern
#

It stores how many seconds player have left in theyre cooldown session

west glacier
#

okay

#

Thx

noble lantern
west glacier
#

perfect

#

i have one error with this playersInCooldown

noble lantern
#

ConcurrentModificationException?

#

or something else

noble lantern
#

should of seen my latest spigot post

#

shits like 1k words i bet

#

daamn was almost right on point

noble lantern
west glacier
#

i cant send images

noble lantern
#

?verify

#

bad bot

#

you need to verify to send pics ie link your spigot account to discord

#

i forgot how its done

west glacier
#

i send it to you in private

noble lantern
#

odd wonder why your IDE says that

#

what version of java?

#

Thats a warning right

#

if so you can ignore it

#

or

#

just remove the final declaration

west glacier
#

okay

#

i remove the final declaration

#

but one error still there

knotty gale
#

anyone know how to make a actionbar appear when you type a command

west glacier
#

and the solution that programs give me is this -> create 'playersInCooldown' in type 'new BukkitRunnable()'

#

@Override
public void run() {
this.playersInCooldown.forEach((K, V) -> { // loop throughall keys and value in the hashmap

#

the error is there in blond

quaint mantle
#

blond

noble lantern
noble lantern
quaint mantle