#help-development

1 messages · Page 1367 of 1

cinder thistle
#

pog

unreal quartz
#

build against 8, run on 15 (mostly)

sharp bough
#

can someone show me an example of some gui system with many many custom items?

#

i need to create about 250 custom items

#

and making them 1 by 1 is going to be a nightmare

opal sluice
#

Hi, is there an event for when the open his own inventory ?

#

Cause the InventoryOpenEvent does only fire when it opens and other type of container than his own inv

unreal quartz
#

no

#

the player is always considered to be viewing their inventory

opal sluice
#

Oh ok

serene bane
#

not sure if I'm dim here but I'm trying to colourize a string and the method only accepts characters but it wont let me parse them in ``` public static String format(String s) {
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
s = ChatColor.translateAlternateColorCodes("&", c);

    }
        return s;
}```
dusty herald
#

you don't use "&"

#

it's '&'

#

' is for chars, " is for strings

serene bane
#

wow that was dim

sullen marlin
#

Also you just translate the whole string, not each individually

#

You have it backwards, as the docs would tell you

serene bane
#

yeah I figured that out now I stopped getting the error

#

Thanks for the help

somber hull
#
                            if(args[0].equalsIgnoreCase("redeem")) {
                                Inventory inv = gui.getInv();
                                player.openInventory(inv);
                            }
#

this is run everytime someone rund a command with redeem as the argument

#

obviously

#

Will that inv variable be changed every time someone excecutes the command

#
if(event.getInventory().equals(gui.getInv())) {
#

i have this

#

and it just returns false every time

ivory sleet
#

Yeah

#

I think you should compare InventoryViews or use InventoryHolders, the latter is discouraged due to side effects

lost matrix
somber hull
#

oh ok

#

thank you!

somber hull
#

how do i pass a instance of a class to another class

#

public HealthArmor health = new HealthArmor();

#

this

ivory sleet
#

Probably dependency injection

lost matrix
#

Via the constructor for example

somber hull
#

Ahh ok

#

constructors are still a bit confusing for me

#

but ill try to figure it out

#
        private MainGui gui;

        public Listeners(Main plugin) {
            this.plugin = plugin;
            gui = plugin.guiMain;
        }
#

@lost matrix

#

gives me a null

#

exception

dusty herald
#

is guiMain set?

somber hull
#

In Main yea

#

public MainGui guiMain = new MainGui();

dusty herald
#

check to see if it's null

somber hull
#

If whats null

#

the one in Main?

dusty herald
#

yes

somber hull
#

how?

dusty herald
#

I think guiMain is null

somber hull
#

onEnable if guiMain == null print smthgn>

lost matrix
#

The only thing that could throw a npe in those line is if plugin is null

somber hull
#

ill do that

dusty herald
#

let me see the declaration of Listeners

somber hull
#

public Listeners listener = new Listeners(this);

dusty herald
#

yeah that's your fucky wucky

#

it needs to be declared in onEnable

somber hull
#

thank you

somber hull
dusty herald
#

typically they're in separate classes for better organization

somber hull
#

Ok, no more error

#

But were back to square one

#

Its still false

dusty herald
#

what's false?

somber hull
#

if(event.getInventory().equals(gui.getInv())) {

#
            if(event.getInventory().equals(gui.getInv())) {
                event.setCancelled(true);
#
    public MainGui guiMain = new MainGui();
    @Override
    public void onEnable() {
#

this is in my main class

#
gui = plugin.guiMain;
#

this is where the coimmand is run

#

creating the GUI

#
gui = plugin.guiMain;
#

this is where the listener is

somber hull
nimble prawn
#

Hello, someone knows what the deluxechat api is to put it as a dependency

dusky lynx
#

as far as I know getTitle() was removed from inventories back in 1.13

somber hull
#

if(inventory.contains(fee)) {
Im doing this
fee is == to this

ItemStack fee = new ItemStack(Material.DIAMOND);
fee.setAmount(this.plugin.getConfig().getInt("ammountofsaphires"));

For some reason that no worky

#

it passes as false

#

oh crap

#

wait

#

ItemStack fee = new ItemStack(this.getItem());

#

no material diamond

#

leme test it

summer scroll
#

what is the inventory?

somber hull
#

yea no it still passes as false

#

the inventory

#

Inventory inventory = plr.getInventory();

summer scroll
#

and you're checking if the inventory contains a specific itemstack?

somber hull
#

yes

#

specifically 50 of them

#

wich is defined in the config

dusty herald
summer scroll
#

get the inventory contents instead

somber hull
#

I cant figure that out

#

If i put the contents into a itemstack array

#

here i poisted about it a while ago

#

hmm i cant find it

#

But it just shows up as no methods

dusky lynx
#

When I use inventories I check for specific item stacks, and it works fine... do you need to specifically check for 50 or will 1 be fine?

summer scroll
#

what are you trying to do?

somber hull
#

specifically whatever they put in the config

#

When they click on the item in the inventory. it takes X amount of custom diamonds from their inventory and gives them the item

dusky lynx
#

question, 50 in 1 stack or 50 in the entire inventory?

somber hull
#

but checking if they have the X amount

#

fails

somber hull
#

inventory.contains(fee)

#

wouldnt that work?

dusky lynx
#

For just 1

somber hull
#

fee.setAmount(this.plugin.getConfig().getInt("ammountofsaphires"));

#

sets the anmount to however many is in the config

summer scroll
#

you need to iterate through player inventory contents ig.

somber hull
summer scroll
#

can you show more code?

somber hull
#

Yea

dusky lynx
#

you could check each slot in the inventory and then add it to an int and then check if it’s equal to the amount

somber hull
#

Its just messy

#
Inventory inventory = plr.getInventory();
ItemStack[] invArray = inventory.getContents();
#

that invArray has nothing attatched

#

leme send screenshot

dusky lynx
#

Paste your code

somber hull
dusky lynx
#

?paste

queen dragonBOT
dusty herald
#

if you're just trying to get the items from their inventory, don't use getContents

dusty herald
#

getStorageContents is what you want

summer scroll
#

use for loop

dusty herald
#

getContents iirc returns everything, including their armor and offhand

somber hull
#

o

#

but i still havethe issue

#

i cant do anyhting with it

dusty herald
#

are you using the correct Inventory import?

somber hull
#

i think so

#

leme check

dusty herald
#

nvm

#

also you can't add items to a ItemStack[]

somber hull
#

import org.bukkit.inventory.Inventory;

summer scroll
#
for(ItemStack item : inventory.getStorageContents()){
  // check itemstack.
}
dusty herald
#

or remove them

#

List<ItemStack> would allow you to add and remove ItemStacks

#

though I have no idea what you're trying to do

summer scroll
#

basically you're trying to check if the player has a specific item on their inventory, right?

somber hull
#

List<ItemStack> invArray = new ArrayList<ItemStack>();

#

?

sleek pond
#

quick question, does the getName or wahtever the method is called in the playerexecute command return the command without the slash or with it?

somber hull
#

wich have a special NBT tag

dusty herald
somber hull
#

yea ik that looks bad

#

shh

#

its temperory

summer scroll
#

so, loop every item on the players inventory

dusty herald
#

no no i mean NBT, i've never used it really

somber hull
#

O

summer scroll
#

and check if the item isSimiliar or have that nbt tag.

#

if so, get the amount

dusty herald
#

wtf, updated intellij and it died

sleek pond
#

intellij updates are dumb

#

they release a new version every 3 seconds

dusky lynx
#

ItemStack[] items = inventory.getStorageContents();
int total = 0;
for (ItemStack i : items) {
if (i == yourItem) {total++;}
}
If (total == 50){
// do whatever
}

Could try something like this?

#

might be spelt wrong, csnt type on phone

ivory sleet
#

Omg it’s not formatted

dusky lynx
#

Whatever man, get over it

ivory sleet
#

Oh I was just joking (:

earnest junco
#

Inventory#containsAtLeast to check if there is X amount of a specific item
Inventory#removeItem with a clone of your ItemStack that is set to the amount you want to remove to remove it
Tada, 2 lines

opal sluice
#

Hi, when I do spam click an inventory even if I cancelled the event, sometimes, the item can be placed :/

#

Is there a way to avoid that ?

young knoll
#

I believe it’s only visual

sleek pond
#

sorry for "bumping" my message

opal sluice
#

Unfortunately not :/

young knoll
#

Also creative mode behaves weirdly with inventories

earnest junco
sleek pond
#

that's what I thought as well

opal sluice
#

I'm in survival cause I know it does break things the creative mode

#

It's not picking the item

#

It's placing it

#

if the slot is empty

#

sometimes

#

it just place it anyways

young knoll
#

As far as I know if you are cancelling the event properly you won’t have an issue

opal sluice
#

(but you really have to spam)

young knoll
#

I’ve never had one anyway

earnest junco
quaint mantle
#

ive also never had an issue when cancelling click / place events

opal sluice
#
        if(((clickedSlot == extraSlot1 || clickedSlot == extraSlot2) && !extraSlotTypeUtils.isRing(cursorItem) && (cursorItem != null && cursorItem.getType() != Material.AIR) /*&& extraSlotTypeUtils.isRing(currentItem)*/)
            || (clickedSlot == extraSlot3 && !extraSlotTypeUtils.isNecklace(cursorItem) && !extraSlotTypeUtils.isAccessory(cursorItem) && (cursorItem != null && cursorItem.getType() != Material.AIR) /*&& (extraSlotTypeUtils.isAccessory(currentItem) || extraSlotTypeUtils.isNecklace(currentItem))*/))
        {
            e.setCancelled(true);
            return;
        }
quaint mantle
#

if you are having an issue, you can try calling Player#updateInventory after, see if that fixes anything for you

opal sluice
#

So ugly on discord

#

wait I do a paste

#

?paste

queen dragonBOT
opal sluice
#

basically, it just look after the clicked slot

#

(the raw number from the view)

quaint mantle
#

try calling Player#updateInventory after you cancel

earnest junco
#

Maybe your click results in an InventoryDragEvent, not a click one?

young knoll
#

I’ve never had to listen to that one for anything

#

But it’s worth a try

opal sluice
#

Gonna try

dusty herald
#

anyone know of a way to detect how much durability a block would take a way from an ItemStack if it were used to mine that block?

sleek pond
#

I think there might be a way to do so

dusty herald
#

not sure if durability removal depends on block type

sleek pond
#

but i forget

sleek pond
earnest junco
dusty herald
#

so just removing 1 from the durability should suffice?

earnest junco
#

it always takes 1 damage, minus a % chance when it has dura

young knoll
#

It does

dusty herald
#

ah

young knoll
#

Using a tool on the wrong block does 2 damage

dusty herald
#

hmm

sleek pond
#

wait actually?

opal sluice
#

Yup

#

That was a drag event

#

ffs 😂

earnest junco
#

oh damn, there's a whole lotta exceptions with tool damage

young knoll
#

Mhm

sleek pond
#

wait

#

since when did the registerevent params change

#

oh wait

#

nvm

#

i was using the wrong method xD

opal sluice
#

Does anyone knows how could I know if a region is within a chunk ?

quaint mantle
opal sluice
#

I meant a WorldGuard region ^^

quaint mantle
#

😔

opal sluice
#
    public static boolean isRegionInChunk(Chunk chunk)
    {
        RegionManager regions = getRegionManager(BukkitAdapter.adapt(chunk.getWorld()));
        
        final int maxX = chunk.getX() * 16;
        final int minX = maxX + 15;
        
        final int maxZ = chunk.getZ() * 16;
        final int minZ = maxZ + 15;
        
        final BlockVector3 max = BlockVector3.at(maxX, 256, maxZ);
        final BlockVector3 min = BlockVector3.at(minX, 0, minZ);
        
        ProtectedRegion chunkRegion = new ProtectedCuboidRegion("chunkRegion", min, max);
        if(regions != null)
        {
            return !regions.getApplicableRegions(chunkRegion).getRegions().isEmpty();
        }
        return false;
    }
#

Here you go if someone needs it ^^

EDIT: Thank you btw 😉 @quaint mantle

quaint mantle
#

havent felt that in a while

sullen marlin
quaint mantle
#

Is that a pogchamp?

#

i will turn md5 into a Java ARchive

jade perch
#

That with the spigot api annotations are going to be one of my favorites

crude charm
#
                    for (Player p : Bukkit.getOnlinePlayers()) {
                        if (!args[0].equalsIgnoreCase(p.getDisplayName())) {
                     player.sendMessage(CC.RED + "That player is not online!");
                     return true;
                 }
                        }

                    }

works fine with one person but when 2 join it always says they are offline

jade perch
#

That's cause your loop can only run at max one time

crude charm
#

how do I change that

jade perch
#

you need to not return inside of your for loop

crude charm
#

aight

dusty herald
#

You could just Bukkit#getPlayer(String) and check if it's null

crude charm
#

I did

#

and it didnt weork

dusty herald
#

but don't use display names if you go that method

crude charm
#

oh

#

ok

dusty herald
#

Player#getName()

#

if the displayName is a nick, nothing will happen

crude charm
#

aight

hasty lynx
#

Player player = Bukkit.getPlayer(args[0]);

dusty herald
jade perch
#

you can use getPlayer with their name i'm pretty sure

#

idk if it's case sensitive or not

dusty herald
#

not their displayName

#

chances are it's a nickname

hasty lynx
#
Player player = Bukkit.getPlayer(args[0]);
if (player == null) {
  player.sendMessage(That player is not online!);
}
crude charm
#

like this?

        Player onlineTarget = Bukkit.getPlayer(args[0]);

                if (onlineTarget == null) {
                    player.sendMessage(CC.RED + "That player is not online!");
return true;
                }


dusty herald
#

yes

crude charm
#

aight

#

can I return in that

dusty herald
#

yeah, I'd return after sending the message

crude charm
#

yeah I need to

jade perch
#

java 9 the best

        Optional.ofNullable(Bukkit.getPlayer(args[0]))
                .ifPresentOrElse(
                        player -> {
                            //player stuff
                        },
                        () -> sender.sendMessage("FUCK")
                );
#

can't wait till java 11 is mainstream

earnest junco
#

sender.sendMessage("FUCK")
10/10 error message

dusty herald
young knoll
#

To be fair with them pushing java 11 most hosts will offer it now

#

So you can just make your plugin with java 11 anyway

dusty herald
#

I doubt 1.8.8 server operators will upgrade kekwhyper

young knoll
#

Don’t support 1.8

#

Problem solved

sharp badge
#

I'm trying to take a player's chat event and utilize it in a different method, how would I go about doing this?

Example:
Player clicks with item and is prompted to enter something in chat
It then takes the chat input and uses that to alter additional code

#

If anyone could guide me in the correct direction it would be much appreciated ❤️

quaint mantle
#

add a metadatatag to them

young knoll
#

Dang that API is from 1.1

quaint mantle
#

lol

young knoll
#

Back when they added unique planks to each wood

sharp badge
#

So add a metadatatag to the player and check if it's persistent in the chat event, then if it is we can use it that way?

quaint mantle
#

yh

young knoll
#

Or try that API

earnest junco
#

definitely go with the conversation api

young knoll
#

To be honest I’ve never used it, but I’m sure it works

earnest junco
#

its 10x smoother to use

crude charm
#

how do I make it so that worldedit pastes where im looking

#

but I only want nsew

#

not oother directions

#

currently ive got

        if (player.getLocation().getYaw() > 90 && player.getLocation().getYaw() < -90) clipboard.rotate2D(90);
        if (player.getLocation().getYaw() > 180 && player.getLocation().getYaw() < -180) clipboard.rotate2D(180);
eternal oxide
#

I posted a method for you when you asked this question earlier

crude charm
#

when I posted this question at 5am

eternal oxide
#

no almost a day ago

crude charm
#

huh?

eternal oxide
#
private Location getTarget(Player player) {

    RayTraceResult target = player.rayTraceBlocks(200);
    if (target == null) return null; // no hit

    return target.getHitBlock().getLocation().add(target.getHitBlockFace().getDirection());
}```
#

that will get you the empty Location the player is looking at

#

upto a range of 200

crude charm
#

but im not using 1.16

eternal oxide
#

ah 😦

crude charm
#

why is my code not working?

eternal oxide
#

what is it not doing?

crude charm
#

not rotating it

eternal oxide
#

have you tried debugging the yaw?

crude charm
#

no but I dont see why it wouldn't work

eternal oxide
#

This is why you debug, to see WHY its not working. sysout the yaw to make sure it lays in the ranges you expect

crude charm
#

ok

young knoll
#

I’ve tried nothing and I’m all out of ideas

crude charm
#

like this?

    if (player.getLocation().getYaw() > 90 && player.getLocation().getYaw() < -90) { clipboard.rotate2D(90); printConsole(String.valueOf(player.getLocation().getYaw())); }
young knoll
#

You should probably do it outside of the if statements

crude charm
#

ok

young knoll
#

I assume it’s tracked as a number from 0-360

eternal oxide
#

Ok, now look at your if statement.

young knoll
#

Rather than -180 to 180

eternal oxide
#

Do you think both of those conditions can be true at the same time?

crude charm
#

no

young knoll
#

Oh yeah, didn’t even notice that

eternal oxide
#

Yet you are making it test that both are true with &&

crude charm
#

ok

#

hmm

#

so

eternal oxide
#

perhaps || instead of &&

crude charm
#

yeah

#

thats what I was thinking

#

ok

#

it works now kind of

#

its just not pasting to the right place

#

but it does change depending on where I look

eternal oxide
#

For that you will have to perform your own basic raytrace

crude charm
#

wdym

#

thanks to debugging ive almost got it

eternal oxide
#

using player.getEyeLocation() and player.getEyeLocation().getDirection()

somber hull
#

well...

#

this is new

#

ignore the code

#

i just found a new discord feature

random epoch
#

?paste

queen dragonBOT
somber hull
#

Just sjowing smthng i just found

young knoll
#

It’s a neat feature

#

Not in iOS yet

somber hull
#

f

crude charm
#

cant I just do, clipboard.rotate2D(player.getEyeLocation.getDirection);

eternal oxide
#

pseudo code would be java Location start = player.getEyeLocation(); Vector direction = start.getDirection.clone().normalize(); for (i = 1; i < 200; ) { Block block = player.getWorld().getBlockAt(start.add(direction.clone().multiply(i)); if (block.getType() != Material.AIR) //this is the first block collision so return the last location tested.

somber hull
#

Ok, actuall question this time.

                        for(ItemStack item : inventory.getStorageContents()){
                            if(item != null)
                              if(NBTEditor.getBoolean(item, "isdiamond")) {
                                  
                              }
                            }

this loops through ever item in the inventory and checks for NBT. how do i just delete the items that have the NBT...

#

should be simple but i have no idea lol

#

item.remove doesnt exist...

eternal oxide
#

you set it to AIR

somber hull
#

thank you

somber hull
#

No error

#
                        for(ItemStack item : inventory.getStorageContents()){
                            if(item != null)
                              if(NBTEditor.getBoolean(item, "isdiamond")) {
                                  item.setType(Material.AIR);
                              }
                            }
young knoll
#

Set it to null

#

Also getStroageContents is immutable iirc

somber hull
#

?

#

immutable iirc?

eternal oxide
#

you may want to use the iterator

#

or call remove on the Inventory

somber hull
#

Setting it to null has the same effect

somber hull
eternal oxide
#

Inventory.remove(ItemStack)

somber hull
#

ahh

#

thank

young knoll
#

I don’t think that he’s to that array are reflected in the article inventory unless you use setStorageContents

eternal oxide
#

yep

#

It looks to just be a clone, so remove would work

somber hull
#

oh wait

#

i totally forgot

#

i need to remove exactly 50 of them

#
            for(ItemStack item : inventory.getStorageContents()){
                if(item != null)
                  if(NBTEditor.getBoolean(item, "isdiamond")) {
                      diamondAmount = diamondAmount + item.getAmount();
                  }
                }
#

this counts all of the items they have

#

like the amount

eternal oxide
#

in that case you can always modify your array and then use Inventory.setStorageContents to push your changes back

somber hull
#

ok leme try it rq

eternal oxide
#

You shoudl be able to set teh amount to remove

somber hull
#

but what if i wanna remove say 200

eternal oxide
#

just get teh stack you want, set teh amount on it and call remove

somber hull
#

or more than the stack

eternal oxide
#

Then Math

somber hull
#

ok

#

ill math

hybrid spoke
#

array to list, stream, filter 🤔

sage swift
#

i wish there were more BlockFaces like NORTH_WEST for up/down

eternal oxide
#

? there is an UP and DOWN and NORTH_WEST

sage swift
#

i wish there was something like UP_NORTH

eternal oxide
#

you want a 3x3x3 cube of BlockFaces?

sage swift
#

no, just up north/east/south/west

#

i just decided to take in a Set<Location> to store x/y/z which is probably not an ideal solution

#

and then use getRelative(face.getBlockX(), face.getBlockY(), face.getBlockZ())

quaint mantle
#
public abstract class DirectionBlock implements Block {
    public Block[] getDirectionBlocks() {
        return {
            getRelative(BlockFace.NORTH),
            getRelative(BlockFace.EAST),
            getRelative(BlockFace.SOUTH),
            getRelative(BlockFace.WEST)
        };
    }
}

@gecko10000#7137 smth like this?

#

@sage swift

sage swift
#

no

#

what

quaint mantle
#

you said

#

no, just up north/east/south/west

sage swift
#

up_north, up_east, up_south

#

etc

eternal oxide
#

so you want a 3x3 thats on top of a block?

#

or just cardinal directions on top

#

odd to just want the ones on top

sage swift
#

for a tree traversal

eternal oxide
#

Whats the use case?

#

ah wood

quaint mantle
#

so why not just use getRelative

#

i dont see why we're having this discussion

somber hull
#

I have a plugin that spawns a boss right. Whenever someone dies next to it, and the chunks unload. It despawns
How do i fix this?

somber hull
eternal oxide
#

prevents teh chunk being unloaded until you remove the ticket

somber hull
#

ooo ill look into it

#

is it complicated?

quaint mantle
#

teh

eternal oxide
#

you just call it on the Chunk passing yoru plugin instance

sage swift
#

why are you doing this elgar

quaint mantle
#

yu'roe*

eternal oxide
#

you mean teh typos? Age, arthritis and carpal tunnel

somber hull
#

Could you elaborate?

quaint mantle
#

do what he said

quaint mantle
eternal oxide
#

I'm not yet 60

somber hull
#

call what

quaint mantle
#

you're in your 50s?

somber hull
#

bruh

eternal oxide
#

Yep

quaint mantle
#

damn

quaint mantle
#

veteran spigot member

quaint mantle
somber hull
#

method*

eternal oxide
somber hull
#

oh

#

where

#

oop

#

thanks

quaint mantle
somber hull
quaint mantle
#

lol

somber hull
#

I used to call them functions for a bit lol

quaint mantle
#

its a function

#

in java we call them methods

#

but its still a function

somber hull
#

yes

#

but

#

its called a method

#

so

#

method*

quaint mantle
#

my brain

#

everyone and their dog uses functions

#
interface Method extends Function {}
#

java wanted to be special

#

fr!

#

still a function

#

as it functions

#

it does not method

#

you can function a method but you can't method a function

#

big bron

#

🤯

somber hull
#
Location bossSpawn = this.data.getConfig().getLocation("bossspawn");
        bossSpawn.getWorld().addPluginChunkTicket(null, null, this);
#

am i using this wrong

eternal oxide
#

yes

#

as its an old version the ints are probably chunk x/z coords

somber hull
#

yea but how do i call it

#

world.addpluginchunkticket?

#

cause that didnt work.

eternal oxide
#

or you just use the method from the actual chunk you want the ticket on

#

then it only has a plugin requirement

somber hull
#

how do i get that chunk

#

o

eternal oxide
#

Location.getChunk()

somber hull
#
        Location bossSpawn = this.data.getConfig().getLocation("bossspawn");
        bossSpawn.getChunk().addPluginChunkTicket(this);
    }
#

yea

#

i did that

#

let me test

quaint mantle
somber hull
#

Im not.

#

It was a temporary placeholder

#

?

somber hull
#

yea @eternal oxide that didnt work

#

I tested it while the chunk was unloaded

#

and still errored

quaint mantle
#

an error message would be greatly appreciated

eternal oxide
#

um, it can;t error

somber hull
#

NPE

#

Its trying to kill an unloaded entity

#

it cant

#

also whenever it unloads the mob dissapears

eternal oxide
#
Plugin plugin)
Adds a plugin ticket for this chunk, loading this chunk if it is not already loaded.

A plugin ticket will prevent a chunk from unloading until it is explicitly removed. A plugin instance may only have one ticket per chunk, but each chunk can have multiple plugin tickets. ```
somber hull
#
        Location bossSpawn = this.data.getConfig().getLocation("bossspawn");
        bossSpawn.getChunk().addPluginChunkTicket(this);
#

this is in my onEnable

#

Yet that chunk is still unloaded when i leave the area

eternal oxide
#

add the ticket 1 tick after the server is fully up and running

somber hull
#

howe

#

how do i wait?

eternal oxide
#

Bukkit.getScheduler.runTaskLater

somber hull
#

thank you @eternal oxide

#

@eternal oxide

#
        Bukkit.getServer().getScheduler().runTaskLater(this, new Runnable(){

            @Override
            public void run() {
                Location bossSpawn = this.data.getConfig().getLocation("bossspawn");
                bossSpawn.getChunk().addPluginChunkTicket(null);
            }
        },1);
#

i cant reference the Main class by doing this

#

while inside the runnable

#

How fix?

eternal oxide
#

create a final field

somber hull
#

?

somber hull
eternal oxide
#

in your Main class private final Main INSTANCE; Then in your constructor public Main() { INSTANCE = this; }

#

you can then use INSTANCE

somber hull
#

Should there be a constructor for the runnable?

eternal oxide
#

no your main class constructor

somber hull
#

oh ok

eternal oxide
#

add one for Main

somber hull
#

i dont think i have one

#

yea ill do that

#

then do i instance itself onEnable?

eternal oxide
#

no

#

you set it in teh constructor as I just showed you

somber hull
#

ok

#

yea so

#

after all that

#

spawner.getEntityByUniqueId((UUID) plugin.data.getConfig().get("bossid")).remove();

#

this is giving me an NPE

#

just like it was before

eternal oxide
#

did you use INSTANCE when you added the ticket?

somber hull
#

yea

eternal oxide
#

Then your issue is not with the chunk being unloaded

somber hull
#

ive been using /rl

somber hull
eternal oxide
#

it can;t unload with an active ticket

#

oh um, you trying to cast to a UUID?

somber hull
#

@eternal oxide the chunk is unloading

#

I leave the area

#

and the entity despawns

eternal oxide
#

You shoudl be using UUID.fromString(plugin.data.getConfig().get("bossid"))

#

so long as bossid is a UUID string

somber hull
#

their the same thing no?

eternal oxide
#

I don't believe you can cast String to UUID

somber hull
#

I mean its been working

#

Just not when its unloaded

#

Any way to fix it?

eternal oxide
#

No. This is exactly what the ticket is for. I guess it doesn;t prevent entities despawning though

somber hull
#

hmmm

#

@eternal oxide i just added a bunch of try and catch to just skip the error

#
                        Zombie babyZombie = loc.getWorld().spawn(loc, Zombie.class);
                        babyZombie.setBaby(true);
#

how do i make that happen like 2 times

#

do i just repeat it?

#

or is there a babyZombie.spawn()?

sullen marlin
#

?

#

for (int i = 0; i < 2; i++) // twice ?

somber hull
#

Ik its a dumb question

#

thank you

sage swift
lilac dagger
#

or right clicking in interact @somber hull

somber hull
#

?

lilac dagger
#

same effect can happen there

#

in newer versions right clicking is called twice

#

once for right clicking the main hand and once for the offhand

somber hull
#

well the for loop worked great 😄

#

but thanks for letting me know

lilac dagger
#

ohh i missread

#

i thought you had a bug

somber hull
#

no lol

somber hull
#

@lilac dagger now i havea bug lol

#

but its unrelated

#

how do i check if the player has clicked in the inventory GUI and not the players inventory

sage swift
#

if (clickedInv == null || clickedInv instanceof PlayerInventory) return;

somber hull
#

thank you

lilac dagger
#

better yet

quaint mantle
#

hey fr33styler

lilac dagger
#

clickInv != p.getInventory

#

hey @quaint mantle

quaint mantle
#

nice to meet you

lilac dagger
#

this check is faster than instanceof

quaint mantle
#

btw, How do you enable the player to craft?

#

I want to make from this

#

to green

sage swift
#

you uh

#

need the items

#

to craft it

quaint mantle
#

thanks, but of course. i know that. but I made custom recipe, This is strange, but the custom recipe I made is still impossible even though I have the ingredients.

#

I want to make custom recipe possible without ingredients.

sage swift
#

the red slots are completely client-side, i would assume

#

the client only knows of the recipes themselves

quaint mantle
#

ah thanks

somber hull
drowsy helm
#

what are you trying to achieve? sort of hard to know without background info

somber hull
#

you click

#

and it takes 50 items

#

instead it gives me like 4 stacks lol

#

@drowsy helm

#

i think i did math wrong?

drowsy helm
#
                                  if (newDiamondAmount >= this.plugin.getConfig().getInt("ammountofsaphires")) {
                                      if(newDiamondAmount > this.plugin.getConfig().getInt("ammountofsaphires")) {```
#

whats up with that aswell

somber hull
#

this.plugin.getConfig().getInt("ammountofsaphires") == 50

drowsy helm
#

so you just want to remove 50 form the stack?

somber hull
#

from the entire inventory

#

cause if they set it to more than a stack

#

in the config

#

I wan it to still work

somber hull
#

but how do i take

drowsy helm
#

iterate over all items

#

and keep a current counter of removed items

somber hull
#

?paste

queen dragonBOT
somber hull
#

while i fix that

#

i ran into this

eternal oxide
#

You can;t use the containsAtLeast as you also need them to have the NBT tag

somber hull
#

the only one that gives extar hearts is the helmet

eternal oxide
#

Not sure that will check NBT

somber hull
#
        public ItemStack getItem() {
            ItemStack diamond = new ItemStack(Material.DIAMOND);
            diamond = NBTEditor.set(diamond, true, "isdiamond");
            ItemMeta meta = diamond.getItemMeta();
            
            
            meta.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Legendary Saphire");
            List<String> lore = new ArrayList<String>();
            lore.add("");
            lore.add(ChatColor.BLUE + "" + ChatColor.ITALIC + "A legendary diamond, obtained");
            lore.add(ChatColor.BLUE + "" + ChatColor.ITALIC + "by slaying the Gem Keeper");
            lore.add("");
            lore.add(ChatColor.AQUA + "" + ChatColor.ITALIC + "Use \"/boss redeem\" to redeem");
            lore.add(ChatColor.AQUA + "" + ChatColor.ITALIC + "any peice of armor/tool for " + plugin.getConfig().getInt("ammountofsaphires") + " saphires");
            meta.setLore(lore);
            
            
            meta.addEnchant(Enchantment.DURABILITY, 69420, true);
            
            meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
            meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
            
            diamond.setItemMeta(meta);
            
            
            return diamond;
        }
#

@eternal oxide i have this

#

idk if that would help?

#

thats where i create the item

drowsy helm
#

like i said you can iterate over contents and check if the item is the same

#

keep a current counter of items that match

#

then you can check if they are same

somber hull
#

I already did that lol

drowsy helm
#

similar for removing

somber hull
#
 if(NBTEditor.getBoolean(item, "isdiamond")) {
                                  newDiamondAmount = newDiamondAmount + item.getAmount();
                                  inventory.remove(item);
drowsy helm
#

is newDiamondAmount the current?

somber hull
#

Yea, it starts at 0

#

and goes up by however many is being deleted

#
                        for(ItemStack item : inventory.getStorageContents()){
                            if(item != null)
                              if(NBTEditor.getBoolean(item, "isdiamond")) {
#

if(NBTEditor.getBoolean(item, "isdiamond")) {

#

at this point

#

we know its the item we need

#

i just need to take exactly 50

#

this.plugin.getConfig().getInt("ammountofsaphires") == 50

eternal oxide
#

You need to count all with that NBT tag before you start removing so you know they have enough

somber hull
#
    for(ItemStack item : inventory.getStorageContents()){
                if(item != null)
                  if(NBTEditor.getBoolean(item, "isdiamond")) {
                      diamondAmount = diamondAmount + item.getAmount();
                  }
                }
            
eternal oxide
#

ok

somber hull
#

if(diamondAmount >= this.plugin.getConfig().getInt("ammountofsaphires")) {
drowsy helm
#
int counter = 0;
int amountRequired = this.plugin.getConfig().getInt("ammountofsaphires"));

for(ItemStack item: inventory.getStorageContents()){
  if(item == null) continue;
  if(!NBTEditor.getBoolean(item, "isdiamond")) continue;
  if(counter == amountRequired) return;
  
  if(item.getAmount() >= amountRequired - counter){
    item.setAmount(item.getAmount() - (amountRequired - counter))    
    return;
  }else{
    counter += item.getAmount();
    item.setAmount(0);
  }
}```
#

thats what i meant

eternal oxide
#

Thats close, but you also need to check if you are over adn only reduce by the correct amount

#

in the setAmount

drowsy helm
#

first if statement

eternal oxide
#

ah ok

somber hull
#

leme test that

eternal oxide
#

shoudl that not be if (counter + item.getAmount()

drowsy helm
#

oh actually you would have to account for counter in amount Required

#

yeah the first if statement should be item.getAmoint() >= amountRequired - counter

eternal oxide
#

and teh set also needs to change slightly

#

yep

somber hull
#

@drowsy helm why are you setting the amount to 0

#

is that the same as setting the type to null

#

just deleting it?

drowsy helm
#

same deal

#

its getting set to 0 because it wont fulfill teh amountRequired so it's just taking all of that then looking for the next itemstack

somber hull
#

@drowsy helm thank youfor the help!

drowsy helm
#

all good

somber hull
#

This is creating all the armor im using

#

idk why its not working properly

drowsy helm
#

you should have an itembuilder

somber hull
#

?

daring sierra
#

idk why but seeing extra red hearts just makes me weirded out on mc

somber hull
#

lol

drowsy helm
#

like for example if i want to make an item

#

i can do

#

new ItemBuilder(Material.DIAMOND_HELMET).name("test").enchants(...).Attributes(...).etc etc etc

#

instead of having a whole method for it

somber hull
#

oh

#

well oh well

#

i did this

#

and idk why the attributes are not working?

#

They work on the helmet tho

drowsy helm
#

is ther a maximum for it possibly?

#

try putting it as al ower value and see if it does anything

somber hull
#

well the boots are lower than the helmet

#

and they dont work either

drowsy helm
#

hmm probs has something to do with it being leather armour im thinking

#

since the helmet is just a skull

somber hull
#

hmmm

#

leme try using that other meta type for the other meta stuff

bold parcel
drowsy helm
#

because its the german version lol

bold parcel
#

oh

#

I clicked the link in the index

#

weird

drowsy helm
#

cant seem to find an english version for it hto weird

somber hull
#

hmm that doesnt work either...

drowsy helm
# somber hull hmmm

unrelated but you can easily remove the @SuppressWarnings("static-access")

somber hull
#

imam go to sleep

#

and fix this tomrrow

drowsy helm
#

yeah sleep is the best fix lol

#

im assuming it's your nbt.set() function

#

can just be NBTEditor.set

#

then you dont need to suppress

somber hull
#

Oh yea i figured that out lol

#

Im just too lazy to go and change everything

drowsy helm
#

lmao

somber hull
#

dude im so confused

#

i changed some stuff with the chestplate meta

#

and now it wont let me get it out of the gui

#

this makes no sense

drowsy helm
#

depends how your inventory system works lol

somber hull
#

yea

#

aight

#

sleep time

#

1 am

#

AAAAAAAAAAAAA

bold parcel
drowsy helm
#

yeah thats the one i was looking at

#

i swear i was reading that wiki page like 4 months ago aswell

#

maybe take it up with forum staff

crude charm
#

hello

#

this is going to sound very very dumb

#
public enum DirectionUtil {
    SOUTH,
    SOUTHWEST,
    WEST,
    NORTHWEST,
    NORTH,
    NORTHEAST,
    EAST,
    SOUTHEAST;
    private static final DirectionUtil[] directions = {SOUTH, WEST, NORTH, EAST};
    private static final DirectionUtil[] doubleDirection = {SOUTH, SOUTHWEST, WEST, NORTHWEST, NORTH, NORTHEAST, EAST, SOUTHEAST};
    public DirectionUtil getDirection(Location location) {
        return getDirection(location.getYaw());
    }
    public DirectionUtil getDoubleDirection(Location location) {
        return getDoubleDirection(location.getYaw());
    }
    public DirectionUtil getDirection(float yaw) {
        return directions[((int)(yaw+45F)%360)/90];
    }
    public DirectionUtil getDoubleDirection(float yaw) {
        return doubleDirection[((int)(yaw+22.5F)%360)/45];
    }
}

I have this enum and I want to get one of the methods, how do I get them?

abstract sleet
crude charm
#

ty

abstract sleet
#

np

#

and, if you wanted them to be static, it would be DirectionUtil.getDirection(Location) :)

crude charm
#

yuyp

#

thanks

abstract sleet
#

lmk if it works 👍

crude charm
#

for example, if I wanted to get them facing north, how would I go about doing that

#

what would I put in the float field

abstract sleet
crude charm
#

im trying to get the direction they are looking and run code based on that

abstract sleet
#

Get the player's location, get the yaw of their location, parse that through a method in the enum and make it return a direction.

crude charm
#
    public DirectionUtil getDirection(float yaw) {
        return directions[((int)(yaw+45F)%360)/90];
    }

how do I use this method? what do I put in the yaw field

#

thats what I dont understand

#

why it requires be to give a field

abstract sleet
#

Shouldn't that be a static method? :\

crude charm
abstract sleet
#

So you are meant to input the yaw to return a direction

crude charm
#

I do that

abstract sleet
#

If it was a static method as I suggest, use DirectionUtil direction = DirectionUtil.getDirection(player.getLocation().getYaw());

crude charm
#

ok ty

abstract sleet
#

I don't think that enum is made very well

crude charm
#

ikr\

#

like

#

getDirection should return the direction

#

not whatever it does

#

if (direction == NORTH)

#

like that?

river spear
#

How can I change a line with the Holographic Displays Plugin with the Api?
HologramAdapter ad = (HologramAdapter) HologramAdapter.activeHolograms.get(holo); ad.setLine(1,"§etest"); I've already tried this, but it doesn't work

lilac dagger
#

that class is not an adapter

#

more of a manager

river spear
#

But then how can I change the line?

dry beacon
#

This is my main class, I set up the yml configuration file and I can use it with this.getCustomConfig(), I'm familiar with constructors, though how can I use the config in my other classes? Doing new MyMainClass().getCustomConfig() doesn't seem to work. https://pastebin.com/S2mffCxQ

summer scroll
#

How can I run a task on onDisable? Currently I'm trying to save a data on async and it's giving me errors. Plugin attempted to register task while disabled

abstract sleet
summer scroll
#

So just run it? without a task.

abstract sleet
#

Yes

burnt totem
summer scroll
#

aight, thanks.

random epoch
#

Restart > Reload

abstract sleet
random epoch
summer scroll
#

Huh, onDisable is called when the server stops too.

abstract sleet
chrome beacon
#

You can use sdk-15 if you want. Just make sure you set the target version to java 8

abstract sleet
#

Only bukkit should call onDisable

chrome beacon
#

What are you using to compile

covert urchin
#

literally I just want to get a list of strings into flag value and read back that list as some sort off array from the region flags with WorldGuard API... I can find literally zero documentation because apparently my google-fu is not strong enough and I get irrelevant results that use the same words as what I'm looking for but aren't the same thing.

#

and I am in worldguard docs but can't find anything specific for this? o.O

crude charm
#
        //north
        if (direction == NORTH) clipboard.rotate2D(0);
        //east
        if (direction == EAST) clipboard.rotate2D(90);
        //south
        if (direction == SOUTH) clipboard.rotate2D(180);
        //west
        if (direction == WEST) clipboard.rotate2D(270);

it aint working @abstract sleet

covert urchin
abstract sleet
crude charm
abstract sleet
covert urchin
crude charm
#

aight

abstract sleet
#

Click on the Raw button and make a new class in your project, just paste that code in without the package of course use your own package

#

If it works then I will include it into my lib

chrome beacon
#

Not sure but check File > Project Structure > Project > Project Language Level

crude charm
#

@abstract sleet how do I use it? if Direction.north or if player.getLocation.getYaw(direction.north)

#

ect

random epoch
#

Usually the language level is set to your jdk’s level

burnt totem
#

I can't seem to find a good and clean nametag api, all of them messes with the scoreboard. Is it smart to have it built in with the scoreboard?

chrome beacon
#

You can always just make it yourself

burnt totem
#

yeah but is it smart to have it in the scoreboard?

#

so it don't fuck up the scoreboard

chrome beacon
#

It has to be in the scoreboard

burnt totem
#

ok

dry beacon
#

I have a custom config file, it's in the same class as the onEnable() method, so when I try to create a new instance I get a "plugin is already enabled" error, how can I use my getCustomConfig method in other classes? I would usually just do this.getCustomConfig, though as I mentioned above creating an instance doesn't work java MainClass plugin = new MainClass();


    public FileConfiguration getCustomConfig() {
        return this.customConfig;
    }

    private void createCustomConfig() {
        customConfigFile = new File(getDataFolder(), "config.yml");
        if (!customConfigFile.exists()) {
            customConfigFile.getParentFile().mkdirs();
            saveResource("config.yml", false);
         }

        customConfig= new YamlConfiguration();
        try {
            customConfig.load(customConfigFile);
        } catch (IOException | InvalidConfigurationException e) {
            e.printStackTrace();
        }
    }
summer scroll
#
// MainClass.java
public FileConfiguration getCustomConfig(){
  return this.customConfig;
}

// OtherClass.java
private final MainClass plugin;
public OtherClass(MainClass plugin){
  this.plugin = plugin;
}

public void someMethod(){
  plugin.getCustomConfig().getString(...);
}
``` for example, so you want to pass your main class to the other class using constructors.
abstract sleet
sullen marlin
#

I would love to know when/how the word dependency injection became mainstream

abstract sleet
#

that returns a direction

crude charm
#

ty

abstract sleet
#

you can compare it to another direction (I think that is what you were trying to do) or go Direction.toString() if you want the name of the direction

summer scroll
crude charm
sullen marlin
#

back in my day dependency injection was a mystery thing guice/spring did and that was it

summer scroll
woven coral
#

https://sourceb.in/MOv4h7f2dR - so it doesn't remove my fake voucher, whcih is the paper, but the rest of the code runs fine
so the issue is that if I have 1 paper it wont remove it, but if I have 2, it will remove all

        if (item.getType() == Material.PAPER && item.getItemMeta().equals(createPaper().getItemMeta())) {
            int amount = item.getAmount();
            Material material = Material.PAPER;
            ItemStack itemStack = new ItemStack(material, amount);
            if (p.getInventory().containsAtLeast(itemStack, amount)) {
                p.getInventory().removeItem(itemStack);```
 I tried doing this, but it wouldn't work
summer scroll
#

So you're only passing the necessary thing.

crude charm
#

like this?

 if (DirectionUtil.getDirection(loc.getYaw()) == Direction.NORTH)
summer scroll
crude charm
#

it dont work

#
        //north
        if (DirectionUtil.getDirection(loc.getYaw()) == Direction.NORTH) clipboard.rotate2D(0);
        //east
        if (DirectionUtil.getDirection(loc.getYaw()) == Direction.EAST) clipboard.rotate2D(90);
        //south
        if (DirectionUtil.getDirection(loc.getYaw()) == Direction.SOUTH) clipboard.rotate2D(180);
        //west
        if (DirectionUtil.getDirection(loc.getYaw()) == Direction.WEST) clipboard.rotate2D(270);

summer scroll
#

Debug the DirectionUtil.getDirection(loc.getYaw()) maybe?

abstract sleet
#

are you sure your code is working properly?

#

you should probably use a switch statement as well

switch(DirectionUtil.getDirection(loc.getYaw()) {
  case NORTH:
    clipboard.rotate2D(0);
    break;
  case EAST:
    //...etc
abstract sleet
#

but make sure you debug your own code to make sure it is working properly.

dry beacon
abstract sleet
#

Chek if clipboard.rotate2D is working, check if the code is actually being executed, check if DirectionUtil.getDirection is returning the correct direction

crude charm
#

ofc apart from smth like a command

abstract sleet
#

to debug the method, just add System.out.println("Debug 1") and increment the number each time you use it so that you can identify exactly which parts of the code are and aren't working.

#

You should also add text to the debug logs such as the Direction for example, makes it even easier to source issues.

#

e.g. System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + direction.toString() + ".");

#

What you got currently set up (printing the direction it receives in the switch block) should be enough.

crude charm
#

ok thanks

#

ok

#

so

#

it works

#

apart from west

#

all the rest work

#

or they dont work

#

but it prints correct

#
            case NORTH:
                clipboard.rotate2D(0);
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case EAST:
                clipboard.rotate2D(90);
                printConsole("EAST");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case SOUTH:
                clipboard.rotate2D(180);
                printConsole("SOUTH");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case WEST:
                clipboard.rotate2D(270);
                printConsole("WEST");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
sturdy patrol
#

Mmmmh

#

If you want, I did it in one line in my plugin

#

let's find it...

crude charm
#

sure

sturdy patrol
#

aff nevermind, in my plugin I did the exact invert thing.

crude charm
#

wdym

sturdy patrol
#

sorry x)

crude charm
#

all good

dry beacon
#

I've got a pretty basic question, how can I place my plugin.yml in another folder (in /src), I'm getting a plugin.yml not found error. I've seen people have the file in other folders / packages on github

minor garnet
#

is there a way to identify when the player's tool name has changed ?

drowsy helm
#

in an anvil, yes

minor garnet
#

without a anvil

drowsy helm
#

theres no other vanilla way to change it so no

sullen marlin
#

When it is changed or if it has been changed

#

Two different things

#

When it is changed -> anvil event

#

If it is changed -> ItemMeta#hasDisplayName

minor garnet
#

its bad translator, but

#

I have an item that is named and changed by another plugin, and I want to know if there is a way to identify when this happens

sullen marlin
#

No

minor garnet
#

in the plugin there is no api for it

sullen marlin
#

The other plugin would need to make an event

drowsy helm
#

nothing is called when they rename it, so you cant listen for it

#

unless you have a runnable check every so often but that would be super inefficient

minor garnet
#

not even creating a runnable to check if the item in the hand has a name?

drowsy helm
#

you can cache the name and see if it hs changed

eternal oxide
#

you could check it when its equipped

drowsy helm
#

but it wouldnt be efficient

quiet ice
#

If you want to identify an item persistently you might need to use PDC

eternal oxide
#

use PlayerItemHeldEvent and check its meta

summer scroll
#

Are there any utils or example how to create a subcommand? Like I want to have each class for every command argument, for example the main command is money and the subcommands are deposit, pay, etc.

drowsy helm
#

use acf definitely

#

it's great for stuff like that

eternal oxide
#

a switch statement on args[0] in your onCommand

abstract sleet
summer scroll
#

Currently I have like 15 subcommands, and It's all in one class.

#

Using switch statement on args[0].

#

I feel like that's kinda messy.

eternal oxide
#

yes

#

do you really need 15 sub commands?

summer scroll
#

yes.

eternal oxide
#

are they all truly sub commands?

summer scroll
#

what do you mean by truly?

eternal oxide
#

do they really need to be sub commands of that specific command?

summer scroll
#

oh, yes it needs to be the subcommands of that commands otherwise it's gonna be messy.

#

and might overriding other plugin command.

eternal oxide
#

in that case make a sub command class and register it in your main command class

#

so each sub command gets its own class

abstract sleet
#

I use ElgarL's method above in my plugin, it is working very well and the code is far cleaner than if all subcommands were combined into the same class.

summer scroll
#

I kinda need an example for that.

abstract sleet
#

I'll link you my repo in a tick, in no way is this good code, but just an example that you can see

#

And if anyone has suggestions for it then please let me know

#

All in this subpackage

drowsy helm
#

I'd really recommend ACF

#

or do you not want to use another lib?

summer scroll
#

I don't want to use external lib.

#

In my mind, I will create a SubCommand abstract class.

abstract sleet
#

Have you seen my code aglerr?

summer scroll
#

yes

#
public abstract class SubCommand {
    public abstract String getName();
    public abstract String getDescription();
    public abstract String getSyntax();
    public abstract void perform(CommandSender sender, String[] args);
}
#

and then, on command I check if the args[0] is equalsIgnoreCase to the subcommand name.

abstract sleet
#

I am unsure if any of that is necessary, apart from perform

summer scroll
#

If it's matches, do perform.

abstract sleet
#

I handle syntax etc just inside the subcommand itself

summer scroll
#

Okay, I think I understand now, thanks.

rugged topaz
#

is it possible to create a nametag for the player above their current nametag (sorta like blc prem and hypixel's status system) to display a string? is this through nms, spigot api (armor stands), or..?

summer scroll
#

it's kinda different from lokka, but yeah.

crude charm
#
        switch(DirectionUtil.getDirection(loc.getYaw())) {
            case NORTH:
                clipboard.rotate2D(0);
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case EAST:
                clipboard.rotate2D(90);
                printConsole("EAST");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case SOUTH:
                clipboard.rotate2D(180);
                printConsole("SOUTH");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case WEST:
                clipboard.rotate2D(270);
                printConsole("WEST");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;

why is this not working?

#

it is always spawning north

#

that is full method

#

@abstract sleet

abstract sleet
#

Oh, make sure you are also listening for NORTH_WEST, etc!

#

I will check now.

quaint mantle
#

was Material.getMaterial.(MaterialId) changed in 1.16 bukkit

abstract sleet
#

Use Material.valueOf(materialName) e.g. Material.valueOf("STONE")

abstract sleet
#

Is this the location of the player?

#

Could you add printconsole(loc.getYaw()); to your debug and lmk what that says?

abstract sleet
crude charm
#

oh im dumb

#

nvm

abstract sleet
#

oh shit, I fucked up. 😆
Might have meant to be pitch.

crude charm
#

thats a different place

abstract sleet
#

Yeah, my bad @crude charm

abstract sleet
#

Use getPitch() instead of getYaw() for all of the direction stuff.

abstract sleet
crude charm
#

oh

abstract sleet
#

You can combine multiple cases in a switch statement

crude charm
#

ye

abstract sleet
#

e.g.

case NORTH:
case NORTH_WEST:
  code...
  break;
case WEST:
  code...
  break;
case SOUTH:
case SOUTH_WEST:
  code..
  break;

etc

crude charm
#

why dont u check for north east?

abstract sleet
#

It has north east

#

north, north east, east, south east, south, south west, west, north west.

#

-180 to 180

crude charm
#

hmm

#

ok

#

im a little lost

#

switch(DirectionUtil.getDirection(loc.getYaw())) {

#

should I set it to pitch?

#

I thought pitch was up and down

abstract sleet
#

I got them mixed up, pitch is what we are looking for I think.

crude charm
#

ok

#

OMG IT WORKS

#

kind of

#

just a little off sometimes

#

but apart from that its perfect

#

if I check for the others it will work

#

just a little lost what to check for

abstract sleet
#

I could make the enum more accurate by adding NNW (north north west) etc.

crude charm
#

im already lost for what I should set north west to

#

north

#

or

#

west

#

or

#

idk

abstract sleet
#

Me either. I'd just prioritise north/south

crude charm
#

ok

cosmic sleet
#
            ItemStack[] allItems =  pInv.getContents();
            for (int k = 0; k < allItems.length; k++) {
            }
                getServer().broadcastMessage("" + k);
            }
#

Any idea why k isn t recognized?

crude charm
#
        switch(DirectionUtil.getDirection(loc.getPitch())) {
            case NORTH_WEST:
            case NORTH_EAST:
            case NORTH:
                clipboard.rotate2D(0);
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case EAST:
                clipboard.rotate2D(90);
                printConsole("EAST");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case SOUTH_EAST:
            case SOUTH_WEST:
            case SOUTH:
                clipboard.rotate2D(180);
                printConsole("SOUTH");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;
            case WEST:
                clipboard.rotate2D(270);
                printConsole("WEST");
                System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
                break;

like this?

abstract sleet
cosmic sleet
#

k cannot be resolved to a variable
Syntax error on token "}", delete this token

#

In the cmd

abstract sleet
#

there ya go

#

you have an extra } somewhere.

#

Ooh, I looked past it.

#
ItemStack[] allItems =  pInv.getContents();
for (int k = 0; k < allItems.length; k++) {
  getServer().broadcastMessage("" + k);
}
#

Removed line 3 @cosmic sleet

cosmic sleet
#

?

#

what do you mean

abstract sleet
#

Above the line you broadcast k, you had an extra curly bracket (}).

#

You either need to remove the one on the for(... line, or the one underneath it.

cosmic sleet
#

thx

abstract sleet
#

nw

cosmic sleet
#

i have a question

#

i am making rn a plugin to fetch every 10 seconds the entire inventory of all online players

crude charm
cosmic sleet
#

is it going to take a lot of server performance if i save each inv in a seperate txt file?

summer scroll