#help-development

1 messages Β· Page 1513 of 1

violet niche
#

I am

hardy swan
#

ok, firstly, it that on that head of the player

#

if so, you do not need armor stand

grand swan
#

@quaint mantle please refer to the premium resource guidelines.

summer scroll
grand swan
eternal oxide
hardy swan
#

oh wat?! there is a passenger method.... Im missing a lot

#

frick

#

in that case, can't you set the backpack as the passenger itself?

summer scroll
#

the backpack is an itemstack with custom model data

violet niche
#

K good, "real" players get added to the usercache, so they're being distinguished in some way

eternal oxide
# violet niche I am

You cna compare the UUID of the returned player to UUID.nameUUIDFromBytes(("OfflinePlayer:"+name).getBytes(Charsets.UTF_8)); If its a match then its not a realy player (unless in ofline mode.

summer scroll
#

and afaik armor cannot have custom model data

hardy swan
eternal oxide
#

I remember it returning with a null name but I guess it no longer does

summer scroll
hardy swan
#

yes wat i meant is, I thought you could just add the backpack as a passenger

#

self-realization exclamation

violet niche
eternal oxide
violet niche
#

yea I was wondering where was good to read them

eternal oxide
#

I just use the decompiled sources BuildTools generates

violet niche
#

great

summer scroll
hardy swan
#

also just use one of the visibility methods

#

.setVisible(false) should suffice

summer scroll
#

Wait, I'm having like a weird problem.

#

So I'm trying to spawn an armor stand, but it's automatically be the player's passengers.

hardy swan
#

when did you call equipBackpack() lol

eternal oxide
summer scroll
#

Hold on, I'm gonna do some couple of testing

hardy swan
#

o.O, definitely called setPassenger somewhere

hardy swan
summer scroll
hardy swan
#

try killin the entity and try again

summer scroll
#

kay, i think i fixed it smh

#

ah finally, thanks guys!

quiet ice
#

sighs "wont work" is not telling us much

hybrid spoke
#

when are you calling this?

quiet ice
#

try to delay it by a tick and see if that changes it

hybrid spoke
#

delay it

#

scheduler

#

runTaskLater or runTask

#

the event doesn't count that player, which just entered the bed. just a tick later the player will be added or better said the player will be sleeping

violet niche
#

Can I execute a command on behalf of a player?

hybrid spoke
#

no need to wait a whole second. 1 tick is enough.

#

also you won't need that BukkitTask task =

#

in the task. otherwise you will have the same problem again

quaint mantle
#

can i change item nbt in player's inventory without giving item?(inventory.setItemInMainHand(ITEM))

#

it is

#

try: .setTime(world.getTime() + 24000)
24000 = 1 day

#

Player#getHealth()/Player#getMaxHeatlh() * 10

#

ehm? wha?

quiet ice
#

Player#getMaxHealth is deprecated I think

sacred vector
#

how can i make it so my custom item can not be placed on the ground

#

like it stops them from doing it, so the attributes of the item stay

hybrid spoke
#

cancel the block place event πŸ€”

violet niche
hybrid spoke
violet niche
#

I want to run a command that the player might not have the permission to run

quiet ice
#

many abuse the hell out of setop

violet niche
#

I think Bukkit.getConsoleSender() might do it

hybrid spoke
#

i am not sure if #performCommand bypasses the needed permissions but i dont think so. you could send it over the console

quiet ice
#

Bukkit should have a doPrivilegedCommand or something tbh

violet niche
#

I don't need the original sender, so... hopeful

hybrid spoke
#

Bukkit#dispatchCommand should it be

sacred vector
quiet ice
violet niche
#
return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), String.format("whitelist add %s", String.join(" ", args)));
```atm
#

let's see!

quiet ice
hybrid spoke
quaint mantle
#

anyone know alternative way to write this for java 11 ```java
Bukkit.getScheduler().runTaskLater((Plugin)main, () -> {

}60L);```

violet niche
#

because this way is easier πŸ˜›

quaint mantle
#

With assignment crossbow in hand it isn't charged

ItemStack item = new ItemStack(Material.CROSSBOW)
CrossbowMeta meta = (CrossbowMeta) item.getItemMeta();
meta.addChargedProjectile(new ItemStack(Material.ARROW, 1));
meta.setCustomModelData(200);
item.setItemMeta(meta);
new BukkitRunnable() {
                        @Override
                        public void run() {
                            p.getInventory().setItemInMainHand(item);
                        }
                    }.runTaskLaterAsynchronously(Main.getInstance(), 1);
violet niche
#

I already have the working code using the bukkit api

quaint mantle
#

what is wrond?

violet niche
#

but it has funky error conditions

#

it forces me to UUID defaultUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:"+playerName).getBytes(Charsets.UTF_8));

hybrid spoke
quaint mantle
#

cant use lambas in java 11

quiet ice
#

You mean java 1.1, right?

quaint mantle
quiet ice
#

Because java 11 def. supports it, check your target/source versions

quaint mantle
#

Who da fuk uses Java 11 for MC?

quiet ice
quiet ice
quaint mantle
#

oh

hybrid spoke
quaint mantle
quiet ice
#

not even then

quaint mantle
vapid thorn
#

so the old way with cauldrons I just had to cast block data to Cauldron, but now with layered cauldrons how do I set that up now? I tried against block data and even state and both state I cant cast it for either

quiet ice
quaint mantle
quiet ice
#

It wont work

sacred vector
#

is damage all like sharpness for a sword?

quiet ice
#

You have a half anonymous class - half lambda construct

quaint mantle
vapid thorn
#

DamageAll iirc is sharpness

quiet ice
#

a Java 16 JVM will in 99% of cases be able to load Java 11 plugins

sacred vector
#

i'm adding enchants not attributes atm

violet niche
#

which makes total sense

#

but bleghh

#

the api's just passing around a bunch of strings and I dont think I get to touch the permissions

quiet ice
#

why can't you just do Bukkit.getOfflinePlayer(String.join(" ", args)).setWhitelisted(true);? Or is there an issue with the UUIDs

violet niche
#

The alternative version is ```java
if (args.length == 1) {
String playerName = args[0];
UUID defaultUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:"+playerName).getBytes(Charsets.UTF_8));
OfflinePlayer player = Bukkit.getOfflinePlayer(playerName);
if (!player.getUniqueId().equals(defaultUUID)) {
player.setWhitelisted(true);
sender.sendMessage(String.format("Could not find player "%s"", playerName));
return true;
}
sender.sendMessage(String.format("Could not find player "%s"", playerName));
}
return false;

#

But this has two problems

#

The UUID hackery sucks

hybrid spoke
violet niche
#

and it's on the main thread so it freezes the game for a mo

quiet ice
#

why not check for hasJoinedBefore?

hybrid spoke
#

this could cause lags AND you could be banned if you have too many requests

violet niche
#

Because it's too late then

hybrid spoke
#

you need the uuid

violet niche
#

And I need players who havent joined before

quiet ice
hybrid spoke
#

#getOfflinePlayer(String) will contact the mojang api no matter what. it needs to get the uuid.

quiet ice
#

At least unless you do that really frequently

hybrid spoke
#

as i said, at too many requests

violet niche
#

The CommandSender interface is interesting though

#

Can I extend it to have the isPermissionSet api return "yes"?

quiet ice
#

Otherwise you could easily ban servers by just logging in a ton of offline-mode accounts

violet niche
#

This is still way simpler :/ ```java

    boolean isOp = sender.isOp();
    sender.setOp(true);
    boolean ret = Bukkit.dispatchCommand(sender, String.format("whitelist add %s", String.join(" ", args)));
    sender.setOp(isOp);
    return ret;
hybrid spoke
#

why do you argue against me if we are actually saying the same?

quiet ice
#

because it is not a concern

#

Well, wouldn't work

#

You still need the offline player instance to #setWhitelisted

violet niche
vapid thorn
#

is the cauldron api messed up or something? I cant even cast blockdata to Levelled anymore. (worked 1.16.5, trying to get working in 1.17)
guess im missing something.?

violet niche
#

It works πŸ€·β€β™‚οΈ

hybrid spoke
#

but its a very bad and insecure practice

quiet ice
#

but very often used

violet niche
#

What vulnerabilities does it really create?

#

Bc if the only alternative is 10x as long for no real benefit then... I dont think I want to use it

hybrid spoke
#

you have the command sender

#

wait

#

what exactly are you trying to do

quiet ice
#

the real concern is that there is a chance of the programmer fucking up and resetting it, other other lesser concern is that anti-malware applications are going to flag the plugin

violet niche
#

basically alias my /welcome <player> command to /whitelist add <player>

#

The user should only need permission to call /welcome, /whitelist shouldnt matter

quiet ice
#

for a moment I wanted to suggest the commands.yml file, but that wont work

vapid thorn
#

while im aware of it, i even tried the new LayeredCauldronBlock and I couldnt get that to work, and its api setup appears to specifically target water, and there was a lava one as well. Im specifically trying to target a cauldron to see if its empty and then if its empty set its water level to full. I have a setup that uses dispensers with water buckets to fill, it worked in 1.16.5 and earlier but with new cauldron mechanics uhg xD

hybrid spoke
#

in your case its not a big thing

vapid thorn
#

the layredCauldronBlock is extended off block data but then tells me it cant be casted to blockdata

#

so idk xD

violet niche
#

It's not a huge amount of work, but it's far more complex than "call whitelist add"

hybrid spoke
#

basically 2 lines of code

violet niche
#

And doesn't represent what Im trying to do as well

violet niche
hybrid spoke
#

well not even 2

hybrid spoke
violet niche
#

So...

#

I just explained why that's insufficient

#

If I want a command with the same utility as whitelist add, I need to write much more code

quiet ice
eternal oxide
#

why not just dispatchCommand with a ConsoleSender

hybrid spoke
violet niche
quiet ice
#

Plugins such as LP do not like OP iirc

#

No idea how they behave towards such code

eternal oxide
quiet ice
#

I think that was already done but replaced due to some reason

violet niche
eternal oxide
#

why?

violet niche
#

The command can also fail for other reasons

eternal oxide
#

The command will alwasy return a boolean. There is no other outcome

violet niche
# eternal oxide why?

I'd want to avoid putting the user message in the console because it doesn't belong there

eternal oxide
#

what user message?

violet niche
eternal oxide
#

you are defining the command it is impossible for it to not parse

violet niche
#

"That player does not exist" doesn't belong on the console

#

...

#

the command is defined by vanilla minecraft

eternal oxide
#

You seem to be making it harder than it actually is

quiet ice
#

You are misunderstanding each other

violet niche
#

Im happy with the simplicity of my impl

eternal oxide
#

You test if the player exists, if it does you issue the command

violet niche
#

I don't know why I'd make it more complex

violet niche
quiet ice
#

The player will never exist though

eternal oxide
#

no its not, its very simple to test if a player exists

violet niche
#

Lol

eternal oxide
#

If you are only allowing players who have been on the server you can simply getOfflinePlayers() and see if yoru player is in there.

#

if you want ANY valid player, getOfflinePlayer, get teh UUID, then get again using the players UUID checking name for null, or compare their returned UUID to the offline generated one.

#

3 ways of doing it

quiet ice
#

Issue is NIO

violet niche
#

And all of them suffer from the same problem of blocking the thread they're running on

quiet ice
#

(though i'd argue NIO is involved there either way)

violet niche
#

And needing user feedback

#

and logging

eternal oxide
#

No only the get offlinePlayer by name blocks

violet niche
#

I'm not going to keep talking about this. Thankyou for your time

eternal oxide
#

every other method is non blocking

hybrid spoke
#

let him do his thing

#

we tried our best

sacred vector
#
        meta.addAttributeModifier(Attribute.GENERIC_ARMOR_TOUGHNESS, 2);
``` Im getting a a underline on the 2, is this how u use a Modifier? 

If not just gimme the link to docs page..
#

yeah i see it now thanks

vapid thorn
#

im slowly beginning to hate cauldrons xD

#

lol

sacred vector
#

yeah no errors with this now

        AttributeModifier modifier = new AttributeModifier(UUID.randomUUID(), "generic.armor_toughness", 2, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HEAD);
        meta.addAttributeModifier(Attribute.GENERIC_ARMOR_TOUGHNESS, modifier);
gaunt hatch
#

Have anyone find a way to get around the refection final field problem in java 16?

quaint mantle
#

I have a problem, i want to import files, but idk it dosen`t work, it always gets red :c

#

thats real descriptive

quaint mantle
#

wtf are you even asking?

quaint mantle
#

stop pinging me

quaint mantle
opal juniper
#

Am i correct in saying that HashMap#getOrDefault will either get the value of the key or return the new default

eternal oxide
#

correct

quaint mantle
opal juniper
#

So if i had a
Map<String, Set<UUID>>
and i ran this:
getOrDefault(isoKey, new HashSet<>()).add(player.getUniqueId());
it would either add it to the existing key or it would add a new set and add the uuid?

gaunt hatch
#

getOrDefault does not add it a return

eternal oxide
#

add does not return a HashSet so no that would not work

sacred vector
#

So we have attributes and I now have them on my armor, but the armor bar can it go more then 10 like health? i want it to show 20 bars of armor because custom armor will each have higher then 10 but at different values

opal juniper
gaunt hatch
#

The idea behind getOrDefault is to return a value from a key or return something if its no there.

opal juniper
#

ohhh i get ya

quaint mantle
#
public static PluginDescriptionFile description = this.getDescription();
public static String version = description.getVersion();

here "this" says "cannot use this in a static context"
how do i get around this?

sacred vector
#

no possible way to edit that without mods

#

?

#

mhm....

quaint mantle
#

how do i import other files in a file?

opal juniper
#

cause i need to add to the set if it does not exist in the map already

eternal oxide
quaint mantle
#

how?

#

inside onEnable()?

gaunt hatch
opal juniper
quaint mantle
#

i dont think i can use this. under onEnable()

gaunt hatch
#

you dont have a check in there

quaint mantle
#

Helppp

gaunt hatch
#

You are just adding it every time

eternal oxide
opal juniper
#

ah - makes sense

eternal oxide
#

Test though

opal juniper
#

πŸ‘

gaunt hatch
#
Set<UUID> uuids = map.getOrDefault(isoKey, new HashSet<>());
        if (!uuids.contains(player.getUniqueId())) {
            uuids.add(player.getUniqueId());
            map.put(isoKey, uuids);
        }
#

Check if its not there add and update the map

opal juniper
#

but sets cannot contain duplicates

eternal oxide
#

correct

opal juniper
#

and for my usecase it is impossible

#

for there to be a duplicate

gaunt hatch
#

then you have to check that also

#

but that is what that does

#

you see how i have it checking the set to see if its not there then it adds it

#

its its there it will not add it and update it

opal juniper
#

im so confused what you are talking about

#

sets cannot contain duplicates

eternal oxide
#

just add. If its a new Set it will get added, if its not it will be added if its not there.

gaunt hatch
#

Also unless its a manager class you should not be access a map with a direct call.

opal juniper
#

what

#

although that is a valid point

#

it seems a bit like you are spouting random knowledge to try and prove yourself?? πŸ™ƒ

gaunt hatch
#

the 'map' object should not be access from a direct call from somewhere lese

#

No i am trying to help, with better code practices

opal juniper
#

Fair enough

#

but this is just a variable

#

not a field

gaunt hatch
#

yes how is it delcared?

#

public static Map<String, Set<UUID> map = new HashMap<>();

Maybe like this?

opal juniper
#

just like this

#

Map<String, Set<UUID>> targetPlayerLanguages = new HashMap<>();

#

cause it is a variable

gaunt hatch
#

and do you access it from outside of the class it is defined in with a direct call?

opal juniper
#

do you know what a variable is

#

in java

vital swift
#

bump

opal juniper
#

They are typically the ones which are part of a method

gaunt hatch
#

correct

#

ugh nvm

#

trying to help with better code practices, do it not the best way

opal juniper
#

sorry i made a typo

#

fields are part of a class

#

variables are part of methods

#

do you see what i mean now

gaunt hatch
#

you mean local variables

opal juniper
#

yuhuh

#

that is the same thing

gaunt hatch
#

no its not

opal juniper
#

kinda is but we should just move on

gaunt hatch
#

there are 3 types of variable

local
instance
static

unreal quartz
vital swift
unreal quartz
#

yeah

#

how do you get it though

vital swift
#

just to debug

gaunt hatch
#

local - in side the method
instance - inside the class
static - global

unreal quartz
#

Bukkit.broadcastMessage("Double: " + i); doesn't look like skript to me

vital swift
#
    broadcast "%balance of player%"```
#

this is the skript

opal juniper
#

he means he is accessing the api with skript

#

and that code is the api

unreal quartz
#

try writing a plugin to access it instead? don't think many people here know how skript works

#

for all we know it could be skript that is broken

vital swift
#

i have auction house plugin

#

and when i have 10000 coins i cant buy stuff for 1 coin

opal juniper
vital swift
#

no it doesn't

unreal quartz
#

that won't broadcast null

opal juniper
#

just checkin

#

then yea - its probs a skript thing

quaint mantle
#
Arenas:
  Map2: {}
  Map1: {}``` How come I can't get the sections under Arenas with this: https://paste.md-5.net/xubakorizu.cs ?
vital swift
opal juniper
#

🀷

unreal quartz
#

could be your plugin is loading (and registering its economy provider) after other plugins get the economy provider

#

so to other plugins it appears as null

quaint mantle
#

Main.java

import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
  PluginDescriptionFile description = this.getDescription();
  String version = description.getVersion();
}

this works fine, but how do i pass it to the below?

CMD.java

sendMessage(String.valueOf(Main.version)
unreal quartz
#

pass whatever you need in the constructor of CMD and store it in a field

#

in this case you can pass the version string, or the plugin instance itself if you want to do more with it

true perch
#

17.06 09:54:01 [Server] INFO Caused by: java.lang.UnsupportedClassVersionError: me/combatborn/firstplugin/FirstPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Am I getting this error because I'm using SDK 11.0.4?

unreal quartz
#

yes

true perch
#

Which version should I use?

unreal quartz
#

your runtime is java 8, your compiuled classes are 11

#

choose one

true perch
#

What do you recommend?

unreal quartz
#

everybody would recommend the latest version for obvious reasons

true perch
#

I've been learning java for the last few months, thought I'd give minecraft plugins a try

#

souns good, thanks for the help

unreal quartz
#

but some servers still run java 8, some java 11, though with mincraft 1.17 java 16 is required

summer scroll
#

Does anyone know why If I logout and have armor stand as a passengers, the helmet won't get removed.

unreal quartz
#

just depends who you're targeting

vital swift
#

but i don't haev other economy plugins

#

like essentials

true perch
#

I'd like to do a 1.17 server yeah

summer scroll
true perch
unreal quartz
#

if you're using 1.17 then you can use any version up to 16

unreal quartz
quaint mantle
#

Hey,

Is it possible to disable portals?

I want players to create them, but not use them

unreal quartz
#

cancel the event

summer scroll
#

That's why it has flying object.

quaint mantle
unreal quartz
#

what version of spigot is it

quaint mantle
#

1.16.5

unreal quartz
quaint mantle
#

They are registered, yes

summer scroll
#

@unreal quartz or it's because I add equipment lock to the armor stand?

#

I add these on armor stand spawn

armorStand.addEquipmentLock(EquipmentSlot.HEAD, ArmorStand.LockType.ADDING);
armorStand.addEquipmentLock(EquipmentSlot.HEAD, ArmorStand.LockType.ADDING_OR_CHANGING);
armorStand.addEquipmentLock(EquipmentSlot.HEAD, ArmorStand.LockType.REMOVING_OR_CHANGING);
quaint mantle
unreal quartz
summer scroll
#

ah true, will try that

#

nvm, still the same

#

the helmet doesn't got removed

unreal quartz
quaint mantle
unreal quartz
#

send your code

summer scroll
#

show whole class maybe

quaint mantle
unreal quartz
#

is the plugin even running?

quaint mantle
#

Yes πŸ˜…

summer scroll
unreal quartz
#

is it even iterating over anything from player.getPassengers()?

#

could be that they get dismounted prior to the event being called

summer scroll
#

Okay, I'm gonna debug it. But what should I do if the entity got ejected before the PlayerQuitEvent got called?

unreal quartz
#

keep track of them somehow

summer scroll
#

And yeah, the entity got rejected before the event gets called.

#

What about store it on the map Map<Player, Entity>?

#

Anyways, thank you for that, i'm gonna sleep for now.

unreal quartz
#

could do that, or by UUID, UUID if you don't want to keep hard references

summer scroll
#

Yeah I think UUID fine, I don't really need Player object.

opal juniper
#

maybe remove that

quaint mantle
#

Does somone know, how to upload maps in spigot server? xd

unreal quartz
#

the final wouldnt affect things

unreal quartz
quaint mantle
opal juniper
#

and also - put a debug sys out in onEnable

quaint mantle
unreal quartz
#

just in teh base directory

#

and unzip it

opal juniper
#

do you mean the picture maps or world maps πŸ™ƒ

#

just checking

quaint mantle
quaint mantle
unreal quartz
#

use a plugin like multiverse to import it, or alter your server.properties to point to the new folder

foggy bough
#

quick question what does ambeint mean? java p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, duration, amplifier, ambient))

unreal quartz
#

Makes potion effect produce more, translucent, particles.

foggy bough
#

ohhh ok and amplifier means that my speed will go faster right?

narrow vessel
#

yeah

quaint mantle
unreal quartz
#

mvtp

quaint mantle
unreal quartz
#

u need to import it

#

first

quaint mantle
sage swift
#

mvimport

#

player data in the world folder

quaint mantle
sage swift
#

mvimport

#

or mv import

quaint mantle
# sage swift mvimport

I have done this, have i to put in /mv import "name of the folder? Or what do i have to input there?" ?

sage swift
#

that's why each multiverse command has feedback when you run it

quaint mantle
cinder fable
#

signs dont work when i click them

#

i should be teleported to hunger games game but dont tp me

quaint mantle
#

you're not making a plugin, wrong channel

shut trail
#

hey , can someone tell me how to add multiple nms versions to plugin

frosty tinsel
#

Hello, is it possible to view the spigot mappings in the ide?

unreal quartz
shut trail
#

thnx i will check it out

#

nvm i did saw that video

#

@frosty tinsel how to do that with maven?

frosty tinsel
#

idk, I actually haven't seen that video

#

try to find it on google

shut trail
unreal quartz
frosty tinsel
#

Is it possible to have Mojang mappings for NMS and spigot mappings for Bukkit at once?

#

Since now, all spigot methods are obfuscated

woeful crescent
#

Hey, can anyone tell me if it matters which plugin instance I put for Bukkit.getScheduler().runTaskLater()?

frosty tinsel
woeful crescent
#

You mean

#

I have to put the plugin instance it's executing from?

#

That's what I've been doing, but I was wondering if it really mattered

frosty tinsel
#

I think so, because then, the task is tied to your plugin.

quiet ice
#

yes it does because otherwise it may not unload properly

true perch
#
public class Test implements CommandExecutor {
    private SecondPlugin plugin;
    public Test(SecondPlugin plugin){
        this.plugin = plugin;
        plugin.getCommand("test").setExecutor(this);
    }
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (!(commandSender instanceof Player)){
            commandSender.sendMessage("Only players may execute this command.");
            return true;
        }else{
            Player p = (Player)commandSender;
            if (p.hasPermission(("test.use"))){
                p.sendMessage("Hello there, this is a test.");
                return true;
            }else{
                p.sendMessage(p.getDisplayName()+" does not have permission to send this command!");
            }
            return false;
        }
    }
}``` 
In the constructor I have the line: ``plugin.getCommand("test").setExecutor(this);``.
When hovering over the "setExecutor" method, it's producing this warning: ``Method invocation 'setExecutor' may produce 'NullPointerException'``
Why is that? Should I be concerned?
shut oyster
#

Because it isnt certain the command actually exist.

novel lodge
#

How can I make it so only the localName of an item matters in a crafting recipe?

true perch
sage swift
#

the ide isn't aware of that

#

but you should be fine

shut oyster
true perch
#

okay cool! good to know thank you

mortal hare
#

who needs intellij

#

when you have sublime text

#

with JDTLS

next zinc
#

Anyone know why this isn't working?

#
player.setHealth(player.getHealth() / player.getAttribute(Attribute.GENERIC_MAX_HEALTH) * 50);
#

It says I can't divide the two

mortal hare
#

what do you want to do

next zinc
#

I want to heal the player by 50%

mortal hare
#

maybe you're diving by 0

#

Division by zero can make weird things like 1=2 in math

#

in that case programming languages forbid you from doing that

next zinc
#

but like

#

that would be an in game error

mortal hare
#

drop your stacktrace

#

here

next zinc
#

1 sec

quaint mantle
#

?jd

next zinc
#

that legit just gives the same error

#

as I see

#

in the editor

quaint mantle
#

Wait

next zinc
#

It says that I can't use the divide operator

quaint mantle
#

Why javadoc is not loading

next zinc
#

Β―_(ツ)_/Β―

chrome beacon
#

Loads for me

#

Β―_(ツ)_/Β―

quaint mantle
#

Oh it fixed

next zinc
#

I guess a better question then is how would I divide a double and an Attribute?

#

since player.GetMaxHealth() is deprecated

unreal quartz
#

AttributeInstance#getValue returns double

next zinc
#

there we go

#

tysm

#

forgot you can add on to attributes like that

quaint mantle
#

could someone help me debug my plugin, it should be working fine but i have no idea whats going wrong, ( its a simple chest cleaner plugin, i also have the code that works fine, but when i try the same for others blocks like barrels, it dont work )

unreal quartz
#

?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.

quaint mantle
#

this works for "chunk" but not for "world" or "server"

if (Blockname.equalsIgnoreCase("Barrel") && blockState instanceof Barrel) {
            Barrel barrel = (Barrel)blockState;
            barrel.getInventory().clear();
        }
        else if (Blockname.equalsIgnoreCase("BlastFurnace") && blockState instanceof BlastFurnace) {
            BlastFurnace blastfurnace = (BlastFurnace)blockState;
            blastfurnace.getInventory().clear();
        }
        else if (Blockname.equalsIgnoreCase("Chest") && blockState instanceof Chest) {
            Chest chest = (Chest)blockState;
            chest.getInventory().clear();
        }
        else if (Blockname.equalsIgnoreCase("Dispenser") && blockState instanceof Dispenser) {
            Dispenser dispenser = (Dispenser)blockState;
            dispenser.getInventory().clear();
        }
        else if (Blockname.equalsIgnoreCase("Dropper") && blockState instanceof Dropper) {
            Dropper dropper = (Dropper)blockState;
            dropper.getInventory().clear();
        }
        else if (Blockname.equalsIgnoreCase("Furnace") && blockState instanceof Furnace) {
            Furnace furnace = (Furnace)blockState;
            furnace.getInventory().clear();
        }
        else if (Blockname.equalsIgnoreCase("Hopper") && blockState instanceof Hopper) {
            Hopper hopper = (Hopper)blockState;
            hopper.getInventory().clear();
        }

original, this works fine but it only supports "chest"

if (blockState instanceof Chest) {
        Chest chest = (Chest)blockState;
        chest.getInventory().clear();
      }
unreal quartz
#

this works for "chunk" but not for "world" or "server"
?

quaint mantle
unreal quartz
#

you can also just cast to InventoryHolder rather than checking for each one

quaint mantle
#

basically you can reset the supported blocks, within your chunk or world or server

true perch
#

Is there an existing method that's better for sending a message to all online players other than doing this:

ArrayList<Player> players = new ArrayList<>(plugin.getServer().getOnlinePlayers());
for (Player player : players) {
    player.sendMessage("The console has sent you a message.");
}```
unreal quartz
#

why are you creating a new array list?

true perch
#

loop through them all to send a message

unreal quartz
#

also you can just use Bukkit.broadcastMessage

true perch
#

ah thanks

unreal quartz
#

yeah but you don't need to create a whole new array list

#

for (Player player : plugin.getServer().getOnlinePlayers())

true perch
#

thats good too

quaint mantle
#

How can i run a command from a console?

shadow gazelle
#

Does a bed count as a container or something?

true perch
quaint mantle
shadow gazelle
#

Because my telekinesis enchant doesn't work on beds, this is the only line that could be stopping that

        if (event.getBlock().getState() instanceof Container)
            return;
unreal quartz
shadow gazelle
#

Maybe because it's a persistent data holder?

quaint mantle
unreal quartz
#

pass the returned value of that into the first one

shadow gazelle
#

It's easy to fix, anyway Β―_(ツ)_/Β―

late dove
#

How to make an inscription in front of a nickname? Is it in the documentation or not?
I can see the inscription in the list of players!

quaint mantle
ebon siren
#

how would i check if a player died to a sword or a bow, i understand that i use PlayerDeathEvents and their last cause but how would i get the item they were killed with

unreal quartz
ebon siren
#

alright, thanks

#

and more question: how would i check if the player's killer was an entity or a player type, i know instanceof exists but player and entity are abstract so it doesn't exactly work

mortal hare
#

do you guys throw IllegalArgumentException when the arguments specified in the function are invalid? If so, why? Doesn't the runtime throw nullpointerexception, and doesnt make the code more heavy just because you add one unneccesary if statement?

lean gull
#

anyone know how to use all the dust particle stuff? like options, transition and normal?

#

spigot api doesn't have examples

unreal quartz
#

if you're writing a method for someone else to use, then throwing an exception with a short message telling them how they fucked up is generally a good idea

mortal hare
#

maybe you're right

unreal quartz
#

it is also much safer to check the arguments and throw an exception than let the code execute with bad parameters as the code relying on that data could be safety critical and potentially cause damage with bad data

ivory sleet
#

for instance if u spawn a redstone particle u can choose to pass new Particle.DustOptions(color,size) through the data parameter iirc

#

or smtng like that

quaint mantle
#

does binding a socket freeze the main thread?

ivory sleet
#

its probably call sensitive

quaint mantle
#

ah nvm its serversocket#accept

#

makes sense

subtle kite
#

So I made a custom item , but people can use it anywhere on the server .
any tips

quaint mantle
#

what are you trying to do?

lean gull
#

what's the difference between playEffect & spawnParticle

chrome beacon
#

Horrible explination but I tried ;/

ebon siren
#

how would i make a broadcasted chat message colored with the minecraft color codes, it broadcasts fine and everything else works but it's only the literal color codes, no actual coloring

this is what it looks like right now "&arkfish&7 fell fatally"

quaint mantle
chrome beacon
#

^^

quaint mantle
shadow gazelle
chrome beacon
quaint mantle
#

startup log

[13:23:28] [Server thread/INFO]: [SocketControl] Loading SocketControl v1.0.0
[13:23:28] [Server thread/INFO]: [SocketControl] Enabling SocketControl v1.0.0
[13:23:28] [Server thread/INFO]: [SocketControl] Enabled!
[13:23:28] [Server thread/INFO]: [SocketControl] Binded socket!
grizzled herald
#

You never start the thread?

quaint mantle
#

probably why

#

thanks

#

ffs

grizzled herald
#

=p

tacit drift
quaint mantle
#

thats 2 brainfarts in under 30 minutes

chrome beacon
#

I mean at least you haven't rewritten your entire system 5 times in one day like I've had to do for my project 😒

quaint mantle
#

thats tuff

#

ok big reveal

chrome beacon
#

oh no it crashed without an error πŸ˜“

pine zephyr
#

Alright, I need help with my multi java versions due to 1.17.

So My project Holograms (https://github.com/wherkamp/Holograms/tree/new_mc)

However I cant compile it. Because The 1.17 module needs to use Java 16
Because it fails and says
class file has wrong version 60.0, should be 55.0

If I set it to Java 16
Gradle Says

ublic class EntityNameable extends EntityArmorStand implements Nameable {
       ^
  bad class file: /home/wherkamp/.m2/repository/org/spigotmc/spigot/1.17-R0.1-SNAPSHOT/spigot-1.17-R0.1-SNAPSHOT.jar(/net/minecraft/world/INamableTileEntity.class)
    class file has wrong version 60.0, should be 55.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
2 errors```

My guess is to have Gradle do two releases one with 1.17 Java 16 and one without.

But I am not sure how to do that. And if that is the best idea
chrome beacon
pine zephyr
chrome beacon
#

You need Java 16 if you want to use NMS

pine zephyr
#

My user base is mostly 1.16 and non of them use Java 16. So I want to push it a bit longer before forcing an update

chrome beacon
#

You might be able to work around this by using a module that you shade in

pine zephyr
#

Thats what I am doing. The 1.17 is shaded in.

shut field
#

can someone please explain to me how to use LootContext?

chrome beacon
#

Yeah you need to compile the module with Java 16

#

Wait a min

#

Yeah I'm not sure

pine zephyr
eternal oxide
#

Yes MC 1.17 requires Java 16, No alternative

pine zephyr
#

If I set the 1.17 module to java 16 this happens

eternal oxide
#

Yeah, you are still forcing java 8 compat

pine zephyr
#

I need to set the entire project to 16

#
java {
    withJavadocJar()
    withSourcesJar()
    targetCompatibility = org.gradle.api.JavaVersion.VERSION_16
    sourceCompatibility = org.gradle.api.JavaVersion.VERSION_16
}```
#

I just did that to the specific module

true perch
#
public class Open implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (!(commandSender instanceof Player)){
            commandSender.sendMessage("Only a player can execute this command.");
            return false;
        }else{
            Player player = (Player)commandSender;
            Inventory gui = Bukkit.createInventory(player,9,"Custom GUI");

            ItemStack gameItem = new ItemStack(Material.DIAMOND_AXE);

            ItemMeta gameItemMeta = gameItem.getItemMeta();

            gameItemMeta.setDisplayName("test");
            gameItemMeta.setUnbreakable(true);
            gameItemMeta.setCustomModelData(101);

            gameItem.setItemMeta(gameItemMeta);

            ItemStack[] menuItems = {gameItem};
            gui.setContents(menuItems);
            player.openInventory(gui);
            return true;
        }
    }
}```When executing this command, I get a long list of errors, what am I doing wrong and how can I fix it? I was just loosely following a video and everything seems to be find until the second I run the command. 
**Here are the errors**: https://hastebin.com/ulobafupez.apache
dusk flicker
#

well fist of all you dont need the else

#

you are returning inside the first if statement, so no matter what it wont execute past that if that condition is met

chrome beacon
#

The major versions will support this

dusk flicker
#

I've never seen the Inventory#setContents used before, ill take a look at the javadocs for it but if you can send your entire class that would be useful/

#

?jd

pine zephyr
#

That will drop support for the old versions. But ok

chrome beacon
pine zephyr
chrome beacon
#

Yeah they will have to deal with that

#

Don't make it too hard for yourself

dusk flicker
#

at this point most services will be running J16 for minecraft as its required for 17

chrome beacon
#

^^

#

And the illegal access permit does fix most broken plugins with Java 16

shut field
#

what location does LootContext.Builder() need?

dusk flicker
#

Check the javadocs

pine zephyr
#

I think I am just going to keep a branch open with older versions for a bit of LTS. and a main branch will be 1.17 + and Java 16 so I can use all the fun nice features

chrome beacon
shut field
dusk flicker
#

Olivo answered you, and that does answer your question.

shut field
#

what is it using that location for though

chrome beacon
#

It's where the chest, mob etc is located I assume

#

The loot does spawn somewhere

dusk flicker
#

Its where the loot will generate

#

Took me a few seconds to find that in the Javadocs, you will have to look closer.

shut field
chrome beacon
#

Javadocs

#

;/

shut field
#

I always keep it open while I'm coding

dusk flicker
#

So Builder is a builder for the 'LootContext' class, so I looked into the actual LootContext class for the getter of 'Location'.

chrome beacon
#

Then try reading it

#

;/

dusk flicker
#

this is basic java and javadoc understanding

opal juniper
#

I need to make api requests but I need them to be as fast as possible - anyone got any tips

quaint mantle
#

Imagine having the Javadocs open and not even reading them smh

dusk flicker
opal juniper
#

I just essentially need it to be as fast as possible

#

It needs to translate things the player inputs in real-time

#

So request to a translation api

violet niche
#

You're going to struggle to do that without client mods

#

But if you need it, the best thing you can optimise is the location the server is running

#

so that it can make direct requests to the translation service

#

some cloud providers will give you much more negligible latency on the requests

opal juniper
#

Yeah - i have no doubt that a lot of the bottle neck is the actual packets getting from a -> b

#

so i am just trying to minimise as much as possible of my latency πŸ™ƒ

violet niche
#

I'm not familiar with the libraries you'd use in java, but a big way to lower latency on frequent requests would be reeping the http connection open

#

so youll need a http library capable of that

opal juniper
#

Yeah - the thing is that on average the same request is about 30% faster on python

#

So 🀷

dusk flicker
#

Id recommend you use Redis

#

It's insanely fast

ivory sleet
#

What are we talking about now?

quaint mantle
#
@Override
public void run() {
    System.out.println("Receive thread is running!");

    try (
        BufferedReader stream = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {

        while (SocketControl.notKilled()) {
            if (stream.ready()) {
                sender.sendRawMessage(stream.readLine());
            }
        }

    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("Receive thread killed!");
}

any reason why this isnt sending any messages to console?

dusk flicker
#

are you starting it

quaint mantle
#

ye

dusk flicker
#

the thread that is

quaint mantle
#

made that mistake too many times now

#

yeah ofc

dusk flicker
#

is it sending the first debug?

quaint mantle
#

yeah

dusk flicker
#

and the last?

quaint mantle
#

nope

#
import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

sock.connect(("localhost", 29317))

while True:
    try:
        sock.send(input(">> ").encode())
    except Exception as e:
        print(e)

>> /tellraw @a "hi"

#

heres the client program

dusk flicker
#

not sure ive never messed with sockets like that lol

quaint mantle
#

this is my first time

ivory sleet
#

Haven’t used java net in ages but do u have the code on GitHub or smtng

quaint mantle
#

yeah ill post it

#

1 sec

ivory sleet
#

What was the issue btw

quaint mantle
#

i send a message and nothing is sent to the console

ivory sleet
#

Oh from that python thing ?

quaint mantle
#

ye

ivory sleet
#

Hmm

#

1 sec gonna hop on pc

true perch
#

that's the whole plugin

dusk flicker
#

send it in a paste

#

by sending both of those you just filled the entire channel up

true perch
dusk flicker
#

delete your message above aswell so its not filling this channel

#

ty

true perch
#
name: FirstGUI
version: 1.0.0
author: CombatBorn
description: This is my first GUI plugin.
main: me.combatborn.firstgui.FirstGUI
api-version: 1.17

commands:
  open:
    description: This commands opens a GUI.```
#

That's the yml, forgot to include it

digital rain
#

just wanted to ask if im doing the things correctly, this is supposed too be a function that can get called anywhere in the plugin, and i wanna be able to input an itemstack into it. so if you have any recommendations tell me

dusk flicker
ivory sleet
#

imaginedev

quaint mantle
#

yes

true perch
#

I'll give it a try

ivory sleet
#

was it the client or server which didnt work

quaint mantle
#

server

digital rain
quiet hearth
#

Im making a shaped recipe and was wondering how you would have a custom item as an item in the recipe. //Shaped Recipe ShapedRecipe shapedRecipe = new ShapedRecipe(NamespacedKey.minecraft("flamethrower_recipe"), item); shapedRecipe.shape("PGP","PFP","PLP"); shapedRecipe.setIngredient('P', ironPlate); shapedRecipe.setIngredient('G', Material.GOLD_INGOT); shapedRecipe.setIngredient('F', Material.FLINT); shapedRecipe.setIngredient('L', Material.LAVA_BUCKET); Bukkit.getServer().addRecipe(shapedRecipe);
IronPlate being the custom recipe

dusk flicker
#

ExactChoice

quiet hearth
#

ok

ivory sleet
quaint mantle
true perch
#

Is it something to do with Spigot 1.17?

quiet hearth
# dusk flicker ExactChoice

I added that and rebuilt the jar and ran it in my server and when i go to put the plates in the places it does not work, but i can craft the item as if they were not part of the recipe

quaint mantle
crude axle
#

Also, Does anyone know why Maven is suddenly giving me this error?: ```[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project structureboxes-
nonlegacy: Fatal error compiling: java.lang.ExceptionInInitializerError: Unable to make field private com.sun.tools.javac.processing.Jav
acProcessingEnvironment$DiscoveredProcessors com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs accessible: modul
e jdk.compiler does not "opens com.sun.tools.javac.processing" to unnamed module @2095c331 -> [Help 1]

eternal oxide
quiet ice
#

what the hell are you doing here

crude axle
quiet ice
#

Impossible

#

It has been always convention to not poke at JVM internals, now it is a rule

#

Well, it has been for a few years now (since august 2017)

crude axle
#

Except I am unable to find any classes that reflect Java internals in that module.

eternal oxide
#

Is yoru IDE not updated? Eclipse?

crude axle
pine zephyr
#

In Minecraft 1.17 where is the registerEntity method inside the WorldServer class

lean gull
#

anyone know why this is happening?
https://i.imgur.com/uf9yNW4.png
i just made a new paper server with a new plugin like i did twice before (following a tutorial) but this time this happens?

#

the only change i made was instead of making a 1.16.5 server i made a 1.17 server

eternal oxide
#

1.17 on a 1.16.5 jar

crude axle
#

So should I update the IDE?

eternal oxide
lean gull
#

elgal i clicked show message cause i was bored and you do realize you're blocked in my account, right? (don't bother answering, i won't click show message again)

digital rain
#

for some reason it doesnt recognize addprimeenchant from the other class, yeah im quite new to coding, anyone can help?

eternal oxide
#

I answer to whoever asks for help, If you are too much of a prick to accept help, thats upto you

digital rain
#

no elgarl is cool

eternal oxide
lean gull
#

ohh it says unsupported api version 1.17

#

that's hella dumb

true perch
#

Why does this crash the server? java Inventory gui = Bukkit.createInventory(player,9,"Custom GUI"); player.openInventory(gui); Crash report: https://hastebin.com/qiqukuwajo.apache

It crashes regardless of if I add an item to the gui object like so: java ItemStack gameItem = new ItemStack(Material.DIAMOND_AXE); ItemMeta gameItemMeta = gameItem.getItemMeta(); gameItemMeta.setUnbreakable(true); gameItemMeta.setCustomModelData(101); gameItem.setItemMeta(gameItemMeta); gui.addItem(gameItem);Does anyone know another solution or know how to fix this?

eternal oxide
digital rain
#

yes

#

this is the addprimeenchant function

quiet ice
eternal oxide
quiet ice
#

I recommend recompiling with the --stacktrace (I think that was it) flag, I highly doubt that your IDE is at fault here

eternal oxide
digital rain
#

yes the command is all good just the addprimeenchant is unrecognized in the class

quaint mantle
#

ok so I'm trying to cancel players from damaging them selves through arrows and harming potions

#

but how can I check the shooter of such potions/arrows

eternal oxide
digital rain
#

oh yeah true

eternal oxide
#

you test teh Entity instanceof Projectile. If it is, cast to Projection and use .getShooter()

mortal hare
#

You guys literally need to try maven with sublime text 4 and java language server

#

its basically an eclipse but way more efficient

#

on resources

#

no lag whatsover

#

it uses the same language server as Eclipse do

eternal oxide
#

No lag here on Eclipse

mortal hare
#

its even more smoother on ST4 since its written in CPP and has hardware acceleration support

#

it supports maven, stub generation, auto imports

#

its feels like VSCode but way faster and more aproppiate for java

eternal oxide
#

I liked VSCode before it became VSCode. Back when it was for VB8

digital rain
eternal oxide
#

np

mortal hare
true perch
#

When I attempt to run BuildTools.jar, the command prompt appears titled C:\Prorgram Files\Java\jk1.8.0_281\bin\java.exe for a split second and nothing happens. Any fix?

mortal hare
#

try running java -jar BuildTools.jar inside cmd

true perch
#

okay

quaint mantle
#
       if(e.getDamager() instanceof Projectile){
            Projectile projectile = (Projectile) e.getDamager();
            if(projectile.getShooter() instanceof Player){
                Player shooter = (Player) projectile.getShooter();
                if(shooter == e.getEntity()){
                    e.setCancelled(true);
                    return;
                }
            }
        }``` something like this
eternal oxide
#

If you are looking to use 1.17 MC you are going to need to install Java 16

mortal hare
#

yea.. And i still don't understand why archlinux doesnt have java 16 inside their official repo, now i need to use AUR's to install it

quaint mantle
#

But a damage potion isn't a projectile when it attacks the player, right.

eternal oxide
chrome beacon
quaint mantle
#

alright

mortal hare
chrome beacon
#

I think that's the case

#

Try installing a non-lts version and see if it can find it

eternal oxide
#

use whatever you need

quaint mantle
#

but can I get the shooter of a splash

mortal hare
#

wait

#

they added it

#

no way

#

they literally added couple days ago to the repo

#

nice

#

that's not the case then

eternal oxide
quaint mantle
#

ah coolio

chrome beacon
mortal hare
#

yep

quaint mantle
#

couldn't I just use the damage event instead of a splash event that way

mortal hare
#

found the non headless version too

chrome beacon
#

Sorry for the repeat pings ;/

eternal oxide
#

as it has its own

quaint mantle
#

but the potion is an entity right

eternal oxide
#

yes

#

but its not the entity thats actually causing the damage

#

its the effect

smoky anchor
#

Hi, how does one check if block contains liquid. Block.isLiquid() checks if it is water or lava and the Waterlogged interface does not work on seagrass.

eternal oxide
#

isWaterlogged is for flooded blocks like corals and fenceposts/stairs. It should work for seagrass, unless its been forgotten

smoky anchor
#

well seagrass is not waterlogged as it can not be without water

chrome beacon
#

Yeah was about to say

#

It has to be in water

eternal oxide
#

if it can't be without water isn't it a superfluous test to see if it has water?

quaint mantle
# eternal oxide I don;t believe a splash potion would trigger that event
    @EventHandler
    public void onSplash(PotionSplashEvent e){
        Potion potion = (Potion) e.getPotion();
        if(potion.getType() == PotionType.INSTANT_DAMAGE){
            Projectile projectile = e.getEntity();
            if(projectile.getShooter() instanceof Player){
                Player shooter = (Player) projectile.getShooter();
                e.getAffectedEntities().remove(shooter);
            }
        }
    }```
quiet hearth
#

How does one change the dye color of a piece of leather armor

smoky anchor
#

I was wondering if there is like one function that checks if there is liquid in this position or not.

eternal oxide
hallow escarp
#

Hello! I am trying to make a falling block to drop random materials on the world.
I have this code, but the falling block doesnt appear or fall.

Location pos = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() + 50, p.getLocation().getY());
          FallingBlock fallingBlock = p.getWorld().spawnFallingBlock(pos, Material.OAK_LOG, (byte)0);```
p is the player variable by the way.
eternal oxide
quaint mantle
eternal oxide
#

k

hallow escarp
#

aka replacing pos with p.getLocation()

#

I also tried teleporting the player to pos, and it worked fine so it has nothing to do with pos

eternal oxide
hallow escarp
#

Thats odd because I was able to tp to it

#

Without any issues

quaint mantle
#

Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftThrownPotion cannot be cast to org.bukkit.potion.Potion
when i do Potion potion = (Potion) e.getPotion();

hallow escarp
#

Ill try this though

eternal oxide
#

Just showing a simpler way to create the location

hallow escarp
#

ah

quaint mantle
#

replaced it with java ThrownPotion potion = e.getPotion(); if(potion.getEffects().contains(PotionType.INSTANT_DAMAGE)){

eternal oxide
# hallow escarp ah

are you using 1.8? If not you shoudl really use one of the non deprecated methods

smoky anchor
next zinc
#

?paste

undone axleBOT
eternal oxide
#

isWaterlogged shoudl be mapping that method

next zinc
#

Ok so whenever I make a player interact event I get a ton of errors mostly revolving around a NPE when I detect if the player has the correct item in their hand. However, I'm not sure exactly how to stop this.
https://paste.md-5.net/bomezepebi.cs

smoky anchor
quaint mantle
#

item may not have itemmeta

eternal oxide
next zinc
#

I know that, but how exactly can I detect those things?

#

make like a check to see if the player is holding null and then cancel it or soemthing?

eternal oxide
#

every time you can get null, assign to a variable and test it

next zinc
#

If I did this would that just automatically make everything else not be detected?

if(!player.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals(ChatColor.DARK_GREEN + "Common Loot Box")) {
                event.setCancelled(true);
                return;
            }
eternal oxide
#
ItemStack item;
if ((item = player.getInventory().getItemInMainHand()).hasItemMeta())```
next zinc
#

ohh

#

I see

eternal oxide
#

you can then use item to do yoru other tests

next zinc
#

thats smart

#

ty

#

ill test it out

hallow escarp
quaint mantle
#

setting it's velocity

hallow escarp
#

Ive tried, instead of making it slower, it just instantly drops

lean gull
eternal oxide
#

yes

sage swift
#

lol

hallow escarp
eternal oxide
#

what are you setting a velocity?

hallow escarp
#

the falling block

eternal oxide
#

yes, what value are you setting?

hallow escarp
#

-1, -1, -1

eternal oxide
#

yeah, thats not going to be good

hallow escarp
#

why>

eternal oxide
#

thats is a vector with length of 1 in all directions

#

fast

hallow escarp
#

so is it the higher i go the slower?

#

or uh?

eternal oxide
#

try new Vector(0, -0.1, 0)

hallow escarp
#

alright

true perch
hallow escarp
#

its just instantly on the floor

#

it doesnt smoothly fall

#

just instantly goes on the floor

#

i dont know if it matters that im using a chest

eternal oxide
#

use a smaller value

hallow escarp
#
            Location pos = p.getLocation().clone().add(0,50,0);
            FallingBlock fallingBlock = p.getWorld().spawnFallingBlock(pos, Material.CHEST.createBlockData());
            fallingBlock.setVelocity(new Vector(0, -0.1, 0));````
#

here is my code

#

with the 0.1

#

figured out why

#

it has to do with the chest

#

for some reason chests cant be smoothly dropped

eternal oxide
#

try fallingBlock.setVelocity(fallingBlock.getVelocity().multiply(0.5))

#

does it have gravity enabled?

hallow escarp
hallow escarp
hallow escarp
eternal oxide
#

odd, but good to know chests are funky

hallow escarp
#

yeah lol

hallow escarp
eternal oxide
hallow escarp
#

is there supposed to be a -0.5

#

or just 0.5

eternal oxide
#

just 0.5

hallow escarp
#

yeah it just makes it super fast

eternal oxide
#

k

dusky spade
#

ik this not bukkit server, but what sound from mc could I use to make a "ding" sound?

hallow escarp
#

player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.5f, 1f);

#

thats what i use atleast

dusky spade
#

hm

#

leme try

#

Hmm

#

its nice

#

but too long

hallow escarp
#

change the pitch maybe

#

i have no idea

dusky spade
#

it sthis one!

#

ENTITY_EXPERIENCE_ORB_PICKUP

vital ridge
#

Can anyone help me to understand this code a bit more?

for (double t = 0; t < 50; t += 0.5) {

                    double x = radius * Math.cos(t);
                    double z = radius * Math.sin(t);

                    p.getWorld().spawnParticle(
                            Particle.REDSTONE, new Location(p.getWorld(), p.getLocation().getX() + x,
                                    p.getLocation().getY() + 1, p.getLocation().getZ() + z),
                            1, new Particle.DustOptions(Color.AQUA, 1));

                }

this code creates a circle
a circle
the thing is
iam fully aware how cos and sin work
i know that if you multiply hypothenus with math.cos(degrees) you will get the horizontal side of the triangle
and sin returns the vertical side of the triangle
the thing is
i cant understand how this is used to create a circle
the 0.5 i understand is how close the particles are to each other
but i dont understand why it is used as the degrees

true perch
#

I'm trying to add some flags to an item, this is what I have but I'm not sure how to initalize ItemFlag flag;

This is what I got so farjava ItemFlag flag; gameItemMeta.getItemFlags().add(flag);

vital ridge
true perch
#
        ItemMeta gameItemMeta = gameItem.getItemMeta();```
eternal oxide
vital ridge
#

On a circle?

#

Wbu the triangle tho

true perch
# vital ridge flags are added with itemmeta
ItemStack gameItem = new ItemStack(Material.DIAMOND_AXE);
ItemMeta gameItemMeta = gameItem.getItemMeta();
gameItemMeta.setDisplayName("1");
gameItemMeta.setUnbreakable(true);
gameItemMeta.setCustomModelData(101);
ItemFlag flag;
gameItemMeta.getItemFlags().add(flag);
gameItem.setItemMeta(gameItemMeta);```
This is what I have for the itemstack so far, just not sure how to initialize the flag
eternal oxide
#

look up Pythagorean theorum and see where cos and sin are used on a angle of the hypotenuse.

vital ridge
#

thank you ill look into it

eternal oxide
#

not a good example though

vital ridge
#

anything helps tbh

lean gull
#

anyone know why this isn't doing anything when i craft?
public void WaterTNTSound(CraftItemEvent event) {

#

uhhhh

#

imma just casually moonwalk outta here

vital ridge
true perch
# vital ridge instead of getitemflags.add, use gameItemMeta.addItemFlags(ItemFlag.(YOUR_ITEM_F...

I wrote a quick method to remove Item Flags from an ItemMeta, but it doessn't seem to do anything java private ItemMeta hideAllFlags(ItemMeta itemMeta){ itemMeta.getItemFlags().add(ItemFlag.HIDE_UNBREAKABLE); itemMeta.getItemFlags().add(ItemFlag.HIDE_DYE); itemMeta.getItemFlags().add(ItemFlag.HIDE_ATTRIBUTES); itemMeta.getItemFlags().add(ItemFlag.HIDE_DESTROYS); itemMeta.getItemFlags().add(ItemFlag.HIDE_ENCHANTS); itemMeta.getItemFlags().add(ItemFlag.HIDE_PLACED_ON); itemMeta.getItemFlags().add(ItemFlag.HIDE_POTION_EFFECTS); return itemMeta; }

vital ridge
#

as i said, use itemMeta.additemflags

true perch
#

oo I'll do that

minor vapor
#

much cleaner

green comet
#

is anyone in intellij idea rn

true perch
lean gull
#

anyone know why sleep has a red line below it in both of these?
TimeUnit.SECONDS.sleep(1);
Thread.sleep(1000);

true perch
eternal oxide
#

Never use sleep in main thread

minor vapor
minor vapor
#

If you mean the dark gray text, that's client side

true perch
#

yeah

minor vapor
#

I believe anyways

true perch
#

oh right! debug mode

lean gull
#

i'm a beginner so i don't really understand, is there a simpler ways to wait a certain amount of time?

crude axle
quiet ice
#

Then this is almost certainly an outdated plugin or something

minor vapor
#

which is passed through the scheduler? lol

crude axle
crude axle
#

The three modules before that are successful

granite stirrup
minor vapor
green comet
#

does anyone here have intellij idea open?

granite stirrup
#

i think

quiet ice
#

looks like it is as it should, I recommend running it with the stacktrace flag (or whatever it is for maven, I always forget) so we have an idea where it happens

lean gull
chrome crane
#

does anyone know why its doing this? I opened the server file with git and i pasted this command: java -jar BuildTools.jar --rev 1.17
It responed with this:Loading BuildTools version: git-BuildTools-7425fec-128 (#128)
Java Version: Java 8 Please do not run in a path with special characters!

hybrid spoke
chrome crane
#

Is this the wrong channel?

quartz goblet
#

when I take a date and dodate -systemtimeinmillis and do my date calcs and getting like 700,000 extra days. Is there something goofy with java date? I know its deprecated but it should still work no?

lean gull
minor vapor
#

If it's not a thing, try Bukkit#getServer()#getScheduler()

lean gull
#

there is on class bukkit

#

but it doesn't say much

minor vapor
#

Then you don't have it as a depend..

#

you meant "no", correct?

lean gull
#

i'm talkin about the api

#

not in code

minor vapor
#

wdym not in code?

lean gull
#

i mean i'm looking at the spigot api rn

minor vapor
#

which has the Bukkit class?

lean gull
#

?

minor vapor
#

yes, what about it?

lean gull
#

you said that can help, but the information doesn't help me

minor vapor
#

You're trying to delay a task, correct?

lean gull
#

well i'm trying to delay a spawn particle within a for loop

minor vapor
#

it has what you need

eternal oxide
#

he will ask you to ex plain what a task is soon

lean gull
#

idk how to use it doe

lean gull
#

and the information it gives isn't helpful

minor vapor
#

It tells you how to use it..

#

has it all

hybrid spoke
#

share us your code and tell us where exactly the error is at

#

?paste

undone axleBOT
hybrid spoke
lean gull
#

currently i have no errors since i'm not really doing anything

#

just a normal for loop with a spawn particle without the delay

lean gull
#

i have no clue how to use this

granite stirrup
#

bro

minor vapor
#

please read them

granite stirrup
#

i think u do java Bukkit.getScheduler().runTaskLater(plugin,new Runnable() { @Override public void run() { // your code } },Ticks); i think

#

im not to sure

#

never used the scheduler myself

vital ridge
# lean gull i have no clue how to use this

Love the video or need more help...or maybe both?
πŸ’¬Join us on Discord: http://discord.gg/invite/fw5cKM3
Thank you for tuning in to this episode of TheSourceCode! ❀️

If you enjoyed this video make sure to show your support by liking , commenting your thoughts, and sharing for all your friends to see and learn!

All code is available on Github:
...

β–Ά Play video
tame coral
eternal oxide
#

He won't listen to you. He will find Thread.sleep and use it against all advice.

quartz goblet
#

yo if this grace.getTime() - System.currentTimeMillis()) is returning 60 billion and I set it with Date grace = new Date(2021, 5, 18, 4, 35, 0); what am I doing wrong?

gaunt hatch
#

thread.sleep oof, RIP

shadow gazelle
#

How would I check the block above the block broken in a BlockBreakEvent?

eternal oxide
#

block.getRelative(BlockFace.UP)

quartz goblet
#

Location loc = e.getLocation()
loc.setY(log.getY()+1)
loc.getBlock----

dense geyser
#

is it possible to change the speed that an item breaks a block? say have a block of dirt mine a log at the same pace as a diamond axe (like changing it's strength per sec?)

true perch
#
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;

public class ClickListener implements Listener {

    @EventHandler
    public void clickEvent(InventoryClickEvent e){
        if (e.getClickedInventory().getTitle().equalsIgnoreCase("Custom GUI")){
            e.setCancelled(true);
        }
    }
}```
For some reason there's no method ``.getTitle()`` in the clickedInventory event ``e.getClickedInventory().getTitle()``. ``.getTitle()`` errors in the above code
eternal oxide
#

e.getView().getTitle()

true perch
#

Thank you. Was that changed recently?

eternal oxide
#

But don;t match Inventories by name

true perch
#

What's a better way to do it?

eternal oxide
#

best to match by instance

true perch
#

I know what the instanceOf expression is and what it does, and I'm assuming that's what you're referring to but I'm not sure how I would do that