#help-development

1 messages · Page 545 of 1

quaint mantle
#

i wanna prevent to tripwire state change
how can i do this i mean which event ?

#

if tripwire states is this
no obstacle will change that

fierce salmon
#

I setup a clicking event to detect when a player clicks on certain items in a specific inventory, but whenver the player clicks on an inventory slot that has nothing in it, it sends the console an error. What can I add to remove this issue?

hybrid spoke
#

check if current item is not null

fierce salmon
#

Like this?

if (event.getCurrentItem().getType() != null){
robust pebble
#

private static Main plugin; This is how I create my plugin
public static Main getPlugin() { // getter for the static plugin instance
return plugin;
}

#

why is this null

#

or how is it null

#

public static NamespacedKey key = new NamespacedKey(getPlugin(), "death_clock");

tardy delta
#

type will always be not null

#

item might be null if thats the question

chrome beacon
tardy delta
#

damn i thought they were one and the same person

robust pebble
#

but what do I set it to, is my question

chrome beacon
#

Set it to your plugin instance

robust pebble
#

ill just do this or somethign

tardy delta
#

?di use this instead of the crappy approach

undone axleBOT
chrome beacon
#

^^

fierce salmon
tardy delta
#

read

serene sigil
#

hi i started a new project; whenever i build it with mvn package it gives me 3 files and each of them are >5kb

#

what should i do?

tardy delta
#

jar files?

serene sigil
#

ye

#

and folders

tardy delta
#

iirc one contains your jar with the shaded stuff, one without and one with only the shaded stuff

#

i only see two tho

serene sigil
#

i did

#

it wont work

tardy delta
#

that you compile stuff into your jar rather than providing it at runtime e.g. through a plugin

serene sigil
#

it says it has a wrong plugin.xml

tardy delta
#

show error

serene sigil
#

sry i meant plugin.yml

tardy delta
#

?paste it

undone axleBOT
serene sigil
#

it looks like this

tardy delta
#

you got resource filtering enabled in your pom.xml?

serene sigil
#

i have no idea

#

ill share my xml

tardy delta
#

doesnt look so

echo basalt
#

where did you put your plugin.yml?

tardy delta
#

dunno if that stuff is enabled by default

serene sigil
tardy delta
#

since when does paper-plugin.yml work

serene sigil
#

wdym?

tardy delta
#

thought it was supposed to be called plugin.yml

serene sigil
#

so i should rename?

tardy delta
#

idk could try

young knoll
#

paper-plugin.yml is for paper

#

Believe it or not

serene sigil
#

which one?

serene sigil
#

now it shows the right icon

tardy delta
#

plugin.yml works for paper too

young knoll
#

Yes but it isn’t there official new format

#

Ohnoes

serene sigil
tardy delta
#

first

#

original is without shaded libs, shaded is just shaded libs so you need first one

fierce salmon
young knoll
#

Why the heck would you ever want just shaded libs

tardy delta
#

idk

serene sigil
#

works now

#

thx!

fierce salmon
#

I wanted to add an ActionBar to my player's screen that displays them their time when running a parkour course and was wondering how often I should have the action bar update to not impact server performance or if it won't even be an issue

young knoll
#

It’s just sending a packet

#

It’s not a huge deal

fierce salmon
#

So sending it once every tick will be fine?

echo basalt
#

p much

#

server can send hundreds of packets per second

fierce salmon
#

ok cool

robust pebble
#

could I use setter injection

celest sonnet
#

how can i get all the values for a key from a yml file

robust pebble
#

instead of dependency injection

tardy delta
#

for what

celest sonnet
#

me or knight?

tardy delta
#

not you

robust pebble
#

is this a good usage for dependency injection ^^^

tardy delta
#

dont make it static and make it final

#

nothing static

robust pebble
#

ok

young knoll
#

Don’t make it sta- ^

tardy delta
#

got you

young knoll
#

D:

robust pebble
#

it rlly wants me to add static 😭

tardy delta
#

use this.plugin

#

and create the key in the constructor

#

please dont

robust pebble
#

wait so I didnt need dependency injecting?

#

im so confusedf

tardy delta
#
class Whatever {
  private final XPlugin plugin;

  public Whatever(XPlugin plugin) {
    this.plugin = plugin;
  }
}```
fierce salmon
#

How do you set an action bar for a player?

robust pebble
#

p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(timeInHms));

tardy delta
#

util classes shouldnt have dependencies

robust pebble
#

I used tyhis

robust pebble
young knoll
#

It’s weird that there isn’t a string version for action bar

tardy delta
#

dont tell that to paper

#

im waiting for string templates but in a different way, it would probably be able to colorize a string

carmine mica
robust pebble
#

?paste

undone axleBOT
robust pebble
#

this dosent even give me a cause

#

at me.creepinson.plugin.Main.onEnable(Main.java:107) ~[?:?]

young knoll
robust pebble
young knoll
#

It does give you a cause

#

Plugin is null

robust pebble
#

no but caused by...

quaint mantle
#

Hi

young knoll
#

It’s caused by plugin being null

quaint mantle
#

How to set my own item texture for itemstack item?

robust pebble
#

figured it out

young knoll
quaint mantle
#

How

young knoll
#

ItemMeta#setCustomModelData

quaint mantle
#

But it support only ints

young knoll
#

Correct

#

You then assign that int to a model in your resource pack

pale pulsar
#

hi i would like to know why my instance is not equal to my inventory can you help me

 @EventHandler()
    public static void onClick(InventoryClickEvent event){


        Player player = (Player) event.getWhoClicked();
        ItemStack current = event.getCurrentItem();
        Inventory clickedInventory = event.getClickedInventory();
        Inventory customanvil = Bukkit.createInventory(null, InventoryType.ANVIL, "anvil");
        if (event.getView().getTitle().equalsIgnoreCase("anvil")){
          Inventory anvil = Bukkit.createInventory(null, InventoryType.ANVIL, "anvil");
          ItemStack paper = new ItemStack(Material.PAPER);
          ItemMeta paper_meta = paper.getItemMeta();
          paper_meta.setDisplayName("a");
          paper.setItemMeta(paper_meta);
        }
        if (event.getClickedInventory() == customanvil) {
            player.sendMessage("instance est egal");
        }
 }
quaint mantle
#

And how to import it to spigot plugin folder

terse ore
#

how long max should a method name be?

carmine mica
#

you have to host the resource pack zip somewhere and send a url to the clients

young knoll
robust pebble
#

why is this returning null

quaint mantle
#

How to add hed to my Itemstack item

echo basalt
#

we're not google

near wasp
quaint mantle
#

I cannot find it

near wasp
#

It’s an event.

echo basalt
#

So?

young knoll
#

Events can be static

#

But shouldn’t be

echo basalt
#

Just like they can be private

#

but shouldn't be

#

Thing is slapping static on everything by default is a really nasty habit

near wasp
#

Shouldn’t is irrelevant to the question. It wouldn’t cause that issue.

echo basalt
#

yeah his issue is that he's tryna check if it's an anvil by doing a title check but still

#

master the basics

#

Welp time to

#

Illusion Search Index - Asking for Help

Hey there, if you're seeing this, there's probably a chance that you've asked for help inefficiently. The goal of this post is to provide tips and tricks that will help you get help.

Let's say you want to create a textured skull item with no prior knowledge:

Before asking for help, it is important to research and attempt a solution towards your problem, I usually follow the following steps:

  • Break down the problem into simple steps (In this case we want to first create an item, and them apply a texture to it)
  • Research the steps individually, and understand how your steps work together (We'd figure out that we need to use the ItemStack class, and apply the texture to its meta)
  • If you're struggling, google your problem. Make sure to efficiently use keywords, I usually just write spigot, followed by a 2-3 word summary (spigot custom head itemstack)
  • No solutions? Look at how existing projects solve your problem (In this case I'd look at the source code of a plugin that messes with player heads, probably on GitHub)
  • Still unable to find an answer? Now is the time to ask for help

When you're asking for help, it is important to describe your problem, what your solution is and any attempts you have made, as well as the expected result.

Here's an example of how to properly ask for help:

Hey there, I am currently trying to create a custom-textured skull ItemStack with a base64 texture value. I already tried using the SkullMeta class but this only allows me to pass a player instead of a base64 string. Here's my current code:

public ItemStack createSkullItem(String base64) {
    ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
    SkullMeta meta = (SkullMeta) skull.getItemMeta();
    
    // I'm stuck
    
    return skull;
}

Here's an example of what not to do:

hello
how player head item works base64

When asking for help, there are a few principles that will help you get answered quicker, feel free to do research about the following:

  • No Hello
  • XY Problem
terse ore
#

should I use saveConfig or saveDefaultConfig?

hazy parrot
#

There is difference

#

saveDefault is writing from plugin resource folder

#

And just save is saving from memory

terse ore
#

using savedefault will overwrite what the user might have changed?

remote swallow
#

No, it will save it if it doesnt exist

#

Always call it on enable

terse ore
#

oh

#

thx

remote swallow
#

If you have a config

echo basalt
#

fml I wanna write this guide but parents arguing loud in the back

#

distracting me

robust pebble
#

why is this returning null?

pale pulsar
quaint mantle
undone axleBOT
remote swallow
robust pebble
#

thanks

tardy delta
#

use none of those

rain patio
#

Does anyone know how I can get player chat input from a gui?

Ex: input custom hex code as an option on a color selection menu

young knoll
#

Use the conversation api

rain patio
#

alright

robust pebble
#

public static void subtractTime(Player player, long hours) {

    PersistentDataContainer pdc = player.getPersistentDataContainer();
    Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
    expires.minus(hours, ChronoUnit.HOURS);
    pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}

this isnt subtractng my time when I die

tardy delta
#

shouldnt you be working with System.currentTimeMillis() and TimeUnit.HOURS.toMillis()

robust pebble
#

uhh im doing real time

#

and the server stopd

#

many times

#

and I wanna change the time

#

to my ability

fierce salmon
#

What I want my plugin to do is when the player takes lava damage, to teleport them to the corresponding teleport point. I am using event.setCancelled() to cancel the lava damage, but it seems when the player takes lava damage, they are now unable to move. Here is my code: https://paste.md-5.net/jewuhoyiju.java

robust pebble
#

disable inventory

#

onenventoryopened sor something

#

then do event.setCamceled

#

?spigotapi

#

I use this

#

Very helpful

mortal hare
#

my brain is broken rn, do you guys know any way to traverse single dimension array columnwise?

#

without additional if checks

robust pebble
rain patio
#

single dimension arrays dont have columns?

mortal hare
robust pebble
#

your welcome

mortal hare
#

[1 2 3 4 5 6 7 8 9] =
1 2 3
4 5 6
7 8 9

-> 1 4 7 2 5 8 3 6 9

robust pebble
#

public static void subtractTime(Player player, long hours) {

    PersistentDataContainer pdc = player.getPersistentDataContainer();
    Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
    expires.minus(hours, ChronoUnit.HOURS);
    pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}

this isnt subtractng my time when I die, How could I fix this

rain patio
#

I'd say change your incriment level and then subtract a certain amount when it gets to one point to simulate a certain column, might need an if statement or two

tardy delta
#

method can only accept one event type

quaint mantle
#

someone give me idea for check tripwire states ?
if players put tripwire to tripwire will not merge and change their faces

rain patio
robust pebble
#

oh lol

#

public static void subtractTime(Player player, long hours) {

    PersistentDataContainer pdc = player.getPersistentDataContainer();
    Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
    expires.minus(hours, ChronoUnit.HOURS);
    pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}

this isnt subtractng my time when I die (dont mind the duplicate im creating a thread!)

mortal hare
#

closest thing i've got is

for (int i = 0; i < size; i += rowSize) {
  // code   
  if (i > size) {
    i %= (size-1);
  }
}

well smth like this

#

i swear sometimes iterating without 2d arrays like this is useful

#

especially when you can usage 2d arrays

#

in cpp for example there's no overload of [][] operator

#

so you can defined 2d shared pointers afaik

#

so you need to declare 1d instead and use it as 2d

pseudo hazel
#

yes I agree, using actual 2d arrays is so annoying

lyric turtle
#

is there way to read code of packets in nms???

mortal hare
#

netty connection pipelines

#

through playerconnection class inside nms player object

lyric turtle
#

oh thx

mortal hare
#

you need to inject duplex channel handler

#

iirc

#

inside netty channel handler or smth like that

flat ruin
mortal hare
#

the worst of it all that its not thread safe

#

as the packets sent async

#

so you cant access the api which is not thread safe

flat ruin
#

bruh

mortal hare
#

well you can but you need to be very careful

#

and not everything is safe

lyric turtle
#

cant u just use scheduler to do sync actions??

mortal hare
#

you can, but i dont remember if the registering of listeners are thread safe

#

prob it is

#

but its tick dependent

#

so if you have something which shouldnt depend on the tickrate its not an option

#

afaik there's nms server runnable method

#

that allows to execute in the main server's thread

#

without any delays

fierce salmon
#

its 0-26

#

oh

#

wait

#

thats for chest

worldly ingot
#

0-8 for the hotbar, 9 - 35 for the inventory slots, top left to bottom right

fierce salmon
#

I am trying to make my plugin detect when a player takes lava damage, and when they do, teleport them to a specific location. For some reason, even thought java event.setCancelled(true) is after the part where I check to see if the entity is a player or not, boats are now unable to burn in lava. Here is my code: https://paste.md-5.net/piwojodake.java

lyric turtle
small current
fierce salmon
#

Let me try with my plugin disabled real quick

#

Oh I guess it wasn't my plugin lol

#

could be worldguard I guess

#

thanks!

lyric turtle
#

like i cant find ClientboundCommandsPacket nowhere

unique bay
#
    public class playerJoinListener implements Listener {
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent event) {
            Player p = event.getPlayer();
            UUID playerID = p.getUniqueId();

            File playerDataFolder = new File(getDataFolder(), "playerData");
            File playerFile = new File(playerDataFolder, playerID + ".yml");

            if (!playerFile.exists()) {
                playerDataFolder.mkdirs();
                try {
                    playerFile.createNewFile();
                    YamlConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile);
                    playerConfig.set("balance", 0);
                    playerConfig.save(playerFile);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }```
#

anyone know why this doesn't save?

#

most of it works, except for the part where it generates the file, but nothing is added to it

old cloud
#

no

#

Dont name your classes lower case

#

heheheha

ivory sleet
unique bay
#

it generates the file, but doesn't set the value

ivory sleet
#

I'd use just new YamlConfiguration()

#

since ur loadConfiguration() call is useless

#

as the file is newly created anyway

#

bad naming convention

#

bad choice of name, else yea

#

YouNameClassesLikeThis

#

notLikeThis

#

yep

#

also

#

u usually add the suffix Listener, and not Event at the end of a class that implements Listener

#

cuz else u tell the reader that the class is a subclass of the org.bukkit.Event class

#

which it isnt

zealous osprey
#

heya @rare aurora, you wouldn't by any chance have run a create modded server, right? Might be confusing you with someone

ivory sleet
#

also, I like to have ur event callback methods public

unique bay
zealous osprey
#

youpackagenamelikethis
yourVariableNamesLikeThis
YOUR_CONSTANT_NAMES_LIKE_THIS
YourClassNamesLikesThis

regal lake
#

YoUrChIlDnAmEsLiKeThIs

ivory sleet
#

also ithundxr, I should say u should bundle callbacks by functionality

robust pebble
#

anyone here good at using pdc and instances

ivory sleet
#

yes

#

just ask away

robust pebble
# ivory sleet yes

public static void subtractTime(Player player, long hours) {

    PersistentDataContainer pdc = player.getPersistentDataContainer();
    Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
    expires.minus(hours, ChronoUnit.HOURS);
    pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}

this isnt subtractng my time when I die

ivory sleet
#

lets assume u write a really large plugin

wise mesa
#

is there an easy way to loop through resources

#

without using like jar file

ivory sleet
#

obv the plugin is gonna have different "functionalities"

wise mesa
#

i want to save all of the resources inside a folder to the plugin's data folder

golden turret
#

how could I intercept methods like ASM but in Spigot?

ivory sleet
#

yeah, well then prob u can bundle everything in one listener

wise mesa
#

how could I access my plugin's jar file?

#

I want to loop through its resources

#

is there an easy way to get it's File or its Path

golden turret
ivory sleet
wise mesa
#

right but like

#

how can I get the file

#

that is my jar file

wise mesa
#

youre meant to interact with the api

#

no mixins or anything

#

not by default at least

#

i do know there is a way to do it

ivory sleet
#

idk if u can maybe use FileSystems

wise mesa
#

im just curious if there's some method that'll easily give me my plugin without just doing something like getDataFolder.parent.getChild(jarname)

ivory sleet
#

ur minus returns a new instant

robust pebble
#

yep just fixed it

ivory sleet
#

(cuz of thread safety mainly)

#

unlike ehm... SimpleEwFormat

wise mesa
#

found it

#

Class.getProtectionDomain().getCodeSource().getLocation()

zealous osprey
#

Why not just use getResourecesAsStream()?

wise mesa
#

oh that would work too

wise mesa
ivory sleet
#

thought u wanted to loop through entries in ur jar file

wise mesa
#

yes

zealous osprey
#

ooh

wise mesa
#

oh would that not work

#

nvm then

zealous osprey
#

you use getResourcesAsStream() to get the data of a file in your plugin jar.
But if you need the jar as a file ig, you could use <Class>.getProtectionDomain().getCodeSource().getLocation() on some kind of "marker" class, which is in a very simple location relative to your jar?

wise mesa
#

hm

#

i want to loop through all resources in my jar

#

that's my goal

#

not all

#

most excluding some folders

ivory sleet
#

as said

#

ZipFile will do?

#

or even JarFile

wise mesa
#

yes i agree

#

that's what Im going to do

ivory sleet
#

then u just use ZipEntry::getName with getResource(AsStream)

terse ore
#

is there a difference between

#

and

#

?

ivory sleet
#

info is short hand

#

like its just shorter

#

but if u need to supply an exception

eternal oxide
#

The difference is less imports 😉

ivory sleet
#

or the type is dynamic then, log(...) is what u'd use

fierce salmon
#

Is there a way to check if a player has joined the server before or not?

eternal oxide
#

hasPlayedBefore()

fierce salmon
#

ty

olive compass
#

Where's a good discord server to help get people onboard for a project

eternal oxide
#

?services

undone axleBOT
thick gust
#

Well I feel like getTicksLived() wouldn't be accurate enough. A snowball could live longer than half a minute to be honest in case you would launch the projectile (snowball) from a high amount of blocks.
!snowball.isValid() doesn't work at all in my if case...
Also, getTicksLived() > 600 wouldn't be correct, as it would have to last at least half a minute I just noticed 😆

river hearth
#

is there some method to get the optimal drops from a block, regardless of the tool? Diamond pickaxe is pretty good, but doesn't get everything.

thick gust
#

I just copied both classes "ReflectionUtils" & "ParticleEffect".

thick gust
river hearth
#

no as in like

#

for most blocks, getDrops with a diamond pickaxe returns what I'd want

#

but an example of a problem is glass, it doesn't drop anything

#

I'm sure there are more examples I'm not thinking of yet either

fierce salmon
#

I have a value in my customconfig.yml named waterbucketclutches and I want to get the value of it +1. How would I do this?

dusky prawn
#

Hi!

Don't hate, im completly new to this.
In my pom.xml, this is red:?

            <artifactId>spigot</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>```
#

Like, the red appears in between the <> things

fierce salmon
#

Are you using IntelliJ?

dusky prawn
#

Yes. :)

#

Sorry i didn't write that. It was important.

fierce salmon
#

Is there a little reload button at the top right of the code screen when inside the pom.xml?

dusky prawn
#

Yes, in a sidebar thing :D?

#

I missclicked it, but something popped up, in the bottom of my screen :p?
Could not find artifact org.spigotmc:spigot:pom:1.18.2-R0.1-SNAPSHOT in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)

fierce salmon
#

This one?

dusky prawn
#

I guess not?

#

I got to error thingy, and 2 check marks?

delicate lynx
#

you have the wrong artifactId

dusky prawn
#

What is that? :o

#

Or more like, how do i fix it?

fierce salmon
dusky prawn
#

Thanks! :)

fierce salmon
#

np

dusky prawn
#

Wow, that was actually pretty easy, thanks!

fierce salmon
#

Of course!

serene sigil
#

hi, whats the file path to a file inside the resources folder?

dusky prawn
#

My @Override is red?

Cannot resolve symbol 'Override'

fierce salmon
#

if you are in IntelliJ you can right click the folder that says resources and copy the path i believe

serene sigil
#

ye but thats the absolute path

#

i want the not absolute one

delicate lynx
#

are you trying to load a resource from the jar

serene sigil
#

yes

delicate lynx
#

you don't need to specify a path

serene sigil
#

ye but when i just typed the name (and extension) it still says no such file or path

eternal oxide
serene sigil
#

no? its inside the resources

eternal oxide
#

there is no resources folder in a jar by default

serene sigil
#

and the size of the jar also changed

eternal oxide
#

open teh jar with a zip tool and see if your file is there

serene sigil
#

alr

dusky prawn
eternal oxide
#

then how are you trying to read it?

serene sigil
#

ProcessBuilder

#

its an exe

eternal oxide
#

what?

#

you can;t execute an exe from inside a jar

serene sigil
#

oh

#

oof

#

how then`?

eternal oxide
#

This sounds odd behaviour

#

why are you packaging an exe?

serene sigil
#

i wanted to try out something lol

#

idk if it will work

eternal oxide
#

you need to extract it to a file

quiet ice
#

You can however pack a dll in the jar and run that through a few hoops

#

Well running isn't really the right word though

serene sigil
#

cuz if i run it somewhere else, the path will change

#

what do i have to do if its in the plugins folder?

eternal oxide
#

you realize an exe will only run on windows

serene sigil
#

it is windows

eternal oxide
#

if you extract it it will extract to wherever your jar is

#

or where you tell it to

serene sigil
#

wait so if its in the same folder (plugins folder) then i can still call it with the name?

eternal oxide
#

yes

hazy parrot
#

You can always use relative paths

serene sigil
#

and what exception will it give me if it cant run?

eternal oxide
#

people are goign to be very suspicious of a jar extracting an exe and running it

calm robin
#

how can i change player name colors for each player? like one player sees some guys name in red but a different player sees the same player with green? like for team differentiation

#

friendlies show up in green on tab, enemies show up in red

#

something like that

#

how could i go about making that

eternal oxide
#

packets only

calm robin
#

ok

eternal oxide
#

sending fake teams

calm robin
#

poggers

wise mesa
#

how can I make a regex that matches strings that start with "META-INF"

eternal oxide
#

?xy

undone axleBOT
wise mesa
#

im looping through a set of strings

#

and want to exclude ones that match certain things

#

like starting with META-INF

#

but idk regex

eternal oxide
#

referencing META-INF sounds more like you are having issues creatign a working jar with shaded libs

quiet ice
#

but uh, java provides the String#startsWith method so I sure hope you cannot use that one

#

Also ^/?META-INF(.+)?$ is probably the better regex, but has slightly different behaviour to what you asked for

zealous osprey
#

Here are the most common characters and their corresponding width. Now just find out how wide a book page is and from there it should be fairly easy

eternal oxide
#

MC uses custom widths

#

which can change depending on resource pack

wise mesa
#

the jar file being my plugin's

zealous osprey
#

Well, ignore that for simplicities sace.

wise mesa
#

and that's why I need to exclude some things

#

like meta-inf

#

or any file that ends in .class

eternal oxide
#

it would probably be easier to specify the types of resources you want

quiet ice
#

Just ignore pom.properties, pom.xml, *.class and *.MF files then

Unless you use services for whatever ungodly reason

wise mesa
quiet ice
#

Let me guess: License files?

wise mesa
wise mesa
#

my team is making a rather complicated plugin for our server

#

with many data oriented parts

#

lots of json files and whatnot

quiet ice
#

or language files I guess. Noone seems to remember that it is required to include the license in your jar

wise mesa
#

instead of loading the resources directly

#

I want to load them from my data folder

#

so that they can be edited without recompiling

robust pebble
#

public static boolean hasExpired(Player player) {

    Instant expired = Instant.ofEpochMilli(player.getPersistentDataContainer().get(PlayerJoined.key, PersistentDataType.LONG));
    return Instant.now().isAfter(expired);
}This is not working
#

how can I fix this

quiet ice
#

how exactly is it not working?

robust pebble
#

like the boolean isnt true

quiet ice
#

Also it really looks like this can be done without the usage of PDC

eternal oxide
#

Its designed to use PDC

quiet ice
quiet ice
#

like really sure?

eternal oxide
#

does the players time show zero?

wise mesa
#

well if the timestamp is in the future

quiet ice
#

Just Sysout the instant (expired) for us

wise mesa
#

wouldn't you expect it to be false

#

because it hasn't expired yet?

robust pebble
#

it is - time

#

right now

#

-28 min

quiet ice
# robust pebble -28 min

Yep that confuses me even more.
Either send the entire code or print expired and give out what the console has to say about it

fringe yew
#

fsr the night vision effect will flash (it's random, usually every 10-100s)
don't talk about how bad the code is lmao

public class ManualListener extends BukkitRunnable {

    private final JavaPlugin plugin;

    public ManualListener(JavaPlugin plugin) {
        this.plugin = plugin;
    }

    @Override
    public void run()
    {
        App.getInstance().getLogger().info("hello");
        final FileConfiguration config = App.getInstance().getConfig();
        List<String> players = config.getStringList("players");
    
        for(String name : players) {
            Player player = Bukkit.getPlayerExact(name);

            if(player == null) {
                continue;
            } else if(name != player.getName() && player != null) {
                player.removePotionEffect(PotionEffectType.NIGHT_VISION);
            }

            player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 255));
        }
    }
}
robust pebble
#

int timeInSeconds = 1;
int timeInTicks = 20 * timeInSeconds;
new BukkitRunnable() {

        @Override
        public void run() {
            //The code inside will be executed in {timeInTicks} ticks.
            for (Player p : Bukkit.getOnlinePlayers()) {
                if(hasExpired(p)){
                    Bukkit.getBanList(BanList.Type.NAME).addBan(String.valueOf(p.getUniqueId()), "Clock Ran Out", null, null);
                }
                // set actionbar
                Long Frt = Instant.now().until(getTime(p), ChronoUnit.MILLIS);
                Duration duration = Duration.ofMillis(Frt);

                long h = duration.toHours();
                long m = duration.toMinutes() % 60;
                long s = duration.getSeconds() % 60;

                String timeInHms = String.format("%02d:%02d:%02d", h, m, s);
                p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(timeInHms));
            }

        }
    }.runTaskTimer(JavaPlugin.getPlugin(Main.class), 1,timeInTicks);
#

private static NamespacedKey key = new NamespacedKey(JavaPlugin.getProvidingPlugin(Main.class), "death_clock");

public static boolean hasExpired(Player player) {

    Instant expired = Instant.ofEpochMilli(player.getPersistentDataContainer().get(PlayerJoined.key, PersistentDataType.LONG));
    return Instant.now().isAfter(expired);
}
quiet ice
#

and where do you store the instant?

robust pebble
nimble oxide
robust pebble
#

public static NamespacedKey key = new NamespacedKey(JavaPlugin.getProvidingPlugin(Main.class), "death_clock");

quiet ice
nimble oxide
fringe yew
fringe yew
robust pebble
#

have no idea how to do that

nimble oxide
fringe yew
quiet ice
pseudo hazel
#

its literally a single line of code

eternal oxide
#

Hes sets teh future time when the player joins if it's a first played

quiet ice
#

Read up on how to use the PDC properly and you should figure it out

robust pebble
#
if(!p.hasPlayedBefore()){
            p.sendMessage(DIALOG + ChatColor.GREEN + "Welcome to the server!");
            // set time
            setClock(p,10);
quiet ice
#

and what is setClock

nimble oxide
# fringe yew command i guess
package com.meteoren.lobien;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.Arrays;

public class guicmd implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (commandSender instanceof Player) {
            Player player = (Player) commandSender;
            Inventory inv = Bukkit.createInventory(player, 45, ChatColor.translateAlternateColorCodes('&', "&e&lLobien"));

            ItemStack close = new ItemStack(Material.BARRIER);
            ItemMeta closeMeta = close.getItemMeta();
            closeMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lLuk Menu"));
            closeMeta.setLore(Arrays.asList(ChatColor.translateAlternateColorCodes('&', "&7| Klik for at lukke menuen")));
            close.setItemMeta(closeMeta);

            inv.setItem(45, close);

        }
        return false;
    }
}
robust pebble
#
public static void setClock(Player player, long hours) {

        Instant expires = Instant.now().plus(hours, ChronoUnit.HOURS);
        player.getPersistentDataContainer().set(key, PersistentDataType.LONG, expires.toEpochMilli());
    }
#

^^^^^

quiet ice
#

That is a NOP

#

I think so at least. Lemme check

nimble oxide
#

What? to me?

quiet ice
#

?jd-s

undone axleBOT
nimble oxide
#

or

fringe yew
#

oh shoot i gtg now srry

quiet ice
#

Ah nevermind. I confused itemstacks with players

nimble oxide
#

whats the problem O.o

quiet ice
#

With itemstacks you'd need to set the itemmeta again, but you don't have the problem with players

quiet ice
#

it is irrelevant for you. I made a mistake

chrome beacon
#

You have a bad plugin.yml

pseudo hazel
nimble oxide
#

me?

pseudo hazel
#

yes

chrome beacon
#

Yes you

pseudo hazel
nimble oxide
#

its just
commands:
test12:

#

and then usage + description

chrome beacon
#

Send the entire plugin.yml

nimble oxide
#
name: Lobien
version: '${project.version}'
main: com.meteoren.lobien.Lobien
api-version: 1.18
commands:
  test12:
  description: Det her er pisse svært
  usage: Du bruger ikke kommandoen rigtigt, dumme svin
chrome beacon
#

?paste

undone axleBOT
nimble oxide
#

there you go

chrome beacon
#

Wrong spacing

pseudo hazel
#

indent the description and usage by 1 more tab

quiet ice
robust pebble
#

I see from actionbar

quiet ice
#

that makes it interesting then

lavish vortex
#

hello guys

#

I need a little help

eternal oxide
#

I see nothign wrong with the code

#

other than it's untidy. you should keep all the clock code in the util class

#

it shoudl also be in it's own class, nothing else in it

robust pebble
#

how to check if instant expire

quiet ice
#

Yeah it should work from the looks of it

eternal oxide
#

no listener, nothing

robust pebble
#

that is question

chrome beacon
undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

eternal oxide
#

you are comparing teh stored instant to a new instant

grim hound
robust pebble
eternal oxide
#

yes

robust pebble
#

but this exact code dosent work tho

eternal oxide
#

Instant.now().isAfter(expired)

#

if expired is in teh past that will return true... I th9ink

quiet ice
eternal oxide
#

check the javadoc on isAfter

robust pebble
quiet ice
#

Ah, show that code then

robust pebble
#
public class PlayerDeath implements Listener {
    @EventHandler
    public void PlayerDeathEvent(PlayerDeathEvent event) {
        Player p = event.getEntity();
        subtractTime(p, 1);
        p.sendMessage(DIALOG+ ChatColor.DARK_RED +"You Died... this means you have lost one hour of your life!");
        Entity n = event.getEntity().getKiller();
        if (n instanceof Player){
                Player np  = (Player) n;
                addTime(np,1);
                np.sendMessage(DIALOG+ChatColor.GREEN + "You killed someone, you get 1 Hour!");
        }
    }
}
quiet ice
#

And the subtractTime and addTime methods?

pseudo hazel
#

oh, this wont solve your issue but you can say instanceof Player np, which saves you from typing a cast manually.

#

unless you are on java 1.ancient ig

quiet ice
#

I guess it is the same methods as sent by ElgarL?

robust pebble
#
public static void addTime(Player player, long hours) {

        PersistentDataContainer pdc = player.getPersistentDataContainer();
        Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
        expires = expires.plus(hours, ChronoUnit.HOURS);
        pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
    }

    /**
     * Subtract time from a Players Deathclock.
     *
     * @param player the Player to remove time from.
     * @param hours the number of hours to remove.
     */
    public static void subtractTime(Player player, long hours) {

        PersistentDataContainer pdc = player.getPersistentDataContainer();
        Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
        expires = expires.minus(hours, ChronoUnit.HOURS);
        pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
    }
lavish vortex
#

who can I dm for help

#

I have images

pseudo hazel
#

noone, get verified

chrome beacon
#

?img

undone axleBOT
lavish vortex
#

?img

undone axleBOT
chrome beacon
#

Also if it's code or errors (text) use a paste

#

?paste

undone axleBOT
lavish vortex
#

waut

#

wait

#

can I send links

agile anvil
#

Yes

quiet ice
robust pebble
lavish vortex
#

the problem is

#

I suppose to have 3 lores

#

but I only have 1

#

anyone know how to resolve this issue ?

pseudo hazel
#

show the code

#

show the code that adds the lore

robust pebble
#

./kill maybe

lavish vortex
#

it is there

agile anvil
#

This is not spigot plugin development related, is it ?

chrome beacon
quiet ice
pseudo hazel
#

thats not java so idk what it is

lavish vortex
#

kk

agile anvil
robust pebble
#

/kill works

quiet ice
#

Try using \n instead of ;

eternal oxide
robust pebble
#
public void PlayerDeathEvent(PlayerDeathEvent event) {
        Player p = event.getEntity();
        subtractTime(p, 1);
        p.sendMessage(DIALOG+ ChatColor.DARK_RED +"You Died... this means you have lost one hour of your life!");
        Entity n = event.getEntity().getKiller();
        if (n instanceof Player){
                Player np  = (Player) n;
                if(!np.equals(p)) {
                    addTime(np, 1);
                    np.sendMessage(DIALOG + ChatColor.GREEN + "You killed someone, you get 1 Hour!");
                }
        }
    }
#

I fixed it

quiet ice
#

Well then the only possible cause that remains is that you fetch and set the death clock under different namespaced keys

robust pebble
#

the suicide problem

quiet ice
#

But uh, in that case it should blow up somewhere else in the pipeline

eternal oxide
#

This is why ALL clock methods shoudl be in a single class, with the NamespacedKey

quiet ice
#

So to be honest I am at a loss.

eternal oxide
#

NOT in your Listner

quiet ice
#

Even the #hasExpired method?

eternal oxide
#

in your code you access the adTime methods etc non static

quiet ice
#

Because the #hasExpired method seems to reference PlayerJoined.key which may be different

eternal oxide
#

they can;t be in their own class if you access them as local methods

robust pebble
#

would the two usages of creating a nnamespaced key variable be conflicting

eternal oxide
#

you shoudl not be creating two keys

robust pebble
#
public class PlayerJoined implements Listener {
    public static NamespacedKey key = new NamespacedKey(JavaPlugin.getProvidingPlugin(Main.class), "death_clock");
public class DeathClockUtils {
    private static NamespacedKey key = new NamespacedKey(JavaPlugin.getProvidingPlugin(Main.class), "death_clock");
eternal oxide
#

but no they shoudl not conflict

robust pebble
#

like this

quiet ice
#

Assuming that the plugin is the same, no - there should be no issues.

eternal oxide
#

do not have anythign to do with the clock outside of the DeathClockUtils

#

PlayerJoined does not need the key

robust pebble
#

thats the problem maybe

fierce salmon
#

Does IntelliJ have a Find and Replace function?

#

nvm i did it

robust pebble
robust pebble
#

should work maybe

#

I removed it

#

now its doing this

#

we are using playerjoinds key

quiet ice
#

Just do key then

#

assuming that both are in DeathClockUtils

robust pebble
#

FOUND IT

#

chatColor.BLUE

#

oh nvm

#

use spigot jd

#

javadocs

quiet ice
#

Using spigot or paper api?

hazy parrot
#

I wouldn't say its deprecated in spigot

quiet ice
#

For latter it is something like NamedTextColor.BLUE

#

But uh, you'd need to use Components and all that jazz too

#

Yes but via Component.text(string, NamedTextColor.BLUE) (without any warranty of any kind) it should work

eternal oxide
quiet ice
#

It has been almost a year since I last touched adventure so there might be slight changes you'd need to do as I could misremember stuff

robust pebble
eternal oxide
#

only 1 key, in the same class

robust pebble
#

yes fixed

eternal oxide
#

ok cool

#

nothing outside that class should access the PDC's

robust pebble
#

checked no uses

quaint mantle
#

ElgarL hi bro can u help me?

robust pebble
#

only in utils

quaint mantle
#

or IK_Knight ?

robust pebble
#

what u tryna do

quaint mantle
#

bro i wanna prevent tripwire rotations

robust pebble
#

i see

quaint mantle
#

do u know tripwire and states ?

#

but blockphysics event not working

robust pebble
eternal oxide
#

god don;t use block physics

robust pebble
#

this has some methods you can use

#

nvm

#

all depricated

eternal oxide
#

What exactly are you trying to do with a tripwire?

quaint mantle
tribal quarry
#

hey there, whats the best practice to register a creaturespawn event listener before the dependency plugin's creaturespawn event listener?

quaint mantle
#

so i do custom items and when click block set custom statated tripwires

#

but i put one more tripwire to near my main tripwire states changing

eternal oxide
#

yes they auto connect

#

place without physics

quaint mantle
quaint mantle
#

and control physics with update ?

eternal oxide
#

yes, listen to blockPlace, if it's a tripwire, cancel the event and Block#setType(Material.TRIPWIRE, false)

quaint mantle
#

alright i try i need afk brb

robust pebble
#

LESGOOO

eternal oxide
#

nice

robust pebble
#

is there a way I could give someone time

eternal oxide
#

you have to kick the player as well as ban. adding a ban will not kick them

robust pebble
#

thats the depricated version of it

eternal oxide
#

no

robust pebble
#

they fixed it and made it better

eternal oxide
#

adding a ban shoudl not kick the player, last I saw

robust pebble
#

no they have new ban

#

system

eternal oxide
#

what?

#

it's the same system it's been for months that I can see

robust pebble
#

oh but its working

eternal oxide
#

ok

#

I guess they changed ban to also kick

tribal quarry
#

are there any events for event registration?

eternal oxide
#

only for services

thick gust
#

why do I get a NoClassDefFoundError when using this api?

quiet ice
#

is it even on the classpath?

thick gust
# thick gust https://github.com/ByteZ1337/ParticleLib
[00:10:44 WARN]: [Rpg] Plugin Rpg v1.0 generated an exception while executing task 24
java.lang.NoClassDefFoundError: xyz/xenondevs/particle/ParticleEffect
        at de.rpg.classes.MageClass$3.run(MageClass.java:191) ~[?:?]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:52) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_372-372]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_372-372]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372-372]
quiet ice
#

Or better said, did you install the lib as a plugin?

#

If not, did you at least shade it?

#

1.12.1 spigot jar? That is ambitious.

thick gust
#

got both in the plugins folder

thick gust
quiet ice
thick gust
#
[00:17:53 ERROR]: Could not load 'plugins\particle-1.8.4.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:152) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:308) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:753) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.Bukkit.reload(Bukkit.java:525) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:651) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:637) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372-372]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
        ... 14 more
echo basalt
#

reload

thick gust
#

the api came without a plugin.yml, so this error is there as well.

echo basalt
thick gust
#

what do u mean with that xD

eternal oxide
#

?shade

#

I was hoping 🙂

#

add maven shade plugin to your pom and set the dependency to compile scope

#

or

#

if using post 1.16.5 you can use the libraries entry in plugin.yml

quaint tapir
#

Vector velocity = endVector.subtract(boss.getLocation().toVector());
does anyone know why this line changes the value of endVector

#

endVector is a bukkit vector
boss is an entity

#

for some reason this line changes the value of endVector

eternal oxide
#

endVector is mutable

quaint tapir
#

what does that mean

eternal oxide
#

it can be changed

#

if you want a copy endVector.clone()

quaint tapir
#

thank you

#

will try it

broken willow
#

help me

#

tf

#

my mail was changed

#

from my account

eternal oxide
undone axleBOT
eternal oxide
quaint mantle
#
    @EventHandler
    public void onPlace(BlockPlaceEvent e) {
        Block block = e.getBlockPlaced();
        if (block.getType() == Material.TRIPWIRE) {
            block.setType(Material.TRIPWIRE, false);
        }
    }```
#

this

eternal oxide
#

cancel the event too

quaint mantle
#

not worked

#

oh oke

#

im trying

eternal oxide
#

if it still doesn;t work you will have to setType 1 tick later

quaint mantle
#

alright

eternal oxide
#

as BlockPlace is a strange event. It actually fires after teh block has changed and undoes the changes if cancelled

#

Bukkit.getScheduler().runTask(()-> { block.setType(Material.TRIPWIRE, false) }, plugin);

quaint mantle
#

;-;

#
    Plugin plugin;

    @EventHandler
    public void onPlace(BlockPlaceEvent e) {
        Block block = e.getBlockPlaced();
        if (block.getType() == Material.TRIPWIRE) {
            e.setCancelled(true);
            new BukkitRunnable(){
                @Override
                public void run(){
                    block.setType(Material.TRIPWIRE, false);
                }
            }.runTaskTimer(plugin, 1, 1);
        }
    }```
#

i did this is wrong ?

eternal oxide
#

not a timer

quaint mantle
#

is cooldown ?

hazy parrot
#

Have you ever initialized that plugin

eternal oxide
#

runTask

#

?di to pass the plugin instance to your listener

undone axleBOT
graceful turret
#

does anybody know what is the statistic that contains all player travelled distance

eternal oxide
#

step one or something

graceful turret
#

or should i add all together

eternal oxide
#

I believe step one is all distance

graceful turret
#

okay i will check ty

graceful turret
eternal oxide
#

could be

quaint mantle
#

where can i learn this means ? can u give me doc ?

#

i did btw thx

#

I've been struggling since morning

graceful turret
eternal oxide
#

?scheduling

undone axleBOT
eternal oxide
#

?jd-s

undone axleBOT
thick gust
#
[00:50:39 WARN]: [Rpg] Task #67 for Rpg v1.0 generated an exception
java.lang.IllegalStateException: Not scheduled yet
        at org.bukkit.scheduler.BukkitRunnable.checkScheduled(BukkitRunnable.java:149) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.scheduler.BukkitRunnable.getTaskId(BukkitRunnable.java:143) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at de.rpg.classes.PriestClass$1.run(PriestClass.java:61) ~[?:?]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:739) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372-372]
public void shootParticlev2(Player player, Particle particle) {
        Location location = player.getEyeLocation();
        Vector direction = location.getDirection();
        Snowball snowball = player.launchProjectile(Snowball.class, direction);
        snowball.setShooter(player);
        snowball.setSilent(true);
        snowball.setBounce(false);
        int taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(Rpg.getInstance(), new BukkitRunnable() {
            @Override
            public void run() {
                if(!player.getWorld().getEntities().contains(snowball)) {
                    snowball.remove();
                    player.sendMessage("§aSnowball landed");
                    /*for(BukkitTask task : Bukkit.getScheduler().getPendingTasks()) {
                        if(task.getTaskId() == this.getTaskId()) {
                            task.cancel();
                        }
                    }*/
                    //this.cancel();
                    /*if(Bukkit.getScheduler().isCurrentlyRunning(this.getTaskId())) {
                        Bukkit.getScheduler().cancelTask(this.getTaskId());
                    }*/
                } else {
                    player.playEffect(snowball.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
                }
            }
        }, 1, 1);
        PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(snowball.getEntityId());
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
    }

Why can't I cancel that task?

#

All 3 ways which are in comment snippet don't work.

quaint mantle
#

works when block place but other features broke this

eternal oxide
#

what features?

quaint mantle
#

walk or ...

eternal oxide
#

thats interact event

quaint mantle
#

ah alrigh

#

but what is this ?

eternal oxide
#

cancel the interact event if the block is tripwire

quaint mantle
eternal oxide
#

that looked like a normal block place to me

quaint mantle
#

idk what first tripwire state changed

eternal oxide
#

shoudl not happen if you cancel and manually place

quaint mantle
#
    public void onPlace(BlockPlaceEvent e) {
        Block block = e.getBlockPlaced();
        if (block.getType() == Material.TRIPWIRE) {
            e.setCancelled(true);
            Bukkit.getScheduler().r(plugin, () -> block.setType(Material.TRIPWIRE, false));
        }
    }```
eternal oxide
#

no annotation?

quaint mantle
#

i already cancelled

eternal oxide
#

make sure the event is annotated and registered

#

Bukkit.getScheduler().r ?

#

.r ?

quaint mantle
#

😄 isnt runtask ? oke

#

wait mb

#

i fixed to runtask

#

but again... ;-;

eternal oxide
#

add a sysout to make sure teh code is running

quaint mantle
#

oke,

thick gust
#

Got a solution...

        new BukkitRunnable()
        {
            public void run()
            {
                if(!player.getWorld().getEntities().contains(snowball)) {
                    snowball.remove();
                    this.cancel();
                } else {
                    player.playEffect(snowball.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
                }
            }
        }.runTaskTimer(Rpg.getInstance(), 1, 1);
quaint mantle
#

holy sh1t

#

wait i upload video

#

if i right click the broken tripwire

#

fixing

#

Is there any way to overcome this?

#

like renovation

eternal oxide
#

you need to cancel interact events with the wires

quaint mantle
eternal oxide
#

just a client display bug then

quaint mantle
#

i will explain u with 1 more video

quaint mantle
#

see ?

#

actually u was understand

eternal oxide
#

yep

quaint mantle
#

how do i prevent this?

eternal oxide
#

probably can't

quaint mantle
#

;-;

wet breach
#

change the blockstate

#

or set it

eternal oxide
#

he does

quaint mantle
#

but i was saw at some server

wet breach
#

and the metadata too?

#

there is a metadata for attached I believe for it

eternal oxide
#

it's a client side bug. the block hasn;t actually changed, just th eclient predictive messing up

#

he's placing without physics so it never connects

wet breach
#

oh, then send a update

quaint mantle
#

can i detect block around blocks and update to blocks clone ?

wet breach
#

I am thinking you probably could use sendblockchange in the api

#

to make the client correct itself

eternal oxide
#

the issue is knowing which block gets messed up

wet breach
#

just send them all

quaint mantle
wet breach
#

we can't diagnose problems in regards to other implementations

quaint mantle
#

yes

wet breach
#

and therefore we only concern ourselves here in regards to spigot

eternal oxide
#

Its more likely just client. Nothign to do with server

quaint mantle
#

can i do this ?
when blockplace or break can i detect around blocks and set clones to block locations ?=

wet breach
#

not sure what you mean by clones

robust pebble
#

/givetime <Player> numofhours

#

I wanna do this command

eternal oxide
#

when you break you should detect it's a trip wire, cancel the event and break it your self

quaint mantle
#

clone method

eternal oxide
#

so again no physics

quaint mantle
#

actually i do this with custom items so i don't use string for place tripwire

#

maybe this will fix

eternal oxide
#

place, interact and break you should be cancelling all and doing yourself.

quaint mantle
#

yes i do with custom item

#

i have question for you guys 😄

#

sry about that

#

how can i check block faces ? but all faces not only 1

wet breach
#

getRelative()

quaint mantle
#

i explain with video

quaint mantle
#

i need use loop ?

eternal oxide
#

BlockFace.getValues().forEach( face -> { if (face.isCardinal()) { code } } )

quaint mantle
#

this is a paper i put everywhere

#

oke i do tomorrow this

#

but i have 1 question more

#

:DDDD

#

sry 😄

eternal oxide
#

You may have to Arrays.stream(), depending on what getValues returns

quaint mantle
#

but i wonder

#

i will do custom leaves with leaves distance

#

u guys know leaves distance ?

#

distance from log

#

this leaves is azalea leaves

#

if i cancel blockphysics event for this leave

#

works leave distances not changing

#

but leaves isnt does not spill

#

can i do this if leaves far from wood i will add scheduler and remove this leaves?

obsidian plinth
#

?paste

undone axleBOT
obsidian plinth
#

is their an easy way to remove the 0 that shows before the string and if u say some dumb shit about formatting i do not care as the sting works how i want it i just dont want the zero before it and i think im overlooking something

https://paste.md-5.net/axiwamagog.cpp

robust pebble
#

/giveTime <Player> <Time - Hours>
I want to use player which would be arg[1] im guessing

#

myb

#

arg[0]

hazy parrot
#

0

robust pebble
#

I see

maiden geode
#

Hello,
I need some help from someone who knows NMS quite well. So I've got around 3 year old plugin which was written for me but I've never got the source code for it. Now I'm trying to modify the nms package and classes within it (it's the last thing to do actually) but my knowledge about multi-version is really poor, especially when it comes to NMS. I'm looking for someone who could modify my code and help me out with it overal (NMS).
Thanks!
Interface:
https://pastebin.com/kgnCmSqz
One of the classes (in this case it's the newest version but I can't figure out imports etc. (I installed buildtools for 1.19.4):
https://pastebin.com/rvtxv8Fd

robust pebble
#
if (sender instanceof ConsoleCommandSender) {
            sender.sendMessage(DIALOG + ChatColor.DARK_RED + "You cannot run this command from the console! Bozo admin get dunked on");
            return false;
        }
        Player player = (Player) sender;
        if (args.length == 0) {
            player.sendMessage(DIALOG + ChatColor.RED + "Wrong Usage! Do /giveTime <Player> <Time - Hours>");
            return true;
        }
        if (args.length == 1) {
            player.sendMessage(DIALOG + ChatColor.RED + "Wrong Usage! Do /giveTime <Player> <Time - Hours>");
            return true;
        }
        // create code to give player time in hours using addTime method from DeathClockUtils
        if (args.length == 2){
            Player target = player.getServer().getPlayer(args[0]);
            // player dose not have to be online
            if (target == null) {
                player.sendMessage(DIALOG + ChatColor.RED + "Player not found!");
                return true;
            }
            Long Frt = Instant.now().until(getTime(player), ChronoUnit.MILLIS);
            long h = Frt / 3600000;
            if (h>=Long.parseLong(args[1])){
                subtractTime(player, Long.parseLong(args[1]));
                addTime(target, Long.parseLong(args[1]));
                player.sendMessage(DIALOG + ChatColor.GREEN + "You have given " + target.getName() + " " + args[1] + " hours of time!");
                target.sendMessage(DIALOG + ChatColor.GREEN + "You have been given " + args[1] + " hours of time by " + player.getName());
                return true;
            } else {
                player.sendMessage(DIALOG + ChatColor.RED + "You do not have enough time to give!");
                return true;
            }

        }


        player.sendMessage(DIALOG + ChatColor.DARK_RED + "Some wierd error happened, I have no idea how to fix it either lmao do /giveTime <Player> Time");
        return false;
#

Does this look good

eternal oxide
#

no

#

you can;t get a Player who is offline

robust pebble
#

even if theyre banned?

eternal oxide
#

Player only exist if online

robust pebble
#

NOOOOOOOOOOOOOOOOOO

#

can I add a thing where it says or if theyre banned?

eternal oxide
#

instead of banning you shoul dconsider forcing them into spectator

robust pebble
#

good idea

#

but thats not doing any good

#

they will be able to tell people where bases are and stuff

#

can I kick them

#

so they relog

eternal oxide
#

force them into another world then

robust pebble
#

and get kicked again

robust pebble
#

oh wait nvm

robust pebble
obsidian plinth
#

is their an easy way to remove the 0 that shows before the string and if u say some dumb shit about formatting i do not care as the sting works how i want it i just dont want the zero before it and i think im overlooking something

https://paste.md-5.net/axiwamagog.cpp

kind hatch
# maiden geode Hello, I need some help from someone who knows NMS quite well. So I've got arou...

You know, I think everything except the hologram creation has been added to the API.

Player#sendTitle() <--- Can be used for titles and subtitles.
Player#sendBlockChange() <--- You can include a Collection<BlockState> to cover large areas.
Player#setWorldBorder() <--- Only visible to that player.

Are you sure you want to continue using NMS for all of that? Cause if you do, you never really specified your issue that you have with it.

#

Well, there is Player#showEntity(), but I think that relies on real entities and not packet based ones. So you could just create a new armorstand and pass it through there.

#

Also, when it comes to holograms, we now have Text Display entities, so maybe there is something that could be added.

robust pebble
#

how would I create a void world and load it and then make a player teleport there

kind hatch
untold jewel
#

Does someone know of a good scoreboard api for 1.19?

river oracle
#

I like FastBoard, but other than that just the Normal one is fine

#

it was improved recently

unique bay
#

finally hit my 300 line mark

kind hatch
robust pebble
#

Bukkit.createWorld()

#

??

unique bay
#

banana

#

oop too much

#

oh well

#
    public class WithdrawBalance implements CommandExecutor {

        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (sender instanceof Player player) {
                // Get the withdrawal amount from args[0] (assuming it's the first argument)
                if (args.length > 0) {
                    try {
                        int withdrawalAmount = Integer.parseInt(args[0]);

                        Material itemMaterial;
                        String nbt = "";

                        if (withdrawalAmount >= 100 && withdrawalAmount <= 999) {
                            itemMaterial = Material.IRON_INGOT;
                            nbt = "Iron";
                        } else if (withdrawalAmount >= 1000 && withdrawalAmount <= 4999) {
                            itemMaterial = Material.GOLD_INGOT;
                            nbt = "Gold";
                        } else if (withdrawalAmount >= 5000) {
                            itemMaterial = Material.DIAMOND;
                            nbt = "Diamond";
                        } else {
                            player.sendMessage(formatMessage("&7Invalid withdrawal amount."));
                            return true;
                        }

                        ItemStack item = new ItemStack(itemMaterial);
                        ItemMeta itemMeta = item.getItemMeta();
                        itemMeta.setDisplayName(nbt + " Withdrawal");
                        itemMeta.setLore(Arrays.asList(formatMessage("&7Withdrawal Amount: &a" + withdrawalAmount)));
                        itemMeta.getPersistentDataContainer().set(KeyConstants.WITHDRAWAL_AMOUNT_KEY, PersistentDataType.INTEGER, withdrawalAmount);
                        item.setItemMeta(itemMeta);
                        player.getInventory().addItem(item);

                        player.sendMessage(formatMessage("&aWithdrawal successful!"));
                    } catch (NumberFormatException e) {
                        player.sendMessage(formatMessage("&cInvalid withdrawal amount."));
                    }
                } else {
                    player.sendMessage(formatMessage("&7Usage: /withdraw &a<amount>"));
                }
            } else {
                sender.sendMessage(formatMessage("This command can only be executed by a player."));
            }
            return true;
        }
    }```
kind hatch
#

?paste exists for a reason

undone axleBOT
unique bay
#

some part about the item meta here causes an issue

unique bay
kind hatch
#

They got ignored though. lol

unique bay
#

not really

#

sorry for the code wall

#

I'm just lost

lavish robin
kind hatch
unique bay
unique bay
#

the first part runs fine when the amount is under 100

#

I figure it's something to do with the PDC

hazy parrot
#

What exception

unique bay
#

it doesn't say

kind hatch
#

Do you have any sort of stacktrace?

unique bay
#

only unhandled exception when the command is run

hazy parrot
#

Can you show it

unique bay
#

I can't show it, can't attach images

hazy parrot
#

?img

undone axleBOT
unique bay
kind hatch
#

Is that the entire thing or is there more?

thick gust
#

How can I get the loc at where a player is looking? It has to be on a block...

unique bay
unique bay
#

it's hard to show all of this on feather

thick gust
kind hatch
thick gust
#

" java.util.Set<org.bukkit.Material> set,
int i"

#

I don't know what those are

kind hatch
#

You could try using Player#getTargetBlockExact() as it only has one parameter. Although it may or may not ignore fluids. Hence the second method.

thick gust
kind hatch
#

Unless you are using an ancient version of the game, there is.

thick gust
#

My compiler can't find one (no auto complete) 😉

kind hatch
#

What version of the API are you using?

thick gust
#

So basically the first parameter can be null / empty or like an empty object and the 2nd one is the range. So if a player is targetting a block having a distance of 50+ blocks, and you insert in 2nd parameter an int of 20, the block will be empty?

thick gust
livid dove
kind hatch
#

Or maybe through things like flowers or grass.

kind hatch
#

?paste

undone axleBOT
thick gust
#

that's not necessary.

#
                                Location destination = p.getTargetBlock(new HashSet<>(), 20).getLocation();
                                p.teleport(destination);

I came up with this now..

worldly ingot
kind hatch
thick gust
#
[03:11:55 ERROR]: Error occurred while enabling Rpg v1.0 (Is it up to date?)
java.lang.NullPointerException: null
        at de.rpg.main.Rpg.loadCommands(Rpg.java:67) ~[?:?]
        at de.rpg.main.Rpg.onEnable(Rpg.java:35) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:402) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:384) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:333) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:755) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.Bukkit.reload(Bukkit.java:525) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:651) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:637) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372-372]
Bukkit.getServer().getPluginCommand("trickster").setExecutor(new TricksterCommand(this));

🙃

#

This line of code is throwing an error

worldly ingot
#

trickster isn't defined in your plugin.yml

#

That's all

thick gust
#

oh right

#

thanks lol

#

happens

worldly ingot
#

I wonder if maybe we can throw a more explicit exception here instead of returning null

#

The amount of times I see beginners fuck this up is crazy

robust pebble
#

how do I create a world and load it

lavish robin
#

In my plugin, could I have different package that handle different things have their own listeners? for example I if I have a lobby package with its own listeners and it checks to see if it applies to that package. Or is it better to just have one listener, and have some sort of way to give that data to the package that is going to be using it?

robust pebble
#

and then teleport a certain player there

thick gust
robust pebble
worldly ingot
#

You're better off using this.getCommand() by the way

#

Does some sanity checks to ensure it's actually your plugin's command

thick gust
#

whatever

#

works the same

worldly ingot
#

Not really

kind hatch
worldly ingot
#

JavaPlugin#getCommand() calls Server#getPluginCommand() but ensures the string is lowercased, fallsback to namespaced commands if it's overridden by another plugin, and ensures that the command you get was actually registered by your plugin

thick gust
#

Teleports me exactly at the same loc as the player has already been

lavish robin
# kind hatch What? Can you please elaborate more on that?

Ok, so I have a minigame server that I am working on, where there are multiple different I guess zones that a player could be in, a lobby, or a minigame. I was thinking about making it so there was one player listener that passed down events to the code controlling the different zones (lobby or minigame) But I was wondering if instead each zone could just have it's own events registered and handle them internaly. (would make splitting it into seperate plugins easier later if I wanted to do that).

kind hatch
# thick gust Doesn't work by the way <@143004075435360256>

Well, I don't use those methods too often, but I think there's limitations to them. IIRC, #getTargetBlock() is limited to what you can reach, and #getTargetBlockExact() is unrestricted. (Obf if you are looking at the sky in the distance, you won't go anywhere.)

lavish robin
#

Could you use a raytrace?

robust pebble
#

how to force gamemode on a player

kind hatch
robust pebble
#

thanks