#help-development

1 messages Β· Page 231 of 1

loud frost
#

like in a terminal? Yes any ide with a terminal can run a server

steady rapids
chrome beacon
loud frost
tardy delta
#

why does HeapCharBuffer has to be an internal class grr

loud frost
#

Found this like 2 weeks ago and its life changing

quaint mantle
#

can i do .equals("player1", "player2")) ??

chrome beacon
tardy delta
#

might wanna google how to compare string in java

steady rapids
#

I'm trying to modify the spigot Jar, can that do it? I need to see it on a IDE to debug and test

tardy delta
#

and tip number one: dont do spigot when you dont know java

steady rapids
#

edit

#

change

#

recode

chrome beacon
#

So you want to make your own patches instead of using the api

#

basically making your own fork

#

If it's just for debugging use the links above so you have access to breakpoints

steady rapids
#

yeah, kind of, I would like to directly edit it tho, im not sure how are the patches made tho

chrome beacon
#

Directly editing is not worth it for debugging and testing. Use breakpoints

steady rapids
valid basin
valid basin
#

It happens with almost any nms

chrome beacon
#

Ah you want the NMS itemstack

#

You need to convert it to a bukkit one

ashen lynx
#

Hi! How can I block sideways moving of a player who riding a horse?

vocal cloud
#

Could you? Probably. Do you want to? Probably not?

valid basin
# chrome beacon You need to convert it to a bukkit one

How to do that?
This is my current code

    public static void restoreInventory(Player p) throws IOException {
        File f = new File(WargroundsMain.getInstance().getDataFolder().getAbsolutePath(), p.getName() + ".yml");
        FileConfiguration c = YamlConfiguration.loadConfiguration(f);
        ItemStack[] content = ((List<ItemStack>) c.get("inventory.armor")).toArray(new ItemStack[0]);
        p.getInventory().setArmorContents(content);
        content = ((List<ItemStack>) c.get("inventory.content")).toArray(new ItemStack[0]);
        p.getInventory().setContents(content);
    }```
ashen lynx
chrome beacon
vocal cloud
#

When I say that what I mean is something along the lines of "it's not going to be easy and it'll probably be very buggy"

valid basin
chrome beacon
#

That's not a bug

#

You just used the wrong import

white root
#

Why do phantoms not extend Monster

undone kernel
#

they are hallucinations that haunt u when you don't sleep

white root
#

I love it when my hallucinations swoop down from the sky and smack me to death

ivory sleet
# white root Why do phantoms not extend Monster

I mean Monster is just an interface that represents monsters as in despawning in peaceful mode, spawning during nights (iirc certain sounds [like swimming] also thats common for all monsters) etc, but both Monster and Phantom nms wise do implement Enemy

white root
#

huh, alright

#

Is there an elegant way to check if a Mob is hostile?

#

without using nms

undone kernel
#

actully maybe but i'm stupid

white root
#

I might just make my own utility method that checks it against a list of hostile EntityTypes that ill make

#

hm, true
But that would return true of things like parrots as well though, no?

#

Since id assume those are also instances of Flying

#

Ah, I see my misunderstanding

hybrid spoke
#

are players flying

white root
#

I had assumed that anything that could fly on its own would be an Flying

#

But this makes sense

#

yeah, that appears to be the case

vague stone
#

What is the ItemStack for Villager Egg?

tardy delta
#

then use spawnegg meta or smth ig

fresh timber
#

I have a plugin that, when a player gets hit or attacks, adds their uuid to a hashmap. After 10 seconds, it removes this from the hashmap. The problem is if you attack once then wait 9 seconds and attack again, you are only on that hashmap for 1 second. Does anyone know of a way I can fix this? I have this error in similar instances a lot.

echo basalt
#

put it again regardless if they're on it or not

fresh timber
#

yes but lets say they attack at 9 secs and it adds them to the hashmap, then one seconds later, it removes them

#

what is that?

#

use millisecionds?

#

oh yes

#

that would work

#

ok, what do I use to get the current millis?

#

oh I see

#

why do ppl use # instead of .

#

ok

#

okay

vital yacht
#

Kind of a dumb question but PDC isn't thread safe right?

eternal oxide
#

Nothing in Bukkit can be assumed to be threadsafe

vital yacht
#

Okay thanks

#

Yeah I wasn't sure if PDC was safe

tardy delta
#

cant really find the deepest impl but ig its backed by some kind of collection that is not threadsafe

eternal oxide
#

PDC is a wrapper around NBT

#

you can;t access native NBT, only spigots

tardy delta
#

ig thats why i couldnt access the deeper classes

vital yacht
#

Yeah looks like just a HashMap

#

I'm looking at Chunk PDC

#
    private final Map<String, Tag> customDataTags = new HashMap<>();
    private final CraftPersistentDataTypeRegistry registry;
    private final CraftPersistentDataAdapterContext adapterContext;

    public CraftPersistentDataContainer(Map<String, Tag> customTags, CraftPersistentDataTypeRegistry registry) {
        this(registry);
        this.customDataTags.putAll(customTags);
    }
sterile token
#

?di

undone axleBOT
sterile token
crimson jasper
#

is there a way for me to change the gradle build location? Like where it puts the built jar file?

hazy parrot
crimson jasper
#

I tried okay

#

x3

#

Solution:

jar {
    destinationDirectory.set(file("$buildDir/someDir"))
}
solid skiff
#

probally a stupid question, but i compiled my plugin, put it in the folder, and it is not in plugin list?

steep scroll
#

I am trying to code a mini games and when I tested it this happened.
Error:
Error occurred while enabling MineClashMiniGames v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?]
at mineclash.minigames.MiniGames.onEnable(MiniGames.java:19) ~[MiniGames-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-223]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-223]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:636) ~[paper-1.19.2.jar:git-Paper-223]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:422) ~[paper-1.19.2.jar:git-Paper-223]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.2.jar:git-Paper-223]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1100) ~[paper-1.19.2.jar:git-Paper-223]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-223]
at java.lang.Thread.run(Thread.java:833) ~[?:?]

hazy parrot
hazy parrot
solid skiff
humble tulip
solid skiff
#

nvm i see the problem

humble tulip
crimson jasper
#

for some reason this just makes it day-night-day-night without actually stopping when it should reach the break;

#

also it doesn't kick me out of bed when it becomes day

crimson jasper
#

Basically nicely skipping time forward to day when only half the servers players are sleeping

humble tulip
#

maybe it's because curSleeping.size() doesnt change

crimson jasper
#

curSleeping.size() = current amount of players in bed

humble tulip
crimson jasper
#

oh

#

is there a foreach tick or something like that?

humble tulip
#

there is

#

?scheduler

#

?scheduling

undone axleBOT
humble tulip
#
new BukkitRunnable() {
  you can define variables here like;
  String name = "minion325";
  @Override
  public void run() {
    The run is like the inside of your while loop. So you can do an if (condition here);
    cancel(); breaks the loop
  }
}.runTaskTimer(plugin, 0L /*<-- the initial delay (0 ticks)*/, 1L /*<-- the interval (1 tick)*/);
crimson jasper
#

Thank you very much ^^

solid skiff
#

Im making a plugin for homes and other stuff like that, how would I override essentials messages

hybrid spoke
#

you mean commands?

winged anvil
solid skiff
#
[18:10:58] [Server thread/ERROR]: Error occurred while enabling CraftyCore v${version} (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "org.craftystudios.CraftyCore.getCommand(String)" is null
    at org.craftystudios.CraftyCore.onEnable(CraftyCore.java:77) ~[CraftyCore-1.1-PRE.jar:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-270]
    at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-270]
    at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:279) ~[paper-1.19.2.jar:git-Paper-270]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1100) ~[paper-1.19.2.jar:git-Paper-270]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-270]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]```

lovely
#

I don't think I have a null value?

humble tulip
#

Oh lol

delicate lynx
#

is the command in plugin.yml

humble tulip
#

Command isn't in plugin.yml

solid skiff
#

i dont see one

ivory sleet
buoyant viper
#

@solid skiff make sure you have the command listed in your plugin.yml file

winged anvil
# ivory sleet What exactly are you doing?

nothing in specific, i do use pdc however. i think it’s already thread safe cause i have a class to represent the data i want stored in the chunk and i use gson to save the object and parse it and blah blah

#

but i save it everytime i make a change to the object so

ivory sleet
#

No thread safety is not about that

winged anvil
#

oh alr so i’m good

#

if i were to create a new runnable and altering chunk pdc would that be potential for error or

ivory sleet
#

Wym create a new runnable?

#

Are you referring to invoking the runnable on another thread?

pine island
#

Anyway to check for a different event in an even handler

pine island
#

this wont work but i got a good idea tyvm

summer scroll
#

What event should I use when a player has successfully crafted something?

humble tulip
pine island
#

trying to detect a right click on a stick after jump

#

here is my code for now

#
public class doubleJump implements Listener {

    public static boolean[] isDoubleJumping = new boolean[2];

    @EventHandler
    public void checkJump(PlayerMoveEvent e) {
        Player player = e.getPlayer();
        Vector velocity = player.getVelocity();
        // Check if the player is moving "up"
        if (velocity.getY() > 0)  {
            // Default jump velocity
            double jumpVelocity = 0.42F; // Default jump velocity
            //check if player has potion effect of jump
            for (PotionEffect effect : player.getActivePotionEffects()) {
                if (effect.getType().equals(PotionEffectType.JUMP)) {
                    jumpVelocity += (float) (effect.getAmplifier() + 1) * 0.1F;
                }
            }
            // Check if player is not on ladder a\nd if jump velocity calculated is equals to player Y velocity
            if ((player.getLocation().getBlock().getType() != Material.LADDER) && (Double.compare(velocity.getY(), jumpVelocity) == 0)) {
                isDoubleJumping[0] = true;
                player.sendMessage("You jumped");
            }
        }
    }
    @EventHandler
    public void ballFiring(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        Action action = event.getAction();
        if ((action == Action.PHYSICAL) || (event.getItem() == null) || (event.getItem().getType() == Material.STICK)) isDoubleJumping[1] = true;

        if (isDoubleJumping[0] && isDoubleJumping[1]) {
            player.setVelocity(player.getLocation().getDirection().multiply(2));
            isDoubleJumping[0] = false;
            isDoubleJumping[1] = false;
        }
    }

}
#

i kinda got lazy w comments

#

@humble tulip

summer scroll
#

It is called when "Called when the recipe of an Item is completed inside a crafting matrix."

#

I need it when the player taking the recipe result.

humble tulip
#

Isn't that what it is?

#

There's also that^^

atomic swift
#

can i use a switch stmt in an onTabComplete bc i get this when trying to complete

humble tulip
#

U can

#

U maybe used it wrong

atomic swift
#
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
        List<String> completion = new ArrayList<String>();
        switch (args.length) {
        case 0:
            if (sender.hasPermission("dungeons.admin.music.playfor")) completion.add("playfor");
            completion.add("play");
            completion.add("stop");
            break;
        case 1:
            switch (args[0]) {
            
            case "play":
                ConfigurationSection sounds = Main.getInstance().getConfig().getConfigurationSection("sounds");
                for (String sound : sounds.getKeys(false)) {
                    completion.add(sound);
                }
                break;
            case "stop":
                break;
            case "playfor":
                ConfigurationSection soundss = Main.getInstance().getConfig().getConfigurationSection("sounds");
                for (String sound : soundss.getKeys(false)) {
                    completion.add(sound);
                }
                break;
            
            default:
                break;
            }
            break;
        case 2:
            if (args[0]=="playfor") { for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                completion.add(player.getName());
                
            };break;}
            switch (args[1]) {
            case "":
                
                break;

            default:
                break;
            }
            break;
        default:
            break;
        }
        
        
        return completion;
    }
humble tulip
#

Where's rhe console error

glad prawn
#

Yes

pine island
#

anyway to pause code execution wout stopping the whole server?

atomic swift
pine island
#

thanks

#

okay i forgot im kinda dumb i just need my code to run after about 8 ticks how would i do that

eternal oxide
#

runTaskLater

pine island
#

mhm figured it out thanks !

sterile token
#

Sorry wrong reply

fading spindle
#

what was the format for a "Date" class in spigot?

sterile token
fading spindle
#

thx

rotund jolt
#

Does anyone know how/if its possible to set a chest animation to be open on 1.18+?

sullen marlin
#

?jd-s

undone axleBOT
rotund jolt
#

I cant find the nms methods used in 1.17- to do so in newer versions

sullen marlin
#

Literally Chest#open

#

No nms needed

white dew
#

Hey, guys, I'm trying to set a compass that points to a player

#
public ItemStack getCompass() {
        ItemStack compass = CustomItem.runnerTracker();

        Location locToGet = player.getLocation();
        locToGet.setY(locToGet.getY()+1);
        player.getWorld().dropItemNaturally(locToGet, compass);

        CompassMeta meta = (CompassMeta)compass.getItemMeta();
        Location loc = new Location(player.getWorld(), 0, 0, 0);
        for (Player p : Bukkit.getOnlinePlayers()) {
            UUID uuid = p.getUniqueId();
            if (uuidToPP.containsKey(uuid)) {
                PlayerPlus pp = uuidToPP.get(uuid);
                if (pp instanceof SpeedRunner) {
                    loc = p.getLocation();
                }
            }
        }
        player.sendMessage(String.valueOf(loc.getX()));
        meta.setLodestone(loc);
        compass.setItemMeta(meta);
        return compass;
    }
#

I manage to get the location of the player

#

and I set meta.setLodestone(loc), that is, I set the position the compass should point

#

then, I update the compass ItemMeta

#

Its not really updating tho

#

I don't know why

rotund jolt
# sullen marlin Literally Chest#open

I keep getting this error, is there any way todo it with compatibility for older versions? java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock cannot be cast to class org.bukkit.block.Chest (org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock and org.bukkit.block.Chest are in unnamed module of loader java.net.URLClassLoader @759ebb3d)

white dew
#

maybe I have to actually create some kind of block for It to point, and Its wrong because Its pointing to an Air location?

river oracle
rotund jolt
worldly ingot
#

Because Chest is a BlockState, not a Block

#

Chest chest = (Chest) block.getState();

rotund jolt
#

oh, okay that makes sense

white dew
#

Hi, I'm trying to set a player tracker with a compass

#
public void updateCompass() {
        CompassMeta meta = (CompassMeta)compass.getItemMeta();
        Location loc = new Location(player.getWorld(), 0, 0, 0);
        for (Player p : Bukkit.getOnlinePlayers()) {
            UUID uuid = p.getUniqueId();
            if (uuidToPP.containsKey(uuid)) {
                PlayerPlus pp = uuidToPP.get(uuid);
                if (pp instanceof SpeedRunner) {
                    loc = p.getLocation();
                }
            }
        }
        meta.setLodestoneTracked(false);
        meta.setLodestone(loc);
        compass.setItemMeta(meta);
    }
#

however

#

It seems like the compass isn't actually pointing to the position I want

#

I'm playing by myself, so, the code should make so the compass points to (0, 0, 0)

#

however, I can't get It to work

#

I don't understand why

#

the location is correct

trim lake
#

How to make BukkitRunnable run in every iteration of for? BukkitRunnable is now run after all iterations of for.

for (int i = 1; i <= countStates; i++) {
            int smeltTime = config.getInt("state-" + i + ".smelt-time");
            long doneTime = System.currentTimeMillis() + (smeltTime*1000);
            int y = i;
            new BukkitRunnable() {
                boolean done = false;                
                int left;                
                public void run() {                    
                    if (done) return;                
                    left = (int) (doneTime-System.currentTimeMillis());    
                    if (left < 0 ) left = 0;
                    if ( System.currentTimeMillis() >= doneTime ) {

                        ItemStack item = new ItemStack(Material.valueOf(config.getString("state-" + y + ".item")));
                        ItemMeta meta = item.getItemMeta();
                        meta.setCustomModelData(config.getInt("state-" + y + ".modeldata"));
                        item.setItemMeta(meta);
                        frame.setItem(item);
                        
                        done = true;
                        cancel();
                    }
                }
            }.runTaskTimer(Main.getPlugin(Main.class), 0, 1);```
trim lake
white dew
#

Maybe!!

#

Why, tho? πŸ€” I thought the compass would update by itself

#

since I did compass.setItemMeta(meta)

trim lake
#

I guess you updating item, but not in player inventory. Idk how to explain in English.

white dew
#

oooh

#

I see :o

#

thank you

#

I will try that

trim lake
#

idk, if that will works πŸ˜„ let me know

white dew
#

thanks!

#

I actually didn't delete It, tho. I just set the lodestone before dropping the item to the player

#

which gives the same result

trim lake
#

Mby there is better solution, maybe u need only player.updateInventory(); or idk how you get compas as ItemStack. If you get like this: player.getInventory().getItemInMainHand(); I guess your code should work.

trim lake
white dew
#

I wonder what I can do to make so It updates every time the player moves, tho. My first thought was to make a listener to detect PlayerMoveEvent and update the item meta of the compass every time the event happens

#

ooooh, I think I'm gonna try to use the player.updateInventory() method!!

#

this way I don't have to constantly delete the compass

trim lake
white dew
#

oooh, thanks :)

#

java is my favorite language, but I'm new as well XD

#

Its very fun

trim lake
#

ye it is, I started with PHP, thats my favorite for some reason

white dew
#

ooooh

#

cool!

#

do you use PHP for backend web development?

trim lake
white dew
#

aaah, I see

#

awesome!!

pine island
#

i know this dumb but im extremely lost

remote swallow
#

?di

undone axleBOT
pine island
#

aight ty

sonic goblet
#

sex.java 🀨

pine island
#

where the problem is

else {
                new BukkitRunnable() {

                    @Override
                    public void run() {
                        isDoubleJumping[0] = false;
                    }

                }.runTaskLater(plugin, 1);

            }
```Error
pine island
pine island
# pine island where the problem is ```java else { new BukkitRunnable() { ...

the whole event listener:

  @EventHandler
    public void checkJump(PlayerMoveEvent e) {
        Player player = e.getPlayer();
        Vector velocity = player.getVelocity();
        // Check if the player is moving "up"
        if (velocity.getY() > 0)  {
            // Default jump velocity
            double jumpVelocity = 0.42F; // Default jump velocity
            //check if player has potion effect of jump
            for (PotionEffect effect : player.getActivePotionEffects()) {
                if (effect.getType().equals(PotionEffectType.JUMP)) {
                    jumpVelocity += (float) (effect.getAmplifier() + 1) * 0.1F;
                }
            }
            // Check if player is not on ladder a\nd if jump velocity calculated is equals to player Y velocity
            if ((player.getLocation().getBlock().getType() != Material.LADDER) && (Double.compare(velocity.getY(), jumpVelocity) == 0)) {
                isDoubleJumping[0] = true;
            }
            else {
                new BukkitRunnable() {

                    @Override
                    public void run() {
                        isDoubleJumping[0] = false;
                    }

                }.runTaskLater(plugin, 1);

            }
        }
    }
#

oh also this "plugin"

pine island
#

im too dumb to understand that

glad prawn
#

Right at the beginning it talks about what you need. 🀣

pine island
#

...as i said im dumb. and i dont realize shit- ,also 4% save

remote swallow
#
public class ClassName implements Listener {
    private final MainClassname plugin;
    public ClassName(MainClassName plugin) {
      this.plugin = plugin;
    }

}
pine island
#

okay does this look good?

glad prawn
#

πŸ‘

pine island
#

finally

#

ty yall

small current
#

nice

mighty pier
#

dependenffy infecion

pine island
#

okay

#

so

#

erm

#

how do u check for an item's name

#

i want to check if stick is named "Movement Stick"

remote swallow
#

if (item.getItemMeta().getDisplayDisplayName().equals("My Item Name"))

frail gale
winged anvil
#

sex plugin

pine island
#

no its a combat and movement plugin i just couldnt find a funny name for the main class

#

my project is literally named after my gf(totally not my dream anime gf mhm)\

small current
#

how can i store pdc on signs

#

but this returns null, its the same block

mighty pier
#

ew persistent data containers

remote swallow
#

pdc is great

mighty pier
#

in the good old 1.8 days there were none

earnest forum
#

right but they are so useful

mighty pier
#

cringe

small current
#

what should i do

mighty pier
#

dont make it

#

simple

small current
#

use nbt

#

for entities

#

but idk for blocks

mighty pier
#

lmao

#

hahaha

#

nbt

small current
#

if there is nbt for blocks

earnest forum
#

only for tile entities

#

blocks with data

#

chests, furnaces

mighty pier
#

i want pre swim update

small current
#

sign?

mighty pier
#

yes

#

sign has data

#

how dj you think you can put text on it

small current
#

i do this and the get returns null

#

its the same block im sure

mighty pier
#

i cum

small current
pine island
drowsy helm
#

you want to summon a firework with playsound?

pine island
drowsy helm
#

youre looking a really outdated post

#

refer to the docs

#

and fireworks have FireworkMeta which can be edited

pine island
drowsy helm
#

well either way i think the methods are the same

pine island
#

ehh some things change

#

but thank you very much

#

i shall leave now before a herd of humans attack me for using an "old version"

#

ahsabsdjkabjksd yes

#

?1.8

undone axleBOT
pine island
#

its not too old.

glad prawn
#

Yes

#

Just 7 years

pine island
#

yeah

#

anwyays

#

im out-

pine island
#

i cant hear the audio

earnest forum
#

check ur in game audio settings

#

make sure nothing is 0%

pine island
#

nope nothing is

glad prawn
earnest forum
#

1 volume should be loud enough

pine island
#

i have it set to 50.

#

i will blast everyones ears off

earnest forum
#

maybe use the Sound enum

glad prawn
#

Sound.ENTITY_PLAYER_LEVELUP 🀷

earnest forum
#

instead of the string

#

yeah

glad prawn
#

It also has a valueOf method

torn shuttle
#

Writing documentation is the mind-killer.

hybrid spoke
torn shuttle
#

github documentation unfortunately

hybrid spoke
#

then let copilot do it for you and copy&paste it

glad prawn
#

Xd

torn shuttle
#

and this is just one page

#

this is killing me

maiden thicket
#

are entity IDs per world or global for the server?

eternal oxide
#

Global. You can teleport entities across worlds

maiden thicket
#

ty!

buoyant violet
#

hey guys

#

i am learning java

#

and i need help about this exercise

wet breach
#

don't expect to be spoonfed

buoyant violet
#

i need just a little help

wet breach
#

however, that doesn't mean we can't help you understand

buoyant violet
#

so

#

16 to 17

#

how do i write in java

#

if (age == 16 && 17)?

#

cause the exercise says that i need to write it only with if and &&

#

not with else if

wet breach
#

so you want to check if their age is greater then 16 and less then 17?

buoyant violet
#

16 to 17

wet breach
#

oh, only with &&

buoyant violet
#

yes

wet breach
#

what a weird question to teach the usage of &&

buoyant violet
#

ye ik

#

i am learning java

wet breach
#

alright have you used && in an if statement before?

buoyant violet
#

cause i want to create plugins and mods

buoyant violet
#

i use it in a String questions

wet breach
#

so && = and in an if statement

buoyant violet
#

&& = and?

#

oh

wet breach
#

it is another way of saying I want to compare with this and also this

buoyant violet
#

wait let me translate

#

cause i am italian

#

i am on B1+ so

wet breach
#

so, instead of writing 2 if statements for checking 16 and 17, you would combine the 2 ifs with &&

buoyant violet
#

ohhh

drowsy helm
#

Why would thye show you an if statement that is never satisfied lol

wet breach
#

if ((this == that) && (this == other)) {}

buoyant violet
#

oh TY man

wet breach
#

so what that says, is the if statement will run only if both those conditions are true

buoyant violet
#

ye but in intellij he tells me that its an error

wet breach
#

I missed a bracket above

#

added it

buoyant violet
#

if (age == 16) && (age == 17)

#

oh yep

#

now it works

#

i am doing programmingbydoing

#

so

wet breach
#

now the reason I said the question isn't quite right for teaching that is because you could do this instead

#

if ( 16 <= age => 17)

#

but it really depends what needs to be accomplished

buoyant violet
#

ye but if i put <16

#

<=16

#

then he would count even to 16 and lower

onyx fjord
wet breach
#

probably, I don't know what they are working on

buoyant violet
#

i am working on a age calculator

onyx fjord
#

It can't be 16 and 17 in the same time

buoyant violet
#

oh

drowsy helm
buoyant violet
#

i need to write liek

#

if you are 16 to 17

#

you can drive but you cant vote

#

and so on

onyx fjord
#

|| ?

wet breach
#

not that it should be used like that

onyx fjord
#

|| - OR
&& - AND

buoyant violet
#

yep its not gonna work

#

i tried it out

onyx fjord
#

Change the symbols

buoyant violet
#

it stops when i say my age

#

ow

#

oh

#

now it works

#

ty @onyx fjord

wet breach
buoyant violet
#

?

#

they learned me that at school

#

its like a program to create algorithms

#

and i dont really suck at that yk

wet breach
#

no

#

I learned algorithms the old fashion way πŸ™‚

buoyant violet
#

thank god you learn it in the old fashion way

#

cause it SUCKS

#

its like really closed as a program

#

you use shapes

#

and much more

#

you dont write codes

wet breach
#

well that is because it isn't for the purpose to learn programming algorithms rather to understand them in how they work

buoyant violet
#

imagine that i need to go from flowgorithm to c# and c++ πŸ’€

wet breach
#

if you can understand how an algorithm is supposed to work, then you know in how it should need to be programmed or how the concept needs to work

buoyant violet
#

and do html

#

yk i would like to do some cool things at school like py, js and css

#

i am not saying that c# and c++ sucks

#

but

#

its difficult

wet breach
#

you don't have to be at school to do cool things

buoyant violet
#

i am trying to learn a lot of languages

#

like c# c++ py

#

i wanna start with java

#

so

#

i am starting with java

wet breach
#

when I was in High school, I hosted and ran one of the school clubs websites from home πŸ™‚

#

it ran on a pentium 3 with 1gb of ram πŸ˜„

buoyant violet
#

pentium 3 its like old gen my guy

wet breach
#

only 90's old gen πŸ˜›

buoyant violet
#

a question = how tf did you start a pc with a 1gb of ram

#

like

#

bro

wet breach
#

windows xp didn't require 2gb of ram to start

#

or the previous windows versions

buoyant violet
#

btw how old are you?

#

cause you know a lot of things

#

btw i am 15

onyx fjord
#

Back in a day

buoyant violet
#

yooo what all yall saying

onyx fjord
#

I'm only 17

#

But ye

humble tulip
#

#general

buoyant violet
#

i am the only tech guy at school that really know this things

#

even the teachers are impressed

#

idk why

onyx fjord
#

I have like 70 people like that in mine

#

Hehe

#

Siuuu

wet breach
#

and then the club shut down. I was known as the ghost founder of the club πŸ™‚

#

mainly because I never really went to school

onyx fjord
#

What website

#

In Poland you have to

#

At least 50% of all hours

wet breach
#

The name of the club was called Legion Tech Club basically a club that revolved around technology and of course anyone was free to join

#

I am one of the founders of it πŸ˜‰

onyx fjord
#

Fun

#

Less fun when you have 4 hours free

#

Daily

#

:/

humble tulip
#

Which host is good for a US based vps?

wet breach
#

anyways, I ran the website for that club and was the only founder who did so, but like no one ever saw me just knew that I was the mysterious founder never present πŸ˜›

onyx fjord
#

Every IT person:

#

Working at Microsoft is a food eating simulator

glossy venture
onyx fjord
#

And walking simulator

wet breach
#

it was awesome because when I did show up, people would gather to just actually see me XD

#

so they could say, they saw the ghost

cobalt marlin
onyx fjord
#

Rare NPC πŸ˜‚

wet breach
buoyant violet
#

btw guys thank you

#

i have finished my assignment

cobalt marlin
onyx fjord
#

About what

wet breach
buoyant violet
humble tulip
#

Ovh?

hybrid spoke
#

otherwise ovh if you got the money

onyx fjord
#

Oh fuck it's help development

wet breach
# humble tulip Ovh?

OVH does exist in the US, their Montreal data center however is also not that bad either in terms of US

next plume
#

Sorry. Misread.

elfin atlas
#

Is there a way to check if a pressure plate is pressed outside of the PlayerInteractEvent (so just checking the current state)

torn shuttle
#

ayy I spilled my drink on my keyboard

#

reset the clock, my average is now once every 5 years

eternal oxide
#

probably

wet breach
wet breach
#

since pressure plates do not implement or extend those interfaces

eternal oxide
#

Looking at the javadocs pressureplates are not mentioned at all, other than deprecated and told to use BlockData

wet breach
#

while it is deprecated it should still work since there really isn't a replacement for such things

elfin atlas
#

Like when a player is standing on it

#

I want to check if he is standing atleast 5 seconds on it to execute something

hushed pawn
#

how to pass argument to the task with that construction?
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
}, 40);

elfin atlas
#

BlockData and casting to powerable?

eternal oxide
#

probably not, but you can try

#

your new question is different though

elfin atlas
#

Is not working,.

eternal oxide
#

you want to listen for a player stepping on a plate and see if they stay on it for 5 seconds

elfin atlas
#

Yep

#

I mean I just need to check if the pressure plate is still pressed after the PlayerInteractEvent

#

Only problem is to check if it is pressed

wet breach
#

get the block in question and check if its a pressure plate

#

if so, just use PressurePlate.isPressed()

#

you can try the casting, but I doubt it will work

elfin atlas
#

Already tried

wet breach
#

I don't mean to cast to PressurePlate

robust sinew
#

why is it that new WorldCreator(worldName).createWorld(); or Bukkit#createWorld(WorldCreator) freeze the server when loading the world?

wet breach
#

You can't cast BlockData to pressure plate first off and second it should be Block

#

you can cast a Block to PressurePlate

elfin atlas
#

Does it only work with Wood_plates?

wet breach
wet breach
#

that is why I said get the block

elfin atlas
#

Okay

#

I will try

hushed pawn
#

how to pass something to the delayed task so it will be the same that at the moment when task was created? (i need to do it every tick)

robust sinew
#

or create a world without that

wet breach
#

I would recommend searching up Aikar flags

#

and using those JVM flags first

remote swallow
#

?flags

undone axleBOT
wet breach
#

there we go

#

that would be the first thing to try

#

the third thing would be to not create the world

#

you could instead just make pre-generated worlds and just call load(world)

#

loading a world is not as resource consuming as creating one

hushed pawn
# wet breach what do you mean by this?

if i create delayed task its just a pice of code that will be executed after some time, but i need some parameter in condition that it was at the time when task was created

wet breach
#

I am not understanding that last part

remote swallow
#

are you wanting variables in a scheduler?

wet breach
#

like, are you needing to figure out how to come up with the time to feed into the method to create the delayed task? o.O

hushed pawn
remote swallow
#

create the variable and set it before the scheduler?

hushed pawn
#

yes, but it changes every tick

remote swallow
#

what is the variable meant to be, like what are you saving

hushed pawn
#

Location

remote swallow
#

check if it matches in the scheduler then run a method if it does

hushed pawn
#

matches to what?

remote swallow
#

what your checking

hushed pawn
#

i didnt meant that

remote swallow
#

or do you just need to save their location every tick

hushed pawn
#

ye, and use that value after 20 ticks

#

in BukkitScheduler

#

but i dont know how

#

maybe i need some kind of buffer

#

i im pretty sure it have to be easier

eternal oxide
#

passing variable is simple, just ensure they are final

#

?scheduling

undone axleBOT
elfin atlas
# wet breach that is why I said get the block

Not working.

[13:56:01 WARN]: [CraftFactory] Task #6161426 for CraftFactory v0.4 generated an exception
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock cannot be cast to class org.bukkit.material.PressurePlate (org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock and org.bukkit.material.PressurePlate are in unnamed module of loader java.net.URLClassLoader @25f38edc)
        at me.katze.cf.games.winterevent.goatfight.GameHandler$4.run(GameHandler.java:202) ~[cf-0.4.jar:?]
        at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.jar:git-Paper-29]
        at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.jar:git-Paper-29]
        at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1490) ~[paper-1.19.jar:git-Paper-29]
        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:446) ~[paper-1.19.jar:git-Paper-29]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1414) ~[paper-1.19.jar:git-Paper-29]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1187) ~[paper-1.19.jar:git-Paper-29]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:302) ~[paper-1.19.jar:git-Paper-29]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
eternal oxide
#

Just don;t use a lambda and pass the variable in the constructor

elfin atlas
echo basalt
#

mans casting the block itself

wet breach
echo basalt
#

instead of the state or data

elfin atlas
wet breach
hushed pawn
echo basalt
#

neither of these extend Block

elfin atlas
#
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.block.impl.CraftPressurePlateWeighted cannot be cast to class org.bukkit.block.data.Powerable (org.bukkit.craftbukkit.v1_19_R1.block.impl.CraftPressurePlateWeighted and org.bukkit.block.data.Powerable are in unnamed module of loader java.net.URLClassLoader @25f38edc)
#

That was the error I got then

hybrid turret
#

I'm very confused rn. Did something change between 1.19.2 and 1.16.4 regarding external libraries?

wet breach
#

BlockData data = Block.getBlockData()
if (data instanceof Powerable) {
    (Powerable) data;
}

if (data instanceof AnaloguePowerable) {
    (AnaloguePowerable) data;
}
undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

wet breach
#

hence why I included it above

#

but with the examples above you should be able to work it into your code to work πŸ™‚

hybrid turret
elfin atlas
wet breach
#

not sure if that is what you were asking

wet breach
# elfin atlas

reason I didn't add anything is because you need to use the methods available to data after casting

#

can't spoonfeed you everything

#

I gave enough code that you should be able to work out how to do it from there

elfin atlas
#

Okay

hybrid turret
elfin atlas
wet breach
#

those two instanceof's should cover all the types of pressure plates

hybrid turret
#

Oh, CraftPlayer and EntityPlayer doesnt exist anymore? o.o

hybrid turret
#

i cant seem to find it at least. welp. time to find out again how to make a /ping command

wet breach
hybrid turret
#

sorry, NMS? i guess i missed a chapter

wet breach
#

net.minecraft.server

hybrid turret
hybrid turret
wet breach
#

They still are, but a restructure in how everything looks happened

#

I think back in 1.17?

hybrid turret
#

oh boy, that's what i get for coding in 1.16 for a whole bunch of time

wet breach
#

lol

hybrid turret
#

i started my plugin at 1.8, ported it to 1.16 (fairly easily) and now i'm confused lmao

wet breach
#

just when you thought you wouldn't be outdated

#

you learn you already are and for quite a while

hybrid turret
#

yeaaah

#

i'm so heavily confused by the ping thing

#

shit

#

before you were able to do that like this:

    CraftPlayer cp = (CraftPlayer) p;
    EntityPlayer ping = cp.getHandle();
    return ping.ping;
  }
#

now that CraftPlayer and EntityPlayer doesn't exist anymore... i'm fucked essentially

wet breach
hybrid turret
#

oh

#

wait

#

i'm so sorry i don't get the bootstrap thing

wet breach
#

but, you can get the ping from the API though

hybrid turret
#

oh, there's a method now

wet breach
#

so maybe not all is lost and might be easier for you now πŸ˜„

hybrid turret
#

i feel stupid

wet breach
#

but if all you were needing was just the ping, well you can just stick with the API now πŸ˜‰

hybrid turret
#

The rest in the plugin is working fine i guess

#

it built at least

#

let's see if it works

#

everything works, hell yeah!

wet breach
crimson jasper
#

for some reason this task doesn't stop when it's day

#

is my logic wrong?

vocal cloud
#

Wouldn't cancel just cancel the current iteration and not the scheduled service

crimson jasper
#

I think cancel stop the whole scheduler

vocal cloud
#

What does the docs say for it? Add some logging to see if that's the case.

crimson jasper
vocal cloud
#

If you put an info log into that if you'll find out if it works or not

crimson jasper
#

Now it worked for some reason

#

probably my logic being weird

elfin atlas
#

Question is there a way to check from a list of locations what is the nearest from the player location and teleport them then there ?

eternal oxide
#

loop the list and use Location#distance

worldly ingot
#

distanceSquared pls & ty

elfin atlas
quiet ice
#

Beware of comparing the World first though

eternal oxide
#

pretty sure distance checks for same world

#

?stash

undone axleBOT
trim lake
#

How to make BukkitRunnable run in every iteration of for? BukkitRunnable is now run after all iterations of for.

            int smeltTime = config.getInt("state-" + i + ".smelt-time");
            long doneTime = System.currentTimeMillis() + (smeltTime*1000);
            int y = i;
            new BukkitRunnable() {
                boolean done = false;                
                int left;                
                public void run() {                    
                    if (done) return;                
                    left = (int) (doneTime-System.currentTimeMillis());    
                    if (left < 0 ) left = 0;
                    if ( System.currentTimeMillis() >= doneTime ) {

                        ItemStack item = new ItemStack(Material.valueOf(config.getString("state-" + y + ".item")));
                        ItemMeta meta = item.getItemMeta();
                        meta.setCustomModelData(config.getInt("state-" + y + ".modeldata"));
                        item.setItemMeta(meta);
                        frame.setItem(item);
                        
                        done = true;
                        cancel();
                    }
                }
            }.runTaskTimer(Main.getPlugin(Main.class), 0, 1);```
wet breach
#

people should learn di

#

and also learn to not name main class as main

remote swallow
#

?main

remote swallow
#

?di

undone axleBOT
wet breach
#

need to start recording these commands

remote swallow
#

lol

wet breach
#

with the above I have no idea which tasktimer they are using

#

I would assume its a delayed one?

wet breach
trim lake
#

So thats the problem πŸ˜„ If I let print some string in runnable is printing run1 and run2 in same time.

wet breach
#

the appropriate math for converting ticks to milliseconds is as so (ticks / 20) * 1000 if we assume ticks is 5, then its 250ms with the math above that you have, it would translate to 5000ms instead which is not accurate at all.

trim lake
#

But im not comparing tick Im comparing time. And problem is, for1 runs, for2 runs and than Runnable. I need to for1 runs, Runnable runs, for2 runs.... etc.

#

and In config Im setting time in seconds

wet breach
#

I am aware you are comparing time, but your time is incorrect due to incorrect math

#

if we use my example above, and lets say smelt time is only 5 ticks. You are saying time wise it is 5 seconds when really it is 250ms

#

that is how far off your time math is

trim lake
#

I dont see thats a problem. Problem is, If I set first time to 10 secodns and secound to 11 seconds, first change will happen after 10 seconds and second change will happen after 1 sec after the first one.

#

I have tested that

wet breach
#

alright keep living with incorrect math and code then

#

you don't see its a problem then I don't see you having a problem above and thus don't require help from me will leave it to someone else to help πŸ™‚

trim lake
#

Im probably dumb, but I relay dont know where is problem.

wet breach
#

well you refuse to fix something pointed out as probably a problem. Generally it is best to fix all that is wrong as people go through to help.
System.currentTimeMillis() >= doneTime since you are comparing time here

#

I have pointed out your math for calculating done time

#

is flawed

#

I gave you the appropriate math above to fix that

trim lake
#

Ye Im comparing time here. So if done time is ex. 1500 and time is 1501 that true and think is done. Or do I miss something? Gona read again.

trim lake
wet breach
#

you are converting ticks to milliseconds incorrectly is what I am saying

#

there is only at most 20 ticks in 1 second. Well to convert to seconds, we have to divide the ticks by 20 and then to convert to milliseconds multiply that result by 1000

#

therefore (ticks / 20) * 1000 = ticks_converted_to_milliseconds

trim lake
#

Idk if I understand correctly, but this is how I understand think. Ex. if system time is 1000 and smeltime is 5 and than I make *1000 to get milliseconds. So if I count 1000+5000 is 6000, so when time hit 6000 is makred as done

#

That how I understand my code

#

but System.currentTimeMillis() is not in ticks, is it?

wet breach
#

no, its milliseconds

trim lake
#

Im not working with ticks, Im working with miliseconds

wet breach
#

I am assuming you are grabbing the smelt time from the API? Like from a furnace. if so the time is in ticks

trim lake
#

and with seconds in config

#

No, Im grabing smelt time from config

#

Is not actually smelting in furnace

wet breach
#

oh my bad then from mis-understanding the smelttime then πŸ™‚

#

lol

trim lake
#

Im just making smeling like in biiiig furnace. So its looks like, fire and above him is itemframe where you smelting the item.

#

I should post more of the code, my bad

#

it would be better understood

wet breach
#

I think the part where it might be going wrong in your code as for your issue is most likely this

trim lake
#

The problem is the BukkitRunnable think is running after all for is done

wet breach
#

if (done) return;

#

I believe it should instead be if(!done) return;

#

the way you have it, says if done = true return

#

the way I have it, says if done does not equal true (AKA if its false)

trim lake
#

Ye, bcs done is set to false on begining of the for loop. And If time hit requested variable Im seting done to ture. Thats why Im returning if done is true, no needed to run Runnable again

wet breach
#

if it were me I would re-write that piece of code to be this instead

hushed pawn
#

how does it calls field abvoe hpbar?

wet breach
#
if(!done) {
    return;
} else {
    cancel()
}
#

I would probably do that instead, in this manner it is checked if the runnable should be running or not

trim lake
#

I gona try. But I need to run Runnable INSIDE for iteration and thats not happening.

wet breach
#

probably because there isn't anything to invoke run

#

do this instead

#
BukkitRunnable taskRunnable = new BukkitRunnable() {
                boolean done = false;                
                int left;                
                public void run() {                    
                    if (done) return;                
                    left = (int) (doneTime-System.currentTimeMillis());    
                    if (left < 0 ) left = 0;
                    if ( System.currentTimeMillis() >= doneTime ) {

                        ItemStack item = new ItemStack(Material.valueOf(config.getString("state-" + y + ".item")));
                        ItemMeta meta = item.getItemMeta();
                        meta.setCustomModelData(config.getInt("state-" + y + ".modeldata"));
                        item.setItemMeta(meta);
                        frame.setItem(item);
                        
                        done = true;
                        cancel();
                    }
                }
            }.runTaskTimer(Main.getPlugin(Main.class), 0, 1);

    for (int i = 1; i <= countStates; i++) {
            int smeltTime = config.getInt("state-" + i + ".smelt-time");
            long doneTime = System.currentTimeMillis() + (smeltTime*1000);
            int y = i;
            taskRunnable.run()
}

think that should work

humble tulip
#

πŸ₯„πŸ‘Ά

wet breach
#

but, you might be better off with making a task instead of using runnable possibly

wet breach
humble tulip
#

My badπŸ˜‚πŸ˜‚

#

I just saw you paste everything for them

wet breach
#

I was showing how it needs to be because their current code, nothing is invoking the run method

twilit roost
#

How can I turn world sides ( North,West.. ) into vector?

wet breach
#

why would you want to do that?

#

a vector from the API takes coordinates

#

coordinates or a location

twilit roost
#

well I want to create line of block going in a direction
but it isn't ever straight

humble tulip
twilit roost
#

well I didn't want to hardcode it
soo I was looking for some solutions

humble tulip
#

Idk how it is but let's assume north is positive x, the vector will be 1,0,0

#

South is - 1,0,0

humble tulip
#

East will be 0,0,1

#

West will be 0,0-1

#

That's assuming positive x is north, you cqn check what it is frm ingame

eternal oxide
#
BlockFace face = BlockFace.NORTH;
Vector vec = new Vector(face.getXMod(), face.getYMod(), face.getZMod());```
twilit roost
#

imma check it
thx

native ruin
#

If(true!=false) { return true;} else{ return false;}

humble tulip
humble tulip
eternal oxide
#

you may be able to just use getDirection() on the BlockFace

wet breach
#

depends which way you are wanting it

#

if you want it from the players perspective you would need the opposite face for the appropriate

echo basalt
wet breach
#

if it is true, it actually does something

echo basalt
#

I know

#

but if done is true

#

it doesn't return

wet breach
#

I mean I suppose they could just move their code below into that if statement lol

echo basalt
#

you don't need the else

#

yes

#

unless you're doing nested ifs and have a weird structure

#

but like

#

why would you

wet breach
stark marlin
#

I've previously used this line of code to set the message format in chat, in the AsyncPlayerChatEvent, however it seems that newer versions of Minecraft cause an "message has been modified by the server" warning to the player. Any way I could prevent that?
event.setFormat(player.getDisplayName() + " Β§7Β» " + (player.hasPermission("chat.white") ? "Β§f" : "Β§7") + msg);

#

Is there a new better method to set the "format" without being able to modify the player's message?

twilit garden
#

hm, is there a way to regenerate the map?, im trying to make a minigame but dont know how to setup servers like hypixel does

#

so if i have a arena thats gonna get blown up, i want it to regenerate after finishing a game

#

sorta like tnt run

wet breach
#

keep a copy of the world in question AKA master. On the world needing being replaced ensure world saving is disabled upon end of game, unload the world delete the world files, copy world files from master then load world

#

voila, arena back as new πŸ™‚

vocal cloud
#

Couldn't you have a blueprint world loaded and just rebuild the world using that?

winged ridge
#

Hello I'm trying to change a block's appearance when its placed. This is what I've done:

@EventHandler
public void onPlace(BlockPlaceEvent event) {
    ItemStack placed = new ItemStack(event.getItemInHand());

    if (placed.isSimilar(CustomBlockItem.custom_block)) {
        Block block = event.getBlock();
        block.setMetadata("aa", new FixedMetadataValue(plugin, true));
        Player player = event.getPlayer();

        player.sendBlockChange(block.getLocation(), Material.OAK_LOG.createBlockData());
    }
}```
#

everything here works unless the last line

#

it doesn't change the block's texture to oak

remote swallow
#

it probably wants just Material.OAK_LOG

#

not Material.OAK_LOG#createBlockData

winged ridge
#

This is the functionsendBlockChange(@NotNull Location loc, @NotNull BlockData block);

#

it requires a blockdata

winged ridge
echo basalt
#

Ehh

#

I hate that sendBlockChange method as it isn't a proper fake block api

winged ridge
#

yeah

#

I have another question, do you know how to prevent the block from going back to it's orig texture?

#

when you click on it

#

I thought about using PlayerInteractEvent but this also detects when a block is placed

echo basalt
#

Yeah no you need to be a bit more severe

winged ridge
#
@EventHandler(priority = EventPriority.HIGHEST)
public void onTouch(PlayerInteractEvent event) {
    if(event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) {
        if (event.getClickedBlock().hasMetadata("aa")) {
            event.setCancelled(true);
        }
    }
}```
#

this is what i did

echo basalt
#

Intercept packets n all

winged ridge
echo basalt
#

Yeah it's annoying

#

I have it as a gist

winged ridge
#

can you send it?

echo basalt
winged ridge
#

that is a lot of code lmao

trim lake
wet breach
#

which are accurate and means you need to re-structure your code

#

another way you could do it, would be to make a class that implements runnable

trim lake
#

I will probably put Runnable in method and send variabels to it that should solve problem mby?

wet breach
#

That could work if I understand what you said correctly

trim lake
#

Im going to do like this: public void runThis(variabels) { Runnable }

wet breach
#

might as well make a class that implements runnable then

#

and then you could just have a method that calls that class

#

or pass the variables to that class

trim lake
#

Is not needed to make a class I gess, If I can make only method

wet breach
#

well you may still encounter the same problem because you would still need to create an inner class

#

or you could try instead of using a runnable to use a bukkittask

#

?scheduler

#

?scheduling

undone axleBOT
trim lake
#

ye, .runTaksLater should be better option mby. gona try

lime aspen
#

We set the skin on the player data so this should also effect tab
you can test this out by sideloading online mode using fastlogin
you could use a mod to still display it, but i don't recommend that
(ps, sorry for late responce)

winged anvil
#

what is the advantage of creating a singleton class when you could just make every field/method static with a private constructor. If its only meant to be instantiated one time, why not just make it static? I don't fully understand singleton pattern

#

or is the pattern to be used for lazy loading, only load when someone actually needs it

pine island
humble tulip
#

Since 1 zombie was facing you, he was thrown towards you but couldn't move due to the blocks

#

If you want the zombies to be thrown away from you, get zombie location.toVector subtract yourLocation.toVector

#

And set their velocity as that

#

You can also normalize it so all are flung the same distance

pine island
humble tulip
#

Um that is not what your code does

#

Your code flings the zombie in the direction they're facing

pine island
#

....

#

i get taht.

#

but

#

there is 4 zombies

#

but only one of them gets launched

#

others dont move.

remote swallow
#

could they already be in the corner?

pine island
humble tulip
#

They were facing the corner

pine island
#

somth like this?

humble tulip
#

Yes

#

That's a bit much though

#

Normalise it and that should be good enf

round finch
#

what this?

pine island
#

ehh ill keep it! makes iit easiser for me to read

humble tulip
pine island
#

got it!

humble tulip
#

Currently, the further away a zombie is the further it'll be thrown

pine island
#

also it works thank u sm!

humble tulip
#

Np

round finch
#

what you trying to?

pine island
round finch
#

i get the math now

remote swallow
# pine island

i love that we can just see console just dying with errors

pine island
#

it barley even chnages the performace

#

my thing works perfectly im afraid that ill breka it if i try to fix them

#

so they stay

remote swallow
#

null checks

round finch
pine island
remote swallow
#

also i dont think ClassCastExceptions are NPE's

humble tulip
#

πŸ˜‚πŸ˜‚

pine island
humble tulip
#

You should fix it

round finch
#

full log

remote swallow
pine island
tardy delta
#

lmfao

remote swallow
#

why what why why why why why why, no

remote swallow
undone axleBOT
tardy delta
#

use the scheduler instead of instantiating bukkitrunnables pls

#
Bukkit.getScheduler().runTaskLater(plugin, task -> { task.cancel(); }, 2);```
#

with pleasure

remote swallow
#

ill show myself out

pine island
tardy delta
#

check line 35

pine island
#

file

#

its @EventHandler 😐

tardy delta
#

also where are ur naming conventions

pine island
tardy delta
#

?

pine island
#

its not a serious plugin

winged ridge
#

I have another question, ```java
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
for (Map.Entry<Location, Block> block : PlaceListener.map.entrySet()) {
Bukkit.getScheduler().runTaskLater(plugin, () -> player.sendBlockChange(block.getValue().getLocation(), block.getValue().getBlockData()), 5);
}
}

I have this code but the sendBlockChange doesn't take effect and I think it's because the chunks aren't loaded, is there a way to wait for them to load then run the sendBlockChange?
pine island
#

its just somth me and the bois would use for 5 days and never use again

tardy delta
#

1+1

pine island
#

"sex"

glossy venture
#

cosntkb.sex

pine island
glossy venture
#

what does that class do

#

lol

pine island
remote swallow
#

its main class

glossy venture
#

lmao

pine island
glossy venture
#

imagine VillagerSexEvent

pine island
#

i mean how hard would it be to place a stalactite(?) under a player

glossy venture
remote swallow
#

stalagmite is floor

glossy venture
#

yeah

#

but ayo

pine island
winged anvil
#

sex plugin

glossy venture
#

cursed

pine island
#

hasbhmbd STOP LMAO

winged anvil
#

sex.java

pine island
#

i hd a project named I love b**bies

glossy venture
#

why

pine island
#

why not

glossy venture
#

what did it do lol

pine island
#

this one is name after my ex

pine island
glossy venture
#

const?

pine island
#

OH

glossy venture
#

ooh

pine island
#

WAIT

#

thats group id

winged anvil
#

id be so much happier if it was Sex plugin

pine island
#

mb

glossy venture
#

yeah

pine island
pine island
glossy venture
#

couldnt take the time to fix the const

winged anvil
#

vanesa sex plugin

remote swallow
pine island
glossy venture
pine island
#

if it wasnt obvious my whole coding folder is a joke

remote swallow
#

same

remote swallow
#

i dont personally keep tabs on dream

pine island
glossy venture
#

ahaaha

glossy venture
pine island
#

the 1st one is a custom domain sexmail.com

pine island
#

have u read anything

#

if my project is named after my ex and my main class is sex why would i care abt my naming conventions, not like someone else is viewing it

#

😐

#

i doubt it exsists

#

even if it did id make my own cus i get bored and need to do smth else

#

how do i make a firework

#

the docs

#

are not helpful

#

wait nvm

undone axleBOT
sinful rapids
#
            ItemStack itemStack = new ItemStack(Material.OAK_DOOR);
            e.getBlock().getLocation().getWorld().dropItem(e.getBlock().getLocation(), itemStack);
            e.setDropItems(false);

How can I make the block that drops can't be taken?

#

BlockBreakEvent

pine island
#

does this look right?

undone axleBOT
pine island
#

..

#

well

#

its copied borrowed from a 1.17 post

#

right my bad

#

?paste for myse;f

undone axleBOT
pine island
pine island
tardy delta
#

does System.exit() work

#

on my stuff it worked

pine island
#
                        Firework firework = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK);
                        FireworkMeta meta = firework.getFireworkMeta();
                        FireworkEffect.Builder builder = FireworkEffect.builder();
                        builder.withTrail().withFlicker().withFade(Color.GREEN, Color.WHITE, Color.YELLOW, Color.BLUE,
                                        Color.FUCHSIA, Color.PURPLE, Color.MAROON, Color.LIME, Color.ORANGE)
                                .with(FireworkEffect.Type.STAR);
                        meta.addEffect(builder.build());
                        meta.setPower(2);
                        firework.setFireworkMeta(meta);

Error:

#

oh- how do i fix that

#

welll my code make sit w color

#

wait

#

actually

#

nvm found it

neat jetty
#

can someone rate my code? i'll send link to github repository in private message

hazy parrot
#

Doesn't bukkit already have built in method for this?

#

Like #broadcast(msg, perm)

neat jetty
vital yacht
#

I’m pretty sure GitHub links would be fine but I would wait for someone else to answer, or you can send it in a paste

pine island
#

u cn send git links

#

yes

#

no Enchanted apple (1.8.. dont ?1.8 me please)

glossy venture
undone axleBOT
glossy venture
#

haha

#

but maybe its a data value of a golden apple

#

idk

pine island
pine island
glossy venture
#

yeah

#

they have a durability value of 1

pine island
#

mhm

#

i found it tysm