#help-development

1 messages · Page 1353 of 1

wet breach
#

could you show your entire pom file?

stray halo
#

when i shutdown the server

paper viper
#

to compile your jar from target sources (and generate if necessary)

ivory sleet
#

pulse just help him ok thanks bye

rapid vigil
#
    public void onCommand(PlayerCommandPreprocessEvent e) {
        if(e.getPlayer().getWorld().getName() == "Lobby") {
            
        }
    }
}``` How do I check If the actual command that the player is using is "/hub" to cancel the event
paper viper
#

ok nevermind

#

this is too many people

#

im out

#

lmao

sacred sedge
paper viper
#

nope im just not going to bother to help anyone at all

#

lol

#

dont like being flooded

wet breach
#

@rapid vigil grab the message, it will contain the command plus the / in it

sacred sedge
wet breach
#

@eternal oxide could be a command of another plugin

rapid vigil
#

No

sacred sedge
rapid vigil
#

I made the command /hub

eternal oxide
#

Just makign sure its the right path to go down

rapid vigil
#

and in the same time I don't want people to be able to use it in the world Lobby

wet breach
#

@eternal oxide looks like you are right lmao

eternal oxide
#

ok, not the right path

wet breach
#

You don't need to do that

quaint mantle
#

hey i want to ask how do i reduce the 20mb size of my plugin when using maven bcz maven like imports every file i use

rapid vigil
#

oh okay,

eternal oxide
#

you add yoru command to your plugin.yml, then register it in code.

wet breach
#

you created the command, which means you can check where it is being ran from

eternal oxide
#

that way it will ONLY run your code when its your command

rapid vigil
steep nova
eternal oxide
#

you do that in your code

#

or easier, TYes you can

rapid vigil
#

ahhh

#

I understand now

#

Thanks for help.

eternal oxide
#

you assign a permission to the command

stray halo
#

bump

eternal oxide
#

thats all in your plugin.yml

#

only players with the permission can use the command

kindred solar
#

a...guys, the console is giving me this error: Fatal error trying to convert blahPlugin v0.1:me/f1nndev/blahblah/blabla.class org.bukkit.plugin.AuthorNagException: No legacy enum constant for MAGENTA_STAINED_GLASS. Did you forget to define a modern (1.13+) api-version in your plugin.yml?

eternal oxide
#

if the plugin is only intended for you, then yes

rapid vigil
#

I'm the one who made it ...

#

xD

eternal oxide
#

the correct way is to use permissions

quaint mantle
rapid vigil
kindred solar
quaint mantle
#

as i said

kindred solar
#

k

wet breach
quaint mantle
#

idk what is shade

wet breach
#

so your plugin is legitimately 20mb from all the stuff you coded?

lost matrix
#

You tried the IRegistry or using the PDC

quaint mantle
#

no

#

it isnt

#

this is my pom.xml

sacred sedge
#

lmao

wet breach
#

@quaint mantle can you remove that and use the past site please?

#

?paste

queen dragonBOT
quaint mantle
#

oh okay

lost matrix
#

A 20mb java project contains years worth of code

wet breach
#

that is why I asked lol

quaint mantle
wet breach
#

its not common to have a java project purely itself be 20mb

kindred solar
#

what's wrong with this if statement? ```java
if(interact.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase("§6§lMenu")

kindred solar
#

why

#

this is my method: ```java
@EventHandler
public boolean onPlayerUse(PlayerInteractEvent interact){

        if (interact.getAction() == Action.LEFT_CLICK_AIR || interact.getAction() == Action.RIGHT_CLICK_AIR) {
            if(interact.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase("§6§lMenu")) {
                interact.setCancelled(true);
                interact.getPlayer().openInventory(menuJogos);
        }
    }

    return true;
}
lost matrix
wet breach
#

@quaint mantle your issue is the jar plugin which can do a type of shading. It is always good practice to ensure all your dependencies have a scope tag on them to prevent accidental shading

#

second, most of those plugins don't need to be defined at all

quaint mantle
#

jar plugin?

wet breach
quaint mantle
#

oh it was there by default

wet breach
#

you can pretty much remove all those plugins if you don't use them

quaint mantle
#

in the <build>?

wet breach
#

it is only necessary to define them if you want to use them and if you have configurations set for them

quaint mantle
#

what is the an <scope>provided</scope>M

wide galleon
#

How can I code an admin gui(when you click on a players head it gives you options for what to do with the player)? i know how to make an interactive menu and how to make a playerhead appear in the menu, but i dont know how to make a menu for the clicked player

wet breach
#

it means the project won't attempt to shade it into the final jar

lost matrix
# kindred solar i ignore all warnings lol

That is not the way to go. If you fix all warnings you will remove 95% of all NullpointerExceptions
Cleaner Example:

  @EventHandler
  public void onPlayerUse(final PlayerInteractEvent event) {
    if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_AIR) {
      return;
    }
    final Player player = event.getPlayer();
    final ItemStack mainHandItem = player.getInventory().getItemInMainHand();
    final ItemMeta meta = mainHandItem.getItemMeta();
    if (meta == null) {
      return;
    }
    if (!meta.hasDisplayName()) {
      return;
    }
    if (meta.getDisplayName().equals("§6§lMenu")) {
      event.setCancelled(true);
      event.getPlayer().openInventory(menuJogos);
    }
  }
wet breach
#

and assumes it will be provided later

lost matrix
kindred solar
#

oh, like a const?

lost matrix
quaint mantle
wet breach
#

you have test, system, compile and provided

kindred solar
wet breach
#

compile means the dependency should be compiled into the project AKA shaded. but the tags are useless unless you specify certain plugins to be used by maven.

quaint mantle
#

so should i use <scope>provided</scope> for spigot-api?

wet breach
#

yes because spigot-api is already part of the spigot server

quaint mantle
#

okay

eternal oxide
#

You can easily answer that yourself. Do you think it will be available on the server your plugin is running?

quaint mantle
#

im sorry im just beginning with maven

wet breach
#

Anything that might not possibly be provided and isn't already a plugin as well should be something you should shade into your plugin and if you are going to do shading it is always best to do relocation on shaded artifacts.

#

This prevents conflicts with dependencies your plugin relies on, but some other plugin might also have(and didn't properly relocate such things themselves) or the user might be able to provide later. IE you shade another plugin into your project, but that plugin can be provided by the user.

quaint mantle
#

okay but like if i remove the spigot apis the size will drop to 8mb from 20mb

#

how do i fix that

#

i used the an provided scope tag

eternal oxide
#

You don;t fix it. That is correct

wet breach
#

8mb sounds a whole lot better then 20mb XD

quaint mantle
#

yea but i need those mavens bcz then the plugin will not work without it

#

Hi, I have a problem with a plugin I wrote. It is designed to give the player an axe when entering the game. This is not happening. The plugin works with all other items except axes.

    @EventHandler
    public static void onPlayerJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();

        ItemStack item = new ItemStack(Material.GOLDEN_AXE);

        player.getInventory().addItem(item);
    }

ERROR: https://imgur.com/a/FnFrVC7

eternal oxide
#

You only set a scope. You still have access to everything, its just not included in the final jar

quaint mantle
#

and that scope should be provided rightM

eternal oxide
#

yes

kindred solar
wet breach
#

for spigot-api yes

wet breach
#

however some of your dependencies is questionable and something we can't fully answer. So that is something you are going to have to determine with all the dependencies you have defined

quaint mantle
#

GOLDEN_AXE doesnt exist

quaint mantle
#

wait

#

what?

#

golden axe doesnt exists

#

so how can i give this item to player

#

in Material. there isnt golden axe possible

#

as it says

#

what version u using

#

1.12.2

#

I was using 1.14.4, but I changed it to this

#

use GOLD_AXE

weary geyser
#

How would you generate a method when an annotation is applied?

quaint mantle
#

when I use Material.IRON_SHOVEL it normally gives a shovel, it doesn't work only with axes

quaint mantle
#

Cannot resolve symbol 'GOLD_AXE'

wet breach
#

Normally you have a plugin tied to the build process that reads annotations and does this for you @weary geyser unless you are making your own annotation processor? o.O

quaint mantle
#

show me the code

#

it literally keeps deleting my messages

quaint mantle
lost matrix
# kindred solar and what about the warning that say that a method is never used?

It means that you never call that method. If you download the MCDev plugin for IntelliJ then those warnings get automatically suppressed for eventhandler and command methods.
If this warning is not shown by an eventhandler or command method and its not part of an API you want to expose then it means the whole method is useless because you never call it.

quaint mantle
#

well, the problem disappeared when I uploaded the spigot version again. Thanks a lot for your help! ❤️

#

okay

carmine ivy
#

Hey I'm trying to make particles when a player moves but it isn't working. Here's the code:

package Listeners;

import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

public class OwnerParticleTrail implements Listener {

    public void onPlayerMove(PlayerMoveEvent e){

        Player p = e.getPlayer();
        if(p.hasPermission("wolfpvp.owner")){
            if (!e.getFrom().getBlock().equals(e.getTo().getBlock())){
                World world = p.getWorld();
                world.spawnParticle(Particle.HEART, e.getFrom(), 3, 0, 0.5, 0);
            }
        }
    }
}
quaint mantle
#

add the an @brave glenHandler

#

f

#

@EventHandler

carmine ivy
#

lmao

quaint mantle
#

add this before the public void

carmine ivy
#

Poggers it works

quaint mantle
#

xD basic error

carmine ivy
#

Yeah I need to get better at this stuff lmao

quaint mantle
#

ahh dont worry i also forget sometimes

final fog
#

Happens to the best of us

#

dont worry about it

carmine ivy
#

Thanks guys

quaint mantle
#

youre welcome

kindred solar
#
        if (meta.getDisplayName().equals("§6§lMenu")) {
            event.setCancelled(true);
            event.getPlayer().openInventory(menuJogos);
        }
#

this keeps not opening my menu

quaint mantle
#

try this

#
        if (meta.getDisplayName().equals("§6§lMenu")) {
            event.getPlayer().openInventory(menuJogos);
            event.setCancelled(true);
        }
eternal oxide
#

are you using the InventoryClickEvent?

kindred solar
#

playerInteractEvent

quaint mantle
#

show the full code

kindred solar
#

?paste

queen dragonBOT
kindred solar
quaint mantle
#

in the main method use getServer().getPluginManager().registerEvents(this, this); instead of Bukkit.getServer().getPluginManager().registerEvents(this, this);

wet breach
#

essentially does the same thing

cinder thistle
#

they call the same stuff

wet breach
#

only difference is one uses the Static method and your suggestion uses the plugin instance instead

cinder thistle
#

they return the same server instance

#

yeah that

kindred solar
quaint mantle
#

well yea but why use bukkit in the getserver

kindred solar
#

cuz forums said XD

wet breach
#

I just stated the difference

#

they both do the same thing, one is static and the other way isn't

dusty herald
#

ASmonkagun im sorry what

wet breach
#

static method is needed in some cases but not always, but doesn't really matter which is used

quaint mantle
#

well yea

eternal oxide
#

@kindred solar put a sysout just before you attempt to open the inventory to see if your code gets that far

quaint mantle
#

@kindred solar try using final ItemStack mainHandItem = player.getInventory().getItemInHand();

kindred solar
quaint mantle
#

you tried to get mainhand item and not item in hand

eternal oxide
#

so its failing on the name match?

quaint mantle
#

no

#

he used different item

#

he tried to use the main item in hand not get item in hand

eternal oxide
#

his hand code is fine

quaint mantle
#

i mean it works for me

kindred solar
quaint mantle
#

what ver you using

eternal oxide
#

use stripColorCodes and then check

#

The string you are passing is not encoded for color so it will not match

kindred solar
quaint mantle
#

what server version u using

eternal oxide
#

§6§l are characters that get encoded to orange and bold, but they don;t look like that when encoded

dusty herald
#

1.15.5?

kindred solar
#

no

#

i mean

#

1.16.5

#

ups

eternal oxide
#

the string you are getting from your item is probably already encoded

wet breach
#

@kindred solar you should use the api methods to apply colors to certain things. It is bad to use the super script symbol directly and causes problems most of the time.

kindred solar
eternal oxide
#

Either strip colors or encode your string to compare

wet breach
#

be easier to just strip the color codes there is an api method for that

eternal oxide
#

ChatColor.

eternal oxide
#

so ChatColor.stripColor(meta.getDisplayName()).equals("Menu")

dusty herald
#

What I usually do is make a custom Inventory class and check if the inventory is an instance of that class

wet breach
#

Well they are on the part of checking for specific item

#

and if that specific item is used, it opens the custom inventory

dusty herald
#

ohh

eternal oxide
#

I gave you the code to use

kindred solar
#

ik

#

but more i learn better

eternal oxide
#

One thing at a time. Does it work now?

wet breach
#

What they were talking about is when you want to ensure the inventory being used is indeed the custom inventory and not some other inventory

#

but that isn't your problem at the moment though

kindred solar
kindred solar
sharp bough
#

why does this cancel the event? i cant manipulate the players inventories as a normal chest?

        if (!(sender instanceof Player)) {
            sender.sendMessage("You can't run this command in the console!");
            return true;
        }
        Player player = (Player) sender;
        if(CheckPermission.checkPerm("essentials.invsee",player)){
            if(args.length == 0){
                player.sendMessage("To use this command, run: invsee [Player]");
            }
            else{
                Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
                Inventory targetInv = targetPlayer.getInventory();
                player.openInventory(targetInv);
            }
        }```
eternal oxide
#

you could do the reverse and instead encode your string to test ChatColor.translateAlternate

sharp bough
#

normally i would make an event listener to cancel the event

#

but in this case it cancels it self?

#

this Player target = Bukkit.getPlayer(args[0].trim()); int id = Integer.parseInt(args[1]); int amount = Integer.parseInt(args[2]); ItemStack item = new ItemStack(id,amount); target.getInventory().remove(item); target.updateInventory();
is the closest thing i found

kindred solar
sharp bough
#

but i dont want to make it with a command, i want to edit it irl

sharp bough
cinder thistle
#

then why call it an event

sharp bough
#

because then you move the players itemstack then you have an event

#

but only opening it is not an event

#

what i mean is, i can open the inv of the player, but i cant edit the item stacks in it

cinder thistle
#

I c

ancient whale
#

Hey does anyone know why titles are not showing on lunar client ?
It's working well on the Minecraft launcher (1.8.8)

IChatBaseComponent chatTitle = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + "Ayyy test" + "\",color:" + ChatColor.GOLD.name().toLowerCase() + "}");

PacketPlayOutTitle title = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, chatTitle,20,80,20);

((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
minor garnet
#

why packets

sullen dome
#

maybe dumb question, but how would i listen to a logger? lol, never used loggers before that much, only used like Logger.log() and thats it lol

carmine ivy
#

I'm trying to use a compass for my lobby compass but everytime I right click it teleports me. How do I get rid of it

quaint mantle
#

in a worldedit config

carmine ivy
#

Brb

quaint mantle
#

set navigation-wand.max-distance to 0

carmine ivy
#

Thanks

quaint mantle
#

or -1 it should work both ways

carmine ivy
#

It worked!

quaint mantle
#

nice xD

upper zodiac
#

would anyone know why my schematics arent pasting when using the fawe api? i have the right file and everything, but when i run the method to paste it nothing happens. no errors, no nothing. just not pasting. https://paste.md-5.net/daxixoxaqu.java is my code for pasting the schematic.

kindred solar
#

guys, how do i fix this warning? 'ItemStack(org.bukkit.Material, int, short)' is deprecated

eternal oxide
earnest fractal
#

Hi! I would like to check if a player inventory is completely empty, but I am not finding the proper way to do it since checking for null on each ItemStack is not working . Any advise?

kindred solar
#

what's the method to dont let the player change the slot of an item in the inventory that i created? isnt it event.setCancelled(true); ?

sullen dome
wet breach
#

I see you noticed 😉

eternal oxide
#

I was distracted 🙂

sullen dome
#

ah lol there's even a isEmpty method lol, nvm

wet breach
#

and even if there wasn't

#

there is a getContents() method which gives you an array

#

which you simply could check if that was empty

sullen dome
#

i had in mind that i had to check for like every slot... idk why tho

wet breach
#

That used to be the case long time ago

fathom timber
#

Whats a good api for making a inventory (gui)?

wet breach
#

like 1.5 versions time

sullen dome
#

lol

upper zodiac
fathom timber
#

On GH or spigot website?

wet breach
#

There is actually quite a lot

upper zodiac
wet breach
#

just going to have to go through them and pick the one you like

upper zodiac
#

i use it, its really good

wet breach
#

overall, creating your own GUI though isn't all that difficult

upper zodiac
#

yea, just annoying to make things like auto updating guis

#

(ones that read from variables and update when you clcik it)

fathom timber
#

Oh

kindred solar
#

omg, idk what is but i think bukkit doesnt want to me to program it, at few minutes this code was working, now isnt anymore

#
    @EventHandler
    public void onPlayerUse(PlayerInteractEvent event) {
        if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_AIR) {
            return;
        }
        final Player player = event.getPlayer();
        final ItemStack mainHandItem = player.getInventory().getItemInOffHand();
        final ItemMeta meta = mainHandItem.getItemMeta();
        if (meta == null) {
            return;
        }
        if (!meta.hasDisplayName()) {
            return;
        }
        if (ChatColor.stripColor(meta.getDisplayName()).equals("Menu")) {
            event.getPlayer().openInventory(menuJogos);
        }
    }
quaint mantle
#

where is the item you want to click located ?

kindred solar
#

in the hand

eternal oxide
#

getItemInOffHand()

quaint mantle
#

you set the item in offfhand?

#

then its not gonna work

eternal oxide
#

you changed it from Main hand to Off hand

quaint mantle
#

no?

kindred solar
#

main hand wasnt working

eternal oxide
#

main hand is what was working

quaint mantle
#

which version u using

kindred solar
#

1.16.5

quaint mantle
#

okay lemme try

kindred solar
#

nvm

#

guys

#

im dumb

#

it wasnt working on main hand so i changed to off hand and i tried in the other hand and its working

#

how do i check the name of the inventory in "InventoryClickEvent"?

eternal oxide
#

getView()#

kindred solar
#

doesnt exist

eternal oxide
#

event.getView().

kindred solar
#

ah k ty

eternal oxide
#

name is under that

kindred solar
#

but my inventory has a name with a color, is there any problem?

eternal oxide
#

strip colors or translate

kindred solar
#

im making this if

#
if(ChatColor.stripColor(event.getView().getTitle().equals("Modos de jogo!")))
eternal oxide
#

) in the wrong place

kindred solar
#

nvm

eternal oxide
#

delete one from the end and put it after getTitle()

kindred solar
#

ikik

#

but ty

ancient whale
# minor garnet why packets

Is there an other way ? I checked on the web, found one guy doing it differently, using player#spigot#sendMessage, but can't manage to make it work, But splitting the PacketPlayOutTitle in 2 object, one with the length and the other with the title actually works 😄

minor garnet
#

player.sendTitle i think ?

lost matrix
ashen flicker
#

The ancient version LOL

south onyx
lost matrix
#

If people would learn to read stack traces and fix all warnings their IDE gives them then we would have 95% less of: "Plz Help" + plonks down NPE

minor garnet
lost matrix
south onyx
#

ok

#
CompassMeta cm = (CompassMeta) e.getPlayer().getInventory().getItemInMainHand().getItemMeta();
                    cm.setDisplayName(ChatColor.GREEN + "Tracking Compass");
                    cm.setLore(Main.getInstance().lore);
                    cm.setLodestoneTracked(false);
                    cm.setLodestone(playerTracked.getLocation());
                    e.getPlayer().getInventory().getItemInMainHand().setItemMeta(cm);
                    e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Tracking: " + playerTracked.getDisplayName() + ", Distance: " + Math.round(locationDistances.get(playerTracked))));
#

its the first line

lost matrix
south onyx
#

ok

#

btw i checked if their holding a compass in their main hand

#

so idk why it won't work

lost matrix
#

Pls post the method that contains this line

south onyx
#

ohh ok

eternal oxide
#

err

lost matrix
#

...

eternal oxide
#

I was confused with all the Main 🙂

lost matrix
#

Im still deciding if i want to read it or just tell you to extract that code into at least 4 more methods...

south onyx
#

sorry, ik my code isn't that good

eternal oxide
#

this test is going to fail bad java if (e.getPlayer() == Main.getInstance().imposter && e.getPlayer().getInventory().getItemInMainHand() == Main.getInstance().blindnessStick && e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {

south onyx
#

should i separate it into multiple if statements?

eternal oxide
#

the last two tests shoudl be in ()

south onyx
#

ok

uncut elm
#

Hello, I was wondering how I would go about getting a custom plug-in developed for my server

eternal oxide
#

?services

queen dragonBOT
south onyx
eternal oxide
#

same for line 20

#

then try yoru code again

south onyx
#

ok

eternal oxide
#

it still won't work

#

but you may not get the npe anymore

south onyx
#

ok

#

but how do i get it to work?

eternal oxide
#

um, honestly I'd rewrite the whole thing. Sorry but thats my opinion 😦

south onyx
#

screw it imma delete it

eternal oxide
#

ok, first a few suggestions.

#

Don;t store player object, store their UUID (getUniqueId)

lost matrix
# south onyx should i separate it into multiple if statements?

This is how a clean up could look like:

  private boolean isBlindessStick(ItemStack itemStack) {
    return Main.getInstance().blindnessStick.equals(itemStack);
  }

  @EventHandler
  public void onPlayerInteract(final PlayerInteractEvent event) {
    Main plugin = Main.getInstance();
    Player player = event.getPlayer();
    ItemStack playerHandItem = player.getInventory().getItemInMainHand();

    if (!plugin.isImposterActive() || !isBlindessStickSet()) {
      return;
    }
    ... and so on

Take it slow. Create new variables. Return early. Create new methods. Never exceed the line limit. And dont ever use single character variables like 'e' or 'p'

ancient whale
south onyx
#

nope

#

deleting it

quaint mantle
#

yo it works

opal juniper
#

wait, how lmao

quaint mantle
#

that's cool

eternal oxide
#

wth, how?

opal juniper
#

is it when you upload a file?

quaint mantle
#

Discord added a feature where you can upload .java files to discord and it will do that ^

#

yes

opal juniper
#

does it work with other languages like .... .py?

quaint mantle
#

try it out

#

yes

opal juniper
#

nice

eternal oxide
#

ah, it would be nice if they added that to `` 1java

opal juniper
#

that is a point @eternal oxide

kindred solar
#

guys, how do i teleport a player to a specific location?

#

and what do i put inside this -> ()?

quaint mantle
#

world, x, y, z

#

pitch and yaw are optional

#

bruh

kindred solar
kind coral
#

is it good to make a class abstract to get its "Instance" i have more methods in this class.

quaint mantle
#

why did you give it a string

#

I said world

eternal oxide
#

?jd use the search function top right for teleport

eternal oxide
#

javadocs are your friend

quaint mantle
#

@kindred solar

#

try that

eternal oxide
#

you'll suffocate, but it would work 🙂

kindred solar
quaint mantle
#

feed it the correct world then

eternal oxide
#

Bukkit.getWorld(namehere)

kindred solar
quaint mantle
#

Then for player.getworld set that the world you want to teleport them so Bukkit.getWorld(world)

eternal oxide
#

or player.teleport(Bukkit.getWorld("worldname").getSpawnLocation());

quaint mantle
#

^ That also works.

kind glacier
#

Can someone help me

eternal oxide
#

?ask

queen dragonBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.

kind glacier
#

ok

#

so I want to make the chat color dark orange

#

but it's not working

lost matrix
kind glacier
#

no

quaint mantle
#
public class GameWindow extends JFrame {
    public GameWindow(MainWindow mainWindow) {
        setName("2v2 Fight");

        var button = new JButton("Exit");
        Dimension dimension = new Dimension(40, 40);

        button.setPreferredSize(dimension);
        button.setMaximumSize(dimension);

        button.addActionListener(e -> {
            mainWindow.setVisible(true);
            setVisible(false);
        });

        add(button);
        setSize(600, 600);
    }
}

its not making the button any size

#

it keeps matching the window size

eternal oxide
#

your frame probably needs a layout

lost matrix
kind glacier
#

Player player = thisistheeventinstance.getPlayer();

player.sendMessage(ChatColor.DarkOrange + "hello");

quaint mantle
#

that doesnt work lol

eternal oxide
#

"" + chatcolor...

#

it has to know its a string before it can process the ChatColor

lost matrix
kind glacier
#

so I put the string before now

#

so it can process

eternal oxide
#

no

#

just an em,pty strign will do

kind glacier
#

but i want it to say hello

lost matrix
kind glacier
#

not nothing

eternal oxide
#

player.sendMessage("" + ChatColor.DarkOrange + "hello");

kind glacier
#

ohhhhhhhhhhhhhhhhhhh

lost matrix
eternal oxide
#

else you have to use ChatColor.DarkOrange.toString()

#

it does

lost matrix
#

This implicitly calls ChatColor.GOLD.toString()

kind glacier
#

THERE IS NO DARK ORANGE

#

I HAVE TO USE GOLD

#

STUPID SPIGOT

eternal oxide
#

Lets see if he reports it as working 😉

kind glacier
#

this is why

lost matrix
kind glacier
#

I prefer craftbukkit over spigot

kind glacier
eternal oxide
#

CB is in Spigot

kind glacier
#

i'm pretty sure htey are two different companies elgar

#

there is bukkit company and there is spigot company

#

and they are like rivals

#

I think

eternal oxide
#

nope

lost matrix
kind glacier
#

so then should I be mad at notch and jeb and dinnerbone

#

for hard coding

lost matrix
kind glacier
#

why did it die

#

thats very sad

#

its so good

#

like you can do so much stuff (besides color 😠 )

lost matrix
lost matrix
#

Spigot provides the whole craftbukkit API

eternal oxide
#

as for the concatenation thing. If you don't start with a string it attempts to serialize the object

lost matrix
# eternal oxide as for the concatenation thing. If you don't start with a string it attempts to ...

Makes no sense to me. Concatenation is a pure Java thing.

This:

public class SandboxCore {

  public static void main(String[] args) {
    String concat = SomeEnum.WEST + " some other Text";
    System.out.println(concat);

    System.out.println(SomeEnum.NORTH + " Some more Text");
  }

  public enum SomeEnum {

    NORTH,
    SOUTH,
    EAST,
    WEST;

    @Override
    public String toString() {
      System.out.println("CALL");
      return super.toString().toLowerCase();
    }

  }

}

Results in:

CALL
west some other Text
CALL
north Some more Text

Process finished with exit code 0
eternal oxide
#

yep, try it with Chatcolor and Spigot

lost matrix
#

Concatenation order does not matter. Only if the value is a primitive

lost matrix
eternal oxide
#

I definitely remember this being an issue, I don't remember when though.

lost matrix
#
  @Override
  public void onEnable() {
    final String welcome = ChatColor.AQUA + "Hello";
    Bukkit.getPluginManager().registerEvents(new Listener() {
      @EventHandler
      public void onJoin(final PlayerJoinEvent event) {
        event.getPlayer().sendMessage(welcome);
        event.getPlayer().sendMessage(ChatColor.GOLD + "More Hi");
      }
    }, this);
  }
eternal oxide
#

I guess I'm wrong. One of those mandella effect moments I suppose

lost matrix
#

I get you

vital ridge
#

Is entitytarget event bugged for the newer mobs like hoglins & zoglins?

#

Im cancelling it, it cancels at first, but if i hit the mob he still starts targeting me

kindred solar
#

some1 help me plz, when a player joins im getting this error: Could not pass event PlayerJoinEvent to blahPlugin v0.1 org.bukkit.event.EventException: null

vital ridge
#

no other mob does that

lost matrix
#

So more null checks

kindred solar
vital ridge
#
@EventHandler
    public void onWrongTarget(EntityTargetLivingEntityEvent e) {

        if (main.getConfig().getBoolean("hostile-mobs-attack") == false) {

            if (e.getEntity() instanceof Hoglin) {
                if (e.getTarget() instanceof LivingEntity) {
                    
                    e.setCancelled(true);

                }
            }

        }

    }

thats my code

#

That works at first, so hoglin wont attack me first as it normally does, but if i hit him once, he immediately starts attacking me

#

but other hostile mobs wont and work fine

#

So I assume its bugged for newer mobs?

kindred solar
eternal oxide
#

the stacktrace you have will say what line the NPE occurred on

#

stacktrace being the spam that said null

kindred solar
#

wdym

eternal oxide
#

the error you got in game (in the log)

#

its called a stacktrace.

#

you need to read that and find the first mention of YOUR code

#

it will tell you a line number and the class the error occurred in.

kindred solar
#

1 min

sacred phoenix
#

How can I make it so that when you run a command and put in args player names are not popping up in the list of possible args how can I change player names to a list of blocks

wet breach
wet breach
#

the standard used is the ANSI colors

somber hull
#

If anyone know 1.12 nms hit me up

#

Im super confused

real vapor
#

?ask

queen dragonBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.

somber hull
#

bruh

#

people just yelled at me for that

#

Im not asking to ask

kind glacier
#

?ask

somber hull
#

Im asking if anyone knows how to use NMS

#

anyway

#

i want to make a zombie with around 1k HP, some armor that is just for looks, give it speed 2, and make it drop a different item.

#

How

kindred solar
#

how do i check if a command was executed in a specific world?

onyx shale
#

doesnt 1.12 have the attribute api?

somber hull
#

When they execute the command

#

sender.getwrold or smthng

kindred solar
#

tyty

somber hull
#

@kindred solar you would do sender.Location or smthng, then location.getworld

onyx shale
#

seems 1.12 does have attribute api already

#

so you dont even need nms

#

to change a entity max health

wet breach
#
Player player = (Player)sender;
#

is all that is needed

#

then you can just player.getWorld();

onyx shale
#

for armor? LivingEntity has getEquipmet where you can set everything about the entity,main hand/offhand and armor

kindred solar
eternal oxide
#

no

onyx shale
#

getWorld returns a World instance

eternal oxide
#

getWorld().getName().equals

kindred solar
#

ah k tyy

somber hull
#

?

onyx shale
#

health using the attribute api,LivingEntity.getAttribute...generic max health...setbase value then set its health

#

armor? LivingEntity.getequipment then fire away

somber hull
#

Oh, yea i figured that out

vocal cloud
#

Yeah you don't need NMS

somber hull
#

What is the purpose of NMS

#

like when would you need to use it

onyx shale
#

indepth changing

#

pathfinding

#

custom logic

eternal oxide
#

last resort

onyx shale
#

want a zombie to teleport like a enderman? thats nms

vocal cloud
#

When you want to control aspects of the game that aren't in the API

ivory sleet
#

When the api does not expose something that may only be accessible with nms

onyx shale
#

mostly pathfinding being the usual one

#

atm

ivory sleet
#

It is mostly used in legacy versions as the api wasnt as feature rich like it is nowadays

abstract relic
#

I used nms

kindred solar
abstract relic
#

to reimplement bees

#

to be a bit more interesting

#

built bee ai from the ground up

onyx shale
#

@kindred solar what exactly is the final goal

abstract relic
#

comparing strings

#

is better than comparing worlds

#

yes

onyx shale
#

depends..

quaint mantle
#

Hey there,
Is it possible to implement path finding for EntityPlayer in NMS?

kindred solar
ivory sleet
#

I mean why

abstract relic
#

what

#

yes it is

onyx shale
#

people always think they can go the easy way to create a npc that way

abstract relic
#

wait no it isnt

#

i think

onyx shale
#

entityplayer lacks alot of stuff needed for pathfinding

abstract relic
#

we use a custom thing at work

#

mb

onyx shale
#

as it shouldnt be a thing

quaint mantle
# onyx shale nope

So basically there is no way of doing this? or I'm thinking wrong cuz I see some people using human npc for their plugin to follow a player

onyx shale
#

thats packets

#

basically you have to fully manage that said npc

#

constantly refreshing

#

what he does

#

he follows a player?you have to keep track of the current location,the new location it should be at,update the packet so it looks like it moved,while also updating the animation packet to simulate walking/running

#

alot of shit...

#

you can always "inspire" from citizens

quaint mantle
#

I used fake Network Manager to create many human npcs and they work perfectly and they spawn and nothing is wrong with that and I used world.addEntity(playerentity) for adding the npc to the world so it can easily interact with the environment.

onyx shale
#

yes

quaint mantle
#

but seems I cannot use goalFinder in EntityPlayer class

onyx shale
#

that will spawn a player being useless

quaint mantle
#

cuz it doesn't exist

onyx shale
#

yes entityplayer

#

does not have these

#

as it shouldnt

#

its not a ai based entity

quaint mantle
#

so the best way is to make an another entity which is not player like zombie, then shape it like a human and then disguise it as a human player and using path finders right?

onyx shale
#

you could using some libs

#

but you need to keep an eye on performance

#

just to be sure

quaint mantle
#

citizens navigation and pathfinding was not really complete and perfect

onyx shale
#

you are not the only one

#

most people get hit by the implementation after thinking of some good logic

#

e.q bandits/hostile npcs on adventure servers or shit

quaint mantle
ivory sleet
#

popo

kindred solar
#

what's the difference between build and rebuild (when build artifacts)?

opaque mango
#

don't use IntelliJ artifacts, use a proper build system: Maven or Gradle

eternal oxide
#

Build builds any changed files. rebuild builds all files, changed or not

opaque mango
#

I love ghost pings

#

thanks

kindred solar
#

lol sry

rose tundra
#

How can I verify that there are no blocks in a location?

unborn heart
#

Get the block, see if it's air

#

There is never "no block" at any location

#

There is at least air.

kindred solar
#

what's the color code for brown? does some1 know?

dusty herald
#

unless you delete the air

#

what happens if you delete the air?

eternal oxide
#

ChatColor.

kindred solar
#

ah k ty

eternal oxide
#

you can;t delete air

dusty herald
#

delete the air

eternal oxide
#

AIR is a block, it has no delete method

kindred solar
rose tundra
main dew
#

Plugin orebfuscator load (but I remove this plugin with folder plugins)

unborn heart
#

Yes, but personally I prefer guard clauses.

#

i.e. if (!q.getType() == Material.AIR) return;

main dew
unborn heart
#

err

#

!= not !q

#

Brain dead lol

main dew
eternal oxide
#

use gold or use teh bungee chatcolor for Hex colors

kindred solar
#

k ty

kindred solar
eternal oxide
#

delete your spigot import and choose the md_5 one when offered

distant fern
#

Hi. Why my if doesnt work?

if(p.getInventory().getItemInMainHand().equals(Material.WHEAT)){

eternal oxide
#

import net.md_5.bungee.api.ChatColor;

kindred solar
dusty herald
eternal oxide
#

to replace your bukkit import

kindred solar
eternal oxide
#

no

distant fern
#

What the if should look like

dusty herald
#

getItemInMainHand().getType() == Material.WHEAT

unborn heart
#

You should null check that

#

Don't hang methods off things that could be null

kindred solar
distant fern
dusty herald
#

you didn't add the getType()

eternal oxide
#

so long as you removed the bukkit chatcolor import

distant fern
#

a ok

kindred solar
minor garnet
#

?paste

queen dragonBOT
vital ridge
#

Does anyone know if entitytargetevent is bugged for newer mobs? Like zoglin & hoglin. Im canceling the targentevent for them, it works at first, but if i hit the hoglin he still starts to attack me. The code works perfectly for other mobs but not for zoglins & hoglins

#
@EventHandler
    public void onWrongTarget(EntityTargetLivingEntityEvent e) {

        if (main.getConfig().getBoolean("hostile-mobs-attack") == false) {

            if (e.getEntity() instanceof Hoglin) {
                if (e.getTarget() instanceof LivingEntity) {
                    
                    e.setCancelled(true);

                }
            }

        }

    }
eternal oxide
#

You are modifying something Async

quaint mantle
#

Hello! I've been trying to set a max amount of allowed chests to be opened per player but I don't seem to get it right, I've tried a lot of things and it's gone horribly wrong...Anyone here know how I can do this?

minor garnet
eternal oxide
#

yes

unborn heart
#

What do you mean, do you mean like they can only open 5 chests at all within a certain time? Where do you mean ever? Are you referring to special chest, or chest in general?

quaint mantle
unborn heart
#

You can create a map with key uuid and value integer, then every time they open the chest you would check if the stored integer is that the max amount, and if it is yell at them and cancel the event. If it is not, increment it.

#

Just be sure to jump the map to config at shut down, and populate on load. Also don't forget to clean the map when the player logs out.

#

Dump not jump, damn speech-to-text haha

#

Are you going to let them ever reset their counter? You'd want to code in some logic for that as well.

quaint mantle
#

Yeah, it's a minigame ish thing so when the round ends, it resets I guess and when a new round starts, it starts to count again

unborn heart
#

Ah, that's good, that makes it easy to do then.

#

Also in your code, I would not hard-code your limits. I see people in the forums all the time hard coding stuff like that. You're much better off to pull that stuff from config, so if you decide later to change how it works you don't have to recompile your plug-in.

minor garnet
wet breach
#

Just use an expiring cache hashmap and problem solved

#

and yes, make it a configurable option to change the amount of chests that can used.

unborn heart
#

I'm not familiar with that, is that a special type of collection with a built-in time?

quaint mantle
wet breach
#

You can make it expire at a specified time, which means you don't really have to worry about clearing the map yourself and then creating the entire thing again

#

its part guava which is shaded into spigot 🙂

#

so nothing new needs to be added

unborn heart
#

That's pretty cool. Nice.

wet breach
#

you can even make the cache expire for other reasons

#

like if it gets written to, it expires it or expire on read etc

#

and then if it does expire

#

you can set it to refresh itself

#

IE, recheck configs to see if them chest counts should be increased

#

or if its expired instead of nulling out or throwing NPE's lets create the new object and put it back in the cache

#

many many things you can use it for and super handy a lot of the times

quaint mantle
#

Okay, thank you to both of you for helping!

wet breach
#

one of these days I will specifically do youtube videos of The more you know with plugin coding

#

and everyday it will just be something new it brings up that a lot of people are just not familiar with

somber hull
#
        public Entity spawnBossEntity(Location loc) {
            Zombie bossEntity = loc.getWorld().spawn(loc, Zombie.class);
            if (plugin.getConfig().contains("bosshealth")) {
            long bossHealth = plugin.getConfig().getLong("bosshealth");
            bossEntity.setMaxHealth(bossHealth);
            bossEntity.setHealth(bossHealth);
            }else {
                plugin.getLogger().log(Level.SEVERE, "BossHealth is missing in config... Setting to 1000...");
                plugin.getConfig().set("bosshealth", 1000);
                bossEntity.setMaxHealth(1000);
                bossEntity.setHealth(1000);
            }
            return bossEntity;
        }
#

how do i apply NBT to this entity

#

1.12

#

I want to apply it, then check for it later

lost matrix
#

PDC was 1.13+ right?

#

Then you need NMS

wet breach
#

metadata was a thing before that

lost matrix
wet breach
#

only difference from then and now is that it didn't persist

somber hull
#

So do i have to redo the entity stuff in NMS?

wet breach
#

depends what you are comfortable with doing

lost matrix
somber hull
#

Ok

wet breach
#

If you don't want to use NMS, then its just a matter of you tracking that information between restarts and re-applying it yourself

lost matrix
# somber hull Ok

EntityLiving nmsLiving = ((CraftLivingEntity) entity).getHandle();

kindred solar
#

guys i was with 2 players on the server but the scoreboard wasnt updating the online players

somber hull
#

7smile i gtg ill work on this later. thanks for the help ill write that down

kindred solar
lost matrix
wet breach
#

You have to destroy and recreate the scoreboard if I remember correctly

#

to update custom stuff on scoreboards

kindred solar
#

but my friend joined and for him i think it was 2 players and for me was only 1

lost matrix
wet breach
#

If the item you are trying to update isn't something native to scoreboards to keep track of, yes

#

its a pain sometimes

unkempt peak
#

So i am using a method to reset a map for a minigame by deleting the world file and making a copy from a source world file that is the unmodified map. It works fine the only issue is i get an error when i try to reset it and nobody as been on the source world to load it.

The process cannot access the file because another process has locked a portion of the file

how do i stop this from happening?

wet breach
#

you need to unload all the chunks

#

or simply unload the world

#

before removing the world

sour rampart
#

when i have

if (player.getWorld() == World.Environment.THE_END) {

    }

it gives me the error: Incompatible operand types World and World.Environment
How do i fix this? PS: I'm new to java

unkempt peak
#

the error isn't when deleting the world it's when copying from the source world@wet breach

wet breach
#

then your problem lies in the copying code

#

somewhere you are returning objects involved with it, and thus locking up the files

unkempt peak
#

but it works fine if i go to the source world before resetting the map.

wet breach
#

what do you mean if you go to the source world?

#

are you saying you have the source world loaded into the server ?

unkempt peak
#

yes

wet breach
#

that is your problem

unkempt peak
#

do i need to unload it?

wet breach
#

never load the source world, just keep it in a directory

unkempt peak
#

ok

wet breach
#

and then just copy files you need, load the new world and only the new world

#

then you won't have problems with file locking

#

also to avoid waiting on world deletion

#

create a method to create a new ID every time you make a new world

#

and have people join that new world, this way the server doesn't have to rush to delete old worlds 🙂

unkempt peak
#

well it deletes in like 4 ticks so it's not much of an issue currently but ill keep that in mind

wet breach
#

example. lets say your source world is named tagworld. Everytime you copy that source world to a new directory to load for the server, append it with a random ID

#

@unkempt peak currently not an issue

#

but when you have 4-5 games going at the same time, why waste cpu resources deleting worlds that can be done at the end of the day

#

only concern is HDD space lol

unkempt peak
#

that's true

#

i might implement it later if i see any preformance issues

#

thanks for the help

wet breach
#

and the deleting of the worlds doesn't need to be done from plugin

#

you can totally make a bash script to handle that

#

thus further not impeding the mc server 🙂

#

the more things that don't need to be done in the MC server itself the better 😉

#

and then to further help with the task, set the bash script as a cron job to run at whatever intervals you specify lol

sour rampart
#

when i have

if (player.getWorld() == World.Environment.THE_END) {

    }

it gives me the error: Incompatible operand types World and World.Environment
How do i fix this? PS: I'm new to java

wet breach
#
if(player.getWorld().getEnvironment() == World.Environment.THE_END) { }
unkempt peak
#

yeah currently the way im doing is i have minigame-mapname as the source world and then to run multiple games it just automatically creates 3 copies and then to reset a minigame it deletes minigame-mapname-1 and copies minigame-mapname to minigame-mapname-1

opal juniper
#

?jd

opal juniper
wet breach
#

the way I did it for a fairly large MC network, was to create a 6 digit ID for the new maps, which was usually just the time in 24 format plus the day. Had a bash script that ran every 6-8 hours that would check these digits against the current day and time. If it was old it deleted it. Bash script was configured based on how many games were allowed to be running at one time and thus would leave that many worlds.

opal juniper
#

oh, bit late lmao

unkempt peak
#

thanks

wet breach
#

super easy and super easy creating the cron job too

#

and good news, there is plenty of tutorials to do both

unkempt peak
#

yeah should be pretty easy to learn

cloud berry
#

guys which of these is more efficient method for updating player data on database?
a) update data per-variable every time something changes
b) make a timer that loops through loaded players every few seconds and updates entire player records at a time (those that have changed at least 1 thing)

keep in mind all db activity is async ofc, also i may be using more than 1 layer of database (ideally redis + mysql but just mysql for now)

sullen marlin
#

Depends how often things change

cloud berry
#

that makes sense

sullen marlin
#

The one that happens the least will probably be the fastest

ivory sleet
#

I know luckperms use a daemon task to update everything every 30 seconds or so

cloud berry
#

ty md_5 😄

wet breach
#

@cloud berry could use expiring cache for this. When cache expires you can have it update the DB before it completely removes object from cache.

cloud berry
wet breach
#

not sure how that would be different with your loop

#

if the server crashes nothing is going to save lol

ivory sleet
#

LEOcab I know guava has some cool loading caches but maybe try caffeine (altho needs shade and prob relocate also)

cloud berry
#

well true i guess its the same thing xD

wet breach
#

with the cache you can just have it expire if the object hasn't been touched

ivory sleet
#

^

wet breach
#

this way you are not keeping things in memory that really just haven't been used

#

if it is needed it can easily load it if its not in the cache

ivory sleet
#

It also has async caches but normally you wanna handle that yourself

cloud berry
#

oh actually i did plan on having a cache, i just havent gotten to that part yet ;-;

wet breach
#

Guava, Apache, Caffeine and few other libs have expiring caches 🙂

#

use the one you are best comfortable with really

real vapor
#

Just use Guava, already bundled in 🙂

cloud berry
#

ohhhhhh i see how this works

#

more dedicated solution than runnables lol

wet breach
#

yes

ivory sleet
#

yeah I just like caffeine as it removes the throws declaration as opposed to guava iirc and uses interfaces instead of abstract classes

cloud berry
#

ill be using these instead of runnable for the cache xD ty guys 😄

wet breach
#

technically a runnable is used, but these are more efficient, cleaner and easier to use for such things.

ivory sleet
#

it kind of abstracts away the work you would otherwise have to implement yourself in a good way

cloud berry
#

this might get complicated cause its a two-way cache :I

server <-> database <-> server

wet breach
#

^

#

what Conclure said

ivory sleet
#

what is the database btw?

cloud berry
wet breach
#

combine this with redis

cloud berry
wet breach
#

if you don't want to worry about the logic of saving to a DB

#

this way you can make your cache only worry about redis, and redis handles the fetching/saving to DB 😄

cloud berry
ivory sleet
#

leocab hmm so you use redis but what type of persistent database?

wet breach
#

going to assume the standard SQL DB stuff

cloud berry
#

redis for speed, sql for persist

#

jooq for sql

ivory sleet
#

hmm okay

wet breach
#

not only speed, but to handle some logic of the loading/unloading you won't need to program 😉

cloud berry
#

i literally aint even got started wit redis yet ;-; jooq way easier than i thought it would b doe

ivory sleet
#

what lib do u use for redis btw

#

if you use any

cloud berry
#

idek which ones there r ;-; i just picked it cause several ppl recommended it lol, i just did some basic research on it so i just kno the basics of how it works

#

do u know a good 1?

ivory sleet
#

lettuce

#

it has an asynchronous api as opposed to smtng like jedis

cloud berry
#

😮

#

omg yes i super need async

ivory sleet
#

or "api" more like it better helps you deal with multithreading stuff

wet breach
#

you mean jredis @ivory sleet ?

viscid cave
#

Is it possible to host a functional discord bot on a Minecraft Plugin?

wet breach
#

yes

ivory sleet
#

oh yeah

#

that might be the name

wet breach
ivory sleet
#

ah

wet breach
#

the workflow visualized

#

or modality

ivory sleet
#

looks good

quaint mantle
#

Hey! I have this code right here, works totally fine and all but I can't seem to get the x amount of chests.

    public static ArrayList<Player> ChestOpen = new ArrayList<>();
    public static HashMap<Player, Integer> ChestsOpen = new HashMap<>();
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
        
        Player p = e.getPlayer();
        
        if (e.getClickedBlock().getState() instanceof Chest) {
            if (!GlobalState.isState(GlobalState.WARMUP) || GlobalState.isState(GlobalState.IN_GAME)) {
                e.setCancelled(true);
            } else {
                if (ChestAllowedUpdater.canOpenChest == true) {
                    e.setCancelled(true);
                    e.getClickedBlock().setType(Material.AIR);
                    if (!ChestsOpen.get(p).equals(thing.getInstance().getConfig().getInt("chests-per-player") - 1)) {
                        int toAdd = 1;
                        int newChestsOpened = toAdd + ChestsOpen.get(p);
                        ChestsOpen.put(p, newChestsOpened);
                    }
                } else {
                    e.setCancelled(true);
                    ChestsOpen.remove(p);
                    ChestOpen.remove(p);
                    p.sendMessage(ChatColor.translateAlternateColorCodes('&', MessagePrefix.messagePrefix() + "&7You have already opened " + thing.getInstance().getConfig().getInt("chests-per-player") + " chests!"));
                }
            }
        }
    }
    
    public static int totalChests(Player player) {
        return ChestsOpen.size();
    }```
wet breach
#

create a class for your hashmap

#

or just simply do ChestsOpen.get(player.getUUID());

#

never put the player object into the hashmap

#

use the player's UUID as the key

#

also, don't use static everywhere either

#
public ConcurrentHashMap<UUID, Integer> ChestsOpen = new ConcurrentHashMap<>();

Also recommend using concurrenthashmap here in case you need to do update/read at the same time. Prevents some other types of problems 😉

rose tundra
#

Hey, I have this code to place a block in the direction of the player, but I can't get it to be placed right in front, that is, if the player is looking down, it is placed right where he is and pushes him and I don't want that p = (Player) sender; Location Lp = p.getLocation(); Vector vec = p.getLocation().getDirection(); vec.setY(0); Location frontlocation = Lp.add(vec); Block q = frontlocation.getBlock(); if(q.getType() == Material.AIR) frontlocation.getBlock().setType(Material.DIAMOND_BLOCK);

wet breach
#

if they are looking down, teleport them 1 block up at the same time of placing a block where they were at

#

easy to check if where they are placing a block, is the same spot the player is standing

rose tundra
#

🤯

deft sedge
#

Can I set a book title as a string variable?

wet breach
#

elaborate ?

deft sedge
#

so I have this command that is supposed to give a spicific player a book titled one of the arguments in the command

sullen dome
#

2 questions:

1: how much values can an ArrayList have without creating lag/errors?
2: What Encoding does the Server-Console have? (If it works that way lol)

deft sedge
ivory sleet
#

ArrayList can fit quite many elements I think

#

it depends on ram ultimately

sullen dome
#

quite many is relative

#

could mean 5000, could mean 5mio

ivory sleet
#

Yeah ofc, its hard to say exactly as it depends what type of objects

sullen dome
#

Strings

#

only

deft sedge
#

So I did bookmeta.setTitle(<StringVariableHere>); Is that an option

#

because when i get the book

ivory sleet
#

How many do you plan to fit?

deft sedge
#

it just calls it Written book

sullen dome
#

well, related to what it can hold

#

gimme a sec

deft sedge
#

@wet breach

#

the book says invalid book tag

ivory sleet
#

do u set the meta?

sullen dome
#
                while ((s = bufferedreader.readLine()) != null) {
                    if (!logLines.contains(s)) {
                        logLines.add(s);
                        //do some other stuff
                    }
                }

i am basically getting the lines from the console-log-file, and adding them into the arrayList, to make sure they doesn't get readed multiple times

deft sedge
#

well i do

sullen dome
#

so question now is, how many lines/Strings can that list contain

#

before i have to clear it

ivory sleet
#

How mach ram are you running on?

#

or memory

deft sedge
quaint mantle
#

I am trying to make a Hypixel looking AFK system here and does anyone know how I can repeat sending this title and subtitle whilst the player is AFK in Limbo? Current code: ```java
public class autoafk implements Listener {
@EventHandler
public void onKick(ServerKickEvent e){
if(e.getKickReason().contains("afk")){ //spigot plugin kicks players for 'afk' when they are afk
if ((e.getPlayer() instanceof ProxiedPlayer)) {
ProxiedPlayer p = e.getPlayer();
e.setCancelled(true);
p.connect(ProxyServer.getInstance().getServerInfo("limbo"));
if(p.getServer().equals("limbo")) {
ProxyServer.getInstance().createTitle()
.title(new ComponentBuilder("You are AFK")
.color(ChatColor.RED).create())
.subTitle(new ComponentBuilder("Move around to return to the lobby.")
.color(ChatColor.YELLOW).create())
.fadeIn(20)
.stay(-1)
.fadeOut(20)
.send(p);
}

sullen dome
#

currently (localhost, just for testing) 1gb, on my main server it's.... let me see

wet breach
#

buffer size I mean*

sullen dome
#

3.5GB

wet breach
#

a good limit is 1024 for text files

#

if you are making the buffer 3.5GB then really defeating the purpose of the buffer

cerulean jasper
#

How do I initialize this hashmap for players for example?

    public final static Map<Player, Skill> skillMap = new HashMap<Player, Skill>();
ivory sleet
#

its already instantiated if thats ur question

#

but you'd use skillMap.put(playerInstance,value)

#

assume you wanna initialize a value for a specific player

wet breach
#

what is with everyone using statics suddenly again

cerulean jasper
#

How do I assign players for example?

sullen dome
#

just dont want to work with that directly-get-from-console stuff, that is so confusing to me, so i am doing it this way

wet breach
#

Second, do not put player objects into collections

ivory sleet
sullen dome
#

loggers*

rapid vigil
#
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player p = (Player) sender;
        if (label.equalsIgnoreCase("arm")) {
            ArmorStand as = (ArmorStand) p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
            as.getName().equalsIgnoreCase("arm");
        }
        return false;
    }
}``` Hello, right here I've made a command to spawn an AS at player, But I want the AS to spawn with diamond armor, How do I do that?
wet breach
#

@sullen dome the way I am suggesting doesn't use loggers, but you don't need the buffer to be 3.5GB. If you really want to do it that way then just use memorymapped files.

sullen dome
#

well, i can use a logger, to log the file directly from the console, instead of from the latest.log. but it's complicated, so i did it like this.

#

for me it is complicated

wet breach
rapid vigil
#

Thanks.

sour rampart
#

[18:11:16 ERROR]: Error occurred while enabling TestPlugin v1.0 (Is it up to date?)
java.lang.NullPointerException: null
at com.mounterisastudios.testplugin.commands.HelloCommand.<init>(HelloCommand.java:26) ~[?:?]
at com.mounterisastudios.testplugin.Main.onEnable(Main.java:10) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:494) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:408) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:435) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:218) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:809) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_271]

Any help?

sullen dome
#

what is line 26 in HelloCommand

wet breach
#

your HelloCommand is null

sour rampart
#

plugin.getCommand("startgame").setExecutor(this);

sullen dome
#

wait... shouldn't that be in the onEnable?

eternal oxide
#

startgame command is not correctly entered in your plugin,.yml

sullen dome
#

could be, yeah

sour rampart
#

oof lol right

eternal oxide
#

it is

sour rampart
#

im new to java

wet breach
#

Everyone is new to java today 😄

#

sadly everyone is abusing statics too 😦

sullen dome
#

to my other question:

#

what encoding does the console use

#

it seems to not use utf8

wet breach
#

which console?

eternal oxide
#

its not, its system based

sullen dome
#

(The latest.log to be clear)

ivory sleet
#

feels like

wet breach
#

@sullen dome it uses whatever is set for the JVM. If this isn't specifically set for the JVM it uses whatever the system default is.

#

normally on linux it uses system default, on windows java puts a default for the JVM in the settings

#

you can override this with a JVM argument as well btw

sullen dome
#

what should i use here?

#

like utf8 seems to copy those weird icons

#

or creates them

wet breach
#

it didn't create them

sullen dome
#

convert*, whatever

wet breach
#

what happens is the encoding the JVM uses couldn't properly handle whatever those icons were before and so that is how it is saved. UTF-8 isn't going to magically reverse broken characters from an encoding that couldn't handle it to begin with.

sullen dome
#

the log-file seems to be encoded in utf8.

#

notepad++ says so

eternal oxide
#

it is. default console isn;t

sullen dome
#

well nvm, i see the icons are in the logfile as well lol

#

thought they are broken on the way from logfile to discord-channel

wet breach
#

Yep, when the character being saved, falls outside of the encoding can handle, it just turns them into squares instead of just missing characters

#

to indicate there was something here, but couldn't be saved properly

sullen dome
#

what could that values have been? no clue

#

thought it ends with the dot

wet breach
#

most of the time it is just color codes

sullen dome
#

could it be this? >

wet breach
#

no, its the encoding for colors

sullen dome
#

why are there colorcodes used

wet breach
#

you can't see it in console because the console is interpretting the codes properly, it just can't save them properly.

sullen dome
#

just not showing them in that git bash?

#

nvm

wet breach
#

yeah git bash is just ignoring them

sour rampart
sullen dome
#

fuck

#

sorry, just love that too much

wet breach
#

so what needs to happen in your code logic below that

#

is you need to look at the command that was executed

#

and execute the appropriate block code depending which command it was

sullen dome
#

well, do i have to ignore that fucked-up squares, or can i remove them somehow before sending them?

main dew
wet breach
#

you can remove them, generally they get defaulted to a square character like that, so what you can do is check the squares code point for the character and see if they are all the same. Generally should be. And then just filter out those characters 🙂

#

or you can just simply do nothing

#

those characters are not going to do any harm

sullen dome
#

they are harming my one working eye lol

wet breach
#

lol

sullen dome
#

would use .replace(), but cant copy that square into code lol

wet breach
#

you can copy that square into code @sullen dome

sullen dome
#

holy god

kindred solar
#

ups

sullen dome
#

god bless you

#

my eye ahhh

kindred solar
#

sry xd

#

?paste

queen dragonBOT
sullen dome
#

doesn't look right

wet breach
#

ah right, its the control character

#

give me a sec

sullen dome
#

when using as string it looks like this

#

do all those Objects.requireNonNull() actually helps? hate intellij for showing it as error without them

ivory sleet
#

no

#

just throws npe if its null

sullen dome
#

good to know

ivory sleet
#

but it becomes more apparent I guess

sullen dome
#

as i always ignore that yellow lines lol

kindred solar
#

should i take them out?

ivory sleet
#

yeah same

sullen dome
#

doesnt matter i guess

wet breach
#

@sullen dome the character is just ^

sullen dome
#

why would that be there

wet breach
#

but here I have a regex that will catch them since they are different depending on the color being used

#

because that is the control character for ANSI colors

#

which is what minecraft uses for color codes

#

well the console does anyways

#

's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g'

#

that is the regex to catch the ANSI control characters up to 256

#

fortunately you don't need to go beyond that

sullen dome
#

holy god, that looks like you got that from a like 9 years long coding class lol

wet breach
#

ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an ASCII escape character and a bracket character, are embedded into text. The terminal interprets these sequences as command...

sullen dome
#

why can't code just look normal

#

why is the world like that

wet breach
#

well good news, you don't have to figure out the regex 😄

#

I just gave it to you lol

#

so you do a replace using the regex as the pattern to match

#

and replace it with nothing

sullen dome
#

replace that with " " or with ""?

#

would second one even work?

wet breach
#

either one works, the first will add a space in the place of the character the second will just remove the character

sullen dome
#

ok then i use the sec

#

are the ' actually with the regex? or was that just a wrong wrote

wet breach
#

not part of the regex

#

but you need to use ' ' though

#

well I guess you could use " "

sullen dome
#

`` doesnt work