#help-development

1 messages · Page 1672 of 1

median anvil
#

@lost matrix it worked, thank you

lost matrix
#

He is not trying to check if a block is within a BoundingBox but get every Block within a box.

raven ore
lost matrix
#

I at least hope he doesnt check if a block is within the bounds like that

stone sinew
raven ore
#

yes i found but cancel() doesnt exist

stone sinew
#

Ah shit yeah forgot. One sec

stone sinew
raven ore
#

where ?

stone sinew
devout spoke
#

why I can take items from inventory if I set it e.setCancelled(true);
I can take only with shift click

stone sinew
white quiver
#

Oh I didn't know about those. I installed maven, what should be my next step?

eternal night
#

if you are trying to setup a spigot plugin using maven, there are a bunch of nice tutorials out there

bronze night
#

btw, how can i do that?

eternal night
#

https://www.spigotmc.org/wiki/spigot-maven/ this is a written tutorial.
https://plugins.jetbrains.com/plugin/8327-minecraft-development can create the entire project layout for a spigot plugin using maven for you

stone sinew
# devout spoke thanks

NP. If it still doesn't work can always add a delay and remove the item and reupdate the player inventory.

severe oracle
#

i have: java @EventHandler public static void onRclick(PlayerInteractEvent event) { Player player = event.getPlayer(); if (event.getAction() == Action.LEFT_CLICK_AIR && player.getInventory().getItemInMainHand().getType() == Material.AIR) { and for some reason ti sometimes triggers when i rightclick on villagers.

eternal night
#

left click air is triggered every time the client sends an animation packet for the arm swing which happens when interacting with villagers afaik

#

there is sadly no better way to trigger left click air, as the client does not communicate it :/

severe oracle
#

ok thank you

terse orbit
#

How would I add onto a PersistentDataType.LONG_ARRAY

lost matrix
eternal night
# terse orbit How would I add onto a `PersistentDataType.LONG_ARRAY`
final long[] newData = new long[]{1};
final long[] data = persistentDataContainer.get(namespacedKey, PersistentDataType.LONG_ARRAY);
final long[] updatedData = ArrayUtils.addAll(data, newData);
persistentDataContainer.set(namespacedKey, PersistentDataType.LONG_ARRAY, updatedData);
#

something around that ?

#

basic concept is to just get the array -> create a new one that contains the old one plus the added array -> store the new one

lost matrix
eternal night
#

the apache utils does too

vast sapphire
#

How do I make a kill counter

median anvil
#

is there a way to make the plugin run before all other plugins?

true perch
#

Trying to think of a good way to generate blocks from a starting point dependant on which direction the player is facing. Here's a reference picture: (0,0 being the start location). I could for sure do this without problem if it were just one direction, but I want this to work with North, South, East, and West. Any thought? https://i.imgur.com/mS6F6Ea.png

lost matrix
median anvil
#

world delete plugin, where on startup before world is generated it deletes the world file contents.

eternal oxide
#

So many doing that today

median anvil
#

i got the delete part

eternal oxide
#

did some server just do a popular game mode or something?

#

You are the 4th person today to ask how to do it

median anvil
#

Idk, but i'm remaking a very very old gamemode

true perch
lost matrix
median anvil
#

@true perch thats what im using, but its still not working

#

@lost matrix is onload an event just like onEnable?

true perch
vast sapphire
#

so set it to 1 or something?

lost matrix
eternal oxide
#

in onLoad, check Bukkit.getWorlds().isEmpty() then recursive delete all files and folders for your main world.

true perch
eternal oxide
#

You must check worlds is empty or you will attempt to delete an active world if you do a reload

floral pewter
#

Hey, I'm having some trouble with the remapped version of 1.17. I get an error where an obfuscated class is missing when running my plugin after having reobfuscated it it with specialsource.

#

Here's a section of my pom.xml:

#

And here's the error I'm getting

eternal oxide
#

SO much spam. Not read a line of it

floral pewter
#

Sorry for the spam, I realise now that I should have uploaded them as files

eternal oxide
floral pewter
#

I read the 1.17 post, which I used to add the specialsource plugin

median anvil
#

what about deleting the file after the world has been saved. unfortunately the onDisable event occurs before the world is saved, so it will delete the file and then save it again.

floral pewter
#

And that the remapped jar should be distribution ready

eternal oxide
#

You are using maven so you don;t need specialsource

floral pewter
#

But I need to reobfuscate it if I want to distribute the files legally, no?

eternal oxide
#

When choosing to use the 'Mojang Mappings', it is absolutely imperative that you are aware of the conditions attached to them as well as the Mojang EULA. These are not restrictions you can simply ignore. In particular you may only 'use the mappings for development purposes'. This means that you must only use the remapped-mojang jar for development and must remap your plugin prior to distribution. For those **not** using Maven you can download SpecialSource to help you do this here, and we encourage the creation of instructions/tools for other build systems.

floral pewter
#

I'm pretty sure I have a dependency on the deobfuscated jar file, and that the specialsource-maven-plugin reobfuscates it for distribution

#

Or have I misunderstood the post?

eternal oxide
#

It reads to me that the Maven section does it all for you

#

I have never done it so I'm just going on what I've read and others have said

floral pewter
#

Ah

#

Which makes sense, since the server doesn't use mojang mappings if I'm correct

wary harness
#

how would I check if ArrayList of Locations already contains location

#

would it be better to use hashmap for it

#

and use cordinates as key

#

or something

ivory sleet
#

Set

#

Maybe

#

(:

lost matrix
true perch
wary harness
lost matrix
ivory sleet
#

Well what are you trying to do? Tldr

lost matrix
#

For contains

wary harness
#

so I am calculating some locations adding them to lets say arraylist

bronze night
#

So i want to get the online players and check if they are above or equal to 1 and im getting this error in console and i don't know how can i fix it doe

ivory sleet
#

The set interface guarantees no duplicates, however the common implementation HashSet#contains is O(1) if the elements contained have rightfully implemented the Object#hashCode method

wary harness
#

and when u check if it contains(location)

lost matrix
wary harness
bronze night
wary harness
#

and it is not same

quasi flint
#

; 7

wary harness
#

even when it has same cordiantes

#

and when u check if list.contains(location)

ivory sleet
#

yes that’s why I asked for your intentions

wary harness
#

so will

#

that work with Set ?

lost matrix
# bronze night ye
    final Collection<? extends Player> onlinePlayerList = Bukkit.getOnlinePlayers();
    final int countOfOnlinePlayers = onlinePlayerList.size();
    if (countOfOnlinePlayers > 0) {
      // Do stuff
    }
mellow edge
#
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: pluginpack/Plugin has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes c```
wary harness
ivory sleet
mellow edge
#

how can I fix that?

lost matrix
bronze night
#

ahh

#

i saw it rn

mellow edge
#

so...

bronze night
#

the "onlinePlayerList.size()"

#

XD

#

thanks for help

lost matrix
# mellow edge so...

Either compile with an older java version or update the version that is running the server.

lost matrix
mellow edge
lost matrix
mellow edge
#

im using version 1.16

lost matrix
mellow edge
#

no

lost matrix
#

Then no idea how to change the compile src version...

wary harness
# ivory sleet Well give us the entire picture

so what I am doing is calculating some shapes and then adding there location to list
sometimes I get same cordinates because I am using Math.round
and I don't want the multiple location object with same cordiantes
and if I check if list.contains(location)
it wont work because every location is differenet object but they can have same coordinates

lost matrix
#

Ah wait i know.

mellow edge
lost matrix
lost matrix
mellow edge
#

that's good idea!

lost matrix
#

Also List#contains scales suuuper bad

sharp bough
#

does anyone have a decent amount of experience with fabric that can answer a few question?

lost matrix
worldly ingot
#

Either works though

mellow edge
#

or in eclipse I think that I must just that:

bronze night
#

btw, how can i broadcast textcomponent?

sharp bough
mellow edge
#

Java compiler

sharp bough
#

i already found the documentation

#

is it possible that you can add items?

lost matrix
sharp bough
#

im not sure what it is creating

lost matrix
#

Fabric is not targeted towards public servers but rather small, closed communities where every player

#

knows each other.

mellow edge
#

bdw why I can't paste pictures in this chat?

lost matrix
#

?verify

#

?verified

#

idk

mellow edge
#

ok I will quickly do that

lost matrix
sharp bough
#

ah

lost matrix
#

He has to go to a website. Install Fabric and then download and install each mod that is on the server.

#

Manually

mellow edge
#

I must make spigot account and than verify it?

sharp bough
lost matrix
worldly ingot
#

With Spigot you're restricted to the server. On Fabric you can manipulate both the server and the client

#

That is unless you're making a Fabric mod that should be useable on a non-Fabric server in which case you're bound to the client

sharp bough
#

and the client? thats interesting, lets say i want to create the good old emerald pick, i could make the texture, add the values to it and make it work?

#

both server and client side

worldly ingot
#

Yes, though the server would have to be a Fabric server running your mod so it recognizes and registers your pickaxe properly

sharp bough
#

and then client side shows the new pick

worldly ingot
#

Can't make an emerald pickaxe and expect to join a vanilla or Spigot server for instance

#

Yes

sharp bough
#

shit thats insnae

#

thx

worldly ingot
#

It would be a new item in the registry

#

👍

lost matrix
# sharp bough shit thats insnae

This will give you a glimpse of whats possible:
https://www.youtube.com/watch?v=jDIuWv7ROi8

Today coming at you with the least efficient cake factory ever made.
Create is a Minecraft mod for Forge 1.14.4, with 1.15 to follow. It adds a variety of very useful building tools, as well as technology based on kinetics and rotational power. It is a free-time open-source project by a bunch of Minecraft players who love the creative aspect of ...

▶ Play video
grim ice
#

@ivory sleet

#

r u chatting in a mc server rn?

bronze night
#

i have another question, so somehow i managed to create the script(with some help) that sends a message when there is 1 or more players online, every 10 minutes, and now i don't know how to register it into the main .java file

lost matrix
bronze night
#

but i didn't put any @brave glenHandler there

#

or should i ?

lost matrix
bronze night
#

like

#

wait

#

lemme try something

quaint mantle
#

hello iam about to edit the Essentials plugin tho i encountered a problem.. i want to change colors but i dont know how to do it is there any other way instead of changing the .jar file itself

lost matrix
quaint mantle
#

uu nice to know they are very messy

lost matrix
quaint mantle
#

look i just used the Java Decomplier and see the color is $6

#

but i cant copy that part

#

and insert it to my text editor

lost matrix
quaint mantle
#

yes i looked that up

quaint mantle
quaint mantle
lost matrix
bronze night
#

something went wrong

true perch
#

Does anyone know why the block at the desired location isn't being set to stone?java @EventHandler public boolean onTablePlace(BlockPlaceEvent e){ e.setCancelled(true); Location location = e.getBlockPlaced().getLocation(); generateTable(location) } public void generateTable(Location location){ location.getBlock().setType(Material.STONE); }

bronze night
#

so i did this

true perch
bronze night
#

so

#

should i add EventHandler there?

lost matrix
bronze night
#

it didn't somehow

#

XD

lost matrix
#

*If it runs once

bronze night
#

hm

lost matrix
#

Do you call this method somewhere?

bronze night
#

nope

true perch
#
public boolean generateTable(Location location, Player player){

    new BukkitRunnable() {
        @Override
        public void run() {
            cancel();
        }
    }.runTaskTimer(YuCraft.MAINPLUGIN,1,0);

    location.getBlock().setType(Material.STONE);
    return false;
}```the delay didn't help
mellow edge
#
org.bukkit.plugin.AuthorNagException: No legacy enum constant for FIRE_CHARGE. Did you forget to define a modern (1.13+) api-version in your plugin.yml?```
lost matrix
true perch
lost matrix
#

?scheduling

undone axleBOT
ivory sleet
lost matrix
quaint mantle
lost matrix
# bronze night nope

The program cant just guess what you are thinking. You need to tell the program to run your code somehow

quaint mantle
#

why i cant copy the A with the ˇ

lost matrix
mellow edge
lost matrix
#

XDD what?

paper falcon
#

you mean on cracked servers when players have to /register ?

severe oracle
#

how do i get all all players in scoreboard team ?

mellow edge
#

I think that the site for plugin.yml is a bit outdated

unreal quartz
true perch
lost matrix
unreal quartz
#

who doesn't love breaking shit

quaint mantle
lost matrix
#

What plugin? We need more information. I dont think any half decent plugin uses readable Strings for authorization.

#

I mean you can listen for the PlayerCommandPreprocessEvent and read the values from there

mellow edge
#

and also plugin now somehow load and then it stops because that message occurs: [22:58:34 ERROR]: Error occurred while enabling fireball v1.16.5 (Is it up to date?) java.lang.NullPointerException: null

severe oracle
#

how do i get all players in a scoreboard team ?

paper falcon
#

hey guys, how do I make my ItemStack public so I can use it in other classes rather than copy-pasting it?

worldly ice
#

public ItemStack itemStack?

paper falcon
worldly ice
#

you have to instantiate the itemstack to change the item

native nexus
#

Does anyone know how to get default item attributes without NMS?

grim ice
#

@true perch

#

u make a delay with

#

Bukkit.getScheduler().runTaskLater(hgawuegauweghaweiughawei0ghaiweg0);

#

if u dont know what to replace in hgawuegauweghaweiughawei0ghaiweg0 learn java

#

:D

true perch
#

I thanked the person who sent the resource after I read up about it :^)

grim ice
#

o

#

i didnt see it

#

ok

#

btw r u not using dependency injection

true perch
#

Not sure what that is.

grim ice
#

o

true perch
#

I'm currently trying to code something that copies the structure on the left, this is what I've gotten so far. https://prnt.sc/1qtz3w4

paper falcon
#

Can you please show me an example of making a public ItemStack? I googled, found many articles, but it still lead me to nowhere... @worldly ice

true perch
#

public ItemStack item = new ItemStack(Material.EMERALD);

grim ice
#

btw

#

?learnjava

undone axleBOT
paper falcon
#

that won't work, tried

true perch
paper falcon
#

use it in another class without having to copy-paste it there

true perch
#

Then make it a static reference

#

You could do public static ItemStack item = new ItemStack(Material.EMERALD);
Then do ClassName.item to get said static object.

#

Very bad practice to do that for most things, but that's one way to do it.

paper falcon
#

ok thanks, I'll try sum

mellow edge
#

why plugin doesn't load corectly?

#
[23:35:06 ERROR]: Error occurred while enabling fireball v1.16.5 (Is it up to date?)
java.lang.NullPointerException: null```
open vapor
#

how can i tell if an armor stand collides with a block?

grim ice
#

?learnjava

undone axleBOT
mellow edge
#

?

#

why did you tag me

unreal quartz
#

you're famous

stiff ember
#

hi

gaunt saffron
#

what lib/method/ressource should i do todo a url request with bearer token and json response?
idk java libs at all so please give an easy one

gaunt saffron
lost matrix
#

Only if they have gravity disabled

#

Then they teleport just fine

lost matrix
#

What version are you on?

gaunt saffron
#

i need to whitelist this website fionally...

lost matrix
#

Are the Armostands packet based or spawned via the Spigot API?

#

Then log the line right before the teleportation and see if it is even called

gaunt saffron
vagrant stratus
#

Guys, we have threads. Use them, it'll make things so much easier to keep track of

eternal oxide
#

Use teh spawn method with the consumer

mellow edge
#

how can I check if entitiy is 2 blocks away from player?

gleaming jasper
mellow edge
#

no I need that in plugin

gleaming jasper
#

you can add datapacks to servers

eternal oxide
#

Location#distanceSquared

mellow edge
gleaming jasper
#

ok

mellow edge
#

I found this: if (distanceSquared(pl.getLocation(), en.getLocation()) < as

eternal oxide
#

no, there is a method in Location

wary harness
#

is it possible to use breakNaturaly()
and check if block can be broken

ivory sleet
#

I updated ask command (:

#

?ask

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. Create a thread in case the help channel you are using is already in use!

wary harness
#

So what I am saying I am braking block which are in HashSet

#

but will it breakNaturaly() check if event is cancled

eternal oxide
#

If you want to see if other plugins are going to prevent the block break you need to fire an event so they can see your attempt

wary harness
#

does it even runs block brake event

#

so I need to call

#

BlockBrakeEvent

#

for every block

eternal oxide
#

and check the cancelled state

wary harness
#

ok thanks

#

I was thinking breakNaturaly()

#

runs event

#

when u use it with getBlock().breakNaturally(e.getPlayer().getItemInHand());

#

thanks

eternal oxide
#

You can test it but I don;t believe it does

wary harness
#

I need to grab all those block

#

and give drops to player direcly to inventory

#

so best will be to call event

#

?paste

undone axleBOT
wary harness
#

curent noob code

#

😂

remote light
#

hi how do i put that i can edit the complete tab in the basic version of bungeecord

remote light
#

I have to modify the complete Tab and put only some commands that I want

worldly ice
#

Are you trying to modify the default tab complete of a command?

remote light
#

Yep

worldly ice
#

if i remember correctly u use the tabcomplete interface

remote light
#

Ok

regal anchor
#

Hello everyone, EntityChangeBlockEvent does not seem to work with TNTPrimed and a tnt does not seem to be a FallingBlock either

#

any idea ?

eternal oxide
#

only happens just before it goes bang

crude charm
#

^

eternal oxide
#

if you are looking for when it spawns EntitySpawnEvent

crude charm
#

Just spawn it

eternal oxide
#

Its one entity. it has a small base

crude charm
#

You dont need the bedrock

crude charm
#

you cant remove that

regal anchor
left lodge
#

I'm making a plugin where I listen to BlockBreakEvent and use event.setDropItems(false) to stop items from being dropped from the block that was broken. However, this seems to also stop items from being dropped from blocks that "depend" on the block that was broken, such as torches, flowers, levers, etc. I initially thought that maybe two BlockBreakEventss were being called, but that doesn't seem to be the case. It this a bug or expected behaviour? If it's expected behaviour, how do I get around it (no hacky ways please)?

waxen plinth
#

Cancel BlockDropItemEvent

torpid matrix
#

Then

#

@thorn narwhal

golden turret
gaunt saffron
#


package com.thechemicalworkshop.com.disasterscontrol;


import java.net.HttpURLConnection;
import java.net.URL;

public class kill_on_stop {
    
    public static void main(String[] args) {

        try {

            URL url = new URL("https://mc.thechemicalworkshop.com/api/client");
            HttpURLConnection http = (HttpURLConnection)url.openConnection();
            http.setRequestProperty("Accept", "Application/vnd.pterodactyl.v1+json");
            http.setRequestProperty("Content-Type", "application/json");
            http.setRequestProperty("Authorization", "Bearer REDACTED");

            System.out.println(http.getResponseCode() + " " + http.getResponseMessage());
            http.disconnect();

        } catch (Exception e) {
            /*
             * Fail quietly.
             * No need to spam a stack trace.
             */
            System.out.println("error!");
        }
    }
}

i created this file, stuff.java
how would i use it inside main java file?
is it even correct lol

unreal quartz
#

wat

gaunt saffron
crude charm
#

uh

#

what

unreal quartz
#

by putting it in a plugin

crude charm
gaunt saffron
#

okay

#

do i need to call it from the plugin itself?

gaunt saffron
#

yeah i dropped java 8 years ago 🙄

unreal quartz
#

void doThing() {
// thing
}

onEnable {
doThing();
}

crude charm
#

?learnjava

undone axleBOT
gaunt saffron
unreal quartz
#

what you're asking isn't even a java specific question

#

it's just.. common sense

gaunt saffron
#

well i know i need to load/import it, question how

gaunt saffron
#

okay whatever can't get worse than errors

#

but takes like 1-2mins to run...

wary harness
#

so if I call manually block brake event

#

that will not brake block

gaunt saffron
crude charm
#

@timid root

timid root
#

hello

crude charm
#

hi

timid root
#

ive got to go

#

ill be back on soon

crude charm
median anvil
#

can you cancel the enderpearl teleportation event inside the onProjectileHitEvent?

#

or can you at least get a cast of the Enderpearl that caused the teleportation in the TeleportationEvent?

median anvil
#

cancel the teleportation of the enderpearl depending on the lore of the enderpearl

hexed hatch
#

what you should do is listen for the PlayerInteractEvent, and if the enderpearl meets your criteria, set the owner field to null

median anvil
#

ooo

hexed hatch
#

that's the cleanest solution really

unkempt peak
#

Yeah

median anvil
#

never thought of that. can you set the owner field in player the onProjectileLaunch event?

median anvil
#

k

unkempt peak
#

Use a persistent data container

hexed hatch
#

As long as you can get the projectile it will work

quaint mantle
#

tell me why you are using lore over PDC

hexed hatch
#

because lore is uncomplicated

unkempt peak
quaint mantle
#

its horrible and unsafe

hexed hatch
#

localized-name is a good way for identifying custom items

quaint mantle
#

yet its not

hexed hatch
#

eh

quaint mantle
#

?pdc @median anvil

median anvil
#

idk what pdc is

quaint mantle
#

learn

hexed hatch
#

pdc is better

median anvil
#

ive been using lore for everything xD

unkempt peak
#

Persistent data container

quaint mantle
#

its easy

median anvil
#

damn.

unkempt peak
#

Store data in an items json

hexed hatch
#

lore is pretty gross for item identification, especially if you're iterating through multiple lines

quaint mantle
hexed hatch
#

but for the sake of simplicity, localized names work well

#

I didn't suggest it to him forehead

unkempt peak
quaint mantle
#

you said names are good

hexed hatch
#

localized names

median anvil
#

i've been using lore cause I watch youtube and thats what they do... thanks for telling me pdc exists tho.

hexed hatch
#

That's not the display name field, it's invisible meta on the item intended for resource pack translation

median anvil
#

YES

#

lol

quaint mantle
#

hes a bullshitter who spreads bad code

hexed hatch
#

localized name =/= display name

median anvil
#

his code has worked for me so far, but then again im new to java in general so...

hexed hatch
#

yeah his practices suck

quaint mantle
#

its working code but bad code

hexed hatch
#

he's one of the ones I used in the beginning lol

unkempt peak
median anvil
#

well, ill probably rewrite my plugin the correct way after I get everything working.

quaint mantle
hexed hatch
#

lol the good ol' "I'll make it better later" manuever

#

fun fact: it never happens

worldly ice
#

true

median anvil
#

I'll try, i'm still a beginner. I'm already on my second rewrite actually.

#

each time i get further and further

#

btw the I grabbed the enderpearl and set the shooter to null but it did not work, i still teleported.

hexed hatch
#

Send your code please

#

In a code block if you know how

#

Or better yet

#

?paste

undone axleBOT
hexed hatch
#

make sure you're registering your listener

#

and when something doesn't work, put some lines that output a string right above the part that makes the change to see if it even fires

median anvil
worldly ice
#

Any errors?

hexed hatch
#

@median anvil is there a setOwner method?

#

I see you have setShooter, see if there is a setOwner method as well

median anvil
#

no

#

there isnt

hexed hatch
#

Is this listener registered?

median anvil
#

a setOwner method nor any errors

#

yes

hexed hatch
#

Put a System.out.println("ooga"); above that

worldly ice
#

ooga

hexed hatch
#

see if it's even being reached

glossy scroll
#

setShooter

#

also looked at ender pearl code

#

can confirm

#

it is setShooter

hexed hatch
#

Cool

median anvil
#

Bukkit.getConsoleSender().sendMessage("TESTING ENDERPEARL");enderPearl.setShooter(null);

#

its being reached just not doing anything.

worldly ice
#

Maybe a getShooter() after that to test if it's actually null?

#

idk

glossy scroll
#

what version of spigot are you using

median anvil
#

1.17.1 from intelij plugin

#

java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "org.bukkit.entity.EnderPearl.getShooter()" is null

worldly ice
#

hmm

median anvil
#

it is turning it null, but its still teleporting me

#

I event tried canceling the enderpearl land event, but still teleported me.

worldly ice
#

Can you confirm that you can modify the ender pearl in other ways?

#

i have no idea at this point

median anvil
#

yeah, I set it to explode when it hits the ground.

worldly ice
#

the op specifically states that setting the shooter to null didn't work

median anvil
#

it explodes, but also teleports me into the explosion

mighty vine
#

is there a post thats realy indeeph about what to learn. I know post say learn OOP learn abstract learn java öearn spigot but not deep pls @ me if you have link or can tell me deeper

mighty vine
#

what is all it

#

I need 1 to 10 step by step with sentences I can put into google

quaint mantle
#

1.Maps rarely are passed through classes

  1. Never hardcode if statements for things like quests, skills, create check objects

  2. Always create an API for your classes and allow everything to be changed

  3. Javadoc everywhere

  4. static isnt to make life easier

  5. understand OOP

  6. abstract everything

  7. understand object constants vs enums and when to use them

median anvil
#

i did it by deleting the enderpearl when it hit the ground!

mighty vine
#

thx imaginedev but I dont understand the first two. Can you show examples where its right and where its wrong thx

open vapor
#

best way to store data permanently?

worldly ice
#

In an entity?

#

or just data in general

open vapor
#

in general

worldly ice
#

Use a config file

median anvil
#

so is pdc part of nms?

#

cause i've been storing my persistent data as lore in items xD

quaint mantle
#

ye

median anvil
#

i didn't even know pdc existed. but now i'm interested

quaint mantle
#

its like easy nbt

median anvil
#

i don't think i can do nbt/nms with the spigot plugin im using in intelij cause it doesnt have the imports. I was trying to follow a tutorial on creating npcs, and I couldn't cause I dont have the nms imports.

quaint mantle
#

pdc handles it all

median anvil
#

okay.

#

@quaint mantle will persistent data be injected into the block placed from the block item in hand?

#

so if i had an itemstack of blocks with persistent data, and placed a block, would that placed block hold the data I stored in the Itemstack of that block?

quaint mantle
#

no

median anvil
#

oh.

quaint mantle
#

had to do some research

#

but it only works on certain types

#
Banner, Barrel, Beacon, Bed, Beehive, Bell, BlastFurnace, BrewingStand, Campfire, Chest, CommandBlock, Comparator, Conduit, Container, CreatureSpawner, DaylightDetector, Dispenser, Dropper, EnchantingTable, EnderChest, EndGateway, EntityBlockStorage<T>, Furnace, Hopper, Jigsaw, Jukebox, Lectern, SculkSensor, ShulkerBox, Sign, Skull, Smoker, Structure
median anvil
#

Well I was thinking chests and stuff

#

okay awesome!

quaint mantle
#

oh yeah

#

go for it 👍

median anvil
#

I wish I knew about pdc before writing thousands of lines of code depending on lore...

quaint mantle
neon kestrel
#
        PlayerInventory playerInventory = player.getInventory();
        playerInventory.clear();
        playerInventory.setExtraContents(null);
        playerInventory.setItemInMainHand(null);
        playerInventory.setItemInOffHand(null);
        playerInventory.setArmorContents(null);
        playerInventory.setStorageContents(null);
``` How do I clear the little crafting area in the player's inventory? I've managed to clear every other part of the player's inventory except for this
#

Ended up closing the inventory first then clearing it

quaint mantle
#

save contents
close
set contents

median anvil
#

can you allow crafting recipes under certain conditions/permissions?

worldly ingot
#

Yes. There's a PrepareItemCraftEvent you can use

#

To check which recipe is in the table in that event, there's a getRecipe() method

quaint mantle
#

Choco choco

median anvil
#

ty

quaint mantle
#
# Yes, the file extension is .ASS
# Cry about it.

final var name = prompt()
print('Hello', name) 

@worldly ingot Choco likes?

worldly ingot
#

I like .ass, I don't like the mangling of Java & Python

#

lol

quaint mantle
#

Sad

worldly ingot
#

What is .ass? Async script? ;p

quaint mantle
#

Assess

#

im making it

worldly ingot
#

Figured as much

quaint mantle
#

Choco Choco rate syntax

median anvil
#

with the PrepareItemCraftEvent can you check if the event.recipe is equal to a custom recipe you created?

worldly ingot
#
Recipe recipe = event.getRecipe();
if (recipe instanceof Keyed keyed && !keyed.getKey().toString().equals("yourplugin:key")) { // or equals() the NamespacedKey directly
    return; // Return if it's not your recipe
}

event.getInventory().setResult(null); // Remove it from the result under x condition
median anvil
#

@worldly ingot i have a separate class that holds my custom recipes in functions that return the recipes

quaint mantle
#

creating a new recipe everytime its called Talk

median anvil
#

its only called once on startup

quaint mantle
#

Ok

#

still though

median anvil
#

how would I access that recipe / key?

#

the instanceof Keyed keyed is what is confusing me rn.

worldly ingot
#

Java 16 feature

#

Equivalent to

Recipe recipe = event.getRecipe();
if (recipe instanceof Keyed) {
    Keyed keyed = (Keyed) recipe;
}
lavish hemlock
#

did you know: Choco likes ass?

median anvil
#

this should work right?

#

cause its not

lavish hemlock
#

it should be namespace:seed_stew

#

replace namespace with wherever it comes from, e.g. minecraft

median anvil
#

I set the namespace as the plugin I think

worldly ingot
#

getKey().equals("some string") will never be true

#

Note in my initial snippet I did getKey().toString().equals("some string")

#

NamespacedKey.equals(String) is impossible. String.equals(String) however. 5Head

median anvil
#

Amazing, thank you!

sage pine
#

Hey guys I have a question for you if you know the answer i'd really appreciate it.

My server pulls the docker container image for about 4 minutes. When it finally pulls it after 4 minutes, the server starts like normal. But what is causing the container image to be so slow?

It's a rise-2 from OVH. I have 18G allocated to the docker container, and only 14 on the actual minecraft server (4g heap)

neat trellis
#

How do I spawn particles for every player except one?

quaint mantle
neat trellis
#

ok thanks

#

i thought there might be a better way

quaint mantle
#

No

burnt current
#

Hey! quick question: I was dealing with JDBC yesterday and asked for help here in this regard. Someone helped me and gave me an example of how to create a DataSource.Then I created the following class:

public static DataSource MySQLDataSource() throws SQLException {
        MysqlDataSource dataSource = new MysqlConnectionPoolDataSource();
            File file = new File("D:\Programming\Plugins\sfspConfig.yml");
            YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
                dataSource.setServerName(yamlConfiguration.getString("host"));
                dataSource.setPortNumber(yamlConfiguration.getInt("port"));
                dataSource.setDatabaseName(yamlConfiguration.getString("database"));
                dataSource.setUser(yamlConfiguration.getString("user"));
                dataSource.setPassword(yamlConfiguration.getString("password"));

                testDataSource(dataSource);
                return dataSource;
    }

    private static void testDataSource(DataSource dataSource) throws SQLException {
        try (Connection conn = dataSource.getConnection()) {
            if(!conn.isValid(1000)) {
                throw new SQLException("Database not connected!");
            } else
                System.out.println("Database connected!");
        }
    }

However, now I don't know how to continue. Can anyone help me there?

hybrid spoke
severe oracle
#

how do i get player nbt ?

quaint mantle
#

hello is there any reason why my dynmap should not work ?

stoic ravine
#

I made two actions now, is this good enough to register if the player right cliekd an entity?

        UUID uuid = e.getPlayer().getUniqueId();
        Player p = e.getPlayer();
        Class clasS = Main.getClassManager().getClass(uuid);
        if (clasS.equals(Class.PRIEST)) {
          Entity action = e.getRightClicked();
          if ((action.equals(action) && ```
burnt current
stoic ravine
#

if ((action.equals(action.getType() == EntityType.ZOMBIE) ahhh like this, but can I do an entitytype for all entities there is?

hybrid spoke
#

you can loop over the entitytypes

hybrid spoke
stoic ravine
#

I see

vivid cave
#

How can I store PacketPlayOutMap in files efficiently?

#

actually my goal is to be able to cache again every of my PacketPlayOutMap after restarting serv

mellow edge
#

how can I make that BukkitRunnable will repeat the proces 10 seconds

#

.runTaskTimer(this, 0L, 2L);

candid galleon
#

It’s in ticks, 20 ticks = 1 second

#

2 would be 1/10 of a second

tame coral
#

So 10*20 = 200 ticks !

#

Mafs

mellow edge
candid galleon
#

If 2 is 1/10 of a second what do you think 20 is

mellow edge
#

10

candid galleon
#

1 / 20 ticks per second * 20 = Once per second

mellow edge
#

ok

#

so 200 ticks is 10 seconds if I undestand

tidal skiff
#

is there any way to get a twitch chat into minceraft with spigot

ivory sleet
ivory sleet
mellow edge
tidal skiff
#

i think i have one but i have no idea how it owrks

mellow edge
#

you can just find an example on internet

upbeat sky
#

I'm having trouble compiling my plugin. I get this error:
org.bukkit.plugin.InvalidPluginException: Cannot find main class `nl.naimverboom.aresessentials.GeneralClasses.AresEssentials'
In my plugin.yml, I have this:

What do I do to fix?

quaint mantle
#

packages lower case only

upbeat sky
#

That's not going to fix the problem I'm facing

chrome beacon
#

Well does your main class exist in that location

upbeat sky
#

It does

mellow edge
#

how to check if block is blast protected

chrome beacon
upbeat sky
paper falcon
upbeat sky
chrome beacon
#

You need the entire thing not just the ending

upbeat sky
#

You mean on the top?

chrome beacon
#

Yes

upbeat sky
#

Wait I think i found the problem

#

Alright

#

The problem was very dumb

#

if you look at the project files i forgot to wrap everything in a package

mellow edge
#

how to check if block is blast protected

grim ice
#

prob nms

#

or some hacky code

opal juniper
#

what so like if they are sneaking completely ignore it

devout spoke
#

why when I try to teleport the location I create here

                World world = plugin.getServer().getWorld(data.getString("world"));
                Location location = new Location(world, data.getInt("LocX"), data.getInt("LocY"), data.getInt("LocZ"));

its gives me an error java.lang.IllegalArgumentException: location.world
and when i try to create item there it works?

opal juniper
#

ig you could listen to the move event - check how close to the edge of a block they are and if that next block is air disable the crouch

mellow edge
#

can I make egg entity unbreackable? I mean when it colides with a block it won't break

opal juniper
#

what do you mean by break

chrome beacon
#

Eggs break when they hit a block

#

Looks like he wants to just have a bunch of eggs floating or smth

opal juniper
#

ew

#

thats gonna be laggy as hell

grim ice
opal juniper
#

well

#

it depends on how many eggs

grim ice
#

except if u have a very shitty server

mellow edge
#

I can just when player throws it get his position into 3 intagers and then when the egg breaks I can just spawn new one in the same direction

mortal hare
#

how to check if block is blast protected
@mellow edge im pretty sure Material enum class has method to check if enum block type is unbreakable

#

I could be wrong tho

maiden briar
#

Is there a way to get it higher? java.lang.IllegalArgumentException: Health must be between 0 and 20.0, but was 20.200000762939453. (attribute base value: 20.0)

summer scroll
#

So I just switched to java 16 for 1.17.1 plugin and I received a warning saying that's the class could be a Java Record, and I'm wondering If it will have the same effect like the dependency injection. Because I originally want to pass my main class to other class and I got this warning instead.

public record PlayerEvents(PersonaPlugin plugin) implements Listener {

}
#

It's like lombok tbh lol

chrome beacon
maiden briar
#

Ok so the attribute is able to have a higher value?

chrome beacon
#

Yes

#

That will give more hearts

maiden briar
#

Do I have to set baseValue?

chrome beacon
#

Believe so

maiden briar
#

Ok thx

#

And what is the max value Minecraft allows?

chrome beacon
#

Float or double max

#

Can't remember

stiff ember
chrome beacon
#

Probably float max

stiff ember
#

well yeah

#

that

#

lol

maiden briar
chrome beacon
#

Aight

#

Why do you even need higher

#

That amount is going to fill your screen

maiden briar
#

Yep true 😄

tardy delta
#

can i combine a textcomponent (clickable message) with a normal string message?

eternal oxide
#

component builder

tardy delta
#

lemme see

#

aha

summer scroll
eternal oxide
#

Thats not the line that gave the error, but it is the text you sent. Use prepared statements

#

You also definitely don't wank all those columns to be TEXT

lost matrix
#

Ok those readings are a bit weird...

unreal quartz
eternal oxide
#

no but you can for all the rest

slim kernel
#

Can I somehow delete the item after someone dropped it?

unreal quartz
#

not needed, it's a hardcoded statement to create the table

unreal quartz
lost matrix
lean gull
#

could still use some help with this

lost matrix
#

You can not cast a String to a Material. Use the method Material.matchMaterial()

vagrant edge
#

how can i obfuscate my code ?
ping me for answers

lean gull
#

i am literally on that webpage

#

it doesn't really help

lost matrix
vagrant edge
lost matrix
lean gull
#

so like this?
Material.matchMaterial(cfgn.getMaterialsConfig().getString("disableElytraMovementCheckMaterialDisabledConfig"));

summer scroll
lost matrix
slim kernel
#

I tried to delete the Item after it gets dropped but with that method I only delete Items that are already dropped and not the one that I am currently dropping. How can I delete the Item as fast as possible after someone dropped it?

Collection<Entity> list = player.getWorld().getNearbyEntities(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation(), 10, 10, 10, (entity) -> entity.getType() == EntityType.DROPPED_ITEM);
        for (Entity entity : list) {
            Item item = (Item) entity;
            if (item.getItemStack().getType() == RegisterManager.getPlayersElements().get(player.getUniqueId())) {
                item.getItemStack().setAmount(0);
                player.sendMessage("deleted");
            }
        }
lost matrix
crimson terrace
#

^

slim kernel
#

oh

#

thank you haha

crimson terrace
#

Im pretty sure you can cancel that event too in case there are items you dont want to delete...

slim kernel
crimson terrace
#

Oh well

#

Theres always if()

slim kernel
#

Yeah but I do something on left click Air and it the dropp triggers the left click air and thats the problem

crimson terrace
#

If the event is set cancelled shouldnt it not trigger that anymore?

slim kernel
crimson terrace
#

Welp, gotta figure out a workaround then. Maybe try something like a public static boolean you set false when it happens and if its false you cancel the interact event?

#

Worked for entityspawnevent

slim kernel
#

Its okay I already fixed it but thank you

trail flume
#

Ok so, how can I get what block a snowball hit in 1.8.8?

tardy delta
#

im confused

crimson terrace
#

Never worked with 1.8.8 but isnt there a projectileHitEvent or something?

trail flume
#

Yeah but I need to know what block it hit

crimson terrace
#

Event.gethitBlock or something?

trail flume
#

nope

#

theres nothing in that event to get the hit block

crimson terrace
#

Am at my phone so i cant check anything really

#

Anything in event.getProjectile?

trail flume
#

It's getEntity, and no.

#

I don't need an exact block, shall I just get the snowball's location and round that to a block?

crimson terrace
#

Maybe even use the vector it has before hitting to determine the actual block it hit...

trail flume
#

True

crimson terrace
#

Might be weird around corners tho

trail flume
#

Yeah

crimson terrace
#

Write your own getHitBlock method XD

trail flume
#

Nah I'm good ty

#

XD

crimson terrace
#

😄

candid galleon
tardy delta
#

im confused i forgot how to do it

trail flume
#
Snowball snowball = (Snowball) p.getWorld().spawnEntity(p.getLocation(), EntityType.SNOWBALL);
snowball.setVelocity(p.getLocation().getDirection().multiply(2));
```This isn't going to work is it.
#

The snowball will instantly destroy right?

grim ice
#

WHY R U CASTING

#

wait nvm

trail flume
#

XD

candid galleon
trail flume
candid galleon
#

Well, did it work?

trail flume
#

Sometimes

#

So I wondered if I'd done something wrong or that was expected

candid galleon
#

as far as I know that should work

trail flume
#

No because it spawns on the player so instantly destroys, adding the players direction to the spawn location fixes that.

lean gull
#

anyone know why i can't use this in another class?

    public static ItemStack createItem(String name, Material mat, List<String> lore, int cmd) {
        ItemStack item = new ItemStack(mat,1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(name);
        meta.setCustomModelData(cmd);
        meta.setLore(lore);
        item.setItemMeta(meta);
        return item;
    }``` i could before but i did some stuff and for some reason now i can't
#

nvm

#

it just doesn't suggest it

severe oracle
#

what is wrong herejava public static void brodcastToTeam(Team team, String message) { Player LoopingPlayer = null; for(int i = 0; i <= playersList.size(); i++) { LoopingPlayer = playersList.get(i); if(team.getPlayers().contains(LoopingPlayer)) { LoopingPlayer.sendMessage(message); } } return; } ?

olive badger
eager hinge
#

what error are you getting?

#

is team.getPlayers() a List<Player>?

severe oracle
#

how can i send error ?

eager hinge
#

it it is, then you can simply do to send to all team members

for(Player TeamMember : team.getPlayers()) TeamMember.sendMessage(message)
severe oracle
#

it doesen't let me upload a filr

eager hinge
#

just copy last 5 lines there should be the error message

severe oracle
#

this ? at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1220) ~[patched_1.16.5.jar:git-Paper-787] at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1134) ~[patched_1.16.5.jar:git-Paper-787] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-787] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]

severe oracle
eager hinge
eager hinge
severe oracle
#

i can't find "Caused by:"

#

well i saw that : [17:03:47 ERROR]: Could not pass event BlockBreakEvent to bedwars v1.0

eager hinge
#

Found a random error online...

The errors usually look like this

[12:37:14 ERROR]: Could not pass event PlayerInteractEvent to hub v1.0
org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:226) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.PlayerInteractManager.interact(PlayerInteractManager.java:463) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:724) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:50) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:80) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        at java.base/java.lang.Thread.run(Thread.java:832) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.hasItemMeta()" because the return value of "org.bukkit.event.player.PlayerInteractEvent.getItem()" is null
        at me.Items.Interact.onInteract(Interact.java:15) ~[?:?]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[?:?]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot-18.jar:git-Spigot-c3c767f-33d5de3]
        ... 16 more
#

you can see the two parts, first one is the exception and a stack trace and the second one is the error message

severe oracle
#

the code you send: it returns
Required type:
OfflinePlayer
Provided:
Player

tardy delta
#

null

eager hinge
severe oracle
#

for(Player/*not offlien player*/ TeamMember : team.getPlayers())

eager hinge
#

what is the return type for team.getPlayers()

severe oracle
#

Set<offline player>

eager hinge
#

Why are the team members offline players? Can you even send a message to offline player?

severe oracle
#

i don't think so

#

also i am realy new to java

#

and i got it to work with:java public static void brodcastToTeam(Team team, String message) { Player LoopingPlayer = null; for(int i = 0; i < playersList.size(); i++) { if(team.getPlayers().contains(playersList.get(i))) { playersList.get(i).sendMessage(message); } } return; }

eager hinge
severe oracle
#

other versions ?

eager hinge
#

but i don't understand why are you using OfflinePlayer. and how can you call the sendMessage method on an Offline Player. That one doesn't exist i believe

severe oracle
#

well i didn't know about for-each as i don't think C has that

ivory sleet
#

it’s actually a while loop when compiled

#

But yeah syntactic sugar

severe oracle
#

thank you for the help

#

the code works if i do:java for(OfflinePlayer TeamMember : team.getPlayers()) { TeamMember.getPlayer().sendMessage(message); }

atomic gyro
#

Hey there guys. I've been getting a bunch of differing results when trying to get where a player is looking, and can't really seem to make any of them work. Any tips?

#

I more or less want to get the entity or block a player is looking at, whichever comes first.

severe oracle
#

do you want to know what block he is looking at ?

#

or just direction ?

atomic gyro
#

Just what entity they're looking at

limpid veldt
#

Is there a better way than this to convert enchantment names to their "pretty" names such as DAMAGE_ALL to Sharpness?
Checked the javadocs and the .getName() method just returns the namespaced name.

https://bukkit.org/threads/getting-enchantment-name-level-from-item-to-string.170737/

eager hinge
atomic gyro
craggy cypress
#

Is there a way to check if a sound is allready playing? (1.12.2)
I looked into the docs, but i can only find things like playSound() and stopSound()

rapid meteor
#

Can someone show me a quick plugin.yml file like just a command.

#

Or something.

#

I have problems with it.

#

And I wanna know if you guys have the solution for my problem.

eager hinge
rapid meteor
#

what about the command name.

eager hinge
# limpid veldt Is there a better way than this to convert enchantment names to their "pretty" n...

I believe that is done just on the client side as you can change the language in the settings.

found this:
https://www.spigotmc.org/threads/looking-for-the-in-game-enchant-names.290133/
Essentials plugin do that too. The last message also contains a code with the finished thing. You can just copy that and add some new enchanments added since 2017

limpid veldt
#

oof

#

basically just a switch statement

rapid meteor
#

Can anyone please write me a quick plugin.yml with 1 command.

#

Please?

limpid veldt
#

thanks anyways tho

atomic gyro
#

I'm having some issues trying to use the RayTraceResult, if anybody can help me with how it works.

eager hinge
# limpid veldt basically just a switch statement

yeah, but you can do different methods too,
Essentials apparently does it with a Map<String, Enchantment> and it's all coded in a file
But you could also just load that from a text or config file

limpid veldt
# rapid meteor Can anyone please write me a quick plugin.yml with 1 command.
version: version
main: main of your class. com.dublindevil.dubshop.DubShop
api-version: 1.17
prefix: log prefix like CoolPlugin or DS or smtn
depend: [ ] plugins to depend on
authors: [ your name here ]
description: desc of your plugin

commands:
  createshop:
    permission-message: You do not have permission to execute this command
    permission: dubshop.createshop
    description: Create Sign Shops
    aliases: setshop
    usage: /createshop <price> <quantity> [Warp Name]```
#

so just import the essX library and get the enchs? that seems like a pretty good option tbh

eager hinge
atomic gyro
#

ohhh, once I run that I should run the result?

eager hinge
#

that method returns the result and you can getHitEntity()

rapid meteor
#

Like commands:HelloWorld:usage </command>?

atomic gyro
limpid veldt
#

like it shows an example command of createshop there

#

/createshop

#

the usage is just what is shown when the commandexecutor returns false

eager hinge
# atomic gyro Oh, so like this?

do something like
Player.getLocation().getWorld().rayTraceEntities(Player.getLocation(), Player.getEyeLocation().getDirection(), 10)

rapid meteor
limpid veldt
#

the plugin.yml in a plugin declares the command, you then need to create an executor for it in the main

atomic gyro
limpid veldt
#

the executor class is called when the command is executed

rapid meteor
#

Like if I were to type /hello

#

How do I make that valid?

#

So it says Hello Again!

#

I know how to do it in Java.

limpid veldt
#

you need a lot more than just a yml to do anything lol

rapid meteor
#

I know how to create the command.

#

But I don't know how to set a "prefix" for it.

#

Like so it's valid typing /hello

eager hinge
rapid meteor
#

And it would return an result.

rapid meteor
#

dubz88?

limpid veldt
# rapid meteor And it would return an result.

in the onEnable put this to declare the HelloCommand class as the one that handles /hello
this.getCommand("hello").setExecutor(new HelloCommand());

then make a class called HelloCommand and make it implement the CommandExecutor


    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
      sender.sendMessage("hello");
      return true;
    }
}
rapid meteor
#

I saw an tutorial.

limpid veldt
#

there are several ways to do it

rapid meteor
#

An it said something like command:
HelloWorld:
usage: </command>

limpid veldt
rapid meteor
#

Ohhhhhhh

#

Know I kinda get it.

atomic gyro
#

I got the code to run, but the .getHitEntity() is returning null despite looking at an entity.

#

Safe to say I'm looking at one.

#
        Entity LookingAt = Result.getHitEntity();
        
        if(p.hasPermission("laserEyes.use")){
            if(!(LookingAt == null)) {
                p.sendMessage("Target " + LookingAt + " removed.");
                LookingAt.remove();
                return true;
            } else {
                p.sendMessage("Target is unable to be removed.");
                return true;
            }
        } else {
            p.sendMessage("You do not have permission to execute this command!");
        }
        return false;```
#

this is the code that is acting up

eager hinge
minor garnet
#

@atomic gyrotry p.getEyeLocation() else p.getLocation

atomic gyro
#

It was the distance that was the issue.

#

Had to ram into the mob to remove them.

#

Is the distance in Pixels or 1 = .1 blocks?

eager hinge
#

that might not work though 😄

atomic gyro
#

Oh yeah, as long as you can see it it should work.

#

didn't work, it has to be finite. I guess 99999 will cover it.

spiral bramble
#

I'm going to develop a custom plugin for my 1.17.1 server, do I need to use J16?

eager hinge
atomic gyro
#

I tried 100, and Double.MAX_VALUE.

hybrid spoke
atomic gyro
#

Trying to set it so that an entity I'm looking at while I run the command is removed.

hybrid spoke
#

and for what the double?

atomic gyro
#

For some reason, the double value on
RayTraceResult Result = p.getLocation().getWorld().rayTraceEntities(p.getLocation(), p.getEyeLocation().getDirection(), 10);
Isn't working

#

10 worked before, and now is no longer working.

lost matrix
atomic gyro
lost matrix
#

Try starting the ray trace from the players head and not his feet

quaint mantle
#

Anyone make own plugins for bedwars

#

Pls

stone sinew
lost matrix
hybrid spoke
undone axleBOT
atomic gyro
hybrid spoke
quaint mantle
#

Anyone can devlop @stone sinew

#

Plugin

atomic gyro
#

Changed it to start from my head, removed myself from game.

stone sinew
quaint mantle
#

Ok

lost matrix
atomic gyro
#

I'll change it up next time I make a plugin I guess.

#

How do I avoid removing myself from the game?

lost matrix
hybrid spoke
atomic gyro
lost matrix
# atomic gyro How would I input a predicate? I'm pretty rusty on my implementation.
    final World world = player.getWorld();
    final Location start = player.getEyeLocation();
    final Vector direction = start.getDirection();
    final double distance = 10.0;
    final Predicate<Entity> filter = (hit) -> !hit.equals(player);
    final RayTraceResult result = world.rayTraceEntities(start, direction, distance, filter);

You might also get away with

    final Predicate<Entity> filter = (hit) -> hit != player;
hybrid spoke
#

final final final final final

lost matrix
atomic gyro
#

What would (hit) be?

lost matrix
#

hit is the entity that is being hit. This is called a lambda expression.
It takes an entity and returns a boolean (Predicates are defined like that)

atomic gyro
#

so (hit) is the same as .getHitEntity()?

#

how can you call it before the method finishes?

grim ice
lost matrix
# atomic gyro What would (hit) be?

You can not call this method yourself. This is a method that you construct. It gets called internally for every entity that is hit.
If the method you passed returns false then the hit entity gets ignored and just proceeds. Its like a filter for when to stop the ray trace.

atomic gyro
#

i am thoroughly confused because this is glowing red like the sun in my IDE and theres no bukkit imports to fix it

lost matrix
#
  final RayTraceResult Result = world.rayTraceEntities(start, direction, 10, this::isViableEntity);
  ...

  private boolean isViableEntity(final Entity entity) {
    // Check if entity is viable
    return true; // Or false
  }

You can also define them like this.
Its basically just a delegate method you pass.

atomic gyro
#

1.8 / 1.17.1

lost matrix
#

Show your code

#

Also use Java 16 for 1.17.1

atomic gyro
#
RayTraceResult Result = p.getLocation().getWorld().rayTraceEntities(p.getEyeLocation(), p.getEyeLocation().getDirection(), 10, filter);
Entity LookingAt = Result.getHitEntity();```
#

oh jeez thats messy

#

isnt that messy on my side, sorry

lost matrix
rapid meteor
#

Can anyone tell me why my server logs out a message saying my permissions.yml is empty?

tardy delta
#

is there a difference between ```java
new Gui().open();

and

Gui obj = new Gui();
obj.open();

rapid meteor
#

Can anyone tell me why my server logs out a message saying my permissions.yml is empty?

atomic gyro
eager hinge
hybrid spoke
tardy delta
#

ah not

#

ofc

rapid meteor
#

Can anyone tell me why my server logs out a message saying my permissions.yml is empty?

tardy delta
#

thats normal

hybrid spoke
grim ice
#

how

rapid meteor
#

Cause my plugin won’t come on then

grim ice
#

they both won't stop ur code from working in most cases but they should be used

tardy delta
#

oh

#

use vault?

hybrid spoke
grim ice
#

well

#

explain it at least lol

hybrid spoke
#

private is important. final is too, but not for local vars.

grim ice
#

hmm

atomic gyro
#

For some reason, p.getWorld() doesn't work.

hybrid spoke
#

private is used to have something "class-only". important for encapsulation. final is used to declare something as "will not change anymore" what is not necressary for local vars in most cases.

tardy delta
atomic gyro
#

Still doesn't work.

tardy delta
#

what does it say

atomic gyro
#

It's saying there's a type mismatch and that it can't convert org.bukkit.World to the MC version of .world.

#

Type mismatch: cannot convert from org.bukkit.World to net.minecraft.world.level.World

tardy delta
#

are you using org.bukkit.World?

atomic gyro
#

Now, how do I get rayTraceEntities to stop seeing my Predicate as a double?

tardy delta
violet depot
#

I want to cancel the scheduled task or delayed task 30 sec or 600ticks when player mount on entity but i am not sure how to do it

tardy delta
#

start in in the player mount event or something?

eager hinge
#

300 ticks isn't 30 seconds

violet depot
eager hinge
#

you need to create a global variable for the taskID, create the task, save the id of it to the variable. And on PlayerMountEntityEvent Cancel Task with that ID
Also check if it's been 30 seconds, and don't do it. Clear for next time.

You could put the taskIDs to a HashMap. so each player can do that at the same time

tardy delta
#

Bukkit.cancellTask()

#

biem

#

ah shit no

violet depot
tardy delta
#

Bukkit.getScheduler().cancelTask(pid);

atomic gyro
#

can someone tell me why this doesn't work?

#

It's saying result can't be resolved.

opal epoch
#

Is there way to read in .jar files and use them as addons for the main plugin ?

ivory sleet
violet depot
atomic gyro
grim ice
#

@atomic gyro

tardy delta
grim ice
#

do you understand what smile wrote for you

#

if you don't

#

?learnjava

undone axleBOT
grim ice
#

if you don't understand what conclure said

atomic gyro
#

I understand what he wrote, not how to implement it.

grim ice
atomic gyro
#

I understand what scope is, just not where he was referring to it.

#

I'm not gonna claim I know java well but I understand it enough.

grim ice
#

you don't seem to

vague oracle
#

Damn

ivory sleet
#

OkaKnight thing is

opal epoch
# tardy delta dependency

I created an abstract class..
i want that other developers who are not able to see my code write addons wich depends on my abstract class...

grim ice
#

what conclure said is 10 minutes of java

ivory sleet
#

A variable only lives inside the
{

}
It’s declared in usually

ivory sleet
#

if you have something like this:
{
Object result;
}
result.method();
at line 4 variable result becomes unreachable

tardy delta
#

is you assume other devs dont use a decompiler then they cant read it

ivory sleet
#

So a good way to handle it is to move the result.method() part to line 3, whilst } comes at lines 4 instead

lean gull
#

can someone help? i got an error
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.file.FileConfiguration.getString(String)" because the return value of "ConfigManager.getMaterialsConfig()" is null

    public FileConfiguration getMaterialsConfig() {
        return materials;
    }```
#

tell me what more code u need btw

opal epoch
tardy delta
#

smh how do i do a word with a line through

grim ice
#

send the code

#

pls

#

the "org.bukkit.configuration.file.FileConfiguration.getString(String)

#

show us the getString

#

ill fix it for you

lean gull
#

Material mat = Material.matchMaterial(cfgn.getMaterialsConfig().getString(name + "ConfigEnabled"));

grim ice
#

well not exactly

#

but the npe will stop

ivory sleet
#

The problem is inside the ConfigManager and another class that depends on it tho 2Hex

grim ice
#

Material mat = Material.matchMaterial(cfgn.getMaterialsConfig().getString(name + "ConfigEnabled", ""));