#help-development

1 messages ยท Page 1384 of 1

shut plaza
#

help

#

my custom recipe plugin is not working

#

this works well with items on 3*3

#

but not working like this image

#

this is working well

drowsy helm
#

a good note with programming, if it repeatable, you can cut it down

lost matrix
#

Yeah. Im not doing that for sure. I would rather create a quick tool that uses NMS on the latest version and generate one big json file that i can use later on.

drowsy helm
#

check out org.bukkit.craftbukkit.util.CraftMagicNumbers

#

I'm not sure if it's a still a thing tho ill check

lost matrix
#

It is

drowsy helm
#

but there is a getItem(material).canDEstroySpecialBlock(IBlockData)

lost matrix
#

Will be helpful

drowsy helm
#

and a getDestroySpeed in item

#

ig you could match the default with the current item's

lost matrix
# shut plaza but not working like this image

Creating a custom recipe resolver is quite the task. You can do one of two things:
Generate some sort of hash for the 3x3 grid. Map the shape to a Predicate<ItemStack> and iterate over all registered recipes until you find the right one.

drowsy helm
#

i have code for a recipe resolver if you want but it has my own code intertwined in it

shut plaza
drowsy helm
#

you can cut that code down by 80%

#

do that first then you have less points of failure

bright jasper
#

๐Ÿ‘

#

It is brokey

drowsy helm
#

?services

queen dragonBOT
shut plaza
lost matrix
# shut plaza umm.. plz look my code, find error

You will get big problems when someone wants to create a 1x2 or 2x2 or 2x2 or 2x3 or 3x2 or 1x3 or 3x1 recipe. This is quite more complex then you might think.
But im willing to share my MatrixTruncator class when you are at that point.
What does your Bukkit.broadcastMessage(one + "/" + two + "/" + three); tell you when you register a recipe that doesnt work? Is the shape alright?

Also you dont cache the registered recipes anywhere. So when the server restarts, all recipes are gone.

crude charm
bright jasper
#

I need a way to have a player with multiple line tags over their head. Have tried MultilineAPI but it doesn't work and has weird issues with 1.16

shut plaza
bright jasper
#

Cant find any other way to do that

drowsy helm
lost matrix
drowsy helm
#

havent tested it

#

but like along those lines

#

you see how you dont need to set an individual variable for each item

shut plaza
drowsy helm
bright jasper
#

Yeah the namer API was the one that did that, I don't know how i would implement stuff like that myself tho

#

when i use multilineapi

lost matrix
bright jasper
#

wont there be noises and stuff

drowsy helm
#

no

#

you can set silent

#

and no ai

lost matrix
#

Custom nms entity implementation. No noises, no server side ticking.

#

And fully async.

bright jasper
#

oh god nms

drowsy helm
#

you dont have to use nms

#

its just better if you want to optimise

bright jasper
#

๐Ÿ‘ This is the one time i will ask. May a kind soul give me code

bright jasper
drowsy helm
#

protocollib isnt nms

#

its packets

lost matrix
#

But the real problem starts when another plugin tries to mount the player with something. Boy that was a hustle with packet listening and re arranging the nametags.

bright jasper
#

doesnt protocollib use nms?

#

oh no it doesnt nvm

drowsy helm
#

well packets are nms

#

but

lost matrix
#

I mean it does under the hood.

lost matrix
shut plaza
drowsy helm
#

so its not being called

lost matrix
lost matrix
#

Material m11 = i11.getType(); throws a NPE if the slot is empty.

lost matrix
drowsy helm
#

i sent a refactored method before, look at that and see how you can cut down

#

yo smile wanna have a contest

lost matrix
drowsy helm
#

who can write the shortest method for that snippet he gave

lost matrix
#

What are the exact specifications?
Input ItemStack[]
Output String[] which represents the shape?

drowsy helm
#

input inventory probs

#

thats what they original method is

lost matrix
#

Ok. With or without truncation?

drowsy helm
#

eh, with makes it even shorter lol

lost matrix
#

Nope. With it i will at least take an hour.

#

For me at least

drowsy helm
#

alr without then lol

lost matrix
#

Uh sure. So
public String[] toShape(Inventory inv)
But then the ingredients kind of get lost in the process.

drowsy helm
#

in the method
10, 11, 12, 19 20, 21 28,29, 30 are the matrix slots

#

and 23 is output slot

lost matrix
#

So should we just make the shortest code that adds a recipe to bukkit by taking the Inventory as input then?

drowsy helm
#

yeah

#

so can just do void instead

#

of string[]

lost matrix
#

Alright lets try that.

shut plaza
drowsy helm
#

I never tested it, It's jsut a guideline

#

on how you could do it

shut plaza
#

ok

woven flume
#

Has anyone developed a version of tnt that's slightly stronger

drowsy helm
#

null pointer exception

shut plaza
#

oh ok

lost matrix
young knoll
#

That's for drops

#

And TnT already has 100% drop rate

woven flume
#

I understand how i would make tnt itself stronger but how would you create a separate version of tnt

sleek pond
#

Not in any easy way

drowsy helm
#

alr i believe I'm done smile

sleek pond
#

You would have to find a way to make them unstackable

young knoll
#

That's easy...

woven flume
#

Why would they need to be unstackable

sleek pond
#

So you can differentiate between the 2

woven flume
#

I would enchant the second

#

or make it look enchanted I mean

woven flume
young knoll
#

PDC makes it easy to distinguish between the items

#

It's a bit harder when they are placed

lost matrix
#

woops not yield. Strenght

#

obvsly...

woven flume
#

I'm just not clear on how to add a new item

young knoll
#

You'll need to store the custom TNT in a database or chunk PDC

woven flume
#

I've never done it before

shut plaza
drowsy helm
#

you're printing the entire class

shut plaza
#

i can't see printStackTrace() because of this

woven flume
young knoll
#

Look at any plugin that handles custom block data

#

Sliemfun does, but that may not be the best example

woven flume
#

I realize this sounds really dumb but could you provide a specific example?

shut plaza
woven flume
#

I'm the type of learner that needs to look at a specific section that clearly demonstrates something

young knoll
#

I don't have a specific example

woven flume
#

Would you be willing to find one? I have been finding this problem really frustrating so it would be a tremendous help

drowsy helm
lost matrix
#

The recipe i mean

drowsy helm
#

yeah I think I'm done

#

may not be efficient but it's short lel

lost matrix
#

Im almost done

shut plaza
young knoll
#

You're trying to set the item for a recipe key, but the recipe doesn't have that key

shut plaza
#

can i set ingeident before shape?

woven flume
#

What command would I use to spawn tnt at a certain location

young knoll
#

Command? /summon

drowsy helm
#

no, you need to set shape first

woven flume
#

But what is the entity name for a primed tnt

drowsy helm
#

wait i think

#

dont 100% remember

woven flume
#

I saw that it changed from primetnt in 2018

bright jasper
#

Is there just an API that lets me set a custom username above head, ive tried all the public ones but they either dont work with spaces or dont support hex colors

young knoll
#

I mean, /summon lets you tab through all entities

shut plaza
bright jasper
young knoll
#

AreaEffectClouds may also be useful for that

#

The problem I had was invisible entities hiding them name of lower entities in the stack

shut plaza
#
            ItemStack[][] map = new ItemStack[][] {
                new ItemStack[] {inv.getItem(10), inv.getItem(11), inv.getItem(12)},
                new ItemStack[] {inv.getItem(19), inv.getItem(20), inv.getItem(21)},
                new ItemStack[] {inv.getItem(28), inv.getItem(29), inv.getItem(30)}
            };
            
            int charIndex = 65; // 0x41
            List<String> tier = new ArrayList<>();
            ItemStack result = inv.getItem(23);
     
            NamespacedKey key = new NamespacedKey(Main.pl, "ay");
            ShapedRecipe r = new ShapedRecipe(key, result);
            
            for(ItemStack[] f : map) {
                StringBuilder sb = new StringBuilder();
                for(ItemStack s : f) {
                    if(s == null) {
                        sb.append(" ");
                    }else {
                        sb.append((char)charIndex);
                    }
                    r.setIngredient((char)charIndex, s.getType());
                    charIndex++; 
                }
                tier.add(sb.toString());
            }
            
            r.shape(tier.get(0), tier.get(1), tier.get(2));
     
            Bukkit.addRecipe(r);
        } catch (Exception e) {
            Bukkit.broadcastMessage(e.getMessage());
        }

OK, and @drowsy helm 's code set ingerdiit first

lost matrix
# drowsy helm no, you need to set shape first

Ok im done:

  private static final int[] MATRIX_SLOTS = {10, 11, 12, 19, 20, 21, 28, 29, 30};
  private static final int RESULT_SLOT = 23;

  public void register(final Inventory inventory) {
    final AtomicInteger c = new AtomicInteger('A');
    final String line = Arrays.toString(IntStream.rangeClosed(0, 9)
        .map(i -> SpigotCore.MATRIX_SLOTS[i])
        .mapToObj(inventory::getItem)
        .map(i -> i == null ? ' ' : (char) c.getAndIncrement())
        .toArray(Character[]::new));
    final String randomName = Arrays.toString(IntStream.generate(ThreadLocalRandom.current()::nextInt)
        .limit(10)
        .map(char.class::cast)
        .toArray());
    final ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.minecraft(randomName), inventory.getItem(SpigotCore.RESULT_SLOT));
    recipe.shape(line.substring(0, 3), line.substring(3, 6), line.substring(6, 9));
    c.set('A');
    IntStream.rangeClosed(0, 9).map(i -> SpigotCore.MATRIX_SLOTS[i]).forEach(index -> {
      ItemStack i;
      if((i = inventory.getItem(index)) != null) recipe.setIngredient((char) c.getAndIncrement(), i.getType());
    });
  }
drowsy helm
#

ouu i like that

young knoll
#

One letter variables everywhere

lost matrix
#

We should make the code as short as possible. So readability was no concern XD

drowsy helm
#
    
    void addCustomRecipe(Inventory inv) {
        ItemStack[] map = new ItemStack[] {inv.getItem(10), inv.getItem(11), inv.getItem(12), inv.getItem(19), inv.getItem(20), inv.getItem(21),inv.getItem(28), inv.getItem(29), inv.getItem(30)};
        NamespacedKey key = new NamespacedKey(plugin, "");
        ShapedRecipe r = new ShapedRecipe(key, inv.getItem(23));
        char indexChar = 'a';
        String output = "abc,def,ghi";
        for(ItemStack item : map) {
            if(item == null) output.replace(indexChar, ' ');
            r.setIngredient(indexChar, item.getType());
            indexChar++;}
        r.shape(output.split(",")[0], output.split(",")[1], output.split(",")[2]);
        Bukkit.addRecipe(r);
    }```
#

but now i realise i can't set ingredient before hand so I'm sorta disqualified lmao

#

and i didnt do a random name

#

so i think you win smile lol

lost matrix
#

lul smileybolb

#

If i look at that code in like 10min im just conna be confused

drowsy helm
#

never new char had a getAndIncrement method thats great

#

lmao, doesn't need to be readable just works

lost matrix
#

Thats from AtomicInteger so i had an effectively final mutable character in my streams

crude charm
drowsy helm
#

oh thats awesome, never worked with AtomicInts before

#

needa check that out

young knoll
#

Wait until you try AtomicBombs

lost matrix
#

Its normally used for multithreading. But MutableInt from apache is normally the way to go.

drowsy helm
#

yeah I only use atomic stuff for my async stuff thats about it

#

even then ,rarely

drowsy helm
lost matrix
# drowsy helm Sounds interesting ๐Ÿค”๐Ÿค”๐Ÿค”
  private final Map<UUID, Integer> scores = new HashMap<>();

  public void incrementScore(final UUID id) {
    final int current = this.scores.getOrDefault(id, 0);
    this.scores.put(id, current + 1);
  }

  public int getScore(final UUID id) {
    return this.scores.getOrDefault(id, 0);
  }

Can be simplified to

  private final Map<UUID, MutableInt> scores = new HashMap<>();

  public void incrementScore(final UUID id) {
    this.scores.computeIfAbsent(id, key -> new MutableInt()).increment();
  }

  public int getScore(final UUID id) {
    return this.scores.getOrDefault(id, new MutableInt()).intValue();
  }
drowsy helm
#

does that use maps?

lost matrix
#

I mean... you could also do this:

  private final Map<UUID, Integer> scores = new HashMap<>();

  public void incrementScore(final UUID id) {
    this.scores.compute(id, (key, value) -> value == null ? 0 : value + 1);
  }

  public int getScore(final UUID id) {
    return this.scores.getOrDefault(id, 0);
  }

But thats not as understandable.

drowsy helm
#

streams sorry not maps

#

you said that's apache right?

woven flume
#

I'm really just struggling to understand how i create a custom variant of an item

lost matrix
#

No streams. Just lamdas. I use MutableInts in Maps because then i dont need to get the element, do stuff with it and then put it back in.
Because Integers are immutable you have to always change the value of your map. If its mutable then you can just get it and mutate it as you like.

lost matrix
drowsy helm
#

Ah I see yeah that's really interesting I think I'll adopt that more

lost matrix
crude charm
woven flume
#

Does it have a pdc by default?

woven flume
drowsy helm
#

so let me get this right you want a custom tnt block right

#

taht explodes bigger

woven flume
#

Yes

lost matrix
woven flume
#

I know it's probably juvenile for an experienced minecraft dev

#

But i haven't done any work with minecraft before

#

I'm just trying to help a friend add a stronger tnt to his server

crude charm
lost matrix
drowsy helm
#

theres no real way of differentiating a tnt block once it is placed

#

so it might be hard keeping track of it

lost matrix
#

Oh god scoreboards... looks like luckperms is missing some RegisteredServiceProvider<>

woven flume
#

How about a way to make a custom tnt summon a second tnt to its explosion?

#

Nevermind that would probably have the same issue

crude charm
#

its an api

#

made by the same guy tho

drowsy helm
#

it would be easy to modify any tnt explosion

#

but just for some explosions may be hard

crude charm
lost matrix
woven flume
#

Do you have any suggestions on workarounds

#

I just want a variant which is a bit better for raiding

#

Any insight is really appreciated

#

The advice so far has been really educational ๐Ÿ™‚

lost matrix
#

If you are fine with just a primed tnt spawning that has a longer fuse time instead of a block that is placed then i can give you a simple solution.

drowsy helm
#

you could always cache the location, but theres no permanence over restarts

woven flume
#

I think we found a way to make a longer fuse time but that probably wouldnt make raiding all that easier

young knoll
lost matrix
woven flume
#

Actually I think we just found a plugin!

#

Thanks so much guys, I really appreciated this

lost matrix
woven flume
drowsy helm
#

i wolder how they did it

woven flume
#

We are looking into it

lost matrix
#

Lets decompile it and see ๐Ÿ˜„

drowsy helm
#

they have one main class

#

thats always good

#

it just primes the tnt

#

instantly

#

lmao

lost matrix
#

Thats what we suggested earlier...

young knoll
#

I believe I have a adapter that can store xyz+string

#

Actually itโ€™s an array of a custom class that stores xyz+string

#

Same idea though

crude charm
woven flume
#

So did you see a problem with it?

#

Srry if I wasted your time

drowsy helm
#

lmao no you didnt

#

it's pretty badly coded

#

but if you dont mind it instantly priming you could use it

lost matrix
woven flume
#

Maybe I wasn't specific

#

I was looking for that

#

I think i got confused

lost matrix
#

Lol ok. Then i can give you a bit of that juicy spoon feed

young knoll
#

๐Ÿฅ„

drowsy helm
#

pls spoonfeed me smile ๐Ÿ˜ซ

woven flume
#

How did you decompile it btw? The plugin comes with x10, x100, x100 but we would like to alter it to be a bit more manageable.

drowsy helm
#

use jdgui

#

for decompiling

young knoll
#

Or any decompiler

drowsy helm
#

or any yes, but i like jd lel

young knoll
#

Iโ€™ve never tried using one to modify and recompile anything

drowsy helm
#

can you not just use the default spigot stuff

crude charm
#

I did

#

before

#

but it didnt work too well

drowsy helm
#

It looks like it just isnt registering the service, either theres a setup step that you missed or the api is broken

#

theres probably a help discord for that api

crude charm
#

there is

#

but no replys

#

only 163 people

lost matrix
# woven flume How did you decompile it btw? The plugin comes with x10, x100, x100 but we would...

This class does it all for you:
https://gist.github.com/Flo0/2563702ddff61a3bde726dd7933f7029

Example usage:

public class SpigotCore extends JavaPlugin {

  private TNTManager tntManager;

  @Override
  public void onEnable() {
    this.tntManager = new TNTManager(this);
  }

  public ItemStack createTNT(final float strength, final float yield, final int fuseTime) {
    final ItemStack tntItem = new ItemStack(Material.TNT);

    final ItemMeta meta = tntItem.getItemMeta();
    meta.setLore(Arrays.asList("", "ยง7Str: " + strength, "ยง7Yield: " + yield, "ยง7FuseTime: " + fuseTime));
    tntItem.setItemMeta(meta);

    this.tntManager.setStrength(tntItem, strength);
    this.tntManager.setYield(tntItem, yield);
    this.tntManager.setFuseTime(tntItem, fuseTime);

    return tntItem;
  }

}

Result:

young knoll
#

Now Iโ€™m tempted to make a proper more tnt plugin with a resource pack and all

#

Hmm

#

Another idea for the pile I suppose

lost matrix
# young knoll Another idea for the pile I suppose

I got like 10 different project ideas with half written plugins laying around. One Just the usual boost of creativity each month that slowly fades into a new cool idea that is never going to be finished.

young knoll
#

Pretty much

lost matrix
#

But i actually currently re-write AdvancedMachines 2.0.0 which is almost done and will def be released ๐Ÿ˜„

young knoll
#

Sounds fancy

#

I probably wouldnโ€™t even need and pdc storage if I just used noteblock states, although the issue with that is compatibility with other plugins, and disabling note blocks...

#

Data driven blocks when Mojang

lost matrix
young knoll
#

Blocks are the big ones

#

People have done some impressive mobs and guis already

lost matrix
#

Custom blocks are also a thing. But all of those 3 have really big drawbacks.
The mobs lag the server like hell. The GUIs are not dynamic (So bars etc are really hard)
and blocks might also lag the server (if done with spawners) or replace current states.

young knoll
#

Origin realms doesnโ€™t seem to be doing too bad with what they have

lost matrix
#

Let me google that

lost matrix
#

But i guess you can do a lot already. But in every video i saw the guy was like "origin realms is experiencing lags"

young knoll
#

Yeah makes sense

#

Fun to look at though

crude charm
#

angryfrown I AM SO SO SO SO SO SO ANGRYangryfrown

lilac dagger
#

hi angy

crude charm
#

this stupid scoreboard

lilac dagger
#

why are you suffering?

#

what you can't solve on it?

crude charm
#

BECAUSE ITS ME

#

STUPID SCOREBOARD angryfrown

#

util

#

dont work

#

3 apis

#

dont work

#

compiling it into my project

lilac dagger
#

you don't need utils or api

#

just use the bukkit one

crude charm
#

but... but... but

#

im about to cry Crying

#

wow pepe crying actually got me emotional

#

ok the ultimate soundcloud @lilac dagger

#

I will use bukkit scoreboard

#

just for you

lilac dagger
#

๐Ÿ‘€ that's the api

#

it works great

#

been using the default

crude charm
#

WE'LL SEE ABOUT THAT ONE

#

HAHAHAHAHAHAHAHA

cerulean valley
#

itemframes seem to lose all persistent data attached to them, any workaround for it?

eternal oxide
#

are you actually using teh PDC or just meta?

cerulean valley
#

PDC

#

talking about the itemframe entity, not the item

eternal oxide
#

Yes, the entity has both PDC and meta which is why I asked

crude charm
#

I need to know something, he says crying

#

can you use a list to add the lines using spigot scoreboard, it reluctantly asks @eternal oxide

opal juniper
#

What is a good way of getting a hash for the setResourcePack?

#

I need to it stay the same if the resource pack stayed the same

lilac dagger
#

use an website

#

or digest the resource yourself

#

to extract the sha1

near crypt
#

i try to code a mlg plugin and i want to tp the player 40 blocks in the air, but only when there is not a block over the player not even in 1000 blocks hight how can i do this?

#

in 1.16

cerulean valley
#

the problem might be the update method from CraftItemFrame:

    private void update() {
        EntityItemFrame old = this.getHandle();

        WorldServer world = ((CraftWorld) getWorld()).getHandle();
        BlockPosition position = old.getBlockPosition();
        EnumDirection direction = old.getDirection();
        ItemStack item = old.getItem() != null ? old.getItem().cloneItemStack() : null;

        old.die();

        EntityItemFrame frame = new EntityItemFrame(world, position, direction);
        frame.setItem(item);
        world.addEntity(frame);
        this.entity = frame;
    }
eternal oxide
near crypt
#

but i dont want just the highest block i want every block in the range from the players hight to lets say 1000 or so

eternal oxide
near crypt
#

and how can i compare it?

crude charm
#

this is what I wanna do

#

    public String getTitle(Player player) {
        return Hub.mainColour + Hub.serverName;
    }

    public List<String> getLines(Player player) {
        final List<String> line = new ArrayList<>();

        line.add(Hub.ambientColour + "----------------------------");
        line.add(Hub.mainColour + "PlayerCount:");
        line.add(Hub.secondColour + "1");
        line.add(" ");
        line.add(Hub.mainColour + "Rank:");
        line.add(Hub.secondColour + Hub.rankPlaceholder(player));
        line.add(Hub.ambientColour + "---------------------------- ");

        return line;
}

    }

I wanna use these values

near crypt
#

i have this code at the moment: import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class mlgCommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    
    if(sender instanceof Player) {
        Player p = (Player) sender;
        if(args.length == 0) {
            Location mlg = p.getLocation().add(0, 60, 0);
            p.teleport(mlg);
        } else
            p.sendMessage("ยงcBitte benutze ยง6/mlg");
    }
    return false;
}

}

crude charm
#
```java
is a think u know
near crypt
#

how can i do this?

crude charm
#

'''java

near crypt
#

ah okay

#

sorry

#

'''java import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class mlgCommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    
    if(sender instanceof Player) {
        Player p = (Player) sender;
        if(args.length == 0) {
            Location mlg = p.getLocation().add(0, 60, 0);
            p.teleport(mlg);
        } else
            p.sendMessage("ยงcBitte benutze ยง6/mlg");
    }
    return false;
}

}

#

hmmm....

drowsy helm
#

3 more on the other size

#

side

crude charm
#

nonono

near crypt
#

oh hahaha

crude charm
#

ye

near crypt
#

'''java import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class mlgCommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    
    if(sender instanceof Player) {
        Player p = (Player) sender;
        if(args.length == 0) {
            Location mlg = p.getLocation().add(0, 60, 0);
            p.teleport(mlg);
        } else
            p.sendMessage("ยงcBitte benutze ยง6/mlg");
    }
    return false;
}

}'''

#

ups

drowsy helm
#

you are using '

#

not `

crude charm
#

`

drowsy helm
#

top left ontop of the tilda key

crude charm
#

`` then a third

near crypt
#

xD iam so lost sooorry guys ๐Ÿ˜ฆ

drowsy helm
#

you're fine man lmao

young knoll
#

If the getHighestBlockY is > the player Y then there is a block above them

drowsy helm
#
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class mlgCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        if(sender instanceof Player) {
            Player p = (Player) sender;
            if(args.length == 0) {
                Location mlg = p.getLocation().add(0, 60, 0);
                p.teleport(mlg);
            } else
                p.sendMessage("ยงcBitte benutze ยง6/mlg");
        }
        return false;
    }


near crypt
#
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class mlgCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if(sender instanceof Player) {
            Player p = (Player) sender;
            if(args.length == 0) {
                Location mlg = p.getLocation().add(0, 60, 0);
                p.teleport(mlg);
            } else
                p.sendMessage("ยงcBitte benutze ยง6/mlg");
        }
        return false;
    }
    
        

}```
crude charm
#

close

near crypt
#

yes

#

and can someone help me?

crude charm
#

just gotta add java now

#

so it colours it

drowsy helm
#

dont worry we see the code now

near crypt
#

ah okay

drowsy helm
#

so what exactly is the problem with it?

dense kestrel
near crypt
#

i want that the player can not teleport when there is a block anywhere over his had

#

even in hight 1000 or so

dense kestrel
#

here

#

let me send ya something

near crypt
#

okay

eternal oxide
#

You were already told. getHighestBlockY and compare to the players Y. if its greater then there is a block above them.

drowsy helm
#

p.getWorld().getHighestBlockYAt(p.getLocation())

near crypt
#

ah okay

#

now i get it

drowsy helm
#

then if that location is higher than their loc, they cant

near crypt
#

i guess

dense kestrel
#

Wait, you said any height?

near crypt
#

yes

cerulean valley
#

if there is any single or multiple block above the player, then the highest block at the players position is higher than the players position itself

#

no need to check for more blocks

near crypt
#

ok

dense kestrel
#

why not just do the highest block up to the height limit? I mean technically the height can go up forever....

#

if ya set your server with no limit

drowsy helm
#

}```
#

easy done

eternal oxide
#

getHIghestBlockYAt returns an int of the highest block

drowsy helm
#

thats all you need to check

near crypt
#

okay thanks guys i love you

quaint mantle
#

Sus!

young knoll
dense kestrel
young knoll
#

It canโ€™t be raised

#

Only lowered

dense kestrel
#

hell, i never worry about that because i only code for 1.8 XD

#

you sure? I think you can on Hyperion jar

young knoll
#

Maybe with a ton of jank to the games internals

#

No idea how the client will respond

dense kestrel
#

lol, i know that a lot of cannon jars have a max y option

cerulean valley
#

as far as i know, the client only knows how to handle blocks up to 256, only with the 1.17 snapshots there is the support for higher blocks

#

and that, like the others said, the limit setting can only be lowered

young knoll
#

Yeah the internal data structures just donโ€™t support above that

dense kestrel
#

ahh, tbh i never touched it

#

i just saw it in some jars configs

drowsy helm
#

yeah its probably max input between 0 and 256

#

anything over the client isnt made to deal with

dense kestrel
young knoll
#

Not sure why any fork would need that considering itโ€™s in vanilla(?)

#

I think itโ€™s vanilla anyway

dense kestrel
#

idk, they just add it usually lol

dense kestrel
#

most those forks are $500 each XD

dense kestrel
crude charm
#

Forks of what

dense kestrel
eternal oxide
dense kestrel
#
    public static boolean idkWhatToNameThis(Location loc) {
        while (loc.getBlock().getType().equals(Material.AIR)) {
            if (loc.getBlockY() >= 256) {
                return true;
            }
            loc = loc.add(0, 1, 0);
        }
        return false;
    }

@near crypt this should work

crude charm
dense kestrel
#

Cannon Jars

crude charm
#

Only stella sells for that much

near crypt
#

noo i get it now

dense kestrel
#

lol, i can name at least 5 that are that much XD

near crypt
#

i think

crude charm
#

Even tho its not amazing, the supreme of server jars lmfao

#

What others?

young knoll
dense kestrel
#

StellarSpigot, GemSpigot, Hyperion, Bestles, etc

dense kestrel
crude charm
#

They private thp

dense kestrel
#

public

#

they just cost like 500 each

crude charm
#

Fr?

dense kestrel
#

yea

#

and they sell hella well

crude charm
#

Thought they were provate

dense kestrel
#

Bestles is

#

but its like 20k

crude charm
young knoll
#

If you are spending $500 on a silly 1.8 optimized fork then you may want to re-evaluate some things

crude charm
#

Ikr

dense kestrel
crude charm
#

Its a fucking jar

dense kestrel
#

or cannons dont work

crude charm
#

Makes sens for cores

dense kestrel
#

cant have a Factions server without it

#

and none are cheap

crude charm
#

But not spigot.jar

#

Its a fork

#

For 50l

dense kestrel
#

they have no option

young knoll
#

Cannons work fine?

dense kestrel
#

they have to pay it

crude charm
#

No

dense kestrel
#

no they dont without a cannon jar

crude charm
#

Buy one cheaper

young knoll
#

Whatever

crude charm
#

Make ur own

dense kestrel
#

none are cheap

#

they all sell for a fuck ton

crude charm
#

Optimise a cheap one

young knoll
#

If you want some fancy cannons, make a plugin for it

dense kestrel
#

there are no cheap ones, they all just sell for a ton

#

XD

crude charm
#

Aspigot

dense kestrel
crude charm
#

Beer spigot

dense kestrel
#

here let me show ya something

crude charm
#

Sure

#

Im not a factions guy

#

I do prac, kitpvp, hubs, server cores, ffa, uhc, meetup and so on

dense kestrel
#

ok, found a SS

#

let me show ya have the jars have to handle multiple of (all shotting at 2sec-3sec each) and hold a steady 20tps

#

this is just a basic raiding cannon

#

without sand loaded ofc

#

if you dont have a good jar your server will just go to 2tps and the cannons just blow up

crude charm
#

Is โ€œconsider meโ€ a thing people put in their name

#

I swear ive done commission work for like 5 people with that in their name

dense kestrel
#

No idea, iv had this account for 8 years

crude charm
#

๐Ÿ˜ฏ

dense kestrel
crude charm
dense kestrel
#

Yea, well thats why they cost so much though

crude charm
#

Ik but it still seems crazy, a fork of spigot costs the same as a server core

#

Server cores take months, with alot of knowledge this can take a week

dense kestrel
#

Trust me, those forks dont take a week XD

crude charm
#

I bet if u know what ur doing and ur me (working from 9-1am) then it would take a week

near crypt
#

and how can i tp the player in the hight that he gives in the command for example /mlg 100 (100 blocks in the height)

dense kestrel
#

change the method to return a location at the top block if its air

#

or pass Player into the method

#

and right before ya return try

#

ture*

#

just tp the player to the location

near crypt
#

ยดยดยดimport org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class mlgCommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    
    if(sender instanceof Player) {
        Player p = (Player) sender;
        if(args.length == 0) {
            if(p.getLocation().getBlockY() > p.getWorld().getHighestBlockYAt(p.getLocation())){
                Location mlg = p.getLocation().add(0, 60, 0);
                p.teleport(mlg);
            } else
                p.sendMessage("ยงcEs dรผrfen sich keine Blรถcke รผber dir befinden!");
        } else if(args.length == 1) {
            Location customMlg = p.getLocation().add(0, args[0], 0);
        }ยดยดยดjava
        
    }
    return false;
}

}

#

damn

young knoll
#

If you check that they have given at least one argument, you can parse it to an integer with parseInt

near crypt
#

shit sorry

#

๐Ÿ˜ฆ

dense kestrel
#

you new to coding?

near crypt
#

yeah a bit

dense kestrel
#

ahh

near crypt
#

?

dense kestrel
#

Integer.parseInt(args[0])

near crypt
#

okay thx

dense kestrel
#

np

summer scroll
#

How do I check If the player has specific amount of itemstack with nbt tag on their inventory?

quaint mantle
#

not worth it

summer scroll
#

You mean it's bad for performance?

near crypt
#

how can i cap the Integer so that i cant give /mlg 100000

quaint mantle
#

idk

summer scroll
near crypt
#

oh yes true

summer scroll
quaint mantle
summer scroll
#

i'm currently creating a shop with item as the currency, custom item that has nbt tag on it.

quaint mantle
#

nah

#

use PDC

#

1.14.4+

summer scroll
#

pdc is nbt tags

#

i'm on 1.16.5

quaint mantle
#

use a persistantdatacontainer

summer scroll
#

well, spigot api nbt tag

quaint mantle
#

pretty much

summer scroll
#

and i'm using that currently

mortal hare
#

are there anyone good with netty?

#

how can i discard data received through the pipeline channel handler?

mortal hare
#

nvm

near crypt
#

why cant i do this?

#

ยดยดif(p.getItemInHand().getType() == Material.WATER_BUCKET) {

                }ยดยดยดjava
#

ยดยดยดif(p.getItemInHand().getType() == Material.WATER_BUCKET) {

                }ยดยดยด
#
                        
                    }```
#

sry

eternal oxide
#

What do you mean why can;t you do it?

near crypt
#

getItemInHand is crossed out

#

and yellow underlined

eternal oxide
#

deprecated. use getItemInMainHand()

mortal hare
#

This is deprecated because 1.9 introduced second hand mechanic

near crypt
#

there is no p.getItemInMainHand

mortal hare
#

what kind of spigot api are you using

near crypt
#

normal 1.16.5 spigot

mortal hare
#

#Player.getInventory().getItemInMainHand()

near crypt
#

oh okay

vapid oyster
#

How would I get the display name of a Written Book?

#

I tried itemStack.getItemMeta().displayName() but I always get null

quaint mantle
#

getDisplayName() returns the item name

#

so you shouldn't be unless you're doing something else

#

are you iterating through the player's contents?

#

or how are you getting the item

vapid oyster
#
    public void questBook(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        player.sendMessage("Event fired!");
        ItemStack itemStack = event.getItem();
        if (event.getHand() == EquipmentSlot.HAND) {
            player.sendMessage("Hand");
            if (itemStack != null) {
                player.sendMessage("Not Null");
                player.sendMessage(itemStack.getItemMeta().displayName().toString());```
near crypt
#

and how can i check the armor of a player?

vapid oyster
quaint mantle
#

is displayName() really working for you @vapid oyster

#

the function is getDisplayName()

vapid oyster
#

That's depreciated for me, but I'm using Paper API, so maybe that's why

near crypt
#

How can i check the armor of a player when i created a variable for the player

#

so player. ...

sage swift
#

getArmorContents

eternal oxide
#

getInventory()

vapid oyster
#

player.getInventory().getArmorContents()

sage swift
#

of inventory

near crypt
#

yes thx

#

and how can i ask if the armor contains a specific armor piece?

#

if(!p.getInventory().getArmorContents().)java

#

this is my code

eternal oxide
#

getArmorContents() returns an array, so check each for a match

near crypt
#

and what is the code if i want to check if a player has a elytra?

eternal oxide
#

equipped? it will be in an armor slot

near crypt
#

yes when a elytra is equipped

oak torrent
#

ok so I need help with some code

#

idk how it works

#

and, like i have never used this ways in normal java

sage swift
#

?paste

queen dragonBOT
oak torrent
#

yes sorry

sage swift
#

check that sender is player

#

don't call main class Main

oak torrent
#

im new

#

wdym?

sage swift
#

return false will show usage you defined in plugin.yml

near crypt
#

@eternal oxide do you solved my problem?

sage swift
#

check the appropriate slot in the array, Skull.

oak torrent
#

what about private Main plugin?

sage swift
#

don't call the main class Main

oak torrent
#

is that even possible in java?

eternal oxide
#

no

oak torrent
#

ok

sage swift
#

it will conflict with standalone application naming of Main

oak torrent
#

i see

sage swift
#

i usually just call the main class the name of the plugin

oak torrent
#

look, im c++ gang

#

i dont get java

#

so this is a little bit confusing

eternal oxide
#

An applications Main class is when that application is an executable that instances itself. A plugin is instanced by Spigot so Spigot has a Main, your plugin should use something else, like your plugins name as its main class.

oak torrent
#

private CreeperSpawn plugin; so what does this do now?

#

Like, is it a variable?

sage swift
#

it stores the plugin object so it can be accessed

eternal oxide
#

thats a private field (variable)

oak torrent
#

but it is not accessed

near crypt
#

@sage swift how can i get the slot of the array and what is the slot of the Elytra

sage swift
#

and when you create the command class it sets the variable to the plugin object so you can use it locally

eternal oxide
#

that as you wrote it is defined but not initialized

sage swift
near crypt
#

ik how but not where

#

with []

sage swift
#

so what do you think is the elytra slot

#

out of 4

near crypt
#

2

sage swift
#

ok

eternal oxide
sage swift
#

so getArmorContents()[1] should be sufficient.

near crypt
#

ah okay

sage swift
#

check null first, of course

near crypt
#

yes

oak torrent
#

cant I just use the args?

#

instead of this private CreeperSpawn plugin;

#

this public CreeperCommand(CreeperSpawn plugin)

eternal oxide
#

assign teh class field from that constructor

#

Dependency injection

near crypt
#
                            Location mlg = p.getLocation().add(0, 60, 0);
                            p.teleport(mlg);
                        } else
                            p.sendMessage("ยงcDu darfst keine Elytra anhaben");
                    } else```
#

so is this right?

eternal oxide
#

no

#

Arrays index on zero

near crypt
#

why? the elytra is on 2 or not?

eternal oxide
#

No, its in the 2nd slot, which is not [2]

near crypt
#

so 1 because it begins at 0

eternal oxide
#

yes

near crypt
#

but it is still not right

eternal oxide
#
ItemStack chest = p.getInventory.getArmorContents()[1];
if (chest == null || chest.getType() != Material.ELYTRA) {
//codehere
}```
#

or != as you want to do it if they are not wearing an elytra

near crypt
#

ty

#

why did i do this with null

eternal oxide
near crypt
#

but now it always say that i wear a elytra

#

so the else

eternal oxide
hybrid spoke
eternal oxide
#

you never use equals on null nor an enum comparison

cerulean valley
#

why not on enums? (i know that == also works there though)

exotic plaza
#

How to make this optmize?

Entity victim2 = victim.getEntity();
        if (victim2 instanceof Player){
            Player p = ((Player) victim2).getPlayer();
            if (p.hasPermission("damage.get.1")){
                victim.setDamage(level1_getdamage);
            }
            if (p.hasPermission("damage.get.2")){
                victim.setDamage(level2_getdamage);
            }
            if (p.hasPermission("damage.get.3")){
                victim.setDamage(level3_getdamage);
            }
            if (p.hasPermission("damage.get.4")){
                victim.setDamage(level4_getdamage);
            }
eternal oxide
cerulean valley
#

yes

hybrid spoke
#

That is completely wrong.

I think the #equals() method is better for reasons written out here: https://stackoverflow.com/a/14874376/14574069

Besides, after further research, it doesn't matter in the end because the #equals() method of an enum 1. cannot be overwritten and 2. looks like this:

    public final boolean equals(Object other) {
        return this==other;
    }
eternal oxide
hybrid spoke
eternal oxide
#

that statement is true

#

an equals check does defer to == however equals is not null safe

hybrid spoke
eternal oxide
#

yes and its NOT null safe

quiet ice
#

Plus it is an additional method call

hybrid spoke
eternal oxide
#

what is an extra method call?

hybrid spoke
eternal oxide
#

Its not ignoring it, its null safe checking.

quiet ice
#

Use #ordinal(), it is not null safe and it safe for when people are doing strange shit with reflection

cerulean valley
#

null safe checking is good if you expect a value to be null

eternal oxide
#

This is java. nulls are everywhere

fading lake
#

"strange shit with reflection" lmfao

cerulean valley
#

exactly

#

so sometimes you'd rather have an exception if something isn't supposed to be null but somehow is it anyway

quiet ice
cerulean valley
#

personally i use .equals when the enum is used in a more object-like context, and == when it's used in a more constant-like context

#

and == for small pieces of code where i know or don't know if it can be null and don't care about it XD

lost matrix
#

Enums should always compared by their identity. Its null safe and internally its compard like this anyways

cerulean valley
#

null-safety is not always a good thing

#

that was the argument being made

lost matrix
#

lol. when is being null safe not a good thing?

cerulean valley
#

scroll up

lost matrix
#

How far ^^ link plz

cerulean valley
quiet ice
#

Generally you will never have null enums

#

If you have your API is flawed and you'd need to rethink it

#

If you use null as another state of an enum, why not just make another enum state?

cerulean valley
#

yep, that's another reason why throwing an exception is better

quaint mantle
#

how to fix this when trying to add an enchantment to block item?
'addEnchant(org.bukkit.enchantments.Enchantment, int, boolean)' in 'org.bukkit.inventory.meta.ItemMeta' cannot be applied to '(net.minecraft.server.v1_8_R3.Enchantment, int)'

#

line:

meta.addEnchant(Enchantment.ARROW_FIRE, 1);```
cerulean valley
#

(i think this is starting to become more of a philosophical discussion and unrelated to this channel)

lost matrix
quiet ice
#

What I'm saying is that it's that you need to try very hard to get null enums, internal java API throws exceptions when trying to look up wrong enum states

cerulean valley
#

using "==" is not always a "covering the case" thing though, it can just as likely be being ignorant to it

quiet ice
#

More often than not the application will run just fine being null safe

cerulean valley
#

if the value being null is an invalid state of the program, the == operator will not do anything about it, instead of noticing that the state is invalid

#

i'm not saying "==" is bad or to never use it, i use it most of the times, but i think there are enough valid use cases for .equals

lunar wigeon
#

guys how can i make Fake packet?

eternal oxide
#

equals has its uses, they are just not for null or enum checks.

lost matrix
lunar wigeon
#

fake packets

quiet ice
#

How can I breathe?

#

Well, my question was more specific than yours

lost matrix
lunar wigeon
#

you know

#

fake packets

quiet ice
#

We do not know

lunar wigeon
#

packets but fake

eternal oxide
#

use a pencil and copy a packet so you have a fake one?

lunar wigeon
#

yes

quiet ice
#

Fake as in "not sent to the client" or as in "sent to the client but not sent naturally"

lunar wigeon
#

but

#

i want to send packets

#

but fake

lost matrix
#

I mean... you could just write a serializer that sends the client random bytes... the notchian client will most likely just throw them away. Thats pretty fake.

eternal oxide
#

I'm sensing troll

quiet ice
#

That is an excellent explanation of your question, support will arrive soonโ„ข๏ธ

cerulean valley
#

use nsm code, e.g. ((CraftPlayer)player).getHandle().playerConnection.sendPacket(...)

quiet ice
#

Yes, but that is not fake

#

You are actually sending a real packet

lost matrix
cerulean valley
#

no no, the packet is fake, not the delivery system:
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new FakePacket(...))

quiet ice
#

But by sending it you are materialising it in a real packet, I don't get it

cerulean valley
#

๐Ÿค”

#

true

eternal oxide
#

Silly, just use the fakePlayerConnection.

quaint mantle
#

packets r real

lost matrix
open lily
#

you can implement fakePackets

#

like @lunar wigeon

lunar wigeon
#

yes

open lily
#

but how

lunar wigeon
#

fake packets handler

#

magic

open lily
#

oh yes

#

what you can do with fake packets?

#

crash?

#

or what

lunar wigeon
#

im crashing servers with it!

open lily
#

ok

lunar wigeon
#

its new bypass

open lily
#

very good ๐Ÿ™‚

lunar wigeon
#

yes

#

one packet crash

#

a have my own engine

#

Fake Packet Engine

#

do you want it guys?

quiet ice
#

This is server support, not client support

#

Since fabric just killed itself, you need to ask forge support

open lily
#

I thought he tried to implement fake packet into a plugin

lost matrix
quiet ice
#

Just some Drama and a new WIP fork

oak torrent
#

so I solved my problem

lost matrix
oak torrent
#
public class CreeperCommand implements CommandExecutor
{
    private CreeperSpawn plugin;
    
    public CreeperCommand(CreeperSpawn plugin)
    {
        this.plugin = plugin;
        plugin.getCommand("creeperspawn").setExecutor(this);
    }```
#

i didnt see the this in this.plugin = plugin;

#

lmao

oak torrent
lost matrix
quaint mantle
#

Hi, Any better ways to code this?

drowsy helm
#

hashmap

#

definitely

lost matrix
# quaint mantle Hi, Any better ways to code this?

Several.

  1. Use an enum for each effect with each entry having an abstract method that consumes a player.
  2. Use HashMap<String, Consumer<Player>> that applies effects to the player based on the given String

Ill give you an example for the enum

drowsy helm
#

i dont think a consumer would be necessary since it's all the same code

#

oh sorry nvm its diff effects

#

i woudl just use a HashMap<String, PotionEffectType>

#

but a consumer would def work aswell

lost matrix
# quaint mantle Hi, Any better ways to code this?

This is the abstract enum aproach.

public enum PlayerEffect {

  NAUSEA() {
    @Override
    void apply(final Player player, final int duration, final int amplifier) {
      player.sendMessage("You are now nauseous for " + duration / 20D + "s");
      player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, duration, amplifier));
    }
  },
  SPEED() {
    @Override
    void apply(final Player player, final int duration, final int amplifier) {
      player.sendMessage("You are now fast for " + duration / 20D + "s");
      player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, duration, amplifier));
    }
  };

  abstract void apply(Player player, int duration, int amplifier);

  public static PlayerEffect fromCommandInput(final String input) {
    return PlayerEffect.valueOf(input.toUpperCase());
  }

}
#

Then just use PlayerEffect.fromCommandInput(input).apply(player, 120, 1); Or something like that.

near crypt
#

how can i code a cooldown for any command?

#

pls help me

#

i need to know this

outer sorrel
lost matrix
lost matrix
outer sorrel
#

okay, might not do it then lol

lunar wigeon
#

@lost matrix accept

outer sorrel
#

thanks anyway

near crypt
#

@lost matrix do u have a code for this?

lost matrix
worldly ingot
#
Bukkit.getPluginManager().registerEvent(BlockBreakEvent.class, new Listener() {}, EventPriority.NORMAL, (listener, event) -> {
    // Do your thing here
}, this);```
near crypt
#

okay i try it and you try it okay? ๐Ÿ˜„

worldly ingot
#

though obviously you'd pull that class from reflection with Class.getByName()

#

or whatever that method is. I forget. it's 6am lol

eternal oxide
#

forName

worldly ingot
#

yeah that one

near crypt
#

@lost matrix should i do the cooldown in the main?

lost matrix
near crypt
#

ok

#

is it a HashMap?

bold hollow
#

I would use a HashMap for mapping. Yes.

lost matrix
near crypt
#

should i create a HashMap for the cooldown

#

?

#

private HashMap<UUID, Long> map = new HashMap<>();

#

so i created the Map now

#

and what should i do with it

#

@lost matrix

lost matrix
#

Yes. But this way you would have a global cooldown and couldnt distinguish between different commands.

near crypt
#

and how do i get a single cooldown for it?

#

the command

lost matrix
#

Giving each cooldown a name. So basically Map<UUID, Map<String, Long>>

quaint mantle
#

@lost matrix I have an error with this code IntelliJ doesn't know input what would i do?

near crypt
#

sorry but idk how this works does anyone has a code for a cooldown for a command?

near crypt
#

no i find nothing

lost matrix
# quaint mantle

With this you essentially remove all the if cases and just pass args[1] as the input

quaint mantle
#

Oh okay

#

I removed all of if methods

lost matrix
# near crypt sorry but idk how this works does anyone has a code for a cooldown for a command...

This is what i just wrote. Didnt test and its not easy to understand for someone who just started.

public class CooldownManager {

  private final Map<String, Long> cooldownDefinitions = new HashMap<>();
  private final Map<UUID, Map<String, Long>> executionTimes = new HashMap<>();

  public void defineCooldown(final String cooldownName, final long timeInMillis) {
    this.cooldownDefinitions.put(cooldownName, timeInMillis);
  }

  public long getCooldownLeft(final UUID userID, final String cooldownName) {
    final long lastExecution = this.executionTimes.computeIfAbsent(userID, id -> new HashMap<>()).getOrDefault(cooldownName, 0L);
    final long definedCooldown = this.cooldownDefinitions.getOrDefault(cooldownName, 0L);
    final long timePassed = System.currentTimeMillis() - lastExecution;
    return definedCooldown - timePassed;
  }

  public boolean isCooldownRunning(final UUID userID, final String cooldownName) {
    return this.getCooldownLeft(userID, cooldownName) > 0;
  }

  public void setExecution(final UUID userID, final String cooldownName) {
    this.executionTimes.computeIfAbsent(userID, id -> new HashMap<>()).put(cooldownName, System.currentTimeMillis());
  }

}
quaint mantle
#

@lost matrix will this work or it has a problem?

lost matrix
quaint mantle
#

but i have a problem with this

lost matrix
#

And you should check if o is null

quaint mantle
lost matrix
#

input is just args[1]

quaint mantle
lost matrix
#

And really try to prevent single character variables.
So player instead of p
and targetPlayer instead of o

quaint mantle
#

Yes but It's save's more time if i have a single character

eternal oxide
#

readable code is better than shorter

lost matrix
#

Doesnt matter. Its dirty coding and readable code is more valuable than all the initial time you spend because it
saves you time overall.

quaint mantle
#

Okay

#
private void giveEffects(Player player, String[] args) {
        Player target = Bukkit.getPlayer(args[0]);
        final String input = args[1];

        if (args.length <= 1) {
            player.sendMessage(coloredChat.chat("&cUsage: /Effect (Player) (Effect) [Time] [Level]"));
            return;
            
        } else {
            PotionEffects.fromCommandInput(input).apply(target, 120, 1);
        }
        player.sendMessage(coloredChat.chat("&8[&cErrors&8] &7Effect Mored Nazar Peyda Nashod!"));
    }
#

Is it good now?

lost matrix
#

You need to check args.length <= 1 before you get the first element from your array.

quaint mantle
#

oh i must remove the return;

#

i forgot

lost matrix
quaint mantle
#

Okay

quaint mantle
eternal oxide
#

[1] needs a check of 2, and checked BEFORE you try to read it

lost matrix
#

But after you accessed the array.
Its like sitting down in the theatre and then checking if there is a chair where you just sat down
instead of first checking if a chair is at the point where you about to sit down.

quaint mantle
#

Sorry if i'm wasting your time

lost matrix
quaint mantle
#

9?

#

of whole array?

#

you mean?

#

minimal is 0

#

Java starts at 0 am i right?

#

so minimal length should be 0

lost matrix
#

Nope.
Ok lets say we have an array defined like this:
int[] content = new int[3];
What is
A) The length of this array
B) The content of this array

quaint mantle
#

A: 4
B: 0 - 1 - 2 - 3

#

got problem OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); this is not returning the players correct uuid but it does return players correct name any reason why ?

quiet ice
#

No

quaint mantle
#

What's wrong?

lost matrix
# quaint mantle Is it correct?

The right answer is
A) 3
B) {0, 0, 0}

Next question. What would the result of this code be:

  public static void main(final String[] args) {
    int[] content = new int[3];
    int x = content[3];
    System.out.println(x);
  }
quiet ice
#

the syntax is new Object[length], where as length is the length of the array

brazen bolt
#

can i make custom structures spawning from my plugins?

#

as in alot of plugins which gen custom terrian?

brazen bolt
#

TUTS!?!?

quiet ice
#

Possible yes? How? Idk, probably by using chunk creating events

#

?jd

brazen bolt
#

ill wiat for a reply woth soem tut m a super rookie i know some java

quiet ice
lost matrix
brazen bolt
#

hmmi dontw anna use datapacks thats teh thiong

brazen bolt
lost matrix
quiet ice
#

They can be a pain to do

tribal holly
#

Someone know how to summun a totem revive effect with custom textures (if i can use custom model data will be the best) ?

quiet ice
#

Especially in code, most of the vanilla minecraft world gen is now handled in datapacks as far as I have heard

oak torrent
#

is there any place you recomend me to learn about plugins?

lost matrix
#

Or just watch videos

quaint prism
#

Hi, I'm having an issue where when I upload an update to a plugin in spigotmc.org it doesn't actually update. I have a test server and my plugin works. When I update the resource and then download it, plugin doesn't work. Why does this happen?

near crypt
#

if(p.getWorld().getName() == "world")

#

why does this not work?

#

i want to check if the player is in the overworld

eternal oxide
#

String compare uses .equals

near crypt
#

oh okay

lost matrix
near crypt
#

okay

#

yes thx

#

Ily

brazen bolt
#

is their any solution or totorial for me to learn how to gen custom structures i justw anna do that?

lost matrix
brazen bolt
#

and m interested in adding custom structures which vanilla neeeeeds

sour sand
#

is there a way to change the spigot.yml file from the plugin

lost matrix
sour sand
#

ok thanks

lost matrix
brazen bolt
#

i dont wanna do world gen

#

just spawn some structures on a biome i please

quiet ice
#

well, the basics will be the same

lost matrix
quiet ice
#

Unless the structure is vanilla, then that will be a bit different

left swift
#

how can i refresh the block? My point is that when I do setType for example a fence it doesn't connect to adjacent blocks so I would like to refresh it to get those connections. I tried:

b.getState().update(true, true);``` but it doesn't work
crude charm
#

I AM

#

SO SO SO ANGRY

#

3 apis, 2 utils and scoreboards aint working

#

got a util that WORKS

#

now

#

BUT

#

its static

#

and I didnt know before using it

#

ugh

cinder thistle
#

aluminium > aluminum

lost matrix
#

Who says aluminum?

crude charm
#

me

cinder thistle
#

americans

#

I'm american but calling aluminium better is 1) half true and 2) starts arguments :D

crude charm
#

im not

cinder thistle
#

lol

cinder thistle
#

the totem and a few particles

#

idk which

tribal holly
#

but i wanna use different textures depending on the custom model data

cinder thistle
#

ยฏ_(ใƒ„)_/ยฏ

#

told you all I know

tribal holly
#

i saw a server doing this but can't find it again

drowsy helm
#

Is there an event for when the player's inv gets updated in any way, be it click, pick up item, add item with plugin etc?

#

or will i have to manually check myself

rotund ravine
#

Check

lost matrix
drowsy helm
#

Hmm, I have a plugin that syncs my inv between bungee servers and currently I'm saving to a db on PlayerQuitEvent, however it doesn't save fast enough so by the time the player joins the next server they will have pulled old data

tribal holly
drowsy helm
#

cant think of a better way of doing it atm

tribal holly
drowsy helm
#

I cant determine that

#

they can switch at will

lost matrix
tribal holly
drowsy helm
#

hmm theres not really a way of knowing whether the data has persisted between servers though

#

I was thinking literally just delay the loading of data by 1 second after join

lost matrix
drowsy helm
#

but then that opens the door for duplication

drowsy helm
#

yep

exotic oriole
#

PreparedStatement ps = plugin.MySQL.getConnection().prepareStatement("INSERT IGNORE INTO tokens" + " (NAME,UUID) VALUES(?,?)");

#

why this line is not working

lost matrix
#

Then just send a message via the plugin messaging channel, and add the user ID to a Set on your bungeecord.
Then send the player to the other server and keep him in the AsyncPlayerPreLoginEvent. Constantly ask bungeecord if the player is still in the Set (also using the plugin messaging channel) and just wait in a loop.
Then create a query on a new thread on the origin server that saves the data. As soon as the query is done you send a plugin message to the bungeecord that removes the player from the set, then loads the data (still in the async event) and lets him connect.

lost matrix
drowsy helm
#

hmm yeah ill see

#

might do it through redis instead

tribal holly
#

3D model ?

#

something like that ?

lost matrix
#

I just set the model id of the ItemStack to another texture and it then showed its icon when the player died. But i cant quite remember if it worked like that. It was not intended but just a nice side effect.

lost matrix
#

This might actually be a client side thing

earnest junco
# exotic oriole why this line is not working

PreparedStatements are a bit more special than that. The statement is first sent to the database without executing it, so the database can parse and compile it. Then, when you execute the statement, you bind the values (setString(1, "name");) to the parameters(?) and the database can execute the statement.
Whichever interface you're using probably won't allow you to emulate that procedure and requires you to immediately specify values.

exotic oriole
#

and how can i make that to work?

near crypt
#

what is the event for a player enter the end?

earnest junco
crude charm
#

code1:

#

code2:

drowsy helm
#

paste in codeblocks pls

ornate heart
crude charm
drowsy helm
#

pastebin

crude charm
#

ew

#

?paste

queen dragonBOT
lost matrix
# crude charm error:

Are you trying to get the scoreboard manager before your onEnable()??
So in your onLoad() or in a field like ScoreBoard board = Bukkit.getScoreboardManager...??

exotic oriole
crude charm
#

but after I added the update methd

#

it all broke

earnest junco
deep wave
#

You can't access things like the scoreboard manager before onEnable (post world)

drowsy helm
#

most bukkit related api methods shouldn't be accessed before onEnable is called

near crypt
#

and how can i get the world teleported to

lost matrix
# crude charm but after I added the update methd
  1. You are using 1.8 which is an ancient version and unsuppoted
  2. You cant get the ScoreboardManager before Bukkit initialized it. So the onEnable is the first location you should ever call for the ScoreboardManager
ornate heart
quaint prism
#

guys, how do I contact with spigot forum support?

near crypt
#

iam using the PlayerChangedWorldEvent

drowsy helm
#

anyone aware of an event that allows me to get a Player's message after it is processed. AsyncPlayerChatEvent gives me the message and format, but not the processed message

near crypt
#

@ornate heart PlayerChangedWorldEvent

deep wave
#

I mean, realiably, no

ornate heart
#

player#getWorld

crude charm
#
  1. I kinda have to use 1.8, its what consumers want

    public void load() {

//        commands
        new ServerCommand(this).register();

//        events
//


        loadPlayer();
        itemHandler.selectorManager.openSelectorEvent();
        itemHandler.selectorManager.clickedSlot();

        scoreboardHandler.makeScoreboard();
        scoreboardHandler.updateScoreboard();


        noWeather.noWeather();

        itemHandler.storeItem.sendStoreLink();

        itemHandler.giveItems();
        itemHandler.onInvMove();
        itemHandler.onDrop();

        doubleJump.setFlight();
        doubleJump.addVelocity();
        doubleJump.keepDoubleJump();

        noDamage.onDamage();
        noDamage.solveWorldHunger();

        build.blockPlace();
        build.blockBreak();
tribal holly
near crypt
#

but this is the world from right?

#

not the end in my case

deep wave
#

you can listen to the chat event on the monitor level, but, generally, if some plugin cancels the event and does it on its own you have no way to hook into that without hooking every chat plugin