#help-development

1 messages · Page 1751 of 1

lavish hemlock
#

do de.haikobra.knockffa.KnockFFA or smthn lmao

summer scroll
#

i think that's a package just with uppercase on the first letter, no?

lavish hemlock
#

if it is:
don't do that

#

either way something bad is going on there

summer scroll
#

yup

lavish hemlock
#

(btw this also makes API slightly weirder, as someone could extend/construct any of these, meaning you need to state that they're uninheritable and unconstructable)

#

(which then causes more redundancy)

#
public final class De {
    private De() {}

    public static final class HaiKobra {
        private HaiKobra() {}

        public static final class KnockFFA {
            // ...
        }
    }
}
#

I get that something like De.HaiKobra.KnockFFA might seem alright to someone from like a C++ or C# background bc of namespaces

#

but

#

in Java it is really bad taste

#

oh okay I believe it's just a package name cuz of the stacktraces above

#

in which case

#

don't use capitals, don't repeat package names

#

you already say de.haikobra but then repeat it with De.HaiKobra a package name after

#

also I dunno what the tyko. at the beginning is for lol

#

anyway ye I don't know what your problem is, just wanted to comment on the poor codestyle

opaque panther
olive valve
#

hello! i have been trying to remove a certain line of lore from an item int amount = Integer.parseInt(args[2]); ItemStack item = p.getInventory().getItemInMainHand(); ItemMeta meta = item.getItemMeta(); List<String> lore = meta.getLore(); String singleline = lore.get(amount); meta.getLore().remove(singleline); item.setItemMeta(meta); here is my code can anyone tell me how to get an int index of a lore line?

opaque panther
#

did you set the lore after

young knoll
#

Don’t lists have an indexOf

#

getLore returns a copy, so you can’t just edit it without using setlore

opaque panther
#

get lore from meta
change lore by indexof list
set lore
i think thats the way

young knoll
#

No idea, I’ve never used that plugin

olive valve
opaque panther
#

if you wanted to remove a line of lore, remove the element from the lore arraylist or list, then do meta.setlore(list)

olive valve
young knoll
#

I believe you can just call remove with the index

olive valve
young knoll
#

Mhm

olive valve
#

it didnt work

#

oh wait i just tested the actual command but it didnt print the line System.out.println("test") so its the actual command

#

i got it to work

opaque grove
#

I need help with creating NPC. The only code snipptes only are with craftbukkit, but it seems to be no where available.

topaz cape
#

so uh is it actually possible to upload and download a file to sql using hikaricp

subtle folio
#

im trying to spawn a zombie with armor and a custom name, i get this error ```[18:49:35 ERROR]: null

org.bukkit.command.CommandException: Unhandled exception executing command 'spawnzombie' in plugin Tazpvp v${project.version}

at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[server.jar:git-Spigot-21fe707-e1ebe52]

at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[server.jar:git-Spigot-21fe707-e1ebe52]

at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-21fe707-e1ebe52]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_292]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_292]

at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [server.jar:git-Spigot-21fe707-e1ebe52]

at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [server.jar:git-Spigot-21fe707-e1ebe52]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]

Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftZombie cannot be cast to net.ntdi.tazpvp.listeners.function.Zombie

at net.ntdi.tazpvp.listeners.function.Zombie.spawnZombie(Zombie.java:44) ~[?:?]

at net.ntdi.tazpvp.commands.moderation.SpawnZombieCommand.onCommand(SpawnZombieCommand.java:13) ~[?:?]

at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-21fe707-e1ebe52]

... 15 more```  this is my code ```java

public void spawnZombie(){
System.out.println("Spawn zombie method called");
Location loc = new Location(world, xzomb, yzomb, zzomb);
Zombie zom = (Zombie) world.spawnEntity(loc, EntityType.ZOMBIE);
LivingEntity livingEntity = (LivingEntity) zom;
((LivingEntity) zom).getEquipment().setHelmet(new ItemStack(Material.LEATHER_BOOTS));
((LivingEntity) zom).setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "Ntdi's Henchmen");
((LivingEntity) zom).setCustomNameVisible(true);
System.out.println("Spawned 1 zombie");
}```

worn tundra
subtle folio
#

like hastebin?

worn tundra
#

Yeah

subtle folio
#

there you go

worn tundra
#

What line is Zombie 44?

worn tundra
#

You probably messed up your imports

subtle folio
#

wdym

#

how do u even mess that up

buoyant viper
#

Zombie already extends LivingEntity no?

#

u shouldnt need 2 cast it

worn tundra
#

You are casting Zombie zom = (Zombie)

#

Using the wrong class

subtle folio
#

yeah

worn tundra
#

You have a Zombie.java class somewhere in your project

subtle folio
#

oh yeah

worn tundra
#

And you are importing that

subtle folio
#

i should prob rename

worn tundra
#

Instead of the bukkit Zombie class

#

Hence you get the class cast exception

#

Can't cast irrelevant object to another

buoyant viper
#

net.ntdi.tazpvp.listeners.function.Zombie

worn tundra
#

Yup

buoyant viper
#

is your commands class name Zombie

#

?

subtle folio
#

itsname zombiespawncommand

buoyant viper
#

hm

#

oh duh package listeners obv that wouldnt b a command

#

im dum

#

i would just rename ur Zombie.java class to like ZombieListener or something idk

subtle folio
#

doing rn

buoyant viper
#

and then redo the imports / remove the castings

#

ye

worn tundra
#

You don't have to rename it

#

Just change the import

buoyant viper
#

id still rename for sanity's sake

subtle folio
#

yup i think that fixed it

#

the color of my things changed

#

😛

worn tundra
#

lmao

#

The "color" literally tells you what's wrong

subtle folio
#

yeah

#

intellji 🦾

worn tundra
#

Any ide bro

#

that's what they're for

subtle folio
#

i have this in my onEnable()

        for(Entity e : world.getEntities()) {
            if (e instanceof Zombie){
                e.remove();
                System.out.println("Removed startup zombieLogic");
            }
        }``` and my whole server just stops running anything else
chrome beacon
#

That's going to take a lot of time

subtle folio
#

oh

#

buts its a empty world

young knoll
#

Won’t take much time

#

Only the spawn chunks will be loaded

subtle folio
#

zombieLogic.spawnZombie();

twilit wharf
#

can I use CraftBukkit on a spigot plugin? I have seen some plugin code using CraftBukkit, and wasnt sure what it was

young knoll
#

Yes

#

But you should avoid it if possible

twilit wharf
#

also

#

Bukkit.getServer().getBannedPlayers() is returning [] yet I have multiple banned people on my server.

#

same with Bukkit.getBanList(BanList.Type.NAME).getBanEntries()

chrome beacon
#

Do you have a ban plugin?

subtle folio
#

is calling functions outside of the java class in the onEnable function lead to server not working or smt?

quaint mantle
#

What?

quaint mantle
#

depends

subtle folio
#

im gonna try moving it all the main java class and see what happens

quaint mantle
#

what are you trying to do

subtle folio
#

i call a function to spawn a zombie with a custom name and helmet

quaint mantle
#

and what do you mean by this

#

lead to server not working or smt?

subtle folio
#

with a bukkit runnable delay of 200L

#

that was bad typing my plugin doesnt load anything

#

after taht

#

basically

quaint mantle
#

Your plugin doesn't load anything?

subtle folio
#

yep

unreal quartz
#

tragic

subtle folio
#

doesnt register any command

#

stuff like that

quaint mantle
#

Can we see your code?

subtle folio
#
    public void onEnable() {
        // Plugin startup logic
        System.out.println("Tazpvp Logic is now ONLINE");

        World world = Bukkit.getWorld("grind");
        for(Entity e : world.getEntities()) {
            if (e instanceof Zombie){
                e.remove();
                System.out.println("Removed startup zombieLogic");
            }
        }

        new ZombieLogic().initZombies(4, 200);
ivory sleet
subtle folio
#
        System.out.println("Spawn zombieLogic method called");
        Location loc = new Location(world, xzomb, yzomb, zzomb);
        Zombie zom = (Zombie) world.spawnEntity(loc, EntityType.ZOMBIE);
        LivingEntity livingEntity = (LivingEntity) zom;
        ((LivingEntity) zom).getEquipment().setHelmet(new ItemStack(Material.LEATHER_BOOTS));
        ((LivingEntity) zom).setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "Ntdi's Henchmen");
        ((LivingEntity) zom).setCustomNameVisible(true);
        System.out.println("Spawned 1 zombieLogic");
    }

    public void initZombies(Integer amount, Integer delay){
            new BukkitRunnable() {
                @Override
                public void run() {
                    for (int i = 0; i < amount; i++) {
                        spawnZombie();
                    }
                }
            }.runTaskLater(TazPvP.getInstance(), 200L);
    }
#

ignore not using the delay in innit zombies

young knoll
#

The runnable timers don’t start until the server is fully up and running

subtle folio
#

ah, so should i like async or await or smt

unreal quartz
#

what r u trying to do

subtle folio
#

;-;

unreal quartz
#

async/await isnt a thing in java

subtle folio
#

async chat event

unreal quartz
#

what about it

ivory sleet
subtle folio
#

it has async in the name

quaint mantle
#

and threads

unreal quartz
#

but what are you trying to do with it

subtle folio
#

either way im trying to spawn 4 zombies with custom anme and helmet 10s after the server starts

ivory sleet
#

async is basically just the CompletableFuture return and calling join on it is similar to await

unreal quartz
#

and what's the issue with the code above

quaint mantle
#

any errors in console when the server starts?

subtle folio
#

this

unreal quartz
#

those zombies probably wont be removed

subtle folio
#

the removing part works

#

its the spawning part that doesnt

unreal quartz
#

since the world wont have any entites loaded as the server is starting

quaint mantle
unreal quartz
#

Plugin cannot be null

#

TazPvP.getInstance() is null

subtle folio
#

wdym

quaint mantle
#

what does getInstance return

young knoll
#

null

subtle folio
#
        return instance;
    }```
quaint mantle
#

ok not like that

unreal quartz
#

yes bur you never assign instance

quaint mantle
#

you never defined "instance" in your class

young knoll
#

You define it

quaint mantle
#

assigned*

young knoll
#

But don’t assign it

quaint mantle
#

fuck I get confused

subtle folio
#

oh

#

assign it in the zombie class aswell

#

not just the mian class?

unreal quartz
#

no

quaint mantle
#

only in the main class, at the top inside the onEnable function

subtle folio
#

instance = TazPvP.getInstance();

quaint mantle
#

no

unreal quartz
#

absolutely not

subtle folio
#

wdym not

unreal quartz
#

because TazPvP.getInstance() is null

subtle folio
#

how do I fix that then...

quaint mantle
#

you're basically assigning a null value to a null value

subtle folio
#

waiittt

unreal quartz
#

think to yourself what TazPvP.getInstance() is supposed to return

subtle folio
#

instance = this;

quaint mantle
#

😄

#

why does using .clone().add(0,0,0) actually reduce the process-price by around O(N-N/sig)?

young knoll
#

What

#

That makes no sense

quaint mantle
#

huhh

#

?

ivory sleet
quaint mantle
#

ye

ivory sleet
#

its the same

quaint mantle
#

no its not

ivory sleet
#

yes it is

quaint mantle
#

no

young knoll
#

Shouldn’t cloning it make it take longer

quaint mantle
#

but after .add

ivory sleet
#

time complexity doesnt denote time tho lol

quaint mantle
#

it seemed to get better again

unreal quartz
#

show us your testing methodology

ivory sleet
#

it just denotes the amount of extra operations correlating to n

quaint mantle
#

exactly

ivory sleet
#

so how is copying worse?

quaint mantle
#

i didnt say it was worse..

ivory sleet
#

yes it does take some performance

#

but it wont make time complexity worse nor change it at all

muted crest
#

Hey guys my plugin wont load and the server told me that the plugin doesnt contains plugin.yml but i use jd-gui and i saw him

quaint mantle
unreal quartz
#

so what are you saying?

quaint mantle
#

actually i might need better testing

#

I think you were meant to say the amount of time it takes to run?

quaint mantle
#

right? or

#

no

#

what did you mean

#

but anyways this leads to my second question if u guys didnt mind

muted crest
# muted crest Hey guys my plugin wont load and the server told me that the plugin doesnt conta...
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:154) ~[server.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [server.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [server.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [server.jar:git-Spigot-db6de12-18fbb24]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
    ... 6 more```
quaint mantle
muted crest
young knoll
#

Wrong reply, but close enough

quaint mantle
#

still the correct answer haha

muted crest
quaint mantle
#

yes

#

plugin.yml

#

not Plugin.yml

young knoll
#

Plugin.yml -> plugin.yml

muted crest
#

Ho im stupid 😂 thnx u

tacit mica
#

For the PersistantDataType, is there a default setting for a boolean?

young knoll
#

No

#

Just store a byte and use .has

ivory sleet
#

you can just use the byte type or smtng

tacit mica
#

So I should just use a byye?

ivory sleet
#

ye

quaint mantle
#

been trying to find a hacky-way to create something like this, provided center location, radius

blocks will be set by the function

L = the location the function would be provided
           L
BLOCK AIR AIR AIR BLOCK
BLOCK AIR AIR AIR BLOCK
BLOCK AIR AIR AIR BLOCK
BLOCK BLOCK BLOCK BLOCK

this would be the case for all dimensions, this is just a 2D elaboration.

any ideas?

tacit mica
#

Byte*, ok thanks!

ivory sleet
quaint mantle
#

no no

#

basically

#

L = player location

#

i want to set those blocks under the player

ivory sleet
#

ah

young knoll
#

Looks like the want a trench under the player

quaint mantle
#

kind of

#

yes

#

for loops 😄

young knoll
#

Or maybe a box with no roof, not sure

quaint mantle
#

but

mint flare
#

Hey ! Can we close an inventory only after player adding an item in a chest ?

quaint mantle
#

i thought about creating two cubes

#

first of BLOCK second with air

young knoll
quaint mantle
#

but im kinda braindead right now and i cant wait until tomorrow

young knoll
#

Actually close inventory might be one of the ones you are meant to delay a tick

#

Either way

mint flare
ivory sleet
#

no

#

?scheduling covers it

undone axleBOT
ivory sleet
#

look at scheduling a task

young knoll
#

You can listen to the close event and forcibly reopen it

twilit wharf
young knoll
#

They may manage bans themselves rather than using the vanilla sytem

twilit wharf
#

I dont want to keep it

#

I was looking at something, should I try to delete it and re ban?

young knoll
#

Worth a try

twilit wharf
#

yep

#

that was the issue

#

but it returns a CraftOfflinePlayer class

#

I will have to see if I can convert it

young knoll
#

Should be an OfflinePlayer

#

CraftOfflinePlayer is just the impl

vast shale
#

I'm trying to order and group player attacks based on a saved integer within objects attached via their UUID. For example, multiple players might have the attack number 4 and i'm trying to add their UUIDs to something so, once their sorted by the saved integer, I can group their attacks together, starting with attack number 0. Does anyone have a clever way of doing this?

pastel mauve
#

I tried developing a plugin but in the console, it tells me to use Version 60 of Java instead of 61, but i dont know how to switch it. I downloaded Java 16 but in IntelliJ it tells ne to use Java 17

shadow tide
#

I'm trying to use, and I copied their setup code, I have it as a dependency in the plugin.yml, obviously is is a plugin in my server, and it is still giving me this message: Disabled due to no Vault dependency found!

vast shale
#

Are you using the latest spigot and vault?

shadow tide
#

im downloading the latest spigot rn

#

i have the latest vault

vast shale
#

Does vault say it was enabled in console on startup?

shadow tide
#

yes

vast shale
#

Send your plugin.yml

shadow tide
#
name: customrecipies
version: 1.0
author: CJendantix
main: com.CJendantix.CustomRecipes.CustomRecipes
api-version: 1.17
depend: [Vault]```
vast shale
#

What other plugins are installed? Anything to do with the economy other than vault?

quiet ice
shadow tide
#

you mean the setup code?

quiet ice
#

Nah, in the log

vast shale
#

Vault isn't an economy plugin. Its just an API. Try installing EssentialsX

quiet ice
#

Myeh

#

You have to ask yourself why Vault is used, it isn't just an Eco API after all

shadow tide
#

its not for economy lol, its 4 perms

opaque grove
#

How do i set the armor of a npc

shadow tide
#

the attribute or the visuals?

opaque grove
#

visual

shadow tide
#

no clue

vast shale
#

What're you using for your NPC?

shadow tide
#

pls help me

#

my friend has been waiting for this plugin to be complete for a month now

foggy estuary
#

Where can i find the list for all the import org.bukkits

shadow tide
#

if you need the import it will tell you automatically

opaque grove
#

EntityPlayer npc = new EntityPlayer(nmsServer, nmsWorld, gameProfile); @vast shale

shadow tide
#

it is better to only use the ones you need to get rid of clutter

hazy rose
#

u know a free vps for hosting mc?

shadow tide
foggy estuary
#

I meant bukkit classes but dw i found them

hazy rose
#

pls help

shadow tide
#

no

#

Serious Spigot and BungeeCord programming/development help | Ask other questions here

hazy rose
#

ok

shadow tide
#

fine ill help

#
vast shale
humble garnet
#

?services

undone axleBOT
vast shale
#

Specifically setupPermissions method of the VaultAPI

#

@opaque grove

chrome beacon
#

1.9 forge docs???

opaque grove
vast shale
#

Yeah google search first result of entityplayer interface. Didnt see that

#

Glad you got it work!

shadow tide
#

does this need to be here? ```java
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if(!(sender instanceof Player)) {
log.info("Only players are supported for this Example Plugin, but you should not do this!!!");
return true;
}

    Player player = (Player) sender;
    
    if(command.getLabel().equals("test-economy")) {
        // Lets give the player 1.05 currency (note that SOME economic plugins require rounding!)
        sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getName()))));
        EconomyResponse r = econ.depositPlayer(player, 1.05);
        if(r.transactionSuccess()) {
            sender.sendMessage(String.format("You were given %s and now have %s", econ.format(r.amount), econ.format(r.balance)));
        } else {
            sender.sendMessage(String.format("An error occured: %s", r.errorMessage));
        }
        return true;
    } else if(command.getLabel().equals("test-permission")) {
        // Lets test if user has the node "example.plugin.awesome" to determine if they are awesome or just suck
        if(perms.has(player, "example.plugin.awesome")) {
            sender.sendMessage("You are awesome!");
        } else {
            sender.sendMessage("You suck!");
        }
        return true;
    } else {
        return false;
    }
}```
#

I wouldn't think so

#

@vast shale

vast shale
#

No thats just stopping anything other than a player from running the commands

young knoll
#

Imagine using log.info rather than sender.sendMessage

shadow tide
#

sorry I meant the entire command

vast shale
#

Are you asking if you need that onCommand function for it to work?

shadow tide
#

yes

vast shale
#

No you dont need that

shadow tide
#

k

vast shale
#

Do you have a permissions plugin? Again vault is an API

shadow tide
#

im not even using the economy anyway

shadow tide
#

it is for my plugin

#

my plugin is the permissions plugin

#

using the vault api

vast shale
#

Is your plugin being enabled before vault?

shadow tide
#

no

vast shale
#

Send your main from your plugin

shadow tide
#

?paste

undone axleBOT
shadow tide
vast shale
#

Have you tried downloading an economy plugin?

if (!setupEconomy() ) {
            log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
shadow tide
#

why tf would i need one, i am getting the feeling that you have no idea how the vault plugin works and you are just guessing

vast shale
#

...

#

Goodluck my guy

shadow tide
#

?

vast shale
#

Just troubleshooting, you gotta try possible solutions

ivory sleet
tribal onyx
#

Ello

shadow tide
opaque grove
#

I am getting this error:
java.lang.ClassCastException: class java.lang.Byte cannot be cast to class java.lang.Float (java.lang.Byte and java.lang.Float are in module java.base of loader 'bootstrap')
Cause of this lines:

DataWatcher watcher = npc.getDataWatcher();
watcher.set(new DataWatcherObject<>(15, DataWatcherRegistry.a), (byte) 127);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(npc.getId(), watcher, true);
connection.sendPacket(packet);
#

Any clue why

crimson terrace
#

You sure those are the lines?

#

Its a class cast exception because you tried to cast byte to float from what Im reading

elfin talon
#
for (int i = 0; i < LOC.size(); i++) {
            int id = i+1;
            LOC.get(i).getBlock().setType(Material.SKULL);
            String name = Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getName();
            Skull skull = (Skull)  LOC.get(i).getBlock().getState();
            skull.setSkullType(SkullType.PLAYER);
            skull.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getPlayer());
            skull.update();```

```java.lang.NullPointerException: player```

the error is in the skull.setOwningPlayer ... line
sullen marlin
#

why you calling .getPlayer

young knoll
#

You can't just call getPlayer on an OfflinePlayer

#

And you also don't need to

elfin talon
#

yeah thanks it works

ivory sleet
#

just use runTask instead of runTaskAsynchronously

sullen marlin
#

and remove the sleep

ivory sleet
#

^

sullen marlin
#

put the delay as the parameter to runTask

#

you should never ever use Thread.sleep in spigot

ivory sleet
#

there is a method called runTaskTimer which is probably what you're looking for :p

#

?scheduling this does cover what you need robustly

undone axleBOT
ivory sleet
#

essentially yees

#

but the wiki covers it to

#

if you scroll down a bit c:

#

you got the delightful potential of evolving your programming skills then

#

send the code

#

move the countdown inside the BukkitRunnable such that its on the same indent level as the method run

#

yes

#

well

sullen marlin
#

its ticks

ivory sleet
#

🥳

#

😌

young knoll
#

Map*

ivory sleet
#

a map ya

sullen marlin
#

put the countdown variable inside the runnable

#

no map needed

young knoll
#

Is it a dictionary in python too? The more you know

ivory sleet
trail oriole
#

Quick help needed

#

i can't get an inv to open a second one

#
@EventHandler
    public void onClick(InventoryClickEvent event) {
        Inventory inv = event.getInventory();
        Player p = (Player) event.getWhoClicked();
        ItemStack current = event.getCurrentItem();
        
        if (current == null) return;
        
        if(inv.getName().equalsIgnoreCase("§7Main kiwi menu")) {
            
            event.setCancelled(true);
            
            if (current.getItemMeta().getDisplayName().equalsIgnoreCase("§6Open §2wands §6menu")) {
                p.closeInventory();
                Inventory invWand = Bukkit.createInventory(null, 54, "§7Wand menu");
                
                p.openInventory(invWand);
            }
        }
        
        
    }
}```
#

there is no error but the second inv won't open

ivory sleet
young knoll
#

Also you are meant to delay that a tick

#

Not that I have in the past

trail oriole
#

should I debug the whole thing ?

#

ok

#

so the first if doesn't pass

#

although if(inv.getName().equalsIgnoreCase("§7Main kiwi menu")) this has the exacty same name as my inv

mint flare
trail oriole
#

Inventory inv = Bukkit.createInventory(null, 54, "§7Main kiwi menu");

ivory sleet
#

check the spoilers presented early

#

@mint flare

mint flare
#

I saw, but as I absolutely do not make my plugin work in this way I do not see at all what it is xD

#

Owh. My bad, i say trash x)

ivory sleet
#

no worries

trail oriole
#

i'm confused

#

Can i send the whole class ?

#

i really can't get to the error

young knoll
#

Just reload the map from a save

#

Unload the world, delete it, copy in the fresh world file, load the world

#

Something like this

misty current
#

would spigot be angry if i constructed a CraftPlayer? something like

public class CustomPlayer extends CraftPlayer {

    public CustomPlayer(Player p) {
        super((CraftServer) Bukkit.getServer(), ((CraftPlayer) p).getHandle());
    }
    
}
#

basically i need it to have a player with custom methods but i'm pretty sure spigot would not appreciate it

#

@ me if u reply

young knoll
#

Just make a wrapper class that keeps track of the bukkit player as a field

misty current
#

oh yea makes sense

#

no nasty nms

#

so i'd put in a getter for a Player

young knoll
#

Mhm

#

Just make sure to remove it from any data structures when they disconnect

misty current
#

yep

#

thanks

sullen marlin
#

why would you do this

misty current
#

store CustomPlayer instances in a list and associate to them data and utils methods

young knoll
#

You generally don't need to store the bukkit player

misty current
#

let's say each player has a level

sullen marlin
#

you could just do what everyone else does and make a wrapper

young knoll
#

As you will generally have a reference to it already, how else would you be getting the custom player data

sullen marlin
#

so 1) your plugin doesn't conflict with everyone; and 2) doesn't break on every update

young knoll
#

I did tell them to do that

misty current
#

yea and i switched to a wrapper class now

#
public class CustomPlayer {

    private final Player p;

    public CustomPlayer(Player p) {
        this.p = p;
    }
    
    public Player getPlayer() {
        return p;
    }
}
``` if that's what you meant
#

i need a reference to the player in there so i can use it for stuff like saving to yaml with the player's uuid

young knoll
#

Make the minigame in another world

#

You can't unload the main world

graceful turret
#

guys what's the difference between remove() and removeItem()?

quaint mantle
#

remove removes all

#

removeItem removes the amount

graceful turret
#

thx

trail oriole
#
        @EventHandler
    public void onClick(InventoryClickEvent event) {
        
        Inventory inv = event.getClickedInventory();
        Player p = (Player) event.getWhoClicked();
        ItemStack current = event.getCurrentItem();
        
        if (current == null) return;
        
        p.sendMessage("debug 1");
        
        if(inv.getTitle().equalsIgnoreCase("§7Main kiwi menu")) {
            
            p.sendMessage("debug 2");
            
            event.setCancelled(true);
            
            if (current.getItemMeta().getDisplayName().equalsIgnoreCase("§6Open wands menu")) {
                p.closeInventory();
                
                p.sendMessage("debug 3");
                
                Inventory invWand = Bukkit.createInventory(null, 54, "§7Wand menu");
                p.openInventory(invWand);
            }
        }
        
    }
}``` I still can't get this to work, istg i tried everything and none of the debugs are working
graceful turret
#

what's the last debug message?

trail oriole
#

wdym

graceful turret
#
 p.sendMessage("debug 2");
  p.sendMessage("debug 3");```
trail oriole
#

none of the debugs displays

graceful turret
#

event registered?

trail oriole
#

well i think so

#

should be

#

it's imported

#

i checked on spigot's docs

#

and this is the one

misty current
#

imported != registered

trail oriole
#

how do I know if it is registered ?

young knoll
#

Did ya call registerEvents

trail oriole
#

sorry i'm a beginner kinda confused around here

misty current
#

if you registered it it is registered

#

else it isnt

trail oriole
#

then i did not ?

misty current
#

guess so

trail oriole
#

how do i do that ?

misty current
#

Bukkit.getServer().getPluginManager().registerEvents(new MyEvent(), plugin);

twilit wharf
#

getServer().getPluginManager().registerEvents(new "Event Class Name"(), this);

misty current
#

plugin being the instance of your main class

trail oriole
#

so i shall put this in my onEnable() right ?

twilit wharf
#

yeah

misty current
#

yep

trail oriole
#

and what do i replace plugin by again ?

trail oriole
#

yeah nvm

#

i didn't see your message sorry

misty current
#

write this if it is in your main class

trail oriole
#

yeah i did it

misty current
#

kk

trail oriole
#

ok so let me retry now

#

ok now i have the first debug only

#

but it works better

#
if (current == null) return;
        
        if(inv.getTitle().equalsIgnoreCase("§7Main kiwi menu")) {```
#

seems to be stuck within these ifs

sturdy storm
#

How can i check how many players are on? I want to do an if statement of if players >= x.... or something like that how can i do that?

trail oriole
#

loop all players in a avr

stark stag
#

Bukkit.getOnlinePlayers().size()

sturdy storm
stark stag
#

Google is your friend 🙂

sturdy storm
stark stag
#

Plugin is a variable which refers to the plugin that you are creating

#

You can name it anything you want... but it refers the the instance of JavaPlugin

#

If you don't have access to the plugin variable then you can reference the broadcastMessage method directly from the Bukkit class using Bukkit.broadcastMessage()

sturdy storm
#

so i made one named "wepwawet" so just wepwawet.getServer().broadcastMessage("Message")

When i do that it then gives the error on the getServer() and it does the same if i replace it with Bukkit like idk what to put

#

@stark stag?

stark stag
#

I assume you are creating a Minecraft plugin for Java, yes?

#

If so, then the first thing you must do is create a Java class for your plugin which extends JavaPlugin

#

The variable which you are trying to access is the instance of the plugin you have created

#

You can obtain a reference to the plugin using the this keyword in any method on the plugin

#

Or, alternatively, you can avoid this issue by accessing the Bukkit API using static methods on the Bukkit class as previously explained

sullen marlin
#

well whats the error when you build

#

I assume the red is just your ide not understanding rather than an actual error

#

post the actual build log

#

copy one of the examples

#

I've never used yguard on a plugin so don't really know the exact config

#

if you want a Proguard config I can help you with that intead

#

no

#

this example needs java 11+

#
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <options>
                        <option>-allowaccessmodification</option>
                        <option>-repackageclasses com.example.plugin</option>
                        <option>-renamesourcefileattribute SourceFile</option>
                        <option>-keepattributes RuntimeVisibleAnnotations</option>
                        <option>-keepattributes SourceFile,LineNumberTable</option>
                        <option>-keepclassmembers class * { @org.bukkit.event.EventHandler *; }</option>
                        <option>-keepclassmembers class * { @net.md_5.bungee.event.EventHandler *; }</option>
                        <option>-keep class * extends org.bukkit.plugin.java.JavaPlugin</option>
                        <option>-keep class * extends net.md_5.bungee.api.plugin.Plugin</option>
                    </options>
                    <libs>
                        <lib>${java.home}/jmods</lib>
                    </libs>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>6.1.1</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>```
#

don't forget to change the repackageclasses part

sturdy storm
# stark stag You can obtain a reference to the plugin using the `this` keyword in any method ...

im confused about the this keyword. I have these two things whats wrong

public final class ForestblockTimer extends JavaPlugin {

    public void onEnable() {
            int players = getOnlinePlayers().size();
            BukkitScheduler scheduler = getServer().getScheduler();
            scheduler.scheduleSyncDelayedTask(this, new Runnable() {
                @Override
                public void run() {
                if (players >= 4) {
                    wepwawet.getServer().broadcastMessage("wepwawet");
                }
                }
            }, 20L);
        }
    }

and this in a folder called tasks

public class wepwawet extends BukkitRunnable {

    wepwawet plugin;
    wepwawet(wepwawet plugin) {
        this.plugin = plugin;
    }

    public void run() {
        System.out.println("Task has been run");
    }

}
stark stag
#

Replace wepwawet with this

young knoll
#

this refers to the current instance of the class

twilit wharf
#

I want to make a menu showing the currently banned players, and I want it to create as many menus as there are 51 banned players. I cant seem to figure out how to do it. StaffPlusPlus somehow did it.

young knoll
#

Inside ForestblockTimer this will be an instance of ForestblockTimer

#

Inside wepwawet this will be an instance of wepwawet

stark stag
#

Also, the BukkitRunnable class you created doesn't make sense. Replace wepwawet plugin; with ForestblockTimer plugin

sturdy storm
stark stag
#

Your current issue is in the class named wepwawet which extends BukkitRunnable

young knoll
#

this.getServer will only work in a class that extends JavaPlugin

#

However you can use Bukkit.getServer anywhere

trail oriole
#
    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        
        Inventory inv = event.getInventory();
        ItemStack clickedItem = event.getCurrentItem();
        Player p = (Player) event.getWhoClicked();
        
        if(inv.getTitle() == "§7Main kiwi menu") {
            
            event.setCancelled(true);
            if (clickedItem == null) return;
            
            if (clickedItem.getItemMeta().getDisplayName().equalsIgnoreCase("§6Open wands menu")) {
                p.closeInventory();
                
                Inventory invWand = Bukkit.createInventory(null, 54, "§7Wand menu");
                p.openInventory(invWand);
            }
        }
        
    }```i've tried modifying my code in all the ways i could think of and i still can't get it to open that new inv
sturdy storm
young knoll
#

I mean, it should

trail oriole
#

?paste

undone axleBOT
trail oriole
#

any help ?

young knoll
#

30.10 02:44:00 [Server] INFO Caused by: java.lang.NoSuchMethodError: org.bukkit.inventory.Inventory.getName()Ljava/lang/String;

#

getName was removed a while ago

trail oriole
#

i tried getTitle() too

young knoll
#

Still no

trail oriole
#

oh

young knoll
#

event.getView().getTitle()

trail oriole
#

may i ask why ?

sturdy storm
trail oriole
young knoll
stark stag
#

@sturdy storm that's what happens for me too because I am using Paper 1.17.1

sullen marlin
#

@quaint mantle should work for java14+ I think, what issue you having?

#

try bumping to the latest versions

#
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.5.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <options>
                        <option>-allowaccessmodification</option>
                        <option>-repackageclasses com.example.plugin</option>
                        <option>-renamesourcefileattribute SourceFile</option>
                        <option>-keepattributes RuntimeVisibleAnnotations</option>
                        <option>-keepattributes SourceFile,LineNumberTable</option>
                        <option>-keepclassmembers class * { @org.bukkit.event.EventHandler *; }</option>
                        <option>-keepclassmembers class * { @net.md_5.bungee.event.EventHandler *; }</option>
                        <option>-keep class * extends org.bukkit.plugin.java.JavaPlugin</option>
                        <option>-keep class * extends net.md_5.bungee.api.plugin.Plugin</option>
                    </options>
                    <libs>
                        <lib>${java.home}/jmods</lib>
                    </libs>
                </configuration>
            </plugin>```
#

see if that works, uses latest version of proguard

twilit wharf
sullen marlin
#

haven't tested it myself

stark stag
sullen marlin
#

'Serious **Spigot **and BungeeCord programming/development help'

stark stag
#

He asked the question

young knoll
#

I mean you can still use the deprecated one

sullen marlin
#

proguard is finnicky

#

especially with depends

trail oriole
#

why is getItemInHand() deprecated ?

sullen marlin
#

read the javadocs

young knoll
#

Because there are 2 hands

trail oriole
#

lmao

young knoll
#

Which hand is hand

trail oriole
#

really ?

young knoll
#

Yes?

#

They added a second hand several years ago

trail oriole
#

oh i thought you were joking

wind tulip
#

Getting direction of a block and then setting it (getAxis();)

sturdy storm
young knoll
#

No

#

Bukkit and spigot are quite similar as they are both developed together these days

#

Paper is entirely different

trail oriole
#
    @SuppressWarnings("deprecation")
    public void onItemClick(PlayerInteractEvent event) {
        Player p = (Player) event.getPlayer();
        
        if(p.getItemInHand().getType() == Material.BLAZE_ROD){
            if (event.getAction() == Action.RIGHT_CLICK_AIR) {
                p.launchProjectile(Fireball.class);
            }
        }
    }``` why isn't this working ?
#

I have no idea how to use onItemClickEvent so i tried this

young knoll
#

Did ya register it

trail oriole
#

Bukkit.getServer().getPluginManager().registerEvents(new wandMechs(), this); this ?

#

i have this in my main class

jade perch
#

Don't see the @EventHandler unless you didn't include it

trail oriole
#

is that it ?

#

hold on

#

ok

young knoll
#

Ah yep, I saw an annotation and just assumed it was eventhandler

trail oriole
#

i'm dumb

#

i may have forgot the event handler

#

but like

#

no worries

#

😅

#

any ideas on how I could modify the fireball explosion's force

sullen marlin
#

Check the docs

jade perch
#

maybe store the fireball entity uuid in a map

#

and on ProjectileHitEvent change what happens

#

make the fattest explosion

sullen marlin
#

Or use the hand dandy setYield method

young knoll
#

Should have a method for it

jade perch
#

even better

young knoll
#

Oh gosh that is weird

#

Yield means different things between explosive and explode event

sullen marlin
#

Sad

trail oriole
#

although i used Fireball.class to launch it, and i can't directly modify it's yield

sullen marlin
#

Alexa, play despacito

#

Why can't you?

#

It's a method in fireball

trail oriole
#

either i don't know how, or i can'(t

sullen marlin
#

setYield

jade perch
#

store the value of launchProjectile that will be your fireball entity

trail oriole
#

i tried Fireball.class.setYield()

#

didn't work

trail oriole
sullen marlin
#

No you call it on the return value of launchProjectile

trail oriole
#

oh ok

young knoll
#

Woo generics

foggy estuary
#

``@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {

        Entity entity = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"), 0 , 29 , -181 ),EntityType.STRAY);
            
        entity.setGlowing(true);
        entity.setCustomName("test");
        entity.setCustomNameVisible(true);``
#

does anyone know how to make it so the entity only spawns once using an if statement?

young knoll
#

Once per player?

#

Once in general?

foggy estuary
#

in general

#

at that one location

young knoll
#

Get the location as a vector and add it to a set

#

Then make use of .contains

foggy estuary
#

Ok thank you.

young knoll
#

Not sure if location.toVector uses int coords or double coords

foggy estuary
#

double

young knoll
#

If it uses doubles you can just make your own vector using new Vector

#

Assuming you only want it once per block

foggy estuary
#

I do

young knoll
#

Make your own vector using getBlockX/Y/Z then

quaint mantle
#

Heya! I've not made a Bungee cord plugin before but essentially what I'm aiming to do is connect a Bukkit plugin across 3 servers on a network

So essentially we have a core plugin which we've decided to connect to a single remotely hosted MySQL database and want to edit it to where all of our players on all of our 3 survival servers can use the features together rather than it being individual per-server

The way I thought I might achieve this is using BungeeCord and triggering event calls(since this plugin relies on caching data because of its size)? But i'm not certain as it's very new to me. But essentially, would it be possible/feasible to make our Bukkit plugin call an event from the BungeeCord plugin which in turn the Bungee would handle the event. The other plugins would Listen for the custom event and then perform a certain action (aka like updating a cached list/etc)

#

If anyone has any better suggestions too of course, I'll take them; never have I been asked to take a plugin of this caliber and stretch it across a network lmao nor do i have bungee experience yet

ivory sleet
#

You can use something like redis as a shared cache

#

And rabbitmq as a message broker for your event bus maybe

ornate patio
#

if a player is at like y = 100000, do the chunks below them still render?

#

(ping me pls)

young knoll
ornate patio
#

ah, alright

#

thanks

subtle folio
#

im trying to get whenever a pressure plate in certain cords are but my code is not working

#
@EventHandler
    public void onCheckPoint(PlayerInteractEvent event){
        if (event.getPlayer().getWorld().getName().equals("parkour")){
            if (event.getAction().equals(Action.PHYSICAL)){
                if (event.getClickedBlock().getType() == Material.STONE_PLATE){
                    System.out.println(event.getClickedBlock().getLocation() + " " + event.getClickedBlock().getType());
                    if (event.getPlayer().getLocation() == new Location(Bukkit.getWorld("parkour"), -3, 38, -62) && TazPvP.statsManager.getCheckpoints(event.getPlayer()) < 1){
                        TazPvP.statsManager.setCheckpoints(event.getPlayer(), 1);
                        event.getPlayer().sendMessage(ChatColor.GREEN + "Checkpoint set");
                    }```
young knoll
#

What part does it make it to

subtle folio
#

it makes it to printint the location

#

but when checking the cords

#

[03:17:02 INFO]: Location{world=CraftWorld{name=parkour},x=-3.0,y=38.0,z=-62.0,pitch=0.0,yaw=0.0} STONE_PLATE

#

this is what console prints

young knoll
#

Ah

#

That players location will probably never be equal to that location

#

Because they are almost never perfectly aligned with a block

subtle folio
#

i also tried getting the block

drowsy helm
#

you can check distance

subtle folio
#

how do I do that?

young knoll
#

Location.distance

#

Actually distanceSquared is probably better

subtle folio
#

if (event.getClickedBlock().getLocation().distanceSquared(event.getPlayer().getLocation()))

#

idk how to use this condition lmao

drowsy helm
#

is the output is less than like 1

subtle folio
#

`if (new Location(Bukkit.getWorld("parkour"), -3, 38, -62).distanceSquared(event.getPlayer())){

                }`
drowsy helm
#

use variables aswell makes it cleaner

subtle folio
#

im using this now

#

still dont understand how to sepcify o:

drowsy helm
#
Location blockLoc = event.getClickedBlock().getLocation();
Location playerLoc = event.getPlayer().getLocation();
if(blockLoc.distanceSquared(playerLoc) < 1){
  //do stuff
}```
#

something like that

subtle folio
#

that cant be applied

#

int cant compare world location

drowsy helm
#

thats why i said something like that

#

dont copy paste

subtle folio
#

im not copy and pasting

drowsy helm
#

distanceSquared returns a double it should be fine anyway

#

can i see how you did it

subtle folio
#

                    }```
drowsy helm
#

you have the < 1 in the wrong place

#

use variables it will make your code 100x cleaner

subtle folio
#

ohh

#

ty

#
  • variables are cringe in 1 time use
drowsy helm
#

not at all

#

makes your code far more readable

#

and you dont have lines that stretch 100 characters

next stratus
rancid pine
#

can anyone help me and tell me the main things i need to know to understand how to make plugins and how the game works

#

because im confused about a lot of things and i've been trying to learn

young knoll
#

Do you know java

pastel mauve
#

I tried developing a plugin but in the console, it tells me to use Version 60 of Java instead of 61, but i dont know how to switch it. I downloaded Java 16 but in IntelliJ it tells ne to use Java 17

drowsy helm
#

you have to actually set the compiler version

rancid pine
urban nova
#

Hello, I'm new to spigot, and i need to save data, e.g. player money. What I need to use? JSON or something else? Thanks

young knoll
#

Json is a good method

#

Spigot has Gson built in

#

SQLite is another option

urban nova
#

Thanks

urban nova
young knoll
urban nova
#

Thanks

alpine urchin
#

but true json is good

acoustic pendant
#

a custom event ig

#

you specify if a player has 5 you compare to the other players

#

and then you make the placement

#

i think

verbal nymph
#

Which of these three would be the correct approach for declaring & initializing the world variable?

Initialize as static class variable.

public class TimeModifierTask implements Runnable {
    static final World WORLD = Bukkit.getWorlds().get(0);
    final int modifier;

    public TimeModifierTask(int modifier) {
        this.modifier = modifier;
    }

    public void run() {
        WORLD.setTime(WORLD.getTime() + modifier)
    }
}```
Initialize in constructor.
```java
public class TimeModifierTask implements Runnable {
    final World world;
    final int modifier;

    public TimeModifierTask(int modifier) {
        this.modifier = modifier;
        this.world = Bukkit.getWorlds().get(0);
    }

    public void run() {
        world.setTime(world.getTime() + modifier)
    }
}```
Pass it to the task
```java
public class TimeModifierTask implements Runnable {
    final World world;
    final int modifier;

    public TimeModifierTask(int modifier, World world) {
        this.modifier = modifier;
        this.world = world;
    }

    public void run() {
        world.setTime(world.getTime() + modifier)
    }
}```
outer sorrel
#

probably not the best place to ask but really not sure where else

acoustic pendant
#

Hey, do anyone know why is this code always null?

            } else if (args.length == 2) {
                Player target = Bukkit.getPlayerExact(args[0]);
                if (target != null) {
                    target.getName();
                    player.sendMessage(ChatColor.BLUE + "/mana remove {Player} {amount}");
                } else {
                    player.sendMessage(ChatColor.AQUA + "[MineSpace]" + ChatColor.RED + " Specify a real player!");
                }```
#
            } else if (args.length == 2) {
                Player target = Bukkit.getPlayerExact(args[0]);
                if (args[0].equalsIgnoreCase(target.getName())) {
                    if (target != null) {
                        target.getName();
                        player.sendMessage(ChatColor.BLUE + "/mana remove {Player} {amount}");
                    } else {
                        player.sendMessage(ChatColor.AQUA + "[MineSpace]" + ChatColor.RED + " Specify a real player!");
                    }
                }
#

the second one ^^

quaint mantle
#

is there any pdc api in 1.8.8 ?

#

or anyway to save data in an itemstack without nms in 1.8.8

acoustic pendant
celest isle
#

package lustrecrew.damagetag.utils;

import org.bukkit.entity.ArmorStand;

public class Task extends Thread {
    ArmorStand place;

    public Task(ArmorStand armorStand) {
        this.place = armorStand;
    }

    public void run() {
        try {
            Thread.sleep(10L);
            this.place.remove();
        } catch (InterruptedException var2) {
            var2.printStackTrace();
        }

    }
}```

```package lustrecrew.damagetag.events;

import lustrecrew.damagetag.armorstand.CreateArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;

public class DamageEvent implements Listener {
    public DamageEvent() {
    }

    @EventHandler
    public void onDamageEvent(EntityDamageEvent event) {
        if (event.getEntity() instanceof Player) {
            Player player = (Player)event.getEntity();
            double i = event.getDamage();
            i = (double)Math.round(i);
            i /= 2.0D;
            new CreateArmorStand(i, player);
        }

    }

}```
any idea why the armorstand doesnt get removed
#

1.17

acoustic pendant
#

what are you trying to do?

#

damage indicator?

celest isle
#

yeah

acoustic pendant
#

well, i have it other way...

acoustic pendant
celest isle
#

thats too much extra resource to use on the server as we are coding a mmorpg server lol

#

dont wanna have it constantly counting

acoustic pendant
#

when you create it

#

you make a delay for 40ticks for example

#

and it deletes

opaque grove
#

When i create a packetreader to read PacketPlayInUseEntity my getValues for actions do not return ATTACK/INTERACT, but net.minecraft.network.protocol.game.PacketPlayInUseEntity$1@2362ee72. Only getValue of "a" (entityid) seems to work how it should

ancient herald
#

Hello everyone! How i can modify the drop of an hanging entity like itemframes? I mean the itemframe drop itself, not the item that contains.

lost matrix
acoustic pendant
#

Hello! how can i do so here it doesn't send this warning:

ancient herald
lost matrix
lost matrix
# acoustic pendant

amount >= 0.00D is a boolean expression so it will either be true or false.
args[2] is a String. So you are comparing a String with a boolean which will always not be equal.

acoustic pendant
lost matrix
acoustic pendant
#

the value that the player is giving

#

the number

lost matrix
acoustic pendant
#

hmm

lost matrix
# ancient herald So what i should do?

Lets see. EntityDeathEvent only gets called for LivingEntities. And ItemFrame is not one.
So we would have to look into workarounds. Maybe the EntityDropItemEvent or some ItemFrame property.

ancient herald
#

At least there is a way to prevent itemframe from dropping itself?

young knoll
#

There are events for hanging entities

ancient herald
#

3 events

#

And no one of the three has something to change/remove the drop of the itemframe

#

Neither ItemFrame class has something about it

#

You can only change the item contained inside it, but it is not what i am looking for

young knoll
#

You could cancel those events and then just .remove() the entity

ancient herald
#

Would it drop something?

#

or just removes it?

lost matrix
#

Maybe something like this:

      @EventHandler
      public void onDeath(final HangingBreakEvent event) {
        if (event.getEntity() instanceof ItemFrame frame) {
          event.setCancelled(true);
          final ItemStack item = frame.getItem();
          if (!item.getType().isAir()) {
            frame.getWorld().dropItemNaturally(frame.getLocation(), item);
          }
          frame.remove();
        }
      }
#

Yeah this works

ancient herald
#

thanks!

#

Really

pastel relic
#

hey, does anyone know how i can make gradient text, or just use custom colours?

lost matrix
#

Make the "score" Comparable, put it in an ordered collection like a List and call .sort() on it.
Or just use a TreeSet from the beginning.

ancient herald
lost matrix
ancient herald
lost matrix
young knoll
#

Otherwise you can use ChatColor.of

pastel relic
jade perch
#

what your buildfile config look like

lost matrix
#

Here is another example:

  private final Map<UUID, Double> scoreMap = new LinkedHashMap<>();

  public void setScore(final UUID userID, final double score) {
    this.scoreMap.put(userID, score);
  }

  public double getScore(final UUID userID) {
    return this.scoreMap.getOrDefault(userID, 0D);
  }

  public List<Entry<UUID, Double>> getTop(final int amount) {
    return this.scoreMap.entrySet().stream()
        .sorted((e1, e2) -> (int) (e1.getValue() - e2.getValue() + 0.5D))
        .limit(amount)
        .toList();
  }

You can also write the getTop() method in a more old school way. But it will require some more lines.

young knoll
pastel relic
young knoll
#

No

pastel relic
#

sorry, im quite new to java

young knoll
#

The text goes outside the brackets

pastel relic
#

oh

ancient herald
jade perch
#

You using gradle or maven?

#

if not you don't have one

pastel relic
#

ChatColor.of((“#rrggbb”) + "example text")? or ChatColor.of(“#rrggbb”) + "example text"?

pastel relic
#

the what?

#

whats a latter?

ancient herald
#

Using the integrated one of intellij

jade perch
#

What does your Build, Execution, Deployment > Compiler > Java Compiler look like

lost matrix
#

Yes

lost matrix
# ancient herald I'm using no builders

I would look at File > Project Structure > Project > Project SDK
and File > Project Structure > Modules > Language Level
Make sure both of them are at least 16

#

If you use an old Java version then you need to do this, yes.

#

What spigot version are you on?

jade perch
#

Make sure to change the bytecode version to 16

#

other than that I think you need to update your artifacts

#

I haven't touched artifacts in years, but that's probably it

pastel relic
ancient herald
jade perch
#

Sweet, np

lost matrix
young knoll
pastel relic
pastel relic
#

aaa worked!!

#

tysm again ^^

rigid hazel
#

Is the InventoryCloseEvent called, when a player had open their inventory and left the server?

lost matrix
rigid hazel
#

Oh. Can I do that with custom inventories too?

lost matrix
#

If the user has some other inventory open then the InventoryCloseEvent fires if he leaves.
I dont get what you mean by "Can I do that with custom inventories too". You want the event to NOT fire for other inventories too?

rigid hazel
#

And when the event is fired on leave then everything is fine.

lost matrix
#

The InventoryCloseEvent is fired for every inventory that is not the players own PlayerInventory. This is also true for when a Player quits.

rigid hazel
#

Nice. This is very, very nice. thanks

lost matrix
#

reverse the comparator. e2 - e1

coral heron
lost matrix
#

As in write a plugin which breaks this?

coral heron
#

either that or just..... abuse it ingame

#

since I need to test if the transaction handler hasn't got any weird behaviour

#

i'd be real helpful since I am not really good at it

hazy carbon
#

how can I make it so basically someone invites someone to the discord server they get an item in-game

summer scroll
#

How can I set right arm of armor stand pose with packets? It takes Vector instead of EulerAngle.

lost matrix
coral heron
lost matrix
coral heron
#

shiid

#

sorry

lost matrix
#

You also need to map a discord user to a mc user which is a different story. IP mapping would be an option or manual registration.

hazy carbon
#

is there just a simple plugin?

lost matrix
coral heron
lost matrix
#

You forgot to shade in the kotlin lib...

#

Sure. Just split the message at the whitespace chars

acoustic pendant
#

Hey, could anyone help me about config.yml? guides only explain about changing messages and don't know more about that :/

coral heron
#

on my machine it runs fine

#

@lost matrix are you using stock java?

lost matrix
#
  public String[] getArgs(String commandMessage) {
    return commandMessage.split(" ");
  }

or if you want to remove the /command
then

  public String[] getArgs(String commandMessage) {
    String[] allPieces = commandMessage.split(" ");
    String[] args = new String[allPieces.length - 1];
    System.arraycopy(allPieces, 1, args, 0, args.length);
    return args;
  }
lost matrix
coral heron
lost matrix
coral heron
#

also the plugin breaks with java 8 if you try it on java 16 it works

summer scroll
#

How can I rotate armor stand with packets?

#

the whole body, like ArmorStand#setRotation does.

stone sinew
#

Exactly what it says... name cannot be null.

args[0] is null.

lavish hemlock
#

Maybe set the value in it when you create it? lmao

eternal night
#

Why are you even creating a new args array

stone sinew
#

Get the message from the event and split it.
Instead of String[] args = new String[1]
String args = event.getmessage().split(" ")

eternal night
#

oh this is a listener 😓

lavish hemlock
#

:| really

#

you're really going to ask "and then?"

stone sinew
#

e.getMessage() returns the whole string so if you split on it args[0] will be the command /<command> so adjust accordingly.

quaint mantle
#

player.getInventory().addItem(new ItemStack(Material.YOUR_ITEM, Amount));

tardy delta
#

what's the difference between an direct initialisation and a static block?

ivory sleet
#

Direct initialization?

#

A static block runs when the class loads

#

Which usually happens once during runtime

unique meteor
#

only once

#

class loads if the JVM starts

#

would need to restart the whole program to load it again

ivory sleet
#

It can happen more times

#

Classes can unload and then you can technically load them again

tardy delta
#

and why would you use a static block if you can just do private static final int i = 123;

ivory sleet
#

If you want to perform logic

#

Like let’s say a loop or smtng

tardy delta
#

ah

#

like a map or some things

ivory sleet
#

Yeah maybe

unique meteor
#

or if your class constructor needs a parameter

#

and you need to define that parameter before with some extras

ivory sleet
tardy delta
#

oki

vestal matrix
#
            for (String arg : args) {
                builder.append(arg).append(" ");
            }
            String argsCombined = builder.toString();
            Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', argsCombined));``` how could i exclude the 1st argument from the broadcast? args[0]
opal juniper
#

Arrays.stream(args).toList().subList(1,args.length - 1) Something like this would work, granted it assumes args.length < 0 and is probably not the fastest due to the stream

quaint mantle
opal juniper
#

yea a simple for loop works

#

lol

quaint mantle
#

Or Arrays.copyOfRange

opal juniper
#

i thought "I wonder if there is a better way than a for loop" and just completely abandoned the whole idea

#

just use the for loop imo

tardy delta
#

normally if cancel becomes true, the runnable should be cancelled right?

#

i have a
.runTaskTimerAsynchronously(plugin, 1L, 1L);
after it

ivory sleet
#

And do you use the cancel variable there as well?

tardy delta
#

uhh what its just this

acoustic pendant
#

Hello! i'm trying to do a thing but i'm not getting it...

How can i do to access the boolean from other class?

tardy delta
#

make a getter?

#

and dont make your variable starts with a capital letter

opal juniper
#

either make it a public field

#

or make a getter

eternal night
#

Your if statement is also pretty useless

opal juniper
#

idk why you need that tho

acoustic pendant
eternal night
#

if(x = true) will always execute

acoustic pendant
tardy delta
#

you want a command to set the boolean to true?

acoustic pendant
#

or false

#

and i have a command class

#

but can't access the boolean from the other class

#

trying doing an instance

#

but no

tardy delta
#

make a getter

#

or a setter

#

probably

public void setCancelled() {
  cancelled = !cancelled; // toggle it
}```
true vault
#

Hi, i get this error while trying to connect to my MySQL Server (localhost)
I double checked password and everything else
Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
My Code to connect to the Database:
con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, user, password);
I have tried using useSSL=false but it still gives me the same error.

                        "?autoReconnect=true" +
                        "&verifyServerCertificate=false" +
                        "&useSSL=false";
                con = DriverManager.getConnection(dbURL, user, password);```

How do i provide 'truststore for server certificate verification' and is there a way to not having to use one? 
Or is there something wrong with my code that i just don't see?
tardy delta
#

i dunno

opal juniper
#

setCancelled should make it = true

#

or take param

tardy delta
#

i dunno what he's trying to achieve

true vault
opal juniper
#

i just dont know

coral heron
# true vault Hi, i get this error while trying to connect to my MySQL Server (localhost) *I d...
  //Load Drivers
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            Properties properties = new Properties();
            properties.put("user", user);
            properties.put("password", password);
            properties.put("autoReconnect", "true");
            properties.put("useSSL", "false");
            properties.put("verifyServerCertificate", "false");
            //Connect to database
            String url = "jdbc:mysql://" + host + ":" + port + "/" + databaseName;
            conn = DriverManager.getConnection(url, properties);
tardy delta
#

PropertiesBuilder :kekw:

opal juniper
tardy delta
#

wheres my nitro

coral heron
#

got this from the best plugin ever, (eco sql bridge) and modified it

#

by best I mean very weird

opal juniper
#

eco as in auxilor?

coral heron
opal juniper
#

ah

acoustic pendant
#

by a command

#

i have it false as default

tardy delta
#

probably mine then

true vault
coral heron
acoustic pendant
tardy delta
#

if you want to "untoggle it"

#

uh no

#

just a method

acoustic pendant
#

wait

#

wait

coral heron
#

what sql server are you connecting to?

acoustic pendant
# tardy delta just a method

i was thinking about having it in false by default and then check if it is false, then change to true if not, then change to false

#

but i can't access that method in the command class

tardy delta
#

a boolean field is false by default

#

smh my wifi was a minute down and i kept playing on the server

true vault
coral heron
true vault
#

Well yesterday it worked fine 😞

coral heron
#

well what happened between yesterday and now? since nothing is wrong with your code

#

oh actually

#
properties.put("allowPublicKeyRetrieval","true");
#

add this

#

also warning:

AllowPublicKeyRetrieval=True could allow a malicious proxy to perform a MITM attack to get the plaintext password, so it is False by default and must be explicitly enabled.

acoustic pendant
#

@tardy delta

                    if (plugin.isCancelled()) {
                        //true
                        plugin.setCancelled(false);
                    } else {
                        //false
                        plugin.setCancelled(false);
                    }

this will work i guess?

tardy delta
#

plugin.setCancelled :/$

#

it would work

acoustic pendant
#

oh wait

#

both are in false

tardy delta
#

the name of the method

acoustic pendant
#

lol

#

oh xD

tardy delta
#

ah didnt even see it

acoustic pendant
#

i did the generate code

tardy delta
#

just make a toggle method

true vault
acoustic pendant
coral heron
#

maybe

acoustic pendant
#

the console says that this.plugin is null

tardy delta
#

:/

acoustic pendant
tardy delta
#

are you sure it's excluded?

wind tulip
#

https://imgur.com/a/WmMsOrL

My plugin is supposed to let you cycle bed colors, but it doesn't work if the bed is facing south, which is really weird.

coral heron
wind tulip
#

yes

quiet ice
#

likely because of how blocks are ticked

wind tulip
quiet ice
#

try supressing block updates when updating the block data

wind tulip
#

How? Sorry I'm new to java & spigot lol

quiet ice
#

?jd

wind tulip
#

oh do you think it happens because there isn't a "pillow" part

#

loc.getBlock().setBlockData(newData, false);

#

did I do it right

quiet ice
#

yes

wind tulip
#

it still happens though

quiet ice
#

hm, let me see how I did it in my plugin

#

Only set the material. However your loc.getBlock().setBlockData(newData); call is superfluous, I believe it can be removed

wind tulip
#

I use the setData for the direction

#

of the bed

regal lake
#

The bed already have a direction i guess ?

quiet ice
#

what happens if you remove that too?

wind tulip
#

if I remove the setBlockData the new-placed bed will always face the default direction

#

which is north I think

quiet ice
#

I feared that

#

welp, not much I can help you with then

wind tulip
#

but do you think it happens because the front part of the bed is missing?

tacit drift
#

no

quiet ice
#

possible, but I do not think so - it is certainly a legal - albeit cursed state

plucky crow
#
    @EventHandler
    public void compassclick(PlayerInteractEvent e) {
          ItemStack compass = e.getItem();
            if (compass != null) {
            }
        if (e.getPlayer().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.RED+""+ChatColor.BOLD+"Lobiye dön"));
           compassgui(e.getPlayer());
    }

can you fix this code? If I click on a space or a block it gives an error.

tacit drift
#

send error

#

?paste

undone axleBOT
plucky crow
tacit drift
#

what is line 182

glossy scroll
#

getItemMeta is null most likely

plucky crow
#

}

#

1 minut

tacit drift
#

you have a ;

#

at the end of if

glossy scroll
#

compass.hasItemMeta()

tacit drift
#

oh yeah

glossy scroll
#

getDisplayName also might be null

#

Hard to tell when not using java 16

#

Or whichever one gives better NPE outputs

tardy delta
#

?di

undone axleBOT
verbal nymph
#

Can this really throw a NullPointerException?

tardy delta
#

in which context?

coral heron
tardy delta
#

but probably player is null

#

i wouldnt know why

verbal nymph
#

yeah, getKiller() can return null

#

But would it really throw a NPE here or is the IDE just wrong?