#help-development

1 messages · Page 2216 of 1

sterile token
#

spigot-api is on a repository

sacred mountain
#

best way to write this?

tardy delta
#

Validate.notNulls smh

eternal oxide
#

never seen it like that. all the tutorials and gradle wiki show without. But I use Maven so...

sacred mountain
tardy delta
#

or just a for loop lol

humble tulip
#

Is that from my verify class?

#

😂

#

That's so old

trail pilot
humble tulip
#

I doubt i even use it

ivory sleet
#

iirc nope

sacred mountain
vivid hill
ivory sleet
#

since it sends player info packet

sacred mountain
#

and now the mysql manager doesnt work

#

mfao

ivory sleet
#

tho, string you could resend a new player info packet

#

to add em to the tablist

eternal oxide
sacred mountain
#

it rreturns ("The validated object is null")

#

not a boolean

eternal oxide
#

ok

trail pilot
#

wtf 1.18.1 work and 1.18.2 no

#

tf

sterile token
sacred mountain
sterile token
sacred mountain
#

yez

sterile token
#

I would use a lovevly foreach :D

sacred mountain
#

i tried but

#

i dont know how to return from a lambda

trail pilot
lost matrix
sterile token
#

Hmn

trail pilot
#

lombok hihihih

sacred mountain
thorn isle
#

Use arrays.aslist instead

sacred mountain
#

ight

lost matrix
#

There is not much you can do here. If you wanted to use a functional foreach then you would have to stream them which would be unnecessary overhead.

sacred mountain
#

why?

thorn isle
#

List.of is less efficient

sacred mountain
#

mk

thorn isle
#

Because it has to clone the array

tall dragon
#

yea idk why alot of people are so obsessed with using streams

sacred mountain
#

ive never used a stream idk it looks ehhh

warm saddle
#

Heyo how would I go about make a Bukkit Runnable that used a random time each time in a range?

lost matrix
#
  public static boolean isNotNull(Object... objects) {
    return Arrays.stream(objects).allMatch(Objects::nonNull);
  }
ivory sleet
sacred mountain
ivory sleet
#

and as soon as valhalla is delivered they will be competitive with normal loops

tall dragon
lost matrix
ivory sleet
#

¯_(ツ)_/¯

sacred mountain
#

looks really nice

ivory sleet
#

you've seen it?

sacred mountain
#

the valhalla project

ivory sleet
#

I mean not everything of it is delivered yet

#

like universal generics is still preview or candidate iirc

#

but ye

#

some of it is delivered

sterile token
#

BuildTools doesnt work. It says starting process for building spigot but it doesnt do anything else. And if i try to close it it tells process x is running do you want to cancel it

vivid hill
#
Loading BuildTools version: git-BuildTools-1fbeb7f-147 (#147)
Java Version: Java 17
Current Path: C:\Users\toron\OneDrive\Desktop\buildpath\.
Please do not run BuildTools in a Dropbox, OneDrive, or similar. You can always copy the completed jars there later.

This happens when i load build tools it doesnt open a consol it just gives me a file

kind hatch
#

Why does no one read?

tall dragon
#

well what does it say....

vivid hill
tall dragon
#

Please do not run BuildTools in a Dropbox, OneDrive, or similar. You can always copy the completed jars there later.

vivid hill
#

but

tall dragon
#

so?

vivid hill
#

that isnt a dropbox OneDrive

tall dragon
#

its stilll in there

chrome beacon
#

Your desktop is inside OneDrive

vivid hill
#

oh

kind hatch
#

^

chrome beacon
#

Put your folder somewhere else

vivid hill
sacred mountain
#

@ivory sleet whats the difference between your

return Arrays.stream(objects).allMatch(Objects::nonNull);```
and
```java
return !Arrays.stream(objects).anyMatch(Objects::isNull);```
#

just an idea since it might be faster to finish at one null

sacred mountain
#

instead of check them all

sacred mountain
#

my brain isnt braining

#

one sec

sterile token
#

Are cryptos allow on spigot? Not mining

lost matrix
# warm saddle Heyo how would I go about make a Bukkit Runnable that used a random time each ti...
@AllArgsConstructor
public class SelfRepeatingRandomTimeRunnable extends BukkitRunnable {

  private final JavaPlugin plugin;
  private final Runnable wrappedRunnable;
  private final int minTime;
  private final int maxTime;

  @Override
  public void run() {
    wrappedRunnable.run();
    int delay = ThreadLocalRandom.current().nextInt(minTime, maxTime);
    new SelfRepeatingRandomTimeRunnable(plugin, wrappedRunnable, minTime, maxTime).runTaskLater(plugin, delay);
  }

}
sacred mountain
#

ok nvm yeah my question still works

kind hatch
sterile token
#

Basically mc player mining but fake crypto

#

Do i explain?

tall dragon
sacred mountain
rain echo
#

Hi! Should I create a separated class for my every custom inventory, or can I create only one and add all the events there?

frank stone
#

I'm pretty new to spigot and just made my first plugin which changes the join and quit message for players. I'm now wondering if there is a way to remove the color prefix from the message in the console. I don't want my logs to be in color or anything. What I want is that the console logs,

[22:03:35] [Server thread/INFO]: swamp4frog has left.
instead of
[22:03:35] [Server thread/INFO]: §eswamp4frog§r has left.

sacred mountain
#

coc

tall dragon
#

it should be fine

sterile token
#

My goal is to add a think that x time mines x amount of an int a crypto

lost matrix
sterile token
#

Oh i lol

#

I will check

lost matrix
kind hatch
sterile token
sacred mountain
#

        return Arrays.stream(objects).allMatch(Objects::nonNull);
        return Arrays.stream(objects).noneMatch(Objects::isNull);```
whats the difference
kind hatch
rain echo
#

okay

#

thanks for the answer

sacred mountain
#

ok

green prism
#

OHH!! Thanksss!

#

PreparedStatement ps = plugin.getMySQL().getConnection().prepareStatement("INSERT IGNORE INFO agencies " + "(ID,AgencyName,AgencyOwner,Balance,MaxBalance) VALUES (NULL,?,?,?,?)");
Seems not valid wtf hmhm
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'agencies (ID,AgencyName,AgencyOwner,Balance,MaxBalance) VALUES (NULL,'Microsoft...'

eternal oxide
#

an AgnecyName that starts Microsoft ?

green prism
#

yep

#

It's the given Agency Name

lost matrix
humble tulip
#

Did u mean to do insert info or into?

lost matrix
lost matrix
tall dragon
#

😦

green prism
#

i'm poor

#

free* budget for this plug-in

lost matrix
#

not sure. But if you are a student (school or university, doesnt matter) then you get it for free

tall dragon
#

yeaa

#

but im not

lost matrix
#

F

tall dragon
#

and its way too expensive imo for someone just hobbying

#

for companies. sure i can understand the price

sacred mountain
#

hey uh

#

theres nothing in this file

#

and theres no error message

#

what do i do with it

tall dragon
#

its like 150 euros a year

lost matrix
green prism
sterile token
#

Why still Command#getName()?

tall dragon
#

its not that bad. but idk if im willing to pay that just to have sql support

untold jewel
#

How would I make args[0] from commandclass usable in a Listener class

tall dragon
#

is there anything else usefull?

sacred mountain
green prism
lost matrix
sterile token
#

What do you need

eternal oxide
green prism
#

ah

#

hm

sterile token
#

LightFurry i can help you, what the issue?

sacred mountain
#

is that github

#

or an error

sterile token
#

You are asking why the file is in red?

sacred mountain
#

yes

sterile token
#

But hy you care if it works?

untold jewel
#

How would I make args[0] from commandclass usable in a Listener class

sacred mountain
#

as in

#

i think theres like

#

autocomplete for the syntax

#

if i connect to the database

#

but i cant see any database thing anywhere

sacred mountain
#

o

#

thank

subtle folio
#

is there way to auto import in intellij?

lost matrix
sacred mountain
# lost matrix

do i need to put the database.db in the resources folder before testing connection?

untold jewel
sacred mountain
#

and will just database.db work in the name field

#

because you put something that looks like a path

lost matrix
lost matrix
elder birch
#

i have a question

lost matrix
sacred mountain
#

uh

subtle folio
green prism
#

@eternal oxide Workz!!! Thanks bro, you made my day 🙂

elder birch
#

how do i setup a region to spawn mobs

lost matrix
untold jewel
lost matrix
glass mauve
#

how can I turn Bukkit.getOnlinePlayers() into List<Player>?
is this valid? Bukkit.getOnlinePlayers().stream().map(Player::getPlayer).collect(Collectors.toList());

subtle folio
lost matrix
sterile token
ivory sleet
#

yes

elder birch
lost matrix
glass mauve
#

it returns Collection<? extends Player>

ivory sleet
#

List<CraftPlayer> iirc

glass mauve
#

im not sure if cast works

ivory sleet
#

but ye

#

that stream works

glass mauve
sacred mountain
# lost matrix

aight ive done this, how do i view the database? i dont see any of the columns i added showing up

lost matrix
elder birch
glass mauve
sacred mountain
#

its grey

subtle folio
#
List<Player> playersAvaible = new ArrayList<>();
        for (Player player : Bukkit.getOnlinePlayers()) {
            playersAvaible.add(player);
        }```
sacred mountain
subtle folio
#

List

lost matrix
ivory sleet
subtle folio
sacred mountain
#

idk where my getOnlinePlayers comes from but its interesting

lost matrix
#

Also ArrayList has a bulk constructor.

  public List<Player> getOnlinePlayerList() {
    return new ArrayList<>(Bukkit.getOnlinePlayers());
  }
subtle folio
#

ok fam

glass mauve
#

👍

elder birch
lost matrix
elder birch
#

i already have a random vector so makes it easier

sacred mountain
#

whats the best way to get all players with a certain attribute? like if theyre in creative mode, they have a permission, theyre in the nether, etc

#

is there an easy syntax for it or do i just for loop it

#

well not easy syntax,. but efficient

tall dragon
#

if you want to do it based on all kinds of different attributes

lost matrix
sacred mountain
#
public static Collection<? extends Player> getWorldPlayers(World world) {
        List<Player> players = new ArrayList<>();
        for (Player player : BukkitUtils.getOnlinePlayers()) {
            if (Objects.equals(player.getWorld(), world)) {
                players.add(player);
            }
        }
        return players;
    }```
something better than this
tall dragon
#

you could make a method that tests using a predicate

ornate patio
#

How do i give a play a water bottle? all drinkable items fall under the item "potion"

sacred mountain
tall dragon
sacred mountain
#

no as in

#

never used them

#

im googling lol

tall dragon
#

wait let me show u

sacred mountain
#

alr

#

iirc its the arg before the lambda

#

or is that wrong

sterile token
#

Where i cando recomm for spigot?

#

Is there a page for recommendation?

lost matrix
# sacred mountain whats the best way to get all players with a certain attribute? like if theyre i...

For the iterative approach:

  // Abstraction
  public List<? extends Player> getAllPlayersWhere(Predicate<Player> filter) {
    return Bukkit.getOnlinePlayers().stream().filter(filter).toList();
  }

  // Example implementations
  public List<? extends Player> getAllCreativePlayers() {
    return getAllPlayersWhere(player -> player.getGameMode() == GameMode.CREATIVE);
  }

  public List<? extends Player> getAllLowHealthPlayer() {
    return getAllPlayersWhere(player -> player.getHealth() < 5);
  }
tall dragon
#
    public void test()
    {
        getPlayers((player) ->
        {
            return player.getGameMode() == GameMode.CREATIVE
        });
    }

    public Set<Player> getPlayers(Predicate<Player> condition)
    {
        Set<Player> players = new HashSet<>();
        for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
            if (condition.test(onlinePlayer)) players.add(onlinePlayer);
        }
        return players;
    }
#

for example

elder birch
# lost matrix I would define the area on a lower level (architectural wise) as a BoundingBox. ...

public void spawnMobs(int size, int mobCap, int spawnTime) {
task = new BukkitRunnable() {
@Override
public void run() {
int spawnAmount = (int) (Math.random() * (mobCap + 1)), count = 0;
while(count <= spawnAmount) {
count++;
int ranX = getRandomWithNeg(size), ranZ = getRandomWithNeg(size);
Block block = world.getHighestBlockAt(ranX, ranZ);
Location loc = block.getLocation().clone().add(0, 1, 0);

                world.spawnEntity(loc, EntityType.ZOMBIE);
            }
        }

    }.runTaskTimer(this, 0L, spawnTime);
}

@Override
public void onDisable() {
    Bukkit.getLogger().info("Plugin Disabled");
}

private int getRandomWithNeg(int size) {
    int random = (int) (Math.random() * (size +1));
    if (Math.random() > 0.5) random *= -1;
    return random;
}

}

sacred mountain
#

ow

tall dragon
#

wowww

elder birch
#

that the code handleing the mob spawning currently

tall dragon
#

please use ?paste for alot of code

elder birch
#

okay soz

subtle folio
#

0L 😦

sacred mountain
elder birch
#

?paste

undone axleBOT
sacred mountain
tall dragon
sacred mountain
#

infinitely fast infact

tall dragon
#

that will now return a Set of only all online players that are in creative mode

ornate patio
sacred mountain
lost matrix
sacred mountain
#

which method do you think is better?

elder birch
#

so how could i implement the BoundingBox into my current code

tall dragon
sacred mountain
#

lo

#

l

tall dragon
#

cant argue with that logic

sacred mountain
#

true true

tall dragon
#

but smile's example is doing bassically the same thing

#

its pretty neat

sacred mountain
#

Thread.sleep(50000)

#

fast

#

because like

#

its one line

tall dragon
#

System.exit(1);

glass mauve
#

how can I use TabCompleter for two args

tall dragon
#

faster 😄

sacred mountain
crude loom
lost matrix
# elder birch https://paste.md-5.net/gawajabela.java

First improvement i would apply.

    private int getRandomWithNeg(int size) {
        int random = (int) (Math.random() * (size +1));
        if (Math.random() > 0.5) random *= -1;
        return random;
    }

to

  private int getRandomWithNeg(int size) {
    return ThreadLocalRandom.current().nextInt(-size, size + 1);
  }
elder birch
#

makes sense thats

#

thanks*

glass mauve
lost matrix
elder birch
#

Block block = world.getHighestBlockAt(ranX, ranZ); is returning as null and i cant seem to figure out why

ornate patio
#

is it possible to get rid of this "No Effects" lore from a water bottle?

ornate patio
#

I've already tried waterBottleMeta.setLore(null); but it doesn't work

crude loom
# glass mauve I dont get it, how can I check which argument im at
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
   if(command.getName().equalsIgnoreCase("yourcommand"){
   if(args.length == 1)
      return Arrays.asList("first autocomplete")
   else if(args.length == 2)
      return Arrays.asList("second autocomplete")
  }

}
glass mauve
#

yea already got it

elder birch
lament swallow
#
String[] words = event.getMessage().split(" ");
for(String word : words) {
    for(Player p : Bukkit.getOnlinePlayers()) {
        if(p.getName().equals(word)){
            p.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 2, 1);
            event.setMessage(event.getMessage().replaceAll(p.getName(), ChatColor.translateAlternateColorCodes('&', "&a&o" + p.getName() + "&r&f")));
        }
    }
}```
Anybody knows why this doesn't play the the sound to a mentionned player in the chat?
lost matrix
worldly ingot
ornate patio
#

thanks

lost matrix
lost matrix
lament swallow
#

lemme check

crude loom
#

maybe you should use equlsignorecase ?

lost matrix
ornate patio
#

is there a lower and upper bound to AbstractHorse#getJumpStrength()

lost matrix
#

You should use Bukkit.getPlayer(String) instead

ornate patio
#

or can i have spaceship horse with 1000 block jump height

lost matrix
lament swallow
lost matrix
tall dragon
#

as far as i know it will always be a player

lost matrix
#

I have yet to find an occasion where a mere HumanEntity clicks an Inventory...

tall dragon
#

how do i do?

lost matrix
#

Fine i guess? Thats a random question...

#

Just blindly cast it. And tell no one i said that.

crimson comet
#

I'm getting a regression between my tests with mc 1.17.1-1.18.2 and 1.19 with my HeadSweeper plugin. It works fine in 1.18.2 and earlier, but when using spigot or paper 1.19 the head seems to lose its nbt data and just becomes a steve head. This only happens when the head is left-clicked, not when it is right-clicked. Attached is the piece of code that should cancel the player interact event. Any idea why this could be happening? Is this a client-side or a server-side issue?

lost matrix
#

Just ask the one who clicked politely. In most cases they will just tell you if they are a player or not.

tall dragon
lost matrix
hybrid spoke
crimson comet
lost matrix
covert karma
#

whats the "heart beating" sound effect that hypixel uses in murder mystery assassin mode

hybrid spoke
rain meadow
#

I have a problem with my InventoryClickEvent where it is only being registered when I click on an item out of an inventory. I'm trying to detect when a player places an item into a gui instead

crimson comet
lost matrix
#

oof

crimson comet
#

But I think the metadata isnt the issue, because the other code afterwards does run.

lost matrix
crimson comet
lost matrix
elder birch
#

and a line establashing world and a World

lost matrix
elder birch
#

Thacks for the help!!

lost matrix
rain meadow
#

If I use the actual inventory

#

it dont work

cinder spindle
#

Hey
I have an existing plugin what uses gradle, but I cant import spigot library into the project, can anyone help me? 🙂

rain meadow
#

pretty sure

lost matrix
lost matrix
cinder spindle
#

I've never used gradle

pale egret
lost matrix
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

pale egret
rain meadow
lost matrix
undone axleBOT
pale egret
#

no

rain meadow
#

nothing happens?

round elbow
#

how can i use pterodactyl's api in a spigot plugin

pale egret
#

nothing happens

lost matrix
rain meadow
#

Have you registered it in your main and plugin yml?

ornate patio
#

more of a Java question, but

private static <E extends Enum<E>> E getRandom() {
    Random random = new Random();
    return E.values()[random.nextInt(E.values().length)];
}

I'm trying to make this method return a random enum value from a given enum, but I'm getting The method values() is undefined for the type E. What's the correct way to do this?

eternal oxide
pale egret
#

I did this

    getCommand("gmc").setExecutor(new Creative());
    getCommand("gms").setExecutor(new Survival());
    getCommand("gmsp").setExecutor(new Spectator());
#

wait, I need to set the permission in the plugin.yml

quartz basalt
#

vault is a dependency in my plugin and i have
private boolean setupEconomy() { if (getServer().getPluginManager().getPlugin("Vault") == null) { return false; } RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class); if (rsp == null) { return false; } econ = rsp.getProvider(); return true; } public static Economy getEconomy() { return econ; }
whjcih is called when my plugin is enabled but whenever i use getEconomy() its always null, why is this happening? vault is on my server, its a dependency, so this makes no sense

  - Vault```
eternal oxide
pale egret
eternal oxide
#

Do you even have an eco plugin?

lost matrix
eternal oxide
#

each command has its own permision

#

permission: plugin.gmc

ornate patio
#

do i take in the enum class as a parameter instead?

lost matrix
# ornate patio wdym

Like this for example:

  private static <E extends Enum<E>> E getRandom(Class<E> enumClass) {
    Random random = ThreadLocalRandom.current();
    E[] constants = enumClass.getEnumConstants();
    return constants[random.nextInt(constants.length)];
  }
ornate patio
#

thanks

eternal oxide
#

add some sysouts to see how far its getting

quartz basalt
#

already have it thinks vault doesnt exist

#

but it 100% does

lost matrix
eternal oxide
#

Your plugin would not start if Vault didn;t exist as its a depend

rain meadow
lost matrix
lost matrix
rain meadow
#

Ah no. So I have a gui. And I'm placing an item into it. I'm trying to detect it but the event only triggers when I take the item out of the gui

crude loom
#

Try to also use InventoryDragEvent?

lost matrix
rain meadow
crimson comet
lost matrix
broken marlin
#

Hi ya'll, I'm new to spigot and I'm trying to learn about good conventions for putting a cooldown on handling events.

For example, lets say we wanted to message a player the block that they're standing on every 1 second whenever they move,
I'm trying to find a good standard to practice this since most events are not handled every single tick.

Here is some java/pseudocode for the ideas

// approach 1: check every tick for player move event and only issue message after 1 second
//   this feels kind of inefficient because you have to listen for every single PlayerMoveEvent, but maybe its the standard?
//   we can also clean this up and handle this as a new event
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    // keep track of time in map somewhere
    int ticks = SomeTimeKeepingMap();
    if (ticks % 20 == 0) {
      player.message("you are standing on this block %s");
    }
}
// approach 2: issue a BukkitRunnable task to manually check PlayerMoveEvent every 20 seconds (not sure how to manually listen though)
//   sucky because infinite loop but more efficient than the first
//   also sucky because this seems like spaghetti code and not a correct approach for the problem
public class MessagePlayerAboutBlockBelowTask extends BukkitRunnable {
    private final JavaPlugin plugin;
    private int counter;

    @Override
    public void run() {
        // check event on time
        if (counter % 20 && plugin.listenForPlayerMoveEvent()) {
            player.message("you are standing on this block %s");
        }
    }
}

// and then later start this task on plugin enable
// approach 3: this was my first intuitive approach
//   I truly don't believe this is possible but maybe I'm missing something that makes this a standard convention

// Listener.java
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    // run task that constantly checks every second and cancels when no more player movement
    BukkitTask task = new MessagePlayerAboutBlockBelowTask(plugin).runTask(plugin);

    // make listener synchronously wait for task to finish (I don't think this method exists anywhere)
    this.waitForTaskToFinish(task);
}
lost matrix
crimson comet
#

Async board update?

rain meadow
broken marlin
#

what's an async board update?

crimson comet
#

Headsweeper is minesweeper using heads in minecraft. I meant in response to 7smile7 as solution for my problem

#

where I update the minesweeper board asynchronously.

broken marlin
#

that's a pretty cool concept o:

lost matrix
broken marlin
#

But yeah in that case if we just want every 1 second regardless of player movement, we would just loop through forever with a task I think

small current
harsh totem
#

so I have this line: private final JSONObject obj = new JSONObject();
and I use obj.remove() and obj.put() and it works fine but no json file is created and idk why

#

its json-simple

ivory sleet
#

I mean

cinder spindle
ivory sleet
#

you need to write the object through some dumpster

harsh totem
#

wdym

lost matrix
# broken marlin The example I put is not the best use case, but I am specifically wondering abou...

There are very few circumstances where adding a cooldown on an event makes any sense.
But here is a trivial approach

  private static final long MAX_MILLIS = 1000L;
  private final Map<UUID, Long> moveEventTimestamps = new HashMap<>();

  public void onMove(PlayerMoveEvent event) {
    long lastMoved = moveEventTimestamps.computeIfAbsent(event.getPlayer().getUniqueId(), key -> 0L);
    if(System.currentTimeMillis() < lastMoved + MAX_MILLIS) {
      return;
    }
    event.getPlayer().sendMessage("You moved.");
  }
ivory sleet
#

use JSONParser ytg

lost matrix
lost matrix
broken marlin
lethal coral
#

is there any way that I could generalize this

lost matrix
broken marlin
#

Does anyone have any public github repos available of their own plugin projects that you wouldn't mind sharing? I think it would be nice to learn by example 😅

lethal coral
# lost matrix More context pls. This looks like a design problem. Casting is the only way to i...

so basically I'm making a skript addon. I have to make an enum so that I can correctly register the persistent data types and allow the users to just type those in (since they're variables in the actual persistentdatatype class)

This is the enum

public enum PersistentDataType{
    SHORT(org.bukkit.persistence.PersistentDataType.SHORT),
    INTEGER(org.bukkit.persistence.PersistentDataType.INTEGER),
    LONG(org.bukkit.persistence.PersistentDataType.LONG),
    FLOAT(org.bukkit.persistence.PersistentDataType.FLOAT),
    DOUBLE(org.bukkit.persistence.PersistentDataType.DOUBLE),
    STRING(org.bukkit.persistence.PersistentDataType.STRING);
    /*
    Removed the below tags due to issues setting & getting
    INTEGER_ARRAY(org.bukkit.persistence.PersistentDataType.INTEGER_ARRAY),
    LONG_ARRAY(org.bukkit.persistence.PersistentDataType.LONG_ARRAY);*/

    private final org.bukkit.persistence.PersistentDataType<?, ?> type;

    <Z, T> PersistentDataType(org.bukkit.persistence.PersistentDataType<T, Z> type){
        this.type = type;
    }

    public org.bukkit.persistence.PersistentDataType<?, ?> getType() {
        return type;
    }
}
ruby fjord
#

since Which spigot API version CustomModelData, in ItemMeta class has been implemented?

lethal coral
#

and I don't want to have to switch each and every one of those to supply the type in the PersistentDataContainer#set() method, the whole reason of why I'm trying to save the var in each enum value

lost matrix
lethal coral
#

a-ha!

#

thank you sir

lost matrix
#

*Not sure if this works

iron glade
#

I ran into the same problem again, the config is not saving its comments

ruby fjord
lost matrix
ruby fjord
#

so it was in 1.13

harsh totem
#

it says fileNotFound

        JSONParser parser = new JSONParser();
        try (Reader reader = new FileReader("src/main/resources/data.json")) {
            JSONObject jsonObject = (JSONObject) parser.parse(reader);
            jsonObject.put(location,amplifier);
        } catch (IOException | ParseException e) {
            throw new RuntimeException(e);
        }
    }```
#

but it's here

tender shard
#

it's in /data.json

#

also I doubt that you can just use a FileReader to read a resource

tardy delta
#

you can just do plugin.getResource

#

to get an inputstream iirc

harsh totem
tender shard
#

as I said, you cannot just use a FileReader because you don't have any file at that path

#

you only have a resource in your .jar

#

so you do plugin.getResource or plugin.saveResource as fourteen said

#

where else would it be? o0

harsh totem
#

I was told that it must be there

tender shard
#

yes

#

it belongs into resources

iron glade
#

yea it has to be there

tender shard
#

that's correct

#

it would be weird to have it anywhere else

harsh totem
#

wait so what about the fileNotFound problem?

tender shard
#

everything in "resources" gets put into the root "folder" of your .jar

#

whether it ends up in your plugins data folder depends whether you tell your plugin save it there

harsh totem
tender shard
#

use an InputStreamReader

harsh totem
#

what

tender shard
#

you save it to file of course

#

JavaPlugin#saveResource("/config.yml") for example takes the config.yml out of the .jar and saves it

#

in the data folder

tender shard
#

what do you need data.json for?

#

you can easily save included files with saveResource()

harsh totem
#

how would you have done this?

tender shard
harsh totem
tender shard
#

no, why?

harsh totem
#

whereelse it would be saved if not in there

tender shard
#

in the plugin's data folder

#

like in /plugins/ChestSort but definitely not inside the .jar itsef lol

harsh totem
#

i don't see any data folder in the project

tender shard
#

of course not. the data folder is on the server

#

plugins/ChestSort/...

#

that's the data folder

harsh totem
#

ok

tender shard
#

it's where an admin expects to find the config.yml file

#

there you can save your json file

#
File myJson = new File(plugin.getDataFolder(), "myJson.json");
tardy delta
#

plugin#saveResource -> will save the provided file from the resources folder to the datafolder of the plugin, so /server/plugins/<your plugin>

pale egret
#

does anyone know a good server host that is pretty cheap and has good performance

quaint mantle
#

Minejut

tardy delta
quaint mantle
#

minehut

#

@pale egret minehut is epic

harsh totem
tender shard
#

?learnjava

undone axleBOT
pale egret
tender shard
#

"plugin" is of course a reference to your plugin's instance

quaint mantle
#

well

tender shard
#

for example "this" in your main class

harsh totem
tender shard
#

yeah then use that

harsh totem
#
    public newLimit(JavaPlugin plugin) {
        this.plugin = plugin;
    }```
newLimit is the class name
harsh totem
tardy delta
undone axleBOT
tardy delta
#

mwh ye you already got it

iron glade
#

is 1.19 having problems with saving comments in config or wtf is going on

tardy delta
#

and name your class names with an uppercase letter

iron glade
#

enable what?

harsh totem
#

can you send me a basic example plugin because i actually don't understand what to do?
i'll understand if not

tender shard
#
MemoryConfiguration.options().parseComments(true);
iron glade
#

no I just use saveDefaultConfig() in the onEnable

tender shard
#

saveDefaultConfig() will save the comments.

iron glade
#

as I thought parseComments is true by default

tender shard
#

saveDefaultConfig() simply saves the file exactly as it is

iron glade
#

why is this then only putting the header as a comment

#

the config

tender shard
#

I highly suspect that you save the file manually again later instead of only calling saveDefaultConfig

iron glade
iron glade
tender shard
# iron glade

is this the result of doing NOTHING besides calling "saveDefaultConfig()"?

modest garnet
#

first time using mysql but whenever i join the server i get this error and my data is not saved anyone know what this means
if they need any files just let me know
https://paste.md-5.net/dapeyenaho.sql

tender shard
#

your SQL statement is incorrect

modest garnet
#

do you know what line

tender shard
#

what's the SQL statement in CustomPlayer line 44?

modest garnet
tender shard
#

yeah but what's the statement

humble tulip
#

No the statement

modest garnet
#

PreparedStatement statement1 = plugin.getDatabase().getConnection().prepareStatement("INSERT INTO players (ID, NAME, UUID, balance, minecoins, crystals) VALUES (" +
"default," +
"'"+Bukkit.getPlayer(uuid).getName()+"'" +
"'"+uuid.toString()+"'" +
0 +
0 +
0 + ");" );

tender shard
#

use code blocks pls

iron glade
humble tulip
#

?paste it atleast

undone axleBOT
humble tulip
#

Why are u using prepared statements without ?s

harsh totem
#

I have started a raid and waited for the pillagers to win and they killed all the villagers but the raid hasn't been finished.
i've been waiting for half an hour after the villagers were dead and nothing happens.
any ideas?

tender shard
tender shard
tender shard
#

do you know basic SQL?

#

because that cannot possibly work

harsh totem
tender shard
#

your SQL statement should look like this:

modest garnet
tender shard
#
PreparedStatement statement = ...prepareStatement("INSERT INTO players (ID, NAME, UUID, BALANCE, MINECOINS, CRYSTALS) VALUES (?, ?, ?, ?, ?, ?)");
statement.setInt(1, someId);
statement.setString(2, someName);
....
opal juniper
#

noone needs to learn SQL realistically

#

i just get gh copilot to generate it for me

sacred mountain
#

can someone explain the difference between String.valueOf and .toString()

#

they seem to do the same thing after testig

lost matrix
#

null safety

sacred mountain
#

which one?

#

the vlaueOf

modest garnet
#

this look better?

tender shard
sacred mountain
#

toString will throw npe right if null

tender shard
sacred mountain
#

but valueof will return 'null'

tender shard
#
    public static String valueOf(Object obj) {
        return (obj == null) ? "null" : obj.toString();
    }```
ivory sleet
#

toString is nice if you wanna assert non nullness

#

else go with valueOf

tender shard
#

someObj.toString() = NPE if someObj is null

tender shard
#

String.valueOf(someObj) is "null" if someObj is null

tender shard
sacred mountain
#

oh right

#

thanks :)

modest garnet
tender shard
modest garnet
#

yes

tender shard
#

okay then simply do not provide the ID in your statement

#

one sec

#

here - you simply do not tell it about ID and then mysql will use the default value which in this is the auto incremented value

modest garnet
#

ahh ok yes ty

iron glade
#

How do I keep the comments when changing a value in the config?

tender shard
#

yourConfig.options().parseComments(true)

iron glade
#

like, let's say I do getConfig().set("SomeValue", true);

#

after that I would have to use saveConfig() ?

tender shard
#

I think so

iron glade
#

but saveConfig() removes the comments

tender shard
#

even when you set parseComments(true) ?

iron glade
#

I'll try

#

substring?

tender shard
#

yeah of course - substr

#
if(myString.length() > 1024) {
  myString = myString.substring(0,1024);
}
#

I normally put that into a method if I need it more than once

    public static String subStringIfTooLong(String string, int length) {
        if(string.length() <= length) return string;
        return string.substring(0,length);
    }```
iron glade
#

but how else would I save the config after I changed a value in it?

quaint mantle
#

Sorry for this being a simple question, I’m just unable to find the answer online.
Would ProxyServer#getPlayer(uuid)#getName() be able to return the uuid of a player that has joined the bungee network but is currently offline?

subtle folio
#

Can I make a new thread and run bukkit schedulers on it?

lost matrix
lost matrix
subtle folio
#

on the new thread..

lost matrix
#

So first of all: You cant run a scheduler. A scheduler schedules tasks.
Im not entirely sure what you are asking. But the BukkitScheduler is thread safe which means you can schedule runnables
from within another thread context.

ornate patio
#

how do i get the default no permission message

#

I want to get a command's no permission message, but if it doesn't exist, then get the actual server default message, ("I'm sorry, but you do not have permission...")

lost matrix
# lost matrix So first of all: You cant run a scheduler. A scheduler schedules tasks. Im not e...

So this

new Thread(() -> Bukkit.getScheduler().runTask(SpigotSandbox.this, () -> System.out.println("Hi"))).start();

Or this

CompletableFuture.runAsync(() -> Bukkit.getScheduler().runTask(SpigotSandbox.this, () -> System.out.println("Hi")));

Or this

ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(() -> Bukkit.getScheduler().runTask(SpigotSandbox.this, () -> System.out.println("Hi")));

Is completely safe.

shadow gazelle
#

What happened to Particle.BARRIER after 1.16?

lost matrix
ornate patio
#

damn

lost matrix
#

Well not so bad after all because you can just create a constant

ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is a mistake."

And send it instead.

ornate patio
#

I guess I'll just copy that

#

thanks so much 🙏

lost matrix
#

Honestly this should be in the spigot.yml

ornate patio
#

it should

steep nova
#

Is there an event that gets called when a gravel/sand/dragon egg block is destroyed by a torch?

shadow gazelle
#

Never mind, found it

steep nova
lost matrix
oak thorn
#

Hey, I am trying to prevent players from using commands while in an active arena match in my PvP plugin. It seems to me that cancelling the command in the PlayerCommandPreprocessEvent is the best solution, however I can not get this event to trigger what so ever. Any ideas as to why it won't run?

lost matrix
oak thorn
#
getServer().getPluginManager().registerEvents(new Main(), this);

That should do it, in the onEnable(). Right?

lost matrix
oak thorn
#

Yup. Can I not do EventHandling in the JavaPlugin class?

subtle folio
#

naming main class main uhoh

lost matrix
subtle folio
lost matrix
#

^

oak thorn
#

Replacing new Main() with "this" fixed it actually. But would it be beneficial for me to separating anyways?

lost matrix
#

Separation of concerns is another one that tells you to... separate your concerns. Its more abstract but still applies.

oak thorn
#

Aha, makes sense! I'll make a separate class for listeners then. Thanks for clearing things up for me guys, very new to spigot development so forums like these are invaluable 🙂

untold jewel
#

?paste

undone axleBOT
untold jewel
#

Does not give console error but the command does not work. I really dont know what it is

brave sparrow
untold jewel
#

Yes sir

brave sparrow
#

Can you show your plugin.yml

#

And also, can you define “does not work”

untold jewel
#

name: TargetGUI
version: '${project.version}'
main: com.william.targetgui.Main
api-version: 1.19
commands:
target:

#

now it gives out a error though

brave sparrow
#

For one thing you need a return in the command when you check if the sender is a player

untold jewel
#

the command should be /target [player]

brave sparrow
#

You’re going to want to return true if the command succeeded, not false

#

The target player should not be static

sterile token
#

Im trying to compile smth for a friend but intellij complain saying: "cannot access net.grandtheftmc.gliders.listeners" when the packet is there

untold jewel
#

need it for Listener...

brave sparrow
#

You’re going to need to pass it around

brave sparrow
#

If two people run the command that’s going to overwrite one of them

untold jewel
brave sparrow
shadow gazelle
#

Is there some issue with enchanted items in crafting recipes?

#

Other than the table not forcing you to match them exactly

shadow gazelle
#

This was working the other day and now it just isn't working

steep nova
brave sparrow
brave sparrow
shadow gazelle
#

Forgot to add this to that message, there's another recipe that's eight enchanted items and one normal item, it works

#

With both I'm checking to make sure that the items provided have the custom name and enchantment for the glow

brave sparrow
#

Sounds like the enchantment is not the issue then

#

Can you show your code?

shadow gazelle
#

It works with the 1.16 API, there's no difference in the recipes

brave sparrow
shadow gazelle
#
    public static ShapedRecipe soulVialRecipe() {
        RecipeChoice.ExactChoice sgRC = new RecipeChoice.ExactChoice(soulGlass());
        RecipeChoice.ExactChoice soulariumRC = new RecipeChoice.ExactChoice(soularium());
        NamespacedKey svKey = new NamespacedKey(plugin, "empty_soul_vial");
        ShapedRecipe svRecipe = new ShapedRecipe(svKey, emptySoulVial());

        svRecipe.shape(" S ", "G G", " G ");
        svRecipe.setIngredient('S', soulariumRC);
        svRecipe.setIngredient('G', sgRC);
        return svRecipe;
    }
#

There's the recipe for what isn't crafting

#

The recipes for the other two items it uses are working

brave sparrow
#

Let’s see the working ones

shadow gazelle
#

oh, wait

brave sparrow
#

Lol

shadow gazelle
#

how the hell did I not notice that

brave sparrow
#

Ding

shadow gazelle
#
            if (!inventory.getResult().isSimilar(emptySoulVial()) && inventory.contains(soularium(), 1)) {
                inventory.setResult(new ItemStack(Material.AIR));
            } else if (inventory.getResult().isSimilar(emptySoulVial()) && (!inventory.contains(soulGlass(), 3)
                    || !inventory.contains(soularium(), 1))) {
                inventory.setResult(new ItemStack(Material.AIR));
#

🤦‍♂️

brave sparrow
#

That’ll do it

shadow gazelle
#

Now I wonder if the issue with the drop event is caused by something stupid like that, too

lost matrix
shadow gazelle
#

as in add a custom tag to the items?

steep nova
lost matrix
upper tendon
#

How do you clear advancements from a player?

shadow gazelle
#

nice

#

some plugin in my server is messing with my plugin

paper oxide
#

how would I stop players from opening any chest ?

eternal oxide
#

in the InteractEvent check if its a Chest and cancel the event

paper oxide
#

1.8*

shadow gazelle
#

Still the same

pastel juniper
#

I made a custom snowball with PersistentDataContainer, when I throw the snoball does it keep it's PDC???

eternal oxide
#

no, you have to apply it to the projectile

pastel juniper
#

Can I spawn a projectile with custom texture???

eternal oxide
#

yes

pastel juniper
shadow gazelle
eternal oxide
#

?paste

undone axleBOT
eternal oxide
#

It puts MetaData on the Snowball, but you can use PDC too

#

It allows you to throw spawn eggs instead of having to place them

pastel juniper
eternal oxide
#

if you are using custom model data then get teh meta and set it. Don;t forget to put the meta back on the snowball

pastel juniper
steep nova
#

How do I check whether the ender dragon egg has been broken by a piston?

jagged goblet
#

Can someone explains me what is the purpose of Maven/Gradle? Cause I can't figure it out myself, it's like doing everything I've done so far but everytime I need to add a dependency I have to copy paste some stuff in pom.xml

untold jewel
#

So I'm making a /target <player> plugin. When you do /target <player> and he is online you get a GUI which you can use to effect the specified player. For example click in the inventory to kill. But it seems like I cant figure out how to store the args[0] as a UUID for my Listener class. Since when I use the GUI it should execute it

#

I dont know if that made any sense but

pastel juniper
#

I 've made sth similar

eternal oxide
untold jewel
pastel juniper
#

Give me a second

untold jewel
#

I can also send the classes if needed'

young shell
#

Is it possible to convert BlockData to MaterialData or the other way around?

eternal oxide
jagged goblet
eternal oxide
untold jewel
#

I want to know how I can use or store the target in my Listener calls

jagged goblet
untold jewel
#

class

eternal oxide
pastel juniper
untold jewel
jagged goblet
sharp token
eternal oxide
sharp token
#

@untold jewel can you send your class and tell me what the exact issue is?

untold jewel
#

I can, thank you

grand flint
#

What do you call this and how can I change it

humble tulip
#

Playercount

#

Listen to serverlistpingevent

untold jewel
#

But I cant access args[0] or target from my listeners class

#

and I dont know how I can store the target or use it

humble tulip
#

Args 0 is the player

#

So the method u use to open the gui

#

It should open it for the player

grand flint
#

Thank you

humble tulip
#

But also let that method takenthe target as well

#

I cant click your listener class btw

sharp token
#

/target [arg0] [arg1] [etc]

#

yes like he said arg0 is going to be the player name

untold jewel
#

I just want to know how I can access target from my listeners class

humble tulip
#

U need to have a map somewhere

sharp token
#

Player target = event.get.... etc

untold jewel
#

I have target = bukkkit.getPlayerExact(args[0]) but in listeners I want to use target.setHealth(0)

humble tulip
#

Maybe in ur main class

sharp token
#

yes

humble tulip
#

So map<uuid, uuid>

#

First uuid is of the sender, second is target

#

When they run tje command, put them in this map

#

When they close tje inv remove them

#

The*

#

The same way u put targetgui in the constructor, u can put targetmap

sharp token
#

Wait so I have a question about your plugin design, how come you're listening for an inventory click event?

humble tulip
#

It's for a gui

untold jewel
#

I am opening the GUI which im going to punish the target wtih

#

so when I click a block inside the GUI it kills the targeted player

sharp token
#

Ohhhhhh I see.

#

and you want that instance of the target to be in your listener class?

#

Is that what you're asking?

untold jewel
#

Yes so I can use target.something

#

I know maybe these questions are extremly noobie but I appreciate the help !

humble tulip
#

Oblak

novel wyvern
#

i am having problems with bungee and connecting it is telling me SEVERE in everyone and it will not let me do the server command to all of the servers

humble tulip
#

Create a map in ur main class

untold jewel
#

okay..

humble tulip
#

And pass that map to ur listener and command

eternal oxide
#

you don;t need a map, just pass the variables

humble tulip
untold jewel
sharp token
#

Make a static variable for your class, then make a getter for that variable in that class

#

then in your other class use ClassName.get();

#

that's how you could access something from another class

#

But this is much easier if you just do this all with a listening I don't understand why you need a command

#

I recommend rewriting the plugin

eternal oxide
#
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (!(sender instanceof Player)) return;
Player target = Bukkit.getPlayerExact(arg[0]);
if (target != null) new PunishGUI((Player)sender, target);```
sharp token
#

You could do something like a punish command that gives you an item and when you click that item it opens up a GUI that you can interact with

#

this eliminates the need to share any variables

eternal oxide
#

create a PunishGUI class with a constructor which accepts those values

untold jewel
#

Have to say I'm a little confused but I'll give it a go

eternal oxide
#

as you are talking about args I assume you start with a command to open your GUI

sharp token
#

Have a command that gives you a specific "punish" item

#

then do everything in the listener

eternal oxide
#

you don;t need an item

#

the command opens the UI with all the options in it

sharp token
#

That's what I recommended before as well

eternal oxide
#

yep

sharp token
#

Idk I'm just trying to give him options

novel wyvern
#

i am having problems with bungee and connecting it is telling me SEVERE in everyone and it will not let me do the server command to all of the servers

eternal oxide
#

If he has an "admin" type item in game he has to do all sorts of crap to ensure it doesn't end up in a players hands

sharp token
#

That's true yes

#

indeed

untold jewel
#

ElgarL do you want my InventoryManager class too?

eternal oxide
#

I'm not writing it for you 🙂

#

just implement that code I showed you into your existing command

#

for a start

#

your IDE will even tell you there is no PunishGUI class and give you an option to create one

untold jewel
#

I have a targetGUI class

eternal oxide
#

ignore that for now

sharp token
#

in your GUI just make a constructor and initialize your field variables to whatever is fed into the constructor

eternal oxide
#

I want you to use the IDE suggestion to create a Punish class as it will also create teh constructor for you

vocal pine
#

man im at a loss for how to figure out the next exit a minecart will take on a corner
so i have the actual momentum vector
i have the position along either X or Z
i have the pair of exits (relative to the rail it's on)
but i can't figure out how to use these things together to work it out, i keep getting stuck in the same loop

  1. need the exit to figure out if it's past the midpoint (flips velocity)
  2. need to know if it's past the midpoint to figure out the exit

the problem that keeps complicating it is the momentum vector could be just wrong if the player holds a sideways key it'll add momentum that way

eternal oxide
#

get the Direction of the minecart not the velocity

vocal pine
#

wait

#

the actual rotation right

#

Ya hmmmmmmmmmmmmm

#

Thanks i think that could be what i need to work it out

#

just spent 3hrs staring blankly at it waiting for an idea lmao

untold jewel
#

Thansks for the help but it really does not seem to compute

eternal oxide
undone axleBOT
eternal oxide
#

ok scrap your Listener class....

untold jewel
#

throw it out the window

eternal oxide
#

You need a class that handles your GUI, it will have its own Listener, so you'll be combining your targetGUI and your listener class

#

however, this needs to be useablke by more than one admin so you need to instance your targetGUI class

#

um, your code seems super over the top complex

#

ok let me throw an example together

untold jewel
#

complex..

#

thank you friend

undone ruin
#

Is there a way to clone an Entity?
Like have a major Entity (or its data) and use its information to create a new minor Entity?

lost matrix
brave sparrow
undone ruin
lost matrix
undone ruin
#

oh, you gave me a good idea

#

thank you

lost matrix
eternal oxide
untold jewel
#

Thread

eternal oxide
#

sorry I tagged the wrong person 😦

#

oh

#

you just registered ok

steep nova
#

How do you prevent a player from giving the allay a certain item? I tried PlayerInteractEntityEvent but it didnt work

eternal oxide
#

prevent teh player dropping the item

steep nova
ornate patio
#

using optifine, it's possible to have multiple variations for the same color or style with a resource pack. Would it be possible to choose which one of these variations is used server-side?

#

for example the horse color "chestnut" has 5 different colors that are randomly picked from the resource pack, and the horse style "black" has another 7 different variations

#

i want to choose which variation to use

#

idk if this is possible though

#

because on a server restart the variations randomize again

#

(ping me if you respond pls)

polar cypress
#

Cannot determine path to 'tools.jar' library for 17 (C:\Program Files\Java\jdk-17.0.3.1)

#

wat

#

is my intellij outdated or something

kind hatch
ornate patio
#

I was just wondering if there was some kind of "Optifine resource pack" plugin that let me control it

#

Because what’s also interesting is that the same mob looks exactly the same on two different clients

kind hatch
#

Unfortunately, I think that there would have to be an optifine setting added for controlling variations. I think I tried to do something similar and found that optifine just does variations with no way to control it by default.

I’m not an expert on resource packs, but I do know that controlling variation is possible with custom data and if the pack is the one handling the textures, it should work just fine even for optifine players.

#

I know that you can do some things with a resource pack that would only work for players who have optifine installed. (Custom enchantment book tier textures is one example)

#

@ornate patio

polar cypress
#

why doesnt extend javaplugin work now :/

vocal cloud
#

Cause you're missing the dependency

polar cypress
#

i added the jarfile as a library

vocal cloud
#

Use a package manager like maven

polar cypress
#

maven has all those weird parameters for adding dependencies

drowsy helm
#

wdym

#

its a simple copy paste lol

#

far more reliable than jar files

eternal oxide
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

crude estuary
#

Thanks CafeBabe

polar cypress
#

yea i was just told that minecraft shifted to a bundler style jar

golden turret
#

if I send an entity packet like spawn but the entity is far from the player, when the player comes near to the entity, will it show up? What about switching worlds?

tender shard
compact haven
#

kekw maybe they don’t understand that maven just makes each group, artifact, and version more verbose

#

grade literally the same things just in 1 string

subtle folio
#

Say I have a list of YAML strings like this: ```yaml
example:

  • "one"
  • "cars"
#

how would I get all values of example?

tender shard
#

getStringList("example")

subtle folio
#

so like config.getConfigurationSection("bad-words.").getStringList("bad-words.")?

tender shard
#
List<String> list = getConfig().getStringList("example");
for(String line : list) {
  // ...
}
#

erm wait

#

no

subtle folio
#

oh bruh

#

im brain dead

#

ty

#

its too late for me to be programming

tender shard
#

if your config look slike this:

bad-words:
- asd
- asd

then just getConfig().getStringList("bad-words");

subtle folio
#

yep yep

#

asd asd

tender shard
#

truer words have never been spoken

subtle folio
#

100%

subtle folio
#

am back, for some reason my List is empty but my config.yml in my server contains a bunch of strings..

#
public static boolean isOffending(String text) {
        String[] words = text.split(" ");
        Bukkit.getLogger().info(Arrays.toString(words));
        List<String> noNoWords = badWords();
        Bukkit.getLogger().info(noNoWords.toString());
        for (String s : words) {
            Bukkit.getLogger().info(s);
            if (noNoWords.contains(s.toLowerCase(Locale.ROOT))) {
                return true;
            }
        }
        return false;
    }```
#

ignore the logging statements

#
public static List<String> badWords() {
        return Tazpvp.getInstance().config.getStringList("bad-words.");
    }``` badWords function
#

what about your plugin.yml ?

harsh totem
#

right😅

subtle folio
#

nice one 😛

harsh totem
#

this is the error org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.18.2
this is in the pom file <version>1.18.2-R0.1-SNAPSHOT</version>
this is in yml file api-version: 1.18.2

#

why am i getting an error

subtle folio
#

do api-verison: 1.18

harsh totem
#

ok

patent sonnet
#

hello I am have an issue with AdvancementDisplay.getType() intellij is not giving me any code errors but i'm getting build errors
oddly enough the error goes away when I simply comment the snippet out

    class file is invalid for class org.bukkit.advancement.AdvancementDisplayType
    Please remove or make sure it appears in the correct subdirectory of the classpath.

im not the most java savvy but it looks like there is no class but an enum there? (correct me if im wrong)

  • 1.19 server and game
  • api version: spigot-api-1.19-R0.1-20220615.101427-27
  • java 17
ornate patio
mellow edge
#

how can I see the server TPS

#

I mean how can I get it

harsh totem
#

I have this obj.put("Mama", "Joe"); write();
and this public void write(){ try (PrintWriter out = new PrintWriter(new FileWriter("data.json"))) { out.write(obj.toString()); } catch (Exception e) { e.printStackTrace(); } }
and for some reason nothing happens

glossy venture
#

you may have to flush and close it

#

idk

#
out.flush();
out.close();
harsh totem
#

what is flush and close

glossy venture
#

flush makes sure all data has been written

#

so to the disk

#

as it stores it in a buffer first

#

in memory

#

and close closes the file handle i think

#

allows other code to access it

harsh totem
#

@glossy venture the IDE says that there is no need for out.close and i put out.flush like you said and it still did nothing as before

glossy venture
#

bruh

#

idk then

harsh totem
#

:(

#

now I have this try (FileWriter file = new FileWriter("data.json")) { file.write(obj.toJSONString()); file.flush(); } catch (IOException e) { e.printStackTrace(); } and it still does nothing and there are no errors

#

I open the json file and it's empty

tall dragon
#

Why not use Files#write

#

Is so much easier

harsh totem
native nexus
#
public class Json {
    private static final Gson GSON = new GsonBuilder()
            .setPrettyPrinting()
            .create();

    public static void write(Plugin plugin, String fileName, Object object) {
        Path path = check(plugin, fileName);

        try (BufferedWriter bufferedWriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
            GSON.toJson(object, bufferedWriter);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static <T> T read(Plugin plugin, String fileName, Type type) {
        try {
            BufferedReader bufferedReader = Files.newBufferedReader(check(plugin, fileName), StandardCharsets.UTF_8);
            JsonReader jsonReader = new JsonReader(bufferedReader);
            return GSON.fromJson(jsonReader, type);
        } catch (IOException e) {
            return null;
        }
    }

    private static Path check(Plugin plugin, String fileName) {
        Path path = Paths.get(plugin.getDataFolder() + "/" + fileName + ".json");
        try {
            if (!Files.exists(path)) {
                Files.createDirectories(path.getParent());
                Files.createFile(path);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return path;
    }
``` This is what I always use
tall dragon
harsh totem
#

@tall dragon if I have this json file:

{

}
``` will Files#write() write it in the middle line or the first line?
tall dragon
#

Pretty sure you can just have a. Empty file

harsh totem
#

I can't

glossy venture
tall dragon
#

Yea

#

It will

harsh totem
#

ok so I shouldn't use it

tall dragon
#

Ah u need to append to it?

harsh totem
#

why doesn't this do anything?
obj is a JSONObject

        try (FileWriter file = new FileWriter("data.json")) {
            file.write(obj.toJSONString());
            file.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }```
tall dragon
#

No idea

#

I would just load everything im the file as jsonobject. Add what i need to add and write it back using Files#write

harsh totem
#

maybe the path is the problem?

#

idk

hybrid spoke
#

debug

harsh totem
wind sphinx
#

Anyone knows how to check if a player placed a minecart? I want to add a tag to the cart of the player that placed it, but I don't know how to detect if a player placed a minecart.

wind sphinx
#

How do i get the player that placed it?

crude snow
#
@EventHandler
    public void onEntityExplode(EntityExplodeEvent e) {
        for (Block b : e.blockList()) {
            
            final BlockState state = b.getState();
            b.setType(Material.BEDROCK);
            
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                public void run() {
                    state.update(true, false);
                }
            }, 20);
            
        }
    }

Not replacing the block list with bedrock, instead just replacing it with air.
Any fix?

hybrid spoke
crude snow
#

Nvm found a solution.

humble tulip
#
String sql = "SELECT %s.%s,%s.%s,%s,%s,%s,%s FROM %s LEFT JOIN %s ON %s.%s=%s.%s WHERE %s".formatted(TABLE_NAME,UUID_COLUMN,PLAYERS_TABLE_NAME,NAME,CONTENTS,NUMSLOTS,MAXSLOTS,TEMPLATE,TABLE_NAME,PLAYERS_TABLE_NAME,TABLE_NAME,UUID_COLUMN,PLAYERS_TABLE_NAME,UUID_COLUMN, "HELLO");
#

LOL

midnight shore
#

public SkinProperty getSkinProperty(){
GameProfile profile = ((CraftPlayer) getBukkitPlayer()).getProfile();
PropertyMap map = profile.getProperties();
String texture = map.asMap().entrySet().stream().findFirst().get().getValue().stream().findFirst().get().getValue();
String signature = map.asMap().entrySet().stream().findFirst().get().getValue().stream().findFirst().get().getSignature();
return new SkinProperty(texture, signature);
}

This doesn't produce the right texture and signature of a player... can someone help me? 1.18.2

short raptor
#

Hi guys, I've got this other plugin which has an "API" class with some public methods I want to access from my plugin. How can I do it? There's no wiki or docs at all for this plugin

#

In fact I had to decompile the jar to see this (but it's only for personal use, not selling/posting myself, don't worry)

chrome beacon
chrome beacon
short raptor
#

I didn't know that was a thing

#

I'll find out how to do that thx

chrome beacon
#

The world you want to check

#

Well a String is a String and not a world

#

You would have to get the world from the String

#

Bukkt.getWorld(name)

onyx fjord
#

is there a clean way to do an if statement that accepts any candle type other than adding them all with || ?

hybrid spoke
#

switch?

native nexus
#

Anyone comfortable with guice? I need some assistance with managing injections

neon nymph
#

Hello guys, what do I store when I want to store the exact copy of a block, so that whenever I, let's say, right click a different block, it can check whether that block is equal to my stored block?

onyx fjord
#

damn

#

stranger things season 2 intro has brighter letters

neon nymph
#

Yes, the more specific the better

covert karma
#

so i am trying to get the command output of Bukkit.dispatchCommand and I am trying to use a wrapper around the console sender to add this to a stringbuilder like shown in this post
https://www.spigotmc.org/threads/how-do-i-get-the-output-of-dispatchcommand-command-when-called-by-callsyncmethod.354521/
the thing is, the stringbuilder is just empty all the time, does dispatchcommand not use the specified sender to send the results?

drowsy helm
neon nymph
#

I see, that's what I figured as well. Is there really no other stuff I might need?

drowsy helm
#

cant really think of any tbh

neon nymph
#

Alright, thanks for the input! 😄

visual jungle
#

Trying to ignite a creeper when it spawns, there is no .ignite or setFuse() for Creepers.
Any help is appreciated.

#

I am using 1.8 btw.

vocal cloud
#

1.8
Ah that's the issue lol

visual jungle
#

Is there anyway to do it?

chrome beacon
#

You'll have to use NMS then

visual jungle
#

Uh oh

#

okay ty for the help

short raptor
chrome beacon
short raptor
#

I did it like that

#

Was I supposed to do the "From Maven"?

chrome beacon
#

You should never use that menu if you have a maven project

short raptor
#

Oh

chrome beacon
short raptor
#

Ok thx

noble forge
#

Is anyone familiar with PacketWrapper? How would I be able to spawn an area effect cloud with meta data?

#

there is a wrapper to spawn a living entity and one to spawn a (non-living) entity. The living entity wrapper allows to set metadata but the nonliving one doesn't.

#

An area effect cloud isnt alive right so I should not use the living entity wrapper?