#help-development

1 messages · Page 1759 of 1

solar sable
#

use luckperms?

rough jay
#

I'm trying to use as less plugins that possible... for now I'm using only HologramAPI

solar sable
#

oh

#

well luckperms can help with setting up permissions to groups or as you call it “roles”

#

well if you want to use less plugins then idk how to sadly, sorry

young knoll
#

You generally are going to want a permission plugin for most servers anyway

solar sable
#

yup

#

anyone know how to make an invisible entity?

young knoll
#

Depends on the entity

#

ArmorStand has setVisible

#

Other entities generally use a potion effect

solar sable
#

what about an entity that you can ride on

young knoll
#

You can ride on anything

solar sable
#

well what i’m trying to do is to right click on a stair and then the player will sit on it but i only figured out on the right click detection but not the entity

young knoll
#

I would use an armorstand

solar sable
young knoll
#

They can easily be made invisible, you can also set noGravity and they don't make sounds

#

No AI to tick either

solar sable
#

oh

#

well now what i need to figure out is to summon it when it is clicked and then remove it when it is done sitting down

young knoll
#

InteractEvent and DismountEvent

solar sable
#

oh

#

how to summon it when it is clicked

#

i dont know how to summon entities yet

solar sable
#

thanks

young knoll
#

Creating descriptive parsing errors

quaint mantle
#

does someone know a lifesteal smp plugin for 1.16.5?

rough jay
#

Would anyone have an idea how to make custom roles that give permissions to player who have these roles?

#

P.S. I want to make these roles with my plugin (to code it) not with another plugin such as LuckyPerms

grand flint
#

Why does this not work,

public void onInteract(PlayerInteractEvent event) {
        if (!event.hasItem())
            return;
        if (event.getItem().getType() != Material.POTION)
            return;
        if (event.getClickedBlock() == null) {
            event.getPlayer().sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Use potion at a respawn tower!");
            event.setCancelled(true);
            return;
        }
}```
#

when holding a potion and clicking the floor or any block it doesn't send the message

stone sinew
#

Because your checking if there is no clicked block

#

event.getClickedBlock() == null

grand flint
#

Nothing happens if I click the air either?

stone sinew
#

Is the event registered? Debug it

grand flint
#

How do I debug something in java?

#

Never did it before

#

Print it in console?

#

Like the server's console?

stone sinew
#

How ever you want.
System.out
Bukkit.getLogger
JavaPlugin.getLogger
Bukkit.broadcastMessage
Etc...

grand flint
stone sinew
#

All of them technically xD
Bukkit.broadcastMessage sends to chat as well though.

grand flint
#

should I check use that to check if playerinteract event is being registered?

stone sinew
#

Yeap

grand flint
#

kk

stone sinew
#

Well you would know if its registered actually. Did you write
Bukkit.getPluginManager().registerEvents
anywhere?

grand flint
#

no?

stone sinew
#

Then you didn't register the listener lol

grand flint
#

Is that an import or?

stone sinew
grand flint
stone sinew
#

Depends on your listener and the code where your listener is.

grand flint
#

It is in the main file

tame coral
grand flint
#

Thank you ❤️

#

target.teleport(404.5, 66, 92.5); is this not how you teleport a player?

chrome beacon
#

It is

subtle folio
#

Hey so im trying to make a leaderboard of the top 10 players in my plugin, this is my current code but it displays all users not just top 10, how do I fix this? ```java
private static final HashMap<OfflinePlayer, Integer> unsortMap = new HashMap<>();
public static final boolean DESC = false;

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

    Player p = (Player) sender;

    p.sendMessage(ChatColor.GREEN + "----------");
    for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
        unsortMap.put(player, TazPvP.statsManager.getLevel(player));
    }

    Map<OfflinePlayer, Integer> sortedMapDesc = sortByComparator(unsortMap, DESC);
    printMap(sortedMapDesc, p);
    return true;
}

private static Map<OfflinePlayer, Integer> sortByComparator(Map<OfflinePlayer, Integer> unsortMap, final boolean order)
{

    List<Map.Entry<OfflinePlayer, Integer>> list = new LinkedList<>(unsortMap.entrySet());

    // Sorting the list based on values
    list.sort((o1, o2) -> {
        if (order) {
            return o1.getValue().compareTo(o2.getValue());
        } else {
            return o2.getValue().compareTo(o1.getValue());

        }
    });

    // Maintaining insertion order with the help of LinkedList
    Map<OfflinePlayer, Integer> sortedMap = new LinkedHashMap<>();
    for (Map.Entry<OfflinePlayer, Integer> entry : list)
    {
        sortedMap.put(entry.getKey(), entry.getValue());
    }

    return sortedMap;
}

public static void printMap(Map<OfflinePlayer, Integer> map, Player p)
{
    for (Map.Entry<OfflinePlayer, Integer> entry : map.entrySet())
    {
        p.sendMessage(entry.getKey().getName() + " " + entry.getValue());

    }
}```
grand flint
#

It says Cannot resolve method 'teleport(double, int, double)'

chrome beacon
#

Well not exactly you need location

#

Get it from those coords

grand flint
#

Could you show me an example please

#

Is it using .getLocation()

chrome beacon
#

That's one way

grand flint
#

or wait

#

target.teleport(event.getPlayer().getLocation().set(404.5, 66, 92.5));

#

Is this right?

golden turret
#

java

wide coyote
#

no

chrome beacon
grand flint
#

I asked you if you could show me an example

#

I didn't ask for my specific code any example can help

grand flint
wide coyote
#

np

grand flint
# wide coyote np
Location loc = new Location(target.getWorld(), 404.5, 66, 92.5, 0, 0);
target.teleport(loc);```
Is this correct?
golden turret
grand flint
#

👍

tranquil viper
tranquil viper
#

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class ReloadNoInvis implements CommandExecutor {

    private NoInvis noe;

    public ReloadNoInvis(NoInvis noe) {
        this.noe = noe;
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

        if (sender.isOp()) {
            noe.reloadConfig();
            sender.sendMessage("Reloaded NoInvis.");
        }

        return false;
    }

}
#

the main class is just registering the event how you would

#

command*

chrome beacon
subtle folio
wide coyote
shy hamlet
#

Say, quick question about prepare enchantment events...
Does setEnchantmentLevel do anything?

example:


        e.getOffers()[0].setEnchantment(Enchantment.KNOCKBACK);
        e.getOffers()[0].setEnchantmentLevel(5);
        e.getOffers()[0].setCost(60);

Both setEnchantment and setCost do work but setEnchantmentLevel does nothing except for changing the display name...

grand flint
#

how do I get a player from a differnet listener, for example I have a death listener how do I get that player who died from another listener

chrome beacon
#

Save player in a weak set

grand flint
#

What is that?

left swift
#

how can i make EntityArmorStand movement using velocity?

eternal night
#

entityArmorStand.getBukkitEntity().setVelocity(new Vector(0,1,0));

left swift
grand flint
#

Java uses milliseconds right?

eternal night
#

if you don't actually have the armor stand on the server

#

good luck simulating its velocity

runic mesa
#

How would i give armor to my custom mob

left swift
waxen barn
#

Does anyone idea why this gives me a cast error

Sign sign = (Sign) world.getBlockAt(X + x, 1, Z + z).getState();
                    sign.setLine(0, String.valueOf(temperature.a(x >> 2, 0, z >> 2)));
                    sign.setLine(1, String.valueOf(humidity.a(x >> 2, 0, z >> 2)));
                    sign.setLine(2, String.valueOf(altitude.a(x >> 2, 0, z >> 2)));
                    sign.setLine(3, String.valueOf(weirdness.a(x >> 2, 0, z >> 2)));

?

#

The stupid sign took me more time, than the biome nms xd

#
import org.bukkit.block.Sign;```
#

this is my import

young knoll
#

Is the block a sign

waxen barn
young knoll
#

Very curious why a sign is being placed at bedrock level

waxen barn
young knoll
#

I see

#

Yes it is one block above the bottom bedrock layer

runic mesa
#

How do I make a method to give a baby zombie armor

#

For each one I define

#

That could work for each one *

waxen barn
#

For some reason, uncommenting this line

Sign sign = (Sign) world.getBlockAt(X + x, 1, Z + z).getState();

freezes the chunk generation.

#

ik, that it's probably because I am getting it from the world, not the chunk, but is there some way, how to use only chunk and not world (because I didn't find a way how to get block state using the chunk object)

#

i don't have any idea, if I understood you correctly, but try using e.getMessage() instead of e.getFormat()

#

if I didn't understand you correctly, some example of the input and output can help

#

oh, ok

graceful oak
#

So if I need to check between multiple items when doing something is it possible to create a material list that I can check easily because right now my if conditions are really long using or for each material im checking

stone sinew
quaint mantle
#

Set<Material> matSet = EnumSet.of(Material.STONE, Material.DIRT);
@graceful oak

graceful oak
#

Whats the difference?

quaint mantle
#

faster

graceful oak
#

Interesting alright thanks

main dew
#

how can I check who used the nickname Proscreeam1337 (for example) use API?

wide coyote
echo basalt
#

Question (Not spigot-specific, but helps to ask here):

How can I add multiple versions of a single project to my IDE, and allocate each version to a class?

#

I'm having some issues where some classes get a ton imports that have changed / got removed, and it'd be nice if I could just work with the code directly instead of doing a crazy reflections dance

main dew
#

I can see on nameMC who used this nick before but on mojang API idk ;/

limpid umbra
#

Language API

silver shuttle
left swift
#

Why if the EntityArmorStand is marker/is no gravity, velocity movement doesn't work?

raw coral
#

How do I make it so the Ender Dragon is unable to break blocks.

silver shuttle
# raw coral How do I make it so the Ender Dragon is unable to break blocks.
@EventHandler
public void stopDragonDamage(EntityExplodeEvent event) // Listen for the event...
{
  Entity e = event.getEntity();
  if(e instanceof EntityComplexPart) // it it's a part of a dragon...
    e = ((EntityComplexPart)e).getParent(); // ... get the dragon...
  if(e instanceof EnderDragon) // if it's a dragon...
    event.getBlocks().clear(); // ...clear the list of destroyed blocks. A event.setCancelled(true); should work, too, just have a look what you like more. ;)
}
silver shuttle
#

or null

left swift
silver shuttle
#

i mean you can set its gravity on and cancel all its y movement

#

but i wouldnt know any other way

#

btw does anyone know why minecrafts coordinate system is non Cartesian? Like why is vertical y and z is on the plane?

spare marsh
#

if I sleep a thread I am opening to do something else, it wont affect the main thread correct?

silver shuttle
#

yes

spare marsh
#

Yes it will affect or yes it will not affect?

shy hamlet
hybrid spoke
silver shuttle
spare marsh
#

Alright thank you!

raw coral
#

Although

spare marsh
raw coral
#

Make sure you don't use the spigot api

#

in your new thread

hybrid spoke
#

depends

raw coral
#

unless you do Bukkit.runTask

#

or its sending chat messages

#

but most things in the api are not thread safe

silver shuttle
spare marsh
# raw coral Although

So to actually use Spigot's API I would have to do Bukkit.runTask() and do it from there right?

shy hamlet
#

yeah I guessed so, but does not change a thing other then it's display name

raw coral
#

In the thread, yes.

silver shuttle
shy hamlet
#

(only in table)

raw coral
#

Whatever is in the Bukkit.runTask() runnable runs on the main thread

hybrid spoke
shy hamlet
#
    @EventHandler
    void prepareItemEnchantEvent(PrepareItemEnchantEvent e) {
        Player p = e.getEnchanter();

        p.sendMessage("=== PrepareItemEnchantEvent ===");
        p.sendMessage("getEnchantBlock() -> " + e.getEnchantBlock());
        p.sendMessage("getEnchantmentBonus() -> " + e.getEnchantmentBonus());
        p.sendMessage("getOffers() -> ");
        for(EnchantmentOffer o : e.getOffers()) {
            if(o == null) p.sendMessage("    null");
            else p.sendMessage("    " + o.getEnchantment() + String.format(" [%d]", o.getEnchantmentLevel()));
        }
        p.sendMessage("\n\n");

        e.getOffers()[0].setEnchantment(Enchantment.KNOCKBACK);
        e.getOffers()[0].setEnchantmentLevel(5);
        e.getOffers()[0].setCost(60);
    }
spare marsh
#

Sounds good thanks. I actually had planned sending a message jaja

undone axleBOT
raw coral
#

Also instead of making threads you should use bukkits system with runTaskAynchronously

spare marsh
#

Alright thank you

raw coral
#

Ive heard that the chat runs on a different thread

#

but I might be wrong

hybrid spoke
#

the normal player chat yeah

#

sendMessage not

raw coral
#

but dont try messing with inventories

spare marsh
#

Well yes but I am using Callables and Future

hybrid spoke
#

could also have a perms check which could crash

#

not sure

raw coral
#

anyway just use Bukkit.runTask to be sage

#

safe

spare marsh
#

Alright thank you.

hybrid spoke
#

but be aware of the 1 tick delay

spare marsh
#

I am sleeping the thread for a second and every seconds messaging the player

#

in that thread

#

but I call the Bukkit.runTask

#

I should be fine right?

raw coral
#

why not just use BUkkit.runTaskLater

spare marsh
#

Because I need to know if the current task was successful or not

#

I need runnable to return a value

#

and Callables can actually do that

#

and I want it to wait for its value then do something and I am using Future for that

echo basalt
#

Uhhh

#

CompletableFuture is pretty much all you need

#

Although you might have to pair it with a latch for some more complex systems (Packet system that sends a request and provides a CompletableFuture of the reply, for example)

spare marsh
#

Oh okay I didn't know that, Thank you!

young knoll
#

Sending a message async should be fine

#

It’s just a packet

hybrid spoke
#

but for what

#

you can just use a scheduler timer and callback

tranquil viper
#

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class ReloadNoInvis implements CommandExecutor {

    private NoInvis noe;

    public ReloadNoInvis(NoInvis noe) {
        this.noe = noe;
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

        if (sender.isOp()) {
            noe.reloadConfig();
            sender.sendMessage("Reloaded NoInvis.");
        }

        return false;
    }

}```
#

import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin;

import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.session.SessionManager;

public class NoInvis extends JavaPlugin {

    ConsoleCommandSender console = getServer().getConsoleSender();

    @Override
    public void onEnable() {
        console.sendMessage(ChatColor.GREEN + "NoInvis started successfully! " + ChatColor.DARK_PURPLE
                + "Made by Pray on 11/5/2021, Version: 1.0");
        getConfig().options().copyDefaults();
        saveDefaultConfig();

        getConfig().createSection("no-invis-in-pvp");
        getConfig().set("no-invis-in-pvp.enabled", true);
        getConfig().set("no-invis-in-pvp.message", "&e(!) &cInvisibility is disabled in pvp!");

        getConfig().createSection("no-harm-in-pvp");
        getConfig().set("no-harm-in-pvp.enabled", true);
        getConfig().set("no-harm-in-pvp.message", "&e(!) &cInstant Harming is disabled in pvp!");

        saveConfig();

        initCmds();
        initEvents();

        SessionManager sessionManager = WorldGuard.getInstance().getPlatform().getSessionManager();
        sessionManager.registerHandler(CustomHandler.FACTORY, null);
    }

    public void initCmds() {
        getCommand("noinvisreload").setExecutor(new ReloadNoInvis(this));
    }

    public void initEvents() {
        getServer().getPluginManager().registerEvents(new Listeners(this), this);
    }

}
eternal night
#

you have two plugins defining the same class

#

use proper package names

#

me.pray is not a proper package name

subtle folio
#

Hey, I have this function that loops throguh a given Map Im trying to make it only loop for the first ten times. this is my current code but its not sending anything at all, ```java
public static int times = 1;

public static void printMap(Map<OfflinePlayer, Integer> map, Player p)
{
for (Map.Entry<OfflinePlayer, Integer> entry : map.entrySet())
{
if (times <= 11){
return;
} else {
p.sendMessage(ChatColor.GOLD + "#" + times + " " + entry.getKey().getName() + " " + entry.getValue());
times++;
}

    }
}``` the map contains data and all.
eternal night
#

a static variable for a counter seems problematic

subtle folio
#

How so? im not too familliar with the differences?

eternal night
#

also you are returning if times is smaller or equal to 11

subtle folio
#

OH

eternal night
#

well, you'd have to reset that variable

#

after the method is run once it would be stuck at 12

#

hopefully

#

or well, 11

subtle folio
#

if i just get rid of the static

#

that wont happen?

eternal night
#

just define that variable in the method itself

subtle folio
#

alright

eternal night
#

additionally, maps do not have the concept of order @subtle folio

subtle folio
#

I have my own sorting function from hashmap to map

#

dont fret.

eternal night
#

there is no sorting on maps o.O

#

usually

quaint mantle
#

hashmap has no sort

subtle folio
#

well i made it sort

quaint mantle
#

you wouldn't be using a hashmap anyway if you were sorting it somewhere

eternal night
#

I mean I guess you could sort a tree map

quaint mantle
#

treemap is sorted by default

eternal night
#

yea but you'd need a custom sorting function usually

quaint mantle
#

Make sure to use linked hashmap if you're sorting 🙂

quaint mantle
#

flip it

eternal night
quaint mantle
#

ok i didnt read

subtle folio
quaint mantle
#

I also just suggesting doing a continue and not shoving the code in an if else

eternal night
#

how would a continue benefit their usecase o.O

#

continue makes no sense here

subtle folio
eternal night
#

you should stick to return

#

continue would keep on iterating over the rest of entries even tho none of them are eligible to be printed.

quaint mantle
#

oh yeah not continue, return

#

but separate it

#

i guess its up to you, compiler will fix it anyway

#

but usually doing the check that ends the code execution first is cleaner

#

then no need to indent the message and int increment

sharp bough
sharp bough
#

ah sorry chat didint update

subtle folio
#

👌

sharp bough
#

i just saw the messages lol

quaint mantle
#

Cmon lucasy

#

you gotta do better man :/

sharp bough
#

bruh+

#

154 contributions in the entire year? gotta do better man

#

jk jk

subtle folio
#

lmk what files you need to see bc i cant decipher these errors

subtle folio
#

oh sweet thanks

sharp bough
subtle folio
#

ive figured out the issue, im using entry.getKey().getPlayer().hasPermission("perm"){ to find out if the entry had a perm but its not liking that

#

is there a way to do the same thing

#

entry.getKey() is a offlinPplayer

sharp bough
#

maybe you need to cast it

#

do Player p = entry.getkey

subtle folio
#

kk

sharp bough
#

and then check if p.hasperm

subtle folio
#

I can check a OfflinePlayer right?

#

becuase my entry.getKey is a offline player

sharp bough
#

let me check

#

try that

subtle folio
#

the solution for them is vault.

#

ig i gotta depend on that

sharp bough
#

OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(<player name or UUID>);
player.hasPermission("some.permission.node");
that didnt work?

#

i dont see why you would need vault tbh

subtle folio
#

no

#

that doesnt work.

#

the method is also decapracated

#

lol

tranquil viper
#

How can I put a custom message where the music would play?

lavish hemlock
#

uhhh

#

I mean you could intercept the item click event

#

check if the item is a music disc being clicked on a jukebox

#

then display the text via an actionbar API like modern Spigot, Adventure, or ActionBarAPI

tranquil viper
#

I just want to play it

#

i dont mean when clicking the jukebox

#

just like if someone types a command

lavish hemlock
#

well, custom music discs don't fucking exist

#

oh

tranquil viper
#

I have seen it before

#

lmao

lavish hemlock
#

not in basegame

tranquil viper
#

like custom text

#

not custom music

lavish hemlock
#

then just display it via an actionbar API like I said :p

tranquil viper
#

k

lavish hemlock
#

newer Spigot supports it by default

young knoll
#

Player.spigot.sendMessage with ChatMessageType.ACTION_BAR iirc

tranquil viper
#

thanks!

summer scroll
#

what is the packet limit for minecraft client?

#

like how many packets can be send in 1 second

golden turret
#

i think that it is unlimited

subtle folio
next stratus
drowsy helm
livid tundra
#

it probably depends on the client and server

quaint mantle
#

Well if we turn of spigot limit then maybe unlimited i think

drowsy helm
#

Yeah probably but not a good idea to surpass it

drowsy helm
#

Anyone here ever worked with building a resourcepack from INSIDE of the plugin jar. (i.e I want to dynamically create my resource pack then let the player load it)

#

just curious as to how to approach it

young knoll
#

I imagine you simply create it in the data folder and then zip it using Java’s zipfile methods

#

Sending it to the player is a bit more complicated

summer scroll
boreal badge
#

I need help I have a survival world and I have a little spawn area when you join the world And Idk how to have them spawn there when they join the world for the first time and ones they go to there bed they don’t spawn there no more

quasi flint
#

Playerjoinevent

#

Teleport

#

After 2 sec

quaint mantle
#

can

#

i get tech support?

quaint mantle
tardy delta
solid cargo
quaint mantle
#

omg free anti virus?

solid cargo
#

very much

solid cargo
#

anyways, ask your issue

#

whats wrong with ur timings?

odd quarry
#

how can i make top10 with data in a yml

solid cargo
#

the uptime is kinda sad

quaint mantle
#

tps

#

8

solid cargo
#

restart ur srever

#

the uptime shall not be longer than 12 hours

tardy delta
#

Oh

quaint mantle
#

why restart?

#

but ok

solid cargo
#

trust me

#

it will fix 99% of issues

tardy delta
#

Does that gets the tps low?

solid cargo
#

yes, it stores bunch of useless stuff

#

and then it dies

tardy delta
#

That's why big servers have a daily restart 🤠

solid cargo
#

yes!

tardy delta
#

Wew

quaint mantle
#

mhm

#

i have 45 players

solid cargo
#

doesnt matter, ur ram is overkill

tardy delta
#

Just say them bye bye

solid cargo
tardy delta
#

Whoa

quaint mantle
#

do you want me to give it more?

#

1tb?

solid cargo
#

no lmfao

tardy delta
#

Noo

quaint mantle
#

oke

#

i have a server whit 2 tb ram

tardy delta
#

Imagine using 1 tb

quaint mantle
#

:/

solid cargo
#

anyways, restart ur server

#

players will thank you later

quaint mantle
#

yea

#

i am not sure abt that lol

solid cargo
#

im a dev on a server that reaches 5 tps if not restarted in 24 hours

quaint mantle
#

[09:00:21 WARN]: Can't keep up! Is the server overloaded? Running 5007ms or 100 ticks behind

#

already

tardy delta
#

Theres a website which tells you how many ram to use depending on the amount of players and plugins

solid cargo
#

thats fine, let it stabilize

drowsy helm
tardy delta
#

I thought maximum was 40gb of something

#

Or even 20

solid cargo
#

even md_5 doesnt want overkill servers

quaint mantle
#

[09:01:24 INFO]: TPS from last 1m, 5m, 15m: 17.23, 19.11, 19.69?

drowsy helm
#

for 32 bit its like 2gb 64bit is heaps more

#

anything over 12gb for a server is a waste

solid cargo
#

and see what they doing

drowsy helm
#

if you have the infrastructure to support 12gb+ per server you should be server meshing

solid cargo
#

prolly even hypixel mega lobbies dont have 20gb of ram

drowsy helm
#

they are hella optimised

quaint mantle
solid cargo
#

fax

solid cargo
#

also there are other types of lag machines

#

such as armor stands

quaint mantle
#

that is why i have ArmorStand-Limiter v1.4.jar

solid cargo
#

all plugins have bypasses!

#

how does it limit them tho?

#

how many plugins you have?

#

ok whats ur tps rn?

quaint mantle
#

14.56

drowsy helm
#

sheesh

#

have you ran timings yet?

quaint mantle
#

i found 0 lagg mashineee

solid cargo
#

decreasing?

quaint mantle
drowsy helm
#

if its slowly going down it means theres a mem leak

solid cargo
#

no, tps

quaint mantle
#

so?

solid cargo
#

do you commonly reload your server?

#

to quickly deploy updates?

quaint mantle
#

some dude said this

#

you got chunk and entity issue

solid cargo
#

decrease max mobs in 1 chunk

quaint mantle
#

how?

solid cargo
#

go to paper.yml

#

and there would be an option

#

or spigot.yml i forgot

quaint mantle
#

entity-activation-range:
animals: 16
monsters: 24
raiders: 48
misc: 8
water: 16
villagers: 32
flying-monsters: 32
villagers-work-immunity-after: 100
villagers-work-immunity-for: 20
villagers-active-for-panic: true
tick-inactive-villagers: false
wake-up-inactive:
animals-max-per-tick: 4
animals-every: 1200
animals-for: 100
monsters-max-per-tick: 8
monsters-every: 400
monsters-for: 100
villagers-max-per-tick: 4
villagers-every: 600
villagers-for: 100
flying-monsters-max-per-tick: 8
flying-monsters-every: 200
flying-monsters-for: 100

#

=

#

oh 17 tps

#

```yml
code
```

#

spawn-limits:
monsters: 25
animals: 8
water-animals: 7
water-ambient: 8
ambient: 1
chunk-gc:
period-in-ticks: 400
ticks-per:
animal-spawns: 400
monster-spawns: 1
water-spawns: 1
water-ambient-spawns: 1
ambient-spawns: 1
autosave: 6000
aliases: now-in-commands.yml

#

or?

#

this

quaint mantle
#

what do i change it to?

solid cargo
#

slash it like 5 times

quaint mantle
#

tf

#

slash?

solid cargo
#

yes, divide monsters by 5

quaint mantle
#

i dont know math

solid cargo
#

so now spawn limits will be 5

#

thats very basic math

#

2nd grate math

quaint mantle
solid cargo
quaint mantle
#

ok

#

that is all?

solid cargo
#

might as well double autosave

quaint mantle
#

12000?

solid cargo
#

yeah

quaint mantle
#

and then restart?

solid cargo
#

nope

quaint mantle
solid cargo
#

reduce animals to 4

quaint mantle
#

oke

quaint mantle
solid cargo
#

u can restart

quaint mantle
#

[09:13:30 INFO]: <ClownPiecre> NO
[09:13:32 INFO]: <Kawaii_Chans> DONT
[09:13:32 INFO]: <ClownPiecre> dont restart
[09:13:33 INFO]: <~ZelZOO> done
[09:13:34 INFO]: <~Le_Savage> poek come
[09:13:35 INFO]: <~ZelZOO> u eat

#

lo0l

solid cargo
#

tell them to fuck off and restart

quaint mantle
quaint mantle
tardy delta
#

Yea true ofcourse you need to test it

quaint mantle
#

mhm

#

i guess iil just have 14 tps

solid cargo
#

just git gud lol

quaint mantle
#

git gud tf

#

what

#

does

#

this

#

mean+

#

09:37:34 [INFO] [Browncars2] disconnected with: Internal Exception: io.netty.handler.codec.EncoderException: java.lang.NullPointerException: Cannot invoke "java.lang.Enum.ordinal()" because "instance" is null

#

i removed all the via plugins

#

im making a plugin which changes the xp of the exp bottle if it has an nbt tag, here is my code:

public void onThrowBottle(ExpBottleEvent e) {
        if (e.getEntity() instanceof Player) {
            Player p = (Player) e.getEntity();
            ItemStack item = p.getItemInUse();
            net.minecraft.world.item.ItemStack bottle = CraftItemStack.asNMSCopy(item);

how do i check if the "bottle" has the nbt tag "grand:1b"

quaint mantle
#

1.17.1

eternal oxide
#

then use PDC

quaint mantle
#

but i want the items to generate into treasure chests too

#

so ill use loot tables to generate them with nbt tags

eternal oxide
#

PDC is on all items. its a wrapper for nbt tags

drowsy helm
#

pdc is just the spigot wrapper for nbt

#

its the seame thing

quaint mantle
eternal oxide
#

?pdc

quaint mantle
#

kk lemme check

#

how am i supposed to use this?

drowsy helm
#

use a NamespacedKey

quaint mantle
#

idk how to

eternal oxide
#

of your "grand:1b"

quaint mantle
#

NamespacedKey nbtTag = new NamespacedKey(this, "grand:1b");

#

?

eternal oxide
#

new NamespacedKey...

tardy flame
#
public class Sheep extends EntitySheep  {

    public Sheep(@NotNull Location location, @NotNull Player player, @NotNull Pet pet) {
        super(EntityTypes.ax, ((CraftWorld) Objects.requireNonNull(location.getWorld())).getHandle());
        this.setPosition(location.getX(), location.getY(), location.getZ());
        this.setHealth(20.0f);
        this.ageLocked = true;
        this.setBaby(true);
        this.setCustomNameVisible(true);
        this.setInvulnerable(true);
        this.setGoalTarget(((CraftPlayer)player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, true);
        pet.setOwnerUUID(player.getUniqueId());
        pet.setOwnUUID(this.getUniqueID());
    }

    public void initPathfinder(){
        this.bP.a(1, new PathfinderGoalPet(this, 1.9, 15));
        this.bP.a(0, new PathfinderGoalFloat(this));
        this.bP.a(2, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 4.0F));


    }
drowsy helm
#

dont forget nbt is a key value pair

#

so grand:1b should probs be your value

tardy flame
#

Class object, anyone know how to fix this eror?

eternal oxide
#

not quite right

quaint mantle
drowsy helm
tardy flame
eternal oxide
#

he is using nbt to create teh items so he uses no plugin

tardy flame
eternal oxide
#

his actual key is "grand:1b", grand being the plugin in this instance

quaint mantle
#

umm im very new at this i just need to make a new type of grand experience bottle which takes in the xpbottleevent to find when it is thrown

#

i didnt think it would be this complicated tho

eternal oxide
#

new NamespacedKey("grand", "1b")

quaint mantle
#

ohh

#

thank you

drowsy helm
#

NamespacedKey takes plugin and key name

eternal oxide
#

it also accepts two strings

drowsy helm
#

does it?

#

oh damn

quaint mantle
#

yeah

#

it says in the docs

eternal oxide
#

it is deprecated but can be used to create nbt keys

quaint mantle
#

what is the error

drowsy helm
#

you're using it as if its the key

#

its the namespace

eternal oxide
#

teh namespace is "grand"

#

"1b" is the key

drowsy helm
#

whats the value then?

eternal oxide
#

that value is a type, aka String

drowsy helm
#

the way im seeing it is grand is the key, 1b is the value

#

idk its weird naming lol

quaint mantle
#

yeah as in grand:1b

eternal oxide
#

it is odd to understand yep

quaint mantle
eternal oxide
#

however you are putting the value on your item not using a plugin?

drowsy helm
#

nbt tags are to put it simply a hashmap on an itemstack

quaint mantle
#

ah

eternal oxide
#

yep, teh NamespacedKey is an nbt/plugin name/key

#

so in this case the namespace is "grand" and the key is "1b" so teh NamespacedKey" is "grand:1b"

drowsy helm
#

The namespaced key just makes it a bit more confusing as it adds another layer of complexity, but its just to make it so keys don't clash

eternal oxide
#

with whatever value is assigned

quaint mantle
#

will this work?

eternal oxide
#

no, you are not looking for a container

quaint mantle
#

oh

drowsy helm
#

if I were you i would just make it key: "expRank" value: "1b" or similar

#

makes more sense

eternal oxide
#

you are looking for whatever data/value you assigned

#

if you put a string, then look for a String

drowsy helm
#

out of curiosity what does 1b mean?

quaint mantle
drowsy helm
#

so whats the 1b?

quaint mantle
#

i dont really know xD

drowsy helm
#

key: bottleType value:grand

#

easy

quaint mantle
#

ohhh

eternal oxide
#

show us where you create your nbt on the item

quaint mantle
#

nicee

drowsy helm
#

figure it out yet?

quaint mantle
#

i had to go for a sec

quaint mantle
eternal oxide
#

it all depends on how you are creating yrou nbt tags in the first place

quaint mantle
#

im sorry if this bothers you im really new at this

quaint mantle
#

the nbt tag

eternal oxide
#

then yes

quaint mantle
#

okk

eternal oxide
#

I wonder if it would be "minecraft:bottleType"

#

as you are using vanilla to add it

quaint mantle
#

no that works too

#

there's a tiny problem tho

eternal oxide
#

I'm talking about reading if from the PDC api

quaint mantle
#

for some reason item.getPersistentDataContainer is not applicable, whats the point of getting the data from the player?

quaint mantle
eternal oxide
#

you shoudl not be getting it from teh player

#

you should be reading the PDC from the bottle

drowsy helm
#

no no namespace is your plugin name

#

not the key

eternal oxide
#

Its nowe

#

not

#

he's not using a plugin to add it

#

so his plugin is not in the key

#

he's using vanilla commands to create an item with nbt

quaint mantle
#

but when i do it i get erro

drowsy helm
#

yeah the namespace still shouldn't be used AS a key

quaint mantle
eternal oxide
#

I believe the PDC is in teh ItemMeta

quaint mantle
#

Its on item meta

#

oh

#

okay

#

so this should be it

quaint mantle
#

you shouldnt use that namespacedkey constructor

drowsy helm
quaint mantle
quaint mantle
drowsy helm
#

like i said before you are using namespace as the key

#

in your example key = bottleType value = grand

quaint mantle
#

ok, so what should i do?

quaint mantle
drowsy helm
#

its the same equivalent as using a hashmap just for the key

#

you need to check the value

quaint mantle
#

how

#

im really confused ;-;

eternal oxide
#

you added it using vanilla commands so your NamespacedKey is actually "minecraft:bottleType" I believe

quaint mantle
#

okay

#

should work?

eternal oxide
#

Not looked but try it and see

#

Just looked, no

quaint mantle
#

um

#

how do i then

#

Look at deprecation note

drowsy helm
#

use get

#

dont use has

eternal oxide
#

your namespace is minecraft, yoru key is bottleType

quaint mantle
#

Dont use minecraft namespace either

quaint mantle
#

your plugin's one instead

eternal oxide
summer scroll
quaint mantle
drowsy helm
quaint mantle
#

Thats not how pdc looks like in nbt

eternal oxide
#

they shoudl be added using teh default minecraft namespace

quaint mantle
#

Why? Just use plugin namespace in command

drowsy helm
#

namespaced key is purely bukkit

quaint mantle
quaint mantle
#

give me a minute.

#

okay

drowsy helm
#

PacketPlayOutEntityLook, PacketPlayOutEntityHeadRotation

summer scroll
#

i used the head rotation packet

#

for the head

#

and entity teleport for the body

blazing scarab
#

pdc data is in PublicBukkitValues compound

restive tangle
#
    private EntityType entity;
    private String name;
    private boolean glow;
    private int borderSize;

    public Overworld(Wife plugin){
        this.entity = EntityType.valueOf(plugin.getConfig().getString("overworld.borderMob"));
        this.name = Utilities.color(plugin.getConfig().getString("overworld.borderMobName"));
        this.glow = plugin.getConfig().getBoolean("overworld.borderMobGlow");
        this.borderSize = plugin.getConfig().getInt("overworld.borderSize");
    }

    public void spawnMob(Location location){
    }
#

I want to get the entity type as an entity so I can set everything.

quaint mantle
#

/give @p experience_bottle{display:{Name:'{"text":"Grand Experience Bottle","color":"blue","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}'}, PublicBukkitValues:{"plugin:bottle_type":"grand"}} 1

#

thanks gepron1x

restive tangle
blazing scarab
#

thats it

restive tangle
#

How would I do that, It won't let me spawn anything.

young knoll
#

World.spawn

restive tangle
#

I want to get the entity type as an entity so I can set it's custom name.

blazing scarab
#

as i already told you, spawn the entity first

#

entity type and entity are different things

restive tangle
#

I know, then how then will I access it?

vernal pier
#

It returns the entity

quaint mantle
#

the code remains the same tho, right?

young knoll
#

Actually the one that takes an entity type returns a generic entity

#

But you can use EntityType.getEntityClass

#

Something like that anyway

hushed garnet
#

How do you route events to other classes in a smart way? so like if I have a BossUtils listener that registers the EntityDamageByEntityEvent() listener, how would you pass that down to various boss classes depending on which boss it is?

Currently I'm doing it the dumb way and using EntityDamageByEntityEvent() in each of my classes.

restive tangle
young knoll
#

Just create a method that takes the event as a parameter

summer scroll
#

Did anyone know why the rotation of 2 characters model (Steve and Alex) is different even tho the value is the same?

hushed garnet
young knoll
#

public void whatever(EntityDamageEvent event)

hushed garnet
#

I guess I need to create a list of like boss names, and on attack, check name, and send to the right class if so

#

or on boss class create, register the boss name and event?

#

ah i guess that's the way to do it!

vernal pier
hushed garnet
#

so like a hashmap of <String bossname, Event>

quaint mantle
#

Oops wrong message

#

the code remains saem?

hushed garnet
young knoll
#

call it from the listener

quaint mantle
#

no. meta.getPdc().get(new NamespacedKey(plugin, "bottle_type"), STRING).equals("grade")

#

In command you'd have to also replace "plugin" with your lowercase plugin name

hushed garnet
# young knoll call it from the listener

I understand what you're saying, but maybe you're not following what I'm trying to do. I'm already registering the listener once, but I'd like to pass those around dynamically to other boss classes without having to setup a bunch of if bossname == then bossname.attack(eventData)...

young knoll
#

So have an attack method in each boss class

hushed garnet
#

yes i've done that.

#

that's not what i'm asking.

young knoll
#

Then you just need to call attack on all your boss classes from within the event

quaint mantle
#

plugin name in plugin.yml

acoustic pendant
#

ok, so i'm new using vectors and I would like some help using them...

public boolean runCircle(Location loc, float radius, float speed) {
     for (double t = 0; t < 7; t += 0.1){
         float x = radius * (float) Math.sin(t);
         float z = radius * (float) Math.cos(t);
         ArmorStand circle = (ArmorStand) Bukkit.getWorld("world").spawnEntity(new Location(loc.getWorld(), (float) loc.getX() + x, (float) loc.getY(), loc.getZ() + z), EntityType.ARMOR_STAND);
         circle.setVisible(false);
         circle.setGravity(false);
         circle.setMarker(true);
         circle.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
         circle.setVelocity(speed);
     }
     return false;
 }```

What else do i have to set in ``circle.setVelocity``? location i guess?
#

this doesn't help

quaint mantle
quasi flint
#

The Vector ur lookin

#

i guess

acoustic pendant
acoustic pendant
#

with Vector speed i mean this: public boolean runCircle(Location loc, float radius, Vector speed) {

hybrid spoke
#

for what do you need a speed here

#

what is your method supposed to do

acoustic pendant
#

to move armorstands in circles

#

and speed is the speed of those armorstands

hybrid spoke
#

and why is your t 7? it normally just goes up to 1

acoustic pendant
#

because if not, it doesn't create a full circle

hybrid spoke
#

ohh, now i see it. circle is the armorstand

acoustic pendant
#

yep

#

but i'm getting an error in the vector

#

to move them

hybrid spoke
#

velocity is the knockback you give them. get their location as a vector and multiply it

ancient herald
#

How i can get the string id of an item stack?

hybrid spoke
#

just the material has

acoustic pendant
#

their location as a vector and multiply?

hybrid spoke
#

in lower versions at least

hybrid spoke
acoustic pendant
#

circle.getLocation().toVector();

#

oh

#

and how do i specify speed

hybrid spoke
#

the double in multiply

eternal oxide
#

circle.getLocation().getDirection()

hybrid spoke
#

but in your case

#

it will just push it somewhere

acoustic pendant
#

circle.getLocation().toVector().multiply(speed);

#

like this?

hybrid spoke
#

yeah

acoustic pendant
#

ok, will try

#

ty!

hybrid spoke
#

but probably what elgar said makes more sense

#

but then your armorstand have to look into the direction you want to push it

eternal oxide
#

how are you trying to move the stand? in what direction?

hybrid spoke
#

in a circle

eternal oxide
#

around what?

eternal oxide
#

ah

hushed garnet
#

How would you repeat this in a smarter way?

public void onBossDeath(EntityDeathEvent event) {    
    if (event.getEntity().getName().equals(boss1Name)) {
        boss1Death(event.getEntity());
        
    } else if (event.getEntity().getName().equals(boss2Name)) {
        boss2Death(event.getEntity());

    } else if (event.getEntity().getName().equals(boss3Name)) {
        boss3Death(event.getEntity());

    ... halp me!!!
}
acoustic pendant
acoustic pendant
acoustic pendant
#

and if i specify a number i don't apreciate a movement or it's not being done

ancient herald
#

How i can get the NBT tags of an item as string?

quaint mantle
hybrid spoke
hushed garnet
hybrid spoke
#

you spawn the armorstand in the method and then spawn a circle right away expecting the armorstand to move around in that circle

#

your armorstand will just be pushed 100 times and then stop

#

you probably have to cache the locations of the circle points and let it move around in a scheduler

acoustic pendant
hushed garnet
#

an Interface Class uses Extends ...? sorry, dumb questions... trying to get smarter!

hybrid spoke
acoustic pendant
#

why

hybrid spoke
#

because you are in a loop

#

and inside your loop

#

you are spawning new armorstands

acoustic pendant
#

uhm

#

so, how do i stop that

hybrid spoke
#

okay wait, i got something wrong here. the armorstands are those floating blocks.

#

so thats probably fine

hushed garnet
#

How to make this smarter...

acoustic pendant
#

ok xD

hybrid spoke
#

but to let them move in a circle you have to cache them

#

so you can reuse them and let them move

acoustic pendant
#

doesn't this: circle.getLocation().toVector().multiply(speed); get the armor stands and make them move?

hybrid spoke
#

yeah as i said, one time and then never again

#

but i guess you want to keep them moving

acoustic pendant
#

oh

#

so schedule right?

#

or task

ancient herald
hybrid spoke
#

its more or less the same

ancient herald
acoustic pendant
#

i don't remember for what schdule was, but now i get it. will read about that

#

thank you very much!

rough jay
#

Would anyone have an idea how to make custom roles that give permissions to player who have these roles?

P.S. I want to make these roles with my plugin (to code it) not with another plugin such as LuckyPerms

opal juniper
#

by hand

#

its just a tiny bit of yaml

quaint mantle
opal juniper
#
name: NAME
version: 1.0
author: AUTHOR
main: whatever.your.package.class
quaint mantle
#

no i mean, how do i get it to generate when the server is run

opal juniper
#

uh

#

its bundled in the plugin jar

quaint mantle
#

um when i use my server, there is no folder generated with plugin.yml

opal juniper
#

plugin.yml is not generated

#

teh plugin maker makes it

#

and puts it in the jar

#

so that the server knows how to load the plugin

quaint mantle
opal juniper
#

you are using intellij

#

so put it in the resources folder

quaint mantle
#

What does "teh" mean

opal juniper
#

its in the file explorer on the left

#

"teh" == "the"

#

lol

quaint mantle
#

ah LoL

minor garnet
#

Hey is possible detect idcplayer skin model ir alex or steve?

ancient herald
quaint mantle
#

No

#

@quaint mantle it still doesnt work ;-;

#

my code

#
package net.fordium.xpbottles.events;

import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ExpBottleEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;

public class GrandXp implements Listener {

    @EventHandler
    public void onThrowBottle(ExpBottleEvent e) {
        System.out.println("bottle print event");
        if (e.getEntity() instanceof Player) {
            Player p = (Player) e.getEntity();
            ItemStack item = p.getItemInUse();
            ItemMeta meta = item.getItemMeta();
            PersistentDataContainer container = meta.getPersistentDataContainer();
            if (container.get(new NamespacedKey("XpBottles", "bottleType"), PersistentDataType.STRING).equals("grand")) {
                e.setExperience(1395);
            }
        }
    }

}
#

bottle_type instewd of bottleType

quaint mantle
ancient herald
young knoll
#

Namespaced keys can’t have caps

quaint mantle
#

And use a plugin when you create namespaced key

quaint mantle
#

also

#

still doesnt work

#

Show the command

#
/give @p experience_bottle{display:{Name:'{"text":"Grand Experience Bottle","color":"blue","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}'}, PublicBukkitValues:{"XpBottles:bottle_type":"grand"}} 1
quaint mantle
quaint mantle
#

what else?

#

Your plugin name

#

Thats namespace

quaint mantle
#

no?

#

then what's the problem

#

just change it in namespace?

#

XpBottle -> xpbottle

#

please dont mind my stupidness im really an amateaur

#

in the command...

#

okay

#

and for the love dont use the deprecated constructor

quaint mantle
quaint mantle
#

NamespacedKey(Plugin, String)

quaint mantle
wide coyote
quaint mantle
young knoll
wide coyote
quaint mantle
#

how should i do it

hybrid spoke
#

?learnjava

undone axleBOT
young knoll
#

?di

undone axleBOT
quaint mantle
#

um i dont want to learn java, im not a plugin dev, just wanna make a single simple plugin to add new xp bottles to my private server

#

thats it

chrome beacon
#

... then hire someone

#

?services

undone axleBOT
quaint mantle
chrome beacon
#

And?

quaint mantle
#

so its obvious i wouldnt be willing to spend much money on it

hybrid spoke
#

if its not much to do you will also find someone making it for a vouch

quaint mantle
#

but who will?

hybrid spoke
#

?services anyone here

undone axleBOT
hybrid spoke
#

there are alot of people offering a small free plugin for a vouch

quaint mantle
rough jay
quaint mantle
#

oka

quaint mantle
dense remnant
#

Hey how do I iterate through all chunks inside of a world border?

tardy delta
#

for (chunk c : world.getchunks)?

quaint mantle
quaint mantle
#

what is so funny about it now^^

dense remnant
#

How do I get the contents of a book inside of a lectern?

chrome beacon
idle wren
#

how can i send a player a message where only one part is underlined?

main dew
quaint mantle
idle wren
solar sable
#

how to spawn an entity at the loc of where you right click

#

i figured out on how to spawn the entity but idk how to make it spawn at the loc of where you right click

summer scroll
#

Listen to PlayerInteractEvent

chrome beacon
#

^ Get the right clicked block and get it's location

solar sable
#

how?

chrome beacon
#

What part

solar sable
#

how to get the right clicked block

chrome beacon
#

Event#getClickedBlock

#

Well PlayerInteractAtBlockEvent

#

Or smth like that

solar sable
#

and then .getLocation ?

chrome beacon
#

Yes

solar sable
#

so the result would be event#getClickedBlock().getLocation()

summer scroll
#

There you go, you got your location

solar sable
#

ooh okay then

#

got it

#

thank you! 🙏

dense remnant
#

Are chunks 16 or 256 Blocks high?

tardy delta
#

256

quaint mantle
#
                    p.getWorld().setThundering(true);
                    p.getWorld().setThunderDuration(2*60*2);

This wont work, i wana die

ancient herald
#

Why the method ItemMeta#getDisplayName returns me an empty string?

#

Someone can give me help plz

ancient herald
#

how i can get the name of an material then?

quaint mantle
#

sadly you cant really do much with spigot

ancient plank
#

#getType().name() returns the material name of an item

#

in a string

#

I think itemstacks have that

tardy delta
#

its an enum

ancient plank
#

true

young knoll
tardy delta
#

what does .getPlayer().getPlayer() even does?

young knoll
#

Nothing

quaint mantle
tardy delta
#

oh

quaint mantle
#

Hey

#

can someone help me with an idea im trying to work with!

tardy delta
#

i unserstand

tardy delta
quaint mantle
#

I am trying to make a idea of where when you spawn in the server you get a random amount of hearts ranging from 6-12

tardy delta
#

you need player.setHealth() for that

quaint mantle
#

Hey guys, what do I have to add to my code if I don’t want to destroy the block protected by other blocks?
(for example: protect a block of dirt that is covered with obsidian)

  public void onExplode(EntityExplodeEvent e) {
        List<String> blocks = new ArrayList<String>();
        blocks = Main.plugin.getConfig().getStringList("blocks");
    for (Block block : new ArrayList<Block>(e.blockList())) {
      if (!blocks.contains(block.getType().toString())) {
          e.blockList().remove(block);
      }
    }

(blocks is a list of block that won't explode)

ancient herald
ancient plank
#

unlucky

last ledge
#

how to make cooldowns

#

like command cooldowns

#

event cooldowns

#

give some ideas pls

quaint mantle
#

Hey can someone help me

last ledge
quaint mantle
#

I am trying to make a idea of where when you spawn in the server you get a random amount of hearts ranging from 6-12

#

If someone can assist me in this please dm me!

tardy delta
#

you need a Random object for that

opal juniper
#

Yep, either use Random or ThreadLocalRandom.current()

tardy delta
#
@Eventhandler
public void onJoin(PlayerJoinEvent event) {
  Random random = new Random();
  event.getPlayer().setHealth(random.nextInt(7) + 6);
}```
#

something like this

#

that would go from 6 to 12 right?

last ledge
#

how to make cooldowns
like command cooldowns
event cooldowns
give some ideas pls

tardy delta
#

with a timestamp

last ledge
#

how

tardy delta
#

store players in a map

#

so a map<uuid, long>

#

and you store the time when they used that command the last time

quaint mantle
#

@last ledge can you help me?

tardy delta
#

like System.currenTimeMillis()

tardy delta
#

🥣

tardy delta
#

i dunno if a BlockBreakEvent gets fired when tnt explodes

eternal oxide
#

it doesn;t

#

only the entity explode event with a block list

quaint mantle
#

public void onExplode(EntityExplodeEvent e) {
        List<String> blocks = new ArrayList<String>();
        blocks = Main.plugin.getConfig().getStringList("blocks");
    for (Block block : new ArrayList<Block>(e.blockList())) {
      if (!blocks.contains(block.getType().toString())) {
          e.blockList().remove(block);
      } e.setCancelled(true);
    }
#

like this ??

eternal oxide
#

you can modify the list to prevent certain blocks being blown up

#

that for loop with error will a concurrent modification error

#

ah new array, you are ok

rough jay
#

(for example, let's say I write down the username Flow_ in the team_two file, then when Flow_ will connect to my server for the first time, it will automatically give him the group TEAM_TWO

tardy delta
#

lombok the way to go :kekw:

quaint mantle
#

now there is no explosion lol

subtle folio
#

https://imgur.com/a/u71ESx7 Im getting flung after I get killed whenever I force a respawn with this p.spigot().respawn(); ive tried both p.setVelocity(new Vector(0, 0, 0)); p.teleport(new Location(Bukkit.getWorld("spawn"), 0.5, 50, 0.5, 180, 0)); any ideas on how to fix?

tardy delta
#

maybe there is a way to prevent the block from breaking

quaint mantle
#

There's already equals method in enum which works perfectly

rough jay
#

ok

idle wren
#

i want to send a message to a player where one part is underlined
ChatColor.DARK_GREEN + "text" + ChatColor.GREEN + "" + ChatColor.UNDERLINE + "underlined" + ChatColor.DARK_GREEN + "text"
i wrote this but somehow the first text also gets underlined in green. how can i only underline the middle part?

last ledge
#

why is AsyncPlayerChat depreciated, whats the alternative for it

last ledge
#

&u or something is like that for underline

#

check in google

idle wren
#

ok thanks

quaint mantle
last ledge
quaint mantle
#

See deprecation note

tardy delta
#

packets probably

#

i dunno

#

anyways how can i fix this?

lavish hemlock
#

declare a dependency on JetBrains Annotations

tardy delta
#

they told me to do it like this

#

ah it works rn

last ledge
#
    @EventHandler
    public void onChat(AsyncChatEvent event){
        Player player = event.getPlayer();
        player.
    }
}```
I am trying to get player's message
but there is no option in ``player.``
raw coral
#

Does anyone know how i can stop the bedrock portal from spawning after killing a dragon?

fallow merlin
#

So I have a string that looks like minecraft:grass[snowy=false] and the like and I want to parse the tags in the brackets how would I do that?

tardy delta
#

regex

fallow merlin
#

I don't know how to use regex

tardy delta
#

dont ask me how 😳

lavish hemlock
#

doing that in regex would be hard

#

you'd wanna substring the [] part, then split by the tag's delimiter to get each pair

fallow merlin
#

would it just be \\[ to split everything after the square bracket?

lavish hemlock
#

and then if you need the name and value by themselves, split by =

tardy delta
#

and cast the second part to a boolean

lavish hemlock
#

no, Boolean.valueOf

#

you cannot cast a string to a boolean

last ledge
lavish hemlock
#

plus, valueOf handles improper values too via exception

quaint mantle
#

Say I have a stick with an nbt tag "stick:1b"...
I have this code to get the player inventory on say an entity hit event

@EventHandler
public void onEntityHit(PlayerInteractEntityEvent e) {
Player player = e.getPlayer();
ItemStack stack = player.getItemInUse();
ItemMeta meta = stack.getItemMeta();
}

now how do I check if the "Stack" item is the stick with the nbt tag "stick:1b"

raw coral
rough jay
#

So I made this Group enum https://pastebin.com/iimATpF5
And each player can be in one of the groups...
What I'm looking for is a way for someone to write the usernames in a file, and when the player with the matching username connects, it automatically gives him a group.
The Group of a player is saved in his datamap right here:

lavish hemlock
#

write the enum's name to the file as well via name()

quaint mantle
#

welp it literally state that...

lavish hemlock
#

and then when the file is loaded, Group.valueOf

#

if you wanna be safe, when loading the group's name from the file, you can do toUppercase() as valueOf requires the names match 1-1.

iron palm
#

is it possible to set a world name to string in configuration files? (toString isnt working)