#help-development

1 messages · Page 1564 of 1

somber hull
#

holy shit

#

i put command

#

not commands in my plugin.yml

#

you were wrong

ionic reef
#

gheez ok mate

#

wt ur doing still isnt a conventional way to do it

somber hull
#

I mean

#

it seems better, since its out of the way, and not adding junk to your onenable

#

but its preference

granite stirrup
#
class B{public static void main(String[]a){for(int i=99;i>=0;i--){System.out.println((((i==0?" No more "+"bottles ":""+(i==1?"- bottle ":"- bottles ")))+"of beer on the wall,"+(i==0?" no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.":"- bottle"+(i!=1?"s ":" ")+"of beer.\nTake one down and pass it around,"+(i-1==0?" no more ":"0 ")+(i-1==1?"bottle ":"bottles ")+"of beer on the wall.\n")).replace("0"," "+(i-1)).replace("-"," "+i).substring(1));}}}``` anyone know how to make this shorter?
proud basin
#

regex maybe

granite stirrup
#

it is regex

#

lmao

#

well not regex

somber hull
#

getting strnage project error...

drowsy helm
#

is the aim to be 1 line?

granite stirrup
#

but .replace can take regex

granite stirrup
drowsy helm
#
public static void main(String[]a){for(int i=99;i>=0;i--){System.out.println(((i==0?" No more bottles ":"- bottle! ")+"of beer on the wall,"+(i==0?" no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.":" - bottle! "+"of beer.\nTake one down and pass it around,"+(i-1==0?" no more ":" $ ")+"bottle@ of beer on the wall.\n")).replace("-",""+i).replace("$",""+(i-1)).replace("@",i-1==1?"":"s").replace("!",i==1?"":"s"));}}```
#

bout 10 chars shorter lol

#

could probs cut down even more buy grouping common words

quaint mantle
#

sadly, mine doesn't work 😦

#

still error only on line 43 3.2.4

half breach
sand rune
#

Guys, How to set A Permission for a Player , and Set him a Custom NickName

quasi flint
lament bronze
#

you probably put the wrong command

#

make sure your command is also defined in the plugin.yml file

granite stirrup
#

i wrote this interpreter from scratch

quaint mantle
#

how to make gui

granite stirrup
quaint mantle
#

no shit

#

how

granite stirrup
#

Bukkit.createInventory

#

?jd

quaint mantle
#

no

granite stirrup
#

yes

urban hedge
#

Does anyone know how I can get player Nicks to appear above their head after using /nick? It appears in chat and tab but not above their head? ( Note : Ranks do show, just not nicks )

granite stirrup
#

player.openInventory(yourInventory);

opal juniper
urban hedge
crude hound
#

hello, I have a problem : when I send a message to a player all § are replaced by an  so how can I solve this (I pick this message from a JSON file encoded in UTF-8)

granite stirrup
#

try using &

crude hound
#

k

#

I will just try something

#

the thing I just tryed worked, thx!

eternal oxide
#

That means your file, or how you are saving/loading is not UTF-8

granite stirrup
#

@eternal oxide im feeling good since i made a BrainFuck Interpreter

#

lol

maiden briar
#

If I want to download a plugin from spigotmc.org, I can do https://www.spigotmc.org/resources/<resource>/download?version=<id>, but I don't know how to translate versions to version id's

keen kelp
#

Why does spawning a particle at a Location fine but teleporting a Player to the same location variable puts them at a weird place

maiden briar
keen kelp
#
        Location loc = user.getEyeLocation();
        Vector dir = loc.getDirection();

        RayTraceResult result = user.getWorld().rayTraceBlocks(loc, dir, dist, FluidCollisionMode.NEVER, false);

        Location end;
        if(result != null) {
            end = result.getHitBlock().getRelative(result.getHitBlockFace(),1).getLocation();
        }
        else {
            end = loc.clone().add(dir.multiply(dist));
        }

        user.teleport(end.toCenterLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);  //This doesn't work
        user.getWorld().spawnParticle(Particle.FLAME,end.toCenterLocation(),0);   // This does
opal juniper
#

Still going??? Lmao

#

Is the issue the teleport don’t work

keen kelp
#

No

#

It teleports to a weird location

#

if I do this
user.getWorld().spawnParticle(Particle.FLAME,end,0);

#

THe particle spawns at the right location

#

But if I put user.teleport before that

#

or after

#

It goes to a strange location

opal juniper
#

Hmmm, weird

keen kelp
#

Yeah

quaint mantle
#

Hello is there any item drop event? (But not PlayerItemDropEvent , Entity... BlockDrop..)

keen kelp
#

Like when player q out an item?

quaint mantle
#

nopp

quaint mantle
#

okay!

quaint mantle
keen kelp
#

That's blockDrop

opal juniper
#

^^

quaint mantle
#

nop it doesn't detect

#

only detect one that I broke

opal juniper
#

I looked and there is not a superclass u can use

quaint mantle
#

Hmmmmmmmmm

#

sad

#

should I use packet?

#

but can we make replace item with packet?

opal juniper
#

There must be an event listener for it

keen kelp
#

Well

#

if you use paper

#

There's BlockDestroyEvent

quaint mantle
#

oh

#

I'm using my own

#

lets take look at paper patch

keen kelp
#

gl

quaint mantle
#

HMmmmm

#

I found blockdestory event

#

But I don't know where to run this event.

#

xD

opal juniper
#

Look when it gets run

quaint mantle
#

how to look that?

opal juniper
#

If not open a jira issue I guess

quaint mantle
eternal oxide
#

You don;t run events normally, you listen for them

quaint mantle
#

manager.callEvent(new BlockDestoryEvent)

quaint mantle
eternal oxide
#

using paper or not makes no sense

vocal mirage
#

Hi!
Is there any way to know if a block has already been destroyed ?

Thanks

quaint mantle
#

nvm

quaint mantle
#

in specific location?

vocal mirage
# quaint mantle wdym?

to make a jobs plugin, to prevent players to break, place forever to cheat with exp system

quaint mantle
#

Then use PersistantDataContainer 😄

vocal mirage
#

i'm going to look at that

#

thanks

quaint mantle
#

I high recommanded you looking codedred's tutorial

#

np

#

I learned that from that video

opal juniper
#

?pdc

opal juniper
#

Or that

vocal mirage
eternal oxide
vocal mirage
#

@eternal oxide

eternal oxide
#

?

#

ah

#

Not very clear

#

What block are they placing/breaking to get XP?

#

You should not give exp for breaking blocks that return themselves, like sand, dirt, gravel

vocal mirage
#

Well... my server has an xp server.
To make it simple, when you break a block, you win xp. When you have more than 1500 Xp, you're level 2.
The problem is that if you find a iron ore, and that you break and replace the block forever, you're winning XP with the same block.. so you're cheating with XP system.
And i try to prevent that

eternal oxide
#

Your simplest method would to be to make those blocks drop iron instead of ore

#

or, you could set a flag on those blocks once mined and prevent them being placed

#

the simplest though is to have all ores drop ingots instead of ores

vocal mirage
#

?

eternal oxide
#

coal doesn;t drop a block, it drops coal

#

as you are on 1.12 you have no PDC, so you are either going to have to use NBTAPI or go the drop ingots route

vocal mirage
#

yep.. but i'm not talking about xp, i say that if you make drop ingots instead of ores with iron, gold... coal wouldn't have any utility and i don't wan't to do that

eternal oxide
#

coal give exp when broken

vocal mirage
#

yes... but it causes problems with iron or gold for ex.

maiden briar
#

How do I get Server returned HTTP response code: 503 for URL: https://spigotmc.org/... if I don't use this in my program? I tried with search in IntelliJ to find this url, but I can't find it

eternal oxide
#

if you set an NBT tag on the ItemStracks as they drop you can then check for those tags when they try to place a block

vocal mirage
smoky oak
#

as far as i know yes

#

the data on players gets erased if the server stops though

eternal oxide
smoky oak
#

on another note why does this not send anything?

Set<String> mb = configuration.getConfigurationSection("").getKeys(false);
//Also tried configuration.getKeys(false);
//Same result.
//The config DOES contain keys and values
sender.sendMessage(mb.toArray(new String[mb.size()]));```
eternal oxide
#

don;t getConfigurationSection("")

#

just getKeys

smoky oak
#

same result

eternal oxide
#

is there anything in your configuration?

smoky oak
#

yes

eternal oxide
#

Yeah, not going to be able to help with just that info

keen kelp
#

Can i raytrace with a player hitbox?

#

Instead of like a small ray

smoky oak
#

because this works:
configuration.getStringList("keys");

eternal oxide
keen kelp
#

But then it would be 2x2 right

#

I want it to be 1x2

smoky oak
#

get player bounding box

#

trace from that thigns edges

eternal oxide
#

it is a ray, it expands in both axis, its a radius

keen kelp
#

yeah...

maiden briar
#

I get this error Server returned HTTP response code: 503 for URL: https://spigotmc.org/resources/85346/download?version=407160 while I am trying to download from this url: fileDownloader.downloadAndUnzip("https://api.spiget.org/v2/resources/85346/versions/" + versionID + "/download", new File("TvheeAPI-" + versionNumber), download.getName());, as the stacktrace prints, this is the line with the problem

maiden briar
#

Yes I know, but I am downloading from another url

chrome beacon
#

You can't automate file download from spigot

maiden briar
#

I literary changed it, but the program still downloads files

chrome beacon
#

Spiget is just a wrapper for spigotmc

maiden briar
#

And my new System.out prints will print, but this won't change?

#

Ik

chrome beacon
#

You need to host the file yourself

maiden briar
#

No because I can download it form spiget, but the problem is that I get an error from an url I am not downloading from

chrome beacon
#

Spiget probably redirects

#

Now you need to host the jar yourself

maiden briar
#

No they don't, I have tried in my browser

chrome beacon
#

My guy please just listen

maiden briar
#

Try yourself downloading from this url https://api.spiget.org/v2/resources/85346/versions/364426/download

#

Just an example btw

chrome beacon
#

You cannot automate the download from spigotmc

maiden briar
#
final ReadableByteChannel channel;

connection = (HttpURLConnection) new URL("https://api.spiget.org/v2/resources/" + resourceId + "/download").openConnection();
connection.setRequestProperty("User-Agent", TvheeAPIPlugin.getInstance().getDescription().getPluginName());
channel = Channels.newChannel(connection.getInputStream());

final String path = DebugMessage.class.getProtectionDomain().getCodeSource().getLocation().getPath();
final String decodedPath = URLDecoder.decode(path, StandardCharsets.UTF_8);
final CustomFile thisJarFile = new CustomFile(decodedPath);
final CustomFile destination = new CustomFile(thisJarFile.getParentFile(), TvheeAPIPlugin.getInstance().getDescription().getPluginName() + " V" + newVersion + ".jar");
final FileOutputStream output = new FileOutputStream(destination);

output.getChannel().transferFrom(channel, 0, Long.MAX_VALUE);
output.flush();
output.close();

And why does this code success then?

chrome beacon
#

If it works then why are you here

maiden briar
#

Because the error sais I am using another URL

chrome beacon
#

I'm aware

#

Open developer tools and see if spiget redirects you

maiden briar
#

I never used https://spigotmc.org/resources/85346/download?version=407160 anywhere in my program

maiden briar
#

And how?

chrome beacon
#

F12

maiden briar
#

Ah I will see

chrome beacon
#

I cannot check because my school disabled it

maiden briar
#

I can't see the download link, it just downloads if I click on F12

vocal mirage
#

?

maiden briar
#

https://www.redirect-checker.org/index.php sais

Result
https://api.spiget.org/v2/resources/85346/versions/364426/download
302 Found
https://spigotmc.org/resources/85346/download?version=364426
503 Service Temporarily Unavailable
eternal oxide
#

you add the tag to any broken block (ItemStack) you don't want them to place again. Then in the block place event you check for the tag, if you find it, cancel the event

chrome beacon
#

Now you're going to have to upload the jar yourself

#

You can use github for this

maiden briar
#

Yes I am using it already

#

But I didn't upload until version 1.6

#

But what will the url be then?

vocal mirage
eternal oxide
#

I already told you

#

I'm not teaching you Java

vocal mirage
ivory sleet
#

?learnjava fingerguns

undone axleBOT
smoky oak
#

Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_17_R1.CraftOfflinePlayer cannot be cast to class org.bukkit.entity.Player (org.bukkit.craftbukkit.v1_17_R1.CraftOfflinePlayer and org.bukkit.entity.Player are in unnamed module of loader 'app')

Player p1 = (Player) Bukkit.getOfflinePlayer(player);```

SINCE WHEN?!
ivory sleet
#

Just like all Animals aren’t Pigs

smoky oak
#

it is a player

ivory sleet
#

OfflinePlayer is not a Player necessarily

#

A Player will always be an OfflinePlayer

#

Not the other way around

chrome beacon
#

Use isOnline on the offline player and then use getPlayer

vocal mirage
ivory sleet
#

Same honestly, only so much I still have to learn

chrome beacon
#

Or if you know already that the player is online use Bukkit.getPlayer instead of getOfflinePlayer

smoky oak
#

question

#

if that does not work

#

how do you manipulate offline players

chrome beacon
#

You don't

ivory sleet
#

Manipulate in terms of?

chrome beacon
#

If you really need to you will have to modify their player data file

smoky oak
#

i see

chrome beacon
#

The server does not keep every player in ram. Only the ones that are online

smoky oak
#

well its not that important

ivory sleet
#

You can manipulate offline players statistics if that’s what you want to do

dusk yarrow
smoky oak
#

eh fair enough its just annoying right now

#

i just seemed to remember that that code worked before

#

so im a bit pissed

#

as in

#

it fails if i give it my name

waxen plaza
#

I tried using my plugin on other version then 1.17 and it doesn't work at all, the console says it's loaded but commands don't work and I get some other error... What do I need to do?

eternal oxide
#

read your latest.log for errors

waxen plaza
#

it's some sqlite database errors, but that doesn't have anything to do with my commands not working at all

eternal oxide
#

What api version did you set in your plugin.yml?

waxen plaza
#

when testing 1.8.8 I set 1.8.8, I also changed it in the pom.xml and I used java 8 for compiling

eternal oxide
#

api version is only supported 1.13+

#

I think 1.13

waxen plaza
#

really?

eternal oxide
#

anything below that is ignored

waxen plaza
#

but does the plugin also work in 1.8?

eternal oxide
#

depends on your plugin

waxen plaza
#

right

granite stirrup
waxen plaza
#

Does it matter if I use java 8 or 16?

eternal oxide
#

no

waxen plaza
#

oh ok

onyx shale
#

well..

eternal oxide
#

so long as you set teh version to build for

onyx shale
#

afaik 1.8 is not able to use java 16

granite stirrup
eternal oxide
#

just set the target version and you should be good

granite stirrup
#

There's a option and for some reason on 1.8 If you turn it off it lets me use java 11 on it probs will work with java 16 too but I haven't tried yet

waxen plaza
#

I'm trying to build now and test

#

?paste

undone axleBOT
waxen plaza
eternal oxide
#

1.13 not 1.13.2

smoky oak
#

u got a caused by message accompanying that?

#

@waxen plaza

eternal oxide
#

its his api version thats wrong

smoky oak
#

wait

#

that could be my issue too

waxen plaza
#

do I change it both in plugin yml and pom xml?

eternal oxide
#

your plugin yml needs 1.13

#

it only accepts major version

waxen plaza
#

ok

midnight galleon
#

Would there be any way to make a gui that looks like the creative inventory and be openable in other gamemodes

#

Basically open the creative inventory in survival with custom listeners

opal juniper
#

so i need to make an entity which can be flying. i would like to be able to make it fly from point a to point b without flying through stuff and through unloaded chunks. what is the best way to do this?

#

there is no easy way as far as i know to make an ai for ideally an armour stand as then i could put blocks on the head to make a custom model

waxen plaza
eternal oxide
#

fix the errors

waxen plaza
#

The erros don't appear if I use 1.17 server

opal juniper
eternal oxide
shrewd solstice
#

how can i create an Itemstack and the Itemstack is the item on the head of my armorstand???

unreal quartz
#

new ItemStack?

shrewd solstice
#

ok but i dont know to set the item stack for the item the armor stand have on head

unreal quartz
#

cast your entity to ArmorStand

fervent chasm
#

Hey, is there a method to change a citizen's npc's gamemode?

unreal quartz
#

you can access its methods from there

shrewd solstice
#

like this????? : Entity ArmorStand = e.getEntity().getPassengers().get(0);

split egret
#

(ArmorStand) e.getEntity().getPassengers().get(0);

undone axleBOT
split egret
#

I hate americans

#

making me spell Amour amor

#

and Colour color

unreal quartz
#

ikr

split egret
#

Screw you guys

#

Messes me up every time

unreal quartz
#

still write my source code comments and documentation in british english out of pure spite

fervent chasm
#

pls helpp

split egret
#

🚫 🥄

unreal quartz
#

i am sure if you simply searched up the citizens docs you will find your answer there

split egret
#

I've only just started with Java, but JavaDoc and Gradle kinda lit

#

It's no pip

fervent chasm
#

cant find it

unreal quartz
#

you have to be joking right

fervent chasm
#

idk

split egret
unreal quartz
split egret
#

I found it in like 15 seconds

fervent chasm
#

I mean, I can't find a method to change the gamemode in the documentation

unreal quartz
#

whoops

#

NPC#setProtected

fervent chasm
#

will try it out

quaint mantle
unreal quartz
#

at me.pixelwarp.ducksmp.Enchantments.<clinit>(Enchantments.java:11) ~[?:?]

quaint mantle
#
private static Enchantment InstantKill = new InstantKillEnchantment(new NamespacedKey(plugin, "instant_kill_enchantment"));
unreal quartz
#

plugin is null

chrome beacon
#

If you have coded before that error isn't hard to figure out

quaint mantle
#

i know

unreal quartz
#

then why ask

quaint mantle
#

i know what the error is

#

but i dont know why it comes

chrome beacon
quaint mantle
#

i init plugin before loading other stuff

unreal quartz
#

you're trying to reference plugin in a field, which means plugin must be set

#

if it is set in the constructor then it is not set in time

#

the fields are initialzied first

#

initialized

bronze notch
#

I'm having issues with this set/get items code. Setting items always works fine. Getting only works the first time after a restart, then it always says the 'list' is null. I checked if the provided path always matches, and it does.

unreal quartz
#

reload the config before using it

bronze notch
#

Why is that necessary? The config should be the same as the file, after calling saveConfig?

unreal quartz
#

setConfig sets whatever is in memory to config, but your config is not properly loaded when your plugin starts up

#

i'm not sure what your getList method does, but bukkits get list will never return null

bronze notch
#

The problem occurs when the plugin is already running. The first time I get the items after a restart it works fine, the config is always loaded at start.

unreal quartz
#

have you inspected your config.yml after a save?

dusty herald
#

saveConfig is a void

unreal quartz
#

the code wouldn't compile if it was void

dusty herald
#

true ig they're using a custom method 🤷

bronze notch
#

After saving, items are visible in the list. Getting returns nothing, while I try to access the correct path.

#

getList comes from MemorySection

quaint mantle
fervent chasm
#

anoder question, I've made a citizen npc equip armour, but it doesn't seem to have any effect on the protection of the npc, purely cosmetic. How can I fix this?

unreal quartz
quaint mantle
#

enchantments class then ?

bronze notch
quaint mantle
unreal quartz
#

move the initialization of instantkill and plugin into your constructor, and pass the plugin through the constructor

#

why reason why the entire enchantments class is static?

quaint mantle
#

so it doesnt init InstantKill more times than 1

#

the enchantment

#

but what is the difference between putting the plugin in constructors & having a static get variable for it ?

unreal quartz
#

does not need to be static to do that

quaint mantle
#

ok

unreal quartz
smoky oak
#

Seeing how that's solved how do i check best if an input was a number? as in part of the command

#

do I just do Integer.parseInt() and catch the exception if there's any?

unreal quartz
unreal quartz
#

but that is the easiest way

bronze notch
#

It works when calling reloadConfig before getList. So I guess it is a list yes.

unreal quartz
#

i do not remember why, but lists specifically resolve to null when trying to call them before calling reloadConfig

quaint mantle
#

lmb i don't understand i am calling "plugin = this" in my main class before using the other classes

#

so shouldnt it be set before the other classes are trying to use it ?

unreal quartz
#

that plugin field is only set when onEnable is called, but spigot needs to construct your class first before calling onEnable, and it's during that process where your fields are initialized

quaint mantle
#

oh

bronze notch
#

Never experienced that before. Is calling reloadConfig in my saveConfig, after save(file), a good fix? Or should I just do it after saving lists?

ivory sleet
#

pvpmaster r u using a static singleton?

quaint mantle
#

can i like delay when the fields init like maybe "TimeUnit.SECONDS.sleep(10)" ?

unreal quartz
chrome beacon
#

Never sleep on the main thread

unreal quartz
#

i think you're not understanding

ivory sleet
#

Why tho pvpmaster

#

Sounds like an xy problem

smoky oak
#

Does the console use java.lang or java.util.logging

#

for level

ivory sleet
#

logging

smoky oak
#

um

ivory sleet
#

I think?

smoky oak
#

ah

#

ok thanks

bronze notch
quaint mantle
#

i am just trying to create enchantments but i need to set the enchantment.class field acceptingNew accessible to true but then in the same method i call "Enchant.registerEnchantment(Enchantments.getInstantKill())" but the plugin is null

ivory sleet
#

Just sounds like you got a trouble with initialization order here

chrome beacon
#

^

quaint mantle
#

i also think so but idk where

ivory sleet
#

in onEnable you first set the field accessible and then set it to true, then register?

sand rune
#

Guys how to make when I click item in GUI , it sends message

ivory sleet
#

Code runs linearly unless you tell it not to

ivory sleet
#

@sand rune handle InvenotryClickEvent

sand rune
#

Then @ivory sleet

chrome beacon
quaint mantle
#

that was a test

#

just ignore that part

ivory sleet
#

Also send the loadEnchantments method

chrome beacon
#

You will literally have the entire server wait

quaint mantle
sand rune
#

@ivory sleet

ivory sleet
chrome beacon
quaint mantle
#

where do i call it then

chrome beacon
#

Call it after you set the plugin

quaint mantle
#

oh

#

i just realized that i am dumb

ivory sleet
#

lol

#

No it’s fine

quaint mantle
#

i was setting the variable over on enable i was supossed to set it in onEnable under plugin = this;

bronze notch
#

@unreal quartz I found a solution! Just as you asked me, is the thing I'm saving a list. I don't think it was in the config. It gets parsed after saving to the file, but stays an array in memory. Saving it as a list solved my issue!

unreal quartz
#

nice

bronze notch
#

Thanks for helping me out 🙂

unreal quartz
#

no prlblem

supple elk
#

hey guys, I've got a problem

#

I have a custom tab menu, but when a player joins my server they are still visible

ivory sleet
#

Ok that looks fantastic tho

supple elk
#

thanks 😄

#

took me a while

#

I have an player join event which runs the function which displays the tab menu

supple elk
chrome beacon
#

Delay with one tick

#

And see if that fixes it

supple elk
#

mkay

ivory sleet
#

Also olivolja

#

?scheduling mind checking if everything looks fine here btw.

undone axleBOT
supple elk
#

thanks 🙂

#

annoyingly tho the fake player doesn't copy over my skin's mask

chrome beacon
chrome beacon
unreal quartz
supple elk
#

uhhh, I wasn't planning to

chrome beacon
#

:sadge:

supple elk
#

you're welcome to see/have the code if you want tho

unreal quartz
#

cuz uhh this is (mildly) annoying lol

supple elk
#

it's basically all the same stuff as making npcs

chrome beacon
supple elk
#

with a few less steps

#

k

#

I'll dm you then

chrome beacon
#

I always use Citizens for NPCs

waxen plaza
#

Is queuing static method calls necesarry when writing to a database?

unreal quartz
#

what do you mean by that

waxen plaza
#

If 2 players leave at once the server then the saveData method I have will be called at the same time twice trying to write data to the database and probably giving me an error from one of the methods that the database is locked

unreal quartz
#

you do not need to synchronise it yourself, that is managed by the database

waxen plaza
#

ok then I just got to test it to make sure 🙂

unreal quartz
#

databases are designed for this purpose

waxen plaza
#

ok

fervent chasm
#

I've been using npc.getTrait(Equipment.class).set(Equipment.EquipmentSlot.BOOTS, new ItemStack(Material.NETHERITE_BOOTS, 1)); to equip armour onto npcs, but it seems to be purely cosmetic, it seems to have no effect on the actual protection of the NPC. how can I fix this, or is there another method to actually set the resistance of the NPC
(yes, Ive tried asking the Citizen's discord)

chrome beacon
#

It should affect protection if I remember correctly

quaint mantle
#

Hey there! How can I get the output of an item in furnace?

crude charm
#

How can I send each line on a new line? using \n is ugly and creates this ugly effect

stone sinew
crude charm
#

i'll try again with what you have provided

stone sinew
crude charm
#

no

#

intelliJ was shouting at me

stone sinew
#

Can't stand using intellij

crude charm
#

why do I say string?

stone sinew
crude charm
#

yup

stone sinew
#

Remove the // to lol

crude charm
#

yeah

#

i've been told in the past to use t

#

idk why

stone sinew
#

You can use anything. Its your variable name

eternal night
#

also you don't toString a completable future

crude charm
#

ofc

eternal night
#

that is not how you grab the resulting value from it

crude charm
hybrid spoke
crude charm
#

completeable future not complete

winged ridge
#

Hello, I've set a new version in the plugin.yml file, but when the plugin is loaded, the old version is still displayed.

sage swift
#

CompletableFuture#thenApply will run the code inside that lambda once the future completes

eternal night
#

might also use CompletableFuture#whenComplete

crude charm
#
    public CompletableFuture<Integer> getPlayerCount(String serverName) {
        Player player = getFirstPlayer();
        CompletableFuture<Integer> future = new CompletableFuture<>();

        synchronized (callbackMap) {
            callbackMap.compute("PlayerCount-" + serverName, this.computeQueueValue(future));
        }

        ByteArrayDataOutput output = ByteStreams.newDataOutput();
        output.writeUTF("PlayerCount");
        output.writeUTF(serverName);
        player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
        return future;
    }

was sent this extreamly shit code by a friend. Going to rewrite it all

sage swift
#

you can use CompletableFuture#get, but that will retrieve it right there and then on that thread

crude charm
#

it's given me so many issues over the years

#

sometimes it works

#

sometimes not

#

so idk

#

just gonna do it the "intended" way

#

or that's what i'm planning

ivory sleet
#

synchronized 😬

crude charm
#

but last time I tried to fix it then it took me 13 hours with no end result

#

sooooo

#

yeah

#

unless it's easy i'm giving up on it

ivory sleet
#

It’s hard to tell from that snippet solely

crude charm
#

it's all like that

ivory sleet
#

?

crude charm
#

?paste

undone axleBOT
crude charm
ivory sleet
#

But btw while we’re going I suggest using Lock over synchronized, especially when it comes to completablefuture

crude charm
#

ik that's why i'm rewriting it. Got sent it by a friend and been using it on and off but it's given me too many issues. Sometimes it works and sometimes not

onyx shale
#

well...

crude charm
#

havent bothered doing something till now

quaint mantle
crude charm
quaint mantle
crude charm
#

what is the "output of an item in a furnace"

stone sinew
quaint mantle
#

I want to know what would be the ouput of this iron ore if it was burned in a furnace

#

so here an iron ingot

waxen plaza
#

How could I simulate players joining and leaving the server to test my plugin?

quaint mantle
onyx shale
#

the most common way is to simply open up anoter minecraft

waxen plaza
#

I need 10+ players

onyx shale
#

same concept

#

also you dont need 10 players

#

to test something

stone sinew
chrome beacon
onyx shale
#

because you want something to work with 10+ players doesnt mean you need that many to test the mechanics

stone sinew
#

Bukkit.getRecipesFor(ItemStack) and check for furnace recipes and get the result.

quaint mantle
#

great thank you!

chrome beacon
quaint mantle
#

This is what I used to do :

waxen plaza
quaint mantle
#
    private ItemStack furnace(ItemStack item) {
        if (item == null)
            return null; // Because item can be null
        
        while (recipeIterator.hasNext()) {
            Recipe recipe = recipeIterator.next();
            if (!(recipe instanceof CookingRecipe))
                continue;
            CookingRecipe<?> recipe1 = (CookingRecipe<?>) recipe;
            if (recipe1.getInputChoice().test(item))
                return new ItemStack(recipe.getResult().getType(), item.getAmount());
        }
        return null; // return result furnace :)
    }```
chrome beacon
#

Code it to what you need

quaint mantle
#

but I needed reflection

stone sinew
waxen plaza
onyx shale
#

why do you need 10 in the first place?

quaint mantle
#
    private ItemStack furnace(ItemStack item) {
        if (item == null)
            return null; // Because item can be null
        for (Recipe recipe: Bukkit.getRecipesFor(item)) {
            if (!(recipe instanceof CookingRecipe<?> cookingRecipe))
                continue;
            if (cookingRecipe.getInputChoice().test(item))
                return new ItemStack(recipe.getResult().getType(), item.getAmount());
        }
        return null; // return result furnace :)
    }```
onyx shale
#

even when i make minigames the minimum is 6 players however nothing stopping me to test with 3

quaint mantle
#

this should do the job!

quaint mantle
quaint mantle
stone sinew
quaint mantle
#

great

chrome beacon
#

Javascript isn't very hard to use either

winged ridge
#

Hello, I have a plugin where I've set a new version/description in the plugin.yml file, but when the plugin is loaded, the old version/desc is still displayed, the plugin.yml doesn't seem to update when I build the package

vale cradle
#

You used the same item?

#

Try to clone it every time

chrome beacon
#

Well you are looping through all stacks

#

Anyway just use the built in removeItem

vale cradle
#

And you're just checking by the Material

#

Any other item in the inventory with the named material will be affected tho

chrome beacon
#

Not if you give it an itemstack

stiff topaz
#

Ill try that

sand rune
#

Guys , when I did Inventory Click Event it didn't work , I register the events , @EventHandler , Why That

vale cradle
#

I'm not also sure what is the purpose of the amount variable

crude charm
#

IntelliJ? HELLO?

chrome beacon
vale cradle
sand rune
#

@chrome beacon Yes

crude charm
#

and intelliJ wont take it

chrome beacon
vale cradle
#

you talking about the shuttle variable?

crude charm
#

yes

#

it's my instance of the main class

#

and it wont take it

vale cradle
#

what I see is that variable being an instance variable and you attempted to call it from a static block

#

won't work

crude charm
#

omg

#

lmfao

#

I didnt realise I set the method the static

#

bruh

#

it's 1am and i've been up till 5am the last few days working on this so my brain is dead lmfao

vale cradle
#

ye, take a rest dud

chrome beacon
#

Taking a break is important

crude charm
#

I'm the most productive at this time tho for some reason

#

maybe dumb

stiff topaz
#

ikr

#

1 am is the best

crude charm
#

but I actually do something

stiff topaz
#

You do more when your tired

vale cradle
#

ye, but you do bad code

#

mostly

stiff topaz
#

bad code is still code

vale cradle
#

no

stiff topaz
#

sleep is no code

vale cradle
#

In the future, you will regret not have written that code in a better way

crude charm
#

as long as it's optimized, readable and works it's fine with me

#

obviously I have it laid out nicely so it's readable but i'm not gonna spend my life cleaning code noone will see

vale cradle
#

I'm not talking about optimization but code structure, bruh

ivory sleet
#

Writing clean code is also a treat for you in the future, necessarily not for others

vale cradle
#

it's fine tho

crude charm
#

depends what you classify as "clean"

vale cradle
crude charm
#

I would consider my code as clean and easily readable but not the best possible way you can think of

#

it's very easy to read for me

vale cradle
#

clean for me is a good structure design

ivory sleet
vale cradle
#

not just optimized

#

but ye, depends

#

it's fine tho

sand rune
#

See ur dm @chrome beacon

lusty cipher
#

is the getBlock for BlockPistonEvent the block it's moving, or the piston itself?

crude charm
#

try changing this

ivory sleet
#

It’s not an event u should use spnda

winged ridge
ivory sleet
#

It’s one of the "PlayerEvent" kinds

crude charm
lusty cipher
#

Yes I know

winged ridge
#

no

lusty cipher
#

There's two subclasses of it

crude charm
lusty cipher
#

But they just super that definition

crude charm
#

grandle?

lusty cipher
#

Which is why I just mentioned it

quaint mantle
#

hi

winged ridge
#

I didnt choose any when creating the project

ivory sleet
#

It’s the piston

crude charm
lusty cipher
#

ok thanks

winged ridge
#

oh

#

but it worked before

crude charm
#

but anyway check if it's updating when you build it

#

decompile it

winged ridge
#

no it doesnt

crude charm
#

then something is wrong when building it

winged ridge
#

like the plugin.yml is old

crude charm
#

is the actual plugin updating

winged ridge
#

yes

#

but not the plugin.yml

crude charm
#

delete the old plugin.yml and replace it manually put in a new one

winged ridge
#

ok

vale cradle
crude charm
winged ridge
#

yes, I use Build>build artifact

winged ridge
crude charm
#

are you sure you actually changed it?

#

it will change if you did it manually and the plugin loaded

vale cradle
#

Ctrl + Alt + Shift + S

waxen plaza
#

Is your output directory in your servers plugins folder? if it is and the server it's running it might not replace the old jar

winged ridge
vale cradle
vale cradle
#

Module settings.

#

Sources tab

winged ridge
#

or this?

vale cradle
#

ye

#

erm, where's your resouces folder?

crude charm
#

^

winged ridge
#

I put my plugin.yml inside the src

crude charm
#

nope

#

need a folder for it

winged ridge
#

hmm I was doing like that before

crude charm
#

also download "minecraft dev" for intelliJ makes stuff 100 times faster and removes all room for error

winged ridge
#

ok

crude charm
#

also

paper viper
#

Consider using maven or grade

crude charm
#

or

chrome beacon
#

But yeah

paper viper
#

Lol

crude charm
#

lmfao

#

oops

vale cradle
#

If he doesn't have a resources folder he can add the file itself to the build directly

#

in the project structure window, go to the artifacts, then the plus sign and add the file

winged ridge
#

what are maven/gradle for?

crude charm
#

compiling

vale cradle
#

That would work for you but consider using gradle/maven next time

vale cradle
vale cradle
quaint mantle
vale cradle
#

I know, but better be clear

#

gradle/maven are in charge of compiling, have and update dependencies and control the modules of your project

#

yet, you can use them just for compiling or have updated dependencies

vale cradle
#

?

winged ridge
vale cradle
#

no

#

select the artifact

#

the artifact you already use to compile

winged ridge
#

ok

vale cradle
#

and select the plus sign of their config to add the file

winged ridge
#

like that?

vale cradle
#

yes

winged ridge
#

same thing.

#

plugin.yml not updated

quaint mantle
vale cradle
#

select rebuild when building

#

not build

winged ridge
#

ok

quaint mantle
#

hi

#

babes

winged ridge
#

it works! : )

#

i'll have to use rebuild each time?

vale cradle
#

still, I'm not confident of leaving your plugin.yml files in the src folder

vale cradle
winged ridge
quaint mantle
#

resources

vale cradle
winged ridge
#

I create the folder?

unreal quartz
#

IJ doesn't create a resources folder by default

vale cradle
#

it does I believe

quaint mantle
#

it does

unreal quartz
#

every non java file in src is just copied to the compiled jar

quaint mantle
#

silly billy

unreal quartz
#

no it doesn't

winged ridge
#

i created the folder and moved the file to it

quaint mantle
#

u did it wrong

unreal quartz
#

?

quaint mantle
#

thrrr is a plugin

vale cradle
quaint mantle
#

that does everything for u

#

lol

unreal quartz
unreal quartz
#

i am telling you it is not created by default

quaint mantle
#

IT FUCKING IS

unreal quartz
#

make a new project then

winged ridge
#

wasnt created by default for me

unreal quartz
#

precisely

chrome beacon
#

It's not unless you create a maven project

unreal quartz
#

if you do not use a build system

#

it is not created

#

simple

quaint mantle
#

ur mom is yum

vale cradle
vale cradle
tardy delta
#

Is there actually a faster way for a tabcompleter than this?

vale cradle
#

you need to choose what do you want to put on it

#

idea doesn't create the plugin.yml lol

unreal quartz
vale cradle
#

the mc dev plugin does it

winged ridge
#

wait resources folder should be at the root of the projects?

unreal quartz
#

just have a constant list

quaint mantle
paper viper
#

And like stop

quaint mantle
#

y

unreal quartz
quaint mantle
#

python sucks

vale cradle
#

read my status

waxen plaza
quaint mantle
#

python user can perish

waxen plaza
#

imagine minecraft made with python

quaint mantle
#

LOL

paper viper
#

Disgusting

vale cradle
paper viper
#

That would be slow

quaint mantle
#

never said u were

vale cradle
quaint mantle
#

lol

#

imagine

#

being made with

#

php

waxen plaza
#

ok and now imagine it was made with C++

vale cradle
#

Bedrock

winged ridge
#

what do I choose to add the resources folder?

waxen plaza
quaint mantle
waxen plaza
#

but Bedrock is not java edition

unreal quartz
vale cradle
vale cradle
#

tag the folder as resources from there

winged ridge
#

ok did it

#

rebuild now?

gleaming grove
#

What is the max language level that spiot supports ?

unreal quartz
#

clean then build

unreal quartz
#

whatever jvm it is run as then that is the max

winged ridge
#

now I'm getting the same problem as the beginning

unreal quartz
#

which is

gleaming grove
winged ridge
unreal quartz
#

paper enforces java 16 on version 1.17+

winged ridge
#

but the plugin itself is

unreal quartz
#

clean your output and build your artifact

winged ridge
#

delete the out folder or re-use the clean option in build artifacts

unreal quartz
#

you should be able to run two at a time but clean then build artifacts

winged ridge
#

works

#

thanks

unreal quartz
#

no problem

quaint mantle
#

hello, i need some help
i'm trying to remove some AI of mob, like his head movements, deplacement, etc...
someone have an idea ?

quaint mantle
#

¯_(ツ)_/¯

urban lava
#

how do i reopen my eclipse project

#

oh wait

#

nvm

quaint mantle
urban lava
#

nvm

#

i did it

#

i was just being stupid

#

so i want to make a plugin where when a healer hits a healable person they heal the amount of damage that should be done

#

so i want to make two commands

#

/healer

#

and /healable

#

how would i set up the commands so that i can identify players those commands have been used on

#

for the event detection

stone sinew
#

EntityDamageByEntityEvent

urban lava
#

to make two commands from one

#

like

#

/healer add

#

and /healer remove

#

would i have to make them seperately

quaint mantle
#

no

#

in the command function

#

theres a list of strings

#

which is the syntax

#

i forgot the name

#

but i think its the 4th variable in the function

#

lemme find it

#
 @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        return false;
    }
#

use "args"

#

for example

#

in the command /healer add

#

"add" would be args[0]

urban lava
#

ah ok

quaint mantle
#

yeah

#

but make sure

#

u check that args[0] exists

#

otherwise u get error

#

and then if it doesnt

#

return like

#

"incorrect syntax! please use /healer add/remove"

#

something like that

urban lava
#

ok

quaint mantle
#

by return i mean send a message to the player

urban lava
#

yeah

quaint mantle
#

also

#

u could do like

urban lava
#

wait for the package file where i store my classes should that be in the src/main/java or in just src

quaint mantle
#

src

#

thats what i do

urban lava
#

ok

quaint mantle
#

if u wanna do like /healer add (player)

urban lava
#

yeah

quaint mantle
#

just use args[1]

urban lava
#

oh cuz that woudl be the next arguement

#

its kinda like in a discord bot

quaint mantle
#

yep

#

yes

#

its how lists work

#

and then check if Bukkit.getPlayer(args[1]) is null

#

if it is

#

then that means the player doesnt exist

#

actually i think u should use getofflineplayer

urban lava
#

yeah

#

cuz they neecd to be online

#

wait

#

im confused

#

cuz it shoudl only work with online players

quaint mantle
#

oh

#

ok then

urban lava
#

i think

#

cuz like its for a manhunt thing with my friends

quaint mantle
#

u could do

#

once u get

#

Bukkit.getOfflinePlayer()

#

OfflinePlayer.isOnline()

urban lava
#

ah makes sense

quaint mantle
urban lava
#

woudl this make sure that if they dc rc it will still stay?

quaint mantle
#

yeah

#

until server restarts

urban lava
#

cool cool

#

server restart is a pain to store im guesing

quaint mantle
#

not really

unreal quartz
quaint mantle
#

use yml file

urban lava
#

you need to like interface with hashs and stuff

#

idk much abt java tho

#

im kinda just guessing stuff

quaint mantle
#

i forogt

unreal quartz
#

don't use getOfflinePlayer(String) unless you need to

quaint mantle
#

havent done spigot in a bit

unreal quartz
#

it will block the main thread as it makes a request to Mojang if they have never joined before

quaint mantle
#

so what would u use

unreal quartz
#

depends what you're doing

quaint mantle
#

getofflineplayer(string) is deprecated anyways

quaint mantle
unreal quartz
#

just getPlayer will suffice

#

that returns a Player object or null

quaint mantle
#

okay thanks

tardy delta
#

If i try to remove something out of a hashmap, will that throw an nullpointer when its not in there?

unreal quartz
#

no

tardy delta
#

oh then its an unneccesary check

urban lava
#

wait how do i update maven

#

im stupid

unreal quartz
#

update it?

tardy delta
#

so i can remove the contains part?

unreal quartz
#

yes

tardy delta
#

fine

urban lava
unreal quartz
#

maven on the sidebar > refresh

tardy delta
#

😳

unreal quartz
eternal night
#

perfection

urban lava
#

im on eclipse lol

unreal quartz
#

oh

#

well

urban lava
#

cuz thats what the tutorial on bukkit if for

unreal quartz
#

¯_(ツ)_/¯

urban lava
#

should i use intellij

unreal quartz
#

up to u

urban lava
#

idk

#

i jsut wanan know

#

intellij looks cleaner from those ss

unreal quartz
#

entirely a personal decision

urban lava
#

waht do people think

#

i want opinions

#

im too lazy to swtich actually

tardy delta
#

and which one is actually better for storing players uuid? a hashlist or a hashset?

unreal quartz
#

depends what you want

#

also hashlist isn't part of the jdk

#

you probably mean arraylist

tardy delta
#

uhh wait

unreal quartz
#

hashset doesn't allow duplicates (which is fine for UUIDs) but does nto have a get method since it is unordered

tardy delta
#

ah yea arraylist

unreal quartz
#

though since it's hash based it's contains method is O(1) rather than the arraylist O(n)

#

just dpeends what youre doing

tardy delta
#

i'm just using them like to store an uuid temporary until the command is handled or something

#

probably temporary is the wrong word

#

ah nvm

unreal quartz
#

a set is fine

#

it doesnt matter realistically

tardy delta
#

yea thanks

#

i'm cleaning my whole plugin smh

urban lava
#

for api-version what do i put

#

1.16.5?

#

in plugin.yml

unreal quartz
#

whatever api version you're targeting

#

1.13 1.14 1.15 1.16 1.17

urban lava
#

ok

#

ty

#

in my command class what do i import

unreal quartz
#

wut

#

the interface to implement?

urban lava
#

like in the .java file what do i import

#

i know implements CommandExectuor

#

but like is there a way to shorten this

unreal quartz
#

it's in org.bukkit.command.CommandExecutor

urban lava
#
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
unreal quartz
#

you can use wildcard imports tho they are generally discouraged as it can cause namespace conflicts

urban lava
#

when i only import the thing you said

#

eclipse shows CommandSender, and command with red lines

unreal quartz
#

of course

urban lava
#

and when i look at the error it says to import this

unreal quartz
#

because you haven't imported it

#

you need to import it

#

unless you want to write out org.bukkit.command.CommandSender every time you need to refer to that class

#

the imports have 0 impact on your code readability

urban lava
#

ok

shut field
#

how can I initialize a List<ItemStack> without setting it to null

unreal quartz
#

by creating a new arraylist?

shut field
#

doesn't that give me like 10 functions I need to fill in though?

unreal quartz
#

no because arraylist is an implementation of list

#

if you try to initialise a List what you're actually doing is creating an anonymous class which implements List

#

since List is an interface

shut field
grave kite
#

Hi, how do I get the slot number from InventoryClickEvent? I mean the slot item is moved to not what slot was clicked

unreal quartz
#

i believe there is a seperate event for that

dusk yarrow
#

How can I turn a name (for example "maxthier") into something like this: ("--------"), "conminelp" would then be for example "---------". So the number of characters in the name in the form of "-".

grave kite
unreal quartz
#

or not

#

I'm not entirely sure