#help-development
1 messages · Page 2156 of 1
I've got a question, is World#getTime() saved in tick format? I'm assuming it is however whenever I'm doing the math to convert the ticks to time I am getting something different from EssentialsX
afaik no
its saved in minecraft time. 24000 is max
public class CleanupExample {
public static void main(String[] args) throws IOException {
@Cleanup InputStream in = new FileInputStream(args[0]);
@Cleanup OutputStream out = new FileOutputStream(args[1]);
byte[] bytes = new byte[10000];
while (true) {
int cursor = in.read(bytes);
if (cursor == -1) break;
out.write(bytes, 0, cursor);
}
}
}
it returns value which you input inside vanilla /time set command
I just went with creating different worlds for each team.
Although i'm running into a little issue here.
You could use the PlayerItemConsumeEvent
it follows 24 hour format but multiplied by 1000
Into the bukkit.yml file, there's a setting that allows you to change the directory of where the world will be generated, but it does not work for some reason.
its for this thing, theres no point to use a try with resources there
and i found the suppresswarning string, its just 'resource'
wow... thats helpful and I feel stupid for not getting that sooner 🤦♂️
Then just bridge the events by using a data structure. You just need to find out which one is fired first.
what is max durability? is it 1?
Depends on the ItemStack...
Well... its an integer type so that would be quite weird
short
In the context of resource packs (when speaking of predicates for example) then 1.0 is the max value.
ow 7smile7, i might indeed want to write implementations for the ConfigSupplier
i can just put them in the enum file
Yeah you can just do
H2("something", new H2ConfigSupplier())
Where H2ConfigSupplier implements ConfigSupplier
is there any way to create enchant from string?
Wait so your enum has a constructor (String, Supplier<ConfigSupplier>) ?
Big meh
no no no (String, ConfigSupplier)
i meant to store suppliers to the actual configsupplier object
You would want to create a String that represents a NamespacedKey
too much supplier in that sentence tbh
if i want to check if there is air at some coordinates is this the fastest way to do it: loc.getBlock().getBlockData().getMaterial() == Material.AIR?
is there no method just like isEmpty or something
A Block is never empty. Every single Block in a chunk from 0,0,0 to 15,255,15 has a value.
You simply call
if(block.getType().isAir()) {
}
:v
getBlock().getType().isAir()
thank you
public static final Enchantment MENDING = new EnchantmentWrapper("mending"); wait am i can't do sth ilke this?
try-with-resources is life
This literally just calls
Enchantment.getByKey(NamespacedKey.minecraft("mending"))
internally. It also doesnt really make much sense because you can get all vanilla enchantments
from the Enchantment class
Enchantment.MENDING
no fancy annotation bs for closing
so i can call EnchantmentWarpper ?
Yes
Material#name i'd say
material.toString()
Wait. name() is the clean solution. Doesnt make a diff here but usually you want to use name() for dev purposes and toString for readable representations.
what is toString for an enum even returning? as those are just constants
when its not overridden
the same as name()
ah
public static void createWorld(Player p, String name){
WorldCreator creator = WorldCreator.name(name);
p.sendMessage("World creation started.");
new BukkitRunnable() {
@Override
public void run() {
creator.environment(World.Environment.NORMAL);
creator.type(WorldType.NORMAL);
creator.createWorld();
}
}.runTaskAsynchronously(GioxMC.getPlugin());
Bukkit.createWorld(creator);
p.sendMessage("World creation finished.");
}```
This is the current code that I use to generate worlds, and for some reason, I cannot run it async, is there a particular way to do it or ?
I tried running .createWorld(creator) async, but it errors me.
You cant create a world async. I had the same problem a few days ago. Best i could do is lower the loading time to 30ms by disabling
loading the spawn chunks.
anyways goodnight
Could you help me to do the same ?
And also, does it hit the tps hard ?
Depends on how much user traffic you have and if you cache worlds for a while etc.
Well lets say you have 70 players, about 60 worlds need to be loaded.
1 world per player 1 island per player
Is it skyblock?
Yeap.
I think u should use slimeworlds then
huh?
oh same as what hypixel uses
Is it possible to disable the "Saved Inventory" feature?
Yeah
do you mean keep inventory?
So I can just use their api and implement it into my plugin ?
No, you can set up a hotbar in singleplayer, and load it instantly if you're in creative on any other server.
well disabling it completely from the server afaik is not possible, but what you can do is to cancel those actions, just like inventory click events and such
but since its creative inventory feature
i doubt that it even possible since many things on creative inventories are being handled by client
its probs possible
but im not sure
since items are being added to the player's inventory, server should get info about the player's inventory, thus restoring the previous inventory state should be possible, but im not sure if this exists inside bukkit api or you need to implement this check yourself
I have a playerinteractevent and i only want it to fire on right clicks how do i do that
Is there anything that I can do to load a world async and not have as much performance impact ?
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:220) ~[guava-31.0.1-jre.jar:?]
at org.bukkit.NamespacedKey.<init>(NamespacedKey.java:50) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.NamespacedKey.minecraft(NamespacedKey.java:143) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.enchantments.EnchantmentWrapper.<init>(EnchantmentWrapper.java:12) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at me.placek.blockeconomy.shops.ShopItem.toItemStack(ShopItem.java:38) ~[BlockEconomy.jar:?]
at me.placek.blockeconomy.commands.ItemCreationTest.onCommand(ItemCreationTest.java:18) ~[BlockEconomy.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]``` why am i getting that error?
public ShopItem(ItemStack item) {
count = item.getAmount();
name = item.getItemMeta().getDisplayName();
material = item.getType().toString();
enchants = new HashMap<>();
if(!item.getItemMeta().getEnchants().isEmpty()) {
for(Map.Entry<Enchantment, Integer> entry : item.getItemMeta().getEnchants().entrySet()) {
enchants.put(entry.getKey().toString(), entry.getValue());
}
}
}
int count;
String name;
String material;
Map<String, Integer> enchants;
public ItemStack toItemStack() {
ItemStack item = new ItemStack(Material.matchMaterial(material), count);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
if(!enchants.isEmpty()) {
for(Map.Entry<String, Integer> entry : enchants.entrySet()) {
meta.addEnchant(new EnchantmentWrapper(entry.getKey()), entry.getValue(), false);
}
}
return item;
}
}``` code
Line 38
your key is invalid it says it
Caused by: java.lang.IllegalArgumentException: Invalid key. Must be [a-z0-9/._-]: Enchantment[minecraft:blast_protection, PROTECTION_EXPLOSIONS]
but i'm getting these keys from itemStack before
so how could i convert string to enchant?
guys how do i detect if a playerinteractevent was a right click or left click?
e.getAction()
Returns an enum describing what the action was
Right/left click on a block/air
Hi, I'm very new to spigot plugins. I'm trying to create a PAPI expansion. What am I missing?
https://i.ibb.co/QNgzPJG/image.png
thank you redempt
You're missing PAPI
Are you using maven/gradle?
maven
Do you have placeholder api declared as a dependency via your pom.xml
i have it as dep in plugin.yml
That's not enough
what do i need to do?
You need to declare it as a dependency in your pom.xml
Declaring it in your plugin.yml will make spigot give an error if your plugin is on the server without the dependency
Declaring it in your pom.xml is what actually allows you to link your code against it though
thanks, I have found the xml i need to add
<repositories>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>{VERSION}</version>
<scope>provided</scope>
</dependency>
</dependencies>
did getkey in enchantment returns key with both string values?
i added that but I still get java: package me.clip.placeholderapi.expansion does not exist
I changed it a while ago lol
which seems to be the latest
Why lua?
i made it
except for just adding the repository and dependency in pom.xml, is there anything else I need to do?
Refresh your project.
thanks, that worked
and now i converted it into json
Bukkit is an API. You can spawn particles with #World.spawnParticle() method afaik, but if you want some complex patterns and you don't know shit about trigonometry and calculus, you'll need to research it or use someone else's work.
I decided to do it in 1 world, so when players create an island, it makes it 500 blocks away from the last made island.
ah ok
- Saving on memory.
- Reduces tps drops by alot when creating a player island.
yeah that's a good solution as well
Although I'll have to look on how to make it so they cannot leave the island, and cannot destroy other people's island.
I though of using the PlayerMoveEvent
But wouldn't it be too laggy ?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
If not, you can use this ^
you learnt java already?
lol
^
@dense falcon the best way is to read the docs, they explain it better than anyone can
yeah he knows java
his forge mods are clean
Uh what?
but DO YOU
i know c better than you
@dense falcon https://hub.spigotmc.org/javadocs/bukkit/
package index
I'd suggest you to start just by looking around, then start by doing small projects.
A tuto will be better :> please 🐺
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
youtube tutorials on spigot are assfluid
There isn't really any good tutorials that I know.
just go through the wiki
Yeah.
they are better than any youtube tutorial
Are what?
I know but, the docs is not very... good for me.
wdym ?????
I am fond of learning by using a tuto and no a doc.
if you know java then docs are fine
if you can learn forge then you can do spigot
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
First one is the best for starters.
I am learning forge by seeing tuto and no the doc.
And know a oop does not means I know read another doc.
You learn one javadoc you learn them all. Learning javadoc is key to learning spigot or you'll be stuck asking basic questions for the rest of your life
The spigot doc is good but for example a tuto is better than doc for some reasons: more clearer for a lot of developer, a specific goal.
But I did not learn any programming langage with the doc.
my guy he knows java
he knows the forge api
I've always got used to tutorials but Spigot's doc isn't the worst but sometimes it's nonsense!
You should start making projects. That's the best way to learn. Tutorials are on the forums for various more complex topics and 99% of the time the docs are the answer
In truth I manage to find myself there, it's just a question of precise objective...
The docs are mostly ask and ye shall find.
https://www.spigotmc.org/wiki/spigot-plugin-development/ thanks for the links because it will help me :).
as far as a I know, the forge API is 1000 times harder than spigot, so he'll have no trouble learning this.
my point exactly
Yeah forge has a higher learning curve and you need to know your way around java and the like. Spigot is easier and has a docs that actually exists
declaration: package: org.bukkit.event.player, class: AsyncPlayerPreLoginEvent
Ouch ouch ouch.
Program based name
?
ouch?
Ouch?
Nevermind 🤣.
Btw., why it is deprecated? https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerChatEvent.html
This event will fire from the main thread and allows the use of all of the Bukkit API, unlike the AsyncPlayerChatEvent.
Listening to this event forces chat to wait for the main thread which causes delays for chat. AsyncPlayerChatEvent is the encouraged alternative for thread safe implementations.
im trying to cause an effect on an entity for 15 seconds but i dont understand how to get the time
is it ticks or ?
ticks
Ticks.
is 1 tick 1 second
20 ticks is 1 sec.
name = item.getItemMeta().getDisplayName(); how could i get item name? this doesn't work.
please tell me thats not all of your code
me ?
thats gonna crash your server
count = item.getAmount();
name = item.getItemMeta().getDisplayName();
material = item.getType().toString();
enchants = new HashMap<>();
if(!item.getItemMeta().getEnchants().isEmpty()) {
for(Map.Entry<Enchantment, Integer> entry : item.getItemMeta().getEnchants().entrySet()) {
enchants.put(entry.getKey().getKey(), entry.getValue());
}
}
}```
why doesnt that work
guys i got one of those bugs lol
mu json created from this loks like this [{"shopItem":{"count":1,"name":"","material":"STONE_SWORD","enchants":{"minecraft:blast_protection":4}},"shopType":"sell","isAdmin":false,"id":"shopId","price":2,"shopOwnerId":"098cb022-6500-4fa5-acf4-e9a3d223d61b"}] that's why i know it's not working
any idea as to how i should count the ticks?
first time trying this
bukkitrunnable
the 'this looks like an easy fix' 132912303219058435 hours later: 'fucc'
maybe if you showed us the error we could actually help you
i was uploading it lopl
https://www.klgrth.io/paste/jjsvn it looks like a standard bad syntax yaml error right well no
interesting
yaml in a sec
?scheduling if you need resources
thx
io.github.turpcoding.easyreport.ReportCommand.onCommand(ReportCommand.java:62)
how can i get item name?
oh yeah mb 1 sec
mainClass.reloadConfig();``` it's just a reload
of the config.yml ofc
how can i check if two itemstacks are equal in material and name, but ignore the quantity
ItemStack#isSimilar()
event.getItem().setAmount(event.getAmount() - 1)?
Close, you would want to use ItemStack#getAmount() instead of Event#getAmount() as the latter does not exist.
Does anybody have any idea on how I would do a basic minecraft account link.
I have a webserver in nodejs all I wanna do is make a player click a link and get his account linked. I know how to code just need the logic behind it. Cause it doesnt make sense in my head.
Hey so I am having a weird issue with spigot buildtools, for some reason when I try to build a version below 1.14 I get this error: java.lang.RuntimeException: Error running command, return status !=0: [C:\Windows\system32\cmd.exe, /D, /C, sh, applyPatches.sh] at org.spigotmc.builder.Builder.runProcess0(Builder.java:973) at org.spigotmc.builder.Builder.runProcess(Builder.java:904) at org.spigotmc.builder.Builder.main(Builder.java:703) at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27) I know this error is on the buildtools website but I don't have a Linux system and I'm not running it from cmd, also I redownloaded buildtools and I am using java 1.8
declaration: package: org.bukkit.persistence, interface: PersistentDataHolder
I think you need java 16 or 17 to run build tools now.
Not for older versions, you still need java 8
I've tried with 16 and 17 too
Can you send the full log?
Is there anyway to lower the duration of a particle when spawning with PacketPlayOutWorldParticles? From what I read it looks like its hardcoded in the client but I wanted to ask to make sure
No the speed of which the particle moves, but the time till it disappears
hello, is there any way to code it so that, if right clicking with an item CONTAINING the word "blank", it does the action?
ty
So I just downloaded the latest buildtools and ran it with java 8. No issues.
Are you running it in a new directory or an existing one? Because you should always run it in a new directory.
Also, do you have Git installed?
You could use the PlayerInteractEvent, get the item and then name from the item, and use the name.contains(); method
ty
make sure to do null checks
It's an existing one, I hadn't thought of that but I haven't had problems in the past
at me.placek.blockeconomy.shops.ShopManager.getShopCount(ShopManager.java:28) ~[BlockEconomy.jar:?]
at me.placek.blockeconomy.commands.ShopCommand.onCommand(ShopCommand.java:54) ~[BlockEconomy.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]``` what is wrong with this code?
public void restore() throws IOException {
String path = "plugins" + File.separator + "BlockEconomy" + File.separator + "shops";
File shopFile = new File(path, "shops.json");
File shopPath = new File(path);
if(!shopFile.exists())
return;
if(shopFile.length() == 0)
return;
FileReader fileReader = new FileReader(shopFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
StringBuffer stringBuffer = new StringBuffer();
String line = null;
do {
line = bufferedReader.readLine();
if(line == null)
break;
stringBuffer.append(line);
} while(line != null);
shops = new Gson().fromJson(stringBuffer.toString(), shops.getClass());
Bukkit.getServer().getConsoleSender().sendMessage(BlockEconomy.getPrefix() + ChatColor.GREEN + "Załadowano sklepy.");
Bukkit.getServer().getConsoleSender().sendMessage(BlockEconomy.getPrefix() + ChatColor.WHITE + "Lista sklepów:" + shops);
}```
String playerId = player.getUniqueId().toString();
int shopCount = 0;
for(Shop shop : shops) {
if(shop.getShopOwnerId().equals(playerId))
shopCount++;
}
return shopCount;
}```
Its possible to set an armorstand the skin of a player?
And then try to put the armor-stand lying in the floor?
as if it were a corpse
nah u use entity players
like you're trying to duplicate the player on the floor
like that murder mystery game on hypixel?
Yes
In this episode of the Spigot MC Plugin series, I start a new plugin called Bodied. This plugin makes it so when a player dies, an NPC is spawned using NMS and is made to lay down and have no nametag. In the next parts of this plugin's development, I will show you how to put items in the body once the player dies, and if no one claims it after a...
Thanks
Can you execute console commands on clickable text?
You can make a proxy command type thing that just forces the console to run it
can someone help me with what appears to be a yaml syntax error
it looks fine to me
so I'm thinking of making a utility for guis and such but I don't know how I would put that in my other projects. my initial thought is to use something like jitpack then put the scope as system for the dependency. Any thoughts?
Any idea why this isn't working? I want to set the players health to 5 when they are a distance of 10 from an entity
Are you teleporting the entity/ does the entity teleport on it's own (e.g Shulkers, Enderman) ?
Do I need to check that?
I was just basing it off of where the player is
If you're just going to be using it locally you can setup a local repository and use it from that with maven and gradle probably
Well that code only fires on EntityTeleport, like the event implies

I wonder what I should change the event to tho
EntityMoveEvent, or if you know which entities you're checking for, use a Runnable.
Just all entity’s know general, so I’ll just use the EntityMoveEvent
Wait EntityMoveEvent doesn't exist nvm
oh lol respect
Runnable it is then, probably better way anyways.
let me try that
well I want other people to be able to use it too
Yeah JitPack would work, I use GitHub Packages albeit it's a pain in the ass. Other option if you have a VPS/Dedi is to setup a Nexus repo and host them yourself.
how would I go about doing it though
They all have guides for setting them up
that's not what I meant
like I'm creating a new paper project and it has the onEnable and onDisable which confuses me as the plugin I'm going to be using it in will have that as well
will that have conflicts if I have the scope as system
It shouldn't, since your APIs plugin.yml would never be found if it's shaded into another plugin.
Therefore they'd never be called by the server anyways. In my API I have an onEnable that does nothing just in case someone loads the API as a standalone.
so if I make a gui util how would my inventory click event be registered from there
Make them register your API with their Plugin instance
That worked, thanks for your help!
Actually I have another question lol
So im trying to create a plug in where it destroys every block that is touching the original block that is broken
but for some reaosn its only breaking the block to the right of it, not infront, to the left, below, above, or to the right
👀 that's some code
Lol
Are u trying to break the block or replace it tonair
The broken block isn't set to air until after all the listeners are executed
You can check if the event is cancelled
right
Or u can put (ignoreCancelled = true)
Next to @EventHandler
Also check the getRelative(BlockFace) method
For block
block.getRelative(BlockFace.UP).setType(Material.AIR);
why do I need to do that?
Also why do you get back the block at location one
Im telling Build Tools to run 1.8.4 but it outputs 1.8.8
any reason why it would change it.
You already have it by doing event.getBlock
The logs seem to start with 1.8.4 but then switch to 1.8.8
Why do you need 1.8.4 anyways
ah i see
dont need that param
Working on a few projects and just testing different versions
but it shouldnt just switch over
Hm let me try
smh the logs are too big
thank you for your help!
how
the inital version it finds is correct to 1.8.4 as u can check in the json api
Sec
Doesn't seem like it supports 1.8.4 for some reason.
1.8.8, 1.8.3, and 1.8 only
🤷♂️
yet 1.8.4 exist
Yeah I have no idea
Yeah, but change the URL to https://hub.spigotmc.org/versions/1.8.8.json lol
They're the same hashes. It's just a delegate.
No idea why some 1.8 versions aren't supported, but oh well I guess.
Generally testing on 1.8.8 should be good enough. Anyone running 1.8 should be using 1.8.8.
It may also be that 1.8.4 didn't have any server changes so it's effectively the same thing as testing on 1.8.3
@uneven fiber
because if it dosnt support it or just redirects to 1.8.8 then it shouldnt show
I guess, but it might as well try to correct it by automatically updating you then throwing an error I suppose
Just some design thing they decided to do.
--rev(top)
The version to build.
Requires a version argument.
Defaults to the latest available version.
Bruh
What
it will "revert" to the latest version of it
so 1.8.4 goes to 1.8.8
yk what I mean
Nah 1.8.4 goes to 1.8.8 because that's what the json is, it's just 1.8.8.
That default is referring to if you don't put a --rev argument.
ahh
but like if it says 1.8.4 it should be 1.8.4 not 1.8.8
if they dont support it then dont show it yk
always think of loops whenever youre writing the same code over and over
anyways ty for the help ill make some adjustments on my end
yeah
hi does anyone happen to have worked on papi b4?
on papi or with papi
with
i did
im trying to parse placeholders
mhm
using setPlaceholder(player, msg)
lol actually i was coding a for loop when i just checked discrod and saw your message
so is it fine to pass null for player ?
no
not possible
i read the docs but it does not state the purpose of player
like if i have a global broadcast that is independent of players what do i pass?
i never had to use it to do that
but i think it is
If you have a placeholder that doesn't require player then just throw whatever there as long as it's not null.
To broadcast just loop Bukkit#getOnlinePlayers and send the message
true. i think this approach is cleaner. Thanks!
i think null is safe
the method to apply placeholders has the player as nullable
oh it's nullable?
yeah
i think ill stick to iter all players since then the other player related placeholders will be available
u can also do that
follow the methods called in the return statment
its safe so its up to u
yep. thanks yall
How do I get X number of blocks around a player
like a invisble sphere around the player which returns all the blocks in it
I want to check if they have some light level and remove if they do (unless they are a light source) cuz LightAPI leaves some spots even tho i try to set it false
bounding box
if you have the opposing corners of a bounding box, you can easily create a loop to go through all the coords to get the blocks
this is what I get when I try to use jitpack with my utility
I don't know what I'm missing
I do see that is clearly has an error though
Read the report?
I have the error log
which is what this is from
⚠️ ERROR: No build artifacts found
Expected artifacts in: $HOME/.m2/repository/me/hapily/plugins/util/paper-plugin-util/1.0```
Do you have a build in your pom?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
this is what I've got
Wack. No idea. I don't use jitpack anymore due to the issues
any other suggestions for people who don't want to spend more than 30 minutes setting it up
/home/jitpack/build/src/main/java/me/hapily/plugins/util/paperpluginutil/menus/Menu.java:[4,18] cannot access org.bukkit.Bukkit
bad class file: /home/jitpack/.m2/repository/io/papermc/paper/paper-api/1.18.2-R0.1-SNAPSHOT/paper-api-1.18.2-R0.1-SNAPSHOT.jar(org/bukkit/Bukkit.class)
class file has wrong version 61.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
Well this also looks like an issue
yeah
both the same though
it looks like jitpack is on the wrong version? I'm not sure how to interpret that
Looks like jitpack has 17 since it says that the /home/jitpack class is 61 and that the base is 52 which is 8?
?paste your pom rq
Ohhh
Did you add a jitpack config so it compiles it for 17 too? Cause it defaults 8 afaik
could it be that this was 1.8 :troll:
I didn't do any config stuff
Yeah, try changing that
this is driving me nuts
I don't use jitpack for a good reason 
no way
i dont even think jitpack supports 17
i remember it took like 4 months for jitpack to support 16
Yeah just host your own™️
i h8 it
Gotta host it yourself so it's done right
Hey, so how would I go about getting an instance of the NMS item class from a bukkit item class without creating a copy?
there are some static CraftItemStack methods for that i believe
Yeah there is a method to convert. I don't remember
If I have a .yml that I want to load to hashmaps for each player on startup, how would I pull this off or at least read where to make this happen?
Example:
MYUUID1:
Null: 1
Foo: 0
Bar: 0
MYUUID2:
Null: 3
Foo: 2
Bar: 1
Plugin#getConfig().getValues()
if those are in your root path
Is there a way to dispatch a command without logging?
why would you want to issue a command with no logging?
I want to dispatch a command in my plugin without spamming the console, the reason I have to use a command is because I am trying to play a sound to a player and i need it to support modded sounds
Right now I'm using Bukkit.dispatchCommand with playsound
I tried that with a sound and I just got a null error, does that support modded sounds?
does exactly as the command playsound does
Yes but that creates a copy and I have to redefine my item
If the modded sounds are available in playsound they should be available in that
I'm guessing the modded sounds may use a namespacedKey style of naming though
Thats how most modded stuff used to work when I was using them
Oh wait i think i figured it out
Yeah i think that method will work
Thanks
Ok so this is weird
It works for playSound(string) but not stopSound(string)
When i use stopSound I just get a null error
What is null?
stopSound is a void. It has no return type
finally I got it working, sorry I was being dumb lol this is why I shouldn't be coding at 3 am
Hi. I want to create spawning a mob with custom name and hp! How to create a variable of that mob?
Ravager ravager = ..??
If i create something like this:
Entity spawnedPig = myWorld.spawnEntity(spawnLocation, EntityType.PIG);
Then i cant edit his health
How can I do that instead of sending the next action bar, it adds seconds to what is right now
this is anti logout
how can i check if a player has an item in their inventory without counting the player's off hand?
regular inventory object doesnt count off hand right?
would PlayerInventory.contains() count also the item in the off-hand?
i gues ye
how could i prevent that?
i would do if inv.contains(item) && !offhand.getItem().equals(item)
long time since i've worked with inventory stuff so forgive me that bad code
How can we make backups in databases like Redis but save part of the map.
Kind as soon as the player connects, it brings back part of the desired map.
probably you misunderstood... i wanted to check only if in the inventory (without counting the off-hand) there is an item, because in the off-hand there will always be that item (as i programmed like that)
tbh at this point ill just loop over the inventory slots that exclude the off hand slot
Hio, I am trying to build a 1.8 plugin and I set all of the encoding properties in my gradle build file to use UTF-8 but I still run into issues with UTF-8 characters being all ugly and buggy in chat.
compileJava {
options.encoding = "UTF-8"
}
javadoc {
options.encoding = "UTF-8"
}
processResources {
filteringCharset = "UTF-8"
}
}```
build.gradle.kts contains this
are your actual files saved in UTF-8?
My IntelliJ is using UTF-8 for the files.
Where are you seeing these odd encodings?
and you read that data from a config file?
Yes.
then your config file is not UTF-8
Startup parameters
if its not saved as UTF-8 before it will not be after compiling
Try to put -Dfile.encoding=UTF-8 before the -jar in your startup parameters.
Alright, I appreciate it.
That did the trick man, I appreciate it :)
No problem 😄
I got made a plugin when 1.17 was newest, are there any things I need to look out for if I wanna run it on 1.18?
Another question. I want to make a boss that drops a player items. But it drop to who it spawned by item. So its named Bos... of player "playername".
Now Im stuck pls help
if (e.getEntity().getType().equals(EntityType.RAVAGER)) {
ItemStack Beacon = new ItemStack(Material.PRISMARINE_SHARD, 30);
ItemMeta meta = Beacon.getItemMeta();
meta.setDisplayName("§dPLATYNA");
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
Beacon.setItemMeta(meta);
if (e.getEntity().getCustomName() != null && e.getEntity().getCustomName().startsWith("§l[BOSS]Duzy Swiniol gracza ")) {
Im stuck
}
}
}
}
Just try it on 1.18, but as far as I know no there isn't
Just tried and had some issues with location of dropping blocks but I don’t think it’s a version issue
Ty
what event is that?
Use ?pdc
EntityDeathEvent
ah you want to drop the item?
I somehow understand what he's trying to achieve.
Basically he only want to drop items to the player who spawned the entity.
declaration: package: org.bukkit, interface: World
no. to add it to eq. But not the Killer eq. The player that the mob name ends with
ill make a picture in paint for u:D
ugh i mean are you trying to only drop an item when someone killed a boss, if the player who killed it also spawned it?
Drop items only to the player who spawned boss, no matter who the killer is.
Directly add into player's inventory?
yeap
Store pdc to the entity with the player who spawned the entity name.
And then on EntityDeathEvent, check If the entity who died has the data, If so get the player name from the pdc and then add the item to the inventory.
?pdc
pdc means?
oh
persistent data container
ok ill check how to do it
how to check if item can be stacked? i mean how to check if it is a tool or sth.
declaration: package: org.bukkit.inventory, class: ItemStack
How works skyblock?
wdym
you load an island from a template for every player, and put them on it
then you allow them to tp to it
maybe make a hub
rest is up to you
I mean to save the island of a player.
Someone told me he is using Jedis.
Slime world manager?
Just data like a level, rank?
Can you get a player owning a PlayerInventory
redis is just meant to be a cache, you want a more long term storage like sql or something
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/PlayerInventory.html#getHolder() as in that?
declaration: package: org.bukkit.inventory, interface: PlayerInventory
I am on 1.17.1
It's probably the same
As a lot of people will be mad, going from min 1.16.5 to min 1.17.1, their pc's can't handle 1.17.1 o no
getHolder
(I am making fun of them fyi)
dont see a reason why it wouldnt be in 1.17.1
nope
nvm
it exists
Intelli just forgot to find it
https://helpch.at/docs/1.17.1/org/bukkit/inventory/PlayerInventory.html#getHolder() according to helpchat it is
declaration: package: org.bukkit.inventory, interface: PlayerInventory
how do u use jedis for slyblock?
lel
i used it for inventory persistence across server instances but otherwise doesnt really help with the skyblock itself
eh your system should always send them to the same server
Except it's not a world but a part.
wdym a part?
Swm allows u to have a world per player
i just had a 10 min timer after they left
Since u can load the entire world in memory
yeah thats what swm is made for
I need to look into redis more
its not made to store ENTIRE worlds just like small things
pretty much perfect for skyblock
Hypixel uses it
my suggestion: store only the chunks that are built in + 1 in the 8 directions, allowing you to still build but use an incredibly low amount of space
honestly even just PlayerJoinEvent is good
redis is super fast you barely notice the delay
Just use SlimeWorldManager it does all of that for you, fast and stores entities aswell
its IS the best system out right now for that usecase
Hypixel made a whole forum post about it, they stored like 1m player islands in something like 40gb
its insanely efficient
It's cause it cuts out the empty space of the chunks. That combined with a smaller storage format.
Very clever, but a pain to make from scratch.
Really glad they made it public knowledge.
But how do we create the part of the player in your thing there...
each player has their own world
you just load it in and tp them onto it
then when they leave, save it and remove it form the server
and it works on a database so can be loaded onto any other server
Do u have a bungee plugin unloading data?
You didn't understand, they say to load, to import or to update but how do you "create"???
I mean you could but I handled all of my stuff either on the server instance itself or a non-plugin application running on the server
just create a slime world template and copy it over
???
i dont understand your question exactly
Fast enf to do it sync?
oh hell yeah
its almost the same speed as reading from mem
How can you import something which does not exist???
There is nothing to create a backup to impor after.
import.
Isn't that up to you to make?
yeah im saying make a template and copy it over
Suddenly whenever I use a command that uses smth with json I get an error.... What is the issue and how can I fix its?
code: https://github.com/ItzJustNico/PlertanixPlot/blob/master/src/main/java/com/itzjustnico/plertanixplot/plots/PlotHandler.java
error: https://gist.github.com/ItzJustNico/55ebcf718d6f910dad48f2726be5d1b9
"Make a template" ?
Make your island, convert it to a slime world, then use that world as your template. Make copies of it when you need to create a new island.
Ahhhhhhhhhh.
whats in PluginJsonWriter?
Are you using reflection of some sorts? Cause that's what it looks like to me.
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @337a8cd2
Also, what's on Line 58 of PluginJsonWriter?
dont know what a Reflection is so not on purpose
Oh, it's because of gson
yeah gson is trying to access it
gson uses reflection and other stuff to scan your class in order to know how to serialize and deserialize it, you probably ought to provide a TypeAdapter or instance creator to gson
That error is usually json attempting to serialize an object it knows nothign about
gson is trying to deserialize the data into that class type
all it does is hold a File
It might be due to the transient keyword.
Oh, well looking up the keyword's usecase. It's there to prevent serialization of an object. So if you set the entire file to be transient, it won't serialize.
but everything worked before and I didnt change the keyword
I just tried it and even if I remove the keyword it is still the same error
whats the use for JsonDAtaFile anyway
you're already directly serializing from the file to PlotData
yeah and everything worked fine and I never changed anything there
is fawe okay for pasting schematics like skyblock islands ?
wait cant I save locations with json?
you can
you should be able to
but you pretty much want to supply a command/strategy object for how its done if you use gson
is it ?
is there anything better ?
define better
Ye it's fine and usually skyblock islands are really small so technically u can even gen them yourselves
better performance
It's good enough
how should i
myeah doing it yourself given that you know what you're doing
i want to like paste different islands at different locations of ONE world
since fawe relies on top of a ton of other stuff
Fawe is better than generating yourself but I'm saying that you can do it yourself
hmm because I removed the Location variable and the variable in the constructor there: https://github.com/ItzJustNico/PlertanixPlot/blob/master/src/main/java/com/itzjustnico/plertanixplot/plots/PlotData.java
and everything that used it and now I dont have the error anymore
oh yeah
actually
Location has an instance field called world
which is a WeakReference<World>
gson doesnt know how to deal with that specifically
Create a new object
so you could just provide a TypeAdapter<Location> to gson
if you do getConfigurationSection on a config, and you pass like a.b, do you get config.a.b or it throws an error?
You'll get the value at the path a.b inside the config.
conclure im bored and wanna code, got any servers?
so the configuration section b
not talking about value
talking about configuration sections
Just one question, have you started watching anime?
Uhmm... no..
is it the Japanese role play server? LOL
Let’s go #general btw
Caused by: java.lang.ClassNotFoundException: org.bukkit.Nameable Anyone got any ideas?
wrong version / dependency
When storing player data, should i use multiple columns or should i serilize to json and just store that
What storage are you using?
If it’s a relational database then you don’t wanna store the data as a blob
Sql
Yes then multiple columns
Ok
In that way you can take advantage of the fact that its sql
Ok got it
stop using 1.8
Funny one 😆
Any more info?
wdym
Other than a classnotfound
it wasn't meant to be a joke
you're using an MC version where this class doesn't exist yet
I'm pretty sure it does exist
so what is your MC version?
im not using plain spigot
Not according to your stackstrace.
im so smart
I am 3% smart0r
7smile7 told me to create different classes instead of passing lambdas as an argument in the constants
otherwise it warns me that im instantiating a hikaridatasource not in a try with resources
which doesnt make sense here
let me google this for you 🙂
okayy and how do I use the TypeAdapter then to use the Location to teleport somebody?
is spigot down
idk but i'm high
nvm
xd
no jk and spigot is online
aight
Yeah it was
but the website is indeed kinda slow rn
I couldn't load it
Anyone know how I get the Location out of the TypeAdapter<Location> to teleport somebody?
I am having issues with LightAPI, i try to make it so it looks like the player has a spotlight.
Currently I set a light at the player location and remove the last one. But some arent getting removed
The cases when theres no removal is
- when player jumps (the old one still stays there)
- when player moves diagonally (the light still stays t here)
reload
Laughs in cached pages.
caching doesn't really work if you wanna write a forums post though 😄
hm maybe ask on their discord
True, but I can fuck with people if it's really down.
do they have one
the issue is with how my code stores the locations i think
cuz it leaves one or two
should i make a list of last 5 locations
?paste your code
I am having problems getting a custom Event I wrote to work.
It extends the CreatureSpawnEvent and adds some data to it, but when I try to listen to it it does not work. I registered the Listener
The constructor of the event is called, I know that much. I put a System.out in there to check it. Is there anything I could be missing?
?
?paste your code
did you properly override the getHandlers method?
I think you actually need to register your event with bukkit. Bukkit#registerEvent() maybe?
nope you only have to register the listeners
for example here's my ArmorEquipEvent - it's not needed to "register" the event itself, only classes that listen to it -> https://github.com/JEFF-Media-GbR/ArmorEquipEvent
I see
that should be everything that matters, if you need more just let me know
oh ok let me do that really quick
check out lines 27, 79 and 89: https://github.com/JEFF-Media-GbR/ArmorEquipEvent/blob/d5eea509b5e25b5702922e514009df745351e3bc/src/main/java/com/jeff_media/armorequipevent/ArmorEquipEvent.java#L27 @crimson terrace
you have to override both the static getHandlerList and the non-static getHandlers() method
just create an empty handlerlist and make both methods return it
send your RemoverThread class too pls
https://paste.md-5.net/itebekukeq.java This should do it, right?
yes that looks good
ok thanks 😄
np 🙂
hm that's weird
why are you iterating over x and Z from -1 to 10?
I'd simply store all lights you have created and then use that list
BungeeCord
Im trying to register commands using for loop
but it's not working..
Main: ```java
Main.getPlugin.getLogger().info("TEST");
Configuration config = Main.getPlugin.config.serversConfig;
for(String s : config.getSection("servers").getStringList("")){
Main.getPlugin.getLogger().info(s);
Main.getPlugin.getProxy().getPluginManager().registerCommand(Main.getPlugin,new JoinServer(s));
}
your string list is always empty
you cannot have a list at ""
show your config file pls
for(String s : config.getSection("servers").getKeys(false)
this will return "survival" and "hub"
now you can get the list for each of those servers
by doing List<String> list = config.getStringList("servers." + s);
great :3
It's still not working, Ive done the handlerlist things but it doesn't print "Received Event!" from the Listener i registered for the event
I'll try to register it manually even tho it should be registered already
your event and your event listener are in the same .jar file, right?
yes
then i have no idea
ok I'll watch some videos and try fixing it. thanks for helping tho 😄
can't hurt to send all your code anyway, maybe it's just a tiny stupid error lol
I don't think theres much more to send related to the problem tbh
ughm wait
the code you sent
you still listen to the "original" event
you have to listen to your custom event class
this is what you sent:
@EventHandler
public void onMonsterSpawn(CreatureSpawnEvent event) {
oh yeah that's correct
how do i check if any player is at certain location
get the Location of the player using Player#getLocation() ?
oh you edited your message
loop over all online players and then check if their location is nearby the location oyu wanna check
oh that can be kinda performance bad
wrong class, this is the one
obviously you CANNOT compare locations with == because even moving by 0.000001 block will make it not work anymore
@Override
public void run() {
for (Location loc : this.vLights.getLightLocations()) {
int lightLevel = LightAPI.get().getLightLevel(
loc.getWorld().getName(),
loc.getBlockX(),
loc.getBlockY(),
loc.getBlockZ()
);
if (lightLevel > 0) {
LightAPI.get().setLightLevel(
loc.getWorld().getName(),
loc.getBlockX(),
loc.getBlockY(),
loc.getBlockZ(),
0
);
}
}
}
not really, it's no problem at all
a nested loop
comparing locations and looping over players is fast, you don't have to worry about performance
np
Anyone know how to use a TypeAdapter<Location> because I cant save a normal Location in a json?
why don't oyu just use YAML?
Location implements ConfigurationSerializable so you can simply do stuff like myFile.set("location",myLocation);
@Override
public void run() {
for (Location loc : this.vLights.getLightLocations()) {
for (Player player: this.vLights.getServer().getOnlinePlayers()) {
if(player.getLocation().getBlock().equals(loc.getBlock())) {
int lightLevel = LightAPI.get().getLightLevel(
loc.getWorld().getName(),
loc.getBlockX(),
loc.getBlockY(),
loc.getBlockZ()
);
if (lightLevel > 0) {
LightAPI.get().setLightLevel(
loc.getWorld().getName(),
loc.getBlockX(),
loc.getBlockY(),
loc.getBlockZ(),
0
);
}
}
}
}
}
because I got a big plot plugin that uses json for everything and now I need a location in there
@tender shard
okay but what exactly is the problem? Do you want to save a location, or load one?
Yo uhave to implement it yourself
a TypeAdapter is a class that has two methods: write(...) and read(...)
Should I run it using Bukkit Scheduler each tick?
If I was you, I'd simply use the already ConfigurationSerializable features of Location
yes
ty
is there an hotkey to resolve all imports in a class?
resolve?
for which ide
you mean to "get rid of the imports" and use qualified class names instead?
idk conclure told me to use TypeAdapter....
so like this example here?
hm yeah you can do that but it sounds like a lot of actually unneeded work
okay and how would the thing you said work?
TypeAdapter<Location> adapter = new TypeAdapter<Location>() {
@Override
public void write(JsonWriter jsonWriter, Location location) throws IOException {
// Do something
}
@Override
public Location read(JsonReader jsonReader) throws IOException {
// Do something
}
};
you basically have to do all the work yourself, which is to create a new location and manually read/write the existing's locations world, x, y, z, ...
there's also Location.serialize() which does all this for you and returns a Map<String,Object> with all the important data
but I am not sure how to turn this into Json exactly
I don't really like json, I use YAML for everything
so sorry I cannot really help you lol
and If I just save x y z yaw pitch separately in the json and put it together in the code?
yes, that's basically what you have to do
yes
okay thank you mfnalex for explaining me everything
oh no
I can save a world tho
you can simply either save the world's name, or the world's UUID
and then retrieve it again using Bukkit.getWorld(myWorldsName)
truee
I recommend to use names for worlds instead of UUIDs
sometimes people delete the world and let it regenerate using the same name, so I think names are better to identify worlds
okay thank you
np
what it would kind of look like to re-construct it or save it. Except you will eventually build the location manually after you get all the info needed 🙂
just store teh world name and the Block
oh
the best way to store a location though is to grab the location object as a string
both will serialize fine
and then use Base64 on it
okay think I am gonna try that thanks
then you can just unconvert that base64 string back into a location object 😄
but still need yaw and pitch right?
you can save it but not required
okay
you really only need the world name and a Vector for the three coords
wait should i safe a vektor or a block now
its upto you, depends on yoru precision requirement
if its for defining areas you only need the 3 values from a Block
okok
do your areas have a vertical element?
Uh still the same thing