#help-development

1 messages · Page 2214 of 1

eternal oxide
#

still uses the above methods

dense shoal
#

You're asking for a plugin rec

#

Is NCP around?

warm galleon
#

Im trying to make a sentry thing on the player, when you stop moving and look around it shoots arrows, but im getting a heck load of excessive velocities and the arrows dont aim towards mobs just shoots diagonally up in the same direction

@EventHandler
    public void onMove(PlayerMoveEvent e) {
        if (!playerLocations.containsKey(e.getPlayer())) {
            playerLocations.put(e.getPlayer(), e.getPlayer().getLocation());
            return;
        }
        Location l = e.getPlayer().getLocation();
        Location l2 = playerLocations.get(e.getPlayer());
        if (l.getX() != l2.getX() || l.getY() != l2.getY() || l.getZ() != l2.getZ()) {
            playerLocations.put(e.getPlayer(), l);
            return;
        }
        List<Entity> targets = e.getPlayer().getNearbyEntities(10, 10, 10).stream().filter(en -> en.getEntityId() != e.getPlayer().getEntityId()).collect(Collectors.toList());
        for (Entity entity : targets) {
            e.getPlayer().launchProjectile(Arrow.class, entity.getLocation().toVector());
        }

    }```
eternal oxide
#

unlikely you'll find a OS one. Too easy for noobs to work around it

dense shoal
#

NoCheatPlus still around?

dense shoal
eternal oxide
dense shoal
#

Add comments

eternal oxide
#
    /**
     * Pass a Projectile and a destination
     * to set its direction and new velocity.
     * 
     * @param projectile
     * @param targetLoc
     * @return
     */
    public void setTarget(final Projectile projectile, final Location targetLoc) {
    
        final Vector velocityVector = targetLoc.toVector().subtract(projectile.getLocation().toVector());
        velocityVector.normalize().multiply(projectile.getVelocity().length());
        projectile.setVelocity(velocityVector);
    }```
warm galleon
#

oh

#

that was a method all this time

dense shoal
#

Well yeah

warm galleon
#

wait what class

#

cuz i acnnot find it for my life lmao

eternal oxide
#

its not in spigot

warm galleon
#

oh

eternal oxide
#

copy that method

warm galleon
#

totally not spoonfed

eternal oxide
#

totally not 🙂

dense shoal
#

I'm getting a weird case of deja vu. Where have I seen that code before?

warm galleon
#

what would the starting velocity be then

#

because in player.launchprojectile you need to pass in velocity too i think

eternal oxide
#

it crops up in here a lot. Myself and 7smile7 wrote it a long while back as an example

warm galleon
#

wait no theres another method without

#

im a dumass

dense shoal
#

Ah gotcha

green prism
eternal oxide
#

I've never used any lib

green prism
eternal oxide
#

do you already have the texture as a Base64 string?

pale egret
#

I'm wanting to start a server, but idk what server host to go with. What do y'all recommend

lethal roost
#

yeah i know, it's just i didn't know what casting meant before now (like i know what it IS but just not the term) so i didn't understand what the red thing said, my bad

pale egret
green prism
#

OVH

covert karma
#

how do i get the coordinates of the nearest structure? like the /locate command

#

(in 1.19 if that matters)

eternal oxide
green prism
#

uhhh thatsnks

onyx fjord
#

why would you host servers on windows in first place

eternal oxide
#

um, seems you still can;t force set a texture to a profile, even with the new PlayerProfiles

onyx fjord
#

like 99% servers in the world use unix-like systems

covert karma
eternal oxide
eternal oxide
#

yeah no signature 😦

quaint mantle
#

can you somehow redirect the console stream to somewhere on the server? for example to the chat?

plush zodiac
#

someone know how to add command when you buy item in economy plugin?

bold copper
#

Hello everyone, please tell me, is it possible to do something similar with lore at ItemStack? String.format("String1,\n String2 %s", object)

eternal oxide
#

You need to know how to use Mojang mappings

#

?paste

undone axleBOT
chrome beacon
#

If you want to get a head you can do that without NMS

eternal oxide
#

but thats using NMS

chrome beacon
#

Why not use the new API?

eternal oxide
#

it has no set texture

chrome beacon
#

It does

eternal oxide
#

?

green prism
eternal oxide
#

oh yes, if you have a URL or a texture and signature

echo basalt
#

GameProfile is not nms

#

It's part of mojang authlib

humble tulip
eternal oxide
#

sorry yep

chrome beacon
eternal oxide
#

I'm so used to annoying NMS today

green prism
echo basalt
#

And not that much of a pain in the ass to mess with

green prism
#

I don't want to use some legacy items

echo basalt
#

Nms doesn't even bother me anymore

eternal oxide
#

all teh setSkin methods take a URL

chrome beacon
#

Yeah

#

ofc they do

eternal oxide
#

exactly, which is why reflection to set a custom texture

chrome beacon
humble tulip
#

?paste

undone axleBOT
green prism
#

?paste

undone axleBOT
humble tulip
green prism
humble tulip
#

here is a class to set skull textures from 1.8-1.19

chrome beacon
#

What are you talking about

#

oh you're messing with NMS again

#

Use the methods I sent

chrome beacon
#

and simply decode base64 for texture link

green prism
#

i'll try and let u know

tardy delta
humble tulip
dry pike
#

Im trying to find information to read up on regarding remote processing large resource intensive functions remotely... Would you call it an API? I basically want to sent data to another server and process it there and return processed information. What is this called? I cant seem to find the right keywords to search for more information regarding the topic?

humble tulip
#

u can use sockets, bungee plugin messaging, possibly redis

cyan compass
#

Question. if i use Bukkit.getServer().unloadWorld(Bukkit.getWorld(worldName), true); and the world it's trying to unload isn't loaded. What will happen?

humble tulip
#

depends on what ur doing

undone axleBOT
dry pike
# humble tulip depends on what ur doing

Basically just want to perform some logic remotely to reduce the load on my main server. I don't need to communicate with another minecraft server rather just another machine with extra resources available.

humble tulip
#

Ohh well you can create an api that works over http or something

cyan compass
# humble tulip ?tryandsee

Thanks but i came here to ask instead because this feels like something people would know the answer to already which would save me time so that i don't have to write code that probably will fail, then package the plugin, put it onto the server, boot the server (which takes like 2 minutes on it's own) and boot up my game and login and test it

dry pike
cyan compass
#

So i was busy typing that

humble tulip
#

Could've been typing code and packaging your jar😂

#

Just throw it in your onenable and put it in a 1.8 testserver which starts up in 10 seconds

#

Could be done in 1 min

humble tulip
dry pike
humble tulip
eternal oxide
dry pike
chrome beacon
humble tulip
golden raven
#

hello could someone send me a script of a game mode for the roles because I am a beginner and I would like to know what it looks like ty

humble tulip
#

and then use a bukkitrunnable to return the the main thread and set whatever

dry pike
eternal oxide
chrome beacon
dry pike
humble tulip
#

yep

humble tulip
#

Callback<Result>

dry pike
green prism
humble tulip
#

one sec, i can show u how it's done in my plugin

dry pike
#

Is a callback similar to an api returning processed data?

chrome beacon
green prism
#

ah

green prism
golden turret
#

is it possible to create fake players using the api?

chrome beacon
#

No

#

You will need NMS

golden turret
#

spigot bad

green prism
golden turret
#

nms good

humble tulip
#
    public Callback<EnderChest> getEnderChest(String name) {
        CaselessString mcName = new CaselessString(name);
        if (this.nameUUIDMap.containsKey(mcName) && this.uuidEnderChestMap.get(this.nameUUIDMap.get(mcName)) != null)
            return Callback.withResult(this.uuidEnderChestMap.get(this.nameUUIDMap.get(mcName)));

        if (this.nameCallbackMap.containsKey(mcName))
            return nameCallbackMap.get(mcName);

        Callback<EnderChest> callback = new Callback<>();
        this.nameCallbackMap.put(mcName, callback);

        Bukkit.getScheduler().runTaskAsynchronously(this.getPlugin(), () -> {
            EnderChestSnapshot snapshot = this.dataManager.loadEnderChest(name);

            EnderChest enderChest = snapshot == null ? null : new EnderChest(snapshot.getUuid(), snapshot.getName(), snapshot.getContents(), getInventoryNames(snapshot.getName()));
            Bukkit.getScheduler().runTask(this.getPlugin(), () -> {
                this.nameCallbackMap.remove(mcName);
                if (enderChest != null) {
                    this.uuidEnderChestMap.put(snapshot.getUuid(), enderChest);
                    this.nameUUIDMap.put(mcName, snapshot.getUuid());
                }
                callback.setResult(enderChest);
            });
        });

        return callback;
    }
#

look at how u can use callbacks

#

callback is a class i made myself in this case

eternal oxide
dry pike
humble tulip
#

u create a callback object which u return, u then create an async task which does the heavy stuff and then u create a sync task and set the result of the callback so that the callback result stuff can be executed sync

tardy delta
#

and it can be simplified that code

glossy venture
#

yeah could also use CompletableFuture there

humble tulip
#

wont i have to use a runnable to return to the main thread?

glossy venture
#

ah

humble tulip
#

if i return a completable future, i'll have to use a bukkitrunnable wherever i call the method so that i can return to the main thread

covert karma
#

why does player.getWorld().locateNearestStructure(player.getLocation(), StructureType.NETHER_FORTRESS, 10000, true); always return null?

covert karma
#

yes

humble tulip
#

ok then idk

#

someone else might

visual mulch
#

How do I download the development tool]

#

(intellijidea)

hasty prawn
#

Same way you download anything else

visual mulch
#

or do I just use this lol

hasty prawn
#

No, IntelliJ isn't affiliated with MC

#

Yes that

eternal oxide
visual mulch
humble tulip
dry pike
chrome beacon
eternal oxide
humble tulip
#

last one returns a string

#
    public static String getUrlFromSkull(SkullMeta meta) {
        try {
            GameProfile profile = ((GameProfile) profileField.get(meta));

            if (profile == null)
                return null;

            Optional<Property> optional = profile.getProperties().get("textures").stream().findFirst();

            if (optional.isEmpty())
                return null;

            return new String(Base64.getDecoder().decode(optional.get().getValue().getBytes())).replace("{textures:{SKIN:{url:\"", "").replace("\"}}}", "");

        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return "";
    }
chrome beacon
#

Looks like discord did something

eternal oxide
#

just having teh link is no good. I need to generate teh URL with just the texture

humble tulip
#

wdym?

chrome beacon
#

I don't see the problem

eternal oxide
humble tulip
#

you have the link to the textures

chrome beacon
#

Why not

eternal oxide
#

We have an encoded Base64 texture

humble tulip
#

i dont see what you need

eternal oxide
#

to set that as a texture in the profile we need a URL

eternal oxide
#

convert from Base64 texture to URL =

chrome beacon
#

Base64 -> JSON -> get url

humble tulip
#

base64 texture is what the profile uses

#

not url

chrome beacon
#

API uses url

#

that's why we need it

eternal oxide
humble tulip
#

oh

#

i dont use playerprofile

#

i use reflection instead

chrome beacon
#

I still don't see the problem?

humble tulip
eternal oxide
humble tulip
#

u can

chrome beacon
#

Let me write it for you ElgarL

humble tulip
#

new String(Base64.getDecoder().decode(base64.getBytes())).replace("{textures:{SKIN:{url:\"", "").replace("\"}}}", "");

#

like this

eternal oxide
#

ah I didn;t decode

humble tulip
#

ofc u need to decode it

#

but are you using reflection or playerprofile?

eternal oxide
#

trying PlayerProfile

humble tulip
#

ok

humble tulip
green prism
dark arrow
#

is there any documentation for mojang mappings like spigot api

eternal oxide
#

No javadocs no

dark arrow
#

?nms

#

😦

#

its becomes hard to find the methods

#

?sadlife

eternal oxide
#

as that is JUST the texture

humble tulip
#

wdym JUST the texture?

golden turret
#

guys, im in 1.17.1 (i MUST be on that version) and i dont have the hideEntity and showEntity methods so im making these by hand. This is my current code:
NPC.java: https://paste.md-5.net/ixofegafak.java
NPCListener.java: https://paste.md-5.net/quxefatuzo.cs
Configuration.java: https://paste.md-5.net/otoyadecov.php
Basically, when i first create the npc (NPC#spawn) it works fine and i can right click the entity but when i despawn it for the player (NPC#hide) and then show it again (NPC#show) i cant right click the npc anymore.
What can i do to fix it?

humble tulip
#

can u send the "texture" ur trying to get the url for?

eternal oxide
#

Simple to apply via reflection

green prism
#

🧐

#

what r u trying to do?

humble tulip
green prism
#

🧐 🧑‍🌾

humble tulip
eternal oxide
#

replaces? they shoudl not be in teh decoded string

green prism
#

isn't more easier use split?

humble tulip
green prism
#

.split("\ "")[6]

#

can't do the backslash attached

eternal oxide
#

still no good

#

Caused by: java.lang.IllegalArgumentException: Illegal base64 character 3a

green prism
#

wy

#

a

eternal oxide
#

That String I posted is JUST the texture

humble tulip
#

bruh what are you doing

green prism
eternal oxide
#

its teh texture without the {"textures":{"SKIN":

humble tulip
#

works for me

#

you're doing something wrong

green prism
#

you're not replacing a :

#

that's the 3a error

eternal oxide
#

You are getting a String fine. now get a URL from that

green prism
#

from decoded

#

just replace or split by "

#

and here u go

chrome beacon
#

Yeah exactly that

#

then put that url in to api and done

eternal oxide
#

seems sloppy

chrome beacon
#

Better than reflection

eternal oxide
#

true

green prism
#

I follow you from 100 followers

eternal oxide
#

actually that shoudl be valid json

chrome beacon
#

That is valid json

green prism
chrome beacon
#

I've been saying that this entire time 🙃

steep nova
#

How do you detect if an item has been thrown into the void?

chrome beacon
#

That would be a bit hard

humble tulip
#

check the item a few ticks later maybe

chrome beacon
#

I guess you could keep a reference and check isDead

#

then get location

green prism
#

no?

humble tulip
#

after a few ticks tho

chrome beacon
#

Just y < 0

#

use the scheduler for that yeah

humble tulip
#

when the velocity is no longer horizontal

trail lintel
#

How do I check if a block is a source block for water or lava? Some old answers were saying check if Block.getData() returned 0, but that method is deprecated now.

green prism
#

@eternal oxide, how u doing? did you make it?

eternal oxide
#

still messing with it

chrome beacon
#

Should I just make it instead?

eternal oxide
#

Nah I'd shoot you 🙂

chrome beacon
#

I really should this is the third time I have explained this step by step

#

I can have an example next time

eternal oxide
#

Your step by step is lacking

green prism
humble tulip
#

what dont u understand elgar

chrome beacon
#

I sent methods for each step

#

with javadoc

#

and told you to decode and get link

green prism
humble tulip
#

u have base 64 string

#

u decode and get {"textures":{"SKIN":{"url":"http://textures.minecraft.net/texture/a9f11c0d497f227089cbf614601109caf615453940ef5f64ebb177957e4fa6e5"}}}

eternal oxide
#

I'm just having problems decoding the json now

chrome beacon
green prism
humble tulip
#

u can split at "

#

or u can just replace the first and last part

green prism
eternal oxide
#

nah its json, shoudl process it as such

humble tulip
green prism
humble tulip
#

it does

green prism
#

so

#

0

#

1

humble tulip
#

so 7

green prism
#

2

#

ah

humble tulip
#

json.split("\"")[7]

#

like that elgar

#

ops

green prism
#

with a backslash before the "

#

\ "

humble tulip
#

gotta escape the \

#

i forgot to do that

eternal oxide
#

json has keys for a reason

humble tulip
#

oh dear god

#

u wanna use gson then?

humble tulip
#

who cares if json has keys

green prism
eternal oxide
#

I care. I'd like to do it properly. no shortcuts

humble tulip
#

actaully using gson is more inefficient

#

since ur parsing the string into a json object

green prism
eternal oxide
#

um true

#

but thats ugly ^ 🙂

green prism
#

wat

#

that's quite mad ahaha

tardy delta
#

whaat

green prism
#

FourteenBrush

quaint mantle
#

if somone has experience with GCP, can you help me out? im hosting my server on gcp linux and my plugin uses mysql but im not sure how i can get a localhosted mysql database on gcp

green prism
humble tulip
#

if json is ugly and splitting is a shortcut

#

just dont set a skin then

steep nova
humble tulip
#

use alex or steve

green prism
tardy delta
green prism
# steep nova What event should I use for this?

Example:

public void onPlayerDropItem(PlayerDropItemEvent e) {
if(e.getItem().getItemstack().getType().equals(Material.SLIME_BALL) {
Location slimy_location= e.getItem().getLocation()
// etc
}
}```
humble tulip
#

or use the api of skullmeta.setOwningPlayer

lusty cipher
#

has 1.19 broken custom inventories in some way?

tardy delta
green prism
lusty cipher
#

one of my inventories just doesn't open

#

no error

#

the function opening it runs

#

but nothing happens

green prism
lusty cipher
#

and it looks as if the inventory opens for a split second and directly disappears again

steep nova
green prism
#

bRUHHHH

steep nova
#

Wdym

green prism
#

takes a deep breath

humble tulip
steep nova
#

I need it to work for one particular item, not all items

tardy delta
steep nova
#

And it may not always be dropped by a player, it could be dropped by something else

green prism
#
public void onPlayerDropItem(PlayerDropItemEvent e) {
if(e.getItem().getItemStack().getType().equals(Material.YOURFAVORITEMATERIALRIGHTTHEREOKAY?) {
     if(e.getItem().getLocation().getHighestBlock < 0) {
        player.getInventory().add(e.getItem().getItemStack())
    }
}```
humble tulip
#

Why do u need to know if an item is in the void?

steep nova
#

I don’t want it to get destroyed, I want it to be returned to a player

green prism
steep nova
quaint mantle
#

yes

#

its a PlayerDrop event

steep nova
#

What if the player uses a dispenser, or other method

green prism
steep nova
#

Bruh

#

Care to explain then?

green prism
#

@steep nova Example

    public void onDispense(BlockDispenseEvent e){
    if(e.getBlock().getType() == Material.DISPENSER){
    //Your Code
    }
    }```
quaint mantle
#

Hello guys, I have an issue with my maven local repo. I am trying to use spigot-api 1.19 but I don't understand this error:

#

I am using gradle and here is what it looks like in my config:

#
compileOnly group: 'net.md-5', name: 'bungeecord-api', version: '1.17-R0.1-SNAPSHOT'
green prism
#

that's not 1.19

steep nova
quaint mantle
#

wow sorry wrong line

#
        compileOnly group: 'org.spigotmc', name: 'spigot-api', version: '1.19-R0.1-SNAPSHOT'
#

here is the correct one

quaint mantle
#

if there isnt a itemdrop event universally then yes you will

green prism
#

Thunderin the best

covert karma
#

./locate command works

green prism
#

use maven if you like kids

crisp steeple
quaint mantle
#

itemspawn isnt the same as itemdrop i thought

#

Called when an item is spawned into a world

#

its when an item gets spawned, not dropped

crisp steeple
#

i mean yeah, but if you want to listen for every way an item can appear you would use that

#

if you only want to listen for when a player drops an item, then theres really only one way they could

eternal oxide
quaint mantle
#

im not sure if when a item is dropped (no matter the source), this event would get triggered

#

only one way to find out!

eternal oxide
#

just has a Steve skin

#

oh ignore me, I'll crawl into a hole 🙂

quaint mantle
#

can i come with?

#

if somone has experience with GCP, can you help me out? im hosting my server on gcp linux and my plugin uses mysql but im not sure how i can get a localhosted mysql database on gcp

eternal oxide
#

I didn;'t even set the meta 🙂

crisp steeple
chrome beacon
# eternal oxide oh ignore me, I'll crawl into a hole 🙂
JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject();
JsonObject textures1 = json.get("textures").getAsJsonObject();
JsonObject skin = textures1.get("SKIN").getAsJsonObject();
String urlString = skin.get("url").getAsString();

If you want to use json

eternal oxide
humble tulip
#

Lmfao

covert karma
rain echo
#

Hi!

chrome beacon
eternal oxide
#

lol

#

well at least the other reflection one will work for him

rain echo
#

How could I create an event for a custom inventory, I mean how I could detect my custom inventory without using the getHolder or getTitle /Name function?

eternal oxide
arctic moth
#

what would be the best way to append all of the args after an arg to a string

crisp steeple
river oracle
river oracle
rain echo
crisp steeple
#

no, just need to compare the instance of the inventory to another

river oracle
#

this.inventory.equals(e.getInventory) returns true or false

crisp steeple
#

lets say you have a custom inventory, whenever you create that inventory you could add it to a Set somewhere. then, you have a listener for an inventoryclickevent, when that fires you iterate through the inventories in that set, see if theres one there that matches the inventory in the event, and if so you trigger a method in that custom inventory

cunning prism
#

hey guy so did just bungeecord-chat repo got down? its can't find for me on build :(

rain echo
#

like a new instace

#

separated from the opened inventory

#

menu = new menu();

crisp steeple
#

so that you have a reference of it that you can track

rain echo
covert karma
#

ok since this apparently doesnt work using spigot api, can someone help me how to get a TagKey<Structure> in nms so i can call ServerLevel#findNearestMapStructure ?

rain echo
#

im doing something wrong

crisp steeple
green prism
#

@eternal oxide, anyway in the end, I’m in 1.16.5 and I found thanks to Olivo that the method he thought was too advanced for my technology of the twentieth century... now I will use your method thank you very much for your help!

eternal oxide
#

np it was fun to be baffled for a bit

tall dragon
#

can any suggest a good particle for displaying a region?

#

bassically a box of particles

green prism
#

wat

green prism
arctic moth
# crisp steeple no

wait so im confused is array supposed to be the Arrays.copyOfRange thing? last time i checked Array isnt a CharSequence

crisp steeple
arctic moth
#

oh

#

k

#

thx

green prism
#

is static itemstack a memory leak?

green prism
#

it seems the best xd

tall dragon
#

well i need another color

#

preferably a particle that stays mostly still

brittle lily
#

hi guys, I added a value that players can change at will.For example, whatever is written as the 1st argument in a command is the value. But when the Player makes a 2nd action, the preset value remains constant. how can i reset the value after it's done with the command

quaint mantle
#

if somone has experience with GCP, can you help me out? im hosting my server on gcp linux and my plugin uses mysql but im not sure how i can get a localhosted mysql database on gcp

#

does anyone have a good "guide" on how to make scoreboards?

ivory sleet
#

the javadocs

quaint mantle
arctic moth
#

smh purple is overriding bold

#

theres no reset char in there

eternal oxide
#

When was PlayerProfile added 1.17?

arctic moth
eternal oxide
#

nah its spigot

ivory sleet
eternal oxide
#

it was around 1.17 not sure if before or after

ivory sleet
#

but else there's a wiki

lusty cipher
pale egret
lusty cipher
#

or 1.18.x

#

fairly recent at least

tall dragon
#

pretty sure 1.17 yea

pale egret
eternal oxide
#

I'll comment it 🙂

proper notch
subtle folio
#

Hey gaymers, say I have a list of yml inside a container like this. How would I be able to get all the UUID's inside of it?

quaint mantle
#

@ivory sleet nvm ur right

maybe i should not forget the annotation for a eventhandler yes im dumb

lusty cipher
#

or what are those

subtle folio
#

no..

#

its serialized objects silly

ivory sleet
humble tulip
subtle folio
#

yay ty

humble tulip
subtle folio
#

Im poor lmao

#

cant afford one of those

humble tulip
#

Sqlite

#

A file database

subtle folio
#

ohh

#

not yaml it?

covert karma
#

please, has no one here ever used locateNearestStructure before
it seems to just not work at all

humble tulip
#

Not yaml

subtle folio
#

but yaml cool

humble tulip
#

Ppl might tamper with the yml file for one

#

Since they'll think its configurable

subtle folio
#

its for a server core 😛

#

i have folders setup for storage and configs

crude cobalt
#

Quick question, can I cancel a player's attack on another entity?

subtle folio
#
  • if ppl want to they can edit it
subtle folio
humble tulip
#

Modifying serialized data can corrupt it

subtle folio
#

this is the full file

#

so if ppl wanna edit the players portion they may

humble tulip
#

You do whatever suits u

subtle folio
#

alr alr 😛

humble tulip
#

Personally, I'd use a db

rain echo
humble tulip
#

That'll work

subtle folio
#

What is a Set

humble tulip
#

Depedns on the usecase, there may or may not be a better way

humble tulip
subtle folio
#

ah perfect

humble tulip
#

So u can't get any specific thing

subtle folio
#

mhm mhm

#

but i can iterate over it

humble tulip
#

Just get all and iterate, check if it contains and remove and add

subtle folio
#

mhm mhm

crude cobalt
quaint mantle
#

if somone has experience with GCP, can you help me out? im hosting my server on gcp linux and my plugin uses mysql but im not sure how i can get a localhosted mysql database on gcp

subtle folio
#

minion

humble tulip
#

Hi

humble tulip
#

Oh i dont

#

I use ubuntu

subtle folio
#

i thought u were the db man

quaint mantle
#

thats fine

#

ubuntu works

#

i can migrate at any point so if you can help, thatd be great

humble tulip
#

I setup my db by followong an online guide

quaint mantle
#

yeah me too, i got to the point where mysql-server is installed but im stuck here

crisp steeple
humble tulip
#

Watching a yt vid might be your best bet

quaint mantle
#

do i have to set a password? ill have to make changes to the plugin for that if i do

humble tulip
#

U can implement inventoryholder

#

And check if the holders match in the listener

#

It's also not version specific

humble tulip
#

That's not the best way sergiu

crisp steeple
covert karma
#

How do I locate the nearest Nether Fortress?
World#locateNearestStructure always returns null, even though the /locate command itself is able to find it
using Bukkit.dispatchCommand to execute /locate doesnt produce a result
And lastly, I cant figure out how to use nms to do it because it requires a TagKey<Structure> and idk how to get that
please i have been trying to do this for so long now i need help

crisp steeple
# humble tulip Why not?

Because that's not what its supposed to be used for, and people abuse it as a way to check what type of an inventory is when using instances is a more reliable way

humble tulip
covert karma
#

this was not for 1.19

humble tulip
#

Should work the same

covert karma
#

it seems to have changed a lot

humble tulip
#

Look into nms and see how the locatw command works

#

And basically copy it

covert karma
#

i did that

#

yea

#

i did that

#

but it doesnt work out

#

how do i get a TagKey<Structure>

humble tulip
#

See how the command gets it

covert karma
#

its a whole bunch of other shit that i dont know how to get

humble tulip
humble tulip
#

Sorry

crisp steeple
humble tulip
eternal oxide
covert karma
eternal oxide
#

I'm saying if the chunk is not loaded or not generated it will not be searched

covert karma
#

as far as i understand it, it just says that it will not generate chunks, but is still able to search in not-generated chunks

#

but either way, it still doesnt work when literally standing inside a fortress so that doesnt really matter

eternal oxide
#

possibly

#

The javadoc is not clear on that

tranquil dome
#

Would it be problematic to frequently check and update player metadata? On playerMoveEvent, entityDamageByEntityEvent, entityLaunchEvent etc.

eternal oxide
#

use PlayerMoveEvent as little as you can

tranquil dome
#

I'm assuming it can cause lag?

chrome beacon
#

Yeah

#

Gamerules are per world

#

(on spigot)

solid sigil
#

one by one

chrome beacon
#

Go to each world and run the command world be the easiest

solid sigil
#

maybe a shell script?

golden turret
#

the 1st image is the id of the entity (Entity#getEntityId) when it is spawned
the 2nd one is the id of the right clicked entity in the event
the 3rd is me getting the entity id inside a packet listener I wrote

I spawn the entity and I can interact with it. Then some things happen and I send a destroy packet to the player and after a few things, I send the spawn packet for the packet listener to work. Lets say the entity id when it spawns is 10. When I right click it, the printed id is 10. When I right click again (after the destroy and spawn packet) the printed id is also 10 but when I try to get the entity based on the id by looping all entities, it never finds the entity I want. Why does this happen?

solid sigil
#

youd have to write a script to launch each world, change the rule, then close it

chrome beacon
#

Just use the API

solid sigil
#

seems unnecessary. how many worlds do u have

#

def unnecessary lol

#

but no harm in practicing code stuff

#

gotcha

tall dragon
#

sooo i need some big brains. say I have a List of locations and 1 location inside that list is an origin point i'm trying to look for a good way to sort that list so the locations will spread from that origin point here is an image of what i'm trying to do in 2d space, i'm looking for an efficient way to do this in 3d space https://gyazo.com/07dadf5b0fa540d5b1b884d877bc8aed
thanks in advance.

solid sigil
#

I don't really understand what youre trying to do

#

tbh

tall dragon
#

i feel like i gave a pretty clear explaination

solid sigil
#

i might just be small brain

quaint mantle
#

why is it 4 1 0 2 3 5 6

#

that is not sorted sequence

solid sigil
#

p new to spigot anyway, I hope someone helps find a solution

eternal oxide
#

are these locations connected (ie Blocks)?

solid sigil
#

yeah like i cant see a pattern

tall dragon
#

1,2 are on equal distance

echo basalt
tall dragon
#

so they are random like that

#

same as 4, 3

solid sigil
#

what about the directionality

#

why is there an arrow from 1-4 but not 3-5

tall dragon
#

i forgot -,-

eternal oxide
solid sigil
#

ah nvm

solid sigil
#

thought it might be significant

eternal oxide
#

then its simple. I already did a class for that

#

one sec while I find it. I did it for finding sequential claimed chunks

tall dragon
#

sure

eternal oxide
#

?paste

undone axleBOT
eternal oxide
#

this uses a WorldCoord system. Basically chunks

tall dragon
#

im not sure i understand how i willl use this right away.

eternal oxide
#

getPlotCardinal and getPlotOrdinal get claimed Plots around an origin

#

getPlotAllConnected uses those methods to tree search all connected plots

tall dragon
#

ahh i see

#

and all i gotta do is change it to work with blocks

#

thanks

eternal oxide
#

yep

quartz basalt
#

why am i getting this error from @EventHandler public void onRightClick(PlayerInteractEvent e) { if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { ArrayList<Material> materialArrayList = new ArrayList<>(); for (String materials : Kits.getInstance().getConfig().getStringList("blocks")) { materialArrayList.add(Material.valueOf(materials.toUpperCase())); } if (!materialArrayList.isEmpty()) { if (materialArrayList.contains(Objects.requireNonNull(e.getClickedBlock()).getType())) { Player p = e.getPlayer(); p.openInventory(GUILib.getGUI()); } } } } - [21:22:12 ERROR]: Could not pass event PlayerInteractEvent to Kits v1.0-SNAPSHOT java.lang.ArrayIndexOutOfBoundsException: null thats it btw theres nothing else

eternal oxide
#

that code is not throwing that error

quartz basalt
#

yeah it is wdym

vocal cloud
#

Please throw the whole stack trace into a pastebin

quartz basalt
#

thats it

#

thats all thats in my console

vocal cloud
#

Yeah that's not being thrown by this method

quartz basalt
#

... but thats the only event in my plugin

eternal oxide
#

Nothign in that code accesses any index of an array

quartz basalt
#

tf then why would i be getting that error

vocal cloud
#

Also do a null check don't use Object.RequiresNonNull

eternal oxide
#

post the full stack trace and we might be able to tell you. There is more to the error

vast raven
#

In a DropEvent, I passed on a method the item dropped as itemStack, in that method, doing taser.getItemMeta().setDisplayName("§6§lTaser §e«1»"); , causes no erros, but it doesn't change the name.

covert karma
#

you have to setitemmeta

#

after

tall dragon
#

getItemMeta returns a clone

quartz basalt
#

that is it

eternal oxide
#

look in your log file

vast raven
quartz basalt
eternal oxide
#

You have to set teh altered ItemMeta, not another clone

sage coral
#

hello can me wehre help

quartz basalt
#

oh nvm

sage coral
#

@sage coral

quartz basalt
eternal oxide
#

?paste

undone axleBOT
quartz basalt
#

1sec restarting server

covert karma
#

tip that people in here apparently hate: you can use plugman and autoreload

#

so you dont have to restart your server every time

eternal oxide
#

Its fine for dev work, but once things break (and they will) always full restart

quartz basalt
#

plugman was the issue after i restarted my server it sent the full error but i got it now ty

eternal oxide
#

🙂

sage coral
#

i need the plugin Jlib and it removed on spigot mc and now i need your help . ITS VERRY IMPORTANT !!!

eternal oxide
sage coral
#

YES

eternal oxide
#

Very old. for 1.7.9 Bukkit

sage coral
#

is the sure code i need this for plugin

sage coral
#

can you help me ?

eternal oxide
#

well, thats the Github for it

#

you'll need to compile it. At least it uses Maven

golden turret
#

im spawning my entity like this and when I right click it, the entity despawns. How to fix it?

covert karma
#

what even is that, it was made 8 years ago and has no description in the readme at all

#

jlib i mean

eternal oxide
#

some mention about packets

#

No clue. Never heard of it. That was a DDG search "spigot jlib"

covert karma
#

interesting that first thing people do is apparently ask on discord instead of googling

sage coral
eternal oxide
sage coral
#

how does that work?

#

cann you help me whit this

solid sigil
covert karma
eternal oxide
covert karma
#

open the project in intellij, build and then package

sage coral
eternal oxide
#

There are many issues with this code

solid sigil
#

🪦 rip

sage coral
covert karma
#

you should ask a proper question instead of just "can you help"

eternal oxide
vale cradle
# sage coral can you help me?

I think the problem is that nobody seems to understand what are you really asking for. Or what are you working with. Makes it very hard to help you.

eternal oxide
#

@sage coral ^

sage coral
#

thx

eternal oxide
#

I have no idea if it will work though.

vale cradle
#

I thought he wanted it removed lol

eternal oxide
#

So many type safety warnings and it used a maven plugin that no longer exist

vale cradle
eternal oxide
#

yep

#

CB 1.7.9

sage coral
#

org.bukkit.plugin.UnknownDependencyException: WastedGuns
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:216) [server.jar:git-Spigot-79a30d7-f4830a1]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:305) [server.jar:git-Spigot-79a30d7-f4830a1]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:205) [server.jar:git-Spigot-79a30d7-f4830a1]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [server.jar:git-Spigot-79a30d7-f4830a1]
at java.lang.Thread.run(Thread.java:833) [?:?]
[22:58:28 ERROR]: Could not load 'plugins\WastedVehicles.jar' in folder 'plugins'

#

cann any me help

eternal oxide
#

um, 1.12?

vale cradle
#

there's no dependency found

eternal oxide
#

no way that 1.7.9 JLib will work on 1.12

vale cradle
#

you have to put the WastedGuns plugin in the Plugins folder for it to work ig

sage coral
#

it is

eternal oxide
#

Let me know if you get it all working so I can delete this code from my IDE

tardy delta
#

hows the plugin called?

#

dont think that it requires a dependency but cannot be found

vale cradle
#

I believe couldn't load WastedVehicles because WastedGuns plugin was not found

sage coral
#

dont work this plugin have tihs eroor

#

any talk ? wiht screen shere?

eternal oxide
#

You need to find the plugin called WastedGuns

sterile token
#

where i can find jConsole library?

#

I have looking it for more than 1 week

eternal oxide
#

JConsole should be included in your Java install

pale egret
#

how would I make it so if a player doesn't have a certain permission when they break a block it doesn't break?

terse raven
#

!Player.haspermssion -> event.cancel

#

How do you what

#

PlayerDeathEvent and check for location

pale egret
terse raven
#

event.setCancelled

#

or something

eternal oxide
#

or if you mean you want to spawn them somewhere do it in the respawn event

pale egret
eternal oxide
#

do you want to avoid the death screen, or wait for them to click respawn?

eternal oxide
#

use teh setRespawnLocation

pale egret
terse raven
#

?events

eternal oxide
#

no

terse raven
eternal oxide
#

they will only be repawnign if they died

terse raven
#

?eventapi

undone axleBOT
pale egret
#

i tried doing e.setCancelled(true); it didn't work

vale cradle
#

did you register the listener?

#

and used the @EventHandler?

pale egret
#

Bukkit.getPluginManager().registerEvents(new Welcome(), this); I did this

#

and yes i did use eventhandler

vale cradle
#

show your code then?

pale egret
#

wait nvm I forgot to do the listener

upper tendon
#

Is there a way to detect when anything enters a players inventory?

tardy delta
#

itempickup event

vale cradle
#

PlayerPickupItemEvent & Certain instances (not always) of the InventoryClickEvent

upper tendon
#

Ok I have those, but Inventory click wont detect shift clicking items

vale cradle
#

it should

#

ig

#

no, I think it should

#

which version you are?

upper tendon
#

1.19

sterile token
#

java -jar BuildTools.jar --rev 1.19 => "Version not found"

eternal oxide
#

update your BuildTools I guess

sage coral
#

canmn wre my help

pale egret
#

How would I make it so when do /plugins it shows a message and doesnt show you the plugins

eternal oxide
#

remove the plugins command from the command map

#

Else they can still do minecraft:plugins

sterile token
#

Lmao i didnt know i have to update buildtools

eternal oxide
#

my script auto updates mine, so I never have to

sterile token
#

I thought the build tools was just a connector

#

😮‍💨

eternal oxide
#

it gets updates and fixes occasionally

vale cradle
pale egret
#

ok

sterile token
vale cradle
#

that too I guess :P

sterile token
#

You can completly unregister the plugin command

#

Also why dont do they do a explicity getter for it? 🤔

vale cradle
#

I usually replace the commands using the regex: /\s*(.*:) to blank space, then check if the first word matches because I'm lazy

sterile token
#

Its ugly annoying using reflections every time you want to access to CMDMap

vale cradle
#

lol

sterile token
#

what?

#

Im not doing anything

vale cradle
#

I had to google it everytime

vale cradle
sterile token
#

So

#

Why you get mad...

vale cradle
#

I didn't get mad, I was just joking because I thought you were, there are a few memes in the dev community about the email regex, all good lol ;)

sterile token
#

Oh ok

#

My bad

vale cradle
sage coral
#

how can make a surecode to a plugin?

vale cradle
sterile token
sage coral
#

I'm too stupid for that

sterile token
#

Because there is no other way

golden turret
sterile token
#

Amazing build tools

#

Is really that i would have to install 1.17 java for compiling a 1.19 spigot

golden turret
#

very good

sterile token
#

Is not posible to compile it with the JDK 17, instead of java 17?

golden turret
#

i think you just responded to the wrong person

sterile token
#

Is it possible to compile spigot 1.19, with JDK 17?

vale cradle
#

I think it's meant to be like that

#

required*

sterile token
#

Because my build tools, said java 17 required

#

So im confused

vale cradle
sterile token
vale cradle
sterile token
#

I have on my system java 8 + JDK 8 and JDK 17

vale cradle
#

open console and do java --version

#

you will see what your default java version is

sterile token
#

Appears 8

#

That why

#

I also didnt install Java 17, i installed the JDK 17

vale cradle
#

if you want to change your default you can modify the $JAVA_HOME env variable or manually use the binary file of the Java 17 folder when running BuildTools

vale cradle
sterile token
eternal oxide
pale egret
#

How do I make a command with spaces

vale cradle
#

??

golden turret
#

and i was teleporting far from the entity

sterile token
#

Arrays start counting from 0

#

so let say i run: /command <player> <text>

/command => will be your command
<player> => Your first argument, index 0 in the array
<text> => Your second argument, index 1 in the array

#

Do i explain?

vale cradle
#

(make sure to check first the length of the array before accessing on one of their indexes ;))

sterile token
#

Because in case, they run your command with 0 arguments, and you are checking if x argument equals to something. Then you will get an exception

golden turret
tender shard
#

you shoulndt implement your own inventoryholder at all

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 ```depend:

  • Vault```
tender shard
#

you can use an inventoryholder to check to what an inventory belongs

#

for example in inventory click event, you can get the inventory's holder and it might be a chest

#

or it's the player itself, when they clicked in their own inventory

#

you implement your own inventoryholder but you should not do that. Bukkit interfaces aren't meant to be implemented by plugins

#

you should rather create some custom object to hold information, and then store it inside a map together with the inventory that you want to associate it with

#

no. the javadocs explicitly say that the API is designed to "only be implemented by server software" and "should not be implemented by plugins"

tardy delta
#

i always extends invholder to see if an inv is one of my custom invs 🥺

#

instead of holding a map

tender shard
#

yeah I also used to do that

#

but actually one shouldnt do that

tardy delta
#

but then im having separate listeners for each gui instance

#

not really ideal

tender shard
#

why that?

#

instead of

if(inventory.getHolder() instanceof MyGuiHolder)

you just do

if(myGuis.contains(inventory))
tardy delta
#

just in the gui class i have a listener that listens for the specific slots being clicked, im not storing the guis anywhere so i havent made it static

#

anyways i should really go to bed lol

tender shard
#

no

tardy delta
#

gn 👋🥺

tender shard
#

you should come online

#

good night 😗

tardy delta
#

4 hours sleep lmao

tender shard
#

If you need this, then sure, why not.

#

However in stuff like INventoryClickEvent etc, you can always get the player using getWhoClicked or getViewers

#

so I personally needed to store the player too. I simply store a Map like

Map<Inventory,InventoryInformation>
``` or similar. Where InventoryInformation is just an object that holds all the information I need
subtle folio
#

gaymers how do I like math yo

#

like say I had a number 3

#

how would I get 1, 2, 3

#

or like number 2

#

how would I get 1, 2

tender shard
subtle folio
#

yess

#

i love you

tender shard
#

for int i = 1; i <= target; i++

#

or an IntStream

subtle folio
#

nah int stream cringe

tender shard
#

you should simply store it somewhere in a field or so

pale egret
#

Where can I download bungeecord 1.8.8

subtle folio
#

forewhom loop >

tender shard
#

if you only need to loop, then just a for loop

subtle folio
#

yep 😄

ivory sleet
subtle folio
#

sounds like brawhala

#

can I wishlist on steam?

tender shard
#

it sounds like some medieval mmorpg

ivory sleet
#

It’s a java enhancement project lol

subtle folio
ivory sleet
#

Or well the name of one

subtle folio
#

im being silly

ivory sleet
#

Figures

tender shard
#

imajin is a java worsening project

#

that's why i stole his goat horn and his allay

subtle folio
#

Who even is Imajin

#

he just popped up one day

tender shard
#

he was previously called imaginedev

subtle folio
#

ohhh

#

ik him nvm

tender shard
#

yes lol

delicate lynx
#

the class doesn't exist then

tender shard
#

(or couldnt be loaded because of exceptions in <clinit>)

#

it's no problem, it just makes no sense

#

send the full stacktrace

#

90% the class doesn't exist, 10% couldnt be loaded because of errors in <clinit>

vocal tundra
#

anyone know a good gun cocking sound combination

tender shard
#

lol

#

it's when you "load" then gun

#

well not load

#

when you "make it ready to shoot"

quaint mantle
#

i love cocking

#

i love the sound of cocking

#

i love the feel of cocking

tender shard
#

❤️

quaint mantle
#

i love cock

#

oh sorry i forgot the ing

vocal tundra
#

lol

#

I mean I was thinking the clicking note blocks would work but they're kinda lackluster

surreal spoke
#

Hi, how can ı change my plugins version? I made a mistake and made it 1.19 but ı want it to be on 1.18.1

lethal roost
subtle folio
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>desired verison</version>
            <scope>provided</scope>
        </dependency>```
surreal spoke
#

just changing it to 1.18.1 would work?

#

thanks

subtle folio
surreal spoke
#

yeah the program just fixed it

tender shard
#

InventoryClickEvent is what you're looking for

lethal roost
#

well i want to have a message send in the console if the player "drops" the item down in a slot

#

it only fires when the player picks up the item in their inventory

tender shard
#

InventoryClickEvent, then check if the action == DROP_ALL_CURSOR or DROP_ONE_CURSOR I think

lethal roost
#

wait so how do i do that

winged anvil
#

you needa check if getCurrentItem() is Air and that the item on the cursor isnt* air

lethal roost
winged anvil
#

its kinda weird, if you click on a slot in your inventory, if theres nothing in the slot it will say its Material.AIR but if you have like a chest open or separate inventory, it will be null

lethal roost
#

lol

#

anyways thx guys

winged anvil
#

anyone have a non-tedious way to see if a block can be harvested and dropped by a tool

#

preferably without having to map the tool directly to a block

lethal roost
#

wait so if i drop a wooden axe in my offhand slot, why doesn't the console say anything? what did i do wrong in this code here

i want the console to send a message whenever i drop a wooden axe in the offhand slot

worldly ingot
#

Because it's not an InventoryClickEvent

drowsy helm
#

PlayerDropItemEvent

worldly ingot
#

You can't drop things from your off hand

tender shard
#

I think with "drop into" the offhand they mean equipping it?

lethal roost
#

yeah that's what i mean, sorry for the bad wording

worldly ingot
#

Gotcha. You want to check the cursor item, not the off hand item

#

(which can technically be null too, so yeah)

ItemStack item = event.getCursor();
if (item != null && item.getType() == Material.WOODEN_AXE) {
    // Do your thing here
}```
#

Note however that there's also a SWAP_WITH_CURSOR action you'll want to check for

tender shard
#

and number keys could work too I guess

worldly ingot
#

^

tender shard
#

there's so many ways to equip something

lethal roost
#

that makes sense, gotcha

#

ooh yeah that's another thing i gotta cover, thx for reminding me haha

#

ty for the help!

tender shard
#

also the INventoryDragEvent 😛

lethal roost
#

sheesh

tender shard
#

but I think that should be everything

lethal roost
#

hopefully lol

quaint mantle
#

Is spigot programming is hybrid of Java and C# or its Java and JavaScript?

eternal night
#

wat

#

it is purely java

#

or well, any language you can get into the JVM

#

if you wanna use kotlin, that is possible too

quaint mantle
#

oh bruh, i just know C# very good and i just see that java is almost the same lol.

eternal night
#

Well yea the syntax is somewhat close ? Tho that is the case with a lot of c style languages

drowsy helm
#

surface layer they are similar but otherwise completely different

subtle folio
#

this is disgusting

drowsy helm
#

split it up then

subtle folio
#

okay

drowsy helm
#

also why not use UUIDs in your guilds hashmap

#

would make life easier

subtle folio
#

I store them in yaml 😦

drowsy helm
#

ah

subtle folio
#

i do have a sorted hashmap for them

#

so I can rank them

#

but still painful

glossy wren
#

Hello, I am trying to create a custom item plugin and I am struggling with efficently registering the items.

I want each item class to have a registerItem method that creates a new CustomItem object with set properties. (this will be run when the server starts)

If CustomItem contains a constructor, it cannot be abstract therefore cannot have abstract methods. How can I force each item class to have the registerItem method?

If this is not the best way to go about this, what else should I try?

Each class should have this:

public static void registerItem() {
    CustomItem STARTER_SWORD = new CustomItem(Material.WOODEN_SWORD, "Starter Sword");
    CustomItem.saveItemToConfig(STARTER_SWORD.toItem());
}
drowsy helm
#

it can be abstract?

#

abstract classess can have constructors

glossy wren
#

abstract classes cannot be instantiated though, right?

drowsy helm
#

yeah but their children can

#

and will call the constructor

glossy wren
#

I am currently using a Builder to create the item (the code was just an example)

#

right now my code actually looks like

Item STARTER_SWORD = new Item.ItemBuilder(Material.WOODEN_SWORD, "Starter Sword");
drowsy helm
#

just have a public abstract ItemStack buildItem()

#

then call that on start

#

doesnt have to be static

#

or call in constructor

glossy wren
#

so ditch the builder?

#

rn it just creates a CustomItem object

drowsy helm
#

you can still use that builder in the implementation of the buildItem method

glossy wren
#

so in the child classes it would look like

public ItemStack buildItem() {
  Item STARTER_SWORD = new Item.ItemBuilder(Material.WOODEN_SWORD, "Starter Sword");
  return STARTER_SWORD;
}
#

right?