#help-development

1 messages · Page 1670 of 1

tardy delta
#

id unno why a map

quaint mantle
#

I didn't notice that I wrote EconomyManager.setupEconomy (); in the wrong place

tardy delta
#

and no i dont want > 1

quaint mantle
#

public void onEnable() {
instance = this;
Bukkit.getPluginManager().registerEvents(new BubleUse(), this);
Bukkit.getPluginManager().registerEvents(new GUI(), this);
Bukkit.getPluginManager().registerEvents(new ItemUtil(), this);
EconomyManager.setupEconomy();
File config = new File(getDataFolder() + File.separator + "config.yml");
if (!config.exists()) {
getConfig().options().copyDefaults(true);
saveDefaultConfig();

    }

}
maiden briar
#

Yes I already thought so

#

Did you fix it?

quaint mantle
#

if (!config.exists()) {
getConfig().options().copyDefaults(true);
saveDefaultConfig();

tardy delta
#

Listener[] omg

quaint mantle
#

я это написал здесь

#

I wrote it hereъ

#

EconomyManager.setupEconomy();

quaint mantle
maiden briar
#

Ok np

quaint mantle
#

thank you very much for your help

maiden briar
#

And my patience 😄

#

But anyways u can always ask me

quaint mantle
#

okay, thanks

prime reef
#

also, where is 'p' coming from?

grim ice
#

ofc it can

lavish hemlock
#

well it depends on if the variable is set after initialization

grim ice
#

final doesn't make a set immutable so it should be fine?>

lavish hemlock
#

some people do that to clear a collection as opposed to .clear()

#

which can be faster sometimes

prime reef
#

but off the top of my head you could condense it into this

private HashMap<UUID, Boolean> flyingPlayers = new HashMap<>();

protected boolean execute(CommandSender sender, String[] args) {
   Player target;
   // you could do this in one line but for the sake of readability i'll do it this way
   if (args.length >= 1)
       target = Bukkit.getPlayer(args[0]);
   else if (sender instanceof Player)
       target = (Player) sender;

   if (target != null)
       flyingPlayers.put(target.getUniqueId(), flyingPlayers.containsKey(target.getUniqueId()) ? !flyingPlayers.get(target.getUniqueId()) : true);
   return true;
}```
#

i changed the method because i have no idea where you're getting 'p' from

#

you shouldn't be generating a new instance of a command every time a player uses it, if that's what you're doing

ivory sleet
#

indeed

tardy delta
#

p is the player

prime reef
#

yes

#

I gathered as much

grim ice
#

imagine one letter variables

prime reef
#

but where are you getting that? because it's not an argument in your method

prime reef
tardy delta
#

parent class

#

^^

prime reef
#

What's the parent class?

tardy delta
#

abstract command

prime reef
#

...are you setting p every time a player executes a command?

tardy delta
#

no

#

parent class has the oncommand method

prime reef
#

so p is a class level variable?

tall dragon
#

he probably uses something like this

public abstract class TargettedCommand extends SimpleSubCommand
{


   protected TargettedCommand(SimpleCommandGroup parent, String sublabel) {
       super(parent, sublabel);
   }

   @Override
   protected void onCommand() {
       final Player player = findPlayer(args[0]);
       onTargettedCommand(player);
   }

   protected abstract void onTargettedCommand(Player target);
}
prime reef
#

his execute method only accepts arguments and the command class has a class-level variable called 'p', from what I can gather

tardy delta
#

?paste

undone axleBOT
tardy delta
prime reef
#

so you are in fact setting p every time a command is executed

#

can you see why this would cause problems?

tardy delta
#

no

tall dragon
#

its generally not really encouraged to cache a player object either

prime reef
#

^ mutable

#

which is why it would cause problems

#

instead of doing that, just pass the relevant player in through execute

tardy delta
#

:/

prime reef
#

it's not a massive change to make to your existing class

severe marsh
#

How do I connect my plugin to discord webhook and log events with it?

tardy delta
#

why would i pass the player every time if i can get him from there

prime reef
#

just add a CommandSender parameter to execute and pass that in through your onCommand method instead

tardy delta
#

i know but why

prime reef
#

because you're not caching and operating on a reference to a mutable object that way

ivory sleet
#

such as JDA or Javacord or Discord4j

tardy delta
ivory sleet
#

implementing low level logic to handle discord api is gonna take you quite the effort

#

so just use a library for it 😄

prime reef
#

not 100% certain how spigot's server thread works but there's a risk of running into situations where that player object changes and messes up the results of a command execution

severe marsh
#

Alright got any good tutorials for it?

tardy delta
#

jordan osterberg

ivory sleet
#

there's lots on the internet, find one and send it here and I'll review

prime reef
ivory sleet
prime reef
#

for context, we're discussing his command class, whereby each command caches a reference to the player that last used it and uses that to execute the command

#

this

severe marsh
ivory sleet
#

that ones probably fine

tardy delta
prime reef
#

whereas i'm saying that you should only be passing through command senders as parameters rather than caching them

severe marsh
#

O

prime reef
#

esp since player is mutable

severe marsh
#

Well guess I'll watch it then

#

Thanks for help 👍

ivory sleet
#

yeah well its not a great design

tardy delta
#

i dunno what caching is

ivory sleet
#

but a player instance is valid during its entire online session

prime reef
#

hanging onto a reference for later use

ivory sleet
#

that is login all the way to disconnect

lapis veldt
#

What's a good auction plugin?

prime reef
#

it'll more or less work, but there's pretty much no need for it

ivory sleet
prime reef
#

and again depending on threading/etc. there can be issues

ivory sleet
#

yeah

prime reef
#

because if your object changes in the course of command processing, it will produce undesired results

#

also a reason to never use mutable keys in a map

tardy delta
#

ah yea but i'm storing the player no?

ivory sleet
#

well the majority of bukkit api isnt thread safe and is made for the server thread merely

tardy delta
#

yea maybe changing the value on every command but yea

ivory sleet
#

ye

prime reef
#

basically, code with the assumption that everything can and will break

#

murphy's law lmao

tardy delta
#

nothing will break here :/

prime reef
#

also good practice to follow best practices just to keep yourself sharp (^:

ivory sleet
#

myes java

#

List::of

prime reef
#

i hate java

tardy delta
#

LMAO

prime reef
#

it was my first language but C# is just so much better

ivory sleet
#

yeah its great except its unorthodox choices of cases

prime reef
#

Java's main thing is being cross platform

opal juniper
#

At what point can plugins no longer be added to the plugins folder to be detected for that session? If a plugin that loads on STARTUP adds a plugin will it be detected that session?

tardy delta
#

i only use C# for visual parts

prime reef
#

i mostly use C# for game dev, since Unity/MonoGame (or XNA depending on your age), but writing desktop applications for Windows with it is piss easy

ivory sleet
#

isnt startup like ultra early

prime reef
#

I deliberately chose it for some accessibility software I wrote because I knew the friends I originally wrote it for would be happy to just have an .exe that runs out of the gate

opal juniper
#

It is but the fact that It is loading plugins indicates that it may have already "locked in" teh plugin list

#

ie ->

Gets all plugins
loads the ones @ STARTUP
does the other shit
loads the ones @ POSTWORLD
final stuff

prime reef
#

okay before I go, I'll drop my original question here again:

how inefficient would it be to forgo using NMS pathfinding in favor of writing my own (version-independent) code? the implementation isn't the issue, I'm just wondering if having a thread running to manage entity AI and pathfinding would cause any sort of massive overhead compared to the development overhead + pain in the ass factor of using NMS.

opal juniper
#

and a plugin added at Startup may not be detected

#

hmm - this may be a question for the paper folk

prime reef
#

tl;dr I'm writing an AI system that people can extend with their own custom coded modules and script onto entities mythicmobs-style and NMS is just cursed

crude sleet
#
    public static void updateLevel(Player p) {
        Bukkit.getOnlinePlayers().forEach(all -> {
            Scoreboard scoreboard = all.getScoreboard();
            Objective obj;

            if(scoreboard.getObjective(p.getName()) == null) {
                obj = scoreboard.registerNewObjective(p.getName(), "dummy");
            } else {
                obj = scoreboard.getObjective(p.getName());
            }

            obj.setDisplaySlot(DisplaySlot.BELOW_NAME);

            Score score = obj.getScore(p.getName());
            NitUser user = new NitUser(p.getUniqueId().toString());
             XYSection section = (XYSection) user.getSection(new XYSection(p));
            obj.setDisplayName("§7→ §bLevel §7| §f" + section.getMana() + "§7 → §bMana");
            score.setScore(section.getLevel());

            all.setScoreboard(scoreboard);
        });
    }

Hello, I would like to set the mana and level as the BELOW_NAME of each player. Unfortunately i have the problem that it is set correctly for one player, but the same mana number is set for the next two as for the 1st set and the levels are then 0

floral pewter
#

Hey, is there any documentation for how one should implement SpecialSource in their build process?

#

I'm looking at specialsource-maven-plugin, and the only example of its usage is this forum post

#

Nevermind! I scrolled up and found out that the 1.17 release thread had info

#

^v^

mellow edge
#

will that code shoot fireball in the direction player is facing when he will press on mousebutton or did I something wrong?

#
    Action ac = click.getAction();
    if(ac == Action.RIGHT_CLICK_AIR) {
    if(player.getItemInHand().getType() == Material.FIRE_CHARGE) {
            player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.FIREBALL);
            Fireball ball = player.launchProjectile(Fireball.class);
            ball.setVelocity(player.getLocation().getDirection().multiply(2));
            player.sendMessage("fireball was launched");
            
        }
    }
}```
ivory sleet
#

have you tried?

mellow edge
#

no, I'm just asking if code is written good before I export anything

waxen plinth
#

That will spawn 2 fireballs

mellow edge
#

yeah but is that code written well if u ignore player.getItemInHand because it is deprecated

eternal oxide
#

you only use ac once so don;t make a variable for it

grim ice
#

don't make throwaway variables if they're not for readability sake

#

that's what I follow, Idk if it's good practice though

wary harness
#

so question if u use cos for x , sin for y what do u use with z ?

eternal oxide
#

if (click.getAction() != Action.RIGHT_CLICK_AIR) return;

wary harness
#

cos to ?

mellow edge
#

o

mellow edge
eternal oxide
mellow edge
#

lol forgot to delete it thanks

grim ice
#

looping through the inventory slots is the only way iirc

#

wait

#

this is hwo to check i guess

#

o

#

getContents()

#

check for the values of getContents()

#

or u know

#

just go with the usual way, checkign for slots

#

do some logic with this

kindred valley
#

hey i have ```if (clickedEntity instanceof Player) {
if(player.hasPermission("illegal")) {

            if (kelepce.isSimilar(player.getInventory().getItemInMainHand()));

            ((Player) clickedEntity).setWalkSpeed(0);

            player.openInventory(((Player) clickedEntity).getInventory());
            
            
        }``` this method i want to see someone others inventory by clicking them and the method setwalkspeed still working when im closing the inventory, how can i provide walk speed default after closing the inventory.
river dirge
# crude sleet Can anyone help?

Instead if passing the player as an argument just loop over all the players ans use the player object to get his mana and lvl instead of the player you passed as an argument.

If you really want to make an updatPlayerLvl then only update the scoreboard of that player 😉

severe marsh
#

Hey @ivory sleet I tried implementing webhook system and everything is working good so far but I got an issue where I cant include \n when setting description of an embed. Any ideas on how to fix it?

eternal oxide
#

what happens when you include \n?

iron condor
#

hey what to do If I made two plugins that depend on each other?

eternal oxide
#

design better

severe marsh
iron condor
#

expected that answe

eternal oxide
severe marsh
#

wdym?

eternal oxide
#

double \

severe marsh
#

lemme try

river dirge
severe marsh
#

It worked @eternal oxide, thanks

iron condor
eternal oxide
#

can either work without the other, or are they really a depend on both

waxen plinth
#

Put them both as depending on each other and make them not reference each other in onEnable and you should be good

river dirge
#

just tell your plugin its a dependency and say what plugin it should be. Then disable it when it cant detect the plugin. If you add it as a dependency it will load the plugin as one of the last ones. after that you can ask for a list of the plugin and print an error and unload the plugin

raven ore
#

Help, the event "AsyncChatEvent" isnt call, because i use bungeechat. Do you have any idea to fix that ?

iron condor
#
``` what does that mean?
austere cove
#

linking errors because you have two plugins providing the same class

austere cove
#

do chunk tickets prevent the world from unloading too?

#

it should right

lost matrix
lost matrix
iron condor
#

I have another plugin that uses the same plugin as an API

austere cove
#

I need to keep a chunk loaded for sth, but the chunk ofc wont stay loaded if the world itself gets unloaded

lost matrix
iron condor
#

so what do I do?

iron condor
#

can I shade without maven?

lost matrix
lost matrix
iron condor
#

can i do it in pom.xml?

pliant flame
#

2 questions. What's the best plugin for taking your custom models and import them in the game?
and if I were to make my own model maker from scratch, how would I do that/

austere cove
#

what did I do now

#

no error messages nothing

waxen plinth
#

Some plugin may have called Bukkit.shutdown() or something

#

Remove all plugins

austere cove
#

unlikely cos I have no weird plugins on my test server and no warning or whatever in the logs

lost matrix
austere cove
#

fam there was an exception thrown by my plugin in an event listener that caused the server to disable

#

but the weirdest thing is that it was only visible in logs once I disabled debug in spigot.yml

twilit rivet
#

any decent way to use the #applyBonemeal(blockface)? I've seen reflection;NMS stuff, but I don't know if there's other ways?

severe marsh
#

How do I access WebhookURL?

twilit rivet
#

get the webhooklink from your server

severe marsh
#

No I mean like how do I get its path?

#

Is it DiscordWebhook/WebhookURL or?

twilit rivet
#

path should be there

twilit rivet
#

wait no

#

https://discord.com/api/webhooks/

#

on your webhook that you set-up for your server, there should be Copy Link

lost matrix
severe marsh
#

Yes I wanted that, thanks!

bitter mural
#

is there a standard database that most developers use? For storing and retrieving large lists of blocks etc.

twilit rivet
#

ohh, my bad

bitter mural
#

I guess I meant is there a library that makes those easy to use with Spigot with limited lag

lost matrix
#

Then there is no possibility for lag

twilit rivet
bitter mural
#

do you guys have a favorite tutorial site or video for this specific task? I've never worked with a database, this is my first foray

mellow edge
#

hi how can I make that only ops can use a command

#

or just how to check if the player has op

vague oracle
#

player.isOp()

lost matrix
bitter mural
#

Thank you very much!

mellow edge
reef wind
#

why would you use op over permissions?

#

@mellow edge

mellow edge
#

idk

#

I want that only all op level 4 players can use a command

raven ore
#

How can i call asyncplayerchatevent with bungee chat

lost matrix
raven ore
#

Yes

lost matrix
#

Are you sure? Uninstall the plugin and see if the event is then fired.

raven ore
#

Yes i am sure because, i try on a spigot local server and it works

lost matrix
crude sleet
#
    public static void updatePlayer(Player p) {
            Scoreboard scoreboard = p.getScoreboard();
            Objective obj;

            if(scoreboard.getObjective(p.getName()) == null) {
                obj = scoreboard.registerNewObjective(p.getName(), "dummy");
            } else {
                obj = scoreboard.getObjective(p.getName());
            }

            obj.setDisplaySlot(DisplaySlot.BELOW_NAME);

            Score score = obj.getScore(p.getName());
            NitUser user = new NitUser(p.getUniqueId().toString());
            WizardBuildSection section = (WizardBuildSection) user.getSection(new WizardBuildSection(p));
            obj.setDisplayName("§7→ §bLevel §7| §f" + section.getMana() + "§7 → §bMana");
            Bukkit.broadcastMessage(p.getName());
            Bukkit.broadcastMessage(section.getMana() + "");

            score.setScore(section.getLevel());

            p.setScoreboard(scoreboard);
            

    }

Hey, at this Point if any players join my game, i only see my mana at the other player, but thats wrong. I like to see the mana of the other player, not my own. Can anyone help?

#

The output of my Broadcast with "section.getMana()" is correct but the Displayname is wrong

tall basin
#

Hey! I can not cast Dynmap plugin instance to DynmapAPI which it implements.

@Override
public void onEnable() {
    DynmapAPI api = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap");
}

It throws ClassCastException. Has anyone faced such a problem?

raven rampart
#

Are you including the API in your package?

tall basin
#

yes, of course

raven rampart
#

You shouldn't

#

Dynmap will include it and your dependency should have a scope of provided

vast sapphire
#
        if (e.getCurrentItem()==blue) {
            Inventory inv = Bukkit.createInventory(null, 27, format("&2" + p.getName().toUpperCase()));

            for (int i = 0; i < inv.getSize(); i++) {
                if (inv.getItem(i) == null) {
                    inv.setItem(i, pane);
                }
                inv.setItem(10, sharpness);
            }
            p.openInventory(inv);
        }
private final ItemStack blue = new ItemBuilder(Material.STAINED_GLASS_PANE).setDisplayName(format("&1Enchant")).setDyeColor(DyeColor.BLUE).toItemStack();

Why when I click on the blue glass it doesn't open the inventory? I tried it with regular stained glass material but it doesn't work for the custom itemstack?

lost matrix
#

e.getCurrentItem()==blue

#

This is almost never true

#

Dont check objects with == use .equals()

vast sapphire
#

ok

tall basin
lost matrix
vast sapphire
#

ah ok

#

it works with .equals but i'll change it

raven rampart
tall basin
raven rampart
#

In Maven, this is corrected by adding <scope>provided</scope> in the dependency definition of the POM

lost matrix
tall basin
tall basin
raven ore
#

@lost matrix so i uninstall bungeechat and it is the problem

lost matrix
# tall basin what it means?

It means that you need the scope provided on your dependency.
Look into your compiled jar and check if the dynmap src code is inside.

raven rampart
tall basin
#
repositories {
    mavenCentral()
    maven {
        name = 'spigotmc-repo'
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
    }
    maven {
        url = 'https://repo.mikeprimm.com/'
    }
}

dependencies {
    implementation 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
    implementation 'us.dynmap:dynmap-api:3.1'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
ivory sleet
#

No

#

compileOnly for the APIs

lost matrix
raven rampart
#

Should be provided, not implementation

tall basin
#

oh, sorry

#

i will try

ivory sleet
#

should be compileOnly not provided

#

provided is a maven thing

raven rampart
ivory sleet
#

Nope

#

Tho it has compile however it’s deprecated

raven rampart
#

Sorry @tall basin, like I said I'm not that familiar with Gradle

ivory sleet
#

You usually use compileOnly, implementation, api, compileOnlyApi or runtimeOnly

raven rampart
#

I think I was reading about a Gradle plugin that does that.

ivory sleet
#

Ye

dim bluff
#

hi, how can I put all of the message in a config string? I saw something talk about using % but I cant seem to find anything

#

like how would I add for example an int which changes

ivory sleet
#

I can literally not read that sorry

#

?paste

undone axleBOT
tall basin
#

@raven rampart, @ivory sleet, @lost matrix
yes it worked. i used compileOnly. thank you all

dim bluff
#

how would I add this + sec which is an int, to me "color_of_numbers" config String

lost matrix
dim bluff
#

oh yeah forgot. Will do!

#

ty

dim bluff
raven rampart
#

Okay, I am feeling like an idiot here trying to create a double chest.

location.getBlock().setType(Material.CHEST);
        location.getBlock().getRelative(BlockFace.WEST).setType(Material.CHEST);
        Chest chest1 = (Chest) location.getBlock().getState();
        Chest chest2 = (Chest) location.getBlock().getRelative(BlockFace.WEST).getState();
        ((org.bukkit.block.data.type.Chest) chest1.getBlockData()).setType(org.bukkit.block.data.type.Chest.Type.LEFT);
        ((org.bukkit.block.data.type.Chest) chest2.getBlockData()).setType(org.bukkit.block.data.type.Chest.Type.RIGHT);
lost matrix
raven rampart
# lost matrix You need to set the changed BlockData back on the Block

Like this?

location.getBlock().setType(Material.CHEST);
location.getBlock().getRelative(BlockFace.WEST).setType(Material.CHEST);
Chest chest1 = (Chest) location.getBlock().getState();
Chest chest2 = (Chest) location.getBlock().getRelative(BlockFace.WEST).getState();
org.bukkit.block.data.type.Chest chest1Data = (org.bukkit.block.data.type.Chest) chest1.getBlockData();
org.bukkit.block.data.type.Chest chest2Data = (org.bukkit.block.data.type.Chest) chest2.getBlockData();
chest1Data.setType(org.bukkit.block.data.type.Chest.Type.LEFT);
chest2Data.setType(org.bukkit.block.data.type.Chest.Type.RIGHT);
chest1.setBlockData(chest1Data);
chest2.setBlockData(chest2Data);
#

Crap. That is the state

lost matrix
raven rampart
#

I need the state for later, but I need to set the BlockData back on the block and not the state

#

right?

lost matrix
#

Yes

raven rampart
#

Well, aside from mixing up my LEFT/RIGHT EAST/WEST, it worked. Thank you @lost matrix

gaunt hatch
#

Did they change how the PlayerList.getStatisticManager worked?

Before i could have custom NPC with a spiecal uni character in the name, but now it can not and errors on the npc create when trying to create the npc

dim bluff
#

the thing is that I want to write the string in config. But then somehow when I call the config string, it takes the int value or something

#

I'm rly confused on how to do

#

literally put this in a single config thing

#

so a string + an int but somehow have it all stored in a config string

#

wanna do something like this in my config

#

apparently percentages are usable

#

but I cant find anything online

#

just a mention

#

I need all of it to be in the config file

#

this is what I put in config?

#

???

#

my sendmessage should just look like this at the end

#

oh kk I see

#

yeye I see gonna test

#

is there a way to not need to set and directly write it in the config?

#

well instead of doing a command to setString(....
directly manually in the config do it

#

well I just want to be able to completely change the layout of the sentence from config

#

like change the order of strings, rewrite some of the strings etc

#

Tyty ill test out some stuff

white obsidian
#

I have a bungeecord plugin that runs a SocketServer which spigot servers connect to. However, it’s causing a lot of CPU usage and crashes of my entire Linux server (admins thought I was mining Bitcoin with it lmao).

The way I’m doing it is just running a runnable asynchronously to accept sockets which starts a Client thread (this is where I get the huge CPU usage) which has a while loop to read from an input stream. I’m really confused why this takes so much processing, is my approach wrong? I can provide code if needed.

quaint mantle
#

definitely do not create a thread/user

quaint mantle
#

you can use 20 ticks, every tick loop through the users and see if they sent a packet

#

clients*

raven rampart
#

I am struggling to set the custom name of a chest. I don't understand why this isn't working:

((org.bukkit.block.Chest) location.getBlock().getState()).setCustomName("Whatever I want");
eternal oxide
#

Store the state, as after changing it you have to apply it

#

a BlockState is a snapshot of the Block at that point in time

open vapor
#

why does playerinteract event get called twice from a right click? google said it was because of the offhand but i implemented their fix and it didn't work

eternal oxide
#

Two hands. It triggers for each

open vapor
#

yes, how do i tell them apart

raven rampart
eternal oxide
open vapor
#

event.gethand doesnt work

open vapor
#

it always returns HAND

raven rampart
open vapor
#

both the LEFT_CLICK_AIR and RIGHT_CLICK_AIR are called when i right click

eternal oxide
eternal oxide
open vapor
#

ok, but how do i make sure that only 1 gets processed

eternal oxide
#

If you only want to run your code on right click air if (event.getAction() != Action.RIGHT_CLICK_AIR) return;

quaint mantle
gaunt hatch
eternal oxide
#

because thats how you wrote it

gaunt hatch
#

what?

eternal oxide
#

A stack trace only tells us there was an error

gaunt hatch
#

In PlayerList.class it should be trying to make the file using the UUID but doesnt then tried the name and fails.

#

I know that

#

I am asking why its not trying it with the UUID

eternal oxide
#

You've shown no code so its impossible to say

gaunt hatch
#

That is in spigot

#

it its that false if clause on file1.exists() but shouldnt cause the uuid is part of the gameprofile and the NPC

#

so it should create

raven rampart
#

Is there a way to create a beam, like a beacon or when and end gateway is created?

eternal oxide
#

I'd guess it would only create the file if the player was on the server, the name file is probably a legacy fallback.

gaunt hatch
#

...

eternal oxide
#

NPC, so not a real player?

gaunt hatch
#

so why did it work fine till a update for spigot went out?

#

Was working fine like 1 month ago

#

Code was not changed based on what i can see in the patch in git for spigot for that class

eternal oxide
#

No clue as I don;t deal with nms

fading lake
#

Mob Pathfindergoals Question

eternal oxide
#

Does your NPC exist in the PlayerList?

winged anvil
#

ok elgar

gaunt hatch
#

It happens on NPC create on the super

eternal oxide
#

It actually calls PlayerList.savePlayerFiles(EntityPlayer) ?

winged anvil
#

so how would I read the config file ive created, and store the list of that config into a HashSet<Location> ```private static final HashSet<Location> points = new HashSet<>();
private static final DataManager data = new DataManager();

public static void getPointsOnFile() {
    points.addAll((HashSet<Location>) data.getConfig().getList("Data.SpawnPoints"));
    System.out.println(points);
}

public static HashSet<Location> getPoints() {
    return points;
}```
#

im still on this

eternal oxide
#

You can;t cast List to Set, but you can Set<Location> points = new HashSet(config.getList...);

gaunt hatch
#

I sent a picture of the code above

#

it tried to create the file.

#

I might have found a way around it using a overlord of the nms method

winged anvil
#

whats the difference between Set<> and HashSet<>?

eternal oxide
#

Set is the Base class of HashSet

eternal oxide
gaunt hatch
#

1.17

#

wait java or spigot?

eternal oxide
#

spigot

gaunt hatch
#

yea 1.17.1

eternal oxide
#

k

gaunt hatch
#

HA

#

got it

eternal oxide
#

What was the cause?

#

No player data to generate teh file?

gaunt hatch
#

I overrided the getStatisticManager in the PlayerList.class in my HumanEntityNPC class and pass in a empty class set to force it to bypass and never create it

eternal oxide
#

ah

#

much better than polluting the Player dat files.

gaunt hatch
#

They get wiped anyway

#

Dont save anything on the player save file store all that data in a db

eternal oxide
#

Pretty sure they only get wiped if you do it

gaunt hatch
#

server gets destoryed on restart

eternal oxide
#

ah ok

gaunt hatch
#

the container is destory and re-loaded clean from a image

eternal oxide
#

yep, docker

winged anvil
#

ok im so fuckin lost

eternal oxide
#

Show what you have so far

winged anvil
#

on enable im trying to save the locations into a HashSet from the locations that are inside my file that way when I set the values in the config again I will keep the values that we're also previously in the file

eternal oxide
#

yes

winged anvil
#

yes

#
        Set<Location> points = new HashSet(data.getConfig().getList("Data.SpawnPoints"));
        System.out.println(points);
    }``` I tried this but I get NullPointer
eternal oxide
#

is the path correct?

winged anvil
#

yes

#

one sec imma test something

vast sapphire
#

how do I get past the 16 scoreboard char limit in 1.8.8?

eternal oxide
#

Scoreboards support up to around 64 characters but only 16 printable

vast sapphire
#

well I got this ```st
[00:34:23 ERROR]: Error occurred while enabling Zenon v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Team name 'score.criterion.1' is longer than the limit of 16 characters````

winged anvil
#

    private static HashSet<Location> points;
    private static final DataManager data = new DataManager();

    public static void getPointsOnFile() {
        if (data.getConfig().getList("Data.SpawnPoints") == null)
            points = new HashSet<>();
        
        points = (HashSet<Location>) data.getConfig().getList("Data.SpawnPoints");
        System.out.println(points);
    }``` this makes sense no?
#

if theres no locations saved it creates new set, if there are points then it creates a set with those points

vast sapphire
#

try it?

winged anvil
#

it doesnt work, it overrides the file with the new set even though there were locations saved

eternal oxide
#

As I said, you can;t cast a List of Locations to a set

gaunt hatch
#

^ you need to store the value of the loc and then load it back on server start from the config.

#

Also you want to be careful with loc. If you are using more then 1 world, make sure the world is loaded first or it throws a big fit

eternal oxide
#
    private static Set<Location> points = new HashSet<>();

    public static void getPointsOnFile() {
        
        @SuppressWarnings("unchecked")
        List<Location> temp = (List<Location>) data.getConfig().getList("Data.SpawnPoints");

        if (temp != null) points.addAll(temp);
    }```
winged anvil
#

Ok that makes sense

#

what im confused on that I need a bit of clarifying is how Set<> HashSet<> and List<> all work together here

#

so you take the points and cast them into a List<> then if that list isnt empty then you add the list into a Set<> or HashSet<>?

eternal oxide
#

Set and List are both Base classes that are extended with things like ArrayLIst, LinkedList, HashSet.

#

The extended types add functionality like HashSets order their contents based upon a Hash value of each object it contains

#

Lists can contain duplicates, Sets can not. Every entry must be unique

winged anvil
#

that makes sense

#

also

#

    private static Set<Location> points = new HashSet<>();
    private static final DataManager data = new DataManager();

    public static void getPointsOnFile() {

        @SuppressWarnings("unchecked")
        List<Location> temp = (List<Location>) data.getConfig().getList("Data.SpawnPoints");

        if (temp != null) points.addAll(temp);

        System.out.println(points);
    }``` ok to confirm this is correct?
#

but it did the same

eternal oxide
#

Yes, however you need to stop using everything static.

#

static has its uses but not here

winged anvil
#

i only did here cause i got lazy and this is a test before moving it to my main plugin

eternal oxide
#

ok

winged anvil
#

yes but this did not add to the file it over-rid the file

eternal oxide
#

then you are not loading the data before saving

open vapor
#

I want to make an item that has one function when you right click it, and one function when you left click it

I have it set up so when the interact event is called, it does one thing if it's a LEFT_CLICK_BLOCK or LEFT_CLICK_AIR, and one thing if it's a RIGHT_CLICK_BLOCK or RIGHT_CLICK_AIR

when i right click air with the item, the interact event is called twice, once calling LEFT_CLICK_AIR, and once calling RIGHT_CLICK_AIR

i am aware it's because it's being called once for each hand, but i do not know how to tell if its actually a left click, or if it's just a left and right click.
I tried using e.GetHand, and it always returned main hand. I also tried using e.getItem().equals(e.getPlayer().getInventory().getItemInMainHand()), but it didn't work.

what should i do to tell if it's just a normal left click, or a left click caused by the offhand thing

eternal oxide
#

getHand() should return an EquipmentSlot HAND or OFF_HAND

#

oh sorry

#

That wasn;t your isue

#

It should not fire a RIGHT_CLICK_ if you left clicked

open vapor
#

yes, but it does fire a left click if i right click

eternal oxide
#

it will fire twice RIGHT_CLICK_AIR passing two different EquipmentSlot in getHand

open vapor
#

getHand always returned HAND when i tried it. never OFFHAND

eternal oxide
#

one sec

#

teh event fires once for me

#

if you have nothing in your off hand it will not fire offhand

open vapor
#

there is nothing in my offhand?

eternal oxide
#
    @EventHandler
    public void onClick(PlayerInteractEvent event){

        System.out.println(event.getHand().name() + ":" + event.getAction().name());
}```
#
[03:28:28] [Server thread/INFO]: HAND:RIGHT_CLICK_AIR
[03:28:28] [Server thread/INFO]: OFF_HAND:RIGHT_CLICK_AIR```
#

that was clicking once left, then right, then right with a torch in my off hand

open vapor
#

if i left click once

#

right click once

eternal oxide
#

do you have an item in your off hand?

open vapor
#

no

#

do you want the code? maybe theres something screwing it up

eternal oxide
#

let me run a clean clas. I have other stuff in my test code that could interfere

open vapor
#

wait hang on

#

i think i messed something up

#

any other item will work fine

#

exept for the item i want to use

eternal oxide
#

What item?

open vapor
#

book and quill

#

hmm

#

yeah that seems to be the problem

#

any other item works fine

eternal oxide
#

yes, its trying to open the book so you can edit it

open vapor
#

ahh

#

i was using inventory.close to remove the book gui

eternal oxide
#

odd that it fires a left + right for a book though

open vapor
#

so naturally, i should replace the item with a different one implement a cooldown

eternal oxide
#

You could use a book as its only the right click that does both

#

left click only fires left

rare cave
#

Hi there can anyone help to validate a Minecraft username with regular expression

#

This didnt work

eternal oxide
#

Basically, if you receive a right click with the book and quill, set a boolean. If teh boolean is set and you see a left click with a book and quill ignore it, reset boolean.

gaunt hatch
#

why not just ignore the off hand?

eternal oxide
#

he wants a different action on left and right click

gaunt hatch
#

ahh

eternal oxide
#

he can ignore off_hand

#

but his HAND he has to know which click it is

quaint mantle
#

not .equals, == to avoid it being called twice

#

LEFT_CLICK_*, item == inMainHand

quaint mantle
neat trellis
#

I want to know the best way to approach/structure a function that takes a location and over the period of 5 seconds, any player that enters a certain range of it gets launched up.

worldly ingot
#

We'll start there ;p

raven rampart
neat trellis
neat trellis
worldly ingot
#

You're writing a plugin, right?

raven rampart
#

An armor stand?

neat trellis
#

yea... im not used to doing plugins, i have done a lot of datapacks. would a hashmap be better?

worldly ingot
#

Ah you're used to data packs. That explains a bit

#

So you're free from a lot of a data pack's restrictions. Namely being able to keep track of locations

#

You can do that without an entity. We're in the code world, we can hold reference to those just in memory with a Location instance

#

And you really only care about the locations not anything else, so an ArrayList would suffice

neat trellis
#

oh alright

worldly ingot
#

In short, whenever your command is run, you can add the location to that list. In your PlayerMoveEvent, if their current position is < x distance from that location, do whatever it is you need to do

#

Location has a nice distanceSquared() method for you

raven rampart
#

You could use World.getNearbyEntitiesByType to grab all players within a distance from a location.

worldly ingot
#

Another alternative, yeah

neat trellis
#

would getNearbyEntitiesByType be more optimized?

raven rampart
#

And to throw them upwards take their velocity vector an increase the y value.

worldly ingot
#

Well, getNearbyEntitiesByType() is cubic, so that's something to keep in mind

raven rampart
#

I am not exactly sure what the back end is doing with getNearbyEntitiesByType but it has been more efficient than anything similar i've tried to impelement.

worldly ingot
#

GNEBT creates a bounding box, selects all entities in the world and returns any >= and <= your bounds

#

Either way you're just doing some quick comparisons

neat trellis
#

So I understand how to use PlayerMoveEvent as it is per player, but how would I use getNearbyEntitiesByType as I assume it should only be used at that location instead of each player, for the 5 seconds

raven rampart
#

There are a few ways to skin this cat. My first thought is to use a task

worldly ingot
#

And mine would have been to use the move event 😅

#

Don't think either approach is inherently wrong

raven rampart
#

The move event with an external timer would work.

neat trellis
#

I guess ill try the player move event as I think I know how to do that

#

Thank you guys this was very helpful

eternal oxide
#

I'd run a timer myself and trigger it every 5 ticks. No need to run any faster.

worldly ingot
#

Just be sure to use Location#distanceSquared() instead of #distance() and check if <= 25. You really don't need that sqrt call

eternal oxide
#

test in PlayerMove shoudl be avoided if you can.

raven rampart
eternal oxide
#

yes

worldly ingot
#

I mean, it's not as though listening to it is going to cause issues. It's what you do in that listener that may cause issues

#

And numerical comparisons are what computers do best ;p

raven rampart
#

But we should still try to minimize them

eternal oxide
#

True, however he's only launching players who get close to a location so precision isn;t really needed

raven rampart
#

every method call adds some overhead

worldly ingot
#

Suppose you have the added benefit also of not listening while you have no active locations

raven rampart
#

Which you would only run the task for the 5 seconds locations were active, then you have none

eternal oxide
#

Yep, one check every 5 ticks, or 20 checks (possibly) per player per tick if in PlayerMove.

ivory sleet
#

And static methods are like sugar for instance

#

So it matters even less

raven rampart
#

But considering what ElgarL is outlining, 100 calls vs 1 should still be considered.

#

Even if it is ejected as quickly as possible.

#

You're still doing some comparison to eject.

ivory sleet
#

Idk I mean rarely the case where you have 100 calls vs 1 call

eternal oxide
#

Not often, but if everyone goes throwing code in PlayerMove, it quickly mounts up

ivory sleet
#

If you use paper, it auto gens an asm event executor which is quite fast also

#

PlayerMoveEvent is also limited to the ticking isn’t it.

eternal oxide
#

yes

neat trellis
#

Are threads considered bad for plugins? Im wondering how to remove the location after the 5 seconds

ivory sleet
#

Use the bukkit scheduler

#

But no threads alone aren’t, it’s really the intention of them that makes them good or bad

gleaming jasper
#

Hi everyone! I'm getting an error in console:
[11:30:58 ERROR]: [PlaceholderAPI] failed to load class files of expansions
This is my code here, I have no idea what's causing this error. https://pastebin.com/AF9fkK16 I'd appreciate any help on how to fix it tho! thanks!
(Please ping if you respond :))

ivory sleet
#

However I suggest using the BukkitScheduler to schedule a method that runs on the server thread so you don’t have to implement thread safety yourself, can be a lifesaver sometimes.

gleaming jasper
ivory sleet
#

The error trace after the error thing like
at blah.blah.blah[;]
caused by blah.blah

gleaming jasper
#

ahhh haha yes

#

i put it in the thread

eternal oxide
#

Blue needs someone to teach him how to build with InteliJ and not include all his dependencies.

#

His jar contains Spigot, PlaceholderAPI jars and all classes shaded too.

quaint mantle
#

Hey elgarl

#
a = 5
print(a / 2)

name = prompt("Name: ")
print("Hello, " + name)

Look at this

eternal oxide
#

when he's making a PlaceholderAPI expansion so it shoudl only have his com folder with his single class

eternal oxide
#

nice

quaint mantle
#

Thanks

eternal oxide
#

I did play with creating languages years ago, but that was in Delphi

quaint mantle
#

it compiles some things, but if theres a function call it isnt constant

eternal oxide
#

I'd not remember any of it today

quaint mantle
#

all i gotta do now is learn how to parse args

#

could do function_call(*value) but i have to account for lists

eternal oxide
#

So we'll be seeing Jimagine released soon? 🙂

quaint mantle
#

No idea

#

gotta convert the python to java

ivory sleet
#

Will functions be first class objects?

quaint mantle
#

this is the route im taking
math ✅ - variables ✅ - builtins, final fields ✅ - functions - classes

#

functions are easy

#

but, i have to sacrifice either open end of lines or require ';'

#
a = 5;
print(a / 2);

name = prompt("Name: ");
print("Hello, " + name);

doesnt feel right

waxen plinth
#

Because you're making python

#

And python doesn't have ;

quaint mantle
#

No!

#

it does

waxen plinth
#

It doesn't require it

quaint mantle
#

gonna use {}s anyways

waxen plinth
#

I'm personally fond of ;

#

Use namespaces

quaint mantle
#

but then ill need ;s

#

?

waxen plinth
#

std.print and std.prompt

quaint mantle
#

why

#

besides clogging namespaces

waxen plinth
#

One of python's biggest problems is pollution of the global namespace

#

Don't follow that route

quaint mantle
#

Ok

waxen plinth
#

Namespacing is very good

#

And make it strongly statically typed

#

Use some keyword for variable declaration so it's explicit

#

let or var or val or the type of the variable

quaint mantle
#

But why

waxen plinth
#

Because declaring a variable is different from assigning a value

#

And they should look different

quaint mantle
#

a = 5
a: final, const = 5

waxen plinth
#

Hmm

quaint mantle
#

U likey 😩

waxen plinth
#

Why would it be final + const

quaint mantle
#

bad example

waxen plinth
#

You could do the kotlin route of var for mutable and val for immutable

quaint mantle
#

a: final, protected = 5

quaint mantle
waxen plinth
#

Is it?

quaint mantle
#

yes

#

not the idea but debugging

#

I like final or a: final

waxen plinth
#

Okay well I don't think a: private would be very visually pleasing

quaint mantle
waxen plinth
#

I'd go with final var a or something

#

var doesn't require backtracking

quaint mantle
waxen plinth
#

And you won't need backtracking at all if you just use a lexer generator

quaint mantle
#

I have a lexer already 😩

waxen plinth
#

Hm

#

You should let users redeclare a variable in the same scope

#

But keep it statically typed

#

That's one of my favorite bits of rust

quaint mantle
#

oo

waxen plinth
#

You can declare a variable with the same name later in the same scope and it replaces it

#

But keeps static typing

#

chefs kiss

#

Perfection

quaint mantle
#
func add(int a, int b) {
    if a == b {
        protect c = a # optional '='
        loop (4) {
            c += bt.random(5)
        }
    } else {
        z = 10
    }
    z = 15 # error!
}

@waxen plinth ?

waxen plinth
#

Hmm

#

I like it

quaint mantle
#

Woo

waxen plinth
#

Why would a = 10 error though

quaint mantle
#

once the scope is left its final

waxen plinth
#

Wait what's protect

#

But it's in the scope of the function

quaint mantle
#

scope as in { }

waxen plinth
#

I know

#

It's declared as a function parameter

quaint mantle
#

wait

#

holdon

waxen plinth
#

Also what's bt

neat trellis
#

How do I stop a bukkit RepeatingTask, the problem is that it is in a function and multiple can be running

waxen plinth
#

You can keep the task ID when scheduling and cancel it later

#

With BukkitScheduler#cancelTask(int)

quaint mantle
#

I could just do finalize b @waxen plinth

waxen plinth
#

z shouldn't be visible

neat trellis
quaint mantle
#

its interpreted

waxen plinth
#

And I don't know why you would ever finalize a variable

quaint mantle
#

if its global

#

why is object.finalize a thing anyways

waxen plinth
#

Just declare it as final

waxen plinth
#

It used to get run when the object was garbage collected

quaint mantle
#

Ah

#

why is it not a thing anymore?

#

seems useful

waxen plinth
#

Bad design

#

Objects should not handle their own deletion

quaint mantle
#

anyways how do i make this namespaced feature

waxen plinth
#

Just have namespaces like packages or modules

#

Honestly I like having them with a separate naming convention

#

TitleCase for namespaces, camelCase for functions and variables

quaint mantle
#

normal is camelCase
builtins are snake_case

waxen plinth
#

Hmm

#

Why should they differ?

#

Java is self hosted, meaning most of java's standard library is written in java

#

Using normal java functions, and it all acts like regular functions

#

Even natives

quaint mantle
#

Ok

unkempt peak
#

how can i remove the senders username in a tab complete i have an argument that is a custom string so it doesn't have any tab completions but when i return null it shows the senders username as an option

Returning an empty list works

burnt current
#

Hey Quick question: I would like to connect my plugin to MySQL and have already done some research on JDBC. Among other things, I have read that the method of establishing the connection with the Drivermanager is not so good and that it is better to establish the connection with the DataSource. However, I haven't found anything that really explains in a comprehensible way (for me) what you need and what exactly you have to create and write. Can anyone help me there?

unkempt peak
#

@burnt current

quaint mantle
#

I have this plugin that sends data from a client I made to a database and then the server fetches the database every second. Do you think it would be better to switch to sockets?

waxen plinth
#

Probably best to stick to established software with rigorous security and support

quaint mantle
iron condor
#

to shade I have to add this <relocation> <pattern>com.elunar.plugin</pattern> <shadedPattern>com.shaded.elunar.plugin</shadedPattern> </relocation> </relocations>
to the shading plugin inside pom.xml?

summer scroll
#

What packet should I use to change player name above head?

quaint mantle
#

how do I send a message to the player with the number of coins?

double money = EconomyManager.e.getBalance(p);
p.sendMessage(money);

chrome beacon
#

Check wiki.vg and find every packet with name or uuid information and change that

#

No

#

It doesn't matter what you use

quaint mantle
#

@maiden briar, you are here?

chrome beacon
#

Simply add "" + or use String.valueOf

#

They do

#

Don't

#

Use the contents list

burnt current
# unkempt peak this is a great tutorial for it https://www.spigotmc.org/wiki/connecting-to-data...

so (just for me to understand again) first I create a new class into which I then write the following:

MysqlDataSource dataSource = new MysqlConnectionPoolDataSource();
    private File file = new File("myPath");
    private YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);

then I should read the data from my Config and then configure the DataSource. I'll do an extra method for that, won't I?

quaint mantle
#

@chrome beacon

#

I have 967,400 thousand on my balance. is it possible to somehow show this as well?

iron condor
#
java.lang.ClassCastException: class com.elunar.plugin.DeathGhost cannot be cast to class com.shaded.elunar.plugin.DeathGhost (com.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @5f6837f2; com.shaded.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @4eb3ed8a)```
#

what does that mean?

chrome beacon
#

._.

#

If you want

#

It doesn't matter

quaint mantle
#

if I write /money, it shows 967,400.
e if I send a message to players with the amount of money, it shows 967400.0

chrome beacon
iron condor
#

so how can I fix it?

quaint mantle
#

is it possible to do the same as with the /money command?

chrome beacon
quaint mantle
#

@chrome beacon

burnt current
iron condor
chrome beacon
#

... Wiki.vg contains what you need. Read it and have patience

chrome beacon
iron condor
quaint mantle
#

@chrome beacon,please tell me, is it possible to do this?

chrome beacon
chrome beacon
chrome beacon
#

And what is the /money command

#

There are a lot of them

iron condor
# chrome beacon Yeah now use the right DeathGhost as variable

java.lang.ClassCastException: class com.elunar.plugin.DeathGhost cannot be cast to class com.elunar.plugin.DeathGhost (com.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @78d4450a; com.elunar.plugin.DeathGhost is in unnamed module of loader 'CombatLog.jar' @9997912)

quaint mantle
chrome beacon
#

You should only have one

iron condor
#

I have 2 plugins that use the same API

chrome beacon
#

Yeah you need to relocate then

#

Don't have two of the same class in the same package

iron condor
#

wdym?

chrome beacon
#

You need to change the package name in one of the jars

#

So they both don't contain the api in the same path

reef wind
quaint mantle
#

?

reef wind
#

Verify so you can send ss

hybrid spoke
#

!verify

undone axleBOT
#

Usage: !verify <forums username>

iron condor
# chrome beacon So they both don't contain the api in the same path

but then I get this error java.lang.ClassCastException: class com.elunar.plugin.DeathGhost cannot be cast to class com.shaded.elunar.plugin.DeathGhost (com.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @5f6837f2; com.shaded.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @4eb3ed8a)

quaint mantle
#

!verify 4ebypel

undone axleBOT
quaint mantle
#

@chrome beacon, I want to add a comma, after a thousand.
for example, 1,000, 1,500

chrome beacon
#

I.e the non-shaded one

#

Because that one is running as a plugin

quaint mantle
#

how?

iron condor
#

what should run on the server, the shaded or the original ?

#

what do I use in other plugins, the shaded or the original?

chrome beacon
#

None preferably

unkempt peak
#

?paste

undone axleBOT
unkempt peak
iron condor
hybrid spoke
unkempt peak
#

??

#

It was just a class from a random plugin

hybrid spoke
#

doesnt change the fact that its package naming is crap

unkempt peak
#

Wdym?

#

I don't have a website

hybrid spoke
#

w-..

#

what

unkempt peak
#

???

#

Nani?

#

Do you think everyone has their own website?

#

Do you have one?

hybrid spoke
#

i do

#

but thats not the point

#

i am just saying

#

that your package-naming is crap and out of the convention

#

because your first letter is uppercase

unkempt peak
#

And?

maiden briar
#

@quaint mantle I just woke up

quaint mantle
#

double money = EconomyManager.e.getBalance(p);
p.sendMessage("" + String.valueOf(money));

#

shows 1000

#

how do I make it show 1.000?

maiden briar
#

Ok let me work ok it

#

You money value is an int right?

#

@quaint mantle

quaint mantle
maiden briar
#

Ok also good

ivory sleet
quaint mantle
#

double money = EconomyManager.e.getBalance(p);
p.sendMessage("" + String.valueOf(money));
shows 1000

#

how do I make it show 1,000?

ivory sleet
#

Oh you want to format it?

quaint mantle
#

yes

ivory sleet
#

NumberFormat.getInstance(Locale.ROOT)

maiden briar
#
double moneyDouble;
String money = String.valueOf(moneyDouble);
StringBuilder moneyBuilder = new StringBuilder();
for(int i = money.length(); i > 0; i = i - 3)
     moneyBuilder.append(money.substring(i, i + 3).append(".");
#

Written from my phone

ivory sleet
#

Or sendMessage(NumberFormat.getInstance(Locale.ROOT).format(money))

maiden briar
#

@quaint mantle

quaint mantle
#

a?

#

thank you very much

maiden briar
#

Even String.format() also works

prisma badge
#

Hi guys I am having trouble with my code

iron condor
#
``` trying to use my api in a plugin
#
        deathGhost = (DeathGhost) Bukkit.getPluginManager().getPlugin("DeathGhost");
hybrid spoke
#

seems like you have DeathGhost each per plugin

iron condor
#

I dont

maiden briar
prisma badge
#
Integer i = new Integer(251);
for (Player p : Bukkit.getOnlinePlayers()) {
  if (getId(p.equals(i))) {
    System.out.println("test")
  }
}

Why doesn't it print "test"?

lavish hemlock
prisma badge
maiden briar
#

Tell me what works the best for you

lavish hemlock
#

Well, for one Player could never equal an Integer (please use int instead)

hybrid spoke
iron condor
maiden briar
hybrid spoke
#

stop trolling sir

lavish hemlock
#

well, that is bound to fail on compile-time

#

you can't do if (int)

#

only if (boolean)

hybrid spoke
#

let this troll alone @lavish hemlock

prisma badge
#
public int getId(boolean bool) {
  if (bool != false) {
    return 3;
  } else {
    return 3;
  }
}```
#

thats getId

prisma badge
lavish hemlock
#

yep okay nope you were right that is definitely troll-quality

prisma badge
#

I just started Java yesterday

#

I'm trying to make a hello world plugin

hybrid spoke
#

a white name trolling. he is not even allowed to do that

maiden briar
#

Then you need to LEARN it first

lavish hemlock
#

If you just started learning Java, please do not try to write a Spigot plugin.

hybrid spoke
#

?learnjava

undone axleBOT
prisma badge
#

IM NOT TROLLING ):<

hybrid spoke
#

spigot is a great project to learn java with

#

but you should also do something else sometimes. otherwise you will get a false concept of programming (only serverside and with api)

quaint mantle
maiden briar
#

Ok then use that

prisma badge
#

please help me with my issue

maiden briar
#

What is the error? I need to know for my knowledge

lavish hemlock
# prisma badge please help me with my issue

Listen dude, we don't even know what you're trying to accomplish with your code, and it literally isn't even valid semantically so I dunno how you got it to compile.
Go and use one of the links above to learn more about Java.

quaint mantle
#

?paste

undone axleBOT
lavish hemlock
#

As it stands, the only way someone could help you would be to write your plugin for you :p And that's not very good for learning.

quaint mantle
maiden briar
#

Thx

lavish hemlock
burnt current
unkempt peak
opal juniper
#

lmaoo

hybrid spoke
#

he is trolling

maiden briar
#

@prisma badge I have dm u with a good course you can try

#

He just left

unkempt peak
burnt current
#

OK. Well, I don't know much about configs. But I have created a config file via the plugin. My question would be, how could I then pass the config correctly into the method?

unkempt peak
#

You just need to create a config with all the info and pass it into the datasource

unkempt peak
burnt current
unkempt peak
unkempt peak
burnt current
#

yes

grim ice
#

it is

#

for me at least

#

I learnt a lot from reading people code

lavish hemlock
#

I meant in a sense of copy-paste with no explanation.

unkempt peak
# burnt current yes

Why are you getting local host? Is that the key of the host value in you config?

lavish hemlock
#

I actually do also learn a lot from code examples.

#

It's easier for my brain to read code than a bunch of terminology.

grim ice
#

copy pasting won't get you any where because you won't know how to adapt it to your code

#

even if you know how, it will be confusing

#

that's why i never copy something i dont understand

burnt current
unkempt peak
lavish hemlock
#

I'll copy shit I don't understand but I'll figure out what it means via Google or docs.

unkempt peak
burnt current
#

I got it mixed up it is host

unkempt peak
grim ice
#

right now I need something to code so I can practice but there's nothing

burnt current
unkempt peak
burnt current
#

yes

unkempt peak
#

The whole point of the config is so it's not hardcoded

burnt current
#

oh ok so i shouldnt store the values in variables

unkempt peak
#

No just pass them into the datasource like my example

#

Once your datasource is configured just test the connection with the method in my example and return the datasource

burnt current
#

so I should just use

dataSource.setServerName(sqlconfig.getString("database.host"));
        dataSource.setPortNumber(sqlconfig.getInt("database.port"));
        dataSource.setDatabaseName(sqlconfig.getString("database.database"));
        dataSource.setUser(sqlconfig.getString("database.user"));
        dataSource.setPassword(sqlconfig.getString("database.password"));
grim ice
#

@unkempt peak I heard loading up stuff from config when a plugin loads then getting the value from a list / variable is better, is that true or am I misunderstanding

unkempt peak
opal juniper
grim ice
#

I see

opal juniper
#

de/serialise it onEnable/Disable

grim ice
#

o

unkempt peak
grim ice
#

may you show me an example so i get familar with it?

burnt current
unkempt peak
#

Yeah

#

Ok I gtg fr now bye

burnt current
#

Okay, I'll give it a try. Thanks first

unkempt peak
#

Dm me if you need anything else

burnt current
#

bb

burnt current
grim ice
#

Hey, I heard loading up stuff from config when a plugin loads then getting the value from a list / variable is better than getting the config values on runtime, may someone show me an example? It would be appreciated.

grim ice
#

o

hybrid spoke
#

loading and getting the data out of the config at runtime (everytime you need it) isnt actually that bad but a bad practice

#

i mean, loading it onEnable is also at runtime

grim ice
#

and then later you just do Variables.someVar?

hybrid spoke
#

yeah

grim ice
#

thx

white obsidian
chrome beacon
# iron condor so how can I use the api?

If API is shaded you don't run it add as a plugin. Instead just target the API classes directly. If your plugin wants to depend on the non-shaded plugin you simply get the plugin instance and use that

grim ice
#

why 1 letter variables

#

oh wait this is an old thing

lean gull
chrome beacon
#

Have you learned Java basics yet

lean gull
#

i know some

reef wind
#

You can't in 1 day lmao

#

You need a few months to learn java

hybrid spoke
#

didnt you just left the discord mr buenny?

lean gull
#

this is how i learn

hybrid spoke
#

because everyone told you to just learn java first

lean gull
#

godcipher i did but then i joined back

reef wind
lean gull
#

too bad i'm already learning

hybrid spoke
#

so i will welcome you back then

lean gull
#

:p

hybrid spoke
#

?learnjava welcome back

undone axleBOT
reef wind
#

You need to take a course or something for a few months

crystal pike
#

What would be the best way, to keep mobs respawning in a dedicated area?

Currently I set the boundingbox, and assigning the BukkitRunnable to a field inside each zone.
Then I call .runTaskTimer.

And then I check if an entity dies within the boundingbox zone, but how would I keep track of the respawn runnable, and make sure it's stopped before trying again, and making sure if 3 zombies were killed at the same time, it doesn't recall the runTaskTimer. Cause atm. I run into Task is already scheduled.

lean gull
#

i went through like a full hour course and i went through half the codeacademy java course

#

got bored so i stopped

reef wind
#

You can't learn in 1 day

#

You need a few months

lean gull
#

yes, you already said that :p

#

look if you're not gonna bother helping then just don't waste both of our time responding

reef wind
#

You went through 1 hour and half a course, that is not enough to know java. Which you can clearly see.

#

But it's your choice

lean gull
#

i do know that i do not know the basics, but i'm okay with that and i'm learning with this method

reef wind
#

your choice but I am warning you that you won't learn this way.

lean gull
crystal pike
hybrid spoke
maiden briar
#

Is there an event this if a wolf gets angry he gets a target?

#

I want to cancel that

hybrid spoke
#

a wrapper would make everything much easier since you can keep track of the entity, spawning location, region, etc.

hybrid spoke
maiden briar
#

Ok I will try thanks

crystal pike
#

So would that require NMS? To make a specific entity which just resmeblnces any vanilla mob, but just has my wrapper methods aswell

hybrid spoke
#

making a custom entity would require NMS

crystal pike
#

Is there a way to map nms?, cause I would be lost in all the a, b, c etc...

hybrid spoke
#

i am not sure. didnt used NMS that much. especially not in the newer versions. but since everyone is talking about mojang mappings you could look at that

eternal night
#

Ngl I feel like a custom entity in a case where you don't need custom pathfinder logic or other ai related changes might still be overkill

hybrid spoke
#

probably, but a solution.

mellow edge
#

can I make the event in main class and then register it like this:``` getServer().getPluginManager().registerEvents(this, this);

hybrid spoke
mellow edge
#

yes I have them

lean gull
#

i still need help btw

mellow edge
#

also how can I put event into event

#
public void onLounch(ProjectileLaunchEvent e) {```
#

and than another one

#

in it

radiant aspen
#

Anyone here good at nms? 👀 Im trying to get IBlockData from a spigot block

crystal pike
#

I'm trying to fetch nearbyEntities within nms, but it requires a entity as the first argument, so wouldn't that require me to keep one instance alive at all times?

radiant aspen
#

Nevermind, I figured it out

crystal pike
#

Check how many of my custom mobs is in a specific area.

radiant aspen
#

Try using BoundingBox's

crystal pike
#

Can bukkit/spigot methods interact with nms classes?

radiant aspen
#

not sure why you would want to use nms for this?

crystal pike
#

nvm

radiant aspen
#

just do

world.getNearbyEntities(BoundingBox.of(new Location(world, 0, 0, 0), new Location(world, 100, 100, 100)));
radiant aspen
#

probabbly not, older versions are lacking in the api

#

use 1.17

crystal pike
hybrid spoke
crystal pike
#

Trying to wrap any entity, so I can intercept the die call and other stuff.

radiant aspen
#

could just use events?

hybrid spoke
crystal pike
#

too messy, and I would need to use nms either way, to control their movement to be within a certain boundingbox

hybrid spoke
#

oh if you need to use NMS anyways just create custom entities

crystal pike
#

So one custom entity for each entity.

#

alrighty

tardy delta
#

what does ConsoleSender#getName() returns?

#

"console" ?

crystal pike
#

Alright, last questin for now I swear Why does my bukkitrunnable.runTaskLater after the delay, keep running? Shouldn't it only run once?

tardy delta
#

because its a runnable

#

idk

#

tbh

eternal oxide
#

runTaskLater runs once

crystal pike
#
new BukkitRunnable() {
            @Override
            public void run() {
                System.out.println("RESPAWNING ENTITY!");
                mobzone.respawnEntity();
                this.cancel();
            }
        }.runTaskLater(Bukkit.getPluginManager().getPlugin("questing"), mobzone.respawnTime * 20);

Also tried without this.cancel()

#

This is ran constant