#help-development

1 messages · Page 1692 of 1

lost matrix
#
  1. Target Block might be null. Def check for that.
  2. Pathfinder is not part of Spigot
  3. findPath might return null. Def check for that
  4. Make sure that disabling the AI does not hinder the pathfinder.
copper dove
# lost matrix 1) Target Block ``might`` be null. Def check for that. 2) Pathfinder is not part...

Current code:

                    if (ghast.getPassengers().size() == 0) {
                        this.cancel();
                    }
                    Block block = p.getTargetBlock(120);
                    Location target = block.getLocation();
                    if (target == null) {
                        System.out.println("Target is null.");
                        return;
                    }
                    if (ghast.getPathfinder().findPath(target) == null) {
                        System.out.println("Path is null");
                        return;
                    }
                    ghast.getPathfinder().moveTo(ghast.getPathfinder().findPath(target));
                    System.out.println("Moving ghast to " + target);

Output:
Path is null

#

(disabling AI messes with pathfinder so I removed that)

#

Basically I'm trying to get the Ghast to move toward wherever the Player is looking.

#

(as if you're 'controlling' the ghast)

crude charm
quasi flint
#

no bump

#

if someone knows it he answers

#

or she

copper dove
#

k

burnt current
#

Hey! Short question: I have created the following class to be able to insert something into my database table.:

private DataSourceProvider dataSource;


    public Connection conn() {
        dataSource = new DataSourceProvider(Main.getPlugin());
        return dataSource.getConnection();
    }

    public boolean addPlayer(UUID uuid, String playername, int coins) {
        try (Connection conn = conn(); PreparedStatement stmt = conn.prepareStatement("INSERT INTO playerdata (UUID, playername, coins) VALUES (?,?,?),")) {
            stmt.setString(1, uuid.toString());
            stmt.setString(2, playername);
            stmt.setInt(3, coins);
            return true;
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return false;
    }```
 Unfortunately, I can't call the addPlayer method in my desired location. Can anyone help me with this?
quasi flint
#

its not static

#

dumb dumb

#

?java

#

or create an instance of the class

#

call it from there

copper dove
#

In your class where you're trying to access it, lets say SampleClass.java

#
public class SampleClass {
  private DataManager data;

  public SampleClass(DataManager data) {
    dataManager = data;
  }
}
#

And then access via dataManager.addPlayer()

quasi flint
#

or just Datamanager manager = new DataManager();

copper dove
#

lmao yeah just do that

#

sorry was thinking of a main class

chrome beacon
#

Might not want multiple

#

Since it's a data manager

copper dove
#

^

#

I'd do what I wrote above to get an instance to your main class

chrome beacon
#

I'd do as PxL said

copper dove
#

And then add a dataManager variable to your main class

#

and then access it through that

quasi flint
#

my thing id universal. u can ude it whenver u want. maybe not perfekt for this scenario

#

but works modt of the cases

#

modt

#

most

burnt current
quasi flint
#

use the other answer

#

works beter

#

better

#

from pxl

burnt current
#

ok so i create a new class and create this Methods right?

quasi flint
#

nono

#

@copper dove can u explain it to him

#

i can explain way better

#

u can

#

bruh

quasi flint
#

no classes extra needed

#

put it where u need

#

in the method as an example

copper dove
# burnt current ok so i create a new class and create this Methods right?

Custom config files! Woo, save that data!

P.S I always pronounce "parser" wrong :(

------ Links ------

Download Eclipse: https://www.eclipse.org/downloads/packages/release/2019-03/r/eclipse-ide-java-developers

Download Spigot: https://getbukkit.org/download/spigot

Build Spigot: https://www.spigotmc.org/wiki/buildtools/

Starting Server up: ...

▶ Play video
#

So basically

#

You have your main class (Main.java)

#

In your class (Example.java) have this code:

public class Example {
  
  private Main main;  
  public Example(Main instance) {
    main = instance;
  }
}

and then in your code you can access methods from your main class

#

In your main class

#
DataManager data = new DataManager();
Example example = new Example(this);
#

Make a method like so:

public DataManager getDataManager() {
  return this.data;
}
#

and on your Example class you can use:

#
main.getDataManager().whateverMethodYouWantHere
#

if this doesn't make sense you need to learn basic java.

#

(not a bad thing! we all start somewhere :D)

tardy delta
#

Of just private Main plugin = Main.getClass(Main.class);

prisma needle
#

Is it possible to get a list of biomes a player has been in? Sort of like the "Adventuring Time?" advancements, but I want to run my own action once a player has visited certain biomes.

dense remnant
#

How to make a tabcompleter for multiple arguments?

eternal oxide
#

return a List depending on the length of args

gaunt saffron
#

Quick question is there a way with normal minecraft commands
To make a tool that can break any block instantly? Not like remove bur break (like instamine netherrack)
Or do i have to code smth up? (How hard would it be..?) I tried eff 100 netherite pick but dirt takes forever

Pls ping me

dense remnant
eternal oxide
#

What? you return the appropriate list for whatever part of the command you are in (args.length)

dense remnant
#

Sorry for the bad sentence structure xD

I mean when you enter /give, it then suggests entering "<Player>" in greyish color. And in the tabcompleter it looks different

eternal oxide
#

looks different?

burnt current
gaunt saffron
#

Oh

#

Ah nah but then bormal breakkng is influenced too

#

I could use adventure but that mskes lore issues...

#

So prob custom plugin :(
I need to detect when user is clicking on a block and naturally break it...

#

Or amth along these lines

#

🙄

vernal pier
quaint mantle
#

Any formula to convert seconds to ticks?

regal dew
#
  • 20
quaint mantle
#

Thanks

eternal oxide
#

if no server lag/load

visual tide
#

is it possible for a plugin to act as a recieving webhook, or get external data to it in any other way?

potent apex
#

awa

visual tide
solid cargo
#

is there a way i can play a CUSTOM song/sound (nbs ofc) when my custom entity spawns

hasty prawn
solid cargo
#

only example i know is when you summon a dragon in hypixel skyblock, it plays a song

hasty prawn
#

For a new song you'd have to use a resource pack, otherwise you can do it by just combining all the current MC sounds and playing them as a song.

solid cargo
#

but how can hypixel do that

#

they play it like

#

somehow different

hasty prawn
#

Doubt it. There's a lot of sounds at your disposal, especially with volume and pitch settings.

solid cargo
#

also combining all mc sounds is way too messy

hasty prawn
#

It is, but you'll have to use a resourcepack if you want to avoid that.

solid cargo
#

so you think hypixel did it the dirty way?

gaunt saffron
hasty prawn
#

If they made a song without requiring a resourcepack? Yep.

solid cargo
#

huh??

hasty prawn
#

They do it all the time. What do you think the Housing Parkour music is? Thonk

solid cargo
#

oh

#

they run a plugin

#

something like GMusic

#

but better

#

and also if they did that shiz manually, the plugin file would be like at 100mb

hasty prawn
#

Nah, you can probably make an external file to house the song data and then the plugin just reads the file to know when to play what sound

solid cargo
#

lmfao

#

then the admin's patience is insane

#

OH WAIT

#

OR

#

add that gmusic thing

#

and when the boss spawns, play the music to the e.getPlayer()

#

with a command

hasty prawn
#

Why a command

solid cargo
#

like

#

something like

#

runCommand (idk the thing) and then ("/gmusic play SONG_NAME " + e.getPlayer)

#

no?

#

you know the GMusic plugin right?

hasty prawn
#

Yeah but I'm guessing it has an API for playing something to a player.

#

It's unlikely they're using GMusic anyways.

solid cargo
#

yeah they coded their own plugin

#

but a beginner can use GMusic

#

i will try with GMusic

restive tangle
#

for some reason i cant get a reference of my Main class

ivory sleet
#

You probably want to have another reference then

regal dew
#

use the this keyword in your Main class and pass it around as parameter of constructors of other classes

restive tangle
#

nevermind , i changed its name and it seems to work now

solid cargo
#

how can i make a specific task only run once

safe flower
young knoll
solid cargo
#

wait nvm

#

but i want for an event task to run once

young knoll
#

What?

solid cargo
#

cuz i currently use this method

#

for the task to run, but now that the testing has ended, i need to make it to run only once in the bosse's lifetime

young knoll
#

Save the bosses uuid in a set after it runs and use contains

#

Or add a pdc tag after its run

solid cargo
#

yeah but can i do it for a whole chonk of tasks

#

like 150 lines of tasks

quaint mantle
#

Any efficient way to update a scoreboard?

solid cargo
#

for who was that meant @quaint mantle

quaint mantle
#

For Rayan sorry.

solid cargo
#

ah ok

quaint mantle
#

i dont get reflections

#
    public static void spawnAs(Player player, Location loc) {
        EntityArmorStand stand = new EntityArmorStand(((CraftWorld)loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());

        PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand);

        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
    }
#

like how to do this

#

with reflections

young knoll
#

A lot of getDeclaredMethod and class.forName

quaint mantle
#

bruh can anyone spoonfeed me that ?

young knoll
#

I mean I don’t think anyone will do that

#

You should consider doing research into reflection

#

Or using a module system

quaint mantle
#

i realy dont get reflections

#

any way to change spigot api armor stand for each player without packets ?

young knoll
#

Probably not

quaint mantle
#

i realy dont get reflections

proud basin
#
System.out.println("Spoonfeed");```
young knoll
#

I generally don’t use it for NMS

#

Modules take a bit more time, but are easier to follow

onyx shale
#

Same.. reflections are breaking things,also a reason why it broke so much with the new java version

young knoll
#

Now you get to used cursed unsafe

quaint mantle
#

oh

#

mobile hates codeblocks, plx forgiv

tardy delta
#

System.err.println("err")

floral pewter
#

Hey. I'm trying to use the ProtocolLib Play.Server.RECIPE_UPDATE packet, but without any luck. I haven't been able to find example usages of it, so I started looking for the structure which I'm supposed to construct the packet with.

Running java PacketContainer packet = new PacketContainer(PacketType.Play.Server.RECIPE_UPDATE); for (Field field : packet.getStructures().getFields()) { Bukkit.broadcastMessage(field.getAnnotatedType().toString()); } gives me java.util.List<net.minecraft.world.item.crafting.IRecipe<?>>, for which I find no structure modifiers except for .getAttributeCollectionModifier()

#

I am unsure how to serialise custom crafting recipes into this format

gritty urchin
#

Hey how do I use an internal module as maven plugin

floral pewter
#

What I'm essentially trying to do is send stonecutter recipes ad-hoc as the player opens the GUI

gritty urchin
#

which doesn't use the pluginRepositories repo

burnt current
somber hull
#

So, i want to have a general idea of what im doing before making my plugin

#

How would i go about custom boats

#

Im thinking about just doing it the same as custom vehicles

#

But on water

#

But how would i go about making said custom vehicles, i know i have to use packets

#

But the only source code i could find to help me out used NMS

#

I wanna use protocollib

ivory sleet
#

What’s the actual question?

somber hull
#

How would i make a custom vehicle

#

Im not looking to be spoonfed code, just how i would go about doing it

somber hull
#

@ivory sleet ok 😐

lost matrix
ancient whale
#

Hi, is there a way to perform a bungee command from spigot API ? player#performCommand() googled around and couldn't find anything working.

young knoll
#

I believe you have to use pmc

#

?pmc

ancient whale
mortal hare
#

// C++ code to find
// duplicates in O(n) time
#include <bits/stdc++.h>
using namespace std;
 
// Function to print duplicates
void printRepeating(int arr[], int size)
{
    int i;
    cout << "The repeating elements are:" << endl;
    for (i = 0; i < size; i++) {
        if (arr[abs(arr[i])] >= 0)
            arr[abs(arr[i])] = -arr[abs(arr[i])];
        else
            cout << abs(arr[i]) << " ";
    }
}
 
// Driver Code
int main()
{
    int arr[] = { 1, 2, 3, 1, 3, 6, 6 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
    printRepeating(arr, arr_size);
    return 0;
}
 
// This code is contributed
// by Akanksha Rai

anyone have idea how this algorithm works (ignore the C++ language, this has nothing to do with it)? I cant seem to bend my brain how this works

#

why absolute values are the index value of another's index

idle cove
#

i am trying to start coding spigot 1.8.8/1.8.9 plugins and after following a youtube tutorial to make a simple plugin that outputs a message to the console i got this error in the console and the message that was supposed to be outputted did not appear

#

can i send the error in a pastebin link for help?

mortal hare
#

yes you can

young knoll
#

?paste

undone axleBOT
idle cove
young knoll
#

You need to compile with older java

mortal hare
#

You compiled the plugin with incompatible version of java for the server to run

young knoll
#

You can change that in your build script or in the project settings of your ide

mortal hare
#

you compiled the plugin for the java version which your server doesnt use

#

for 1.8.8 you need to compile this with Java SE 1.8

#

or Java SE 1.7 iirc, but both versions are legacy versions, which are deprecated, so i'll choose the most recent one which you can use (1.8 supports lambdas and many optimizations)

hasty jackal
# mortal hare ```c // C++ code to find // duplicates in O(n) time #include <bits/stdc++.h> us...

when you're looking for unique values (which you need to know to remove the duplicate values), you need to store information about whether or not you have seen a certain value. You can either save that in a map somewhere else, with bitflags or what have you. In this case however, it's using the sign of the value at the number you're trying to check; if the number is negative it has already encountered it, otherwise it hasn't (and thus subsequently flips the sign at that location). it's important to note that this only works if (a) you only have positive numbers in the array and (b) that all the numbers are smaller than the length of your array

mortal hare
#

that's what I know myself, the thing is i cant seem to think why it uses this element arr[abs(arr[i])]

hasty jackal
#

because arr[i] may be negative

#

since it may have its sign flipped because the number i was already seen

mortal hare
#

why abs(arr[i]) element value is used as an index for the array

#

all the numbers are smaller than the length of your array

#

that answers my question

hasty jackal
#

arr[i] the value you want to check if it was already seen or not -> abs(arr[i]) because i may have been seen and thus the sign of arr[i] was flipped and you want the original number back

idle cove
# mortal hare or Java SE 1.7 iirc, but both versions are legacy versions, which are deprecated...

i did have a similar problem before when trying to setup the server using git and the solution i found was to delete the jdk 17 that was installed and it allowed me to create the server without problems though before coming to that solution i had searched for so long trying to find out where i can download java 1.8 and couldnt find a link or site to download it by searching on the oracle website and looking for java 1.8 download links on third party sites. do you know where i could find a download to it, sorry if this is a dumb question.

mortal hare
#

google AdoptOpenJDK

#

or Amazon Corretto

#

or Oracle Java SE 1.8

quaint mantle
#

Is it possible to iterate over both online and offline players in one for loop?

#

I'm a slight java newbie, so i'm not sure

mortal hare
#

if you mean OfflinePlayer and Player types, these are derived from Player interfaces so they both could be iterated at the same time

idle cove
#

I downloaded the Amazon Corretto JDK 8, will i have to change anything else or should the server and plugin work now?

mortal hare
#

change the build version inside project

hasty jackal
#

you mean the other way around - a player is also an offline player, but not the other way around. the base one is offlineplayer

mortal hare
#

depending on your IDE

idle cove
#

I use intellij

idle cove
#

but i am not familiar with what you mean

mortal hare
idle cove
#

I use build artifacts, i dont actually know what maven or gradle really is.

mortal hare
#
To change the project structure settings, click the IDE and Project Settings button on the toolbar and select Project Structure the Project Structure button or select File | Project Structure (Ctrl+Alt+Shift+S) from the main menu.
#

there's option to select project sdk

#

change it to 1.8

#

that you've just downloaded

#

if it doesnt exist there, restart your ide

idle cove
#

Ok

mortal hare
#

after that try to build the plugin once again

shadow tide
#

If you are online I got into something personal but I think the code you are looking for is java entity.getPersistentDataContainer().set(key, PersistentDataType.BYTE, 1);

#

When I hover over .set it shows this error The method set(NamespacedKey, PersistentDataType<T,Z>, Z) in the type PersistentDataContainer is not applicable for the arguments (NamespacedKey, PersistentDataType<Byte,Byte>, int)

#

Hello?

idle cove
shadow tide
#

sorry, I still don't fully understand casting, so what do I do?

mortal hare
#

change 1 to 1b

shadow tide
#

got it!

mortal hare
#

b letter should make your number in byte type

shadow tide
#

nope

#

Syntax error on token "b", delete this token

young knoll
#

I think b is Boolean because weird

#

Or nothing

mortal hare
#

oh yea

young knoll
#

(byte) xxx

shadow tide
#

no

mortal hare
#

delete the b

#

letter

#

and do (byte) 1

shadow tide
#

no, wrong paste

#

Type mismatch: cannot convert from void to PersistentDataContainer

quaint mantle
#
for(OfflinePlayer p : Bukkit.getOfflinePlayers()) {
    p.getUniqueId();
}```

Seems to return online players to, is this normal?
idle cove
#

when i run javac version in the command prompt it tells me that i am running javac 1.8.0_302

mortal hare
mortal hare
#

that file has the UUID json map of all players joined in that server previously

young knoll
#

?paste

undone axleBOT
shadow tide
#

PersistentDataContainer container = entity.getPersistentDataContainer().set(key, PersistentDataType.BYTE, (byte)1);

quaint mantle
#

I see

idle cove
#

and even in control panel programs it shows Java 8 Update 261 in the list of programs

hasty jackal
mortal hare
#

you need JDK, not JRE

#

you need development kit

young knoll
idle cove
#

ohhhh

shadow tide
#

ahh

mortal hare
#

not runtime environment

shadow tide
#

wait

#

huh

idle cove
#

if i uninstall the jre will it affect anything or should i download the java 8 jdk first then delete the jre

mortal hare
#

one runs things, other one runs and adds developer features, compilations, libs, etc.

idle cove
#

ok thanks i understand now

idle cove
mortal hare
#

JDK includes JRE

shadow tide
#

oh, didn't know that

#

k

#

well, yeah

#

It doesn't matter the order tho

idle cove
#

the corretto one didnt seem to work so i am going to try AdoptOpenJDK

mortal hare
#

yeah its better to use adoptopenjdk since it doesnt rely on amazon dev team

#

but it works fine

mortal hare
#
PersistentDataContainer container = entity.getPersistentDataContainer();
container.set(key, PersistentDataType.BYTE, (byte)1);
shadow tide
#

Ahh

mortal hare
#

.getPersistentDataContainer(); does

#

that way you store that in a variable and set the returned object via set method

crimson terrace
#

is there a way to set a timer via the persistentDataContainer?

mortal hare
#

you can technically make .set() return the instance of the object but that's illegal in java conventions terminology. Unless you do some builder class

idle cove
#

the only error that i got on both adoptopenjdk and amazoncorretto is Error: java: invalid source release: 14

mortal hare
#

check modules section

#

and check if the java version is correct there too

#

in project structures

shadow tide
#

Ok, I need to somehow get a variable from a different function, possible?

idle cove
#

it is

shadow tide
#

k, how?

mortal hare
#

if function returns something yes

shadow tide
#

does

#

I think

#

its an event

mortal hare
#
int returnedValue = function();
#

you really need to learn the basics of java first. that's not the insult, but necessity, there's no way you're gonna code spigot plugin if you don't know how methods and classes work properly in detail

shadow tide
#

does an event return something?

#

and what

mortal hare
#

Event is a class

#

its an instance object

idle cove
#

the version in the modules is 1.8 aswell

mortal hare
#

try to create new project

#

maybe you used some kind of template

shadow tide
mortal hare
#

.java file is the source code file, .class is bytecode compiled file

shadow tide
#

I mean this public void onRightClick(PlayerInteractEvent event) {

mortal hare
#

basically a class is technically translatable unit in the terms of .class files

#

even if you include multiple classes in one file. it would generate the same amount of .class files in the jar file as if you made them separately

shadow tide
#

I need to grab the container variable from an event so I can detect it in a different event

mortal hare
#

what's the event type

#

i havent used Spigot API in a while, but I remember a bit of it

#

what type of event do you have as an instance

shadow tide
#

the event I need the container variable from is PlayerInteractEvent and the one I need to detect to is EntityDamageByEntityEvent

mortal hare
#

BlockBreakEvent, EntityInteractEvent etc?

waxen plinth
#

?learnjava

undone axleBOT
mortal hare
#

what are you trying to achieve exactly in practical terms

shadow tide
#

I know it isn't supposed to be an insult but seriously I'm fed up with this

#

I am trying to detect if an entity was hit by an arrow spawned by a custom item, and if it is, make the damage it deals really high

waxen plinth
#

When the arrow is shot

#

Add a tag to it

#

Actually no

#

When the arrow is shot just set its damage higher

waxen plinth
#

You can do that without fiddling with the damage event

#

Literally Arrow#setDamage

shadow tide
#

omfg, I haven't even thought about casting the arrow entitytype to my entity I'm so fcking stupid

mortal hare
#

that's limiting tho, because he couldnt do anything besides setting the damage

waxen plinth
#

If that's all you want though

#

The solution is that simple

mortal hare
#

if you want to add message when the player is hit or some kind of custom event

#

you need to add some data

#

to store about the arrow

idle cove
#

Thank you so much dovidas i really appreciate it it all works now!

mortal hare
#

np

shadow tide
#

this gives me an error ((Arrow) entity);

waxen plinth
#

Are you gonna tell us anything else

#

Like, I don't know, the surrounding code

#

The error

shadow tide
#

sorry

mortal hare
#

lol

#

i just found out

#

that the trident

#

is technically an "arrow" in the game code

#

😂

waxen plinth
#

Nice

shadow tide
#

error The left-hand side of an assignment must be a variable surrounding code Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.ARROW); ((Arrow) entity);

mortal hare
#

well

#
Arrow entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.ARROW);
#

what about this

shadow tide
#

yeah

waxen plinth
#

You can't just do (Arrow) entity

#

You have to assign a variable to that

shadow tide
#

this worked for a fireball Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL); ((Fireball) entity).setYield(10);

waxen plinth
#

Yeah

#

Just casting doesn't do anything though

#

It's like if you just did

#

4;

#

What is the language supposed to do with that

#

You either call a method or set a variable to it

shadow tide
#

I also tried to do ((Arrow) entity).setDamage it threw the same error

young knoll
#

Pretty sure spawnEntity returns the right type anyway

#

So you don't need to cast

mortal hare
#

casting returns the object in other data type thus why you should save it to the variable

#

else it would decay to nothing and will not be compiled, since it wouldnt be used and it would be useless

#

its like a function with a return value, but its not a function but it works similarly

lost matrix
lost matrix
young knoll
#

Ah

shadow tide
#

please don't tell me I'm stupid but would this work Arrow entity = (Arrow) player.getWorld().spawnEntity(player.getLocation(), EntityType.ARROW);

#

prob not

#

but

mortal hare
#

also afaik interface Arrow wouldnt include spectral arrows

#

so if you want those you need to get AbstractArrow interface instead of Arrow

lost matrix
shadow tide
#

I'm not talking about that]

#

the fireball was just an example

lost matrix
shadow tide
#

so this would work? java Location location = player.getLocation(); final World world = location.getWorld(); final Arrow entity = world.spawn(location, Arrow.class, ball -> ball.setDamage(10));

#

I should change the variables but

#

yes?

rough jay
#

why this is not triggered when teleport cause is END_GATEAWAY:

   public void onPlayerTeleportTp(PlayerTeleportEvent e) {
        Bukkit.broadcastMessage(e.getCause() + "");
    }
mortal hare
#

my theory would be that teleportation is not the same as entering the separate dimension since it would need much more to do for the Server to get you there vs just a simple teleportation

#

do you mean the end portal or that credits portal

shadow tide
#

now none of my events are working and there are no errors

mortal hare
rough jay
shadow tide
#

I gtg soon

#

pls

dull sparrow
#

Adding NMS EntityPlayer to server causes NPE

mortal hare
#

credits still counts as dimension portal still it teleports you back to overworld

#

but it derives from playerTeleportEvent

#

🤔

#

that's really interesting

wispy monolith
#

How to check if a player have a specific potion effect?

fossil prawn
#
if(response.transactionSuccess()){
                String m = plugin.getConfig().getString("Settings.klaarmessage");
                m.replace("%geld%", String.valueOf(amount));
                this.p.sendMessage(Logger.color(m));
            }

why does this still send: + %geld%?

mortal hare
#

#org.bukkit.entity.LivingEntity.getActivePotionEffects();

wispy monolith
mortal hare
#

idk man sorry

hasty jackal
wispy monolith
#

How to check if a player have a specific potion effect?

mortal hare
#

dude

quaint mantle
wispy monolith
mortal hare
#
if (player.hasPotionEffect(PotionEffectType.BAD_OMEN)) {
  player.sendMessage("You have bad omen effect!");
}
quaint mantle
mortal hare
#

PotionEffectType is an enum

wispy monolith
fossil prawn
mortal hare
bright wind
#

anybody know how i can cancel runnable?

blissful folio
#

How can I rotate an armor stand's face and body to face EXACTLY where the player is facing?

quaint mantle
#

🙂

crimson terrace
blissful folio
crimson terrace
#

you can get the taskID from the scheduling and cancel that outside the runnable

#

or are you trying to cancel it inside the runnable?

echo basalt
blissful folio
#

Oh I see

#

what would target be?

echo basalt
#

the armor stand's location

#

if it gives weird results invert the variables

blissful folio
#

Alrighty

#

I'll see if it works, thanks!

#

and actually, how would i implement the rotation angle?

crimson terrace
#

anyone know how to stop TNT from blowing up items?

#

cancelling the explodeEvent doesnt work

blissful folio
mortal hare
crimson terrace
#

doesnt that just clear the blocks that get destroyed in the explosion?

hasty jackal
mortal hare
#

oh yeah right

echo basalt
#

Not too sure on euler angles

#

but treat the rotation angle as yaw

mortal hare
#

try to hook entityevent

crimson terrace
#

hm

mortal hare
#

and see what type causes the items to dissapear

blissful folio
fossil prawn
crimson terrace
#

never worked with EntityEvent, will try it tho 😄

mortal hare
#

technically dropped items are entities

#

so they must be either deleted or damaged

crimson terrace
#

not just technically

mortal hare
#

and maybe the explode algorithm fires entity events

crimson terrace
#

im not sure how to work with EntityEvent tho

mortal hare
#

oh its an abstract class

#

try to hook entitydeath or entitydamagebyentity

#

events

#

and see if your dropped items pop up there as an victims

crimson terrace
#

well its not entityDamageByBlock since primed tnt is an entity

mortal hare
#

right

crimson terrace
#

yeah I dont know how to continue from this

tall dragon
#

well cancel the event?

crimson terrace
#

cant cancel that and I only want it to not disappear if the tnt that blows it up has a specific Scoreboardtag

mortal hare
#

you can do that or

crimson terrace
tall dragon
#

which event ru using

crimson terrace
#

I think the EntityDamageEvent would be better than the deathEvent

#

since you get a cause there

mortal hare
#

but items dont have health

#

they kinda dissapear

crimson terrace
#

it might still get damaged

#

who knows... its worth a try 🙂

mortal hare
#

try to send the message first

#

to see even if that count as death/damage for an item

crimson terrace
#

will do

tall dragon
#

EntityDamageEvent should work

crimson terrace
#

no I think it needs EntityDamagedByEntityEvent since I have to have getters on the tnt that explodes

tall dragon
#

what for

crimson terrace
#

since I have to check wether the tnt which blew up has a certain Scoreboardtag

tall dragon
#

well

#

just use the cause

sage dock
tall dragon
#
if (e.getCause() != EntityDamageEvent.DamageCause.BLOCK_EXPLOSION
                && e.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) {
            return;
        }

@crimson terrace

mortal hare
#

there's no difference in results since EntityDamagedByEntityEvent extends EntityDamageEvent

#

since primetnt is the entity and item is an entity it should work just fine

crimson terrace
mortal hare
#

maybe im wrong

crimson terrace
#

XD

tall dragon
#

well shreb it depends should all tnt not blow up items

#

or specific ones

#

?

#

the code i written above simply checks if the item was destroyed by an explosion

#

if not it returns

#

but this method only works if all Tnt should not blow up items

crimson terrace
#

yeah hold on I almost got it i think

crimson terrace
tall dragon
#

that might work, i would add a check wether or not the dropped item is an instanceof Item though

crimson terrace
#

well I am checking if the entity is the type droppedItem

tall dragon
#

@sage dock i think its due to you creating a new MessageManagers class in your TellCommand, ReplyCommand

#

both have different Class instances

#

@crimson terrace can never be too certain :)

tall dragon
#

private final MessageManagers messageManagers = new MessageManagers(); you have this atop both classes

#

meaning they are different instances

#

you're creating new ones

unkempt peak
crimson terrace
unkempt peak
#

Make a getter

tall dragon
#

it is in fact putting the values, in the wrong instance

torn oyster
#

why did intellij make me do this

#

is that even normal

quaint mantle
#

No

#

show the error before

torn oyster
quaint mantle
#

show the code too

torn oyster
#
RarityGuiObject uncommonChest = (RarityGuiObject) new RarityGuiObject(Material.CHEST, ev -> {
        
        }, Rarity.UNCOMMON).setName("&aLoot Crate").addLore(" ", "" + ChatColor.GREEN + ChatColor.BOLD + "UNCOMMON");```
#

thats code

#

imagine it without the cast

quaint mantle
torn oyster
#

oh yeah i think ur right

#

i forgot to change that with the extends

#

oh well lol its fine

young knoll
#

Someone using the full path for DamageCause

quaint mantle
young knoll
#

¯_(ツ)_/¯

#

I guess it makes it a bit clearer?

woeful crescent
#

Anyone know how to use DataWatchers in ≤1.8?

woeful crescent
#

DataWatchers

#

That NMS status thing

#

In 1.8

#

All the documentation is for 1.9+

#

Anyone?

echo basalt
#

create it with the NMS entity

#

write the fields

#

and toss it into the metadata packet

#

And then to write

#

dataWatcher.a(id, value)

#

The accepted value types are these

#

@woeful crescent

safe flower
#

What are the chances I could get someone to join VC and help me with an InventoryClickEvent?

young knoll
#

?ask

undone axleBOT
#

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

echo basalt
unkempt peak
#

Anyone know why Enchantment#getByKey is throwing a noSuchMethodError in version before 1.16?

young knoll
#

Probably didn't exist

unkempt peak
#

if it wasn't added yet what how would you get an enchantment from a string in pre 1.16

young knoll
#

Probably still byName

unkempt peak
#

ah ok

#

will that also work in 1.16+?

young knoll
#

It's deprecated, but it should

unkempt peak
#

ok cool ig ill just have to deal with it being deprecated because i need it for my plugin to be compatible with older versions

#

unless there is a better way of storing an enchant in a pdc

quaint mantle
#

Is there a way I can determine if 2 players are sleeping in a "double" bed ? Would iterate all sleeping players on the same time 1 block apart be a viable option ?

unreal quartz
#

aww cute

quaint mantle
#

😛

somber hull
#

Moving vehicles with packets, how would I Gia bout doing that

#

And if it’s boats should I just use a boat rather than an armor stand?

dense shoal
#

How to I validate that a player is holding a banner?

I'm not satisfied with this. It feels hacky, but it works.

Object.getPlayer().getInventory().getItemInMainHand().getType().toString().contains("_BANNER")```

I feel like it should be something like:
```java
Object.getPlayer().getInventory().getItemInMainHand() instanceof Banner```
But this doesn't work and I don't think instanceof can apply to an ItemStack.

I also don't want to maintain a list of all of the types of banners. Any ideas?
dense shoal
#

I could replace contains() with endsWith()

somber hull
#

If item.getType == material.BANNER

#

dense shoal
#

wat

#

tries

somber hull
#

Use the material bein

#

Enum

quaint mantle
#

No\

#

dont, its deprecated

somber hull
#

dense shoal
quaint mantle
#

Item instnaceof Banner

somber hull
#

Since when?

quaint mantle
#

😐

dense shoal
#

This has been removed for a while

somber hull
#

I’m on mobile

#

Is a banner not a item anymore???

dense shoal
#

There are a ton of diff colors is the issues

somber hull
#

Awww

#

I see

#

Yea

#

If item instanceof banner

#

Should work

quaint mantle
#

it doesnt

#
if (playerMainHand.getItemMeta() instanceof BannerMeta) { /* ... */ }
dense shoal
#

OHHH it's getItemMeta?

quaint mantle
#

ye

quaint mantle
#

did you import the right banner

dense shoal
#

I'm using org.bukkit.block.Banner

quaint mantle
#

org.bukkit.inventory.meta.BannerMeta

dense shoal
#
        // If the player is holding a banner
        if (!(playerMainHand.getItemMeta() instanceof BannerMeta))
            throw new MassiveException().addMsg("<b>You must hold a banner in your hand to do this.");

Perfect, thank you so much! I have another application where I need to try a boat now lmao.

#

OK, so how would I apply this to a boat? I have a monster in the closet type thing that I should think about fixing now.

#

I tried doing the same as that except instance of boat btw

prime reef
#

does anyone know of a spigot library that can accurately handle 3D rotations about arbitrary axes?

#

if not I guess I'll have to do it after all lmao

dense shoal
#

What are you rotating?

prime reef
#

locations

dense shoal
#

Player locations?

prime reef
#

no, Location objects.

#

It's just one set of 3D coordinates about another.

#

It doesn't actually have to be a Spigot library if I can just pass in the numbers and shade in the library, though.

#

I'm lazy and don't want to write a Quaternion class.

dense shoal
#

Gosh, maybe like Transform3D?

prime reef
#

I'll look into it, one sec

prime reef
#

yep, just found it haha

#

thanks though!

#

this might actually be extremely useful, if sort of tedious

#

it's more or less got the functionality I want

#

the main thing I'm having an issue with is rotation about arbitrary axes

dense shoal
#

I had to do this once for a client that wanted a demo of 3D modeling like 3 years ago

#

You need to do this regularly to ever feel comfortable doing this crap

prime reef
#

and it's sort of hard to locate proper information on arbitrary axis rotations because every google result is all about matrix math LOL

#

like bruh I just want something relevant to this library

#

I'm familiar with vector/matrix math, but it's a LOT of boilerplate code

dense shoal
#

I'm a spring guy mostly. But I like hobby coding for this server.

karmic bear
#

what version of java should I use when developing plugins

#

8 or can I use 16

paper viper
#

encouraged to use 16

#

Also im sorry about your pet

#

Hope your pet lives in peace 🤞

karmic bear
#

thank you

karmic bear
#

the guide on setting up bungeecord plugin development on intellij is for 1.16

#
<dependency>
            <groupId>net.md-5</groupId>
            <artifactId>bungeecord-api</artifactId>
            <version>1.16-R0.5-SNAPSHOT</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.md-5</groupId>
            <artifactId>bungeecord-api</artifactId>
            <version>1.16-R0.5-SNAPSHOT</version>
            <type>javadoc</type>
            <scope>provided</scope>
        </dependency>```
#

where do i get the new information for the pom file

#

1.17-R0.X-Snapshot etc

#

the pom stuff doesnt work anymore, or at the very least, not for me

paper viper
#

Try just updating it to 1.17

#

or like

#

set the 1.16 part

#

to 1.17

karmic bear
#

but where did they find the info for that in the first place

#

so i can input the latest values for <version> etc

karmic bear
#

thanks

quaint mantle
#

hi

#

I made it so that blocks were placed 5 blocks away from me

#

@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(e.getItem().getType() != Material.STICK)
return;
if (e.getAction() != Action.RIGHT_CLICK_AIR)
return;

    Block b = p.getTargetBlock(null, 5);
    Location loc = b.getLocation();
    int x = loc.getBlockX();
    int y = loc.getBlockY();
    int z = loc.getBlockZ();
    
    p.getWorld().getBlockAt(x, y, z).setType(Material.WOOD);
#

but if I click with a stick in the water, the blocks are placed in me. how can this be fixed? water is considered as an obstacle

young knoll
#

Use that set where you pass null

#

Pass anything you want to be ignored

quaint mantle
#

I didn't understand. can I have an example, please?

young knoll
#

Block b = p.getTargetBlock(null, 5);

#

Pass a set of air and water

quaint mantle
#

how?

young knoll
#

What version

quaint mantle
#

1.12.2

young knoll
#

Arrays.stream(array).collect(Collectors.toSet());

#

Or just Stream.of

quaint mantle
#

I still didn't understand)

quaint mantle
#

thanks

quaint mantle
#

How to drop particles from the center of the block outwards, like a mini explosion?

#

radius?

#

force i assume

#

i forgor the particle methods

quaint mantle
#

okay

#

Location loc = b.getLocation();
p.getWorld().createExplosion(loc, 1);

quaint mantle
#

?

#

thats an explosion

#

not particles

#

I think he means with particles

#

instead of 1, you can choose a different explosion radius

quaint mantle
#

I would like to make a mini particle explosion coming from the center of the block. It could be rocket particles for example.

#

particle 10.300 y?

dry forum
#

how can i get this to work:

EulerAngle onePercent = givenlocation.subtract(arm).multiply(1d / time2);``` when i hover over (arm) i get this error in intellij ```Cannot resolve method 'subtract(org.bukkit.util.EulerAngle)'```, how can i fix this?
young knoll
#

What is givenlocation

quaint mantle
#

@young knoll

#

please help me. I do not understand

young knoll
#

what

dry forum
# young knoll What is givenlocation
                String locy = args[3];
                String locz = args[4];
                Location givenlocation = new Location(foundCrystal.getWorld(), Double.parseDouble(locx), Double.parseDouble(locy), Double.parseDouble(locz));```
eternal oxide
dry forum
quaint mantle
eternal oxide
dry forum
#

ah ok thanks

quaint mantle
#

hey there, i was wondering if there was a way to take the AsyncPlayerChatEvent and dispense a different message depending on the recipient

#

I know it provides a #setMessage option

eternal oxide
young knoll
quaint mantle
#

guys

#

Is that an option?

eternal oxide
quaint mantle
#

I totally do, but

#

I don't see a setRecipients option here

#

just a getter

young knoll
#

Correct

eternal oxide
#

yes, you getRecipients then modify the collection

young knoll
#

" The set returned is not guaranteed to be mutable and may auto-populate on access. Any listener accessing the returned set should be aware that it may reduce performance for a lazy set implementation.

Listeners should be aware that modifying the list may throw UnsupportedOperationException if the event caller provides an unmodifiable set."

dry forum
#

is there anyway to divide multiply subtract or add EulerAngles?

eternal oxide
dry forum
#

im trying to do double x = 0; EulerAngle originalRotation = foundCrystal.getLeftArmPose().add(x); and its saying 'add(double, double, double)' in 'org.bukkit.util.EulerAngle' cannot be applied to '(double)' ive tried int, float, string, and all that nothing is working (yes i know x = 0)

eternal oxide
#

it requires THREE doubles

dry forum
#

oh ;-;

quaint mantle
#

how to spawn particle in center of block?

#

player.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, block.getLocation(), 30, 0, 0, 0, .3);

#

not spawning in center

hasty prawn
#

Add 0.5 to the Location not the offset.

#

The offset would be 0.5 from the location, so if you want 0.5 from the center, add 0.5 to both the location AND the offset.

quaint mantle
#

works, thanks

quaint mantle
#

Any way to programmatically change a path name in a config?

opal juniper
#

wdym path name

quasi flint
#

prob smth like example.text.1

#

innthe config

opal juniper
#

oh rite

#

i imagine you would have to copy all teh data to a new key and remove the previous one

quaint mantle
#

or anything else

#

cause i dont get what you mean

oblique pike
#

Is there any case in which the plugin will not catch InventoryClickEvent?

oblique pike
#

Then im totally confused

#

As at some point i just see this event being ignored

quasi flint
#

wut?

#

when where and why?

oblique pike
#

I have a GUI that should detect when you put specified item in it and then do things with it

#

But when i randomly place that item many times, there is a totally random point when it does not

quasi flint
#

no clue why

oblique pike
#

Like i even added this shit to see

#

And it does not event write "Click event"

quasi flint
#

maybe just add a delay for the clicking

#

i dunno

oblique pike
quasi flint
#

ignore that

#

wont work

#

i have no clue

#

sory

oblique pike
#

Well i probably understood what happens. Sometimes you just accidentally hold the mouse button for too long and it makes InventoryDragEvent which i do not handle

quasi flint
#

;7

#

than u know what u have to do

quaint mantle
copper scaffold
#

Can someone pleas help me with this?
https://pastebin.com/s6hJDNHk
why is my permission not setting the right way? I can't find whats wrong. Its not working because my blockbreak event will be cancelled when i have not the permissions, it looks like this:

public class BreakBlockListener implements Listener {  
  @EventHandler
    public void breakBlock(BlockBreakEvent e){
        Player p = e.getPlayer();
        if(!p.hasPermission("blockbreak")){
            e.setCancelled(true);
            Plugin.INSTANCE.log("test");
            p.sendMessage(ChatColor.RED + "You don't have the permission to do that!");
        }
    }
}
quaint mantle
#

if you have the permission it will get broken

#

but if you dont it wouldnt ?

#

i dont get it

#

you want to cancel break

#

if someone doesnt have the permission ?

drowsy helm
#

thats what they're doing

copper scaffold
#

it is not working after i set the permission to a player.

quaint mantle
#

try checking for perm "blockbreak.break"

drowsy helm
#

dont just use blockbreak as a perm name

copper scaffold
#

okay

#

should i set this permission into the plugin.yml or not?

drowsy helm
#

not entireley necessary

#

that code looks fine i think its just your Permissions stuff thats not properly assigning the perm

copper scaffold
#

okay

copper scaffold
quaint mantle
drowsy helm
#

thats just a permission name it makes no difference

#

the problem is in setting the perms

copper scaffold
eternal oxide
#

How are you giving the player the permission?

copper scaffold
eternal oxide
#

did you get teh attachment or create a new one?

copper scaffold
#

im doing it like this:

 public void setupPermissions(Player p){
        UUID uuid = p.getUniqueId();
        PermissionAttachment attachment = p.addAttachment(this);
        this.playerPermissions.put(p.getUniqueId(),attachment);
        PermissionAttachment attachments = this.playerPermissions.get(uuid);
        String rank = PermissionConfig.INS.get("groups." + uuid + ".rank");
        for(String perms : PermissionConfig.getConfiguration().getStringList("groups." + rank + ".rank")) {
                log(perms + "");
                attachments.setPermission(perms, true);
        }
    }
eternal oxide
#

what does your log show for adding permissions?

copper scaffold
#

the blockbreak.break permission

eternal oxide
#

after you add all your permissions to the attachment try calling attachments.getPermissible().recalculatePermissions();

copper scaffold
#

okay

#

isn't working

eternal oxide
#

?paste your actual log where its adding the perms

undone axleBOT
copper scaffold
copper scaffold
eternal oxide
#

FishenJoe got the perm but the player who joined is BimEinsGamer?

#

however your log doesn't prefix so it it giving a perm of FishenJoe blockbreak.break?

copper scaffold
quaint mantle
#

I made it so that blocks were placed 5 blocks away from me
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(e.getItem().getType() != Material.STICK)
return;
if (e.getAction() != Action.RIGHT_CLICK_AIR)
return;

    Block b = p.getTargetBlock(null, 5);
    Location loc = b.getLocation();
    int x = loc.getBlockX();
    int y = loc.getBlockY();
    int z = loc.getBlockZ();

    p.getWorld().getBlockAt(x, y, z).setType(Material.WOOD);

but if I click with a stick in the water, the blocks are placed in me. how can this be fixed? water is considered as an obstacle

shadow tide
#

I have a PDC in an event, and I need to check if an entity has that PDC in another event, specifically this one EntityDamageByEntityEvent. How would I do this?

compact cape
#

Any one experienced with citizens api?

#

I have 2 issues

shadow tide
eternal night
#

the pdc is persistent ? Setting a value in it in one event will respectively allow you in another event to get or has that value

compact cape
#

Citizens API:

  1. The skin I set is not working 😦
SkinTrait skin = this.npc.getTraitNullable(SkinTrait.class);
if (skin != null) skin.setSkinName(player.getName(), true);
  1. I want to make my NPC be targetted by mobs like a player does
shadow tide
eternal night
#

why would you have a container variable ? The pdc is meant to attach data to an entity/tile entity/item stack

shadow tide
#

idk

eternal night
#

passing your namespaced key around is another thing, you might be able to do that through normal dependency injection

#

e.g. as a constructor parameter

shadow tide
#

gtg

quaint mantle
#

getTargetBlockExact();

#

is there any analog on version 1.12.2?

chrome beacon
#

Show code

unreal quartz
chrome beacon
quaint mantle
chrome beacon
#

Then merge them

quaint mantle
#

*no idea how to merge them

eternal oxide
#

basic java

quaint mantle
#

Gonna google time

chrome beacon
#

Just add a second argument

quaint mantle
chrome beacon
#

You need to give it both

#

This is quite basic Java

eternal oxide
#

google "java multiple arg constructor"

quaint mantle
#

Yep im trying to find the correct word lol

chrome beacon
#

ElgarL have you worked with Bluetooth?

#

I'm struggeling to get things working

eternal oxide
#

problems with the stack?

#

Windows is shit for Bluetooth

chrome beacon
#

Debian11

eternal oxide
#

You have more of a chance then

chrome beacon
#

Well bluetooth is working. I just have no idea how to control it with Java or JS

eternal oxide
#

I've never tried

chrome beacon
#

I found the Eclipse Kura library docs are meh

eternal oxide
#

Your using a 3rd party API or Oracles?

chrome beacon
#

Oracle has none

#

It just has a standard it does not exist in the jdk

#

And the libraries that implement it are 10 years old or paid

eternal oxide
#

nothing recent

quaint mantle
#

guys

#

@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(e.getItem().getType() != Material.STICK)
return;
if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
return;

    Block c = e.getClickedBlock();
    
    Location loc = c.getLocation();
    int x = loc.getBlockX();
    int y = loc.getBlockY();
    int z = loc.getBlockZ();
    
    
    p.getWorld().getBlockAt(x, y, z).setType(Material.WOOD);

    e.setCancelled(true);
    
}

}

#

this puts blocks when I click on the stick

#

but it replaces the block with wood

eternal oxide
#

So whats the problem?

quaint mantle
#

how can I make the blocks be placed as usual without a stick?

eternal oxide
#

what blocks?

quaint mantle
#

I want that when you click on the stick, the blocks are placed as usual

#

how can I send a screenshot or video?

eternal oxide
#

You are not making sense. Your last two statements directly contradict each other

quaint mantle
#

when you click on a block with a stick, the blocks are replaced with wood. I need them not to be replaced, but to be put

eternal oxide
#

put?

quaint mantle
#

no

#

this is a translator

#

place

eternal oxide
#

Currently you replace the hit block with wood. What do you want to happen?

quaint mantle
#

so that it happens like a normal block that I put with my hand

eternal oxide
#

so when you click with a stick you want a wooden block placed, as if you had placed it?

quaint mantle
#

нуы

#

yes

eternal oxide
#

block = event.getClickedBlock().getRelative(event.getBlockFace());

#

then you just set that to Wood

quaint mantle
#

щлфн

#

okay

#

thanks

#

works!

#

thank you very much

slim kernel
quaint mantle
#

I didn't understand. write more details

eternal oxide
#

You are using startLocation.add This modifies the Location itself, so you are actually modifying it 3 times

slim kernel
eternal oxide
#

If you want to calculate a location clone it, or only add to it once

#

well, you can;t do that in a single for loop in a method without a timer

eternal oxide
#

it would all be done instantly and you'd only see teh final result

quaint mantle
#

@eternal oxide

quaint mantle
#

how do I pick up an item from the inventory?

eternal oxide
#

expand

#

pickup an item?

quaint mantle
#

yes

eternal oxide
#

I don't understand what you want to do

quaint mantle
#

pick up an item from the inventory

eternal oxide
#

Not enough information

last ledge
#

someone pls tell me

#

how to make custom items destroy after use

quaint mantle
#

p.getInventory().remove(Material.STICK);

#

like this, only pick up 1 item

eternal oxide
#

ah

last ledge
#

for me

quaint mantle
#

no

quaint mantle
last ledge
#

I made a custom item which adds max health of a player

quaint mantle
#

just a second

last ledge
#

i want the item to be usable only once

#

like 1 item = 1 heart

#

but when players use item

#

the item dosent get destroyed

eternal oxide
# last ledge this is the answer?
inven = p.getInventory();
slot = inven.first(Material.STICK);
item = inven.getItem(slot);
item.setAmount(item.getAmount() - 1);```
#

You may have to put the item back in the slot you got it from. Its been a while since I used an Inventory

last ledge
#

i want to destroy item

#

not put

eternal oxide
#

that wasn;t for you

last ledge
#

u pinged me???

eternal oxide
#

oh sorry, wrong pping

last ledge
eternal oxide
quaint mantle
#

this removes the item completely

last ledge
eternal oxide
quaint mantle
#

do you need to remove 1 item after using it?

last ledge
#

are u saying me?

quaint mantle
eternal oxide
#

That code will find the first stick in your inventory and remove 1 from the stack

quaint mantle
#

p.getInventory().remove(Material.STICK);

#

removes all sticks from the inventory any number

eternal oxide
#

yes

#

look at the code I posted for you above

quaint mantle
#

3 stacks were taken away from me

#

okay

#

thanks

last ledge
eternal oxide
quaint mantle
#

Inventory i = p.getInventory();
int slot = i.first(Material.STICK);
ItemStack item = i.getItem(slot);
item.setAmount(item.getAmount() - 1);

last ledge
# eternal oxide Have you tried setting the Attribute for GENERIC_MAX_HEALTH to the ItemMeta?

`
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import smp.heart.heartsmp.items.ItemManager;

public class Heart implements Listener {
@EventHandler
public static void onRightClick(PlayerInteractEvent event){
if(event.getAction() == Action.RIGHT_CLICK_AIR) {
if(event.getItem() != null){
if(event.getItem().getItemMeta().equals(ItemManager.Heart.getItemMeta())){
Player player = event.getPlayer();
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(player.getHealth()+2);
player.getInventory().remove(Material.getMaterial("fragment"));
}
}
}
}
}
`

quaint mantle
#

will take 1 stick from the inventory

eternal oxide
#

please use code nlocks

quaint mantle
#

do you need to pick up 1 item with a specific name and description?

last ledge
eternal oxide
#

yes

#

ok first off fragment is not a valid Material

last ledge
#

where is codenlocks google?

last ledge
eternal oxide
#

So this line will do nothing player.getInventory().remove(Material.getMaterial("fragment"));

last ledge
#

fragment is my custom item

eternal oxide
#

Material is an enum, you can;t add Materials to it

last ledge
#

i have defined material already

eternal oxide
#

then use teh ItemStack reference for fragment

last ledge
#

private static void fragment (){ ItemStack item = new ItemStack(Material.CARROT_ON_A_STICK, 1); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(ChatColor.RED + "Heart Fragment "); List<String> lore = new ArrayList<>(); lore.add(ChatColor.LIGHT_PURPLE + "Use four of these to craft a Heart!"); meta.setLore(lore); item.setItemMeta(meta); fragment = item;

last ledge
eternal oxide
#

player.getInventory().remove(ItemManager.Heart);

last ledge
#

ok

quaint mantle
#

package test;

import java.util.List;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class ItemUtil implements Listener {

public static ItemStack item(Material material, int amount, byte data, String name, List<String> lore) {
    ItemStack item = new ItemStack(material, amount, data);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(name);
    meta.setLore(lore);
    item.setItemMeta(meta);
    return item;
}

public static ItemStack item(Material material, String name) {
    ItemStack item = new ItemStack(material);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(name);
    item.setItemMeta(meta);
    return item;
}

}

eternal oxide
#

or fragment, whatever its called that you are using

quaint mantle
#

ItemUtil.item(Material.ACACIA_DOOR, 1, (byte) 0, "name", "lore");

eternal oxide
#

"lore" is a string, not a List

quaint mantle
#

oh

#

i'm use config

eternal oxide
#

new ArrayList({"lore"}) or something close

last ledge
#

if there is more than 1 in a slot

#

then it dosent remove

eternal oxide
#

then you need to use similar code as I posted above for the Russian chap. you have to match using ItemStack#isSimilar

#

one sec

last ledge
#

can u reply in that message pls

eternal oxide
#

the item is always going to be in hand?

last ledge
#

yes

#

i want the item to be removed when right clicked

eternal oxide
#

then just reduce the stack size

last ledge
#

how

#

pls send me code snippet

eternal oxide
#

event.getItem().setAmount(event.getItem().getAmount() - 1)

#

not sure if getItem clones it though

last ledge
#

eh i dont understand 😦

eternal oxide
#

try that line, see if it works

hasty jackal
#

wouldn't that just do ... nothing?

last ledge
#

where do i add that line

eternal oxide
#

yes sorry

hasty jackal
#

thought as much hah

eternal oxide
#

needs the -1

last ledge
#

where do i add it though

eternal oxide
#

you replace your current line where you try to remove the item

last ledge
#

ok

blissful folio
#

can you offset the armor stand when it's riding a player?

last ledge
quaint mantle
#

Can anyone help me fix a config file? I've been editing the config file essentialsX, and it keeps resetting, which is usually because of the fact that theres something wrong. can anyone have a look? x

quaint mantle
#

oh i thought this counted as development 😅 sorry

tall dragon
#

well you should probably attach the file

#

so people can take a look