#help-development
1 messages Β· Page 56 of 1
can you send the code you have
public void sendRequest(Player player, String request) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Message");
out.writeUTF("ambmt");
out.writeUTF(request);
player.sendPluginMessage(this, "Bungeecord", out.toByteArray());
}
Ignore the debugs lol
How do you listen to the messages
did you register the listener
oh its BungeeCord
not Bungeecord
its case sensitive
thats the problem
any ideas?
it prob is
brooo if its that
lmao
im not doing that
heheheha
damn that sucks
watch it not be that rofl
remember to change it in the listener too
ah
always copy and paste kdis
π
i love you
big dubs thank you man π
np
Is it possible to request data from a bungeecord plugin via a spigot plugin? Such as receiving a variable, or other piece of information upon request. I havent found any examples of this online, and most tutorials that I have found haven't really explained this. If someone has any code examples or could push me in the right direction it would be greatly appreciated π
how can i ban players with a reason?
.ban Playernam Reason
Yes, you can either use plugin messaging to accomplish this, or to go down a better approach - you could use redis pubsub to retrieve information from other servers/proxies
There should be methods to do this in the ban list
Bukkit.getBanList(BanList.Type.NAME)
Why not, I honestly think threads are the way to go?
Apart from like one word answers
Which is usually just linking to a thread someone could have found on google
for in depth problems I think forcing the use of threads tidies things up. But most of the questions in this channel probably don't fit the use case I guess
Also there already is a forum. I would use the forum for complex questions and discord for small questions with like up to three sentence answers
I'm aware not everyone does that tho
which one?
Yeah so that's basically the same as spigotmc forum on the web then
So unless it's synced in some way I would say that isn't a great idea. Especially since you can't find those threads in google. So we will get the same questions day by day
I read my own message wrong and changed something that was correct before. oops
changed it back
Yes, that would work
Thank you, I'll look into it!
Hey does anyone know how I could detect if a player opens a villager's inventory, but doesn't trade? meaning they close the inventory without making a trade
my first thought was playerInteractEntityEvent, but i'm not sure how to see if they don't make a trade and how to run it once they close the inventory
I've searched google and found nothing
probably InventoryCloseEvent
You could try something like this, there may be a better way to do it though.
@EventHandler
public void onOpenInventory(InventoryOpenEvent e) {
Player player = (Player) e.getPlayer();
InventoryType inventoryType = e.getInventory().getType();
}
And then check if the inventory is a villagers inventory.
InventoryType seems to have a lot of options, not sure which one would be a villager trading menu
it's Merchant
Idea - listen for when a player interacts with a villager with trades. Store them in a List for example if they do this.
Listen for InventoryClickEvent for when a player clicks on the result slot (aka the slot where the traded item is). If it's empty, then ignore it. If it's not empty, that means the player has traded with the villager - and at that point you can remove them from the list.
When they close the inventory, you can then check if they're still in the list. If they aren't, that means they have traded and you can ignore it. If they are, that means they haven't traded and you can execute your code.
tell me if you understand
oooh ok that makes sense
good idea, thanks!
understood
β€οΈ
If you're using paperspigot/any server jar forked from paper, there is an api inside of the paper-api dependency to detect wether or not the player trades with a villager (PlayerTradeEvent)
πͺ
OOOO
i am using paper!
sweet! that makes it way easier, thanks!!!!
:(
i usually use spigot
but i just realized that im using paper for my newest project
lol
cya
this still works? i'm using it and the events are not working.
TextComponent message = new TextComponent("Click me");
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org"));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Visit the Spigot website!").create()));
sender.sendMessage(message.toLegacyText());```
https://www.spigotmc.org/wiki/the-chat-component-api/
toLegacyText will remove hover and click events
Use sender.spigot().sendMessage(message)
thanks, in versions 1.8 for example there is no spigot() method, how could it be done?
there should be, make sure you are using a spigot dependency and not a bukkit one
I'm stupid, I was sending the message as CommandSender not as a player π€¦ββοΈ
owo
and the HoverEvent is there another way to do it now? I see that in recent versions it is deprecated
thx π
?jd-s
Define summoning only one?
well
like a death animation
on kill it makes a thunder spawn on the death location
i forgot how to make one
help me please
like how to make the thunder appear on death.getLocation();
death.getLocation.getworld.spawnEntity()
well, start with adding the return true; inside of the ifs
tried with that but
how do i spawn the lightihng π
that's what im askin
death.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.LIGHTNING);
Or you can just use strike lightning (location)
I WAS WRITING LIGHTING
oh lol
how do i get the entity that was spawned in the SPAWN_ENTITY packet through ProtocolLib?
oo im dumb didn't saw the getWorld().strikeLightning();
The docs are nice for that
what'd happen if i cancel the LightningStrikeEvent
like i want it to cause no damage
but
event.getPacket().getStrings().readSafely(1); just returns null, but i think that 1 should be the way to get UUID considering:
and considering: https://wiki.vg/Protocol#Spawn_Entity
ProtocolLib doesn't refer to the protocol specification
It pulls from the fields of the packet class
You should be able to getUUIDs().readSafely(1)
Yo Choco any word from md_5 or should I ping him
No he's been relatively quiet lol, though I really don't think since tags would be accepted
you can't milk those?
I'll wait a few days 
What the hell conversation did you come from? lol
If it exists you can milk it
π
got it tysm
Player p = e.getPlayer();
Block targetBlock = p.getTargetBlock(null, 5);
if (p.isSneaking() && String.valueOf(targetBlock.getType()) == "CHEST") {
FileConfiguration config = plugin.getConfig();
String coordination = targetBlock.getLocation().getBlockX() + " " + targetBlock.getLocation().getBlockY() + " " + targetBlock.getLocation().getBlockZ();
if(targetBlock instanceof Chest) {
``` why is the last if won't return true even though i am looking at a chest?
I can't use the targetBlock as a chest even though it is a chest
wtf is this String.valueOf(targetBlock.getType()) == "CHEST"
Creative
That is creative
Anyways, getType() returns a Material, which is a constant you can check against. So targetBlock.getType() == Material.CHEST
how would i make an armorstand using nms? it says ArmorStand cant be initialized but thats what https://nms.screamingsandals.org/1.18.1/net/minecraft/world/entity/decoration/ArmorStand.html says
why are you using 1.18.1 is the real question
im using 1.18.2 but same issue
have you tried new EntityArmorStand(EntityTypes.ARMOR_STAND, world);?
that works but ARMOR_STAND doesnt exist, did you mean Type or?
how would i add & to the start of the pattern?
because its just #FFFFFF instead of &#FFFFFF
private static final Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
public static String color(String text) {
for(Matcher match = pattern.matcher(text); match.find(); match = pattern.matcher(text)) {
String color = text.substring(match.start(), match.end());
text = text.replace(color, ChatColor.of(color) + "");
}
return ChatColor.translateAlternateColorCodes('&', text);
}```
EntityTypes.ARMOR_STAND doesn't exist?
EntityType.ARMOR_STAND
oh my bad lol
EntityTypes
<? extends net.minecraft.world.entity.decoration.EntityArmorStand>
Provided:
EntityType``` it seems like nms does use Types but armor_stand doesnt exist
You cant use bukkit types in nms. Mojang doesnt code their software with spigot in mind.
Just look at the constructor of ArmorStand
ArmorStand stand = new EntityArmorStand(EntityTypes., s); none of the auto complete things for that make sense
EntityArmorStand is from the old mappings. Dont use them. Since 1.17 you should always use mojang mappings
ArmorStand stand = new ArmorStand(EntityType.ARMOR_STAND, world);
this works for me
'ArmorStand' is abstract; cannot be instantiated
what are your imports?
Thats the bukkit armorstand. You need the nms ArmorStand.
import net.minecraft.network.chat.ChatMessageType;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.protocol.game.PacketPlayOutChat;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;
import net.minecraft.world.level.World;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;```
there is the problem
there is only the bukkit import i see
remove
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
Because you are not using mojang mappings
that too, was wondering why your imports are versioned
huh?
Thats CraftBukkit
I thought they weren't versioned anymore?
Also happens with the mojang mappings. CraftBukkit is independent.
wdym im not using mojang mappings
did you run buildtools to get a remapped jar?
The CraftBukkit packages have always been versioned. Didnt change.
ah
??
i run buildtools im using 1.18.2 spigot maven
well, did you?
https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-2-release.534760/
Scroll down to them "NMS" section
You need to run BuildTools with the remapped flag. Its all covered in this thread.
java -jar BuildTools.jar --rev 1.18.2 --remapped
oh? shouldnt it be updated on the buildtools then
After that you need to setup the special sources plugin for maven
this is a good guide on how to do that https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/
umm i just ran it and now the only import that works is for armorstands <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> <classifier>remapped-mojang</classifier> </dependency>
Did you manually add any jars to your project?
no
Ok then make sure that this is your only spigot dependency and that you have set up the special sources plugin
special sources pluugin?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
oh shit
i added that to my pom and it still doesnt work same issue
?paste your pom
Hey guys, I have a question. I created a Class that uses the Listener but I want to add a delay to it after the event has been triggered.
I tried implementing the Bukkit scheduler within the class file but I can't seem to use it properly.
Any ideas?
The code:
package listeners;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
public class miscEvents implements Listener {
@EventHandler
public void onPlayerStep(PlayerMoveEvent event) {
event.getPlayer().sendMessage("You have stepped");
//Add delay here
event.getPlayer().getLocation().subtract(0, 1, 0).getBlock().setType(Material.AIR);
}
}
Use the bukkit scheduler to delay an action by a few ticks
Bukkit#getScheduler#runTaskLater()
Would that be in the same class file or different?
I dont understand this question...
like do i put the bukkit get scheduler in the same code?
wait, i'll try it again first before anything
This sounds like you jumped into spigot before learning the very basics of java. Not a good idea.
Then the question should be trivial to answer for yourself
Hmm idkk. im not familiar with the Spigot stuff
So what I want to do is:
Whenever a player walks, the block that they walked on will dissapear after 3 seconds
That is really hard to achieve properly. What if they break and then place a another block there? You need to keep track of everything.
?scheduling
Are YamlConfiguration values cached in memory or is it reading the disk every time?
yaml config is just a glorified hashmap
gotchu
public class miscEvents implements Listener {
@EventHandler
public void onPlayerStep(PlayerMoveEvent event) {
event.getPlayer().sendMessage("You have stepped");
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(plugin,()-> System.out.println("Hello"),20);
}
}
I almost have it but not sure what plugin is supposed to refer to. Is it supposed to refer the Class that im trying to use?
Is the scheduler supposed to be in a separate class and I import the other class in?
An instance of your JavaPlugin
like the actual plugin that runs it all?
Use a proper map? They've been around for quite a while.
Map#put()
Map#get()
I'm surprised your code compiled with that lowercase method. (Assuming that's the bukkit scheduler)
Update: I fixed my problem π₯³
how do you get a list of uuids that are online on the server/world
Player UUIDs?
yes
Iterate over Bukkit#getOnlinePlayers(), get the player's UUID, and put them in a list.
how would you iterate over it
A for loop?
im just curious since im relatively new to java
how would you structure said for loop
i know i could just do a normal one
but do you have any specific ways of doing it
so i know that
javac <filename.java>
converts it to a .class
however my system runs java 17
how can i javac in java8?
Well, you could use a foreach loop. It's a simpler way to use for loops with one dimensional arrays.
List<Object> myList = new ArrayList();
// For each object that is in `myList` do this.
for (Object obj : myList) {
// Do stuff.
}
You just have to point to the javac of a Java 8 bin
you got an example for me
The reason javac works is because your PATH environment variable points to Java 17, but really it's equivalent to just calling a J17 javac
D:/Program Files/AdoptOpenJDK/jdk-8.0.275.1-hotspot/bin/javac whatever.java
You change that to wherever you have your JDK 8 installed
how do i write it as there is a " " in program files
Depends on what script you're using. Powershell, Command Prompt, Bash, etc.
cmd
You can surround Program Files in quotation marks
e.g. C:/"Program Files"/whatever
I don't think it actually does. You can just surround the path with quotation marks. It works for most languages too.
Surround the entire path with quotation marks.
"C:/path/to/your/file"
worked
hey guys, I have my Listener registered but it breaks when I extend JavaPlugin like this:
public class miscEvents extends JavaPlugin implements Listener {
@EventHandler
public void onPlayerStep(PlayerMoveEvent event) {
event.getPlayer().sendMessage("Message");
}
}
thanks
but when I remove the extend, it works fine
Yeah, you don't have to extend JavaPlugin. Only one class in your plugin should extend this class
Your listener should just implement Listener
ohh I see
so then if I have something like this: ```java
public class miscEvents implements Listener {
@EventHandler
public void onPlayerStep(PlayerMoveEvent event) {
event.getPlayer().sendMessage("You have stepped");
new BukkitRunnable(){
@Override
public void run() {
event.getPlayer().getLocation().subtract(0, 1, 0).getBlock().setType(Material.AIR); }
}.runTaskTimer(this, 0, 5);
}
}
If you need JavaPlugin methods, you can pass through an instance of your class in the constructor and assign it to a field
public class MyListener implements Listener {
private final MyMainClass plugin;
public MyListener(MyMainClass plugin) {
this.plugin = plugin;
}
}```
Then you can refer to plugin instead
When you create an instance of your listener, you'll need to give it an argument now. The instance of your plugin class
If you're constructing it in the plugin class, you can just pass this
How could I get the player's uuid from Player player = event.getPlayer();?
Player#getUniqueId()
getUniqueId()
Thank you!
One more question, I have Map<UUID, Boolean> resourcePackStatus = new HashMap<>(); set in an event class, how could I get the boolean in a command?
I've never worked with this type of stuff before, so this is all quite new to me haha
Map#get() will return the value of the given key.
So if your player UUID is the key, use Map#get(<playerUUID>) and you will get the boolean tied to them.
Create a manager class of which only one instance exists that contains the map. Pass this manager to both the listener and the command.
Not sure if this is against the rules like papermc but I am looking for someone that may be able to help me make the core for my Minecraft server what I need done is here https://trello.com/b/XwDZh9gy/ve-core. If you are able to do any of it DM me for more info. I can also pay a tad.
So, I couldn't just do something like Map.get(player.getUniqueId());?
I need a manager class that somehow passes it to my command?
This sounds like you didnt take the time to learn the java basics before jumping into Spigot...
Yeah, I didn't really get around to arrays and that sort of stuff before doing this :P
Its more an issue of object orientation. So your manager class should look something like this
public class ResourcepackManager {
private final Map<UUID, Boolean> resourcepackStatusMap = new HashMap<>();
public boolean getStatus(UUID playerId) {
return resourcepackStatusMap.get(playerId);
}
public void setStatus(UUID playerId, boolean status) {
resourcepackStatusMap.put(playerId, status);
}
public void remove(UUID playerId) {
resourcepackStatusMap.remove(playerId);
}
}
And in your onEnable you create one instance of that class and pass the same instance to all objects that need it.
@Override
public void onEnable() {
ResourcepackManager resourcepackManager = new ResourcepackManager();
// Pass the manager to a listener
// Pass the manager to a command
}
And never create a new instance again. Every new instance has its own new HashMap. Use the same instance everywhere.
Okay, so to pass the manager to a command, would it look similar to this? getCommand("god").setExecutor(new GodCommand(this, resourcepackManager));
Yes. It should be passed through the constructor.
This is called dependency injection. π
Okay maybe two more questions... sorry!
I have ```java
public class ResourcePackManager {
private final Map<UUID, Boolean> resourcepackStatusMap = new HashMap<>();
public static boolean getStatus(UUID playerId) {
return resourcepackStatusMap.get(playerId);
}
public void setStatus(UUID playerId, boolean status) {
resourcepackStatusMap.put(playerId, status);
}
public void remove(UUID playerId) {
resourcepackStatusMap.remove(playerId);
}
}``` in my ResourcePackManager.class, it's telling me that I should make it static. Non-static field 'resourcepackStatusMap' cannot be referenced from a static context
Would this hurt anything? Just so I don't mess anything else up π
Yes. Dont make anything static here. Dont use a static context to call those methods.
You mean the action of flowing from one block to another?
Wait, now I'm getting a few mixed things. public static boolean getStatus I remove static from this too?
@lost matrix could you code me a plugin for $$. Not too hard
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Yes remove static from this method.
Gotcha, okay, thank you! I'll finish what I'm trying to do :D
declaration: package: org.bukkit.event.block, class: BlockFromToEvent
One more thing, I'm so sorry π
java Boolean test = ResourcePackManager.getStatus(player.getUniqueId()); is how I would assume to get the status, but I'm now receiving this error: java Non-static method 'getStatus(java.util.UUID)' cannot be referenced from a static context
anyone know of a plugin which converts vault 1000000 to 1m
ofc for k, m, b, t, q, qt etc
dont use a static method
This is not how any of this works... Just dont use the methods as static methods.
any tips and tricks on making guis?
bro ive looked lol,. thats why i came here. try be Useful next time xx
i feel like i can improve it
I have a function but it bad
i rlly gotta remake it
want that?
why is it "bad"?
What specifically are you looking for?
the formatting it bad
I see, I'm just dumb, took a small bit of playing around to get it, thank you guys very much for your help :D
well im doing java inv.setItem(0, blank); inv.setItem(1, blank); inv.setItem(2, blank); inv.setItem(3, blank); inv.setItem(4, blank); inv.setItem(5, blank); inv.setItem(6, blank); inv.setItem(7, blank); inv.setItem(8, blank); inv.setItem(9, blank); inv.setItem(17, blank); inv.setItem(18, blank); inv.setItem(26, blank); inv.setItem(27, blank); inv.setItem(35, blank); inv.setItem(36, blank); inv.setItem(37, blank); inv.setItem(38, blank); inv.setItem(42, blank); inv.setItem(43, blank); inv.setItem(44, blank); and there has to be a way of improving this
maybe adding numbers to a list and looping that list?
Let me introduce you to for loops
use a for loop dude
public static String format(Double value) {
DecimalFormat decimalFormat = new DecimalFormat("0.##");
if (value > 0) {
String data = "NGTN,,90\\.OTGN,,87\\.STGN,,84\\.HNGT,,81\\.QTGTN,,78\\.QTGT,,75\\.TGT,,72\\.DGT,,69\\.UG,,66\\.V,,63\\.NVD,,60\\.OD,,57\\.SPT,,54\\.HD,,51\\.QTD,,48\\.QTW,,45\\.TD,,42\\.DD,,39\\.UD,,36\\.D,,33\\.N,,30\\.OCT,,27\\.SP,,24\\.HT,,21\\.QT,,18\\.Q,,15\\.T,,12\\.B,,9\\.M,,6\\.K,,3";
for (String str : data.split("\\.")) {
String[] output = str.replace("\\", "").split(",,");
if (value >= Math.pow(10, Integer.parseInt(output[1]))) {
return decimalFormat.format(value / Math.pow(10, Integer.parseInt(output[1]))) + output[0];
}
}
}
return decimalFormat.format(value);
}``` ik it ain't the best im going to remake this some time in the future but it works
r u developing for paid plugins at the moment?
Like you code a plugin that I pay u for?
for loop and spread operator for your parameter
ik loops
Is it for 1.8?
public static String formatDouble(double value) {
String[] suffixes = {"K", "M", "B", "T", "Qad", "Qin", "Sext", "Sept", "Oct", "Non", "Dec", "Und", "Duod", "Tred", "Quat", "Quind", "Sexd", "Septe", "Octo", "Nov", "Vigin"};
if(value > 1000) {
for (int pwr = 3; pwr <= 63; pwr += 3) {
int index = (pwr / 3) - 1;
double powVal = Math.pow(10, pwr);
if (value < powVal) {
String str = String.format("%.2f" + suffixes[index - 1], value / Math.pow(10, pwr - 3));
str = str.replace(".00", "");
return str;
}
}
}
String str = String.format("%.0f", value);
str = str.replace(".00", "");
return str;
}```
this is mine if you want it
much more readable
yes
Then hell no. Who even uses that version anymore?
is there a ready made plugin for this
a lot of ppl
?1.8
Too old! (Click the link to get the exact time)
lmao
1.8 bad
non
i dont see a lot of people developing for hypixel though
π’
idk but if its a vault impl shouild take you 10 mins to do
Its a practice server
for hypixel kinda'
why not just practice in hypixel
Is there a reason why you dont want to use external libraries for guis?
Creating properly working and well performing guis is not easy.
well i would rather
you got one?
i couldn't find one that satisfied me π
cufp are you actually looking for a developer?
if you wanna get good at oop making your own inv system is good
I didn't see this
I personally dont use any libs
thanks i'll try it out
I'll try this one, and i may make my own in the future
Thats a good plan
how big is the dependency. i dont want my plugin super big
one sec, let me build the plugin and see
800kb
with minimizeJar as true it went down to like 50kb
what does that even do
ik it works but does it remove any essentials
I c
In which version of spigot does the ComponentBuilder() change to Text() of the TextComponent?
Why the hate amongst protocollib?
removes any common dependencies, it will also remove any class files that aren't loaded by the class loader
typically if you use a sql driver you can't use minimizeJar without some extra maven config, maven cant detect all use cases
finally someone who understands lol!
except i cant completely say i do the same lol
i use protocollib, libsdisguises mostly
and then i have like an nbt thing i forked
ProtocolLib is the only spigot dependency i have
is it possible to set data for a block like persistentDataContainer?
nvm, fixed it
Only if the Block is a TileState (Furnace, Dropper, Barrel etc)
Otherwise you need an external library for that.
does that include chest?
Does anyone know how to get (in spigot) or how minecraft creates the DAT files created for itemstacks in saved inventories?
You mean the method MC uses to turn ItemStacks into NBT?
clarify a bit more?
The format is called nbt
do you mean the NBT data or the file itself?
this, didn't know which to refer to it as lol
net.minecraft.world.item.ItemStack item = ...;
CompoundTag nbtTag = new CompoundTag();
item.save(nbtTag);
String data = nbtTag.getAsString();
(thats nms itemstack btw)
`
public static final class ItemStackJsonSerializer implements JsonSerializer<ItemStack>, JsonDeserializer<ItemStack> {
@Override
public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(CraftItemStack.asNMSCopy(src).save(new CompoundTag()).getAsString());
}
@Override
public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
try {
String asString = json.getAsJsonPrimitive().getAsString();
CompoundTag compoundTag = TagParser.parseTag(asString);
net.minecraft.world.item.ItemStack nmsStack = net.minecraft.world.item.ItemStack.of(compoundTag);
return CraftItemStack.asCraftMirror(nmsStack);
} catch (CommandSyntaxException e) {
throw new IllegalArgumentException(e);
}
}
}```
a gson deserializer i made
using that concept
You can also make one that is version independent
how so
class ItemStackAdapter : JsonSerializer<ItemStack>, JsonDeserializer<ItemStack> {
override fun serialize(src: ItemStack, typeOfSrc: Type, context: JsonSerializationContext): JsonElement {
val outputStream = ByteArrayOutputStream()
val dataOutput = BukkitObjectOutputStream(outputStream)
dataOutput.writeObject(src)
dataOutput.close()
return JsonPrimitive(Base64Coder.encodeLines(outputStream.toByteArray()))
}
override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): ItemStack {
val inputStream = ByteArrayInputStream(Base64Coder.decodeLines(json.asJsonPrimitive.asString))
val dataInput = BukkitObjectInputStream(inputStream)
val itemStack = dataInput.readObject() as ItemStack
dataInput.close()
return itemStack
}
}
Using BukkitObjectOutputStream
yep, all of these work
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/ItemSerializer.java#L33 you've also got this if you dont need Gson serializers
how does one get multiple worlds on one server
well first of all kotlin (ew) and second of all base64 (ew)
(i dont want to use a 34d party plugin)
kotlin is ok
yea but i dont like using it
yea it needs a little improvement
well i dont care about any of that its just personal preference
i find it to be hard to understand and read haha
Just create a new World
Bukkit.createWorld(WorldCreator.name("CoolWorld"));
If the world folder already exists then its loaded
Bukkit.getWorlds
how would you force a player into that world
Teleport
lol
Trivial example
Player player = ...;
World world = Bukkit.createWorld(WorldCreator.name("CoolWorld"));
player.teleport(world.getSpawnLocation());
can you specify maps for that world?
maps?
i maen sure
Just copy a world folder
you just need to get rid of the uid and session.lock
^ And that too.
I would delete them on your template worlds in the first place.
Yeah. Spigot does a lot of IO on the main thread.
Ive gotten it to 20 - 30ms by disabling loading the spawn chunks and having a decent nvme ssd on my root server.
But still...
20-30ms ?
by disabling spawn chunks
u mean
@EventHandler
public void onWorldInit(WorldInitEvent event) {
World world = event.getWorld();
world.setKeepSpawnInMemory(false);
world.setAutoSave(false);
}
yeah
You can also specify this in the WorldCreator now iirc
Might be fork
Nah i thinks its paper stuff
oh i realized
that code snippet...
was not in a listener
now that i moved it, i do see a performance boost
Inventory chestInventory = ((Chest) chest).getInventory();
for(final ItemStack item : chestInventory) {
}``` would i need to use chestInventory.all() or would this work as well?
Inventory implements Iterable<ItemStack>
So you can do your for loops and forEach calls
awesome
PlayerMoveEvent keeps getting triggered. Whats best way to check if player moved to a new block? My idea was to store the int of blockX and blockY but that'll disappear immediately since the code will finish running
or is there something better than PlayerMoveEvent for my case?
This is the best performing way i came across so far
@EventHandler
public void onMove(PlayerMoveEvent event) {
Location from = event.getFrom();
Location to = event.getTo();
if(to == null) {
return;
}
int fromX = from.getBlockX();
int fromY = from.getBlockY();
int fromZ = from.getBlockZ();
int toX = to.getBlockX();
int toY = to.getBlockY();
int toZ = to.getBlockZ();
if(fromX == toX && fromY == toY && fromZ == toZ) {
return;
}
// Player moved from one block to another
}
Why is getLogger().log(Level.FINE, "text"); not working in some cases in my onEnable?
cant you just check from.distance(to) > 1?
No
Wouldnt work and would also be very expensive
yeah fair
you can move very slowly from one block to another. 0.000001 per tick.
You only want to detect when movement crosses a block border. Doesnt matter at which speed.
ah yeah you're right
What would be the best way to implement a feature where when wearing, for example, a diamond helmet it would give the player an extra heart? And when they take it off they loose the heart.
For this exact case you can just add an attribute modifier to the helmet and give it health.
What's the attribute modifier called?
I was thinking GENERIC_MAX_HEALTH but I thought that was only for entities
One moment
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
ItemMeta meta = helmet.getItemMeta();
meta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, new AttributeModifier("move-boost", 0.2, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("damage-boost", 0.35, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
meta.addAttributeModifier(Attribute.GENERIC_MAX_HEALTH, new AttributeModifier("health-boost", 4, AttributeModifier.Operation.ADD_NUMBER));
meta.setDisplayName("Β§6Helmet of rush");
helmet.setItemMeta(meta);
Usually you would specify an equipment slot for the AttributeModifier
Thanks, but how do I make it so it's only When on Head?
Usually you would specify an equipment slot for the AttributeModifier
Okay thanks
how would i set a placeholder?
because im getting the placeholder
but how do i remove like 2500 from it
Are you talking about placeholder api?
yeah because im using placeholders for their balance
double economy = Double.parseDouble(PlaceholderAPI.setPlaceholders(e.getPlayer(), GenCorePlus.getYaml().getString("money.type")));```
but it could be any placeholder if its a number
so how would i remove from it?
A placeholder is not a number. You cant just subtract a number from a placeholder...
well how would i do that? Like any alternatives
You can not subtract a number from a placeholder. Maybe rephrase your question. Be more precise.
okay, how would i get a variable from another plugin then. Because i need a way for them to have configurable balance. Some people might not wanna use vault's api for that
Question: "how would i get a variable from another plugin"
Answer: Use their API or if they dont provide one then dig through the code and find the right places to retrieve values from.
hmm, any way to make that more user friendly?
Question: " i need a way for them to have configurable balance"
Answer: Who is "them"? This sentence is out of context.
or should i just use vault's api
The users, since my plugin is on spigotmc
Some people might not wanna use vault's api for that
For what? What is "that" refering to? And are "Some people" other developers or server administrators?
i would like more configuration since people like that
But you cant provide configuration for plugins of other developers
yeahh
ima just stick with vault's api ig
ain't the worst
I am still confused as to what you are trying to achieve in the first place...
How Can I instance inventories per world?
Database item serialization preferably you could also store the contents in a json file
You need to serialize the inventories, store them somewhere and when a player changes a world you simply
set his inventory contents. A Map<UUID, ItemStack[]> for each player that maps the world id to the inventory contents should do just fine.
I would load all inventories as soon as the player joins in a Map<UUID, ItemStack[]>. Loading them
when he changes a world means you need to load them on the main thread.
Or you need to give him the inventory with a small delay of a few hundred ms. Then you can also do it on world change but async.
If I created a team like this
ScoreboardManager sm = Bukkit.getScoreboardManager();
Scoreboard scoreboard = sm.getNewScoreboard();
Team DinoMine = scoreboard.registerNewTeam("Map1");
//ADD PLAYER TO TEAM
player.setScoreboard(scoreboard);
DinoMine.addEntry(player.getName());
And I check if the player is in that team with
player.getScoreboard().getEntryTeam(player.getName()).equals()
What exactly should I check for
Ahhh bukkit scoreboard api the most horrific thing on earth.
Well based on your code it looks like the team is the player name
doesnt getEntryTeam return the team/s the player or thing is on?
Tbh I'd have to recheck the docs I suck at this stuff gimme a second lol
lol thanks
yea, thats how I got it too
So all you want to do is check if it's null or not then proceed with the knowledge you have the team
yea
Personally I use a api called fastboard and constructed my own teams api lol I hate bukkit scoreboards so much
It's likely mojangs fault
Fastboard is all packets if your looking for something light weight
Otherwise there are some other neat options outbthere
For teams you can just apply a scoreboard and add logic for each team
Could be achieved via a team object
Im having some issues using getOfflinePlayer() to get a Player Head. Keep in mind, the player has not joined the server previously. Is there a better way to do this?
The code:
public void addPlayer(UUID player, Tripair<String,Double,Integer> tripair) {
// Put player and information into a Hashmap (key: UUID)
players.put(player,tripair);
// Get the time remaining from minutes
String time = tripair.getThird() != -5 ? ((int) (Math.floor(((double) tripair.getThird()))) / 60) + "h:" + (tripair.getThird() % 60 > 9 ? "" : "0") + tripair.getThird() % 60 + "m" : "Β§4No bids yet";
// Get player head
ItemStack head = Heads.get(player,
"Β§a" + Bukkit.getOfflinePlayer(player)..getName(),
List.of("Β§eActive Bid: Β§7$" + tripair.getSecond() + "m Β§8(" + tripair.getFirst() + ")",
"Β§eTime Left: Β§7" + time,
" ",
player.toString()));
// Add ItemStack to GUI
freeAgencyGUI.gui.addItem(head);
// Add to config
FreeAgents.addFreeAgent(player,tripair);
}
The issue is "Bukkit.getOfflinePlayer(player)..getName()" returning null. I'm not sure how to get around this, as I know the player exists. Is there better way to get a player head from someone who hasent joined?
If my code wasn't proprietary I'd gladly Share it maybe one day I'll release something
I use website urls
I don't bother with the offline player bs
If you want a certain skin to always display highly reccomend using Bukkits PlayerProfile api
Yeah the offline player stuff seems pretty dumb, just didnt know a better way of doing it
Bukkit#createPlayerProfile iirc you can add a skin url and then apply it to the skull
I need to make a resource on this I feel like this is still relatively unknown that It exists
Yeah, I had tried using getOfflinePlayer(player).getPlayerProfile() previously, but obviously that did nothing as the offline player was null.
Should it work just like this?
PlayerProfile playerProfile = Bukkit.createPlayerProfile(player);
String name = playerProfile.getName();
Or would doing it via url still be better for this
Use createPlayerProfile(UUID.random()
Don't provide a player
Than provide skin data to it
"player" is a uuid, I had just named it player
Is it random
no it's not
You shouldn't use a players uiid just make a random one
Alright so-
create a PlayerProfile with a random uuid, attach the player skin via a url, then attach that skin to the head?
Yep
On Minecraft-Heads.com you can find more than 30.000 custom heads, which can be used to decorate your world! The collection is seperated into two databases: the first contains custom heads, which never change their texture, using the Give-Codes from Minecraft 1.8+, the second one includes player heads which can be used in all Minecraft versions.
How would using minecraft-heads.com work for using a 'casual' player head? Such as a friend of mine or a specific user thats not on that website.
Not well but that's just good for custom gimmicky stuff
Yea i dont think we have a choice but to use java lmfao
You can technically use any jvm language
or technically kotlin can be used
just use base64 textures
base64 is just the encoded url base64 isn't supported via player profiles
as a whole, great langauge. Not great for low level stuff
yes it is
I've only seen url
i prefer rust
Unless it was updated
o-o
its always been like that
create a fake player profile
apply base 64 texture and signature
done
Bukkits player profile api is relatively new
you're talking aobut GameProfile right
ah
Again why I should make a resource it's super useful
I reccomend using bukkit api for it but go ahead
public ItemBuilder skullTexture(String base64Texture, String sign) {
SkullMeta headMeta = (SkullMeta) this.item.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", base64Texture, sign));
Field profileField = null;
try {
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
e1.printStackTrace();
}
this.item.setItemMeta(headMeta);
return this;
}
}```
you can use that if you need Tias
Alright, thank you! What do I put in for the sign parameter?
if you want to pull a player's signature you can use sessionserver.mojang.com/session/minecraft/profile/UUID
pretty sure you can leave signature out iirc
You can do that with the spigot api now
I've just figured out quite the odd workaround since I was having a bit of a hard time understanding the profile stuff. Copy and pasted my playerdata folder from a server that the players I wanted had joined before, and put it into my 'world' playerdata folder. It worked. Although, it would probably be useful to figure this stuff out, in the case it decides to break at some point
Anyone know how to create a team with Fastboards?
public ItemStack texturedSkull(URL skinUrl) {
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) head.getItemMeta();
PlayerProfile profile = Bukkit.createPlayerProfile("_SOME_NAME_");
PlayerTextures textures = profile.getTextures();
textures.setSkin(skinUrl);
meta.setOwnerProfile(profile);
head.setItemMeta(meta);
return head;
}
Doesn't support teams you'd have to make your own api for thay
But teams are easy enough to make
The only issue with using PlayerProfile is, every one gets added to the servers usercache.
You must be careful not to create too many, although they do expire in three? months.
they still remain in teh cache
Its a fixed number. I think the default is 10k
Does this method work for players that have not joined the server previously?
This method doesnt need any players
But wouldnβt i have to use the built in bukkit api for that
Becuase if i do, iβd die
No just make your own api
Classes and events
Teams are a simple concept
Bukkit doesnt seem to think so
The scoreboard api sucks and i reccomended an alternative option is all
Yea
Thats true
Except i just cant find a good api for that
and i have no clue how to make my own lmao
Did your team break another plugin?
I'm a minigame dev lol so I guess it's easier said then done
No, the bukkit scoreboard api is just so confusing, like, for example, why the hell do i need a scoreboard in the first place? I just want a team to divide players into
Well that's just how vanilla works
Blame Mojang
Yea so thats why im looking to create a api
Yea, fastboards works well for scoreboards, but sucks for teams
Ill check what and how to make an api
Thanks for your help
Well each player can have a profile cache the profile and store what team the player is on you could also use these classes to store other game info
A more longterm solution is a file storage or pdc
Making your own api will still need that scoreboard
Not really
It will
If you just ditch bukkit completely and set up your own teams and logic no bullshit
It's what I do
So you use nms
.-.
Somethings require teams
Like?
im just trying to divide players into three maps
Then skip the Teams API
I just use other apis for the name tag stuff lol
So they use teams
Collision is math not teams
If I ever need them I'll go use nms and figure out a better abstraction but thus far haven't needed them
Everything I need is managed by my custom team object
I've done teams with packets and spigot api before
Just make a system that uses the spigot api
It will be easier to maintain
True, but then u still need to use the spigot api
Eh I'm not to worried about maintaining a team's api if I actually use it
I'll die by considering that scoreboard api horrific at best
Well you still need to do the same things just without the spigot api
The goal would be to see if I can find a better abstraction to make it easier and more understandable on an nms level versus navigating the scoreboard hell hole spigot offers
Yes
And then make sure you don't break spigot plugins
It's more work than just using the existing one
why do some dependencies that worked in 2017 do not work anymore for the same plugin?
If you want to make an api do that but use the spigot api internally
Sometimes work is required to make a good product
Moved repo out of date etc etc
New versions
Removal of old versions
what can I do?
Nothing
Well it depends on what the problem is
He wasn't descriptive enough so generally nothing is the correct answer
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
^
Anyone use tabnine and does it help your workflow?
Copilot is great tabnine less so
Yes but copilot is going to not be so free soon
Worthy investment
override fun π
is onDisable() called on reload?
well, you kinda pay for using free code samples π
including yours
Yes
ok ty
Does setdefaults set comments for config files?
Also can anyone recommend come good data managers for config files
Will all players have access/permission to execute my command is I didnβt specify any permission needed?
normally yes
unless you defined a default permission in your config file
default-permission: op```
Nah, ok thanks
tried it, was just shit
copilot is the only thing that properly works and is actually helpful
damn, I might have to get a job
lol
nah jk, github copiot is basically an auto stackoverflow copy and paste tool.
I tried something with Raytrace but failed. How can I find where an item or entity thrown with the Dispenser will end up?
you cannot raytrace that, you have to calculate the trajectory basically
rip, just cancel the event and spawn it a location
well another idea would be to make the item invisible, wait until isOnGround is true, and then you know where it ends up lmao
even if i find the trajectory the trajectory may contain obstructions.
how to check?
yeah you'd have to scan every full block that's on that path
wait just detect the item being dropped and start a runnable
test every second to see if its on the ground or not
what are you actually trying to do anyway?
There are things that have a very long range. (fireball)
why do you need the hypothetical end location in the moment when it's dispensed?
What I'm trying to do is prevent items or fireballs from entering the chunk I want.
a simple timer will do then
Won't it cause lags?
no?
I'd add all currently thrown entities to a set or something. then check every tick if that entity is in your chunk, if yes, kill it. after 5 seconds or so, remove them from the set again
unless you are going to track 10's of thousands of items in motion over multiple chunks, no
it shouldn't if you aren't calculating the mass of the sun
its funny how people always think "this might cause lag"
they should just look at the Entity#tick method
nvm that would still be fine
or ServerLevel#tick
The reason I'm thinking about this is because there will be a lot of fireballs going towards infinity.
how many fireballs are you thinking there will be?
Short lived and not thousands
they cant go to infinity
yeah they despawn after a while
Then I will listen for the spawn event and loop the item until it drops
I wonder what happened if the earth would suddenyl have the mass of the sun
let me start universe sandbox and find out
hmm, I'm not sure, I wouldn't put that in a timer tho
we would instantly be crushed by gravity, I guess
is it correct?
The sun is about 1,000 times more massive than Jupiter, and I know for a fact that jupiter would crush you
the world would also flood as all land mass would be hyper compressed
that should be good
I dont know how to explain it correctly. I want to add a dependency but maven cant resolve the dependency. its a plugin so can I use the jar and put it in the lib directory to get it work?
install it using maven
what dependency?
ProtocolLib-API
thats in maven, add it properly
trough dependencies?
did you add the repo?
yes
Im getting the error Cannot resolve com.comphenix.protocol:ProtocolLib-API:4.4.0
<repositories>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>```
Have you got that?
I only got the dependency
you need the repository
its the official one
ok thank you
You can find that from here https://github.com/aadnk/ProtocolLib
saying this is a craftworld and not a level Level s = ((CraftWorld)loc.getWorld()).getHandle() in 1.18.2 it works fine this is 1.19.2 but i cant find anything that says how id fix this
java.lang.ClassCastException: class [Lorg.bukkit.inventory.ItemStack; cannot be cast to class java.util.List ([Lorg.bukkit.inventory.ItemStack; is in unnamed module of loader java.net.URLClassLoader @515f550a; java.util.List is in module java.base of loader 'bootstrap')
tf am i supposed to do
getting this error Could not find artifact com.comphenix.protocol:ProtocolLib-API:pom:4.7.0 in paperspigot-repo (https://repo.destroystokyo.com/repository/maven-public/)
playerConfig.getList returns null even tho ive got a check for playerConfig.contains
it searches all repos in order, for every dependency
Can order actually cause a problem?
it'd fuck up our solar system pretty much lol
did u add plib repo?
btw use 5.0
I add this one
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
ServerLevel not level
Lol the planets knew what was coming and got the fuck out of there
lmao yeah
alright thanks but it still says its a worldserver to serverlevel
an ItemStack is not a List, it can;t be cast
use ProtocolLib artifact, not ProtocolLib-API
player.playerConfig.set("inventory", inventory.getContents());
it should be a list.
WorldServer are the fake names
Mokang Mappings, it's called ServerLevel
yeah ik but the code i sent it says its a worldserver not a serverlevel
that is not the line thats throwing the error
so idk how to fix that
Could not find artifact com.comphenix.protocol:ProtocolLib:pom:5.0 in paperspigot-repo
I really have no idea what to do
add the protocollib repo
he has the repo
If your maven dependencies and repositories match when I sent you and its still happening, delete your .m2 folder and redownload your dependencies
.
where can I find this folder?
it's pointless to look into that folder, just use the correct version
anyway it's in your home folder/.m2/repository
why delete it ...
I had to delete mine because my school corrupted all the server certificates. I deleted all the server certificates but the error persisted until I deleted the .m2
Could be another cause for their case, good to cover all bases.
you could also just have done mvn clean package -U to retry to download snapshots
it's simply not working for this dude because they keep using 5.0 instead of 5.0.0
Intellij does recommend that with a link in the errors sometimes
Also could you recommend a good data manager for config files
I want to create my own but I need some inspiration
is there anything that's missing in the builtin YamlConfiguration class?
proper error handling
I usually just extend YamlConfiguration
then I just do new("someFile.yml")
it loads the defaults from the plugins resources, then saves it as default config if not done yet, and tries to load it. if there's an error, ofc it also can't do much
I mean what do you mean with "proper error handling"
something ignores my gradle home π
if a yaml is broken, you can't read it
I don't know much about how YamlConfiguration operates in that regard but personally I like to throw a couple things at an error to try to remedy it for a throw an exception
Also a config manager makes life a bit easier for some
but wdym with "config manager"?
config/data manager
yeah what is it supposed to do
manage setting defaults, getting strings, constructing the file if it doesn't exist etc
anyone?
use mojang mappings
cast it
Mojang mapping will save you a lot of bother if you do a lot of work with NMS
why do they obfuscate the fking game
bruh I just did a google search for NMS and I found your blog
alrighjt that works thanks is there anyway to check what a method changed to in a version?
just common sense
set the search to "Spigot", then you can enter the "old" class name and it will show you the new names
.setPosition in 1.19.2 but in 1.18.2 its just a, c and crap
you are not using Mopjang mappings
yeah, that's because you didnt use mojang mappings in 1.18.2
when i use mappings all the net. imports dont work
run build tools
also i am
for 1.18.2
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
</dependency>
they are all fine, you just use teh Mojang mapped ones
for example, check out the ServerLevel information:
you can see that the getRecipeManager() is called q() in spigot
and getTagManager() in mojang mappings, is r() in spigot/obfuscated mappings()
pls just read this @dry forum and do everything exactly like this, and remove all your spigot dependencies
you have to enter the class name
where setPosition is declared
how am i gonna know where that is
how could you not know that when you use it? o0
you can't just do .setPosition randomly
you must have an object to call this on
oh i thought u mean minecraft class on the website?
yeah, that's what I mean
Is there a way to constantly check a boolean? Like a while true loop?
how am i gonna know what class mojang put the setPos method in
whats this for?
the question makes no sense really
you said i need to know the class the method is called in
you currently have a class, let's say BlockPos. You use getPos on it. So you know that the class is called BlockPos and that's what you enter on that site
there are probably like 200 classes that have a setPos method
how am I gonna know which one you are talking about
i dont understand why would i type my class name in on the website how is the website gonna know what classes i use
I want to check if a player is in water, i always used the player move event, but surely there must be a better way
ughm what
Player move event is fine
bro
The alternative would be a runnable, but that would actually not great compared to player move event
It is sorta ok, but when you place water beneath you and dont move, oc nothing happens
you wanna switch from obfuscated/spigot to mojang mappings. so e.g. you used WorldServer right now. Then you enter WorldServer on that site, and click on it. now it tells you "WorldServer is actualled called ServerLevel, and the method "WorldServer#a()" is actually called "ServerLevel#addEntity()" etc
yes
Oh no not runnables, and its checking when a player falls into water so it should be fine
Using a runnable in this instance would be alright, there isn't really any other simple alternative to check for that
a place block event maybe, but water spreads so that wouldn't work
oh wait i get it now sorry
Dumb question (new to java) why cant you just use a while true loop
https://nms.screamingsandals.org/1.19.2/net/minecraft/world/entity/decoration/ArmorStand.html setpos isnt on here though
yeah, that's because setPos isn't declared on the ArmorStand, but on the Entity class itself. If you don't find it there, click on "extends LivingEntity" at the top. it won't be there too, so keep going to the super class until you find it (it should be in "Entity")
Because that runs constantly and prevents code under it from running if you aren't threading, it also runs as fast as possible. A runnable is limited to 1 tick
ahh ok ty
new BukkitRunnable() {
@Override
public void run() {
if (((Player) player).isInWater()) {
((Player) player).setHealth(0);
}
}
}.runTaskTimer(NeoPerformance.getInstance(), 0, 1);```
np! I know it's annoying, that's why you should always use mojang mappings in the beginning, and not switch to it later π
does anyone know how to troubleshoot this problem
my IntelliJ run with a high cpu usage for no reason
https://i.imgur.com/ak9MXWn.png
An example
so i should be using a and not setpos?
noooo, you should be using setPos of course
oh ok ty
and the "remapping" part in your pom.xml will then translate it back to a() so that it actually works on the server
ohh
so you can use the "fancy names" while coding, but make it still work on the server
because the server .jar itself uses the weird, fucked up names
ok ty for explaining it lmao i havent really used nms
np!
java.lang.ClassCastException: class [Lorg.bukkit.inventory.ItemStack; cannot be cast to class org.bukkit.inventory.ItemStack ([Lorg.bukkit.inventory.ItemStack; and org.bukkit.inventory.ItemStack are in unnamed module of loader java.net.URLClassLoader @515f550a)
i am losing my sanity
you shaded the bukkit api into your plugin
huh
so you now have two different ItemStack classes
once the server's, once your plugin's
I remember my first time when I did that
do not shade bukkit api π
unshade it.
Boy that was not fun
i've did so many stupid mistakes so many times, that meanwhile I can tell people instantly what they did wrong by just guessing it lol
If you are confused send your pom file in paste and we can point out which part is shading it
Thats probably the problem
Also why do people reupload your plugins to black spigot when it is free to begin with?
And then not update it to the latest version.
probably to get likes there
Well their account is banned now so I hope the likes was worth it
cannot find symbol w h a t
nms.spawnArmorstand(e.getPlayer().getLocation(), e.getPlayer(), true, true);
Just call it a feature
huh
what is "nms"?
my interface for the different nms versions
then you didnt define a "spawnArmorstand(Location, Player, boolean, boolean)" method there
void spawnArmorstand(Location loc, Player p, boolean gravity, boolean visible); i did
yeah
but you are passing a bukkit player
your interface should of course take a bukkit player, not an NMS player
?paste the full code, including imports, of your interface
of the class im using spawnarmorstand?
your nms interface
import org.bukkit.entity.Player;
public interface NMS {
void spawnArmorstand(Location loc, Player p, boolean gravity, boolean visible);
}```
?paste the whole class where you are using that interface. the one where you get the "symbol not found" message
did you get a Loading NMS message at startup?
its when i package the plugin
I wanna know if you can check if a chest is accessible without breaking blocks (in an open area) that surrounds it?
hell na jere.com takes me to this woman
why does her photo look like she died 20 years ago
Lol
whats diamond sword GENERIC_ATTACK_SPEED?
I'm using packets to update my GUI Inventories but recently I found some issues...
PacketPlayOutOpenWindow packet = new PacketPlayOutOpenWindow(player.bU.j, container, title);
if (player.b != null) player.b.a(packet);
First issue was calling player#closeInventory() does not work...
But having it sent in a task will fix the issue... Till plugin is disabling... When plugin is going to disable it tries to close all open GUIs (To prevent item stealing) but I can not use tasks to close the GUIs...
Any idea how can I fix this?
Oh hey π
we cross our paths again π
yep
is there a bukkit to mojang nms mapping translator
Yes there is a quite good one π wait a second
Well that's it π€·
yes
lmao
Anyone can provide guidance ?
How to convert that Mon Sep 12 12:23:07 CEST 2022 in a Date object ?
cannot find symbol w h a t
Datetimeformatter?