#help-development

1 messages · Page 1750 of 1

quaint mantle
#

let's see

#

Also another thing to look into is try-with-resource

#

You can do try (PreparedStatement statement = connection.prepareStatement()) {

}

#

It will automatically close your statement

#

closing the statement didn't really solve my issue

#

Well it was needed anyways :p as for your issue. Not really sure why it’s lagging the main thread when it’s being called asynchronously thTs weird

lost matrix
#

Accessing a database or any other IO on the main thread naturally produces lag

quaint mantle
#

Yea that’s the thing tho he’s doing it asynchronously by the looks of it, unless I missed something. I’m reading his code on my phone so maybe I read it wrong but looks good to me

#

maybe it's happening in other places?

#

how can I pinpoint it

lost matrix
#

I just read the question at the beginning XD
If you want to load player specific data then your should use the AsyncPlayerPreLoginEvent. There you can just access your DB as long as you want.

quaint mantle
#

does it not let the player join until the task has finished?

#

Do you make other DB calls or mess around with any files anywhere?

#

Events don’t complete until what you’re doing inside of the listener is finished

#

I do, hence why I needed help pinpointing the location

#

is there a way to do so?

#

Yea you can’t really pinpoint it you just gotta look at all your db calls and file usage

#

And see if you’re doing anything on the main thread

#

I think I'm (theoretically) doing it in async in every call

#

If I am inside a callback, am I working in the main thread?

#

i.e here

        Database.someStuff(result -> {
            Database.doSomeStuff();
        });
``` where someStuff is wrapped in a .runAsync task
#

Yea if you’re inside the callback as long as you run the call as a sync task it will be on the main thread

#

so in other words doSomeStuff is on the main thread?

#

maybe that's why it was lagging

#

Yes that’s correct

#

in what way can I edit Map asynchronously?

#

via a mutex?

#

How about a ConcurrentHashMap?

wide flicker
#

Anyone know how to prevent an arrow from being sent to clients when fired? (to make it completely invisible)

Tried sending an entity destroy packet immediately after firing the arrow, but it still sometimes appears for a frame or so

quaint mantle
#

Maybe listen to spawn entity packets and cancel it if it’s the right one

rugged topaz
#

can't use player#launchProjectile to launch a bat in the player's front facing direction, what's a solution?

#

or more particularly, i want to launch a bat from the player's face always following the direction of their crosshair

wide flicker
tardy delta
#

in this case, does it creates a new instances on every loop?

unkempt peak
#

Yeah, just create the itemstack before the loop

#

Also you could just set every slot to glass pane and then set your other items overwriting the glass

tardy delta
#

true but then i would have to fill air blocks back in

paper viper
#

thats not readable lmao

tardy delta
#

uhh i only need it once

paper viper
#

It doesnt matter

#

its a large ass array

tardy delta
#

variables that i dont need..

swift spear
#

Trying to update my old plugin to 1.17 coming up with those 2 issues. 1. RandomPositionGenerator isnt a thing anymore? 2. The operator < is undefined for the argument type(s) boolean, double any ideas? 1.16 worked fine

paper viper
tardy delta
#

hmwoa ok

paper viper
#

if people were to look at your code, they would be disgusted from how tight it is

#

store it outside

vague oracle
#

Surely creating 1 array over idk 50 times is better

tardy delta
#

but whats better now when i have only one class instance? making a field static or not when it doesnt really belong to an instance?

#

you mean to the chat?

#

(only he's able to see it)

#

a title on the screen?

#

liek this?

#

player.sendTitle()

#

if you added the spigot api as an dependency

quaint mantle
#

sorted :D

tardy delta
#

is that lang given a value every time an enum value gets loaded?

round gale
#

Is there some way to execute my /version command before the paper one?
(I know about the loadbefore, but I can't load before paper lol)

tardy delta
#

plugin commands should override the vanilla ones by default

ancient plank
#

/pluginnamespace:command

#

like /essentials:kill for example

golden turret
#
String shape = "#########" +
               "#xxxxxxx#"
               "#########";

char[] chars = shape.toCharArray();

int currentItem = 0;
for (char c : chars) {
  if (c == '#')
    //put glass
  if (c == 'x') {
    //put the item based on the currentIndex
    currentIndex++;
  }
}```
rugged topaz
#

if i wanted to manipulate the speed of a bat, would that be with nms or possible thru the API?

tame elbow
#

zomifiedpiglin set agrow(no idea how to spell this word)

#

could anyone help in thread above? ^^^^^^^^^

ivory sleet
#

Be patient

tame elbow
#

okay.

coral helm
#

FileConfiguration

ancient whale
#

Hi, Does anyone know how to get the event trigger from Player#damage ? feels like entitydamage doesn't trigger from what I tested

opal juniper
#

it should

ancient whale
#

Well it actually does trigger when I use the damage(double,entity) but not when I use damage(double)

#

And I am using a plugin which seems to be using the damage(double)

#

Which doesn't trigger properly my events

hardy agate
#

is there a built in method for getting players nbt? (preferably as a raw string or dictionary)

ivory sleet
#

Player extends PersistentDataHolder

#

And PDC API is a way to talk with nbt

hardy agate
ivory sleet
#

PersistentDataHolder has the method getPersistentDataContainer which returns a PersistentDataContainer instance

#

?jd-s

undone axleBOT
ivory sleet
#

search for persistentdatacontainer

#

should give you the methods you need

hardy agate
#

hm

#

this is more or less giberish

eternal oxide
#

?pdc

hardy agate
#

and will this give me raw nbt?

#

I'm not trying to edit a players nbt

#

I'm trying to save it as a string

eternal oxide
#

explain your goal

hardy agate
#

variables

#

in mcfunction

#

${variable name}

#

the idea being that I could say something along the lines of
/var <variable name> = <selector>.getNBT(<path>)

eternal oxide
#

ok, the PDC is persistent. You save your data to the PDC and its on the player object until you remove it or the player data gets wiped.

ivory sleet
#

We still assume you’re coding this in Java

hardy agate
#

yes

#

but it's essentially going to find and replace, and send the edited command

eternal oxide
#

then yes teh PDC is what you want to use

hardy agate
#

and I assume there's something in the docs about this?

eternal oxide
#

we just linked you to teh docs and a tutorial

hardy agate
eternal oxide
#

try reading it?

hardy agate
#

also: the game stops while spigot is running something right?

#

like while I'm running the code of my parser, the server will freeze

eternal oxide
#

if you run it on the main thread, yes

vestal moat
#

protocolib's tab completer events... i see no javadocs... how can i modify that list sent to client?

vast shale
#

Im having issues with opening a custom inventory. I printed out the player's current open inventory and it appears to be changing, but no GUI appears..

Before openInventory(): org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView@3a2ab454
After : org.bukkit.craftbukkit.v1_17_R1.inventory.CraftContainer$1@686a2933

Heres my methods. The message "Opening Win Inventory!" does appear.

    public void WinBattleGUI() {
        WinInv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "" + "Exp");
        initWinInvItems();
    }
    
    public void initWinInvItems() {
        WinInv.setItem(0, createGuiItem(Material.PURPLE_CONCRETE, ChatColor.DARK_PURPLE + "" + "Test"));
    }
    
    public void openWinInventory(final HumanEntity e) {
        WinBattleGUI();
        e.sendMessage("Opening Win Inventory!");
        Bukkit.getServer().broadcastMessage("1: " + e.getOpenInventory().toString());
        e.openInventory(WinInv);
        Bukkit.getServer().broadcastMessage("2: " + e.getOpenInventory().toString());
    }
eternal oxide
#

At what point are you trying to open this inventory? in an event?

vast shale
#

After a battle finishes. I have a method "finishBattle" that invokes openWinInventory(player)

eternal oxide
#

are these triggered through an event?

vast shale
#

Yes, the battle starts on an NPCInteract event

eternal oxide
#

Your debug says you already had a view open when you opened your Inventory

vast shale
#

I run player.closeInventory and print it out. The same

org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView@3a2ab454
``` is printed
#

Is there another way to force close and possible guis?

eternal oxide
#

are you doing any of this from an InventoryClickEvent?

vast shale
#

Yes

eternal oxide
#

finally

#

You need to read teh Javadoc on InventoryClickEvent

vestal moat
#

!paste

#

?paste

undone axleBOT
vast shale
#

Hmm okay. I'll take a look. Am I missing something specific?

eternal oxide
#

yes, very

#

read its comments

vestal moat
#

https://paste.md-5.net/kifimimufe.rb i just did ```java
@Override
public void onPacketSending(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Server.TAB_COMPLETE) {
PacketContainer container = event.getPacket();
String[] completions = container.getStringArrays().read(0);

    }
}```
tame elbow
#

PigZombie.setAngry() has 2 inputs a boolean and arg0. what would go in the arg0 space if the boolean is true?

ivory sleet
#

?jd-s check the docs

undone axleBOT
vast shale
#

I've glanced through, specifically at InventoryClickEvent and am not seeing something obvious...

tame elbow
eternal oxide
#

Because InventoryClickEvent occurs within a modification of the Inventory, not all Inventory related methods are safe to use.

The following should never be invoked by an EventHandler for InventoryClickEvent using the HumanEntity or InventoryView associated with this event:

    HumanEntity.closeInventory()
    HumanEntity.openInventory(Inventory)
    HumanEntity.openWorkbench(Location, boolean)
    HumanEntity.openEnchanting(Location, boolean)
    InventoryView.close() 

To invoke one of these methods, schedule a task using BukkitScheduler.runTask(Plugin, Runnable), which will run the task on the next tick. Also be aware that this is not an exhaustive list, and other methods could potentially create issues as well. ```
tame elbow
vast shale
#

But im using the interface Player not HumanEntity, is this still an issue?

ivory sleet
#

Check their docs then

eternal oxide
#

yes

tame elbow
vast shale
#

What other object could I use? If I can't use Player or HumanEntity

eternal oxide
#

Player is a sub interface of HumanEntity

eternal oxide
#

You do as teh javadoc says and use a runnable

#

read teh javadoc, it tells you to use teh scheduler to run a task 1 tick later

tame elbow
eternal oxide
#

?scheduling

undone axleBOT
vast shale
#

Hmm okay. So I should make a runnable that is invoked to close the player's inventory after 1 tick?

eternal oxide
#

no, to open your new one

vast shale
#

Hmm. I have a battle GUI that opens fine first, but then opening the WinInventory doesn't work. Why would it work on its first interion?

eternal oxide
#

because you are not opening yoru battle inventory through the InventoryClickEvent

vast shale
#

I'm not directly using the InventoryClickEvent to open the inventory. Will the runnable still fix my issue?

eternal oxide
#

You are calling the open method from the InventoryClickEvent

vast shale
#

Not directly, but eventually

eternal oxide
#

it all branches FROM the event. Its an event based system

#

you are still IN the code path of the event when you call open

golden turret
#

?paste

undone axleBOT
vast shale
#

Ahh gotcha, thank you for sticking with me!

#

Look right?

#
public void openWinInventoryLater(HumanEntity e) {
        new BukkitRunnable() {
            @Override
            public void run() {
                e.openInventory(WinInv);
            }
        }.runTaskLater(main, 1);
    }
eternal oxide
#

try it and see, it won't break anything

tame elbow
#

Could anyone help me in my thread? About setting zombified piglin agro.

golden turret
eternal oxide
#

Yeah thats probably not going to work

#

You are trying to create an instance of StringReader, which is a sub class of the class you are in., which has not yet finished being intitialized

#

your abstract class does not actually exist yet when you try to sub class it in StringReader

golden turret
#

hm

#

alright

#

what do you recommend

eternal oxide
#

separate it from your registry

ivory sleet
#

Also y static 😐

eternal oxide
#

Your registry should be autonomous and not depend upon anything

tame elbow
#

Zombiefied Piglin automatically attack players off spawn

mint flare
#

Hey !

I actually create an inventory like a backpack of 27 slots and i put 9 differents item in the first line, 9 red stained glass in the second, and the third is empty.

What event i have to use to see when a player put one item in one slot of this backpack ?

thanks in advance

golden turret
#

inventoru click

mint flare
#

this works if one player just shift+click on item ? 🤔

golden turret
#

yes but it will be called on the player inventory

mint flare
#

Arf :/

golden turret
#

so you need to check the top inventpry

#

the first is the normal click

#

you click and then click in the target inventory with the item in the cursor

#

so you just need to check the clicked inventory

#

the 2nd you need to see if it is a shift click

#

if so you need to verify if the top inventory is your backpack and if it is empty

lost matrix
lost matrix
golden turret
mint flare
round gale
young knoll
#

You can replace it using the PlayerCommandPreProcessEvent

lost matrix
# round gale nope, unfortunately not working

Do you want to actually overwrite a fully namespaced command like
/minecraft:help
Otherwise just registering /help would override the default help command unless you used the full namespace

young knoll
#

Doesn't work with spigot commands, which may be the issue

#

Since spigot replaces /help afaik

#

I did this in the past

#
    @EventHandler
    public void onCommand(PlayerCommandPreprocessEvent event) {
        if (event.getMessage().equalsIgnoreCase("/plugins") || event.getMessage().equalsIgnoreCase("/pl")) {
            event.setMessage("/plugingui:plugins");
        }
    }
round gale
#

I'm using this code. so it should work, if paper cmds are replacable

public class VersionCommand implements CommandExecutor {
    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
        FileConfiguration config = CustomVersionSeedCommand.plugin.getConfig();
        if (sender.hasPermission("CustomVersionSeedCommand.original.versioncommand")) {
            Bukkit.dispatchCommand(sender, "bukkit:version");
        } else {
            Set<String> lines = config.getConfigurationSection(ConfigVariables.VERSION_SECTION).getKeys(false);
            for(String one_line : lines) {
                sender.sendMessage(one_line);
            }
        }
        return true;
    }
}
#

(I do not have OP Permissions)

lost matrix
#

Sysout which branch gets called

round gale
lost matrix
#

Also this can just be bypassed by a user if he just types /bukkit:version instead of /version

round gale
#

you can block that with permissions. What my "client" wanted, was a plugin that can output a funny message, when you type /version

tacit mica
#

There's no event for when tile entities are initialized, right?

lost matrix
round gale
round gale
lost matrix
# tacit mica There's no event for when tile entities are initialized, right?

Meh. Best you can do is this:

  private void initTileEntity(final BlockState entity) {
    // Init/Check your tiles here
  }

  private void initChunk(final Chunk chunk) {
    Arrays.stream(chunk.getTileEntities()).forEach(this::initTileEntity);
  }

  @EventHandler
  public void onWorldLoad(final WorldLoadEvent event) {
    Arrays.stream(event.getWorld().getLoadedChunks()).forEach(this::initChunk);
  }

  @EventHandler
  public void onChunkLoad(final ChunkLoadEvent event) {
    this.initChunk(event.getChunk());
  }

And dont forget to enable your plugin before the worlds load so that the default chunks in the default world are also affected.

round gale
tacit mica
#

One thing though I just remembered

#

Actually nevermind

round gale
#
public class VersionCommand implements Listener {

    public static final String BUKKIT_VERSION = "bukkit:version";

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerExecutingVersionCommand(PlayerCommandPreprocessEvent e) {

        FileConfiguration cfg = CustomVersionSeedCommand.plugin.getConfig();
        String command = e.getMessage();
        Player player = e.getPlayer();

        player.sendMessage("I am being called!");
        player.sendMessage(command);

        if(command.equalsIgnoreCase("/version")) {
            if(player.hasPermission("CustomVersionSeedCommand.original.versioncommand")) {
                e.setMessage(BUKKIT_VERSION);
            } else {
                Set<String> all_lines = cfg.getConfigurationSection(ConfigVariables.VERSION_SECTION).getKeys(false);
                for(String one_line : all_lines) {
                    player.sendMessage(one_line);
                }
            }
        }
    }
}
#

Output in chat:

/version
Normal paper /version output
.
.
.
tame elbow
#

could anyone help me in my thread?

lost matrix
#

First of all:
Dont read out of configurations all the time.
Secondly:
This works for me just fine

public class VersionCommandHandler implements Listener {

  private final Set<String> commandSet = Set.of("/version", "/bukkit:version");
  private final List<String> lines;

  public VersionCommandHandler(final FileConfiguration configuration) {
    this.lines = configuration.getStringList("section");
  }

  private void sendLines(final Player player) {
    this.lines.forEach(player::sendMessage);
  }

  private boolean hasBypassPermission(final Player player) {
    return player.hasPermission("CustomVersionSeedCommand.original.versioncommand");
  }

  private boolean isWatchedCommand(final String command) {
    return this.commandSet.contains(command);
  }

  @EventHandler
  public void onVersionCommand(final PlayerCommandPreprocessEvent event) {
    final String command = event.getMessage();
    final Player sender = event.getPlayer();
    if (!this.isWatchedCommand(command)) {
      return;
    }
    if (this.hasBypassPermission(sender)) {
      return;
    }
    event.setCancelled(true);
    this.sendLines(sender);
  }

}
round gale
#

ahh i forgot the setcancelled

#

I'll take a look at it Tomorrow (I don't want to copy the code if I don't understand it completely)
But a huge thank you! ^^

tame elbow
#

?scheduling

undone axleBOT
rotund patio
#

So I have the standard plugin channel setup, where

player.sendPluginMessage(Plugin.getInstance(), Constants.API_CHANNEL_ID, out.toByteArray());

However, my forge client doesn't receive this. I'm sure that the forge client works for vanilla plugin channels (minecraft:register).

ornate patio
#

if I send chunks to a client outside of render distance using protocollib, will the client just throw it out or nah?

fallow merlin
#

the client wont care if its outside their own render distance right?

arctic moth
#

is there a way to change mob fire rate or does that require forge

ornate patio
#

im just trying to teleport someone millions of blocks away without having the couple seconds of unloaded chunks

arctic moth
#

like make things shoot really fast

arctic moth
ornate patio
arctic moth
#

idk

#

try

ornate patio
#

i have no idea how, and I’ll have to learn protocollib to try it

#

just askin before I spend the time to learn it

dense geyser
#

How do you get the offline UUID of a player?

eternal night
#

what is an offline uuid of a player o.O

young knoll
#

The UUID used in offline mode

#

It's somehow computed by their name

dense geyser
#

WAIT I worked it out

#

UUID.nameUUIDFromBytes(("OfflinePlayer:username").getBytes()) interestingly simple

rancid pine
#

for the attributemodifier, on the operation you can add numbers, but there is no method to set the attribute equal to a certain number

#

all you can do is add and subtract

#

does anyone have any ideas?

brave trellis
#

how would i use '' inside a yml configuration and get it as a string, for example

#
thing:
  - 'd''
#

and get it as d'

sullen marlin
#

"d'"

brave trellis
#

thank u

sullen marlin
rancid pine
brave trellis
#

is it the same?

sullen marlin
#

Idk !!str or a text block maybe

#

Go check a yaml guide

#

Or just call .set in your code and see what spigot does

brave trellis
#

alright

mint flare
#

Hey ! Someone know how to know if the cursor have no Item (in inventory) with getCursor ?

jade perch
#

I assume the value of get cursor would be null

mint flare
#

Me too but getCursor().toString() return : ItemStack{AIR x 0}

jade perch
#

Then check if it's equal to air

mint flare
#

it not match with ItemStack(Material.AIR,0) or ItemStack(Material.AIR)

jade perch
#

Itemstack.getmaterial == Material.AIR

quaint mantle
#

getType

jade perch
#

Yea that

quaint mantle
#

if you didnt switch to web dev you would've known that

#

🙄

jade perch
#

Intellij remembers for me

mint flare
#

Owh good idea x)

#

Yes ! It works ! Thanks a lot 🙂

jade perch
#

Np

mint flare
#

And in 1.8.9 can we differentiate 2 wools ? (different colors)

jade perch
#

Easiest way would probably be XMaterial

young knoll
#

Or the legacy MaterialData

mint flare
#

it's not Deprecated ?

jade perch
#

I mean it's 1.8 so

mint flare
#

true

#

all in .getData() is Deprecated even in 1.8 =' (

jade perch
#

Just use XMaterial

mint flare
#

I don't know what it is, I'll get some information! Thanks

young knoll
#

I mean there is nothing stopping you using it

#

Don't think MD is going to go back to 1.8 to remove it

vast shale
#

I'm trying to order and group player attacks based on a saved integer within objects attached via their UUID. For example, multiple players might have the attack number 4 and i'm trying to add their UUIDs to something so, once their sorted by the saved integer, I can group their attacks together. Does anyone have a clever way of doing this?

quaint mantle
#

Hey, I read you can't track when a player opens their own inventory (since it's client-sided.) what's the next best thing/event?

young knoll
#

Wait for them to click something I guess

quaint mantle
#

just InventoryClickEvent? do I need to do something to determine it's the players inventory and not another?

young knoll
#

Check if it’s an instance of PlayerInventory

quaint mantle
#

alright, thank you

next stratus
humble garnet
#

Anyone here experienced with OP prison style servers ?

drowsy helm
#

somewhat

#

whats the question

humble garnet
#

Looking to make my own server but have absolutely no clue how to code or anything

drowsy helm
#

would you like me to send you some java tutorials?

#

or are you looking for a dev

#

if so

#

?services

undone axleBOT
young knoll
#

I’m sure there are plenty of public plugins to configure

humble garnet
humble garnet
drowsy helm
#

check out the forum link above^

#

and be ready to spend a pretty penny for a dev

humble garnet
#

Any roughy idea of a cost ?

drowsy helm
#

depends on the dev, some do per project, some per hour

#

starting from 15/hr for a decent dev

#

thats a rough estimate, idk some devs charge different

humble garnet
#

Ah ok I see

#

Sorry to sound like an idiot, but how do I write a post in the forum? ( I have an account)

drowsy helm
#

on the top right theres a blue "Post New Thread" button

humble garnet
#

I need atleast 20 posts and a week old account

drowsy helm
#

oh yeah for resources you need some posts

eternal oxide
eternal oxide
humble garnet
#

No, I have no experience

#

I have coded on FIVEM

#

But never in Java

drowsy helm
#

what lang does FIVEM support

young knoll
#

The heck is fivem

quaint mantle
#

I think it's lua

young knoll
#

Oh no

drowsy helm
#

gta roleplay thingo

young knoll
#

Luarraysstartat1

drowsy helm
#

pog

quaint mantle
#

"FiveM supports the general purpose programming language Lua as one of its scripting languages. Lua is a very easy language to learn, simple to use and fast to write. To use Lua, just use . lua in your scripts file extensions."

drowsy helm
#

i learnt lua maybe 5 years ago

#

i hate it

young knoll
#

Skript but LUA

fallow merlin
#

Lua is a very easy language to learn if u hate urself

young knoll
#

Actually that could be kind of neat

fallow merlin
#

or play roblox

drowsy helm
#

i mean theres a lot of lua interpreters out there

eternal oxide
drowsy helm
#

a lua version of skript wouldn't be out of the picture

young knoll
#

Would be less cursed

eternal oxide
#

?learnjava

undone axleBOT
quaint mantle
#

would take a long time to make an op prison server core because of the optimizations needed but I believe you could do it 😄

#

@humble garnet

eternal oxide
#

Theres a few people about who would teach, but not the real basics. You must at least know how to use an IDE and write a java program

young knoll
#

Is optimization that important for op prison

humble garnet
#

Ok thank you, I’ll have a look around, it would probably be a lot quicker and better done if I find a dev though, but I will make sure to have some skills prior! Thank you all for the help

ancient plank
#

fivem supports c# too iirc

#

I used to make fivem c# server addons

humble garnet
#

Ok cool! If anyone knows of any developers looking for work, please let me know! I’m trying to get this sorted as soon as possible!

vocal cloud
#

What kind of work

#

Prison work. Depends on what you need lol. It can cost a few bucks to hundreds depending on many factors

undone axleBOT
sharp saffron
#

hey if I want to learn how to make custom plugins is visual studios a good software to do so? Im asking this as im already familiar with visual studios as I use it for python projects

ivory sleet
#

I’d suggest an actual ide

chrome beacon
#

It is one

ivory sleet
#

But you can make visual studio code to work like an ide with extensions

chrome beacon
#

He said visual studio not vs code

ivory sleet
#

Oh nvm

chrome beacon
#

Too be fair he might be talking about vs code

ivory sleet
#

Ye lol

sharp saffron
#

its da same thing

chrome beacon
#

It's really not

sharp saffron
#

well im an idiot xD

chrome beacon
#

VS code is a fancy text editor. VS is a full IDE

sharp saffron
#

oh

#

My plan is to make a custom crates plugin

#

but im gonna start with something more simple as im not that dumb

chrome beacon
#

I recommend using Intellij for plugins. And then you can use Pycharm for Python

sharp saffron
#

ill check them out

ivory sleet
sharp saffron
#

im a beginer so I know how to do website (html css) and ik the basics aswell hex and binary good enough to know what im doing but im relatively knew to Java and spigot api

ivory sleet
#

Ah okay yeah then initiate with something simpler

sharp saffron
#

im gonna just start with a simple ping pong command

ivory sleet
#

Sounds good

chrome beacon
#

I'd read through one of the Java tutorials too

#

?learnjava

undone axleBOT
sharp saffron
#

in terms of difficulty is do you guys know if java is harder or easier than python?

chrome beacon
#

Harder

sharp saffron
#

k

chrome beacon
#

Python is a quite easy language to learn

sharp saffron
#

yea

chrome beacon
#

Which is why many recommend it for beginners

ivory sleet
#

Igloo did you work with object orientation regarding python?

sharp saffron
sharp saffron
#

well anyway ima get started thanks for the help

chrome beacon
sharp saffron
#

ya ik i was joking

#

last question is intellij free?

chrome beacon
#

Yes if you use the community edition

#

Same goes for pycharm

sharp saffron
#

right one?

ornate spire
#

yes

summer scroll
summer scroll
#

Yeah but I don't know the math for the rotation

tacit drift
#

make a task with a infinite loop that changes setHeadPose constantly

#

i think

ivory sleet
#

Probably want to set the right arm to reach right out such that you get a right angle between the arm and the body, then manipulate the body pose

summer scroll
#

Done the arm

ivory sleet
#

You’ll have to use an EulerAngle for setting the body pose

sharp saffron
#

quick question so ive just downloaded intellij and minecarft developer but for the project SDK what do i select?

summer scroll
#

to rotate it in a task

tacit drift
#

i think intellij can install a jdk by it self too idk

onyx fjord
#

@summer scroll i had a fucking weird dream...

sharp saffron
#

it tells me i can install version from 1.8 to 17 is there any in particular or does it not matter?

summer scroll
#

wut

onyx fjord
#

So I had a dream

#

About your backpack plugin becoming free

#

Yeah...

summer scroll
#

hahahah

onyx fjord
#

I swear to god

#

I thought it's real

#

That's how you end up

#

Being on spigot 24/7

summer scroll
#

you like it huh?

tacit drift
#

😳

sharp saffron
#

im pretty sure that called insanity

summer scroll
#

um the ArmorStand#setRightArmPose doesn't seem to be working for me for some reason.

#

Still downwards like this

onyx fjord
#

Bruh religion exam

#

Wrong chat

onyx fjord
acoustic widget
#

Hello, do you guys use library or something else for easy database managment ? I would like to provide for my future plugin every type of database like h2, json, mysql, sqlite

tacit drift
#

Look at what LuckPerms does

quaint mantle
#

guys

#

i wonder what if i remove the unsafe values in spigot?

quaint mantle
#

Use World.spawnEntity() and pass this value as the entitytype

valid solstice
#
if(!(player.getInventory().getItemInMainHand().equals(BaowgsPick.baowg_pick))){
            player.getInventory().addItem(player.getInventory().getItemInMainHand());
            return;
        }

why is this if statement triggering but when it adds an item to my inventory, it is EQUALS to the item im holding

little trail
#

what database should i use

#

not too much data

#

like probably a row per player

drowsy helm
hazy rose
#

int expAmount = 100; ExperienceOrb orb = null; Location loc = /*someLocation*/; ((ExperienceOrb) loc.getWorld().spawn(loc, ExperienceOrb.class)).setExperience(expAmount);

valid solstice
drowsy helm
little trail
#

yes, which sql db

#

i know how to do it in python but not java

drowsy helm
#

mysql is easy to setup and use

little trail
#

alr ty

drowsy helm
little trail
#

does postgres exist for java too?

valid solstice
#

i am adding the item in their hand IF their item is NOT equal to a certain itemstack, but the item given to me when i tried it is equal to that certain itemstack

drowsy helm
#

yeah it does

drowsy helm
#

postgres is just a database, its the library you are looking for

hazy rose
drowsy helm
#

just use a for loop

little trail
drowsy helm
valid solstice
drowsy helm
#

just use jdbc

drowsy helm
hazy rose
#

Do u have plugin who make exp bottle drown from no where just by using command?

ivory sleet
valid solstice
#

my question is, why is the if statement getting satisfied?

#

when infact, it should not

drowsy helm
#

thats what im saying

little trail
drowsy helm
#

you are testing with the Baowgs pick in your hand right

#

but it is still being satisfied

valid solstice
#

yup

#

so how would i make it not satisfy

#

theoretically, it should not be satisfied

drowsy helm
#

dont use a static itemstack and make a proper handler

valid solstice
#

wdym by proper handler?

drowsy helm
#

like a wrapper class for custom items instead of a static variable

#

ill send through an example, give me a sec

valid solstice
#

mhm sure

ivory sleet
drowsy helm
#

something like that where you have a method to check whether an itemstack is actually a custom item

#

far better than using one static itemstack

#

think about it, if you give 10 players the same itemstack, it will share all the same data

valid solstice
drowsy helm
#

stack size, enchant etc etc

#

so you can handle it properly

#

just checking whether item in hand = static itemstack is crude and won't work in many circumstances

valid solstice
#

so ill just create a getter that creates a new copy of the item stack and returns that item stack?

#

then in my listener ill run the getter method

#

thats what im understanding

drowsy helm
#

yeah, then to check whether it actually is a custom item have a method in the custom item class

valid solstice
#

alright ill try that out, thanks

drowsy helm
#

unless you want to check material, name and lore but that is a big workaround

#

and can be cheated easily

valid solstice
#

yea ill stick with itemstack

#

will if(!(player.getInventory().getItemInMainHand().equals(BaowgsPick.baowg_pick))){ get satisfied if the itemstack from getiteminmainhand has a different durability than the itemstack?

drowsy helm
#

well in an ideal setup you would just use

ItemStack hand = player.getInventory().getItemInMainHand();
if(itemManager.getHandler(hand) != CustomItem.BaowgsPick){
//do stuff
} ```
#

that getHandler method would return an enum

#

and the enum being a list of all your custom items

#

the struggle with comparing an itemstack to a static one is data will vary. durability, stack size, name etc

summer scroll
#

Will ignore the stack size.

#

Honestly you can just use PDC I guess, make things easier.

drowsy helm
#

yeah but theres many cases where custom items will vary with lore etc

#

^ my example uses nbt

summer scroll
#

Yeah true, nbt it is then.

little trail
#

so if im using postgres, do i just create the db with the postgres user with CREATE DATABASE then login to that db with the same postgres user?

#

i guess ill do that then

#

actually it wont even work for stuff like minehut as well i dont have access outside of the mc server and my folder so ig sqlite

drowsy helm
#

wdym stuff like minehut

silver shuttle
#

How do you register commands without reloading a plugin AND without adding the command to the plugin.yml?

#

for example, how do commandalias plugins do it

drowsy helm
#

checkout plugin.yml annotations

eternal oxide
#

a command alias plugin should not be registering any commands

#

its just providing aliases for existing ones

silver shuttle
#

okay but a plugin like ezcommands

#

makes own commands and registers them

#

how does one do that

eternal oxide
#

reflect into the command map

silver shuttle
#

aaah okayy

silver shuttle
#

thats cool

summer scroll
#

but you still need to register it in plugin.yml

eternal oxide
#

no you don't

summer scroll
#

really?

eternal oxide
#

not when reflecting

silver shuttle
#

would be useless if you did have to

#

is it even possible to change the plugin.yml by the plugin itself?

eternal oxide
#

no

silver shuttle
#

no right? since its compiled etc

eternal oxide
#

its not that its compiled, its that its in use

silver shuttle
#

ah ok

silver shuttle
#

why are methods like sendTitle deprecated and replaced over time?

round gale
#

I use it too in one of my Plugins, i don't know why they aren't deprecated in the SpigotMC API Website but in IntelliJ

eternal oxide
#

teh javadocs and Intelij are identical deprecations

#

sendTitle (if I remember) the two arg method was deprecated. You have to use the full 5 arg method

round gale
eternal oxide
#

just use -1 for all thre ints and it works identical to the deprecated method

silver shuttle
round gale
silver shuttle
#

showTitle uses 1 argument

eternal oxide
#

deprecated

#

inteliJ uses those exact same javadocs

round gale
silver shuttle
round gale
#

this is deprecated in intellij.

eternal oxide
#

no

#

thats the 5 arg method

round gale
tardy delta
#

whats this?
java.lang.ExceptionInInitializerError: null

silver shuttle
eternal oxide
#

That is Paper not spigot

silver shuttle
#

oh kk

round gale
#

lol.

eternal oxide
tardy delta
#

ah i found it

round gale
#

hover over it long enough, okey okey

silver shuttle
#

very useful ^^

sharp saffron
#

does anyone know how to remove the dependency of citizens for goldencrates I dont want to pay the 10$ and I generally dont need it as its described as an optional dependency here is the source codehttps://github.com/nulli0n/GoldenCrates

GitHub

Contribute to nulli0n/GoldenCrates development by creating an account on GitHub.

summer scroll
silver shuttle
#

if its in the depend of the plugin.yml just remove it

sharp saffron
#

I get a few error messages

silver shuttle
summer scroll
sharp saffron
#

29.10 10:56:48 [Server] Server thread/ERROR [Citizens] v2.0.24-SNAPSHOT (build 1605) is not compatible with Minecraft v1_17_R1 - try upgrading or downgrading Citizens. Disabling.
51 29.10 10:56:48 [Server] Server thread/INFO [Citizens] Disabling Citizens v2.0.24-SNAPSHOT (build 1605)
52 29.10 10:56:48 [Server] Server thread/ERROR [NexEngine] Plugin NexEngine v**...** has failed to register events for class su.nexmedia.engine.hooks.external.citizens.CitizensHK because net/citizensnpcs/api/trait/TraitInfo does not exist.
53 29.10 10:56:48 [Server] Server thread/INFO [NexEngine] [Hook] Citizens: Success!

#

(was too long to take screenshot)

summer scroll
#

idk, i think they are using their own libs and i cannot see that code

sharp saffron
#

ok

summer scroll
opal juniper
#

they have a jenkins

summer scroll
#

yeah xd, i dont see why you dont want to add citizens

opal juniper
sharp saffron
summer scroll
#

on the jenkins page

sharp saffron
#

TYSM!!!!!

little trail
#

does anyone know how i can do thread.join but asynchronously

acoustic pendant
#

Hello, i have an error

#

and it says that "customFile" is null

#

but, don't know how to solve it

#

could anyone help me? 😄

celest isle
#

lol anyone have an easy way yo do the
Location loc = Player.Location();
it doesnt work for me lol

little trail
celest isle
#

yeah

#

oh shoot its getLocation

fallow merlin
#

tab complete is ur friend

celest isle
#

nope i have no hope

fallow merlin
#

ook then

little trail
#

it would usually be getSomething anyway

celest isle
#

    public class TestNMS extends EntityZombie {
        public TestNMS(Location loc) {
            super(((CraftWorld)loc.getWorld()).getHandle());
            this.setPosition(loc.getX(), loc.getY(), loc.getZ());
        }
        Location loc = Player.getLocation();
        TestNMS NMS1 = new MySuperZombie(((CraftWorld)world).getHandle());
        NMS1.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
        ((CraftWorld)loc.getWorld()).getHandle().addEntity(NMS1, CreatureSpawnEvent.SpawnReason.CUSTOM);

    }


#

Im trying to do the nms thing

#

oh god i forgot i need to put it inside commandexecutor

little trail
#

you know java // codeblocks exist so stop() { using = snippets; }.likeThat();

plucky crow
#

This command can be executed only from the game!
Can I remove the error without changing the plugin?
There are some commands that don't need console and I want to run these commands through console.

tardy delta
#

which command?

plucky crow
#

digitalclock /dc runclock 1

tardy delta
#

probably not

#

if the author doesnt have an option for that

plucky crow
#

Do you know any other plugin similar to this plugin?

#

1.8

acoustic pendant
tardy delta
#

in the sysout?

glossy venture
#
    public static Direction getNeighborDirection(BlockPos origin, BlockPos neighbor) {
        int ox = origin.getX() - neighbor.getX();
        int oy = origin.getY() - neighbor.getY();
        int oz = origin.getZ() - neighbor.getZ();

        switch (ox) {
            
        case 1: return Direction.EAST;
        case -1: return Direction.WEST;

        default:
        switch (oy) {

        case 1: return Direction.UP;
        case -1: return Direction.DOWN;

        default:
        switch (oz) {

        case 1: return Direction.NORTH;
        case -1: return Direction.SOUTH;

        }

        }

        }

        return Direction.SOUTH;
    }
``` u think this will work
#

idk how to do this

#

its only ever next to it

#

never further

#

so no need to do > and <

acoustic pendant
#

the error is this:

glossy venture
#

ur attempting to save your file before its loaded

#

or it doesnt exist at all

#

check if YamlConfiguration.loadConfiguration(file); returns null if it doesnt exist

acoustic pendant
#

when a player joins it creates a file

deep sail
#

Rather than file.getParentFile().mkdirs();

acoustic pendant
deep sail
#

Oh so it does exist already

#

Hm

glossy venture
#

nah that will create the file itself as a directory

acoustic pendant
#

wait

acoustic pendant
#

not when i join...

acoustic pendant
#
            if (!file.exists()) {
                customFile = YamlConfiguration.loadConfiguration(file);
            }
summer scroll
#

the file needs to be exist before you use it with loadConfiguration

acoustic pendant
#

i'm checking if the file exist

#

and if it does it creates

#

right?

#

@summer scroll?

glossy venture
summer scroll
#

you need to create the file first before using loadConfiguration

glossy venture
#
if (!file.exists()) {
  file.createNewFile();
}

customFile = YamlConfiguration.loadConfiguration(customFile);
acoustic pendant
#

i'm doing it already

glossy venture
#

or use

if (!file.exists()) {
  throw new IllegalArgumentException("file doesnt exist");
}

customFile = YamlConfiguration.loadConfiguration(customFile);
glossy venture
#

in the 2nd one

#

and also

#

u need to create the file itself

acoustic pendant
#

ye ye, that was now...

glossy venture
#
file.createNewFile();
unique hamlet
#

how do you enchant an item past its cap?

summer scroll
acoustic pendant
glossy venture
unique hamlet
young knoll
#

It’s just addEnchantment in the meta

unique hamlet
#

oh yteah that's literally a thing

#

nice

#

thanks :D

glossy venture
#

as customFile is null

acoustic pendant
#

no?

#

save is after

glossy venture
#

you are creating an empty file

acoustic pendant
#

yes

glossy venture
#

i think it might return null

#

as it doesnt have anything to load

acoustic pendant
#

uh

glossy venture
#

but im not sure

round gale
#
public class VersionCommand implements Listener {

    private static final String BUKKIT_VERSION = "/bukkit:version";
    private static final String HEX_CODE_REGEX = "&#[a-fA-F0-9]{6}";

    private final Pattern pattern = Pattern.compile(HEX_CODE_REGEX);

    private final FileConfiguration cfg = CustomVersionSeedCommand.plugin.getConfig();
    private final List<String> all_lines = cfg.getConfigurationSection(ConfigVariables.VERSION_SECTION).getStringList(ConfigVariables.STRING_LIST_MESSAGE);

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerExecutingVersionCommand(PlayerCommandPreprocessEvent e) {

        String command = e.getMessage();

        if (command.equalsIgnoreCase("/version")) {
            customVersionCommand(e.getPlayer(), e);
        } else if (command.equalsIgnoreCase("/ver")) {
            customVersionCommand(e.getPlayer(), e);
        } else {
            return;
        }
    }

    private void customVersionCommand(Player player, PlayerCommandPreprocessEvent e) {
        if(player.hasPermission("CustomVersionSeedCommand.original.versioncommand")) {
            e.setMessage(BUKKIT_VERSION);
        } else {
            for (String one_line : all_lines) {
                one_line = hexCodeFormatter(one_line);
                player.sendMessage(one_line);
            }
            e.setCancelled(true);
        }
    }
    private String hexCodeFormatter(String msg) {
        Matcher match = pattern.matcher(msg);
        while(match.find()) {
            String color = msg.substring(match.start(), match.end());
            color = color.replace("&","");
            msg = msg.replace("&"+color, ChatColor.of(color) + "");
            match = pattern.matcher(msg);
        }
        return msg;
    }
}

It's working for me now!
(can anyone please help me, if this is optimized?)

acoustic pendant
tardy delta
#

wait what else return

round gale
tardy delta
#

no

#

if no clause is found it just exits the method

acoustic pendant
#

java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.file.FileConfiguration.addDefault(String, Object)" because the return value of "me.fragment.minespaceskills.store.dataStoreOnJoin.get()" is null

#

this error

round gale
tardy delta
#

yes

plucky crow
#

player.playSound(player.getLocation(), Sound.LAVA, 0.4f, 1.0f);
How do I get the sound to be heard everywhere, not just in one spot?

eternal night
#

You'll presumably want to sent the sound to every player ?

plucky crow
#

no just one player

eternal night
#

What do you mean with everywhere then ?

plucky crow
#

I changed the lava sound, it is a long sound but it is not heard from a certain block away.

eternal night
#

Concerning you are using the players location, it would always be heard

plucky crow
#

just my bad english

#

There is a sound of lava at the player's location, but when she moves away, the sound becomes muted and inaudible until she goes to the place where the sound started.

#

I just want to extend the reach of the sound.

#

i solved
just player.playSound(player.getLocation(), Sound.LAVA, 1000.0f, 1.0f);

tardy delta
#

how does inventory instanceof SomeClass works?

#

does the class needs to have an Inventory field?

#

like it worked before

chrome beacon
#

The inventory has to be an instance of SomeClass for that to work

tardy delta
#

cant i just check if inventory instanceof ParentClassOfCustomGui?

#

liek i have custom gui classes like TradeGui, ShopGui and in the inventory click event i'm checking if the inventories are instanceof GuiCreator (which is the parent class of all those mentioned before)

humble garnet
#

anyone know which plugin is used to make a pickaxe have custom enchants? play.wildprison.net ( the one use on there)

acoustic widget
#

What is the best way to use InventoryClickEvent ? I have created custom GUI menu and I have some codes on items in this custom menu but i would like to be sure I don't send my action to another gui menu ?
how do you guys do that ? I see many tutorial using itemname (if itemname = "blababla) do this, but I think it's a bad pratice because if two gui menu use same item name, my code will be run

eternal oxide
tardy delta
#

but if that would be a subclass of inventory, i would have to define all those methods

#

idk why but instanceof worked everytime and now it doesnt

eternal oxide
#

it has to actually be an instanceof Inventory for it to be true

tardy delta
#

but how can i check then if the inventory is from one of my custom gui classes?

#

as instanceof doesnt work

eternal oxide
#

you compare the inventory instance,

stone sinew
tardy delta
eternal oxide
#

==

#

if (inventory == yourGUI.getInventory())

tardy delta
#

but the problem is that there are multiple instances

eternal oxide
#

and?

tardy delta
#

i cant check that for every instance

eternal oxide
#

why not?

tardy delta
#

because i'm not storing them somewhere and the amount of them could be big

eternal oxide
#

You have to be storing them at some point

humble garnet
#

anyone know where i can change the server listing name ?

#

its not in properties.yml

stone sinew
#

InventoryHolder Cough

tardy delta
#

hmm if i just let my super class implement inventoryholder, can i check then if the event.getInventory().getHolder() instanceof Superclass?

tardy delta
#

there is no other easy way

eternal oxide
#

^ yes

tardy delta
#

lets try that

#

but its strange that this doesnt get logged

eternal oxide
#

GuiCreator is not an Inventory

#

it should trigger that

tardy delta
#

cringe

eternal oxide
#

I'd have to guess you forgot to register the listener?

tardy delta
#

no

zinc spire
#

Is there anyway to store Itemstack into mysql except serializing itemstack to base64?

eternal oxide
#

not simply, no

zinc spire
#

oh...

tardy delta
#

now this gets logged

mint flare
#

Hey, little fast question, when we spam click on an Inventory, InventoryClickEvent can't catch all click right ? 🤔

humble garnet
#

im using crateKey, and the createtier command isnt working ? any ideas ?

eternal oxide
humble garnet
#

o thanks

lean bone
#

I am trying to load maps onto item frames on server start, but for some reason the item frame entities cannot be found. On server start there are 0 entities in the chunk where the item frame is supposed to be, but 30 seconds after server start there are, even though the chunk is loaded in both cases. Is there something I can do about this?

crimson terrace
#

you may be checking before the entities are loaded

lean bone
#

Is there any way to load the entities?

tardy delta
lean bone
#

I tried using chunk#load() but that didn't seem to do anything

stone sinew
#

Chunks aren't loaded instantly

eternal night
#

Eeeh, 1.17 separate chunk and entity loaded

#

loading*

lean bone
#

Is there any way to load the entities

eternal night
#

Use I believe it's EntitiesLoadEvent

#

It's called whenever the entities of a recently loaded chunk were finished loading

lean bone
eternal night
#

Yeah, again a chunk being loaded does not guarantee its entities being loaded

lean bone
#

Yes I understand, I'll see if I can listen to the event

mint flare
#

It's weird, my InventoryClickEvent don't catch all click.. it's a problem of allowed RAM ? 🤔

tardy delta
#

which clicks doesnt it catch?

mint flare
#

about one left click out of 10

#

It isn't type click problem, just sometimes he ctach the click, and sometimes (more rarely) not

#

It's a problem cause at each click on a backpack inventory i have to compare the item with an other and if all click isn't catch i can't compare 😦

acoustic widget
tardy delta
#

smh i forgot the this

#

now it seems to work

rugged topaz
#

hey, considering this returns a map ProxyServer.getInstance().getServers() am i suppose to grab the value of each element in the map or is there another way to get all the servers?

#

trying to loop through all the servers connected to bungee.

eternal oxide
#

ProxyServer.getInstance().getServers().getKeys()

acoustic widget
rugged topaz
eternal oxide
#

probably

rugged topaz
#

yea, plus it's .values i'm looking for anyway but you pointed me towards the right path ty

tardy delta
#

i just let all my classes extend a base class (GuiCreator) which implements InventoryHolder

acoustic widget
#

how you check if event is called by your gui

#

i had the same question when you was talking here

tardy delta
#

ah when making the inventory in the GuiCreator class, i pass this as InventoryHolder

acoustic widget
#

oh so you use holder too

#

ok ok thanks

tardy delta
#

and in the listener

acoustic widget
#

Nice thanks 😉

tardy delta
#

👍

#

only problem is my stupid navigation system which gave it up

celest isle
#

Anyone have any idea how to solve this error?

#
    public static class Dude extends EntityZombie {

        public Dude(World world, Player p)
        {
            super(((CraftWorld)world).getHandle());
            Location loc = p.getLocation();
            Dude dude = new Dude(((CraftWorld)world).getHandle());
            dude.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
            ((CraftWorld)loc.getWorld()).getHandle().addEntity(dude, CreatureSpawnEvent.SpawnReason.CUSTOM);
        }
    }
tardy delta
#

new Dude() :kekw:

celest isle
#

im talking about this lol

tardy delta
#

ah i see stackoverflow

celest isle
eternal oxide
#

what is the error?

onyx shale
#

i see a bad casting

#

of asking a bukkit world

#

and giving it a craftworld

celest isle
#

its first time of me messing with nms and im confused

eternal oxide
#

yoru method wants a Bukkit world

tardy delta
#

Dude dude = new Dude()
-> Dude dude = new Dude()
-> Dude dude = new Dude()
...
you understand?

onyx shale
#

so only new Dude(world)

tardy delta
#

thats a stackoverflow no?

celest isle
#

I..

tardy delta
#

creating instances of itself in the constructor

onyx shale
#

thats alot of dudes

tardy delta
#

that's a whole army

celest isle
#

Jeez, never thought i need to write 10 lines of code to spawn a dude i can do from just 1 line

#

because its nms

onyx shale
#

well...

#

not rly..

mint flare
#

So, i don't find solution to left click who are not caught by the InventoryClickEvent
Do i have to search an other way to do what i need ?
Like verifying item when inventory is closed ?

tardy delta
#

whats even the point of making a new dude when making a new dude?

onyx shale
#

the dude needs another dude to have fun with

tardy delta
#

OOOOOHHH

celest isle
#

yep, i dont get it at all

onyx shale
#

well...

#

i would be honest and tell you that a java basic mistake but im too lazy rn

celest isle
#

yeah i know i gave the wrong world but

onyx shale
#

not that

#

the fact you created a infinite loop

tardy delta
#

Can't you just

public Dude(World world, Player player) {
  super(((CraftWorld)world).getHandle());
  setLocation(player.getLocation());
  ((CraftWorld)loc.getWorld()).getHandle().addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
}```
#

🥄

onyx shale
#

?spoon

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

quaint mantle
#

Dude

tardy delta
#

smh that emoji sucks

onyx shale
#

but eh

celest isle
#

bruh

onyx shale
#

i guess when it comes to nms? we can close an eye

tardy delta
#

he probably doesnt know you can pass this as argument

celest isle
#

i legit dont

tardy delta
#

this is just the current instance with all methods and stuff

onyx shale
#

current instance wich is extending the entity hence why it accepts it btw...

tardy delta
#

true

#

ssh

onyx shale
#

just in case you think you can do this for everything😂

celest isle
#

oh i think i get it

tardy delta
#

bug hunting for a week now...

acoustic widget
#

@tardy delta
I'm looking for add holders too,

e.getClickedInventory().getHolder()
return com.example.testmaven.gui.holders.MenuHolder

e.getClickedInventory().getHolder() instanceof MenuHolder
return false

here my holder

package com.example.testmaven.gui.holders;

import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;

public class MenuHolder implements InventoryHolder {
    @Override
    public Inventory getInventory() {
        return null;
    }
}

Stange no ?

gritty urchin
#

How do I make a armorstand not lag behind when teleporting it every tick?

onyx shale
#

you dont do it through api

#

wich im sure your doin

#

you use packets

gritty urchin
#

How will that make any difference

celest isle
#

when nothing is in /out 😔 🙏

acoustic widget
#

The problem is e.getClickedInventory().getHolder() instanceof MenuHolder return false even of true
When e.getClickedInventory().getHolder() = com.example.testmaven.gui.holders.MenuHolder

onyx shale
tardy delta
#

cringe

onyx shale
acoustic widget
#

Yes

gritty urchin
onyx shale
#

and you are clicking the right inventory not the players one right?

tardy delta
#

oh french

acoustic widget
#

yes @onyx shale

#

🇫🇷

tardy delta
#

and if you try event.getInventory() instead of clickedinv

onyx shale
#

hmm whats with the specific package name?

acoustic widget
onyx shale
#

is it the same as the one in create inventory?

#

check theyr definiton

acoustic widget
#

yes same

onyx shale
#

hmm should work

#

try putting a debug above the check

#

and see if it reaches the check

acoustic widget
#

Ok nevermind, i had to reload all entier server. I'm using biletool plugin for hot reload plugin when they are edited and seems to cause that bug

onyx shale
#

👍

acoustic widget
#

it works so

little trail
#

trying to understand concurrency with java and java CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> { // some database connection return "Result of the asynchronous computation"; }).thenApply(result -> { System.out.println(result); return "Result of the then apply"; });
how would i get the result from this?

#

preferably not a blocking way to get it

ivory sleet
#

join

#

Then just use thenAccept

little trail
#

ah right

ivory sleet
#

Or if you want to chain it could use
thenApply where the function returns its argument

little trail
#

so do i not need thenapply?

ivory sleet
#

As said

#

thenAccept is viable

#

However it returns a CompletableFuture<Void>

#

Which does no longer contained the computed object

#

This if you want to chain more higher ordered functions after the future you might just use thenApply where the lambda passed return its argument

#

Since that’ll keep the computed object

little trail
#

oh so i cant get the object back out of it without blocking?

ivory sleet
#

Yes you can but you can’t await the result

#

Since that’ll block

#

So the only option would be a callback

tardy delta
#

should i cache inventory instances?

ivory sleet
#

Depends

little trail
#

i kinda want to extract the database connection, if its on the main thread and only occurs on startup i guess its fine?

ivory sleet
#

Extract the database connection?

little trail
#

well

#

i want the connection object stored in my class

#

wait what does thenapply do

ivory sleet
#

Pretty sure you can instantiate the connection pool and everything synchronous assuming it’s during bootstrap time. But then again queries, updates and retrievals from the database should be done async

#

it chains a Function<T,R> on to the future

#

Where the method returns CompletableFuture<R>

little trail
#

i honestly have no idea what R is

ivory sleet
#

R is the type parameter standing for resulting type

little trail
#

ah

#

so thenApplyAsync wouldnt let me get the connection from the future?

ivory sleet
#

Don’t use the async one

#

The future is already async

rugged topaz
#

are you able to grab the ProxyServer on a spigot plugin? ProxyServer.getInstance()

ivory sleet
#

If it’s from BungeeCord no

little trail
#

whats the difference between the async and non-async methods, do they do nothing in this context or are they just not different

ivory sleet
#

They’re very different

tardy delta
#

because they dont have an await, does that mean its a different thread?

ivory sleet
#

You often establish a CompletableFuture with CompletableFuture::runAsync or supplyAsync which will use a thread from the executor you pass along with the supplier or runnable (the executor is by default the common fork join pool). Assume you do call thenBlahAsync, basically it’ll just use another thread from the executor, so it’ll be async in relation to the already async task.

little trail
#

ah right

#

so the async one runs it again in a different task

ivory sleet
#

Await means you just wait for something to be done, in java we have Future::get or CompletableFuture::join for instance

ivory sleet
#

Which in 99% of the times is unnecessary

little trail
#

tysm

#

wrapping my head around concurrency is hard

ivory sleet
#

Yeah it’s a bit weird at first

mint flare
#

I just don't understand why : https://youtu.be/8IIf9w0NWv0
why i can't put this lapis block in the backpack

Red message is in english : "Sorry, it's not the good item =("

normally, when i try to put an item in the backpack, the plugin will check if it's the same item that the item in first line and if not, the event is cancel

#
Inventory inv = event.getClickedInventory();
Player player =  (Player) event.getView().getPlayer();
ClickType type = event.getClick();
player.sendMessage(type.toString() + debug);
player.sendMessage(inv.getType().toString());
debug++;
if (type == ClickType.DOUBLE_CLICK) {event.setCancelled(true); return;}
        if (type == ClickType.LEFT && inv.getType() == InventoryType.CHEST && inv.getName().equals("§8Backpack")) {
            
            if (event.getSlot() < 18 || event.getCursor().getType() == Material.AIR) {
                event.setCancelled(true);
                return;
            }else {
                Team team = Team.getUserTeam(player.getDisplayName());
                Backpack backpack = team.getBackpack();
                int itemSlot = event.getSlot();
                System.out.println(inv.getItem(itemSlot-18));
                System.out.println(event.getCursor());
                              System.out.println(event.getCursor().isSimilar(inv.getItem(itemSlot-18)));
                if (!event.getCursor().equals(inv.getItem(itemSlot-18))) {
                    player.sendMessage("§cCe n'est pas le bon item... =(");
                    event.setCancelled(true);
                    player.updateInventory();
                    return;
                }else {
                    player.sendMessage("§a c'est le bon item, votre équipe marque un point !");
                    backpack.goalAchieved(itemSlot);
                    backpack.updateBackpack();
                    player.updateInventory();
                    team.addOnePoint();
                }
            }
        }
hasty prawn
#

I would imagine no

mint flare
#

Only (normally) the good item

hasty prawn
#

Whats the normally good item

mint flare
#

if you try to put an item in the first slot of the third line, the good item is the first item of the first line

hasty prawn
#

Oh I see

#

Change the if statement to use isSimilar instead of equals

mint flare
#

I didn't think it's the problem 'cause in the video, the click when i could put the labis block below the quartz block didn't catch by InventoryClickEvent 🤔

#

Otherwise, a message would have been send in the Minecraft chat

And i don't understand why this click is catch by the eventHandler
RAM problem maybe ? i put 2048 to max ram

elfin talon
#
 if (newlocation.getBlock().getState().getType() == Material.WALL_SIGN || newlocation.getBlock().getState().getType() == Material.SIGN_POST) {
                BlockState blockState = newlocation.getBlock().getState();
                Sign S = (Sign) blockState;
                
            }``` how can i set a line of the shield. It´s the version 1.12.2. S.setLine() doesn`t work with this code
hasty prawn
mint flare
#

but in first instruction of the event there is :

ClickType type = event.getClick();
player.sendMessage(type.toString() + debug);
player.sendMessage(inv.getType().toString());

if this was an other click type, he should have displayed

tardy delta
#

if cancel becomes true, it should get cancelled no?

hasty prawn
mint flare
#

the best solution, i think, is to change the way that the plugins works no ?
An idea is to let player put all he wants in the third line of backpack and when he close the inventory, i compare items
tell me if i'm wrong

patent quarry
#

Hey everyone ! I dont find the way to get the value of each pixel of a map. Is it possible to get them ?
I saw MapCanvas but idk how to get it

rare minnow
#

Hey, is there an event or way to detect vehicle collisions when ridden? e.g: Boat hits wall => action

Cause i've tried it (VehicleBlockCollisionEvent )and it only works if they do it by themselves

opaque panther
#

how to send images here

ivory sleet
#

verify

opaque panther
#

its not working

#

what should i type

#

when i tried it before it didnt send me any message in my soigot accoun

rare minnow
#

uh idk then

opaque panther
#

ok i verified

#

somehow it worked now

ivory sleet
#

pog

ivory sleet
opaque panther
#

anyway can someone help me, I can't select version in intellij spigot plugin settings

#

i saw other people do it

#

without error

#

why is it not working for me

ivory sleet
#

might have to re install the plugin

#

seems to be broken

opaque panther
ivory sleet
#

report thjat

#

but yeah

#

ensure u got the latest intellij version

#

and then reinstall that plugin

opaque panther
#

isnt 2021.2.3 the latest intellij

ivory sleet
#

idk

#

you can check urself I believe

hasty prawn
#

That's the latest version yeah

opaque panther
#

bruh i reinstalled the plugin and it still erro

ivory sleet
#

hmm you might wanna delete that spigot.json file

#

such that it can generate a new valid one

opaque panther
#

i cant find the location of the spigot.json

#

it says com.google.....

ivory sleet
#

Go and ask in their discord maybe

#

They should be knowledgeable about it tbf

opaque panther
#

i could only find the github. I posted an issue there a week ago

ivory sleet
#

no response?

opaque panther
#

the only way I could make a plugin was by asking another guy to give me a template

opaque panther
ivory sleet
#

oof

elfin talon
#

hey i have an error java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockState cannot be cast to class org.bukkit.block.Skull (org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockState and org.bukkit.block.Skull are in unnamed module of loader 'app') at tyko.de.haikobra.knockffa.De.HaiKobra.ranking.Ranking.set(Ranking.java:51) ~[?:?]

   LOC.get(i).getBlock().setType(Material.SKULL);
            Skull skull = (Skull) LOC.get(i).getBlock().getState();
            skull.setSkullType(SkullType.PLAYER);
            String name = Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getName();
            skull.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getPlayer());
            skull.update();```

But when i import the material and the block i get the error: ```'org.bukkit.block.Skull' is already defined in a single-type import```
#

Who can help me with this error or has a suggestion?

eternal oxide
#

You setType on a BlockState, then you get a new BlockState and try to cast to Skull. It will not be a Skull as you never committed the change from the last state.

#

nm, ignore me, I was reading it wrong

#

However your LOC.get(i).getBlock().getState() seems to be returning a CraftBlockState, why?

young knoll
#

CraftBlockState is the implementation

#

The bukkit one is only an interface

eternal oxide
#

yes, but that method shoudl return a BlockState not the implementation

young knoll
#

It does return a BlockState

#

CraftBlockState implements blockstate

eternal oxide
#

I wouldn;t expect to see his cast error on a BlockState

eternal oxide
elfin talon
#
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;

import tyko.de.haikobra.knockffa.De.HaiKobra.KnockFFA;
import tyko.de.haikobra.knockffa.De.HaiKobra.MySQL.SQLStats;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;```
eternal oxide
#

Yeah no clue, I'm tired and my heads not working.

lavish hemlock
#

who does this
tyko.de.haikobra.knockffa.De.HaiKobra.KnockFFA

elfin talon
#

its the main class

lavish hemlock
#

ye but don't you have to nest that in like two other fuckin' classes?

#
class De {
    static class HaiKobra {
        static class KnockFFA {

        }
    }
}
#

a new file is generated for every class ^

#

so that becomes De, De$HaiKobra, and De$HaiKobra$KnockFFA when compiled

#

which, I'm not entirely sure if this correct, but I believe De must be loaded if De$HaiKobra is

#

which means this approach causes two unnecessary problems:

#
  • code size increase for redundant classes
  • class load overhead for redundant classes
#

just like

summer scroll
#

what