#help-development

1 messages · Page 463 of 1

regal scaffold
#

Did you read the page?

#

I can tell not

#

There's a fat paragraph explaining exactly what you asked

vital sandal
#

just read it and still no idea why use injection :l

#

any example with the same case?

true perch
#

Is there a list of valid API-Versions? My server is running 1.19.4-R0.1-SNAPSHOT, unsure what the format looks like in the server.yml file.

chrome beacon
#

The API version would be 1.19

true perch
#

Thank you

regal scaffold
#

There's a max distance property

serene sigil
#

how do i set the durability of an item?

#

cuz u cannot with itemmeta

fluid river
#

setDamage()

#

ig

serene sigil
fluid river
#

version?

serene sigil
#

1.16

fluid river
chrome beacon
#

^^

serene sigil
#

tried that

chrome beacon
#

It does work

serene sigil
#

does nothing

chrome beacon
#

Make sure you have the right import

fluid river
#

isn't it calculated other way tho

chrome beacon
#

You shouldn't have to cast it back to item meta

fluid river
#

with +

fluid river
#

instead of -

serene sigil
chrome beacon
#

ah wait old version

#

Ignore me

#

Was looking at 1.19 Javadoc

regal scaffold
#

If I want to make a logger file for every chat message that is sent

#

Do I make my ChatListener write every single log into a LogManager which saves it into a file?

fluid river
#

file for every message?

#

oh

#

mb

regal scaffold
#

Like, how can I constantly append onto a file without removing current contents

fluid river
chrome beacon
regal scaffold
serene sigil
#

alr

#

ill try

fluid river
fluid river
#

why xor mojang

#

you can learn by coding with somebody who already has some knowledge

#

and by just asking questions too

#

JREE

#

java runtime enterprise environment/edition

regal scaffold
#

java.lang.IllegalStateException: PhoneMessageEvent may only be triggered synchronously.

#

How can I make my event trigger async from AsyncChatEvent?

rotund ravine
#

make it async

#

?jd-s

undone axleBOT
regal scaffold
#

Wut

rotund ravine
#

?stash

undone axleBOT
remote swallow
regal scaffold
#

That runs it sync

#

Do all events have to be called synced?

remote swallow
#

for async you need to add other stuff into the event

#

check staff for async chat event

misty current
#

how can I copy a module? when I do, intellij doesn't treat it as a module for some reason as you can see (the 1_19_R3 is the copied module and the 1_8_R3 is the original one)

regal scaffold
#

Yeah I'll go check asyncChatEvent

#

Thanks jan

remote swallow
#

did you add the module name to parent pom

misty current
#

lemme test rq

#

oh nevermind

#

thank you

tawny pine
#

Did you help that guy with a ray tracing bukkit thingy?

#

Did you do a ray tracing thingy?

#

No wait it was u

jovial shadow
#

How can i make a plugin that drops an item every time a certain amount of people join

rotund ravine
#

?learnjava!

undone axleBOT
lost matrix
jovial shadow
#

thanks

tardy delta
pseudo hazel
#

what potato wrote this?

tardy delta
#

oh man

pseudo hazel
#

what page are you reading

tall dragon
tardy delta
rough drift
tawny pine
#

sry for ping

#

:/

hazy parrot
tardy delta
#

click the link

tawny pine
#

guys this is a basic java question but how can i break from an if statement?

#

and continue to the rest of the code

#

:/

left depot
#

Put your new code on the same line as the if statement

eternal oxide
#

or move yrou code into a method so you can return when you are finished

left depot
#

Like


if {}
else {}

New Code

if i am ight

tardy delta
#

is that just an alias?

young knoll
#

Use a command framework that can register them at runtime

tardy delta
#

id just parse them myself and do some reflection with the commandmap

echo basalt
chrome beacon
#

;/

left depot
#

oops

echo basalt
#

get sniped

tardy delta
#

half hour now 💀

echo basalt
#

so

#

YML is organized in "sections" and all

tawny pine
#

Guys I'm using the code:
if (getNearestEntityInSight(p, 100).equals(null)) { Bukkit.broadcastMessage("null"); } else { org.bukkit.entity.Damageable Shot = (org.bukkit.entity.Damageable) getNearestEntityInSight(p, 100); Shot.damage(10, p);
If getNearestIntityInSight returns null it is meant to broadcast null to the server.
It still damages the entity if it is in sight and carries on with the code afterwards, but if the output is null, it doesn't carry on with the code, or output null to the server like is written.

echo basalt
#

And you can call getKeys for any given section

#

to get all the keys for that section

#

yes skull me

#

so if you call

config.getKeys(false) -> ["Menus"]

mighty pier
#

guys type +:skull:

echo basalt
#

but if you call

#

getConfigurationSection("Menus").getKeys(false) -> ["menu1", "menu2"]

#

So what if

#

You do something like

tawny pine
#

if i want to see if something returns null do i just do .equals(null) or what?

icy beacon
#

== null should be fine

echo basalt
#
ConfigurationSection menusSection = config.getConfigurationSection("Menus");

for(String key : menusSection.getKeys(false)) {
  if(!menusSection.isConfigurationSection(key)) {
    // incorrectly formatted config
    continue;
  }

  ConfigurationSection submenuSection = menusSection.getConfigurationSection(key);
  ...
}
icy beacon
#

to check for nullability

echo basalt
#

and it's an instance menu

#

so it'll throw a NPE

icy beacon
#

oh true

#

so == null it is all the way

echo basalt
#

use ==

#

yeah

tawny pine
#

ah ok ty 🙂

#

working now

#

ty guys

left depot
#

// You can open the inventory with this
    public void openInventory(final HumanEntity ent) {
        ent.openInventory(inv);
    }

Found this code on the internet just for looking, but the cmd is then ./inv?

echo basalt
#

registering commands dynamically is a whole other process

#

you can still make it

#

you're learning

left depot
#

Same, i started few days ago with Spigotdev

echo basalt
#

registering commands dynamically is a bit annoying

#

but it boils down to simple concepts

#
  • access the command manager
  • inject new commands into it
#

and maybe optionally refresh all the commands for all players

pseudo hazel
#

why do you need to register new commands dnamically?

left depot
#

atm i dont know how to link a cmd to a eventhandler

pseudo hazel
#

no , thats why i am asking

#

guessing is the root of all mistakes

vocal cloud
#

There should almost never be a reason to reg dynamic commands. At least the core /xyz. Sub commands are a lot easier to make dynamic

echo basalt
#

my command engine does shit dynamically

pseudo hazel
#

I see

echo basalt
#

the main thing is skipping the plugin.yml

vocal cloud
#

Dynamic as in when the server loads?

echo basalt
#

uhh

vocal cloud
#

I thought we were talking about on the fly

echo basalt
#

the server loads, I do some database stuff

#

and then it loads after the first tick

#

on the fly is a bit icky but I don't do it immediately on startup

left depot
#
package kloppie74.wildwestern.minerrobot;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.Arrays;

public class ExampleGui implements Listener {
    private final Inventory inv;

    public ExampleGui() {
        // Create a new inventory, with no owner (as this isn't a real inventory), a size of nine, called example
        inv = Bukkit.createInventory(null, 9, "Example");

        // Put the items into the inventory
        initializeItems();
    }

    // You can call this whenever you want to put the items in
    public void initializeItems() {
        inv.addItem(createGuiItem(Material.DIAMOND_SWORD, "Example Sword", "§aFirst line of the lore", "§bSecond line of the lore"));
        inv.addItem(createGuiItem(Material.IRON_HELMET, "§bExample Helmet", "§aFirst line of the lore", "§bSecond line of the lore"));
    }

    // Nice little method to create a gui item with a custom name, and description
    protected ItemStack createGuiItem(final Material material, final String name, final String... lore) {
        final ItemStack item = new ItemStack(material, 1);
        final ItemMeta meta = item.getItemMeta();

        // Set the name of the item
        meta.setDisplayName(name);

        // Set the lore of the item
        meta.setLore(Arrays.asList(lore));

        item.setItemMeta(meta);

        return item;
    }

    // You can open the inventory with this
    public void openInventory(final HumanEntity ent) {
        ent.openInventory(inv);
    }

    
}
pseudo hazel
#

any reason why you cannot use something like /open menu and /open help

left depot
#

How to link a ./command to this like ./inv?

pseudo hazel
#

then you can just get the argument from what's in the config

echo basalt
#

are you seriously implementing listener

young knoll
#

The frog has a gun!

novel oxide
#

So, I want to optimize a plugin I am making that will only apply to a specific location. I have thought of two ways but I am wondering if there are any other ways. 1st, doing a simple check if the world or location is within the sought area of effect. 2nd (which I don't know how to do but I am thinking it would be possible) activating the event checks and commands for whenever a specified command is run and stopped at another specified command. Any ideas?

echo basalt
#

micro optimization

novel oxide
#

I feel like after a certain amount of event checkers it'd start to build up. Plus the code itself in the checkers is not opimized whatsoever ¯_(ツ)_/¯

left depot
#

3sec

novel oxide
#

Besides, any small optimization is a good optimization

echo basalt
#

not really no

left depot
echo basalt
#

premature optimization is the root of all evil

novel oxide
#

It's already made

echo basalt
pseudo hazel
#

I would rather focus on actual optimizations rather than small baby things

left depot
novel oxide
#

As of right now, it is implementing the 1st type I mentioned

pseudo hazel
fluid river
#

sheeeit

left depot
#

atm their is no way to open the menu

pseudo hazel
#

oh

#

create a command executor and just create the menu in there

paper venture
#

What does entity target block mean? I want to get the first block on the player sight with 15 blocks limitation, I'm using player.getTargetBlockExact(15), is it fine?

novel oxide
#

Alright well thanks I guess for the... suggestion

echo basalt
#

yes

pseudo hazel
#

but honestly, option 2 sounds like it would be worse for performance

novel oxide
#

Really? I'd think the opposite. You'd use a plugin like world guard or something to run the initial command and only apply to that specific player initiator.

smoky adder
#

how do i execute a command when the player clicks on slot 0 position? I tried with event.getSlot() == 0 but it works only if I open the inventory and click with the mouse arrow..

novel oxide
#

Actually wait, can you attach event handlers to specific players outside of running them on every player and doing a check for UUID, username, or any check in general?

tall dragon
#

uhhh no

eternal oxide
#

bad idea

tall dragon
#

i mean u can. but u'd have to make ur own system and you would still just be filtering for which players to trigger an event

novel oxide
#

Damn, that'd suck. Guess I'll just stick with what I have now. I'm already doing short-circuit with the first if statement being the world check

pseudo hazel
tall dragon
#

but did u even do any benchmarks?, is ur code really performing that poorly?

novel oxide
#

It's not, but I have only tested it on my dev server and not the actual server yet

tall dragon
#

shoulnt you create some timings reports while using your plugin then?

tall dragon
#

or run some spark profilers

novel oxide
#

Oh my god, I never knew that was a thing

smoky adder
novel oxide
#

The more you know

tardy delta
pseudo hazel
smoky adder
#

like when you enter the hub and click on the compass in your inventory to open the menu

rotund lotus
#

Hey Guys. Looking for a bit of advice on the best way of going about developing a custom world generation system. I'm looking to emulate similiarly what origin realms do, where users can create a 'realm' and build in a 1000x1000 area that is generated. I'm fine with that, however what would be the best way of doing this? I see on origin realms, they have created a world with a UUID for each realm, I would have thought it made more sense to have a world with multiple 'realms' on it. Is this efficient? loading, unloading worlds as players teleport to their own.

true perch
#

What's a quick way to add color to text?

pseudo hazel
#

ChatColor.GREEN + "text"

jagged bobcat
#

I'm getting error java.lang.IllegalArgumentException: Unsupported class file major version 63 when trying to shade my plugin. Is there a reason why I am getting it?

smoky adder
tall dragon
pseudo hazel
quiet ice
kind hatch
rotund lotus
tall dragon
#

if its pretty big best course of action would probably be to have an automatically scaling networks that starts up mini servers as they are needed acting as the players realm

#

similar to hypixel handles their islands

true perch
#

How do you give text a color based on a hex value?

kind hatch
#

ChatColor#of()

true perch
#

Thank you

rotund lotus
#

or maybe I'm wrong

tall dragon
#

they probably have some very impressive hardware then. but i dont have any knowledge of their actual hardware

kind hatch
#

Their islands are probably on a separate network with some scaling infrastructure.

tall dragon
#

probably yea

#

using slimeworlds might not be viable

#

if 400 worlds are to be loaded into memory

#

even if they are only 1k by 1k

echo basalt
#

hypixel has a proprietary very shitty scaling system

kind hatch
#

It's better than 400 normal worlds though

tall dragon
#

thats alot of data

#

yea, very true

echo basalt
#

from what I've understood from my interviews

#

they run a mini server with all the plugins and just toggle them off depending on what's being played

kind hatch
#

Their slime world tech is pretty cool though.

echo basalt
#

slime worlds are cool but it's more of a fancy proprietary system to save a lot of disk space

smoky adder
echo basalt
#

they also have this thing where you can paste a structure anywhere n shit

#

and spin up tons of new worlds

kind hatch
tall dragon
#

very interesting read

young knoll
#

Why don't they just deploy the plugins they need when the spin up a server

echo basalt
#

because it's legacy code

#

that they can't bother maintaining

kind hatch
young knoll
#

My favorite

echo basalt
#

it's a very old legacy system

pseudo hazel
#

cannot execute command when player clicks on item

echo basalt
#

made back in like 2014 iirc

young knoll
#

I'm willing to bet hypixel has a large amount of jank going on behind the scenes

true perch
echo basalt
#

there is some jank

kind hatch
tall dragon
#

i mean to be honest, what big network doesnt

echo basalt
#

there is also a bunch of cool shit

kind hatch
young knoll
#

Something can be both cool and jank

true perch
kind hatch
#

That would be why

true perch
#

I plan to implement bungeecord though

#

Same thing?

young knoll
#

You pretty much always want the bungee ChatColor now

kind hatch
#

Sort of. The ChatColor api is just available in the spigot api.

rotund lotus
kind hatch
#

So there's no downside to using it.

young knoll
#

I'm surprised the bukkit one isn't deprecated

kind hatch
young knoll
kind hatch
true perch
#

import net.md_5.bungee.api.ChatColor; fixed the import

rotund lotus
kind hatch
#

Yea, but why does all the new stuff get added to the bungee import instead of the bukkit one?

young knoll
#

Yeah hex isn't in the bukkit one

kind hatch
#

I just don't fully understand the rationale behind it.

young knoll
#

Idk

#

Spigot also still maintains separate patches

#

¯_(ツ)_/¯

pseudo hazel
#

because the bungee one is just more up to date

kind hatch
pseudo hazel
#

thats true

#

idk either

#

?pdc

smoky adder
#

I have a configuration for each slot in the config file: slot1: name, material,lore slot2: ... How do I add a command: example command to execute a command when I right click on a certain slot?..

kind hatch
#

Add a section for commands?

smoky adder
#

yes, but how do I understand the item I'm holding? this can change according to the configuration as i assign the command ??

kind hatch
#

Configurations are held in memory so once it's set, you'd have to either restart or reload the configuration for anything to be changed.
Secondly, clarify something. Are you talking about an item in a GUI or an item the player is holding in their hand?

smoky adder
#

an item the player is holding, such as itemjoin

kind hatch
#

I'm assuming that you already have item checks in place to determine that the item the player is holding is the one that matches in the config,
You'd only have to add some code to execute the commands if the item matches.

smoky adder
#

and just what you said i can't do...

kind hatch
#

So you want to know how to do the item checks?

#

That message is in the spigot.yml

smoky adder
#

would you know how to do it?

kind hatch
#

Manual file read? I don't think there is an api method available to change it. So you're left with the yaml file import.

File spigotYML = new File(<Server Directory>, "spigot.yml");
FileConfiguration spigotYMLConfig = YamlConfiguration.loadConfiguration(spigotYML);

spigotYMLConfig.getString("messages.unknown-command");
weak meteor
#

i think this is good

#

for me, at least 🙂

kind hatch
haughty storm
smoky adder
kind hatch
smoky adder
kind hatch
#

?paste your code

undone axleBOT
eternal oxide
smoky adder
#

Yes wait 10 minutes pla

haughty storm
kind hatch
#

You don't cast to a block though. You cast to the state. So just Chest chest = (Chest) state;

haughty storm
#

ah ok, I'll try that Thank you

serene sigil
#

how to manually make an item break?

paper venture
#

The question is not about minecraft but about the java. Today I learned about Function Consumer and Supplier, so is there any need in custom functional interfaces when you can always use existing ones?

haughty storm
obsidian plinth
#

i need to detect what painting a played based is that a thing

paper venture
kind hatch
haughty storm
true perch
#

How do I pass in the main class to an enum class without storing the main class as a static instance?

kind hatch
haughty storm
#

ah, thank you

twin crater
smoky adder
true perch
#

which requires a reference to the main class

sterile token
true perch
#

Yeah basically the same

kind hatch
eternal oxide
#

utilities should not be an intialized class

sterile token
kind hatch
eternal oxide
#

not unless it's a static singleton

true perch
#

I like that

sterile token
obsidian plinth
#

i need to detect what painting a played based is that a thing

sterile token
#

How would you get the config instance from main class ? without doing a shity static getter for the instance

public enum Messages {
  
  private Config config; 

  PREFIX(config.getString("General.Prefix")),
  INVALID_USER(config.getString("Messages.Invalid.Sender"));

  @Getter private final String text;
  
  Messages(String text) {
    this.text = text;
  }
}
kind hatch
serene sigil
tender shard
#

Paintings are entities, not blocks

sterile token
true perch
tender shard
#

Blocks are not

#

Neither are chunks nor worlds or particles

eternal oxide
sterile token
#

Entity is every object which represents a model?

kind hatch
tender shard
sterile token
sterile token
tender shard
#

Yeah i just wanted to say that BlockPlaceEvent won‘t work for paintings lol

true perch
sterile token
#

I always have that confuse tho my bad alex

kind hatch
twin crater
tender shard
sterile token
#

See my example for asking

tender shard
#

A utils class shouldnt need an instance. Just store the keys in the main class

kind hatch
serene sigil
young knoll
#

Set it to null and play the break effect

sterile token
serene sigil
kind hatch
sterile token
#

When ever i need to code over a code they provide and it contain a static getter for instance i prefer to reject it

weak meteor
#

I have this abstract class and i wanna call it in another class, the purpose of this is: if i extend this class just make the getFileName method and bc it is extended i dont need to make more methods, right?

#

the other class:

tender shard
#

Correct

kind hatch
#

yes

weak meteor
#

so

#

i wanna call it in main

#

error

sterile token
# weak meteor

UsersConfig should be better naming and also following the naming convention

twin crater
weak meteor
#

srry

tender shard
kind hatch
# weak meteor

Either you think it's static, (which it's not) or that method isn't public.

weak meteor
terse ore
tender shard
#

Also why is that class name in lower case

weak meteor
sterile token
weak meteor
#

error

tawny pine
#

guys im using this code:
}.runTaskTimer(MinecraftPluginJava, 5, 1);
it says to reference your plugin as the first parameter, should i just put my plugin name? for some reason it doesnt accept this

kind hatch
weak meteor
weak meteor
#

class

#

extending YamlConfig

tender shard
tawny pine
tawny pine
terse ore
tawny pine
#

ty 🙂

tawny pine
#

:/

#

🙂

terse ore
#

you can make a getInstance() method in your main plugin class

#

that returns the plugin instance

terse ore
#

and then do YourMainPlugin.getInstance() to access the instnace

twin crater
tawny pine
terse ore
kind hatch
tawny pine
weak meteor
#

what to do

terse ore
#
public class Main extends Java {
private static Main instance;

public void onEnable() {
isntance = this;
}
public static Main getInstance() {
return instance;
}```
smoky adder
#

@kind hatch do you remember the speech from before??

kind hatch
# weak meteor So?

You should be able to access that method so long as you are extending it in another class. How are you creating the users class? (Which should be uppercase btw)

weak meteor
#

like New Java Class

#

Class

kind hatch
# smoky adder .

I don't fully understand then. If someone changes the name, then that's the user's fault. If you want to make it so that the item works regardless of name changes, then you need to put special data in the PDC of the item and compare against that.

eternal oxide
#

?paste

undone axleBOT
eternal oxide
tall dragon
#

any1 know what this is?

#

"new fast maven import"

eternal oxide
#

that allows you to initialize your class while keeping the enum

kind hatch
#

You can also use the JavaPlugin#getPlugin in an enum if you really needed to.

eternal oxide
#

yep.

kind hatch
smoky adder
#

when i in slot1 configuration then slot1: name:"test" material:"test" i also want to add command: "kill test" for example. So I want to connect the content of the command string with the object which is in slot 1 so that when the player clicks the object which is defined in slot one he executes the command which is assigned in the slot. at least i can't find a way to merge these yml files and code

eternal oxide
#

The above evample you can fetch keys with RecipeManager.RECIPIES.ZOMBIE.getKey();

kind hatch
# smoky adder yes

Ok, then forego the item name and lore checks and instead use the PDC to assign custom data. That way, you won't have to worry about players changing the item name.

smoky adder
#

can you give me an example of how to do it?

kind hatch
#

@tender shard I forget, do you have a PDC tutorial on your blog?

kind hatch
#

@smoky adder Use that link ^

smoky adder
#

ok thanks

#

im in 1.12.2

#

and the server is in 1.8.9 it works

kind hatch
#

Then you'll have to use NBT instead.

tall dragon
#

why would u program on 1.12.2 if the server runs on 1.8.9 tho

kind hatch
#

Otherwise, tell your players not to rename those items.

tall dragon
#

u only risk shit not working for no reason

rough ibex
#

moreover why are you on 1.8 at all

smoky adder
#

I don't know since the plugin works in server 1.8.9 even if and 1.12.2 I think up to that version it is compatible

obsidian plinth
#

idk why

twin crater
sterile token
#

Dont critize people using legacy versions we are all free to use the versions we want. But then we cant complain about issues or bugs that must be solved on own

cunning pendant
#

word.

sterile token
sterile token
#

I have the perfect answer and well explained, let me translate it

#

Sorry if i sound rude on the text but is the truth

kindred valley
#

You needda calm down

sterile token
#

I mean i have seen this situation related to legacy since i join this community

#

Its really bad that people oblise you to use ewer versions

cunning pendant
tall dragon
round finch
#

salty?

twin crater
#

wrong chat guys ❤️

round finch
#

yes #general

kindred valley
#

Extraordinary stuff going on.

sterile token
#

It is really annoying this situation of the versioning issue, since they are there to use them and everyone is free to choose the one they want. But then I would not have the right to come to complain because certain things do not work or ask for support itself. Maybe someone will help you, that's the good thing. Basically it is supply and demand, if there were still no people requiring legacy plugins there would be no developers programming them.

Translated with www.DeepL.com/Translator (free version)

kindred valley
#

What if i come this server for help regarding minecraft version 1.5.2. Is it usual?

granite owl
#

why would ppl fight over using different versions of an api exactly?

#

xD

tall dragon
#

probably wont get much response

#

but i woulnt be angry at you for trying.

sterile token
#

For me it is something related to consumerism. Because I have seen 1.8 programmers making over $100 (usd) in really simple commissions. But in 1.19 on the contrary they pay you less, because supposedly the api is better

kind hatch
eternal oxide
#

They are paying 1.8 devs more because it's harder to find a 1.8 dev. You can demand more money.

granite owl
#

id just ignore hate tbh xD

sterile token
granite owl
#

just my suggestion i learned to absorb criticism and filter/+ ignore toxcicity

#

unless its towards beginners xD

#

then i dont ignore it

kindred valley
#

Hello elgar

sterile token
granite owl
sterile token
granite owl
#

im translating my native c++ library to work with different languages ```csharp
public string GetFileExtension()
{
if (IniParser.m_pIniParser_getFileExtension != nullptr)
{
unsafe
{
string? str = Marshal.PtrToStringAnsi(((delegate* unmanaged[Stdcall]<IntPtr, IntPtr>)IniParser.m_pIniParser_getFileExtension.ToPointer())(this.m_pIniParser));

            if (str != null)
            {
                return str;
            }
        }
    }
    
    return "";
}
#

why are you using unsafe contexts, why are you using pointers, this is c#, why are you using delegates, just scrap your project its useless blablabla

#

when i literally explained this before ```txt
im translating my native c++ library to work with different languages

#

once i finished this, ill make my lib work for java and to that extend spigot

sterile token
#

For me is still being consumism

kind hatch
#

You mean consumerism?

regal scaffold
#

Hey, I was directed to AsyncPlayerChatEvent to see how a event could be called Async

sterile token
regal scaffold
#

But I can't seem to figure out how to mirror the implementation or what part allows it to be async

#

I want my custom event to be able to be called async

granite owl
#

isnt player chat running on a different thread altogether?

#

as such being async

#

or wdym

regal scaffold
#

Yes

twin crater
#

yea

regal scaffold
#

And calling a event that's sync from a async thread isn't possible

#

So I need to make my event support async

granite owl
#

write an interface

#

that is thread safe

#

let ur async event populate it

#

and let ur sync thread fetch it

#

basically uni or bidirectional populating with commands and fetching

rotund ravine
granite owl
#

but im still not entirely sure if i got ur question right

regal scaffold
#

Oh yeah lol I just looked at Event class

granite owl
#

kekw ```txt
(process 1776) exited with code -1

regal scaffold
#

I'm trying to use FileHandler to be able to write log-type messages to a file but getting some weird errors

granite owl
#

great now my minecraft launcher keeps crashing with the error msg failed to update launcher all of a sudden

regal scaffold
#

.txt.lck

        FileHandler fileHandler = new FileHandler(file.getPath());

This line says a file with whatever.txt.lck does not exist:

  1. The line above makes a new file called whatever.txt not whatever.txt.lck and I checked that the path wasn't wrong
  2. I think maybe using FileHandler is not the correct approach
kind hatch
#

Is that a lock file?

regal scaffold
#

Uhhh asuming I don't know what a lock file is I'm gonna say no

#
        file = new File(plugin.getDataFolder(), "logs/" + uuid + ".txt");
        FileHandler fileHandler = new FileHandler(file.getPath());
#

I think indeed FileHandler is not the right thing for this

#

Maybe BufferedWriter

rotund ravine
#

Why are you even using s filehandler

#

Why use .txt files too

regal scaffold
#

I looked online and said it was a decent option

ivory sleet
#

a file lock is a mechanic to ensure one process at a time can write/read to the file

regal scaffold
#

But they tend to use it with a logger

regal scaffold
#

Ok ok I'm gonna switch to bufferedWriter since it's a log-system it should constantly write

kind hatch
#

Isn't BufferedWriter the default recommendation for that?

rotund ravine
#

Prolly

regal scaffold
#

Wasn't when I searched but now I will use it

ivory sleet
#

buffered writer is buffed at writing ye

rotund ravine
ivory sleet
rotund ravine
ivory sleet
#

lmao

kind hatch
#

lmao

regal scaffold
#

I mean does the extension of the file really matter?

#

I could just call it .log

ivory sleet
#

well

granite owl
#

is anyone else having problems with their mc launcher rn?

regal scaffold
#

Doesn't make much of a different right? I could literally make it .thisisalogfile

kind hatch
#

It would be better if you had a standard extension though.

ivory sleet
#

.log is for informative purposes

rotund ravine
regal scaffold
#

Yes that is of course correct

#

Lets say I'm storing

#

Chat messages

#

Called by an event inside my plugin

#

So obviously I think .log is the right way

rotund ravine
#

Why not use a database or some cool format like json

regal scaffold
#

I could but

#

Logs are specific to a object

kind hatch
#

.log will work just fine.

regal scaffold
#

I feel like having 1 long log file is worse

#

Than being able to straight up separate it by objects

kind hatch
#

File extensions are mostly arbitrary. On UNIX systems, it doesn't matter what the file extension is. The file contents determines the type

regal scaffold
#

So you can straight up see the logs for a individual object

#

Thought so, thanks for the help guys

rotund ravine
regal scaffold
#

Why would I chose json over just... text tho

#

Is there a specific?

#

Besides maybe future readability

kind hatch
#

I guess parsing for statstics.

rotund ravine
#

Why not? Easy to decode and encode.

regal scaffold
#

It's an extra step tho for something that might be writing into the file 2-3 times per second

#

I guess making a cache is also smart

#

But yeah, i got the idea now

rotund ravine
#

JSON is a lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate. JSON is a text format that is completely language-independent but uses conventions that are familiar to programmers of the C family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. JSON is a better choice than plain text because it provides a standardized format for structuring data and almost every programming language can parse it

regal scaffold
#

Chatgpt but yes, I do agree with that

#

I will probably end up doing it with json

#

Now I have one last qustion

kind hatch
#

Unless you plan on doing anything with the logs, like statistics, then it doesn't matter how you store it.

regal scaffold
#

Using FileHandler like before, you could set a formatter

rotund ravine
#

Shush. Json superior

#

Formatter as in?

regal scaffold
#

Like for example

SimpleFormatter formatter = new SimpleFormatter(); 
#

Instead of that I assume I make my own format for the message before it's written

rotund ravine
#

Yah. Just setup your json encoder and decoder

#

You can tell it how to store as well as how to read.

regal scaffold
#

👍

#

Thanks

#

...

        file = new File(plugin.getDataFolder(), "logs/" + uuid + ".log");
#

Since when does this not create the file

#

If it isn't there

rotund ravine
#

Forever.

regal scaffold
#

tf

kind hatch
#

You have to call #createFile()

regal scaffold
#

What

#
        File phoneDataFile = new File(plugin.getDataFolder(), "phoneData/" + phone.getPhoneUUID() + ".yml");

I'm using this literally 1 class above and it creates the file if it isn't there

kind hatch
#

Could you imagine what would happen if it created a file every time you initialized the class?

regal scaffold
#

I could've swore it was

#

Load if exists, create if not

rotund ravine
kind hatch
regal scaffold
#
        File phoneDataFile = new File(plugin.getDataFolder(), "phoneData/" + phone.getPhoneUUID() + ".yml");
        phoneData = YamlConfiguration.loadConfiguration(phoneDataFile);
        phoneData.save(phoneDataFile);
#

Yes

#

Is that why?

#

Damn, interesting

rotund ravine
#

Yes

kind hatch
#

The Yaml implementation that spigot has is all loaded into memory. You have to write it if you want it to persist.

regal scaffold
#

Learn something new every hour, good philosophy

rotund ravine
#

A file is just a pointer

kind hatch
#

Is that why it's never null?

rotund ravine
#

What’s never null?

kind hatch
#

The File object

regal scaffold
#

It says it's nullable

#

When you read "Then the new file is created" instead of "then the new file instance is created"

#

Makes sense now

rotund ravine
#

Why would it be null

kind hatch
#

Because there's a difference between declaration and initialization.

regal scaffold
#

So wait let me understand something about File then

        file = new File(plugin.getDataFolder(), "logs/" + uuid + ".log"); <--- Path to the file, can exist or not
        if (!file.exists()) { <--- Check if there is a actual file here
            file.createNewFile(); <----- Create the file
                                  <----- I still need to load the file again  like the first line?
        }
rotund ravine
rotund ravine
#

Pointer

#

It doesn’t load shit

kind hatch
#

#createNewFile returns a boolean. It won't create anything if it already exists.

regal scaffold
#

Yeah but IJ said

#

Result of file.createNewFile() is ignored

kind hatch
#

That's because it returns a boolean.

#

It's not a void method.

regal scaffold
#

Oh... bruh

kind hatch
#

It returns whether or not it was actually able to create the file.

regal scaffold
#

Yes yes you're right, I just understood what it said

#

Jesus I had a brain fart

rotund ravine
quaint mantle
#

Why does argv++; break google java convection?

regal scaffold
#

[16:58:09 WARN]: java.io.IOException: The system cannot find the path specified

regal scaffold
#
        file = new File(plugin.getDataFolder(), "logs/" + uuid + ".log");
        if (!file.exists()) {
            file.createNewFile();
        }
```how
#

How does it not find the path if it just created it

fluid river
eternal oxide
#

is there a logs folder already?

regal scaffold
fluid river
#

np i just came back too

regal scaffold
# chrome beacon mkdirs

Another thing that I thought was done by File but instead is done internally by Spigot YamlConf

haughty storm
#

Is there a way to spawn a vanilla structure with a plugin

fluid river
#

you still have mkdir() on File

#

that's just an upgraded version for bukkit to utilize mkdir multiple times afair

chrome beacon
#

?jd-s

undone axleBOT
rotund ravine
# quaint mantle Why does argv++; break google java convection?

According to Google's Java Style Guide, you should use the prefix form of the increment operator (++i) in preference to the postfix form (i++)¹.

The reason for this is that the prefix version (++i) can be more efficient than the postfix version (i++) because it avoids the overhead of creating a temporary variable.

Source: Conversation with Bing, 11/04/2023(1) Google Java Style Guide - GitHub. https://google.github.io/styleguide/javaguide.html Accessed 11/04/2023.
(2) increment operator in java - Stack Overflow. https://stackoverflow.com/questions/27891504/increment-operator-in-java Accessed 11/04/2023.
(3) Google Style Guides | styleguide. https://google.github.io/styleguide/ Accessed 11/04/2023.
(4) Google Java Style Guide - GitHub. https://google.github.io/styleguide/javaguide.html Accessed 11/04/2023.
(5) increment operator in java - Stack Overflow. https://stackoverflow.com/questions/27891504/increment-operator-in-java Accessed 11/04/2023.
(6) Google Style Guides | styleguide. https://google.github.io/styleguide/ Accessed 11/04/2023.
(7) Google Java Style Guide - GitHub. https://google.github.io/styleguide/javaguide.html Accessed 11/04/2023.
(8) increment operator in java - Stack Overflow. https://stackoverflow.com/questions/27891504/increment-operator-in-java Accessed 11/04/2023.
(9) Google Style Guides | styleguide. https://google.github.io/styleguide/ Accessed 11/04/2023.

tardy delta
#

uh oh

kind hatch
quiet ice
rotund ravine
# kind hatch Wth, there's a difference in functionality. One adds before, one adds after. Wha...

You are correct that there is a difference in functionality between the prefix and postfix forms of the increment operator. However, according to Google's Java Style Guide, you should use the prefix form (++i) in preference to the postfix form (i++) because it can be more efficient than the postfix version as it avoids the overhead of creating a temporary variable¹.

Source: Conversation with Bing, 11/04/2023(1) Google Java Style Guide - GitHub. https://google.github.io/styleguide/javaguide.html Accessed 11/04/2023.
(2) Google Style Guides | styleguide. https://google.github.io/styleguide/ Accessed 11/04/2023.
(3) styleguide/eclipse-java-google-style.xml at gh-pages - Github. https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml Accessed 11/04/2023.
(4) Google Java Style Guide - GitHub. https://google.github.io/styleguide/javaguide.html Accessed 11/04/2023.
(5) Google Style Guides | styleguide. https://google.github.io/styleguide/ Accessed 11/04/2023.
(6) styleguide/eclipse-java-google-style.xml at gh-pages - Github. https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml Accessed 11/04/2023.

GitHub

Style guides for Google-originated open-source projects - styleguide/eclipse-java-google-style.xml at gh-pages · google/styleguide

#

Tihi

tardy delta
#

is that chatgpt?

#

jangpt

kind hatch
#

Yes it is @tardy delta

regal scaffold
#

New 4.5 is pretty crazxy

rotund ravine
quiet ice
#

If I had to guess it is more of an error-avoidance mechanism. A loop like

int x = 0;
while (x < 10) {
    x = x++;
}

will loop ad infinitum.
But

int x = 0;
while (x < 10) {
    x = ++x;
}

not.

fluid river
#

does i++ really create a temp variable?

tardy delta
#

bing gives weird answers

fluid river
#

i thought processor/ASM just uses some command for incrementation

quiet ice
quiet ice
#

And with temporary variable I mean like pushing an element to the operand stack

rotund ravine
quiet ice
#

Not a fully-fledged LVT var

rotund ravine
#

Go yell at google

fluid river
#

oh it might be
LOAD_FAST i
LOAD_FAST a
and
TRUE_ADD a

#

or smth similar

#

that's python dis, not real instruction

rotund ravine
# quiet ice On a bytecode level probably. On a JIT level? Unlikely.

Yes, it does matter if the JIT optimizes the bytecode. The JIT compiler can optimize code by removing unnecessary operations and simplifying expressions. In some cases, this can result in the postfix form of the increment operator being optimized to the prefix form². However, it is still generally recommended to use the prefix form of the increment operator (++i) instead of the postfix form (i++) because it can be more efficient than the postfix version as it avoids the overhead of creating a temporary variable².

Source: Conversation with Bing, 11/04/2023(1) How the JIT compiler optimizes code - IBM. https://www.ibm.com/docs/en/SSYKE2_8.0.0/com.ibm.java.vm.80.doc/docs/jit_optimize.html Accessed 11/04/2023.
(2) Increase performance in OpenJDK with JIT | Red Hat Developer. https://developers.redhat.com/articles/2021/06/23/how-jit-compiler-boosts-java-performance-openjdk Accessed 11/04/2023.
(3) Compiler optimization: Java bytecode - Stack Overflow. https://stackoverflow.com/questions/1680024/compiler-optimization-java-bytecode Accessed 11/04/2023.
(4) Increase performance in OpenJDK with JIT | Red Hat Developer. https://developers.redhat.com/articles/2021/06/23/how-jit-compiler-boosts-java-performance-openjdk Accessed 11/04/2023.
(5) Compiler optimization: Java bytecode - Stack Overflow. https://stackoverflow.com/questions/1680024/compiler-optimization-java-bytecode Accessed 11/04/2023.
(6) Understanding JIT Compilation and Optimizations - Oracle. https://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/underst_jit.html Accessed 11/04/2023.

Red Hat Developer

Learn how HotSpot's multi-tiered execution system uses the interpreter, quick compiler, and optimizing compiler to help enhance Java's performance in OpenJDK.

#

Biing

quiet ice
#

Chat GPT seems to have made that up

rotund ravine
#

It links to the ibm post

round finch
quiet ice
#

You know what? Let's test it for ourselves

regal scaffold
#

In python one can make a string using

 whatever_string = f'This string has {variable_number} numbers'
#

What's the alternative for something easy to build strings in java

#

String builder and just have 10 appends?

tardy delta
#

String.format or String#formatted

#

"this string has %s numbers".formatted(num) or whatever placeholder

regal scaffold
#

String format is annoying a bit

#

Yeah

tardy delta
#

we are getting string templates or smth (forgot what its called)

regal scaffold
#

?!/

#

Finally

rotund ravine
regal scaffold
#

String.format it is

#

cba

tardy delta
#

but the syntax is weird

rotund ravine
#

But well, it’s not the same at sll.

quiet ice
#

Prefix:

         0: iconst_0
         1: istore_1
         2: iload_1
         3: ldc           #7                  // int 1000000
         5: if_icmpge     26
         8: getstatic     #8                  // Field java/lang/System.out:Ljava/io/PrintStream;
        11: iload_1
        12: invokedynamic #14,  0             // InvokeDynamic #0:makeConcatWithConstants:(I)Ljava/lang/String;
        17: invokevirtual #18                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
        20: iinc          1, 1
        23: goto          2
        26: return

Postfix is exactly the same. For

class TestPostfix {
    public static void main(String[] args) {
        for (int postfix = 0; postfix < 1_000_000; postfix++) {
            System.out.println("postfix: " + postfix);
        }
     }
}
regal scaffold
#

Gonna be honest I don't like python

rotund ravine
#

Use kotlin 💪🏻

tardy delta
regal scaffold
#

But jesus the python one is clean

#

Being able to do functions/variables inside { }

#

Is so nice

quiet ice
#

If I had to guess javac will optimize any postfix operation that can be compiled down to iinc to use iinc (which basically is the prefix variant)

hard socket
#

how do I make this file be in plugins folder when plugin starts

scarlet kelp
#

Hi guys, Im trying to make server like bhop or surf servers in cs, I mean passing maps and be able to vote for the next one. So the problem is that one map using command blocks can affect another map. So I think it's a good idea to just unload rest of maps (Server.unloadWorld) when map changing, but the problem is that for some reason bukkit won't allow to unload maps which have dimension = 0 (Overworld), I found out it from source code. Have you any ideas how to solve that?

tardy delta
rotund ravine
quiet ice
rotund ravine
#

Then just do saveResource(whatever, false)

hard socket
tardy delta
#

chatgpt didnt know what it was saying when i let it wrote assembly either

rotund ravine
quiet ice
#

No - it made up it's own sources

misty current
#

i'm making a multi module project to make a plugin compatible with different nms versions and i'm getting some compilation errors because of different java versions of the spigot dependency when compiling. Can anyone help me?

#
  bad class file: C:\Users\kill05\.m2\repository\org\spigotmc\spigot\1.19.4-R0.1-SNAPSHOT\spigot-1.19.4-R0.1-SNAPSHOT.jar(net/minecraft/network/NetworkManager.class)
    class file has wrong version 61.0, should be 52.0
quiet ice
#

I grepped it's referenced sources and it does not mention it

rotund ravine
#

Oh well tiip

quiet ice
#

The issue with ChatGPT is that it will make up it's own sources once you ask for verification.

rotund ravine
#

Riip

quiet ice
#

Or rather said it will use unrelated sources

hard socket
#

its not loading

rotund ravine
#

Bing was supposed to be better 🥲 Well it’s good for some things.

hard socket
rotund ravine
quiet ice
#

That IBM document has nothing to do with prefix/postfix incrememnt but rather JIT optimisation (and deoptimisation) in general

tardy delta
#

bing is just, here you have some small info and here are the sources, go figure it out yourself

#

it doesnt really get deep

hard socket
rotund ravine
#

🥲 I am going to bed

#

Someone else will explain it to you

tardy delta
#

gn

tardy delta
quiet ice
#

(or this instead of plugin if you are within your JavaPlugin class)

tardy delta
#

or no this :)

quiet ice
#

(and not using static methods)

young knoll
#

this.getPlugin(MainClass.class).saveResource
:D

tardy delta
#

we arent the first of april anymore

regal scaffold
#

Uhhh

#
        BufferedWriter writer = new BufferedWriter(new java.io.FileWriter(file, true));
        writer.write(message);
#

I see this doesn't include a next line character every time

tardy delta
#

Files.newBufferedWriter

regal scaffold
#

Do I really need to add the endLine each?

regal scaffold
misty current
#

i don't know how i'm supposed to make a plugin compatible through versions 1.8 to 1.19 by using the same java version

young knoll
#

I think you have to compile for java 8

tardy delta
#

musnt you use the lowest java version, not sure if you can set java version per module

regal scaffold
#
        writer.write(message);
        writer.newLine();
young knoll
#

no writeln?

#

Sadge

misty current
#

i'm compiling for java 8, but maven doesn't like me compiling to java 8 with a dependency from java 17

#
  bad class file: C:\Users\kill05\.m2\repository\org\spigotmc\spigot\1.19.4-R0.1-SNAPSHOT\spigot-1.19.4-R0.1-SNAPSHOT.jar(net/minecraft/network/NetworkManager.class)
    class file has wrong version 61.0, should be 52.0
rotund ravine
#

@tender shard ^

tardy delta
regal scaffold
#

If you don't add a newLine

#

It will all go to the side

#

And I saw it had a writer.newLine() method

fluid river
#

writer needs a special character to understand there is a new line

#

otherwise it doesn't know where to stop

regal scaffold
#

Fair

young knoll
#

Just stick it all on one line

fluid river
#

and it doesn't provide line writing

young knoll
#

New lines are a waste of bytes

fluid river
#

you can use a newLine() or

#
  • "\n"
#

would probably work

#

also writer has subclasses

regal scaffold
#

It does

#

Which is nice too

fluid river
#

in there you can use the same thing

misty current
#

so can anyone help me?

misty current
#

on the 1.19 module only?

#

would that compile

tender shard
#

are you using IJ?

#

you simply have to start maven through java 17

#

that's all

#

File -> Project Settings -> JDK

#

you can keep target/source level at 8

misty current
#

you mean project structure

#

i don't have project settings

tardy delta
#

yes

tender shard
#

erm yes

misty current
#

and that would still run on 1.8 servers wouldn't it

tender shard
#

yes

misty current
#

aight lemme try

tender shard
#

this lets you compile against java 17 dependencies, while keeping your actual .jar compatible with java 8

misty current
#

that worked, thanks

tender shard
#

np

misty current
#

also when building a multi module project, am I supposed to build the parent project?

tender shard
#

yes

#

but the parent doesn't have any .jar itself

#

usually you have a distribution module that shades in all your other modules

earnest plinth
#

[22:41:52 ERROR]: Could not load 'plugins/worldedit-bukkit-7.2.14.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!

#

who can help me

misty current
#

yeah that's what i did, i have a plugin module that shades the core and the core shades all the nms implementations

tender shard
#

Dont do that

earnest plinth
tender shard
#

Oh its worldedit

earnest plinth
#

yes lol

tender shard
#

Wrong channel

tardy delta
#

shutdown server

earnest plinth
wind shoal
#

Any idea how to fix? I get the error when I break a block outside an area

eternal oxide
#

line 41

wind shoal
#

Yeah I got that, I'm asking if you got an idea what to do to fix xd

eternal oxide
#

if the array is empty there is no get(0)

hard socket
#

check this.mines.getMinesByLocation(location);

eternal oxide
#

if (masterLocation == null || masterLocation.isEmpty())

unique eagle
#

hello has anyone ever used traincarts and bkcommon lib? I would like to launch a train from my plugin

wind shoal
wind shoal
#

and yeah someone needs to code stuff xD

echo basalt
#

nvm it's open source lmao

unique eagle
regal scaffold
#

Are ACF tryhards online?

#

I want to make a command like:

    @Subcommand("text")
    @Description("Text a contact.")
    @CommandCompletion("@contacts")
    public void onTextCommand(Player sender, @Single String phoneNickname, String... message) {}

But currently the autocomplete goes for all parameters after phoneNickname which is actually the only one it should apply to, then I want to allow the user to be able to enter any amount of arguments since it's a message

#

@lost matrix Only acf tryhard I remember

hard socket
regal scaffold
#

I just managed to StackOverflow my plugin... oh no

#

Infinite event loop gang

tardy mist
# regal scaffold I want to make a command like: ```java @Subcommand("text") @Description...

Please don't use @CommandCompletion on this method, so no autocomplete suggestions are shown after the first arg. Users will have to manually enter the full message

@Subcommand("text")
@Description("Text a contact.")
@CommandCompletion("@contacts")
public void onTextCommand(Player sender, @Single String phoneNickname, @VarArgs String... message) {}``` Here, I am using an `@VarArgs` on the method, to allow any number of args

And here, I am using an `StringBuilder` to concatenate all further args into the message:
```java
public void onTextCommand(Player sender, @Single String phoneNickname, String... messageParts) {
StringBuilder message = new StringBuilder(phoneNickname);
for (String part : messageParts) {
message.append(" ").append(part);
}
// Use message...
}``` 

Generally, to avoid autocomplete applying to all further `args`, you have two options:
1. Don't use `@CommandCompletion`
2. Use `@VarArgs` to allow an arbitrary count of args, and concatenate them yourself
regal scaffold
#

You are a G

#

Thanks for the insanely detailed answer

tardy mist
regal scaffold
#

❤️

#

I have another question unrelated then

tardy mist
#

Ask away

regal scaffold
#

I have a logger method that is supposed to write to 2 different files at the same time

#

For that I created 2 File instances, 2 BufferedWriter instances, 2 String builders

#

But I'm getting a very sexy StackOverflow error

#

It's so long I can't even read it

tardy mist
#

show the code please

regal scaffold
#

?paste

undone axleBOT
regal scaffold
tardy mist
#

synchronize your access to the files, to avoid write conflicts

#

you can synchronize the whole method

regal scaffold
#

Wait but

#

Even if my files are completely separate?

tardy mist
#

or just use the File/BufferedWriter operations

regal scaffold
#

There is no chance both files would be the same

tardy mist
#

wait, let me rewrite it

regal scaffold
#

If you feel like it sure, otherwise just do a mockup

#

Thanks!

tardy mist
#

One thing I can tell you is, the synchronized keyword will ensure only a single thread can execute the method at a time

#

that will avoid conflicts

#

properly closing the resources ensures no leaks

#

checking for and handling IOException is always a good idea

regal scaffold
#

Wait but

#

What is the actual issue

#

Like I understand about synchronized

#

But if the method is just called once

#

Why does it matter

tardy mist
#

🤔

#

Hmm, then the error is because recursion

regal scaffold
#

That could be

tardy mist
#

your method is calling itself repeatedly

#

you have a recursive call to writeMessageLock() inside the method

#

you're accidentally creating and closing the File, BufferedWriter etc

regal scaffold
#

You saw the entire method tho

tardy mist
#

resources in a loop, causing repeated re-opening

regal scaffold
#

Let me log how many times it's called

#

Nope

#

Just once

#

I am big confusion

#

Slowly commenting 1 by 1 here we go

regal scaffold
#

Will do your alternative if I can't find the reason why

brave sparrow
#

You don’t need to make that synchronized

#

It’s not being called from multiple threads

#

That’s unnecessary overhead

tardy mist
#

That is true.

#

Its just an example, but it was clarified

regal scaffold
#

Uhm ok

#

hold on

#

This is bad

#

So, commenting out line by line

#

And eventually reaching the bottom

#

Now... no stackoverflow

brave sparrow
#

Ya

#

Lol

regal scaffold
#

Without a single code change

#

How tf am I gonna recreate that so I can prevent

tardy mist
#

Simplify

brave sparrow
regal scaffold
#

Oh wait

young knoll
#

It’s very hard to cause a stack overflow with no code

#

:)

regal scaffold
#

I found something

brave sparrow
#

What’s on that line

regal scaffold
#

Internal logic

#

?paste

undone axleBOT
regal scaffold
#

Maybe it's not directly related with that

#

But another question

#

So in my logs, I'm openning and closing the files

#

Can't remove this file cause it says in use O.o

#

But it should've been closed

tardy mist
regal scaffold
#

That could be the error

#

I think it's time to implement a buffer to write stuff to files

#

Doing it on every log seems really inefficient

tardy mist
#

tbh, dssd is not a valid class or method name

#

wait i fix it for you

regal scaffold
#

I gtg rn so please tag me and I will see it. Thanks a lot

#

Wait what did you even change

#

The send message line

quaint mantle
#

hi, my default config file isn't being saved to my plugin folder

#

i have a config.yml file in the resources folder

regal scaffold
#

#saveDefaultConfig()

quaint mantle
#

and this.saveDefaultConfig(); was placed into the onEnable event

#

no errors are being thrown in the console

tardy mist
# regal scaffold Wait what did you even change

Objects.requireNonNull(Bukkit.getPlayer(this.phoneOwner)) should be Objects.requireNonNull(Bukkit.getPlayer(phoneOwner)).

no opening { before public void receiveText(Text text)
no closing } at the end of the method
color should be Color
event should be new ClickEvent()
append should .append()

this is what caught my eye at first glance

#

am i wrong, please correct, maybe i sleep with open eyes too

desert spade
hazy parrot
#

Why are you overriding it

quaint mantle
#

uhh

#

because that's what i saw when i opened my project

hazy parrot
#

?

desert spade
hazy parrot
#

You shouldnt override it lmao

young knoll
#

What?

desert spade
#

It's the method inherited from javaplugin

quaint mantle
#

when i first created the plugin it made this file automatically with an onEnable method and onDisable method

hazy parrot
#

OK?

young knoll
#

It’s normal to override onEnable

hazy parrot
#

Not onEnable

#

Or I misunderstand lol

desert spade
#

Is there already a different config file in your plugins folder @quaint mantle

quaint mantle
#

nope

young knoll
#

Actually there is a simple solution to this

#

?nocode

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

alpine swan
#

sometimes I need to add spigot instead of spigot-api as a dependency in my maven for a plugin due to needing NMS. when I do this, I don’t get javadoc descriptions when doing ctrl q on a method. how can I fix this / add javadoc descriptions back since it’s not in spigot jar

quaint mantle
#

this is my first ever java project if code is spaghetti that is why

    public void onEnable() {
        MyDeathEventListener deathEventListener = new MyDeathEventListener(this);
        getServer().getPluginManager().registerEvents(deathEventListener, this);

        this.saveDefaultConfig();
        Logger logger = getLogger();
        File f = new File(getDataFolder() + "/");
        if(!f.exists())
            f.mkdir();
        File myFile = new File(f,"playerdata.yml");
        try {
            myFile.createNewFile();
            logger.info("Created playerdata file.");
        } catch (IOException e) {
            logger.severe("Failed to create playerdata file: " + e.getMessage());
        }
        getServer().getPluginManager().registerEvents(new MyJoinEventListener(this, myFile), this);
        logger.info("Exponential Bans is now started");
    }
young knoll
#

Does your jar have a config.yml file in it

#

And I’m the correct place

quaint mantle
#

i put it in the resources folder

#
startingTime: 4
increaseAmt: 4
maximumBanTime: 48
young knoll
#

Are you building with maven or gradle

quaint mantle
#

maven

young knoll
#

Alright

#

That all seems good

scarlet kelp
#

Hi guys, Im trying to make server like bhop or surf servers in cs, I mean passing maps and be able to vote for the next one. So the problem is that one map using command blocks can affect another map. So I think it's a good idea to just unload rest of maps (Server.unloadWorld) when map changing, but the problem is that for some reason bukkit won't allow to unload maps which have dimension = 0 (Overworld), I found out it from source code. Have you any ideas how to solve that?

young knoll
#

You can’t unload the main world

quaint mantle
scarlet kelp
#

it's not "main"

quaint mantle
#

because there's no config.yml file

scarlet kelp
#

it's just an overworld

#

and i have not only one world of this type

young knoll
#

Check the exported jar with something like 7zip

#

Make sure the config is in there in the right spot

quaint mantle
#

where should i be looking

young knoll
#

It should be in the same place as plugin.yml

remote swallow
#

it should be in the base jar

quaint mantle
#

nope

#

not there

#

oh wait

high igloo
#

hello, does anyo0ne know of a way i could make it possible to place end crystals when there are light blocks in the way? i havent been able tot figure this out and i dont want to have to remov ethe light blovcks from my maps, cuz they dont look the best without light. please let me know if its possible

quaint mantle
#

i'm really silly

#

wrong file

#

yeah that was my mistake