#help-development

1 messages · Page 519 of 1

weak meteor
#

oh

#

nvm

#

just

#

worked out

rotund ravine
#

Takes a bit to update

misty current
#

i thought declared referred to methods/fields declared in that class and not in super classes when you want to get methods/fields

rotund ravine
#

Yes

#

Sortof

misty current
#

well that doesnt really apply to constructors since you can't really call a constructor from a superclass without calling the constructor of the subclass

ivory sleet
#

declared gets type declared members. Non declared gets visible stuff from the outside basically

#

So inherited visible stuff included

#

For constructors yea its a bit special

young knoll
#

Excuse me

quiet ice
#

Mom, someone broke their JDK again!

young knoll
#

You gotta buy the boolean DLC

vast ledge
slim wigeon
#

Types that is

tardy delta
analog matrix
#

Hey, I've programmed a small api and I'm using it in a project.
I add the api using maven. I use the system as scope.
Do I have to put the api also on the server?

river oracle
#

But please don't use system scope

tardy delta
#

c++ is even more fun than java

river oracle
#

That's like the worst way to depend on anything

#

Use a build system like maven to manage everything for you

river oracle
#

Mvn install adds it to your local .m2

tardy delta
#

why not just put it on the server

river oracle
tardy delta
#

why would you mvn install it then

analog matrix
river oracle
#

Which is brain dead design

tardy delta
#

they said they use maven

river oracle
#

mvn install the api into local. M2

#

Its not hard

tardy delta
#

or is only the api on maven but not the impl or some weird stuff

river oracle
analog matrix
#

I found this $ mvn install:install-file -Dfile=<path-to-file> \ -DgroupId=<group-id> -DartifactId=<artifact-id> \ -Dversion=<version> -Dpackaging=<packaging>
but i didnt know how to put this respectively i dont know how to do the break lines

river oracle
#

Why not use maven for both

#

Seems sensible to do

#

And makes life way easier

analog matrix
# river oracle Why not use maven for both

how? i used this command

    -DgroupId=<group-id> -DartifactId=<artifact-id> \
    -Dversion=<version> -Dpackaging=<packaging> ```
But i get everytime a CommandNotFoundException
river oracle
#

Does your api not use maven

#

If it does that command isn't needed

#

Just use mvn install

copper scaffold
#

Is it possible that 2 yml files with configuration settings are copied to the plugin folder, with the content in it i have config.yml & texts.yml, config.yml i can save with

saveDefaultConfig();
``` and how can i get texts.yml to copy top the folder?
small glen
#

i found something, giving levitation 255 effect to player, and he can't jump

rotund ravine
#

?jd-s

undone axleBOT
rotund ravine
#

for the definition

flint coyote
rotund ravine
#

Potion effects at 255 sometimes break their functions

flint coyote
#

I know about that. I'm just wondering if there's other sideeffects

white root
#

Does Bukkit.getScheduler().runTaskLaterAsynchronously use a new thread for each time it's called?
Like, do I need to worry about how much I call this? Cause if each call makes a new thread, that probably wouldn't be ideal

rotund ravine
#

There's a threadpool

copper scaffold
young knoll
#

YamlConfiguration.loadConfiguration(file)

ivory sleet
#

but in short it reuses a thread if the consumption becomes high, else there's a timeout cooldown for when it will terminate a thread after being left unused

meager wolf
#

hello
so i was searching for some minecraft coding free courses
and i didn't really find any
all of them are for 9 years old kids and they explain the most stupid things
do you know any sources ?
i have good experience with java

chrome beacon
meager wolf
#

ty

pseudo hazel
#

or just some good tutorial series on youtube

#

there probably a re a bunch of videos on whatever you need

tardy delta
echo basalt
#

took me 3 weeks to see this

#

I'm not

tardy delta
#

i love it when my code randomly starts working even though i changed nothing

regal scaffold
#

Genius

#

Thanks ill

#

Just took a tiny bit

karmic salmon
#

Sorry But why this not working? java if (args[1].equals(null)){ player.sendMessage(ChatColor.RED + "Sorry But You Need Set a Name To Create New Round!"); player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29); return false;

#

it should check if args[1] is null or not

#

but it send me like error in mc

#

An internal Error occured While Attempting to Perform this command

chrome beacon
#

Also that code is never going to work

#

You can't call equals on null

karmic salmon
#
org.bukkit.command.CommandException: Unhandled exception executing command 'th' in plugin Treasurehunt v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:916) ~[paper-1.19.2.jar:git-Paper-307]
    at org.bukkit.craftbukkit.v1_19_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.2.jar:git-Paper-307]
    at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.2.jar:?]
    at net.minecraft.commands.Commands.performCommand(Commands.java:305) ~[?:?]
    at net.minecraft.commands.Commands.performCommand(Commands.java:289) ~[?:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2294) ~[?:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2248) ~[?:?]
    at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) ~[?:?]
    at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.2.jar:git-Paper-307]
    at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
    at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
    at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.2.jar:git-Paper-307]
    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:185) ~[paper-1.19.2.jar:git-Paper-


undone axleBOT
karmic salmon
chrome beacon
#

Check the length of the array

chrome beacon
#

?learnjava ;/

undone axleBOT
karmic salmon
chrome beacon
#

You don't know how an array works

karmic salmon
#

But i wasn't know how make that lol
Thank you anyway!

karmic salmon
#

but i never use them ☠️

chrome beacon
#

You just showed me that you have no idea how they work

karmic salmon
#

ok

#

Thank you anwyay!

tardy delta
#

memory that was gone is suddenly back

scenic onyx
#

Can you help me with something?

tardy delta
#

?ask

river oracle
#

No

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

river oracle
#

I wanted to mess with them >:(

tardy delta
#

go learn assembly instead youngling

river oracle
tardy delta
#

it was a bit fun for me

remote swallow
#

Ur pfo just made me think of haryy potter

tardy delta
#

and now im writing my own assembly based lang

karmic salmon
#

guys i want this tabcompleter only for like arg 1 or arg 0 how do that? StringUtil.copyPartialMatches(args[0], List.of(arg1tabcompter), completions);

#

when i change the number in (args[0] it error whole code

#

StringUtil.copyPartialMatches(args[0], List.of(arg1tabcompter), completions); StringUtil.copyPartialMatches(args[1], List.of(nothing), completions);

tardy delta
#

should check the args.length

karmic salmon
#

What this do?

scenic onyx
#

How do I make the tnt shoot like the snowball? "

public class Tnttone implements Listener {

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    ItemStack Tnttone = new ItemStack(Material.TNT);
    ItemMeta Tnttone_meta = Tnttone.getItemMeta();
    Tnttone_meta.setDisplayName("§4§lTnttone");//coso sopra
    ArrayList<String> Tnttone_lore = new ArrayList<>();
    Tnttone_lore.add("§bInfo:"); //coso sotto
    Tnttone_lore.add("§dQuando si prende un oggetto"); //coso sotto
    Tnttone_lore.add("§dTenere sempre vuoto il primo Slot"); //coso sotto
    Tnttone_meta.setLore(Tnttone_lore);
    Tnttone.setItemMeta(Tnttone_meta);

    Player player = event.getPlayer();
    if (event.getItem().getAmount() == Tnttone.getAmount() && event.getItem().getType() == Tnttone.getType()) {
        if(event.getItem().isSimilar(Tnttone)) {
            player.launchProjectile(Snowball.class);
            launchTNTProjectile(player);
        }
    }
}

public void launchTNTProjectile(Player player) {

    TNTPrimed tnt = player.getWorld().spawn(player.getLocation(), TNTPrimed.class);
    tnt.setFuseTicks(40);

    new BukkitRunnable() {
        @Override
        public void run() {
            tnt.setVelocity(player.getLocation().getDirection().multiply(10));
        }
    }.runTaskLater((Plugin) this, 1);
}}?
remote swallow
tardy delta
#

like if args.length == 1 (meaning you have the command name and one arg) you return a tabcompletion for that arg

karmic salmon
#

i see-

#

so like if args.length == 0

#

this should return the tabcomleetion for frist arg?

tardy delta
#

no you need one arg, like /command arg0

karmic salmon
#

bec arg starts with 0

remote swallow
#

Also ur copyPartialMatches is wrong (args【num], completions, new ArrayList<>()) then you return this

karmic salmon
#

hm

tardy delta
#

/commandName arg0 arg1 arg2 ...

remote swallow
river oracle
#

Too many emojis OkayuBonk

tardy delta
#

good

karmic salmon
#

sorry how know like if arg 1 isn't set anything so i send error

eternal oxide
#

You do not send errors in tab complete

tardy delta
#

you check is args.length is 1

karmic salmon
tardy delta
#

so you only have args[0]

karmic salmon
tardy delta
#

none of those args will be null so checking args[x] == null wont work

karmic salmon
karmic salmon
# tardy delta you check is args.length is 1

it just send error in consel and do nothing java if (args[0].equals("remove")) { if(args.length == 1){ player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round! " + ChatColor.DARK_RED + args[1]); player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29); return true;

tardy delta
#

uh do length check before you access an element that may or may not exist

karmic salmon
#
 @Override
    public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            if(args.length == 1){
                player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round! " + ChatColor.DARK_RED + args[1]);
                player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
                return true;
            }
            if (args[0].equals("create")) {
                if (Files.isDirectory(Paths.get("plugins\\TreasureHunt\\" + args[1]))) {
                    player.sendMessage(ChatColor.RED + "Sorry But There Are Aready Round Called " + ChatColor.DARK_RED + args[1]);
                    player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
                    return true;
                }```
#

no

#

ig

tardy delta
#

if you only know args.length == 1, only args[0] will exist

#

args.length == 1 -> args[0] exist
2 -> args[0] and 1 exist
3 -> args[0], 1 and 2 exist

karmic salmon
#

oh-

#

so 2 = args[0] and args[1] existed?

tardy delta
#

yes

karmic salmon
#

I Understanding now

tardy delta
#

and dunno what youre trying to do with this

#

ig thats your plugin name

karmic salmon
#

it just counting the args in the command

karmic salmon
karmic salmon
tardy delta
#

well you have JavaPlugin#getDataFolder which returns the folder where you can store plugin data (/plugins/treasurehunt in your case)

tardy delta
#

so could do java File dir = new File(plugin.getDataFolder(), args[1]); if (!dir.exists()) { dir.createNewFile(); } //etc

vocal cloud
#

I'd probably be very much against creating a file on the computer

karmic salmon
vocal cloud
#

Would be much better to just create 1 config file so you don't have to handle creation/loading every time someone runs a command

karmic salmon
#

eh

#

hm

karmic salmon
#
 if(args.length == 2){
                player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round! " + ChatColor.DARK_RED + args[1]);
                player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
                return true;
            }
            if (args[0].equals("create")) {
                if (Files.isDirectory(Paths.get("plugins\\TreasureHunt\\" + args[1]))) {
                    player.sendMessage(ChatColor.RED + "Sorry But There Are Aready Round Called " + ChatColor.DARK_RED + args[1]);
                    player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
                    return true;
                }```
#

it do nothing ;/

#

send error to consel

#

anyone have any idea way?

tardy delta
#

cant really see but the 'if args[0].equals("create")' isnt in the 'args.length == 2' block right

karmic salmon
#

bruh

#

+ args[1]

#

i litty

#

bruh

tardy delta
#

so args.length might even be 0

karmic salmon
#

dude i so dumb

#

no

#

i used args[1]

#

here player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round! " + ChatColor.DARK_RED + args[1]);

#

at end 💀

#

o wait still not working

karmic salmon
#

so it 0??

#

i will try this

tardy delta
#

you say

karmic salmon
#

still not working

#
if(args.length == 0){
                player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round!");
                player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
                return true;```
#

anyone have any other ideas?

tardy delta
#

whats not working

karmic salmon
#

wait we can just send args length]

karmic salmon
karmic salmon
karmic salmon
#

then send error in consel

tardy delta
#

whats it saying

eternal oxide
#

ArrayIndexOutOfBounds

tardy delta
#

no shit 🤡

eternal oxide
#

🙂

karmic salmon
tardy delta
#

im trying not to spoonfeed 💀

karmic salmon
#

bruh now works

#

ah i just add args.length == 1

#

But i learned alot of things today

#

that google is my best friend and args is hard 💀

#

Thank You @tardy delta Btw!

quaint mantle
#

why args still not collection?

eternal oxide
#

changing to a collection would be a breaking change

quaint mantle
#

Yea

eternal oxide
#

not really needed either

tardy delta
#

every toArray() i see triggers me

copper scaffold
tardy delta
#

File instance?

young knoll
#

You can't

#

But you can do new File(plugin.getDataFolder(), "texts.yml")

candid kindle
#

im trying to make a new thread via BukkitRunnable, but this seems to not be making a new thread and instead just lags my server until i close it (though it does run the code, i.e. saying "test" every second). anyone know why?

new BukkitRunnable() {
    @Override
    public void run() {
        try {
            while (true) {
                Bukkit.broadcastMessage("test");
                Thread.sleep(1000);
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}.runTask(plugin);```
eternal oxide
#

you need Async to run off the main thread

slim wigeon
# candid kindle im trying to make a new thread via `BukkitRunnable`, but this seems to not be ma...

Example from my Farm Rod source code Bukkit.getScheduler().scheduleSyncRepeatingTask(this, (Runnable)new Runnable() { @Override public void run() { for(FarmRod farm : farms) { if( farm.getType() == FarmType.CROPS || farm.getType() == FarmType.RESOURCES ) { if( farm.getOptionBoolean("Harvest") ) { farm.harvest(); } if( farm.getOptionBoolean("Plant") ) { farm.plant(); } } if( farm.getType() == FarmType.ANIMALS ) { if( farm.getOptionBoolean("Shear") ) { farm.shear(); } } farm.updateViews(); } } }, 0L, 60L);

tardy delta
#

(Runnable)new Runnable() 🤔

#

<insert lambda here>

quaint mantle
#

()-> {}

slim wigeon
quaint mantle
#
() -> { System.out.println("Hello world"); }
slim wigeon
tardy delta
#

?scheduling

undone axleBOT
tardy delta
slim wigeon
#

I will have to test that but what I have works for right now. Plus my code is splitted to multiple files and plugins so there is nothing to make smaller

tardy delta
#

it should

#

crash?

slim wigeon
#

log check

eternal oxide
#

check the exit code

slim wigeon
#

Odd

tardy delta
#

did you press ctrl c 💀

eternal oxide
#

what are you running?

#

Sorry won't help with forks

#

still a fork

tall saffron
#

This is the config for my scoreboard on my plugin : ```yaml
scoreboard:

    #This variable sets the time after each load of the placeholders (dont set this too low)
    seconds: 15

    title: "&4&lScoreboard"
    values:
        - ""
        - "&a&lStats:"
        - "&eKills: &r%statistic_player_kills%"
        - "&eDeaths: &r%statistic_deaths%"
        - ""
        - "&a&lInfo:"
        - "&rPing: &c%player_ping%"```Its bugs out, like if i put on the first like on the "" a space like this : " " it leaves the first space if not it doesnt, and if you add 2 spaces it bugs out its wierd does someone know why? or how to fix it?, this is the code for the scoreboard : ```java

//Scoreboard

public void scoreboardLoad(Player player) {
    ScoreboardManager manager = Bukkit.getScoreboardManager();
    Scoreboard scoreboard = manager.getNewScoreboard();

    // Get the scoreboard title from the configuration file
    String title = ChatColor.translateAlternateColorCodes('&', getConfig().getString("Config.scoreboard.title"));

    // Register a new objective with the title and set it to be displayed in the sidebar
    Objective objective = scoreboard.registerNewObjective("title", "title", title);
    objective.setDisplaySlot(DisplaySlot.SIDEBAR);

    // Get the list of values from the configuration file
    List<String> values = getConfig().getStringList("Config.scoreboard.values");
    int scoreValue = values.size();

    // Loop through each value and add it as a score in the objective
    for (String value : values) {
        //Adds Colors
        Score normalScore = objective.getScore(ChatColor.translateAlternateColorCodes('&', value));
        //Checks for placeholderapi
        if(hasPapi){
            // Adds Placeholders
            String papiString = PlaceholderAPI.setPlaceholders(player, value);
            Score papiScore = objective.getScore(ChatColor.translateAlternateColorCodes('&', papiString));
            papiScore.setScore(scoreValue);

        }
        else {
            normalScore.setScore(scoreValue);
        }

        // Decrease the score value for the next iteration
        scoreValue--;
    }

    // Set the scoreboard for the player
    player.setScoreboard(scoreboard);
}
echo basalt
#

weird ahh code

#

I'd enforce oop

#

ILLUSION SEARCH INDEX - Simple scoreboard class

public class SimpleBoard {

    private static final int MAX_LINES = 15;
    // private static final int MAX_PREFIX_LENGTH = 16; - Minecraft now uses Components for this, so we don't need to worry about it
    private static final String[] BLANKS = new String[MAX_LINES];

    private final Team[] teams = new Team[MAX_LINES];
    private final Objective objective;

    static {
        for (int index = 0; index < MAX_LINES; index++) {
            BLANKS[index] = new String(new char[]{ChatColor.COLOR_CHAR, (char) ('s' + index)});
        }
    }

    public SimpleBoard() {
        this(Bukkit.getScoreboardManager().getNewScoreboard());
    }

    public SimpleBoard(Scoreboard board) {
        board.clearSlot(DisplaySlot.SIDEBAR);

        objective = board.registerNewObjective("sidebar", "dummy", " ");
        objective.setDisplaySlot(DisplaySlot.SIDEBAR);

        for (int index = 0; index < MAX_LINES; index++) {
            teams[index] = board.registerNewTeam(BLANKS[index]);
            teams[index].addEntry(BLANKS[index]);
        }
    }

    public void setTitle(String title) {
        objective.setDisplayName(title);
    }

    public void setLine(int index, String line) {
        if (index < 0 || index >= MAX_LINES) {
            throw new IndexOutOfBoundsException("Index must be between 0 and " + MAX_LINES);
        }

        if (line == null) {
            line = "";
        }

        /*
         if (line.length() > MAX_PREFIX_LENGTH) {
             line = line.substring(0, MAX_PREFIX_LENGTH);
         }
         */
        teams[index].setPrefix(line);
        objective.getScore(BLANKS[index]).setScore(MAX_LINES - index);
    }

    public void removeLine(int index) {
        if (index < 0 || index >= MAX_LINES) {
            throw new IndexOutOfBoundsException("Index must be between 0 and " + MAX_LINES);
        }

        teams[index].setPrefix(BLANKS[index]);
        objective.getScoreboard().resetScores(BLANKS[index]);
    }

    public void clear() {
        for (int index = 0; index < MAX_LINES; index++) {
            teams[index].setPrefix(BLANKS[index]);
            objective.getScoreboard().resetScores(BLANKS[index]);
        }
    }

    public void displayList(List<String> lines) {
        // we can't let this flicker
        if (lines.size() > MAX_LINES) {
            throw new IllegalArgumentException("List cannot be larger than " + MAX_LINES);
        }

        for(int index = 0; index < MAX_LINES; index++) {
            if (index < lines.size()) {
                setLine(index, lines.get(index));
            } else {
                removeLine(index);
            }
        }
    }

    public void display(Player player) {
        player.setScoreboard(objective.getScoreboard());
    }

    public void hide(Player player) {
        player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
    }

    public void dispose() {
        objective.unregister();
    }
}
#

and then yk

#

some logic

agile anvil
#

Or use FastBoard

tall saffron
tall saffron
vast ledge
#

An API or framework

#

or LIB

#

not sure

tall saffron
#

Oh amma check that out

tall saffron
remote swallow
vast ledge
tall saffron
#

question how can i get from the config yaml values: - "" - "&a&lStats:" - "&eKills: &r%statistic_player_kills%" - "&eDeaths: &r%statistic_deaths%" - "" - "&a&lInfo:" - "&rPing: &c%player_ping%" the spaces separated in the list, and add them as fastboard tells you too, that is with separated with commas as the example they give : java // Change the lines board.updateLines( "", // Empty line "One line", "", "Second line" );

agile anvil
#

Does your list contain the empty strings ?

remote swallow
#

config.getStringList("values")

orchid trout
#

config.getStringList("valyes")

#

cabuyfdsf]

#

sfdnkusaydfghsad

agile anvil
#

If not, create a special character, such as %blankline%, and replace them with ""

tall saffron
#

Oh yeah my bad i just thought i would need to separate them with commas

agile anvil
#

Guys I'm making a minigame lobby, and was wondering about team balancing.
Basically my game requires a maximum of 4 teams (4 players max by team), but you can play with only two. As now I work such that:
Only roundup( nbOfPlayers / 4) + 1 teams are opened. Players are put on the team to equalize the average per team (2 per team). But they can switch.
15s before the beginning, if nbOfPlayers <= 12 i only let opened roundUp(nbOfPlayers/4) teams. So I chose the team(s) with the least players and ask them to choose for the remaining teams.

Do you think it's equal, and balanced? Do you have any critics (except that this question is not code related 🙂 )?

ornate patio
#

Is it possible to customize the break speed of a block

#

Would I have to mess with packets or nms

young knoll
#

Depends how custom you want

#

You can just give the player haste/mining fatigue when they are mining the block

sullen marlin
#

Least glitchy option

ornate patio
#

And wouldn't allow for specific times to the millisecond

#

Also if they have effects from a beacon or elder guardian and such it would be pretty annoying to handle

sullen marlin
#

Block breaking isn't specific to the millisecond anyway lol

ornate patio
#

well

#

specific to the second whatever lol

young knoll
#

Then you need your own system

#

Like hypixel skyblock

wise mesa
#

how can I make a void chunk generator

#

just return for everything?

ornate patio
#

time to explore packets then ig

wet breach
#

like do you want it to start transforming already generated chunks into void space?

wise mesa
#

i want to make a new world that is just void

sullen marlin
wise mesa
#

cool thanks

#

something like this seem about right?

sullen marlin
#

I think so, it might be compulsory to override one method, but just try and see

wise mesa
#

alright I'll give it a try

#

when would server.createWorld return null?

sullen marlin
#

dunno what do the docs say

#

probably if the world with that name is already loaded?

wise mesa
#

docs don't say that's why I asked

#

it actually says that it will return the world that already exists if it already exists

eternal oxide
#

?jd-s

undone axleBOT
eternal oxide
#

?stash I ment

undone axleBOT
tranquil dome
#

This is not a spigot related question, so this might not be the best place to ask, but I need it for my plugin.

Minecraft texture packs have a font folder at ..\assets\minecraft\textures\font. This folder contains some properties files and character sheets that look something like this (see attached image). I need to somehow convert these into a truetype font file that supports plain, bold and italic styles. Does anyone have any idea how to go about this?

wise mesa
#

okay it looks like it gets the world, returns that if it isn't null

#

otherwise tries to create the world

#

and if for some reason it doesn't exist then it will return null

#

so if it tries to make the world but it doesn't exist for some reason, that's when it would return null

sullen marlin
#

idk if that can actuall yhappen tbh

eternal oxide
#

probably not

#

Its the reason for a @nullable annotation though

wise mesa
#

makes sense

#

just gonna Objects.requireNotNull and hope for the best

#

i want to assign plots in this void world spiraling outward from the center

#

but I have no clue how to go about doing this

#

these plots just need to be marked as assigned so that the next time one is needed a different one can be assigned

#

and they don't need to be saved after restarts

#

so this just has to happen in memory

#

hopped in a call with someone and I think I figured it out

#

something I can try at least

fallow latch
#

I am trying to use https://github.com/Shynixn/StructureBlockLib to place a structure from an NBT file saved by a structure block. however when i use it like this:

public static void placeStructure(String name, Location location, Consumer<Throwable> onException, Consumer<Void> onResult) {
        InputStream stream = Doom.getInstance().getResource("structures/" + name + ".nbt");

        StructureBlockLibApi.INSTANCE
                .loadStructure(MyPlugin.getInstance())
                .at(location)
                .loadFromInputStream(stream)
                .onException(onException)
                .onResult(onResult);
}

It complains about Not in GZIP format. Anyone know how to solve this or maybe an easier structure block API? (FAWE seems to only use paper? pls correct if wrong)

eternal oxide
#

you have to not filter resources when you package your jar

#

it corrupts zip formatting

fallow latch
#

could u elaborate pls? also the .nbt file is just saved from a structure block in vanilla minecraft, not a zip file

#

also how can i disable the filter resources?

eternal oxide
#

in your pom

fallow latch
#
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
        </resources>

like this?

#

new to maven

eternal oxide
#

yes, so long as you are not replacing anything in your plugin.yml

#

if you do you have to make separate resource sections

#

like ```xml
<resources>
<!-- Include all resources -->
<resource>
<directory>resources</directory>
<filtering>true</filtering>
<includes>
<include>.yml</include>
<include>
.txt</include>
<include>.json</include>
<include>
.properties</include>
</includes>
</resource>

        <resource>
            <directory>resources</directory>
            <filtering>false</filtering>
            <includes>
                <include>*.nbt</include>
            </includes>
        </resource>
    </resources>```
fallow latch
eternal oxide
#

try it, not sure if resources run the tree

fallow latch
#

nope its still "not in gzip", i will try ur resource sections then

#

it still doesnt work

#

still not in gzip

eternal oxide
#

?paste your resources section

undone axleBOT
fallow latch
eternal oxide
#

looks fine

fallow latch
#

and if i can figure out how to use FAWE i would much rather use that since theres almost no resources about this api

fallow latch
young knoll
#

I assume this is pre 1.18

eternal oxide
#

why use a lib for structure blocks? Spigot has an api

fallow latch
young knoll
#

No

young knoll
#

org.bukkit.structure iirc

eternal oxide
#

Bukkit.getStructureManager()

young knoll
#

We have 3 classes named Structure

#

Because pain

fallow latch
#

oh my god

#

didnt know theres already in the spigot

#

thank you

eternal oxide
#

you still need to use the filtering setting to include your nbt files though

#

They are basically zip files which contain the data.

fallow latch
eternal oxide
#

make sure your files are not corrupt. open them with any zip util

fallow latch
#

does it have to be

eternal oxide
#

zip file containing the data

fallow latch
#

yes i have the same thing

slim wigeon
#

Automatic Cobble Gen Bukkit.getScheduler().scheduleSyncRepeatingTask(this, (Runnable)new Runnable() { @Override public void run() { for(Hopper hopper : hoppers) { hopper.blockBreak(); } } }, 0L, 20L);

fallow latch
#

pls ping when anyone has suggestion for me, gonna be afk for a while, thanks in advanc

eternal oxide
slim wigeon
#

One feature I loved about EpicHoppers and the autosell feature which what started the server shop project

eternal oxide
#

I don;t use that plugin

slim wigeon
#

Used to use it but after I got banned from Paypal, I noticed pirated plugins I can get so I started creating plugins. Its worth creating anyways plus programming makes me smile sso why not start?

#

6 stacks already with 2 running

remote swallow
#

if you want to use new Runnable(){}, use new BukkitRunnable(){}.runTaskTimer(plugin, 0l, 20l)

#

but scheduler should use lambda

flint coyote
#

There's nothing wrong with using a normal Runnable if you don't need the functionality that is offered by a BukkitRunnable. Or am I missing something?
What I don't get is why he casts a Runnable to a Runnable

remote swallow
#

you cant use #runTaskTimer on a normal runnable

#

and iirc bukkit has the class runnable method deprecated

#

?scheduler

flint coyote
#

you can just call start though

remote swallow
#

?scheduling

undone axleBOT
remote swallow
slim wigeon
flint coyote
# remote swallow

then it's a best pratice thing. I wonder why they did not deprecate the legacy methods though

remote swallow
#

you shouldnt need a warning to change your code, the wiki saying how to use the scheduler tells you how it should be used

flint coyote
slim wigeon
#

I have a issue now. I have the block breaking which is the cobble gen but how do I get the hopper inventory?

#

Need to check if the hopper is full so it will stop creating entities in my world

remote swallow
#

do you have the location of the hopper

slim wigeon
#

I do

#

Data file```world:193:65:-121:
Location:
World: world
X: 193
Y: 65
Z: -121
world:193:65:-123:
Location:
World: world
X: 193
Y: 65
Z: -123

remote swallow
young knoll
#

Get block at location, get state

slim wigeon
#

BlockState?

young knoll
#

Yes

slim wigeon
#

Thanks, I will look at that

#

Just need to stop this when full

#

Having too many entities is bad

flat lark
#

Can you save structure locations using StructureBlockLib the vanilla ones.

tender shard
#

ugh seems like somebody put alcohol into my beer or sth

slim wigeon
flat lark
remote swallow
#

structure blocks work fine if they didnt mojang wouldnt use them

slim wigeon
#

I don't know, that is what happened when I was messing with them. It might be another block. You don't see command blocks in creative but you can spawn them. I should not be worrying about this right now. Just be careful what you use

remote swallow
#

you can get them in gmc in 1.19.3

tall furnace
#

So I don't think it's possible, but thought I would see if anyone had found a way to run a piece of code when a player clicks, as opposed to running a command. The reason I don't think it is possible is because it is probably entirely handled on the client side, and therefore they need to send something back to the server for the server to know anything got clicked.

slim wigeon
#

How do I get the blockstate?

tall furnace
#

block.getState

slim wigeon
#

Thanks

wet breach
#

as far as I am aware, you need to click to interact with the world in minecraft and then in the inventory there is a click event

quaint mantle
#

hi everyone, I'm developing an auth plugin and I searched for several months how could I integrate the premium mode in it. Of course the plugin is made for cracked servers (otherwise there's not sense to make the plugin).
I already asked chatgpt, read tons of threads in Spigot (and I think Bukkit), and also read some FastLogin code but as far as I know FastLogin use a proxy or something like that?
Anyways, after some more deep research I think the """solution""" is to get the bearer token of the player or something similar and check it in the Mojang API but that's not possible as I saw.
Also there's an interesting answer in a thread that I didn't understood => https://www.spigotmc.org/threads/get-access-token.386789/#post-3493675

thank's in advance ^^

wet breach
#

you are asking a community for help with something that the majority of the community is against and does not support

#

if the players you are checking for need to have premium

#

then I don't see why the server needs to be in offline mode

quaint mantle
#

I'm not asking for code, I'm just asking for at least how does FastLogin exactly checks the authenticity

wet breach
#

you could just look at the code

#

its not hidden

#

mojang hosts their auth lib on github last I recalled

quaint mantle
young knoll
wet breach
#

nothing you make is going to be more secure

young knoll
#

Granted even with said even it’s still basically just a command

quaint mantle
wet breach
#

mojang is the one that created the authentication for their servers

#

not sure what made you think it was something custom

#

spigot doesn't touch the authentication stuff because that breaks the DMCA for DRM

quaint mantle
wet breach
#

there is a rate limit of 600 requests a minute

#

that should be plenty sufficient for you

remote swallow
#

if fastlogin is a login system for offline servers what is it going to ask mojang api for

quaint mantle
wet breach
#

but like, there is no way to know if the person using the name on the server is the same as what was found

#

since you know, there isn't any sessions

wet breach
#

but for offline servers it is pointless to even do this check

quaint mantle
wet breach
#

because you can't guarantee that the person who connected is actually the owner of said name

quaint mantle
wet breach
#

you are better off doing the reverse

#

you are not by far the first person to even attempt this

#

but, it isn't going to work and the client is going to complain for those who are premium

tall furnace
tall furnace
wet breach
nimble hill
#

Does anyone know how to stop a hopper from working all together?
IE: Its placed, and becomes pretty much a dead block with no states, no ticking, and so on

#

Im aware You can tweak the ticks and such in the configuration, but i mean more broadly kill the block

young knoll
#

There isn’t any way to stop it from ticking afaik

#

But you can cancel various events to stop it from having any functionality

nimble hill
#

Yea, that wont work unfortunately, i need to prevent it from ticking

worldly ingot
#

You could also change its state to enabled=false

nimble hill
#

Thank you!

worldly ingot
#

Don't know whether or not that stops its ticking, but it will stop hopping/transferring items

young knoll
#

Smart

#

But it will probably change back if it receives a block update

nimble hill
#

Im having a hard time finding the Hoppers state switch, but ill give it a minute

worldly ingot
#

org.bukkit.block.data.type.Hopper

#

It's a BlockData type

nimble hill
#

Thats what i thought, but thats not working as id expect

#

Icould also make a Hopper manager, Disable all the ticks for hoppers entirely, and have something else manage them entirely

#

All to 0

#

Then have a whole "Hopper" thread

young knoll
#

When do we get BlockState#setTicking(false)

#

Smh

nimble hill
nimble hill
#

I can actually cancel that // the BlockPhysicsEvent to achieve what i want. Thank you @worldly ingot

#
    @EventHandler
    public void on(BlockPlaceEvent e) {
        Hopper h = e.getBlock().getType() == Material.HOPPER ? (Hopper) e.getBlock().getState() : null;
        BlockState bs = h.getBlock().getState();
        org.bukkit.block.data.type.Hopper hopper = (org.bukkit.block.data.type.Hopper) bs.getBlockData();
        hopper.setEnabled(false);
        bs.setBlockData(hopper);
        bs.update(true);
    }

    // Cancel the event so that the hopper doesn't update
    @EventHandler
    public void on(BlockPhysicsEvent e) {
        if (e.getBlock().getType() == Material.HOPPER) {
            e.setCancelled(true);
        }
    }

in case anyone was curious

slim wigeon
#

How do I get the first item in the overflow list?inv.addItem(new ItemStack(Material.COAL,25))

nimble hill
#

Like if you add an item to an inventory, or items, the retuen or the additem, is a list of items

#

Eg: if you are getting drops:

            List<Item> items = e.getItems().copy();
            e.getItems().clear();
            for (Item i : items) {
                p.playSound(p.getLocation(), Sound.BLOCK_CALCITE_HIT, 0.05f, 0.01f);
                xp(p, 2);
                if (!p.getInventory().addItem(i.getItemStack()).isEmpty()) {
                    p.getWorld().dropItem(p.getLocation(), i.getItemStack());
                }
            }
#

Im checking if the itemstack return is empty

young knoll
#

You could also just do that all in one operation

#

And then drop everything in the overflow map

slim wigeon
#

Well, the issue with that is. You heard of EpicHoppers on Songoda? I trying to re-create that but not a full clone. I can download the plugin if I want to use it as I paid for it but the reason I started the farm rods is because EpicFarming adds items which turned into not realistic. You should not get a golden apple when you timber a tree like EpicTimber does

young knoll
#

You can probably configure that

wise mesa
#

if anyone with worledit/fawe api experience could help me with this it would be great

#

I'm loading a schematic programatically

#

I want to know where the center is

#

the center being like the point that it pastes from

hallow leaf
#

looking for a developer to replicate a game mode of sorts. DMs are open 🙂

wise mesa
#

oh its called getOrigin

#

oops

undone axleBOT
balmy venture
#

yo

#

is it posible to make a plugin so u have an item, and when u right click, it gives u an effect and it has a cooldown

spring creek
#

can some one help me with multy vurse core plugin? I want to know how I can make it so when some one joines for the first time they spawn in some tutorial place then when you do /spawn it takes you some were else but still have it in the same mv world?

balmy venture
#

how

#

im new to coding

#

idk how to code

#

or what to use

#

can u tell me?

remote swallow
#

create your item and give it a pdc tag, check if the item has said tag in the player interact event then do what you want

balmy venture
#

what

#

do u know the bliss smp?

remote swallow
#

?learnjava to start with

undone axleBOT
balmy venture
#

yoo

#

thanks

ornate patio
#

how can I detect if a player's attack was a critical hit

ornate patio
#

ok well

#

I just made a bunch of checks and this works ig

#
@SuppressWarnings("deprecation")
public boolean isCriticalHit(Player player) {
    if (player.getFallDistance() <= 0) {
        return false;
    }

    if (player.isOnGround()) {
        return false;
    }

    if (player.isClimbing()) {
        return false;
    }

    if (player.getLocation().getBlock().isLiquid()) {
        return false;
    }

    if (player.getPotionEffect(PotionEffectType.BLINDNESS) != null || player.getPotionEffect(PotionEffectType.SLOW_FALLING) != null) {
        return false;
    }

    if (player.getVehicle() != null) {
        return false;
    }

    if (player.isSprinting()) {
        return false;
    }

    if (player.getAttackCooldown() < 0.9) {
        return false;
    }

    return true;        
}
tall jacinth
#

Hey, I made a plugin, but when I boot my server, I get this error:
[Server Thread/Error} Could not load 'plugins/MyPlugin.jar' in folder plugins
org.bukkit.plugin.invaliddescriptionexception: Invalid plugin.yml
Jar doesnt contain plugin.yml

#

I remember making all of that, what should I do?

jagged monolith
tall jacinth
jagged monolith
#

?img

undone axleBOT
jagged monolith
#

@tall jacinth ^ Screenshot it and use this and just send the link

tall jacinth
#

2 secs

jagged monolith
#

plugin.yml is in the wrong location

#

It needs to be in the resources folder

#

src/main/resources

tall jacinth
#

Ok, thank you

#

Ill update you when im done!

tall jacinth
jagged monolith
#

plugin.jar. But you should've named the plugin jar in your build file

tall jacinth
#

I think ive got it working

#

I just made a little typo i have to fix

ornate patio
#

out of curiosity why should i be using ThreadLocalRandom.current().nextDouble() instead of Math.random()

tall jacinth
jagged monolith
#

Math.Random() is just find. Depends what you're doing I guess

jagged monolith
tall jacinth
#

but of course

#

it kindof works

jagged monolith
#

ChatGPT isn't something you should rely on for writing everything. It's really only good for getting ideas on how something could be done. Even then it's not that great.

ornate patio
#

I use chatgpt when i wanna ask some obscure question that i prob wont be able to find online

tall jacinth
river oracle
#

google

#

learn to use google

jagged monolith
#

The Spigot java docs for help with spigot api related stuff

#

?learnjava if you need help with java stuff

undone axleBOT
jagged monolith
#

?jd-s

undone axleBOT
ornate patio
#

has anyone tried to replicate crit particle effects from perfoming an actual critical hit before

#

I'm just trying to make some feature where a player can perform a critical hit without actually jumping

#

so I've multiplied the damage by 1.5 and played the crit sound effect

jagged monolith
#

Just spawn the particles?

ornate patio
#

but getting the particles right is very tedious

ornate patio
#

I'm talking about

#

the exact x y and z offset

#

and speed

#

and the count

#

because right now my particles are just flying away from the mob and look a little spaced out

#

if that makes sense

#

its noticably different

echo basalt
#

just look at how nms does

jagged monolith
#

You have to play with those yourself and find out what works for what you're trying to do

ornate patio
#

here are my parameters right now

#

world.spawnParticle(org.bukkit.Particle.CRIT, entity.getLocation(), 25, 0.3, 0.5, 0.3, 0.4);

ornate patio
echo basalt
#

mappings

#

just remap your stuff

#

and then it all just works

#

so unfortunately the regular sword crit stuff seems to be client-sided but we can just use arrows

echo basalt
#

yeah "crit arrows"

#

for probably a fully charged bow

#

they just do a lil

ornate patio
#

oh your talking about the particle effect type

#

i already have that covered

#

isn't it just Particle.CRIT

echo basalt
#

no I mean they actually handle velocity here

ornate patio
#

velocity of what

echo basalt
#

like

#

they use the arrow's velocity in the particle stuff

ornate patio
#

thats goofy

#

anyways im talking about melee hits only i dont need arrow crits

echo basalt
#

perhaps the logic is the same, no?

ornate patio
#

i think the particles are just randomly spread

#

ok honestly

echo basalt
#

depends on the particle

ornate patio
#

idk why im freaking out over this so much

echo basalt
#

arrows do like

ornate patio
#

world.spawnParticle(Particle.CRIT, entity.getLocation().add(0, 0.6, 0), 25, 0.4, 0.4, 0.4, 0.4);
this works fine enough and looks really close to the original

#

im just being too picky ig

echo basalt
#

4 particles where the first one starts at the arrow location and slowly trickles towards arrowLocation + speed

#

and they all have -speed as their speed

#

damage indicator particles are just

ornate patio
#

wait

#

are those the solid values

echo basalt
#

where the particle count is apparently the target's health

#

today I learned

ornate patio
#

wait can u send that line to me

echo basalt
ornate patio
#

wait but

#

is that really true

#

because when i crit a chicken

#

theres still like 20 particles

#

chickens have 4hp

echo basalt
#

maybe it has to do with your health

#

or maybe it's just the amount of damage you done

remote swallow
ornate patio
#

oh wait what

#

ok i just learned something

echo basalt
ornate patio
#

if you use a weapon

#

it spawns "magic crit" particles

#

as well as normal crit particles

echo basalt
#

y eah so

#

those are just packets

#

and the client handles all the logic

#

so you could have just sent packets

ornate patio
#

i could..

echo basalt
#

or did a little nms and call fucking

#

Player#crit(other)

ornate patio
#

is it really worth it

ornate patio
#

if you use a weapon

#

that has an enchantment on it

#

specifically sharpness

#

this is too confusing

#

or smite on undead, or bane of arthropods on arthopods

split gull
#

does FileConfiguration#addDefault(...) add the specified yml option if it isn't already present?

#

i want it to do it once and then let the user decide what to put there

#

how can i achieve this?

remote swallow
#

have a config.yml in src/main/resources, add your defaults add saveDefaultConfig to onEnable

split gull
#

but onEnable runs every time the plugin is loaded, wouldn't that re add the option even if it was removed?

#

i should've mentioned this earlier, i want to make a list that's going to receive some user input

#

ex:

coolname:
    defaultOption:
      - "something"
      - "something2"
    someUserInput:
      - "cool hat"```
#

i want defaultOption to be added when the file is created, how can i do that?

sullen marlin
#

saveDefaultConfig copies the one in the jar and won't overwrite

#

So it's fine for your purposes

split gull
#

ohhh alright, thank you very much, wasn't expecting an answer from you out of all people, ty ❤️

sullen marlin
#

addDefault would add it back (if copyDefaults was true)

#

No worries

tall jacinth
#

No matter what I do, I keep getting this error
Ive re written plugin.yml, and just cant figure it out

#

I know nothing is spelt wrong, ive done that multiple times

quaint mantle
#

Show your path

tall jacinth
remote swallow
#

show plugin.yml and show your file tree

tall jacinth
quaint mantle
#

Right click to java folder and set sources root

remote swallow
#

should be near the bottom mark dir as

tall jacinth
#

Test sources root?

remote swallow
#

sources

#

not test

tall jacinth
remote swallow
#

does your project have a jdk

tall jacinth
#

hold on

#

I dont think i did

#

omg

#

what command do i run?

remote swallow
#

do you have a jdk installed

tall jacinth
#

I should

#

I made another plugin before no problems

remote swallow
#

file -> project structure > top option, i dont remember its name

quaint mantle
#

Why didnt create project using plugin?

remote swallow
#

not everyone uses it

tall jacinth
remote swallow
#

something isnt adding up

tall jacinth
#

What info do you need?

#

im in gen vc1

remote swallow
#

the project structure should show if there was a jdk added

#

does control+alt+shift+s bring anything up

tall jacinth
#

does the fact im using webstorm matter?

#

should i try with vs code

remote swallow
#

ohyeah

#

use intellij idea

#

not webstorm

tall jacinth
#

oh ok lol

#

Ill try vs code?

remote swallow
#

not many people here use vsc but any java ide works

quaint mantle
#

LMAO

tall jacinth
#

I think i know what I did wrong

quaint mantle
tall jacinth
#

I forgot to declare the package

#

🤦‍♂️

remote swallow
#

shouldnt need to declare it, also i wouldnt use webstorm for java development, webstorm is more made for web stuff, js, cs, html etc etc

tall jacinth
#

There we go!

#

Now i have another error

#

uighhhhgkjsbasd

remote swallow
#

?paste it

undone axleBOT
tall jacinth
remote swallow
#

add an api version to plugin.yml

#

eg api: 1.19

tall jacinth
remote swallow
#

show what ur plugin.yml looks like now

tall jacinth
remote swallow
#

change it to 1.17, doesnt need the patch version

tawdry echo
#

why its only triggered when i click at block

remote swallow
#

do you run paper

tall jacinth
remote swallow
#

check the jars updated and restart again

tawdry echo
remote swallow
#

change ignoredCancelled = false to ignoredCancelled = true

#

they cancel the event when its not against a block

tall jacinth
tawdry echo
#

now it igonreCanceled, change it?

remote swallow
#

oh wait my brain did the backwards, change it to false not true lol

remote swallow
#

wtf just happened to the channel

tall jacinth
#

?

remote swallow
#

they have images

#

i just watched them appear

tall jacinth
#

Yeah

#

updates

#

Im surprised I dont have them yet considering im on canary

remote swallow
#

lul

#

i saw them in other discords earlier

mighty ether
#

I'm stuck with how to use sendMessage(). I've tried everything I could think of.

remote swallow
#

playerInstance.sendMessage("string")

#

oh wait my brain farted

#

its api-version not api

tall jacinth
#

ok lol

#

ty

#

bru i gotta restart my whole server

#

java just shit itself and wont stop

remote swallow
#

use task manager lol

tall jacinth
#

ubuntu server

#

and i tried

remote swallow
#

oh jsut press control c to stop the process

tall jacinth
#

I spammed it

#

28 times

remote swallow
#

lmfao

hazy parrot
#

Open another shell -> kill process

#

Altrough, just closing existing shell would end java process

tall jacinth
#

YESS

#

api-version worked

#

WOOOOO HOO

mighty ether
#

SendMessage is crossed out when I tried that.

echo basalt
#

welcome to paper

#

?whereami

remote swallow
#

we need a thread of what dog shite paper does

#

or a wiki

#

or something

quaint mantle
#

Paper is just 1/3 cut vanilla features for more players

quiet ice
#

they have a nice API though

remote swallow
#

theres some good things

#

most bad

karmic salmon
quiet ice
#

But don't just copy & paste your spigot plugins into paper plugins. If you want to use paper you should use it from the get-go and not be afraid of using it

remote swallow
karmic salmon
#

?BRUh

quiet ice
#

Almost everyone uses paper

karmic salmon
#

?whereami

remote swallow
#

whats MainCommandTreasureHunt.java line 23

karmic salmon
#
        if (Files.isDirectory(Paths.get("plugins\\TreasureHunt\\"))) {
        }
        else{
            try {
                Bukkit.getLogger().info("[Treasurehunt] Created TreasureHunt Folder!");
                Files.createDirectory(Paths.get("plugins\\TreasureHunt"));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }```
remote swallow
#

which line specifically

karmic salmon
remote swallow
#

and that is pointless

#

just JavaPlugin#getDataFolder().mkdirs

quiet ice
#

where is your Arrays#asList call?

karmic salmon
#

eh

echo basalt
#

reuse your path

#

pls

quiet ice
#

Also try recompiling

karmic salmon
#

hm

quiet ice
#

Also use / in paths - not \\

echo basalt
#

uhh

karmic salmon
#

it just see if there isn't a file called treasure hunt

quiet ice
#

Latter might not work

echo basalt
#

that's os specific pretty sure

#

but iirc

#

both work

quiet ice
#

The first one always work

echo basalt
#

there's an internal replace call

remote swallow
#

you know what else works

#

File.seperator

echo basalt
#

File.separator / File.separatorChar

quaint mantle
echo basalt
#

b u t

echo basalt
#

saveResource doesn't do the replace calls so use file.separator

#

I've had issues where testing worked in linux but caused issues on windows

karmic salmon
quiet ice
#

Because on linux you can make use of \ so \\ is defo gonna brick on linux

karmic salmon
#

ok!

#

what is plugin

#

it nothing

remote swallow
#

an instance of your plugin

quaint mantle
#

JavaPlugin instance

karmic salmon
#

the file?

remote swallow
#

no, an instance

quaint mantle
#

Bruh he gonna say how to get instance

remote swallow
#

if you dont know what an instance is

vast ledge
#

dayum bro

remote swallow
#

?learnjava

undone axleBOT
karmic salmon
vast ledge
#

You cannot say taht

karmic salmon
#

oh

#

still what is instance

remote swallow
#

learn java before starting plugins

quiet ice
#

Use JavaPlugin.getPlugin(TreasureHunt.class)

karmic salmon
#

I See

karmic salmon
quiet ice
#

It's dumb af but I cannot be arsed to explain DI to you

remote swallow
#

the basics includes instances im guessing

karmic salmon
#

maybe i can't remeber instances

quiet ice
#

An instance is an object

vast ledge
remote swallow
#

the easy answer is everytime you do new Class() that returns an instance, but sometimes you need to reuse that instance, javaplugin is that case, you then have to pass it about or use static getters

quiet ice
#

Not to be confused with the Object class

vast ledge
#

smth like that dont got my ide

echo basalt
#

ew singleton

quiet ice
#

That won't work

echo basalt
#

w h y

#

just di

#

?di

undone axleBOT
vast ledge
vast ledge
quiet ice
#

You cannot assign this to a static

karmic salmon
tawdry echo
#

how can create percentage drop from configuration

vast ledge
#

YOU NEED TO

quiet ice
#

You'd need to do that in the constructor

karmic salmon
remote swallow
#

all that happens if you ask these basic questions is being told to learn java

vast ledge
#

You should know Java before you write a plugin

echo basalt
#

or at least know the basics of programming

quiet ice
tawdry echo
karmic salmon
#

hm

echo basalt
#

I'll write a big post about static and overall static abuse and just reference it next time

remote swallow
karmic salmon
karmic salmon
remote swallow
#

get fricked

karmic salmon
#

rip

quiet ice
#

Telling people to learn java instead of showing them boilerplate solutions that barely work will only reduce motivation

tall jacinth
#

I cant figure out how to add a / command to my plugin, what should I do?

remote swallow
remote swallow
karmic salmon
vast ledge
karmic salmon
#

eh

#

sorry

vast ledge
#

The wiki has a few decent snippets if u wanna find some stuff

remote swallow
# karmic salmon Nope staying learnin java

what, im telling you that learning java while making plugins is fine, just when you encounter something new you dont know or dont understand it is the time to go and learn about that feature and how to use it

buoyant viper
#

me when i

#

?learnjava

undone axleBOT
remote swallow
#

ı

buoyant viper
#

i should do a refresher course

buoyant viper
echo basalt
#

delet this now

karmic salmon
echo basalt
#

you're ruining my immaculate search index

remote swallow
#

im gonna steal the idea from you but fine

echo basalt
#

fuck it

vast ledge
echo basalt
#

Illusion Search Index - Static (aboose)

The concept of static in Java is quite simple when you get to it. To understand static we first must understand how Object Oriented Programming
works.

When creating a class, we're actually creating a structure that an object will follow. This structure defines
what variables are contained within the object, and how the implemented methods interact with such variables.

An object, in java, is created using the new keyword, which calls a constructor defined in the class. You create
a constructor to define some base logic that applies upon initialization of the object, such as the common design pattern
of Dependency/Constructor Injection.

When we talk about an instance of an Object, we're talking about the object as a whole, with its data included. Think of an
object as a box or package of information with a pre-defined structure that is set by the class. That structure indicates
how the data contained within the package behaves.

When passing around objects, with the exception of primitives (int, long, boolean), we're actually passing around a memory
reference to the object. Think of this memory reference as a tracking code, which is used in an internal map/dictionary to indicate
what data belongs to what address. This helps minimize the amount of memory used and is commonly refered to as "Pass by Reference".

Now, how does static come into play?

static is a keyword that indicates that the reference in question should be statically allocated. A statically allocated
object is permamently present in memory (ram), and can be accessible anywhere, at any given time.

By design, a statically allocated object will not be garbage collected, as it can still be accessible by any class at any given
time, even from other static objects or methods. With such a choice, it is exclusively meant for constants, and should also be used
by utility classes.

The only non-constant allowed use of static is in Singletons, which are basically a single constant instance, but are lazily initialized.

TL;DR - Valid usage in:

  • Constants
  • Utility classes
  • Singletons (when DI is impossible)

Examples

Here is an example of a utility class, with a constant

public final class MyUtilityClass { // final to prevent inheritance

    private static final int NUMBER_OFFSET = 100; // constant value, permanent
    
    private MyUtilityClass() { // Private constructor to prevent initialization
    
    }
    
    public static int offsetNumber(int original) {
        return NUMBER_OFFSET + original;
    }
}

Here is an example of a lazy singleton (lazy means it is only initialized when needed)

public class MySingleton {

    private static MySingleton INSTANCE = null;
    
    public static MySingleton getInstance() {
        if(INSTANCE == null) {
            INSTANCE = new MySingleton();
        }
        
        return INSTANCE;
    }
    
    private MySingleton() { // prevent external initialization
        // optional: check for duplicate instances
        if(INSTANCE != null) {
            throw new IllegalStateException("Duplicate instance");
        }
    }
    
    private int currentNumber = 0;
    
    public int getOffsetNumber() {
        return MyUtilityClass.offsetNumber(currentNumber++);
    }
}

Here is what NOT to do:

public class Circus {

    private static PlayerManager playerManager;
    private static SomeOtherManager someOtherManager;
    private static String status = "broke";
    private static int money = -1;
    
    public static PlayerManager getPlayerManager() {
        return playerManager;
    }
    
    public static int getMoney() {
        return money;
    }
    
    public static String getStatus() {
        return status;
    }
    
    public static SomeOtherManager getSomeOtherManager() {
        return someOtherManager;
    }
}
#

(separate message due to character limit)

How can I pass data around without static?

Through Dependency/Constructor Injection (DI). (https://www.spigotmc.org/wiki/using-dependency-injection/)
By passing our data through the object's constructor, we can avoid the use of static and any kind of singleton patterns. Here's a basic example:

public class ExampleListener implements Listener {

  private final ExamplePlugin plugin;

  public ExampleListener(ExamplePlugin plugin) {
    this.plugin = plugin;
  }

  ...
}

And to instantiate it (within our plugin class):
new ExampleListener(this);

Why is the misuse of static bad?

Java is inherently an Object Oriented Programming language (OOP), and its main gimmick is the ability to work with objects. By abusing static, you're breaking the core principle that makes java such a suitable language general use, as well as introducing new issues such as memory leaks (Pro tip: It's never good to mess with mutable data in a static context!) and making your code harder to maintain. Static abuse is one of the easiest ways to introduce tech debt to a project.

Avoid static if you don't understand it. Most often than not you'd end up abusing**

remote swallow
#

funny

#

thats what iw was going for

echo basalt
#

noo my immaculate record

buoyant viper
#

mustve been the wind 💨

karmic salmon
#

Thank for help anwyay

vast ledge
karmic salmon
#

how you

remote swallow
#

no

karmic salmon
#

put 2 plulic void

remote swallow
#

instance =this

karmic salmon
#

public void onEnable() { TreasureHunt instance = this;

#

@Override public void onEnable() { TreasureHunt instance = this; Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!"); this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt()); this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt()); new File(instance.getDataFolder(), "Treasurehunt").mkdir();

#

this should work

vast ledge
#
private TreasureHunt instance;

public void onEnable(){
  instance = this;
} 

public static TresureHunt getInstance(){
 return instance;
}
remote swallow
#
private static TreasureHunt instance;


@Override 
public void onEnable() {
    instance = this;
}

public static TreasureHunt getInstance() {
    return instance;
}
vast ledge
#

How u make color

#

Heh

remote swallow
#

?codeblock

undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
vast ledge
#

oh pog 😄

karmic salmon
#
public final class TreasureHunt extends JavaPlugin {
    private TreasureHunt instance = this;
    public TreasureHunt getInstance(){
        return instance;
    }



    @Override
    public void onEnable() {
        instance = this;
        Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!");
        this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt());
        this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt());
        new File(instance.getDataFolder(), "Treasurehunt").mkdir();

    }```
quiet ice
#

It need to be private static TreasureHunt

karmic salmon
#

ah

remote swallow
#

and remove the = this on iit

quiet ice
#

in both instance and getInstance

karmic salmon
#

it give me error

quiet ice
#

And yeah, remove the instance = this

karmic salmon
remote swallow
#
public final class TreasureHunt extends JavaPlugin {
    private static TreasureHunt instance;
    public TreasureHunt getInstance(){
        return instance;
    }



    @Override
    public void onEnable() {
        instance = this;
        Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!");
        this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt());
        this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt());
        new File(instance.getDataFolder(), "Treasurehunt").mkdir();

    }```
karmic salmon
#

yep

#

i just did that

#

hope it works

#

so like it create instance and set it to this class

#

ig?

remote swallow
#

it has an instance variable, on startup it asigns it then you can access it with TreasureHunt.getInstance()

karmic salmon
#

eh other error]

#

did i do anything wroung here?

public final class TreasureHunt extends JavaPlugin {
    private static TreasureHunt instance;
    public TreasureHunt getInstance(){
        return instance;
    }



    @Override
    public void onEnable() {
        instance = this;
        Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!");
        this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt());
        this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt());
        new File(instance.getDataFolder(), "Treasurehunt").mkdir();

    }```
#

it fine ig

remote swallow
#

nothing wrong

karmic salmon
#

but it give me this error java.lang.ExceptionInInitializerError: null at org.treasurehunt.untitled.TreasureHunt.onEnable(TreasureHunt.java:20) ~[Treasurehunt.jar:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-307] at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:636) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:422) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1100) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-307] at java.lang.Thread.run(Unknown Source) ~[?:?] Caused by: java.lang.NullPointerException at java.util.Objects.requireNonNull(Unknown Source) ~[?:?] at java.util.Arrays$ArrayList.<init>(Unknown Source) ~[?:?] at java.util.Arrays.asList(Unknown Source) ~[?:?] at org.treasurehunt.untitled.MainCommandTreasureHunt.<clinit>(MainCommandTreasureHunt.java:23) ~[Treasurehunt.jar:?] ... 12 more

remote swallow
#

you still have the old code

#

which you dont need

karmic salmon
#

eh

remote swallow
#

if you only need to check if the datafolder is there just mkdirs it on onEnable

#

bc thats all the old code did

karmic salmon
# remote swallow you still have the old code

no old code here ```java
package org.treasurehunt.untitled;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;

public final class TreasureHunt extends JavaPlugin {
private static TreasureHunt instance;
public TreasureHunt getInstance(){
return instance;
}

@Override
public void onEnable() {
    instance = this;
    Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!");
    this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt());
    this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt());
    new File(instance.getDataFolder(), "Treasurehunt").mkdir();

}
@Override
public void onDisable() {
    Bukkit.getLogger().info("[Treasurehunt] The Plugin Just ShutDown!");
}

}```

#

and i dowload the plugin

remote swallow
#

its in MainCommandTreasureHunt

karmic salmon
#

let me check again

remote swallow
#

that is the old code

karmic salmon
remote swallow
#

so remove it

karmic salmon
#

eh

#

oh

#

this Treasurehunt.java

#

bruh

remote swallow
#

yeah

karmic salmon
#

sorry what problem again in MainCommandTreasureHunt

remote swallow
#

this code

karmic salmon
#

this was in treasurehunt

#

not MainCommandTreasurehunt

remote swallow
#

okay then whats line 23 in MainCommandTreasurehunt

karmic salmon
#

static ArrayList<String> names = new ArrayList<String>(Arrays.asList(f.list()));

remote swallow
#

there is your error

#

what is f

karmic salmon
#

deleted

remote swallow
#

deleting stuff bc it errors is the entirely wrong way to do stuff

#

what is f

karmic salmon
#

ah

remote swallow
#

use descriptive var names

karmic salmon
#

i was just testing smth

#

and i forget remove it

#

i thought it wasn't make any error

#

but it did

#

so i don't need it anwyay

remote swallow
#

you also shouldnt make a list like that

karmic salmon
#

it will not function anyway it was test

karmic salmon
#

in treasurehunt folder

#

then get the name of this file

#

and add it to tabcomplete

echo basalt
#

FUCK

karmic salmon
#

but it not working

remote swallow
#

you are making my brain hurt

karmic salmon
#

fr

echo basalt
#

I almost finished writing the guide

#

and discord crashed

#

fml

karmic salmon
#

but this the pain of teach new people ¯_(ツ)_/¯

vast ledge
#

Im bak what broke?

echo basalt
#

lost like 10 minutes of writing

karmic salmon
vast ledge
remote swallow
karmic salmon
vast ledge
remote swallow
#

real

echo basalt
#

fml

#

punching air right now

#

Time to do this in notepad++ this time

vast ledge
#

yea

#

its alot safer

echo basalt
#

ah man it won't be the same

karmic salmon
vast ledge
karmic salmon
#

Just checking bec when i reload it made nothing 💀

remote swallow
#

it should make a folder in plugins/TreasureHunt/Treasurehunt

karmic salmon
#

rip paper

vast ledge
#

wdym rip paper?

karmic salmon
remote swallow
#

that repo doesnt exist

karmic salmon
#

no i was it should make folder in Treasurehunt

remote swallow
karmic salmon
#

i mean in

#

bruh

remote swallow
#

remove that line and add getDataFolder().mkdirs()

karmic salmon
#

i was just want make folde in plugin called treasurehunt

#

oh

vast ledge
#

yep gotta accept the su req

#

reload its public

#

now

spring creek
#

can some one help me with multy vurse core plugin? I want to know how I can make it so when some one joines for the first time they spawn in some tutorial place then when you do /spawn it takes you some were else but still have it in the same mv world?

karmic salmon
remote swallow
#

no need

remote swallow
#

you dont need the instance either