#help-development

1 messages · Page 265 of 1

tardy delta
#

yes

young nimbus
#

ahh okay

#

i was using it since i started

#

but thats not the thing, im struggling with these null message in the title

tardy delta
#

i bet if you use ChatColor the issues will be gone

young nimbus
#

hm

#

but how does it work with ChatColor.translateAlternateColors?

tardy delta
#

you just do ChatColor.translateBlablabla('&', text) and instead of using that weird character you just use & for color codes

#

probably want to make an utility method for that lol

young nimbus
#

ughhh

tardy delta
#

``player.sendMessage(translate("&aHello there"))`

young nimbus
#

i have german keyboard, almost every german coder uses § too, but i will try

#

thanks

tardy delta
#

i guess & is on a german keyboard too

indigo cave
#

is anyone here familiar with protocollib?

young nimbus
tardy delta
#

i am just using a lang system where messages come from a lang.yml file and get automatically translated

#

to more predefined messages

young nimbus
#

okay i understand

#

but i am not supposed to upload that plugin so i wont need a lang.yml file, its just for me

tardy delta
#

that plugin was just for me too, just makes it a little easier changing messages without having to reload the server

young nimbus
#

i get your point

#

but once ive all done, i wont have to change anything yk

#

but back to topic, ive never had any problems with using §, so i bet it wouldnt change anything if i would translate

#

maybe something with my enum class?

tardy delta
#

idk

young nimbus
#

ok

#

if someone else know pls let me know

tardy delta
#

debug that field

ivory sleet
#

You didnt assign color

#

this.color = color; inside the constructor of the enum is needed

#

Additionally, this is why final sometimes helps having, since it’d have yielded a compile time error

young nimbus
#

how tf didnt i saw it hahahah

#

thanks a lot man

tardy delta
#

@AllArgsConstructor \🤔

ivory sleet
tardy delta
#

i believe at some point i might use lombok

ivory sleet
#

Im leaving the scene before it goes too far… 5755_Penguin_dance

rough drift
#

how can I cancel a player changed world event

plush shore
rough drift
#

Cancel changing world, without a portal (plugin executed world switch)

plush shore
rough drift
#

It's handled in another way, basically it's two parts that can't communicate between eachother, and then there's another part that can cancel the switch event, it's a bit complicated to explain lmao

plush shore
#

check if it is a player.

rough drift
#

That's a paper event

topaz cape
#

PlayerChangedWorldEvent?

#

oh wait that doesn't implement cancellable

#

you can try cancel PlayerTeleportEvent

rough drift
#

yeah changing to that

plush shore
topaz cape
#

you wish what

#

that's already an event

rough drift
#
if (event.getCause() != PlayerTeleportEvent.TeleportCause.PLUGIN) return;

var from = event.getFrom();
var to = event.getTo();
if(to == null) return;
var fromWorld = from.getWorld();
var toWorld = to.getWorld();

if (fromWorld == null || toWorld == null) return;

if (fromWorld.getUID().equals(toWorld.getUID())) return;
```lmao
topaz cape
#

if(event.getFrom().getWorld() == event.getTo().getWorld()) return;

tardy delta
#

im wondering how to can be null too, i saw it in the javadoc

topaz cape
#

player#teleport(null)

tardy delta
#

what does that do?

topaz cape
#

throw an exception

tardy delta
#

lmao

hazy parrot
#

Var duke

tardy delta
#

let better

sterile token
#

Ideas for designing a command framework?

tardy delta
sterile token
# tardy delta wdym

Yeah i need ideas for doing it, because i some kind of command framework which allow me to make something like simple command, argument, sub command, childs, etc command based

#

Also if allow to do luckperms similar structure would be great

tardy delta
#

still havent built one?

#

just decide what you want and starting building off that

fading spindle
#

anyway to make arrow damage more the who the person is shooting to? i tried using projectile launch event.

drowsy helm
#

like if they shoot themselves?

#

check for entity damage event

#

if damager is a projectile and the owner is equal to the damagee then apply more

fading spindle
#

oh ok that makes sense

#

thanks

fading spindle
#

ive already setup the specific palyer part by using a hashmap

drowsy helm
#

oh yeah just do the same thing

fading spindle
drowsy helm
fading spindle
#

oh i was uysing the wrong event

sterile token
#

How would you recommend cancelling putting items on second hand, but knowing that the plugin can be put on 1.19 or older versions?

echo basalt
#

Should I just ditch custom entities and publish the NMS tutorial now 🤔

#

but then half of nms ain't there

#

I only spoke about packets 💀

#

300 lines of packets grr

trim lake
#

Is there way how to give priority for listners, in some casses there is to listeners running, but I need only one 😄

sterile token
trim lake
#

perfect

#

thanks

sterile token
#

also you can make a fast search and you will find more than what you expect

#

I think that websites are free to read

drowsy helm
echo basalt
#

yo buby

#

you know much about NMS?

drowsy helm
#

yup

trim lake
echo basalt
trim lake
drowsy helm
#

i would but dont have time atm sorry

echo basalt
#

gotta release it by xmas

trim lake
#

Or just send notification to advancmed area if somehting happend.

lyric sage
#

My booty ich

atomic swift
#

How do i get all players that are not vanished

jagged monolith
#

List through all players online, then check each player if they are isVanished then if they aren't. Add them to another list.

white root
#

I could absolutely be wrong, but I seem to remember most vanish plugins setting a metadata called "vanished"

in an old project (I dont use or maintain it anymore, so it could be outdated), I used Player.hasMetadata("vanished") to check if a player is vanished

#

then just iterate through online players, and if they're not, add them to your notVanished players list

solemn frigate
#

?paste

undone axleBOT
atomic swift
worldly ingot
#

Sure but Player#isInvisible() isn't a method

atomic swift
worldly ingot
#

Oh it is, lol. Though it doesn't apply to players. They just inherit it from entities

atomic swift
#

Player is an Entity lol

#

so im assuming it inherits Entity

worldly ingot
#

It does. They inherit isInvisible() from Entity, but Players don't respect that NBT tag

#

Vanish status is determined by plugins

worldly ingot
subtle folio
#

LivingEntity

worldly ingot
#
public static boolean isVanished(Player player) {
    for (MetadataValue value : player.getMetadata("vanished")) {
        if (value.getAsBoolean()) {
            return true;
        }
    }

    return false;
}```
#

Or something like that. I can't remember exactly what it is

atomic swift
#

so use List<Player> onlineplayers = Bukkit.getOnlinePlayers().stream().filter(player -> !player.getMetadata("vanished").get(0).asBoolean()).collect(Collectors.toList());

sage patio
#

if i do smth like this
its a different runnable for each player, right?

#

runnableList is a HashMap

echo basalt
atomic swift
#

they are

echo basalt
#

you're just putting the same instance returned by Bukkit.getScheduler every time

sage patio
#

so what i should do

atomic swift
#

your suppose to do them like this

Bukkit.getOnlinePlayers()
    .stream()
    .filter(
        player -> !player.getMetadata("vanished").get(0).asBoolean())
    .collect(Collectors.toList());
atomic swift
#

ik waste of lines

echo basalt
#

there's a very crappy way of making it a 2-liner

atomic swift
#

Stream() very easy way to to make a 1 liner

echo basalt
#
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
players.removeIf(player -> !player.hasMetadata("vanished") || !player.getMetadata("vanished").get(0).getAsBoolean());
sage patio
echo basalt
#

That's a data structure issue that you need to figure out

#

I see a bunch of other mistakes in that tiny screenshot you sent

subtle folio
#

am I able to set the player's inventory contents in an PlayerQuitEvent?

subtle folio
#

you cannn

vital yacht
echo basalt
#

Does anyone have a sample pom.xml with Specialsource?

#

just need it to finalize my nms tutorial

crisp quail
#

I'm trying to loop through a list of commands in a config, and execute them in order. However when I run the plugin, it sends them in a random order. Any ideas how i can fix this?

                    for (String command : config.getStringList("startup.commands")) {
                        new DelayedTask(() -> {
                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
                        }, 10);
                    }
echo basalt
#

do the for loop inside of the task

#

seems like a concurrency thing

crisp quail
echo basalt
#

you want to run one every 10 seconds?

#

like in order?

eternal oxide
#

no way will it be 10 seconds. thats in ticks

crisp quail
#

yes

echo basalt
#

ah

eternal oxide
#

ah custom task

crisp quail
#

yes

echo basalt
#
for(int index = 0; index < list.size(); index++) {
  String command = list.get(index);
  new DelayedTask(() -> ..., (index+1) * 10);
}
#

type deal

#

elgar

#

Mind giving a quick look at my NMS guide before I post it?

#

eh whatev imma just post it

humble tulip
crisp quail
echo basalt
#

you'll see it on the front page

echo basalt
humble tulip
#

Rip

echo basalt
#

gotem

#

give me the clout ktnxbye

crisp quail
echo basalt
#

remove the +1

crisp quail
near night
humble tulip
#

can i see your config?

#

@near night

near night
#

yup

humble tulip
#

it's because youre casting to HashMap

near night
#

give me one sec

humble tulip
#

dont save the map like that

near night
#

im just doing this java public static void saveBlocksStore(HashMap<Location, Integer> blocks) { //set the blocks store file to the hashmap blocksStore.set("blocks-store", blocks); //save the blocks store file try { blocksStore.save(blocksStoreFile); } catch (IOException e) { e.printStackTrace(); } }

#

how else can i do it?

humble tulip
#

        Map<Location, Integer> locationIntegerMap = getMap();

        int counter = 0;

        locationIntegerMap.forEach((location, integer) -> {
            config.set("blocks-store." + counter + ".location", location);
            config.set("blocks-store." + counter + ".blocks", integer);
        });
#

like this @near night

near night
#

tysm

humble tulip
#

and you get like this

#
        ConfigurationSection section = config.getConfigurationSection("blocks-store");

        if (section == null)
            return new HashMap<>();

        Map<Location, Integer> map = new HashMap<>();

        for (String key : section.getKeys(false)) {
            map.put(section.getLocation(key + ".location"), section.getInt(key + ".blocks"));
        }
near night
#

thx

subtle folio
#

Do i use .equals or == for uuids?

regal scaffold
#

.equals

subtle folio
#

kk

jagged monolith
#

.equals because it's a string technically.

vital yacht
#

Uh it's not because it's a string, it's because it's an object

#

== compares references, .equals() compares the actual values of objects

#

Does anyone know the event for when a structure block is used?

wet breach
ancient plank
#

:)

shadow owl
vital yacht
#

I need to know the blocks being placed though

vital yacht
drowsy helm
vital yacht
drowsy helm
#

oh he probs meant as a joke then

vital yacht
torn oyster
#

would you guys recommend i use eco to create my plugin

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

abstract sleet
#

Thanks a lot for the guide, been meaning to get into NMS lately, wanting to play around with the entity metadata packets.

abstract sleet
#

if you're going to use someone else's library, make sure you really need to use it, you are able to fork it and maintain it yourself if it changes into a bad direction or gets discontinued, etc

torn oyster
#

also nice name :P

abstract sleet
#

I would have changed it to my Spigot username but

abstract sleet
#

you should ask in their Discord if your plugin would be suited for it

rough drift
#

Why do teams only use ChatColor in 1.19? Couldn't they use a Color class since we have hex support now?

jagged monolith
#

Teams have always used normal ChatColor and not supported hex. I'm not exactly sure of the reason, but I know it's always been that way.

rough drift
#

Kinda dumb imho

chrome beacon
#

Mojank

opal juniper
tardy delta
small current
#

can an entity with a custom name and a pdc get removed naturally?

#

not by plugins etc..

glossy venture
#

but i dont think it will

#

if you do want it to do it manually

#

on chunk unload or something

small current
#

i dont want an entity to be removed at all

#

can this happen?

humble tulip
#

Can be remived naturally by dying 😂

cosmic nebula
#

i want help

#

how to remove host's offline messages in MOTD,In Game

small current
#

and creative damage cancelled

#

no gravity

opal juniper
tardy delta
#

dunno how that happened

summer agate
#

It would seem that you put it there

hardy pollen
#

Hi somene help please how can i get DIAMOND value or normal value using getconfig()?

#
Generator:
  normal:
  - STONE:60
  - COAL_ORE:10
  - IRON_ORE:8
  - GOLD_ORE:5
  - REDSTONE_ORE:7
  - LAPIS_ORE:7
  - EMERALD_ORE:2.5
  - DIAMOND_ORE:2.0
  DIAMOND:
  - DIAMOND_ORE:100
desert loom
#

you mean converting a string to a Material?

wooden garnet
#

are there any good analogues to std::deque in java?

hardy pollen
#

no i only want to get normal String here

#

or DIAMOND string

#

like get list Generator have string value:

  • DIAMOND
  • normal
desert loom
#

I'm kind of confused do you want to get the path Generator.DIAMOND as a List<String>?

#

not sure what you mean by normal string

hardy pollen
#

no i want to get path: Generator

#

i just want to get key name

wooden garnet
#

use Map type

hardy pollen
#

it return value null when i using getconfig.getMapList

wooden garnet
#

It should be List< Map< String, Object > > according to the snippet u provided earlier

desert loom
#

I'm still having trouble understanding what you're trying to achieve

#

if you want the Generator section I guess you could do

ConfigurationSection generatorSection = getConfig().getConfigurationSection("Generator")
#

that would return the Generator section and calling getKeys() on it will return a Set<String> of normal, DIAMOND since they are part of the Generator section.
again, I don't know if that's what you're looking for

echo basalt
hardy pollen
desert loom
#

np

echo basalt
#

love how splitting my guide into 3 posts made me get 3x the positive ratings sunglasses

summer agate
#

Stonks

frank kettle
#

Hey, for some reason my code is not working properly. I'm trying to create something called alliances(like clans, guilds), and everything stores fine in the local yml file when creating the alliance itself.

But then I'm making a command to store in an arraylist used names/tags and a command to list every alliance and it's not working, it keeps returning null(from doing yml.getString...) even tho when speaking on chat it puts my alliance tag fine and when doing /alliance command it opens fine my alliance info.

The code right now is after 5 seconds(a scheduler) the server opens it checks the alliances on yml and loads them. (Beforehand it wasn't working even without the 5 second scheduler so I added it to maybe load it when server was "fine" opened)

current YML file:

alliance:
  total: 2
  '1':
    status: 1
    leader: bad38249-dea9-32bb-84ae-6ec0eb26a3d9
    tag: Test
    name: Testing Alliance
    members: bad38249-dea9-32bb-84ae-6ec0eb26a3d9
    level: 0
    xp: 0
    totalxp: 0
    reputation: 0
  '2':
    status: 1
    leader: bad38249-dea9-32bb-84ae-6ec0eb26a3d9
    tag: Abcd
    name: ABCDEFGH
    members: bad38249-dea9-32bb-84ae-6ec0eb26a3d9
    level: 0
    xp: 0
    totalxp: 0
    reputation: 0

But then when I get the total alliances and then a for to check the alliances names, all return null names and tags...

#
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() {
            @Override
            public void run() {
                allowToJoin = true;
                int totalAlliances = alliancesYML.getInt("alliance.total");
                for (int i = 0; i < totalAlliances; i++) {
                    String path = "alliance.'" + i + "'.";
                    if (alliancesYML.getInt(path + "status") == 0) {
                        Alliance alliance = new Alliance(i);
                        if (alliance.getChunks() != null && alliance.getChunks().size() > 0) {
                            for (String chunk : alliance.getChunks()) {
                                allianceChunks.put(chunk, i);
                            }
                        }
                    }
                }
            }
        }, 20L * 5);```
echo basalt
#

oh god the nesting

frank kettle
#

this is the code to load them when they start

grizzled pollen
#

?paste

undone axleBOT
frank kettle
#

the Alliance class has a setup which loads what's on the yml

#

:susthink:

covert yacht
#

Does someone has an issue with onClickBlock firing twice ?

frank kettle
#
public Alliance(int id) {
        this.id = id;
        setup();
    }

    public void setup() {
        Bukkit.broadcastMessage("Starting setup of an alliance...");
        String path = "alliance.'" + id + "'.";
        if (Main.getInstance().alliancesYML.getInt(path + "status") == 1) {
            setStatus(STATUS.DELETED);
            Bukkit.broadcastMessage("- Alliance deleted.");
        } else {
            setStatus(STATUS.ACTIVE);
            this.leader = Main.getInstance().alliancesYML.getString(path + "leader");
            String membersData = Main.getInstance().alliancesYML.getString(path + "members");
            ArrayList<String> members = new ArrayList<>();
            if (membersData != null) {
                members.addAll(Arrays.asList(membersData.split("#")));
            } else {
                members.add(this.leader);
            }
            this.members = members;
            this.tag = Main.getInstance().alliancesYML.getString(path + "tag");
            this.name = Main.getInstance().alliancesYML.getString(path + "name");```
#

smth like this, then there's more below

#

🤔

echo basalt
#

idk the command

#

there is one

summer agate
frank kettle
#

it keeps returning null from the YML file tho, even tho it stores fine and gets it fine when i do /alliance

covert yacht
summer agate
#

Both events get fired

echo basalt
#

?interactevent

undone axleBOT
#

The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.

For example, only executing code if the main hand was used:

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
        return; // do not progress past this point  |
    }
    // provide functionality
}
echo basalt
#

this one

covert yacht
#
if (event.getHand() == EquipmentSlot.OFF_HAND) {
    return;
}```
#

Thanks copilot xd

#

Thank you too ^^

frank kettle
#

😔 alright, was worth a try

summer agate
#

Gotta love github copilot

undone axleBOT
covert yacht
#

Is this not called spaghetti code ?

echo basalt
#

no

frank kettle
# echo basalt ?arrowcode

it does a for per alliance on yml and then checks their status and loads them.
and then it checks if they have any chunks claimed as an alliance and stores them in the hashmap to use for checking when someone else tries to break into their chunks

echo basalt
#

spaghetti code is worse

#

this mf tryna act like chatgpt

frank kettle
#

not really

#

just been stuck on this for past 2 days and really dont know what else to change and try to fix

echo basalt
#

I'm telling you that your code looks unreadable, and it can be more legible

#

you're telling me what it does

frank kettle
#

bet it's some small thing i'm not seeing so I'm giving my shot here

echo basalt
#

also no point in looping through your aliances like that

dawn hazel
#

Just a side note making your code more readable/making it a habit will save you a lot of trouble

#

It will save your life

frank kettle
#

I can put my chunks loading inside the Alliance class but the problem is the thing before where it's not loading the YML correctly.

#

it does correctly in the command, but not there

frank kettle
summer agate
#

That's why I like to commit before starting to fix, then get it to work, and rollback and put the fix without messing up more code. Might work for you

echo basalt
#
ConfigurationSection alliancesSection = config.getConfigurationSection("alliances");

for(String key : alliancesSection.getKeys(false)) {
  if(key.equalsIgnoreCase("total") {
    continue; // this is not an alliance
  }

  parseAliance(alliancesSection.getConfigurationSection(key));
}
public void parseAlliance(ConfigurationSection section) {
  Status[] statuses = Status.values();
  
  Status status = statuses[section.getInt("status", 1)];
  String leader = section.getString("leader");
  List<String> members = new ArrayList<>(List.of(section.getString("members").split("#")));

  if(members.isEmpty()) {
    members.add(leader);
  }

  String tag = section.getString("tag");
  String name = section.getString("name");

  Alliance alliance = new Alliance(status, leader, members, tag, name);
  // register the alliance
}
#

no need to overcomplicate it

frank kettle
#

oh yeah the configurationsection thing

#

i saw it few months ago but never got to use it or learn it

echo basalt
#

this is why you're struggling

frank kettle
#

so over there u changed the Alliance to receive all the arguments right away on it. is there a reason for it? why not the way i have where i put the ID and the class itself loads them? (or is this a problem?)

echo basalt
#

Alliance is a data class

#

passing the loading logic to it breaks the single responsibility principle

#

you can just make 2 constructors

#

or you can make a constructor with the section and parse it there, bit stupid but still

frank kettle
#

I will try to change my alliance code into being like that first(the class) and then if doesnt work i will look into learning and testing ConfigurationSections

#

i will move to configurationsections later on if not needed yet but feels like i really need to learn them soon🤔

echo basalt
#

FYI

frank kettle
#

thank you for the time

echo basalt
#

a FileConfiguration extends ConfigurationSection

#

pretty sure the only difference is that it has the save(File) and save(OutputStream) methods

frank kettle
#

It's just that I been using that forever and been working fine for me to store something that only the server needs(for more global data i use mysql)

#

weird how it's returning null for the first time, hella annoying

#

ty again, I will get back to fixing it

crisp quail
#

I'm trying to check that if the user has enabled the players-needed module, and then check that if the current online player count is above the specified threshold in the config.

That all works fine, however I need it so if "loop" is equal to true in the config, that it will go back and wait the specified amount of time and then try again.

I'm not sure how to properly implement this, any ideas?

if (config.getBoolean("startup.enabled")) {
            // If wait length is above 0
            if (config.getInt("startup.wait-length") >= 0 && config.getInt("startup.command-interval") >= 0) {
                int seconds = config.getInt("startup.wait-length");
                // Wait specified time
                new DelayedTask(() -> {
                    // Check if there is enough players
                    if (config.getBoolean("startup.players-needed.enabled")) {
                        if (config.getInt("startup.players-needed.amount") >= 0) {
                            if (Bukkit.getServer().getOnlinePlayers().size() < config.getInt("startup.players-needed.amount")) {
                                getLogger().severe("Couldn't send command as there aren't enough players online!");
                                getLogger().severe("Check your config.yml if you think this is a mistake!");
                                return;
                            }
                        }
                    }
                    // For command in commands code
                }, seconds);
            } else {
                getLogger().severe("Couldn't send command as config.yml is invalid!");
            }
        }
#

My config:

startup:
  enabled: true
  players-needed:
    enabled: false
    amount: 1
    loop: true
  wait-length: 5
  command-interval: 2
  commands:
    - "say [AutoCommand] Thanks for using me!"
summer agate
#

Ok first off go invert some if statements so theres not so much indentation. Make a seperate method to check the option, and then you can loop that method

#

so instead of ```java
if (config.getBoolean("startup.players-needed.enabled")) {

do

```java
if !(config.getBoolean("startup.players-needed.enabled")) {
  return;
} 

That way you can keep most code on one level, keeping it readable.

frank kettle
echo basalt
#

Arrays.asList

#

not my fault you're coding in java 8

frank kettle
#

just asking :dontLikeThis:

#

not putting fault

frank kettle
#

i have latest releases almost, like from 2 months ago on everything, is it an option I have to change somewhere?

echo basalt
#

you're coding your project in java 8

frank kettle
#

I clicked to update to 9 over there

echo basalt
#

and running it on like java 17

frank kettle
#

i didn't know, i thought downloading latest jdk would put me with latest

#

where do i change this? is it project or on the IDE? :susthink:

echo basalt
#

either Project Structure or on your build.gradle/pom.xml

frank kettle
echo basalt
#

ye

frank kettle
#

or this "9" now?

#

since i updated to 9

#

or is it correct right now?

#

i checked online something from a month ago and they using same versions as mine for those options

#

i guess now is fully updated?

main dew
#

exists place ender crystal event?

hybrid spoke
#

block place event probably

frank kettle
#

end_crystal block

hybrid spoke
#

otherwise entityspawnevent

echo basalt
#

pretty sure end crystals just work like spawn eggs

main dew
#

oke thanks

#

do you know event to put flower into flower pot?

hybrid spoke
#

playerinteractevent

crisp quail
tardy delta
#

What's Total for

echo basalt
#

yo fourteen

tardy delta
#

Yo

round plinth
#

how do i give myself invisible itemframes with essetnials

#

essentials

echo basalt
tardy delta
#

Looked at it this morning

#

I dunno any of that shit

echo basalt
#

still needs a lot of work

tardy delta
#

Everything was Hidden in the spoilers lol

echo basalt
#

I don't want to provide any extra info

#

like

#

no unwanted walls of text :)

tardy delta
#

True

#

Nice overview

misty ingot
#

how can I have the user select a region (like in worledit) and then when someone tries to go outside that specified region they are pushed back?
(this is for a minigame so I'd need it to work efficiently and only when some variables are true)

tardy delta
#

Learn the worldguard API ig

misty ingot
#

time to die

tardy delta
#

Correct

misty ingot
#

I was really wishing that there was an easy way to just do it myself

tardy delta
#

Probably

#

Listening to some events

molten hearth
#

The worldguard api is a horrible pain in the ass good luck

tardy delta
#

Worldedit too

molten hearth
#

WorldPain Collective™️

tardy delta
#

And their support server is a bunch of idiots that ban you for whatzver reason

#

Got kicked a few times

misty ingot
#

all I need is to allow a user to select 2 regions in a map (for 2 teams) and then not let the team members exit their respective regions

tardy delta
#

And then banned cuz i helped People and im not supposed to do that

echo basalt
#

cubecraft discord be like

molten hearth
#

From someone who designed such a terrible api I'm not surprised they designed the discord in such a terrible way

tardy delta
#

Lol

plain helm
#

Hello guys any of you has any idea of what happens if I set the amount of an item to 0?

tardy delta
#

It goes away doesnt it?

plain helm
#

yeah I think so

tardy delta
#

Or is the amount indicator gone?

plain helm
#

yea that's my doubt

tardy delta
#

Try it

kind hatch
#

Pretty sure it removes the item.

plain helm
#

Alr I'll try it for science

misty ingot
#

I currently have 2 options

#

either I scrap my minigame idea (which is a pretty OG idea and I dont think anyones made it before)
or I literally kill myself trying to learn the worldedit/worldguard API

echo basalt
#

above 1.9 it just becomes air

plain helm
#

oh ok nice

#

I was making a new project just to test it, you saved me a lot of time ❤️

misty ingot
#

is there a "crash course" for the worldedit/worldguard api?

#

I am kinda in the mood to make this minigame without killing myself in the process

tardy delta
#

lol

misty ingot
#

so first I discover that I have to learn WorldGuard API

#

and then the repo is offline

fading spindle
#

?jd-s

undone axleBOT
misty ingot
#

ye ik

#

when I put it in my maven file it says "repo doesnt exist"

restive mango
#

I want to make a general class ‘Move’ which stores a list of projectiles and has a method ‘Run’ which then just returns the result of a method for each of its extensions

#

Sigh this sounds so ugly

#

I just wish I knew how to do it

#

It seems so much like something that should be obvious

fierce salmon
#

Do inventory slots start at the number 0 or 1?

hazy parrot
#

if i would guess i would say 0

fierce salmon
#

alright

misty ingot
#

yes they start from 0

#

like the indices of a list

fierce salmon
#

what event do I use to look to see if the inventory that is clicked on has a certain name?

hazy parrot
#

inventoryclickevent ?

river oracle
#

Make a wrapper object and save the inventory object. Use Dependency Injection to pass it around

lavish wing
#

Guys, how can I display a list of players but in a normal way?
https://ibb.co/341ZBjt

            sender.sendMessage("§ePlayers online: §2" + getServer().getOnlinePlayers().length + "/" + getServer().getMaxPlayers());
            sender.sendMessage("§eList: " + Arrays.toString(getServer().getOnlinePlayers()));
            sender.sendMessage("§6================§e[§2TAB§e]§6================");```
river oracle
#

A loop

lavish wing
river oracle
#

A loop

#

A for loop you know

fossil lily
olive lance
#

Shit

#

I can get 5gb internet at my house

#

Ima start selling Minecraft servers

lavish wing
tardy delta
#

players.stream().collect(Collectors.joining(", ")) or smth

tardy delta
#

players must be a collection

hazy parrot
#

me when String.join

vale ember
#

Hey guys. i wanted to ask, how much more/less efficient is PDC compared to sqlite? In my case i wanna store a list of string ids for each player

tardy delta
#

more

#

databases will always be slow, pdc is backed by a kind of map afaik

lavish wing
vale ember
#

k, thanks for the info

hazy parrot
lavish wing
bright jasper
#

Wacky, why is paper not finding io.papermc.paper:paper-api:1.16.5-R0.1-SNAPSHOT

#

it only has 1.17 as the oldest API version on their repo

remote swallow
#

?paperdev

undone axleBOT
#

Make sure to ask in the appropriate server concerning development towards different JAR types such as PaperMC. (Tip: Google them!)

lavish wing
#

It gives me an error

tardy delta
#

onlineplayers is not an array

#

call .stream()

lavish wing
#

Arrays.stream(Bukkit.getOnlinePlayers());?

#

This?

tardy delta
#

Bukkit.getOnlineblabla.stream().collect() blablabla

lavish wing
#

arghwfhweufwe

#

Can you give me a code?Im really stupid

humble tulip
#

Lmfao he did

tardy delta
#

might wanna use smth else if this is too complicated

lavish wing
tardy delta
#

idk why it does that

quaint mantle
#

ultimately does the same thing

lavish wing
#

🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹

zealous iron
#

Can the playerinteractevent cancel block breaking and block placing

zealous iron
#

omg it can

humble tulip
#

?tryandsee

undone axleBOT
zealous iron
#

bro thats so annoying

tardy delta
#

whats annoying

zealous iron
#

i thought only blockbreeakevent and blockplaceevent canceled block place and break

tardy delta
#

afaik block place and break event are a child of the interact event

zealous iron
#

ahh

lavish wing
# tardy delta idk why it does that

I just decided to steal the method from the server core 😎

        if (cmd.equalsIgnoreCase("online")) {
            String players = "";
            Player[] var5 = Bukkit.getOnlinePlayers();
            int var6 = var5.length;

            for (int var7 = 0; var7 < var6; ++var7) {
                Player player = var5[var7];
                if (!(sender instanceof Player) || ((Player) sender).canSee(player)) {
                    if (players.length() > 0) {
                        players = players + ", ";
                    }

                    players = players + player.getDisplayName();
                }
            }
            sender.sendMessage("§6================§e[§2TAB§e]§6================");
            sender.sendMessage("§ePlayers online: §2" + getServer().getOnlinePlayers().length + "/" + getServer().getMaxPlayers());
            sender.sendMessage("§eList: " + players);
            sender.sendMessage("§6================§e[§2TAB§e]§6================");
            return true;
        }
tardy delta
#

bruh cant longer sent smth to chatgpt, whenever i press enter it gives me a new line

#

sometimes it works sometimes it doesnt

small current
#

how an entity like this (with custom name, pdc and damage cancelled) can be despawned?

#

players report it disapearing

#

and i view the log and they didn't removed it themselves its just not there

fierce salmon
#

is there a way for me to check to see what the name of the gui inventory that is being opened is?

zealous scroll
#

Is it recommended to do dependency injection with Guice or pass the plugin instance to constructors? I'm currently passing my plugin instance to the necessary constructors but I've been reading using Guice is a better practice

ivory sleet
#

Well, wouldn't you still pass your plugin instance through the constructor?

#

guice has field injection sure, but iirc thats discouraged

zealous scroll
#

Field injection is what I meant yeah

echo basalt
#

don't see a need for field injection honestly

#

just use a constructor

ivory sleet
#

^, mainly field injection sort of advocates mutability

#

which is discouraged unless reasoned for

radiant cedar
#

I just started using sql for player stats. Is this way better than just getting and changing from sql everytime

#

How do ppl usually use sql for player stats

#

Do you crete object for each player where an instance is stored and save it onto sql sometimes

small current
radiant cedar
#

Ye uuid is my primary key but

small current
#

all of the plugins use uuid

ivory sleet
#

Yes, one design choice regarding saving data is to sync with the database with a given interval

radiant cedar
#

Should i make object player stats for each player and keep an instance

ivory sleet
#

a sync buffer or whatever u wna call it

radiant cedar
#

Or just keep pulling data from sql

ivory sleet
#

but yes demopro

small current
#

if you save it async there should be no problem

#

and you can pull it once joined

#

and store it in a hashmap

#

apply all the edits you want to the PlayerData object

#

no need of pulling

#

i do this

ivory sleet
#

fetch on join, save on leave or/and after changing the data

small current
radiant cedar
ivory sleet
#

mhm

#

az pmzhero said

#

HashMap<UUID,YourPlayerStatsClass>

#

one per player

radiant cedar
#

Ok but looping through the hashmap wouldnt be suboptimal right to find the player each time

ivory sleet
#

its a map

#

you can use map.get(uuid)

radiant cedar
#

Oh ye it doesnt loop

#

Nvm

ivory sleet
#

yeaz

radiant cedar
#

Ok ty boys

fierce salmon
#

what event do you use to place particles at a certain block?

small current
#

on a command

#

or like when the block is broken?

fierce salmon
#

nvm i figured it out thanks though

wooden garnet
#

what's wrong with Block.SetType function?

#

is it working?...

remote swallow
#

?notworking

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.

eternal oxide
#

nothing wrong with it

wooden garnet
#

does worldedit hook it?

eternal oxide
#

it uses it, yes

small current
#

there is no
Block#SetType

#

its
Block#setType

wooden garnet
#

ok

wooden garnet
small current
#

no i use it

#

how you call it

#

send code

eternal oxide
#

intercept? you seem to be using the vernacular incorrectly.

echo basalt
#

Worldedit probably just uses nms for fast setting

#

by writing into the palette directly

wooden garnet
wooden garnet
eternal oxide
#

there is no hook, you use it or you don't

wooden garnet
#

location is obviously location of a block

echo basalt
#

oof someone comes from python woeisme

wooden garnet
#

i checked the world and coords and they're correct

echo basalt
#

mans got the md_5 formatting style

wooden garnet
#

yes

remote swallow
#

Not block_locatoon PepeCryHands

eternal oxide
#

You are doing something wrong in your code.

remote swallow
#

?conventions

small current
#

i have to fix it in like 10 minutes

wooden garnet
#

i added material diff check and it seems to be working fine

#

but settype still fails in the same loop lol

#

the actual part of code

#

ik int ids are deprecated i use em only for debugging

dawn plover
#

hey, i have a quiestion, i wanted to start making plugins again, i did this a prob half a year ago. but since stopped
i though i used to have the build (artifacts) button somewhere on top of there
but i cant find how. if anyone knows, this would make my life 10 times easier

sterile token
sterile token
#

This way you are using, is building the project via ant, which would not be okay because its a maven project

dawn plover
#

oh aha

#

i am going to look in to that, but never really did it though XD

sterile token
#

yeah

#

I would either suggest using maven or gradle for projects, because they will keep you faster and dependencies are easier to manage

woeful flicker
#

getting this error, problem is with my constructor here:

#

though i do not understand what is wrong

wooden garnet
eternal oxide
woeful flicker
#

it is, lol

#

should be

woeful flicker
#

im just switching up constructor stuff, it was all fine before this lol

wooden garnet
woeful flicker
#

nvm im stupid as fuck

#

changed a letter in the command name by accident

#

xD

wooden garnet
woeful flicker
#

always that 1 lil stupid thing that messed you up

small current
#

when a chunk gets unloaded all mobs disapear

#

tf?

#

it bugs my plugin

#

what does this

tardy delta
#

makes sense?

agile anvil
#

Why does it bug your plugin?

small current
#

well i have an entity

#

with a name

#

it despawns

frail gale
#

How I can make a custom recipe with custom items?

#

I know about exactChoice but this requires the Item properties to be fully the same like Name, Enchants, etc.

regal scaffold
#

But vault is loaded and working. And plugin.yml includes depend: [Vault]

frail gale
#

I wanna make it possible just for a custom item unique ID so just compare Item's NBT data

opal juniper
#

I think

small current
#

this is my code

#

and i name it a little later in the code

#

ahh i dont wanna use packet entities ffs

regal scaffold
#

But vault is loaded and working. And plugin.yml includes depend: [Vault]

rsp seems to be null. Why would this happen

tardy delta
#

show code

regal scaffold
#

Disregard, fixed

small current
#

duck bukkit entities

#

i will use packets

#

aaaa databases

#

it used to be a simple pdc thing

tardy delta
regal scaffold
#

I can't understand what it means by component. Can it be just a string? How could I tell if it presents again

#

All this because setPlayerPrefix is deprecated :/

opal juniper
#

paper?

regal scaffold
#

Yes

opal juniper
#

?whereami

eternal oxide
#

Paper uses components everywhere. This is Spigot, we use Strings

regal scaffold
#

Does that mean I can just use a string and it'll be fine?

gilded knot
#

Any fixes?

opal juniper
#

it lacks many nice featues of components

zealous scroll
#

Component.text(String)

eternal oxide
#

Player does not exist in PreLogin event

regal scaffold
eternal oxide
#

Build against Spigot and your code will always work on Paper. Not vice versa

regal scaffold
#

Hmmmm

gilded knot
eternal oxide
#

if they have logged in before use OfflinePlayer

#

but you can;t access their inventory before they have logged in

gilded knot
#

ah aight

regal scaffold
#

Is that < arrow mandatory now?

#

No matter what I change the prefix to the arrow stays

eternal oxide
#

< is in teh chat format not the name

gilded knot
#

go in essentials config

#

and edit it

regal scaffold
dawn plover
#

i kind of ran in to a problem, the problem being that I am alone XD
how do I easily test multi user plugins without a alt account (and only a local server)
for example tick tack toe
i already thought about:

  • bringing friends over, but thats to hard to do for simply testing
  • buying a alt account, but... no...
  • making a public server, have no idea how, i remember it beeing hard and not knowing the password of my routers
    (i mean, if a public server is the only way i need to take a look at that again :( )
gilded knot
#

the <> is there by default

regal scaffold
#

oH

gilded knot
#

You need to remove it

regal scaffold
#

So I have to change it xd

#

yeah yeah gotcha mb

#

Thanks

echo basalt
#

free trial

dawn plover
tardy delta
#

some kind of weird launcher

regal scaffold
#

Just for testing

tardy delta
#

i used to do that but they removed that functionality

#

and suddenly the conversation stopped

sacred mountain
#

or get friends

dawn plover
#

not sure if thats totally legal or just stolen, anyway, its 10$ to much XD

echo basalt
#

game pass literally gives you the game for free

#

you just buy the game pass trial for 1$

#

under a new microsoft account

#

and profit

#

I did it during my hypixel developer interviews to have a nice account name with no bans

tardy delta
#

lmao

#

im perm banned from hypixel

echo basalt
#

then they asked for all my account names

tardy delta
#

on another ip so i dont really care

echo basalt
#

but it didn't really matter, watchdog bans don't influence your development skills

#

I had some weak points during my interviews that I've been working on

#

and some weird scheduling conflicts like school

fierce goblet
#

Hello! I have a question, my antivirus show me popup (Virus: Java.Trojan.GenericGBA.31552). But problem is with this because that is plugin"ExploitFixer.jar". Sorry if i ask here, but i know here i find good people for resolve my stress...

eternal oxide
#

link to page for plugin?

fierce goblet
#

I use this plugin long time... and i naver have this. My antyvirus: G data.

#

Thats from spigot

agile anvil
#

We need the link

fierce goblet
#

i have this plugin on my computer

agile anvil
#

This plugin is corrupted. Don't use it anymore and remove it from your computer. Download a new one on spigotmc.org

fierce goblet
#

i download this plugin 2021-05-06

#

okey but i download this from official site spigotmc this is reason why i ask

eternal oxide
#

link the spigot page or we can do nothing

fierce goblet
#

really i use my computer yester day 2 days ago but this popup kmy antyvirus show me today

#

its this plugin but give 5 sec i try check version

echo basalt
#

send your jar to @vagrant stratus

fierce goblet
#

i try open my jar file using winrar but i have also popup about virus

#

idk whis plugin now works becouse maybe my antyvris remove some file

remote swallow
#

Antimalware >>>>

molten hearth
#

Oh wait this is about alts

#

ye tru

dawn plover
gilded knot
#

any fixes?

ornate stag
#

hi, i'm new in here so if i'm breaking any rules please warn me!

well, i've got an yml file that is given data in this structure:

bbbdcbc1-996c-435d-9297-9898b419dadc:
Name: George
Staff: Yes
Rank: Begginer
bbbdcbc1-996c-435d-9297-9898b419dadc:
Name: Bob
Staff: No
Rank: Master

how can i go through every key, find the one that has the value 'Bob' and get his UUID?

gilded knot
gilded knot
eternal oxide
#

I already told you, You can't get a player in teh pre login event

gilded knot
#

How would I fix it though

#

It's the only bug stopping me from completing my plugin

eternal oxide
#

you can't

gilded knot
#

:|

eternal oxide
#

there is NO Player in the pre login event

gilded knot
#

Is there another event I can use instead?

eternal oxide
#

join event

gilded knot
#

ah right, cheeres

eternal oxide
#

you can read your sql data in pre login and then give the item in the join event

gilded knot
#

Cheerio

#

Ultimately, this

#

Sorry, It's 10PM

#

Haven't slept in 15-16 hours

agile anvil
#

What does it say when you hover the yellow error?

rough drift
#

nullable

#

I can see it from here

#

giveReward doesn't take into account that the player might be null

eternal oxide
#

use event.getPlayer() not Bukkit.getPlayer

rough drift
#

Also that

gilded knot
#

Oh

#

right

#

Uh

gilded knot
rough drift
#
Player player = event.getPlayer();

try {
  if(hasReferral(player.getUniqueId())) {
    giveReward(player);
    removeReferral(player.getUniqueId());
  }
} catch(SQLException e) {
  e.printStackTrace();
  // Kick player optionally
}
gilded knot
#

Right

rough drift
#

Edited it btw

gilded knot
#

So I need to create a new function for removeReferral

#

gotcha

rough drift
#

Yep

#

And with that remove any referrals

#

You should actually do it this way

gilded knot
#

Mhm

#

reason I was making my own referral plugin is because other ones are either crap or don't support 1.19

rough drift
#
UUID referrer = removeReferral(player.getUniqueId());
if(referrer == null) {
  return;
}

giveReward(player);
// Give a reward to the referrer
#

Something like that in the try-catch

#

because then you can get the referrer, check for referral and remove the referral at once

gilded knot
#

This is my addReferral function

rough drift
#

Yeah

gilded knot
#

I'll just modify it so it removes it

rough drift
#

Remove has referral, then make remove referral get & remove (there is a way to do this in sql, forgot how) and make it return the referral if any

#

otherwise null

#

ah yes

#

you can do

#

DELETE from table where this = that RETURNING *;

golden turret
#

why does this happen? I can build the jar without a problem but IJ keeps saying this

#

using the latest version, of course

rough drift
golden turret
#

thats the thing

#

I dont have that method

rough drift
#

Show me the contents of EntitySlime & your class

#

?paste

undone axleBOT
golden turret
#

the EntitySlime is from the nms

rough drift
#

don't have nms ready rn

gilded knot
#

DELETE from referrals (referring_player_uuid) RETURNING *?

rough drift
#

DELETE from referrals WHERE referring_player_uuid = '?' RETURNING *;

#

something like that

gilded knot
#

then .setString

#

ah got it

rough drift
#

though you should delete by referred_player_uuid

#

otherwise if that player refers two players it will also remove the other referral

gilded knot
#

mhm yeah

#

So in pseudocode

#

When a player joins

#

go into database, Check if any players have typed /refer Ryzanite

#

If there is, then execute /givetoken Ryzanite 2

rough drift
#

basically yes

gilded knot
#

then delete list of players who did /refer Ryzanite for ryzanite

rough drift
#

well not exactly

gilded knot
#

?

rough drift
#

so you make one SQL request

#

and not two

gilded knot
#

ah right

rough drift
#

RETURNING * already gives you the output

gilded knot
gilded knot
rough drift
#

should be referred_player_uuid

gilded knot
#

got it

rough drift
#

otherwise if playerA refers playerB and playerC, if playerB joins it removes playerC's referral

gilded knot
#

Yeah, understood

rough drift
#

Yeah

#

like that

#

though make it return the output referrer UUID

gilded knot
#

A tiny bit confused

rough drift
#

you need to parse the result

#

it returns a ResultSet

#

which has two values

gilded knot
#

Right

rough drift
#

you need to get whichever one is the referrer

#

and parse the UUID

gilded knot
#

Wait how do I reference to the result?

rough drift
#

hm?

gilded knot
#

Oh the execute statement

#

of*

rough drift
#

executeQuery

#

it returns a ResultSet

#

you probs want to use ResultStatement#getString for the UUID

#

so like

#

myStatement.executeQuery().getString(0);

#

gtg

gilded knot
#

Yeah cheers

#

wait got it

#

I think this is it?

ornate stag
#

guys, can i have some help?

jagged monolith
gilded knot
ornate stag
#

yes

zealous osprey
ornate stag
#

i tried to do that :\

#

can't reply to my own messages

ornate stag
#

WAIT

#

I CAN

#

WTF

gilded knot
ornate stag
#

should've checked the 3 dots

zealous osprey
ornate stag
#

doesnt false get only the highest level keys?

zealous osprey
zealous osprey
ornate stag
#

ok

#

also, which path do i give? since i haven't got any paths
is it ok if it is is only ""?

zealous osprey
#

use the getKeys() method just on the plain FileConfiguration object

ornate stag
#

god damn

#

ur a fking genius

#

thank you

river oracle
#

if I want to use CompleteableFuture how many threads should I put in the Executor?
Executor executor = Executors.newFixedThreadPool(10); Is in the example I am looking at, but I don't want to hog resources or possibly cause a server crash from running these tasks

hazy parrot
#

If you do small io tasks, just use cached thread pool

river oracle
#

I'm just doing database queries with callbacks

tardy delta
#

whats wrong with the common pool?

river oracle
#

doesn't that not work unless you set the system property I wasn't sure if spigot had it set or what

tardy delta
#

might just use the bukkit scheduler to complete cfs

river oracle
tardy delta
#

no

river oracle
#

I need to query than do X after

#

which Ig i could lump in one async task

tardy delta
#

just do

var future = new CompletableFuture<>();
scheduler.async(() -> {
  // some heavy stuff
  future.complete(result);
});

future.thenAccept(System.out::println);```
#

or use the common pool

river oracle
#

👍🏽

#

thanks mr brush

tardy delta
#

might wanna specify the bukkit scheduler as executor tho as a lambda

#

task -> scheduler.async(plugin, task) whatever

#

then do CF.supplyAsync(stuff, task -> blablabla)

#

going to sleep now anyways

rich condor
#

Hello. Does anyone have an idea how to set a limit of people who can access protection. The plugin in question is StoneProtect

heavy elm
#

Hi guys, I got a "funny" (💀) problem
Basically I am creating a plugin (called sSkills) that uses a H2 database, that I relocated because I like relocating 👍

Another plugin (ajLeaderboards) uses the same library but with a different version
My plugin somehow ends up loading ajLeaderboards' H2 Driver class even tho I have no link to this plugin since I'm registering the driver using the following:

Class.forName("fr.stellarfx.sskills.libs.h2.Driver");

And it still produces this cute message:

[sSkills] Loaded class us.ajg0702.leaderboards.libs.h2.Driver from ajLeaderboards v2.6.3 which is not a depend or softdepend of this plugin.

It ends up in my database getting corrupted since it doesn't use the same version
Note that my plugin works perfectly fine with no other plugin on the server, I can even reload it, do coffee with it and everything

Idk maybe I just implemented it badly but I searched Google, and I feel like I can't do any better
Thanks 👍

hushed spindle
#

i've got a bit of an annoying issue, where every time i try to save an ItemStack to a config file it's changed ever so slightly in that supposedly identical items no longer match after being loaded in.
as example, this item:
ItemStack{STONE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"italic":false,"color":"white","text":"Not Stone"}],"text":""}}}
turns into
ItemStack{STONE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"white","text":"Not Stone"}],"text":""}}}

causing them to stop stacking and just stop being identical when needed. visually the item looks the exact same, but saving an item to a config file seems to just add this extra nonsense. how can i get around this issue

eternal night
#

You don't

#

Pretty much

last sleet
#

I've never really messed around with files, but maybe you could "serialize" the item into a string that you can later decode?

eternal night
#

The Bukkit system does a full load of the item into their API

#

And that conversation sadly is not guaranteed to maintain the exact same nbt

#

As seen here

eternal night
river oracle
#

I'm still a bit confused on how I should wrap my brain around this. I'm using a Guava's LoadingCache

    @Override
    public SlayedPlayer load(UUID key) throws Exception {
        // heavy database call
        return this.database.select(key);
    }

now I want to get the value of the cache but a call to LoadingCache#get or LoadingCache#getUnchecked would block main thread. Now I would just supply async to the retrieval method, but that seems unecessarily heavy. As in most cases its likely the value will be there. So i'd end up creating an asynchronous thread for pretty much no reason and it'd almost immediately close rather than just retrieving sync since the value is there

** solved **

    public static Future<SlayedPlayer> get(final UUID uuid) {

        if (cache.getIfPresent(uuid) != null) {
            return CompletableFuture.completedFuture(cache.getIfPresent(uuid));
        }
        
        return CompletableFuture.supplyAsync(() -> {
            return cache.getUnchecked(uuid);
        });
    }```
dry forum
#

iim making a shop plugin and if people want to make a spawner shop how would they do that since theres only a material of the spawner not the individual mob spawners

regal scaffold
#
[20:37:28] [Server thread/WARN]: (
[20:37:28] [Server thread/WARN]:     `Unique` int default 0,
[20:37:28] [Server thread/WARN]:     Total    int default 0
[20:37:28] [Server thread/WARN]: )' at line 1
[20:37:28] [Server thread/WARN]:        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
#
(
    `Unique` int default 0,
    Total    int default 0
);

#

How is this wrong

river oracle
#

Spawner Blocks have CreatureSpawner BlockSTate

#

you can do BlockStateMeta#setBlockState
and BlockStateMeta#getBlockState

#

to change the block states

worldly ingot
#

Unless .? is some weird SQL operator I'm unaware of

sterile axle
#

my guess is they're trying to fill the table name via a prepared statement variable injection but that isn't valid for a table name. that makes me extra sus as well because that would almost imply the table name is coming from user input...

regal scaffold
#

event.getPlayer().hasPlayedBefore()
Always returns false. why

sterile axle
#

are you in offline mode

regal scaffold
#

Negative

worldly ingot
#

Where are you running it? ;p

sterile axle
#

(is that still a thing? it breaks in offline right)

regal scaffold
#

PlayerLoginEvent

#

I believe the player has not been fully loaded yet, right?

#

And I have to use PlayerJoinEvent

sterile axle
#

hmm

#

perhaps or try delaying it 1 tick with the scheduler

regal scaffold
#

Hmmmm alright

jagged monolith
regal scaffold
#

Oh

#

Doesn't help me @jagged monolith

#

I need access to getHostname()

#

Only available in PlayerLoginEvent

sterile axle
#

AsyncPlayerPreLoginEvent gives you the InetAddress, which has getHostName

regal scaffold
#

Yeah I just openned the docs and found it

#

Let me give that a try

#

But then how do I access hasPlayedBefore?

#

Get UUID and use getUniqueID()?

jagged monolith
#

Just get the player from the uuid and check the hasPlayedBefore

sterile axle
#

can you get the player from uuid if they're not joined yet? are they in the player list that early?

regal scaffold
#

Can't

#

Gotta convert uuid to player

remote swallow
#

Wouldnt it just return false if its not in thr list

jagged monolith
#

Player player = Bukkit.getPlayer(event.getUniqueId)

Or something like that. On mobile so... lol

regal scaffold
#

oh

sterile axle
#

That won't work if they're not in the server playerlist yet

#

we're talking about prelogin

regal scaffold
#

Forgot about that one let me try

#

Wait

#

But we're checking about hasPlayedBefore()

sterile axle
#

but try it i guess

regal scaffold
#

Wouldn't they be in the list anyways

#

If they're connected or not

sterile axle
#

Dunno. You can try. I haven't checked.

regal scaffold
#

Checking rn

sterile axle
#

But methinks no

jagged monolith
#

If it doesn't work, instead of getPlayer use getOfflinePlayer

regal scaffold
#

Might produce NullPointer

#

There you go

sterile axle
#

getOfflinePlayer may work yes

regal scaffold
#

Ok and lastly before I actually finish my small project with sql injection

#

How can I set a placeholder to make a table

#

```CREATE TABLE IF NOT EXISTS domainlogs." + hostname + "\n" +
"(\n" +
" Unique int default 0 null,\n" +
" Total int default 0 null\n" +
");

#

I wish I could do

CREATE TABLE IF NOT EXISTS domainlogs.?
                    "(`Unique` int default 0 null,
                    "Total    int default 0 null
                    ");

sterile axle
#

It is really questionable to create a dynamic table name like that.

regal scaffold
#

Something like that

sterile axle
#

But...sanitize it properly, and use String.format

regal scaffold
#

Yeah Im aware but it's the functionality of my program

#

Isn't string.format also not safe?

#

Technically?

sterile axle
#

Ensure that hostname is completely sanitized

#

Neither is string concatenation

regal scaffold
#

I'm aware xd

sterile axle
#

But String.format is the cleaner way to do it

regal scaffold
#

I wanted placeholder but not possible

sterile axle
#

Just sanitize the input.

regal scaffold
#

Alright will do that thanks

sterile axle
#

Run it through a regex replace to ensure no special chars are in there and stuff, I guess. then I guess it's ok

regal scaffold
#

btw

#

Copilot

#

Is actually insane

sterile axle
#

yeah

regal scaffold
#

Flawless

#

So clean

#

And so helpfull for single line, it's prediction is out of this world

sterile axle
#

it stands on the shoulders of everyone who commits to github

regal scaffold
#

Amazing

#

Such a genius idea

#

Just makes it so much faster

young nimbus
#

Anyone knows whats wrong there?

sterile axle
#

Hover your mouse over the red underlined area and it will tell you.

young nimbus
#

it says remove invalid modifiers on "shortInteger" and Syntax error on token "String", record expected

sterile axle
#

I need to see the surrounding code

humble tulip
#

I think that's eclips being eclipse

sterile axle
#

Paste the file please

young nimbus
#

ughhh eclipse on her days again

remote swallow
#

?paste

undone axleBOT
young nimbus
#

of cours

humble tulip
#

Like why is the semicolon underlined at int seconds =0;

young nimbus
#

so weird

sterile axle
#

Your method is inside of another method

#

That's not valid Java

humble tulip
#

Oh fuck

young nimbus
#

ohhh

humble tulip
#

Why is the method in a method😂