#help-development

1 messages · Page 2089 of 1

torn shuttle
#

I used to do what you're trying to do and it never ends well

smoky oak
#

public ConvertBlocks(Material a, Material b, Nullable boolean visual, Nullable double chance)
Example of a builder pattern?

torn shuttle
#

there's also the optional keyword but it's a pain

torn shuttle
grim ice
#

u prob alr seen it

torn shuttle
grim ice
#

thats what i did tho

quaint mantle
#

is there any way of getting a tnt entity when it spawns in? through some event

grim ice
#

OH SHIT

#

i misspelled it

#

mbbb

#

nice catch

crisp steeple
#

such a long discussion for such a simple problem lmao

grim ice
#

ye lmfao

torn shuttle
#

wow

smoky oak
#

huh i already employed method chaining, thought i thought it to be the wrong wy to use it. Returning this seemed wrong somehow

torn shuttle
#

if only someone told him that right at the start!

grim ice
#

@Builder

#

lombok in sunglasses:

torn shuttle
grim ice
#

@Getter
@Builder
public class Widget {
private final String name;
private final int id;
}

Widget testWidget = Widget.builder()
.name("foo")
.id(1)
.build();

smoky oak
#

noted. So im going to write a constructor for those not nullable args and do the rest via method chaining

#

thanks

torn shuttle
#

np

grim ice
#

prob not

quiet ice
#

Is it safe to do instance comparision with worlds or should I rather do equality comparision?

torn shuttle
quaint mantle
#

from what i have seen on the forums people have said it doesnt work

#

ye

quiet ice
quaint mantle
#

like from a dispenser or something

torn shuttle
grim ice
#

@Builder(builderMethodName = "internalBuilder")
public class RequiredFieldAnnotation {
@NonNull
private String name;
private String description;

public static RequiredFieldAnnotationBuilder builder(String name) {
    return internalBuilder().name(name);
}

}
i love lombok

quaint mantle
#

its really weird how that hasnt been a thing for how ever many years

#

its a simple thing to add

quiet ice
grim ice
#

not in libraries or APIs tho

quaint mantle
#

i dont have access to the source of the jar thats used

torn shuttle
quaint mantle
#

packets?

viral crag
#

not sure, i'd have to search me

torn shuttle
#

at least I am pretty sure but I will say I historically always do .equals even though I don't have a real reason to do it

viral crag
#

guessing it had to do with someone doing somethin with item swaping

quaint mantle
#

how else would you do it then

viral crag
#

thats about the only time i can think of it being useful

torn shuttle
#

is it abstract?

echo basalt
#

wtf am I doing wrong?
SELECT serialized_object FROM ? WHERE serialized_id = ?

statement = connection.prepareStatement(SQL_DESERIALIZE_OBJECT);
statement.setString(1, table);
statement.setString(2, uuid.toString());
torn shuttle
#

ah yeah it is

echo basalt
#

Thing's giving off an invalid syntax error

quaint mantle
#

confusion 😄

#

thats the whole point, there is no event for tnt being primed

torn shuttle
#

doesn't it trigger an entityspawnevent

undone axleBOT
torn shuttle
#

that does sound like a bug

#

but there is the explosionprimeevent right

crisp steeple
#

tnt entity is kind of weird

torn shuttle
#

guess you can't tell if it's tnt from it?

#

wait no you can

crisp steeple
#

i could not for the life of me get a way to detect when someone left clicks a primed tnt

#

i tried pretty much everything

torn shuttle
#

did you try ExplosionPrimeEvent?

#

assuming explosionprimeevent works which it probably should all you need to do is get the entity and raytrace player hits

#

intersect the two and you're done

vocal cloud
#

Lol people thinking something isn't in the API like that

viral crag
#

re-reading it specifically, I would have suggested it because it specifically targets only HumanEntity and cuts out work

torn shuttle
#

sort of hard to tell just from the api comments

viral crag
#

but yeah it is abstract

torn shuttle
#

I do think it's hilariously phrased though

viral crag
exotic jetty
#
new Timer().scheduleAtFixedRate(new TimerTask() {
                @Override
                public void run() {
                    customizeshopGUI();//refresh inv
                    if (main.inventory.getItem(12) == null)return; //looks if item != null
                    if(main.inventory.getItem(12).getType() == Material.AIR) { // checks if item is air (normal empty slot is set to air)
                        System.out.println("air");

                        return;
                    }else { //if not air it runs this
                        System.out.println("called!!");
                        customizeshopGUI();
                        player.openInventory(main.inventory);
                    }
                }
            },0, 50000);

i got this code in the event on inventory click but it doesnt print annything? i added commands to make it more clear and it should just work if you wanna see the whole file check this link: https://paste.helpch.at/coxuwaferu.cs

viral crag
#

old minecraft version if your using material.air?

exotic jetty
#

no?

#

1.18

torn shuttle
exotic jetty
exotic jetty
vocal cloud
#

I wouldn't mention it if it was right

#

If it really is air that is

crisp steeple
#

seems like getItem(12) might return null and you're using .getType on it

vocal cloud
#

Aren't empty slots null?

#

?jd-s

undone axleBOT
viral crag
#

if they are air, should use isAir() since 1.18 has three types

vocal cloud
exotic jetty
#

okay

#

weird

#

i printed it

smoky oak
#

i believe the reason for that is that since a certain version a itemStack being set to size 0 or Material.AIR deletes it

vocal cloud
#

Mojang calls it vanishable i believe

exotic jetty
crisp steeple
#

that is not a valid statement

exotic jetty
#

what is good sintax?

#

here

crisp steeple
#

i mean .equals doesnt really matter in this case

#

but also are you getting an exception

quaint mantle
#

== for enums and primitives

crisp steeple
#

yea

exotic jetty
#

customizeshopGUI();//refresh inv
System.out.println("sorry");
if (main.inventory.getItem(12) == null)return; //looks if item != null
System.out.println("item is not null");
System.out.println("air");
System.out.println("called!!");
customizeshopGUI();
player.openInventory(main.inventory);
so just try this?

quaint mantle
exotic jetty
#

the timer does not seem to work 🤦

#

nvm

#

fixed it

mighty pier
granite owl
#

quick question anyone knowing how i can null terminate a string?

#

in java

#

like in c++

quaint mantle
#

suprisingly the forums information is outdated and it does in fact get called

tardy delta
viral crag
#

ends with \0

tardy delta
#

still dont know

granite owl
#

"Hello \0 World!"

#

becoming "Hello "

kind hatch
#

It’s a technique used in other languages to define the end of something.

viral crag
#

java has a problem with them, so I am not sure you can use them safely

granite owl
#

id really need it

#

xD

viral crag
#

you would have to manually do it and then hope java doenst implode

tardy delta
#

string.replace("\0", "")

#

:)

granite owl
#

"Hello World"

crisp steeple
#

what are you trying to do?

granite owl
#

the point of null terminating is to cut off whatever is behind the null terminator

crisp steeple
#

subString?

granite owl
tardy delta
#

its replacing the \0 no?

granite owl
#

and i want to be able to specify

tardy delta
#

the characters

granite owl
#

cutting off any further parameters

#

that might come

#

by null terminating them

viral crag
#

use regex

granite owl
crisp steeple
#

subString comes to mind

granite owl
#

\0 is supposed to delete whatever comes after it @tardy delta

granite owl
#

the string

viral crag
#

not exactly ...

crisp steeple
granite owl
#

technically it nulls the memory at its mem address of the primitive string

#

const char*

granite owl
granite owl
crisp steeple
#

if you really wanted you could just do .split("\0")[0]

exotic jetty
#

            new Timer().scheduleAtFixedRate(new TimerTask() {
                @Override
                public void run() {
                    customizeshopGUI();//refresh inv
                    if (main.inventory.getItem(12) == null)return; //looks if item != null
                    System.out.println("item is not null");
                    System.out.println("called!!");
                    customizeshopGUI();
                    player.openInventory(main.inventory);

                }
            },0, 100);

so it doesnt call it when i put a item in slot 12

#

i dont understand why?

viral crag
#

i believe they are trying to prevent adding to a command or injecting additional

tardy delta
#

whats wrong with bukkit scheduler?

granite owl
#

what i originally wanted to do was like String.replace("{break}", '\0') xD @crisp steeple but figured its not that easy

crisp steeple
#

i see

#

well you could just do .split("{break}")[0] in that case

granite owl
#

hm

crisp steeple
exotic jetty
#

the timer runs

#

i checked

viral crag
#

is curious why you do this: if (main.inventory.getItem(12) == null)return; //looks if item != null

exotic jetty
#

tbh idk

#

well nvm

crisp steeple
#

and you're sure if you put a print statement in the == null if statement it would print

exotic jetty
#

in the end

viral crag
#

aside from the inverted logic and forcing an early return, where is main supposed to come from?

exotic jetty
#

its my main class i have a static inventory in there

#

i define that in the function customizeshopGUI();

crisp steeple
#

check console for errors

exotic jetty
#

nothing

crisp steeple
exotic jetty
#

nah just testing

viral crag
#

so why do you call player.openInventory(main.inventory); if it is false?

crisp steeple
#

trying printing out all the contents of the inventory and see what happens

viral crag
#

the null test

crisp steeple
#

also just wondering why you're using a timertask instead of bukkit runnable

exotic jetty
#

that works so its not the point

crisp steeple
#

i mean it could be

#

bukkit runnables are designed to work within minecraft

exotic jetty
#

but i checked of the timer works and it did?

viral crag
#

if the timer is working, I am not sure you are accessing the inventory you think you are

crisp steeple
#

just because the timer works doesnt mean itll always act correctly ingame

exotic jetty
#

so how would you make a timer

kind hatch
#

I believe that Runnable#runTaskTimer() exists.

exotic jetty
# crisp steeple trying printing out all the contents of the inventory and see what happens
[20:29:02] [Server thread/INFO]: ItemStack{RED_WOOL x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"red","text":"Cancel"}],"text":""}}}
[20:29:02] [Server thread/INFO]: ItemStack{OAK_SIGN x 1, TILE_ENTITY_META:{meta-type=TILE_ENTITY, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"text":"Set the title"}],"text":""}, blockMaterial=OAK_SIGN}}
[20:29:02] [Server thread/INFO]: ItemStack{OAK_SIGN x 1, TILE_ENTITY_META:{meta-type=TILE_ENTITY, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"text":"Set the description"}],"text":""}, blockMaterial=OAK_SIGN}}
[20:29:02] [Server thread/INFO]: ItemStack{BLACK_STAINED_GLASS_PANE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"text":" "}],"text":""}}}```
crisp steeple
kind hatch
#

Keep in mind that the delay and period parameters for BukkitRunnables are in server ticks. Not milliseconds.

tardy delta
#

with the shheduler

crisp steeple
tardy delta
#

kek

exotic jetty
#

if i logg the whole inventory

viral crag
#

so you always force return according to your test ...

crisp steeple
#

i would really recommend switching to a bukkit runnable if you havent already

#

if you try to check or modify something between ticks that can break things

exotic jetty
crisp steeple
#

the actual instance

exotic jetty
#

?

crisp steeple
#

the instance of your plugin

#

main class that extends javaplugin

exotic jetty
#

so the name?

crisp steeple
#

no

#

the instance

exotic jetty
#

wtf do you mean with that?

viral crag
#

you can call multiple instances of your plugin

exotic jetty
#

should it just be: <plugin>

crisp steeple
#

<plugin> is your plugin object

earnest forum
#

?learnjava

undone axleBOT
crisp steeple
#

i dont know how else to put that

earnest forum
#

if you don't know what an instance is

#

don't learn spigot

#

yet

viral crag
#

you want to use the one it belongs to

crisp steeple
#

you can get the instance either with dependency injection or static getters

cyan compass
viral crag
#
    @NotNull
    public HandlerList getHandlers() { return handlers; }

   @NotNull
    public static HandlerList getHandlerList() { return handlers; }
    public static DimensionalOrder getPlugin() { return plugin; }
    public static DimensionalOrder getInstance(){ return instance; }
    public static DimensionalOrder getEvent(){ return event; }
#

nice discord ..

cursive loom
#

Hey do you know how I can put HEX color in a scoreboard ? Thats work for my title but thats didn't work for the objectives

            String title = ChatColor.of("#25bfbf") +"S" +ChatColor.of("#29bdad")+"e" +ChatColor.of("#2dbb9b")+ "a" +ChatColor.of("#32ba8a")+"O"+ChatColor.of("#36b878")+"f"
                    +ChatColor.of("#3bb767")+"S"+ChatColor.of("#3fb555")+"k"+ChatColor.of("#44b444")+"y";
            ob.setDisplayName(title);

            Score s2 = ob.getScore("§7│  §e▪ "+hexColor("#24E48A")+"Grade§f: " + SCOREBOARD_UTILS.getGroup(p));
            Score s3 = ob.getScore("§7│  §e▪ §aConnectés§f: §e" + co);
            Score s4 = ob.getScore("§7│  §e▪ §aPlayTime§f: §e" + SCOREBOARD_UTILS.playerTime(p));
            Score s5 = ob.getScore("§7│  §e▪ §bTempFly§f: §e" + SCOREBOARD_UTILS.getFly(p));
            Score s6 = ob.getScore("§7│§b");
            Score s7 = ob.getScore("§7│");
            Score s8 = ob.getScore("§7│§e");
            Score s9 = ob.getScore("§7│  §e▪ §aRôle§f: §e" + SCOREBOARD_UTILS.getRole(p));
            Score s10 = ob.getScore("§7│  §e▪ §aNiveau§f: §e" + level);
            Score s11 = ob.getScore("§7│  §e▪ §aArgent§f: §e" + SHORT_MONEY.getShort(MoneyAPI.getMoney(p)));
            Score s12 = ob.getScore("§7│§0");
            Score s13 = ob.getScore("§7│ §6VoteParty§f(§e" + 0 + "§f/§750§f) §7━");
crisp steeple
#

or make your own system that only stores the coordinates

#

and then converts it to a location

earnest forum
crisp steeple
#

(second option is best if you are planning on having many locations stored)

earnest forum
#

and then get the x,y,z variables from the converted location

cyan compass
#

So get location in the arena and then call the xyz from my converted location?

earnest forum
#

yes

#

can you send your code

#

I wanna see how you are doing it

cyan compass
#
    public Location stringToLocation(String location) {
        String[] str2loc = location.split(",");
        Location loc = new Location(plugin.getServer().getWorld("arena"),0,0,0);

        loc.setX(Double.parseDouble(str2loc[1]));
        loc.setY(Double.parseDouble(str2loc[2]));
        loc.setZ(Double.parseDouble(str2loc[3]));

        return loc;
    }```
earnest forum
#

why not just set the variables on initialize?

cyan compass
#

No idea i somewhat copyed it from that thread

crisp steeple
#

you're starting the array index at 1?

earnest forum
#

and that

#

arrays start at 0

crisp steeple
cyan compass
#

0 was meant to be where "arena" is

cyan compass
crisp steeple
#

well that method will only work if you're storing your location like "world,x,y,z"

cyan compass
#

Yeah...

#

which i'm not :P

crisp steeple
#

how are you then

cyan compass
#
  SouthTeamSpawn: "0, 44, 65"
  NorthTeamSpawn: "0, 44, -65"```
earnest forum
#

start at 0 then

cyan compass
#

That's the config

earnest forum
#

also cut the spaces

#

don't need them

cyan compass
#

wdm

earnest forum
#

"0,44,4" over "0, 44, 4"

cyan compass
#

What's wrong with being able to read it

crisp steeple
#

because then youll have to filter it out later

earnest forum
#

I'm not 100% but I don't think it works with parsing doubles

cyan compass
#

ah

#

ok

#

so this
SouthTeamSpawn: "0,44,65"
NorthTeamSpawn: "0,44,-65"

#

then this for the method

    public Location stringToLocation(String location) {
        String[] str2loc = location.split(",");
        Location loc = new Location(plugin.getServer().getWorld("arena"),0,0,0);

        loc.setX(Double.parseDouble(str2loc[0]));
        loc.setY(Double.parseDouble(str2loc[1]));
        loc.setZ(Double.parseDouble(str2loc[2]));

        return loc;
    }```?
earnest forum
#

if you wanna make it easier store a list of doubles instead

#

yeah like that

crisp steeple
#

should work but you might want to filter out the spaces

cyan compass
#

I cut the spaces

crisp steeple
#

ok then yeah it should be fine

earnest forum
#

but when you create the location you can just do

new Location(world, loc1, loc2, loc3)

#

save some lines

#

excuse the formatting I'm on my phone

cyan compass
#

?

#

ohh instead of doing set?

earnest forum
#

yep

cyan compass
#

I was wondering why the thread didn't do that

exotic jetty
#

figgerd it out it doesnt refresh the invetrotory bc it cant see it

#

bc i dont define the item when its selected

cyan compass
#

So instead of setting i can cut those and put the parses in place of the 0s?

earnest forum
#

yep

#

I think the threads old considering it's on the bukkit forums

smoky oak
#

is the scheduler reset over server reboot or can i schedule a task for a real-time day of ticks in the future and let the server restart at midnight

cursive loom
viral crag
earnest forum
#

it's from 2012

cyan compass
crisp steeple
smoky oak
#

how would that help?

cyan compass
#

so this should be better:

    public Location stringToLocation(String location) {
        String[] str2loc = location.split(",");
        return new Location(plugin.getServer().getWorld("arena"),Double.parseDouble(str2loc[0]),Double.parseDouble(str2loc[1]),Double.parseDouble(str2loc[2]));

    }```
#

Indentation is off cause message length...

#

Do i need new?

#

removing it says yes so i shall keep it

earnest forum
#

ye

cyan compass
#

So this should return a new location in the world of arena?

earnest forum
#

yes

cyan compass
#

Awesome

coarse finch
#

can i use /reload to test new builds or should i restart the server

viral crag
#

restart

coarse finch
#

ok

#

also

#

where should i put config.yml inside the jar?

quaint mantle
quaint mantle
coarse finch
#

i have it in resources but it cant find it

quaint mantle
#

whut

coarse finch
#

The embedded resource 'config.yml' cannot be found in plugins\generalutils-1.0-SNAPSHOT.jar

quaint mantle
#

why is main there

coarse finch
#

it has the plugin.yml in it

quaint mantle
#

should look like this

#

src/main/
| java/
| resources/

coarse finch
#

ok

#

wait

#

do i need to add something else in like plugin.yml for the config to work

quaint mantle
#

no

coarse finch
#

so i just create the file, and use it for config

#

but it doesnt work

mighty pier
#

i have this in my on enable: if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { new SomeExpansion(this).register(); } and this is my someexpansion class: https://paste.md-5.net/ogagulugoj.java, i put %disabler_kills% in the scoreboard and its spamming [18:57:28 WARN]: org.apache.commons.lang.UnhandledException: Plugin Scoreboard-revision vR4 1.1 RELEASE generated an exception while executing task 85 at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NullPointerException in my console

cyan compass
#

Is there a way of saving a resource to a different folder then the normal data folder?

quaint mantle
#

yes

#

1 sec

#

?jd-s

undone axleBOT
coarse finch
#

so why cant it find the config.yml file?

quaint mantle
coarse finch
#

do i need to add it in gradle?

smoky oak
#

JavaPlugin::getConfig() ?

quaint mantle
earnest forum
#

intellij has an option to add it to your build path

quaint mantle
#

wait

#

nvm

mighty pier
#

yes

quaint mantle
# mighty pier yes

you're still loading this class despite the fact those classes might not exist

mighty pier
#

what that mean

coarse finch
mighty pier
#

explain in monkey language

quaint mantle
mighty pier
#

hm

quaint mantle
#

import me.clip.placeholderapi.expansion.PlaceholderExpansion;

#

class must exist!

coarse finch
#

I GOT IT

quaint mantle
#
        if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            //  vvvvvvvvvvvvv class is loaded no matter what! bad stuff happen!!!
            new SomeExpansion(this).register();
        }
coarse finch
#

i put it in the wrong resources folder

mighty pier
#

oh yes

#

but without it it no work

coarse finch
#

i think i put it in gradle resources or smth

quaint mantle
#
Class.forName("me.frandma.disabler.SomeExpansion").invoke(this).register();
#

or something like that

coarse finch
#

ok lets see if it works

mighty pier
#

ok

coarse finch
#

fuck

#

it didnt work

quaint mantle
#

nice

mighty pier
#

e

quaint mantle
#

try catch it

quaint mantle
mighty pier
#

what then

quaint mantle
#

surround it with try catch

#

this is

coarse finch
#

java.lang.ExceptionInInitializerError: null it is ```java
public static void setup() {
file = new File(Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("GeneralUtils")).getDataFolder(), "config.yml");

if (!file.exists()) {
    try {
        file.createNewFile();
    } catch (IOException e) {
        // oof
    }
}
configFile = YamlConfiguration.loadConfiguration(file);

}```

quaint mantle
#

basic java

quaint mantle
coarse finch
#

oh

#

well

#

intellij said use it

quaint mantle
#

intellij dumb dumb

coarse finch
#

so remove it?

mighty pier
#
            Class.forName("me.frandma.disabler.SomeExpansion").invoke(this).register();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }``` like that?
quaint mantle
#
Plugin plugin = Bukkit.getPluginManager().getPlugin("GeneralUtils");
if (plugin == null) {
    Bukkit.getLogger().severe("GeneralUtils was not found!");
    return;
}
opal juniper
coarse finch
#

oh

opal juniper
#

it just moved the exception

mighty pier
quaint mantle
#

i think in never java versions you have to get the constructor

crisp steeple
#

newInstance p sure

opal juniper
#

getDeclaredConstructor

#

or something

coarse finch
opal juniper
#

what code

mighty pier
#

what is invoke

quaint mantle
#

if the plugin isnt found it tells the user and returns out of the function

coarse finch
#

ok

quaint mantle
#

try newInstance instead of invoke

mighty pier
#

k

quaint mantle
#

wait no

coarse finch
#

these thigns on the side only work if theres one of them in the file

crisp steeple
#

what

quaint mantle
# mighty pier k
Class.forName("me.frandma.disabler.SomeExpansion").getConstructor(this.getClass()).newInstance(1);
#

try this

mighty pier
quaint mantle
#

catch it

coarse finch
#

java errors suck

quaint mantle
#

no

#

your code just isnt working

coarse finch
#

yes'

mighty pier
#
            Class.forName("me.frandma.disabler.SomeExpansion").getConstructor(this.getClass()).newInstance(1);
        } catch (ClassNotFoundException | NoSuchMethodException e) {
            //monke
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }``` this happen because newinstance was red
quaint mantle
#

java errors are some of the best you can get unless you're dealing with reflection stuff

quaint mantle
crisp steeple
#

maybe we should just remove all exceptions from java

#

that would fix all issues

coarse finch
#

well they could be more descriptive, instead of saying just the line calling the method that errors

quaint mantle
#

if the code cant error, there are no errors

quaint mantle
#

it tells you exactly where its going wrong

coarse finch
#

no

quaint mantle
#

you cant expect the language to hold your hand throughout every single invocation

mighty pier
#

when the newinstance

coarse finch
#

oh what

#

it says its caused by the plugin being already initialized

#

Caused by: java.lang.IllegalArgumentException: Plugin already initialized!

quaint mantle
#

you're instantiating your main plugin class

#

you cant do that

coarse finch
#

huh

mighty pier
#

what

smoky oak
#
true &= false == true,
false &= false == false``` correct?
grim ice
#

ur class that extends JavaPlugin

#

should be a singletone

#

initialized by Bukkit

coarse finch
# quaint mantle you cant do that
private static GeneralUtils generalUtils = new GeneralUtils();

private static File file;
private static FileConfiguration configFile;

public Config(GeneralUtils generalUtils) {
    Config.generalUtils = generalUtils;
}```could this be it
mighty pier
grim ice
#

ye

mighty pier
#

oh that wasnt for me

quaint mantle
coarse finch
#

ye

#

but i neeed it to get the logger

quaint mantle
#

no you dont

#

?di

undone axleBOT
quaint mantle
coarse finch
#

the tutorial lied!

mighty pier
#

yes

quaint mantle
#

i dont feel like explaining all of it to you

mighty pier
#

where tutorial at

crisp steeple
mighty pier
#

ty

coarse finch
crisp steeple
#

that’s not a lie

quaint mantle
grim ice
quaint mantle
crisp steeple
#

there’s a ton of tutorials out there people will just follow blindly and then have no idea how to work with it afterwards

quaint mantle
#

why does java always like to be different

grim ice
#

Ll

#

lol*

quaint mantle
#

function, method

#

error, exception

#

match, switch

#

shit

#

sorry

#

thats annoying

viral crag
#

hahahaha

quaint mantle
#

i didnt see ur message

grim ice
#

an error fucks up the program

viral crag
#

i said you dont want the reason

grim ice
#

and should be thrown by the jvm only

#

like OOME

#

aka an unrecoverable situation

quaint mantle
#

thats the first time thats happened to me, accidentally deleting someones message

quaint mantle
grim ice
#

lol

#

while exceptions are less KALM than errors (PANIK)

#

therefore handling errors is not something you wanna do usually

quaint mantle
#
let option: Option<i32> = None;
//                    vvvvvv panic!
println!("{}", option.unwrap());
grim ice
#

frick is dis

#

lul

#

js?

quaint mantle
#

rust

grim ice
#

ah

quaint mantle
#

rust is the best language

grim ice
#

if java didnt exist then yes

#

but its better than some

viral crag
#

no..

grim ice
#

(opinion)

quaint mantle
grim ice
#

might not be a fact

#

rust being better might be a fact

quaint mantle
#

rust can do everything java can do and its the fastest and most memory safe langauge

grim ice
#

but my opinion isnt that

#

sorry

quaint mantle
#

java is just convenient because it runs on almost all platforms

viral crag
#

slap down some HDL and see how it performs for you

#

"VHDL is a dataflow language in which every statement is considered for execution simultaneously" tasty stuff

#

unless you like the verilog version instead

crisp steeple
quaint mantle
#

rust > you

ivory sleet
#

mye rust is pretty much the future

quaint mantle
ivory sleet
#

ye indeed

viral crag
#

different purposes than c++

grim ice
#

why r u making me

#

want to learn rust

#

is it oop

viral crag
#

yes

quaint mantle
#

which is basically oop

grim ice
#

if it has a porton of oop

#

then ig ill try it

#

Great

#

ill start tmrw

quaint mantle
#
pub struct Options {
    pub action: String,
    pub path: String,
}

impl Options {
    pub fn new(action: String, path: String) -> Self {
        Self {
            action,
            path,
        }
    }
}

fn require_string(flag: &str, iter: &mut impl Iterator<Item = String>) -> Option<String> {
    match iter.next() {
        Some(value) => Some(value),
        None => {
            println!("flag `{}` requires an argument", flag);
            None
        }
    }
}

rust code

crisp steeple
#

i’ve wanted to learn rust for a while but it’s always just seemed to complicated

grim ice
#

snake case

#

not a good sign but ok

crisp steeple
#

(plus my pc doesn’t have enough storage to install the compiler)

quaint mantle
#

does your pc have 1gb of storage

crisp steeple
#

pretty much yeah

quaint mantle
#

anyways only time its complicated is when borrowing stuff and lifetimes

ivory sleet
#

which is still more simple than what u'd have to do in cpp arguably

quaint mantle
#

indeed

crisp steeple
#

i think my main drive has like 40-100 mb left and external only has 700

grim ice
#

ive always had interest in rust tbf

viral crag
#

"If you are looking for a well-supported and framework-rich language, you will probably choose C++. In other cases, you might want your code to be extremely safe, avoid memory leaks and other undefined behavior then start learning Rust."

quaint mantle
#

rust literally has a crate for everything

#

im sure i can find a hello world crate

viral crag
#

"Dart is a client-optimized language used in API development and in building mobile applications that require complex logic. It is in reality a concise and expressive language and is also more productive."

quaint mantle
#

ive never heard of dart

viral crag
#

it is the main competetor to rust

ivory sleet
#

idk bout dart

#

like it has asynchronous semantics

quaint mantle
#

dart looks like shit

ivory sleet
#

but is not multi threaded

#

or well

#

that part is not exposed to the language users

viral crag
#

By design, Dart is a single-threaded programming language. That's mean we have asynchronous code across application. When a program starts, it creates something that is called Isolate. When isolated created, the microtask manager executes all events asynchronously.

quaint mantle
#

seems unsafe

ivory sleet
#

yes

viral crag
#

sort of

ivory sleet
#

but unlike Java which has a thread api directly exposed to language users

#

which is weird

#

since Dart is kinda Java + JavaScript combo

viral crag
#

most processors these days now have builtin thread handling

ivory sleet
#

mye

quaint mantle
#

send dog pics pls

ivory sleet
#

lol dont have any on my pc as of now

grim ice
#

why is there !

#

in println

viral crag
#

my personal thought is that the language that will surplant c++ is likely the main one that gets used for multi-state processors

quaint mantle
#

if u dont wanna use the macro

grim ice
#

tf is that

quaint mantle
#

its just

#

code

#
fn println<D: AsRef<str>>(message: D) {
    io::stdout().write_all(message.as_ref().as_bytes()).ok();
    io::stdout().flush().ok();
}
#

you can do this or just use println!

ivory sleet
quaint mantle
#

dude

#

autopilot got all of this from

#

1 sec

#

thats actually really impressive

viral crag
ivory sleet
#

yes haskell is nice

viral crag
#

haskell implementation of the quipper language to prepare a superposition

ivory sleet
#

but like sometimes statefulness helps you go much faster without losing too much brain cells

#

and like for things like IO you'd need a monad

#

which in itself can become a bit complicated

#

since you're doing everything purely from the outside (but yes some stuff is impure altho kept away from the user's consciousness)

viral crag
#

hahahaha

#

well you have a potential unlimited number of state results rather than a boolen

coarse finch
#

uhhh

#

intellij froze

#

:)

quaint mantle
#

Happens on potato pc's

coarse finch
#

mines not poatato

#

i have an i7

#

its not unfreezing

#

what do i do

viral crag
#

kill process, something is eatting up java ram\

coarse finch
#

ok

viral crag
#

i cant run discord+spotify+intellij+edge together

coarse finch
#

how much ram u got?

viral crag
#

system says 16gb on this laptop

coarse finch
#

hmm

#

i also have 16

#

whats the best way to update config file?

#

should i overwrite it or

ivory sleet
#

I usually use config versions

coarse finch
coarse finch
ivory sleet
#

well if the config version is older, I just set default values for every key thats missing

coarse finch
#

ok, but what about comments?

ivory sleet
#

ye well spigot supports comments

quiet ice
#

How do I set the timeout of a repository in maven? Some random repository is only partially responding at causes the build time to shoot up to 15 minutes which is not nice at all

ivory sleet
#

gradle or maven?

#

oh

coarse finch
#

also how can i create a permission for /gu reload without setting it for /gu

ivory sleet
#

nvm im blind lol

ivory sleet
coarse finch
ivory sleet
#

declare one in plugin.yml

coarse finch
#

also is online players the default tab completion when there is none set?

ivory sleet
#

yes

coarse finch
#

ok

ivory sleet
#

if you return null

#

then it delegates to the Command::tabComplete which returns that

coarse finch
#

well my custom tab completion isnt working

#
public class InfoTabCompleter implements TabCompleter {

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equals("bring")) {
            List<String> list = new ArrayList<>();
            list.add("reload");
            list.add("info");
            return list;
        }
        return null;
    }
}```
ivory sleet
#

tab completion is a bit complicated at first

#

ye

#

well

coarse finch
#

oh i know

ivory sleet
#

you need to take arguments into consideration

coarse finch
#

yeah

#

can i just check if args.length() > 1?

ivory sleet
#

well

#

what I mean is

#

lets say someone tab completes at /bring rel

#

now that'd result in /bring relreload

coarse finch
#

Oh

coarse finch
#

how wouldi put this string in teh config.yml? &4You don't have permission to use this!

#

yes

#

it works like normal

#

wait i see what your saying now

#

shouldnt be too hard to fix

ivory sleet
#

mye

#

you can use StringUtil::copyPartialMatches

coarse finch
#

then how would i put the ' in the string

#

is there an escape character like in python?

crisp steeple
#

\

ivory sleet
#

either "don't" or 'don''t' (two single quotes)

coarse finch
ivory sleet
#

''

#

two single ones

spring pike
#

I got a Map<String, List<UUID>>
is it possible to get the String of a UUID?

ivory sleet
#

ye

#

should be possible

eternal oxide
#

Only by iterating

coarse finch
#

in the plugin.yml can i add subcommands like yml commands: generalutils: reload:

#

ok

spring pike
#

i dont't think arguments are needed for the command to work

ivory sleet
#

well those are the options if you wanna have a string that contains a single quote apart from unicode escaping

coarse finch
#

tehn how can i create a permission node

ivory sleet
#

else you get a yaml parse error

coarse finch
#

that creates a node?

#

then how would i make it where i can see the permission in the pm?

eternal oxide
#

if you want to use " inside a String you have to escape it

ivory sleet
#

you declare permissions in plugin.yml but thats just to define properties of them, technically every permission already exists

coarse finch
eternal oxide
#

pm?

coarse finch
#

permission manager

ivory sleet
#

literally isnt

eternal oxide
#

yes, your permissions have to be registered

ivory sleet
#

or well

#

if we refer to the proper single quote '

coarse finch
ivory sleet
#

well zacken ’ is not '

eternal oxide
#

you can define any permissions you want in your plugin.yml

eternal oxide
#

check the documentation on spigot for plugin.yml

ivory sleet
#

key: ’blah’ would not be parsed to blah but ’blah’

coarse finch
ivory sleet
#

thats literally invalid

#

by definition

coarse finch
viral crag
#

the syntax

ivory sleet
#

bruh

#

r u trolling?

#

myes

#

it totally works

chrome beacon
#

That yaml parser works great

ivory sleet
#

I mean

#

we can try 50 different parsers

#

each one will yield an error by definition

#

uk what im gonna write a unit test that proves you wrong using snake yaml just to show you

lavish hemlock
#

In English, please?

#

This server is English-only though

chrome beacon
#

^

lavish hemlock
#

You can't just, deny the rules?

hasty prawn
#

I think he just did peepoRiot

lavish hemlock
#

Look at general Spigot rules

#

And yes those apply to the Discord as well

grim ice
#

i refuse

#

rules

#

L

viral crag
#

dont worry, it just says he's wrong

#

we can get lawyer mfnalex over here for you

lavish hemlock
#

#general description also specifies English-only

#

Yeah but it applies everywhere else

#

It's primarily a reminder there bc it's the first place people will chat

hasty prawn
#

Can we speak in Java?

lavish hemlock
#

Well considering Java is not a spoken language, sure.

hasty prawn
#

System.out.println("Hi Spigot server");

noble lantern
#

When adding an attribute modifier (SPEED one) is this expected behaviour to multiple the attribute lore like this?

#

(its being added to a pickaxe)

hasty prawn
viral crag
hasty prawn
#

Javanese lmao

lavish hemlock
#

Well

#

Java isn't the spoken language tho

viral crag
#

It is the native language of more than 98 million people

lavish hemlock
#

Javanese is

#

Java is the place where Javanese is spoken

viral crag
hasty prawn
#

Maow is a fun ruiner hypixel_sad

noble lantern
viral crag
#

so javanese is good here

ivory sleet
#
public class YamlTest {
    Yaml yaml;

    @BeforeEach
    void setup() {
        yaml = new Yaml();
    }

    @RepeatedTest(1_000)
    void givenSingleQuote_doesThrow() {
        var strToTest = """
test: '
""";

        this.yaml.load(strToTest);
        Assertions.assertTrue(true);
    }
}

viral crag
#

ooo

ivory sleet
hasty prawn
#

I guess by default it's just all of them

noble lantern
#

ah yes i see now

#

ty 🙂

ivory sleet
#

@quaint mantle there it is

#

I'd say its probably a bad parser from the site you were using

#
    @Test
    void givenSingleQuote_doesThrow() {
        var strToTest = """
test: '
""";

        this.yaml.load(strToTest);
        Assertions.assertTrue(true);
    }

    @Test
    void givenSingleQuote_doesThrow0() {
        var strToTest = """
test: 'text
""";

        this.yaml.load(strToTest);
        Assertions.assertTrue(true);
    }

    @Test
    void givenSingleQuote_doesThrow1() {
        var strToTest = """
test: text'
""";

        this.yaml.load(strToTest);
        Assertions.assertTrue(true);
    }
#

the last one passes it seems like

#

but not the first or middle one

coarse finch
#

im gonna ask this again, whats the best way to update my config? should i pull out every value, reset, and replace the values?

ivory sleet
#

truly

viral crag
#

it possibly ignores it because its outside of a pair and does not contain anything

ivory sleet
#

ye

coarse finch
#

and reset the values?

ivory sleet
#

lets see if I add another node under

#

well

#

test: text'
test2: true

#

that still worked

#

mye

#

it just ignores it

viral crag
#

in that case it treated it as a char

ivory sleet
#
    @Test
    void givenSingleQuote_doesThrows() {
        var strToTest = """
test: text' #comment
test2: true #comment
""";

        this.yaml.load(strToTest);
        Assertions.assertTrue(true);
    }
#

passes

#

or well print?

coarse finch
ivory sleet
#

I mean

#

it will just print the input

viral crag
#

possibly a special case for strings containing 's or s'

ivory sleet
#

lets see

coarse finch
#

it has 40 stars

ivory sleet
#

{dope: s'}

#

it keeps the quote

#

zacken

#
        Yaml yaml = new Yaml();
        Object load = yaml.load("""
                dope: s'
                """);
        System.out.println(yaml.dump(load));
coarse finch
#

are we staill arguing over yaml lol

ivory sleet
#

experimenting more like

#

but ye

#

cuz yaml specs is a cluster fuck basically

viral crag
#

i would guess it will fail on nonstrings as its not an expected usage

ivory sleet
#

ye lets see

coarse finch
#

how can i loop all the values in my config

ivory sleet
#

test4: []'

#

this failed

#

that worked

#

as well as with booleans

viral crag
#

did it put it in as a char?

ivory sleet
#

config.getValues()

#

ye

knotty gale
#

hey so I have a schedulesyncrepeating task and I want to know how to cancel the task using a command

#

like /cancel

ivory sleet
#

by specification parsers should recognize false and true as boolean values

ivory sleet
ornate heart
viral crag
ivory sleet
#

^

viral crag
#

true and false are just conventions

knotty gale
viral crag
#

not always

#

many time it is something vs nothing

knotty gale
#

also I dont think it is what I am doing to code is wrong. I think its the fact that I am puting 2 commands in one class

ivory sleet
knotty gale
#

is wrong

ornate heart
ivory sleet
#

you wanna use runTaskTimer instead

#

as it gives you a BukkitTask instance as opposed to the one you're using now which provides a mere int

knotty gale
#

but the problem is that the thing wont work because the command doesnt work

ivory sleet
#

mind sharing the command code?

knotty gale
#

sure

viral crag
#

might simply be not canceling as a new one is created

knotty gale
#
public boolean onCommand1(CommandSender sender, Command cmd, String commandLabel, String[] args) {
        if(commandLabel.equalsIgnoreCase("cpc")) {
            Player player = (Player) sender;
            if(!player.isOp()) return false;
            else {
                getServer().getScheduler().cancelTask(PlayClock);
            i = 25;
             for (Player players1 : Bukkit.getOnlinePlayers())
             {
                 players1.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.RED + "PlayClock " + ChatColor.BOLD + "CANCELLED"));
                 players1.playSound(players1.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1);
                 
             }
            
        }
        }
        return false;
    
}

what I had origannly instead of "timer" its playclock

ivory sleet
#

onCommand1

#

well

#

pretty sure that 1 should disappear

knotty gale
#

lol

#

but now it is a duplicate method. do I have to put it in another class?

#

I didnt mean to put the 1 there though

ivory sleet
#

?paste the classes perhaps

undone axleBOT
knotty gale
#

ok

#

well now my variables (that are public) wont work

#

maybe they will hold on

#

nvm they wont

#

I cant redifine the variable right

viral crag
#

...

knotty gale
#

im new sorry

viral crag
#

we really need to see what you are talking about

ivory sleet
#

no worries, but having some basic understanding of Java's "grammar" and its concepts would help you a lot

knotty gale
#

yeah ik

knotty gale
#

without changing the properties of it

tall dragon
#

?di

undone axleBOT
knotty gale
#

ty

ivory sleet
#

Usually you attach variable data to objects that you then pass around with (other) variables

knotty gale
#

oh ok

lavish hemlock
#

Hm

#

Probably the smartest beginner I've seen in here yet.

#

...and their profile is Shrek-themed.

tall dragon
#

insane minecraft enthusaist tho 😄

viral crag
#

hardcore afk - must be a gens player

tall dragon
#

true dedication

viral crag
#

hmm, why did i do this ... - java logic hurts my head

knotty gale
#

I am a minecraft sports player (dont judge)

dusk flicker
#

judged

tall dragon
#

🧑‍⚖️

viral crag
#

minecraft sports? - me looks that up

knotty gale
#

its pretty weird

#

but hey with my very bare bones knowledge they gave me 20 bucks to make a single plugin lmao

sterile token
#

Placeholders.setPlaceholders() can be used on console?

ornate mantle
#

how would i remove a single type of item from an inventory?

sterile token
ornate mantle
#

dont itemstacks have an amount value

#

which differs between different itemstacks

tall dragon
#

this one doesnt care abt that

ornate mantle
#

why tf hasnt it been working for the past hour wtf

tall dragon
#

my bad

#

use the material one

#

the one i linked will care

ornate mantle
tall dragon
#

this one should work for u

ornate mantle
#

no

#

no

#

i have a custom item that has to be removed

small lynx
#

There is a guide to mysql?

ornate mantle
#

it has lore stuff

noble lantern
#

then you need to find that item and remove it manually by setting its amount to 0

small lynx
#

?mysql

viral crag
noble lantern
#

you should have a getMyCustomItemType(ItemStack) method for your plugins API if your implementing custom items correctly

ornate mantle
#

yeah i really should

viral crag
ornate mantle
#

so i have to parse through each item in the inventory

#

clone it

#

set the amount of the clone to 1

tall dragon
#

why clone it?

noble lantern
#

dont clone if your trying to remove

ornate mantle
#

im cloning the item so i can set the amount to 1

#

without messing up the original item

tall dragon
#

just loop -> check if its ur item, set to 0 if amt is equals than 1, else remove 1

noble lantern
#

^

ornate mantle
noble lantern
#

cloning is if you want to modify the item without actually changing it in the ivnentory

tall dragon
#

pdc

ornate mantle
#

i cant just use .equals

noble lantern
#

?pdc

tall dragon
#

use a pdc tag

viral crag
#

didnt you give it an id?

ornate mantle
#

its to differentiate between regular and non regular items

ornate mantle
#

what im using

tall dragon
#

so whats the problem...

ornate mantle
#

i really dont know anymore

#

its 1 am

noble lantern
#

so then its easy just loop through inv -> if item has tag -> set amount to 0

grim ice
#

rust sems cool

viral crag
#

lack of coffee!

grim ice
#

but whats the diff between i32 and u32

viral crag
grim ice
#

wat

viral crag
#

A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]. An unsigned integer is a 32-bit datum that encodes a nonnegative integer in the range [0 to 4294967295].

#

says IBM

grim ice
#

OH RIGHT

#

I know that

#

frostalf told me that months ago

noble lantern
#

ah i dont blame you for forgetting something frost said

#

jkjk

grim ice
#

LMAO

viral crag
#

i do not fully recall but in most cases u32 should be an int. Might be a double though as well

crude loom
#

I want to set the lore of an item such that it would display a players hunger, i mean not a number, with the logo of the eaten chicken
What would be the way to approach that?

viral crag
#

a quick check says it being a double is not yet fully implemented

small lynx
#

There is a guide to mysql

#

Because i want to implement that in my pluign

noble lantern
ornate mantle
viral crag
crude loom
ornate mantle
#

what

noble lantern
#

OHH

ornate mantle
#

lmao

noble lantern
#

AttributeModifiers

crude loom
#

😂

noble lantern
#

was about to say picture would be cool too

grim ice
noble lantern
#

you can do it with Fonts

grim ice
#

itll be a

#

u32

ornate mantle
#

tf is an attributemodifier

noble lantern
#

Allows you to modify attributes an an item without accessing NBT

#

ie

#

attack speed

viral crag
noble lantern
#

hunger amount

#

attack damage, movement speed etc

ornate mantle
#

i think they want the item lore to show the player hunger

noble lantern
#

yes

#

attributes do that

grim ice
#

xd

viral crag
ornate mantle
#

whast th efuck

grim ice
#

its just free space

#

free another 2.1b capacity

#

for no cost

crude loom
viral crag
# grim ice xd

you will have to remember you are using unsigned in all your math functions though

ornate mantle
#

i really need to comment my code

#

or like slightly optimise it so im not copypasting the same method over and over again with slight modifications

muted sand
#

can you "hot swap" a world?
i mean, copying the world files without unloading it before hand?

lavish hemlock
#

I mean you can copy any file that's in use, afaik

crude loom
viral crag
#

try it while streaming so we can watch!

muted sand
viral crag
#

whats to corrupt if you moved the files?

muted sand
#

good point

viral crag
#

i just want to see if it generates randomly or burns up the server

quaint mantle
#

Theoretically, would it be possible to load an unknown amount of commands from the config.yml?
You would be able to add as many as you want, each with a single string they will respond with
So the file would be like:

Commands:
    command1: “Text response”
    command2: “Text response 2
quaint mantle
#

Ok, thanks
That’s all I really needed before I wasted a bunch of time trying to do something that won’t work

quaint mantle
urban spire
#

doe anyone here use gradle, becuse i ran into an issue and cant find a soltuon

viral crag
#

you still need to implement the commands

quaint mantle
urban spire
#

basicly, i have two gradle modules,
I have a build.gradle in each module, a root level build.gradle, and a root level settings.gradle

I'm trying to import modulea into moduleb, i found a stackoverflow answer, but it didnt work and it seems to be outdated as it used stuff like compile and stuff, which doesnt even exist anymore

true jacinth
#

Hey, how do you make Intellij IDE interact with minecraft? for example when I change something in the code and automatically applies to the server

urban spire
#

one second

true jacinth
urban spire
urban spire
#

i see ins but its not doing anything

viral crag
#

do you need to use your function key to access it?

urban spire
#

ah one second

#

oh wow, yep thats works ^-^ i see the context menu

#

wow this is amaing, its just like NuGet

viral crag
#

this is about the only easy-ish way to sort out interdependancies

urban spire
#

ah no image perms

#

but i see a dependency search and my packages on the left, im not seing a way to add terminal into scratches

sterile token
#

Its possible to do a server ping event through spigot to know if server is down or not?

grim ice
#

sooo

#

errors and exceptions in java

#

are in rust but theyre called

#

Result::Errs

#

and Panics

#

nice

lavish hemlock
#

It's actually basically impossible to compare Java and Rust error-handling

grim ice
#

lol

#

exception handling*

lavish hemlock
#

panic is not a thing that can be properly handled (I believe you can listen to it but there's no way to prevent it)

grim ice
#

u dont handle errors

#

xd

lavish hemlock
#

I

#

I don't want the fuckin'

#

semantical bullshit

#

uhh

#

anyway