#help-development

1 messages · Page 1689 of 1

nova grove
#

How would I make a title? I know that this is how I make it with Minecraft commands, but how would I make it in Bukkit?
/title @a title {"text":"Hello","bold":true,"color":"gold"}

waxen plinth
#

lombok 🤮

lost matrix
#

Looks like this class is reserved for EntityHuman only.

quaint mantle
#

ok what should i do now

#

and send the packets at the same tick

torn vale
#
    public void onMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        if (cooldown.containsKey(player)) {
            if (event.getPlayer().isOnGround()) {
                cooldown.put(event.getPlayer(), false);
            }
        }
    }```
isOnGround is depracted. Why? I doesn't work ingame because its depracted
lost matrix
quaint mantle
#

the spawn and metadata

#

at the same tick

lost matrix
torn vale
chrome beacon
#

You can't

#

Anyway it does work

#

Just use it but be aware of spoofing

lost matrix
chrome beacon
#

Yeah I guess that works too

lost matrix
quaint mantle
#

so the armor stand doesnt appears normaly for 1 tick

lost matrix
quaint mantle
#
            Location eloc = event.getEntity().getLocation();



            EntityArmorStand as = new EntityArmorStand(((CraftWorld)eloc.getWorld()).getHandle(), eloc.getX(), eloc.getY(), eloc.getZ());
            as.setInvisible(true);
            as.setNoGravity(true);
            as.setInvulnerable(true);
            as.setMarker(true);
            PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutNamedEntitySpawn(PacketDataS);
            PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(as.getId(), as.getDataWatcher(), true);


            String text;

            if (event.getDamager().isOnGround()) {
                text = Utils.translate("&c- &f" + Math.round(event.getDamage()));
            } else {
                text = Utils.translate("&c- &e" + Math.round(event.getDamage()));
            }
            as.setCustomName(IChatBaseComponent.a(text));
            as.setCustomNameVisible(true);
            ((CraftPlayer) player).getHandle().b.sendPacket(packet);
            ((CraftPlayer) player).getHandle().b.sendPacket(metadataPacket);
hasty prawn
torn vale
hasty prawn
#

Set it right after as.setMarker(true)

quaint mantle
#

oh

#

oh

#

ok

#

thanks

torn vale
earnest lark
#

hgow would i find what time of day it is

lost matrix
earnest lark
#

ingame

lost matrix
torn vale
lost matrix
torn vale
#
package de.leleedits.lobbysystem.listeners;

import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;

import java.util.HashMap;

public class DoubleJumpListener implements Listener {

    private HashMap<Player, Boolean> cooldown = new HashMap<>();

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        event.getPlayer().setAllowFlight(true);
        cooldown.put(event.getPlayer(), false);
    }

    @EventHandler
    public void onFly(PlayerToggleFlightEvent event) {
        Player player = event.getPlayer();
        if (event.getPlayer().getGameMode() == GameMode.SURVIVAL || event.getPlayer().getGameMode() == GameMode.ADVENTURE) {
            event.setCancelled(true);
            if (cooldown.get(event.getPlayer())) return;
            event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().setY(1));
            player.playSound(player.getLocation(), Sound.WITHER_SHOOT,1.0f, 1.0f);
            cooldown.put(event.getPlayer(), true);
        }
    }

    @EventHandler
    public void onMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        if (cooldown.containsKey(player)) {
            if (player.getLocation().add(0,-1,0).getBlock().getType() != Material.AIR) {
                cooldown.put(event.getPlayer(), false);
            }
        }
    }

    @EventHandler
    public void onGamemodeChange(PlayerGameModeChangeEvent event) {
        if (event.getNewGameMode() == GameMode.SURVIVAL || event.getNewGameMode() == GameMode.ADVENTURE) {
            event.getPlayer().setAllowFlight(true);
        }
    }
}

Thats my whole Listener Code

#

If I do double jump theres no cooldown. So I can do it every milisecond in the air. But I only should be able to do it if im on the ground

earnest lark
#

getworldtime is not a value

lost matrix
waxen plinth
#

It resets when the player is on the "ground"

#

But there are a number of reasons that might not work

#
  1. VOID_AIR
#
  1. CAVE_AIR
#
  1. Non-solid blocks
#

It's also worth noting that the player is probably at less than 1 block above the ground when they jump

lost matrix
#

if (player.getLocation().add(0,-1,0).getBlock().getType() != Material.AIR) {
->
if (!player.getLocation().add(0,-0.05,0).getBlock().getType().isAir()) {

waxen plinth
#

So you get 1 block below, and it still gets the ground block

#

You probably want player.getLocation().add(0, -0.1, 0).getBlock().isSolid()

waxen plinth
#

You're using fucking 1.8 aren't you

torn vale
#

yes

waxen plinth
#

🤦

torn vale
#

cannot resolve isSolid

waxen plinth
#

Does 1.8 not have that??

torn vale
#

Cannot resolve method 'isSolid' in 'Block'

lost matrix
#

Sry but then ill have to recede

torn vale
undone pebble
#

get the material instead

waxen plinth
#

Oh it's getType().isSolid()

#

It's a method of Material, not Block

torn vale
#

give me 1min, Ill try it now

waxen plinth
#

At some point I might have to follow suit with 7smile and stop offering support to people using 1.8

torn vale
waxen plinth
#

I'm literally looking at the spigot 1.8.8 docs right now

#

And isSolid() is a method of Material

undone pebble
#

you're doing something wrong lele

torn vale
undone pebble
#

show the code

torn vale
#
package de.leleedits.lobbysystem.listeners;

import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;

import java.util.HashMap;

public class DoubleJumpListener implements Listener {

    private HashMap<Player, Boolean> cooldown = new HashMap<>();

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        event.getPlayer().setAllowFlight(true);
        cooldown.put(event.getPlayer(), false);
    }

    @EventHandler
    public void onFly(PlayerToggleFlightEvent event) {
        Player player = event.getPlayer();
        if (event.getPlayer().getGameMode() == GameMode.SURVIVAL || event.getPlayer().getGameMode() == GameMode.ADVENTURE) {
            event.setCancelled(true);
            if (cooldown.get(event.getPlayer())) return;
            event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().setY(1));
            player.playSound(player.getLocation(), Sound.WITHER_SHOOT,1.0f, 1.0f);
            cooldown.put(event.getPlayer(), true);
        }
    }

    @EventHandler
    public void onMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        if (cooldown.containsKey(player)) {
            if (player.getLocation().add(0, -0.1, 0).getBlock().getType().isSolid()) {
                cooldown.put(event.getPlayer(), false);
            }
        }
    }

    @EventHandler
    public void onGamemodeChange(PlayerGameModeChangeEvent event) {
        if (event.getNewGameMode() == GameMode.SURVIVAL || event.getNewGameMode() == GameMode.ADVENTURE) {
            event.getPlayer().setAllowFlight(true);
        }
    }
}
crimson terrace
#

is there a way to completely remove bossbars or do you just have to remove all players from it?

undone pebble
torn vale
#

1.8.8-R0.1-SNAPSHOT Spigot-API

lost matrix
#

Or do you want to remove it all together?

#
bossBar.removeAll();
crimson terrace
#

My problem is that I keep creating bossbars and Im worried thats gonna take more and more memory

#

the documentation for removeAll() is just that it removes all players, not that it removes the bossbar

lost matrix
torn vale
crimson terrace
#

ok then I should be fine with removing it from the hashmap I set it to as a value and removeAll?

undone pebble
torn vale
undone pebble
#

I have no idea what you're talking about... I wasn't paying attention to whatever yall were talking back then

torn vale
earnest lark
#

I CANT FIND OUT HOW TO GET THE IN GAME TIME

#

caps*

#

can any1 help

lost matrix
earnest lark
#

i got it

lost matrix
earnest lark
#

with event.getentity().getType() how do i find a specific entity type

dry pike
#

What does spigit measure vectors length in, I should have a vector about 10 blocks long but its length is 274.739.....

lost matrix
lost matrix
eternal oxide
dry pike
#

targetLocation.subtract(playerLocation).toVector()

#

is how i get my vector

earnest lark
#

if want to be able to use it like sheep.getmetadata what would i use

#

like EntityType creeper = e.getEntity().getType() == EntityType.CREEPER;

#

but that does not work

lost matrix
#

e.getEntity().getType() == EntityType.CREEPER
This is a boolean expression. So it will return a boolean.

#

"Is the type equal to CREEPER" -> true/false

dry pike
#

Ahh my mistake, endLocation.toVector().subtract(startLocation.toVector())

gray crypt
#

Is there a way to, when one event happens, for a certain amount of time listen for another event and then do something?

earnest lark
#

how would i find the name of a item bieng held bc i dont thing .getName() for items is a thing

quiet ice
#

It depends really

#

If you want to user-provided name use item meta for that, otherwise Classloader hacks

eternal oxide
#

?pdc

quiet ice
#

stupid question here: how do I catch a stackoverflow?

uneven dock
#

How do I replace org.bukkit.material with org.bukkit.blockData in the 1.17.1 API? I'm trying to call some info about cauldrons. Like what they are above, if they are filled. I'm already using org.bukkit.block.data.Levelled to get the water level of the cauldron.

quaint mantle
dull whale
#
            item1.addEnchantment(Enchantment.DURABILITY, 1);
            meta1.addItemFlags(ItemFlag.HIDE_ENCHANTS);
``` I try to glow my gui items without the enchantment names visible but this gives me ERROR: null, why?
quiet ice
#

I got

                    try {
                        // recursive call
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }

this won't work because of obvious reasons (i. e. it generates a stack overflow when generating the stacktrace)

quaint mantle
#
public static void main(String args[]) {
    try {
        main(null);
    }
    catch (StackOverflowError e) {
        System.out.println("Heap size reached");
    }
}

???

#
Heap size reached
Compute time: 0.49 sec(s)
quiet ice
#

huh, apparently the JVM handles StackOverflowError differently to throwable

quaint mantle
#

it doesnt

#

stackoverflowerror extends throwable

quiet ice
#

Well, why else would I get

java.lang.NoClassDefFoundError: Could not initialize class java.lang.StackTraceElement$HashedModules
java.lang.NoClassDefFoundError: Could not initialize class java.lang.StackTraceElement$HashedModules
java.lang.NoClassDefFoundError: Could not initialize class java.lang.StackTraceElement$HashedModules
java.lang.NoClassDefFoundError: Could not initialize class java.lang.StackTraceElement$HashedModules
[...]

when doing catch (Throwable e but nothing if I do catch (StackOverflowError e

quaint mantle
#

because catching throwable has never and will never be reccommended

#
Throwable
   |     \
   |      Error -> Instant Death
   |
Exception
#

worst case scenario you're even catching ThreadDeath

quiet ice
#

Perhaps you should just never try to catch Stack overflows, that's perhaps a better option

quaint mantle
#

of course

#

or just fix your error

#

if your program ever throws StackOverflowError theres a major issue

regal dew
#

or you just hit the JVM’s limit, but at that point you might be interested in trying to change it to a non-recursive program lol

ancient plank
#

the website!

quaint mantle
#

Full of arrogant assholes!

unreal quartz
#

such as yourself!

quaint mantle
#

😢

halcyon mica
#

So I have a issue where when setting a custom ai goal for a entity, it stops one node before the actual target location

#

How'd I fix that?

spiral bramble
#

Bukkit#getOfflinePlayer(String) is deprecated, I'm trying to run a /punish <player> how would I go about getting their UUID?

quaint mantle
#

getOfflinePlayer is useless when it comes to names, since they can be changed after leaving the session

spiral bramble
quaint mantle
#

well you could use the deprecated method

spiral bramble
#

The only downfall being if they change their name between when they leave and I /punish?

unreal quartz
#

alternatively, get rid of the notion of usernames on your server and have everyone use their UUID as their name

spiral bramble
unreal quartz
#

but for real, you will have to use the deprecated method or keep track of UUIDs yourself (which does the same thing)

quaint mantle
#

^

spiral bramble
#

Alrighty then thank you!

#

Considering I'm using Litebans I believe that tracks all the usernames and uuids, I'll just hook is database

median anvil
#

is there a way to use ChatColor with hex color codes?

quaint mantle
#

google it

median anvil
#

i did , it said to use ChatColor.of() but it doesnt have the .of attribute, and valueOf also threw an error.

unreal quartz
#

import bungee chat

median anvil
#

ok

quasi stratus
#

I have a plugin that clears the player's PlayerInventory when opening a custom gui/inventory and I'm trying to make it store the previous inv to restore it once they close the gui.

#

I'm a bit new to programming spigot plugins so i'm not quite sure how to achieve this task.

#
    public PlayerInventory previous_inv;

    @EventHandler
    public void onOpen(InventoryOpenEvent event) {

        if (event.getInventory() != CoreInventories.server_selector) {
            return;
        }

        previous_inv = event.getPlayer().getInventory();

        if (previous_inv != null) event.getPlayer().sendMessage("Successfully saved inventory");

    }

    @EventHandler
    public void onClose(InventoryCloseEvent event) {

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

        if (!(event.getInventory() == CoreInventories.server_selector)) {
            return;
        }

        PlayerInventory inv = player.getInventory();
        inv.removeItem(CoreInventories.survival_item, CoreInventories.creative_item, CoreInventories.prototype_item);

        player.getInventory().setContents(previous_inv.getContents());
        player.updateInventory();

        event.getPlayer().sendMessage("End reached.");

    }```
#

This is what i have for my listeners but still to no avail

split bane
#

Hey is anyone fimiliar with spigot servers, macos, and mysql?
I really need help

quaint mantle
#
record PlayerInventoryContents(ItemStack[] armorContents, ItemStack[] extraContents, ItemStack[] storageContents[]) {}
Map<UUID, PlayerInventoryContents>
split bane
#

I am.

#

Is anyone.

quaint mantle
#

ask the question

split bane
#

Oh

#

Lmao

#

So basicily i am in minecraft hosting a server and for some reason mysql workbench can connect just fine to the mysql instance, but the minecraft plugins that need mysql cannot.

unreal quartz
split bane
#

Ok.

spiral bramble
#

^ removed #getPlayer() it wasn't needed.

unreal quartz
#

that is going to return null if they are offline

#

not to mention the fact you lock the main thread if SQLBridge isn't a cached value and it actually makes a connection

astral imp
#

What kind of file do I need to create to achieve something like

userData.getLevel().max();
userData.getLevel().current();

Like what would getLevel have to be for me to do this

quaint mantle
#

BlockBreakEvent

#

What error

#

you can't just send the link

#

you're compiling java 16 but the server's not 1.17+

#

set your java version in your pom/gradle file to 1.8

#

the java version you're building

#

send console log

#

if theres anything wrong there's gonna be an error

#

it shouldnt matter, but try Bukkit.getLogger().info("Works!");

#

yeah

#

just try it

#

🤷‍♂️

vague oracle
#

If a player triggers bungee's LoginEvent do they 100% call the PlayerDisconnectEvent if they cancel the login before ServerConnectEvent

quaint mantle
#

System.out is broken because bukkit/spigot only uses the logger

#

System.out.print breaks things because of this

#

im sure (100%!!!!!!) that if you use System.out.println it would work

#

but its still reccomended by bukkit to use getLogger().info

#

👍

paper viper
#

Bukkit also complains if you use sysout

quaint mantle
#

I think i've seen someone register their events differently before, and i register mine like this ```
getServer().getPluginManager().registerEvents(new PlayerTeleport(), this);

so, are there more efficient ways to register events?
#

no

worldly ingot
#

There's registerEvent() but it's older

#

registerEvents() is really the only means of registering events properly using the API

quaint mantle
#

how big are Plugin objects in memory

minor garnet
#

And to register commands 🤣

long helm
#

could someone help me figure out why this errors

quaint mantle
#
@Override
public void onDisable() {
    Logger.log("Disabling addons: " + Arrays.toString(ADDONS.toArray()));

    PluginManager pluginManager = this.getServer().getPluginManager();
    
    ADDONS.forEach(pluginManager::disablePlugin);
    ADDONS.clear();
    
    shopManager.clear();
    guiManager.clear();
}

i dont think I should be saving a set of plugins right

earnest lark
#

if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName() == "charge")

#

why does this not work

paper viper
#

you are using reference

#

use .equals

earnest lark
#

yea

#

would work better

paper viper
#

no its not "work better"

#

its the proper way

long helm
paper viper
#

it compares the contents

#

also please for god sake use PDC man

#

?pdc

fickle helm
#

when implementing tab completions on a given project (public List<String> parseTabCompletions...) and you don't want it to return anything, is there a better way than returning an empty string (return List.of("");)?
If I return null then auto suggests shows the user a player list and the only problem with returning an empty string is you get a very small character, shown here:

paper viper
#

Set.of()

#

🧠

fickle helm
#

omg that actually works. thanks!

#

I've been using the empty string method for nearly a year, never even occured to me to use emptyList

quaint mantle
#

i mean

paper viper
#

lol

#

i choose Set.of cause its shorter but Collections is fine

quaint mantle
#

i think Collections.emptyList is also more explicit with the name

paper viper
#

true

waxen plinth
#

Why do people need such things 🤔

#

new ArrayList<>()

#

Collections.emptyList()

#

hmmm

regal dew
#

the first one actually allocates a list on the heap (size 10 by default)

#

second one just returns a staticly constructed list from the collections class, thus no extra heap space

torn vale
#
    @EventHandler
    public void onPlayerBreak(BlockBreakEvent event) {
        Player player = event.getPlayer();
        if (buildPlayers.contains(player)) {
            event.setCancelled(false);
        } else if (!buildPlayers.contains(player)) {
            event.setCancelled(true);
        }
    }```
Why can't I break blocks? Im in the buildPlayers ArrayList but I cant break blocks
dusk flicker
#

Doubt this will solve anything but to make it a bit cleaner you can do just event.setCancelled(!buildPlayers.contains(player));

#

You also don't need the second if statement, you can just use a normal else

torn vale
#

At the moment it look like this:

    @EventHandler
    public void onPlayerBreak(BlockBreakEvent event) {
        Player player = event.getPlayer();
        event.setCancelled(!buildPlayers.contains(player));
    }```
regal dew
#
  1. use UUID’s instead of player instances
  2. ArrayList is a bad datastructure for this, use a HashSet
  3. Don’t set the cancelled state to false (unless this is explicitly what you want)
torn vale
#

okay thank you

#

Sorry for the stupid question but was is my UUID Value?

dusk flicker
#

You want to use a HashSet, not a map

torn vale
#

oh

#
    public void onPlayerBreak(BlockBreakEvent event) {
        Player player = event.getPlayer();
        event.setCancelled(!buildPlayers.contains(player.getUniqueId()));
    }```
Should it work now?
regal dew
#

I’d just change it to:

if (!buildPlayers.contains(player.getUniqueId())) {
    event.setCancelled(true);
}
#

and yeah should work fine, now just change where you add / remove entries from this hashset

dusk flicker
#

If it doesn't work, you prob didn't register the event lol

torn vale
#

did it. Give me 1min, Ill test ist

torn vale
#

Thats my whole code. If I use /build I still cant break blocks. I registred the event and the command too :c

quaint mantle
#

That is messy

torn vale
#

actually thats how I learned to programm in java

#

But can someone spot the problem?

long helm
#
if (args[0].equals("blue")) {}

why does this give me error
Index 0 out of bounds for length 0

quaint mantle
#

it should be

if (args.length == 0) {...}

else if (args.length == 1) {...}

else {
    player.sendMessage(...);
}
regal dew
#

Can you show how you register the command / event?

torn vale
# regal dew Can you show how you register the command / event?
package de.leleedits.lobbysystem;

import de.leleedits.lobbysystem.commands.AuraCommand;
import de.leleedits.lobbysystem.commands.BuildCommand;
import de.leleedits.lobbysystem.commands.SetSpawnCommand;
import de.leleedits.lobbysystem.listeners.*;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;

public class LobbySystem extends JavaPlugin {

    public static LobbySystem plugin;

    public HashMap<String, String> nick = new HashMap<>();

    public void onEnable() {
        this.saveDefaultConfig();
        plugin = this;

        getCommand("setspawn").setExecutor(new SetSpawnCommand());
        getCommand("aura").setExecutor(new AuraCommand());
        getCommand("build").setExecutor(new BuildCommand());

        PluginManager pluginManager = Bukkit.getPluginManager();
        //pluginManager.registerEvents(new BreakListener(), this);
        pluginManager.registerEvents(new DamageListener(), this);
        pluginManager.registerEvents(new HungerListener(), this);
        pluginManager.registerEvents(new ItemDropListener(), this);
        pluginManager.registerEvents(new JoinListener(), this);
        pluginManager.registerEvents(new AuraCommand(), this);
        pluginManager.registerEvents(new WeatherListener(), this);
        pluginManager.registerEvents(new ChatFilterListener(), this);
        pluginManager.registerEvents(new DoubleJumpListener(), this);
        pluginManager.registerEvents(new BuildCommand(), this);
    }
    public static LobbySystem getPlugin() {
        return plugin;
    }
}
long helm
#

so if theres no args how do I handle that withou erroring

quaint mantle
regal dew
long helm
quaint mantle
#
[blue, green] -> length == 2
   \     \
  arg0  arg1

[] -> length == 0
quaint mantle
torn vale
quaint mantle
#
if (args.length == 0) {
    return false;
}
long helm
quaint mantle
#

i dont know what to say

#
if there are no arguments then say "Hey, there's no arguments" and return

Anyways, continue the code
#

thats this

if (args.length == 0) {
    return false;
}
regal dew
long helm
quaint mantle
#

else if

long helm
#

👍

torn vale
quaint mantle
long helm
#

yeah ik

quaint mantle
#

what

long helm
#

I know how to use else if statements in java

#

is what I meant

quaint mantle
#

then why are you asking about if else statements

torn vale
long helm
#

I was asking about the error

quaint mantle
#

Ok

torn vale
#

Shouldn't this work?

I registered it like this:
BuildCommand buildCmd = new BuildCommand();
getCommand("build").setExecutor(new BuildCommand());
pluginManager.registerEvents(new BuildCommand(), this);

regal dew
#

ay no, now ur creating 3x instances

quaint mantle
#

you might as well just use Set#remove, there's no reason to check if it contains then remove it

#

i think thats doing two queries, either way redundant

regal dew
#

hard to type on mobile lol

torn vale
long helm
#
if (args.length == 0) {}
else if (args[0] == "blue") {}
else if (args[0] == "red") {}

compilation error??

quaint mantle
#

why are you doing string comparisons with '=='

torn vale
#
        getCommand("setspawn").setExecutor(new SetSpawnCommand());
        getCommand("aura").setExecutor(new AuraCommand());
        getCommand("build").setExecutor(new BuildCommand());

        PluginManager pluginManager = Bukkit.getPluginManager();
        pluginManager.registerEvents(new DamageListener(), this);
        pluginManager.registerEvents(new HungerListener(), this);
        pluginManager.registerEvents(new ItemDropListener(), this);
        pluginManager.registerEvents(new JoinListener(), this);
        pluginManager.registerEvents(new AuraCommand(), this);
        pluginManager.registerEvents(new WeatherListener(), this);
        pluginManager.registerEvents(new ChatFilterListener(), this);
        pluginManager.registerEvents(new DoubleJumpListener(), this);
        pluginManager.registerEvents(new BuildCommand(), this);

        BuildCommand buildCmd = new BuildCommand();
        getCommand("build").setExecutor(buildCmd);
        pluginManager.registerEvents(buildCmd, this);```
Is it okay like this?
quaint mantle
#

no

regal dew
#

Well, now ur registering them twice

#

Remove the first occurances

quaint mantle
#
Instance instance = new Instance();

function(instance);
otherFunction(instance);
long helm
quaint mantle
#

what errors

long helm
#

Error running 'Plugin [compile]':

torn vale
# regal dew Well, now ur registering them twice
getCommand("setspawn").setExecutor(new SetSpawnCommand());
        getCommand("aura").setExecutor(new AuraCommand());

        PluginManager pluginManager = Bukkit.getPluginManager();
        pluginManager.registerEvents(new DamageListener(), this);
        pluginManager.registerEvents(new HungerListener(), this);
        pluginManager.registerEvents(new ItemDropListener(), this);
        pluginManager.registerEvents(new JoinListener(), this);
        pluginManager.registerEvents(new AuraCommand(), this);
        pluginManager.registerEvents(new WeatherListener(), this);
        pluginManager.registerEvents(new ChatFilterListener(), this);
        pluginManager.registerEvents(new DoubleJumpListener(), this);

        BuildCommand buildCmd = new BuildCommand();
        getCommand("build").setExecutor(buildCmd);
        pluginManager.registerEvents(buildCmd, this);

Im confused lol

quaint mantle
#

What error!!!!

#

send the stack trace

torn vale
#

Now it works. Thank you very much!

regal dew
#

😄

earnest lark
#

dumb question but how do you switch armor items on a entity

quaint mantle
#

setHelmet, setChestplate etc.

earnest lark
#

bruhhh

#

i threid this

quaint mantle
#

okay well what went wrong?

earnest lark
#

i cant use .getarmorcontents

#

or .gethelet and the other ones for some reason

long helm
#

it stopped erroring, thx

quaint mantle
#

send errors

earnest lark
#

'@EventHandler' not applicable to constructor

quaint mantle
#

It tells you

#

thats just a java error

#

why are you annotating your constructor?

paper viper
#

lol

earnest lark
#

i got it

#
    public void Spawnzom(PlayerInteractEntityEvent e) {
        Player p = e.getPlayer();

        if (p.getInventory().getItemInMainHand().getType().equals(Material.RED_DYE)) {
            if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals("Enhancer")) {

                Entity entity = e.getRightClicked();
                if (entity instanceof org.bukkit.entity.Zombie) {
                    Zombie zombie = (Zombie) entity;
                }
            }
        }
    }```
#

why can i not do zombie.getboots()?

quaint mantle
#

getEquipment().getBoots()

halcyon mica
#

Any idea about my custom goal issue?

#

When giving a entity a custom goal that basicially translates to a „go to that location“ thing, it always stops one block before the actual goal

lavish hemlock
#

off-by-one error?

halcyon mica
#

The entity pathfinds to the given location correctly

#

But always stops one block short of the actual block pos given

#

And I am sure it's not because it‘s like on the edge of the target block, because I made sure to only use block positions

#

And even made sure the raw xyz is in the middle of a block

young knoll
#

I mean integer block coords will be the bottom corner afaik

#

But if you have a decimal number of some sort I’m not sure

#

How are you checking if it’s reached the location

hasty prawn
#

Couldn't you just tell it to stop one block closer than you actually want it to

#

Then it would stop one block out, which is where you want!

nova grove
#

When i'm using player.sendMessage() then do I need to put some sort of String in with it?
It gets annoying when I'm trying to do something like this:

// Get all of the players online
for (Player currentPlayer : Bukkit.getServer().getOnlinePlayers())
{
    player.sendMessage(currentPlayer + "");
}
quaint mantle
#

C programmer 🤮

worldly ingot
#

Well that's not going to give you much of a nice output

#

You probably want to print currentPlayer.getName(), but yes it has to be a string

nova grove
worldly ingot
#

Yes. Unlike System.out.println() which accepts an Object, sendMessage() only accepts a String

paper viper
#

cant you just do Bukkit.getOnlinePlayers()

quaint mantle
#

yeah

#

Ykw

#

why does Bukkit steal all of Server's methods?

paper viper
#

Bukkit.getOnlinePlayers().forEach(currentPlayer -> player.sendMessage(currentPlayer.getName())

#

i think you can simplify the logic inside the forEach to a method reference

#

but im too lazy to figure it out rn

paper viper
quaint mantle
#

you cant

paper viper
#

oh nvm

quaint mantle
paper viper
#

i mean it is getOnlinePlayers

#

lol

stone sinew
quaint mantle
#

oh yeah i thought we were talking about Ops question

stone sinew
young knoll
#

Technically that includes console too

#

So it can get a bit spammy if you are doing it often

quaint mantle
#

Petition to delete Bukkit utility class

#

the entire class is just useless server wrapper methods

stone sinew
quaint mantle
#

its one more method

#

remove all of the methods, keep bukkit as a singleton holding more utility methods than just wrapping them for no reason

worldly ingot
#

You can't delete the Bukkit class lol. It's literally what bridges the API to implementation

nova grove
#

When I run my command then I get a head, but it doesn't have the meta. Anyone know what's wrong?

// Get head
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta playerHeadMeta = (SkullMeta) playerHead.getItemMeta();
playerHeadMeta.setOwningPlayer(currentPlayer);
playerHeadMeta.setDisplayName(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + currentPlayer.getName());

// Give the head
player.getInventory().addItem(playerHead);
worldly ingot
#

It's mirroring the methods in Server for convenience

quaint mantle
#

But its one more method

worldly ingot
#

pepecringe so?

quaint mantle
#

Woopty doo

worldly ingot
#
Bukkit.getServer().getOnlinePlayers();
Bukkit.getServer().isOnline();
Bukkit.getServer().addRecipe(recipe);

Server server = Bukkit.getServer();
server.getOnlinePlayers();
server.isOnline();
server.addRecipe(recipe);

Bukkit.getOnlinePlayers();
Bukkit.isOnline();
Bukkit.addRecipe(recipe);```
#

of the three, which would you prefer, really?

#

A redundant call to getServer() every time, an additional variable for no reason, or convenience?

quaint mantle
#

i'd honestly prefer getServer(). more tha nanything

#

I would never be upset if the api changes to #1

paper viper
#

i think conclure at one point was passing two variables in dependency injection. one for his plugin and another for the Server

quaint mantle
#

You save 8 characters

#

who tf cares about saving characters in java

#

its a useless class besides holding the server singleton

quaint mantle
paper viper
#

i dont like how Bukkit stores the server as a singleton

quaint mantle
#
fun main() {

}
public class Main {
    public static void main(String[] args) {

    }
}
stone sinew
quaint mantle
#

i wouldnt like having to do Plugin#getServer

#

But

#

it would all be linked 🤔

#

not a bad idea actually

paper viper
#

or well i should say

#

its one way to solve it i guess

nova grove
#

Quick question. Should I have one return true; at the bottom of my command, or should I have a few of them whenever my command ends?

quaint mantle
#

what

#
missing args
       \
  return false

case one
       \
   return true

case two
       \
    return true

return false // Invalid args
nova grove
#

Thanks.

#

I was just double checking.

nova grove
#

I have another thing that I want to check. When i've been adding colors then I have done ChatColor.RED, but I have seen people do §c. What way is better or does it not matter?

stone sinew
gray zodiac
young knoll
#

Your exported jar doesn’t contain the plugin.yml

#

Where is it located

quaint mantle
#

how would i get an item object from the getDrops method?

young knoll
#

You can’t unless you manually drop them

#

Use BlockDropItemEvent

quaint mantle
#

oh, i'm trying to make a mob drop an item thats in a specific location, so would i not be able to do so this way?

young knoll
#

What do you mean drop an item in a specific location

quaint mantle
#

so if in location x y z, there is a block, and that is what a specific mob will drop when killed

young knoll
#

You can easily spawn your own items in the death event

quaint mantle
#

yes, but i want it to be from a block that can change in a specific spot

young knoll
#

So you want to drop the blocks items when a mob dies

quaint mantle
#

pretty much, if it's possible

young knoll
#

Just iterate over the drops of the block and spawn them using world.dropItem

weak mauve
#

Anyone how to make the armorstand (or any entity) face the player, yaw and pitch might do the trick but im can't find a math for it

keen rock
#
    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {

        ItemStack clickedItem = new ItemStack(Objects.requireNonNull(event.getCurrentItem()));
        ItemStack cursorItem = new ItemStack(Objects.requireNonNull(event.getCursor()));
        if (event.getCursor().getType() == Material.ENCHANTED_BOOK) {
            if (event.getCurrentItem().getType() != Material.AIR) {
                EnchantmentStorageMeta enchMeta = (EnchantmentStorageMeta) cursorItem.getItemMeta();

                assert enchMeta != null;
                if (enchMeta.hasStoredEnchants()) {
                    Bukkit.broadcastMessage("Has enchs");
                    Map<Enchantment, Integer> enchants = enchMeta.getStoredEnchants();
                    clickedItem.addUnsafeEnchantments(enchants);
                    event.getWhoClicked().getInventory().addItem(cursorItem);
                    event.getCursor().setType(Material.AIR);
                    Bukkit.getScheduler().runTaskLater(mainClass, () -> {
                        event.getWhoClicked().getInventory().setItem(event.getSlot(), clickedItem);
                    }, 5L);
                } else {
                    Bukkit.broadcastMessage("No enchs");
                }
            }
        }
    }
```So, I have this code which essentially enchants an item that you click on if your cursor is holding an enchanted book, everything works fine except I can't figure out how to remove the item I click, it always goes into my cursor no matter what and I think it's due to the if statements, but idk
#

I'm very rusty after not having developed in ages, so the solution is prob very easy

tacit drift
#

@keen rock cancel the event

#

event.setCancelled(true)

keen rock
#

I've tried, but doesn't seem to work

#

Wait

#

It appears its just a visual glitch :/ (maybe)

#

So - if I cancel outside of the if statements it works fine, but seems to be visually glitched, cancelling inside the if statements, however, does not work

#

Which obviously I cannot just cancel every InventoryClickEvent, so that's not a valid solution lol

quaint mantle
keen rock
#

I only did it so intellij would shut up about it until I add proper checks

quaint mantle
#

What

keen rock
quaint mantle
#

yes

keen rock
#

Intellij was bugging me to add that- so I did in the meantime until I can add proper checks

rigid cradle
#

Hello everyone, my name is Minh from Vietnam, can you give me a few youtube channels to guide me to write basic minecraft plugins?

rigid cradle
#

I just learned about it too

chrome beacon
#

Yes or no?

rigid cradle
#

maybe no

chrome beacon
#

?learnjava

undone axleBOT
rigid cradle
#

ok

#

tks

near night
#

how do i access the player profile this didn’t work GameProfile playerProfile = ((CraftPlayer) player).getHandle().getProfile(); Field ff = playerProfile.getClass().getDeclaredField("name");

keen rock
#

Json may be a good option

maiden thicket
#

you have it

#

right there

young knoll
#

SQLite is also just saved as a flat file

maiden thicket
#
GameProfile playerProfile = ((CraftPlayer) player).getHandle().getProfile();```
near night
#

im geting error

maiden thicket
#

do you have nms spigot

#

aka buildtools compiled

#

or are you using spigot-api

#

spigot-api dependency for maven doesnt have nms

frosty tinsel
#

Learn it lol

near night
#

oh how do i get build tools

maiden thicket
#

what version of spigot

chrome beacon
undone axleBOT
maiden thicket
#

java -jar BuildTools.jar --rev <version>

near night
#

ok tysm

#

do i need to remove the spigot api from Maven then?

maiden thicket
#

no

#

just rename spigot-api to spigot

#

after buildtools is done

near night
#

ok pog

#

thx

young knoll
#

You can save it however you want honestly

maiden thicket
#

u dont need to really know a lot of sql for simple data storing

#

all you need to know is:

#

DELETE
INSERT INTO
CREATE TABLE

#

and

#

UPDATE

unkempt peak
#

How do i get a more specific material from a PlayerDropItemEvent? when i do event.getItemDrop().getItemStack().getType() it gives me something like WOOL or LOG instead of green wool or birch log

keen rock
#

I believe so, yml is best for configuration as its not very fast, but if you're only storing a few things and don't have a giant playerbase, should be fine with whatever

maiden thicket
#

why

unkempt peak
maiden thicket
#

update it when a player leaves

#

when a player joins, if they have data, load into an object

#

then save it back to sqlite on playerquitevent

maiden thicket
young knoll
#

No way you are on 1.17

maiden thicket
maiden thicket
#

if you aren't getting specific types

unkempt peak
young knoll
#

Or you haven’t put an API version in your plugin.yml

unkempt peak
#

oh

#

but how would i make it compatible with older versions if it needs an api version?

maiden thicket
#

objects

#

learn OOP

#

bingo

keen rock
maiden thicket
#

have you tried that

#

event.getClickedItem().setType(Material.AIR)

young knoll
#

Generally you want to set things to null

#

But setCursor is deprecated iirc

near night
maiden thicket
keen rock
#

Yeah I've tried that, tried cancelling event too, its cause of the if statements but can't thing of another good way to check

maiden thicket
#

update ur pom.xml

#

replace artifact id of spigot-api to spigot

near night
#

ok thx

keen rock
#

Yeah, that's what I used. ClickedItem isn't a thing

young knoll
#

You can do event.getWhoClicked.setItemOnCursor now

maiden thicket
keen rock
#

Word? I don't think that'll work either thought because of the if statements but I'll give it a shot

#

Latest, 1.17.1

quaint mantle
#

how do i make hologram text different per player

chrome beacon
#

Use Packets

quaint mantle
keen rock
#

So here's some debug, I'll post code so you can see what the debug is but basically in the if, it is not seeing the cursor as sword because I haven't ran the event again, and when I try clearing clicked item that doesn't seem to work either

quaint mantle
#

I'm new to spigot

chrome beacon
#

I hope you at least know Java

quaint mantle
river spear
#

How can I set multiple lines in MapMarkers or Wapoints in Itemmaps?

quaint mantle
#

I'm new to spigot tho

#

and java

keen rock
#

InventoryClickEvent problem

keen rock
near night
#

geting errors now

maiden thicket
near night
maiden thicket
#

top right click maven

#

and click the reload button

near night
#

ok i'll try

#

ok fixed tysm

echo basalt
#

Display name and similar things are sent using the Entity Metadata packet

#

You can hook into it using ProtocolLib and somewhat read the data

#

Or just sending a new packet on top

gray zodiac
#

anyone knows how to change player gamemode after they died?

package me.lowjunnhoi.ljhminecraftplugin;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import java.util.concurrent.TimeUnit;

public class Death implements Listener {

    @EventHandler
    public void onDeath(PlayerDeathEvent event) throws InterruptedException {
        Player p = event.getEntity();
        p.sendMessage("You died, changing game mode to survival...");
        event.getEntity().setGameMode(GameMode.SURVIVAL);
        TimeUnit.SECONDS.sleep(10);
        event.getEntity().setGameMode(GameMode.SURVIVAL);
        p.sendMessage("Your game mode is now set to survival!");
        event.getEntity().setGameMode(GameMode.SURVIVAL);

    }
}
keen rock
gray zodiac
#

oh

sullen dome
#

oops, answered wrong message

echo basalt
#

also don't use sleep

sullen dome
#

and if it still doesn't work, do it a tick after the event calls.

@EventHandler
public void onRespawn(PlayerRespawnEvent e){
  Player p = e.getPlayer();
  Bukkit.getScheduler().runTaskLater(<your plugin-class>, () -> {
    p.setGameMode(GameMode.SURVIVAL);
  }, 1L);
}
#

afaik

echo basalt
#

The bukkit scheduler exist

sullen dome
#

(wrote from head)

keen rock
#

^^^ yes much better code lol

sullen dome
#

that's the cleanest method afaik

keen rock
sullen dome
#

can't modify it without braces tho, doo dumb for that without an IDE

solid cargo
sullen dome
#

cool cool cool

echo basalt
sullen dome
#

yea ik

#

but i can't write lambdas without ide, bc idk how the syntax looks out of my head

echo basalt
#

eh

#

It's quite simple

sullen dome
#

guess smt like

Bukkit.getScheduler().runTaskLater(plugin, () -> yourtask(); 50L);
echo basalt
#

If it takes no args, or the args are the same as the lambda params you can do the
:: thing

#

ye

sullen dome
#

oh true

echo basalt
#

but use ,

#

not ;

sullen dome
#

ah i see

#

yeah without ide, no autocomplete and stuff

#

not used to that

echo basalt
#
Bukkit
  .getScheduler()
  .runTaskLater(plugin, () -> player.setGameMode(GameMode.SURVIVAL), 20L);
#

I don't like the bukkit scheduler that much

#

looks a bit ugly

solid cargo
#

sender.sendMessage("Step bro im stuck!");
Will this work? Asking cause im not home and gitHubing from a phone

echo basalt
#

will work yeah

sullen dome
#

i'm confused

solid cargo
#

Nah its for a /stuck command

sullen dome
#

i'm still confused

echo basalt
#

he basically wants

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  sender.sendMessage("Step bro I'm stuck!");
  return true;
}
#

For a /stuck command

sullen dome
#

dud

#

my confusion is...

echo basalt
#

Or are you confused about lambdas?

sullen dome
#

why would you do such a command

echo basalt
#

idk he's stupid

sullen dome
#

i'm confused about why he's doing that

#

thats it

echo basalt
#

no need to question human stupidity

sullen dome
#

true

solid cargo
#

` `` java
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;

public class Stuck implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings){
World world = ( (Player) sender ).getWorld();
if (!( sender instanceof Player )) {
System.out.println("You aren't a player!");
} else
( (Player) sender ).teleport(world.getSpawnLocation());
sender.sendMessage("Step bro im stuck!");
return true;
}

} ```
© 2021 GitHub, Inc.

sullen dome
#

oh my

solid cargo
#

Here all code

sullen dome
#

please

echo basalt
#

code blocks

sullen dome
ivory sleet
#

Lmao

solid cargo
#

Meh

ivory sleet
#

Nice code pillow man

sullen dome
#

or

#

?paste

undone axleBOT
solid cargo
#

There

#

Fixed it

ivory sleet
#

😬

sullen dome
#

what the

solid cargo
#

Not java but still better than plain

echo basalt
#

ew

sullen dome
#

am i the dumb one here?

#

or ...

sullen dome
keen rock
#

He really added `` on every line

solid cargo
#

Omfg whats the difference

sullen dome
#

yourcode

keen rock
#

You did way more work and it looks better the other way xD

ivory sleet
#

```java
Literally code here

sullen dome
#
this
is
the
difference```

`between`
`these`
`two`
solid cargo
#

But..

#

Oh

sullen dome
#

if you dont want, the java isn't too important

#

it's just for color highlighting

keen rock
#

^ can be replaced with any language or just left blank

ivory sleet
#

html (:

solid cargo
#

Bro calm down plz idk how to use discord

ivory sleet
#

I can tell

keen rock
#

U gonna learn today

#

Boi

solid cargo
#

Uh oh

echo basalt
#

this is as complex as making a readme file

ivory sleet
solid cargo
#

But

keen rock
#

Its basic markup lmao

sullen dome
#

i explained it

multiple times

echo basalt
#

but

solid cargo
#

Im on a heckin phone

#

Its hard here

sullen dome
#

oh

echo basalt
#

he doesn't know how to make a readme file

keen rock
#

Just copy this

#

```

sullen dome
#

youre copying code on phone?

keen rock
#

Paste at top and bottom off ur code

solid cargo
#

Yeah whats wrong

ivory sleet
#

import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;

public class Stuck implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String s, String[] strings){
        World world = ( (Player) sender ).getWorld();
        if (!( sender instanceof Player )) {
            System.out.println("You aren't a player!");
        } else
            ( (Player) sender ).teleport(world.getSpawnLocation());
sender.sendMessage("Step bro im stuck!");
    return true;
    }

}
© 2021 GitHub, Inc. ```
#

You wc

keen rock
#

Ayeee he got it

#

See how much better that looks?

solid cargo
#

Si si

#
System.out.println("i hate writing on phone")
sullen dome
#

he made it

keen rock
#

Yeah dev on phone sucks

sullen dome
#

i'm using iphone
never le me write anything on phone

#

or make sure to wait 5 hours for messages

solid cargo
#

When u dont use Math.round()

sullen dome
#

yea, i remember that

#

in my tablist

#

ahhhhh

ivory sleet
#

Or String::format (:

sullen dome
#

tbh, i never use the :: anywhere

#

idk why

#

not used to it

ivory sleet
#

Hmm guess String#format also looks fine

sullen dome
#

imagine you download a 200gb game

#

your start it

#

and ingame, it says
game needs to restart for an update

#

WTF

ivory sleet
#

Hehe

#

Myes relatable

sullen dome
#

mw is hillarious

solid cargo
#

Guess what kind of bot command i will run

#

Its also something i need

#

?learnjava

undone axleBOT
sullen dome
#

/give @RealRivex some food

ivory sleet
#

/op Conclure

sullen dome
#

uhh, isn't discord allowing only / commands since a few weeks?

solid cargo
#

Nrly

ivory sleet
#

I don’t think you can disallow normal cmds

#

Like the ones with a mere prefix

solid cargo
#

The bot probably using some kind of text write event

keen rock
gray zodiac
#

still didn't work after trying many ways

package me.lowjunnhoi.ljhminecraftplugin;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;

import java.util.concurrent.TimeUnit;


public class Death implements Listener {

    @EventHandler
    public void onRespawn(PlayerRespawnEvent e) {
        Player p = e.getPlayer();
        Bukkit.getScheduler().runTaskLater((Plugin) this, () -> p.setGameMode(GameMode.SURVIVAL), 5L);
    }

}
#

the game keeps changing to spectator

keen rock
#

Did u setup a broadcast or something to see if its running that code?

gray zodiac
#

?

wary harness
#

any one can tell me how would I unregister Enchant

#

so remove it from map

#

in Enchants

#

class

#

map is static and private

#

and there is only method to register enchants

keen rock
# gray zodiac ?

Add a broadcast or something to make sure it's actually running that code

wary harness
#

1.8

#

dosn't have that method

hasty jackal
#

then you're on your own with that old version

wary harness
#

it is not the thing

#

which I was asking

#

that is to remove enchant of itemstack

#

I need to unregister enchant

#

from Enchantment class

keen rock
#

I don't believe that's possible, you can only prevent them from getting the enchantment on their item by listening to an enchant event and anvil event

solid cargo
gray zodiac
# keen rock Add a broadcast or something to make sure it's actually running that code

it only sends the 1st message test1 but not the second.

package me.lowjunnhoi.ljhminecraftplugin;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;

import java.util.concurrent.TimeUnit;


public class Death implements Listener {

    @EventHandler
    public void onRespawn(PlayerRespawnEvent e) {
        Player p = e.getPlayer();
        p.sendMessage("test1");
        Bukkit.getScheduler().runTaskLater((Plugin) this, () -> p.setGameMode(GameMode.SURVIVAL), 5L);
        p.sendMessage("test2");

    }

}
echo basalt
#

that's because you're casting some class to plugin

keen rock
#

You need to create an instance of your main class and use that instead

shadow night
#

how to create commands like /command subcommand?

ivory sleet
nova grove
#

I'm making a plugin where it will show some info about a player in a GUI. When I show the world then I want to use this head:
https://minecraft-heads.com/custom-heads/decoration/2984-globe
How can I get the actual name of the player who owns the head? From looking at the give command then it looks like it has an array or list of different names but when I put them into a skin stealler then nothing happens.
SkullOwner:{Id:[I;-1658131564,-640792186,-1301039191,1645992239]}

shadow night
#

If i'm right not every head has a skin

echo basalt
#

I'm not sure why there are 4 numbers, usually it only requires 2

#

Most significant bits and least significant bits

quaint mantle
#

does anyone know how Caused by: java.lang.IllegalArgumentException: location.world is caused

#

im trying to deploy on a cloud server

#

my guess is that the server's jar is a different version to my plugin's development jar

#

would like a second opinion so i can fix this faster

#
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer.teleport(CraftPlayer.java:672) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity.teleport(CraftEntity.java:493) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at me.marco.Minigames.Objects.Minigame.teleportPlayer(Minigame.java:395) ~[?:?]```
#

line 395: player.teleport(location);

eternal oxide
#

Most likely your world is not loaded

quaint mantle
#

the weird thing is im on it

eternal oxide
#

so your world arg is null

quaint mantle
#

yeah

#

i was in the world but it didnt wnat to work

#

its one of those weird like hosting FTP clients that is being a pain

eternal oxide
#

if your world IS loaded then your world reference is bad/stale

#

the world was unloaded at some point or replaced

quaint mantle
quaint mantle
eternal oxide
#

FTP client? That has nothing to do with Spigot/Minecraft, nor loading of worlds

quaint mantle
#

make it a pain to upload files/have preset options

#

im helping someone set something up and i dont have access to the ftp

eternal oxide
#

Still nothing to do with a world being loaded or not

quaint mantle
#

yeah

quaint mantle
#

it works locally but on this server its not

#

im guessing that the versions just dont like eachother

#

@eternal oxide is there a way to reference "world"

#

core.getServer().getWorld("world");

eternal oxide
#

you get a world reference from Bukkit

quaint mantle
#

whats the difference

eternal oxide
#

none

quaint mantle
#

isnt getServer().getWorld() the same

eternal oxide
#

you have to get it when the world is loaded though

#

if you are unloading/reloading worlds the reference will go stale

quaint mantle
#

im not even loadin git

#

like the server starts with the one world

eternal oxide
#

is yoru world actually called "world"?

quaint mantle
#

yeah

#

is there a way to check in spigot

#

like a command

eternal oxide
#

to check what?

quaint mantle
#

the world name

#

/execute in minecraft:overworld run tp @s -88.11 60.00 -82.79 -127.45 22.33

eternal oxide
#

its in your server.properties

quaint mantle
#

i did f3+c

#

@eternal oxide whats it called in server.properties

eternal oxide
#

level-name

quaint mantle
#

ah

#
level-name=world
motd=Powered by AMP```
#

its not on my local server but its in the external servers properties

#

is there another way to get the overworld

eternal oxide
#

no

quaint mantle
#

so odd. im guessing its something to do with the world name being changed by the host

#

could an older/newer jar to the one i compiled with cause an issue like that?

quaint mantle
#

@eternal oxide could an api-version mismatch in the plugin.yml cause that?

eternal oxide
#

thats not going to affect something as simple as getting a world

#

?paste show the code that is throwing the error

undone axleBOT
quaint mantle
eternal oxide
#

when are you setting this.world?

quaint mantle
#

in the constructor of my Manager class

eternal oxide
#

and when do you create your manager class?

quaint mantle
#
    public MinigamesManager(Core core){
        this.core = core;
        this.world = getInstance().getServer().getWorld("world");
    }
#

at onEnable()

eternal oxide
#

as a test change this.world = to this.world = Bukkit.getWorlds().get(0);

quaint mantle
#

ok ill do it next cycle

#

i am not being given access to the box so this is a long process...

#

(thank u for helping 🙂 )

#

@eternal oxide ive encountered a new issue

#
at me.marco.Minigames.Minigames.BedWars.BedWars.onDamage(BedWars.java:709) ~[?:?]```
#
    public void onDamage(EntityDamageEvent event){
        if (!isGameActive()) return;
        if(!(event.getEntity() instanceof Player));
        Player player = (Player) event.getEntity();
        if(!playerInGame(player)) return;
}
#

709= Player player = (Player) event.getEntity();

eternal oxide
#

your logic is back to front

halcyon mica
eternal oxide
#

if(!(event.getEntity() instanceof Player));

halcyon mica
#

But it always stops one block short of the actual target

eternal oxide
#

also your if does nothing as you terminate the line with ;

quaint mantle
#

it does stuff below but i cut it out

#

its right

eternal oxide
#

its wrong

quaint mantle
#

it shoudl be; if its not a player just return

#

OH

#

if(!(event.getEntity() instanceof Player)) return;

#

oops

eternal oxide
#

yep

quaint mantle
#

sorry

halcyon mica
#

As you can see, the entity always stops exactly one block short of the target

tired pendant
#

I am confused by the mojang mappings. Has somebody used them yet?

halcyon mica
#

I am, as we speak

ember skiff
#

Hello, is it okay to use worlds as keys in hashmaps?

#

Or rather store their names as keys

spiral bramble
#

Anyone aware why this is returning null?

eternal oxide
#

because they are not online

spiral bramble
eternal oxide
#

no

spiral bramble
#

Okay.

#

I'll try changing some things

late stone
#

How do I give a skull a custom texture?

tall dragon
#

depends on your server version really

paper viper
#

Does anyone know why I am getting this error while trying to run BuildTools on my jenkins machine? https://paste.helpch.at/ikuqilaboz.sql

I am running the command java -jar BuildTools.jar --rev 1.16.5 and I am using Java 16 to compile.

eternal oxide
#

Not enough information to tell

paper viper
#

Here i can provide the full log:

tall dragon
late stone
tall dragon
#

well i mean minecraft version

#

1.17 im guessing then

late stone
#

yes 1.17.1

eternal oxide
tired pendant
# halcyon mica I am, as we speak

Can you explain to me what you might use them for? I thought they were supposed to help with not relying on versioned packages but it seems like CraftBukkit is still versioned and you can't use most of the classes without a CraftBukkit conversion it seems (at least those that I would use them for)

#

Why use mojang mappings at all, other than not having to guess what an obfuscated method does...

eternal night
#

because the rest of the ecosystem does

paper viper
#

im not sure how that could happen

eternal oxide
#

I start fresh in a clean directory

paper viper
#

kk

#

can you specify the working directory?

#

cause my jar is different lcoation from jenkins java execution dir

eternal oxide
#

it will build in whatever directory yoru buildtools jar is in

paper viper
#

i dont think thats true actually. I am running the command within Jenkins actually

#

and it executes within my project directory for jenkins

#

and not in the same folder as buildtools

#

oddly

#

im also running BuildTools as one of my jenkins steps

weak mauve
#

i think

shadow night
tired spoke
#

i saw from some free plugins, and them uses NMS for having multiversion to 1.8 from 1.12.2, do you reccomend me to use them?

halcyon mica
#

Don't use 1.8 period

#

Don‘t support it

#

It's a dead outdated as fuck version

quasi flint
#

burn this main alive

#

man

shadow night
#

How do plugins for multiple versions work? I have seen plugins that support versions from 1.13 up to 1.17.1

halcyon mica
#

As a side effect, you can only do stuff on parity with the oldest supported version

quasi flint
#

1.7 gp bonkers

#

go

ivory sleet
#

Some plugins work on most server versions without having to deal with further abstractions and nms since the api kinda provides some version compatibility

tired spoke
quasi flint
#

1.16

#

cooler building blocks

#

and there are pvp plugins that change cooldowm

tired spoke
halcyon mica
#

Let 1.8 die already

ivory sleet
#

Yeah it’s outdated and unsupported

quasi flint
#

it lived enough

#

saw enough in its lifetime

halcyon mica
#

It's not even funny anymore, it's just baggage legacy that prevents the game from being used to its full potential

quasi flint
#

this

toxic mesa
#

only reason 1.8 still exists is cuz of the pvp

halcyon mica
#

No

#

False

ivory sleet
#

Would say just the 1.8 fan base

quasi flint
#

look at my plugin i send

onyx shale
#

meh performance for minigames mostly

#

saves alot in hosting cost

quasi flint
#

negates that to a good degree

halcyon mica
#

Only reason why it exists is because people are too stubborn to accept that modern software can replicate their beloved pvp perfectly, and that performance is just a matter of proper optimization

quasi flint
#

fucking keyboard

onyx shale
#

the resource consumed is too big to handle

quasi flint
#

no?

onyx shale
#

slap a 1.17 on a small sized server its gonna choke and die

toxic mesa
onyx shale
#

no matter how many optimizations you make

quasi flint
onyx shale
#

even 1.16 with the nether update

#

will kill it]

halcyon mica
ivory sleet
#

Guys let’s be civil now

onyx shale
#

well.. youv seen mojangs way

quasi flint
#

i smell pai n

toxic mesa
#

I managed to get 110 players in a 1.17 server with 12 gb ram (18 tps), just takes a while to optimise it

halcyon mica
#

I can make a proper rpg system with unique mob ai, custom mobs and custom ui using nothing but server sided code and a resource pack, and it still tuns on 20tps on a 2gb server

#

I don't understand why everyone is crying about performance

onyx shale
#

and what verison

#

will you make it for

halcyon mica
#

1.17

#

It's already running

onyx shale
#

let me know when its done and see if its true

toxic mesa
quasi flint
#

and ur not running on an 512mb ram toaster of some dogshit hoster

toxic mesa
#

true

quasi flint
#

i hope atleast

toxic mesa
#

xD

halcyon mica
#

It probably helps that I am using my own server implementation instead of something bucket based or vanilla wrapped

#

The notchian server is terrible

quasi flint
#

i want too

#

gimme

halcyon mica
#

It's a thing I made for my employer

#

I can't just publish it online

#

It also runs on C++, so it likely won‘t help you much

toxic mesa
#

I mean still, if you just optimise the shit you make correctly it really does not make that much of an impact

quasi flint
#

who wants an server in c++

#

help

#

i certanly do

onyx shale
#

bedrock?

quasi flint
#

java prob

#

would be dope

ivory sleet
#

Honestly Java works great

#

And with J17 giving us the foregin memory api it will become even more powerful

#

Yes we have unsafe but it’s unsafe, hence the name

halcyon mica
#

Java is awful for a game like Minecraft

crude charm
#

or

#

lua

#

or some other random useless shit

halcyon mica
#

Both are terrible

#

There is a reason why performant games are written in C++

crude charm
#

I agree

halcyon mica
#

Because it gives you proper memory control and resource control

crude charm
#

but java is defo not bad

halcyon mica
#

It works, but it's still a terrible choice

crude charm
#

there is a reason there are so many java software dev positions

halcyon mica
#

java jobs are backend infrastructure

#

Not application

crude charm
#

...

#

it is an application

#

for a back-end job

regal dew
#

Rewriting the java edition 1:1 in c++ does not improve performance

crude charm
#

but it would allow for optimizations down the line

regal dew
#

There are definitely bigger improvements you can make rn to the java edition than to remap it in c++ kek

halcyon mica
#

It's not a port

#

It's a reimplementation of the protocol

regal dew
#

same thing can be said about projects like sponge

halcyon mica
#

I didn't even look at the java source for it, to not accidentially carry over bad design choices

#

Like off-threading lighting, but blocking the main thread until it's done

regal dew
#

that makes no sense to do async then is it xd

#

if you’re blocking the main thread anyway

halcyon mica
#

That's what the notchian server is doing

#

And thus everything that wraps it

regal dew
#

better is to get rid of the definition “main thread” and instead pursue an event-based system which can run stuff in parallel

halcyon mica
#

I've based my server structure on Bungie's job pipeline system

halcyon mica
regal dew
#

Sure but that should just make you alert on the difficulties of concurrent programming, not shove away in a corner bcs its scary 😁

halcyon mica
#

You can't just stuff the event system off-thread and expect it to work

#

You'd still need to queue up the main operations on the main thread to be applied to the actual game

regal dew
#

I never talked about implementations, but I think this is going a bit offtopic now lol

quaint mantle
# crude charm lua

some weird conservative kid in another discord server with an anime profile picture tried flexing that he knew lua

#

then he made the mistake of saying that he had a token grabber program in lua 😈

shrewd hemlock
#

hi,
how can i add multiple values to one path in a yamlconfiguration?

hasty jackal
#

using a List<Object> should probably do the trick

shrewd hemlock
#

ohhh... okay. thanks

quaint mantle
#

?learnjava

undone axleBOT
next stratus
#

Hey, i wanna make a method what allows me to store nbt on a block of a specific type of a schematic assigned to it so when I place it on the ground i can get the type assigned to it and then I can run a command to reverse the action. Any advice how to do so?

quaint mantle
#

u gotta ping whoever it is

quaint mantle
quaint mantle
shadow night
#

What are the differences between AsyncPlayerChatEvent and PlayerChatEvent?

ivory sleet
#

AsyncPlayerChatEvent might be fired asynchronously

#

PlayerChatEvent should always be fired on the server thread.

shadow night
#

What is better to use?

ivory sleet
#

Probably the async one since iirc the normal one is deprecated

hasty prawn
#

It is

shadow night
#

Okay

hasty prawn
#

Generally they're always going to be async also, they're only not async if you force them to talk

#

Atleast that's what the docs say peepoG

shadow night
#

Lol

stone sinew