#help-archived

1 messages · Page 156 of 1

subtle blade
#

The thing that tells the item entity that it's a specific type of entity

#

Question for those more familiar... do init blocks get called after constructors? Or before?

#

Actually I should do this differently

#

Alright. That should fix that lol

#

Yep!

boreal tiger
#

in a plugin with multiple shaped/shapeless recipes, are we supposed to use one NamespacedKey for each or one NamespacedKey only?

vernal spruce
#

you mean no more lava floating cow?

#

damn dude FeelsBadMan he was so happy

lone fog
#

You need a new key for each recipe

boreal tiger
#

right thanks 👌

lapis plinth
#

How do i import 1.8 API using Intellij? It wont let me use ENDERDRAGON_GROWL and is forcing me to use ENTITY_ENDERDRAGON_GROWL

vernal spruce
#

if it points to it,then thats the sound

lapis plinth
subtle blade
#

oki Just waiting on review

vernal spruce
#

lavaproof cow?

subtle blade
#

Yessir!

vernal spruce
#

hell yeah!

lapis plinth
#

lmao

subtle blade
frigid ember
#

One message removed from a suspended account.

lapis plinth
#

send full error

forest plaza
#

Thanks a lot Choco!

frigid ember
#

One message removed from a suspended account.

forest plaza
subtle blade
#

Sorry it's not super great with items :(( client-sided limitations

#

There's a hotkey for that?

forest plaza
#

Better than nothing

#

Yeah

subtle blade
#

oic

forest plaza
#

I went through the patchnotes and looked for this stuff

subtle blade
#

That was recently added

#

ClickType.SWAP_OFFHAND

forest plaza
#

Ah nice!

#

Then I can mark it as closed

subtle blade
#

Already was 🙂

lone fog
#

Yay progress

forest plaza
#

Oh wow

frigid ember
#

Fireproof chickens that walk on lava

#

Like striders

#

But from the overworld

forest plaza
#

Horses will be striders

frigid ember
#

Hmm I'll take that

forest plaza
#

Now we need waterproof

frigid ember
#

Waterproof endermen

subtle blade
#

In that case you can cancel the teleport event iirc

frigid ember
#

🤔

cursive mulch
subtle blade
#

6 hour cache time

cursive mulch
#

Ah okay thanks

tiny pebble
#

Is there a ProtocolLib PacketType that only refers to the off hand arm animation? PacketType.Play.Client.ARM_ANIMATION checks for both arms

young vessel
#

How many players can spigot hold on a server?

tiny pebble
#

^ That's usually up to whoever/whatever is hosting the server, not spigot

frigid ember
#

ideally you could just access bukkit reflection and set your player slots

young vessel
#

Yes of course if i want to have 500 players on one server i also need a better server but can this hold spigot?

frigid ember
#

Spigot by itself can hold 120 on a single server

#

you can get upwards of 200 with the right equipment

vernal spruce
#

usually 100 is enough,just split them up in more servers

young vessel
#

Oh okay 👌

#

Thanks

worn fiber
#
    private void createConfig() {
        configFile = new File(getDataFolder(), "config.yml");
        if (!configFile.exists()) {
            configFile.getParentFile().mkdirs();
            this.saveDefaultConfig();
            saveResource("config.yml", true);
            getLogger().info("'config.yml' didn't exist, so it was created.");
        }

        config = new YamlConfiguration();
        try {
            config.load(configFile);
        } catch (IOException | InvalidConfigurationException exception) {
            getLogger().info("Could not load config.yml");
        }
    }```
#

What did I do wrong here?

#

It's not making the file in the plugins directory or in the .jar

frigid ember
#

you can just use the method #saveDefaultConfig()

winged sparrow
#

@tiny pebble there’s a pretty easy nms method for making the offhand move if that’s what you’re looking to do.

tiny pebble
#

that's what I'm looking for yes. I've tried an NMS method but it made the offhand swing indefinitely

frigid ember
#

I don't use protocol lib so I wouldn't know

winged sparrow
#

@tiny pebble I’ll get you the code. I use it for a little dual wielding feature thing of mine

tiny pebble
#

thank you so much 🙂

frigid ember
#

How to get a horse neigh sound? I don't see anything in EntityEffect

naive goblet
#

@worn fiber it doesn't create at all?

winged sparrow
#

I’m also working on a plugin that lets you bash people and things with your shield as a secondary attack, but it has to use the Paper API

#

Since spigot doesn’t support setting the shield cool down.

naive goblet
#

nms 😮

frigid ember
#

I don't think anybody uses just standalone spigot lol

winged sparrow
#

Honestly lol

tiny pebble
#

right now all i'm trying to do is when holding a certain item and you left-click with it, the other item in off-hand also hits lol

naive goblet
#

I do lol

frigid ember
#

I have a custom fork

#

wtf

#

dats not good

naive goblet
#

huh

#

why not

#

works fine for testing my projects 🤷

frigid ember
#

do you guys not use craftbukkit to program?

naive goblet
#

wym by that? the Craft classes ?

frigid ember
#

nonono

#

like

#

bukkit

#

like not spigot

#

but bukkit

lone fog
#

Spigot is just a fork of craftbukkit

naive goblet
#

^

ashen stirrup
#

Uhh I'm having some issues with basic java lmao, I have a class called "GUI", it has a public variable called spawner, inside the class there's a public void method called openInventory which passed a Player object and a StackedSpawner object. In the method I set the aforementioned spawner variable with this.spawner = stackedSpawner (the StackedSpawner passed in the method). I then try to access it in my Listener method after the spawner has been initialized. I feel like i'm being stupid here but any help?

lone fog
#

And craftbukkit shouldn't really be used anyway

frigid ember
#

what

#

So uh

#

Anybody know how to get the horse neigh sound?

#

Its not the EntityEffect enum

naive goblet
#

Jeeb send code ig

lone fog
#

Sounds.ENTTY_HORSE_NEIGH?

#

Or something like that

frigid ember
#

winner winner

#

yes im aware spigot is a fork of bukkit

#

but you shouldnt use spigot in your ide

naive goblet
#

whut

lone fog
#

Why

#

Spigot is the only supported one left isn't it?

ashen stirrup
#
    // Stacked Spawner Object
    public StackedSpawner spawner;

    // OpenInventory Method
    public void openInventory(Player player, StackedSpawner stackedSpawner){
        spawner = stackedSpawner;

        for (InvItems invItems : InvItems.values()) inventory.setItem(invItems.getSlot(), invItems.getStack());

        ItemStack spawnerStack;
        spawnerStack = spawner.getDropItem();
        ItemMeta meta = spawnerStack.getItemMeta();
        meta.setDisplayName(meta.getDisplayName() + ChatColor.translateAlternateColorCodes('&', " &f(&6x" + spawner.getStackAmount() + "&f)"));
        spawnerStack.setItemMeta(meta);
        inventory.setItem(13, spawnerStack);

        ItemStack spacer = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 15);
        for (int i = 0; i < inventory.getSize(); i++){
            if (inventory.getItem(i) == null) inventory.setItem(i, spacer);
        }

        player.openInventory(inventory);
    }

    // Listener Method
    @EventHandler
    public void onClick(InventoryClickEvent event){
        if (event.getInventory().getTitle().equalsIgnoreCase(inventory.getName()) &&
        event.getCurrentItem() != null && !InvItems.isInteractable(event.getCurrentItem())){
            event.setCancelled(true);
            return;
        }
        event.setCancelled(true);

        InvItems invItems = InvItems.stackToObject(event.getCurrentItem());

        if (spawner == null) return;
}
frigid ember
#

there are different forks of spigot people use, but all bukkit is the same

#

some spigots have removed classes

lone fog
#

Every fork comes from spigot though

naive goblet
#

hopefully

lone fog
#

Or at least should

frigid ember
#

i dont think you understand lol

#

like some spigots remove things normal spigot has

naive goblet
#

Jeeb and what was the issue? sorry for me

lone fog
#

Well then they are bad forks /shrug

frigid ember
#

they arent lol

naive goblet
#

green I mean a good fork shouldn't remove anything

ashen stirrup
#

Even though the spawner is initialized through the openInventory method, it still returns null in the InventoryClickEvent

naive goblet
#

It's almost never necessary

frigid ember
#

it can is what im saying

urban stone
#

Hey, when I set setPersistent(false) for a entity, does that mean that the entity will be removed on ChunkUnload or on server shutdown when saving world?

worn fiber
#

@naive goblet Just the folder

#

Not the file

lone fog
#

I mean the only main fork I know of is fine

#

So meh

frigid ember
#

paper?

#

yeah paper is fine

naive goblet
#

if (!plugin.getDataFolder().exists) { plugin.getDataFolder().mkdirs(); } or smtng

worn fiber
#

I did that

naive goblet
#

or if you have a file instance File#getParentFile

frigid ember
#

do people not just use #saveDefaultConfig() ?

worn fiber
#

I don't know

#

That's why I'm asking

naive goblet
#

I mean it's a good practice to do it by your own

frigid ember
#

@worn fiber just use saveDefaultConfig

#

right but its cleaner code

naive goblet
#

wut

frigid ember
#

just removes a bunch of useless code

#

when its already done for you

worn fiber
#
    private void createConfig() {
        configFile = new File(getDataFolder(), "config.yml");
        if (!configFile.exists()) {
            this.saveDefaultConfig();
            saveResource("config.yml", true);
            getLogger().info("'config.yml' didn't exist, so it was created.");
        }

        config = new YamlConfiguration();
        try {
            config.load(configFile);
        } catch (IOException | InvalidConfigurationException exception) {
            getLogger().info("Could not load config.yml");
        }
    }```
#

This doesn't work either

frigid ember
#

no like

#

get rid of that all together

#

and add saveDefaultConfig in onEnable

naive goblet
#

btw saveResource 2nd param should be false in most cases including yours pretty sure

#

@worn fiber And config.yml exist in jar?

worn fiber
#

No.

#

It doesn't exist at all

#

Which is my issue

frigid ember
#

bruh

naive goblet
#

Add it then lol

worn fiber
#

Isn't it supposed to create it?

#

Like most plugins do?

frigid ember
#

no

#

it needs something to copy

naive goblet
#

saveResource copies the file from the jar and puts it in plugin folder + dumps eventual content of the file

#

if you want to create a new file use File#createNewFile instead of JavaPlugin#saveResource

worn fiber
#

So if I ship out this plugin, it'll automatically create config.yml from the one in the jar file?

frigid ember
#

yes

#

its kinda like your plugin.yml

#

the config.yml has to be there too

naive goblet
#

If you're using the built-in config it has to be an embedded resource.

#

But I mean you could eventually create a new config.yml and then dump content

frigid ember
#

but then again config.yml is pointless in todays world really

naive goblet
#

wth why lol

frigid ember
#

all you need it for is to set hostname data lol

#

everything else can be stores via redis

#

or mongodb

naive goblet
#

lmao not everyone has a database etc

frigid ember
#

true

#

my b

sleek minnow
#

Hello, I need help, I downloaded spigot 1.15.2, I made my server, and I deleted the folder by mistake, and now, i'm trying to make another spigot server, and the java file does not work

naive goblet
#

a plain file config isn't pointless but there is surely cases where it should be avoided

#

What did you do?

ashen stirrup
#

Even though the spawner is initialized through the openInventory method, it still returns null in the InventoryClickEvent

naive goblet
#

Oh sry Jeeb

#

lemme look

ashen stirrup
#

All good ❤️

frigid ember
#

@sleek minnow just install it the same way you did

naive goblet
#

Well you're not directly initializing the spawner at openInventory

worn fiber
#

I want to have a config.yml so people can edit prices.

naive goblet
#

yeah

sleek minnow
#

Does not work Green, I reinstalled and now, does not work

frigid ember
#

hmm

#

are there system errors?

ashen stirrup
#

this.spawner = stackedSpawner;
didn't work either

sleek minnow
#

Nope, just the java file doesn't do anything

frigid ember
#

@worn fiber ideally for player data use mysql

worn fiber
#

I want to automatically generate config.yml if it doesn't exist

naive goblet
#

just re-assigning spawner reference jeeb

worn fiber
#

This isn't playerdata

naive goblet
#

felix a premade one or a new one

frigid ember
#

spanish dude you need to add your start command

sleek minnow
#

I have tried a folder retriever but nothing

#

What start command?

frigid ember
ashen stirrup
#

The StackedSpawner is only passed in the openInventory method.

frigid ember
#

or run.bat

sleek minnow
#

And how i do that?

frigid ember
#

depending on your os

naive goblet
#

yes Jeeb

sleek minnow
#

Windows 10

frigid ember
#

spigot wiki forums can help

lone fog
#

IMO for small amounts of player data using yml is fine

frigid ember
#

yes run.bat then

#

ye

worn fiber
#

@naive goblet Premade

naive goblet
#

Coll imagine hypixel though

ashen stirrup
#

How would I then re-assign it in the InventoryClickEvent

lapis plinth
frigid ember
#

i run a larger scale server so i just have no use for config

worn fiber
#

I want it to have a default set of prices that can be modified

frigid ember
#

yea thats good for a config then

naive goblet
#

Jeeb this kinda seem like a xy problem. What are you originally trying to do.

#

Felix start with adding a config.yml the same way you added your plugin.yml

ashen stirrup
#

Add/remove from a stacked spawner, I have the method setup, it's just that the spawner is returning null lmao

lone fog
#

Well of course hypixel needs a DB

#

especially since it's all multi-server

naive goblet
#

nah plain files for life

#

lol

#

defo plain files now

frigid ember
#

all servers large or small need a db regardless if you use flatfile storage or not

worn fiber
#

I made the config.yml

frigid ember
#

add your cfg options then

naive goblet
#

okay it should load now

worn fiber
#

But instead of throwing a hissy fit and melting down when it doesn't exist, I want to create it.

frigid ember
#

then just use saveDefaultConfig in onEnable

#

ez pz

worn fiber
#

I did

#

It doesn't create it

naive goblet
#

I have a config tutorial felix

frigid ember
#

not in createFile

#

lol

#

delete that shit

lapis plinth
#

Lol

#

My shit is broken

worn fiber
#

I didn't do it there Green

naive goblet
sleek minnow
#

@frigid ember I made a start.bat

frigid ember
#

great

worn fiber
#
    @Override
    public void onEnable() {
        // Create the config file if it doesn't exist
        saveDefaultConfig();

        // Register commands
        this.getCommand("helloworld").setExecutor(new HelloWorld());
    }```
frigid ember
#

now run it

worn fiber
#

It does not create it.

frigid ember
#

add saveConfig after it

naive goblet
#

Does the jar contain config.yml?

lapis plinth
sleek minnow
#

And, does not work

worn fiber
#

It does not

#

Does the jar contain config.yml?

frigid ember
#

did you add the start command line?

sleek minnow
#

Error: Unable to acces jarfile spigot.jar

frigid ember
#

the jar needs the config lol

worn fiber
#

I want to create it if it doesn't exist

sleek minnow
#

what config?

worn fiber
#

I said that

frigid ember
#

Spanish phone you need to run as an admin

#

you're saving it to nothing @lapis plinth & File.seperator yikes

sleek minnow
#

Oof

naive goblet
#

@lapis plinth Just set the values of the keys?

frigid ember
#

you cant do that @worn fiber

naive goblet
#

and then save

#

File.seperator is kinda overkill

worn fiber
#

So then how do other plugins auto-create it if it doesn't exist?

lapis plinth
#

Oh

frigid ember
#

they dont lol

#

deconpile the jar file

sleek minnow
#

Says the same @frigid ember

frigid ember
#

youll see the config

#

did you add cmd arguments?

worn fiber
#

Oh

frigid ember
#

such as what ram you want?

naive goblet
#

Double a workaround would be to create an empty config.yml and then add default options

worn fiber
#

So I need to make a file and load it into the config.yml on build

frigid ember
#

🤦‍♂️

worn fiber
#

This doesn't make any sense

sleek minnow
#

i just put this @echo off java -Xms1G -Xmx1G -XX:+UseConcMarkSweepGC -jar spigot.jar nogui pause @frigid ember

worn fiber
#

Is there a file called spigot.jar?

#

Or is it server.jar or something else

frigid ember
#

just run it using java -jar spigot.jar

#

try that

#

and make sure the file name is spigot.jar

#

for the actual jar file

#

keep start.bat the same

sleek minnow
#

Oh lol

#

The name of the jar was spigot-1.15.2.jar :v

frigid ember
#

oh

naive goblet
#

as I did

#

and then re export your project into a jar and see if the jar contains the premade config.yml

worn fiber
#

It works

frigid ember
#

good

naive goblet
#

alg then?

worn fiber
#

I think so

#

Let me test something real quick

lapis plinth
#

you're saving it to nothing @lapis plinth & File.seperator yikes
@frigid ember How do I save it to something?

#

I have customConfig set to smt here FileConfiguration customConfig = YamlConfiguration.loadConfiguration(customYml);

frigid ember
#

create file first

lapis plinth
#

The file is created, the defaults arent added

frigid ember
#

try to create file first*

worn fiber
#

How do I access the config variables?

#

plugin.getConfig().getInteger();

#

This doesn't do it

frigid ember
#

you didnt create it though

lapis plinth
#

how do i "create" it?

frigid ember
#

customYml.createNewFile();

naive goblet
#

plugin.getConfig().getInteger(”path”);

lapis plinth
#

oh

worn fiber
#

Weird, it doesn't do autocomplete

#

I'll try it

lapis plinth
#

so like this

naive goblet
#

it’s maybe getInt

sleek minnow
#

@frigid ember Thanks, now works perfect

#

👍

frigid ember
#

yeah i guess a

worn fiber
#

@naive goblet It doesn't even auto-fill getConfig()

#

I'm in another file btw

lapis plinth
#

@frigid ember still nothing

naive goblet
#

Nope

frigid ember
#

because you're adding defaults as well

#

just do customConfig.set()

lapis plinth
#

kk

frigid ember
#

or you could do saveDefaults

naive goblet
#

Felix send code v

worn fiber
#
public class HelloWorld implements CommandExecutor {
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player player = (Player) sender;
        String x = plugin.getConfig().getInteger().toString();
        player.sendMessage("x");
        return true;
    }
}```
ashen stirrup
#

Add/remove from a stacked spawner, I have the method setup, it's just that the spawner is returning null lmao

naive goblet
#

Remove from what?

ashen stirrup
#

The stacked spawner

#

WildStackerAPI

naive goblet
#

@worn fiber you need to declare the plugin reference

lapis plinth
#

That worked thanks!

worn fiber
#
    public static Plugin plugin;
    public static Plugin getPlugin() {
        return plugin;
    }```
#
        Plugin plugin = PluginPlayground.getPlugin();
        String x = plugin.getConfig().getInteger().toString();```
#

Like this?

#

Or should I make an instance of it?

naive goblet
#

...

#

Dependency injection

worn fiber
#

I don't know what that is.

#

Lemme google.

fair owl
#

would anyone be able to recommend a customisable coloured names plugin? ^^

#

it'd be cool to have custom patterns other than rainbow if that was possible

naive goblet
#
class Main extends JavaPlugin {
  void onEnable() {
    getCommand("command").setExecutor(new Command(this));
  }
}
class Command implements CommandExecutor {
  private final Main plugin;

  public Command(Main plugin) {
    this.plugin = plugin;
  }

  @Override
  public boolean onCommand(CommandSender s, Command c, String l, String[] a) {
    System.out.println(plugin.getConfig().getString("path"));
  }
}``` @worn fiber
vernal spruce
#

is a player ping(delay server-client) stored somewhere? or how would i acces it

naive goblet
#

sam as 1.16.1 released very recently there might not be any of those

fair owl
#

yeah that's fair ^^ i've just not been able to find anything i was looking for in previous versions either

ashen stirrup
#

Any help 😅

naive goblet
#

Jeeb Idk I still don't know what exactly removing a spawner means. When a player breaks it or places it?

vernal spruce
#

nvm found out ping is in craftplayer

ashen stirrup
#

All of that is working, it's just that when going from the openInventory() method to the InventoryClickEvent, spawner variable becomes null. It's not null in the openInventory() method since it's used for one of the ItemStack names.

naive goblet
#

Firstly you should encapsulate the variable spawner

#

and make a setter and a getter for it

#

much easier to maintain

rotund steppe
#

simple question: what's the best way to keep TNT enabled but stop it from causing block damage?

naive goblet
#

Use a plugin for it, pretty sure

rotund steppe
#

recommendations?

ashen stirrup
#
    public StackedSpawner getSpawner(){
        return spawner;
    }
    
    public void setSpawner(StackedSpawner spawner){
        this.spawner = spawner;
    }

Yeah

naive goblet
#

Now set it whenever you want and make sure it isnt null

#

zane nope but shouldn't be that hard to find

ashen stirrup
#

It was only null when I used it in the InventoryClickEvent, not in the openInventory() method

naive goblet
#

Then it wasn't assigned

ashen stirrup
#

I was using this.spawner = spawner

rotund steppe
#

cool thanks :)

frigid ember
#

can someone tell me hoe to make a 60% stone adn 40% cobbleston

naive goblet
#

yes it would be null if you never assigned it

ashen stirrup
#

Doesn't work with getters and setters.

// OPEN INVENTORY METHOD
setSpawner(stackedSpawner);

// INVENTORY CLICK EVENT
StackedSpawner stackedSpawner = getSpawner();
frigid ember
#

hello?

#

how do i set somethign to 60% cobble and 40% stone

ashen stirrup
#

Worldedit?

#

//set 60%cobble,40%stone

#

I believe

frigid ember
#

ok

winged sparrow
#

Think that capability isn’t there anymore

lone fog
#

It is

ashen stirrup
#

Works with FAWE

winged sparrow
#

Also why did //up stop being a thing

lone fog
#

Or at least it was in 1.15

winged sparrow
#

Has anyone noticed that?

lone fog
#

I think it's /up now

winged sparrow
#

Oh

ashen stirrup
#

Anyone got any ideas?

hot girder
#

Hi, I have a question. If I create a Listener for event "InventoryEvent", will it also listen for events "InventoryClickEvent", "InventoryMoveItemEvent", etc?

tiny pebble
#
        manager.addPacketListener(new PacketAdapter(this, PacketType.Play.Client.ARM_ANIMATION) {

            @Override
            public void onPacketReceiving(PacketEvent packetEvent) {

                PacketContainer offhand = manager.createPacket(PacketType.Play.Client.ARM_ANIMATION);
                offhand.getHands().write(0, EnumWrappers.Hand.OFF_HAND);

                CraftPlayer player = (CraftPlayer) packetEvent.getPlayer();
                final PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player.getHandle(), 3);

                List<EnumWrappers.Hand> mainhand = new ArrayList<EnumWrappers.Hand>(Collections.singleton(EnumWrappers.Hand.MAIN_HAND));

                player.sendMessage("checkpoint 1");

                if (player.getInventory().getItemInMainHand().equals(Items.jasonSword) && packetEvent.getPacket().getHands().getValues().equals(mainhand)) {
                    player.sendMessage("checkpoint 2");
                    player.getHandle().playerConnection.sendPacket(packet);
                    player.sendMessage("checkpoint 3");
                }
            }
        });

This is the farthest I've gotten.
I get to checkpoint 2 and 3 successfully, though the off-hand animation doesn't play. Any ideas?

pine goblet
#

anyone know how to get the current players on a bungeecord via spigot?
and the max players of the bungeecord.

naive goblet
#

@hot girder you can’t listen to the InventoryEvent

tiny pebble
#

@winged sparrow Sorry for the mention, let me know if you don't want me to do it again. Just wanted to let you know what I've got so far and what doesn't work since you know how to do this kind of stuff

hot girder
#

bruh, ok

winged sparrow
#

@tiny pebble No problem. I’ve just been busy and haven’t had a chance to get to my machine

#

I don’t remember the code by heart but as soon as I get to my pc and open my IDE I will send it to you

tiny pebble
#

no worries, i'm just working on doing it myself as of now and this is the closest i've gotten haha

#

alrighty, thank you

winged sparrow
#

It’s been at the forefront of my mind, promise lol

tiny pebble
#

haha no worries

frigid ember
#

is (byte) x the same as x & 0xff in bytecode?

nimble stump
#

Yes

worn fiber
#

Are they in the same file?

#

How does it access Main from Command when it didn't make an instance?

#

Does Main() pass itself into Command(), which makes an instance allowing you to access Main?

frigid ember
gaunt shell
#

It seems Spigot 1.16.1 is ignoring the world-container option in bukkit.yml.
All the folders are going into the main server dir instead of my /worlds folder :|

Information:

[16:26:50] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-4d9262c-3b9cf0f (MC: 1.16.1) (Implementing API version 1.16.1-R0.1-SNAPSHOT)
[16:26:50] [Server thread/INFO]: Checking version, please wait...
[16:26:50] [Thread-9/INFO]: You are running the latest version

bukkit.yml

spawn-limits:
  monsters: 70
  animals: 10
  water-animals: 15
  water-ambient: 20
  ambient: 15
chunk-gc:
  period-in-ticks: 600
ticks-per:
  animal-spawns: 400
  monster-spawns: 1
  water-spawns: 1
  water-ambient-spawns: 1
  ambient-spawns: 1
  autosave: 6000
aliases: now-in-commands.yml
settings:
  allow-end: true
  warn-on-overload: true
  permissions-file: permissions.yml
  update-folder: update
  plugin-profiling: false
  connection-throttle: 4000
  query-plugins: true
  deprecated-verbose: default
  shutdown-message: Server closed
  minimum-api: none
  world-container: worlds # This is not working 
lone fog
#

Yeah that is known

#

I believe MD didn't reimplement it because he didn't think many people used it

gaunt shell
#

Oh, that's very unfortunate

#

I hate having worlds in the main folder

#
  • all my servers have worlds in "worlds" that I've made
frigid ember
#

What is the link of the hastebin md5 ?

quartz trench
#

?paste

worldly heathBOT
frigid ember
#

Does anyone know where I can get/hire someone to help with setting up a Spigot server with a few issues?

gaunt shell
#

I've now seen the bug report for my issue, unfortunately my host does not allow me to edit the startup paramaters

#

I hope a better solution is found soon 😦

rustic valley
#

@crisp ermine Hello, I can not join your discord. I guess I'm ban but I have a question about one of your DeluxeChat plugins

gaunt shell
#

Something different as well, the usercache.json was also moved to /worlds when I used a local server to test the startup parameter
Not sure if that's intended or not

frigid ember
#

is this a really overcomplicated way to randomly assign teams?

#
        
        Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
        board.registerNewObjective("Paintball", "dummy", "Paintball Game");
        Team red = board.registerNewTeam("red");
        Team blue = board.registerNewTeam("blue");
        
        Player[] playersArray = (Player[]) Bukkit.getOnlinePlayers().toArray();
        List<Player> players = Arrays.asList(playersArray);
        Collections.shuffle(players);
        
        for (int i = players.size(); i > 0; i--) {
            Player lastPlayer = players.get(players.size() - 1);
            if (players.size() % 2 == 0) {
                red.addEntry(lastPlayer.getName());
            } else {
                blue.addEntry(lastPlayer.getName());;
            }
            players.remove(lastPlayer);
        }
    }```
storm vessel
#

?paste

worldly heathBOT
storm vessel
#

does anyone know what could have caused this?

subtle blade
#

Yes, it is. Don't decompile code and you don't have that issue, robby

quartz trench
#

Where should I make my name change request

frigid ember
#

dont decompile code?

tiny dagger
#

on your profile settings

subtle blade
#
        Player[] playersArray = (Player[]) Bukkit.getOnlinePlayers().toArray();
        List<Player> players = Arrays.asList(playersArray);
        Collections.shuffle(players);
        
        for (int i = players.size(); i > 0; i--) { ```
#

Tends to look a lot like what a decompiler would do

quartz trench
#

thanks

tiny dagger
#

there is also Arrays.sort

frigid ember
#

so are you saying I used a decompiler?

tiny dagger
#

because that runs like 3 times over 👀

#

Collections#shuffle just does toArray and calls Arrays.sort

dusk ferry
#

Okay so bit of an error, updated to paper 1.16 from 1.15. A player logs in, hops in a boat.
Player lost connection: Internal Exception: java.lang.NoClassDefFoundError: net/minecraft/server/v1_15_R1/PacketPlayInVehicleMove

#

Every time they try to rejoin

#

they're insta disconnected

#

hit with that

tiny dagger
#

can we make a petition to change the name to paper instead of spigot?

dusk ferry
#

Doesn't look like a paper error to me

#

So wondering if anyone could help, that's all

#

Since Paper was made from Spigot

tiny dagger
#

anything can be a paper error

#

especially since their build process is completly different

#

so unless you test that bug with a spigot build

#

there is nothing we can do

dusk ferry
#

I'm just gunnah wait till someone else sees, might have experience. I hope thats okay with you

tiny dagger
#

good luck with that then 😉

dusk ferry
#

I'm allowed, right?

tiny dagger
#

i'm just saying you're gonna get the same answear

dusk ferry
#

I asked before about paper issue and got an answer

tiny dagger
#

especially when apparently classes are missing

#

👌

dusk ferry
#

Wait

#

Classes are missing?

#

What do you mean?

subtle blade
#

Regardless of whether or not you think it's a paper issue, you're running software that we do not maintain

#

You should seek support in the appropriate place, we cannot help you with something that may very well not have anything to do with us whatsoever

#

If they deem it to be an issue with CraftBukkit, they may push a patch upstream to resolve it

#

Until you can replicate that issue on Spigot or CraftBukkit, it's nothing we will resolve nor support you with

crimson raft
#

is there any way to get the sender from org.bukkit.plugin.messaging ?

fierce briar
tiny dagger
#

whate exactly?

fierce briar
#

I'm wondering spigot (because Italic Problem (past), or Plugin

#

the names, they are the item names not the Custom names.

#

It's messed up to the point were Sub GUI's are also randomly effected.

#

[14:06:48] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-4d9262c-3b9cf0f (MC: 1.16.1) (Implementing API version 1.16.1-R0.1-SNAPSHOT) [14:06:48] [Server thread/INFO]: Checking version, please wait... [14:06:49] [Thread-72/INFO]: You are running the latest version

lapis plinth
#

whats the mthod to get a file of this name and to be able to read that file;s contents?

naive goblet
#
File file = YOURFILE;
FileConfiguration config = YamlConfiguration.loadConfiguration(file);``` ?
tiny dagger
#

new inputstream?

fierce briar
#

found the problem, It's the Symboles

#

.<

crimson raft
#

found the problem, It's the Symboles
@fierce briar was about to say, they need to be in unicode

#

afaik

#

only utf-8

fierce briar
#

yea transfers [+] = some Symbol

#

anyways. thanks.

lapis plinth
naive goblet
#

You want to read config.yml?

boreal tiger
#

hi @subtle blade , I think I found a bug in beehives again. it seems that EntityBlockStorage#setMaxEntities is not working correctly

#

if I print the #getMaxEntities it prints the correct value

#

but only 3 bees go inside
EDIT: Sorry for the ping, it does work. I forgot to update

naive goblet
#

AtomFTW I'd encapsulate the FileConfiguration instance and perhaps use dependency injection to access it from another class

frigid ember
#

is there a plugin for a kickme command?

lapis plinth
#

@naive goblet I want to read a custom file name, it varies every time

#

and how do I do that xD

naive goblet
#

by name?

lapis plinth
#

Yeah

#

The name will vary depending on who fired the event

naive goblet
#

well could use a File instance and invoke it's constructor that takes a path and a filename

lapis plinth
#

🤔

naive goblet
lapis plinth
#

Lol kk ty

crimson raft
#

is there a plugin for a kickme command?
@frigid ember you dont need a plugin to have a /kickme command

#

can be done from command.yml

#

afaik

naive goblet
#

A plugin would be better though

#

afaik command.yml only makes shortcuts

frigid ember
#

@crimson raft no it can't

#

and conclure's right

#

id have loved /kick @s

#

but

naive goblet
#

I can make that rn if you want lol

frigid ember
#

i dont want to let the entire world kick each other

#

if you have the time, that would be great ❤️

#

and ofc if its not a bother to you

naive goblet
#

What server version?

frigid ember
#

1.16.1

naive goblet
#

So perhaps if they have a permission to do it?

frigid ember
#

sure

#

ive been scouring google for hours and everything i saw was SO outdated

naive goblet
#

haha well should take 5 min if my wifi and pc wants to show some mercy

frigid ember
#

yeah lmao

valid fern
#

How do I make a post on the forums im an idiot

naive goblet
#

First get an account

valid fern
#

Done

naive goblet
#

Then choose which forum you want to post on

valid fern
#

erm

#

Hold up

naive goblet
#

..

valid fern
#

IDRK what I would post it to

naive goblet
valid fern
#

Im trying to give players the permission to run /warp with essentials using luckperms but when I search it I cant find it 😢

#

Oh lul

#

sorry and thx

naive goblet
#

/lp group default permission set essentials.warp.<name>

#

iirc

valid fern
#

Oh thx

worn fiber
#

How can I completely disallow GUI Inventory modification?

#
    // Cancel items being dragged into our GUI
    @EventHandler
    public void onInventoryClick(InventoryDragEvent event) {
        if (event.getInventory() == gui) {
            event.setCancelled(true);
        }
    }```
#

I tried this but it doesn't work

naive goblet
#

InventoryClickEvent#setCancelled(true)

lean fiber
#

hey I have a question

worn fiber
#

What does the pound sign mean?

sturdy oar
#

£ ?

tiny dagger
#

gbp i think

frigid ember
#

lmao yeah

tiny dagger
#

the british pound

lean fiber
#

Anyone has the hunter vs speedruner plugin

#

not the dream one

#

The free one

worn fiber
#

InventoryClickEvent#setCancelled(true)
/
this

subtle blade
#

is a pound, guys

#

lol

frigid ember
#

no

sturdy oar
#

no

frigid ember
#

£ is gbp

subtle blade
#

It's Javadoc notation, Felix

tiny dagger
#

that's hashtag

subtle blade
#

It's how you reference a method

#

oh no you're all gen z PES_CryHands

frigid ember
#

*octothorpe

worn fiber
#

I already have an event handler for InventoryClickEvent

frigid ember
#

;)

sturdy oar
#

it's mainly known as number sign

#

i haven't heard pound sign in my whole life

frigid ember
#

or a sharp

tiny dagger
#

^

subtle blade
#

Have you never gotten an automated message when dialing a company or anything?

worn fiber
#

Is there a full list of events?

subtle blade
#

Dialed an extension?

frigid ember
#

what

tiny dagger
#

how many names must a symbol have before people stop using it altogether

subtle blade
#

"To confirm, press pound"?

frigid ember
#

no

#

we dont have

#

to confirm

#

in phone trees

subtle blade
#

(╯°□°)╯︵ ┻━┻

#

I'm old

frigid ember
#

cuz im british

sturdy oar
#

"octothorp" is the actual name according to Wiki

tiny dagger
#

we call it 'diez' here

worn fiber
#

I have

    // Cancel items being dragged into our GUI
    @EventHandler
    public void onInventoryClick(InventoryDragEvent event) {
        if (event.getInventory() == gui) {
            event.setCancelled(true);
        }
    }```
And
```java
    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        // Ignore if the item clicked was not in our GUI
        if (event.getInventory() != gui) return;

        // Cancel the event so the player doesn't actually take the item
        event.setCancelled(true);

        // Bunch of stuff below here but it's long
frigid ember
#

oh!

#

well

#

til

worn fiber
#

I can still drag and place items into my GUI

subtle blade
#

ANYWAYS. # is javadoc notation lol.

#

Inventories aren't == comparable

sturdy oar
#

DoubleFelix, what is gui

worn fiber
#

An inventory

frigid ember
#

._.

subtle blade
#

However the views are

sturdy oar
#

yeah you don't use == for objects usually

worn fiber
#

Inventories aren't == comparable
@subtle blade The Spigot website lied 😱

naive goblet
#

lol

subtle blade
#

It's full of liars! 😛

frigid ember
#

ok i read that as what is a gui

sturdy oar
#

THe spigot website bad

#

xd

naive goblet
#

remember when the wiki told us to use InventoryHolder

worn fiber
#

No

#

I followed this

subtle blade
#

You should be able to safely compare references of an inventory view

naive goblet
#

ye

worn fiber
#
    // Cancel items being dragged into our GUI
    @EventHandler
    public void onInventoryClick(InventoryDragEvent event) {
        if (event.getInventory().getContents().equals(gui.getContents())) {
            event.setCancelled(true);
        }
    }```
#

Like this?

subtle blade
#

No, its view

#

When you open an inventory you're returned an InventoryView

#

In an InventoryEvent, you can getView() to get an InventoryView

worn fiber
#

if (event.getView().equals(gui)) {?

naive goblet
#

You could but == should be enough

worn fiber
#

But it should still work?

naive goblet
#

¯_(ツ)_/¯

#

never tried

tiny dagger
#

it will

naive goblet
#

is gui an inventory or inventoryview

worn fiber
#

Inventory

naive goblet
#

pretty sure you should compare 2 inventoryviews ?

worn fiber
#

I can still put stuff into it 😔

frigid ember
#

hey @subtle blade, will it ever be possible to allow image sharing here?

#

plz

subtle blade
#

You can. You just have to be verified

frigid ember
#

oh!

subtle blade
frigid ember
#

well now i feel encouraged to make a forum acc

#

whether I actually will is another question

naive goblet
#

always handy

worn fiber
#

There isn't an event for player death :(

worn fiber
#

Oh

sturdy oar
#

.-.

worn fiber
#

You can't cancel it

#

welp

naive goblet
#

just heal the entity

sturdy oar
#

you can't bring back deads to life

subtle blade
#

By that point, the player's already in the process of dying

halcyon snow
#

Maybe you could listen to EntityDamageEvent and check if the damage will kill the player.

#

if it does, cancel it.

#

maybe

ashen stirrup
#

store player location, if they die, respawn them, set their location back?

naive goblet
#

hmm yeah get if health is under 0 or smtng

frigid ember
#

no collision is not possible without teams?

naive goblet
#

.

worn fiber
#

Works fine now lol

#

Now I need to fix this broken GUI

#

Since I can still put items into it.

frigid ember
#

how do i make a backup script?

naive goblet
frigid ember
#

becaise i do /backup and it say there is not an external backup script

worn fiber
#

Does an event handler method need to have the same name as the event?

naive goblet
#

nope

worn fiber
#

I cannot figure out why this is wack then

subtle blade
#

The method can be named whatever you want

worn fiber
#

Dang

naive goblet
#
public void anyname(InventoryClickEvent /* <-- has to be specific and is case sensitive.*/ e /* <-- can be anything aslong as it doesn't take a java keyword*/) {

}```
worn fiber
#
    // Cancel items being dragged into our GUI
    @EventHandler
    public void onInventoryDrag(InventoryDragEvent event) {
        if (event.getView() == gui) {
            event.setCancelled(true);
        }
    }```
#

I made the edits that were suggested

naive goblet
#

gui is still an inventory?

worn fiber
#

Yeah

#

Shouldn't getView() solve that?

heady prairie
#

Does anyone know how to set group chat colours e.g: '&8[{GROUP}] &f{DISPLAYNAME}&7:&r {MESSAGE}' with both essentialschat and luckperms together? I'd assume the bigger community on here know of both plugins and have experiance with them rather than asking the same question on the individual discords. @tropic nacelle

tropic nacelle
#

I know the answer but you pingd me, go ask in essx discord

magic sun
#

does getHostname on PlayerJoinEvent get hostname even if behind bungee? is there a way to get hostname connected with from individual servers?

heady prairie
#

i mean, you said you knew the answer so why not help? i ping for your help 🤦‍♂️

whole haven
#

sorry if this is the wrong place to ask.
Masa's Tweakeroo mod allows you to place directional blocks facing away or to the side relative to you. Making redstone building easier. Sadly this is a fabric mod so I can't put it on my server without changing from spigot to Fabric, but spigot is just so much better for performance. Is anyone here aware of a plugin that allows the same trick?
or even datapack?

naive goblet
#

Elijahzeal pretty sure you could fix it by per group format

#

Hyperbus I don't think anything like that exist as a plugin atleast

lapis plinth
#

well could use a File instance and invoke it's constructor that takes a path and a filename
@naive goblet IDK how to do this, I just got back to my PC and I don't see where in your tutorial would help with this xD

naive goblet
#

It does cover how you could implement a system that takes different filenames etc

#

But if you have command you'd do something like this: [typing takes sometime]

#
//oncommand
String arg = /* your string */;
File file = new File(plugin.getDataFolder() /*path\folder*/, arg + ".yml");
if (!file.exists()) {
  System.out.println(arg + ".yml doesnt exist!");
  return true;
}
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
lapis plinth
#

Huh, I wouldn't have to JUST use a command, this could be used within a Event as well right?

naive goblet
#

yep

lapis plinth
#

kk

naive goblet
#

though eventhandlers is void methods you should just return in File#exists

lapis plinth
#

kk

frigid ember
#

help how do i make a backup script pls help

naive goblet
#

of what?

frigid ember
#

minecraft

naive goblet
#

wym

frigid ember
#

it says

#

something abt no external backup script wehn i do /backup

naive goblet
#

Well idk what you'd need a backup script for?

frigid ember
#

to back up a thing

naive goblet
#

what specifically

lapis plinth
#

make your own .sh script

frigid ember
#

?

lapis plinth
#

backup isnt a built in minecraft command

#

when you run that command its like running backup in the linux terminal

frigid ember
#

ik

#

but how do i put in

lapis plinth
#

use this

frigid ember
#

mac?

naive goblet
#

Linux

frigid ember
#

im on mac

naive goblet
#

Pretty sure you could find a decent tutorial that covers mac

lapis plinth
#

I doubt you'd need backups if you're localhosting a mc server for dev uses

worn fiber
#

gui is still an inventory?
If I switch it to an InventoryView, will it still work as normal?

frigid ember
#

😦 because ive already lost everything twice

#

now three times

lapis plinth
#

how lmao

sturdy oar
#

I backup daily with systemd and crontab

frigid ember
#

it broke

#

how do i BACKUP 😠

#

no one tell me

#

😭

naive goblet
#

DoubleFelix I think you'd do something like InventoryEvent#getView == InventoryInteractEvent#getWhoClicked#getOpenInventory

#

or perhaps not

frigid ember
#

i dont have a hosting i run it off my computer

lapis plinth
frigid ember
#

?

lone fog
#

Google probably has plenty of backup scripts and resources

frigid ember
#

?

lone fog
#

What?

frigid ember
#

how do i get mmy world back

lapis plinth
frigid ember
#

it turned into ocean

lone fog
#

What did you do to it

sturdy oar
#

😂

lone fog
#

Yes atom

lapis plinth
#

kk

frigid ember
#

it was floating island and then oceean

lone fog
#

Well if you don’t have a backup you are likely screwed

frigid ember
#

wot how why i try make backup but no work

lapis plinth
#

system restore it

frigid ember
#

how

#

wot????

#

sytem restore

#

?

lapis plinth
#

does Mac even have system restore

frigid ember
#

what is that

lone fog
#

Mac has time machine iirc

frigid ember
#

:(

#

its ruined

#

ive lost everytign

sturdy oar
#

Glhf

magic sun
#

is there a way to get the hostname connected with from individual servers behind a bungee? e.getHostName gets the bungeeIP

lapis plinth
#

Why tf does it say this file doesnt exist

#

when it does

#

lmao

#

"[18:36:19 INFO]: 22445145-791f-487a-ade0-c93469a7cd2a.yml doesnt exist for some wierd reason!"

lone fog
#

Why are you loading from it before you check that it exists :p

wide jewel
#

what is "path"

lapis plinth
#

Why are you loading from it before you check that it exists :p
@lone fog wdym

#

and this is path

wide jewel
#

why not use new File(getDataFolder(), arg + ".yml")

lone fog
#

^

lapis plinth
#

o

#

k one sec

#

wouldnt I have to define the plugin or sm shit

wide jewel
#

getDataFolder() is a method from JavaPlugin

lone fog
#

Just use an instance of your plugin

lapis plinth
#

but that shouldn't be the issue tho should it?

wide jewel
#

Is that code in your plugin class or another?

lapis plinth
#

That code is in a listener class

wide jewel
#

I'm guessing the listener is constructed from your plugin class then?

lapis plinth
#

I have the listener registered if thats what you're asking

#

im not using any constructors in this class yet

raw plover
#

anyone know if jobs is working 1.16? i cant get mine to work :/

wide jewel
#

If you create a constructor for you're listener with a parameter for your plugin. and then from your plugin class where you use "new Listener()" pass your plugin as an argument e.g. new Listener(this)

#

where this would be your plugin because it's inside your plugin class

#

Then you would store the plugin in a field in your listener class

lapis plinth
#

kk

#

I think i fucked something

#

xD

lone fog
#

No, you pass this in your plugin constructor

lapis plinth
#

o

#

there we go

worn fiber
#

Do I have to register events for them to work?

#

I didn't register a GUI lib class that implements Listener

lone fog
#

Yes you do

lapis plinth
#

It says the file still doesnt exist

worn fiber
#

How do I register those?

lapis plinth
#
    public void registerListeners() {
        PluginManager pm = Bukkit.getServer().getPluginManager();
        pm.registerEvents(new PlayerRightClick(this), this);
        pm.registerEvents(new CorePlace(), this);
        System.out.println("Plugin has successfully registered listeners");

    }
scarlet rover
#

Does anyone know how spigot handles a BlockBreakEvent that breaks multiple blocks? My issue is that if I cancel the drops for a block with a torch attached, then use e.getBlock().getDrops() then I only get the drops for the block, not the torch.

worn fiber
#

GUI is a class which creates a GUI object

#

Do I need to register it?

#

It requires two parameters

lapis plinth
#

IDK i use SimpleInvs api for guis

midnight marten
#

Hello ✋👋

#

It's possible for buy system to bug?

#

A buyer of my plugins say than he have been receive the payment fracture but can't download the plugins

naive goblet
#

Felix I think comparing 2 inventory instances is fine

#

You don't necessarily need to check the inventoryview

worn fiber
#

So I don't need to register it?

naive goblet
#

I mean encapsulate an Inventory

#

and compare with ==

#

should be enough

worn fiber
#

if (event.getContents() == gui) {?

tame drum
#

i still need help with my account because i sent email to support tmp-support (at) spigotmc.org and i havent heard anything since atl east yesratday or two

naive goblet
#

event.getInventory() == gui

worn fiber
#

So this should all work then?

naive goblet
#

or perhaps event.getView().getTopInventory()

worn fiber
#

Should I post a pastebin to all my code?

naive goblet
#

sure

#

and not pastebin

worn fiber
#

What then?

naive goblet
worn fiber
#

There ya go

naive goblet
#

That code is kinda meh

worn fiber
#

What's wrong with it?

naive goblet
#

well use this check:

if (event.getView().getTopInventory() == gui) {
  event.setCancelled(true);
}```
#

I can tell u tmrw, too tired rn

worn fiber
#

welp

lone fog
#

Well you are canceling the event no matter what

#

So no inventories will work

worn fiber
#

But it doesn't cancel it

naive goblet
#

wth dude

worn fiber
#

Oh

tame drum
#

am i sending email to right email? tmp-support@spigotmc.org

naive goblet
#

why do you have 2 methods with the same name

worn fiber
#
        if (event.getInventory() == gui) {
            // Cancel the event so the player doesn't actually take the item
            event.setCancelled(true);
        }
#

I just followed a tutorial

#

I renamed the last one

naive goblet
#

also, are you registering the eventhandlers?

lone fog
#

Nothing wrong with overloaded methods

naive goblet
#

Method names should be discriptive and not missleading. onInventoryClick(InventoryDragEvent e) is kinda meh

lone fog
#

Ah I thought you meant addItem

worn fiber
#

No

#

I don't know how to register it with parameters

naive goblet
#

How's your main looking?

worn fiber
#
    @Override
    public void onEnable() {
        // Register commands
        this.getCommand("shop").setExecutor(new Shop(this));
    }```
naive goblet
#

....

#

obviously it won't work

#

You didn't even register the event

tame drum
#

@subtle blade sorry for the ping but is this current email tmp-support (at) spigotmc.org

worn fiber
#

I don't know how to register it with parameters

naive goblet
#
//onEnable
getServer().getPluginManager().registerEvents(new GUI(), this);
worn fiber
#

But GUI() takes 2 parameters

naive goblet
#

remove those?

#

Well tbh

#

Almost everything with that class isn't very liable

worn fiber
#

How so?

naive goblet
#

You should follow srp

worn fiber
#

What?

naive goblet
#

Single Responsibility Principle

tame drum
#

😦

naive goblet
#

Sentaku well, be patient

tame drum
#

sorry

naive goblet
#

Felix

#

I'd send all classes

#

so we can get a look on what you're really trying to do

tired gazelle
#

Anyone elses bungee plugins get absolutely kneecapped by the latest updates? lol
Namely;

  • Add the MessageRaw channel
  • Add support for contents in Hover Event
    Broke so much of my Bungee plugins it's not even funny
worn fiber
#

This is shop.java

naive goblet
#

Okay start with making a class called Gui

worn fiber
#

Done

naive goblet
#

then add a private final Inventory field

#

and then add a constructor with a String parameter and int parameter

#

Let me type this perhaps

worn fiber
#
    public GUI(String name, int size) {
        
    }```
naive goblet
#

now in that one

#

declare the inv field to be Bukkit.createInventory(null, Utils.color(name), size);

#

If you don't have a Utils class make one

#

and add this method

#
public class Utils {
  public static String color(String str) {
    return ChatColor.translateAlternateColorCodes('&', str):
  }
}```
#

Essentially this is just a shortcut method

#

Calling Utils.color(String)

#

would give us a string but it would transform all valid colorcodes like &6 to color

#

well in your Gui class

#

@worn fiber you there?

light orbit
#

um how do I get spigot

#

I have eclipse

#

and idk how to like get spigot to start doing stuff for mc

light orbit
#

ty

worn fiber
#

Sorry

#

Mom needed me to do something

naive goblet
#

its ok

#

rdy to continue?

worn fiber
#

New file?

#

For that utils bit

naive goblet
#

yes

#

also you may declare the class final

worn fiber
#

Why?

#

What does it do?

#

I know it makes it constant

#

But what does it do for a class?

naive goblet
#

wrong

worn fiber
#

Oh

naive goblet
#

It doesn't make it constant

#

It makes it un-extendable

#

well okay did you make that with the color method?

worn fiber
#

Yes.

naive goblet
#

now back to Gui class

#

we have a private final Inventory field

#

well did you add this?

  private final Inventory inv;
  public Gui(String title, int size) {
    inv = Bukkit.createInventory(null, Utils.color(title), size);
  }```
worn fiber
#

Yeah

#

Gotta swap size and title though

naive goblet
#

don't

#

yeah

#

do

#

sry cant remember everything :i

worn fiber
#

No worries

#

That's done

naive goblet
#

now add a boolean method with a Inventory parameter

#

and make it return inventory == parameter

#

like this

#
public boolean compareTo(Inventory inv) {
  return this.inv = inv; 
}``` taking it as the private final Inventory field is named inv as well
#

You could also add a getter method

worn fiber
#

I named my private final field gui

#
    public boolean compareTo(Inventory inv) {
        return this.gui == inv;
    }```
naive goblet
#

thats right

#

add a getter for gui

worn fiber
#

What's wrong with directly accessing this.gui?

naive goblet
#

I mean essentially gui is final so we can't re assign it but it's generally better to encapsulate objects as it's oop principles and it's more maitainable

#

let's say another plugin uses that class and uses the variable by calling it directly

#

if you now would change name of that variable, their class would break also

worn fiber
#

Got it

naive goblet
#

a getter would prevent it

worn fiber
#

Just a simple public Inventory getGUI() { return this.gui; }?

naive goblet
#

yeah

worn fiber
#

Also this plugin is gonna be private too

naive goblet
#

yeah but it's not a bad practice

frigid ember
#

hi

worn fiber
#

Okay

#
    public boolean compareTo(Inventory inv) {
        return getGUI() == inv;
    }```
naive goblet
#

you don't have to use getGUI there

#

hi Fenzy?

frigid ember
#

how do you store an arraylist in a hashmap

#

please

naive goblet
#

HashMap<K, ArrayList<V>>

#

Though I'd recommend using a Multimap

frigid ember
#

that's the thing

naive goblet
#

?

frigid ember
#

i have no idea how they work

#

and i've searched

#

but ye

naive goblet
#

Multimap?

frigid ember
#

ye

worn fiber
#

What do I use getGUI() for then?

naive goblet
#

Can store more values against a single key

worn fiber
#

Something later?

naive goblet
#

yes outside the class

frigid ember
#

?

naive goblet
#

Fency

light orbit
#

ok I'm trying to use the buildtool thing, I put in the command, and it says I don't have the right amount of storage, but I have 1.4 terabytes on my computer

worn fiber
#

Okay, all done.

naive goblet
#

Fenzy for instance Multimap<String, Integer> can store both 1 and 3 for a single String

frigid ember
#

yes but how do i use it??

naive goblet
#

Multimaps.newMultimap I think

light orbit
#

hello?

naive goblet
#

Crazy what's your used storage maybe it's full

#

Felix create an ItemBuilder class

#

We'll use that to easier construct items

worn fiber
#

Can I copy the one I had before?

#
    protected ItemStack createItem(Material itemType, String name, String lore, int quantity) {
        ItemStack item = new ItemStack(itemType, quantity);
        ItemMeta meta = item.getItemMeta();

        // Set the meta name and lore
        meta.setDisplayName(name);
        meta.setLore(Arrays.asList(lore));

        // Apply the meta to the item
        item.setItemMeta(meta);
        return item;
    }```
light orbit
#

conc I have 1.4 terabytes free on my computer

#

I've used like 120 gb

naive goblet
#

felix nonono

#

that one is not good

worn fiber
#

Oh ok

naive goblet
#

Make this

light orbit
#

ok guys what do I do

worn fiber
#

🤷

naive goblet
#
public final class ItemBuilder implements Supplier<ItemStack> {

  private final Material material;
  private int count;
  private List<Consumer<ItemMeta>> meta;

  public ItemBuilder(Material material) {
    this.material = material;
    this.count = 1;
    this.meta = new LinkedList<>();
  }

  public ItemBuilder setCount(int count) {
    this.count = count;
    return this;
  }
  
  private ItemBuilder withMeta(Consumer<ItemMeta> meta) {
    meta.add(meta);
    return this;
  }
  
  public ItemBuilder setName(String name) {
    return withMeta(meta -> meta.setDisplayName(Utils.color(name)));
  }

  public ItemBuilder setLore(String lore, String... lores) {
    return withMeta(meta -> meta.setLore(Lists.asList(lore, lores).stream().map(Utils::color).collect(Collectors.toList());
  }
  
  @Override
  public ItemStack get() {
    ItemStack itemStack = new ItemStack(material, count);
    ItemMeta itemMeta = item.getItemMeta();
    meta.forEach(consumer -> consumer.accept(itemMeta));
    itemStack.setItemMeta(itemMeta);
    return itemStack;
  }
}```
#

that took some time sry

#

but now what you can do is something like this:

inv.addItem(new ItemBuilder(Material.DIRT).setName("Test").get());
#

.setLore() .setName() .setCount() is all optional

worn fiber
#

What was wrong with mybuilder?

naive goblet
#

It isn't a builder

#

Well you could make a method overloading system

worn fiber
#

It worked though

naive goblet
#

¯_(ツ)_/¯

worn fiber
#

And I understood what it did 👀

naive goblet
#

Okay well

#

I can make a simpler one

#

but the idea is to have one class for building items

worn fiber
#

I had that too

#

It was a method though

naive goblet
#

an instance method in your gui class

#

not in a seperate class

subtle blade
#

That's a lot of consumers

#

Looks wasteful

naive goblet
#

💩 .

subtle blade
#

oh dear

naive goblet
#

lmao

#

it's not that bad though

subtle blade
#

😄

naive goblet
#

yeah

#

but like lore(String... lore)

worn fiber
#

What is String...?

naive goblet
#

you could have it like (String str, String... lore)

#

var arg

#

essentially this

worn fiber
naive goblet
#

yeah

worn fiber
naive goblet
#

return withMeta(meta -> meta.setLore(Lists.asList(lore, lores).stream().map(Utils::color).collect(Collectors.toList());

#

change name of the param to consumer

#

instead of meta