#help-development

1 messages · Page 1646 of 1

toxic mesa
#

ah okay thx

chrome beacon
#

Doesn't always match but it's a good starting point

grim ice
#
Please fix JAVA_HOME environment variable.```
eternal oxide
#

JAVA_HOME is a system environment variable.

grim ice
#

yes

#

but i have my project structure set

#

it shouldnt care about my java_home

eternal oxide
#

ignore it then. I'm sure it will be fine and everything will work correctly.

grim ice
#

o ok

eternal oxide
#

That was sarcasm btw

grim ice
#

:/

eternal oxide
#

errors and warnings as there for a reason. Fix them.

quaint mantle
#

you dont want to mess with her

#

I don't understand why my projects are not finding the spigot artifact anymore, is the repo down?

wary harness
#

@quaint mantle what

quaint mantle
#

if you dont understand your own meme than this is sad

wary harness
#

@quaint mantle i was not dure what are u talking about

#

Xd

#

But understud now xd

errant fractal
#

Hey, i'm currently working on my first spigot plugin, not new to java however but had a quick question, i have a chatListener class which i want to take player's chat messages and store them into a hashmap of the player's username and message so that when a command is executed i can check their last message and if it is "confirm" it executes the command, Is there a simpler way of doing this? Atm i'm struggling to pass the hashmap over from the chatListener class to the command class since i'm unsure as to how it's instantiated with bukkit over standard java

#

I think i'm getting myself confused but i'mnot finding anything helpful online

chrome beacon
#

First of use UUID instead of username

errant fractal
#

I was planning on this but i wasn't sure how to get the player's UUID from the event

#

so i settled for their listname

chrome beacon
#

You use getUniqueID on the player object

#

The problem with usernames is that there are rare cases of duplicate usernames, and you don't want that to break your plugin

errant fractal
#

That's what i was thinking yeah, just couldn't find the method in the API, that's changed thanks

chrome beacon
#

Anyway there isn't a difference between how spigot and java instantiates things

errant fractal
#

Would i be able to skip the chatListener entirely and treat the command executing class allowing it to implement both Listener and commandExector instead?

chrome beacon
#

The listener will be called in the instance you registered it with

somber hull
#

Can i set a persistent data type to a boolean?

eternal oxide
#

(byte) 0/1

somber hull
#

hmm

#

i did 1

#

and it said invalid

eternal oxide
#

did you cast it to byte?

somber hull
#

o

#

a

#

work now

crimson terrace
#

is there an easy way to summon an entity without calling EntitySpawnEvent? or maybe to register the entity as something the event doesnt care about?

eternal oxide
#

Explain

toxic mesa
#

So I'm trying to use the Player Position packet with protocollib, I think (I could be wrong) it should be PacketType.Play.Server.POSITION
I tried this;

        ProtocolManager protocolManager = mainPlugin.getProtocol();
        protocolManager.addPacketListener(new PacketAdapter(mainPlugin,
                ListenerPriority.NORMAL, 
                PacketType.Play.Server.POSITION) {
            @Override
            public void onPacketSending(PacketEvent event) {
                PacketContainer packet = event.getPacket();
                Bukkit.broadcastMessage(String.valueOf(packet.getDoubles().readSafely(0) + "," + String.valueOf(packet.getDoubles().readSafely(1) + "," + packet.getDoubles().readSafely(2))));    
            }
        });

Just to see if it works. It does not broadcast anything and also does not give an error.
Any clue if I should have a different packettype or smth? Am kinda new to packets/protocollib

crimson terrace
#

I would love to have a chance to spawn a horde of Zombies around one if its hit by a player, but currently it crashes the testserver every time it happens

eternal oxide
eternal oxide
#

?paste

undone axleBOT
toxic mesa
crimson terrace
#

how do I pack code into discord?

eternal oxide
#

ok

ivory sleet
#

ok

eternal night
#

?paste

undone axleBOT
crimson terrace
#

currently Ive fixed it by making the horde entites into Husks instead of Zombies since doing it with zombies has a chance to put it into a loop

eternal night
#

what was the error

eternal oxide
eternal night
#

oh I thought only on damage

crimson terrace
#

true, but that only happens when you have the spawn chance at 100%

eternal night
#

you are doing this on spawn ?

crimson terrace
#

yes

#

sorry, i said damaged earlier

#

my bad

eternal oxide
#

didn;t you say you wanted a horde to spawn when a player hit a zombie?

crimson terrace
#

yeah I didnt remember it correctly sorry

eternal night
#

easiest solution is to use the World#spawn method that takes in a Consumer<T> and add a PDC entry to the spawned zombie

#

then check for that PDC entry on entity spawn

#

the passed consumer is executed before the entity is added to the world (and the respective event is called)

eternal oxide
#

at the beginning of your horde spawner code, set a boolean field to indicate you are spawning a horde. Then in your spawn event ignore any spawns when the horde is spawning. Reset the boolean when you finished the spawning

eternal night
#

or that

quaint mantle
#

How do I get a refund from this person? Selling plugins is not responsible.

crimson terrace
eternal night
#

it is xD damn minecraft single thread

crimson terrace
#

sometimes it does help

toxic mesa
#

player#OnGround is deprecated, should I use something else to check if a player is on the ground?

crimson terrace
#

check wether the block under the player is air?

toxic mesa
chrome beacon
#

It's deprecated because the client decides if it's on the ground or not

eternal night
#

only deprecated because the client can modify that field as it likes

eternal oxide
#

deprecated as it can be faked. There is no replacement. Use it but know it could be tricked

toxic mesa
#

F

#

Alright thx

crimson terrace
#

use maven

chrome beacon
#

Or javac if you want to try hard

quaint mantle
#

javac poop

crimson terrace
#

need a screenshot for tutorial?

#

what IDE you using?

dense goblet
#

There is only one IDE for Java

reef wind
crimson terrace
#

Ill program on my calculator if I want to ok?

dense goblet
#

MS Word or quit

crimson terrace
#

Samsung smart fridge gonna come in clutch

reef wind
lost matrix
reef wind
#

inventoryclickevent

crimson terrace
#

you use InventoryPickupItemEvent

lost matrix
crimson terrace
#

oh nvm

chrome beacon
#

Maven works on Windows

crimson terrace
#

sounded like the exact thing he needed

reef wind
#

no

chrome beacon
#

I have it right now

crimson terrace
#

same

chrome beacon
#

No

crimson terrace
#

not even sure why you download it

chrome beacon
#

Just get apache-maven-3.8.2-bin.tar.gz

#

or zip

#

Doesn't matter

reef wind
#

no

crimson terrace
#

I never downloaded it. came with the minecraft plugin for intelliJ

reef wind
#

are you a developer Ryan?

lost matrix
#

You can install it on any platform. But its a bit complicated because you need to edit the system environment variables.

reef wind
#

download the file, it’s that simple.

reef wind
eternal night
#

maven is just jar files 😭 it isn't OS dependend

chrome beacon
#

or you know the official installation instructions work too

reef wind
#

I hope Ryan is not a dev

reef wind
#

🤨

chrome beacon
#

True

reef wind
quaint mantle
#

i lke it, rated 10/10

toxic mesa
#

As player#onGround can be used by the client, what would be an alternative?
Just checking the block under the player will return the wrong block when standing on the edge. Not to mention all the "weird" blocks like beds, skulls ect

eternal oxide
#

There is none. You could get block under, unless crouching with no block under, then get the closest block.

toxic mesa
#

hmm

#

alright ty

true perch
#

How do you change which map an ItemStack is showing in 1.17? Like the data value

true perch
quaint mantle
#

hey im wondering if its possible to log certain things to RCon aswell w/ Console

#

like

#

can i just

#

idk

quiet ice
#

I do not think that that integration exists

quaint mantle
#

im wondering if i can get that in any way :o

quiet ice
#

likely read only

#

?stash

undone axleBOT
quaint mantle
#

ah

#

weird haha

#

because.. you can send things to them (command feedback)

lost matrix
#

You can pipe stdout anywhere. You can even mirror it into dev/null/ if you feel like it.

opal juniper
#

yes

lost matrix
#

Yes. Im not sure what RCon is but you can pipe the logs wherever you want

quaint mantle
#

ah

#

i wonder how, i'll google

#

i forgot Spigot is an actual irl item

#

big brain?

opal juniper
#

spigot + pipe == faucet

lavish hemlock
#

faucet logs

opal juniper
#

new spigot fork - faucet

lost matrix
#

I represent my new spigot fork: nozzle

lavish hemlock
lost matrix
dense goblet
#

Pretty sure all of these were already used lol

quiet ice
#

Or return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource

lavish hemlock
quiet ice
#

yes

dense goblet
quaint mantle
#

bruh

lavish hemlock
quaint mantle
#

yikes

quiet ice
#

that being said, idk if they allow writing to RCON

shy wolf
#

Hey is their an event for die?
or is it EntityDamageByEntityEvent?

plain scroll
#

yo

quaint mantle
#

i think they do allow writing to RCon @quiet ice

#

because you can send command feedback

#

you can .sendMessage()

quiet ice
#

And does it work?

plain scroll
#

so how can i kick a player, i try things like p.KickPlayer(name) but this kicks the player who uses it, ( bc of the p. ) what else can i try?

quiet ice
#

I don't care whether something compiles if it straight up does not work

quaint mantle
#

therefore it must be possible

#

ignore the capslock toggle

plain scroll
quiet ice
#

MD, please fix your website

#

https does not work as intended

quaint mantle
#

what

#

they work for me

quiet ice
#
kickPlayer
void kickPlayer​(@Nullable
String message)
Kicks player with custom kick message.

Parameters:
    message - kick message
#

Yes, that is because you are not using some super strange firefox config

quaint mantle
#

OHH

#

okic

quiet ice
#

So do Bukkit.getPlayer(name).kickPlayer(reason);

shy wolf
lost matrix
quiet ice
lost matrix
#

PlayerDeathEvent for example

quiet ice
#

like seriously, we should start kicking people asking such easy questions

quaint mantle
#

LOL

shy wolf
quaint mantle
opal juniper
shy wolf
#

e

true perch
#

How do you render an image to a certain map id

quaint mantle
#

so am i good to use Bukkit w/ Spigot in my pom.xml

#

or nah

chrome beacon
#

That's Paper

#

Ask them

quaint mantle
#

nah i just use Paper

#

i dont use it in my plugins

chrome beacon
#

Ask them

quaint mantle
#

weird and confusing Component stuff i cbb to learn about

chrome beacon
#

That error is related to something in Paper

halcyon coral
#

i want to get the location of 100 blocks higher than a player

#

Player p = e.getPlayer();
Location sky = loc.getY()+double (100);

chrome beacon
#

Then use the add method on the player location and get the block from that

halcyon coral
#

how do i fix the double(100) part

tame coral
#

100D

chrome beacon
#

Double isn't a location

tame coral
#

the letter at the end of a number is used for typecasting

halcyon coral
#

whats the add method

chrome beacon
#

add(x, y, z)

tame coral
#

oh i didn't look at the rest

tame coral
slim kernel
#

How can I get if a BukkitTask is running?

lost matrix
chrome beacon
halcyon coral
#

ive only used java a few times so im still new

tame coral
#

If you're inside it

tame coral
undone axleBOT
tame coral
#

i recommand you read one of those

halcyon coral
#

Cannot invoke add(int, int, int) on the primitive type double

tame coral
#

uuuuh

chrome beacon
#

._.

tame coral
#

what did you do

halcyon coral
#

thanks for the links im gonna take a read of them

chrome beacon
#

Yeah sounds like a good idea

tame coral
#

ye

halcyon coral
#

Player p = e.getPlayer();
Location loc = p.getLocation();
Location sky = loc.getY().add(0, 100, 0);

slim kernel
# chrome beacon Do you have a reference or id of this task
taskSpawnParticleZ = Bukkit.getScheduler().runTaskTimer(Main.getPlugin(), new Runnable() {
            @Override
            public void run() {

              

                if (taskTimerZ == 50) {
                  taskSpawnParticleZ.canel();
                }

                taskTimerZ++;

                player.getWorld().spawnParticle(shieldParticle, loc, 1);
            }
        }, 0L, 1L);

I wanna know if this task is running or not

tame coral
#

nah it would be Location sky = loc.add(0, 100, 0);

#

since getY returns a double

halcyon coral
#

oops forgot to delete the getY

chrome beacon
tame coral
#

not an actual location

halcyon coral
#

ok thanks

#

p.teleport(sky);

#

also this is a thing right?

slim kernel
quaint mantle
#

?nms

#

sadge

tame coral
#

you have everything right there

vale ember
halcyon coral
#

i did

#

but nothings being imported

tame coral
tame coral
halcyon coral
#

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

import floorToAir.Main;

#

these are my imports

tame coral
#

Because Player implements Entity, every method of Entity can be used in Player

#

(actually Player implements HumanEntity but close enough)

#

Take a look at those java tutorials

random isle
#

Hi hi, i made a Plugin and i have a problem. I like to check if an integer is between two numbers. My Code:
if((LevelingAPI.getPoints(p) >= 1) && (LevelingAPI.getPoints(p) < 200)) { System.out.println("deb2"); lore.add("§7- - - - -"); }
And the error is:
Caused by: java.lang.NullPointerException at me.pierre_rene.MainLevelingSystem.Bukkit.util.GUI.SetItemMeta(GUI.java:57) ~[?:?] at me.pierre_rene.MainLevelingSystem.Bukkit.util.GUI.openGUI(GUI.java:44) ~[?:?] at me.pierre_rene.MainLevelingSystem.Bukkit.util.GUI.onCommand(GUI.java:29) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-dcd1643-e60fc34] ... 15 more

tame coral
#

Which line is line 57

#

also use ```java
```
instead of just ``

lost matrix
#
  Code goes here
tame coral
halcyon coral
#

so if i imported org.bukkit would i need to import anything else

random isle
#

Line 57 is the line where the method are colled and in the method is my code

tame coral
halcyon coral
#

hypothettically

tame coral
#

unnecessary imports are a thing you wanna avoid

#

it's not python

halcyon coral
#

okay thanks for the help

tame coral
#

np

random isle
tame coral
#

which

#

method

random isle
#

in the method is my code

tame coral
random isle
#

wait i upload it

tame coral
#

but which line is line 57

#

that's what we're asking

random isle
lost matrix
#

then LevelingAPI.getPoints(p) returns null

tame coral
#

?paste

undone axleBOT
tame coral
#

use this next time

tame coral
#

(((LevelingAPI.getPoints(p) >= 1) && (LevelingAPI.getPoints(p) < 200)) != false) also what the fuck is that

slim kernel
strong karma
#

Hi I'm relatively new to spigot development and I was able to override the generateChunkData method previously but as I understand it, that's deprecated and it says it's split up? I'm just trying to understand what it means by split up and what should instead be overridden? thanks!

tame coral
tame coral
#

it's the exact same

lost matrix
halcyon coral
#

package floorToAir;

import org.bukkit.plugin.java.JavaPlugin;

import floorToAir.listeners.floorToAirListener;

public class Main {

@Override
public void onEnable() {
    new floorToAirListener(this);
}

}

why does onEnable() get the error "the method onEnable() of type Main must override or implement a supertype method"

#

ive done the exact same layout on my other plugins and it worked

tame coral
#

you didn't implement JavaPlugin

#

(or extend ? i forgor)

lost matrix
strong karma
#

ohh ok thanks I'll look

random isle
glossy barn
vale ember
tame coral
halcyon coral
#

oops forgot to add that

tame coral
#

You need to take care of it

tame coral
lost matrix
strong karma
#

ohh ok I guess the ChunkData is now a public member of the ChunkGenerator? huh

halcyon coral
strong karma
#

unless I'm misunderstanding

random isle
slim kernel
#
if (!taskSpawnParticleTop.isCancelled()) {
                player.sendMessage("1");
                taskSpawnParticleTop.cancel();
}
player.sendMessage("2");
```I did it like this now I dont even get to the "1" or the "2" and get an error in the console....
I wanna know if the BukkitTask is running pls help
tame coral
tame coral
#

You'd rather assign it once to a variable and then use that variable

lost matrix
tame coral
#

Because here you're doing 2 MySQL Queries

random isle
#

yeah ok thx i fix it XD

slim kernel
lost matrix
lost matrix
slim kernel
random isle
#

but it running on many servers on same tame and anny plyer con see it. I think so it is good

halcyon coral
#

package floorToAir.listeners;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

import floorToAir.floorToAir;

public class floorToAirListener implements Listener{

private floorToAir plugin;

public floorToAirListener(floorToAir plugin) {
    this.plugin=plugin;
    Bukkit.getPluginManager().registerEvents(this, plugin);
}

@EventHandler
public void moveEvent(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Location loc = p.getLocation();
    Location sky = loc.add(0, 100, 0);
    Block b = loc.getBlock().getRelative(BlockFace.DOWN);
    if(b.getType()==Material.AIR) {
        
    }
    else if(b.getType()==Material.CAVE_AIR) {
        
    }
    else if(b.getType()==Material.WATER) {
        
    }
    else if(b.getType()==Material.LAVA) {
        
    }
    else if (b.getType()==Material.OBSIDIAN) {
        
    }
    else if (b.getType()==Material.NETHER_PORTAL) {
        
    }
    else if (b.getType()==Material.END_PORTAL) {
        
    }
    else {
        p.teleport(sky);
    }
}

}

where it says private floorToAir plugin; the plugin gets a warning saying "The value of the field floorToAirListener.plugin is not used"

undone axleBOT
halcyon coral
#

but apparently im still meant to include it

tame coral
#

use this please

lost matrix
tame coral
#

and also use switch instead of multiple ifs

slim kernel
lost matrix
#

then taskSpawnParticleTop is null

halcyon coral
opal juniper
tame coral
#

don't worry i code in python too

slim kernel
tame coral
random isle
lost matrix
halcyon coral
tame coral
#

I don't understand this sentence

halcyon coral
#

yh

tame coral
#

If it's only a warning should work

random isle
lost matrix
halcyon coral
#

i sometimes get that warning and sometimes i dont

tame coral
#

And the data'll be synchronised

random isle
slim kernel
tame coral
#

uuuuuuuuh

#

yeah

#

no

#

it'll just be laggy

#

or get it off main thread

lost matrix
random isle
#

yeah in cause of that i use MySql

true perch
#

How do you render an image to a certain map id?

lost matrix
torn oyster
#

what would be the best way to store what kits players have unlocked using mysql?
would it be
UUID, KITNAME, KITNAME, KITNAME, KITNAME etc. and all the KITNAMEs would have true/false
or would it be
UUID, UNLOCKEDKITS and have a long list (separated by comma) of all the kits unlocked?

lost matrix
lost matrix
tame coral
lost matrix
#

And always program async with delegation when using databases.

tame coral
#

delegation ?

#

what is it

lost matrix
#

Consumer<T>, Function<T, E> etc.

random isle
tame coral
tame coral
lost matrix
vale ember
tame coral
#

Like

#

it's not hard

#

check if the method is called

tame coral
#

don't even need a proper debugger for this

#

just print things in the console

slim kernel
lost matrix
slim kernel
vale ember
tame coral
#

Either .toString() it or just check if it works without

tepid monolith
#

Why does it throw out an error

lost matrix
# slim kernel yes that will help thank you a lot

Sry for the chat clutter but its not much happening here, so:

public interface LimitedTask {
  void execute();
  boolean isDone();

  default boolean executeThenCheckIfDone() {
    this.execute();
    return this.isDone();
  }
}
public class LimitedTaskRunnable implements Runnable {

  private final LinkedList<LimitedTask> taskQueue = new LinkedList<>();

  public void addTask(final LimitedTask task) {
    this.taskQueue.add(task);
  }

  @Override
  public void run() {
    final Iterator<LimitedTask> taskIterator = this.taskQueue.iterator();
    while (taskIterator.hasNext()) {
      final LimitedTask task = taskIterator.next();
      task.execute();
      if (task.isDone()) {
        taskIterator.remove();
      }
    }
  }
}
lost matrix
lost matrix
slim kernel
lost matrix
tepid monolith
stone sinew
slim kernel
lost matrix
tepid monolith
lost matrix
tepid monolith
#

I want to pass both

quaint mantle
#

then take both?

#

?learnjava

undone axleBOT
quaint mantle
#

interfaces

lost matrix
grim ice
#

oWo

quaint mantle
#

i've asked before and tried some stuff, none works... how can i write to RCon, as a RemoteConsoleCommandSender

slim kernel
sleek pond
#

Is there a way to prevent flaming arrows? (Wether that be from the flame enchantment or them passing through lava, etc)

quaint mantle
#

i've tried casting, System.out, and even making an arraylist of RemoteConsoleCommandSender and sending things from there

stone sinew
sleek pond
#

doesn't matter as long as the outcome is the same, but would prefer if it visually looked like they are "difused" as wlel

stone sinew
quaint mantle
lost matrix
#

In this example the runnable deals damage to the player until it ticked 10 times or the player disconnects

slim kernel
#

Omg thank you so much it helps alot! Are you german btw?

lost matrix
#

Yes

slim kernel
#

Me too haha

lost matrix
#

my condolences

stone sinew
#

lol

slim kernel
quiet ice
#

germany is fucked up

#

But so is every other country so eh

lost matrix
#

Generating a new world always lags the server out for some reason. Maybe try delaying the teleport for a few ticks and dont teleport him to a random location like 0 75 0 but the actual spawn location of that world because the spawn chunks are generated first.

#

Because the spawn loc is rarely at 0 0

stone sinew
lost matrix
#

Oh god. Ive seen a name that triggers ptsd in me

quaint mantle
#

if (e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (e.getPlayer().getItemInHand().getType() != Material.EXP_BOTTLE)
return;

#

how can I use 2 hands at once?

lost matrix
#

There we go...

lost matrix
lost matrix
stone sinew
lost matrix
# stone sinew I did the spawnlocation instead of 0,0 and that fixed it. (on the first test atl...
  public void teleportWithTicket(final JavaPlugin plugin, final Player player, final Location location) {
    final World world = location.getWorld();
    final int chunkX = location.getBlockX() >> 4;
    final int chunkZ = location.getBlockZ() >> 4;
    world.addPluginChunkTicket(chunkX, chunkZ, plugin);
    Bukkit.getScheduler().runTaskLater(plugin, () -> {
      player.teleport(location);
      world.removePluginChunkTicket(chunkX, chunkX, plugin);
    }, 5);
  }
stone sinew
#

God been trying to get this shit to work for the past 3 days and all it was, was the location wasn't loaded

Rephrase: the chunks were loading lol

opal juniper
#

xD

sleek pond
#

I'm trying to make an irremovable leather cap

opal juniper
#

curse of binding

lost matrix
#

^

sleek pond
#

im stupid

opal juniper
#

then just don’t remove it on death

sleek pond
#

just in the death event remove it from the dropped items list?

opal juniper
#

like remove it from the drops

#

and put it back on them

sleek pond
#

also, you can take it away through code, right?

opal juniper
#

yeah

sleek pond
opal juniper
#

i’m not sure - you may need to put it back after they re spawn

#

do you know if you can set their inv on death @lost matrix

lost matrix
#

You need to keep track of the items that should be kept on death and add them back at the PlayerRespawnEvent

opal juniper
#

yeah ok

#

so if there is just one type of item just keep track of the players that need it and on respawn just set their helmet to that

#

if not you need to keep track of the players and which they need

sleek pond
#

should be pretty simple to add i think

lost matrix
#

Perfect case for a record btw

#

There is just one problem when the player dies and disconnects without respawning.

opal juniper
#

obviously you couldn’t just Inventory#addItem

#

if it’s a helmet

#

cause it wouldn’t be equipped

stone sinew
lost matrix
shy wolf
#

how to get a player head

pulsar schooner
#

Search in spigot forums, there will be plenty of answers there

#

A quick Google search will do

opal juniper
#

ItemStack -> skull meta -> setOwner -> set meta

shy wolf
#

like this?

        ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1);
        SkullMeta meta = (SkullMeta) skull.getItemMeta();
        meta.setOwner(p.getName());
        skull.setItemMeta(meta);
        p.getInventory().setItem(103,skull);
opal juniper
#

sorta

#

you can just get the meta of the itemstack and cast that

#

and

#

you don’t need the short in the itemstack constructor

#

as in

#

remove all that ordinal shit

#

and, you could use getDisplayName i guess

#

but that looks good

shy wolf
#

kk ty

eager sapphire
#

Is there any API to set item lore via Components?
I don't see any, but thought I'd ask in case it's on a spigot() somewhere that I'm missing, or.. something.

lost matrix
shy wolf
#

what is the head index for player?

#

103?

lost matrix
opal juniper
#

oh

shy wolf
opal juniper
#

i know what he means

#

yeah

#

it’s getEquipment

shy wolf
lost matrix
#

Aah

eager sapphire
opal juniper
#

you use the equipment

#

to set the head slot

shy wolf
#

yeay ty

lost matrix
#

player.getEquipment().setHelmet(ItemStack);

opal juniper
#

^

shy wolf
#

ty guys

somber hull
#

How would i keep track of, control the growth of plants?

#

Since their not tile entitys i cant add NBT to them

opal juniper
#

wdym

lusty cipher
#

Since 1.16.4 you can save NBT on just normal blocks

lost matrix
lusty cipher
#

Spigot implemented, i'm not sure for the name, PDC for Chunks, which allows you to add NBT to blocks too

opal juniper
#

does it

lusty cipher
#

Well you kinda can, just use x, y, z as a key in that chunk and you can save blocks to it

lost matrix
#

I know about the chunk PDC but not about PDCs for any arbitrary block

lusty cipher
#

It's not a specific implementation but it works perfectly fine

opal juniper
#

so not really directly then

#

but a workaround

lusty cipher
#

you can still do it

somber hull
lusty cipher
#

you can do chunk.getPersistentDataContainer as far as I know

somber hull
#

Well yea

#

but you said on a specific block

#

how does that work

lusty cipher
#

I'm not sure what the methods are called

#

but you can add stuff to it similar to how a HashMap would work

reef wind
#

you don't need y if you are saving a chunk

lusty cipher
#

and you could just key it using a String

#

and then could do something like block.getX() + "_" + block.getY() + "_" + block.getZ() + "_" as the key

somber hull
#

alright

#

ig that works

opal juniper
#

no

#

use the chunk key

quaint mantle
#

@reef wind

reef wind
#

ok stop fr

quaint mantle
#

I didn't understand

waxen plinth
#

Anyone know the nms call to update a chunk's lighting in 1.17?

#

I've been looking for quite a while now and found nothing

#

In every prior version it's just nms.chunk#initLighting()

echo basalt
#

@waxen plinth
try nmsChunk.i.getChunkProvider().getLightEngine().a(new ChunkCoordIntPair(chunkX, chunkZ));

#

If not, try that class's methods

waxen plinth
#

I tried that

#

And the other methods in the class too

#

This didn't work either

regal anchor
#

Hello, I am trying to prevent my endercrystal to get blew up by my explosion made with createExplosion()

#

I cancelled EntityDamageEvent and EntityExplodeEvent but the entity is still killed

#

a TNT doesn't kill the endercrystal with the events cancelled but createExplosion() does

waxen plinth
#

Spawn TNT and set its fuse to 0 instead of using createExplosion

regal anchor
#

createExplosion() allows me to chose the strength of the explosion

#

I get that this function doesn't trigger EntityExplodeEvent, why not

waxen plinth
#

You can set the yield of TNT

#

That will control the strength of the explosion

regal anchor
#

oh thank you I'll try that

#

I googled "radius", block lists stuff like that but never found "yield"

regal anchor
#

Then createExplosion really is useless

regal anchor
#

but I don't want to cancel everything just not affect the entity

young knoll
#

Doesn't cancelling EntityExplodeEvent cancel the block damage too

regal anchor
#

EntityDamageEvent & EntityExplodeEvent with endercrystal being the entity

#

but maybe endercrystals don't actually explode I was just trying anything

regal anchor
quaint mantle
#

love it when most questions in this channel are about java than spigot

sly trout
#

for 2 things

quaint mantle
#

why ping

sly trout
#

first

#

I didn't pping you

quaint mantle
sly trout
#

uhm so

#

erm...

#

okay.

quaint mantle
#

Ask

sly trout
#

I've got a problem with my start.bat

quaint mantle
sly trout
#
PAUSE
#

alrighty then

hasty prawn
sly trout
#

lol

#

org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/alexandre/cloudboards/Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0

#

any1 would know how to fix this ?

sly trout
#

done

sly trout
#

I've looked online and couldn't find a lot

regal anchor
#

Stop trolling

sly trout
#

are you okay mate

regal anchor
#

Yes

sly trout
#

doesn't seem like it

late stone
#

public class CustomChicken extends EntityChicken {

public CustomChicken(World world) {

    super(world);

}

}

im getting an error at "world" at super

sly trout
#

what's your error?

regal anchor
#

I don't like you windows

sly trout
#

stop trolling math

late stone
# sly trout what's your error?

'EntityChicken(net.minecraft.world.entity.EntityTypes<? extends net.minecraft.world.entity.animal.EntityChicken>, net.minecraft.world.level.World)' in 'net.minecraft.world.entity.animal.EntityChicken' cannot be applied to '(net.minecraft.world.level.World)'

regal anchor
#

Okay sorry Alexandre

late stone
hasty prawn
regal anchor
sly trout
#

MathWellan lil french boi

regal anchor
#

What are you talking about 🙄

sly trout
regal anchor
#

Yea I figured

sly trout
#

I'm using eclipse?

#

I do got intelliJ

#

but

#

yeah I made this plugin on eclipse for some reason

#

but isn't there a way of doing it on eclipse as well?

quaint mantle
#

Intellij betteraPES_Giggle

quaint mantle
sly trout
#

oh forgot screenshots were ass on here

#

well as you can see on the screenshot

#

it's a "Java Project"

quaint mantle
#

u using maven or gradle

sly trout
#

haven't spicified it

quaint mantle
#

pick one, i reccommend maven

sly trout
#

so I gotta create a new project ?

#

aight

quaint mantle
#

No

sly trout
#

oh

quaint mantle
sly trout
#

ermmm

somber hull
#

Can someone explain this for me?

#
        for (int x = loc.getBlockX() - 1; x <= loc.getBlockX() + 1; x++) {
            for (int y = loc.getBlockY() - 1; y <= loc.getBlockY() + 1; y++) {
                for (int z = loc.getBlockZ() - 1; z <= loc.getBlockZ() + 1; z++) {
                    Block b = loc.getWorld().getBlockAt(x, y, z);
                    
                }
#

int x = loc.getBlockX() - 1; x <= loc.getBlockX() + 1; x++ like whats going on here

native nexus
#

You want to generate blocks in a cuboid?

eternal oxide
#

its searching a 3x3 area

somber hull
#

Yea, im trying to get a 3x3 area around the feet of the player

#

that is code that breaks blocks in a 3x3 area

#

So im trying to understand it

eternal oxide
#

So what don;t you understand?

somber hull
#

So i can edit it

somber hull
#

I didnt make it

eternal oxide
#

each x,y,z +1 and -1

somber hull
#

i dont get whats going on here int x = loc.getBlockX() - 1; x <= loc.getBlockX() + 1; x++ or why its in a for loop

eternal oxide
#

so count from x -1 to x + 1

somber hull
#

x <= loc.getBlockX() + 1; like wtf is this...

#

<= ???

eternal oxide
#

teh loop ends when that test is not valid. so when x goes above loc + 1

native nexus
#

Test the code and see what happens...

native nexus
#

The logic is simple

analog inlet
#

Java don't have range like 0..10 in kotlin?

native nexus
#

Nope

analog inlet
#

scan 3x3 using kotlin range is simple

grim ice
#

if u know for loops u can 100% understand it

lavish hemlock
#

ok so:
A for loop is comprised of 3 parts:
The first is executed once when the for loop starts.
The second is a condition, the loop continues if the condition returns true.
The third is executed once per loop.

lavish hemlock
#

The for loops inside it do the same thing, just with block y and block z.

#

Then, it gets the block at the x, y, and z.

hybrid spoke
#

for loops doesnt exist. just for-each loops

#

:(

lavish hemlock
hybrid spoke
#

in java

lavish hemlock
#

That's just false :p

hybrid spoke
#

no

#

"for loops" are actually "for-each loops"

lavish hemlock
#

for-each loops technically compile to while loops, so for-each loops don't exist :p

hybrid spoke
#

they do

#

thats not technically, thats internally.

lavish hemlock
#

And the terminology is "enhanced for loop" but that's semantics

#

Technically, for loops are also while loops

#

And that's both functionally and internally.

hybrid spoke
#

the for-each loop isnt a while loop. maybe it has most likely the same impl. but it does not use a while loop internally

lavish hemlock
#

Do you know how the JVM does loops...?

#

Also, in no situation is a for loop the same as a for-each loop.

#

The fucking Wikipedia description makes a clear separation.

#
Foreach loop (or for each loop) is a control flow statement for traversing items in a collection. Foreach is usually used in place of a standard for loop statement. 
hybrid spoke
#

read the java language specification.

lavish hemlock
hybrid spoke
lavish hemlock
#

Javac desugaring ✨

lavish hemlock
#

WHO SEPARATES TWO DIFFERENT CONCEPTS VIA DIFFERENCE OF A HYPHEN?

#

Do me a favor. Never use "for-each loop" in the context of a for loop.

hybrid spoke
#

i cant

#

its just right

lavish hemlock
#

You will confuse multiple people and make yourself look like a retard.

hybrid spoke
#

idc

#

oracle is on my site

lavish hemlock
#

Also I looked at the JLS.

#

It's technically a for statement.

hybrid spoke
#

a for statement, a for-each loop or an enhanced for loop. but not just a for loop

#

welcome to java

opal juniper
#

xD

tepid monolith
#

When I uncomment the second line, tasks inside of the MenuHandler class, register twice

#

Like that

lost matrix
eternal oxide
#

you are not instance checking the inventory in your events

tepid monolith
#

Then how do I register ConfirmMenu as well

lost matrix
#

Do what Elgarl suggested

tepid monolith
#

I have no idea what he is talking about

#

Could you help me more detailed please?

eternal oxide
#

You need to compare the inventory you create for each GUI is the actual Inventory thats being interacted with in your event.

eternal oxide
#

You are creating two GUI classes so each should only handle the events for its own Inventory

tepid monolith
eternal oxide
#

Yes, you are registering each as an EventHandler, so each should handle their own events.

tepid monolith
#

uhh gime a second

lost matrix
#

Usually you would only register one single menu handler that handles all menus.
With something like a Map<Inventory, GUIHandler> inside.

eternal oxide
#

Your ConfirmMenu shoudl only handle its Inventory as shoudl CreateMenu

lost matrix
#

Because registering one handler for every GUI scales bad. Its just stacking a ton of equals() calls.

eternal oxide
#

^ true

#

A Map woudl be far cleaner

grim ice
#

uhh what

#

how would you use a map for that

eternal night
#

Also imagining rebaking the entire listener map every time

eternal oxide
eternal night
#

Inventory instances are persistent while used by the server

lost matrix
#

Map<Inventory, GUIHandler> <- Then call get on that and check if the return value is null. If not then pass the event to the handler.

grim ice
#

o

#

What's a gui handler tho

eternal night
#

Any class

#

Just something that encapsulates your logic

#

For a specific gui being clicked

grim ice
#

ah ok

eternal oxide
#

and accepts the event when passed on

lost matrix
#

Idk. Could be as simple as

public interface GUIHandler {
  void handleClick(InventoryClickEvent event);
}
grim ice
#

and why all that..

#

u can just check what inventory was clicked normally

lost matrix
eternal oxide
#

even a boolean so yoru main event handler can set the canceled state of its return

grim ice
#

can u show an example if u can

eternal night
#

Deep down it should just be java Consumer<InventoryClickEvent>

grim ice
#

im pretty sure the guy who asked the question didnt get anything and neither did I lol

eternal oxide
#

lol

lost matrix
eternal oxide
#

We basically ended up with, rewrite all the code 🙂

grim ice
#

rewriting a few lines isnt much

#

h o p e f u l l y

eternal night
#

Or you just use a sweet interface framework

#

And enjoy that a bunch of half decent developers used their brains

#

For cute API

grim ice
#

tbh

#

i still dont' get it

grim ice
#

was he doing that

#

you can just check for the inventories in one event tho, right?

#

e

tepid monolith
#

The event inside of the CreateMenu class doesn't work as its supposed to open an Inventory from the ConfirmMenu

grim ice
#

wait

#

r u registering each event in a class

#

??

tepid monolith
#

Yeah each GUI class has their own event inside of them

#

And I'm registering them inside of my main class

grim ice
#

u dont get me

#

nvm

tepid monolith
#

oh wait, i made a mistake specifying the inventory title

#

a typo

#

lemme see if thats causing it

summer scroll
#

why a listener for each gui?

eternal oxide
#

compare inventory instance not title

#

if clickedInventory.equals(inventory)

tepid monolith
lavish hemlock
tepid monolith
#

in order for them to specify the invetory name

lavish hemlock
#

if you do an identity comparison (==), what changes?

eternal oxide
#

you shoudl already have the Inventory instance in yrou class

tepid monolith
wary harness
#

I am making explosives pick axe whick brakes in radious
What will bes way of braking blocks in radious calling blockbrake even by my self for e ery block in or should i just set them to air
I am thinking if i call event for every block that will make heck can that block be broken or not that could save me time
Os some body have some siggestions?

summer scroll
lavish hemlock
#

not exactly

summer scroll
#

sometimes it doesn't work if you compare object with ==

wary harness
#

@eternal oxide what do u think abou it?

lavish hemlock
#

there's a major difference between == and equals

#

== compares by the instance (aka "by identity")
equals (overridden by a class) compares by value

wary harness
#

@summer scroll if u use equal it can break cose if object is null

tepid monolith
#

is this gonna work?

#

well actually lemme try

lavish hemlock
summer scroll
#

simply just null check it

lavish hemlock
#

why null check when you can combine the null check with the comparison? :)

grim ice
#

ur checking if a clicked inventory equals to a string

summer scroll
# tepid monolith idk

you might want to re-think the design again i think, because ideally you would have only 1 listener for all of the guis

wary harness
#

@lavish hemlock like your way of thinking 👍

lavish hemlock
#

I optimize things :p

tepid monolith
summer scroll
#

so null checking will make the code less optimized?

tepid monolith
#

and that caused multiple registrations

lavish hemlock
#

ofc not

#

it's less optimized by a readability standpoint

#

not a performance standpoint

tepid monolith
#

and btw, this error pops up whenever i click an empty slot (air) of the GUI

#

do i just make it
case AIR:
break;

#

?

lavish hemlock
#

null checks would actually be slightly faster than calling a method since method lookup and shit takes longer than a comparison

grim ice
#

just check if clicked item is null

hybrid spoke
wary harness
#

@eternal oxide thanks

tepid monolith
#

then its gonna make another if

#

prolly too messy

hybrid spoke
#

or you turn that messy spaghetti code into clean readable fabulous ✨ code ✨

tepid monolith
#

how do you exactly check if its null

#

case AIR didnt work

#

neither .isAir

#

this doesnt work either

wary harness
#

@tepid monolith did u return

summer scroll
# tepid monolith

You're checking if the Material is null, check the ItemStack instead.

wary harness
#

Check of item is null

#

U need to do tha first then

#

Check type

#

Step by step my friend

#

Skiping steps is not good

#

You will hurt your knees

#

🤣

tepid monolith
#

im just checking the type

#

getType.equals does the same

wary harness
#

Remove get type

tepid monolith
#

doesnt it?

summer scroll
#

You can't check the type if the ItemStack is null.

tepid monolith
#

oh

summer scroll
#

So you need to check if the ItemStack is null first.

wary harness
#

So dupe your if up and just remove vettype from it

#

And that is done

#

Tben check if type if null

#

If you want

#

But no need for it

#

If item stack is not null

tepid monolith
#

alr so a type cant be null

wary harness
#

Just check does it correspand

tepid monolith
#

so i just gotta check if the getcurrentitem exists or not

wary harness
#

To specific material

#

Yep

#

@tepid monolith

tepid monolith
#

like this?

hybrid spoke
#

you dont have to par null

#

but yes

wary harness
#

Yep remove ()

#

From null

tepid monolith
#

oh true

#

bro wtf is wrong

#

i'm literally checking

#

if its null do nothing

grim ice
#

Bwtf

tepid monolith
#

then if it's not

#

get the type

grim ice
#

wtf

#

wtf is that check bro

summer scroll
#

wtf

grim ice
#

wtf

tepid monolith
#

lol what

grim ice
#

if(event.getCurrentItem() == null) return;

tepid monolith
#

LOL return

grim ice
#

what

tepid monolith
#

no i mean you're right

#

i forgot it

grim ice
#

do you know basic java

tepid monolith
#

learning java at the same time...

grim ice
#

I know it's really annoying when people tell you to learn java

#

but like

#

yeah good luck either way

#

you'll learn it just with using spigot

tepid monolith
#

thank you

lost matrix
opal juniper
#

invisible items??

eternal night
#

? XD

#

Those are glass panes fam

opal juniper
#

fuck me i’m blind as fuck

#

facepalm moment

plain scroll
#

can i make a new class where i make item stacks and recipes?

#

if so what would go here?/

lost matrix
#

?learnjava

undone axleBOT
plain scroll
#

nvm i think i got it

plain scroll
#

Could not load 'plugins/main-1.0-SNAPSHOT.jar' in folder 'plugins': uses the space-character (0x20) in its name

#

hm

quaint mantle
#

?learnjava

undone axleBOT
quiet ice
#

absolute confusion

quaint mantle
quiet ice
plain scroll
#

ok ok

#

ik this is a noob ass question

#

nvm

#

i found it out

ancient whale
#

Hey, I would like to clear an empty glass bottle if dropped in the PlayerDropItemEvent
But so far the only way I got this working is by caching the entityId of the itemDrop and to cancel it's spawn in the EntitySpawnEvent but i'm pretty sure I could avoid using the EntitySpawnEvent, any ideas ? 😒

hardy swan
#

;-; why entitycombustbyblockevent doesnt apply for items in lava

visual tide
#

is there a way to detect when obsidian is formed?
ive tried:
-blockformevent
-blockgrowevent
-blocktofromevent
none of the work
the first 2 dont even fire
and yes i have them registered

vast kelp
#

Then you're doing something wrong, because it's the BlockFromToEvent

visual tide
#
@EventHandler(priority = EventPriority.HIGHEST)
    public void onBlockFromTo(BlockFromToEvent e) {
        if (e.getBlock().getType() == Material.WATER && e.getToBlock().getType() == Material.STATIONARY_LAVA) {
            e.setCancelled(true);
        }
    }
#

doesnt work

vague oracle
vague oracle
ancient whale
# vague oracle Does your version not have event.getItemDrop()?

It does, i have tried ```java
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
if(e.getItemDrop().getItemStack().getType() == Material.GLASS_BOTTLE) {
e.setCancelled(true);
e.getPlayer().getInventory().remove(e.getItemDrop().getItemStack());
}
}

vague oracle
#

why would you cancel it?

vast kelp
# visual tide doesnt work

Instead of cancelling, try e.getToBlock().setType(Material.DIRT); if that works then it can't be cancelled, if it doesn't then either your if statement failed or the event isn't registered

vague oracle
#

delete it all and set the itemdrop to air

visual tide
#

not sure what to make of that

vague oracle
#

at the moment your to material is lava

#

in your code

visual tide
#

yes but wouldnt changing that result in it triggering when water flows anywhere?

vague oracle
#

well you just said e.getToBlock().getType() is air or water

#

but in your statement you use e.getToBlock().getType() == Material.STATIONARY_LAVA

visual tide
#

yes but changing that would make it fire when water is flowing anywhere

vague oracle
#

how?

#

if 1 is lava

#

and 1 is water

visual tide
#

and even then a fromToEvent wont cover it
since you can make obsidian by placing lava like so and that wont trigger fromTo

ancient whale
lost matrix
#

What are you trying to do?
Look at BlockFormEvent if you want to control formation of cobble/obsidian

visual tide
vast kelp
visual tide
#

true that would be an option

lost matrix
#

BlockFormEvent works

vast kelp
visual tide
lost matrix
#

What spigot version are you on?

visual tide
#

1.8.8-R0.1

lost matrix
# visual tide 1.8.8-R0.1

Support was dropped almost half a decade ago.
Use ancient software -> live with the bugs that will never get fixed

visual tide
#

ah

#

welp ok thanks

lost matrix
vast kelp
#

Everyone, do we prefer javax.annotation.Nonnull or org.jetbrains.annotations.NotNull?

vague oracle
#

or lombok.NonNull 😉

unreal quartz
#

spigot themselves use jetbrains'

lost matrix
#

def jetbrains for me. If you use intellij then you get nice support for them.

quaint mantle
#

@lost matrix

vast kelp
#

Thanks for the input all

lost matrix
quaint mantle
#

I kind of figured out how to do it

quaint mantle
#

🤣

plain scroll
#

ok so if i do somethin like

int warn = 0; 
#

does that warn ver - if i modify it woud it be diffrent for each player?

hybrid spoke
#

no

#

it would be the same for each player

#

or everytime a new one if its a local var

plain scroll
#

oh so how could i make it so its diffrent for each player?

lost matrix
plain scroll
#

so somethin like this

eternal night
#

👀👀

hidden delta
plain scroll
#

good point

lost matrix
# plain scroll

Not really. In fact not even close. Try to create a sandbox project and play around with maps so you understand how to use them.

plain scroll
#

yea, im trying to add a warn system to my plugin , i thaught it would be easyer lmao

hidden delta
plain scroll
#

?

hidden delta
#

It is from the basics

#

You need to understand how to save the data on specific way

plain scroll
#

yea ik lol

#

thats what im doin rn

hidden delta
#

😐

plain scroll
#

:/

#

oh no i dont know how to store data in a certon way 😬