#help-development
1 messages · Page 312 of 1
FileConfiguration.get("path"), FileConfiguration.set("path", value) then save it
or check if the pdc.has(STPRAGE, getDataType()) before calling get(...)
Okay and about for eaching the whole file?
you should be able to
How exactly?
Same thing @tender shard
for (String key : FileConfiguration.getKeys(false)) System.out.println(key);
that would loop over all keys
Okay thx
if you want to get every option you can in the config use getKeys true
And to delete stuff?
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?
set it to null probably
declaration: package: org.bukkit.event.block, class: BlockPlaceEvent
check if the block is a rail
what's "actionRight" line 34?
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;
}
hm idk, can you send the full source code? it's hard to debug it with only snippets
Dming
kk
I don't think what I want will happen if we cancel this event. I just want them not to get attached to each other
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?
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
how do you get all players within the render distance of a player
is Bukkit#getViewDistance even relevant
don't even think the client reports what they have set for view distance
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
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
It does
hopefully it works
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
I don't think Spigot has a way to access the player view distance
Paper does though
i have to refresh the disguised players as entities when they join a player's render distance
InventoryClickEvent e
How can I get a chest object from this event?
get the inventoryholder
there is no guarantee that a chest is associated with the given inventory though, but you would just check
wait
how do i calculate viewDistance for nearby entities then
a chunk is a 16x16 right?
Yes
so Bukkit#viewDistance x 16 x 16?
Why not just use Protocollib and listen to when the player becomes visible and replace that
Same with movement packets and such
nope i have to make it for a lib that shouldn't depend on any plugin
Then shade PacketEvents or TinyProtocol
i dont even know what TinyProtocol is
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
hi guys , how i can do , snow ball can destroy snow_block ?
i want something like this https://www.spigotmc.org/resources/✈️vehicles-no-resourcepacks-needed.12446/
unlike that plugin, i want to put many more blocks, hundreds, so the lag is important to determine which method to use
yeah, didnt happen for me in 1.19.3
whats your version?
ProjectileHitEvent
1.19.2 i think
check if projectile is a sonwball, check if the hit block is a snow block
thanks
hm it worked fine for me in 1.19.3
ok, but is that the best way to achieve what i want?
print out the falling lock location every tick and see if it changes
if it does change, it's indeed server-side
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
you could make the fallingblock a passenger of the armorstand i guess
mfnalex if i want player get knockback from snow ball , how i can do?
what java version for 1.19.x?
17
apply some velocity manually
Vector vec = snowball.getVelocity().normalize();
player.setVelocity(player.getVelocioty().add(vec));
or sth like that
i love u
not so loud, my bf is here
I have a question how would you get the players inventory and then give it back once a command has been done?
You can store the inventory in a map until the command is run
Use get and set contents
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());
you would need to use ChatColor.translateAlternateColorCodes('&', string) for that
use ComponentBuilder
?jd-bcc
wrap the ChatColor.translate... in it
TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&cMy Text"))
sth like this
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
you dont need the .create
Ah, okay
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
Does ItemStack#deserializeBytes() not exist in 1.19.3?
that is papers api
mb
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/ItemSerializer.java#L62 this is how you can do with normal bukkit api
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
are you sure that your uri should have http
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');
})
})```
yes
so i dont need http?
u need ws:// iirc
or wss if using ssl
uhuh
let me try
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?
you need a resource pack that overrides the texture using CustomModelData, then create an ItemStack with the same custom model data
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
kk
then I just set something like a diamond pickaxes CustomModelData and DIsplayName to something else?
yes
oh wait, that is outdated
Hello, I'm Geegaz ! As you may know, the first snapshots of the 1.14 introduced a new format for the JSON item models custom model data ....
Ok thanks
get that resource pack, then check out how it works
Where do I put the custom texture?
@rare rover what is your import of socket class ?
im trying to find docs on java impl, but there is quite a few
<dependency>
<groupId>io.socket</groupId>
<artifactId>engine.io-client</artifactId>
<version>2.1.0</version>
</dependency>```
im dumb
your socket.on for player event
is inside of function for connection listener
yes
should it be like that ?
the tutorial said to do that
can you check socket.hasListeners("playerJoin"); ?
i did not
also try to just send message, without emiting event
i do
to see if problem is in client or server
^
ah
okay
waiting for my mc server to start rq
hmm
didn't send and hasListeners = false
🤔
try to put socket.on for player outside of listener for connection
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');
});```
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
are you even using socket.io ?
sooo
Too old! (Click the link to get the exact time)
you cannot use WG 7 with this ancient MC version anyway
you need a way older WG version
WG 7.1.0 is 1.19+
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
for 1.8.8 you need WorldGuard 6.2
Alright I updated my pom and to use 6.2 and not i get cannot access com.sk89q.worldedit.Vector
you need worldedit too
6.1
Works thanks
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
BlockBreakEvent
How do I see if the block was broken with my custom pickaxe?
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
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
can u show how you've coded it up?
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
}
}
is there a way to place structures like a netherfortress in 1.19.3 like how /place structure does it?
right. you can't just write ur main classes name like that
Yeah
u need an actual reference to it
So how should I got about doing that?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Ok thank you
I keep getting excessive velocities errors
Is there a way to hide them because the velocity i am setting isnt that much
what velocity are you setting?
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
can't look, in game
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
I don't see anything related to a max velocity of 10 in craftbukkit's code
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?
Full stacktrace thank you
not using the same method so no point
a
It does not add. Set it to 0 0 0 and see for yourself
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);
how do i spawn a nether fortress like the /place command does in 1.19.3?
start the socket server with http package
does anyone know if there's a proper VTL plugin for IntelliJ? By default IJ gets confused when you add VTL to java files
@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!
you never cancel the event if the player clicks into the above inventory
decompile the server .jar and check what the command does
oh ykwhat great idea
thanks
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
See also structure api
somehow those structures are only loaded when a the vanilla generator already used them
how? can u explain that?
event.setCancelled(true), if a user clicks into your GUI inventory
bump 🥲
I mean have you looked for it?
i didn't understand i'm put if player clicked in inventory(type != playerInventory) then cancel what should i do then?
yes. only thing I found is some android plugin and that only seems to work for standalone vtl files, but not for VTL embedded into java
I'd also be fine with installing VSCode or whatever, if only there exists a proper plugin for this
Create a plugin for it yourself
🥲
funny lol
I once tried creating a simple intellij plugin and I didnt even know where to start
@primal goblet cancel the event mister
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
if(!e.getClickedInventory().getType().equals(InventoryType.PLAYER)) {
e.setResult(Result.DENY);
e.setCancelled(true);
}
i already canceled
Why
and dont wanna test it on multiple versions
No
MinecraftServer.getServer().server.getCommandMap().register("", new Ranks());
Yikes
no the bukkit commandmap
how? 😮
i have no clue
You’re only canceling if they are pressing the player inventory
What u have probably works
ty
there's a !
that what i was asking xd
I am asking you if it is intended
this code will work for every version? from 1.8 -> 1.19?
no i tried to cancel it without any checks and still like this..
idk, I only use 1.16.5+. However since it's only craftbukkit classes, and they havent changed since forever, it should also work in 1.8, I guess
Seems false
i'll give it a shot
however, I'd use ACF instead of manually changing the commandmap
Acf do be lit
no.. sadly
Nah
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);
}
❤️
I use a String... because angelchest's config looks like this:
command-list-angelchests:
- aclist
- angelchestlist
- ...
so I can just throw in the list
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
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
can one make maven archetype only use a certain <fileSet> if a specific property is set?
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
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
How do I get the block at that position?
myWorld.getBlockAt(x,y,z)
kk
does player.BreakBlock take time or is it instant?
Since I need something that is instant but also has the drops
Methods usually run instantly
kk
what is "ServerLevel"
might be WorldServer depending on mapping
ServerLevel is ServerLevel
are you not using mojang mappings?
is there a dependency im missing?
I want to make it relative to where a block is broken
no
Whats the best way to do that?
well by setting centerX, centerY, centerZ to the coordinates of the block
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
square or cube
square
so just dont use Y
then do not loop over Y, obviously
just get rid of the Y loop
thank you
I don't understand how that would solve it
you'll have to use blockfaces
How would I do that?
oh you wanna do it depending on where the player looks?
Yes
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
Hard coding it would be really clunky
you can just use a switch
not really, you only have 3 cases
east/west, north/south, or up/down
Yeah I was thinking i'd have to do more for some reason
I'll just do an inline statement
should be easy enough
Also wouldn't these be half of radius?
nvm
no
i get what you did
ur thinking of diameter
ye
You doing some sort of tinker hammer enchant?
?paste
kk
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
Is there a method to get the towards thing or would I have to map that my self?
Like it says Facing: north (Towards negative Z)
so you somehow gotta turn that into "normal" directions
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);
}
You can be facing north, but looking down.
yeah sure
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
No you'd want what face you are hitting the block at.
I thought they wanted to base it off the direction the player is looking
Well kinda
that's what they said earlier
But i asked if they wanted to do a tinkerhammer style, and that's what face you are breaking the block at.
Yeah
yeah then it's easy
getCLickedBlockFace
.
In what?
kk thx
BlockBreakEvent
When was that added?
Doesn't exist
@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;
}
Both ways would work
I'd rather use a loop so you can adjust the radius whenever you want
I never said not to?
^
I didnt say you said that lol
I just said that I'd prefer a loop over hardcoding the blockfaces
Ah, well it was easier.
yeah sure, if you only want to do 3x3, I'd also hardcode it
If you ar ehaving a player break it
you gotta also take into account anticheats btw
oh yeah, you gotta hook into a lot of anti cheat apis
or you uncancel the events by listening to them yourself lmao
Before I make any public plugins im gonna make quite a few private ones
I just cheesed it https://paste.md-5.net/heramuvifo.cs
interesting lol
there should be some generic AntiCheatEvent
that all anti cheats use
This also hooks into protection plugins.
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;
im struggling on how to install build tools for 1.19.3
what exactly is the problem?
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
one sec
How do I make my pick only run blockbreakevent if it's breaking the right type?
Like a pickaxe mining sand shouldnt work
it says 17.0.5
but a pickaxe mining stone or ores should
then download BuildTools.jar and put it somewhere
then go into that directory with command prompt
You don’t
just check if the block its breaking is stone or ores and if it isnt then cancel the event
then enter java -jar BuildTools.jar --rev 1.19.3 --remapped
?xy
Asking about your attempted solution rather than your actual problem
Put the checks in the event @eager girder
okay i will
okay my code from earlier works fine lol. just had to switch NORTH/SOUTH and EAST/WEST in the switch/case
Do I check for if it's a stone or ores
Like what do I check for is my main question
What about more angled shit
Check for what you want
well that won't work when just checking the clicked blockface
mineable/pickaxe
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
Ohhh isPreferredTool exists
yeah but that one can be misleading
How so?
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
it does make sense
so yeah there's a few edge cases
okay another example, WHEAT
what's the preferred tool for wheat?
every tool? or none?
should be the hoe ?
It works for my use case
that isn't how it works
what do i do after that
its not based on your personal interpretation
did it say BUILD SUCCESS?
or based on what gives what advantage
oh not yet
why would a hoe be preferred over bare hands for wheat?
it can have fortune
okay it just said that
the method doesnt check that. all it does is to check whether the block would drop anything when using this itemstack
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))
pretty sure it doesn't
but I have no interest in really opening up the implementation source to see it/show it
Oh it does
Maybe it doesnt work for my use case
that's from the DiggerItem class
I can also just check for mineable/pickaxe too
it simply checks whether the block would drop something, and nothing more
what the heck intellij
Anyone can help me there?
https://www.spigotmc.org/threads/need-help-about-chunkgenerator.586382/
maybe show the worldedit code that gets the server stuck
How do I check for #mineable/pickaxe?
I remove that code. let me rewrite it :)
Tag.MINEABLE_PICKAXE.isTagged(Material.DIRT)
can someone make this usable in 1.19.3? https://github.com/liltinyten/worldwhitelist
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
"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."
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
now how do i use this?
i looked at the link but it doesnt explain what i do
?switchmappings
this explains on how you change your old mappings to the new ones
the first link was only to setup your project
is the "ServerLevel" thing supposed to work now or nah
cause it still says it cannot resolve symbol
and it doesnt let me import a class
?notworking
"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.
yes, it's supposed to be able to import now. ?paste your pom.xml
you didnt add the classifier to the spigot dependency
you also didnt add the whole remapping part
yeah i didnt understand it, thats what i was asking about earlier
i shouldve clarified lol
what exactly do you not understand?
like how im supposed to change the pom.xml
do i just paste whats in the blog into it or?
you put the <plugin> thing into your already existing <plugins> section
and you add the <classifier> into your spigot <dependency>
<version>1.2.2</version>```
this part is giving me an error
saying its not found
it should work after clicking the reload button
nope
?paste your pom again pls
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?
oh ill do that rq
this must NOT be enabled
its not enabled
please send your full maven log. to get it, click the uppermost entry on the left of the output, then copy/paste the full output
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
so how do you suggest? like how can I paste it on chunk?
its not fixed on location. it will generate randomly
how do i get this window
like open it
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?
just try to compile (mvn package), then it should open
just double click on "package" here
the last entry was me compiling
send the full output pls
If it shows no error during compiling but it does in intellij you can ignore said error
well it did work fine
ignore that it's marked in red, intellij sometimes messes it up. it did compile fine
oh okay
This B)
you could try File -> Invalidate Caches to get rid of the red underlining
Intellij is a bit funky with POMs at times
dont click any of the boxes? just hit invalidate and restart?
yeah that should be enough
alr
it'll take a while after restarting before it loaded all dependencies again
so much pain for spawning a fortress lmaoo
ive been here for hours
even before the build tools stuff
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
💀
Structure var4 = (Structure)var1.value();```
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?
well var3 is an NMS World i think
so just World but under NMS?
think so
What's the recommended way to get the main class instance from a static util method?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
THIS HURTS MY EEEEYES
Who did that
i did that
why did you do that
how else would I do that
in a way that doesn't make everyone wanna die
it's a maven archetype -> https://github.com/JEFF-Media-GbR/maven-spigot-plugin
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"));
full stacktrace
Why must cool things require such horrible syntax 
how would i make a projectile disappear after flying 100 blocks?
I DONT KNOW D: also VTL is so badly documented
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;
}
}
I dont even know how to use custom contexts after 2 hours of googling
I dont even know what VTL is
save the origin location in the projectile's PDC, then loop over all active projectiles every tick (or save the projectile in a list, if you only wanna do it for certain ones), then check if their current location's distamce is >= 100 from the original location
Velocity Templating Language or sth

with my archetype, you can generate projects like this:
Now thats fancy
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
Definition of developer right now. Spending hours automating an issue that takes 5 minutes to do manually 
did you import the bukkit Structure insteard of the NMS one?
probably hehe
one sec
wdym with that?
I meant, send the full stacktrace, and not just one line, pls
yeah exactly lol
maybe other people will find it useful, then it was already worth it though
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
like this?
what should be the argument in catch()?
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
i have a gui with slots not filled would this get the slots that are empty gui.getInventory().all(Material.AIR).keySet()
probably
what does it return?
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 ^
[]
It's emptyyyy
just loop over it normally
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);
}
}
and this is my gui its empt
y
that definitely works
He’s checking something else dummy
No
Empty slots are usually not air, but they can be air or null
wdym? They wanna get the slot numbers of all empty slots, and that's what I sent
He asked if his thing worked. And you said probably
yeah then we found out that it doesnt work, so I sent a working solution
does the worldedit api have anything about pasting ingame structures?
no
yeah i figured
how would i do raytracing?
Google your question before asking it:
https://www.google.com/
^^
hmmm
Looks about eight
how do i publish a plugin to the website? (for in the future)
by clicking on the upload button
Make an account and publish by clicking upload
oh, idk how i didn't see that xd, thanks
yeah it's indeed a bit hidden lol
Not rly
well this question got asked here more than once
Like the people who don’t google i guess
close enough
reflections
and because i want my lib to be independent
i only wanna listen for 1 packet man 😦
Packet events
it's finally done!! (for now)
https://github.com/JEFF-Media-GbR/spigot-plugin-archetype
Would be nice if some people could try that and see if there's any bugs or anything 😄
nah
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?
btw you probably need worldedit too: https://worldedit.enginehub.org/en/latest/api/index.html
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?
that you used 7.x instead of the actual version
So what would be the actual version?
Oh okay thanks
and 7.3.0-SNAPSHOT for worldedit-bukkit: https://maven.enginehub.org/repo/com/sk89q/worldedit/worldedit-bukkit/
Still comes up with errors after doing this though?
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.
Yes
then clicking the reload button should work
Yep it just takes a bit
looks cool, i’ve never really looked at archetypes before. i probs won’t use it cause i already use the mcdev plugin but i can see this being useful
thx. it's mainly useful for adding dependencies, setting up remapping etc, because the dev plugin doesn't do that
Wait do they both use the same repo?
or do I need to add another for worldedit? I added the worldguard one already
Same repo
Okay then yes.
The worldguard is working fine. The worldedit has an error in the version
?paste your pom please
You wrote worldguard twice
Instead of worldedit
The 7.3.0 one has to be worldedit
I feel extremely dumb
Change both the groupId and the artifactId
Yep. I don't know how I did that and some how didn't even realise.
We all do lol
yeah sure
Omw to sumbit a feature request
I wonder what ij plugins
Oki
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
which one?
Yep it all works the way it should now. Thanks so much for all the help. Sorry for messing up there lol
np!
btw you need to use maven to compile, too
double click on package. do NOT use build artifacts
Where is the package?
<project folder>/target/
i have question, where "PacketPlayInPositionLook" is received from player and interpreted?
if you wanna make maven put the .jar somewhere else, check out this: https://blog.jeff-media.com/common-maven-questions/
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.
oki. you can also use profiles to dynamically change where it puts the file, but I guess you dont need that lol
Yep well thanks for all the help
np
where "PacketPlayInPositionLook" is handled in code? where its setting player position based on this packet?
probably net/minecraft/server/network/PlayerConnection
actual name is net.minecraft.server.network.ServerGamePacketListenerImpl
thx
in spigot mappings: PlayerConnection#handleMovePlayer(PacketPlayInFlying)
the PlayInPositionLook packet extends PacketPlayInFlying
yeah and is that making a big difference while handling?
both are handled the same way
im wondering how limit of teleport by client is working
the only difference is that for the Look packet, X,Y,Z delta is always 0
oh
like when server sends s08 packet (i dont remember its mojang name) then client is sending PlayInPositionLook
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
thing is that
server can teleport player as far as it wants
but player cant teleport itself so far
how server is keeping track
wdym?
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
Using worldguard api. Should "RegionManager regions = container.get(world);" world come up as an error. Container is defined "RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();"
@tender shard Added your archetype to https://www.spigotmc.org/wiki/resources-list/
you need a WorldEdit world
BukkitAdapter.adapt(myBukkitWorld)
thx!
ofc the server doesn't check teleports that it initiated itself
it only checks the distance for incoming teleport / move packets, not outgoing
So would myBukkitWorld be replaced with the name of the world?
yes
Alright thanks
server can teleport player as far as it wants, player cant teleport itself as far as it wants
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
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?
yes
Absolutely bullshit
5 blocks still seem pretty op
No?
Exactly
Ah well, it’s good for beginners i guess https://betterprogramming.pub/well-intentioned-but-bad-advice-for-beginner-programmers-dc806edd20bd?gi=683fa10f888f
Better you use it for yourself
Hm?
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?
mfs
@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.
can you actually teleport with that or just offset your current position?
It’ll most likely get them banned by an anticheat
wasnt the question
ah so the server at least somewhat synchs the player and the servers info
I understand what you mean ... but it doesnt mean dumb when you want to use the official ways of listening to packets. its just more fun when you invent it by your own.
Again, if you are a beginner sure. Use it to learn, if you are already familiar with it, just reinventing the wheel is a big waste of time.
Packets are a place where small fuck up will break everything
Will easily crash the client
For example if you send too big packet than expected client will disconnect
Or even worse even all players may disconnect
Not a beginner but still would prefer using nms for sending packets
Why? It seems extremely restrictive
I had more luck with nms packets than plib tbh
Learning a library just for a thing would be also a waste of time while you can do it by yourself and you're not forced to do it right?
The library in question is not that hard and is well documented
thats interesting
Which one
Protocollib
Obviously for you it seems
While you get examples you gotta figure out a lot yourself
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?
Don't forget to break Optifine TOS
Optifine is annoying
Why don't they just remove fast math
If it causes issues with anticheats
Optifine is a mess for modders too
It literally overrides code with it's own binary patch
Client anticheats are just stupid
and still exploitable
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
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
there are like 4 packets to spawn an npc
How would you detect if a killer is in a certain region with worldguard api? (onPlayerDeath event)
isn't this one for players coming in render distance
It's for generic mobs
There's the player info, for tab
entity spawn maybe
uhh
metadata
break it down
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
but the player is already in
and in tab
doesn't matter
dont need playerinfo for tab for 1.19.3
if u are on latest
u need it to add the player in only
im not sending any packets im just listening to them
what are u trying to do w listening to them
oh i see
might be player info add player
check wiki.vg/protocol
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
still not working
if both do not match or both are not in valid names?
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
if both are NOT matched OR both are not in valid
if ((color1 matches && color2 matches) || (color1 in names && color2 in names)) { // smth valid }
well whats the problem
for some reason if i put 2 valid hex's in i get the error message
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
import the bukkit version
How?
when you type Locat pick the one in org.bukkit
?paste the class
you shouldnt need to use BukkitAdapter fora normal location
Is there anyway of seeing if the event.getEntity is in a certain region?
Yes
How?
What exactly are you doing if I may ask
I am running an event when a player is killed?
WorldGuard API
In a certain region
Is there an easier way?
Else you can probably just grab all regions the entity is in
private static final Pattern hexPattern = Pattern.compile("#[a-fA-F0-9]{6}"); ah yes these are 2 invalid hex's, dont gethow
Well to use the worldguard api on an entity does it need to be .wrapplayer? Or can I use event.getentity?
Could probably use a location
As you were doing alr
Idr the api in my head
Worked with it last a month ago
Okay do you know how I could check if that location was in a certain region or not?
Are matching each of them individually?
RegionManager, no?
yeah
if (!(BungeeCoreSpigot.hexPattern().matcher(color1).matches() && BungeeCoreSpigot.hexPattern().matcher(color2).matches()) || !(BungeeCoreSpigot.validNameValues().containsKey(color1) && BungeeCoreSpigot.validNameValues().containsKey(color2))) {
That tells me nothing
color1 is the first hex, color2 is the 2nd
hexPattern is that hex pattern
alex im judging you
pattern is fine
why are are you checking whether the valid names does NOT contain color1 and DOES contain color2?
print colors
oh wait my bad
smh
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
so just check them each seperately
boolean isColor1ValidHex= ...
and print what fails

variable for readability
BungeeCoreSpigot.hexPattern() man doesnt want readability
blame alex
That’s not too bad?
I would have used a private static final PatTern HEX_PATERN
but if you combine it, it looks like BungeeCoreSpigot.hexPattern().matcher(color1).matches() 💀
but who cares
i was gonna use that
this is way too nested and confusing
then i thought i might need it elsewhere
even your ide should complain
blaming you in general since your present you couldnt figure it out either
Yeah the pattern isn’t bad, but it depends on how you use it
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
noooooo
i cooked that in an air fryer
also, it's okay if first is hex and second is "red"
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
I'd do it like this:
boolean color1Valid = isHex(color1) || isNormalColorName(color1);
// same for color2
if(!color1Valid || !color2Valid) error
look at you having brain cells
(worldguard) How do I convert event.getEntity().getKiller() to a wg.wrapPlayer
ig it needs a Player instance?
How does that work?
dont they have mapper classes?/converter
