#help-development

1 messages · Page 312 of 1

tender shard
#

you currently try to get data even for stuff that doesnt exist

remote swallow
#

FileConfiguration.get("path"), FileConfiguration.set("path", value) then save it

tender shard
#

or check if the pdc.has(STPRAGE, getDataType()) before calling get(...)

elfin atlas
remote swallow
#

you should be able to

elfin atlas
#

How exactly?

regal scaffold
#

Same thing @tender shard

remote swallow
#

for (String key : FileConfiguration.getKeys(false)) System.out.println(key);

#

that would loop over all keys

elfin atlas
#

Okay thx

regal scaffold
remote swallow
#

if you want to get every option you can in the config use getKeys true

elfin atlas
#

And to delete stuff?

austere solstice
#

Hi guys. As you know when we place a rail in the corner it converts automatically to a corner rail. Can we cancel that? Which event is that?

remote swallow
tender shard
regal scaffold
#

ItemInformation info = Keys.getStorage(chest);

#

But that data is already verified

#
    public boolean verify(PlayerInteractEvent e) {
        Bukkit.getLogger().info("Verifying");
        if (e.getHand() != EquipmentSlot.HAND)
            return false;
        if (e.getClickedBlock() == null || e.getClickedBlock().getType() == Material.AIR)
            return false;
        if (e.getClickedBlock().getType() != Material.CHEST)
            return false;
        if (e.getClickedBlock().getType() == Material.CHEST && !Keys.storageExists((Chest)e.getClickedBlock().getState())) {
            return false;
        }
        return true;
    }
tender shard
#

hm idk, can you send the full source code? it's hard to debug it with only snippets

regal scaffold
#

Dming

tender shard
#

kk

austere solstice
frank kettle
#

Is it possible to check if a natural made chest(village, portals, ships, etc) to know if it's one of those chests if opening a chest? And to check which type of chest loot it has?

weak bear
#

Hey mans how can I do for take info of another plugin and use it on mine ?

#

Like take info of AreaShop for his plugin

topaz cape
#

how do you get all players within the render distance of a player

#

is Bukkit#getViewDistance even relevant

wet breach
#

so what you would do is just assume they are using the view distance set by the server

#

you would use that, and then search within that cube that is rendered

topaz cape
#
private void refreshEntities(Player player) {
        int view = Bukkit.getViewDistance() * 5;
        List<Entity> entities = player.getNearbyEntities(view, view, view);
        HashSet<UUID> ids = new HashSet<>();
        for (Entity entity : entities) {
            if (!(entity instanceof Player)) {
                continue;
            }
            Player p = (Player) entity;
            if (!provider.isDisguised(p) || isRefreshed(player, p) || p == player) {
                continue;
            }
            if (provider.getInfo(p).hasEntity()) {
                provider.refreshAsEntity(p, player);
                player.sendMessage("refreshed " + p.getName());
                ids.add(p.getUniqueId());
            }
        }
        refreshedMap.put(player.getUniqueId(), ids);
    }```
#

I just did this

topaz cape
#

hopefully it works

wet breach
# chrome beacon It does

I guess you could use what the client reports, but probably best to just use the server setting as that is more likely to be consistent

#

depending on what needs to be done etc

#

but nice to know it does report it

chrome beacon
#

I don't think Spigot has a way to access the player view distance

#

Paper does though

topaz cape
#

i have to refresh the disguised players as entities when they join a player's render distance

regal scaffold
#
InventoryClickEvent e

How can I get a chest object from this event?

wet breach
#

there is no guarantee that a chest is associated with the given inventory though, but you would just check

topaz cape
#

wait

#

how do i calculate viewDistance for nearby entities then

#

a chunk is a 16x16 right?

chrome beacon
#

Yes

topaz cape
#

so Bukkit#viewDistance x 16 x 16?

chrome beacon
#

Same with movement packets and such

topaz cape
#

nope i have to make it for a lib that shouldn't depend on any plugin

chrome beacon
#

Then shade PacketEvents or TinyProtocol

topaz cape
#

i dont even know what TinyProtocol is

fluid cypress
#

mine is slowly falling down, for some reason

#

i guess its a client side thing?

#

anyway, i guess i should ask what is the best way to do what i want, maybe with armor stands? or something else

spice shoal
#

hi guys , how i can do , snow ball can destroy snow_block ?

fluid cypress
#

unlike that plugin, i want to put many more blocks, hundreds, so the lag is important to determine which method to use

tender shard
#

whats your version?

tender shard
fluid cypress
#

1.19.2 i think

tender shard
#

check if projectile is a sonwball, check if the hit block is a snow block

spice shoal
tender shard
fluid cypress
#

ok, but is that the best way to achieve what i want?

tender shard
#

print out the falling lock location every tick and see if it changes

#

if it does change, it's indeed server-side

fluid cypress
#

ok ill check later for that

#

can i achieve the same thing with armor stands?

#

is there any other way besides armor stands (if possible) and falling blocks?

#

basically move blocks around

tender shard
spice shoal
#

mfnalex if i want player get knockback from snow ball , how i can do?

tawdry echo
#

what java version for 1.19.x?

spice shoal
tender shard
#
Vector vec = snowball.getVelocity().normalize();
player.setVelocity(player.getVelocioty().add(vec));

or sth like that

spice shoal
#

i love u

tender shard
#

not so loud, my bf is here

spice shoal
#

sorry

#

i love ur men

wicked ember
#

I have a question how would you get the players inventory and then give it back once a command has been done?

chrome beacon
#

You can store the inventory in a map until the command is run

#

Use get and set contents

lime moat
#

Using Bungeecord messages, can I use & for color formatting? If so, how? Current code is: java p.sendMessage(new ComponentBuilder(server + " has not been linked to a lobby!").color(ChatColor.GREEN).create());

remote swallow
#

you would need to use ChatColor.translateAlternateColorCodes('&', string) for that

lime moat
remote swallow
#

use ComponentBuilder

tender shard
#

?jd-bcc

remote swallow
#

wrap the ChatColor.translate... in it

tender shard
#
TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&cMy Text"))
#

sth like this

lime moat
#

Thank you! :D

#

One more thing I can't seem to wrap my head around java String server = p.getServer().getInfo().getName(); String c1 = server.substring(0, 1).toUpperCase(); String capitalized = c1 + server.substring(1); p.sendMessage(new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&4" + capitalized).create())); How would I be able to use capitalized? .create() just doesn't like it

#

Without capitalized, it works fine

remote swallow
#

you dont need the .create

lime moat
#

Ah, okay

remote swallow
#

or you need the .create outside of the ChatColr.translate parenthesis

#

move the .create to the last )

#

so p.sendMessage(new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&4" + capitalized)).create());

#

smh

marsh hawk
#

Does ItemStack#deserializeBytes() not exist in 1.19.3?

remote swallow
#

that is papers api

marsh hawk
#

mb

tender shard
rare rover
#

i cant get socket.io to work, it says its connected but whenever i emit something, the client never receives it

#
    Socket socket;

    @Override
    public void onEnable() {
        socket = new Socket(URI.create("http://localhost:3000"));   
        socket.open();
        Bukkit.getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        JsonObject json = new JsonObject();
        json.addProperty("player", e.getPlayer().getName());
        socket.emit("playerJoin", json);
        Bukkit.broadcastMessage(json.toString());
    }```
#

never sends to the client

hazy parrot
rare rover
#

yes, it says "New Connection" but i just cant emit anything

#
server.on('connection', (socket) => {
    console.log('New connection');

    socket.on('playerJoin', (arg) => {
        console.log('Player joined');
    })
})```
hazy parrot
#

isn't socket io websocket based ?

#

not http api

opal juniper
#

yes

rare rover
#

so i dont need http?

opal juniper
#

u need ws:// iirc

hazy parrot
#

or wss if using ssl

opal juniper
#

uhuh

rare rover
#

let me try

eager girder
#

How would I make a custom item with a custom texture?

#

Can someone link me a guide or the stuff that I need to know to make it?

tender shard
#

you need a resource pack that overrides the texture using CustomModelData, then create an ItemStack with the same custom model data

rare rover
#

doesn't say "Player joined"

tender shard
eager girder
#

kk

rare rover
#

does show the json tho

eager girder
#

then I just set something like a diamond pickaxes CustomModelData and DIsplayName to something else?

tender shard
#

yes

tender shard
eager girder
#

Ok thanks

tender shard
#

get that resource pack, then check out how it works

eager girder
#

Where do I put the custom texture?

rare rover
#

check google

#

there's multiple tutorials on custom textures

hazy parrot
#

@rare rover what is your import of socket class ?

#

im trying to find docs on java impl, but there is quite a few

rare rover
#
<dependency>
            <groupId>io.socket</groupId>
            <artifactId>engine.io-client</artifactId>
            <version>2.1.0</version>
        </dependency>```
hazy parrot
#

your socket.on for player event

#

is inside of function for connection listener

rare rover
#

yes

hazy parrot
#

should it be like that ?

rare rover
#

the tutorial said to do that

hazy parrot
#

can you check socket.hasListeners("playerJoin"); ?

rare rover
#

i did not

hazy parrot
#

also try to just send message, without emiting event

rare rover
#

i do

hazy parrot
#

to see if problem is in client or server

rare rover
hazy parrot
#

socket.send

#

not in mc

rare rover
#

ah

#

okay

#

waiting for my mc server to start rq

#

hmm

#

didn't send and hasListeners = false

#

🤔

hazy parrot
#

try to put socket.on for player outside of listener for connection

rare rover
#

Okay

#

same result

#

this is my js code

const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);

server.on('connection', (socket) => {
    console.log('New connection');
})

server.on('playerJoin', (arg) => {
  console.log('Player joined');
})

server.listen(3000, () => {
  console.log('listening on *:3000');
});```
feral swallow
#

Hello, I keep getting "cannot access com.sk89q.worldguard.WorldGuard" with this line of code java import com.sk89q.worldguard.WorldGuard; here is my pom.xml https://pastebin.com/Em6wEwFW

undone axleBOT
tender shard
#

you need a way older WG version

#

WG 7.1.0 is 1.19+

rare rover
# hazy parrot are you even using socket.io ?

well if i do this:

const { Server } = require('socket.io');

const io = new Server(3000);
io.on('connection', (socket) => {
  console.log('a user connected');

  socket.on('disconnect', () => {
    console.log('user disconnected');
  });
})``` it wont connect to my plugin
tender shard
#

for 1.8.8 you need WorldGuard 6.2

feral swallow
feral swallow
eager girder
#

So I have a custom pickaxe, what is the event called when it breaks a block

#

I want it to mine in a 3x3 area

tall dragon
#

BlockBreakEvent

eager girder
#

How do I see if the block was broken with my custom pickaxe?

tall dragon
#

when you give a player you custom pickaxe. apply a pdc to tag to it. in the event check if the pickaxe has the tag

eager girder
#

Alright thank you

#

How do I get the plugin to put in the namespace key?

#

I get Expression expected when I try to put in my main class

tall dragon
#

can u show how you've coded it up?

eager girder
#

DiamondHammer Class:

public class DiamondHammer {
    public static ItemStack getDiamondHammer() {
        ItemStack diamondHammer = new ItemStack(Material.DIAMOND_PICKAXE);
        ItemMeta diamondHammerItemMeta = diamondHammer.getItemMeta();

        assert diamondHammerItemMeta != null;

        PersistentDataContainer diamondHammerPDC = diamondHammerItemMeta.getPersistentDataContainer();

        NamespacedKey HammerData = new NamespacedKey(Hammer, "");
        diamondHammerPDC.set(HammerData);

        diamondHammerItemMeta.setDisplayName("Diamond Hammer");
        diamondHammerItemMeta.setCustomModelData(1);

        diamondHammer.setItemMeta(diamondHammerItemMeta);

        return diamondHammer;
    }
}

Hammer Class (Main Plugin):

package com.atk.hammer;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import static org.bukkit.Bukkit.getServer;

public final class Hammer extends JavaPlugin  {

    @Override
    public void onEnable() {
        
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }
}
atomic violet
#

is there a way to place structures like a netherfortress in 1.19.3 like how /place structure does it?

tall dragon
eager girder
#

Yeah

tall dragon
#

u need an actual reference to it

eager girder
#

So how should I got about doing that?

tall dragon
#

?di

undone axleBOT
eager girder
#

Ok thank you

feral swallow
#

I keep getting excessive velocities errors

#

Is there a way to hide them because the velocity i am setting isnt that much

eternal oxide
feral swallow
#

0, 1, -5 i think

#

Im trying using the multiple method instead

eternal oxide
#

thats 6 meters per tick, so 120 meters per second

#

if that is your actual vector

#

Which can't be correct as the max is 10

#

sysout the vector

feral swallow
#

I was using .add

#

so the total vector could of been higher

#

Ill print it tho

eternal oxide
#

can't look, in game

feral swallow
#

well it just says Excessive velocity set detected: tried to set velocity of entity #65 to (0.0, 0.9215999984741211, -5.0)

#

then a stacktrace related to bukkit

tender shard
#

I don't see anything related to a max velocity of 10 in craftbukkit's code

feral swallow
#

Trying a new approach but for some reason if i jump it sends me farther java p.setVelocity(new Vector(0, 0.3, -2));

#

If its not adding it why would that happen?

rotund ravine
feral swallow
rotund ravine
#

It does not add. Set it to 0 0 0 and see for yourself

tranquil stump
#

Why does this code sometimes teleport the player at y=-55 when that isn't what is in the location

#
    @EventHandler
    public void playerJoinEvent(PlayerJoinEvent e)
    {
        final World world_train = Bukkit.getWorld("world_train");
        if (world_train == null)
        {
            plugin.getLogger().severe("world_train not found! disabling...");
            plugin.getServer().getPluginManager().disablePlugin(plugin);
            return;
        }

        final Location train = new Location(world_train, -59.3, -59, 22.675, 165.3f, 1.3f);

        final Player p = e.getPlayer();
        p.teleport(train);
atomic violet
#

how do i spawn a nether fortress like the /place command does in 1.19.3?

primal goblet
tender shard
#

does anyone know if there's a proper VTL plugin for IntelliJ? By default IJ gets confused when you add VTL to java files

primal goblet
#
@EventHandler
    public void _click(InventoryClickEvent e) {
        if(e.getClickedInventory() == null) return;
        if(!e.getClickedInventory().getType().equals(InventoryType.PLAYER)) {
            e.setResult(Result.DENY);
            e.setCancelled(true);
        }

        if(e.getCurrentItem() == null) return;
        if(e.getWhoClicked() == null || !(e.getWhoClicked() instanceof Player)) return;

        Inventory inventory = e.getClickedInventory();
        if(e.getClickedInventory().getType().equals(InventoryType.PLAYER)) {
            return;
        }
}

am i doing something wrong? cuz the members can put their items to the kits inventory!

tender shard
tender shard
atomic violet
#

thanks

tender shard
#
   public static int placeStructure(CommandSourceStack var0, Holder.Reference<Structure> var1, BlockPos var2) throws CommandSyntaxException {
      ServerLevel var3 = var0.getLevel();
      Structure var4 = (Structure)var1.value();
      ChunkGenerator var5 = var3.getChunkSource().getGenerator();
      StructureStart var6 = var4.generate(var0.registryAccess(), var5, var5.getBiomeSource(), var3.getChunkSource().randomState(), var3.getStructureManager(), var3.getSeed(), new ChunkPos(var2), 0, var3, (var0x) -> {
         return true;
      });
      if (!var6.isValid()) {
         throw ERROR_STRUCTURE_FAILED.create();
      } else {
         BoundingBox var7 = var6.getBoundingBox();
         ChunkPos var8 = new ChunkPos(SectionPos.blockToSectionCoord(var7.minX()), SectionPos.blockToSectionCoord(var7.minZ()));
         ChunkPos var9 = new ChunkPos(SectionPos.blockToSectionCoord(var7.maxX()), SectionPos.blockToSectionCoord(var7.maxZ()));
         checkLoaded(var3, var8, var9);
         ChunkPos.rangeClosed(var8, var9).forEach((var3x) -> {
            var6.placeInChunk(var3, var3.structureManager(), var5, var3.getRandom(), new BoundingBox(var3x.getMinBlockX(), var3.getMinBuildHeight(), var3x.getMinBlockZ(), var3x.getMaxBlockX(), var3.getMaxBuildHeight(), var3x.getMaxBlockZ()), var3x);
         });
         String var10 = var1.key().location().toString();
         var0.sendSuccess(Component.translatable("commands.place.structure.success", var10, var2.getX(), var2.getY(), var2.getZ()), true);
         return 1;
      }
   }
#

@atomic violet

#

class is net.minecraft.server.commands.PlaceCommand

sullen marlin
#

See also structure api

tender shard
primal goblet
tender shard
rotund ravine
primal goblet
tender shard
#

I'd also be fine with installing VSCode or whatever, if only there exists a proper plugin for this

rotund ravine
#

Create a plugin for it yourself

tender shard
#

I once tried creating a simple intellij plugin and I didnt even know where to start

rotund ravine
#

@primal goblet cancel the event mister

humble tulip
#

Does anyone have a snippet for registering/unregistering commands via the commandMap

#

I have one that I wrote long ago but i cant remember if it works

primal goblet
humble tulip
#

and dont wanna test it on multiple versions

primal goblet
rotund ravine
#

Yikes

humble tulip
#

no the bukkit commandmap

primal goblet
primal goblet
rotund ravine
rotund ravine
tender shard
humble tulip
#

ty

rotund ravine
#

Ah

#

Well, why are they allowed to move their own stuffv

primal goblet
rotund ravine
#

I am asking you if it is intended

primal goblet
primal goblet
tender shard
tender shard
#

however, I'd use ACF instead of manually changing the commandmap

rotund ravine
#

Acf do be lit

primal goblet
rotund ravine
#

Nah

humble tulip
# tender shard https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jef...

I recommend changing

    public static void registerCommand(@Nullable final String permission, final String... aliases) {

        final PluginCommand command = getCommand(aliases[0]);

        command.setAliases(Arrays.asList(aliases));
        command.setPermission(permission);

        getCommandMap().register(JeffLib.getPlugin().getDescription().getName(), command);
    }

to

    public static void registerCommand(@Nullable final String permission, String name, final String... aliases) {

        final PluginCommand command = getCommand(name);

        command.setAliases(Arrays.asList(aliases));
        command.setPermission(permission);

        getCommandMap().register(JeffLib.getPlugin().getDescription().getName(), command);
    }
tender shard
#

❤️

tender shard
#

so I can just throw in the list

humble tulip
#

ah ok

#

makes sense

tender shard
#

but yeah sure, I could add a convenience method that uses a String name and String... aliases

#

wouldnt hurt

#

or a CommandBuilder lol

new CommandBuilder().withName("aclist").withAliases("angelchestlist","acl").withPermission("angelchest.command.list").register();
#

wtf have I been doing here, I have no clue what it does lol

#

ugh why does intelliJ display the properties in this random order? It is totally different from the order in which I declared it. And the weird thing is, it always uses the same weird order

compact haven
#

help anyone who has written Async Mongo Java queries

#

how should I query a document with a specific id & an embedded key? i.e. and(eq("id", ...), ...?)

#

as for embedded key, I mean exists but for a key inside of another object

tender shard
#

can one make maven archetype only use a certain <fileSet> if a specific property is set?

eager girder
#

How do I get blocks in a square around blocks?

#

Like I have a center block

#

and I want to get the ones around it

tender shard
#

a nested for loop

#
final int radius = 5;
final int centerX;
final int centerY;
final int centerZ;

for(int x = centerX - radius; x <= centerX + radius; x++) {
  // same for y
    // same for z
eager girder
#

How do I get the block at that position?

tender shard
#

myWorld.getBlockAt(x,y,z)

eager girder
#

kk

#

does player.BreakBlock take time or is it instant?

#

Since I need something that is instant but also has the drops

rotund ravine
#

Methods usually run instantly

eager girder
#

kk

earnest forum
#

might be WorldServer depending on mapping

tender shard
#

are you not using mojang mappings?

atomic violet
eager girder
atomic violet
#

no

eager girder
#

Whats the best way to do that?

tender shard
#

you should definitely use spigot remapped

#

?nms

tender shard
eager girder
#

So if you are looking at the block and you break it, then it would break in a 3x3 square or 5x5 square

#

not in a 5x5x5

earnest forum
#

square or cube

eager girder
#

square

earnest forum
#

so just dont use Y

eager girder
#

You can still look at a wall

#

or look down

tender shard
#

just get rid of the Y loop

atomic violet
eager girder
#

I don't understand how that would solve it

earnest forum
eager girder
#

How would I do that?

earnest forum
#

im not too sure

#

havent used them before

tender shard
#

oh you wanna do it depending on where the player looks?

eager girder
#

Yes

tender shard
#

well then you need some vector maths

#

or you do it hardcoded

#

e.g. when player looks east or west, loop over X and Y, when they look south or north, loop over Y and Z, when they look up or down, loop over X and Z

eager girder
#

Hard coding it would be really clunky

earnest forum
#

you can just use a switch

tender shard
#

east/west, north/south, or up/down

eager girder
#

Yeah I was thinking i'd have to do more for some reason

#

I'll just do an inline statement

#

should be easy enough

eager girder
#

nvm

earnest forum
#

no

eager girder
#

i get what you did

earnest forum
#

ur thinking of diameter

eager girder
#

ye

rotund ravine
#

You doing some sort of tinker hammer enchant?

eager girder
#

Yes

#

5x5 would be 2

#

3x3 would be 1

rotund ravine
#

?paste

undone axleBOT
eager girder
#

kk

rotund ravine
#

I did one a while back

#

like a few years

tender shard
#
    public static Set<Block> getBlocks(Location center, BlockFace facing) {
        int radius = 5;

        int radiusX, radiusY, radiusZ = radius;

        switch (facing) {
            case NORTH:
            case SOUTH:
                radiusX = 0;
                radiusY = radius;
                radiusZ = radius;
                break;
            case EAST:
            case WEST:
                radiusX = radius;
                radiusY = radius;
                radiusZ = 0;
                break;
            case UP:
            case DOWN:
                radiusX = radius;
                radiusY = 0;
                radiusZ = radius;
                break;
            default:
                throw new IllegalArgumentException();
        }
        
        Set<Block> blocks = new HashSet<>();
        int centerX = center.getBlockX();
        int centerY = center.getBlockY();
        int centerZ = center.getBlockZ();
        for (int x = centerX-radiusX; x <= centerX+radiusX; x++) {
            for (int y = centerY-radiusY; y <= centerY+radiusY; y++) {
                for (int z = centerZ-radiusZ; z <= centerZ+radiusZ; z++) {
                    blocks.add(center.getWorld().getBlockAt(x, y, z));
                }
            }
        }
        
        return blocks;
    }
#

sth like this should work. Haven't tested it

#

maybe NORTH/SOUTH and EAST/WEST is switched, idk

eager girder
#

Is there a method to get the towards thing or would I have to map that my self?

tender shard
#

Player#getFacing()

#

but that could also be SOUTH_SOUTH_WEST or sth

eager girder
#

Like it says Facing: north (Towards negative Z)

tender shard
#

so you somehow gotta turn that into "normal" directions

rotund ravine
#
    public BlockFace getBlockFace(Player player) {
        List<Block> lastTwoTargetBlocks = player.getLastTwoTargetBlocks((Set<Material>) null, 100);
        if (lastTwoTargetBlocks.size() != 2 || !lastTwoTargetBlocks.get(1).getType().isOccluding()) return null;
        Block targetBlock = lastTwoTargetBlocks.get(1);
        Block adjacentBlock = lastTwoTargetBlocks.get(0);
        return targetBlock.getFace(adjacentBlock);
    }
eager girder
#

So I have to map it myself

#

kk

rotund ravine
tender shard
#

something like this

    public static BlockFace getFacing(Player player) {
        float pitch = player.getLocation().getPitch();
        float yaw = player.getLocation().getYaw();
        
        if(pitch > 45) {
            return BlockFace.DOWN;
        }
        if(pitch < -45) {
            return BlockFace.UP;
        }
        if(yaw < -135 || yaw > 135) {
            return BlockFace.NORTH;
        }
        if(yaw < -45) {
            return BlockFace.EAST;
        }
        if(yaw < 45) {
            return BlockFace.SOUTH;
        }
        if(yaw < 135) {
            return BlockFace.WEST;
        }
        return null;
    }
#

havent checked the numbers, maybe they are correct, maybe they aren't. you gotta try this yourself

rotund ravine
#

No you'd want what face you are hitting the block at.

tender shard
#

I thought they wanted to base it off the direction the player is looking

rotund ravine
#

Well kinda

tender shard
#

that's what they said earlier

rotund ravine
#

But i asked if they wanted to do a tinkerhammer style, and that's what face you are breaking the block at.

eager girder
#

I want to do it based on the side you break it on

#

Yeah

rotund ravine
#

Yeah

tender shard
#

getCLickedBlockFace

eager girder
eager girder
tender shard
rotund ravine
#

When was that added?

eager girder
tender shard
#

oh wait

#

it's in PlayerInteractEvent

#

you gotta cache that

rotund ravine
#

Or just use my method.

#

It works.

tender shard
#
    @EventHandler
    public void onClick(PlayerInteractEvent event) {
        if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            clickedFace = event.getBlockFace();
        }
    }
    
    @EventHandler
    public void onBreak(BlockBreakEvent event) {
        if(clickedFace == null) return;
        
        // do your stuff
        
        clickedFace = null;
    }
eager girder
#

Both ways would work

tender shard
#

I'd rather use a loop so you can adjust the radius whenever you want

rotund ravine
#

I never said not to?

eager girder
#

^

tender shard
#

I didnt say you said that lol

#

I just said that I'd prefer a loop over hardcoding the blockfaces

rotund ravine
#

Ah, well it was easier.

tender shard
#

yeah sure, if you only want to do 3x3, I'd also hardcode it

rotund ravine
#

you gotta also take into account anticheats btw

eager girder
#

It's not going to be a public plugin

#

Just making it for my server

tender shard
#

oh yeah, you gotta hook into a lot of anti cheat apis

#

or you uncancel the events by listening to them yourself lmao

eager girder
#

Before I make any public plugins im gonna make quite a few private ones

tender shard
#

interesting lol

#

there should be some generic AntiCheatEvent

#

that all anti cheats use

rotund ravine
#

This also hooks into protection plugins.

eager girder
#

I just did it like this

#
int xRadius = clickedFace == BlockFace.NORTH || clickedFace == BlockFace.SOUTH ? radius : 1;
int yRadius = !(clickedFace == BlockFace.UP || clickedFace == BlockFace.DOWN) ? radius : 1;
int zRadius = clickedFace == BlockFace.EAST || clickedFace == BlockFace.WEST ? radius : 1;
atomic violet
#

im struggling on how to install build tools for 1.19.3

tender shard
#

what exactly is the problem?

atomic violet
#

im using the .bat file method where you paste the batch code from the site and i was following a video as well cause its been a while but the video was for 1.17.1, idk if thats relevent, but it asked for the version after i run the bat file. which is normal but then it asked whether i wanna use java 8, 16 or 17

#

and if i type "17" it just says done and to press any key to continue

#

the last time i installed it was for 1.16.5

tender shard
#

I'd just run buildtools manually

#
  1. open command prompt
atomic violet
#

using git?

#

oh

tender shard
#
  1. enter java -version
#

what does it print?

atomic violet
#

one sec

eager girder
#

How do I make my pick only run blockbreakevent if it's breaking the right type?

#

Like a pickaxe mining sand shouldnt work

atomic violet
#

it says 17.0.5

eager girder
#

but a pickaxe mining stone or ores should

tender shard
#

then go into that directory with command prompt

atomic violet
tender shard
#

then enter java -jar BuildTools.jar --rev 1.19.3 --remapped

rotund ravine
#

?xy

undone axleBOT
rotund ravine
#

Put the checks in the event @eager girder

tender shard
eager girder
#

Like what do I check for is my main question

rotund ravine
tender shard
eager girder
#

mineable/pickaxe

atomic violet
#

im currently trying to make the captive minecraft map in a plugin

#

i wanna spawn the nether fortress and stronghold closer to 0, 0 so it makes the game more possible tho

eager girder
#

Ohhh isPreferredTool exists

tender shard
eager girder
#

How so?

tender shard
#

e.g. idk if it returns true on leaves for shears or swords. it will only be true for one, although both can make sense sometimes

wet breach
#

it does make sense

tender shard
#

so yeah there's a few edge cases

wet breach
#

swords are not the preferred tool

#

for leaves

tender shard
#

okay another example, WHEAT

#

what's the preferred tool for wheat?

#

every tool? or none?

wet breach
#

should be the hoe ?

eager girder
#

It works for my use case

tender shard
#

a hoe doesn't give any advantage over a pickaxe

#

or bare hands

wet breach
#

that isn't how it works

atomic violet
wet breach
#

its not based on your personal interpretation

tender shard
wet breach
#

or based on what gives what advantage

atomic violet
tender shard
wet breach
atomic violet
tender shard
eager girder
#

For some reason this makes it only mine 5 blocks instead of the 9, it works without it
if (targetBlock.getBlockData().getMaterial() == block.getBlockData().getMaterial() && targetBlock.isPreferredTool(item))

tender shard
#

that means, DIRT would return true for pickaxes as well

wet breach
#

but I have no interest in really opening up the implementation source to see it/show it

eager girder
#

Maybe it doesnt work for my use case

tender shard
#

that's from the DiggerItem class

eager girder
#

I can also just check for mineable/pickaxe too

tender shard
#

it simply checks whether the block would drop something, and nothing more

#

what the heck intellij

warm light
tender shard
#

maybe show the worldedit code that gets the server stuck

eager girder
#

How do I check for #mineable/pickaxe?

warm light
tender shard
fossil pike
undone axleBOT
fossil pike
# tender shard ?services

"Quetell, please note that in order to be able to post new threads in this section you must have an account with at least 20 posts and at least 1 week of age. Upon reaching these amounts you will automatically be promoted within a few hours."

tender shard
#

well then write some posts in off-topic

#

there's so many useless threads there

#

e.g. "when did you start playing minecraft"

#

or the countdown game

#

you'll get to 20 posts within a few hours or less

atomic violet
#

i looked at the link but it doesnt explain what i do

tender shard
#

?switchmappings

tender shard
#

this explains on how you change your old mappings to the new ones

#

the first link was only to setup your project

atomic violet
#

cause it still says it cannot resolve symbol

#

and it doesnt let me import a class

rotund ravine
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

tender shard
tender shard
#

yeah you didnt read my first blog post

#

?nms

tender shard
#

you didnt add the classifier to the spigot dependency

#

you also didnt add the whole remapping part

atomic violet
#

i shouldve clarified lol

tender shard
#

what exactly do you not understand?

atomic violet
#

like how im supposed to change the pom.xml

#

do i just paste whats in the blog into it or?

tender shard
#

you put the <plugin> thing into your already existing <plugins> section

#

and you add the <classifier> into your spigot <dependency>

atomic violet
#

oh i see

#

and then just reload?

tender shard
#

yeah, after you changed it, click the "maven reload" button

#

then it should work

atomic violet
#
                <version>1.2.2</version>```
#

this part is giving me an error

#

saying its not found

tender shard
#

it should work after clicking the reload button

atomic violet
#

nope

tender shard
#

?paste your pom again pls

undone axleBOT
atomic violet
#

i probably didnt do it right

tender shard
#

it looks correct, except that you didn't adjust the 1.18.2 part to 1.19.3 in the specialsource plugin

#

did you maybe accidentally enable maven offline mode?

tender shard
#

this must NOT be enabled

atomic violet
tender shard
tender shard
# warm light

I don't think you can just paste schematics into yet ungenerated chunks. you'll have to wait until the chunk got fully generated, and THEN use worldedit

warm light
#

so how do you suggest? like how can I paste it on chunk?
its not fixed on location. it will generate randomly

atomic violet
#

like open it

tender shard
#

I never messed with world generation. Is there maybe a way in WorldEdit's API to get an EditSession not from a world, but from whatever you get in the chunk generator?

tender shard
#

just double click on "package" here

atomic violet
tender shard
atomic violet
quaint mantle
#

If it shows no error during compiling but it does in intellij you can ignore said error

tender shard
#

well it did work fine

#

ignore that it's marked in red, intellij sometimes messes it up. it did compile fine

atomic violet
#

oh okay

tender shard
#

you could try File -> Invalidate Caches to get rid of the red underlining

quaint mantle
#

Intellij is a bit funky with POMs at times

atomic violet
#

dont click any of the boxes? just hit invalidate and restart?

tender shard
#

yeah that should be enough

atomic violet
#

alr

tender shard
#

it'll take a while after restarting before it loaded all dependencies again

atomic violet
#

so much pain for spawning a fortress lmaoo

#

ive been here for hours

#

even before the build tools stuff

tender shard
#

yeah builtin structures are a pain in the ass, and not in the good way

#

the maven part is going to be easy compared to the actual structure spawning code lol

atomic violet
#

💀

atomic violet
#

so what is var0.getLevel doing and var1.value()

#

everything else i kind of understand

#

these two, absolutely no clue except var4 is supposed to be the structure being spawned i think right?

buoyant viper
#

well var3 is an NMS World i think

atomic violet
buoyant viper
#

think so

woeful moon
#

What's the recommended way to get the main class instance from a static util method?

jagged monolith
#

?di

undone axleBOT
tender shard
#

THIS HURTS MY EEEEYES

hasty prawn
#

Who did that

tender shard
#

i did that

hasty prawn
#

why did you do that

tender shard
#

how else would I do that

hasty prawn
#

in a way that doesn't make everyone wanna die

tender shard
tawdry parcel
#

My Code is not working, it says Unhandled exception: java.io.IOException under FileWriter:

Gson gson = new Gson();
gson.toJson(123.45, new FileWriter("/konerutils/ranks.json"));
tender shard
#

full stacktrace

hasty prawn
hexed falcon
#

how would i make a projectile disappear after flying 100 blocks?

tender shard
tawdry parcel
# tender shard full stacktrace
package com.koner.konerutils.ranks;

import com.google.gson.Gson;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import java.io.FileWriter;

public class RankCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Gson gson = new Gson();
        gson.toJson(123.45, new FileWriter("/konerutils/ranks.json"));
        return false;
    }
}
tender shard
hasty prawn
#

I dont even know what VTL is

tender shard
tender shard
hasty prawn
tender shard
#

with my archetype, you can generate projects like this:

hasty prawn
#

Now thats fancy

tender shard
#

it creates the main class, plugin.yml, adds dependencies and plugins if required, e.g. remapping for 1.17+, or mockbukkit including junit and an example unit tests, and more

#

I've spent so many hours on it now, but I hope it'll pay out eventually lol

atomic violet
#

bruh

hasty prawn
#

Definition of developer right now. Spending hours automating an issue that takes 5 minutes to do manually KEKW

tender shard
atomic violet
#

one sec

tawdry parcel
tender shard
#

I meant, send the full stacktrace, and not just one line, pls

tender shard
#

maybe other people will find it useful, then it was already worth it though

atomic violet
#

can i import both the bukkit and nms version so i can get the fortress? probably not but im not as experienced with it so figured id ask

tender shard
#

oooh it's a compiler error

#

you gotta wrap it into a try/catch

tawdry parcel
#

what should be the argument in catch()?

tender shard
#

Exception exception

#

and inside { } you print out the stacktrace

#
try {
  somethingThatMightThrowIOException();
} catch (IOException exception) {
  exception.printStackTrace();
}
#

btw you should use a try-with-resources for AutoClosable resources such as FileWriter

#
try(FileWriter writer = new FileWriter(...)) {
  writer.doSomething();
} catch (IOException exception) {
  exception.printStackTrace();
}
#

like this

atomic swift
#

i have a gui with slots not filled would this get the slots that are empty gui.getInventory().all(Material.AIR).keySet()

tender shard
#

probably

atomic swift
#

ikr

#

but it doesnt

#

so i am confused

tender shard
#

what does it return?

atomic swift
#

i have no idea

#

ill check

atomic violet
#

this Structure var4 = (Structure)var1.value(); and this checkLoaded(var3, var8, var9); are the last two things throwing errors in the code for placing structures, idk what its asking for in the var4 structure thing, obv a structure but i have no clue how to format it, and i think the checkLoaded thing is checking if those coords and the level is loaded but idk why its doing that

#

nms btw ^

atomic swift
river oracle
#

It's emptyyyy

atomic swift
#

yes

#

ovi

tender shard
#
        List<Integer> emptySlots = new ArrayList<>();
        for(int i = 0; i < player.getInventory().getSize(); i++) {
            ItemStack item = player.getInventory().getItem(i);
            if(item == null) {
                emptySlots.add(i);
            }
        }
atomic swift
#

and this is my gui its empt
y

tender shard
rotund ravine
#

He’s checking something else dummy

rotund ravine
#

Empty slots are usually not air, but they can be air or null

tender shard
rotund ravine
#

He asked if his thing worked. And you said probably

tender shard
#

yeah then we found out that it doesnt work, so I sent a working solution

atomic violet
#

does the worldedit api have anything about pasting ingame structures?

atomic violet
#

yeah i figured

hexed falcon
#

how would i do raytracing?

rotund ravine
undone axleBOT
chrome beacon
#

Use the ray trace methods

#

?jd-s

undone axleBOT
chrome beacon
#

^^

rotund ravine
#

Looks about eight

twilit fern
#

how do i publish a plugin to the website? (for in the future)

tender shard
river oracle
#

Make an account and publish by clicking upload

tender shard
twilit fern
#

oh, idk how i didn't see that xd, thanks

tender shard
#

yeah it's indeed a bit hidden lol

rotund ravine
#

Not rly

tender shard
#

well this question got asked here more than once

rotund ravine
#

Like the people who don’t google i guess

opal juniper
#

?howtopostaresource

#

?howtopostathread

undone axleBOT
opal juniper
#

close enough

topaz cape
#

am i doing this right?

#

or is readChannel for only packet receiving

rotund ravine
#

How did you register it

#

Also why not use protocollib?

topaz cape
#

reflections

topaz cape
rotund ravine
#

That’s dumb

#

Don’t reimplement the wheel all the time

topaz cape
#

i only wanna listen for 1 packet man 😦

remote swallow
#

Packet events

tender shard
topaz cape
velvet chasm
#

Can someone please tell me how I add worldguard as a dependency in pom.xml? Like where do I find the artifactID groupId and version?

velvet chasm
#

Thanks so much.

#

<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.x</version>
<scope>provided</scope>
</dependency>
What have I done wrong here?

tender shard
#

that you used 7.x instead of the actual version

velvet chasm
#

So what would be the actual version?

tender shard
#

7.1.0-SNAPSHOT

velvet chasm
#

Oh okay thanks

tender shard
velvet chasm
#

Still comes up with errors after doing this though?

tender shard
#

click the maven reload button

velvet chasm
#

Okay thanks I'll try that. Sorry this is my first time working with dependencies. I have come here for plugin help before. I learnt some java and went pretty well until I found this problem.

tender shard
#

no problem

#

you did add the repo, right?

velvet chasm
#

Yes

tender shard
#

then clicking the reload button should work

velvet chasm
#

Yep it just takes a bit

opal juniper
tender shard
velvet chasm
#

or do I need to add another for worldedit? I added the worldguard one already

tender shard
velvet chasm
#

Okay then yes.

#

The worldguard is working fine. The worldedit has an error in the version

tender shard
#

?paste your pom please

undone axleBOT
velvet chasm
tender shard
#

You wrote worldguard twice

#

Instead of worldedit

#

The 7.3.0 one has to be worldedit

velvet chasm
#

I feel extremely dumb

tender shard
#

Change both the groupId and the artifactId

velvet chasm
#

Yep. I don't know how I did that and some how didn't even realise.

tender shard
remote swallow
#

I wonder what ij plugins

tender shard
remote swallow
#

If they arent too hard i might make one so people cant roast me for using mc dev

#

Ill guess there coded in jva or kitlin

#

Ill find out later

tender shard
velvet chasm
tender shard
#

np!

#

btw you need to use maven to compile, too

#

double click on package. do NOT use build artifacts

velvet chasm
#

Where is the package?

tender shard
#

<project folder>/target/

lyric turtle
#

i have question, where "PacketPlayInPositionLook" is received from player and interpreted?

tender shard
velvet chasm
#

Yeah I've set it up to do that before. I usually have the folder open anyway so it doesn't really matter that much to me.

tender shard
#

oki. you can also use profiles to dynamically change where it puts the file, but I guess you dont need that lol

velvet chasm
#

Yep well thanks for all the help

tender shard
#

np

lyric turtle
#

where "PacketPlayInPositionLook" is handled in code? where its setting player position based on this packet?

tender shard
#

probably net/minecraft/server/network/PlayerConnection

#

actual name is net.minecraft.server.network.ServerGamePacketListenerImpl

lyric turtle
#

thx

tender shard
#

the PlayInPositionLook packet extends PacketPlayInFlying

lyric turtle
#

yeah and is that making a big difference while handling?

tender shard
#

both are handled the same way

lyric turtle
#

im wondering how limit of teleport by client is working

tender shard
#

the only difference is that for the Look packet, X,Y,Z delta is always 0

lyric turtle
#

oh

tender shard
lyric turtle
#

like when server sends s08 packet (i dont remember its mojang name) then client is sending PlayInPositionLook

tender shard
#

the limit seems to be 100 when not falling / flying, otherwise 300

#

but no idea what 100 refers to

#

and it's multiplied with var28 which is this:

#

no clue what's going on there lol

lyric turtle
#

thing is that

#

server can teleport player as far as it wants

#

but player cant teleport itself so far

#

how server is keeping track

tender shard
#

wdym?

lyric turtle
#

modified client can teleport itself with PlayInPositionLook

#

but it cant teleport more than some distance

#

but when server is sending teleport request

#

then it can

velvet chasm
#

Using worldguard api. Should "RegionManager regions = container.get(world);" world come up as an error. Container is defined "RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();"

vast kelp
tender shard
#

you need a WorldEdit world

tender shard
tender shard
#

it only checks the distance for incoming teleport / move packets, not outgoing

velvet chasm
tender shard
#

yes

velvet chasm
#

Alright thanks

lyric turtle
#

S -> C: S08
C -> S: C06

#

if server wont send S08 then player cant tp further than some distance

#

if server wont send S08 and player will send C06 for far away coords then it wont work

#

if server will send S08 then it will work

#

and its somehow checked by server

lethal python
#

hey guys i am trying to insert something into a database and then immediately spawn an entity which has the primary key of the new db entry stored into the entity's persistentdatacontainer. for my database class, should the method to insert new stuff return the new primary key and return -1 on failure, or should it be done a different way?

buoyant viper
#

u work with 1.8.x?

remote swallow
#

you smelling packets now?

#

covid really messed you up

lyric turtle
#

yes

iron palm
hybrid spoke
#

5 blocks still seem pretty op

rotund ravine
iron palm
hybrid spoke
#

by teleporting?

#

or faking a position?

rotund ravine
rotund ravine
iron palm
#

making the plugin independent doesnt mean to reimplement the wheel.
however if you're going to continue with this dumb idea then go on ahead and why dont you use thousand bullshits for a simple plugin ??? dont you wanna reimplement the wheel right?

tardy delta
rotund ravine
#

@iron palm You are making very little sense m8

#

I supported your argument, but not in the uneducated way that you wanted it seems. Reinventing the wheel is a waste of time. People already ise protocollib so there is no shame in depending on it instead of trying to implement it yourself.

hybrid spoke
#

can you actually teleport with that or just offset your current position?

rotund ravine
hybrid spoke
#

ah so the server at least somewhat synchs the player and the servers info

iron palm
rotund ravine
onyx fjord
#

Packets are a place where small fuck up will break everything

rotund ravine
#

Will easily crash the client

onyx fjord
#

For example if you send too big packet than expected client will disconnect

#

Or even worse even all players may disconnect

iron palm
rotund ravine
onyx fjord
#

I had more luck with nms packets than plib tbh

iron palm
rotund ravine
#

The library in question is not that hard and is well documented

hybrid spoke
#

thats interesting

rotund ravine
#

Protocollib

onyx fjord
#

Meh

#

It's just meh

rotund ravine
#

Obviously for you it seems

onyx fjord
#

While you get examples you gotta figure out a lot yourself

lyric turtle
#

is there way to trick server that it wont be able to teleport me because it will think that im trying to teleport on my own?

onyx fjord
#

Not a cheat if you call it an utility client 🤙

#

Jk cheating is stupid

chrome beacon
#

Don't forget to break Optifine TOS

onyx fjord
#

Optifine is annoying

#

Why don't they just remove fast math

#

If it causes issues with anticheats

chrome beacon
#

Optifine is a mess for modders too

onyx fjord
#

If you do very precise cheat checking you will notice it

#

For example grim

chrome beacon
#

It literally overrides code with it's own binary patch

hybrid spoke
#

badlion goes brrr

#

exactly

onyx fjord
#

Client anticheats are just stupid

hybrid spoke
#

and still exploitable

onyx fjord
#

Totally not invasive

#

Did you mean it checking running processes?

#

Oh

exotic garnet
#

Would anyone be able to tell me why this doesn't work?

        if (section.getBoolean("glow")) {
            Enchantment enchantment = item.getType().toString().contains("ROD") ? Enchantment.SILK_TOUCH : Enchantment.LURE;
            item.addUnsafeEnchantment(enchantment, 1);
            meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        }
#

This if statement is in a method that takes in a configuration section

#

The enchant isn't being applied to item

#

Everything else in this method is working, material, lore, name, item flags, etc but I can't get the enchant effect to work.

#

Btw this method is used to take a configuration section and create an Itemstack from the info in that section.

#

The item itemmeta is set to meta at the very end of this method

topaz cape
#

what's the packet sent when rendering a player on another player's screen (in render distance)

#

isn't it PacketPlayOutNamedEntitySpawn?

#

i wrote this but it seems to not reach the end

echo basalt
#

there are like 4 packets to spawn an npc

velvet chasm
#

How would you detect if a killer is in a certain region with worldguard api? (onPlayerDeath event)

topaz cape
echo basalt
#

There's the player info, for tab

#

entity spawn maybe

#

uhh

#

metadata

topaz cape
#

wdym

#

also it only sends ID

echo basalt
#

You need more than just entity type to spawn a player

#

it's.. a special case

topaz cape
#

the paket constructor only takes EntityHuman

#

it's no special case

echo basalt
#

To spawn an NPC:
-> PlayerInfoPacket
-> NamedEntitySpawn

#

just NamedEntitySpawn don't do anything

#

because it's waiting for the PlayerInfoPacket containing data such as skin

#

and then send rotations and all

topaz cape
#

and in tab

echo basalt
#

doesn't matter

maiden thicket
#

dont need playerinfo for tab for 1.19.3

#

if u are on latest

#

u need it to add the player in only

topaz cape
#

im not sending any packets im just listening to them

maiden thicket
#

what are u trying to do w listening to them

#

oh i see

#

might be player info add player

remote swallow
#

if ((!BungeeCoreSpigot.hexPattern().matcher(color1).matches() && !BungeeCoreSpigot.hexPattern().matcher(color2).matches()) || (!BungeeCoreSpigot.validNameValues().containsKey(color1) && !BungeeCoreSpigot.validNameValues().containsKey(color2))) { my brain isnt working at full capcity so am i correct in sayng this should check if color one and two both dont match the pattern or they both arent in the validNameValues

tardy delta
#

still not working

tardy delta
remote swallow
#

they could be either

#

both would need to either match the pattern or be a key in the map

#

or actually

#

my brain just brained

eternal oxide
#

if both are NOT matched OR both are not in valid

remote swallow
#

i should probably have those as all ors

#

so i could use a hex and a name

tardy delta
#

if ((color1 matches && color2 matches) || (color1 in names && color2 in names)) { // smth valid }

remote swallow
#

thats pertty much what i have now

#

otherthan backwards

tardy delta
#

well whats the problem

remote swallow
#

for some reason if i put 2 valid hex's in i get the error message

velvet chasm
#

I am trying to make a Location. I have worldguard and worldedit api. It keeps saying I am using Location from worldedit and I need bukkit Location. How do I change it to be bukkit

remote swallow
#

import the bukkit version

velvet chasm
#

How?

remote swallow
#

when you type Locat pick the one in org.bukkit

velvet chasm
#

I am doing that

#

It is giving me the same error

remote swallow
#

?paste the class

undone axleBOT
velvet chasm
remote swallow
#

you shouldnt need to use BukkitAdapter fora normal location

ivory sleet
#

You imported Location to be the bukkit one

#

But you use it as the world edit one

velvet chasm
#

Is there anyway of seeing if the event.getEntity is in a certain region?

ivory sleet
#

Yes

velvet chasm
#

How?

ivory sleet
#

What exactly are you doing if I may ask

velvet chasm
#

I am running an event when a player is killed?

eternal oxide
#

WorldGuard API

velvet chasm
#

In a certain region

ivory sleet
#

One way is to register a session

#

And listen for when something enters/exits

velvet chasm
#

Is there an easier way?

ivory sleet
#

Else you can probably just grab all regions the entity is in

remote swallow
#

private static final Pattern hexPattern = Pattern.compile("#[a-fA-F0-9]{6}"); ah yes these are 2 invalid hex's, dont gethow

velvet chasm
ivory sleet
#

Could probably use a location

#

As you were doing alr

#

Idr the api in my head

#

Worked with it last a month ago

velvet chasm
#

Okay do you know how I could check if that location was in a certain region or not?

ivory sleet
remote swallow
#

if (!(BungeeCoreSpigot.hexPattern().matcher(color1).matches() && BungeeCoreSpigot.hexPattern().matcher(color2).matches()) || !(BungeeCoreSpigot.validNameValues().containsKey(color1) && BungeeCoreSpigot.validNameValues().containsKey(color2))) {

ivory sleet
#

That tells me nothing

remote swallow
#

color1 is the first hex, color2 is the 2nd

#

hexPattern is that hex pattern

#

alex im judging you

eternal oxide
#

pattern is fine

tender shard
#

why are are you checking whether the valid names does NOT contain color1 and DOES contain color2?

tardy delta
#

print colors

tender shard
#

oh wait my bad

remote swallow
#

smh

tender shard
#

yeah bro send thefull if

#

not just the condition

remote swallow
#
if (!(BungeeCoreSpigot.hexPattern().matcher(color1).matches() && BungeeCoreSpigot.hexPattern().matcher(color2).matches()) || !(BungeeCoreSpigot.validNameValues().containsKey(color1) && BungeeCoreSpigot.validNameValues().containsKey(color2))) {
            player.sendMessage(Utils.format(plugin.getConfig().getString("messages.incorrect-color")));
            return;
        }
#

judging intensifies

tender shard
#

check the conditions

#

dont throw 4 nested conditions into one if statement

remote swallow
#

so just check them each seperately

tender shard
#

boolean isColor1ValidHex= ...

tardy delta
#

and print what fails

remote swallow
eternal oxide
#

variable for readability

tardy delta
#

BungeeCoreSpigot.hexPattern() man doesnt want readability

remote swallow
#

alex made the class

#

i could also probably make that not static

tardy delta
#

blame alex

ivory sleet
tender shard
#

i didnt write any hexPattern method

#

😛

remote swallow
#

i wrote that part

#

you made the class

tender shard
#

I would have used a private static final PatTern HEX_PATERN

tardy delta
#

but if you combine it, it looks like BungeeCoreSpigot.hexPattern().matcher(color1).matches() 💀

tender shard
#

but who cares

remote swallow
hybrid spoke
remote swallow
#

then i thought i might need it elsewhere

hybrid spoke
#

even your ide should complain

remote swallow
#

my brain wasnt working lastnight

#

blame past me

#

brb gotta go check on oven

tender shard
#

is your pizza still in the oven?!

#

didnt you put it there 3 hours ago?

hybrid spoke
#

blaming you in general since your present you couldnt figure it out either

tardy delta
#

my pattern is #[a-fA-F\\d]{6}

#

so cant be that

ivory sleet
#

Yeah the pattern isn’t bad, but it depends on how you use it

tender shard
#

yeah well they check if it does NOT match the hex (which it does) or does NOT match the names like red,green, yellow

#

ofc that won't work

remote swallow
#

i cooked that in an air fryer

tender shard
#

also, it's okay if first is hex and second is "red"

remote swallow
#

this is a new oven and we had to like turn it on for an hour at 200 to burn it in

#

or get rid of factory stuff

tender shard
#

I'd do it like this:

boolean color1Valid = isHex(color1) || isNormalColorName(color1);
// same for color2

if(!color1Valid || !color2Valid) error
remote swallow
#

look at you having brain cells

velvet chasm
#

(worldguard) How do I convert event.getEntity().getKiller() to a wg.wrapPlayer

tardy delta
#

ig it needs a Player instance?

velvet chasm
#

How does that work?

hybrid spoke