#help-development

1 messages · Page 1772 of 1

young knoll
#

You are storing values from the config into variables

#

Those variables won’t magically update when you reload the config

olive valve
#

this is probably a dumbo question but how could i reload the variables?

patent horizon
#

so im tryna make a cylindrical vector function but am having trouble with the rotation part. how can i rotate the vector so it spawns the armor stand in a circle rather than just spinning the armor stands around?

    public void sheepRod(Location loc) {

        Vector newlocation = new Vector(1.5, -0.75, 0);
        newlocation.rotateAroundX(loc.getPitch()+180);
        Location manipulatedLocation = loc.add(newlocation);
        manipulatedLocation.setPitch(loc.getYaw()+50);

        LivingEntity rodDummy = (LivingEntity) Bukkit.getWorld("ul_plex").spawnEntity(manipulatedLocation, EntityType.ARMOR_STAND);```
young knoll
#

Or just read from the config instance each time

livid tundra
#

how would I see if a block was placed by a player?

unkempt peak
#

And are you seeing if it's placed by a specific player or any player

livid tundra
#

It would be better if I could check what kind of block it is, and same for checking what player, but I'll take what I can get

wide coyote
#

i dont think that is possible without caching or smth

#

if your version is +1.14 you can set a special PDC value

livid tundra
#

how

#

also, what do you mean by caching

wide coyote
#

i mean when a player place or break a block, cache it

#

which is not a good idea

livid tundra
#

why

#

cache means save it to a list or something, right?

wide coyote
#

in that case if you want to know which player placed it map, so yes

livid tundra
#

what

wide coyote
#

just nevermind and use pdc

tranquil viper
#
public class Events implements Listener {
     private boolean doubleOres = false;
      
     public boolean getDoubleOres() {
        return doubleOres;
    }

    public void setDoubleOres(boolean doubleOres) {
        this.doubleOres = doubleOres;
    }
}

public class DoubleOreEvent implements Listener {

    Events events;

    public DoubleOreEvent(Events events) {
        this.events = events;
    }

    @EventHandler
    public void doubleOreEvent(BlockBreakEvent event) {
        if (!events.getDoubleOres()) return;
    }
}

Why does the doubleOreEvent always say that events.getDoubleOres() is false even if it's true?

livid tundra
#

what's pdc (I'm new)

wide coyote
#

persistentdatacontainer

livid tundra
#

how do I use that

young knoll
#

?pdc

young knoll
#

Also chunk pdc is newer than 1.14

livid tundra
#

oh, and thanks!

young knoll
#

I think it’s 1.16

livid tundra
#

I'm using 1.16.5

wide coyote
#

ah my bad, it is not going to work for normal blocks iirc

#

only for tiles i guess

young knoll
#

Correct

livid tundra
#

?

wide coyote
#

tile entities

#

like spawners

young knoll
#

But you can use the chunk pdc, although if you are doing it on any large scale you probably want a database

livid tundra
#

oh

#

how do I get a database

young knoll
#

Look into SQLite or MySQL

livid tundra
#

also, right now I'm just saving a list to a text file, but I feel like that's spageti code

livid tundra
wide coyote
#

you get a free mysql server but it will be slow

#

you can use sqlite

#

its free

wide coyote
#

thats better

livid tundra
#

is there a way to not use sql?

young knoll
#

Technically json is an option too, but a database is better for a large scale

livid tundra
#

how would I use json

young knoll
#

Save an array of data

#

Probably world,x,y,z and then whatever else you want

livid tundra
#

so I just save it normally? (it being in a jar doesn't affect anything?)

young knoll
#

Why would it be in a jar

livid tundra
#

when I compile my plugin it turns into a jar

young knoll
#

Right

#

But you save data to your plugins data folder

#

Not back into the jar

livid tundra
#

do I have to specifie it when I save the array?

young knoll
#

Specify what

livid tundra
#

where to save

#

to

young knoll
#

Yes

#

You have access to plugin.getDataFolder

wide coyote
#

he is just going to store the player's name i guess

livid tundra
#

what does plugin.getdatafolder do

#

return the path of the datafolder?

wide coyote
#

not path, the file

#

*folder

young knoll
#

Chunk pdc isn’t the best idea if you are going to be storing a lot of blocks

livid tundra
#

folder name?

wide coyote
#

no

livid tundra
#

I mean path by like /home/users/plugin/datafolder

young knoll
#

Starts to make the world data bulky, the nice thing about external storage is that you can easily remove it if you want to remove the plugin

#

It returns a file instance

livid tundra
#

which I can access the path from, right?

young knoll
#

Sure

#

If you for some reason want to

livid tundra
#

I need the path to write to the file

young knoll
#

No you don’t

livid tundra
#

?

young knoll
#

Look at the constructors for File

livid tundra
#

wait, so there's a method/class in the spigot api to write a json file?

young knoll
#

I never said that but yes, there is

#

Spigot includes gson

livid tundra
#

I can't find File in the documentation

#

assuming it's org.bukkit.File

young knoll
#

No

#

File is a java class

livid tundra
#

how do I write a json file using the spigot api

young knoll
livid tundra
#

I can't find gson in the documentation either

#

what do I import?

young knoll
#

I just sent you the documentation

livid tundra
#

I thought you said spigot includes gson

#

so what do I import?

young knoll
#

You still import the same thing

#

The spigot server shades gson

#

Actually I’m pretty sure the vanilla server also shades json

livid tundra
#

so I add

  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.8.9</version>
</dependency>```
and import com.google.gson.Gson, right?
young knoll
#

You don’t need to add the dependency

#

Spigot already shades it

livid tundra
#

I just import com.google.gson.Gson?

young knoll
#

Actually you might still need it if you are only depending on the spigot API and not the entire server

livid tundra
#

?

drowsy helm
#

dont think the spigot import has gson aswell

young knoll
#

It does

#

Because the minecraft server has it

livid tundra
#

?

young knoll
#

But the API is probably just the API

drowsy helm
#

yes but that doesn't mean the api will have gson

livid tundra
#

api means the spigot dependency I added, right?

young knoll
livid tundra
#

do I or do I not add the dependency

young knoll
#

Have you tried importing it without the dependency?

livid tundra
#

not yet

dry forum
#

SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); how can i get the current time using this format?

young knoll
#

Can’t you pass in System.currentTimeMills

dry forum
#

yeah i got it ty

stone light
#

JAR creation failed. See details for additional information.
io/github/NightTerror04 [in TerrorGames] is not on its project's build path
help

#

ok closing the files fixed it wtf

tranquil viper
#
  switch(effect.getType()) {
  }                        
}```
#

so this isn't possible?

young knoll
#

Isn’t it an enum

tranquil viper
#

that's what I thought xd

young knoll
#

Nope it’s a class

#

You can switch on getName though

tranquil viper
#

not very reliable though it would probably be safer to use else if statements to check the type

young knoll
#

I mean getName is consistent

sullen marlin
#

java should add custom switches

#

they kind of already did for strings

#

dunno why they couldnt just reuse that for all objects

young knoll
#

Why is it not an enum

#

From the looks of it it used to be

tranquil viper
#

https://hastebin.de/zupacaviwo.lua

Right now I am creating a new inventory every time someone opens the inv, is there a smarter & more optimized way of creating the same inventory for multiple different players?

young knoll
#

Does the stuff in it change per player

#

Also dear lord please use some loops

analog prairie
#

How to implement monsters not attacking players in java code

quaint mantle
#

welp

#

might be remove all of their ai?

analog prairie
#

I just want to temporarily close

young knoll
#

Cancel the target event

analog prairie
#

In Player or entity

young knoll
#

EntityTargetLivingEntityEvent iirc

analog prairie
young knoll
#

It will effect all living entities

tranquil viper
analog prairie
#

I just want to temporarily disable survival damage, because GeyserMC users are often killed by monsters during the loading phase

tranquil viper
#

thats so genius

analog prairie
young knoll
#

setNoDamageTicks on the player

#

Or give them temporary resistance 5

analog prairie
analog prairie
#

Is playerjoinevent equal to the completion of the player's terrain loaded?

sullen marlin
#

you cant tell when the player has loaded all their terrain, that depends on their system

vapid thorn
#

So I basically added it so shulkers spawn around in the end (replaced enderman at a very low/rare rate)

I did color them. However I did add the #setRemoveWhenFarAway(true) to them. yet they dont seem to despawn even with that on.

young knoll
#

Try setPersistent(false)

maiden mountain
#

public class CustomInventory implements InventoryHolder

#

And inside that use
Bukkit.createInventory(this, 9, "Epic Inventory") ;

tranquil viper
#

How can I send a player a title until they enter something in chat?

#

efficiently

tardy delta
#

Player. sendtitle does that takes a time?

tranquil viper
#

it takes the parameters: title, subtitle, fade in, stay, and fade out

tardy delta
#

Uhh tells me nothing

tranquil viper
#

yes it does lmao

tardy delta
#

Probably need a runnable or something to keep it on the screen

tranquil viper
#

stay is the duration it stays for in ticks

tardy delta
#

Ah

pine island
#

any help Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_16_R3.command.ColouredConsoleSender incompatible with org.bukkit.entity.Player?

tardy delta
#

Craftbukkit

pine island
#

oh god

lavish hemlock
#

well, are ya runnin' it on 1.16?

pine island
#

YES

#

woops caps

eternal oxide
#

you are performing a blind cast

pine island
#

shall i switch to Java 8?

tranquil viper
#

java 8 is better for plugin development imo

lavish hemlock
#

if you wanna support pre-1.16 (right?), Java 8

pine island
#

ok thansk!

tranquil viper
quaint mantle
#

I want. java 16.

eternal oxide
#

use java 16

tranquil viper
#

I was thinking a runnable but I'm not sure how efficient that would be on a server where 200+ people could be using it

lavish hemlock
#

why do people always ask me?

tranquil viper
#

You seem like a genius

lavish hemlock
#

owo thankies

tranquil viper
#

xd

lavish hemlock
#

anyway I prefer Java 8

#

if I wanted Java 16's features, I'd just use Kotlin :)

#

@tranquil viper couldn't you just use Bukkit's scheduler to keep a 0 fade-out title on screen every second?

#

tbh I've never experimented with permanent titles

#

ye it seems like people suggest using scheduler tasks

pine island
lavish hemlock
#

then y'know just listen to player chat and do shit when chat happens

pine island
#

hmm

tranquil viper
#

Yes but again I'm not sure how efficient that would be with 200+ using it at once

#

yk

hybrid spoke
#

would be the async player chat event

lavish hemlock
#

ye

tranquil viper
#

Would it be worth to use an async runnable?

lavish hemlock
#

well, if you can make it work properly, I don't see why you shouldn't

hybrid spoke
#

its already async

lavish hemlock
#

he means for the title setter

pine island
#

also i was wondering if getting player look position & summoning pigs in the look direction was possible i will retexture pigs to wb as a welcome back message

hybrid spoke
lavish hemlock
#

GodCipher read the chat :p

hybrid spoke
#

meh

tranquil viper
lavish hemlock
#

"how to do"
"do it"

pine island
#

yeah how do i get the look position?

hybrid spoke
#

not even a bit worth it and not sure if it would survive, probably not

tranquil viper
#

player.getEyeLocation()

#

I believe

pine island
#

well ty

tranquil viper
#

np

#

:)

pine island
#

on player join event in @event Listners right?

hybrid spoke
#

into any of your listener classes

quaint mantle
#

Listners.

#

Noce.

#

OH NO

#

...

pine island
#

whats the Player join event cant find it

#

also it dosnt auto import

chrome beacon
#

It's called PlayerJoinEvent

pine island
#

ik

chrome beacon
#

If you can't find it somethings wrong

pine island
#

oof

tranquil viper
#

how do I play a sound to just one player?

analog prairie
#

Is there any way to let me know that the player is ready

eternal night
#

The player has a playSound method

analog prairie
#

I try to use ping!=0

tranquil viper
eternal night
#

That is the world method

tranquil viper
#

Caused by: java.lang.IllegalStateException: InventoryOpenEvent cannot be triggered asynchronously from another thread.

#

anyone know how to get around this?

#

I'm opening an inv when a message is received

eternal night
#

Schedule it on the scheduler as a task

pine island
#

how do i know what location a player is looking at what i found was Get targetBlock = target block not N,E,S,W & geteyelocation = where player is standing

#

also how do i add player in event listner? bcs (Player)sender wont work

hybrid spoke
tardy delta
#

what do they mean result ignored?

#

the boolean value?

tawny horizon
tardy delta
#

pog

tawny horizon
#

The code executed inside of the function is executed either way

#

so in that instance just ignore it

tardy delta
#

for some reason my files also dont save

tawny horizon
#

Please post your saveConfig method

tardy delta
#

?paste

undone axleBOT
tardy delta
tawny horizon
#

Correct me if i am wring

#

wrong*

#

but would it not be easier to just have one class made for handling all configs?

tardy delta
#

that's one class no?

tawny horizon
#

aka, you type in the file name and all methods for loading it, saving it, and everything

tawny horizon
tardy delta
#

yea

tawny horizon
#

Ok, you said the file just doesnt save period or?

#

when you make changes it does not load changes

tardy delta
#

it doesnt save things

#

but it seems like it does because i'm reading directly from the file, which works and when i open it there's nothing inside

tawny horizon
#

When do you run the "saveConfig()" method?

tardy delta
#

like here

#
homes = plugin.getConfigManager().getHomes();
quaint mantle
#

hello, i found a multiversion actionbar method with reflections in spigot threads in linux, and now im on windows and i cant find it. if you have the link can you give please ?

misty current
#

Are completable futures safe to use with spigot? I'm unsure since spigoy has it's own multithreading stuff

drowsy helm
#

what does os have to do with actionbars?

quaint mantle
#

so i can find the link

mental bone
#

like

#

starting from version x there's a method without nms

quaint mantle
#

a thread was made for it

#

there was a method

#

i copied it and i used it

#

but now i cant find my code

mental bone
#

what browser do you primarily use

quaint mantle
#

i used chrome on linux

#

i dont have time to go back with just a restart 😂

mental bone
quaint mantle
#

hmm

#

wait

#

it was in another account

#

found it

#

ah yes

mental bone
#

noice

twilit vector
#

I am making a lifesteal plugin for 1.12.2. Which events and stuff should i use for this. I'm new to this

drowsy helm
#

EntityDamageByEntityEvent should be the only event you need really

twilit vector
#

okay!

#

thank you!

#

Also I want to make it such that if a new player(joined less than an hour ago) is killed, he will not loose hearts

drowsy helm
#

what do you mean not lose hearts?

twilit vector
#

Like other players cant steal the new player's hearts

drowsy helm
#

oh as in they can't lifesteal off of new players?

twilit vector
#

yeah

#

something like a grace period

drowsy helm
#

you'll have to keep a record of the new players who joined and have a timer, then in your EntityDamageByEntityEvent check if they are on that list

#

it's a bit more complex

twilit vector
#

ohk

#

is there anything else i can do to keep new players safe when they start?

#

other than timing

drowsy helm
#

not that i can think of tbh

twilit vector
#

can i use a timer plugin along side this plugin?

#

some timer plugin which is already made

#

is there somethinglike that?

drowsy helm
#

a timer for what?

twilit vector
#

1 hour timer which starts when the player joins

drowsy helm
#

oh spigot already has an inbuilt timer system with bukkit schedulers

#

no need to use another plugin

twilit vector
#

ohh

twilit vector
#

ohhhhh

#

i get it now

#

ohh

#

okay

drowsy helm
#

yeah

twilit vector
#

thank you!

drowsy helm
#

but you have to make the decision whether you want to make an individual timer per player

#

or have a larger timer that checks every 10 or so seconds to see whether their 1 hour timer is over

twilit vector
#

but everyone wont join at the same time so this wont work

#

its a public server

drowsy helm
#

yes it would work

#

what i mean is have a list of players

#

new players

#

and that timer that goes every 10 seconds would go through each player and see what time they joined, and if their time is over an hour, remove them from that list

twilit vector
#

ohhhhhh

#

great idea

#

Thank you sm!!

steady rapids
#

is it fine to use an array of ItemStack if I want to save a list of "special items" like weapons created by the crackshot plugin? or will the items lose their properties? like coloured names and the ability to shoot

drowsy helm
#

yes you could

#

just be sure to clone them when giving it to a player

#

the better alternative if you're using custom items is to have a handler class but that still works

steady rapids
#

hmmm thx

#

now I need to figure out how to save that array to a file xd and load it back

drowsy helm
#

itemstack already has a yml serializer if you're using that

#

if not binary blob or base64

tardy delta
#

cant save any data in my plugin

drowsy helm
tardy delta
#

i dunno nothing gets saved

drowsy helm
#

as in to a yml?

tardy delta
#

yes

tardy delta
drowsy helm
#

strange it looks fine to me

#

its creating the config correctly, right?

tardy delta
#

yes

#

and i'm getting values directly from config which works but the config is empty :/

drowsy helm
#

means your config isn't loading correctly then

quaint mantle
#

✨adventure✨

tardy delta
#

i dunno

quaint mantle
#

uhm the message was sent like 40 minutes after

hybrid spoke
#

never hasnt

quaint mantle
#

How do I stop a person from taking books from lectern? Let him read the book but not take it

#

Which event is responsible for this?

#

idr

quaint mantle
#

thanks

chrome beacon
#

Machine learning is possible

hybrid spoke
#

what does this matter?

#

machine learning has many "difficulties". you can set up a simple one or get very complex

quaint mantle
#

Yes, why not?

#

Thats not easy

covert shoal
#

So ik this isn't necessarily a Spigot question... But it has some relation as far as how plugins are loaded. Anyone able to help me with a bit of reflection?.. https://i.imgur.com/1g7qXsz.png

hushed garnet
#

Config question, how do I access the list of levels here? I am going nuts trying to access this! 🙃

enabled: true
levels:
- 1:
    xp: 64
    blocks:
    - stone
- 2:
    xp: 128
    blocks:
    - iron_ore
- 3:
    xp: 256
    blocks:
    - diamond_ore

Where am I going wrong here?

File configFile = new File(Main.plugin.getDataFolder(), "levels.yml");
config = YamlConfiguration.loadConfiguration(configFile);

Utils.debug("enabled? " + config.getBoolean("enabled") ); // works fine!

List<String> lvls = config.getStringList("levels"); // empty
for (String l : lvls) {
    Utils.debug("l? " + l);
}

List<String> lvlstring = config.getString("levels"); // contains data
Utils.debug("lvlstring len? " + lvlstring.length());
#

Can a config stringList not contain objects?

eternal oxide
#

levels is not a StringLIst

hushed garnet
#
levels:
- 0
- 1
- 2

works okay as a string list

eternal oxide
#

yes, that IS a StringList

hushed garnet
#
levels:
- 0:
... stuff
- 1:
... stuff
- 2:
... stuff

fails

eternal oxide
#

that is NOT a StringLIst

young knoll
#

Yes

#

Because a string list cannot be used as keys

eternal oxide
#

levels is a MemorySection

hushed garnet
#

ohhhh

#

Hmmm so what's a better way to tackle this?

#

I feel like I'm going about this the wrong way

eternal oxide
#

just load levels correctly as a MemorySection and loop its maps

eternal oxide
#

or you could just for (String key: section.getKeys(false)) {

covert shoal
eternal oxide
covert shoal
#

No, it's a jar I'm trying to load at runtime.

#

Just like a plugin.

eternal oxide
#

you can't use teh Exception of the jar you are about to load

covert shoal
#

Well I did. But my problem is for some reason it's not loading the class...

#

The important part in that code is the user agent.

eternal oxide
#

Your error is a NoClassDefFoundError

covert shoal
#

Yes.

eternal oxide
#

Not a ClassNotFound, so you are looking for a class thats nto there

covert shoal
#

But I load the class above?...

tardy delta
#

What's the difference?

covert shoal
#
                URLClassLoader cl = new URLClassLoader(new URL[]{jar.toURI().toURL()}, this.getClass().getClassLoader());
Class jauntException = cl.loadClass("com.jaunt.JauntException");```
eternal oxide
#

NoClassDefFoundError means he's tried to find/load a Class that doesn't exist for the provided parameters.
ClassNotFoundError means the whole class doesn;t exist.

covert shoal
#

So how would I resolve that?...

#

🤔

tardy delta
#

Oh

eternal oxide
covert shoal
#
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL("https://jaunt-api.com/download.htm").openStream(), "UTF-8"))){
            String loc;

            while ((loc = reader.readLine()) != null)
                if (loc.contains("location")) break;

            loc = loc.split("\"")[1];

            File appData = OS.getDataFolder();
            if (!appData.exists()) appData.mkdir();

            return new File(appData, loc.substring(0, loc.length()-4)+".jar");
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }```
hushed garnet
covert shoal
#

import java.io.File;

public enum OS{
    MAC(System.getProperty("user.home")+"/Library/Application Support"), LINUX(System.getenv("XDG_DATA_HOME")), WINDOWS(System.getenv("LOCALAPPDATA"));

    private static final String DATA_FOLDER = "WebScraper";

    private static OS os;

    private String appData;
    private Boolean isARM;
    private int arch;

    OS(String appData){
        this.appData = appData;
    }

    public boolean isARM(){
        return (isARM != null) ? isARM : (isARM = System.getProperty("os.arch").contains("aarch"));
    }

    public int getArch(){
        return (this.arch > 0) ? this.arch : (this.arch = (System.getProperty("os.arch").contains("64") ? 64 : 32));
    }

    public File getDataFolder(){
        return new File(appData+((this == WINDOWS) ? "\\" : "/")+DATA_FOLDER);
    }

    public static OS getOS(){
        if (os == null) {
            String OS = System.getProperty("os.name").toLowerCase();

            os = OS.contains("win") ? WINDOWS : (OS.contains("mac") ? MAC : LINUX);
            os.getArch();
        }
        return os;
    }


    @Override
    public String toString(){
        return name() + " (x" + arch + ((isARM) ? "-ARM)" : ") | AppData: " + appData);
    }
}
maiden mountain
#

What is the preffered Java SDK version for developing plugins?
I'm currently using version 16

young knoll
#

16 for 1.17

#

8 for earlier

eternal night
#

Java 17 tbf

#

If you run your own server

#

With your own plugins

young knoll
#

Unless it’s a private plugin in which case use whatever you want

maiden mountain
#

Its a public plugin

#

That i',m working on

eternal night
#

Then java 16 is the highest you can count on

eternal oxide
#

What is the lowest server version you want to run on/support?

maiden mountain
#

1.13

eternal night
#

Oh

maiden mountain
#

It doesnt depend on any minecraft server version

eternal night
#

Huh ?

#

Minecraft 1.16.5 still ran using java 8

#

If you are planning on releasing a plugin for 1.13 you can use java 16

#

Cant

eternal oxide
#

if you want it to run on MC 1.13 then build with java 16 and compile for java 8

maiden mountain
#

Alright, thanks guys

eternal oxide
#

set both target and source as java 8

maiden mountain
#

How can i do that?

eternal oxide
#

use maven

maiden mountain
eternal oxide
#

yes

eternal oxide
#

You don;t seem to understand what void means

#

what event?

#

ok, what are you currently doing and what do you want to do instead?

frosty tinsel
#

No it's not

#

If you mean the interactive messages in chat

#

Yep

#

You can't unfortunately

maiden mountain
#

I know what you mean tho

#

But you cannot

#

I was looking for the same thing yesterday

frosty tinsel
#

A workaround is to make a command, that will be run by that textconponent

maiden mountain
#

^

#

big brain @frosty tinsel

frosty tinsel
#

All the plugins do it like this

maiden mountain
#

If you need any more help. Feel free to ask

hybrid spoke
tranquil viper
hybrid spoke
tranquil viper
#

Ok

maiden mountain
hybrid spoke
glossy venture
#

make an internal command with arguments which will tell the server what to do

#

and then run it

#

ok

#

oh ye

#

jezus im late

maiden mountain
acoustic pendant
#

How can i separate this per player but without storing it?

opal juniper
#

this is an event right?

#

i think i am looking at an event

acoustic pendant
opal juniper
#

well just have a getPlayer or something

acoustic pendant
#

what

opal juniper
#

in teh event

acoustic pendant
#

hmm

opal juniper
#

idk really what you mean

maiden mountain
#

Could you be a little more obvious ?

foggy estuary
#

Does anyone know how to code it so if you fall in void and have a certian item on you, you dont die but teleport to spawn

#

certain

opal juniper
#

i mean you could probably use the player move event but that seems inefficient

#

maybe a runnable

#

check the y cord of the player

#

if < 0 then check inv

eternal night
#

Listening to the damage event and checking if it's void damage might be a lot cheaper

eternal oxide
#

/kill is also void damage I believe

maiden mountain
#

Yep, it is. Thats why you always get the "Fell out of the world" death message

vague oracle
#

Check how much damage you take

#

If it’s over 1000 then it’s /kill I think

spare prism
#

Hello! I'm trying to make a custom pathfindergoal using the nms (1.17.1) and it doesn't work (the zombie just stay and look at me). I want the zombie to follow and attack me when I sprint (<= 80 blocks of distance), when I walk (<= 40 blocks of distance) and when I sneak (>= 10 blocks of distance). My class: https://pastebin.com/D8bHnMq7

foggy estuary
#
                  Location blockloc = player.getLocation().add(0, 27, -176);
                  
                  if ( blockloc.getBlock().getType().equals(Material.RAW_GOLD_BLOCK)) {
                      blockloc.getBlock().setType(Material.AIR);
                  }
                  
                    return false;
                }
                 
                 }
                
                     }``` does anyone know why this isnt working?
eternal oxide
#

either the command isn't being run or the block at the location isn't a RAW_GOLD_BLOCK

mystic sky
#

Also he's IDE indexing it's epic seems md_5

foggy estuary
#

?paste

undone axleBOT
foggy estuary
eternal oxide
#

use == to compare a Material

#

not .equals

digital rain
#

getting cannot set to an empty path error? not sure what's the syntax

eternal oxide
#

other than that, I can;t tell if your code path is ok as your indents are all over teh place

eternal oxide
digital rain
#

oh so i use '.' only in conjunction?

#

i mean between the two things

#

i dont know terminology

foggy estuary
eternal oxide
#

add sysout to yoru code to see if its getting to that section of code

dreamy canopy
#

hello ! I begin in java and I created a maintenance plugin and it works but now I wanna save the list of player to the list to keep it when I reload the server I already do that but it's not working if you could help me it would be amazing I give you the code

vale ember
#

why are you using wrapper Boolean instead of primitive type? also please be specific what is not working exactly, do you get any errors? if yes, please show logs

#

also: in command class ur checking if argument count is more or equal to 1 and trying to access 2nd argument

torn shuttle
#

greetings, bretheren

#

I come to thee in mine time of need

#

aside from drowned and zombification does the entity transform event apply to anything else?

dreamy canopy
vale ember
vale ember
gentle laurel
#

how do i turn target into a public variable?

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
        if (sender instanceof Player) {
            Player p = (Player) sender;
            if (args.length == 1){
                for (Player target : Bukkit.getOnlinePlayers()){
                    if (args[0] == target.getName()) {
...
}```
torn shuttle
#

you don't

#

you're doing this backwards

vale ember
torn shuttle
#

pass the value to where it needs to go

gentle laurel
#

i just want this: if i use /report <player name> it opens a gui with the different reasons. if i for example click on the reason "hacking", it makes the player execute the command /report <player that i used before> <reason>

#

so i need to save for the player what name he wrote last time

vale ember
gentle laurel
#

can you give me an example/send me the whole code? im new to spigot coding 🙂

torn shuttle
#

that class will take the player in its constructor

gentle laurel
#

i think yes

digital rain
#

uhh, im in a whole phase where i have no idea, what to do, reload method is called in onenable, while save method is in ondisable method, you can ask me for other stuff if you want, thing is that it doesnt work

#

ping me if you dont like smth

dreamy canopy
#

there is an error

vale ember
#

@gentle laurel

public class ReportCommand implements CommandExecutor {
    public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
        if (sender instanceof Player) {
            Player player = (Player) sender;

            if (args.length == 1) {
                Player playerToReport = Bukkit.getPlayer(args[0]);

                // GUI code... from what we get reason

                String newArgs = Arrays.copyOf(args, 2);
                newArgs[1] = reason;

                onCommand(sender, command, alias, newArgs);
            } else if (args.length == 2) {
                // Do some stuff with reason recievd as args[1] and player nick recived as args[0]
            }
        }
    }
}

something like this

dreamy canopy
#

I can't upload so I screenshot

#

I can't too xD

vale ember
#

also cuz UUIDs are stored as strings use getStringList. AND you should check if it is null because it may be plugin's firs load and if yes then assign it to empty list

dreamy canopy
#

ohhhh right

#

so I did if(CommandMaintenance.maintenancelist == null){
if(CommandMaintenance.maintenancelist.isEmpty()){

#

is it good ?

#

oh yes I do

glossy venture
#

so instead of becoming

Players: # list
  - 321389172837182638
  - 123981293712983789
  - #etc..
``` (which i suppose you want) it will become
```yaml
Players: 23123123123123 # last UUID in the list, one value
#

i think you can actually just use ```java
Main.instance.config.set("Players", playerList);

digital rain
#

yeah well i havent tested that yet but you have a point

glossy venture
#

oh

digital rain
#

but when i convert uuid to string it always comes with !!java.util.UUID in front of it

glossy venture
#

is that a problem?

#

in your case

digital rain
#

yes bc i think that is not applicable for the uuid.fromstring method

glossy venture
#

yeah but then you can just use

playerList = (List<UUID>)Main.instance.config.get("Players");
#

i dont even know if the cast is necessary

digital rain
glossy venture
#

can you send your config.yml

#

or the Players part

vale ember
glossy venture
#

at least

glossy venture
dreamy canopy
digital rain
#

Players: !!java.util.UUID '9fef0449-7993-4a16-9875-4b095d67d65d'
thats all in config.yml

#

but it empties out during server on

glossy venture
#

because that doesnt look like a list to me

vale ember
digital rain
#

its a list with only single element

glossy venture
#

oh wait UUID doesnt have a constructor with a string

dreamy canopy
#

okay I try what you said

glossy venture
#

you have to use UUID.fromString() for some reason

#

ofc

digital rain
#

i can try to get two people on

glossy venture
#

nah wont work

digital rain
#

so like what to do?

glossy venture
#
/* Saving */
List<String> uuidStrings = playerList.stream().map(UUID::toString).collect(Collectors.toList());

/* Loading */
List<UUID> uuids = Main.instance.config.getStringList("Players").stream().map(UUID::fromString).collect(Collectors.toList());
#

basically an alternate way of doing something like

/* Saving */
List<String> strings = new ArrayList<>();
for (UUID u : playerList) {
  strings.add(u.toString());
}
Main.instance.config.set("Players", strings);
dreamy canopy
#

oh sorry I didn't know

dreamy canopy
#

ah xD

vale ember
#

I'll send right code in few minutes

dreamy canopy
dreamy canopy
#

thx I replaced it

steady rapids
#

how do you setup build.gradle to build the plaugin? with its dependencies and files like the config?

vestal moat
#

Is it possible to compile a project that depend on discordsrv with jda relocated and another module for bungee that shades jda (discordsrv doesn't support bungee) and it compiled as new package

#

(With gradle)

glossy venture
#

ah yes

gray comet
#

🔨

glossy venture
#

thank you intellij

crimson terrace
#

damn you really used the wrong capture of ?

glossy venture
#

damn it

crimson terrace
#

lmao

glossy venture
#

hate when that happens

crimson terrace
#

intelliJ never forgiving you for that one

glossy venture
#

sadge

foggy estuary
#

How do i fit another class into Main in plugin.yml

quaint mantle
#

You dont

foggy estuary
#

Then how do i make it work

glossy venture
foggy estuary
#

ok ty

glossy venture
#

for different classes

glossy venture
quaint mantle
#

Get an understanding of what class is

glossy venture
#

theres so many people in here with zero understanding of java

quaint mantle
#

well, thats unavoidable

glossy venture
#

well yes

#

of course

#

but many people refuse to learn it

#

i think

chrome beacon
#

^^

#

Too many refuse to learn it

glossy venture
#

yeah

quaint mantle
#

they don't see a point of doing this i think

crimson terrace
#

I believe its just so many people who want to make their own plugins with no prior experience in coding... the thing is when you have the very basics down you can learn java using plugins. thats what I did and its going good

glossy venture
#

i cant blame them from wanting to have fun

#

with coding

#

but youre going to lose interest very quickly if you dont know the basics

#

and you dont get spoon fed code

vale ember
# dreamy canopy oh thx so much

First of all: if you don't want to lose all players in 'Liste' each time server is reloading, you should load it's previous value to maintance list. To do so:

public static List<UUID> maintancelist;

static {
if (Main.getConfig().getStringList("Liste") == null) {
maintancelist = new ArrayList<>();
} else {
maintancelist = Main.getConfig().getStringList("Liste").stream().map(UUID::fromString).collect(Collectors.toList());
}

Then just use set method like you used in your original code. @dreamy canopy

dreamy canopy
#

Thx so much I'll try

digital rain
#

well actually it worked

#

so sorry for ping

#

😄

#

Also what methods can i use to not keep reloading the whole server, but only the plugin

#

or anything that would speed up the start up

visual tide
wide creek
#

im trying save all the chunk that are in a forest, im using ChunkSnapshot#getBiome. The problem is that some chunk aren't in a forest.
Code:

for (int count = 0; count < 1000 && loading; count++) {
                    x = x + 16;
                    if (z > 5000) {
                        return;
                    }
                    if (x >= 5000) {
                        x = 0;
                        z = z + 16;
                        continue;
                    }
                    ChunkSnapshot chunkSnapshot = world.getEmptyChunkSnapshot(x,z, true, false);
                    if (chunkSnapshot.getBiome(7, 40, 7) == Biome.FOREST) { //coordinates where there is 100% a block
                        int xCoord = chunkSnapshot.getX();
                        int zCoord = chunkSnapshot.getZ();
                        String coords = xCoord + "/" + zCoord;
                        PerPlayerBorder.plugin.setChunk(coords);
                    }
                }
              
quaint mantle
#

hello, how to check if server is running 1.13 higher or lower

#

is there any simple method or i should check for all versions

#

ok nvm i will check

stone sinew
#

Bukkit.getVersion()

quaint mantle
#

i found it

tardy delta
#

what is it?

#

i found some way but i forgot the site name

quaint mantle
#

I just wanted a skull string

#

To use the right material

quaint mantle
#

For multiversion support

#

e.g
boolean supportsPdc = false
try {
Class.forName("PersistentDataHolder")
supportsPdc = true
catch(ClassNotFoundException ex)

quaint mantle
#

And btw in 1.13 and higher

#

Is it named player head

#

Player_head

#

But caps

#

And lower

#

SKULL_ITEM

#

Right ?

#

yeah, and you create itemstacks differently

#

On old versions you also have to specificy data

#

Ik

#

And what happens to the data

#

In 1.13

#

Will it be ignored ?

#

i guess so

#

Thanks for your help

arctic moth
#

is there an event for when the time changes

#

or do i just have to have a runnable check the time

#

btw i mean like day, night, etc.

tardy delta
#

there s no event

stone sinew
#

WorldTimeChangeEvent I think

tardy delta
#

heh

#

thats new

stone sinew
#

I think lol. Could be wrong

sleek pond
#

What's the difference between Material.matchMaterial(String) and Material.getMaterial(String)

stone sinew
sleek pond
#

e.g.?

#

like DIAMON_HELM

#

would that return DIAMOND_HELMET?

stone sinew
#

Maybe. I'm just reading the java doc

sleek pond
#

yea i've already done that

#

but it's not really specific

eternal night
#

pretty certain that it is simply a better alternative to valueOf. It allows namespaces, spaces are replaced with _ and it allows for legacy name checking

torn oyster
#

does bukkit.getworld(string)

eternal night
#

additionally, you won't get an exception if the material isn't found but rather just null

torn oyster
#

load a world if it isnt loaded

eternal night
#

no

#

it does not

torn oyster
#

does that mean ill have to do some worldcreator stuff then

eternal night
#

yea

torn oyster
#

sigh

#

is respawneevent called before or after a player respawns

ivory sleet
#

Think it calls getMaterial at some point

torn oyster
# stone sinew During

so if i got the player's location in the event, it would return the place they died at?

stone sinew
#

Oh looks like the players location would return their death location during the event.

#

cause there is only getRespawnLocation/setRespawnLocation

mellow edge
#

I need java version 16 to run 1.17 and then I will need java 17 to run 1.18, why in the past few updates java version was always the same?

ivory sleet
#

Honestly it’s quite a mystery

#

But the plan was to migrate from java 8 to Java 11 since 11 is also long term support

#

But then mojang decided to go all the way up to 16

#

Idk if mojang is considering java 17, but probably since it’s also long term support

quaint mantle
#

Didnt java 11 was in paper plans only

ivory sleet
#

Initially I believe

#

I don’t know the exact details, it was something along that

visual tide
ivory sleet
#

Ah good

mellow edge
#

ok, thanks! Then when I'll switch from 1.17 to 1.18 I will switch my java version to 17 ig

#

(my server), clients have build-in java runtime I think

ivory sleet
#

Yuh

#

The launcher downloads the needed jdk if absent

quaint mantle
#

how would i set permissions so the /plugin command can not be accessed by everyone

twilit wharf
#

use a permissions API like luckperms or use built in bukkit permissions, there are tutorials everywhere

quaint mantle
#

yep i have luckperms

torn shuttle
#

is this linter warning solvable while still using Bukkit.getLogger()?

quaint mantle
twilit wharf
#

say on command, if user doesnt have this group or role, return false, else, continue logic

quaint mantle
#

yea but im confused how to set it to server commands and not plugin commands

#

do i just create a command with the same name and set permissions to that or?

tranquil viper
#

luckperms uses / in console right

#

so typing luckperms in console wouldn’t work

quaint mantle
#

i find luckperms only works in the console

#

now i gtg

young knoll
#

I mean, someone did already tell him that :p

glossy venture
#

my dc glitches sometimes i cant see long message history for a few tens of seconds

gray crypt
#

This is moreso a java related question, but if I was to create a child of another plugin's class, and override one of the methods therein, would the original plugin use my method, or it's original method wherever it is called?

ivory sleet
#

Depends

#

With the assumption that you passed an instance of your subclass, then your overridden method would be used, else not

sleek pond
#

anyone know if it's possible to summon a beacon beam without the base resource blocks?

#

I want to use it to highlight the location of any item

left swift
#

How can I block a name change for a specific entity?

sleek pond
#

just not possible?

chrome beacon
#

Yeah it's handled by the client

#

(Iirc)

sleek pond
#

rippp

ivory sleet
#

Yuh there’s an argument for that

olive valve
#

hello i need help with reloading values in my config.yml reloadConfig(); does not work

#

My Command Class:


    String noPerms = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("NoPermissionsMessage"));
    String reloadMessage = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("ReloadMessage"));
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        Player p = (Player) sender;
        if(p.hasPermission("combatloggz.reload")){
            p.sendMessage(reloadMessage);
            plugin.reloadConfig();
        }else {
            p.sendMessage(noPerms);
        }

        return true;
    }```
ivory sleet
#

Well

#

You are caching the values from the config before reloading

#

(caching -> storing them)

olive valve
#

so do i reload before i store my values?

young knoll
#

I already told you why it wasn’t working, and how you could get around it

olive valve
#

i could not figure out what to do

ivory sleet
#

when you reload, you’ll have to use smtng like

this.plugin.reloadConfig();
this.noPerm = this.plugin.getConfig().getString("path");

olive valve
#

ok

ivory sleet
#

To store the newly obtained value from the configuration reload

olive valve
#

alright

ivory sleet
#

You see, values of variables aren’t updated by themselves. Someone has to set a new value to a variable manually.

olive valve
#

ok i completely missed that.

ivory sleet
#

No worries

#

Now you know 🍉

olive valve
ivory sleet
#

Yes

olive valve
#

ok thanks!

ivory sleet
#

A variable of any primitive data type can be manipulated the same way all other variables can.

stone light
#

symbol: variable Material
location: class Counters
Counters.java:204: error: cannot find symbol
mat == Material.Fire)) {
^
symbol: variable Material
location: class Counters
Getting this error when compiling

#

Anyone know why?

ivory sleet
#

Send the class

#

?paste

undone axleBOT
stone light
#

the whole thing?

ivory sleet
#

Yuh

#

Also

#

I’d appreciate if you got it formatted, just in case you don’t, as it would be significantly easier to find the syntax error here

stone light
#

ok

young knoll
#

Material is an enum

#

The values are all UPPER_CASE

young knoll
#

Yeah none of those lower case enum constants are valid

#

Your IDE should be yelling at you

stone light
#

even as uppercase it still has the same error

#

wow I am an idiot

#

I think I firgured it out now

#

and nevermind

errant snow
#

Hey so im making a custom world generator, however only 1 chunk actually used it and all other chunks are just air, any idea why?

public GridWorld(String worldName) {
    this.worldName = worldName;
        this.worldCreator = new WorldCreator(worldName);
    this.worldCreator.generator(new ShipWorldGenerator());
}

as you can see I set the generator to my custom generator but it doesn't actually use it past the first chunk

#

here's the chunk generator

@Override
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome) {
    ChunkData chunkData = createChunkData(world);
    // fill bottom layer with barrier
    chunkData.setRegion(
            chunkX * 16,
            0,
            chunkZ * 16,
            (chunkX * 16) + 15,
            0,
            (chunkZ * 16) + 15,
            Material.BARRIER);
    // fill up to y60 with water
    chunkData.setRegion(
            chunkX * 16,
            1,
            chunkZ * 16,
            (chunkX * 16) + 15,
            60,
            (chunkZ * 16) + 15,
            Material.WATER);
    return chunkData;
}
olive valve
quaint mantle
#

hey, someone I know is using an invsee plugin (I assume since it has this problem it's not the essentials invsee command, I'll ask which he's using.) and it's eating items sometimes when you view modify someone's inventory, like completely deleting them. I don't know if this is specific to this plugin, or if it's due to confliction with something else, and was wondering if I make a invsee plugin for them (should they not want to use the essentials one for whatever reason), what's likely to be the cause of something like this, and what would be the best way to implement such a feature safely?

eternal oxide
#

Losing items would most likely be down to incorrectly opening the players inventory for both the player and the viewer. It (kinda) works but the inventory is not designed to do that. Both can modify it and items will be lost

#

A good invsee should clone the inventory and replace it when finished

quaint mantle
#

apparently they're using essentials one, but I don't think this issue is likely down to essentials? they have lots of smaller custom plugins, could they conflict and cause such a thing? e.g if they had a plugin to save a players inventory every x seconds via a runnable, and someone was invseeing and had an item in their hand and not in the inventory?

subtle kite
#

I would suggest telling the plugin maker about it.

quaint mantle
#

going to have to try diagnose whether it's essentials itself or something custom they have being the reason

eternal oxide
#

yes, anything that messes with the inventory will potentially break invsee.

quaint mantle
#

gotcha, thank you -- I'll have a read over their plugins and see if I can pick anything out

true perch
#
[01:18:22] [Server thread/WARN]: [Yu-Craft] Loaded class net.milkbowl.vault.economy.Economy from Vault v1.7.3-b131 which is not a depend, softdepend or loadbefore of this plugin.
[01:18:22] [Server thread/ERROR]: [Yu-Craft] - Disabled due to no Vault dependency found!```
how can I fix this error?
#

I have vault installed on the server

eternal oxide
#

do you have an eco plugin?

subtle kite
#

you need Vault

true perch
#

My custom Yu-Craft plugin is the only economy plugin I intend to use

subtle kite
#

most plugins use Vault for eco

#

Disabled due to no Vault dependency found!

eternal oxide
#

is your plugin registering with vault as an eco provider?

true perch
#

Yeah that's why I'm trying to change my custom currency system to vault

subtle kite
#

Elgarl , he needs vault

eternal oxide
#

he has vault

subtle kite
#

Disabled due to no Vault dependency found!

true perch
subtle kite
#

What vault version do you have?

true perch
eternal oxide
#

he doesn;t have an eco registered with vault is his issue

subtle kite
#

it wants Vault v1.7.3-b131

#

wait wrong chat also

true perch
#

I have Vault v1.7.3-b131 according to /vault-info

subtle kite
#

sorry , I thought this is help-server

#

;0

eternal oxide
#

right chat, its his plugin he's tryign to register

true perch
#

I have Vault v1.7.3-b131 according to /vault-info

eternal oxide
#

show code where you are registering yrou eco with vault?

subtle kite
#

register command

#

so what is your main page

eternal oxide
#

?paste

undone axleBOT
subtle kite
#

also you need to do your ... hold on I'm waiting for intellij

true perch
#
        if (!setupEconomy() ) {
            Bukkit.getLogger().severe(("[Yu-Craft] - Disabled due to no Vault dependency found!"));
            getServer().getPluginManager().disablePlugin(this);
            return;
        }```
#
    private boolean setupEconomy() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) {
            return false;
        }
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) {
            return false;
        }
        this.economy = rsp.getProvider();
        return true;
    }```
#

I already have a static instance of the main class, so I decided not to make this.economy static as the api says

eternal oxide
#

No, that is getting a provider. Where do you regsiter yoru economy?

subtle kite
#

Bukkit.getLogger().severe(("[Yu-Craft] - Disabled due to no Vault dependency found!"));

why is it servere ? just wondering

true perch
#

It's pretty severe to be fair

eternal oxide
#

Your plugin has to regsiter an RSP with bukkit

eternal oxide
#

eg, this is how iConomy registers java final ServicesManager sm = Server.getServicesManager(); sm.register(Economy.class, new VaultConnector(this), this, ServicePriority.Highest); log.info("[iConomy] Registered Vault interface.");

true perch
#

I can implement that into my plugin, now I'm wondering how it will fix my issue, how it will impact the plugin, and what I could use those instances for?

eternal oxide
#

you create a vault connector (google), register it with Bukkkit and vault will see it when you ask for an eco

true perch
#

Okay I see, so it's just something to help Vault understand that "Yu-Craft" is using it

#

right?

eternal oxide
#

its telling Bukkit that your plugins is an Economy provider

#

Vault simply looks for any providers and gives access to plugins

#

?paste

undone axleBOT
true perch
#

Okay cool! I'll do that.

#

Okay cool! I'll do that.

eternal oxide
true perch
#

Decided to get rid of my custom economy system because there's way too much support with public plugins via vault

#

thank you very much

#

I think there's something severely with how I've attempted adding Vault to my plugin.
When doing so, I downloaded the latest version of Vault, went to Project Structure, Modules, Dependencies, then added the latest Vault.jar there, and changed scope to "provided". Not sure how to properly do it :/

eternal oxide
#

do you not use maven or any build tool?

true perch
#

I use Maven but I barely know what that is.

#

Every time I attempt to add a dependency there, it appears red

eternal oxide
#

if you use maven you should not be manually adding dependencies

true perch
#

How could I automate it?

eternal oxide
#

all dependencies should be listed in your pom

#
        <dependency>
            <groupId>com.github.MilkBowl</groupId>
            <artifactId>VaultAPI</artifactId>
            <version>1.7</version>
            <scope>provided</scope>
        </dependency>```
true perch
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.17.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>```
eternal oxide
#

and add a repository xml <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository>

true perch
#

when I add ```

<dependency>
    <groupId>com.github.MilkBowl</groupId>
    <artifactId>VaultAPI</artifactId>
    <version>1.7</version>
    <scope>provided</scope>
</dependency>```to my dependencies, it appears red
eternal oxide
#

add the repository

true perch
#

repository gives no errors. I don't need the dependency?

eternal oxide
#

you need both

#

teh repository tells it where to look, the dependency tells it what to look for

#

?paste

undone axleBOT
true perch
#

it always appears as red

eternal oxide
#

what IDE?

true perch
#

intellij

eternal oxide
#

there shoudl be a button to refresh or something

#

top left or bottom right

#

I don;t use intelij

true perch
#

I'm looking around for it, what is it called in your IDE?

eternal oxide
#

Eclipse doesn;t have one, it auto does it

true perch
#

Every time I've ever attempted to add a dependency in Maven, it always appears as red

#

ah

eternal oxide
#

I know others who use intelij say there is an update/refresh button when you have the pom open

true perch
#

Error is "Dependency in com.github.MilkBowl:VaultAPI:1.17 not found"

#

in the pom.xml

eternal oxide
#

1.17?

#

vault is 1.7

true perch
#

my bad, yeah it says 1.7

true perch
#

I right-clicked my pom.xml and clicked "reload from disk" nothing is red now!

#

I'll give it a try

#

same as before

eternal oxide
#

you have to create that class

#

I think it extends Economy else it implements

#

that class will contain the access methods Vault needs to use your eco

true perch
eternal oxide
#

none of that is to register a new economy, only USE an existing one

true perch
#

Ah I see, what methods should I incorperate in the VaultConnector class

eternal oxide
#

have it implement Economy

#

its an interface so it will tell you what to add

true perch
#

okay cool thanks! I'll give it a shot

eternal oxide
#

public class VaultConnector implements Economy {

true perch
#

Mhm that's all good and working. Do I need to do anything further after implementing the methods?

eternal oxide
#

hook them to your eco to get and set data

true perch
eternal oxide
#

yep

true perch
#

My goal is to transfer my custom currency system into a more a universal currency system so I don't need to re-invent the wheel so-to-speak. There are dozens of auction, marketplace, player shop plugins already out there so I thought: Why code them myself when people have already done them so many times?
Should I be actually doing all of this to achieve this goal? Is there a simplier solution? I just feel a bit confused by this right now.

eternal oxide
#

if you want others to use your plugin you best support vault

true perch
#

Oh, this project is completely for personal use.

eternal oxide
#

then why bother with vault at all?

true perch
#

I thought it may make it easier to have a universal currency to hook into all of these plugins

young knoll
#

Don’t you need to use vault to interface with said existing plugins

eternal oxide
#

its his plugin

#

If this is just for yoru use then you don;t need to hook anything

true perch
#

What would you recommend instead? When I add some public plugin, how can I allow that plugin to use the same currency as my plugin?

eternal oxide
#

as I said, if you want plugins written by OTHER people to use your eco you need to implement vault

#

you can;t force other plugins to use your plugin

#

not unless you implement a vault connector so they can see it

true perch
#

Alright so I should just continue with the implemented methods from public class VaultConnector implements Economy {

#

I really appreciate the help, I'm just a bit slow with it because it's all new to me

oblique wigeon
#

Would anyone have an idea as to how I should detect players placing items in inventories? InventoryClickEvent doesn't get called, so I'm not sure what to use instead.

eternal oxide
#

click or drag events will fire

oblique wigeon
eternal oxide
#

it will fire when you let go

oblique wigeon
#

shoot sorry lmao i had borken if statement

#

must be something else

oblique wigeon
# eternal oxide it will fire when you let go

Ok, update , I've refined the problem to checking if the grindstone slots are full. Since the only way to differentiate them is by checking the slot type (differentiate the quickbar/grindstone inventories) how would I check whether specifically the grindstone inventory is full, as i can't specify a slot type? Perhaps inventoryholders?

sleek pond
#

is there a better way for making restart persistent timers than just saving the time remaining onDisable?

#

because in a crash, if the plugins are foreced to close, it might not call, right?

young knoll
#

I mean you can save regularly

tranquil viper
#

https://gyazo.com/a83752ea6b157d1247a7b3a8064b7dc4 anyone know why this is happening when I try and making a rolling animation?

public void rollMachine(UUID uuid) {

        if(rollingMachine.contains(uuid)) return;

        Player player = Bukkit.getPlayer(uuid);

        Inventory inv = getInvOfPlayer(uuid);

        int fiftyFifty = new Random().nextInt(50) + 1;
        int bet = getBetAmountOfPlayer(uuid);

        boolean win;

        if(isEven(fiftyFifty)) {
           plugin.econ.depositPlayer(Bukkit.getOfflinePlayer(uuid), bet);
           win = true;
        } else {
            Roulette.econ.withdrawPlayer(Bukkit.getOfflinePlayer(uuid), bet);
            win = false;
        }


        int rolling = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
            @Override
            public void run() {
               for(int i = 36; i < 45; i++) {
                   flip(inv, player, i);
               }
            }
        }, 0L, 5L);

        Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
            @Override
            public void run() {
                Bukkit.getScheduler().cancelTask(rolling);
                if(win) {
                    player.sendMessage(format("&aYou won."));
                } else {
                    player.sendMessage(format("&cYou lost."));
                }
            }
        }, 400L);

    }


private void flip(Inventory inv, Player player, int slot) {
        ItemStack lostMoney = newItem(Material.BLACK_CONCRETE, "&cLost your money", null);
        ItemStack doubleMoney = newItem(Material.RED_CONCRETE, "&aDouble your money", null);

        if(isEven(slot)) {
            for (int i = 36; i < 45; i++) {
                if (isEven(i)) {
                    inv.setItem(i, lostMoney);
                } else {
                    inv.setItem(i, doubleMoney);
                }
            }
        } else {
            for (int i = 36; i < 45; i++) {
                if (isEven(i)) {
                    inv.setItem(i, doubleMoney);
                } else {
                    inv.setItem(i, lostMoney);
                }
            }
        }

        player.updateInventory();
    }
#

If it's hard to see, it flickers a change in the inventory but doesn't actually change

young knoll
#

Why do you generate an int for 50/50

tranquil viper
#

50/50 chance of winning or losing

#

in roulette

#

I could probably just do 1 and 2

young knoll
#

random.nextBoolean

tranquil viper
#

oh

#

I forgot that was a thing xd

#

Any idea why it flickers and doesn't animate

young knoll
#

Why do you call flip in a loop

#

If it already loops over each item

tranquil viper
#

because I only want it to flip specific items

#

oh

#

wait

#

i see that

#

its cause I copied code from earlier whoops

young knoll
#

Don’t believe you need to call updateInventory either

tranquil viper
#

ok

hollow spindle
#

Heyoo, I'm having issues with comparing 2 Inventories. Trying to get the InventoryClickEvent to cancel to stop the GUI from being modified but during the comparison check, it fails to check if they (the GUI and the event inventory) are the same.

[ScreenManager.java]

 public void display(Player player) {
        // Displays the current stack GUI to the player.
        player.openInventory(gui);

    }

    @EventHandler
    public void onInventoryDrag(InventoryDragEvent e) {
        if (e.getInventory().equals(this.gui)) {
            Bukkit.getLogger().warning("Blocked");
            e.setCancelled(true);
        }
    }

    @EventHandler
    public void onInventoryClick(InventoryClickEvent e) {
        Bukkit.getLogger().severe("--- Event Inventory");
        Bukkit.getLogger().warning(e.getInventory().toString());
        Bukkit.getLogger().severe("--- Class Inventory");
        Bukkit.getLogger().warning(gui.toString());

        if (e.getInventory().equals(gui)) {
            Bukkit.getLogger().warning("Blocked");
            e.setCancelled(true);
        }
    }
#

It's like both inventories are somehow different, even though im using the same local variable gui as the way to open and manipulate.

#

Please ping me when you have the chance to help with me because I'm most likely trying to play around with it or digging up some open sourced GUI plugins

tranquil viper
#

If that makes sense xd

young knoll
#

Store the view returned by openInventory

hollow spindle
hollow spindle
tranquil viper
#

I just worded it weirdly

hollow spindle
tranquil viper
#

oke :)

if you're interested, what I do is:

private final HashMap<UUID, Inventory> bettingInventories = new HashMap<>();

//on command do this
Inventory rouletteInv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Roulette");

bettingInventories.put(player.getUniqueId(), rouletteInv);
//on click do this
if(event.getClickedInventory() != getInvOfPlayer(uuid)) return;

then I can just use the uuid to get the desired inventory and check if its the

young knoll
#

Yeah you can just store the view in a set and use contains

tranquil viper
#

anyone know how to achieve the drum roll sound effect?

tardy wing
sullen marlin
#

Not really what are you trying to do?

#

I mean git is an index?

tardy wing
sullen marlin
#

a git repo is a database

#

convert the file history to whatever format you need

tardy wing
#

is that doable with client-sided only js.
the site uses bitbucket right? where's the api endpoint I can't find the root for where I'm supposed to put
/repositories/{workspace}/{repo_slug}/commits/

#

o that's only bitbucket cloud with an api, not self-hosted as far as I can see

#

but this is so much more jank than every other mapping provider. at least they give me maven pom's (or a json in yarn's case)

tardy wing
grave hound
#

Math.random() < 0.0001 is 1 in 1000 percent chance right ?

tacit drift
#

should i use a scheduler or a thread when sending packets to all players constantly?

glossy venture
sullen marlin
#

always use the scheduler

tacit drift
#

ok

glossy venture
#

or well actually Math.random() <= 0.0001

hollow spindle
#

Heyo again haha, I'm wondering why does <ItemEnchantEvent>.getOffers() return 3 things instead of an array of things?
Had a for loop constructed like

for (EnchantmentOffer eo : e.getOffers() ) {
  eo.getEnchantment().getKey(); // Somewhere had String.valueOf()
}

This even applies to iterated loops like:

for (int i = 0; i < eo.getOffers().length; i++) {
  eo.getOffers[i].getEnchantment().getKey(); // Somewhere had String.valueOf()
}

And for some reason it spat out 9 entries, repeating the 3 offers 3 times. Am I interpreting this wrong?

#

Ohhhh, i was able to trim it down to the cause.

#

Seems the event was booted 3 times, I'm kinda unsure how to proceed after this (As in make it run once)?

maiden mountain
#

So the event get executed 3 times?

hollow spindle
#

yeah

hybrid spoke
#

return 3 things instead of an array of things?
as you can see it returns an array of 3 things.

maiden mountain
#

Which event? The world save?

hollow spindle
#

Added a top level logger and it got booted 3 times

#

Uhhh

hybrid spoke
#

can you send us more code?

hollow spindle
#

yeah sure

hybrid spoke
steady rapids
#

how do you guys build your plugins? I've just switched to gradle but when I build it, it gives me a jar without the dependencies and without the config file in it

maiden mountain
#

So i assume you only want it to be executed once right?

crimson terrace
hollow spindle
#
package xyz.nekonii.hexcraft.VanillaEnchantOverride.listeners;

import org.bukkit.enchantments.EnchantmentOffer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
import org.bukkit.plugin.Plugin;

import java.util.Arrays;

public class EnchantingTable implements Listener {
    Plugin plugin;
    public EnchantingTable(Plugin plugin) {
        this.plugin = plugin;
    }

    @EventHandler
    public void PrepareItemEnchant(PrepareItemEnchantEvent e) {
        this.plugin.getLogger().info("Launched test");

        for (EnchantmentOffer eo : e.getOffers()) {
            this.plugin.getLogger().info(String.valueOf(eo.getEnchantment().getKey()));
        }
    }
}
hybrid spoke
#

so at least if smth changes

maiden mountain
#

@steady rapids When creating a new artifact. Choose jar > From modules with dependencies

hollow spindle
#

And it wouldn't make sense because it doesn't return each individual offer

maiden mountain
#

Go to File > Project structure > Artifacts > Jar > + > From modules with dependencies