#help-development
1 messages · Page 969 of 1
k, i'll try
If you did not put it in a subdir within the resources folder, that is correct - otherwise no.
could you screenshot your project layout?
use mvn clean package to build your jar and maybe try to also drop the leading slash
clean package is that right ? https://imgur.com/vhQRupj
yeah, if you go the IDE route - first invoke clean, then the package goal
wtf is happening
i have an error on plugin.yml now
"Jar does not contain plugin.yml"
well that narrows it down a bit. Could you paste the contents of the pom.xml?
hm strange, I am not seeing any obvious defects (though I am slightly unnerved by the fact that the pom isn't 200 lines long :p)
why it would be 200 lines XD
including the license file and other formalities, multi-release-jar stuff, the javadoc and source plugins and last but not least the maven-gpg-plugin all contribute to my minimum buildscript being rather long
yea i see, but it worked like that too, plugin is working tho, just when i try to implements SQL connexion, it crash
@quiet ice no more idea to my issue ?
not really at this point in time
are you ok to try with screenshare ?
I have another question, the translations should be at resources folder or like a external folder at the main tree of the project for better maintenance? Keeping in mind I have multiple modules
how do i properly manage servers for a minigame for exmaple?
like how do ppl auto start them
did they code an external service for that?
by clicking start
k8s
🤨
or that
I misread this at first
question, how does entityspawnevent actually implement cancellable? does it create the entity and remove it if it gets cancelled?
because the event itself passes a valid entity
I don't think entities have to be spawned in the world do they?
does anyone know a solution to this problem: I have two kinds of events, an EntityExplodeEvent and a BlockPhysicsEvent. When the explode event triggers, I'm giving the player all exploded blocks directly into the inventory. The problem is that the explosions seem to overlap, and I sometimes get a few blocks too many. Any idea how to tackle that?
Solid chance the event is called on the addFreshEntity method
Cancelling it just prevents it from being registered to the world and sent to players
Meaning it loses all references and can be GC'd
Also anyone know how to hide these messages
[EntityLookup] Failed to remove entity ChestBoat['Birch Boat with Chest'/426, uuid='a0fe2493-6705-4c4c-96b9-a78044977ecd', l='ServerLevel[world]', x=395.55, y=62.52, z=-216.04, cpos=[24, -14], tl=120, v=true, removed=DISCARDED] by uuid, current entity mapped: null
@ me with response please.
dont spawn
fellas, Player#breakBlock() seems to be pretty heavy on the server when done more than normal. is there a better way to break blocks with natural drops?
preferably not just setting to air and dropping the drops manually because that doesnt play well with other plugins that might affect drops
Hello, is there a more optimized way to do that?```java
@EventHandler
public void onItemPickup(EntityPickupItemEvent e){
if(!(e.getEntity() instanceof Player player)) return;
for(CraftingRecipe recipe : recipesConstructor.getRegisteredRecipes()){
if(recipe instanceof ShapedRecipe shaped){
if(shaped.getIngredientMap().containsValue(e.getItem().getItemStack())){
player.discoverRecipe(shaped.getKey());
}
} else if(recipe instanceof ShapelessRecipe shapeless){
if(shapeless.getIngredientList().contains(e.getItem().getItemStack())){
player.discoverRecipe(shapeless.getKey());
}
}
}
}```
In my main file I have this code that is supposed to share the main class:
private static PermaVision instance;
public static PermaVision getInstance() {
return instance;
}
and this in my onEnable method:
instance = this;
I'm getting this error when my other java file tries to access .getLogger()
java.lang.NullPointerException: Cannot invoke "co.uk.robuxtrex.pv2.PermaVision.getLogger()" because "this.main" is null
at co.uk.robuxtrex.pv2.Modules.SendConsoleMessage(Modules.java:60) ~[?:?]
at co.uk.robuxtrex.pv2.PermaVision.onEnable(PermaVision.java:42) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[server.jar:git-Spigot-550ebace-7019900e2]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:335) [server.jar:git-Spigot-550ebace-7019900e2]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [server.jar:git-Spigot-550ebace-7019900e2]
at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.java:356) [server.jar:git-Spigot-550ebace-7019900e2]
at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.java:316) [server.jar:git-Spigot-550ebace-7019900e2]
at net.minecraft.server.v1_8_R1.MinecraftServer.q(MinecraftServer.java:402) [server.jar:git-Spigot-550ebace-7019900e2]
at net.minecraft.server.v1_8_R1.MinecraftServer.k(MinecraftServer.java:370) [server.jar:git-Spigot-550ebace-7019900e2]
at net.minecraft.server.v1_8_R1.MinecraftServer.a(MinecraftServer.java:325) [server.jar:git-Spigot-550ebace-7019900e2]
at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:211) [server.jar:git-Spigot-550ebace-7019900e2]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:505) [server.jar:git-Spigot-550ebace-7019900e2]
at java.base/java.lang.Thread.run(Thread.java:840) [?:?]
are you using the class which makes your plugin crash before onEnable?
hold up
are you using the plugin as a library
i think i may know why wait there
fixed it! it was because i was trying to get the main file as soon as the main method in the erroring file was run
therefore making it error because it was trying to get the plugin before it was enabled
thanks lol
👍
is it possible to simulate a period of time to fully spread liquids in a chunk?
anyone know why my console is sayin this?
[16:52:55 WARN]: [PermaVision] Default system encoding may have misread config.yml from plugin jar
config yml file: https://paste.md-5.net/elajagaxek.coffeescript
My guess would be the ⚠️
would there be any way to silence it? since it's loading the file completely fine
you can remove the ⚠️ from the config
@shadow night sorry, and thank you bro
?services @hasty hamlet and don't DM random ppl
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/
hey, I was updating one of my plugins when I noticed hex codes don't work in vanilla mc's tab
anyone knows why? here's my hex util class if you need it https://paste.md-5.net/voveyedati.java
(repost from yesterday since it got burried with no answer)
@grave vale Try changing your regex? Also you might be substringing incorrectly in the spigot branch
"&#([a-fA-F0-9]{6});"
Try that instead?
Alright I'l ltry
s = s.replace(color, net.md_5.bungee.api.ChatColor.of(color.substring(2, 8)) + "");
let me just start my intellij
And that for the substring
i made an edit to the regex
still doesn't work (with the regex you just edited)
What's happening?
hmmm 🤔
is it possible to simulate the spread of all liquids in a chunk?
does anyone know if it's possible to get the item entity from dropItemNaturally? I need to apply a scoreboard tag to it, but would like to not iterate over all possible entities to find the one that I care about
oh I found something: dropItemNatually has a consumer argument (and actually returns the item entity as well)
Hello! How can I check that player got effect from insta heal/damage potions? EntityPotionEffectEvent doesn't work, but it works with other effects
Well, it works only with /effect command, but not with potions
doesn't dropItemNaturally literally return the Item entity?
.
you could get the consume event
PlayerItemConsumeEvent and check if the item type is a potion
Then I should get 3 events for each potion type? Splash, lingering and normal one
Well, thanks
can i block ticks with this?
theres also a PotionSplashEvent and a LingeringPotionSplashEvent
i'll probably have to try it soon
Block ticks?
no, entity
i have a falling block
but i'll see if i can do it without
i'll set no gravity and time and see how it goes
What
uh... I'm having a real odd issue with potioneffects, any time I use the command it applies / removes the effect within the same frame. The toggling is working perfect... Am I just stoned or did I forget how to apply potion effects?
private final Set<Player> playersWithNightVision = new HashSet<>();
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (!(commandSender instanceof Player)){
return false;
}
Player player = (Player) commandSender;
if (!player.hasPermission("orchard.nightvision")){
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou do not have permission to use this command!"));
return false;
}
if (!playersWithNightVision.contains(player)) {
player.sendMessage(ChatColor.GREEN + "Night Vision applied!");
playersWithNightVision.add(player);
player.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(1, 32767));
} else {
player.sendMessage(ChatColor.RED + "Night Vision removed!");
playersWithNightVision.remove(player);
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
}
return true;
}```
I'm really upset I even have to ask about this... but I genuinely can't figure it out
Toggles every use of the command, so that works...
tbf i've never seen createEffect before
Neither have I, idk if I'm like really high or what
Javadocs op :p
yes
as if I need level 255 night vision D:
But it takes an int so idk what happens to said int
32767 is a heck of a high amplifier
1 tick of nightvision 32767 please
Literally spent 15 minutes trying different toggling methods
Also in modern versions you can use -1 (or PotionEffect.INFINITE_DURATION) for an infinite effect
ah good to know
On older ones I would just do Integer.MAX_VALUE
I gotta stop going to sleep cooked and waking up cooking again
Out of everything I'm putting into this core, night vision is the one that stumped me D:
Hey guys
So I was making a plugin, it’s about hover on top of a username, and it should tell u if the player is an User, Administrator or Moderator based on the LuckPerms group
It should display it as a hover text if u move ur mouse on the username in the chat
I’ll send the code I made
?paste
This actually happens when I try the plugin (this code) it isn’t actually a hoverable text, the code placed it as an username, not as hover text
Here’s from the terminal
public ItemStackBuilder addLore(Component lore) {
if (im.hasLore()) {
im.lore().add(lore);
}
else {
im.lore(Arrays.asList(lore));
}
return this;
}
I'm using this to add lore to an item, but for some reason only the very last lore entry is actually visible on the item. Any idea what could be wrong? It's definitely entering the hasLore condition
Because you are overwriting the lore every time you are calling this method
.add shouldn't overwrite the lore though?
also that's the Paper API
You are just concatenating Strings. I dont understand how a hoverable component should emerge from that...
How should I change it?
you need to send actual Components instead 😅
I believe this might be helpful? https://www.spigotmc.org/wiki/the-chat-component-api/
I did a code with components, but I get 4 errors in my IDE
Should I send it?
sure
You're never sending a message
Which message
hoverableMessage
Could u please make an example? I don’t know where to place it
I’m stuck here since 5 hours :sob
?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
or if by example you mean write the thing for you then no
What packets are needed to spawn a player?
(except for player info update and entity spawn)
Those two should od the trick
turns out i had my locations and uuids messed up, thx 🙂
what was the website for package naming reference?
package or packet?
?nms
yeah there was a website with a wierd design and therse also a command for the website but i dont rember it
thanks
Compare different mappings with this website: https://mappings.cephx.dev
that one
When I call an event, a synchronous event, is it done on the same tick or is it called on next tick?
Bukkit.getPluginManager().callEvent(event);```
Same tick
Build Tools failing to run
It is called right away in this line of code and passed to all Listeners.
Thats why you can actually check if the event was cancelled in the next line directly.
Perfect
is there any way to disable/check advanced tooltips on players
no they are client sided
afaik
yes
how do i make a plugin that sends all packets recieved in chat
That's a lot of packets
not rlly its for personal use
i am just testing a mod im developing and i need to see the packets but i cannot find a good tutorial on how to do this
Sends them where
any books recommendations for clean code/refactoring in java?
chat
can i register permissions other than with the plugin.yml?
Does Effective Java count
how would I change the result of a recipe
reading it rn
like make it so when you craft a wooden pickaxe it does my custom version
do I just have to remove and recreate it
I believe creating a Permission object should allow plugins like LuckPerms to detect it
though the config.yml is the ideal way
That's one way to do it, yes
I mean have you tried modifying it
design patterns can be nice
since it puts canonical names and forms on common patterns in code
ive tried to look for a setResult method
I mean mutating the ItemStack from getResult
alr thanks
oh right
you can do that
hmmm
idk if that will work
try it and see ig
since the itemstack I want to set it to is one thats created with another method
unless theres a way to copy the value into it
i think what you want to do is listen, you can use protocollib for this
oh btw, if you do send them in chat, it'll cause a loop
just movement packets no chat packets
then you can listen to the the moving packets
i don't know the names exactly, you will find them in protocollib
if you don't want to use nms you'll have to hook into netty, however it might be worse for you if you don't want to worry about version support
i dont think protocollib is updated to 1.20.4
It is (get it on github)
i found it thank you
Lets say there are two players online. One is AFK, loading a set of chunks with entities in them. The other player, nearby, decides to fly off, deloading the entitys client side, but they are still loaded serverside (since the afk account is there). Is there an event or something I can use to track when that player unloads entities but the chunk remains loaded by anothe player?
It was mentioned on the forum
md_5 said it isnt being discussed currently (at least that is what he said 1 year ago)
getting the PDC isn't. Getting the item meta you get the PDC from is meh
I mean, no ™️
its more of a "be smart about ItemStack#getItemMeta calls"
yea
like, if you can, don't call it twice
i am using lombok in gradle, but when i run gradle javadoc the javadoc does not have any method (if i am using the @Getter, for example, the method is not on the javadoc). how can i fix it?
save yourself a good amount of trouble and use the gradle plugin for lombok
configures lombok for you iirc and also properly setups delombok configurations needed for ^ javadoc and sourceJars
so you don't end up like bungeecord source jars 
Specify the version to latest
that is about it
Yes
most are going to be fine ™️
shade is one of the ones where keeping it to latest is useful
Bungee is delomboked?
Is it? I could have sworn last time I used it ij was screaming at me that source and bytecode didn't match up
Certainly the javadoc anyway
https://github.com/SpigotMC/BungeeCord/blob/1be25b6c74ec2be4b15adf8ca53a0497f01e2afe/pom.xml#L332
Hi, I have this code to put a chest in the direction I want, but now I would like to keep the chest in the open position (i.e. have only the top of the chest open, like when a player open chest) but after searching I can't find anything )=
Block chestBlock1 = chestLocation1.getBlock();
Chest chest1 = (Chest) chestBlock1.getState();
chest1.getBlock().setData((byte) 3);
declaration: package: org.bukkit.block, interface: Lidded
Cast block state, call .open
Chest1.open()
This is good but not in old versions )=
This is why you should update
uhm
can you access shulker inventories from a itemmoveevent
or am i trippin and crazy
Why wouldn’t you be able to
easy, don't use old versions
you can 🤡 all you want but 1.8 is dead
upgrade
I think there is technically a maven plugin that handles that too? similar to gradle
dunno
not a ✨ maven ✨pro
Just delombok the source itself
results in this pretty picture
why is it that when you cancel PlayerLeashEntityEvent it eats the lead?
unsure why that is built in ?
and how do I not do that lol
Wdym eats the lead
probably means the lead disappears
yea, the lead disappears
@EventHandler
public void onLeash(PlayerLeashEntityEvent event) {
Player player = event.getPlayer();
ItemStack itemStack = player.getInventory().getItemInMainHand();
if(itemStack.hasItemMeta() && hookHandler.isHook(itemStack)) { //Todo: the item vanishes.
event.setCancelled(true);
}
}```
tried placing it back into the players inventory, but then he recieved two.
it's an odd ordeal the entire thing 😂
Anyone know how to hide these messages?
[EntityLookup] Failed to remove entity EntityBoat['Birch Boat'/800, uuid='28bbf4fd-cddc-4bed-b693-b4ded6440cfe', l='ServerLevel[world]', x=636.62, y=63.00, z=-335.14, cpos=[39, -21], tl=0, v=true, removed=DISCARDED] by uuid, current entity mapped: null
a dumb fix you could do
add one
and then remove one
lmao
log filter
do u know the java docs for it?
if it works it works
rather have a working version than a non working lol
No, but I can explain it.
Cool can i get the explaination then lols
Make a class that extends AbstractFilter (org.apache.logging.log4j.core.filter.AbstractFilter)
After that have a method where you can register the filter, should look something like this.
public void registerFilter() {
Logger logger = (Logger) LogManager.getRootLogger();
logger.addFilter(this);
}
and heres the rest
@Override
public Result filter(LogEvent event) {
return event == null ? Result.NEUTRAL : isLoggable(event.getMessage().getFormattedMessage());
}
@Override
public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
return isLoggable(msg.getFormattedMessage());
}
@Override
public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) {
return isLoggable(msg);
}
@Override
public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
return msg == null ? Result.NEUTRAL : isLoggable(msg.toString());
}
private Result isLoggable(String msg) {
if (msg != null) {
if (msg.toLowerCase().contains("filtered string")) {
return Result.DENY;
}
}
return Result.NEUTRAL;
}
"filtered string" should be whatever you don't wanna have logged
yeah
then i call this how?
if (msg.toLowerCase().contains("[entitylookup]")) {
In your onEnable method do new YourClass().registerFilter();
does it take every single message?
don't think so
cool thanks 👍
bro really just spoonfed me a whole porridge
and im not complaining
Not working???
private Result isLoggable(String msg) {
if (msg != null) {
if (msg.toLowerCase().contains(" warn]: [entitylookup]")) {
return Result.DENY;
}
}
return Result.NEUTRAL;
}
@Override
public void onEnable() {
// Plugin startup logic
plugin = this;
new Filter().registerFilter();
Filter is the name of the class
warn isnt actually IN the log
its just the message
so check if it contains
[entitylookup]
trying now
still appearing
private Result isLoggable(String msg) {
if (msg != null) {
if (msg.toLowerCase().contains("[entitylookup]")) {
return Result.DENY;
}
}
return Result.NEUTRAL;
}
package me.assailent.advancedboating.Utils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.filter.AbstractFilter;
import org.apache.logging.log4j.message.Message;
import org.bukkit.Bukkit;
public class Filter extends AbstractFilter {
imports and line of class
org.bukkit.Bukkit is unused
make it "Failed to remove entity"
will empty stacks always be a stack of air or will they be null
like if im using Inventory.getItem
ok
inve been lied to
is there no easy way to tell if an itemstack is empty?
is there seriously not a method for this
TAPER?
@EventHandler
public void onInventoryMove(InventoryMoveItemEvent event) {
Inventory source = event.getSource();
ItemStack transferredItem = event.getItem();
if (isHopperInventory(source)) {
if (transferredItem != null && isShulkerBox(transferredItem)) {
BlockStateMeta meta = (BlockStateMeta) transferredItem.getItemMeta();
if (meta != null && meta.getBlockState() instanceof ShulkerBox) {
ShulkerBox box = (ShulkerBox) meta.getBlockState();
for (ItemStack itemStack : box.getInventory().getContents()) {
if (itemStack != null) {
if (itemStack.getType() == Material.DIRT) {
Bukkit.broadcastMessage("Removed: " + itemStack);
itemStack.setAmount(0);
box.update();
Bukkit.broadcastMessage("It's air now!: " + itemStack);
}
}
}
}
}
}
}
private boolean isHopperInventory(Inventory inventory) {
return inventory.getHolder() instanceof org.bukkit.block.Hopper;
}
i know this looks shit, but why doesn't this update the shulkers inventory when moved from hopper, im losing my mind bc its not clearing it lmao
if .getItem(int) == null then its empty.
iirc
ohp cool
for (int i = 0; i < 27; i++) {
if (inventory.getItem(i) == null) {
ItemStack itemStack = ItemStacks.createItemStack(items.getConfigurationSection("empty_item"), p);
ItemMeta itemMetas = itemStack.getItemMeta();
itemMetas.getPersistentDataContainer().set(unclickable, PersistentDataType.BOOLEAN, true);
itemStack.setItemMeta(itemMetas);
inventory.setItem(i, itemStack);
}
}
is functional for me
yea idk
Inventory#getItem() return an ItemStack
so
ItemStack#equals(null);
whould work
my ide says it will always return true idk
intellij?
ya
cuz mine says its fine
if (inventory.getItem(i) == null)
it prefers it to be that
but
if (inventory.getItem(i).equals(null))
What is ADD equal to?
12
weird cuz it works for me in other spots
maybe intellij remaps it?
or its the java version
boat.getPersistentDataContainer().remove(keys.getEmpty());
boat.getPersistentDataContainer().remove(keys.getClaimedKey());
boat.getPersistentDataContainer().remove(keys.getNameKey());
boat.getPersistentDataContainer().remove(keys.getOwnerKey());
boat.getPersistentDataContainer().remove(keys.getStowedKey());
boat.getPersistentDataContainer().remove(keys.getIdKey());
Is this syntax wrong or something
because they dont seem to be getting removed?
boat?
Entity boat;
sanity is lost
can u quickly add java after the three `'s
gotchya
literally i got everything my only problem is basically removing the item or really accessing the actual shulker inventory
idk why it's not removing anything 🤷♂️
i'd just get the inventory data and clear that
or just copy it and drop the inventory
well i was originally doing that, but im doing an item to test it now
it just wont update the inventory when it leaves the hopper/basically at the end of the event
originally was doing box.getInventory().clear(); and it just wasn't working
the issue is ghosting. player.updateInventory(); works but IDEA isn't happy. 'updateInventory()' is marked unstable with @ApiStatus.Internal
?jira
can you convert PDC to a byte array
I don't see it implementing serializable so I guess not?
I'm making a boat stow/claiming plugin
Stowing serializes the boat as string and stores it in an SQL database then removes it.
When the boat is unloaded by the server
(Or unaccessable from World#getEntitiesByClass(Boat.class) )
I want the boat to be automatically stowed.
@EventHandler
private void stowOnUnload(EntitiesUnloadEvent e) {
if (e.getEntities().isEmpty()) {
return;
}
for (Entity entity : e.getEntities()) {
if (!(entity instanceof Boat || entity instanceof ChestBoat)) {
continue;
}
if (entity.getPersistentDataContainer().get(keys.getClaimedKey(), PersistentDataType.STRING) == null) {
continue;
}
boatUtilities.Stow(Bukkit.getPlayer(entity.getPersistentDataContainer().get(keys.getClaimedKey(), PersistentDataType.STRING)), entity.getPersistentDataContainer().get(keys.getIdKey(), PersistentDataType.INTEGER));
}
}
that is my code but it fails tow ork.
to work*
hmm what does not work, did you try to debug through?
make some temp vars from the pdc, this last line is hard to read.
also, Stow is probably a function and if you're trying to follow the conventions it should strat with s
Are you storing the "owner" by player name ? If so, don't. Those change, use player UUID instead.
seems like it just doesnt attempt it considering there are no errors
or messages sent to the player
its uuid as string
Bukkit.getPlayer(String uuid)
iirc
nvm thats not how it works
converting String to uuid then running that
yeah.. no
Have you registered the listener ?
Try putting some printouts in the method
Yea i forgot this. added it and it worked im so fucking stupid sometimes
someone please add it so we can getPlayer(@NotNull String uuid)
no, that would clearly conflict
just convert string to UUID, it's just one call
getPlayerFromUuid()
but am lazy
. . .
bru-
lmfao
UUID.fromString(...) is too hard to write ?
yes
especially because my calls r already long and im making mess spaghetti code for testing
line from testing
Player p = Bukkit.getPlayer(UUID.fromString(entity.getPersistentDataContainer().get(keys.getClaimedKey(), PersistentDataType.STRING)));
as I said, make variables
thats one of the small lines
call it player, not p -> use descriptive names
split it the fuck up then
UUID playerUUID = ...;
and then get the player.
Long one from old testing (just seeing if the checks would function
if (entity.getPersistentDataContainer().has(keys.getClaimedKey()) && Objects.equals(entity.getPersistentDataContainer().get(keys.getClaimedKey(), PersistentDataType.STRING), p.getUniqueId().toString())) {
nah cuz its always p so its fine
i have descriptive names for most things
except
players
events
exceptions
sure, your code
But it is not descriptive
People have been yelled at for using e for events
(totally not me nu-uh)
player = p
events = e
exceptions = ex
yea e is usually exceptions im prtty sure
"There are only two hard things in Computer Science: cache invalidation and naming things."
that'd be conflicting with getPlayer(String name)
why not just pass an UUID instead
can we add to the quote with "and not being lazy"
and the hard disk
it got "hard" in its name
"There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors."
why does everyone ignore the HARD disks
"There are only three hard things in Computer Science: cache invalidation, naming things and HARD disks" - mfnalex
thank you!
"There are only three hard things in Computer Science: cache invalidation, naming things, off-by-one errors and HARD disks"
-steve6472
There, hopefully includes everything.
you have to also put my quote there too
"There are only three hard things in Computer Science: cache invalidation, naming things, off-by-one errors and HARD disks"
~~ mnalex
~~ -steve6472
XD
stupid discord breaks wikipedia's ~~~~ quote formatting
result: a baby?
yeye, im dum
IIRC unsing normal bash formatting int can also properly display all color codes
discord's new font for code formatting made me confused a bit
how id it prevoiously look? I'm on canary on both mac and windows and haven't noticed a new font
it didnt even change wdum
The gasslight is real
can someone show a before/after pic?
to me it still looks like this on both mac and windows
Sure, one moment
There you go
^nothing changed
what's the difference between Chunk#load and Chunk#setForceLoaded
load loads it right now and then... it might unloaded anytime again
setForceLoaded makes it kept loaded
declaration: package: org.bukkit, interface: Chunk
oo
it's like setForceLoaded but different plugins can "add to it", the nit only gets get unloaded when all other plugins have removed their chunk ticket again too
good shit
try {
p.playSound(p.getLocation(), Sound.valueOf(soundNms), volume, pitch);
} catch (IllegalArgumentException e) {
Bukkit.getLogger().warning("Sound " + soundNms + " does not exist!");
}
returns
[20:49:40 WARN]: Sound entity.allay.item_taken does not exist!
[20:49:40 WARN]: Sound block.enchantment_table.use does not exist!
soundNms = entity.allay.item_taken
and
block.enchantment_table.use
which both exist with /playsound
valueOf matches an Enum constant with a String. This only works if the String is identical to the Enum value.
How do i get the Sound Enum from a minecraft style string?
So like with the command
/playsound block.enchantment_table.use
how do i get
BLOCK_ENCHANTMENT_TABLE_USE
from
block.enchantment_table.use
Those keys are used in registries. You need to construct a NamespacedKey and get the Sound from the sound registry.
NamespacedKey soundKey = NamespacedKey.minecraft(soundName);
Sound sound = Registry.SOUNDS.get(soundKey);
ohh gotchu
does NamespacedKey.minecraft(soundName) return an error if the sound name isnt an actaul sound name
or is it the Register.SOUNDS.get(soundKey)
The registry will return null in that case
Set<Chunk> chunks = new HashSet<>();
int minX = Math.min(location1.getBlockX(), location2.getBlockX());
int maxX = Math.max(location1.getBlockX(), location2.getBlockX());
int minZ = Math.min(location1.getBlockZ(), location2.getBlockZ());
int maxZ = Math.max(location1.getBlockZ(), location2.getBlockZ());
for (int x = minX; x < maxX; x++) {
for (int z = minZ; z < maxZ; z++) {
Chunk chunk = new Location(location1.getWorld(), x, 0, z).getChunk();
chunk.addPluginChunkTicket(this);
chunks.add(chunk);
}
}```
this aint no work
Is there any good way of removing an entity when it is unloaded from the world? I tried removing on EntitiesUnloadEvent but for some reason EntitiesUnloadEvent#entities doesn't contain all the entities in the unloaded chunk?
no, you can create namespaces from arbitrary names
yes, that will return null instead, as the sausage said
I don't think setVelocity works for "player-controlled" entities (= players)
It should
is the player maybe a passenger of another entity or sth
You are essentially adding 256 chunk tickets per chunk with this. The X and Z of a chunk are vastly different thatn the X and Z of a Block.
A chunk contains 16x16 blocks, each block having a different X and Z while the chunk has the exact same X and Z still.
You can get the Chunks between two locations using a BoundingBox and my new World method: 😊
public void loadChunksBetween(Location locA, Location locB) {
World world = locA.getWorld();
BoundingBox box = BoundingBox.of(locA, locB);
world.getIntersectingChunks(box).forEach(chunk -> {
});
}
Or you can manually calculate them using
public void loadChunksBetween(Location locA, Location locB) {
int minX = Math.min(locA.getBlockX(), locB.getBlockX()) >> 4;
int maxX = Math.max(locA.getBlockX(), locB.getBlockX()) >> 4;
int minZ = Math.min(locA.getBlockZ(), locB.getBlockZ()) >> 4;
int maxZ = Math.max(locA.getBlockZ(), locB.getBlockZ()) >> 4;
World world = locA.getWorld();
for (int x = minX; x <= maxX; x += 16) {
for (int z = minZ; z <= maxZ; z += 16) {
Chunk chunk = world.getChunkAt(x, z);
}
}
}
The >> 4 is equivalent to / 16
that doesn't matter
that'd only lead to the Vector beeing 0,1,0 instead of 0,5,0
ic
to me the code looks good and should work
Add a debug statement and check if this method is even called. This should launch the player way up into the sky
this
5 = 5 meters per second squared= should be like 50 blocks high after a few secs lol
maybe he was trying it on an actual entity instead of the player then it'd matter
Yes it does got called but not launch
Try lower values
if i have a loaded chunk with no players in it and this animation is playing then it always returns the dying mob
if that doesn't make sense i basically killed the mob and instantly did /suicide and getting the nearest entity to that location returns the dying mob (the chunk has a ticket)
I'm not really understanding what the issue/question is
i suck at explaining
basically spawning mobs in ticketed chunks that are supposed to not be loaded (aka have no players) doesn't really spawn them
also if a ticketed chunk has a dying mob and the chunk has no players then the dying mob never disappears and getting nearest entity at the dying mob's location returns the dying mob
i found Chunk#isEntitiesLoaded() this might be doing something
Saving lists in persistent data type?
PersistentDataType.LIST
Yea but what does this store to?
Likst
String example = entity.getPersistentDataContainer().get(keys.getExampleKey, PersistentDataType.STRING)
what type does it return?
a list is a list of objects iirc
cool
this returns the string value of that key in the persistent data container
yes
yea
thats what its meant to do
isnt it
before i set it
entity.getPersistentDataContainter().set(keys.getExampleKey, PersistentDataType.STRING, "wahtever")
what r u trying to do?
So basically its a boat upgrade plugin
so this would be where the boat stores what upgrades it has
(it has to be stored on the entity)
ic
if all upgrades r the same but some boats cant be upgraded to a specific level, for example boat 1 can be upgraded 3 times but boat 2 can be upgraded 5 times then just store the upgraded boat stats and save how many times that boat can be upgraded in the pdc
I would recommend implementing a custom PersistentDataType<BoatData, T> which stores the entire object
at once, instead of tinkering with the default PDC types which are mainly used for trivial single values.
boatdata is a custom class that u make
thats what i was asking :)
But then im assuming the boat data class would have getters in it or???
I assumed that you have a structure which loads your data from a PDC into a proper class and then stores it in a manager.
Eg
public class CustomBoatManager {
private final Map<UUID, BoatData> liveBoatData;
}
When a boat is spawned, you load its data from a PDC into a BoatData instance and add it to the Manager with the Boats UUID.
Then when its unloaded, you remove the BoatData from the Manager and store it back into the PDC of the Boat.
No
basically all the data from the boats when its spawned is stored directly in PDC
and then it gets serialized into a string when despawned and saved to a databse
spawning it just deserializes that string and makes an exact carbon copy
You should prefer concrete class implementations over tinkering with random data in PDCs or Config files
Right but how would I do that?
PDC = PersistentDataContainer
It should be used as a persistent medium where possible.
If you use a Database already, then the PDC is kinda useless to you.
No because the way the database works.
Basically the database is just a table
player | boat1 string | boat2 string | boat3 string
where boat(number) string is the serialization of the entity
the db is only storing the entity
no other data
(This is so players can easily trade spawned boats)

You need more tables:
For your players
| UUID | BoatID | BoatID | ...
| UUID | BoatID | BoatID | ...
| UUID | BoatID | BoatID | ...
Then for the boats:
| Boat ID | BoatData |
| Boat ID | BoatData |
| Boat ID | BoatData |
Then you can simply move the BoatID between players.
not a thing?
What do you mean by that? What is not a thing.
I hate sql but this does make sense
?pdc
It was...
oh the bot died
nvm bot is just ded
Nope, you get omega banned now for writing in this channel. This channel is meant to be empty.
But then ... how do i make uuids????
that seems like more pain to me
than whatever tf it is i got going on.
bot dead
What do you mean by "make UUIDs"
For the players you use their UUID and for Boats you can use their UUID. They both already have an assigned UUID.
F
💀
Least incorrect information from spigot discord 💀
i have given worse advices here, trust me
Right and then i just save boatdata as a hashmap
?
wait sql supports hashmap or no
no
😭
serialize hashmap as string?
then deserialize it on usage?
What hashmap?
for boatdata
The map never gets serialized
U can store directly?
Only the values in your map
can i put a pdc on an entity too? or just for itemstack ?
Yes you can
don't abuse it before its too late and @lost matrix convinces u to refactor ur whole plugin
well if he saw my plugin he would obliterate me out of the server
i'd get banned from Spigot itself
same but he is seeing it
| Assailent (Player) | 141490129414901490 (Boat uuid) | ...
then in boat table
|14141491241840 (boat uuid | ????? | ...
waht goes in ????
Here is every class which has a PDC with the most important ones marked
ok thank you, now i gotta find out how xd. Is the spigot javadoc site enough to understand what it is and its implemenation on the code? or is a tutorial needed?
blud forgot itemmeta
Player table:
| 605c45af-060f... (Player UUID) | 0be40c9b-84c2... (Boat UUID) |
Boat data table:
| 0be40c9b-84c2... (Boat UUID) | {x: 10, y: 10 ...} (Serialized Boat Data) |
Thats what i mean the boat data is a hashmap right?
oh wait
ur asying
just get the data off of the physical boat
natively, no
and AbstractHorses :3 it's where I keep my banking information
stored in an AbstractHorses' PDC
honestly probably safer than most crypto currencies
true
I'm not storing the hyatatjaf. I'm storing custom data onto the boat
Is the abstract horse invincible tho ?
until he accidentally pushes toGit and all AI includes it in auto complete
Ofc, its abstract
lmfao real
if you somehow manage to acquire an ABstractHOrse instance that's not instance of anything else, it'd just throw NoSuchMethodError or whatever if you wanna damge it
lmao
it's like Thorns, but in code
"you wanna damage me bro? Nah, your code will fail instead"
IIRC not even kotlin allows constructing instances of abstract classes or interfaces unless ofc you just make up an anon class
but the anon class would have to override all abstract methods so that obv doesnt count
Is it possible to store a bucket runnable or lambda specific behavior (the run method)
why
?xy
huh
seems the bot is dead 😭
just store the lambda in a variable? lol
or just create a seperate function
i don't understand what they are trying to do here
Hold on I'm thinking
😔
hello. im trying to make a system that would allow players to open shulker boxes in their inventory without placing them. it works and items get put into shulker boxes, however after I open a shulker like that once, I have a visual bug that my inventory doesn't get updated when I pickup items from ground. but if i open a shulker like that again, the inventory gets updated. how can i fix that?
code: https://pastebin.com/tw9T12kW
I have a gui which let's me "code" in game. I am using lambas (consumer, bukkitrunnable, function) to store the behavior, I want to persist it past restarts so now I'm looking for a way to do that
The behavior of the lambda
you need a config/db for that
i don't quite understand
if you parse your lambda from a set of instructions, save the instructions and parse them on startup
^^
Quick showcase of a simple anti-cheat I made (still working on it)
(I've never used spigot before so it took me about 6 hours because I didn't wanna learn it lol)
I’ve never used or even learned Java,
So I feel like learning it by myself (no I didn’t to a tutorial idk I can’t. I haven’t learned any of the languages, I’m self taught lmao) in less than prolly 3 hours is pretty good
The reach is a little bit far because it only counts per block reach when the player could be slightly farther on a block and get falsely flagged
Basically everything besides inventory movement is just casting a ray from the players eyes and seeing if it hits the target
That's pretty nice
Ty ❤️❤️❤️ I was waiting for someone to reply lol
I know 😭 I was watching the video
lol
Also, there is a limited reach for survival/creative
with some extra to account for ping
Wdym
i.e. the server has a max reach, with a tiny bit of extra to account for lag
Ohh yeah lol
Is it configurable?
Idk that was a dumb question
hardcoded iirc
Yeah but isn’t there a new command or something to change that?
ah yes
I don’t keep up with updates much lol
Ah so I should probably make it check for the servers max reach
But it has a config
I forgot to show it tho
get the attribute of the player and use that
But it’s like
Ya
actions:
Reach:
- “sendMessage: Potential Cheating”
Something like that
Actually almost exactly like that
Well I’m on vacation right now
lol
So I’ll cya!
H
I
T
how to get persistent data container value of key:"x"
?pdc
The bots still down
One seck d
i have seen this post somehting like 17 times
Man you should read it this time around it teaches you everything you need to know about pdc
you are right. thank you, i'm gonna check again
can you \n when you're sending a chat message?
Idk try and see maybe??
Aldo it's /n btw
i'm trying to save myself having to compile the entire plugin and test it to see if it worked
you could just give me a yes or no?
I'd lean towards no but I'd say their is a possibility
thank you
You can not. Btw just double checked
alr
lol
lmao
make it so you can do that then!
how can i use raycast to damage all entities in the player's direction upto 10 blocks?
Create multiple rays
When the first ray hits, create a new ray that ignored the hit entity
and keeps going until the next one
Does # Text work in a resource's description? (to make the text larger, like in github)
is there a way to add like an int value to a item stack which doesnt change the appearce of the item but it can be read by my code ?
PDC
persistant data container ?
Yee
itemstack.getpdc.set(thatkey,type,value);
or will it save to the item meta
damn its been like 30 mins since enabling 2fa yet im still getting this button
?pdc
?pdc
Ok guess I’ll go fuck myself
rip cafebabe 😢
Spigot bot died ig
Anyways think of pdc as basically a container of the items meta
May I ask what people need to move mobs for? Not that it’s a bad project or anything, just curious
Same reason you want to move builds, maybe a player ingame asked you to move a mob of theirs, or maybe you're a builder and you want to move an armour stand from one location to another without remaking it
Hi
hi.
Ty lord tuaasn!
Idk why ?pdc giving me issues 😦
Hi guys, could anyone help me? I’m making a Hover Username plugin and I would need help in TextComponents and mini messages
Fair enough, I hadn’t considered those
CafeBabe went to the hospital today >:
!ask
rip the bot died
AHHAA
Wdym by hover username? Ie: (hoverable) {PlayerName} {prefix} >>> {message}
Yea the username
I don’t have prefixes nor suffixes
Just the username
U put ur mouse on top of a player’s username and u see some info about the player
That’s what I want to do with player.hasPermission
uhhhh
iirc then you're going to intercept the chat event, and manipulate it based on the permission
intercept the chat event
so if player.hasPermission("x") -> replace their message with what you want, ie: textComponent for the username to make it hoverable, then just put the rest of their message
you'll have to build the textcomponent to do what you want
but hoverables aren't that bad
No place an hoverMessage
Yes but it does not need to replace anything
You have to manipulate the message in order to make the username with a hoverable attached to it
The username must be the same
the actual message the player sends doesnt change rather the format if you will
It dosnt need to change
^ here’s the code
the username content remains the same, the component is replaced to an hoverable
^
How do I do that? If I may ask
Ok but in the example
They show it on a message
Not on an actual username
let's go adventure bukkit
true
Today we look at the Chat Component API. If you have any suggestions for future topics let me know in the comments! If you have any questions or issues feel free to ask me for help in the comments or in my discord server. 99% of the time the answer is one Google search away.
.
Join my discord: https://discord.gg/UMUrJZASXJ
.
Helpful Links:
Chat ...
watch this
Already saw it + same situation
It’s on a message
Not on username
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String playerName = player.getName();
String message = event.getMessage();
// Create a TextComponent for the player's username
TextComponent usernameComponent = new TextComponent(playerName);
usernameComponent.setColor(ChatColor.AQUA);
usernameComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent("Click to view player information")}));
// Create a TextComponent for the message
TextComponent messageComponent = new TextComponent(": " + message);
messageComponent.setColor(ChatColor.WHITE);
// Combine both components
usernameComponent.addExtra(messageComponent);
// Send the chat message
event.setCancelled(true); // Cancel original message event
getServer().broadcast(usernameComponent);
}```
This may be ai generated but it's uh followable... there are some things that I would do differently, but from what I see this should work fine
So, I should take out the TextComponent part right
no, the hoverable is a part of that
The textComponent is how you're going to define the hoverable on the {userName}
it's doing exactly what the example code is
I don’t really know how to implement it into my code
Bc it’s kinda different than mine
username isnt an object its a string retrieved from player.getName(); method
I don’t have both of them in my code
Username you can get from the event
since you have the player object, you just player.getname
.
I have Player player = event.getPlayer();
man
I should change it into event getname right?
right so now player.getName, retrieves the name of the player
no
You have the player object
you just need a new line that extracts the name
ie:
So I should change it into player.getname?
String someName = player.getName;
Player player = event.getPlayer();
String playerName = player.getName();```
If it needs to be constant within that method yes, which i believe it does in your case
just look at this
Otherwise when you already have the player object, most times you can just include player.getName, instead of making a new string object. But in your case I think the playerName should be a constant within the method
Ok I added it
you can even just String playerName = event.getPlayer().getName(); if you wont use the player object again
which is not the case
Usually you'll want the player object before you derive the name but thats more dependent on the event used
But I’ll just stick with this
thats good
That will be fine
Ok, now we need to add the actual textcomponent
Just follow the snippet, cuz I mean it's not bad just uh different
also @polar forge why are you uploading a new resource every time you make a new update instead of updating the current one?
I didn’t know u could do that
It'd be pretty dumb if you couldn't haha, imagine needing to upload a new source every patch/update 💀
Yea kinda annoying tbh
But let’s go further
So
I now need to add the textcomponent
to test the code
I’ll just follow the Example of ChatGpT
he then uses pluginmanager to download it from spigot and test the code
Yea
i wouldnt have the patience
For what?
doing all this each time i update a line of my code
spigot isnt a version control platform
you could just build it and drag the jar in your server's plugins folder
instead of uploading each time
idk how md_5 feels about his storage being used like this 😭
Quello che ho fatto tipo ieri?
That’s what I did yesterday when u told me
when you change the code you click on the green run button on intellij idea
So, it’s not something I’m not totally doing
it will build a new jar, you go to the target folder and get the compiled jar, move it to the local server
hey i copied an tutorial to make an 2nd config but my problem is that the 2nd config loads but is empty here are the code:
So do I need to add the textcomponent to the end of the code or at the beginning?
I think at the end
what
It’s related to my problem
prob i can help what it the problem
Hoverable Username
If u put ur mouse on top of an username u would get some info of the username
HoverText/hovermessages
do you think u can help me?
:/
Create a text component, usep player#spigot().sendMessage()
can you help me too
bot dead
I already have a code and I miss the textcomponent, https://paste.md-5.net/dazusuyita.java
The bot died?
?paste
Beuhhh
"bot dead"
how can i use it
https://paste.md-5.net @clear elm
but here is the code
paste it dont send it like that
^^^
how can i send it from there
Sec egitto
Sure Bad, take ur time
click on the link and paste it
Then press save and send the link
Which is the main class and which the class?
The first one I would guess is a main class
main the first class the 2nd
yea
Sorry @polar forge taking a bit longer, broke my os
Np
Take ur time
Always surprises me how easily I can break things
lol
Idk assaulted my fstab
oh unix based os
Noice
component = new TextComponent("ERROR - Missing Partition");
component.setHoverEvent(new HoverEvent(HoverEvent.Action.-, TextComponent.fromLegacyText("Text")))
player.spigot().sendMessage(component)
Theres the basic jist of it
Do I need to replace “Text” with something?
Yea, with your Text
But my text differs from what ur permission is
wdym?
TextComponent comp = new TextComponent(event.getMessage());
String hoverMessage = ChatColor.WHITE + "User";
if (player.hasPermission("moderator")) {
hoverMessage = ChatColor.AQUA + "Moderator";
} else if (player.hasPermission("admin")) {
hoverMessage = ChatColor.RED + "Administrator";
} else if (player.hasPermission("wood")) {
hoverMessage = ChatColor.YELLOW + "Wood Kit";
} else if (player.hasPermission("wood-mod")) {
hoverMessage = ChatColor.AQUA + "Moderator";
} else if (player.hasPermission("stone")) {
hoverMessage = ChatColor.YELLOW + "Stone Kit";
} else if (player.hasPermission("stone-mod")) {
hoverMessage = ChatColor.AQUA + "Moderator";
}
comp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hoverMessage)));
player.spigot().sendMessage(comp);
please use switch statements🙏
This should work? I’ll try it out and keep u updated
Just insterted my code into his, hes the one that use if else xD
ah lol
don't🙏
Is there a reason?
readability
Oh
but honestly i prefer kotlin when
