#help-development

1 messages · Page 1753 of 1

valid solstice
#

alright thanks

hollow aspen
#

mhm!

tacit mica
#

Looks like it, thanks!

hollow aspen
#

also i'm having an issue with my own code, and i'm not sure why. a basic event isn't triggering, and i know i'm missing something, i'm just not sure what (it's been months since i've created plugins)

tacit mica
#

You're registering the event, and using the handlers?

hollow aspen
quaint mantle
#

i watched a coding stream yesterday and they were figuring out an issue for like a good half hour and they registered the wrong event kekw

hollow aspen
#

i'm hoping that's not the case 😭

tacit mica
#

You should be using something like this

        PluginManager pluginManager = this.getServer().getPluginManager();
        pluginManager.registerEvents(new OreFormEvent(), this);
#

The this is a plugin

#

Using this as the listener should work as well as long as you implement Listener

hollow aspen
#

lemme double check

#

yup! that works! tysm!!

valid solstice
#

according to my ide Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(mainClass, new BukkitRunnable() { scheduleSyncRepeatingTask is deprecated?

young knoll
#

Use the various runTask methods

hollow aspen
#

runTaskTmer?

#

yeah

#

to be more clear, try this, specifically?

new BukkitRunnable() {
public void run(){
//Code
}
}.runTaskTimer(plugin, 0, 20); 
``` (apologies if it doesn't work, i'm only googling to find answers, as i haven't coded a plugin in months)
valid solstice
#

0 is the delay

#

and 20 is the ticks of how often it repeats?

#

is that correct?

hollow aspen
#

p sure!

valid solstice
#

thanks!

hollow aspen
valid solstice
#

gotcha!!!

#

thankx

hollow aspen
#

mhm!

ivory sleet
#

?scheduling ftr

undone axleBOT
little trail
#

whats the method to send a message that looks like a player?

opal juniper
#

well

#

Player#chat is a thing

#

if not just send a message to everyone with the correct formatting

little trail
#

i think ill do the latter as id also want ones that arent actually players inside minecraft

#

is the send message to everyone Server.broadcastMessage ?

iron palm
#

hello
what's wrong with this code it isnt working...
Main class onenabled code :

     getConfig().options().copyDefaults();
     saveDefaultConfig();

JoinLeaveListeners code (which is not working)

public class JoinLeaveListeners extends JavaPlugin implements Listener {
    @EventHandler
    public void playerJoin(PlayerJoinEvent e){

        Player player = e.getPlayer();
        player.teleport(getConfig().getLocation("spawn"));
  e.setJoinMessage(getConfig().getString("joinmessage").replace("%player%" , player.getDisplayName()).replace("&", "§"));
    }
}
little trail
#

And is coloured text possible

eternal oxide
#

only ONE class should extend JavaPlugin

iron palm
eternal oxide
#

?di

undone axleBOT
eternal oxide
#

you don;t extend JavaPlugin anywhere but your plugin entry class

little trail
#

You can probably just pass the plugin class from your plugin into the listener

little trail
#

or is it just the default how a player messages

opal juniper
#

yeah just
<name> message

little trail
#

ah alr

#

is coloured text possible?

opal juniper
#

yes

little trail
#

how

#

is it those § formattings or & or something

opal juniper
#

Use the enum

opal juniper
#

ChatColor

#

Player#sendMessage("<" + Player.getDisplatName() + ">" + ChatColor.Blue + message)

little trail
#

ahh

#

tysm

valid solstice
#

is using a flint and steel counted as a block place event for Material.FIRE?

flint badger
#

So I've made a custom block with a red mushroom material, how can I make it so that if a player walks over it with the PlayerMoveEvent I can distinguish between one of my blocks and a vanilla red mushroom

golden turret
opal juniper
#

why

#

ew

little trail
golden turret
#

the enum will just replace the & to § for you

ivory sleet
#

That’s not the point tho

little trail
#

Again, I'll be sticking with the enum thanks

ivory sleet
#

First of all way more readable and also it avoids some encoding issues

golden turret
#

to fix the encoding issues just fix it yourself

ivory sleet
#

Wat

little trail
#

Yeah no I'm gonna use the enum, it's just much easier

opal juniper
golden turret
#

and the & is §

#

so &6 = §6

ivory sleet
#

No lol

golden turret
#

yes lol

ivory sleet
#

They’re not the same

opal juniper
#

what conclure said

#

they arent

golden turret
#

the result will be the same

#

& will be replaced to §

opal juniper
#

no it wont

little trail
#

What's the asBungee method for

ivory sleet
#

If you translate & to § yes maybe

#

Believe it turns it into the bungee ChatColor type

opal juniper
#

yes

little trail
#

I assume I don't need to worry about that

opal juniper
#

org.bukkit.ChatColor -> net.md_5.<whatever>.ChatColor

ivory sleet
#

If you can, use bungee chat api over the Bukkit one

opal juniper
#

why?

little trail
#

What's the difference

ivory sleet
#

because the Bukkit chatcolor isn’t being updated anymore

#

For instance it’s still an Enum

little trail
#

Oh alright ty

iron palm
# eternal oxide ?di

it was outdated...
I tried another way but still it isnt working
Main class :

    public static KnockbackFFA INSTANCE;```
```    @Override
    public void onEnable() {
        INSTANCE= this;
        getConfig().options().copyDefaults();
        saveDefaultConfig();
        getServer().getPluginManager().registerEvents(new JoinLeaveListeners(),this);
}

other one :

    public static KnockbackFFA INSTANCE=KnockbackFFA.INSTANCE;
    @EventHandler
    public void playerJoin(PlayerJoinEvent e){

        Player player = e.getPlayer();
        player.teleport(INSTANCE.getConfig().getLocation("spawn"));
           e.setJoinMessage(INSTANCE.getConfig().getString("joinmessage").replace("%player%" , player.getDisplayName()).replace("&", "§"));
    }
}```
The summary of error i've got

[22:24:50] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to KnockbackFFA v1.1-BETA
org.bukkit.event.EventException: null
eternal oxide
#

Delete the copyDefaults line. It does nothing.

eternal oxide
#

INSTANCE is null because its not initialized

#

you never set it

#

also ?di is not outdated. its just fine

iron palm
eternal oxide
#

it is 100% not outdated. Its just fine

iron palm
eternal oxide
#

makes no difference

iron palm
#

...

eternal oxide
#

Dependency Injection is passing a reference from one class to another

alpine urchin
#

of it no longer being an enum

ivory sleet
#

Hex representable ChatColor instances

iron palm
eternal oxide
#

yes, INSTANCE in yoru main class is null

iron palm
#

no it isnt null

eternal oxide
#

initialize it. it current has no assignment

iron palm
eternal oxide
#

yes, but when you grab a reference it IS null as you do it statically

quaint mantle
#

ChatColor.stripColor only removes § symbols but not & symbols, is this intended?

lavish hemlock
#

the INSTANCE in your listener accesses KnockbackFFA.INSTANCE before it has been set via INSTANCE = this;

#

therefore, it's null

iron palm
eternal oxide
#

no

#

well

#

no, as you are doign it as a Field

#

just remove your static Field in your listener and access the static directly in main

#

or do it properly and use DI

eternal oxide
#

You only make one call to it so Main.INSTANCE

iron palm
#

so you mean i have to remove the static from my main class and in other class i should directly get that class right?

eternal oxide
#

no

#

leave static in Main, delete the whole Field in your Listener and replace your INSTANCE in your Listener code to use Main.INSTANCE

#

btw a Field is a variable defined at the Class level.

quaint mantle
young knoll
#

Yes

#

Translate the other ones first

quaint mantle
#

What do you mean by that

#

In my string I have "§aGreen and &cRed"

young knoll
#

ChatColor.translateAlternateColorCodes

quaint mantle
#

I want to strip the colours

iron palm
quaint mantle
#

But it won't work when there is two

quaint mantle
alpine urchin
#

LOL

tardy delta
#

I use JavaPlugin.getPlugin(My plugin class) 🥶

ivory sleet
#

That’s good tho

tardy delta
#

Long code

lavish hemlock
#

I use dependency injection

#

e.g. public MyDependent(MyPlugin plugin)

#

as a sane person should

ivory sleet
#

I rarely pass my plugin instance but yeah dependency injection superior

eternal oxide
tardy delta
#

Ooh something that i use

solid cargo
tardy delta
#

Uhh what's the problem i Cant really see it Well on my phone

solid cargo
#

and as you can see, it doesnt

quaint mantle
little trail
#

what are the hexes for ChatColor

young knoll
#

What do you mean

little trail
#

well

#

what is DARK_AQUA for instance

#

#??????

young knoll
#
    public static final ChatColor BLACK = new ChatColor('0', "black", new Color(0));
    public static final ChatColor DARK_BLUE = new ChatColor('1', "dark_blue", new Color(170));
    public static final ChatColor DARK_GREEN = new ChatColor('2', "dark_green", new Color(43520));
    public static final ChatColor DARK_AQUA = new ChatColor('3', "dark_aqua", new Color(43690));
    public static final ChatColor DARK_RED = new ChatColor('4', "dark_red", new Color(11141120));
    public static final ChatColor DARK_PURPLE = new ChatColor('5', "dark_purple", new Color(11141290));
    public static final ChatColor GOLD = new ChatColor('6', "gold", new Color(16755200));
    public static final ChatColor GRAY = new ChatColor('7', "gray", new Color(11184810));
    public static final ChatColor DARK_GRAY = new ChatColor('8', "dark_gray", new Color(5592405));
    public static final ChatColor BLUE = new ChatColor('9', "blue", new Color(5592575));
    public static final ChatColor GREEN = new ChatColor('a', "green", new Color(5635925));
    public static final ChatColor AQUA = new ChatColor('b', "aqua", new Color(5636095));
    public static final ChatColor RED = new ChatColor('c', "red", new Color(16733525));
    public static final ChatColor LIGHT_PURPLE = new ChatColor('d', "light_purple", new Color(16733695));
    public static final ChatColor YELLOW = new ChatColor('e', "yellow", new Color(16777045));
    public static final ChatColor WHITE = new ChatColor('f', "white", new Color(16777215));
#

You will have to convert the ints

little trail
#

alr ty

iron palm
#

should i register a CommandExecutor class like Listener classes in main class?

young knoll
#

getCommand(name).setExecutor

weary summit
#

Index Out Of Bounds when Bukkit.createWorld() is used

iron palm
young knoll
#

Well yeah

opal juniper
#

lol

young knoll
#

It takes an executor instance

iron palm
#

oh

silver shuttle
#

anyone knows why my IntelliJ doesnt show the spigot symbol on the plugin.yml?

#

it works in my other project which also uses the Minecraft Plugin

iron palm
silver shuttle
young knoll
#

And import it

silver shuttle
#

^^

iron palm
silver shuttle
#

show me your file tree

#

of your project

iron palm
#

well got the answer

#

thanks

silver shuttle
#

so if you use SoundEngine here you need to also use SoundEngine somewhere on the left in the .class files

silver shuttle
#

good

severe zenith
#

does anyone know how to include the maven dependencies to the jar in intellij

bleak void
#

Hi! i need a plugin that gives me messages when i click a block

#

can someone tell me?

next stratus
bleak void
#

yes

severe zenith
#

i cant choose the main class because its not runnable

#

nvm, can be empty

next stratus
#

Hey, I'm using the WorldGuardWrapper and was wondering if there's a way to change a cuboid region area? I'm using https://paste.bristermitten.me/feworajofi.coffee to create the region but I don't know how to change the corner locations of it

bleak void
silver shuttle
#

just check if they right click a block, then what that block is

next stratus
#

on player interact event, if block type is what you need do something

silver shuttle
#
    @EventHandler
    public void RightClick(PlayerInteractEvent event) {
        Material i = event.getPlayer().getInventory().getItemInMainHand().getType();
        Player p = event.getPlayer();
        if(i == Material.NETHERITE_HELMET || i == Material.DIAMOND_HELMET || i == Material.IRON_HELMET || i == Material.GOLDEN_HELMET || i == Material.LEATHER_HELMET || i == Material.CHAINMAIL_HELMET || i == Material.TURTLE_HELMET || i== Material.DRAGON_HEAD || i== Material.SKELETON_SKULL || i == Material.WITHER_SKELETON_SKULL || i == Material.PLAYER_HEAD || i == Material.ZOMBIE_HEAD || i == Material.CREEPER_HEAD) {
            if(event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
                ItemStack equipped = p.getInventory().getHelmet();
                ItemStack hand = p.getInventory().getItemInMainHand();
                p.getInventory().setHelmet(hand);
                p.getInventory().setItemInMainHand(equipped);
            }
        }
    }
}

This is an example

next stratus
#

oh my that's a lot of if else's

silver shuttle
#

armor switching xd

next stratus
#

Couldn't you make a list of those and check if the material is in the list to make it more tidy?

young knoll
#

Yeah you probably want an EnumSet

next stratus
#

Or an EnumSet ;p

silver shuttle
#

too lazy to implement anything else, this does the job well enough

#

only need the list once anyways

#

wait why is there no ConfigurationFile.getChar() method?

#

How do I do that instead

#

ah nvm

tardy delta
#

Whoa

#

Cant you use a switch?

quaint mantle
#

switch syntax sux

young knoll
#

Would be nice if we could shortform stuff like this

#

Maybe something like var == (a || b ||c)

quaint mantle
#

do you have Tag.ARMOR.contains(material) on spigot

tardy delta
#

Oh forgot about that

young knoll
#

No

quaint mantle
#

sad

young knoll
#

Not hard to make your own tag system with enum sets

#

I have one for each armor part and the various tools

tardy delta
#

Why not a switch 🥶

quaint mantle
#

But you'd have to update a plugin everytime when New armor got added to the game

tardy delta
#

Effeciency?

young knoll
#

Yeah

#

But it doesn’t happen too often thankfully

quaint mantle
#

Still if'd be nice to have tags on spigot natively

#

idk if spigot will ever take paper features

eternal oxide
#

spigot has material tags

#

Tag,STAIRS.isTagged(Material)

quaint mantle
#

Ah

#

Cool

bitter ridge
#

any ideas how to make this using reflection?

young knoll
#

Just doesn’t have a tag for armor

quaint mantle
bitter ridge
#

Ik the red part is 1.17 and green one is 1.17.1 and I am making my plugin work on both using reflection. Pathfinding is the last thing before I'm done with reflection

#

it's almost the same just these two letters 😢

young knoll
#

I didn’t know 1.17.1 was a different NMS version

opal juniper
#

it is?

#

i didn’t think the mappings changed

young knoll
#

I guess so? I didn’t think so either

tardy delta
#

Does int a = b++ also modifies b?

#

In java

opal juniper
#

yes? check it tho

tardy delta
#

Oh 🥶

unkempt peak
#

If it does and you don't want to modify b just use (b+1) instead

gloomy arch
#

Hi, I'm new to spigot programming, and I've been running into an issue I have hard time finding help for online.
Basically, I'm trying to add a new smithing recipe where combining an iron pickaxe with a diamond results in a diamond pickaxe with a specific ItemMeta attached to it.
Adding the recipe works fine, but the resultant diamond pickaxe does not have the itemmeta attached to it. It's weird to me bc I use a method to generate the custom diamond pickaxe, and calling it in other contexts works as expected.

#

public static Recipe getDiamondCoatedPickaxeRecipe(NamespacedKey nms) {
ItemStack ironPickaxe = new ItemStack(Material.IRON_PICKAXE);
ItemStack diamond = new ItemStack(Material.DIAMOND);

    SmithingRecipe recipe = new SmithingRecipe(nms, getCoatedPickaxe(ironPickaxe), new MaterialChoice(Material.IRON_PICKAXE), new ExactChoice(diamond));
    return recipe;
}
#

I was wondering if anybody had any experience with this, and if this is expected behavior, and something I'm going to have to work around on.

onyx shale
#

it will ask for a ItemStack,you can create the itemstack first,give it a meta with name then create the recipe

gloomy arch
onyx shale
#

well one will give you a vanilla pickaxe

#

the other will give your custom itemstack

gloomy arch
# onyx shale it will ask for a ItemStack,you can create the itemstack first,give it a meta wi...

public static ItemStack getCoatedPickaxe(ItemStack ironPickaxe) {
if (!ironPickaxe.getType().equals(Material.IRON_PICKAXE)) {
if (SlardcraftPlugin.DEBUG) Bukkit.broadcastMessage("ERROR: UNEXPECTED ITEM FOR IRON PICKAXE: " + ironPickaxe.toString());
throw new IllegalArgumentException();
}
ItemStack is = new ItemStack(Material.DIAMOND_PICKAXE);
ItemMeta isMeta = is.getItemMeta();
isMeta.setDisplayName("" + ChatColor.AQUA + "Coated " + ChatColor.RESET + "Pickaxe");
//isMeta.setLocalizedName(getCoatedPickaxeMeta(ironPickaxe));
is.setItemMeta(isMeta);
return is;
}

This is the function I use

onyx shale
#

also im mostly refering

gloomy arch
#

new MaterialChoice(Material.IRON_PICKAXE) This is the left side of the smithing table

onyx shale
#

to the result

#

not to your iron

quaint mantle
#

We need a predicate recipechoice

onyx shale
#

ah nvm thats the result

gloomy arch
gloomy arch
onyx shale
#

strange

#

should work,whats the output?

gloomy arch
#

It results in a default diamond pickaxe

onyx shale
#

hmm

#

try debugging it

#

call the method earlier and check the name

quaint mantle
#

thats wasnt an answer though, the recipe choice where you can do custom checks on ItemStacks. For example, checking if ingredient has custom model data or pdc tag

young knoll
#

That was suggested

#

MD said no

quaint mantle
#

why

gloomy arch
# onyx shale try debugging it

Yeah, I'll try some stuff. I have command that calls the same getCoatedPickaxe() method, and it returns the proper result.

onyx shale
#

strange might be a bug

#

with smithing recipe

young knoll
#

Not a big

#

Big

#

Rude

#

The meta of the input item is copied, since that’s how smithing tables work

#

Use the event if you want a custom output

onyx shale
#

so the fact its asking for a itemstack is pointless

#

if it wont copy everything

young knoll
# quaint mantle why

There is a Jira ticket somewhere, something about not knowing what to do when the plugin is disabled

#

Yeah it should just be a material

#

But you can make use of the itemstack in the event since you can just grab the result of the recipe

onyx shale
#

hmm yeah at least its a work around

gloomy arch
gloomy arch
young knoll
#

Last I tried though using setResult in the event broke things

#

Maybe it’s been fixed

onyx shale
#

yes recipes other than crafting ones were always... buggy

#

even they got fixed in recent versions

gloomy arch
# gloomy arch Cool, I'll try this. Thanks guys.

Just got it working.
For anyone curious, I just set the resultant item stack of the smithing recipe to a diamond pickaxe and created a listener for PrepareSmithingRecipeEvent

@EventHandler
public void coatedPickaxeListener(PrepareSmithingEvent event) {
if (!event.getResult().getType().equals(Material.DIAMOND_PICKAXE)) {
return;
}
ItemStack ironPickaxe = event.getInventory().getItem(0);
if (!ironPickaxe.getType().equals(Material.IRON_PICKAXE)) {
return;
}
event.setResult(CoatedPickaxe.getCoatedPickaxe(ironPickaxe));
}

young knoll
#

Does that work

gloomy arch
#

Yeah

young knoll
#

Interesting, must have been fixed then

#

Last time I tried to use setResult I couldn’t take the time out

tacit mica
#

Does anyone know how to set the random tick rate of a world through code?

#

I would expect it to be something simple like getWorld().setTickrate(int)

#

Nevermind, seems to be under setGameRule

ashen flicker
#

Yea it’s simple, you could also issue a console command, though it’s not necessary

tame elbow
#

hey, if I wanted to heal a player fully. I would just player.setHealth(10); ?

silver shuttle
#

could cause issues

tame elbow
#

is there an alternative i could use?

silver shuttle
#

first thing that comes to my mind is apply instant health effect of a very large scale

#

but might be scuffed if theres a better solution

paper viper
silver shuttle
paper viper
#

setHealth

silver shuttle
#

yes thats what I mean

paper viper
#

Oh ah

#

health boost

silver shuttle
#

heal a player fully --> if he has 24 hearts instead of 20 through health boost, that gets cancelled

paper viper
#

Tctutt do your players have health boost?

#

you can just calculate it anyways

silver shuttle
#

wait

#

targetPlayer.setHealth(targetPlayer.getMaxHealth());

#

6 years old tho

#

check if it still works @tame elbow

tame elbow
#

okay, ill test it

#

its deprecated

silver shuttle
#

replaced by?

tame elbow
#

GENERIC_MAX_HEALTH

young knoll
#

getAttribute

silver shuttle
#

try if it still works anyway, even if it is deprecated

young knoll
#

It does

#

It just delegates to getAttribute(Blah).getValue

silver shuttle
#

ah kk

#

so there's your solution Tctutt

tame elbow
#

okay ill see if that works, Thanks!

#

it works thank you!

silver shuttle
#

np

formal dome
#

?paste

undone axleBOT
formal dome
#

hey guys im' just wondering if this looks about right for sending a piece of data via a socket

#

its supposed to send a message from a onPlayerCommandPreprocessEevnt() through a socket to my server where my jda bot chills at

sullen marlin
#

yup that's a socket alright

#

I'd probably recommend a message queue or just putting the jda bot in the plugin, but if you want to use a socket that's ok

dark osprey
#

Depending on my code, is it possible to get an error depending on whether or not you use a lambda expression?

formal dome
#

thanks md_5!

drowsy helm
#

wdym

#

could you give an example

dark osprey
#

(Bukkit.getScheduler().runTaskTimer(plugin, () -> { do stuff

#

            @Override
            public void run() { do stuff
drowsy helm
#

yes i know what lambda is but what do you mean get an error on whether you use it

#

like if they dont use a lambda expression you throw an error?

formal dome
dark osprey
#

I am getting an NPE error because I am using a lambda expression.

drowsy helm
#

can you show your code

dark osprey
#

sure

#

for full code?

drowsy helm
#

yeah full code and the error

#

because you cant get an npe for using lambda its probably something else

dark osprey
drowsy helm
#

you know theres a @Setter notation with lombok

dark osprey
#

yes i know

drowsy helm
#

which is line 95?

dark osprey
#

the line 95 Location holo = getFindEntity().getLocation().clone();

drowsy helm
#

getFindEntity() is returning null then

#

or getLocation()

tacit mica
#

Is there any way to remove the UI that comes up when you start up a server locally? For me I would rather just use the console

drowsy helm
#

-nogui param

spare marsh
#

Hello, quick question. So I am creating a method that will get an inventory but inside a method I am calling another method that updates content inside that GUI. It wouldn't matter if the method to update returns void since what the method is updating is the same inventory and pointing to the same memory object so there wouldn't be a need to reassign that GUI instance correct?

graceful oak
#

I have a quick question after looking at a few plugins online I have noticed that they are organized with tons of different files and functions. Now these plugins have a lot of content and have had tons of time to be cleaned up and optimized. Is there any way I should be focusing on writing my code or is it more of an overtime situation with my own self improvents to make the plugin better

spare marsh
#

I would suggest just keeping your code neat. Create methods for every task you want to do and call the properly instead of having code that looks like junk. For sure look for the a way to get your methods to use less hardware as possible. I would say just avoid using methods that are overkill. Use the best primitive data types. I wouldn't know TBH personally I like to keep my code very commented and call methods for every task to make your main code block look more organized too. For example if you're updating an inventory when a condition is met, instead of updating on the block that's checking, call a method an pass in the inventory instance. Maybe this can help? I'm not very advanced https://stackoverflow.com/questions/12087275/how-do-you-organize-class-source-code-in-java

graceful oak
#

Thanks

#

So I am creating a type of xp gaining system when mining specific blocks and everything has gone good so far but I am at the point of the block being replaced and I have it storing metadata so that the server knows the block has been placed so it does not give xp. Now I am thinking the best approach to this would be a hashmap that saves to a file on server shutdown to save the blocks that were placed for when it comes back up. Would this be a good way to do this or is there a faster way?

young knoll
#

?clean-code

undone axleBOT
young knoll
#

For large amounts of blocks you probably want a database

#

I believe you can convert the block data to a string and store that

graceful oak
#

Would a database make it faster or is it just a better storage option

spare marsh
spare marsh
spare marsh
# young knoll Also use the world x y z as a unique identifier

I think that is also a good idea but you would need to convert the World, x, y, z to a single string format, then load Split it back up to actually format the location. If you just encode it instead, you could get the block location from the decoded block.

#

also every metadata of the block could be loaded back up

young knoll
#

Actually the data probably already contains the location

#

And you would keep the 4 separate, no reason to combine them

spare marsh
#

Yeah the block contains the location which is why I'm saying that you could just encode the block and when its decoded it will be the block instance so the location could just be accessed from there.

young knoll
#

Yeah you can just use a simple auto incrementing key

quaint mantle
#

alr i need some help with particle rotation and animations

#

im really bad at math, im just trying to make this sphere like rotate...

#

and i took a bunch of code and mashed it together

#

idrk what im doing tbh

iron palm
#

Hey uh
what's wrong with this while it should save the location in spawn:
but it isnt!
KnockbackFFA.getInstance().getConfig().addDefault("spawn", ((Player) sender).getLocation());

quaint mantle
#

reload?

#

forgot reload?

#

@iron palm

iron palm
quaint mantle
#

reloadConfig.

iron palm
#

oh

#

right

#

thanks

quaint mantle
#

did you even know that?

#

LOL

#

uhhh

iron palm
#
                KnockbackFFA.getInstance().reloadConfig();```
quaint mantle
#

Don't ghost ping @iron palm

#

At least say the reason before delete a ping.

#

Tho I saw that

#

Uhhh try use getConfig.set();

iron palm
iron palm
iron palm
#

uh not working

dark osprey
#

Do you have any console issue? @iron palm

dark osprey
#

Did you save config? @iron palm

iron palm
dark osprey
#

no reloadConfig

#

saveConfig();

iron palm
#

oh

#

so should i remove reloadConfig?

dark osprey
#

yes

#

you dont need reloadConfig

iron palm
#

thanks

#

but it only reloads the config

young knoll
#

It reloads it from file

#

Deleting any changes you’ve made in memory

iron palm
#

it is also removing the guides i have written in config

#
                KnockbackFFA.getInstance().saveConfig();

Why it isnt saving the configs value?
config file :

eternal oxide
#

show the actual config thats saved

quaint mantle
#

any reason i could be getting a ClassNotDef error when the class is defined?

eternal oxide
#

not shaded

#

or teh required lib is not on the server

quaint mantle
eternal oxide
#

yes

quaint mantle
#

odd...?

#

the command was just working so idrk whats up tbh

eternal oxide
#

does that class actually exist in your compiled jar?

quaint mantle
#

let me seee

#

ok nowi t works

#

idk anymore

eternal oxide
#

🙂

quaint mantle
#

thats the most Eclipse thing that's happened to me for a while

#

lmfao

iron palm
noble knot
#

Any reason why reload config doesn't work

#

I almost tried everything but this is the only thing that got it working

#

Is there an easier way of doing it?

iron palm
#

can't hook the placeholder api to my plugin in pom.xml i got an error :Invalid content was found starting with element '{"http://maven.apache.org/POM/4.0.0":repositories}'. One of '{"http://maven.apache.org/POM/4.0.0":parent, "http://maven.apache.org/POM/4.0.0":url, "http://maven.apache.org/POM/4.0.0":prerequisites, "http://maven.apache.org/POM/4.0.0":issueManagement, "http://maven.apache.org/POM/4.0.0":ciManagement, "http://maven.apache.org/POM/4.0.0":inceptionYear, "http://maven.apache.org/POM/4.0.0":mailingLists, "http://maven.apache.org/POM/4.0.0":developers, "http://maven.apache.org/POM/4.0.0":contributors, "http://maven.apache.org/POM/4.0.0":licenses, "http://maven.apache.org/POM/4.0.0":scm, "http://maven.apache.org/POM/4.0.0":organization, "http://maven.apache.org/POM/4.0.0":profiles, "http://maven.apache.org/POM/4.0.0":modules, "http://maven.apache.org/POM/4.0.0":pluginRepositories, "http://maven.apache.org/POM/4.0.0":reports, "http://maven.apache.org/POM/4.0.0":reporting, "http://maven.apache.org/POM/4.0.0":dependencyManagement, "http://maven.apache.org/POM/4.0.0":distributionManagement}' is expected.

    <repository>
      <id>placeholderapi</id>
      <url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
    </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>me.clip</groupId>
      <artifactId>placeholderapi</artifactId>
      <version>1.16</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>```
pale pasture
iron palm
pale pasture
#

just add it as Buildpath?

iron palm
pale pasture
#

oh ok, i never done it with macen

#

maven"

iron palm
#

i never done with gradle too ...

pale pasture
#

i use normal Java xD

iron palm
#

oh

#

lol

pale pasture
#

is it better using maven or Java

#

my look so

#

ignore the errors

iron palm
tacit drift
#

maven easier to understand and use

#

gradle faster

pale pasture
tardy flame
pale pasture
#

bc i do that everytime?

tardy flame
#

That's....

pale pasture
#

and i learned it so

tardy flame
#

Where did you learn it?

pale pasture
#

from tutorials, many tutorials

tardy flame
#

Fuck tutorials

#

Only skill

#

(don't take tutorials so seriously, practically all of them teach java not object oriented which is bad)

pale pasture
#

ok, so its bad using a package for Main.java?

tardy flame
#

If i remember correctly yes

pale pasture
#

oh ok..

tardy flame
#

I mean it's not big deal

#

But it it easier to use without additional packages

pale pasture
#

hmm ok

#

but for me its something i do autmaticly, when i create a plugin

tardy flame
#

For me i create entire new class called plugin Name + Controller in which i do all operation on start / disable server and I have everything in main class clean

pale pasture
#

but ist bad using only one class for everything

#

oh ups

eternal oxide
#

Name your plugin entry class the same as your plugin.

eternal oxide
tardy delta
eternal oxide
#

You are literally turning off the power and wondering why the lights went off too

noble knot
eternal oxide
#

just call reloadConfig()

noble knot
#

It doesn't work

tardy delta
#

why turning off your plugin?

noble knot
#

I tried

eternal oxide
#

its a single thread

noble knot
noble knot
eternal oxide
#

all plugins run on a single main thread

#

when you call reloadConfig() everything waits for your config to be reloaded

noble knot
#

Ok?

eternal oxide
#

a slight simplification, but thats the general process

#

you need do no more than call reloadConfig()

noble knot
#

What else?

eternal oxide
#

nothing

noble knot
#

?

eternal oxide
#

?

#

you literally call reloadConfig(), nothgin more or less

#

If you are seeing an old config, then you are holding a reference to an out of date FileConfiguration somewhere

noble knot
#

SO like this?

eternal oxide
#

if thats the name of your plugin, yes. However you should really pass an instance of your main class rather than getting the plugin statically

noble knot
#

I am in my main class

eternal oxide
#

then just call reloadConfig()

tardy delta
#

disabling the plugin and then trying to reload it :/

eternal oxide
#

you don;t need a plugin reference as your main IS your plugin

noble knot
#

bruh

#

oh k it was becuz my function was static

#

so now how do i reload config in another class?

eternal oxide
#

you pass that class a reference to your main class

noble knot
#

sheesh

eternal oxide
#

?di

undone axleBOT
noble knot
#

With a constructor?

tardy delta
#

yesh

noble knot
eternal oxide
#

yes

noble knot
#

ok

#

gud

#

lemme test now

#

bruh

#

wait

eternal oxide
#

you are trying to access plugin in a Field when its only set in your constructor

#

at that point plugin is null

noble knot
#

🤔

#

So i put that later

eternal oxide
#

you have to read the values after you assign plugin

noble knot
#

ye h

#

K fixed

#

poof

#

error

eternal oxide
#

bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.amazindev.amazinutilities.AmazinUtilities.getCommand(String)" is null

noble knot
#

yes

eternal oxide
#

your command doesn;t exist in your plugin.yml

noble knot
#

huh

#

oh

#

done

#

I changed it in the config

#

But it doesn't change

eternal oxide
#

yes, because you set the value to a Field when your command class is instanced

tardy delta
#

hmm i'm kinda struggling to find a way to save a Map<UUID, ItemStack[]> to a file. The ItemStack[] is saved in a base64 string so in fact its Map<UUID, String> but i want to save it like

safe-chests:
  - uuid1 : base64-string
  - uuid2: etc
eternal oxide
#

a Field never changes unless you change it. So you need to update it after you reload teh config

sullen marlin
#

The - is pointless

tardy delta
#

now i have it like this

dataFile.set("safe-chests", SafechestGui.getMenus().values().stream().map(InventorySerialisation::itemStackArrayToBase64).collect(Collectors.toList()));```
sullen marlin
#

Reverse your logic

#

Items.forEach(set(item.uuid, serialize))

eternal oxide
#

an ItemStack would actually be shorter saved through serialization to yaml rather than converting to base64

tardy delta
sullen marlin
#

Yes

tardy delta
#

lets try it

alpine urchin
#

md_5, when we will have a spigot meetup

noble knot
sullen marlin
#

Wrong channel

tardy delta
mortal hare
#

is there any way to get leashable entities in NMS or spigot?

sullen marlin
#

Wdym

mortal hare
#

entities that in vanilla can be used with lead

sullen marlin
#

Every living entity can

mortal hare
#

yes, but not everyone persists

#

second tick removes leash if its hostile for example

sullen marlin
#

didn’t know that was a thing

#

Find out the criteria and just check yourself?

#

Its gonna be something easy like instanceof Living and not instanceof Monster

mortal hare
#

but what about villagers

#

they're leashable too

zealous osprey
#

Is "onTabCompete" exclusive to commands, or can it be used in the normal chatbox aswell. I assume so, but couldn't find anything.

sullen marlin
#

They’re living and not monsters

mortal hare
#
    public static boolean isLeashable(LivingEntity entity) {
        switch (entity.getType()) {
            case WOLF, CAT -> {
                return ((Tameable) entity).isTamed();
            } case AXOLOTL, BEE, CHICKEN, COW, DOLPHIN, FOX, GOAT, HOGLIN, HORSE, ZOMBIE_HORSE, SKELETON_HORSE, IRON_GOLEM, LLAMA, TRADER_LLAMA, MUSHROOM_COW, MULE, OCELOT, PARROT, PIG, POLAR_BEAR, RABBIT, SHEEP, SNOWMAN, SQUID, GLOW_SQUID, STRIDER, ZOGLIN -> {
                return true;
            }
        }
        return false;
    }

this is what I currently have

sullen marlin
#

Definitely exclusive in 1.13+ or whenever they redid it to be fancy

#

Can’t recall older versions

#

Why do people use those new switches everywhere now

mortal hare
#

because Intellij doesnt shut up

mortal hare
#

wait nvm strider is not a monster

#

ok

#

but still i need to check enderdragon

mortal hare
mortal hare
vale ember
#

can someone help changing sword damage without using NMS?

zealous osprey
#

ye I saw, you could make fake players, that's to much of a hassle tho

mortal hare
#

It utilises brigadier (although poorly) internally to provide suggestions to the client, so there's no way to suggest autocompletions without tinkering with the command api

mortal hare
zealous osprey
#

sadly, I hoped there would be an easier fix, due to minecraft also having autocomplete in normal chatbox, but ye, sadly nothing to be done

tardy delta
vale ember
tardy delta
#

i guess the entitydamagevent

#

and adapt the damage if the damager is a player

vale ember
#

i'd like to use attributes

tardy delta
#

uhh

vale ember
#

but when i use them on sword it removes sword attack speed and dont change attack damage properly

#

i am trying to add 5 damage to iron sword

#
        ItemMeta meta = item.getItemMeta();

        assert meta != null;
        UUID uuid = UUID.randomUUID();
        String name = "test";
        meta.addAttributeModifier(attribute, new AttributeModifier(uuid, name, 5, operation));

        item.setItemMeta(meta);
mortal hare
#
public class EntityInteractListener implements Listener {

    @EventHandler
    public void onEntityInteract(PlayerInteractAtEntityEvent event) {
        if (event.getHand() != EquipmentSlot.HAND || event.getPlayer().getInventory().getItemInMainHand().getType() != Material.STICK || !(event.getRightClicked() instanceof LivingEntity)) return;
        ((LivingEntity) event.getRightClicked()).setLeashHolder(event.getPlayer());
    }
}

such a simple method, but it doesnt leash the mobs whenever i hold the stick

#

even cows

#

it just drops the lead on the ground

vale ember
mortal hare
mortal hare
vale ember
mortal hare
#

Iirc attributes are not new stuff so it should be 1.8 compatible for sure

#

they were probably added in 1.6 or 1.7

#

iirc

vale ember
#

and also there isn't Attribute.GENERIC_DAMAGE

#

i added EquipmentSlot.Hand but it still removes attack speed and makes text blue instead of green in 1.17.1

mortal hare
mortal hare
#

it just refuses to be leashed

#

leash drops on the ground

rough jay
#

Please I need help I tried what I could but it still doesn't work...

tardy delta
#

is it true that all database operations should be executed async, no matter how big they are?

paper viper
#

yes

tardy delta
#

oki

noble knot
eternal oxide
gleaming grove
#

Hi, do you know any API for Integration tests in spigot?

acoustic pendant
#

How could i do to change things like this by the config?

#.#
are decimals
so, how can i do to the people change as they want?
to add less or more decimals
#.###
or

tardy delta
noble knot
#

No errors tho

quaint mantle
#

Hello everyone, is there a tool with which I can convert a plugin, i.e. a .jar file, back into a project?

eternal oxide
#

it can't "not reload"

noble knot
eternal oxide
#

it is, you are just doing somethign wrong

quaint mantle
#

Yes, I have a decompiler but with it I can only look at the source code and not edit anything.

eternal oxide
#

probably reading it wrong

noble knot
#

Wdym

eternal oxide
#

as I said before, you are copying the values from the config to Fields. If you do not update them when you reload your config they will not change.

quaint mantle
#

But with the tool I can only view source code or not?

quaint mantle
#

Yes, the one you sent me

eternal oxide
#

the same way you set them in the first place

noble knot
#

This not enough?

eternal oxide
#

that reloads teh config

tardy delta
acoustic pendant
tardy delta
#

changing a value in config?

eternal oxide
#

you have fields in yoru Listener/command class?

quaint mantle
noble knot
#

But how do I reload those?

eternal oxide
#

where you are copying values from your config

noble knot
eternal oxide
#

as I just said, you set them the same as you did the first time

noble knot
#

How do I update them?

eternal oxide
#

or you stop messing about with the fields and read from the config.

eternal oxide
#

I feel like I'm being trolled here.

noble knot
#

No?

eternal oxide
#

I think you are. You stopped using the constructor and passing yoru main class and changed to a Field with a getter

#

you actually went to worse from decent

acoustic pendant
noble knot
# eternal oxide I think you are. You stopped using the constructor and passing yoru main class a...
public class ReloadConfigCommand implements CommandExecutor {
    AmazinUtilities plugin;

    public ReloadConfigCommand(AmazinUtilities plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        String noPerms = plugin.getConfig().getString("noPerms");
        String successfullyReloadedConfig = plugin.getConfig().getString("successfullyReloadedConfig");
        if(sender.hasPermission("amazinutilities.reload")) {

            Player player = (Player) sender;
            plugin.reloadConfig();
            player.sendMessage(ChatColor.GREEN + successfullyReloadedConfig);  // where ?
        } else {
            sender.sendMessage(ChatColor.RED + noPerms + "(amazinutilities.reload)");
        }
        return true;
    }
}
``` I am using the constructor when i reload. I don't understand what you're saying.
eternal oxide
#

look at that code, you are reading the successfullyReloadedConfig string before you even reload

noble knot
#

Yes but before I was testing the rules command

#

Not this message

eternal oxide
#

there are no buts, you are reading from teh config and then reloading. You are using data from the old config

noble knot
#
public class RulesCommand implements CommandExecutor {
    public JavaPlugin plugin = AmazinUtilities.getPlugin(AmazinUtilities.class);
    public FileConfiguration config = plugin.getConfig();
    String rules = config.getString("rules");
    String noPerms = config.getString("noPerms");


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

        if (sender.hasPermission("amazinutilities.rules")) {
            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', rules));

        } else {
            sender.sendMessage(ChatColor.RED + noPerms + "(amazinutilities.rules)");
        }
        return true;
    }
}``` ?
eternal oxide
#

you've not shown code from rules, you were askign about yoru reload

noble knot
#

Bruh

eternal oxide
#

ok, you create two String Fields

#

why?

#

just read from the config

#

plugin.getConfig()

noble knot
# eternal oxide just read from the config
public class RulesCommand implements CommandExecutor {
    public JavaPlugin plugin = AmazinUtilities.getPlugin(AmazinUtilities.class);

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

        if (sender.hasPermission("amazinutilities.rules")) {
            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("rules")));

        } else {
            sender.sendMessage(ChatColor.RED + plugin.getConfig().getString("noPerms") + "(amazinutilities.rules)");
        }
        return true;
    }
}``` Like this?
eternal oxide
#

yes

noble knot
#

Ok lemme test

#

also at the begining do i use Plugin or JavaPlugin?

#

It works

noble knot
vale ember
#

is there a way to add overall regen, heart, or damage to player with any weapon?

onyx shale
#

? be more specific

bleak void
#

Hello! someone joined into my server and executed a command that crashed my server. (/mv ^(.........................*.++)$^). Are there any more commands that can do this?

onyx shale
#

very known exploit

#

thats why you should update your plugins..

bleak void
#

all of them are updated

#

i am blocking them with nocheatplus and thats why i want to know the commands

onyx shale
#

so i guess ur multiverse is 4.3.1?

bleak void
#

no, i told that i have to install the compatible version for my server

#

my server version is 1.8

onyx shale
#

ahh.. nvm then

#

in that case i strongly doubt you will get any support fo 1.8...

bleak void
#

so i installed multiverse 2.5-b699 (beta)

onyx shale
#

you could ask the author to fix it in 1.8 as well but not sure he will bother

bleak void
#

i blocked that command from nocheatplus

#

i was just asking if it is a list of commands that have to be blocked😅

onyx shale
#

thats the only one known so far

bleak void
#

oh ok, thank you!

vale ember
#

how to change natural regen, damage of everything of specific player, and heart count?

onyx shale
#

be more specific

vale ember
#

like make player damage more no matter what weapon

onyx shale
#

listen to damage event check if its your player,add more to it

vale ember
#

and what about adding hearts?

onyx shale
#

get players generic max health attribute

#

set it higher

toxic hornet
#

im bad at that stuff

rapid vigil
#

Hey I have a little question, I'm coding on 1.16 and I noticed that the setDisplayName() method in ItemMeta is deprecated, I just wanna know what is the new method for setting a display name

weak mauve
#

anyone know what method is triggered when you mine a block

rapid vigil
weak mauve
#

other than .as();

#

no

#

NMS

rapid vigil
#

Ah

weak mauve
#

im making mining system

rapid vigil
#

PacketPlayOutBlockBreak?

weak mauve
#

and the as() break when combine with Mining fatigue

toxic hornet
#

Can anyone help me make a bungeecord server? I have a lot of servers already and want to make them into gamemodes..
im bad at that stuff

weak mauve
rapid vigil
rapid vigil
#

And also the way to create a GUI for me is deprecated

eternal oxide
#

If teh javadocs don;t say deprecated its not

rapid vigil
#

Might be a bug?

eternal oxide
#

Would you be using "not" Spigot?

weak mauve
#

well yes

rapid vigil
#

I just knew why

#

It's because I'm using paper

rapid vigil
#

Paper is actually smoother but not sure if spigot has more methods, I noticed that paper has more stuff

#

That's why I use it, and I use spigot when I wanna use NMS & Packets

weak mauve
rapid vigil
weak mauve
#

im still developing in 1.8

#

lol

#
public static void spawn(org.bukkit.Location l) {
    FunctioningAPI a = api.registerInstance(getPlugin());
    SEntityWild sent = new SEntityWild(EntityType.PLAYER,
    10000000,
    10000,
    SkySimStandardAI.class,
    getPlugin(),
    true
    ));
    a.registerEntity(sent);
    SEntityEquipments seq = sent.getEquipment().getHandle();
    ((SkySimNPCMob) sent).setSkinFrom(Source.PLAYER_NAME, "AMOGUS");

    FullArmorSet fqs = a.buildArmorSetFromHexColor(0x0000, EnumArmorType.LEATHER_ARMOR);
    fqs.setGlowing(0,1,1,1);
    fqs.setUnbreakable(1,1,1,1);
    fqs.setDefense(100,100,100,100);
    seq.t().register(fqs);

    sent.setTarget(api.chooseRandomInRange(l,16,16,16, EntityType.PLAYER));
    sent.spawnAt(l.toSkySimLocation().s());
}
 
#

then i need some of my own method like this

quaint mantle
last ledge
#

how do i send list of commands from config.yml?

quaint mantle
#

Huh?

stone sinew
acoustic widget
#

Hello, how can i manage "entity" to save in database like symfony or laravel in web development but in java. I would like to build something easy for my plugin and I have some data to save in database. Do you have any tips ? Thanks

acoustic pendant
#

How could i do to change things like this by the config?

#.#
are decimals
so, how can i do to the people change as they want?
to add less or more decimals
#.###
or

tardy delta
#

do i need to close something in a database when calling connection.prepareStatement(string)?

vale ember
#

is there a way to display text above hotbar WITHOUT using NMS or APIs?

left swift
#

hey i have a quick question i am creating a class extending entityarmorstand, and i wish the mob (armorstand) i create had a natural movement like other mobs (pig or cow), how can i do that?

hasty prawn
vale ember
hasty prawn
#

What version are you using

#

I don't know what version that was added in, but I don't think it's a 1.8.9 feature, if you're looking to support that. If you're supporting 1.8.9, there's no Spigot API for sending an Action Bar as far as I'm aware, so you need to resort to one of the options you said earlier.

vale ember
#

i want to make plugin that'll work on all version from 1.8 to 1.17.1 but currently i am testing on 1.17.1

hasty prawn
#

Well Reflection it is then. You need to send packets if they're on versions that don't have the API

acoustic pendant
#
        WorldCreator wc = new WorldCreator("AsteroidWorld");

        wc.environment(World.Environment.NORMAL);
        wc.type(WorldType.FLAT);

        wc.generatorSettings("2;0;1");
        wc.createWorld();
#

Hello, i have this code that "makes" a void world

#

but that makes that the plugin throws an error to the console

#

do i have to specify something else?

hasty prawn
#

Send the error

#

?paste

undone axleBOT
hasty prawn
#

It doesn't like your generator settings

acoustic pendant
#

what?

hasty prawn
#

wc.generatorSettings("2;0;1");

#

It doesn't like 2;0;1

acoustic pendant
#

uhm

#

it creates in a 1.8

#

server

acoustic pendant
hasty prawn
#

You just need to correct the String, I'm sure there's some tutorial out there for 1.8.9 for valid JSON. I don't know what it should be off the top of my head.

acoustic pendant
#

because i haven't found nothing about 1.16

hasty prawn
#

If you're going to use outdated software, yes

#

There's an example for 1.16 generator settings in the docs

acoustic widget
#

Hello guys what do you use for database storing ? anylibrary or something else ? I would like to easily use h2 or mysql, sqlite

onyx shale
#

unless you plan cross-server data..

left swift
#

How can i make entity ArmorStand with natural mob movement?

graceful oak
#

I am trying to create a system that tracks certain blocks placed by players using metadata. The way I want to do it is by storing the blocks chunk as a key then location as a value in a hash map that way I dont need to load all the blocks on startup but rather on chunk loads so there isnt too much for the server to do. The problem I am running into is when im using the hash map wouldn't a new block in the chunk just replace the last since they would both have the key of the chunk? Is there a better way for me to setup this system? I was going to store them in a yaml file under each chunk on server shutdown

young knoll
#

Multimaps exist

#

1 key may have several values

graceful oak
#

oh cool ill look into that thanks

opal juniper
#

uh so like uh do essentials have an api

#

for their chat

#

or no

#

i tried looking everywhere

#

but i can’t find it

tacit drift
tardy delta
#

Essentials chat?

#

And then vault added

graceful oak
#

So im creating a private map for keeping track of blocks that were placed by players and im trying to use a multimap but I cant initialize the map like this. Am I doing something wrong or is this not possible. From what ive been seeing its better off for me to create a normal hashmap and just use an arraylist as my value but I figured I would ask incase there is a way to do it like this

https://pastebin.com/b2Nae5wB
'ListMultimap' is abstract; cannot be instantiated

quaint mantle
#

Well, thats it

acoustic widget
#

Hello why i don't have description of methods on IDEA ?
In this doc i see "Returns the folder that the plugin data's files are located in.". There is a way to get them ?

Edit : solved by right clicking project > Download source & docs

young knoll
#

private final Multimap<Class<? extends Event>, EventWrapper<? extends Event>> handlerMap = ArrayListMultimap.create();

quaint mantle
#

There should be an implementation of Listmultimap

opal juniper
#

Anyone know how i get a users rank on essentials

#

/ their message prefix

#

on essentials chat

young knoll
#

The rank can be obtained from vault

tender shard
young knoll
#

It's in chat

iron palm
#

how can i get inventory from an entity(which im sure it is player)

opal juniper
#

Player#getInventory

#

wdym by:

which im sure it is player
Its either a player or its not

#

You probably need an instanceof check

iron palm
opal juniper
#
if (entity instanceof Player) {
  Player player = (Player) entity;
}

Newer Java versions:

if (entity instanceof Player player) {
}
iron palm
opal juniper
#

so cast it

solid cargo
#

how da heck do i uncompress doubles

#

cause look at this, the ones above uses ints, the ones below use floats, cause it works like that

young knoll
#

What's the issue?

solid cargo
#

/eco take Power_Button 1.0E9

#

this is what console executes

young knoll
#

You probably need a parser for that

solid cargo
#

thanks <3

grand flint
#

What is wrong with these,

import org.bukkit.craftbukkit.v1_17_1_R0.entity.CraftPlayer;
import net.minecraft.server.v1_17_1_R0.ChatComponentText;
import net.minecraft.server.v1_17_1_R0.PacketPlayOutPlayerListHeaderFooter;```
I think I did the 1.17.1 part wrong not sure how to fix it just errors
young knoll
#

import net.minecraft.network.chat.ChatComponentText;

#

NMS was repackaged

#

Your IDE should handle imports for you

grand flint
#

Fixed it thank you

#

Why does this line,
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); give me the error, cannot resolve constructor PacketPlayOutPlayerListHeaderFooter();

young knoll
#

Why are you using a packet for that

grand flint
grand flint
#

Thank you

grand flint
young knoll
#

Remove the sendPacket line?

grand flint
young knoll
#

You can just use player.setPlayerListFooter

#

And setPlayerListHeader if you want that too

grand flint
#

I already managed to do that

#

So I get rid of the getHandle and playerConnection and just do ((CraftPlayer)player).setPlayerListFooter

young knoll
#

Get rid of the cast to CraftPlayer too

grand flint
#

if (Bukkit.getOnlinePlayers().size() != 0) {
for (Player player : Bukkit.getOnlinePlayers())
player.setPlayerListFooter();
}

grand flint
young knoll
#

You need to provide a string

#

?learnjava

undone axleBOT
grand flint
# young knoll ?learnjava

Does it being animated change anything? I am making an animated tab list is that why the plugin tutorial used packets?

young knoll
#

Doubt it

#

That method basically just sends a packet for you

grand flint
grand flint
tender shard
young knoll
#

It surprised me too

grand flint
tender shard
#

yeah that totally makes sense

#

java is pretty straightforward when you used other OOP languages already 🙂

grand flint
#

I'll manage! :)

tender shard
#

great! let us know when you got any questions 🙂

grand flint
#

Will do! It would probably be more mc related rather than simple java 😂

#

Thanks for the help anyways

tardy delta
#

Boo

lean gull
#

hello! i have a question regarding apis:
i want to make a plugin with the minecraft heads api like the heads database plugin, but i do not know how
for example, i do not know how to even use the api in a plugin, like read from it or split by head. i also don't know how to make it work with pages, like to count how much heads there are and then make enough pages accordingly

tardy delta
#

Steal hdb

lean gull
#

no

tender shard
torn vale
#
    @EventHandler
    public void onWitherSound(EntityExplodeEvent e) {
        if (e.getEntityType() == EntityType.WITHER) {
            int soundRange = plugin.getConfig().getInt("spawnSoundRange");

            for (Player player : plugin.getServer().getOnlinePlayers()) {
                if (e.getLocation().getWorld().equals(player.getWorld())) {
                    if (e.getEntity().getLocation().distance(player.getLocation()) <= soundRange) {
                        player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1F, 1F);
                    } else if (e.getEntity().getLocation().distance(player.getLocation()) >= soundRange) {
                        return;
                    }
                }
            }
        }
    }```
This is my code. Does any1 knows how to cancel ONLY the wither spawn sound in m else if body?
lean gull
tender shard
torn vale
#

idk why

tender shard
#

erm ofc you can

lean gull
#

how do i use the api from a plugin? as in how do i read from it?
how do i then split it to individual heads? like to get each head instead of just a massive text wall
how do i make it so it works with pages? there aren't enough slots in a gui to fit that amount of heads

lean gull
#

ok

torn vale
young knoll
#

I smell outdated

torn vale
#

its spigot 1.8 btw

tender shard
young knoll
#

Yep that would be why

#

Use a packet listener

torn vale
quaint mantle
young knoll
#

Protection Environmental is Protection

#

Protection fall is feather falling

torn vale
quaint mantle
arctic moth
#

how do you change the firerate of vanilla mobs like skeleton

young knoll
#

Smite and Sharpness

quaint mantle
#

Do you know if there is a list of these converted to the in-game names?

#

Thank you btw

young knoll
#

Don't know, but they are generally pretty obvious

young knoll
arctic moth
#

wdym

#

its not pathfinding its shooting rlly fasyt

#

like thats what i want it to do

#

like ik i could get target but idk what after

#

or is there just like an nbt for fire rate

young knoll
#

Actually that isn't a goal

arctic moth
#

lol

torn vale
young knoll
#

Yes

torn vale
#

okay

young knoll
#

Shooting is controlled by EntitySkeletonAbstract#a

hollow bluff
#

Isnt it pathfinder goal? Pretty sure it is?

young knoll
#

Not in 1.17

little trail
#
[21:37:37 WARN]: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "915631c8")```
 ```java
CompletableFuture.supplyAsync(() -> {
    try {
        Statement statement = conn.createStatement();
        statement.setQueryTimeout(30);
        statement.executeUpdate(
                String.format("INSERT INTO players (id, uuid) VALUES (%s, %s)", id, uuid));
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return String.format("Player with id %s and uuid %s added to database!");
}).thenAccept(result -> {
    logger.info(result);
    return;
});```
lean gull
#

can anyone help me with an api in my thread? (it's a discord thread, not a forum thread)

young knoll
#

Granted I am not sure where EntitySkeletonAbstract#a is called from

torn vale
young knoll
arctic moth
young knoll
#

I assume it is either Entity Sound Effect Sound Effect or Named Sound Effect

torn vale
#

So how to use it? I never worked with this api before

torn vale
#

I only need the PacketTypee.Play.Server part

young knoll
#

Believe that cancels boss sounds

rough jay
#

still waiting for help...

torn vale
#
    public OnPacketSending(Plugin plugin)

which import is "Plugin"?

young knoll
#

import org.bukkit.plugin.Plugin;?

#

It's a superclass of JavaPlugin

torn vale
#

ty

little trail
young knoll
#

Or just look at the imports in the git file

torn vale
#

in the git file there is no import for Plugin

young knoll
#

Final import

torn vale
#

thats why im asking lol

#

oh okay

#

oh wait

#

I didnt saw the import, my fault

little trail
#

i insert the uuid and it doesnt like it

torn vale
#

How to register the onPacketSending in my Main Class?

young knoll
#

Follow the tutorial

torn vale
#

okay so Id 1023 is Wither spawning. Should it work now?

#
        protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, PacketType.Play.Server.WORLD_EVENT) {
            @Override
            public void onPacketSending(PacketEvent event) {
                PacketContainer packet = event.getPacket();
                Player player = event.getPlayer();
                int effectId =  packet.getIntegers().read(0);
                int range = plugin.getConfig().getInt("spawnSoundRange");
                Location location = packet.getBlockPositionModifier().read(0).toLocation(player.getWorld());
                if (effectId == 1023) {
                    if (player.getLocation().distance(location) >= range) {
                        event.setCancelled(true);
                    }
                }
            }
        });```
#

I dont have ProtocolLib installed on my server so I cant test it atm

young knoll
#

Only one way to find out

little trail
#

if you cant test it, wait until you can

#

as it wont work if you dont have the plugin on

torn vale
#
package de.leleedits.antiwithersound;

import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {

    public static Main plugin;
    private ProtocolManager protocolManager;

    public void onEnable() {
        plugin = this;

        protocolManager = ProtocolLibrary.getProtocolManager();

        protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, PacketType.Play.Server.WORLD_EVENT) {
            @Override
            public void onPacketSending(PacketEvent event) {
                PacketContainer packet = event.getPacket();
                Player player = event.getPlayer();
                int effectId =  packet.getIntegers().read(0);
                int range = plugin.getConfig().getInt("spawnSoundRange");
                Location location = packet.getBlockPositionModifier().read(0).toLocation(player.getWorld());
                if (effectId == 1023) {
                    if (player.getLocation().distance(location) >= range) {
                        event.setCancelled(true);
                    }
                }
            }
        });
    }
    public static Main getPlugin() {
        return plugin;
    }
}

Why isnt the server using the plugin?

young knoll
#

Check startup logs

#

Make sure you have the plugin.yml sorted

#

Etc

torn vale
little trail
#
[21:37:37 WARN]: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "915631c8")```

 ```java
CompletableFuture.supplyAsync(() -> {
    try {
        Statement statement = conn.createStatement();
        statement.setQueryTimeout(30);
        statement.executeUpdate(
                String.format("INSERT INTO players (id, uuid) VALUES (%s, %s)", id, uuid));
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return String.format("Player with id %s and uuid %s added to database!");
}).thenAccept(result -> {
    logger.info(result);
    return;
});```
 where id and uuid are simply strings
young knoll
torn vale
#

ofc

#

no wait

#

no xd

#

naah dont works

#

still getting the spawn sound

alpine urchin
#

ok

quaint mantle
rough jay
young knoll
torn vale
#

How to print the id?

#

Like I would do it with a for loop

#

but idk

quaint mantle
#

your playerDataMap isn't static so that definitely wont work

#

Your add balance also has no way to confirm if it was added

lean gull
#

can someone help me in my discord thread please? thanks in advance

rough jay
#

so do I have to make every method in PlayerManager static?

young knoll
#

Then spawn a wither and see what number comes through

torn vale
#

yea but I mean how to get the int

#

like I didnt got how to do it on my own

rough jay
wide coyote
#

why static

rough jay
#

well idk

#

you see, if I do PlayerManager.getPlayerBalance(p) it says :
Non-static method 'getPlayerBalance(org.bukkit.OfflinePlayer)' cannot be referenced from a static context

#

so the only way to make it work is to make getPlayerBalance static