#help-development

1 messages · Page 145 of 1

torn oyster
#

oh okay

#

is there a way to get org.bukkit.Color from a string?

#

i don't wanna have to get the rgb codes for my config

tall dragon
#

well Color implements ConfigurationSerializable

#

you could just use that

high pewter
#

I've only just realised that you can't actually even copy run configurations between projects (unless I code my own IDEA plugin for it which I cba to do) so I have to set it all up every time I create a new project 😭

fresh timber
#

bump

subtle folio
#

I have a system for adding teams to a player, is there any way I can fix new players not being able to see old player's teams?

// Create scoreboard and teams
    public static void setNametags(Player p) {
        p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());

        for (Rank rank : Rank.values()) {
            Team team = p.getScoreboard().registerNewTeam(rank.getOrderSymbol() + rank.name());
            team.setPrefix(ChatColor.translateAlternateColorCodes('&', rank.getDisplay()));
            team.setColor(rank.getColor());
        }
    }

    // Assign player to their team
    public static void newTag(Player p) {
        Random r = new Random();
        Rank rank = Rank.values()[r.nextInt(Rank.values().length)];
        for (Player target : Bukkit.getOnlinePlayers()) {
            target.getScoreboard().getTeam(rank.getOrderSymbol() + rank.name()).addEntry(p.getName());
        }
    }

    // Remove player from all scoreboards
    public static void removeTag(Player p) {
        for (Player target : Bukkit.getOnlinePlayers()) {
            target.getScoreboard().getEntryTeam(p.getName()).removeEntry(p.getName());
        }
    }```
jaunty crag
#

wdym

subtle folio
# jaunty crag wdym

like player 1 joins and player 2 joins, player 1 can see the team and nametag of player 2 but player 2 can only see their nametag and team and not player 1's

jaunty crag
#

sorry, i dont know

subtle folio
#

All good

sterile token
#

Ntdi

#

You have to update the players

#

Im not sure how its done

#

But every time a player joims you need to update the nametags

torn oyster
#

java.lang.IllegalArgumentException: Invalid key. Must be [a-z0-9/._-]: PROTECTION_ENVIRONMENTAL

#

bruh

#

oh

#

wait it should be lowercase, huh

echo basalt
#

you seem to be using minecraft namespaced keys for enchantments

#

use minecraft names

unborn kiln
#

Hey, is there a way to disguise an entity such as a zombie as an EntityPlayer?

torn oyster
#
    public void randomTP(Player p, World w) {
        Random rand = new Random();

        int bounds = (int) (Math.round(w.getWorldBorder().getSize()) - 5); // padding

        int x = rand.nextInt(bounds * 2) - bounds;
        int z = rand.nextInt(bounds * 2) - bounds;
        Location loc = new Location(w, x, w.getHighestBlockYAt(x, z) + 1, z);

        int tries = 0;
        while (!w.getBlockAt(loc.clone().add(0, -1, 0)).getType().isSolid()) {
            tries++;
            x = rand.nextInt(bounds * 2) - bounds;
            z = rand.nextInt(bounds * 2) - bounds;
            loc = new Location(w, x, w.getHighestBlockYAt(x, z) + 1, z);

            if (tries > bounds * bounds) {
                break;
            }
        }

        p.teleport(loc);
    }```
#

the method doesn't randomly tp

#

its horrible i can tell

sterile token
#

?doesntwork

torn oyster
#

it just doesn't work

#

no errors

sterile token
#

Hmn

#

So you have a logic problems

torn oyster
#

what the name suggests

#

randomly teleports within bounds

#

actually i could use /spreadplayers

#

that might be better

sterile token
#

First of all what its bounds

torn oyster
#

worldborder

#

what

hasty obsidian
#

Does anyone know how can I give a potion to a player inside a BukkitTask

young knoll
#

Just

#

Give them the effect?

sterile token
torn oyster
#

it's meant to randomly teleport them from a whole different world

#

to a random place within the border

sterile token
#

Ohh on

#

I catch 8t

#

He want to teleprot a player a random location without leaving the world bordes

#

I thought he was trying to teleprot the player to another random player

#

🤣

#

I mean he first said that

young knoll
#

Debug statements

#

Or breakpoints if you want to be fancy

sterile token
#

Yes

#

When you have issue without errores

#

You have to make something called debug

#

Which is a process Where you add Messages to see what its working or not

vague oracle
#

Should use the logger

#

Just better :/ only a suggestion

sterile token
#

King

#

Dont over complicate a simple match

#

Bruh its just a debug 🤣 🤣

young knoll
#

No reason to use the logger for debugging

vague oracle
#

lol suggestion but ok

#

Better practice in the long run :/

young knoll
#

Yes but it requires a plugin instance

#

And passing one just for debugging if you don’t already have one is annoying

vague oracle
#

Bro why are you mad lol I made a suggestion nothing to do with you :/

#

I would assume it’s a command so easy to dependency inject

#

It has the plug-in name and the time so that’s why it’s used

#

Cool no one asked

vocal cloud
#

Using a proper logger includes class name as well

#

Yes, have you never used a proper logger before?

vague oracle
#

Obviously not :/

vocal cloud
#

It's just something useful to have. Timestamps are important only if you need to backtrace an event to a time. If someone complains your plugin threw an error yesterday at noon and sends you a log that's thicker than a snowstorm it's great to be able to use timestamps to find it

#

Potentially, yes. But it's good practice to have it imo. Have you every accidentally left a println somewhere and had to track it down? It's a lot easier when it's a logger that tells you the class name

tall dragon
vocal cloud
#

Sounds like a lot of work for a problem you don't need to have

tall dragon
#

fair

sterile token
#

Agree with mime

#

Miike*

jaunty crag
#

can scoreboards do precise colors?

#

i cant post images here but i did one in chat and i did one on the scoreboard and the scoreboard one looked really messed up

dusk flicker
#

?img

undone axleBOT
jaunty crag
#

alright

#

imma post it in a sec

#

look at chat then look at scoreboard

#

something is wrong

jaunty crag
#

my guess is that they do not do accurate colors maybe but i have no idea truly

vague oracle
#

Scoreboard allow hex colours?

#

Does your*

wary topaz
#

'getName()' in 'org.bukkit.Bukkit' cannot be applied to '(java.lang.String)'

#

Player target = Bukkit.getPlayer(Bukkit.getName((args[1])));

compact haven
#

what the fuck are you doing

wary topaz
#

A gamemode command

compact haven
#

it's just Bukkit.getPlayer(args[1])

#

like Bukkit.getName() is something COMPLETELY unrelated

wary topaz
compact haven
#

and why you have two damn sets of parenthesis for getName is also beyond me

#

to get the username it's

#

target.getName();

#

though welcome to Java & I hope you enjoy it

wary topaz
#

'getName()' in 'org.bukkit.Bukkit' cannot be applied to '(java.lang.String)'

compact haven
#

bro

#

to get the Player object using their username, you use Bukkit.getPlayer( the username, so args[1] )

#

then to get their name, to print it, you use player.getName()

wary topaz
#

ohhhh

#

thanks mate

compact haven
#

np

lilac island
#

yeo yall know about the slime farms at all ?

wary topaz
#

wit I fixed it

#

Wait* I had to add a (

#

()

wary topaz
desert frigate
wary topaz
#

I did.

desert frigate
#

it doesn't show in pastebin

#

send full code

wary topaz
vocal cloud
#

full code

#

whole class

wary topaz
#

oh crpa my control a didnt work

#

mb

vocal cloud
#

that hurts my eyes

steady rivet
#

Does anyone know what enchantment can be applied to pretty much anything? I am needing to enchant an item in my gui but its yelling at me cause its an enchantment not meant for the item.

vocal cloud
#

So much wrong with it. There's a reason it's so difficult to find the issue

desert frigate
#

args[1] is second input?

#

Use args[0]?

vocal cloud
#

No not error. Just really bad practice

wary topaz
vocal cloud
#

You don't declare your target variable is the only error

wary topaz
#

Variable 'target' is already defined in the scope

desert frigate
#

why does it need to be so complicated

wary topaz
#

cause i'm new to java

vocal cloud
#

your formatting is off. The entire thing is scoped really wackily

#

if you're in intellij spam ctrl+alt+L every 5 lines or something

wary topaz
#

bet

kindred valley
#

How can i make models

vocal cloud
#

Blockbench?

wary topaz
#

I dont think it did anything

steady rivet
vocal cloud
#

like, you can condense all of these into a few lines

mighty pier
#

ikr

#

my friend says my coding is bad

#

but this is just horrible

wary topaz
#

control alt l did nothing

vocal cloud
#

Could probably shave around 75-100 lines from it

mighty pier
#

use switch() and add a setGamemode(Sender s, Player target) method

vocal cloud
#

no need for a switch for that code

mighty pier
#

e

#

its the same thing but he just changed the strings

#

it would be cleaner imo

#

Bukkit.getServer().getConsoleSender().sendMessage("§e§lYou

#

wtf

#

just do sender.sendmessage

#

itll work with console

wary topaz
#

like I knew that

vocal cloud
#

like you could make it smaller but 99% of the data fits in a simple function call

kindred valley
#

For Minecraft

chrome beacon
kindred valley
#

Is it hard? Or texturing?

civic wind
glossy venture
#

will allow you to add anything with any level to anything

steady rivet
glossy venture
#

yeah so just add protection to a sword so it wont do anything

#

and hide the enchant list

#

with an item flag

wintry ibex
#
java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.socketRead(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
        at sun.security.ssl.SSLSocketInputRecord.readHeader(Unknown Source)
        at sun.security.ssl.SSLSocketInputRecord.decode(Unknown Source)
        at sun.security.ssl.SSLTransport.decode(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
        at org.spigotmc.builder.Builder.get(Builder.java:795)
        at org.spigotmc.builder.Builder.main(Builder.java:277)
        at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)```
#

help

eternal oxide
#

java.net.SocketTimeoutException: Read timed out

#

website didn;t respond

wintry ibex
#

so i need to wait?

eternal oxide
#

try it again or wait

#

make sure you can access spigotmc

wintry ibex
#

when i open spigotmc this page is looping so i can't access spigotmc

#

like when its done its loading again and repeat

eternal oxide
#

make sure your computer clock is set to teh correct time/date

wintry ibex
#

already

eternal oxide
#

site is fine for me by the way, so its local to you or specific to you

wintry ibex
#

huh

#

so do you have things that can fix

eternal oxide
#

did you modify any ssl settings on yoru computer?

wintry ibex
#

No

#

yesterday is work normally teh website

mighty pier
#

are you on a vpn?

wintry ibex
#

No

eternal oxide
#

Did you change anything at all since yesterday?

wintry ibex
#

ofc no

eternal oxide
#

Then no clue.

wintry ibex
#

;/

#

but i can access this

young knoll
#

Why do you want 1.16.4

wintry ibex
#

yess now the web working because i forget my network and connect it again

wintry ibex
young knoll
#

Isn’t it basically identical to .5

wintry ibex
#

idk but it says need 1.16.4

remote swallow
#

what says

wintry ibex
#

wait

#
> Task :version-support1_16:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':version-support1_16:compileJava'.
> Could not resolve all files for configuration ':version-support1_16:compileClasspath'.
> Could not find org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/spigot-1.16.4-R0.1-SNAPSHOT.pom
       - file:/C:/Users/Nurisantoso/.m2/repository/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/maven-metadata.xml
       - file:/C:/Users/Nurisantoso/.m2/repository/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/spigot-1.16.4-R0.1-SNAPSHOT.pom
       - https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/maven-metadata.xml
       - https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/spigot-1.16.4-R0.1-SNAPSHOT.pom
       - https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/maven-metadata.xml
       - https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/spigot-1.16.4-R0.1-SNAPSHOT.pom
     Required by:
         project :version-support1_16

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 30s
7 actionable tasks: 1 executed, 6 up-to-date```
#

that

remote swallow
#

thats java version

#

not spigot build tools

wintry ibex
#

no before issue is 1.12.2 and i build 1.12.2 with buildtools and solved :/

young knoll
#

I would advise changing to 1.16.5

remote swallow
#

^^

young knoll
#

Should be a simple edit in build.gradle

wintry ibex
remote swallow
#

cant say ive done multi-module, so im guessing its either in the version-support1_16 build.gradle or the main build.gradle

dim palm
#

Can you help me do this? i don't know so much Java

dusk scroll
eternal oxide
remote swallow
#

yes

dim palm
#

thanks

eternal oxide
#

there are two bits you need to modify

#

the return of hasNext() and the value of Y in next()

#

in next() you need to loop from max Y to min Y instead of the current 0 to sizeY

#

basically reversing it and decreasing instead of increasing

#

Line 708 you need to set y (and only y) to its max value, not zero

#

line 712 you need to check for y > sizeY

kindred valley
#

Do you have a good custom config tutorial

eternal oxide
#

719 you need to decrement Y and test less than

#

720 set y to max y

remote swallow
eternal oxide
#

721 decrease y

#

If you do all that correctly, it will work in reverse

torn oyster
#

alright so i need some advice

#

i'm working on my Minigame Library

#

and I want to remove boilerplate code when creating minigames

#

so i am thinking of having different interfaces depending on the type of game (e.g. team game, solo game),

#

and the custom MinigamePlayer and Minigame class to implement them

#

is that a good idea?

#

or is there a better way

kindred valley
#

Do you have load(); , save(); , get(); methods for custom configs

eternal oxide
#

no

dim palm
#

😦

eternal oxide
#

line 27 if (--y <= 0) {

#

line 28 y = y2

#

delete line 30

torn oyster
#

anyone able to help?

#

sorry if i'm sounding desperate, i'm kinda trying to get this started

eternal oxide
#

line 16 should probably actually be y = sizeY

#

and line 28 y = sizeY

dim palm
eternal oxide
#

also return x < sizeX && y > 0 && z < sizeZ;

dim palm
#

xd

eternal oxide
#

You have errors because you didn;t copy the original correctly

#

this.w ? Thats a world but you have no w field in that class

#

You need the whole class

#

and modify precisely what I told you.

dim palm
eternal oxide
#

line 28 may need to be just < and not <= but you will have to try it and see

twin venture
#

hi anyone know a good way to
checks if the started week is the same as the current week
and if day, if the day the quest has started at is the same as the current day
if there's no match, it'll say false

#

so when i finish the quests of today , tmr i can't finish them .. nothing happend , its bcz of this code right here :

wintry ibex
warm light
#

is it possible to get PersistentData of a offline player?

eternal oxide
#

no

#

PDC only exists for online players

kindred valley
#

Do you have configuration class

wintry ibex
eternal oxide
#

https://hub.spigotmc.org/stash/scm/spigot/bukkit.git: connection failed You have internet issues

wintry ibex
#

ah again

#

:/

kindred valley
eternal oxide
#

?

#

No clue what you are asking

wintry ibex
#

ah yeah now working

kindred valley
eternal oxide
#

?configs

undone axleBOT
kindred valley
#

I couldnt find saving

#

How can i save the config

eternal oxide
#

Its all covered in that link

#

saving, loading and custom

kindred valley
#

And how u use an api

kindred valley
eternal oxide
#

It all depends on what you are doing

#

you only have to save if you made changes

kindred valley
#

Ok thanks

#

And how that guy code from mobile

eternal oxide
#

I can hardy see my mobile screen.

eternal oxide
#

Its been many years since I messed with a gregorian calendar. Can;t help you.

kindred valley
#

I hate school

#

I am coding to a book rn

young knoll
#

Fairly sure you can convert a timestamp into a date fairly easily

#

And then do some math from there

#

You may even be able to convert it to a calendar and then use the methods from that class

eternal oxide
#

If you want a simple way to tell if something is passed a deadline```java
Instant start = Instant.now();
Duration duration = Duration.ofDays(1);

    Instant finished = Instant.now();
    
    if (finished.isAfter(start.plus(duration))) {
        // To late
    }```
twin venture
#

can i use starteddate?

#

this one?

#

when a quest start

eternal oxide
#

yes, its just millis

twin venture
#

alright

#

thank you so much

eternal oxide
#

Thats just Instant.now().toMillis()

#

or somethgin close

twin venture
#

oh i see

#

that's even better 😄

eternal oxide
#
long startedDate = System.currentTimeMillis();

Instant start = Instant.ofEpochMilli(startedDate);
Duration duration = Duration.ofDays(1);
        
Instant finished = Instant.now();
        
if (finished.isAfter(start.plus(duration))) {
        // To late
}```
twin venture
#

what if i have a Questtypes?

#

like i want to check if the quest is daily or weekly?

eternal oxide
#

You should have a quest, when it starts and how long it runs for.

twin venture
#

yes

#

i do

eternal oxide
#

then you would get teh start data/time and its duration

twin venture
#

yes i can

#

no need for posudo code or smth , just tell me what i must do to get it fixed

#

bcz the problem right now is weird

#

when i finish a quests & challenges today

#

and i play tomrrow ,

#

i can't get any rewards

#

it stop right here :

#

code return right here

azure hawk
#

it worked 5 minutes ago then i reconnected my wlan and now it doesnt work anymore tf

eternal oxide
#
public boolean isInTime(Quest quest) {
    Instant finished = Instant.now();
    long questStarted = quest.getStarted();
    long durationOfDays = quest.getDuration();

    return finished.isBefore(Instant.ofEpochMilli(questStarted).plus(Duration.ofDays(durationOfDays)));
}```
#

if you make your quest return Instants it makes it a lot easier

twin venture
#

alright thanks alot

pseudo hazel
#

you didnt type it correctly

twin venture
#

ofDays

#

yeah

#

i thought it too

#

i fixed let me try it now

#

thanks

torn oyster
#

how would I return a class that implements an interface

#

if that's possible

#

I have a Team interface in my library and in each plugin using the library, it should have an Enum which implements the Team interface

eternal oxide
#

you return the interface

torn oyster
#

and i have a MinigamePlayer class which should return the new Enum that implements the Team interface

torn oyster
#

i already do that

#

but surely there is a way without casting

pseudo hazel
#

well if the MinigamePlayer can only return the enum, then have it return the enum

eternal oxide
#
public class CraftTeam implements Team { }

public Team getTeam() {
    return new CraftTeam();
}```
torn oyster
#

but each team enum implements the team interface (they aren't called the same thing ofc)

pseudo hazel
#

yeah

#

well there is no way around casting it

torn oyster
#

oh you changed it

#

lol

#

yep

#
    public @Nullable MinigamePlayer getMinigamePlayer(OfflinePlayer p) {
        Optional<MinigamePlayer> minigamePlayer = playerList.stream().filter(mp -> mp.getPlayer().equals(p)).findFirst();
        return minigamePlayer.orElse(null);
    }
#

and is there a way to return this without having to cast it?

pseudo hazel
#

wait so where is the enum stuff used?

torn oyster
#

new question

pseudo hazel
#

oh

#

so where is this cast then

torn oyster
#

it's abstract

pseudo hazel
#

yes

#

well this code does not know what other classes there might be , so you need to return the abstract and cast it in the implementation, that's kind of the point of making it abstract

azure hawk
#

org.spigotmc:spigot-api:pom:1.19.2-R0.1-20220922.001925-23 failed to transfer from https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced. Original error: Could not transfer artifact org.spigotmc:spigot-api:pom:1.19.2-R0.1-20220922.001925-23 from/to spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): transfer failed for https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.19.2-R0.1-SNAPSHOT/spigot-api-1.19.2-R0.1-20220922.001925-23.pom

Try run Maven import with -U flag (force update snapshots)

Thats when i reload maven

torn oyster
#

is that possible

#

or convert it somehow**

pseudo hazel
#

what is the relation between minigameplayer and extendedplayer

torn oyster
#

ExtendedPlayer extends MinigamePlayer

pseudo hazel
#

okay

#

well you cant cast it in one line

#

because a list of minigameplayers does not guarantee a list of valid extendedplayers

#

like you could make another class extend mp and have that list be a mix between extendedplayer and this new class

#

so you need to create a new list of extendedplayers

#

and then loop over minigameplayers

#

and cast and put it in extendedplayers if its valid

ivory sleet
#

But it would yield a compile time warning

glossy venture
#

though this would assume every player in the list is of type ExtendedPlayer

#

if its not you get a runtime error

dim palm
lost matrix
ivory sleet
#

Yeah

glossy venture
#

yeah

#

but does the compiler allow that

#

like that

pseudo hazel
#

yes but if you dont want a bunch of nulls then converting it in your own loop might be more beneficial

ivory sleet
#

The problem is that they might use an impl which derives List<ExtendedPlayer>

#

In which casting it to where a supertype is passed to the type param for the outer type would result in an error during runtime

#

But if you use for instance ArrayList

torn oyster
#
    public List<ExtendedPlayer> getHexPlayerList() {
        List<ExtendedPlayer> casted = new ArrayList<>();
        for (MinigamePlayer p : getPlayerList()) {
            if (p instanceof ExtendedPlayer ep) casted.add(ep);
        }
        return casted;
    }
ivory sleet
#

Then the type is guaranteed to be erased

torn oyster
#

would that work?

pseudo hazel
#

yes I think so

torn oyster
#

is there a stream() way to do this

#

or is this as compact as it can be

ivory sleet
#

Yes

torn oyster
#

is it just .forEach()?

pseudo hazel
#

yes

ivory sleet
#

stream().filter(Type.class::isInstance).map(Type.class::cast).toList()

#

Or sth

pseudo hazel
#

or that

lost matrix
#

yes

ivory sleet
#

(Doesnt filter nulls tho)

lost matrix
#

Are you sure?

#

Type.class::isInstance returns false on nulls

ivory sleet
#

Does it?

lost matrix
#

null doesnt have a type so...

ivory sleet
#

Yeah probably does speaking of which

torn oyster
#

so yeah i think so

ivory sleet
#

Ah alr

#

Then yeah

ivory sleet
#

Tho it would be possible with side effects

pseudo hazel
#

why cant you use it then

ivory sleet
#

It was worded poorly, you could use forEach just that it’d be somewhat awkward and stateful

torn oyster
#

i can't override the getPlayerList method using the List<ExtendedPlayer> so I had to create a new method unfortunately

#

idk it seems less clean

#

but oh well

pseudo hazel
#

yes since its just another version of writing out the loop

#

use generics maybe

ivory sleet
#

He uses it alr

torn oyster
ivory sleet
#

List is a type constructor

#

Yes

#

List<E>

#

E is a generic

pseudo hazel
#

but I mean use more xD

ivory sleet
#

Quared

#

You can use List<? extends MinigamePlayer>

#

and then for a given subclass that overrides a method that returns the aforementioned type, you could instead return List<ExtendedPlayer> if wanted

pseudo hazel
#

yes

#

that's what I meant

ivory sleet
#

Oh then you meant a wildcard type

pseudo hazel
#

yes but its still part of the generic thing

#

but I couldnt come up with the name for it

ivory sleet
#

Yes, but every type involves generics

#

Since every type can be passed to a (generic) type parameter (unless you restrict it)

lost matrix
#

Just use List<Object> everywhere

ivory sleet
lost matrix
#

Heck why stop there? Just use Object.

pseudo hazel
#

yes I was about to say that lmao

ivory sleet
#

💀

civic wind
#

What method or way would i go about saving data of players who have been banned and then displaying it ina. Gui, so im making a punish gui, if the player has already been banned, it crosses that one out and then you click the next one (longer punishment)

rancid roost
#

Hey, how can I create paid resource on spigotmc?

lost matrix
lost matrix
undone axleBOT
twin venture
#

iam not good at english sometimes

eternal oxide
#

No thats how long the quest will run for, 1 day or 7 days etc

twin venture
#

this is the current code

civic wind
lost matrix
civic wind
#

Yeah im going to use yml file i dont know how to grab data from there though and check it in if statements but i guess ill post in here when i get to that point and if i get stuck xd

lost matrix
civic wind
#

Okay thanks will give this a go

sterile token
#

For loading files you can use class FileConfiguration from spigot api

eternal oxide
#

?configs

undone axleBOT
fluid river
#

woke up

#

where are noobs

#

show me

ivory sleet
#

?

pseudo hazel
#

noobs are everywhere

fluid river
pseudo hazel
#

is anyone familiar with how plugins for stuff like minigames get integrated into bigger servers? like for example I am making my plugin but I intend on servers being able to use it as a minigame that can run paralell to itself etc. like are those just individual servers or whats the process for that kinda stuff

thorn isle
#

Write me an algorithm that gives me the velocity needed to throw a player from x to y, accounting for gravity and drag

pseudo hazel
#

you arent on copilot xD

fluid river
#

or you just disable gravity for player and throw him forward

fluid river
#

guys just install minigames and configure them on server

thorn isle
#

I have found the math for calculating the trajectory and initial velocity, but it doesn't account for drag

#

So the trajectory is inaccurate for longer distances

pseudo hazel
fluid river
#

i think most of the servers code minigames by themselves

pseudo hazel
#

yeah I guess

#

like the bigger servers for sure

ivory sleet
#

And a proxy

pseudo hazel
#

what does the database store

ivory sleet
#

Data that is shared across different backends

#

Since synchronizing state is sometimes easier if layered behind some separate service

#

But also, a message broker like redis or rabbit is usually also rather crucial

#

Especially since plugin messaging isnt designed for independent backend to backend messaging

pseudo hazel
#

so is that to sync stuff like highscore or currencies or what across a server network?

ivory sleet
#

Myeah

#

can be sessional also

#

Ofc you’d still use a persistency layered database also

#

As in memory would be wiped if you reboot

pseudo hazel
#

what about minigames that are really self contained, like I am making a bingo plugin and it doesnt really interact with anything, I would imagine from the players perspective you would join a lobby and then the game starts and let's say people can join mid game if they join the lobby

#

and when the game is over everything gets reset

#

what kind of sessional data would that need, or is it not applicable in this case?

ivory sleet
#

Probably dont need sessional data then

#

But when you said minigame I imagine something like hypixel

#

that really scales

pseudo hazel
#

yes

#

liek bedwars or something

ivory sleet
#

Pretty much

pseudo hazel
#

I mean the game itself is basic enough

ivory sleet
#

Yuh

pseudo hazel
#

but then you would use whatever database stuff you described to manage scores and unlocked kits and whatever that can be used outside of teh direct minigame (instance)

ivory sleet
#

Yes

pseudo hazel
#

okay that makes sense

ivory sleet
#

For insance parties if you have that

#

A friend system over the network

pseudo hazel
#

yes thats a good one

ivory sleet
#

Either you out those two behind your proxy

#

Or you have something like an in mem db such as redis

pseudo hazel
#

but in what way would I have to worry about that as the devloper of just the minigame

#

like I shouldnt care about how the players in a party get to join the same team right?

ivory sleet
#

Idk depends on what exactly you are designing

pseudo hazel
#

beacuse I might now know the structure of the party system

ivory sleet
#

Is it just the minigame?

pseudo hazel
#

well yes

ivory sleet
#

It might be hard, but server owners would probably use other plugins for a friend system or party system, in that case you’d just have to interoperate those plugins

#

Either if they provide an api, or if you do

#

Though, what you presumably want to write is a proxy plugin, for bungeecord or velocity etc, which would manage the bed wars games life cycle

#

Assuming some server owner wants to have it split out and deployed multiple servers

pseudo hazel
#

yes that makes sense

#

Thanks for your feedback

ivory sleet
#

Yea, good luck, but honestly Im gonna be genuine, writing mini game plugins is gross since you are pretty much bound to depend on poor apis of other plugins that server owners use

pseudo hazel
#

yes thats what I was afraid of as well, but ill see if I can find a way to be as little depended on other bs as possible xD

lost matrix
#

Minigames are not something i would write for the public to use

pseudo hazel
#

you mean you would only write them for actual clients

lost matrix
#

Yes where i have full control over the integration

vocal cloud
#

I think that unless you're designing for a server you're going to have a bad time. You'd have to supply a massive API along with integrating a lot of others to the point where you're spending more time working on integration than minigames

pseudo hazel
#

hmm thats a good point as well

#

maybe I could just leave this plugin as it is for casual players to just play and if server owners wanted to use it in their servers charge for the integration (if its feasible for me to do)

tardy delta
civic wind
#

Hey

hasty obsidian
#

Does anyone know how to make setIngredient a custom Item

lost matrix
hasty obsidian
#

ok

tardy delta
#

should be making a customitems plugin ig

fluid river
#

wachu know 'bout scrolling down the array

kindred valley
hasty obsidian
#

Command not working after create recipe

onyx fjord
#

When there's people talking much put that shit in scheduler ay

Thank you for listening

fluid river
onyx fjord
#

Doesn't it like create on demand

pseudo hazel
#

you get, set stuff and then save

onyx fjord
#

You mean specific armor gives X hp?

#

I don't see why that needs to be code in code?

lost matrix
#

There are attributes for that. Just add an attribute modifier with health on the armor

untold jewel
#

real easy tho

onyx fjord
#

You can setup yml file by hand

fluid river
#

config.set("yourArmorSet.healtPlus", 10)

untold jewel
#

Dont you just make a PersisntData item and put attributes

#

when equipped

fluid river
#

now your armor has a 10 health value

untold jewel
#

Persistent

fluid river
#

and you can get it from config

lost matrix
#

Here is an example of what you can do with attribute modifiers

fluid river
#

lore 💀

lost matrix
#

You can always hide the attributes with a flag and create your own lore

fluid river
lost matrix
#

Then you need to find a way of detecting equipment changes

#

?configs

undone axleBOT
lost matrix
#

But dont read/write files on runtime. Load them once the server starts and save them when the server stops.
In between do an async flush every 15mins

untold jewel
#
 public boolean canBuy(Player player, int amount) {
        if (getBalance(player) >= amount) {
            return false;
        } else {
            return true;
        }
    }
#

is this a good way of doing it?

lost matrix
pseudo hazel
#

the second argument in the get is to specify a default value if the path you provided is invalid

fluid river
#

?learnjava

undone axleBOT
vagrant stratus
#

I hate regex.
CreateObject("WMPlayer.OCX.7")
What would be the regex to get what's in the CreateObject string?
e.g.

CreateObject("Example")
CreateObject("Example2")
lost matrix
#

\(\".*?\"\)

vocal cloud
#

Regex is a fun and enjoyable experience.

lost matrix
civic wind
lost matrix
vocal cloud
#

(["'])(?:(?=(\?))\2.)*?\1

pseudo hazel
#

wtf is that xD

vocal cloud
#

I hate regex

vagrant stratus
#

So do I but I need it for a specific non-MC project lmao

pseudo hazel
#

I would just use a named group

fluid river
#

FREE JAVA LESSONS

pseudo hazel
#

CreateObject\("(?<the_string>\S+)"\)

hollow pelican
#

I have a problem with my shield knockback, it keeps pulling me towards whatever I'm being hit by whenever I damage the player directly upon hit with their shield out.

#

And I have no clue how to fix it.

vagrant stratus
#

Specifying the string is not an option in this case @pseudo hazel

civic wind
vagrant stratus
#

Has to get any string

pseudo hazel
#

I am not specifiying the string

#

thats just the name of the catpured group

hollow pelican
vagrant stratus
#

<the_string>?

pseudo hazel
#

the \S is actually specifyng the string

civic wind
pseudo hazel
#

but idk if you also wanna use spaces

civic wind
hollow pelican
#

😒

pseudo hazel
#

(?<group>) is called a named capture group

hollow pelican
#

I'm genuinely trying to fix the issue.

#

Not get told how to break my PC, reboot my router or reboot my PC.

pseudo hazel
#

pretty much all regex implementations then have a functio to match and get the groups by name

civic wind
#

Did you edit the knockback already

hasty obsidian
pseudo hazel
#

so like regex.match().group("the_string") would get you whats inside the ""

hollow pelican
#

Any attempts to do that don't provide realistic knockback.

#

If the enemy is looking up and the player jumps, the player is launched backwards through the air.

civic wind
#

I’m trying to work out why you’re having this issue

lost matrix
hollow pelican
#

It causes reverse knockback which just pulls me towards whatever's hitting me.

civic wind
hasty obsidian
hollow pelican
tawdry python
#

Is there a way to disable spawner animation for the player?

pseudo hazel
#

or whatever its called

lost matrix
#

clone()

lost matrix
warm light
#

the libraries features not working on 1.8 server :/

lost matrix
#

?1.8

undone axleBOT
lost matrix
#

Good

hasty obsidian
marble estuary
#

How can I create something that happens after like 5 seconds inside an event with listener?

undone axleBOT
pseudo hazel
#

I already told you @hasty obsidian

#

and also try to print to see if teh command gets executed at all

lost matrix
drowsy pawn
#

hello

#

CraftMagicNumbers supported 1.19?

lost matrix
#

CraftMagicNumbers supported in no version. They are magic numbers for a reason.

warm light
lost matrix
untold jewel
# hasty obsidian so uhhh what am I supposed to do instead?

do something like this

  private static ItemStack createShard(){
        ItemStack item = new ItemStack(Material.AMETHYST_SHARD, 1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.RED + "Revolution Shard");
        meta.addEnchant(Enchantment.LUCK, 1, true);
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        item.setItemMeta(meta);
        return item;

    }
lost matrix
untold jewel
#

when you call the method you want it to return the itemstack, not nothing which is what void essentially is

hasty obsidian
lost matrix
#

Never ever reload. This feature is not supported by spigot and will lead to errors in many cases.

hasty obsidian
#

what

tender shard
#

do not use /Reload

hasty obsidian
#

what do I use instead then

tardy delta
#

use restart

tender shard
#

restrart

#

?reload

#

hm

#

I thought there was a command that explains it

vagrant stratus
#

new regex question @lost matrix
set (.+) = (.+)
How would I make it also look for set (.+)=(.+)?

Set objFSO=CreateObject("Scripting.FileSystemObject") and Set objFSO = CreateObject("Scripting.FileSystemObject")
for example

hasty obsidian
#

rip

lost matrix
# hasty obsidian what

Nunca recargar. Esta característica no es compatible con spigot y dará lugar a errores en muchos casos.

Ne jamais recharger. Cette fonctionnalité n'est pas prise en charge par le robinet et entraînera des erreurs dans de nombreux cas.

pseudo hazel
#

reload works most of the time for me, but its never a guarantee

lost matrix
vagrant stratus
#

lmao

hasty prawn
#

Reload is fine if you're on a development server, never okay on production

vagrant stratus
pseudo hazel
#

what do you want to match?

hasty obsidian
pseudo hazel
#

like what are the parts in those strings you actually care about

vagrant stratus
#

two examples are provided within that message.

set <variable_name> = <variable_value> and set <variable_name>=<variable_value>
The above gets both already, I just need it to look for set <variable_name>=<variable_value> too since those don't get detected

marble estuary
pseudo hazel
#

okay

untold jewel
marble estuary
untold jewel
#

What do you mean none of them helped

#

You are trying to run a delayed task

lost matrix
vagrant stratus
#

set (.+) = (.+) works, just need it to detect set (.+)=(.+) as well lol

tender shard
#

set (.+) ?= ?(.+)

#

? = previous character is optional

marble estuary
#

I will explain my problem better

I am trying to make a crop regrow after 5 seconds of it being destroyed

vagrant stratus
#

👍

untold jewel
#

yeah

vagrant stratus
#

This project is gonna make me a god at regex istg lmao

untold jewel
#

run a asyncdelayedtask and set the age of the crop

tardy delta
#

what

vocal cloud
#

Async?

untold jewel
#

hm

lost matrix
untold jewel
#

ScheduleSyncDelayedTask lol

pseudo hazel
#

if the whitespace and stuff is inconsistent you could also consider using trim()

untold jewel
#

mb

marble estuary
#

Isn't there a simple way to just wait a bit?

pseudo hazel
#

wait nvm that only removed leading and ending whitespace

tardy delta
#

use the scheduler lol?

lost matrix
pseudo hazel
#

then add a variable that you set when its growing back

#

that you will need to serialize/save i guess

tawdry python
lost matrix
# marble estuary Isn't there a simple way to just wait a bit?

This is your "Just wait a bit" approach

  @EventHandler
  public void onBreak(BlockBreakEvent event) {
    Block block = event.getBlock();
    Material material = block.getType();
    Bukkit.getScheduler().runTaskLater(plugin, () -> block.setType(material), 5 * 20);
  }

But there are so many problems surrounding this... Really fragile.

marble estuary
quiet ice
marble estuary
lost matrix
marble estuary
vocal cloud
lost matrix
# marble estuary can you show me how?

But you need a whole infrastructure for this.
A manager, a data class, a scheduler, a PriorityQueue, a serializer and your data class has to implement Comparable for itself.

lost matrix
marble estuary
#

I think its way too complex for what I'm trying to do

lost matrix
tardy delta
#

what is he even tryin to do

marble estuary
lost matrix
# marble estuary I'm just setting the age back to the max

Well then its not too bad.
So you need to do the following:

  • Listen to the BlockBreakEvent
  • Check if broken block is Ageable
  • Schedule for one tick later: Set the broken block back to the original type
  • Schedule for 5s (100 ticks) later: Set the age of the block to max [if the block still has the same type]
marble estuary
lost matrix
#

?scheduling

undone axleBOT
marble estuary
#

that confused me

lost matrix
#

?learnjava

undone axleBOT
lost matrix
#

I can do this all day

pseudo hazel
#

what confused you about it

lost matrix
marble estuary
#

The examples

lost matrix
#

Which one specifically?

marble estuary
#

When scheduling a task, you will also need to pass your main plugin class instance. Here is three examples of how it can be done:

lost matrix
#

So getting the instance of your main plugin class is what confuses you?

eternal oxide
#

Objects and Instances, very basic Java

marble estuary
#

part of it

#

Scheduling a Delayed Task is the main part that I get confused at

lost matrix
# marble estuary part of it

Then i cant help you. This is very basic java question. Something you usually learn in the first 1 or 2 weeks.

pseudo hazel
#

to get your plugin class instance, you can just do Bukkit.getPlugin(YourPlugin.class)

quiet ice
#

Getting the plugin instance is easy: JavaPlugin.getProvidingPlugin(new Object() {}.getClass())

onyx fjord
#

what is provides: [] for in plugin.yml?

quiet ice
lost matrix
pseudo hazel
#

what part about the delayed task do you not understand

#

the BukkitScheduler or the BukkitRunnable?

onyx fjord
marble estuary
#

scheduler.runTaskLater(plugin, () -> { in that part when I tried to follow that plugin appeared red after I did all of the previous steps like they showed

onyx fjord
#

i saw some plugin use it

quiet ice
#

?stash

undone axleBOT
lost matrix
onyx fjord
#

isnt that libraries: ?

quiet ice
#

Its other plugins this plugins has bundled in

#

I.e. FAWE might provide regular WE so plugins depending on WE will not crash even though FAWE was installed

lost matrix
#

Ah ok so its not for maven dependencies but stuff like worldedit

#

Where your plugin basically mimics the api of another plugin

quiet ice
#

Also meant if you rename your plugin

#

A bit outside of the bukkit world, but fabric-api for example provides "fabric", while it's name is "fabric-api" - this grants a given degree of backwards compat as mentioned previously

marble estuary
#

After I tried following the tutorial I get an error can't resolve symbol 'plugin'

lost matrix
#

You need a variable with the name 'plugin'

#

And it has to be of type JavaPlugin.
And it needs to be your instance of JavaPlugin.

marble estuary
#
            this.plugin = plugin;```
#

inside the main class

lost matrix
#

The main class doesnt need an instance of itself...

untold jewel
#

xD

#

in other classes use

#
public Main plugin;

public ClassName(Main plugin) {
this.plugin = plugin;
}

vocal cloud
#

Watch the spoon feeding, and don't name ur main class main

untold jewel
#

I just typed Main so he would understand that its the main class

#

I dont call it main

vocal cloud
civic wind
vocal cloud
eternal oxide
#

because Plugins are extensions of an App not an app themselves

civic wind
#

I just call my Main class main as its the one with on enable, disable, configs etc then the rest i name to what they are

eternal oxide
#

Not good design

civic wind
#

Noted!

untold jewel
#

Usaully its good practice to name the main class your project name so example SkyblockPlugin.

red sedge
#

how would i set the mining progress of a block

vocal cloud
#

That's client side I believe

red sedge
#

andddd how would I change it..?

#

Packets is what im guessing?

eternal oxide
#

I believe there is a method to set teh stage

lost matrix
#

I think its fully client side now

#

There is a method in the api for that but im not sure it still works

red sedge
red sedge
#

gosh proper punctuation is hard

onyx fjord
#

Im making a string matcher, and heres my question, how can i do something like this

given string: 123 something something 123
While 123 is never the same
is there a way to make argument X accept any string or int or whatever

#

real message is something like this:
Player X did X

#

i want it to match based on words player and did

tardy delta
#

🤔

onyx fjord
#

hard to explain

tardy delta
#

whats x

onyx fjord
#

X can be me or you

lost matrix
#
    String message = "Player %s did %s";
    message = message.formatted(player.getName(), something.getInfo());

You just want to format text?

onyx fjord
#

its never the same

tardy delta
#

uwu

onyx fjord
#

no no

vocal cloud
#

Split and get [1] and [3]?

onyx fjord
#

okay thats close

hazy parrot
#

bump ig

tardy delta
#

dunno how that syntax looks lol

onyx fjord
tardy delta
#

how do you even know where your player name is

vocal cloud
onyx fjord
#

got it

#

👍

mellow edge
#

is possible to add a custom "block" in spigot?

lost matrix
# mellow edge is possible to add a custom "block" in spigot?

No. Only with a lot of trickery and even then its very janky. Minecraft doesnt allow any completely new additions originating from a server.
In order to add blocks you would also have to add those blocks to the client. And this is simply not possible in Minecraft vanilla.

#

Thats why forge exists.

mellow edge
#

well what if I create an entity and then use PlayerInteractEvent on it?

icy beacon
#

A bad trick would be to use some very rare block (if it's for a private server, just select a block that isn't used on your server), retexture it and force behavior

lost matrix
icy beacon
#

^

mellow edge
lost matrix
#

And you wont be able to walk on it

mellow edge
#

that is also true, and I think I would also need to prompt users to download a resource pack

stuck flax
#

is the logger thread safe?

mellow edge
#

I'm sure they could implement a system where a json of a block data is sent to the client and then the client registers that as a block

#

but that would need to be done by mojang for default client

untold jewel
#

Anyone who has a good GUI api?

harsh totem
#

?learnjava

undone axleBOT
untold jewel
#

Thanks!!

untold jewel
#

I'm making a economy plugin. Already have balance and basic commands such as /pay /balance and admin commands

#

I want to make a shop, but is there an easy way to connect price and items together

wet breach
#

which event are you using?

untold jewel
#

Do I use a hashmap or is there any other way to again "connect" (dont know a better word for it) the item and prices

#

yes

last swift
#

how do i fetch a bow's drawback power?

wet breach
#

you could just make a custom item wrapper that contains price on the items. Works for a global shop

eternal oxide
#

Does the price change?

granite vapor
untold jewel
iron glade
#

then cast to warden and use the #clearAnger() method

eternal oxide
#

Then it depends on how and when you need a price

#

if you only need the price when its in a shop theres no point in keeping it permanent. Just look it up

#

Map would be fine

glossy venture
#

is this a good way to generate a message

civic wind
#

It's saying the ItemStack is null

#

?runforest

faint frost
#

what is even

#

2468

untold jewel
#

?schedule

#

?schedules

#

?scheduling

undone axleBOT
arctic moth
#

how to spam goat rams

civic wind
#

ignore what i said it works i forgot to restart server LOL

iron glade
civic wind
#

I know bro, I'm going to amend my code at some point and use pdc

#

I'm getting this error though, even tho it does work

granite vapor
# iron glade think u should use instanceof Warden

Thank you. Could you please check my code, why the clearAnger and setAnger method cannot change the anger of Warden? Nothing is happen. Do I use the method incorrectly?

The .getAnger() and .getAngerLevel() are working.

public void onEntityDamage(EntityDamageByEntityEvent event) {
        if (event.getDamager().getType() == EntityType.WARDEN) {
            Entity warden = event.getDamager();
            if (warden instanceof Warden) {
                ((Warden) warden).clearAnger(warden);
                ((Warden) warden).setAnger(warden,0);
                
                System.out.println(((Warden) warden).getAnger());
                System.out.println(((Warden) warden).getAngerLevel());
            }
            event.setCancelled(true);
        }
    }
civic wind
vocal cloud
#

Love the null check after calling a method which makes it pointless

civic wind
#

😮

#

so put null check before meta check? That's what you're saying?

vocal cloud
#

Well the IDE has highlighted a bunch of stuff. Might as well read it

civic wind
#

I have

#

This better sir?:)

vocal cloud
#

Well if you've read it you can fix it

civic wind
#

ahh kk

#

I should check air twice though right?

#

Yeh..

arctic moth
#

the guy helping me went offline or smth

#

nvm

#

that probably works

#

not a runnable

#

but scheduler

civic wind
#

Why not Morice? Just out of curiosity

#

Static means it won't be changed right?

iron glade
arctic moth
#

or you could do this

((BukkitRunnable) () -> {
  // code here
 }).runTaskTimer(instance, 3L, 3L)
civic wind
#

What would you use static for though? Like why is it bad practice

arctic moth
#

show stacktrace

undone axleBOT
iron glade
#

same

arctic moth
#

pl extension

#

normally links ending with .something download immediately

arctic moth
#

?

quaint mantle
#

Hi, is there any method to find who caused a player to get damaged through a secondary event?
e.g. If they're hit with a sword that has fire aspect, Itll see fire as damaging the player after the original hit, not the person that hit them.
Is there anyway to find this info out?

arctic moth
#

that is also on their cdn

iron glade
arctic moth
#

yep hosted on cdn

#

you cant upload it directly, it has to be hosted somewhere for people to download it

#

so discord hosts it

#

lol thats a png i was gonna paste the link to it

#

^

onyx fjord
#

how is the thing foo ? "bar" : "baz" called?

tall dragon
#

inline if statement

rough drift
tall dragon
#

that is... an if statement..

onyx fjord
#

yee

#

wait so

#

for boolean

#

lets say foo is true, then i t returns bar?

tall dragon
#

yes

onyx fjord
#

and if its false baz?

tall dragon
#

yes

arctic moth
#

how would i play sounds that are under a custom namespace? (resource pack sounds.json)

onyx fjord
#

perfect thats what i want

quaint mantle
iron glade
#

0,15s you mean

dim palm
civic wind
#

How can I have outside my command boolean constructor

#

I need it for my gui

undone axleBOT
solid cargo
#

yo guys smol vote: should i get NBT-API just to check if player holds a chest with nbt

fluid river
#

or

#

FREE JAVA LESSONS

#

or

#

?learnjava

undone axleBOT
civic wind
#

Did you just assume I was human?

fluid river
#

no i said can you axplain like human

civic wind
#

I can't

#

because im not

fluid river
#

then no answer

civic wind
#

kk

solid cargo
#

does meta.hasLore() boolean also return true if there is a +NBT thingy in the description?

eternal night
#

no

solid cargo
#

AUGHHHH

fluid river
#

why do you need dis

solid cargo
#

i want a simple way to disable the uhh

#

middle click to get a chest with nbt data

#

aka a simple way to "ban" a player

cobalt thorn
kindred valley
granite vapor
granite vapor
vocal cloud
#

Why would you want to do that

chrome beacon
#

?paste

undone axleBOT
chrome beacon
#

^ put the code there and send the link

grim ice
#

yeah ill just

#

?learnjava

undone axleBOT
grim ice
#

at this point

#

just learn java then remake the whole thing

jaunty crag
#

i dont know how to get it to allow it

ripe canyon
#

how to see all purchased plugins on spigot?

vivid skiff
#

How can i add a values like

playersList:
- Player1
- Player2

in a yaml data file?

vivid skiff
fringe hemlock
#

Use your YamlConfiguration variable and there is a .getStringList(); and .set(path, value); supports list

untold jewel
#

        PersistentDataContainer data = bankNoteMeta.getPersistentDataContainer();
        data.set(new NamespacedKey(plugin ,"balance"), PersistentDataType.INTEGER, amount);

        bankNote.setItemMeta(bankNoteMeta);

        if (args.length == 1) {
            amount = economyManager.parse(args[0]);
            if (!(economyManager.getBalance(player) < amount)) {
                player.getInventory().addItem(bankNote);
                try {
                    economyManager.withdrawPlayer(player, amount);
                    ChatUtil.sendMessagePrefix(player, "&7You withdrew &a$" + amount + "&7 into a banknote!");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } else {
                ChatUtil.sendMessagePrefix(player, "&cYou do not have sufficient balance to do withdraw this amount!");
            }
        }

        return true;

This works but on the InteractEvent it doesnt remove or do

#
 int amount;

    @EventHandler
    public void onBankNoteDeposit(PlayerInteractEvent event) throws IOException {
        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInMainHand();
        amount = Objects.requireNonNull(item.getItemMeta()).getPersistentDataContainer().get(new NamespacedKey(plugin, "balance"), PersistentDataType.INTEGER);

        if (!item.hasItemMeta()) return;
        if (event.getAction() != Action.RIGHT_CLICK_AIR || event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
        if (!Objects.requireNonNull(item.getItemMeta()).getPersistentDataContainer().has(new NamespacedKey(plugin, "balance"), PersistentDataType.INTEGER)) return;

        player.getInventory().remove(item);
        economyManager.depositPlayer(player, amount);
        ChatUtil.sendMessagePrefix(player, "&7You have deposited a bank note of &a$" + amount);
    }
#

nvm i see the problem i think

#

Okay so I fixed the event problem, but when I deposit lets say 100, it takes 100 from me but on the lore/banknote it says 0

#

as amount

fiery prairie
#
                if(isChatLocked == true) {
                   isChatLocked = false;
                   for(Player all : Bukkit.getOnlinePlayers()){
                       all.sendMessage(Utils.color(getConfig().getString("chat-unlock-success-all").replace("%player%", p.getDisplayName())));
                   }
                } else {
                    for(Player all : Bukkit.getOnlinePlayers()){
                        all.sendMessage(Utils.color(getConfig().getString("chat-lock-success-all").replace("%player%", p.getDisplayName())));
                    }
                    isChatLocked = true;
                }

the getString parts return npe, as if they dont exist in the config, although they do that, could any help me?

tawdry python
#

I was thinking, would it be possible for the plugin to start the server with a specific IP? That is, before passing the plugin, I would ask for the ip of his server, set it in the plugin, and if when he started the plugin, the server IP was not the IP set by me, the plugin would not start, it will be a good idea or can cause problems?

eternal oxide
#

would be hacked out in seconds

vocal cloud
#

That sounds like an awful way to do things.

untold jewel
# fiery prairie ```java if(isChatLocked == true) { isChatLock...
   public static boolean lockchat = true;


    @Override
    public void execute(Player player, String[] args) {
        if (args.length == 0) {
            ChatUtil.sendMessagePrefix(player, "&7You have &6&l" + lcStatus() + " &7the chat!");
            for (Player players : Bukkit.getOnlinePlayers()) {
                ChatUtil.sendMessagePrefix(players, "&e" + player.getName() + " &chas&6&l " + lcStatus() + " &cglobal chat!");
            }
            lockchat = !lockchat;
        }
    }

        private final String lcStatus () {
            return lockchat ? "LOCKED" : "UNLOCKED";
        }
}
#

this is what I usally do

chrome beacon
#

You haven't told us what the problem is

untold jewel
#

he literally did tho

pseudo hazel
fiery prairie
untold jewel
# fiery prairie thanks, ill try it out that

    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        Player player = event.getPlayer();
        if (player.hasPermission("plugin.lockchat_bypass")) return;
        if (LockchatCommand.lockchat) return;
        event.setCancelled(true);
        ChatUtil.sendMessagePrefix(player, "&cChat is currently locked!");
    }
#

this is the chat event

fiery prairie
#

i changed a lot of things obv thou

untold jewel
#

whatever you want brother, as long as it works

vocal cloud
#

Please learn java. That entire class is an amalgamation of so many bad practices it's difficult to ignore.

untold jewel
#

lowercase to start off

#

XD

red sedge
#

will BlockBreakEvent call BlockDamageAbortEvent

red sedge
#

check between lines 88 and 126

untold jewel
#

WHAT

#

what

red sedge
#

ikr

vocal cloud
#

A certified learn java moment

red sedge
vocal cloud
#

Block break event happens when a block is broken, the abort event is completely different isn't it?

red sedge
#

Ya it is

#

Ig I was just hoping that like, it also aborts when the block is broken or smth